arch/xtensa: correct the interrupt stack on irq handler

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-12-14 13:55:31 +08:00 committed by Xiang Xiao
parent 51a2db6ffc
commit 93b133fe66
3 changed files with 95 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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