xiaoxiang781216 commented on a change in pull request #5541:
URL: https://github.com/apache/incubator-nuttx/pull/5541#discussion_r811592182
##########
File path: arch/xtensa/src/common/xtensa_swint.c
##########
@@ -94,22 +102,96 @@ int xtensa_svcall(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));
+#if XCHAL_CP_NUM > 0
+ cpstate = (uintptr_t)regs[REG_A3] + cpstate_off;
+ xtensa_coproc_savestate((struct xtensa_cpstate_s *)cpstate);
+#endif
+ }
+
+ break;
+
+ /* A2=SYS_restore_context: This is a restore context command:
+ *
+ * void xtensa_fullcontextrestore(uint32_t *restoreregs)
+ * noreturn_function;
+ *
+ * At this point, the following values are saved in context:
+ *
+ * A2 = SYS_restore_context
+ * A3 = restoreregs
+ *
+ * In this case, we simply need to set CURRENT_REGS to restore
+ * register area referenced in the saved A3. context == CURRENT_REGS
+ * is the normal exception return. By setting CURRENT_REGS =
+ * context[A3], we force the return to the saved context referenced
+ * in A3.
+ */
+
+ case SYS_restore_context:
+ {
+#if XCHAL_CP_NUM > 0
+ cpstate = (uintptr_t)regs[REG_A3] + cpstate_off;
+ xtensa_coproc_restorestate((struct xtensa_cpstate_s *)cpstate);
+#endif
+ DEBUGASSERT(regs[REG_A3] != 0);
+ CURRENT_REGS = (uint32_t *)regs[REG_A3];
+ }
+
+ break;
+
+ /* A2=SYS_switch_context: This is a switch context command:
+ *
+ * void xtensa_switchcontext
+ * (uint32_t *saveregs, uint32_t *restoreregs);
+ *
+ * At this point, the following values are saved in context:
+ *
+ * A2 = SYS_switch_context
+ * A3 = saveregs
+ * A4 = restoreregs
+ *
+ * In this case, we do both: We save the context registers to the save
+ * register area reference by the saved contents of A3 and then set
+ * CURRENT_REGS to the save register area referenced by the saved
+ * contents of A4.
+ */
+
+ case SYS_switch_context:
+ {
+ DEBUGASSERT(regs[REG_A3] != 0 && regs[REG_A4] != 0);
+
+ memcpy((uint32_t *)regs[REG_A3], regs, (4 * XCPTCONTEXT_REGS));
+#if XCHAL_CP_NUM > 0
Review comment:
remvoe, dup in xtensa_irq_dispatch.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]