]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/pdk.git/commitdiff
[PDK-9782] UDMA UT: Port utils_mem.c to support FreeRTOS
authorDon Dominic <a0486429@ti.com>
Mon, 7 Jun 2021 19:35:21 +0000 (01:05 +0530)
committerAnkur <ankurbaranwal@ti.com>
Wed, 9 Jun 2021 06:49:09 +0000 (01:49 -0500)
- Update utils_mem.c to use new HeaP OSAL module API's
  - Replace SYSBIOS APIs with OSAL HeaP API's
  - For System Heap related, Replace SYSBIOS APIs with OSAL MemoryP API's
- Verified UDMA UT for tirtos/freertos

Signed-off-by: Don Dominic <a0486429@ti.com>
packages/ti/drv/udma/unit_test/udma_ut/makefile
packages/ti/drv/udma/unit_test/udma_ut/src/utils_mem.c

index 8559a5eff26167c9a0ece3b63742b978669e5500..5e6632b8bb88982a0e1206ffd371b94eeb4c6fcc 100755 (executable)
@@ -58,13 +58,19 @@ SRCS_COMMON += udma_test_event.c udma_test_flow.c
 SRCS_COMMON += udma_test_bug.c udma_test_misc.c
 SRCS_COMMON += udma_test_soc.c
 ifneq ($(SOC),$(filter $(SOC), am64x))
-SRCS_COMMON += udma_test_proxy.c udma_test_ring_monitor.c
+  SRCS_COMMON += udma_test_proxy.c udma_test_ring_monitor.c
 endif
 SRCS_COMMON += utils_trace.c
-ifeq ($(BUILD_OS_TYPE), tirtos)
-SRCS_COMMON += utils_prf.c utils_mem.c
+ifneq ($(BUILD_OS_TYPE), baremetal)
+  SRCS_COMMON += utils_mem.c
+  # Use baremetal utils_perf for FreeRTOS until Load OSAL is implemented 
+  ifeq ($(BUILD_OS_TYPE), tirtos)
+    SRCS_COMMON += utils_prf.c
+  else 
+    SRCS_COMMON += utils_prf_baremetal.c
+  endif
 else
-SRCS_COMMON += utils_prf_baremetal.c utils_mem_baremetal.c
+  SRCS_COMMON += utils_prf_baremetal.c utils_mem_baremetal.c
 endif
 
 CFLAGS_LOCAL_COMMON = $(PDK_CFLAGS) $(UDMA_CFLAGS) $(UDMAUT_CFLAGS) 
index 9e6494ff5ff1d3b0f52a8b2c873681a646e4f670..b4b154e6a32c1289e687f115c8176f6e840724aa 100755 (executable)
 /* ========================================================================== */
 
 #include <string.h>
-#include <xdc/runtime/System.h>
-#include <xdc/runtime/Memory.h>
-#include <xdc/runtime/IHeap.h>
-#include <ti/sysbios/heaps/HeapMem.h>
-#include <ti/sysbios/knl/Clock.h>
 #include "udma_test.h"
+#include <ti/osal/osal.h>
+#include <ti/osal/HeapP.h>
+#include <ti/osal/MemoryP.h>
 
 /* ========================================================================== */
 /*                           Macros & Typedefs                                */
@@ -72,8 +70,7 @@
 /* ========================================================================== */
 
 /* Memory pool handle */
-static HeapMem_Handle gUtilsHeapMemHandle[UTILS_MEM_HEAP_NUM] = {NULL, NULL};
-static HeapMem_Struct gUtilsHeapMemStruct[UTILS_MEM_HEAP_NUM];
+static HeapP_Handle gUtilsHeapMemHandle[UTILS_MEM_HEAP_NUM] = {NULL, NULL};
 
 static uint8_t gUtilsHeapMemMsmc[UTILS_MEM_HEAP_SIZE_MSMC] __attribute__(( aligned(128), section(".udma_buffer_msmc") ));
 static uint8_t gUtilsHeapMemDdr[UTILS_MEM_HEAP_SIZE_DDR] __attribute__(( aligned(128), section(".udma_buffer_ddr") ));
@@ -88,38 +85,34 @@ static uint32_t gUtilsMemClearBuf = FALSE;
 
 int32_t Utils_memInit(void)
 {
-    HeapMem_Params heapMemPrm;
+    HeapP_Params heapMemPrm;
 
     /* create memory pool heap - Msmc */
-    HeapMem_Params_init(&heapMemPrm);
+    HeapP_Params_init(&heapMemPrm);
     heapMemPrm.buf  = gUtilsHeapMemMsmc;
     heapMemPrm.size = sizeof (gUtilsHeapMemMsmc);
-    HeapMem_construct(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_MSMC], &heapMemPrm);
-    gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_MSMC] = HeapMem_handle(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_MSMC]);
+    gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_MSMC] = HeapP_create(&heapMemPrm);
     GT_assert(UdmaUtTrace, gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_MSMC] != NULL);
 
     /* create memory pool heap - DDR */
