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/nuttx.git

commit 03af486d689825bb3f7015c64475877d6c0d014d
Author: hujun5 <[email protected]>
AuthorDate: Wed Nov 20 14:41:25 2024 +0800

    arm: remove up_set_current_regs/up_current_regs
    
    reason:
    up_set_current_regs initially had two functions:
    
    1: To mark the entry into an interrupt state.
    2: To record the context before an interrupt/exception. If we switch to
       a new task, we need to store the upcoming context regs by calling 
up_set_current_regs(regs).
    
    Currently, we record the context in other ways, so the second function is 
obsolete.
    Therefore, we need to rename up_set_current_regs to better reflect its 
actual meaning,
    which is solely to mark an interrupt.
    
    Signed-off-by: hujun5 <[email protected]>
---
 arch/arm/include/irq.h                | 14 ++++-----
 arch/arm/include/tlsr82/irq.h         |  2 ++
 arch/arm/src/arm/arm_sigdeliver.c     |  4 +--
 arch/arm/src/arm/arm_syscall.c        | 39 -----------------------
 arch/arm/src/armv6-m/arm_sigdeliver.c |  5 ++-
 arch/arm/src/armv6-m/arm_svcall.c     | 58 ++++++++---------------------------
 arch/arm/src/armv7-a/arm_sigdeliver.c |  4 ++-
 arch/arm/src/armv7-a/arm_syscall.c    | 40 ------------------------
 arch/arm/src/armv7-m/arm_sigdeliver.c |  6 +++-
 arch/arm/src/armv7-m/arm_svcall.c     | 58 ++++++++---------------------------
 arch/arm/src/armv7-r/arm_sigdeliver.c |  4 ++-
 arch/arm/src/armv7-r/arm_syscall.c    | 39 -----------------------
 arch/arm/src/armv8-m/arm_sigdeliver.c |  5 ++-
 arch/arm/src/armv8-m/arm_svcall.c     | 58 ++++++++---------------------------
 arch/arm/src/armv8-r/arm_sigdeliver.c |  4 ++-
 arch/arm/src/armv8-r/arm_syscall.c    | 39 -----------------------
 arch/arm/src/common/arm_exit.c        | 10 +-----
 arch/arm/src/common/arm_internal.h    |  5 +--
 arch/arm/src/tlsr82/Make.defs         |  2 --
 19 files changed, 71 insertions(+), 325 deletions(-)

diff --git a/arch/arm/include/irq.h b/arch/arm/include/irq.h
index d6fd08cddd..6f96b99511 100644
--- a/arch/arm/include/irq.h
+++ b/arch/arm/include/irq.h
@@ -82,13 +82,13 @@
 #ifndef __ASSEMBLY__
 
 #ifndef up_switch_context
-#define up_switch_context(tcb, rtcb)                              \
-  do {                                                            \
-    if (!up_interrupt_context())                                  \
-      {                                                           \
-        sys_call2(SYS_switch_context, (uintptr_t)&rtcb->xcp.regs, \
-                  (uintptr_t)tcb->xcp.regs);                      \
-      }                                                           \
+#define up_switch_context(tcb, rtcb)   \
+  do {                                 \
+    if (!up_interrupt_context())       \
+      {                                \
+        sys_call0(SYS_switch_context); \
+      }                                \
+      UNUSED(rtcb);                    \
   } while (0)
 #endif
 
diff --git a/arch/arm/include/tlsr82/irq.h b/arch/arm/include/tlsr82/irq.h
index 115f9f14b6..529c5692aa 100644
--- a/arch/arm/include/tlsr82/irq.h
+++ b/arch/arm/include/tlsr82/irq.h
@@ -283,6 +283,8 @@ static inline_function void up_set_interrupt_context(bool 
flag)
 #endif
 }
 
