From 0c9268784e138f665e896ec313a91d122e012174 Mon Sep 17 00:00:00 2001 From: Benjamin Walsh Date: Mon, 21 Nov 2016 12:11:18 -0500 Subject: [PATCH] arm: support interrupt stack with CONFIG_INIT_STACKS Use the main stack during very early boot so that we can call memset on the interrupt stack. Initialize the interrupt stack before it is used for the rest of the pre-kernel initialization. Change-Id: I6fcc9a08678afdb82e83465cda1c7a2a8c849c9b Signed-off-by: Benjamin Walsh --- arch/arm/core/cortex_m/reset.S | 8 ++++++++ arch/arm/core/cortex_m/vector_table.S | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/arm/core/cortex_m/reset.S b/arch/arm/core/cortex_m/reset.S index dedb5f0982f..564d0a2c1a9 100644 --- a/arch/arm/core/cortex_m/reset.S +++ b/arch/arm/core/cortex_m/reset.S @@ -33,6 +33,7 @@ _ASM_FILE_PROLOGUE GTEXT(__reset) +GTEXT(memset) GDATA(_interrupt_stack) /** @@ -78,6 +79,13 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start) msr BASEPRI, r0 #endif +#ifdef CONFIG_INIT_STACKS + ldr r0, =_interrupt_stack + mov r1, #0xaa + ldr r2, =CONFIG_ISR_STACK_SIZE + bl memset +#endif + /* * Set PSP and use it to boot without using MSP, so that it * gets set to _interrupt_stack during nanoInit(). diff --git a/arch/arm/core/cortex_m/vector_table.S b/arch/arm/core/cortex_m/vector_table.S index 240b3a07c76..c9f725ba743 100644 --- a/arch/arm/core/cortex_m/vector_table.S +++ b/arch/arm/core/cortex_m/vector_table.S @@ -36,6 +36,8 @@ _ASM_FILE_PROLOGUE +GDATA(_main_stack) + SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table) /* in XIP kernels. the entry point is also the start of the vector table */ @@ -43,7 +45,13 @@ SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,_vector_table) SECTION_SUBSEC_FUNC(exc_vector_table,_vector_table_section,__start) #endif - .word 0 /* no need for a stack, the kernel sets one up before running C */ + /* + * setting the _very_ early boot on the main stack allows to use memset + * on the interrupt stack when CONFIG_INIT_STACKS is enabled before + * switching to the interrupt stack for the rest of the early boot + */ + .word _main_stack + CONFIG_MAIN_STACK_SIZE + .word __reset .word __nmi