-    HeapMem_Params_init(&heapMemPrm);
+    HeapP_Params_init(&heapMemPrm);
     heapMemPrm.buf  = gUtilsHeapMemDdr;
     heapMemPrm.size = sizeof (gUtilsHeapMemDdr);
-    HeapMem_construct(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_DDR], &heapMemPrm);
-    gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_DDR] = HeapMem_handle(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_DDR]);
+    gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_DDR] = HeapP_create(&heapMemPrm);
     GT_assert(UdmaUtTrace, gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_DDR] != NULL);
 
     /* create memory pool heap - internal */
-    HeapMem_Params_init(&heapMemPrm);
+    HeapP_Params_init(&heapMemPrm);
     heapMemPrm.buf  = gUtilsHeapMemInternal;
     heapMemPrm.size = sizeof (gUtilsHeapMemInternal);
-    HeapMem_construct(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_INTERNAL], &heapMemPrm);
-    gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_INTERNAL] = HeapMem_handle(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_INTERNAL]);
+    gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_INTERNAL] = HeapP_create(&heapMemPrm);
     GT_assert(UdmaUtTrace, gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_INTERNAL] != NULL);
 
     /* create memory pool heap - OSPI */
-    HeapMem_Params_init(&heapMemPrm);
+    HeapP_Params_init(&heapMemPrm);
     heapMemPrm.buf  = gUtilsHeapMemOspi;
     heapMemPrm.size = sizeof (gUtilsHeapMemOspi);
-    HeapMem_construct(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_OSPI], &heapMemPrm);
-    gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_OSPI] = HeapMem_handle(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_OSPI]);
+    gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_OSPI] = HeapP_create(&heapMemPrm);
     GT_assert(UdmaUtTrace, gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_OSPI] != NULL);
 
     gUtilsMemClearBuf = TRUE;
@@ -130,13 +123,13 @@ int32_t Utils_memInit(void)
 int32_t Utils_memDeInit(void)
 {
     /* delete memory pool heap  */
-    HeapMem_destruct(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_MSMC]);
+    HeapP_delete(&gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_MSMC]);
     gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_MSMC] = NULL;
-    HeapMem_destruct(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_DDR]);
+    HeapP_delete(&gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_DDR]);
     gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_DDR] = NULL;
-    HeapMem_destruct(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_INTERNAL]);
+    HeapP_delete(&gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_INTERNAL]);
     gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_INTERNAL] = NULL;
-    HeapMem_destruct(&gUtilsHeapMemStruct[UTILS_MEM_HEAP_ID_OSPI]);
+    HeapP_delete(&gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_OSPI]);
     gUtilsHeapMemHandle[UTILS_MEM_HEAP_ID_OSPI] = NULL;
     return (UDMA_SOK);
 }
@@ -155,7 +148,7 @@ void *Utils_memAlloc(uint32_t heapId, uint32_t size, uint32_t align)
     }
 
     /* allocate memory  */
-        addr = HeapMem_alloc(gUtilsHeapMemHandle[heapId], size, align, NULL);
+        addr = HeapP_alloc(gUtilsHeapMemHandle[heapId], size);
     if((addr != NULL) && (TRUE == gUtilsMemClearBuf))
     {
         memset(addr, 0U, size);
@@ -177,7 +170,7 @@ int32_t Utils_memFree(uint32_t heapId, void *addr, uint32_t size)
         size = UDMA_CACHELINE_ALIGNMENT;
     }
     /* free previously allocated memory  */
-    HeapMem_free(gUtilsHeapMemHandle[heapId], addr, size);
+    HeapP_free(gUtilsHeapMemHandle[heapId], addr, size);
     return (UDMA_SOK);
 }
 
@@ -238,10 +231,9 @@ int32_t Utils_memCheckHeapStat(const Utils_MemHeapStatus *heapStat)
 
 uint32_t Utils_memGetSystemHeapFreeSpace(void)
 {
-    Memory_Stats stats;
-    extern const IHeap_Handle Memory_defaultHeapInstance;
+    MemoryP_Stats stats;
 
-    Memory_getStats(Memory_defaultHeapInstance, &stats);
+    MemoryP_getStats(&stats);
 
     return ((uint32_t) (stats.totalFreeSize));
 }
@@ -249,12 +241,12 @@ uint32_t Utils_memGetSystemHeapFreeSpace(void)
 uint32_t Utils_memGetBufferHeapFreeSpace(uint32_t heapId)
 {
     uint32_t        totalFreeSize = 0U;
-    Memory_Stats    stats;
+    HeapP_MemStats  stats;
 
     GT_assert(UdmaUtTrace, heapId < UTILS_MEM_HEAP_NUM);
     if(NULL != gUtilsHeapMemHandle[heapId])
     {
-        HeapMem_getStats(gUtilsHeapMemHandle[heapId], &stats);
+        HeapP_getHeapStats(gUtilsHeapMemHandle[heapId], &stats);
         totalFreeSize = (uint32_t) stats.totalFreeSize;
     }
     return (totalFreeSize);