14#ifndef ZEPHYR_LIB_REGIONS_MM_H_
15#define ZEPHYR_LIB_REGIONS_MM_H_
17#include <adsp_memory.h>
18#include <adsp_memory_regions.h>
19#include <ipc/topology.h>
22#include <zephyr/drivers/mm/system_mm.h>
23#include <zephyr/init.h>
24#include <zephyr/sys/mem_blocks.h>
38#define VIRTUAL_REGION_SHARED_HEAP_ATTR 1U
40#define VIRTUAL_REGION_LLEXT_LIBRARIES_ATTR 2U
42#define VIRTUAL_REGION_VPAGES_ATTR 3U
50#define MAX_MEMORY_ALLOCATORS_COUNT 10
55#define DEFAULT_CONFIG_ALOCATORS_COUNT 5
99void *
vmh_alloc(
struct vmh_heap *heap, uint32_t alloc_size);
123#ifdef CONFIG_SYS_MEM_BLOCKS_RUNTIME_STATS
128void vmh_log_stats(
struct vmh_heap *heap);
134void vmh_log_alloc_stats(
struct vmh_heap *heap);
149 return ptr >= range_start && ptr < range_start + range_size;
Memory allocation API, zones, heaps, and alignment utilities.
#define MAX_MEMORY_ALLOCATORS_COUNT
Maximum amount of memory block allocators in one heap.
Definition regions_mm.h:50
static bool vmh_is_ptr_in_memory_range(uintptr_t ptr, uintptr_t range_start, size_t range_size)
Checks if ptr is in range of given memory range.
Definition regions_mm.h:146
void vmh_get_default_heap_config(const struct sys_mm_drv_region *region, struct vmh_heap_config *cfg)
Generate a default heap partition configuration for a memory driver region.
int vmh_free_heap(struct vmh_heap *heap)
Destroy a virtual memory heap and unmap all backing pages.
void * vmh_alloc(struct vmh_heap *heap, uint32_t alloc_size)
Allocate a memory block from the virtual memory heap.
struct vmh_heap * vmh_init_heap(const struct vmh_heap_config *cfg, bool allocating_continuously)
Initialize a virtual memory heap with the given bundle configuration.
int vmh_free(struct vmh_heap *heap, void *ptr)
Free a memory block previously allocated from a virtual memory heap.
Descriptor for a power-of-2 block size bundle in a virtual memory heap.
Definition regions_mm.h:60
size_t number_of_blocks
Number of memory blocks in this bundle.
Definition regions_mm.h:62
size_t block_size
Size of memory block in bytes.
Definition regions_mm.h:61
This is a struct that aggregates vmh_block_bundle_descriptor to create one cfg that can be passed to ...
Definition regions_mm.h:79
struct vmh_block_bundle_descriptor block_bundles_table[MAX_MEMORY_ALLOCATORS_COUNT]
Definition regions_mm.h:80