diff options
| -rw-r--r-- | libcpu/arm/cortex-m0/context_gcc.S | 8 | ||||
| -rw-r--r-- | libcpu/arm/cortex-m0/context_iar.S | 8 | ||||
| -rw-r--r-- | libcpu/arm/cortex-m0/context_rvds.S | 8 |
3 files changed, 21 insertions, 3 deletions
diff --git a/libcpu/arm/cortex-m0/context_gcc.S b/libcpu/arm/cortex-m0/context_gcc.S index 59a81bc580..50e8040a00 100644 --- a/libcpu/arm/cortex-m0/context_gcc.S +++ b/libcpu/arm/cortex-m0/context_gcc.S @@ -197,7 +197,13 @@ rt_hw_interrupt_thread_switch: .type HardFault_Handler, %function HardFault_Handler: /* get current context */ - MRS R0, PSP /* get fault thread stack pointer */ + MRS R0, MSP /* get fault context from handler. */ + MOV R1, LR /* Cortex-M0 has no Thumb-2 TST immediate */ + MOVS R2, #0x04 + TST R1, R2 /* if(!EXC_RETURN[2]) */ + BEQ _get_sp_done + MRS R0, PSP /* get fault context from thread. */ +_get_sp_done: PUSH {LR} BL rt_hw_hard_fault_exception POP {PC} diff --git a/libcpu/arm/cortex-m0/context_iar.S b/libcpu/arm/cortex-m0/context_iar.S index f00d03417f..ee4cf89c9b 100644 --- a/libcpu/arm/cortex-m0/context_iar.S +++ b/libcpu/arm/cortex-m0/context_iar.S @@ -202,7 +202,13 @@ rt_hw_interrupt_thread_switch: HardFault_Handler: ; get current context - MRS r0, psp ; get fault thread stack pointer + MRS r0, msp ; get fault context from handler. + MOV r1, lr ; Cortex-M0 has no Thumb-2 TST immediate + MOVS r2, #0x04 + TST r1, r2 ; if(!EXC_RETURN[2]) + BEQ _get_sp_done + MRS r0, psp ; get fault context from thread. +_get_sp_done PUSH {lr} BL rt_hw_hard_fault_exception POP {pc} diff --git a/libcpu/arm/cortex-m0/context_rvds.S b/libcpu/arm/cortex-m0/context_rvds.S index 3f1a7e267a..809b35363b 100644 --- a/libcpu/arm/cortex-m0/context_rvds.S +++ b/libcpu/arm/cortex-m0/context_rvds.S @@ -208,7 +208,13 @@ HardFault_Handler PROC EXPORT HardFault_Handler ; get current context - MRS r0, psp ; get fault thread stack pointer + MRS r0, msp ; get fault context from handler. + MOV r1, lr ; Cortex-M0 has no Thumb-2 TST immediate + MOVS r2, #0x04 + TST r1, r2 ; if(!EXC_RETURN[2]) + BEQ _get_sp_done + MRS r0, psp ; get fault context from thread. +_get_sp_done PUSH {lr} BL rt_hw_hard_fault_exception POP {pc} |
