summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arm-wt-22k/Android.mk9
-rw-r--r--arm-wt-22k/host_src/eas_hostmm.c142
-rw-r--r--arm-wt-22k/host_src/eas_types.h7
3 files changed, 33 insertions, 125 deletions
diff --git a/arm-wt-22k/Android.mk b/arm-wt-22k/Android.mk
index 8627e9a..3dd8e7a 100644
--- a/arm-wt-22k/Android.mk
+++ b/arm-wt-22k/Android.mk
@@ -38,11 +38,11 @@ LOCAL_SRC_FILES = \
lib_src/jet.c \
host_src/eas_config.c \
host_src/eas_hostmm.c \
- host_src/eas_main.c \
- host_src/eas_report.c \
- host_src/eas_wave.c
+ host_src/eas_report.c
# not using these modules
+# host_src/eas_main.c \
+# host_src/eas_wave.c \
# lib_src/eas_wavefile.c \
# lib_src/eas_wavefiledata.c \
@@ -92,6 +92,9 @@ asm_flags := \
LOCAL_ASFLAGS := \
$(foreach f,$(asm_flags),-Wa,"$(f)")
+# .s files not ported for Clang assembler yet.
+LOCAL_CLANG_ASFLAGS += -no-integrated-as
+
asm_flags :=
LOCAL_CFLAGS += -D NATIVE_EAS_KERNEL
diff --git a/arm-wt-22k/host_src/eas_hostmm.c b/arm-wt-22k/host_src/eas_hostmm.c
index 5243639..f9dcd86 100644
--- a/arm-wt-22k/host_src/eas_hostmm.c
+++ b/arm-wt-22k/host_src/eas_hostmm.c
@@ -85,11 +85,10 @@
*/
typedef struct eas_hw_file_tag
{
- EAS_I32 fileSize;
- EAS_I32 filePos;
- EAS_BOOL dup;
- int fd;
- EAS_I32 offset;
+ int (*readAt)(void *handle, void *buf, int offset, int size);
+ int (*size)(void *handle);
+ int filePos;
+ void *handle;
} EAS_HW_FILE;
typedef struct eas_hw_inst_data_tag
@@ -121,7 +120,7 @@ EAS_RESULT EAS_HWInit (EAS_HW_DATA_HANDLE *pHWInstData)
file = (*pHWInstData)->files;
for (i = 0; i < EAS_MAX_FILE_HANDLES; i++)
{
- file->fd = -1;
+ file->handle = NULL;
file++;
}
@@ -252,42 +251,12 @@ EAS_RESULT EAS_HWOpenFile (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_LOCATOR locat
for (i = 0; i < EAS_MAX_FILE_HANDLES; i++)
{
/* is this slot being used? */
- if (file->fd < 0)
+ if (file->handle == NULL)
{
- if (locator->path) {
- /* open the file */
- if ((fd = open(locator->path, O_RDONLY)) < 0) {
- return EAS_ERROR_FILE_OPEN_FAILED;
- }
- } else {
- /* else file is already open */
- fd = dup(locator->fd);
- }
-
- /* determine the file size */
- if (locator->length == 0) {
- if (lseek(fd, 0, SEEK_END) < 0) {
- close(fd);
- return EAS_ERROR_FILE_LENGTH;
- }
- if ((file->fileSize = lseek(fd, 0, SEEK_CUR)) == -1L) {
- close(fd);
- return EAS_ERROR_FILE_LENGTH;
- }
- }
-
- // file size was passed in
- else {
- file->fileSize = (EAS_I32) locator->length;
- }
-
- file->fd = fd;
- file->offset = locator->offset;
-
- /* initialize some values */
+ file->handle = locator->handle;
+ file->readAt = locator->readAt;
+ file->size = locator->size;
file->filePos = 0;
- file->dup = EAS_FALSE;
-
*pFile = file;
return EAS_SUCCESS;
}
@@ -313,14 +282,14 @@ EAS_RESULT EAS_HWReadFile (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file,
EAS_I32 count;
/* make sure we have a valid handle */
- if (file->fd < 0)
+ if (file->handle == NULL)
return EAS_ERROR_INVALID_HANDLE;
if (n < 0)
return EAS_EOF;
/* calculate the bytes to read */
- count = file->fileSize - file->filePos;
+ count = file->size(file->handle) - file->filePos;
if (n < count)
count = n;
if (count < 0)
@@ -328,8 +297,7 @@ EAS_RESULT EAS_HWReadFile (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file,
/* copy the data to the requested location, and advance the pointer */
if (count) {
- lseek(file->fd, file->filePos + file->offset, SEEK_SET);
- count = read(file->fd, pBuffer, count);
+ count = file->readAt(file->handle, pBuffer, file->filePos, count);
}
file->filePos += count;
*pBytesRead = count;
@@ -430,7 +398,7 @@ EAS_RESULT EAS_HWFilePos (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, E
{
/* make sure we have a valid handle */
- if (file->fd < 0)
+ if (file->handle == NULL)
return EAS_ERROR_INVALID_HANDLE;
*pPosition = file->filePos;
@@ -450,11 +418,11 @@ EAS_RESULT EAS_HWFileSeek (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file,
{
/* make sure we have a valid handle */
- if (file->fd < 0)
+ if (file->handle == NULL)
return EAS_ERROR_INVALID_HANDLE;
/* validate new position */
- if ((position < 0) || (position > file->fileSize))
+ if ((position < 0) || (position > file->size(file->handle)))
return EAS_ERROR_FILE_SEEK;
/* save new position */
@@ -475,12 +443,12 @@ EAS_RESULT EAS_HWFileSeekOfs (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE fil
{
/* make sure we have a valid handle */
- if (file->fd < 0)
+ if (file->handle == NULL)
return EAS_ERROR_INVALID_HANDLE;
/* determine the file position */
position += file->filePos;
- if ((position < 0) || (position > file->fileSize))
+ if ((position < 0) || (position > file->size(file->handle)))
return EAS_ERROR_FILE_SEEK;
/* save new position */
@@ -488,25 +456,6 @@ EAS_RESULT EAS_HWFileSeekOfs (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE fil
return EAS_SUCCESS;
}
-/*----------------------------------------------------------------------------
- *
- * EAS_HWFileLength
- *
- * Return the file length
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, hwInstData) hwInstData available for customer use */
-EAS_RESULT EAS_HWFileLength (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_I32 *pLength)
-{
-
- /* make sure we have a valid handle */
- if (file->fd < 0)
- return EAS_ERROR_INVALID_HANDLE;
-
- *pLength = file->fileSize;
- return EAS_SUCCESS;
-}
/*----------------------------------------------------------------------------
*
@@ -522,7 +471,7 @@ EAS_RESULT EAS_HWDupHandle (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file,
int i;
/* make sure we have a valid handle */
- if (file->fd < 0)
+ if (file->handle == NULL)
return EAS_ERROR_INVALID_HANDLE;
/* find an empty entry in the file table */
@@ -530,16 +479,13 @@ EAS_RESULT EAS_HWDupHandle (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file,
for (i = 0; i < EAS_MAX_FILE_HANDLES; i++)
{
/* is this slot being used? */
- if (dupFile->fd < 0)
+ if (dupFile->handle == NULL)
{
/* copy info from the handle to be duplicated */
+ dupFile->handle = file->handle;
dupFile->filePos = file->filePos;
- dupFile->fileSize = file->fileSize;
- dupFile->fd = file->fd;
- dupFile->offset = file->offset;
-
- /* set the duplicate handle flag */
- dupFile->dup = file->dup = EAS_TRUE;
+ dupFile->readAt = file->readAt;
+ dupFile->size = file->size;
*pDupFile = dupFile;
return EAS_SUCCESS;
@@ -566,50 +512,10 @@ EAS_RESULT EAS_HWCloseFile (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file1
/* make sure we have a valid handle */
- if (file1->fd < 0)
+ if (file1->handle == NULL)
return EAS_ERROR_INVALID_HANDLE;
- /* check for duplicate handle */
- if (file1->dup)
- {
- dupFile = NULL;
- file2 = hwInstData->files;
- for (i = 0; i < EAS_MAX_FILE_HANDLES; i++)
- {
- /* check for duplicate */
- if ((file1 != file2) && (file2->fd == file1->fd))
- {
- /* is there more than one duplicate? */
- if (dupFile != NULL)
- {
- /* clear this entry and return */
- file1->fd = -1;
- return EAS_SUCCESS;
- }
-
- /* this is the first duplicate found */
- else
- dupFile = file2;
- }
- file2++;
- }
-
- /* there is only one duplicate, clear the dup flag */
- if (dupFile)
- dupFile->dup = EAS_FALSE;
- else
- /* if we get here, there's a serious problem */
- return EAS_ERROR_HANDLE_INTEGRITY;
-
- /* clear this entry and return */
- file1->fd = -1;
- return EAS_SUCCESS;
- }
-
- /* no duplicates - close the file */
- close(file1->fd);
- /* clear this entry and return */
- file1->fd = -1;
+ file1->handle = NULL;
return EAS_SUCCESS;
}
diff --git a/arm-wt-22k/host_src/eas_types.h b/arm-wt-22k/host_src/eas_types.h
index d66a2b7..df1d1d8 100644
--- a/arm-wt-22k/host_src/eas_types.h
+++ b/arm-wt-22k/host_src/eas_types.h
@@ -139,10 +139,9 @@ typedef EAS_I32 EAS_FILE_MODE;
/* file locator e.g. filename or memory pointer */
typedef struct s_eas_file_tag {
- const char* path;
- int fd;
- long long offset;
- long long length;
+ void *handle;
+ int(*readAt)(void *handle, void *buf, int offset, int size);
+ int(*size)(void *handle);
} EAS_FILE, *EAS_FILE_LOCATOR;
/* handle to stream */