|
39 | 39 |
|
40 | 40 | #define _DT_COMPATIBLE zephyr_memory_region |
41 | 41 |
|
| 42 | +#define _DT_SECTION_NAME(node_id) DT_STRING_TOKEN(node_id, zephyr_memory_region) |
| 43 | +#define _DT_SECTION_PREFIX(node_id) UTIL_CAT(__, _DT_SECTION_NAME(node_id)) |
| 44 | +#define _DT_SECTION_START(node_id) UTIL_CAT(_DT_SECTION_PREFIX(node_id), _start) |
| 45 | +#define _DT_SECTION_END(node_id) UTIL_CAT(_DT_SECTION_PREFIX(node_id), _end) |
| 46 | +#define _DT_SECTION_SIZE(node_id) UTIL_CAT(_DT_SECTION_PREFIX(node_id), _size) |
| 47 | +#define _DT_SECTION_LOAD(node_id) UTIL_CAT(_DT_SECTION_PREFIX(node_id), _load_start) |
| 48 | + |
42 | 49 | /** |
43 | 50 | * @brief Declare a memory region |
44 | 51 | * |
|
50 | 57 | ORIGIN = DT_REG_ADDR(node_id), \ |
51 | 58 | LENGTH = DT_REG_SIZE(node_id) |
52 | 59 |
|
| 60 | +/** |
| 61 | + * @brief Declare a memory section from the device tree nodes with |
| 62 | + * compatible 'zephyr,memory-region' |
| 63 | + * |
| 64 | + * @param node_id devicetree node identifier |
| 65 | + */ |
| 66 | +#define _SECTION_DECLARE(node_id) \ |
| 67 | + _DT_SECTION_NAME(node_id) DT_REG_ADDR(node_id) (NOLOAD) : \ |
| 68 | + { \ |
| 69 | + _DT_SECTION_START(node_id) = .; \ |
| 70 | + KEEP(*(_DT_SECTION_NAME(node_id))) \ |
| 71 | + KEEP(*(_DT_SECTION_NAME(node_id).*)) \ |
| 72 | + _DT_SECTION_END(node_id) = .; \ |
| 73 | + } > _DT_SECTION_NAME(node_id) \ |
| 74 | + _DT_SECTION_SIZE(node_id) = _DT_SECTION_END(node_id) - _DT_SECTION_START(node_id); \ |
| 75 | + _DT_SECTION_LOAD(node_id) = LOADADDR(_DT_SECTION_NAME(node_id)); |
| 76 | + |
53 | 77 | /** @endcond */ |
54 | 78 |
|
55 | 79 | /** |
|
62 | 86 | */ |
63 | 87 | #define LINKER_DT_REGIONS() \ |
64 | 88 | DT_FOREACH_STATUS_OKAY(_DT_COMPATIBLE, _REGION_DECLARE) |
| 89 | + |
| 90 | +/** |
| 91 | + * @brief Generate linker memory sections from the device tree nodes with |
| 92 | + * compatible 'zephyr,memory-region' |
| 93 | + */ |
| 94 | +#define LINKER_DT_SECTIONS() \ |
| 95 | + DT_FOREACH_STATUS_OKAY(_DT_COMPATIBLE, _SECTION_DECLARE) |
0 commit comments