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/02/22 17:23:50 UTC
[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5506: arch/armv7-a/r: unify switch context from software interrupt
pkarashchenko commented on a change in pull request #5506:
URL: https://github.com/apache/incubator-nuttx/pull/5506#discussion_r811915779
##########
File path: arch/arm/src/arm/arm_fullcontextrestore.S
##########
@@ -60,38 +63,14 @@
.type arm_fullcontextrestore, function
arm_fullcontextrestore:
- /* On entry, a1 (r0) holds address of the register save area. All other
- * registers are available for use.
- */
-
- /* Recover all registers except for r0, r1, R15, and CPSR */
-
- add r1, r0, #(4*REG_R2) /* Offset to REG_R2 storage */
- ldmia r1, {r2-r14} /* Recover registers */
-
- /* Create a stack frame to hold the some registers */
-
- sub sp, sp, #(3*4) /* Frame for three registers */
- ldr r1, [r0, #(4*REG_R0)] /* Fetch the stored r0 value */
- str r1, [sp] /* Save it at the top of the stack */
- ldr r1, [r0, #(4*REG_R1)] /* Fetch the stored r1 value */
- str r1, [sp, #4] /* Save it in the stack */
- ldr r1, [r0, #(4*REG_PC)] /* Fetch the stored pc value */
- str r1, [sp, #8] /* Save it at the bottom of the frame */
-
- /* Now we can restore the CPSR. We wait until we are completely
- * finished with the context save data to do this. Restore the CPSR
- * may re-enable and interrupts and we could be in a context
- * where the save structure is only protected by interrupts being
- * disabled.
- */
-
- ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the stored CPSR value */
- msr spsr_cxsf, r1 /* Set the SPSR */
+ /* Perform the System call with R0=1 and R1=regs */
- /* Now recover r0-r1, pc and cpsr, destroying the stack frame */
+ mov r1, r0 /* R1: regs */
+ mov r0, #SYS_restore_context /* R0: restore context */
+ svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */
- ldmia sp!, {r0-r1, r15}^
+ /* This call should not return */
+ bx lr /* Unnecessary ... will not return */
Review comment:
Should we branch to `lr` or to some fault handler if call returns unexpectedly?
--
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