+#define arm_fullcontextrestore() tc32_fullcontextrestore(this_task()->xcp.regs)
+
 #define up_switch_context(tcb, rtcb)                        \
   do {                                                      \
     if (!up_interrupt_context())                            \
diff --git a/arch/arm/src/arm/arm_sigdeliver.c 
b/arch/arm/src/arm/arm_sigdeliver.c
index b55e820604..a76152b535 100644
--- a/arch/arm/src/arm/arm_sigdeliver.c
+++ b/arch/arm/src/arm/arm_sigdeliver.c
@@ -54,7 +54,6 @@
 void arm_sigdeliver(void)
 {
   struct tcb_s *rtcb = this_task();
-  uint32_t *regs = rtcb->xcp.saved_regs;
 
   board_autoled_on(LED_SIGNAL);
 
@@ -99,5 +98,6 @@ void arm_sigdeliver(void)
   board_autoled_off(LED_SIGNAL);
 
   g_running_tasks[this_cpu()] = NULL;
-  arm_fullcontextrestore(regs);
+  rtcb->xcp.regs = rtcb->xcp.saved_regs;
+  arm_fullcontextrestore();
 }
diff --git a/arch/arm/src/arm/arm_syscall.c b/arch/arm/src/arm/arm_syscall.c
index 338c2216e6..7443e27c1d 100644
--- a/arch/arm/src/arm/arm_syscall.c
+++ b/arch/arm/src/arm/arm_syscall.c
@@ -79,46 +79,7 @@ uint32_t *arm_syscall(uint32_t *regs)
 
   switch (cmd)
     {
-      /* R0=SYS_restore_context:  Restore task context
-       *
-       * void arm_fullcontextrestore(uint32_t *restoreregs)
-       *   noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_restore_context
-       *   R1 = restoreregs
-       */
-
       case SYS_restore_context:
-        {
-          /* Replace 'regs' with the pointer to the register set in
-           * regs[REG_R1].  On return from the system call, that register
-           * set will determine the restored context.
-           */
-
-          tcb->xcp.regs = (uint32_t *)regs[REG_R1];
-          DEBUGASSERT(up_interrupt_context());
-        }
-        break;
-
-      /* R0=SYS_switch_context:  This a switch context command:
-       *
-       *   void arm_switchcontext(uint32_t **saveregs,
-       *                          uint32_t *restoreregs);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_switch_context
-       *   R1 = saveregs
-       *   R2 = restoreregs
-       *
-       * In this case, we do both: We save the context registers to the save
-       * register area reference by the saved contents of R1 and then set
-       * regs to the save register area referenced by the saved
-       * contents of R2.
-       */
-
       case SYS_switch_context:
         break;
 
diff --git a/arch/arm/src/armv6-m/arm_sigdeliver.c 
b/arch/arm/src/armv6-m/arm_sigdeliver.c
index fa6797351d..5fd3f44463 100644
--- a/arch/arm/src/armv6-m/arm_sigdeliver.c
+++ b/arch/arm/src/armv6-m/arm_sigdeliver.c
@@ -162,5 +162,8 @@ retry:
   leave_critical_section((uint16_t)regs[REG_PRIMASK]);
   rtcb->irqcount--;
 #endif
-  arm_fullcontextrestore(regs);
+  g_running_tasks[this_cpu()] = NULL;
+  rtcb->xcp.regs = rtcb->xcp.saved_regs;
+  arm_fullcontextrestore();
+  UNUSED(regs);
 }
diff --git a/arch/arm/src/armv6-m/arm_svcall.c 
b/arch/arm/src/armv6-m/arm_svcall.c
index 2ae54ac4ec..3ef29e4c47 100644
--- a/arch/arm/src/armv6-m/arm_svcall.c
+++ b/arch/arm/src/armv6-m/arm_svcall.c
@@ -117,9 +117,8 @@ static void dispatch_syscall(void)
 
 int arm_svcall(int irq, void *context, void *arg)
 {
-  struct tcb_s *tcb = this_task();
   uint32_t *regs = (uint32_t *)context;
-  uint32_t *new_regs = regs;
+  struct tcb_s *tcb;
   uint32_t cmd;
 
   cmd = regs[REG_R0];
@@ -149,41 +148,15 @@ int arm_svcall(int irq, void *context, void *arg)
 
   switch (cmd)
     {
-      /* R0=SYS_restore_context:  This a restore context command:
-       *
-       *   void arm_fullcontextrestore(uint32_t *restoreregs)
-       *     noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_restore_context
-       *   R1 = restoreregs
-       */
-
       case SYS_restore_context:
-        {
-          DEBUGASSERT(regs[REG_R1] != 0);
-          new_regs = (uint32_t *)regs[REG_R1];
-          tcb->xcp.regs = (uint32_t *)regs[REG_R1];
-        }
-        break;
-
-      /* R0=SYS_switch_context:  This a switch context command:
-       *
-       *   void arm_switchcontext(uint32_t **saveregs,
-       *                          uint32_t *restoreregs);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_switch_context
-       *   R1 = saveregs
-       *   R2 = restoreregs
-       */
-
       case SYS_switch_context:
         {
-          DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
-          new_regs = (uint32_t *)regs[REG_R2];
+          tcb = this_task();
+          restore_critical_section(tcb, this_cpu());
+
+#ifdef CONFIG_DEBUG_SYSCALL_INFO
+          regs = tcb->xcp.regs;
+#endif
         }
         break;
 
@@ -437,13 +410,11 @@ int arm_svcall(int irq, void *context, void *arg)
    * switch.
    */
 
-  if (regs != new_regs)
-    {
-      restore_critical_section(tcb, this_cpu());
-
 #ifdef CONFIG_DEBUG_SYSCALL_INFO
-      regs = new_regs;
-
+#  ifndef CONFIG_DEBUG_SVCALL
+  if (cmd > SYS_switch_context)
+#  endif
+    {
       svcinfo("SVCall Return:\n");
       svcinfo("  R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
               regs[REG_R0],  regs[REG_R1], regs[REG_R2],  regs[REG_R3],
@@ -453,14 +424,9 @@ int arm_svcall(int irq, void *context, void *arg)
               regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]);
       svcinfo(" PSR: %08x EXC_RETURN: %08x CONTROL: %08x\n",
               regs[REG_XPSR], regs[REG_EXC_RETURN], regs[REG_CONTROL]);
-#endif
-    }
-#ifdef CONFIG_DEBUG_SYSCALL_INFO
-  else
-    {
-      svcinfo("SVCall Return: %d\n", regs[REG_R0]);
     }
 #endif
 
+  UNUSED(tcb);
   return OK;
 }
diff --git a/arch/arm/src/armv7-a/arm_sigdeliver.c 
b/arch/arm/src/armv7-a/arm_sigdeliver.c
index 1867aa8844..5c0e058a4e 100644
--- a/arch/arm/src/armv7-a/arm_sigdeliver.c
+++ b/arch/arm/src/armv7-a/arm_sigdeliver.c
@@ -162,5 +162,7 @@ retry:
 #endif
 
   g_running_tasks[this_cpu()] = NULL;
-  arm_fullcontextrestore(regs);
+  rtcb->xcp.regs = rtcb->xcp.saved_regs;
+  arm_fullcontextrestore();
+  UNUSED(regs);
 }
diff --git a/arch/arm/src/armv7-a/arm_syscall.c 
b/arch/arm/src/armv7-a/arm_syscall.c
index 3e43e961bf..f31e403155 100644
--- a/arch/arm/src/armv7-a/arm_syscall.c
+++ b/arch/arm/src/armv7-a/arm_syscall.c
@@ -255,47 +255,7 @@ uint32_t *arm_syscall(uint32_t *regs)
         }
         break;
 #endif
