Sonivox: add SafetyNet log. am: 24d7c408c5
am: f3f1da3028

* commit 'f3f1da3028f61b7026c80a150cc40db52885ab8e':
  Sonivox: add SafetyNet log.
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 @@
 	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 @@
 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 @@
     file = (*pHWInstData)->files;
     for (i = 0; i < EAS_MAX_FILE_HANDLES; i++)
     {
-        file->fd = -1;
+        file->handle = NULL;
         file++;
     }
 
@@ -252,42 +251,12 @@
     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_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 @@
 
     /* 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 @@
 {
 
     /* 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 @@
 {
 
     /* 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 @@
 {
 
     /* 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 @@
     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 @@
     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 @@
     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 @@
 
 
     /* 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 @@
 
 /* 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 */