Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Shared multi-heap interface

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...
 

Detailed Description

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 Documentation

◆ smh_init_reg_fn_t

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.

Parameters
regPointer to the SMH region structure.
v_addrVirtual address obtained after mapping. For non-MMU architectures this value is the physical address of the region.
sizeSize of the region after mapping.
Returns
True if the region is ready to be added to the heap pool. False if the region must be skipped.

Enumeration Type Documentation

◆ 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

Function Documentation

◆ shared_multi_heap_alloc()

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.

Parameters
attrCapability / attribute requested for the memory block.
bytesRequested size of the allocation in bytes.
Returns
A valid pointer to heap memory or NULL if no memory is available.

◆ shared_multi_heap_free()

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.

Parameters
blockBlock to free.

◆ shared_multi_heap_pool_init()

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.

Parameters
smh_init_reg_fnThe function pointer to the region init function. Can be NULL for non-MPU / non-MMU architectures.