-
-      /* R0=SYS_restore_context:  Restore task context
-       *
-       * void arm_fullcontextrestore(uint32_t *restoreregs)
-       *   noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_restore_context
-       *   R1 = restoreregs
-       */
-
       case SYS_restore_context:
-        {
-          /* Replace 'regs' with the pointer to the register set in
-           * regs[REG_R1].  On return from the system call, that register
-           * set will determine the restored context.
-           */
-
-          tcb->xcp.regs = (uint32_t *)regs[REG_R1];
-          DEBUGASSERT(up_interrupt_context());
-        }
-        break;
-
-      /* R0=SYS_switch_context:  This a switch context command:
-       *
-       *   void arm_switchcontext(uint32_t **saveregs,
-       *                          uint32_t *restoreregs);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_switch_context
-       *   R1 = saveregs
-       *   R2 = restoreregs
-       *
-       * In this case, we do both: We save the context registers to the save
-       * register area reference by the saved contents of R1 and then set
-       * regs to the save register area referenced by the saved
-       * contents of R2.
-       */
-
       case SYS_switch_context:
         break;
 
diff --git a/arch/arm/src/armv7-m/arm_sigdeliver.c 
b/arch/arm/src/armv7-m/arm_sigdeliver.c
index 524f2c445b..5642e82623 100644
--- a/arch/arm/src/armv7-m/arm_sigdeliver.c
+++ b/arch/arm/src/armv7-m/arm_sigdeliver.c
@@ -174,5 +174,9 @@ retry:
 #endif
   rtcb->irqcount--;
 #endif
