You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/01/14 18:20:17 UTC

[incubator-nuttx] 01/02: arm/xtensa: save the running registers to xcp context

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit c27839f98e5b00e06a820fed757cbaa24036767f
Author: chao.an <an...@xiaomi.com>
AuthorDate: Wed Jan 12 11:58:31 2022 +0800

    arm/xtensa: save the running registers to xcp context
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 arch/arm/src/common/arm_assert.c          | 31 +++++++++++++---------------
 arch/xtensa/src/common/xtensa_dumpstate.c | 34 +++++++++++++------------------
 2 files changed, 28 insertions(+), 37 deletions(-)

diff --git a/arch/arm/src/common/arm_assert.c b/arch/arm/src/common/arm_assert.c
index 6c1abb7..2d09aed 100644
--- a/arch/arm/src/common/arm_assert.c
+++ b/arch/arm/src/common/arm_assert.c
@@ -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 */
+
+  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(CURRENT_REGS);
+  arm_registerdump(rtcb->xcp.regs);
 
   /* Dump the irq stack */
 
diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c
index 8ed7bf8..39e6629 100644
--- a/arch/xtensa/src/common/xtensa_dumpstate.c
+++ b/arch/xtensa/src/common/xtensa_dumpstate.c
@@ -43,12 +43,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 */