Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
devicetree_regions.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021, Commonwealth Scientific and Industrial Research
3 * Organisation (CSIRO) ABN 41 687 119 230.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Generate memory regions from devicetree nodes.
8 */
9
10#ifndef ZEPHYR_INCLUDE_LINKER_DEVICETREE_REGIONS_H_
11#define ZEPHYR_INCLUDE_LINKER_DEVICETREE_REGIONS_H_
12
13#include <zephyr/devicetree.h>
14#include <zephyr/sys/util.h>
15#include <zephyr/toolchain.h>
16
48#define LINKER_DT_NODE_REGION_NAME_TOKEN(node_id) \
49 DT_STRING_TOKEN(node_id, zephyr_memory_region)
50
82#define LINKER_DT_NODE_REGION_NAME(node_id) \
83 STRINGIFY(LINKER_DT_NODE_REGION_NAME_TOKEN(node_id))
84
85#define _DT_MEMORY_REGION_FLAGS_TOKEN(n) DT_STRING_TOKEN(n, zephyr_memory_region_flags)
86#define _DT_MEMORY_REGION_FLAGS_UNQUOTED(n) DT_STRING_UNQUOTED(n, zephyr_memory_region_flags)
87
88#define _LINKER_L_PAREN (
89#define _LINKER_R_PAREN )
90#define _LINKER_ENCLOSE_PAREN(x) _LINKER_L_PAREN x _LINKER_R_PAREN
91
92#define _LINKER_IS_EMPTY_TOKEN_ 1
93#define _LINKER_IS_EMPTY_TOKEN_EXPAND(x) _LINKER_IS_EMPTY_TOKEN_##x
94#define _LINKER_IS_EMPTY_TOKEN(x) _LINKER_IS_EMPTY_TOKEN_EXPAND(x)
95
136#define LINKER_DT_NODE_REGION_FLAGS(node_id) \
137 COND_CODE_1(DT_NODE_HAS_PROP(node_id, zephyr_memory_region_flags), \
138 (COND_CODE_1(_LINKER_IS_EMPTY_TOKEN(_DT_MEMORY_REGION_FLAGS_TOKEN(node_id)), \
139 (), \
140 (_LINKER_ENCLOSE_PAREN( \
141 _DT_MEMORY_REGION_FLAGS_UNQUOTED(node_id)) \
142 ))), \
143 (_LINKER_ENCLOSE_PAREN(rw)))
144
147#define _DT_COMPATIBLE zephyr_memory_region
148
149#define _DT_SECTION_PREFIX(node_id) UTIL_CAT(__, LINKER_DT_NODE_REGION_NAME_TOKEN(node_id))
150#define _DT_SECTION_START(node_id) UTIL_CAT(_DT_SECTION_PREFIX(node_id), _start)
151#define _DT_SECTION_END(node_id) UTIL_CAT(_DT_SECTION_PREFIX(node_id), _end)
152#define _DT_SECTION_SIZE(node_id) UTIL_CAT(_DT_SECTION_PREFIX(node_id), _size)
153#define _DT_SECTION_LOAD(node_id) UTIL_CAT(_DT_SECTION_PREFIX(node_id), _load_start)
154
178#define _REGION_DECLARE(node_id) \
179 LINKER_DT_NODE_REGION_NAME_TOKEN(node_id) \
180 LINKER_DT_NODE_REGION_FLAGS(node_id) \
181 : ORIGIN = DT_REG_ADDR(node_id), \
182 LENGTH = DT_REG_SIZE(node_id)
183
214#define _SECTION_DECLARE(node_id) \
215 LINKER_DT_NODE_REGION_NAME_TOKEN(node_id) (NOLOAD) : \
216 { \
217 _DT_SECTION_START(node_id) = .; \
218 KEEP(*(LINKER_DT_NODE_REGION_NAME_TOKEN(node_id))) \
219 KEEP(*(LINKER_DT_NODE_REGION_NAME_TOKEN(node_id).*)) \
220 _DT_SECTION_END(node_id) = .; \
221 } > LINKER_DT_NODE_REGION_NAME_TOKEN(node_id) \
222 _DT_SECTION_SIZE(node_id) = _DT_SECTION_END(node_id) - _DT_SECTION_START(node_id); \
223 _DT_SECTION_LOAD(node_id) = LOADADDR(LINKER_DT_NODE_REGION_NAME_TOKEN(node_id));
224
235#define LINKER_DT_REGIONS() \
236 DT_FOREACH_STATUS_OKAY(_DT_COMPATIBLE, _REGION_DECLARE)
237
242#define LINKER_DT_SECTIONS() \
243 DT_FOREACH_STATUS_OKAY(_DT_COMPATIBLE, _SECTION_DECLARE)
244
245#endif /* ZEPHYR_INCLUDE_LINKER_DEVICETREE_REGIONS_H_ */
Devicetree main header.
Misc utilities.
Macros to abstract toolchain specific capabilities.