-  arm_fullcontextrestore(regs);
+
+  g_running_tasks[this_cpu()] = NULL;
+  rtcb->xcp.regs = rtcb->xcp.saved_regs;
+  arm_fullcontextrestore();
+  UNUSED(regs);
 }
diff --git a/arch/arm/src/armv7-m/arm_svcall.c 
b/arch/arm/src/armv7-m/arm_svcall.c
index cd3a7e214a..03e9a43abb 100644
--- a/arch/arm/src/armv7-m/arm_svcall.c
+++ b/arch/arm/src/armv7-m/arm_svcall.c
@@ -125,9 +125,8 @@ static void dispatch_syscall(void)
 
 int arm_svcall(int irq, void *context, void *arg)
 {
-  struct tcb_s *tcb = this_task();
   uint32_t *regs = (uint32_t *)context;
-  uint32_t *new_regs = regs;
+  struct tcb_s *tcb;
   uint32_t cmd;
 
   cmd = regs[REG_R0];
@@ -157,41 +156,15 @@ int arm_svcall(int irq, void *context, void *arg)
 
   switch (cmd)
     {
-      /* R0=SYS_restore_context:  This a restore context command:
-       *
-       *   void arm_fullcontextrestore(uint32_t *restoreregs)
-       *          noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_restore_context
-       *   R1 = restoreregs
-       */
-
       case SYS_restore_context:
-        {
-          DEBUGASSERT(regs[REG_R1] != 0);
-          new_regs = (uint32_t *)regs[REG_R1];
-          tcb->xcp.regs = (uint32_t *)regs[REG_R1];
-        }
-        break;
-
-      /* R0=SYS_switch_context:  This a switch context command:
-       *
-       *   void arm_switchcontext(uint32_t **saveregs,
-       *                          uint32_t *restoreregs);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_switch_context
-       *   R1 = saveregs
-       *   R2 = restoreregs
-       */
-
       case SYS_switch_context:
         {
-          DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
-          new_regs = (uint32_t *)regs[REG_R2];
+          tcb = this_task();
+          restore_critical_section(tcb, this_cpu());
+
+#ifdef CONFIG_DEBUG_SYSCALL_INFO
+          regs = tcb->xcp.regs;
+#endif
         }
         break;
 
@@ -446,13 +419,11 @@ int arm_svcall(int irq, void *context, void *arg)
    * switch.
    */
 
-  if (regs != new_regs)
-    {
-      restore_critical_section(tcb, this_cpu());
-
 #ifdef CONFIG_DEBUG_SYSCALL_INFO
-      regs = new_regs;
-
+#  ifndef CONFIG_DEBUG_SVCALL
+  if (cmd > SYS_switch_context)
+#  endif
+    {
       svcinfo("SVCall Return:\n");
       svcinfo("  R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
               regs[REG_R0],  regs[REG_R1], regs[REG_R2],  regs[REG_R3],
@@ -462,14 +433,9 @@ int arm_svcall(int irq, void *context, void *arg)
               regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]);
       svcinfo(" PSR: %08x EXC_RETURN: %08x CONTROL: %08x\n",
               regs[REG_XPSR], regs[REG_EXC_RETURN], regs[REG_CONTROL]);
-#endif
-    }
-#ifdef CONFIG_DEBUG_SYSCALL_INFO
-  else
-    {
-      svcinfo("SVCall Return: %d\n", regs[REG_R0]);
     }
 #endif
 
+  UNUSED(tcb);
   return OK;
 }
diff --git a/arch/arm/src/armv7-r/arm_sigdeliver.c 
b/arch/arm/src/armv7-r/arm_sigdeliver.c
index 5a63458b9b..009ad90657 100644
--- a/arch/arm/src/armv7-r/arm_sigdeliver.c
+++ b/arch/arm/src/armv7-r/arm_sigdeliver.c
@@ -159,5 +159,7 @@ retry:
 #endif
 
   g_running_tasks[this_cpu()] = NULL;
-  arm_fullcontextrestore(regs);
+  rtcb->xcp.regs = rtcb->xcp.saved_regs;
+  arm_fullcontextrestore();
+  UNUSED(regs);
 }
