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 a4b6b158ce7f99ee8d306e2c8ace83a5002d4cfa
Author: wangming9 <[email protected]>
AuthorDate: Fri Jun 30 14:26:02 2023 +0800

    arch/armv6-m: By default, add REG_EXC_RETURN to xcptcontext.
    
    Signed-off-by: wangming9 <[email protected]>
---
 arch/arm/include/armv6-m/irq.h             | 13 ++-----------
 arch/arm/src/armv6-m/arm_exception.S       | 22 ----------------------
 arch/arm/src/armv6-m/arm_initialstate.c    |  2 --
 arch/arm/src/armv6-m/arm_saveusercontext.S |  8 +++-----
 arch/arm/src/armv6-m/arm_svcall.c          | 10 ----------
 5 files changed, 5 insertions(+), 50 deletions(-)

diff --git a/arch/arm/include/armv6-m/irq.h b/arch/arm/include/armv6-m/irq.h
index f2e59ef39d..b7ea799fc4 100644
--- a/arch/arm/include/armv6-m/irq.h
+++ b/arch/arm/include/armv6-m/irq.h
@@ -69,17 +69,8 @@
 #define REG_R9              (7)  /* R9 */
 #define REG_R10             (8)  /* R10 */
 #define REG_R11             (9)  /* R11 */
-
-/* In the kernel build, we may return to either privileged or unprivileged
- * modes.
- */
-
-#ifdef CONFIG_BUILD_PROTECTED
-#  define REG_EXC_RETURN    (10) /* EXC_RETURN */
-#  define SW_XCPT_REGS      (11)
-#else
-#  define SW_XCPT_REGS      (10)
-#endif
+#define REG_EXC_RETURN      (10) /* EXC_RETURN */
+#define SW_XCPT_REGS        (11)
 
 /* The total number of registers saved by software */
 
diff --git a/arch/arm/src/armv6-m/arm_exception.S 
b/arch/arm/src/armv6-m/arm_exception.S
index 4d8eabbd30..595198b698 100644
--- a/arch/arm/src/armv6-m/arm_exception.S
+++ b/arch/arm/src/armv6-m/arm_exception.S
@@ -114,7 +114,6 @@ exception_common:
         * the context is on the MSP or PSP.
         */
 
-#ifdef CONFIG_BUILD_PROTECTED
        mov             r0, r14                                 /* Copy high 
register to low register */
        lsls            r0, #(31 - EXC_RETURN_PROCESS_BITNO)    /* Move to bit 
31 */
        bmi             1f                                      /* Test bit 31 
*/
@@ -123,9 +122,6 @@ exception_common:
 
 1:
        mrs             r1, psp                                 /* R1=The 
process stack pointer */
-#else
-       mrs             r1, msp                                 /* R1=The main 
stack pointer */
-#endif
 
        /* R1 is the current stack pointer.  HW_XCPT_REGS were pushed onto the 
stack
         * when the interrupt was taken so (R1)+HW_XCPT_SIZE is the value of the
@@ -151,12 +147,8 @@ exception_common:
        mov             r3, r9
        mov             r4, r10
        mov             r5, r11
-#ifdef CONFIG_BUILD_PROTECTED
        mov             r6, r14
        stmia           r0!, {r2-r6}                            /* Save the 
high registers r8-r11 and r14 */
-#else
-       stmia           r0!, {r2-r5}                            /* Save the 
high registers r8-r11 */
-#endif
 
        /* Get the exception number in R0=IRQ, R1=register save area on stack */
 
@@ -196,20 +188,12 @@ exception_common:
 
        movs            r2, #(4*REG_R8)                         /* R2=Offset to 
R8 storage */
        adds            r1, r0, r2                              /* R1=Address 
of R8 storage */
-#ifdef CONFIG_BUILD_PROTECTED
        ldmia           r1!, {r2-r6}                            /* Recover 
R8-R11 and R14 (5 registers)*/
        mov             r8, r2                                  /* Move to 
position in high registers */
        mov             r9, r3
        mov             r10, r4
        mov             r11, r5
        mov             r14, r6                                 /* EXEC_RETURN 
*/
-#else
-       ldmia           r1!, {r2-r5}                            /* Recover 
R8-R11 (4 registers)*/
-       mov             r8, r2                                  /* Move to 
position in high registers */
-       mov             r9, r3
-       mov             r10, r4
-       mov             r11, r5
-#endif
 
        /* Recover SP (R2), PRIMASK (R3), and R4-R7. Determine the value of
         * the stack pointer as it was on entry to the exception handler.
@@ -223,7 +207,6 @@ exception_common:
         * context is on the MSP or PSP.
         */
 
