Sound Open Firmware
Loading...
Searching...
No Matches
alloc.h File Reference

Memory allocation API, zones, heaps, and alignment utilities. More...

Include dependency graph for alloc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mod_alloc_ctx
 Module and pipeline allocation context aggregating a Zephyr heap and optional virtual region. More...
 

Macros

Allocation flags
#define SOF_MEM_FLAG_DMA   BIT(2)
 Allocate memory accessible by DMA controllers (e.g.
 
#define SOF_MEM_FLAG_NO_COPY   BIT(3)
 realloc() skips copying the original content.
 
#define SOF_MEM_FLAG_COHERENT   BIT(4)
 Allocate uncached / coherent memory address.
 
#define SOF_MEM_FLAG_L3   BIT(5)
 Allocate from L3 address space (IMR / external DRAM heap).
 
#define SOF_MEM_FLAG_LOW_POWER   BIT(6)
 Allocate Low power memory address.
 
#define SOF_MEM_FLAG_KERNEL   BIT(7)
 Base allocation flag denoting memory allocated for kernel-space data structures.
 
#define SOF_MEM_FLAG_USER   BIT(8)
 Base allocation flag denoting memory allocated for user-space threads and module execution.
 
#define SOF_MEM_FLAG_USER_SHARED_BUFFER   BIT(9)
 Allocate from shared user memory heap (shared_buffer_heap) accessible across user/kernel domains.
 
#define SOF_MEM_FLAG_LARGE_BUFFER   BIT(10)
 Route allocation to the Virtual Memory Heap (VMH / virtual_buffers_heap) for large stream buffers.
 

Functions

void * rmalloc_align (uint32_t flags, size_t bytes, uint32_t alignment)
 Allocate memory block with explicit alignment and heap selection flags.
 
void * rmalloc (uint32_t flags, size_t bytes)
 Allocate memory block with default natural alignment.
 
void * rzalloc (uint32_t flags, size_t bytes)
 Allocate zero-initialized memory block with default natural alignment.
 
void * rballoc_align (uint32_t flags, size_t bytes, uint32_t alignment)
 Allocate runtime stream buffer with explicit alignment.
 
static void * rballoc (uint32_t flags, size_t bytes)
 Allocate runtime stream buffer aligned to platform data cache line size.
 
void rfree (void *ptr)
 Free memory block allocated by SOF RTOS allocators.
 
void l3_heap_save (void)
 Save and flush L3 heap state and metadata across DSP reset or power gating.
 
void * sof_heap_alloc (struct k_heap *heap, uint32_t flags, size_t bytes, size_t alignment)
 Allocate memory from a specified Zephyr heap or default system heap.
 
void sof_heap_free (struct k_heap *heap, void *addr)
 Free memory allocated via sof_heap_alloc().
 
struct k_heap * sof_sys_heap_get (void)
 Get the system kernel heap descriptor.
 
struct k_heap * sof_sys_user_heap_get (void)
 Get the heap object to use for audio application allocations.
 
static void heap_trace_all (int force)
 Trace and log memory allocation statistics across all active heaps.
 
uintptr_t get_shared_buffer_heap_start (void)
 Returns the start address of shared memory heap for buffers.
 
size_t get_shared_buffer_heap_size (void)
 Returns the total size of shared memory heap for buffers.
 
static void * sof_ctx_alloc (struct mod_alloc_ctx *ctx, uint32_t flags, size_t size, size_t alignment)
 Allocate memory from an allocation context.
 
static void * sof_ctx_zalloc (struct mod_alloc_ctx *ctx, uint32_t flags, size_t size, size_t alignment)
 Allocate zero-initialized memory from an allocation context.
 
static void sof_ctx_free (struct mod_alloc_ctx *ctx, void *ptr)
 Free memory allocated from an allocation context.
 

Detailed Description

Memory allocation API, zones, heaps, and alignment utilities.