Vision Apps User Guide
app_mem.h File Reference

Go to the source code of this file.

Memory heap ID

#define APP_MEM_HEAP_DDR   (0u)
 Heap located in DDR. More...
 
#define APP_MEM_HEAP_L3   (1u)
 Heap located in L3 memory (MSMC) More...
 
#define APP_MEM_HEAP_L2   (2u)
 Heap located in L2 local memory of a CPU. More...
 
#define APP_MEM_HEAP_L1   (3u)
 Heap located in L1 local memory of a CPU. More...
 
#define APP_MEM_HEAP_DDR_SCRATCH   (4u)
 Heap located in DDR and is used as scratch. More...
 
#define APP_MEM_HEAP_DDR_NON_CACHE   (5u)
 Heap located in DDR and in non-cache memory of persistent property. More...
 
#define APP_MEM_HEAP_DDR_NON_CACHE_SCRATCH   (6u)
 Heap located in DDR and in non-cache memory of scratch property. More...
 
#define APP_MEM_HEAP_DDR_WT_CACHE   (7u)
 Heap located in DDR and in cache memory which is configured as write through. More...
 
#define APP_MEM_HEAP_MAX   (8u)
 Max heaps in system. More...
 
typedef uint64_t(* app_mem_shared_target_fxn) (const uint64_t sharedAddr)
 Shared pointer to target pointer address translation callback function. More...
 
typedef uint64_t(* app_mem_target_shared_fxn) (const uint64_t targetAddr)
 target pointer to shared pointer address translation callback function. More...
 

Data Structures

struct  app_mem_heap_prm_t
 Heap initialization parameters. More...
 
struct  app_mem_init_prm_t
 Memory module initialization parameters. More...
 
struct  app_mem_stats_t
 Heap statistics and information. More...
 

Macros

#define APP_MEM_HEAP_NAME_MAX   (16u)
 Max characters to use for heap name. More...
 
Memory heap creation flags

#define APP_MEM_HEAP_FLAGS_TYPE_LINEAR_ALLOCATE   (0x00000001u)
 Heap flag to indicate heap is of type "linear allocater". More...
 
#define APP_MEM_HEAP_FLAGS_IS_SHARED   (0x00000004u)
 Heap flag to indicate if memory that is allocated will be shared with another CPU. More...
 
#define APP_MEM_HEAP_FLAGS_DO_CLEAR_ON_ALLOC   (0x00000008u)
 Heap flag to indicate if memory should be set to 0 after alloc. More...
 

Functions

static void * APP_MEM_ALIGNPTR (void *val, uint32_t align)
 Align ptr value to 'align' bytes. More...
 
static uint64_t APP_MEM_ALIGN64 (uint64_t val, uint32_t align)
 Align 64b value to 'align' bytes. More...
 
static uint32_t APP_MEM_ALIGN32 (uint32_t val, uint32_t align)
 Align 32b value to 'align' bytes. More...
 
static void appMemEnableL1DandL2CacheWb ()
 Enable L1D and L2 Cache by performing a WB. More...
 
void appMemInitPrmSetDefault (app_mem_init_prm_t *prm)
 Set defaults to app_mem_init_prm_t. More...
 
int32_t appMemInit (app_mem_init_prm_t *prm)
 Init heaps for memory allocation. More...
 
int32_t appMemDeInit ()
 De-Init heaps for memory allocation. More...
 
void * appMemAlloc (uint32_t heap_id, uint32_t size, uint32_t align)
 Alloc memory from specific heap. More...
 
int32_t appMemResetScratchHeap (uint32_t heap_id)
 Reset scratch memory. More...
 
int32_t appMemFree (uint32_t heap_id, void *ptr, uint32_t size)
 Free memory that was previously allocated. More...
 
uint32_t appMemGetDmaBufFd (void *virPtr, volatile uint32_t *dmaBufFdOffset)
 Return dmaBufFd of a CMEM buffer pointer. More...
 
int32_t appMemTranslateDmaBufFd (uint32_t dmaBufFd, uint32_t size, uint64_t *virtPtr, uint64_t *phyPtr)
 Translates a given 'dmaBufFd' to virtual and physical addresses. More...
 
void appMemCloseDmaBufFd (int32_t dmaBufFd)
 Close the dmaBufFd of a CMEM buffer pointer. More...
 
uint64_t appMemGetVirt2PhyBufPtr (uint64_t virtPtr, uint32_t heap_id)
 Return physical ptr corresponds to a CMEM virtual ptr. More...
 
int32_t appMemStats (uint32_t heap_id, app_mem_stats_t *stats)
 Return heap statistics and information. More...
 
void appMemCacheInv (void *ptr, uint32_t size)
 Invalidate a section of memory from cache. More...
 
void appMemCacheWb (void *ptr, uint32_t size)
 Write back a section of memory from cache. More...
 
void appMemCacheWbInv (void *ptr, uint32_t size)
 Write back and invalidate a section of memory from cache. More...
 
void appMemPrintMemAllocInfo ()
 Print memory allocation from shared memory region. More...
 
uint64_t appMemShared2PhysPtr (uint64_t shared_ptr, uint32_t heap_id)
 Return the physical pointer from a shared pointer. More...
 
uint64_t appMemShared2TargetPtr (uint64_t shared_ptr)
 Return the physical pointer from a shared pointer. More...
 
void * appMemMap (void *phys_addr, uint32_t size)
 Map the provided physical memory to a virtual address. More...
 
int32_t appMemUnMap (void *virt_addr, uint32_t size)
 Unmap the provided virtual memory. More...