diff --git a/arch/arm/src/armv7-r/arm_syscall.c 
b/arch/arm/src/armv7-r/arm_syscall.c
index 414518012e..315a6f42d4 100644
--- a/arch/arm/src/armv7-r/arm_syscall.c
+++ b/arch/arm/src/armv7-r/arm_syscall.c
@@ -253,46 +253,7 @@ uint32_t *arm_syscall(uint32_t *regs)
         break;
 #endif
 
-      /* R0=SYS_restore_context:  Restore task context
-       *
-       * void arm_fullcontextrestore(uint32_t *restoreregs)
-       *   noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_restore_context
-       *   R1 = restoreregs
-       */
-
       case SYS_restore_context:
-        {
-          /* Replace 'regs' with the pointer to the register set in
-           * regs[REG_R1].  On return from the system call, that register
-           * set will determine the restored context.
-           */
-
-          tcb->xcp.regs = (uint32_t *)regs[REG_R1];
-          DEBUGASSERT(up_interrupt_context());
-        }
-        break;
-
-      /* R0=SYS_switch_context:  This a switch context command:
-       *
-       *   void arm_switchcontext(uint32_t **saveregs,
-       *                          uint32_t *restoreregs);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_switch_context
-       *   R1 = saveregs
-       *   R2 = restoreregs
-       *
-       * In this case, we do both: We save the context registers to the save
-       * register area reference by the saved contents of R1 and then set
-       * regs to the save register area referenced by the saved
-       * contents of R2.
-       */
-
       case SYS_switch_context:
         break;
 
diff --git a/arch/arm/src/armv8-m/arm_sigdeliver.c 
b/arch/arm/src/armv8-m/arm_sigdeliver.c
index 2db03f17d1..aff8738235 100644
--- a/arch/arm/src/armv8-m/arm_sigdeliver.c
+++ b/arch/arm/src/armv8-m/arm_sigdeliver.c
@@ -174,5 +174,8 @@ retry:
 #endif
   rtcb->irqcount--;
 #endif
-  arm_fullcontextrestore(regs);
+  g_running_tasks[this_cpu()] = NULL;
+  rtcb->xcp.regs = rtcb->xcp.saved_regs;
+  arm_fullcontextrestore();
+  UNUSED(regs);
 }
