From a49817d17e76ec83a0faef60f6dc91fad26d22b1 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 23 Apr 2020 17:51:08 -0500 Subject: [PATCH] arm: Convert DT_DTCM_* to new devicetree.h macros Convert various DT_DTCM_* macros to use DT_CHOSEN(zephyr_dtcm) and associated macros from devicetree.h. Signed-off-by: Kumar Gala --- drivers/ethernet/eth_stm32_hal.c | 6 +++--- .../arch/arm/aarch32/cortex_m/scripts/linker.ld | 8 ++++---- include/linker/linker-defs.h | 14 ++++++++++++-- kernel/init.c | 4 ++-- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/ethernet/eth_stm32_hal.c b/drivers/ethernet/eth_stm32_hal.c index c48c998e88a..7cc055fc32f 100644 --- a/drivers/ethernet/eth_stm32_hal.c +++ b/drivers/ethernet/eth_stm32_hal.c @@ -27,12 +27,12 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include "eth_stm32_hal_priv.h" #if defined(CONFIG_ETH_STM32_HAL_USE_DTCM_FOR_DMA_BUFFER) && \ - !defined(DT_DTCM_BASE_ADDRESS) -#error DTCM for DMA buffer is activated but DT_DTCM_BASE_ADDRESS is not present + !DT_HAS_NODE(DT_CHOSEN(zephyr_dtcm)) +#error DTCM for DMA buffer is activated but zephyr,dtcm is not present in dts #endif #if defined(CONFIG_ETH_STM32_HAL_USE_DTCM_FOR_DMA_BUFFER) && \ - defined(DT_DTCM_BASE_ADDRESS) + DT_HAS_NODE(DT_CHOSEN(zephyr_dtcm)) static ETH_DMADescTypeDef dma_rx_desc_tab[ETH_RXBUFNB] __dtcm_noinit_section; static ETH_DMADescTypeDef dma_tx_desc_tab[ETH_TXBUFNB] __dtcm_noinit_section; static u8_t dma_rx_buffer[ETH_RXBUFNB][ETH_RX_BUF_SIZE] __dtcm_noinit_section; diff --git a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld index 6ffe5f126cd..92e80ee97fb 100644 --- a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld @@ -98,8 +98,8 @@ MEMORY #ifdef DT_CCM_BASE_ADDRESS CCM (rw) : ORIGIN = DT_CCM_BASE_ADDRESS, LENGTH = DT_CCM_SIZE * 1K #endif -#ifdef DT_DTCM_BASE_ADDRESS - DTCM (rw) : ORIGIN = DT_DTCM_BASE_ADDRESS, LENGTH = DT_DTCM_SIZE * 1K +#if DT_HAS_NODE(DT_CHOSEN(zephyr_dtcm)) + DTCM (rw) : ORIGIN = DT_REG_ADDR(DT_CHOSEN(zephyr_dtcm)), LENGTH = DT_REG_SIZE(DT_CHOSEN(zephyr_dtcm)) #endif SRAM (wx) : ORIGIN = RAM_ADDR, LENGTH = RAM_SIZE #ifdef CONFIG_BT_STM32_IPM @@ -388,7 +388,7 @@ SECTIONS GROUP_END(RAMABLE_REGION) -#ifdef DT_DTCM_BASE_ADDRESS +#if DT_HAS_NODE(DT_CHOSEN(zephyr_dtcm)) GROUP_START(DTCM) SECTION_PROLOGUE(_DTCM_BSS_SECTION_NAME, (NOLOAD),SUBALIGN(4)) @@ -423,7 +423,7 @@ GROUP_START(DTCM) __dtcm_data_rom_start = LOADADDR(_DTCM_DATA_SECTION_NAME); GROUP_END(DTCM) -#endif /* DT_DTCM_BASE_ADDRESS */ +#endif #ifdef CONFIG_CUSTOM_SECTIONS_LD /* Located in project source directory */ #include diff --git a/include/linker/linker-defs.h b/include/linker/linker-defs.h index 23e3b5e3b9a..8b2549e0313 100644 --- a/include/linker/linker-defs.h +++ b/include/linker/linker-defs.h @@ -24,6 +24,16 @@ #include #include +/* We need to dummy out DT_HAS_NODE when building the unittests since including + * devicetree.h would require generating dummy header files to match what the + * generate creates, so its easier to just dummy out DT_HAS_NODE. + */ +#ifdef ZTEST_UNITTEST +#define DT_HAS_NODE(x) 0 +#else +#include +#endif + #ifdef _LINKER @@ -217,7 +227,7 @@ extern char __ccm_noinit_end[]; extern char __ccm_end[]; #endif /* DT_CCM_BASE_ADDRESS */ -#ifdef DT_DTCM_BASE_ADDRESS +#if DT_HAS_NODE(DT_CHOSEN(zephyr_dtcm)) extern char __dtcm_data_start[]; extern char __dtcm_data_end[]; extern char __dtcm_bss_start[]; @@ -227,7 +237,7 @@ extern char __dtcm_noinit_end[]; extern char __dtcm_data_rom_start[]; extern char __dtcm_start[]; extern char __dtcm_end[]; -#endif /* DT_DTCM_BASE_ADDRESS */ +#endif /* Used by the Security Attribution Unit to configure the * Non-Secure Callable region. diff --git a/kernel/init.c b/kernel/init.c index e5877d7c7e2..fecbb73b6e5 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -110,7 +110,7 @@ void z_bss_zero(void) (void)memset(&__ccm_bss_start, 0, ((u32_t) &__ccm_bss_end - (u32_t) &__ccm_bss_start)); #endif -#ifdef DT_DTCM_BASE_ADDRESS +#if DT_HAS_NODE(DT_CHOSEN(zephyr_dtcm)) (void)memset(&__dtcm_bss_start, 0, ((u32_t) &__dtcm_bss_end - (u32_t) &__dtcm_bss_start)); #endif @@ -151,7 +151,7 @@ void z_data_copy(void) (void)memcpy(&__ccm_data_start, &__ccm_data_rom_start, __ccm_data_end - __ccm_data_start); #endif -#ifdef DT_DTCM_BASE_ADDRESS +#if DT_HAS_NODE(DT_CHOSEN(zephyr_dtcm)) (void)memcpy(&__dtcm_data_start, &__dtcm_data_rom_start, __dtcm_data_end - __dtcm_data_start); #endif