From 01882b86243038982cc65cfd2ef9633182e31604 Mon Sep 17 00:00:00 2001 From: Immo Birnbaum Date: Thu, 15 Jul 2021 13:15:53 +0200 Subject: [PATCH] arch: arm: core: aarch32: support for On-Chip Memory (OCM) areas in aarch32 Introduce support for On-Chip Memory (OCM) areas in aarch32 Cortex-A SoCs. This memory area is suitable for, amongst other things, un- cached device DMA. The OCM memory can reside either at address zero or at a high memory address, with configuration of the memory's lo- cation similar to the configuration of the location of the exception vectors. In both cases, it must be assured that the low/high OCM area declaration doesn't overlap with the exception vectors memory page at either the low/high address. Therefore, all possible OCM location options shall be described in the SoC's device tree, the current location shall be indicated via a "chosen" entry in the target board's device tree. This commit contains the necessary changes to the linker-related files as well as the static region declaration for the MMU in- itialization in the Zynq-7000 SoC-specific init code. Signed-off-by: Immo Birnbaum --- .../arm/aarch32/cortex_a_r/scripts/linker.ld | 28 +++++++++++++++++++ include/linker/linker-defs.h | 6 ++++ include/linker/section_tags.h | 2 ++ include/linker/sections.h | 7 +++-- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld b/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld index 49ee3467b8a..2ed81f197bf 100644 --- a/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -80,6 +81,7 @@ MEMORY { FLASH (rx) : ORIGIN = ROM_ADDR, LENGTH = ROM_SIZE SRAM (wx) : ORIGIN = RAM_ADDR, LENGTH = RAM_SIZE + LINKER_DT_REGION_FROM_NODE(OCM, rw, DT_CHOSEN(zephyr_ocm)) /* Used by and documented in include/linker/intlist.ld */ IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K } @@ -340,6 +342,32 @@ SECTIONS GROUP_END(RAMABLE_REGION) +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ocm), okay) +GROUP_START(OCM) + + SECTION_PROLOGUE(_OCM_BSS_SECTION_NAME, (NOLOAD),SUBALIGN(4)) + { + __ocm_start = .; + __ocm_bss_start = .; + *(.ocm_bss) + *(".ocm_bss.*") + __ocm_bss_end = .; + } GROUP_LINK_IN(OCM) + + SECTION_PROLOGUE(_OCM_DATA_SECTION_NAME,,SUBALIGN(4)) + { + __ocm_data_start = .; + *(.ocm_data) + *(".ocm_data.*") + __ocm_data_end = .; + } GROUP_LINK_IN(OCM) + + __ocm_end = .; + __ocm_size = __ocm_end - __ocm_start; + +GROUP_END(OCM) +#endif + /* Located in generated directory. This file is populated by the * zephyr_linker_sources() Cmake function. */ diff --git a/include/linker/linker-defs.h b/include/linker/linker-defs.h index b005e99428b..58ebb424e2f 100644 --- a/include/linker/linker-defs.h +++ b/include/linker/linker-defs.h @@ -306,6 +306,12 @@ extern char __dtcm_start[]; extern char __dtcm_end[]; #endif +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ocm), okay) +extern char __ocm_start[]; +extern char __ocm_end[]; +extern char __ocm_size[]; +#endif + /* Used by the Security Attribution Unit to configure the * Non-Secure Callable region. */ diff --git a/include/linker/section_tags.h b/include/linker/section_tags.h index f2d7593a65b..12b1378f872 100644 --- a/include/linker/section_tags.h +++ b/include/linker/section_tags.h @@ -28,6 +28,8 @@ #define __dtcm_data_section Z_GENERIC_SECTION(_DTCM_DATA_SECTION_NAME) #define __dtcm_bss_section Z_GENERIC_SECTION(_DTCM_BSS_SECTION_NAME) #define __dtcm_noinit_section Z_GENERIC_SECTION(_DTCM_NOINIT_SECTION_NAME) +#define __ocm_data_section Z_GENERIC_SECTION(_OCM_DATA_SECTION_NAME) +#define __ocm_bss_section Z_GENERIC_SECTION(_OCM_BSS_SECTION_NAME) #define __imx_boot_conf_section Z_GENERIC_SECTION(_IMX_BOOT_CONF_SECTION_NAME) #define __imx_boot_data_section Z_GENERIC_SECTION(_IMX_BOOT_DATA_SECTION_NAME) #define __imx_boot_ivt_section Z_GENERIC_SECTION(_IMX_BOOT_IVT_SECTION_NAME) diff --git a/include/linker/sections.h b/include/linker/sections.h index 49cf558776a..0bab1b8a595 100644 --- a/include/linker/sections.h +++ b/include/linker/sections.h @@ -42,7 +42,7 @@ /* Architecture-specific sections */ #if defined(CONFIG_ARM) #define _KINETIS_FLASH_CONFIG_SECTION_NAME kinetis_flash_config -#define _TI_CCFG_SECTION_NAME .ti_ccfg +#define _TI_CCFG_SECTION_NAME .ti_ccfg #define _CCM_DATA_SECTION_NAME .ccm_data #define _CCM_BSS_SECTION_NAME .ccm_bss @@ -50,9 +50,12 @@ #define _ITCM_SECTION_NAME .itcm -#define _DTCM_DATA_SECTION_NAME .dtcm_data +#define _DTCM_DATA_SECTION_NAME .dtcm_data #define _DTCM_BSS_SECTION_NAME .dtcm_bss #define _DTCM_NOINIT_SECTION_NAME .dtcm_noinit + +#define _OCM_DATA_SECTION_NAME .ocm_data +#define _OCM_BSS_SECTION_NAME .ocm_bss #endif #define _IMX_BOOT_CONF_SECTION_NAME .boot_hdr.conf