]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/commitdiff
Incorporate comments from team porting Linaro ODP to MCSDK3.x
authorTinku Mannan <tmannan@ti.com>
Fri, 21 Nov 2014 19:52:10 +0000 (14:52 -0500)
committerTinku Mannan <tmannan@ti.com>
Fri, 21 Nov 2014 19:52:10 +0000 (14:52 -0500)
ti/runtime/hplib/.gitignore [new file with mode: 0644]
ti/runtime/hplib/hplib_cache.h [changed mode: 0755->0644]
ti/runtime/hplib/hplib_shm.h [changed mode: 0755->0644]
ti/runtime/hplib/hplib_vm.h [changed mode: 0755->0644]
ti/runtime/hplib/module/.gitignore [new file with mode: 0644]
ti/runtime/hplib/src/hplib_shm.c [changed mode: 0755->0644]
ti/runtime/hplib/src/hplib_util.c [changed mode: 0755->0644]
ti/runtime/hplib/src/osal.c [changed mode: 0755->0644]
ti/runtime/hplib/test/bmAllocTest.c [changed mode: 0755->0644]
ti/runtime/hplib/test/shmtest.c [changed mode: 0755->0644]

diff --git a/ti/runtime/hplib/.gitignore b/ti/runtime/hplib/.gitignore
new file mode 100644 (file)
index 0000000..463121b
--- /dev/null
@@ -0,0 +1,6 @@
+*.o\r
+*.a\r
+*.so\r
+*.so.*\r
+.created\r
+/bin \r
old mode 100755 (executable)
new mode 100644 (file)
index ddd1a06..88618ae
@@ -115,6 +115,9 @@ static inline hplib_RetValue hplib_cacheWb(void *ptr, size_t size)
     {
         return hplib_FAILURE;
     }
+#else
+    (void)ptr;
+    (void)size;
 #endif
     return hplib_OK;
 }
@@ -144,6 +147,9 @@ static inline hplib_RetValue hplib_cacheWbInv(void *ptr, size_t size)
     if (ioctl(hplib_mod_fd, HPLIBMOD_IOCCACHEWBINV | HPLIBMOD_IOCMAGIC, &block) == -1) {
         return hplib_FAILURE;
     }
+#else
+    (void)ptr;
+    (void)size;
 #endif
     return hplib_OK;
 }
@@ -172,6 +178,9 @@ static inline hplib_RetValue hplib_cacheInv(void *ptr, size_t size)
     if (ioctl(hplib_mod_fd, HPLIBMOD_IOCCACHEINV | HPLIBMOD_IOCMAGIC, &block) == -1) {
         return hplib_FAILURE;
     }
+#else
+    (void)ptr;
+    (void)size;
 #endif
     return hplib_OK;
 }
old mode 100755 (executable)
new mode 100644 (file)
index a36c52a..5ee6086
@@ -137,7 +137,7 @@ void* hplib_shmCreate(int size);
  *  @retval
  *      void* base address of the shared memory segment, NULL on error
  */
-void* hplib_shmOpen();
+void* hplib_shmOpen(void);
 
 /**
  *  @b Description
@@ -146,7 +146,7 @@ void* hplib_shmOpen();
  *  @retval
  *      hplib_RetValue, @ref hplib_RetValue
  */
-hplib_RetValue hplib_shmDelete();
+hplib_RetValue hplib_shmDelete(void);
 
 /**
  *  @b Description
old mode 100755 (executable)
new mode 100644 (file)
index 4cba899..1f5a3e9
@@ -313,9 +313,10 @@ static inline void* hplib_mVMVirtToPhy (void *ptr)
  */
 static inline void * hplib_mVMPhyToVirtPoolId (void *ptr, uint8_t pool_id)
 {
-    if (pool_id > (HPLIB_MAX_MEM_POOLS -1));
+    if (pool_id > (HPLIB_MAX_MEM_POOLS -1))
                 return (void *) hplib_OK;
-    if (!ptr) return (void *) hplib_OK;
+    if (!ptr) return
+        (void *) hplib_OK;
     if (((uint8_t *)ptr <memPoolAddr[pool_id].memStartPhy)||( (uint8_t *)ptr>memPoolAddr[pool_id].memEndPhy))
         return (void *) hplib_OK;
 
@@ -501,6 +502,18 @@ hplib_RetValue hplib_initMallocArea(int pool_id);
  */
 hplib_RetValue hplib_checkMallocArea(int pool_id);
 
+/**
+ *  @b Description
+ *  @n
+ *      The function API is used to map the given physical address
+ *      to virtual memory space.
+ *  @param[in] addr
+ *          Physical address pointer of memory space
+ *  @param[in] size  size of memory to be mapped
+ *  @retval
+ *      Virtual address pointer of mapped memory space
+ */
+void *hplib_VM_MemMap(void* addr, uint32_t size);
 
 #ifdef __cplusplus
 }
