Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Memory heaps based on memory attributes

Memory heaps based on memory attributes. More...

Functions

int mem_attr_heap_pool_init (void)
 Init the memory pool.
 
void * mem_attr_heap_alloc (uint32_t attr, size_t bytes)
 Allocate memory with a specified attribute and size.
 
void * mem_attr_heap_aligned_alloc (uint32_t attr, size_t align, size_t bytes)
 Allocate aligned memory with a specified attribute, size and alignment.
 
void mem_attr_heap_free (void *block)
 Free the allocated memory.
 
const struct mem_attr_region_tmem_attr_heap_get_region (void *addr)
 Get a specific memory region descriptor for a provided address.
 

Detailed Description

Memory heaps based on memory attributes.

Function Documentation

◆ mem_attr_heap_aligned_alloc()

void * mem_attr_heap_aligned_alloc ( uint32_t  attr,
size_t  align,
size_t  bytes 
)

#include <zephyr/mem_mgmt/mem_attr_heap.h>

Allocate aligned memory with a specified attribute, size and alignment.

Allocates a block of memory of the specified size in bytes and with a specified capability / attribute. Takes an additional parameter specifying a power of two alignment in bytes.

Parameters
attrcapability / attribute requested for the memory block.
alignpower of two alignment for the returned pointer in bytes.
bytesrequested size of the allocation in bytes.
Return values
ptra valid pointer to the allocated memory.
NULLif no memory is available with that attribute and size.

◆ mem_attr_heap_alloc()

void * mem_attr_heap_alloc ( uint32_t  attr,
size_t  bytes 
)

#include <zephyr/mem_mgmt/mem_attr_heap.h>

Allocate memory with a specified attribute and size.

Allocates a block of memory of the specified size in bytes and with a specified capability / attribute. The attribute is used to select the correct memory heap to allocate memory from.

Parameters
attrcapability / attribute requested for the memory block.
bytesrequested size of the allocation in bytes.
Return values
ptra valid pointer to the allocated memory.
NULLif no memory is available with that attribute and size.

◆ mem_attr_heap_free()

void mem_attr_heap_free ( void *  block)

#include <zephyr/mem_mgmt/mem_attr_heap.h>

Free the allocated memory.

Used to free the passed block of memory that must be the return value of a previously call to mem_attr_heap_alloc or mem_attr_heap_aligned_alloc.

Parameters
blockblock to free, must be a pointer to a block allocated by mem_attr_heap_alloc or mem_attr_heap_aligned_alloc.

◆ mem_attr_heap_get_region()

const struct mem_attr_region_t * mem_attr_heap_get_region ( void *  addr)

#include <zephyr/mem_mgmt/mem_attr_heap.h>

Get a specific memory region descriptor for a provided address.

Finds the memory region descriptor struct controlling the provided pointer.

Parameters
addraddress to be found, must be a pointer to a block allocated by mem_attr_heap_alloc or mem_attr_heap_aligned_alloc.
Return values
strpointer to a memory region structure the address belongs to.

◆ mem_attr_heap_pool_init()

int mem_attr_heap_pool_init ( void  )

#include <zephyr/mem_mgmt/mem_attr_heap.h>

Init the memory pool.

This must be the first function to be called to initialize the memory pools from all the memory regions with the a software attribute.

Return values
0on success.
-EALREADYif the pool was already initialized.
-ENOMEMtoo many regions already allocated.