Skip to content

Commit 024ecdd

Browse files
Jordan Yatescarlescufi
authored andcommitted
devicetree: LINKER_DT_NODE_REGION_NAME added
Adds a macro to convert a devicetree node to the name of a linker memory region. Signed-off-by: Jordan Yates <[email protected]>
1 parent 9c98d4f commit 024ecdd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

include/linker/devicetree_regions.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@
77
* Generate memory regions from devicetree nodes.
88
*/
99

10+
/**
11+
* @brief Get the linker memory-region name
12+
*
13+
* This attempts to use the zephyr,memory-region property, falling back
14+
* to the node path if it doesn't exist.
15+
*
16+
* Example devicetree fragment:
17+
*
18+
* / {
19+
* soc {
20+
* sram1: memory@2000000 {
21+
* zephyr,memory-region = "MY_NAME";
22+
* };
23+
* sram2: memory@2001000 { ... };
24+
* };
25+
* };
26+
*
27+
* Example usage:
28+
*
29+
* LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(sram1)) // "MY_NAME"
30+
* LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(sram2)) // "/soc/memory@2001000"
31+
*
32+
* @param node_id node identifier
33+
* @return the name of the memory memory region the node will generate
34+
*/
35+
#define LINKER_DT_NODE_REGION_NAME(node_id) \
36+
DT_PROP_OR(node_id, zephyr_memory_region, DT_NODE_PATH(node_id))
37+
1038
/* Declare a memory region */
1139
#define _REGION_DECLARE(name, attr, node) name(attr) : \
1240
ORIGIN = DT_REG_ADDR(node), \

0 commit comments

Comments
 (0)