diff --git a/arch/arm/src/armv8-m/arm_svcall.c 
b/arch/arm/src/armv8-m/arm_svcall.c
index 2a42d19dc7..5082ee952e 100644
--- a/arch/arm/src/armv8-m/arm_svcall.c
+++ b/arch/arm/src/armv8-m/arm_svcall.c
@@ -125,9 +125,8 @@ static void dispatch_syscall(void)
 
 int arm_svcall(int irq, void *context, void *arg)
 {
-  struct tcb_s *tcb = this_task();
   uint32_t *regs = (uint32_t *)context;
-  uint32_t *new_regs = regs;
+  struct tcb_s *tcb;
   uint32_t cmd;
 
   cmd = regs[REG_R0];
@@ -157,41 +156,15 @@ int arm_svcall(int irq, void *context, void *arg)
 
   switch (cmd)
     {
-      /* R0=SYS_restore_context:  This a restore context command:
-       *
-       *   void arm_fullcontextrestore(uint32_t *restoreregs)
-       *          noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_restore_context
-       *   R1 = restoreregs
-       */
-
       case SYS_restore_context:
-        {
-          DEBUGASSERT(regs[REG_R1] != 0);
-          new_regs = (uint32_t *)regs[REG_R1];
-          tcb->xcp.regs = (uint32_t *)regs[REG_R1];
-        }
-        break;
-
-      /* R0=SYS_switch_context:  This a switch context command:
-       *
-       *   void arm_switchcontext(uint32_t **saveregs,
-       *                          uint32_t *restoreregs);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_switch_context
-       *   R1 = saveregs
-       *   R2 = restoreregs
-       */
-
       case SYS_switch_context:
         {
-          DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
-          new_regs = (uint32_t *)regs[REG_R2];
+          tcb = this_task();
+          restore_critical_section(tcb, this_cpu());
+
+#ifdef CONFIG_DEBUG_SYSCALL_INFO
+          regs = tcb->xcp.regs;
+#endif
         }
         break;
 
@@ -446,13 +419,11 @@ int arm_svcall(int irq, void *context, void *arg)
    * switch.
    */
 
-  if (regs != new_regs)
-    {
-      restore_critical_section(tcb, this_cpu());
-
 #ifdef CONFIG_DEBUG_SYSCALL_INFO
-      regs = new_regs;
-
+#  ifndef CONFIG_DEBUG_SVCALL
+  if (cmd > SYS_switch_context)
+#  endif
+    {
       svcinfo("SVCall Return:\n");
       svcinfo("  R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
               regs[REG_R0],  regs[REG_R1], regs[REG_R2],  regs[REG_R3],
@@ -462,14 +433,9 @@ int arm_svcall(int irq, void *context, void *arg)
               regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]);
       svcinfo(" PSR: %08x EXC_RETURN: %08x CONTROL: %08x\n",
               regs[REG_XPSR], regs[REG_EXC_RETURN], regs[REG_CONTROL]);
-#endif
-    }
-#ifdef CONFIG_DEBUG_SYSCALL_INFO
-  else
-    {
-      svcinfo("SVCall Return: %d\n", regs[REG_R0]);
     }
 #endif
 
+  UNUSED(tcb);
   return OK;
 }
diff --git a/arch/arm/src/armv8-r/arm_sigdeliver.c 
b/arch/arm/src/armv8-r/arm_sigdeliver.c
index e4a8ad5935..5e4015e986 100644
--- a/arch/arm/src/armv8-r/arm_sigdeliver.c
+++ b/arch/arm/src/armv8-r/arm_sigdeliver.c
@@ -157,5 +157,7 @@ retry:
 #endif
 
   g_running_tasks[this_cpu()] = NULL;
-  arm_fullcontextrestore(regs);
+  rtcb->xcp.regs = rtcb->xcp.saved_regs;
+  arm_fullcontextrestore();
+  UNUSED(regs);
 }
diff --git a/arch/arm/src/armv8-r/arm_syscall.c 
b/arch/arm/src/armv8-r/arm_syscall.c
index f1a4d8175b..e478aafecf 100644
--- a/arch/arm/src/armv8-r/arm_syscall.c
+++ b/arch/arm/src/armv8-r/arm_syscall.c
@@ -253,46 +253,7 @@ uint32_t *arm_syscall(uint32_t *regs)
         break;
 #endif
 
