Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Memory-Attr Interface

Memory-Attr Interface. More...

Data Structures

struct  mem_attr_region_t
 memory-attr region structure. More...
 

Macros

#define DT_MEMORY_ATTR_FOREACH_STATUS_OKAY_NODE(fn)    DT_FOREACH_STATUS_OKAY_NODE_VARGS(_FILTER, fn)
 Invokes fn for every status okay node in the tree with property zephyr,memory-attr
 

Functions

size_t mem_attr_get_regions (const struct mem_attr_region_t **region)
 Get the list of memory regions.
 
int mem_attr_check_buf (void *addr, size_t size, uint32_t attr)
 Check if a buffer has correct size and attributes.
 

Detailed Description

Memory-Attr Interface.

Macro Definition Documentation

◆ DT_MEMORY_ATTR_FOREACH_STATUS_OKAY_NODE

#define DT_MEMORY_ATTR_FOREACH_STATUS_OKAY_NODE (   fn)     DT_FOREACH_STATUS_OKAY_NODE_VARGS(_FILTER, fn)

#include <zephyr/mem_mgmt/mem_attr.h>

Invokes fn for every status okay node in the tree with property zephyr,memory-attr

The macro fn must take one parameter, which will be a node identifier with the zephyr,memory-attr property. The macro is expanded once for each node in the tree with status okay. The order that nodes are visited in is not specified.

Parameters
fnmacro to invoke

Function Documentation

◆ mem_attr_check_buf()

int mem_attr_check_buf ( void *  addr,
size_t  size,
uint32_t  attr 
)

#include <zephyr/mem_mgmt/mem_attr.h>

Check if a buffer has correct size and attributes.

This function is used to check if a given buffer with a given set of attributes fully match a memory region in terms of size and attributes.

This is usually used to verify that a buffer has the expected attributes (for example the buffer is cacheable / non-cacheable or belongs to RAM / FLASH, etc...) and it has been correctly allocated.

The expected set of attributes for the buffer is and-matched against the full set of attributes for the memory region it belongs to (bitmask). So the buffer is considered matching when at least that set of attributes are valid for the memory region (but the region can be marked also with other attributes besides the one passed as parameter).

Parameters
addrVirtual address of the user buffer.
sizeSize of the user buffer.
attrExpected / desired attribute for the buffer.
Return values
0if the buffer has the correct size and attribute.
-ENOSYSif the operation is not supported (for example if the MMU is enabled).
-ENOTSUPif the wrong parameters were passed.
-EINVALif the buffer has the wrong set of attributes.
-ENOSPCif the buffer is too big for the region it belongs to.
-ENOBUFSif the buffer is entirely allocated outside a memory region.

◆ mem_attr_get_regions()

size_t mem_attr_get_regions ( const struct mem_attr_region_t **  region)

#include <zephyr/mem_mgmt/mem_attr.h>

Get the list of memory regions.

Get the list of enabled memory regions with their memory-attribute as gathered by DT.

Parameters
regionPointer to pointer to the list of memory regions.
Return values
Numberof memory regions returned in the parameter.