This section contains APIs for memory allocation.
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... | |
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 (void) |
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 (void) |
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... | |
bool | appMemRegionQuery (uint32_t heap_id) |
Check is specified memory region is enabled. More... | |
int32_t | tivxMemRegionTranslate (uint32_t mem_heap_region, uint32_t *heap_id) |
Convert tivx enumerated memory regions to app memory regions. 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 (uint32_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 (void) |
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... | |
uint32_t | appMemGetNumAllocs (void) |
Get number of memory allocation. More... | |
Macros | |
#define | APP_MEM_HEAP_NAME_MAX (16u) |
Max characters to use for heap name. More... | |
Memory heap ID | |
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... | |
#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... | |
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... | |
#define APP_MEM_HEAP_NAME_MAX (16u) |
Max characters to use for heap name.
#define APP_MEM_HEAP_DDR (0u) |
Heap located in DDR.
#define APP_MEM_HEAP_L3 (1u) |
Heap located in L3 memory (MSMC)
#define APP_MEM_HEAP_L2 (2u) |
Heap located in L2 local memory of a CPU.
#define APP_MEM_HEAP_L1 (3u) |
Heap located in L1 local memory of a CPU.
#define APP_MEM_HEAP_DDR_SCRATCH (4u) |
Heap located in DDR and is used as scratch.
#define APP_MEM_HEAP_DDR_NON_CACHE (5u) |
Heap located in DDR and in non-cache memory of persistent property.
#define APP_MEM_HEAP_DDR_NON_CACHE_SCRATCH (6u) |
Heap located in DDR and in non-cache memory of scratch property.
#define APP_MEM_HEAP_DDR_WT_CACHE (7u) |
Heap located in DDR and in cache memory which is configured as write through.
#define APP_MEM_HEAP_MAX (8u) |
Max heaps in system.
#define APP_MEM_HEAP_FLAGS_TYPE_LINEAR_ALLOCATE (0x00000001u) |
Heap flag to indicate heap is of type "linear allocater".
Here alloc increments a offset by alloc size and free resets the offset. This is used typically for L2 memory to allocate it as scratch among multiple algorithms on DSP.
When this flag is not set heap type is normal dynamic memory allocator heap
#define APP_MEM_HEAP_FLAGS_IS_SHARED (0x00000004u) |
Heap flag to indicate if memory that is allocated will be shared with another CPU.
#define APP_MEM_HEAP_FLAGS_DO_CLEAR_ON_ALLOC (0x00000008u) |
Heap flag to indicate if memory should be set to 0 after alloc.
typedef uint64_t(* app_mem_shared_target_fxn) (const uint64_t sharedAddr) |
Shared pointer to target pointer address translation callback function.
This callback function is used to translate the pointer shared across cores to a pointer that can be used by the core it is called from
sharedAddr | [IN] Shared address across remote cores |
typedef uint64_t(* app_mem_target_shared_fxn) (const uint64_t targetAddr) |
target pointer to shared pointer address translation callback function.
This callback function is used to translate a pointer that is be used by the core to the shared pointer that can be used across cores
targetAddr | [IN] Target address of the calling core |
|
inlinestatic |
Align ptr value to 'align' bytes.
|
inlinestatic |
Align 64b value to 'align' bytes.
|
inlinestatic |
Align 32b value to 'align' bytes.
|
inlinestatic |
Enable L1D and L2 Cache by performing a WB.
Applicable only for J784S4 SOC due to coherency difference on these SOC's
void appMemInitPrmSetDefault | ( | app_mem_init_prm_t * | prm | ) |
Set defaults to app_mem_init_prm_t.
Recommend to be called before calling appMemInit() Override default with user specific parameters
By default all heaps are disabled.
prm | [out] Default initialized parameters |
int32_t appMemInit | ( | app_mem_init_prm_t * | prm | ) |
Init heaps for memory allocation.
prm | [in] Initialization parameters |
int32_t appMemDeInit | ( | void | ) |
De-Init heaps for memory allocation.
void* appMemAlloc | ( | uint32_t | heap_id, |
uint32_t | size, | ||
uint32_t | align | ||
) |
Alloc memory from specific heap.
heap_id | [in] See APP_MEM_HEAP_* |
size | [in] Size in bytes to allocate |
align | [in] Minimum alignment requested |
bool appMemRegionQuery | ( | uint32_t | heap_id | ) |
Check is specified memory region is enabled.
heap_id | [in] See APP_MEM_HEAP_* |
int32_t tivxMemRegionTranslate | ( | uint32_t | mem_heap_region, |
uint32_t * | heap_id | ||
) |
Convert tivx enumerated memory regions to app memory regions.
mem_heap_region | [in] See TIVX_MEM_* |
heap_id | [in] See APP_MEM_HEAP_* |
int32_t appMemResetScratchHeap | ( | uint32_t | heap_id | ) |
Reset scratch memory.
heap_id | [in] See APP_MEM_HEAP_* |
int32_t appMemFree | ( | uint32_t | heap_id, |
void * | ptr, | ||
uint32_t | size | ||
) |
Free memory that was previously allocated.
heap_id | [in] See APP_MEM_HEAP_* |
ptr | [in] pointer to allocated memory |
size | [in] size of allocated memory |
uint32_t appMemGetDmaBufFd | ( | void * | virPtr, |
volatile uint32_t * | dmaBufFdOffset | ||
) |
Return dmaBufFd of a CMEM buffer pointer.
virPtr | [in] pointer to allocated memory |
dmaBufFdOffset | [out] offset within the DMA BUF FD where the data is located |
int32_t appMemTranslateDmaBufFd | ( | uint32_t | dmaBufFd, |
uint32_t | size, | ||
uint64_t * | virtPtr, | ||
uint64_t * | phyPtr | ||
) |
Translates a given 'dmaBufFd' to virtual and physical addresses.
dmaBufFd | [in] DMA Buffer Id to translate. |
size | [in] Size of buffer in bytes |
virtPtr | [out] Virtual address of the memory represented by 'dmaBufFd'. |
phyPtr | [out] Physical address of the memory represented by 'dmaBufFd'. |
void appMemCloseDmaBufFd | ( | uint32_t | dmaBufFd | ) |
Close the dmaBufFd of a CMEM buffer pointer.
dmaBufFd | [in] value of dmaBufFd |
uint64_t appMemGetVirt2PhyBufPtr | ( | uint64_t | virtPtr, |
uint32_t | heap_id | ||
) |
Return physical ptr corresponds to a CMEM virtual ptr.
virtPtr | [in] pointer to allocated memory |
heap_id | [in] heap ID |
int32_t appMemStats | ( | uint32_t | heap_id, |
app_mem_stats_t * | stats | ||
) |
Return heap statistics and information.
heap_id | [in] See APP_MEM_HEAP_* |
stats | [in] Heap statistics and information |
void appMemCacheInv | ( | void * | ptr, |
uint32_t | size | ||
) |
Invalidate a section of memory from cache.
ptr | [in] Memory address for cache ops |
size | [in] Size of memory to perform the cache ops |
void appMemCacheWb | ( | void * | ptr, |
uint32_t | size | ||
) |
Write back a section of memory from cache.
ptr | [in] Memory address for cache ops |
size | [in] Size of memory to perform the cache ops |
void appMemCacheWbInv | ( | void * | ptr, |
uint32_t | size | ||
) |
Write back and invalidate a section of memory from cache.
ptr | [in] Memory address for cache ops |
size | [in] Size of memory to perform the cache ops |
void appMemPrintMemAllocInfo | ( | void | ) |
Print memory allocation from shared memory region.
uint64_t appMemShared2PhysPtr | ( | uint64_t | shared_ptr, |
uint32_t | heap_id | ||
) |
Return the physical pointer from a shared pointer.
shared_ptr | [in] pointer to allocated memory |
heap_id | [in] heap ID |
uint64_t appMemShared2TargetPtr | ( | uint64_t | shared_ptr | ) |
Return the physical pointer from a shared pointer.
physPtr | [in] pointer to physical memory |
void* appMemMap | ( | void * | phys_addr, |
uint32_t | size | ||
) |
Map the provided physical memory to a virtual address.
phys_addr | [in] pointer to physical memory |
size | [in] size of physical memory |
int32_t appMemUnMap | ( | void * | virt_addr, |
uint32_t | size | ||
) |
Unmap the provided virtual memory.
virt_addr | [in] pointer to virtual memory |
size | [in] size of virtual memory |
uint32_t appMemGetNumAllocs | ( | void | ) |
Get number of memory allocation.