xtensa: fix up_saveusercontext in interrupt context

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
This commit is contained in:
chenxiaoyi
2024-08-21 12:23:36 +08:00
committed by Xiang Xiao
parent 02c292a25a
commit 45f4ce84ad
@@ -24,9 +24,11 @@
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <nuttx/nuttx.h>
#include <string.h>
#include <arch/irq.h>
#include <arch/syscall.h>
/****************************************************************************
@@ -51,9 +53,47 @@ int up_saveusercontext(void *saveregs)
{
if (up_interrupt_context())
{
/* TODO: save interrupt context */
memset(saveregs, 0x0, XCPTCONTEXT_SIZE);
__asm__ __volatile__
(
" s32i a0, %0, (4 * " STRINGIFY(REG_A0) ")\n"
" s32i a1, %0, (4 * " STRINGIFY(REG_A1) ")\n"
" s32i a2, %0, (4 * " STRINGIFY(REG_A2) ")\n"
" s32i a3, %0, (4 * " STRINGIFY(REG_A3) ")\n"
" movi a2, 1f\n"
"1: s32i a2, %0, (4 * " STRINGIFY(REG_PC) ")\n"
" rsr a2, PS\n"
" s32i a2, %0, (4 * " STRINGIFY(REG_PS) ")\n"
" s32i a4, %0, (4 * " STRINGIFY(REG_A4) ")\n"
" s32i a5, %0, (4 * " STRINGIFY(REG_A5) ")\n"
" s32i a6, %0, (4 * " STRINGIFY(REG_A6) ")\n"
" s32i a7, %0, (4 * " STRINGIFY(REG_A7) ")\n"
" s32i a8, %0, (4 * " STRINGIFY(REG_A8) ")\n"
" s32i a9, %0, (4 * " STRINGIFY(REG_A9) ")\n"
" s32i a10, %0, (4 * " STRINGIFY(REG_A10) ")\n"
" s32i a11, %0, (4 * " STRINGIFY(REG_A11) ")\n"
#ifndef __XTENSA_CALL0_ABI__
" s32i a12, %0, (4 * " STRINGIFY(REG_A12) ")\n"
" s32i a13, %0, (4 * " STRINGIFY(REG_A13) ")\n"
" s32i a14, %0, (4 * " STRINGIFY(REG_A14) ")\n"
" s32i a15, %0, (4 * " STRINGIFY(REG_A15) ")\n"
#endif
" rsr a2, SAR\n"
" s32i a2, %0, (4 * " STRINGIFY(REG_SAR) ")\n"
#if XCHAL_HAVE_S32C1I != 0
" rsr a2, SCOMPARE1\n"
" s32i a2, %0, (4 * " STRINGIFY(REG_SCOMPARE1) ")\n"
#endif
#if XCHAL_HAVE_LOOPS != 0
" rsr a2, LBEG\n"
" s32i a2, %0, (4 * " STRINGIFY(REG_LBEG) ")\n"
" rsr a2, LEND\n"
" s32i a2, %0, (4 * " STRINGIFY(REG_LEND) ")\n"
" rsr a2, LCOUNT\n"
" s32i a2, %0, (4 * " STRINGIFY(REG_LCOUNT) ")\n"
#endif
:
: "a" (saveregs)
);
return 0;
}