Zephyr API Documentation
3.0.0
A Scalable Open Source RTOS
|
|
3.0.0 |
Shared multi-heap interface. More...
Data Structures | |
struct | shared_multi_heap_region |
SMH region struct. More... | |
Typedefs | |
typedef bool(* | smh_init_reg_fn_t) (struct shared_multi_heap_region *reg, uint8_t **v_addr, size_t *size) |
Region init function. More... | |
Enumerations | |
enum | smh_reg_attr { SMH_REG_ATTR_CACHEABLE , SMH_REG_ATTR_NON_CACHEABLE , SMH_REG_ATTR_NUM } |
Memory region attributes / capabilities. More... | |
Functions | |
int | shared_multi_heap_pool_init (smh_init_reg_fn_t smh_init_reg_fn) |
Init the pool. More... | |
void * | shared_multi_heap_alloc (enum smh_reg_attr attr, size_t bytes) |
Allocate memory from the memory shared multi-heap pool. More... | |
void | shared_multi_heap_free (void *block) |
Free memory from the shared multi-heap pool. More... | |
Shared multi-heap interface.
The shared multi-heap manager uses the multi-heap allocator to manage a set of reserved memory regions with different capabilities / attributes (cacheable, non-cacheable, etc...) defined in the DT.
The user can request allocation from the shared pool specifying the capability / attribute of interest for the memory (cacheable / non-cacheable memory, etc...)
typedef bool(* smh_init_reg_fn_t) (struct shared_multi_heap_region *reg, uint8_t **v_addr, size_t *size) |
#include <include/multi_heap/shared_multi_heap.h>
Region init function.
This is a user-provided function whose responsibility is to setup or initialize the memory region passed in input before this is added to the heap pool by the shared multi-heap manager. This function can be used by architectures using MMU / MPU that must correctly map the region before this is considered valid and accessible.
reg | Pointer to the SMH region structure. |
v_addr | Virtual address obtained after mapping. For non-MMU architectures this value is the physical address of the region. |
size | Size of the region after mapping. |
enum smh_reg_attr |
#include <include/multi_heap/shared_multi_heap.h>
Memory region attributes / capabilities.
** This list needs to be kept in sync with shared-multi-heap.yaml **
Enumerator | |
---|---|
SMH_REG_ATTR_CACHEABLE | cacheable |
SMH_REG_ATTR_NON_CACHEABLE | non-cacheable |
SMH_REG_ATTR_NUM | must be the last item |
void * shared_multi_heap_alloc | ( | enum smh_reg_attr | attr, |
size_t | bytes | ||
) |
#include <include/multi_heap/shared_multi_heap.h>
Allocate memory from the memory shared multi-heap pool.
Allocate a block of memory of the specified size in bytes and with a specified capability / attribute.
attr | Capability / attribute requested for the memory block. |
bytes | Requested size of the allocation in bytes. |
void shared_multi_heap_free | ( | void * | block | ) |
#include <include/multi_heap/shared_multi_heap.h>
Free memory from the shared multi-heap pool.
Free the passed block of memory.
block | Block to free. |
int shared_multi_heap_pool_init | ( | smh_init_reg_fn_t | smh_init_reg_fn | ) |
#include <include/multi_heap/shared_multi_heap.h>
Init the pool.
Initialize the shared multi-heap pool and hook-up the region init function.
smh_init_reg_fn | The function pointer to the region init function. Can be NULL for non-MPU / non-MMU architectures. |