-#ifdef CONFIG_BUILD_PROTECTED
        mov             r0, r14                                 /* Copy high 
register to low register */
        lsls            r0, #(31 - EXC_RETURN_PROCESS_BITNO)    /* Move to bit 
31 */
        bmi             3f                                      /* Test bit 31 
*/
@@ -234,11 +217,6 @@ exception_common:
        msr             psp, r1                                 /* R1=The 
process stack pointer */
 
 4:
-#else
-       msr             msp, r1                                 /* R1=The main 
stack pointer */
-       ldr             r0, =EXC_RETURN_PRIVTHR                 /* 
R0=EXC_RETURN to privileged mode */
-       mov             r14, r0                                 /* 
R14=EXC_RETURN to privileged mode */
-#endif
 
        /* Restore the interrupt state */
 
diff --git a/arch/arm/src/armv6-m/arm_initialstate.c 
b/arch/arm/src/armv6-m/arm_initialstate.c
index 2153777318..c7639d26ed 100644
--- a/arch/arm/src/armv6-m/arm_initialstate.c
+++ b/arch/arm/src/armv6-m/arm_initialstate.c
@@ -129,7 +129,6 @@ void up_initial_state(struct tcb_s *tcb)
 #endif
 #endif /* CONFIG_PIC */
 
-#ifdef CONFIG_BUILD_PROTECTED
   /* All tasks start via a stub function in kernel space.  So all
    * tasks must start in privileged thread mode.  If CONFIG_BUILD_PROTECTED
    * is defined, then that stub function will switch to unprivileged
@@ -137,7 +136,6 @@ void up_initial_state(struct tcb_s *tcb)
    */
 
   xcp->regs[REG_EXC_RETURN] = EXC_RETURN_PRIVTHR;
-#endif
 
   /* Enable or disable interrupts, based on user configuration */
 
diff --git a/arch/arm/src/armv6-m/arm_saveusercontext.S 
b/arch/arm/src/armv6-m/arm_saveusercontext.S
index 478bdac079..510d0450b8 100644
--- a/arch/arm/src/armv6-m/arm_saveusercontext.S
+++ b/arch/arm/src/armv6-m/arm_saveusercontext.S
@@ -92,14 +92,12 @@ up_saveusercontext:
        /* Save r11 and EXC_RETURN */
 
        mov             r1, r11
-#ifdef CONFIG_BUILD_PROTECTED
+
        /* Save EXC_RETURN to 0xffffffff */
 
-       movs            r2, #-1
+       movs            r2, #0
+       subs            r2, #1
        stmia           r0!, {r1-r2}
-#else
-       stmia           r0!, {r1}
-#endif
 
        movs            r0, #0
        bx              lr
diff --git a/arch/arm/src/armv6-m/arm_svcall.c 
b/arch/arm/src/armv6-m/arm_svcall.c
index 02a609fc55..b9f96459fb 100644
--- a/arch/arm/src/armv6-m/arm_svcall.c
+++ b/arch/arm/src/armv6-m/arm_svcall.c
@@ -138,13 +138,8 @@ int arm_svcall(int irq, void *context, void *arg)
       svcinfo("  R8: %08x %08x %08x %08x %08x %08x %08x %08x\n",
               regs[REG_R8],  regs[REG_R9],  regs[REG_R10], regs[REG_R11],
               regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]);
-#  ifdef CONFIG_BUILD_PROTECTED
       svcinfo(" PSR: %08x PRIMASK: %08x EXC_RETURN: %08x\n",
               regs[REG_XPSR], regs[REG_PRIMASK], regs[REG_EXC_RETURN]);
-#  else
-      svcinfo(" PSR: %08x PRIMASK: %08x\n",
-              regs[REG_XPSR], regs[REG_PRIMASK]);
-#  endif
     }
 #endif
 
@@ -446,14 +441,9 @@ int arm_svcall(int irq, void *context, void *arg)
               CURRENT_REGS[REG_R10], CURRENT_REGS[REG_R11],
               CURRENT_REGS[REG_R12], CURRENT_REGS[REG_R13],
               CURRENT_REGS[REG_R14], CURRENT_REGS[REG_R15]);
-#  ifdef CONFIG_BUILD_PROTECTED
       svcinfo(" PSR: %08x PRIMASK: %08x EXC_RETURN: %08x\n",
               CURRENT_REGS[REG_XPSR], CURRENT_REGS[REG_PRIMASK],
               CURRENT_REGS[REG_EXC_RETURN]);
-#  else
-      svcinfo(" PSR: %08x PRIMASK: %08x\n",
-              CURRENT_REGS[REG_XPSR], CURRENT_REGS[REG_PRIMASK]);
-#  endif
     }
 #  ifdef CONFIG_DEBUG_SVCALL
   else

Reply via email to