arm/xtensa: save the running registers to xcp context

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an
2022-01-12 11:58:31 +08:00
committed by Xiang Xiao
parent 47f9ec9c45
commit c27839f98e
2 changed files with 28 additions and 37 deletions
+14 -17
View File
@@ -58,12 +58,7 @@
# define CONFIG_BOARD_RESET_ON_ASSERT 0
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_ARCH_STACKDUMP
static uint32_t s_last_regs[XCPTCONTEXT_REGS];
/****************************************************************************
* Private Functions
@@ -96,16 +91,6 @@ static void arm_stackdump(uint32_t sp, uint32_t stack_top)
static void arm_registerdump(FAR volatile uint32_t *regs)
{
/* Are user registers available from interrupt processing? */
if (regs == NULL)
{
/* No.. capture user registers by hand */
arm_saveusercontext(s_last_regs);
regs = s_last_regs;
}
/* Dump the interrupt registers */
_alert("R0: %08x R1: %08x R2: %08x R3: %08x\n",
@@ -368,9 +353,21 @@ static void arm_dumpstate(void)
sched_dumpstack(rtcb->pid);
#endif
/* Dump the registers (if available) */
/* Update the xcp context */
arm_registerdump(CURRENT_REGS);
if (CURRENT_REGS)
{
memcpy(rtcb->xcp.regs,
(FAR uintptr_t *)CURRENT_REGS, XCPTCONTEXT_SIZE);
}
else
{
arm_saveusercontext(rtcb->xcp.regs);
}
/* Dump the registers */
arm_registerdump(rtcb->xcp.regs);
/* Dump the irq stack */
+14 -20
View File
@@ -42,12 +42,6 @@
#ifdef CONFIG_DEBUG_ALERT
/****************************************************************************
* Private Data
****************************************************************************/
static uint32_t s_last_regs[XCPTCONTEXT_REGS];
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -238,20 +232,8 @@ static void xtensa_stackdump(uint32_t sp, uint32_t stack_top)
* Name: xtensa_registerdump
****************************************************************************/
static inline void xtensa_registerdump(void)
static inline void xtensa_registerdump(uintptr_t *regs)
{
uint32_t *regs = (uint32_t *)CURRENT_REGS; /* Don't need volatile here */
/* Are user registers available from interrupt processing? */
if (regs == NULL)
{
/* No.. capture user registers by hand */
xtensa_context_save(s_last_regs);
regs = s_last_regs;
}
_alert(" PC: %08lx PS: %08lx\n",
(unsigned long)regs[REG_PC], (unsigned long)regs[REG_PS]);
_alert(" A0: %08lx A1: %08lx A2: %08lx A3: %08lx\n",
@@ -301,9 +283,21 @@ void xtensa_dumpstate(void)
_alert("CPU%d:\n", up_cpu_index());
#endif
/* Update the xcp context */
if (CURRENT_REGS)
{
memcpy(rtcb->xcp.regs,
(uintptr_t *)CURRENT_REGS, XCPTCONTEXT_REGS);
}
else
{
xtensa_context_save(rtcb->xcp.regs);
}
/* Dump the registers (if available) */
xtensa_registerdump();
xtensa_registerdump(rtcb->xcp.regs);
/* Dump the backtrace */