69 #if defined(FREERTOS) || defined(SAFERTOS) || defined(THREADX) 70 #if defined(MCU_PLUS_SDK) 71 #if defined(HOST_EMULATION) 72 #include <drivers/dmautils/udma_standalone/udma.h> 74 #include <drivers/udma.h> 75 #include <drivers/udma/udma_priv.h> 78 #include <ti/drv/udma/udma.h> 82 #if defined(R5F) && (defined(SOC_J784S4) || defined(SOC_J721S2) || defined(SOC_J742S2)) 83 #include <ti/csl/csl_rat.h> 101 #define APP_MEM_HEAP_NAME_MAX (16u) 135 #define APP_MEM_HEAP_DDR (0u) 138 #define APP_MEM_HEAP_L3 (1u) 141 #define APP_MEM_HEAP_L2 (2u) 144 #define APP_MEM_HEAP_L1 (3u) 147 #define APP_MEM_HEAP_DDR_SCRATCH (4u) 150 #define APP_MEM_HEAP_DDR_NON_CACHE (5u) 153 #define APP_MEM_HEAP_DDR_NON_CACHE_SCRATCH (6u) 156 #define APP_MEM_HEAP_DDR_WT_CACHE (7u) 159 #define APP_MEM_HEAP_MAX (8u) 178 #define APP_MEM_HEAP_FLAGS_TYPE_LINEAR_ALLOCATE (0x00000001u) 182 #define APP_MEM_HEAP_FLAGS_IS_SHARED (0x00000004u) 186 #define APP_MEM_HEAP_FLAGS_DO_CLEAR_ON_ALLOC (0x00000008u) 208 #if defined(FREERTOS) || defined(SAFERTOS) || defined(THREADX) 209 Udma_VirtToPhyFxn virtToPhyFxn;
213 #if defined(R5F) && (defined(SOC_J784S4) || defined(SOC_J721S2) || defined(SOC_J742S2)) 215 CSL_ratRegs *pRatRegs;
217 #if defined(A72) || defined(A53) || defined(PC) 236 #if defined(R5F) && (defined(SOC_J784S4) || defined(SOC_J721S2) || defined(SOC_J742S2)) 246 uint64_t translatedAddress;
248 uint32_t baseAddress;
261 return (
void*)((((uintptr_t)val+align-1u) / align) * align);
269 return (uint64_t)( (uint64_t)(val+align-1u) / align) * align;
277 return (uint32_t)( (uint32_t)(val+align-1u) / align) * align;
280 #if defined(__C7120__) && (defined(SOC_J784S4) || defined(SOC_J742S2)) 285 void appMemC7xSetL2WBINV(uint64_t param);
290 uint64_t appMemC7xGetL2WBINV(
void);
295 void appMemC7xCleaninvalidateL2Cache(
void);
300 void appMemC7xSetL1DWBINV(uint64_t param);
305 uint64_t appMemC7xGetL1DWBINV(
void);
310 void appMemC7xCleaninvalidateL1DCache(
void);
321 #if defined(__C7120__) && (defined(SOC_J784S4) || defined(SOC_J742S2)) 322 appMemC7xCleaninvalidateL1DCache();
323 appMemC7xCleaninvalidateL2Cache();
365 void *
appMemAlloc(uint32_t heap_id, uint32_t size, uint32_t align);
409 int32_t
appMemFree(uint32_t heap_id,
void *ptr, uint32_t size);
419 #if defined(x86_64) || defined(QNX) 435 #if defined(x86_64) || defined(QNX) 446 #if defined(x86_64) || defined(QNX) 534 void *
appMemMap(
void *phys_addr, uint32_t size);
544 int32_t
appMemUnMap(
void *virt_addr, uint32_t size);
552 #if defined(R5F) && (defined(SOC_J784S4) || defined(SOC_J721S2) || defined(SOC_J742S2)) 559 int32_t appMemAddrTranslate(app_mem_rat_prm_t *prm);
566 int32_t appMemSetRatRegs(CSL_ratRegs *pRatRegs);
583 int32_t appMemSetFdPath(
char *path, uint32_t size);
Heap initialization parameters.
Definition: app_mem.h:193
void * base
Definition: app_mem.h:195
void appMemCacheWbInv(void *ptr, uint32_t size)
Write back and invalidate a section of memory from cache.
int32_t appMemResetScratchHeap(uint32_t heap_id)
Reset scratch memory.
uint64_t appMemShared2PhysPtr(uint64_t shared_ptr, uint32_t heap_id)
Return the physical pointer from a shared pointer.
uint32_t heap_id
Definition: app_mem.h:229
Heap statistics and information.
Definition: app_mem.h:227
uint64_t appMemGetVirt2PhyBufPtr(uint64_t virtPtr, uint32_t heap_id)
Return physical ptr corresponds to a CMEM virtual ptr.
#define APP_MEM_HEAP_NAME_MAX
Max characters to use for heap name.
Definition: app_mem.h:101
uint32_t appMemGetNumAllocs(void)
Get number of memory allocation.
void appMemCloseDmaBufFd(uint32_t dmaBufFd)
Close the dmaBufFd of a CMEM buffer pointer.
int32_t appMemStats(uint32_t heap_id, app_mem_stats_t *stats)
Return heap statistics and information.
static uint32_t APP_MEM_ALIGN32(uint32_t val, uint32_t align)
Align 32b value to 'align' bytes.
Definition: app_mem.h:275
int32_t appMemTranslateDmaBufFd(uint32_t dmaBufFd, uint32_t size, uint64_t *virtPtr, uint64_t *phyPtr)
Translates a given 'dmaBufFd' to virtual and physical addresses.
static void appMemEnableL1DandL2CacheWb(void)
Enable L1D and L2 Cache by performing a WB.
Definition: app_mem.h:319
int32_t appMemInit(app_mem_init_prm_t *prm)
Init heaps for memory allocation.
uint64_t(* app_mem_target_shared_fxn)(const uint64_t targetAddr)
target pointer to shared pointer address translation callback function.
Definition: app_mem.h:132
bool appMemRegionQuery(uint32_t heap_id)
Check is specified memory region is enabled.
uint32_t appMemGetDmaBufFd(void *virPtr, volatile uint32_t *dmaBufFdOffset)
Return dmaBufFd of a CMEM buffer pointer.
void appMemCacheWb(void *ptr, uint32_t size)
Write back a section of memory from cache.
uint32_t heap_size
Definition: app_mem.h:231
void * appMemMap(void *phys_addr, uint32_t size)
Map the provided physical memory to a virtual address.
void appMemCacheInv(void *ptr, uint32_t size)
Invalidate a section of memory from cache.
Memory module initialization parameters.
Definition: app_mem.h:205
uint32_t flags
Definition: app_mem.h:198
uint64_t(* app_mem_shared_target_fxn)(const uint64_t sharedAddr)
Shared pointer to target pointer address translation callback function.
Definition: app_mem.h:120
uint64_t appMemShared2TargetPtr(uint64_t shared_ptr)
Return the physical pointer from a shared pointer.
uint32_t free_size
Definition: app_mem.h:232
#define APP_MEM_HEAP_MAX
Max heaps in system.
Definition: app_mem.h:159
int32_t appMemUnMap(void *virt_addr, uint32_t size)
Unmap the provided virtual memory.
int32_t appMemFree(uint32_t heap_id, void *ptr, uint32_t size)
Free memory that was previously allocated.
uint32_t size
Definition: app_mem.h:197
static void * APP_MEM_ALIGNPTR(void *val, uint32_t align)
Align ptr value to 'align' bytes.
Definition: app_mem.h:259
int32_t tivxMemRegionTranslate(uint32_t mem_heap_region, uint32_t *heap_id)
Convert tivx enumerated memory regions to app memory regions.
void appMemInitPrmSetDefault(app_mem_init_prm_t *prm)
Set defaults to app_mem_init_prm_t.
int32_t appMemDeInit(void)
De-Init heaps for memory allocation.
static uint64_t APP_MEM_ALIGN64(uint64_t val, uint32_t align)
Align 64b value to 'align' bytes.
Definition: app_mem.h:267
void appMemPrintMemAllocInfo(void)
Print memory allocation from shared memory region.
void * appMemAlloc(uint32_t heap_id, uint32_t size, uint32_t align)
Alloc memory from specific heap.