arch: xtensa: save current SP before overwrting

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-12-14 17:34:56 +08:00 committed by Xiang Xiao
parent 93b133fe66
commit 2fe06ac083
1 changed files with 10 additions and 3 deletions

View File

@ -225,6 +225,12 @@ _xtensa_user_handler:
mov a2, sp /* Address of state save on stack */
call0 _xtensa_context_save /* Save full register state */
/* Save current SP before (possibly) overwriting it,
* it's the register save area.
*/
mov a12, sp
/* Switch to an interrupt stack if we have one */
#if CONFIG_ARCH_INTERRUPTSTACK > 15
@ -271,17 +277,18 @@ _xtensa_user_handler:
#ifdef __XTENSA_CALL0_ABI__
rsr a2, EXCCAUSE /* Argument 1 (a2) = EXCCAUSE */
mov a3, sp /* Argument 2 (a3) = pointer to register save area */
mov a3, a12 /* Argument 2 (a3) = pointer to register save area */
calx0 xtensa_user /* Call xtensa_user */
#else
rsr a6, EXCCAUSE /* Argument 1 (a6) = EXCCAUSE */
mov a7, sp /* Argument 2 (a7) = pointer to register save area */
mov a7, a12 /* Argument 2 (a7) = pointer to register save area */
call4 xtensa_user /* Call xtensa_user */
mov a2, a6
mov a12, a6
#endif
/* Restore registers in preparation to return from interrupt */
mov a2, a12 /* a2 = address of new state save area */
call0 _xtensa_context_restore /* (Preserves a2) */
/* Restore only level-specific regs (the rest were already restored) */