linker: macros for memory regions from devicetree
Adds a public macro for creating memory regions from devicetree nodes. `DT_REGION_FROM_NODE_STATUS_OKAY` declares the memory regions for consumption by ld, assuming the node exists and has `status = "okay"`. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
parent
73db443320
commit
3979eda93b
1 changed files with 26 additions and 0 deletions
26
include/linker/devicetree_regions.h
Normal file
26
include/linker/devicetree_regions.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Commonwealth Scientific and Industrial Research
|
||||
* Organisation (CSIRO) ABN 41 687 119 230.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Generate memory regions from devicetree nodes.
|
||||
*/
|
||||
|
||||
/* Declare a memory region */
|
||||
#define _REGION_DECLARE(name, attr, node) name(attr) : \
|
||||
ORIGIN = DT_REG_ADDR(node), \
|
||||
LENGTH = DT_REG_SIZE(node)
|
||||
|
||||
/**
|
||||
* @brief Generate a linker memory region from a devicetree node
|
||||
*
|
||||
* @param name name of the generated memory region
|
||||
* @param attr region attributes to use (rx, rw, ...)
|
||||
* @param node devicetree node with a <reg> property defining region location
|
||||
* and size.
|
||||
*/
|
||||
#define DT_REGION_FROM_NODE_STATUS_OKAY(name, attr, node) \
|
||||
COND_CODE_1(DT_NODE_HAS_STATUS(node, okay), \
|
||||
(_REGION_DECLARE(name, attr, node)), \
|
||||
())
|
Loading…
Add table
Add a link
Reference in a new issue