You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/04/28 05:56:27 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6167: arch/xtensa: Replace the xcp context with stack context to improve context switching

xiaoxiang781216 commented on code in PR #6167:
URL: https://github.com/apache/incubator-nuttx/pull/6167#discussion_r860509508


##########
arch/xtensa/src/common/xtensa_dumpstate.c:
##########
@@ -295,12 +295,11 @@ void xtensa_dumpstate(void)
 
   if (CURRENT_REGS)
     {
-      memcpy(rtcb->xcp.regs,
-             (uintptr_t *)CURRENT_REGS, XCPTCONTEXT_SIZE);
+      rtcb->xcp.regs = (uint32_t *)CURRENT_REGS;
     }
   else
     {
-      up_saveusercontext(rtcb->xcp.regs);
+      up_saveusercontext(&rtcb->xcp.regs);

Review Comment:
   need keep the prototype in:
   include/nuttx/arch.h



##########
arch/xtensa/src/common/xtensa_blocktask.c:
##########
@@ -140,7 +140,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
 
           /* Then switch contexts */
 
-          xtensa_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
+          xtensa_switchcontext(&rtcb->xcp.regs, nexttcb->xcp.regs);

Review Comment:
   need update the comment in syscall.h



##########
arch/xtensa/src/common/xtensa_swint.c:
##########
@@ -103,7 +103,7 @@ int xtensa_swint(int irq, void *context, void *arg)
       case SYS_save_context:
         {
           DEBUGASSERT(regs[REG_A3] != 0);
-          memcpy((uint32_t *)regs[REG_A3], regs, (4 * XCPTCONTEXT_REGS));
+          memcpy(*(uint32_t **)regs[REG_A3], regs, XCPTCONTEXT_SIZE);

Review Comment:
   don't need change



##########
arch/xtensa/src/common/xtensa_exit.c:
##########
@@ -145,7 +145,7 @@ void up_exit(int status)
 
   /* Then switch contexts */
 
-  xtensa_context_restore(tcb->xcp.regs);
+  xtensa_context_restore(&tcb->xcp.regs);

Review Comment:
   why need change here?



##########
arch/xtensa/include/irq.h:
##########
@@ -149,12 +149,11 @@ struct xcptcontext
    * another signal handler is executing will be ignored!
    */
 
-  uint32_t saved_pc;
-  uint32_t saved_ps;
+  uint32_t *saved_regs;
 
   /* Register save area */
 
-  uint32_t regs[XCPTCONTEXT_REGS];
+  uint32_t *regs;

Review Comment:
   can we move cpstate at line 161 to stack too?



##########
arch/xtensa/src/common/xtensa_swint.c:
##########
@@ -132,7 +132,7 @@ int xtensa_swint(int irq, void *context, void *arg)
       case SYS_restore_context:
         {
           DEBUGASSERT(regs[REG_A3] != 0);
-          CURRENT_REGS = (uint32_t *)regs[REG_A3];
+          CURRENT_REGS = *(uint32_t **)regs[REG_A3];

Review Comment:
   don't need change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org