-      /* R0=SYS_restore_context:  Restore task context
-       *
-       * void arm_fullcontextrestore(uint32_t *restoreregs)
-       *   noreturn_function;
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_restore_context
-       *   R1 = restoreregs
-       */
-
       case SYS_restore_context:
-        {
-          /* Replace 'regs' with the pointer to the register set in
-           * regs[REG_R1].  On return from the system call, that register
-           * set will determine the restored context.
-           */
-
-          tcb->xcp.regs = (uint32_t *)regs[REG_R1];
-          DEBUGASSERT(up_interrupt_context());
-        }
-        break;
-
-      /* R0=SYS_switch_context:  This a switch context command:
-       *
-       *   void arm_switchcontext(uint32_t **saveregs,
-       *                          uint32_t *restoreregs);
-       *
-       * At this point, the following values are saved in context:
-       *
-       *   R0 = SYS_switch_context
-       *   R1 = saveregs
-       *   R2 = restoreregs
-       *
-       * In this case, we do both: We save the context registers to the save
-       * register area reference by the saved contents of R1 and then set
-       * regs to the save register area referenced by the saved
-       * contents of R2.
-       */
-
       case SYS_switch_context:
         break;
 
diff --git a/arch/arm/src/common/arm_exit.c b/arch/arm/src/common/arm_exit.c
index f238dfa5f3..fa49dc5fed 100644
--- a/arch/arm/src/common/arm_exit.c
+++ b/arch/arm/src/common/arm_exit.c
@@ -54,25 +54,17 @@
 
 void up_exit(int status)
 {
-  struct tcb_s *tcb = this_task();
-
   /* Destroy the task at the head of the ready to run list. */
 
   nxtask_exit();
 
-  /* Now, perform the context switch to the new ready-to-run task at the
-   * head of the list.
-   */
-
-  tcb = this_task();
-
   /* Scheduler parameters will update inside syscall */
 
   g_running_tasks[this_cpu()] = NULL;
 
   /* Then switch contexts */
 
-  arm_fullcontextrestore(tcb->xcp.regs);
+  arm_fullcontextrestore();
 
   /* arm_fullcontextrestore() should not return but could if the software
    * interrupts are disabled.
diff --git a/arch/arm/src/common/arm_internal.h 
b/arch/arm/src/common/arm_internal.h
index 6303c6fc96..b72c256a83 100644
--- a/arch/arm/src/common/arm_internal.h
+++ b/arch/arm/src/common/arm_internal.h
@@ -147,10 +147,7 @@
 /* Context switching */
 
 #ifndef arm_fullcontextrestore
-#  define arm_fullcontextrestore(restoreregs) \
-    sys_call1(SYS_restore_context, (uintptr_t)restoreregs);
-#else
-extern void arm_fullcontextrestore(uint32_t *restoreregs);
+#  define arm_fullcontextrestore() sys_call0(SYS_restore_context)
 #endif
 
 /* Redefine the linker symbols as armlink style */
diff --git a/arch/arm/src/tlsr82/Make.defs b/arch/arm/src/tlsr82/Make.defs
index f1fe854475..9ae2087055 100644
--- a/arch/arm/src/tlsr82/Make.defs
+++ b/arch/arm/src/tlsr82/Make.defs
@@ -64,5 +64,3 @@ ifeq ($(CONFIG_TLSR82_SOFT_FPU),y)
   EXTRA_LIBPATHS += -L$(TOPDIR)/$(CONFIG_TLSR82_SOFT_FPU_LIB_PATH)
   EXTRA_LIBS     += -l$(CONFIG_TLSR82_SOFT_FPU_LIB_NAME)
 endif
-
-CFLAGS += -Darm_fullcontextrestore=tc32_fullcontextrestore

Reply via email to