diff --git a/ti/runtime/hplib/module/.gitignore b/ti/runtime/hplib/module/.gitignore
new file mode 100644 (file)
index 0000000..94dbfb9
--- /dev/null
@@ -0,0 +1,6 @@
+*.ko\r
+.*.cmd\r
+*.mod.c\r
+modules.order\r
+Module.symvers\r
+.tmp_versions \r
old mode 100755 (executable)
new mode 100644 (file)
index 038ae03..f6834ab
@@ -77,14 +77,14 @@ void* hplib_shmCreate(int size)
 
     if (shm_id < 0)
     {
-        printf("hplib_shmCreate: shmget error\n");
+        hplib_Log("hplib_shmCreate: shmget error\n");
         return NULL;
     }
     else
     {
         pBase = (hplib_shmInfo_T*)shmat(shm_id, 0,0);
         if (pBase == (hplib_shmInfo_T*)-1)
-            printf("hplib_shmCreate: shmat error\n");
+            hplib_Log("hplib_shmCreate: shmat error\n");
         else
         {
             pBase->size = size;
@@ -108,7 +108,7 @@ void* hplib_shmOpen(void)
     shm_id = shmget(shm_key, 0, 0666 );
     if (shm_id < 0)
     {
-        printf("hplib_shmOpen: shmget error\n");
+        hplib_Log("hplib_shmOpen: shmget error\n");
         return NULL;
     }
     else
@@ -122,7 +122,7 @@ void* hplib_shmOpen(void)
         pBase = (hplib_shmInfo_T*)shmat(shm_id, 0,0);
         if (pBase == (hplib_shmInfo_T*)-1)
         {
-            printf("hplib_shmOpen: shmat error\n");
+            hplib_Log("hplib_shmOpen: shmat error\n");
             return NULL;
         }
 
@@ -133,12 +133,12 @@ void* hplib_shmOpen(void)
 /**************************************************************************
  *  FUNCTION PURPOSE:  Delete Shared Memory Segment
  **************************************************************************/
-hplib_RetValue hplib_shmDelete()
+hplib_RetValue hplib_shmDelete(void)
 {
     shm_id = shmget(shm_key, 0, 0666 );
     if (shm_id < 0)
     {
-        printf("hplib_shmOpen: shmget error\n");
+        hplib_Log("hplib_shmOpen: shmget error\n");
         return hplib_FAILURE;
     }
     else
@@ -146,7 +146,7 @@ hplib_RetValue hplib_shmDelete()
         int err=shmctl(shm_id, IPC_RMID, 0);
         if(err<0)
         {
-            printf("hplib_shmDelete: shmctl failed\n");
+            hplib_Log("hplib_shmDelete: shmctl failed\n");
             return hplib_FAILURE;
         }
     }
@@ -162,7 +162,7 @@ hplib_RetValue hplib_shmAddEntry(void* base, int size, hplib_shmEntryId_E entryI
 
     if ((pBase->free_offset + size) > pBase->size)
     {
-        printf("hplib_shmAddEntry: insufficient memory request, size %d\n", size);
+        hplib_Log("hplib_shmAddEntry: insufficient memory request, size %d\n", size);
         return hplib_ERR_NOMEM;
     }
 
old mode 100755 (executable)
new mode 100644 (file)
index 751a5c6..872a035
@@ -86,7 +86,7 @@ int hplib_utilModOpen(void)
 
     if (hplib_mod_fd == -1)
     {
-        printf("hplib_utilModOpen error\n");
+        hplib_Log("hplib_utilModOpen error\n");
         return -1;
     }
     return hplib_mod_fd;
@@ -177,7 +177,7 @@ hplib_RetValue hplib_utilSetupThread(int threadId,
     {
         hplib_utilModOpen();
     }
-    if (sched_setaffinity( gettid(), sizeof( cpu_set_t ), pSet ))
+    if (pSet && sched_setaffinity( gettid(), sizeof( cpu_set_t ), pSet ))
     {
         return hplib_FAILURE;
     }
old mode 100755 (executable)
new mode 100644 (file)
index 9d80c28..4d8fd4e
@@ -46,6 +46,8 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdint.h>
+#include <stdarg.h>
 
 #include "hplib.h"
 #include <unistd.h>
@@ -60,6 +62,7 @@
 #include "hplibmod.h"
 #include <ti/drv/sa/sa_osal.h>
 #include <ti/runtime/pktlib/pktlib.h>
+#include <ti/drv/rm/rm_osal.h>
 
 typedef struct osal_shm_Tag
 {
@@ -69,6 +72,7 @@ typedef struct osal_shm_Tag
     hplib_spinLock_T cppi_lock;
     hplib_spinLock_T sa_lock;
     hplib_spinLock_T pktlib_lock;
+    hplib_spinLock_T rm_lock;
     int init_done;
 } osal_shm_T;
 
@@ -82,6 +86,8 @@ uint32_t              Osal_cppi_FreeCounter =0;
 
 static __thread int our_core = 0;
 static __thread HPLIB_SPINLOCK_IF_T* p_lock_if;
+uint32_t    Osal_rm_MallocCounter = 0;
+uint32_t    Osal_rm_FreeCounter   = 0;
 
 void* Osal_saGetSCPhyAddr(void* vaddr);
 
@@ -144,6 +150,7 @@ hplib_RetValue hplib_utilOsalCreate()
     posalShm->cppi_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
     posalShm->sa_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
     posalShm->pktlib_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
+    posalShm->rm_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
 
     posalShm->init_done = 1;
     return retVal;
@@ -514,6 +521,81 @@ void Osal_stubCsExit (void *CsHandle)
     return;
 }
 
+void *Osal_rmMalloc (uint32_t num_bytes)
+{
+    /* Increment the allocation counter. */
+    Osal_rm_MallocCounter++;
+
+    /* Allocate memory. */
+    return calloc(1, num_bytes);
+}
+void Osal_rmFree (void *ptr, uint32_t size)
+{
+    /* Increment the free counter. */
+    Osal_rm_FreeCounter++;
+    free(ptr);
+}
+
+void *Osal_rmCsEnter(void)
+{
+    return NULL;
+}
+
+void Osal_rmCsExit(void *CsHandle)
+{
+
+}
+void Osal_rmBeginMemAccess(void *ptr, uint32_t size)
+{
+    return;
+}
+void Osal_rmEndMemAccess(void *ptr, uint32_t size)
+{
+    return;
+}
+
+void *Osal_rmTaskBlockCreate(void)
+{
+    return(NULL);
+}
+
+void Osal_rmTaskBlock(void *handle)
+{
+
+}
+
+void Osal_rmTaskUnblock(void *handle)
+{
+
+}
+
+void Osal_rmTaskBlockDelete(void *handle)
+{
+
+}
+
+void Osal_rmLog (char *fmt, ... )
+{
+    va_list ap;
+    
+    va_start(ap, fmt);
+    vprintf(fmt, ap);
+    va_end(ap);
+}
+
+void *Osal_rmMtCsEnter(void *mtSemObj)
+{
+    return NULL;
+}
+
+
+void Osal_rmMtCsExit(void *mtSemObj, void *CsHandle)
+{
+
+}
 /* Internal Function used by hplib */
 void* Osal_hplibCsEnter (void)
 {
old mode 100755 (executable)
new mode 100644 (file)
index 0ec6eaa..d305450
@@ -117,7 +117,7 @@ static void* thread_routineP(void* arg)
     cpu_set_t cpu_set;
     hplib_VirtMemPoolheader_T *poolHdr;
 
-    pShmBase = hplib_shmOpen(SHM_SIZE);
+    pShmBase = hplib_shmOpen();
     if(pShmBase == NULL)
     {
         printf("main: hplib_shmCreate failed\n");
@@ -247,7 +247,7 @@ main(int argc, char * argv[])
             break;
 
         case(2): /* Shutdown */
-            hplib_shmDelete(p);
+            hplib_shmDelete();
             hplib_mod_fd=hplib_utilModOpen();
             if (hplib_mod_fd == -1)
             {
old mode 100755 (executable)
new mode 100644 (file)
index e4e5adb..1d9ff83
@@ -102,7 +102,7 @@ main(int argc, char * argv[])
 
         case(2): /* delete */
             //fd = shmget(key, SHM_SIZE, 0666 );
-            hplib_shmDelete(p);
+            hplib_shmDelete();
             hplib_mod_fd=hplib_utilModOpen();
             if (hplib_mod_fd == -1)
             {