12#ifndef __ZEPHYR_RTOS_ALLOC_H__
13#define __ZEPHYR_RTOS_ALLOC_H__
18#include <sof/trace/trace.h>
39#define SOF_MEM_FLAG_DMA BIT(2)
45#define SOF_MEM_FLAG_NO_COPY BIT(3)
53#define SOF_MEM_FLAG_COHERENT BIT(4)
60#define SOF_MEM_FLAG_L3 BIT(5)
65#define SOF_MEM_FLAG_LOW_POWER BIT(6)
67#define SOF_MEM_FLAG_KERNEL BIT(7)
69#define SOF_MEM_FLAG_USER BIT(8)
71#define SOF_MEM_FLAG_USER_SHARED_BUFFER BIT(9)
73#define SOF_MEM_FLAG_LARGE_BUFFER BIT(10)
147static inline void *
rballoc(uint32_t flags,
size_t bytes)
180#ifdef CONFIG_SOF_USERSPACE_INTERFACE_ALLOC
189#include <zephyr/syscalls/alloc.h>
191void *
sof_heap_alloc(
struct k_heap *heap, uint32_t flags,
size_t bytes,
200#if CONFIG_SOF_FULL_ZEPHYR_APPLICATION
231#if CONFIG_SOF_USERSPACE_USE_SHARED_HEAP
271 size_t size,
size_t alignment)
273 if (!ctx || !ctx->
vreg)
294 size_t size,
size_t alignment)
299 memset(ptr, 0, size);
318 if (ctx && ctx->
vreg)
void vregion_free(struct vregion *vr, void *ptr)
Free memory allocated from the specified virtual region.
void * rmalloc_align(uint32_t flags, size_t bytes, uint32_t alignment)
Allocate memory block with explicit alignment and heap selection flags.
size_t get_shared_buffer_heap_size(void)
Returns the total size of shared memory heap for buffers.
static void heap_trace_all(int force)
Trace and log memory allocation statistics across all active heaps.
Definition alloc.h:229
void l3_heap_save(void)
Save and flush L3 heap state and metadata across DSP reset or power gating.
void * rzalloc(uint32_t flags, size_t bytes)
Allocate zero-initialized memory block with default natural alignment.
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.
static void sof_ctx_free(struct mod_alloc_ctx *ctx, void *ptr)
Free memory allocated from an allocation context.
Definition alloc.h:313
void * vregion_alloc_align(struct vregion *vr, size_t size, size_t alignment)
Allocate aligned memory from the specified virtual region.
void rfree(void *ptr)
Free memory block allocated by SOF RTOS allocators.
void * rballoc_align(uint32_t flags, size_t bytes, uint32_t alignment)
Allocate runtime stream buffer with explicit alignment.
struct k_heap * sof_sys_heap_get(void)
Get the system kernel heap descriptor.
uintptr_t get_shared_buffer_heap_start(void)
Returns the start address of shared memory heap for buffers.
static void * rballoc(uint32_t flags, size_t bytes)
Allocate runtime stream buffer aligned to platform data cache line size.
Definition alloc.h:147
void * rmalloc(uint32_t flags, size_t bytes)
Allocate memory block with default natural alignment.
void * vregion_alloc_coherent_align(struct vregion *vr, size_t size, size_t alignment)
Allocate aligned coherent (uncached) memory from the specified virtual region.
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.
Definition alloc.h:293
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.
Definition alloc.h:270
struct k_heap * sof_sys_user_heap_get(void)
Get the heap object to use for audio application allocations.
#define SOF_MEM_FLAG_COHERENT
Allocate uncached / coherent memory address.
Definition alloc.h:53
void sof_heap_free(struct k_heap *heap, void *addr)
Free memory allocated via sof_heap_alloc().
Memory attributes, cold/hot execution paths, and platform memory inclusions.
User-space ABI log levels and binary trace packet header definitions.
Module and pipeline allocation context aggregating a Zephyr heap and optional virtual region.
Definition alloc.h:251
struct vregion * vreg
Optional virtual region for interim/lifetime partitioning.
Definition alloc.h:253
struct k_heap * heap
Underlying Zephyr heap descriptor.
Definition alloc.h:252
Pre-allocated contiguous virtual memory region allocator (lifetime vs interim).