Zephyr Project API  3.2.0
A Scalable Open Source RTOS
devicetree_regions.h File Reference

Go to the source code of this file.

Macros

#define LINKER_DT_NODE_REGION_NAME_TOKEN(node_id)    DT_STRING_TOKEN(node_id, zephyr_memory_region)
 Get the linker memory-region name in a token form. More...
 
#define LINKER_DT_NODE_REGION_NAME(node_id)    STRINGIFY(LINKER_DT_NODE_REGION_NAME_TOKEN(node_id))
 Get the linker memory-region name. More...
 
#define LINKER_DT_REGIONS()    DT_FOREACH_STATUS_OKAY(_DT_COMPATIBLE, _REGION_DECLARE)
 Generate linker memory regions from the device tree nodes with compatible 'zephyr,memory-region'. More...
 
#define LINKER_DT_SECTIONS()    DT_FOREACH_STATUS_OKAY(_DT_COMPATIBLE, _SECTION_DECLARE)
 Generate linker memory sections from the device tree nodes with compatible 'zephyr,memory-region'. More...
 
#define LINKER_DT_REGION_MPU(mpu_fn)   _CHECK_APPLY_FN(_DT_COMPATIBLE, _EXPAND_MPU_FN, mpu_fn)
 Generate MPU regions from the device tree nodes with compatible 'zephyr,memory-region' and 'zephyr,memory-region-mpu' attribute. More...
 

Macro Definition Documentation

◆ LINKER_DT_NODE_REGION_NAME

#define LINKER_DT_NODE_REGION_NAME (   node_id)     STRINGIFY(LINKER_DT_NODE_REGION_NAME_TOKEN(node_id))

Get the linker memory-region name.

This attempts to use the zephyr,memory-region property (with non-alphanumeric characters replaced with underscores).

Example devicetree fragment:

/ {
soc {
sram1: memory@2000000 {
zephyr,memory-region = "MY_NAME";
};
sram2: memory@2001000 {
zephyr,memory-region = "MY@OTHER@NAME";
};
};
};

Example usage:

LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(sram2)) // "MY_OTHER_NAME"
#define LINKER_DT_NODE_REGION_NAME(node_id)
Get the linker memory-region name.
Definition: devicetree_regions.h:78
#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition: devicetree.h:190
Parameters
node_idnode identifier
Returns
the name of the memory memory region the node will generate

◆ LINKER_DT_NODE_REGION_NAME_TOKEN

#define LINKER_DT_NODE_REGION_NAME_TOKEN (   node_id)     DT_STRING_TOKEN(node_id, zephyr_memory_region)

Get the linker memory-region name in a token form.

This attempts to use the zephyr,memory-region property (with non-alphanumeric characters replaced with underscores) returning a token.

Example devicetree fragment:

/ {
soc {
sram1: memory@2000000 {
zephyr,memory-region = "MY_NAME";
};
sram2: memory@2001000 {
zephyr,memory-region = "MY@OTHER@NAME";
};
};
};

Example usage:

#define LINKER_DT_NODE_REGION_NAME_TOKEN(node_id)
Get the linker memory-region name in a token form.
Definition: devicetree_regions.h:44
Parameters
node_idnode identifier
Returns
the name of the memory memory region the node will generate

◆ LINKER_DT_REGION_MPU

#define LINKER_DT_REGION_MPU (   mpu_fn)    _CHECK_APPLY_FN(_DT_COMPATIBLE, _EXPAND_MPU_FN, mpu_fn)

Generate MPU regions from the device tree nodes with compatible 'zephyr,memory-region' and 'zephyr,memory-region-mpu' attribute.

Helper macro to apply an MPU_FN macro to all the memory regions declared using the 'zephyr,memory-region-mpu' property and the 'zephyr,memory-region' compatible.

MPU_FN must take the form:

#define MPU_FN(name, base, size, attr) ...

The 'name', 'base' and 'size' parameters are taken from the DT node.

The 'zephyr,memory-region-mpu' enum property is passed as an extended token to the MPU_FN macro using the 'attr' parameter, in the form REGION_{attr}_ATTR.

The following enums are supported for the 'zephyr,memory-region-mpu' property:

  • RAM
  • RAM_NOCACHE
  • FLASH
  • PPB
  • IO

This means that usually the arch code would provide some macros or defines with the same name of the extended property, that is:

  • REGION_RAM_ATTR
  • REGION_RAM_NOCACHE_ATTR
  • REGION_FLASH_ATTR
  • REGION_PPB_ATTR
  • REGION_IO_ATTR

Example devicetree fragment:

/ {
        soc {
                sram1: memory@2000000 {
                    zephyr,memory-region = "MY_NAME";
                    zephyr,memory-region-mpu = "RAM_NOCACHE";
                };
        };
};

For detailed information about MPU region attribute define configuration refer to the specific architecture MPU header. For example: include/zephyr/arch/arm/aarch32/mpu/arm_mpu_v7m.h.

The 'attr' parameter of the MPU_FN function will be the extended 'REGION_RAM_NOCACHE_ATTR' token and the arch code will be usually implementing a macro with the same name.

Example:

#define REGION_RAM_NOCACHE_ATTR 0xAAAA
#define REGION_RAM_ATTR 0xBBBB
#define REGION_FLASH_ATTR 0xCCCC
#define MPU_FN(p_name, p_base, p_size, p_attr) \
{ \
.name = p_name, \
.base = p_base, \
.size = p_size, \
.attr = p_attr, \
}
static const struct arm_mpu_region mpu_regions[] = {
...
...
};
#define LINKER_DT_REGION_MPU(mpu_fn)
Generate MPU regions from the device tree nodes with compatible 'zephyr,memory-region' and 'zephyr,...
Definition: devicetree_regions.h:291
Definition: arm_mpu.h:27

◆ LINKER_DT_REGIONS

#define LINKER_DT_REGIONS ( )     DT_FOREACH_STATUS_OKAY(_DT_COMPATIBLE, _REGION_DECLARE)

Generate linker memory regions from the device tree nodes with compatible 'zephyr,memory-region'.

Note: for now we do not deal with MEMORY attributes since those are optional, not actually used by Zephyr and they will likely conflict with the MPU configuration.

◆ LINKER_DT_SECTIONS

#define LINKER_DT_SECTIONS ( )     DT_FOREACH_STATUS_OKAY(_DT_COMPATIBLE, _SECTION_DECLARE)

Generate linker memory sections from the device tree nodes with compatible 'zephyr,memory-region'.