Sound Open Firmware
Loading...
Searching...
No Matches
Memory Allocation API

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)

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.

Detailed Description

Macro Definition Documentation

◆ SOF_MEM_FLAG_COHERENT

#define SOF_MEM_FLAG_COHERENT   BIT(4)

Allocate uncached address.

◆ SOF_MEM_FLAG_DMA

#define SOF_MEM_FLAG_DMA   BIT(2)

Allocate DMA-able memory.

◆ SOF_MEM_FLAG_KERNEL

#define SOF_MEM_FLAG_KERNEL   BIT(7)

Allocate kernel memory address.

◆ SOF_MEM_FLAG_L3

#define SOF_MEM_FLAG_L3   BIT(5)

Allocate L3 address.

◆ SOF_MEM_FLAG_LARGE_BUFFER

#define SOF_MEM_FLAG_LARGE_BUFFER   BIT(10)

Use allocation method for large buffers.

◆ SOF_MEM_FLAG_LOW_POWER

#define SOF_MEM_FLAG_LOW_POWER   BIT(6)

Allocate Low power memory address.

◆ SOF_MEM_FLAG_NO_COPY

#define SOF_MEM_FLAG_NO_COPY   BIT(3)

realloc() skips copying the original content.

◆ SOF_MEM_FLAG_USER

#define SOF_MEM_FLAG_USER   BIT(8)

Allocate user memory address.

◆ SOF_MEM_FLAG_USER_SHARED_BUFFER

#define SOF_MEM_FLAG_USER_SHARED_BUFFER   BIT(9)

Allocate shared user memory address.

Function Documentation

◆ heap_trace_all()

void heap_trace_all ( int force)
inlinestatic

◆ l3_heap_save()

void l3_heap_save ( void )

Save L3 heap over DSP reset.

◆ rballoc()

void * rballoc ( uint32_t flags,
size_t bytes )
inlinestatic

Similar to rballoc_align(), returns buffer aligned to PLATFORM_DCACHE_ALIGN.

◆ rballoc_align()

void * rballoc_align ( uint32_t flags,
size_t bytes,
uint32_t alignment )

Allocates memory block.

Parameters
flagsFlags, see SOF_MEM_FLAG_...
bytesSize in bytes.
alignmentAlignment in bytes.
Returns
Pointer to the allocated memory or NULL if failed.

◆ rfree()

void rfree ( void * ptr)

Frees the memory block.

Parameters
ptrPointer to the memory block.

◆ rmalloc()

void * rmalloc ( uint32_t flags,
size_t bytes )

Similar to rmalloc_align(), but no alignment can be specified.

◆ rmalloc_align()

void * rmalloc_align ( uint32_t flags,
size_t bytes,
uint32_t alignment )

Allocates memory block.

Parameters
flagsFlags, see SOF_MEM_FLAG_....
bytesSize in bytes.
alignmentAlignment in bytes.
Returns
Pointer to the allocated memory or NULL if failed.

◆ rzalloc()

void * rzalloc ( uint32_t flags,
size_t bytes )

Similar to rmalloc(), guarantees that returned block is zeroed.

◆ sof_heap_alloc()

void * sof_heap_alloc ( struct k_heap * heap,
uint32_t flags,
size_t bytes,
size_t alignment )

◆ sof_heap_free()

void sof_heap_free ( struct k_heap * heap,
void * addr )

◆ sof_sys_heap_get()

struct k_heap * sof_sys_heap_get ( void )
inlinestatic

◆ sof_sys_user_heap_get()

struct k_heap * sof_sys_user_heap_get ( void )

Returns heap object to use for SOF heap allocations for audio application code.

The returned value may be NULL. This matches with semantics of sof_heap_alloc() that allows passing NULL as the 'heap'. In this case, the heap implementation will choose the heap to use.

The function should not be used for heap allocations for objects that are only used in SOF kernel space.

Note: audio modules should use mod_alloc() instead!