soc: nordic: Provide z_arm_platform_init at link time
Nordic SoCs use this hook to execute `SystemInit` as early as possible after ARM core reset. Previously, `z_arm_platform_init` was defined as assembly code, which would simply jump to the other function. However, this extra code can be avoided by using `SystemInit` directly in place of the `z_arm_platform_init` symbol (whenever it's undefined). This is now done with a linker script containing a `PROVIDE` directive. This saves 4 bytes of ROM (0-16 depending on alignment) and also makes it possible to override `z_arm_platform_init` out of tree, if needed. Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
parent
027a1c30cd
commit
7d45f3c92a
5 changed files with 24 additions and 47 deletions
|
@ -2,14 +2,12 @@
|
|||
|
||||
zephyr_library()
|
||||
|
||||
if(CONFIG_ARM)
|
||||
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "SoC Linker script")
|
||||
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "SoC Linker script")
|
||||
|
||||
zephyr_library_sources(
|
||||
zephyr_library_sources(
|
||||
validate_base_addresses.c
|
||||
validate_enabled_instances.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_HAS_TIMING_FUNCTIONS AND NOT CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
|
||||
if(CONFIG_TIMING_FUNCTIONS)
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
|
||||
add_subdirectory_ifdef(CONFIG_RISCV_CORE_NORDIC_VPR vpr)
|
||||
|
||||
if(CONFIG_ARM AND CONFIG_SOC_FAMILY_NORDIC_NRF)
|
||||
zephyr_library_sources(soc_nrf_common.S)
|
||||
endif()
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c)
|
||||
|
||||
zephyr_include_directories(.)
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief System/hardware module for Nordic Semiconductor nRFxx family processors
|
||||
*/
|
||||
|
||||
#include <zephyr/toolchain.h>
|
||||
#include <zephyr/linker/sections.h>
|
||||
|
||||
_ASM_FILE_PROLOGUE
|
||||
|
||||
GTEXT(SystemInit)
|
||||
GTEXT(z_arm_platform_init)
|
||||
|
||||
SECTION_FUNC(TEXT, z_arm_platform_init)
|
||||
|
||||
/* Implement z_arm_platform_init() directly in ASM,
|
||||
* and ensure no stack access is performed until
|
||||
* we jump to SystemInit().
|
||||
*/
|
||||
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
|
||||
ldr r0, =SystemInit
|
||||
bx r0
|
||||
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
|
||||
b SystemInit
|
||||
#else
|
||||
#error "Unsupported architecture"
|
||||
#endif
|
||||
/* Return occurs via SystemInit */
|
|
@ -4,5 +4,3 @@
|
|||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_library_sources(soc_idle.c soc_irq.S soc_irq.c vector.S)
|
||||
|
||||
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/riscv/common/linker.ld CACHE INTERNAL "")
|
||||
|
|
19
soc/nordic/linker.ld
Normal file
19
soc/nordic/linker.ld
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ARM)
|
||||
#include <zephyr/arch/arm/cortex_m/scripts/linker.ld>
|
||||
|
||||
/* Let SystemInit() be called in place of z_arm_platform_init() by default. */
|
||||
PROVIDE(z_arm_platform_init = SystemInit);
|
||||
|
||||
#elif defined(CONFIG_RISCV)
|
||||
#include <zephyr/arch/riscv/common/linker.ld>
|
||||
|
||||
#else
|
||||
#error Unsupported architecture
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue