diff --git a/arch/xtensa/src/common/xtensa_int_handlers.S b/arch/xtensa/src/common/xtensa_int_handlers.S index 458cb784008..c544b511132 100644 --- a/arch/xtensa/src/common/xtensa_int_handlers.S +++ b/arch/xtensa/src/common/xtensa_int_handlers.S @@ -104,14 +104,15 @@ g_intstacktop: addi \aout, \aout, 1 /* Return aout + 1 */ .endm -/************************************************************************************ +/**************************************************************************** * Name: setintstack * * Description: - * Set the current stack pointer to the "top" the interrupt stack. Single CPU - * case. Must be provided by MCU-specific logic in the SMP case. + * Set the current stack pointer to the "top" the interrupt stack. + * Single CPU case. + * Must be provided by MCU-specific logic in the SMP case. * - ************************************************************************************/ + ****************************************************************************/ #if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 .macro setintstack tmp1 tmp2 @@ -423,6 +424,12 @@ _xtensa_level2_handler: mov a12, sp + /* Switch to an interrupt stack if we have one */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + setintstack a13 a14 +#endif + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ ps_setup 2 a0 @@ -495,6 +502,12 @@ _xtensa_level3_handler: mov a12, sp + /* Switch to an interrupt stack if we have one */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + setintstack a13 a14 +#endif + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ ps_setup 3 a0 @@ -567,6 +580,12 @@ _xtensa_level4_handler: mov a12, sp + /* Switch to an interrupt stack if we have one */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + setintstack a13 a14 +#endif + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ ps_setup 4 a0 @@ -639,6 +658,12 @@ _xtensa_level5_handler: mov a12, sp + /* Switch to an interrupt stack if we have one */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + setintstack a13 a14 +#endif + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ ps_setup 5 a0 @@ -711,6 +736,12 @@ _xtensa_level6_handler: mov a12, sp + /* Switch to an interrupt stack if we have one */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + setintstack a13 a14 +#endif + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ ps_setup 6 a0 diff --git a/arch/xtensa/src/common/xtensa_panic.S b/arch/xtensa/src/common/xtensa_panic.S index 172c49af5c1..8d0f0979462 100644 --- a/arch/xtensa/src/common/xtensa_panic.S +++ b/arch/xtensa/src/common/xtensa_panic.S @@ -66,6 +66,26 @@ #include "chip.h" +/**************************************************************************** + * Assembly Language Macros + ****************************************************************************/ + +/**************************************************************************** + * Name: setintstack + * + * Description: + * Set the current stack pointer to the "top" the interrupt stack. + * Single CPU case. + * Must be provided by MCU-specific logic in the SMP case. + * + ****************************************************************************/ + +#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 + .macro setintstack tmp1 tmp2 + movi a1, g_intstacktop + .endm +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -109,6 +129,12 @@ _xtensa_panic: mov a2, sp /* Address of state save on stack */ call0 _xtensa_context_save /* Save full register state */ + /* Switch to an interrupt stack if we have one */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + setintstack a13 a14 +#endif + /* Save exc cause and vaddr into exception frame */ rsr a0, EXCCAUSE diff --git a/arch/xtensa/src/common/xtensa_user_handler.S b/arch/xtensa/src/common/xtensa_user_handler.S index 7c6a7cdab1b..895f3e27b1c 100644 --- a/arch/xtensa/src/common/xtensa_user_handler.S +++ b/arch/xtensa/src/common/xtensa_user_handler.S @@ -70,6 +70,22 @@ * Assembly Language Macros ****************************************************************************/ +/**************************************************************************** + * Name: setintstack + * + * Description: + * Set the current stack pointer to the "top" the interrupt stack. + * Single CPU case. + * Must be provided by MCU-specific logic in the SMP case. + * + ****************************************************************************/ + +#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 + .macro setintstack tmp1 tmp2 + movi a1, g_intstacktop + .endm +#endif + /**************************************************************************** * Macro: ps_setup * @@ -209,6 +225,12 @@ _xtensa_user_handler: mov a2, sp /* Address of state save on stack */ call0 _xtensa_context_save /* Save full register state */ + /* Switch to an interrupt stack if we have one */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + setintstack a13 a14 +#endif + /* Save exc cause and vaddr into exception frame */ rsr a0, EXCCAUSE @@ -361,6 +383,12 @@ _xtensa_syscall_handler: mov a2, sp /* Address of state save on stack */ call0 _xtensa_context_save /* Save full register state */ + /* Switch to an interrupt stack if we have one */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + setintstack a13 a14 +#endif + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ ps_setup 1 a0 @@ -484,6 +512,12 @@ _xtensa_coproc_handler: mov a2, sp /* Address of state save on stack */ call0 _xtensa_context_save /* Save full register state */ + /* Switch to an interrupt stack if we have one */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + setintstack a13 a14 +#endif + /* Save exc cause and vaddr into exception frame */ rsr a0, EXCCAUSE