Sound Open Firmware
Loading...
Searching...
No Matches
alloc.h File Reference
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

Macros

Allocation flags
#define SOF_MEM_FLAG_DMA   BIT(2)
 Allocate DMA-able memory.
#define SOF_MEM_FLAG_NO_COPY   BIT(3)
 realloc() skips copying the original content.
#define SOF_MEM_FLAG_COHERENT   BIT(4)
 Allocate uncached address.
#define SOF_MEM_FLAG_L3   BIT(5)
 Allocate L3 address.
#define SOF_MEM_FLAG_LOW_POWER   BIT(6)
 Allocate Low power memory address.
#define SOF_MEM_FLAG_KERNEL   BIT(7)
 Allocate kernel memory address.
#define SOF_MEM_FLAG_USER   BIT(8)
 Allocate user memory address.
#define SOF_MEM_FLAG_USER_SHARED_BUFFER   BIT(9)
 Allocate shared user memory address.
#define SOF_MEM_FLAG_LARGE_BUFFER   BIT(10)
 Use allocation method for large buffers.

Functions

void * rmalloc_align (uint32_t flags, size_t bytes, uint32_t alignment)
 Allocates memory block.
void * rmalloc (uint32_t flags, size_t bytes)
 Similar to rmalloc_align(), but no alignment can be specified.
void * rzalloc (uint32_t flags, size_t bytes)
 Similar to rmalloc(), guarantees that returned block is zeroed.
void * rballoc_align (uint32_t flags, size_t bytes, uint32_t alignment)
 Allocates memory block.
static void * rballoc (uint32_t flags, size_t bytes)
 Similar to rballoc_align(), returns buffer aligned to PLATFORM_DCACHE_ALIGN.
void rfree (void *ptr)
 Frees the memory block.
void l3_heap_save (void)
 Save L3 heap over DSP reset.
void * sof_heap_alloc (struct k_heap *heap, uint32_t flags, size_t bytes, size_t alignment)
void sof_heap_free (struct k_heap *heap, void *addr)
static struct k_heap * sof_sys_heap_get (void)
struct k_heap * sof_sys_user_heap_get (void)
 Returns heap object to use for SOF heap allocations for audio application code.
static void heap_trace_all (int force)
static void * sof_ctx_alloc (struct mod_alloc_ctx *ctx, uint32_t flags, size_t size, size_t alignment)
 Allocate memory from a mod_alloc_ctx 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 a mod_alloc_ctx context.
static void sof_ctx_free (struct mod_alloc_ctx *ctx, void *ptr)
 Free memory allocated from a mod_alloc_ctx context.

Function Documentation

◆ sof_ctx_alloc()

void * sof_ctx_alloc ( struct mod_alloc_ctx * ctx,
uint32_t flags,
size_t size,
size_t alignment )
inlinestatic

Allocate memory from a mod_alloc_ctx context.

When the context has a vregion, allocates from the vregion interim partition. Coherent memory is used when SOF_MEM_FLAG_COHERENT is set in flags. Falls back to sof_heap_alloc() otherwise.

Parameters
ctxAllocation context (heap + optional vregion).
flagsAllocation flags (SOF_MEM_FLAG_*).
sizeSize in bytes.
alignmentRequired alignment in bytes.
Returns
Pointer to allocated memory or NULL on failure.

◆ sof_ctx_free()

void sof_ctx_free ( struct mod_alloc_ctx * ctx,
void * ptr )
inlinestatic

Free memory allocated from a mod_alloc_ctx context.

Parameters
ctxAllocation context.
ptrPointer to free.

◆ sof_ctx_zalloc()

void * sof_ctx_zalloc ( struct mod_alloc_ctx * ctx,
uint32_t flags,
size_t size,
size_t alignment )
inlinestatic

Allocate zero-initialized memory from a mod_alloc_ctx context.

Parameters
ctxAllocation context.
flagsAllocation flags (SOF_MEM_FLAG_*).
sizeSize in bytes.
alignmentRequired alignment in bytes.
Returns
Pointer to allocated memory or NULL on failure.