Skip to content

Commit c5b2ebf

Browse files
committed
arch/arm: introduce the pre-stack/RAM init hook
Introduce hook for customize reset.S code even before stack is initialized or RAM is accessed. Hook can be enabled using CONFIG_ARM_SOC_START_HOOK=y. Hook implementation is by soc_start_hook() function which should be provided by custom code. Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 727c15a commit c5b2ebf

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

arch/arm/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ config ARM_ON_EXIT_CPU_IDLE
144144
observed on some SoCs caused by a memory access following WFI/WFE
145145
instructions.
146146

147+
config SOC_PRE_RAM_HOOK
148+
bool "include cpu start hook"
149+
depends on CPU_CORTEX_M
150+
help
151+
This hooks run almost after startup - even before any stack is initiated
152+
or RAM is accessed.
153+
147154
rsource "core/Kconfig"
148155
rsource "core/Kconfig.vfp"
149156

arch/arm/core/cortex_m/reset.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ GTEXT(z_arm_init_arch_hw_at_boot)
3535
#if defined(CONFIG_PM_S2RAM)
3636
GTEXT(arch_pm_s2ram_resume)
3737
#endif
38+
#if defined(CONFIG_SOC_PRE_RAM_HOOK)
39+
GTEXT(soc_pre_ram_hook)
40+
#endif
41+
3842

3943
/*
4044
* PACBTI Mask for CONTROL register:
@@ -100,6 +104,10 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start)
100104

101105
#endif /* CONFIG_INIT_ARCH_HW_AT_BOOT */
102106

107+
#if defined(CONFIG_SOC_PRE_RAM_HOOK)
108+
/* Call custom code that executes before any stack is set up or RAM memory is accessed */
109+
bl soc_pre_ram_hook
110+
#endif
103111
#if defined(CONFIG_PM_S2RAM)
104112
/*
105113
* Temporarily set MSP to interrupt stack so that arch_pm_s2ram_resume can

0 commit comments

Comments
 (0)