diff --git a/libcpu/arm/cortex-m4/context_gcc.S b/libcpu/arm/cortex-m4/context_gcc.S index af6c9934d49da5ee4c1912314adfede4112da158..5985d54fb34e512abeb2dba6023fc35e8dcb413a 100644 --- a/libcpu/arm/cortex-m4/context_gcc.S +++ b/libcpu/arm/cortex-m4/context_gcc.S @@ -145,16 +145,16 @@ switch_to_thread: MSR psp, r1 /* update stack pointer */ -pendsv_exit: - /* restore interrupt */ - MSR PRIMASK, r2 - #if defined (__VFP_FP__) && !defined(__SOFTFP__) ORR lr, lr, #0x10 /* lr |= (1 << 4), clean FPCA. */ CMP r3, #0 /* if(flag_r3 != 0) */ BICNE lr, lr, #0x10 /* lr &= ~(1 << 4), set FPCA. */ #endif +pendsv_exit: + /* restore interrupt */ + MSR PRIMASK, r2 + ORR lr, lr, #0x04 BX lr diff --git a/libcpu/arm/cortex-m4/context_iar.S b/libcpu/arm/cortex-m4/context_iar.S index 4cc9539112b0a936ad31a2410aa13e2736aef993..c34600ea4cd886c969a85c22b3ea32568ecea8e9 100644 --- a/libcpu/arm/cortex-m4/context_iar.S +++ b/libcpu/arm/cortex-m4/context_iar.S @@ -149,10 +149,6 @@ skip_pop_fpu MSR psp, r1 ; update stack pointer -pendsv_exit - ; restore interrupt - MSR PRIMASK, r2 - #if defined ( __ARMVFP__ ) ORR lr, lr, #0x10 ; lr |= (1 << 4), clean FPCA. CBZ r3, return_without_fpu ; if(flag_r3 != 0) @@ -160,6 +156,10 @@ pendsv_exit return_without_fpu #endif +pendsv_exit + ; restore interrupt + MSR PRIMASK, r2 + ORR lr, lr, #0x04 BX lr diff --git a/libcpu/arm/cortex-m4/context_rvds.S b/libcpu/arm/cortex-m4/context_rvds.S index ea894ed0003fb43c372ee897cb5d9faab7c53f15..5cae619287bd0a8ffa6311f48fff9db5dba926bf 100644 --- a/libcpu/arm/cortex-m4/context_rvds.S +++ b/libcpu/arm/cortex-m4/context_rvds.S @@ -147,16 +147,16 @@ switch_to_thread MSR psp, r1 ; update stack pointer -pendsv_exit - ; restore interrupt - MSR PRIMASK, r2 - IF {FPU} != "SoftVFP" ORR lr, lr, #0x10 ; lr |= (1 << 4), clean FPCA. CMP r3, #0 ; if(flag_r3 != 0) BICNE lr, lr, #0x10 ; lr &= ~(1 << 4), set FPCA. ENDIF +pendsv_exit + ; restore interrupt + MSR PRIMASK, r2 + ORR lr, lr, #0x04 BX lr ENDP diff --git a/libcpu/arm/cortex-m7/context_gcc.S b/libcpu/arm/cortex-m7/context_gcc.S index af6c9934d49da5ee4c1912314adfede4112da158..5985d54fb34e512abeb2dba6023fc35e8dcb413a 100644 --- a/libcpu/arm/cortex-m7/context_gcc.S +++ b/libcpu/arm/cortex-m7/context_gcc.S @@ -145,16 +145,16 @@ switch_to_thread: MSR psp, r1 /* update stack pointer */ -pendsv_exit: - /* restore interrupt */ - MSR PRIMASK, r2 - #if defined (__VFP_FP__) && !defined(__SOFTFP__) ORR lr, lr, #0x10 /* lr |= (1 << 4), clean FPCA. */ CMP r3, #0 /* if(flag_r3 != 0) */ BICNE lr, lr, #0x10 /* lr &= ~(1 << 4), set FPCA. */ #endif +pendsv_exit: + /* restore interrupt */ + MSR PRIMASK, r2 + ORR lr, lr, #0x04 BX lr diff --git a/libcpu/arm/cortex-m7/context_iar.S b/libcpu/arm/cortex-m7/context_iar.S index 4cc9539112b0a936ad31a2410aa13e2736aef993..c34600ea4cd886c969a85c22b3ea32568ecea8e9 100644 --- a/libcpu/arm/cortex-m7/context_iar.S +++ b/libcpu/arm/cortex-m7/context_iar.S @@ -149,10 +149,6 @@ skip_pop_fpu MSR psp, r1 ; update stack pointer -pendsv_exit - ; restore interrupt - MSR PRIMASK, r2 - #if defined ( __ARMVFP__ ) ORR lr, lr, #0x10 ; lr |= (1 << 4), clean FPCA. CBZ r3, return_without_fpu ; if(flag_r3 != 0) @@ -160,6 +156,10 @@ pendsv_exit return_without_fpu #endif +pendsv_exit + ; restore interrupt + MSR PRIMASK, r2 + ORR lr, lr, #0x04 BX lr diff --git a/libcpu/arm/cortex-m7/context_rvds.S b/libcpu/arm/cortex-m7/context_rvds.S index 38410c8a3b3e2d32ec728a46e6ee8ca2700326b7..dc9a9586462efd571d7afc2a1ff803aeb17e02f8 100644 --- a/libcpu/arm/cortex-m7/context_rvds.S +++ b/libcpu/arm/cortex-m7/context_rvds.S @@ -147,16 +147,16 @@ switch_to_thread MSR psp, r1 ; update stack pointer -pendsv_exit - ; restore interrupt - MSR PRIMASK, r2 - IF {FPU} != "SoftVFP" ORR lr, lr, #0x10 ; lr |= (1 << 4), clean FPCA. CMP r3, #0 ; if(flag_r3 != 0) BICNE lr, lr, #0x10 ; lr &= ~(1 << 4), set FPCA. ENDIF +pendsv_exit + ; restore interrupt + MSR PRIMASK, r2 + ORR lr, lr, #0x04 BX lr ENDP