Zephyr Project API 3.7.0
A Scalable Open Source RTOS
|
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. | |
Memory-Attr Interface.
#define DT_MEMORY_ATTR_FOREACH_STATUS_OKAY_NODE | ( | fn | ) | DT_FOREACH_STATUS_OKAY_NODE_VARGS(_FILTER, fn) |
#include <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.
fn | macro to invoke |
#include <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).
addr | Virtual address of the user buffer. |
size | Size of the user buffer. |
attr | Expected / desired attribute for the buffer. |
0 | if the buffer has the correct size and attribute. |
-ENOSYS | if the operation is not supported (for example if the MMU is enabled). |
-ENOTSUP | if the wrong parameters were passed. |
-EINVAL | if the buffer has the wrong set of attributes. |
-ENOSPC | if the buffer is too big for the region it belongs to. |
-ENOBUFS | if the buffer is entirely allocated outside a memory region. |
size_t mem_attr_get_regions | ( | const struct mem_attr_region_t ** | region | ) |
#include <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.
region | Pointer to pointer to the list of memory regions. |
Number | of memory regions returned in the parameter. |