diff options
| author | aozima <[email protected]> | 2018-07-24 20:10:30 +0800 |
|---|---|---|
| committer | aozima <[email protected]> | 2018-07-25 21:39:44 +0800 |
| commit | 6c39b2d54d4b1d90f2038617b8df8ea449336085 (patch) | |
| tree | 02eb5c266d08c962ad4b64d56c9bc59e1fb339d1 /libcpu/arm/cortex-m4/context_gcc.S | |
| parent | a0fe71f78f14cb653f4bc219842c9a6a2914766e (diff) | |
[libcpu][comtex-m4] enhancement hard fault exception handler.
Diffstat (limited to 'libcpu/arm/cortex-m4/context_gcc.S')
| -rw-r--r-- | libcpu/arm/cortex-m4/context_gcc.S | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/libcpu/arm/cortex-m4/context_gcc.S b/libcpu/arm/cortex-m4/context_gcc.S index 5985d54fb3..d003ce0ea0 100644 --- a/libcpu/arm/cortex-m4/context_gcc.S +++ b/libcpu/arm/cortex-m4/context_gcc.S @@ -1,7 +1,7 @@ /* * File : context_gcc.S * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2009, RT-Thread Development Team + * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -13,6 +13,7 @@ * 2012-01-01 aozima support context switch load/store FPU register. * 2013-06-18 aozima add restore MSP feature. * 2013-06-23 aozima support lazy stack optimized. + * 2018-07-24 aozima enhancement hard fault exception handler. */ /** @@ -220,10 +221,29 @@ rt_hw_interrupt_thread_switch: .type HardFault_Handler, %function HardFault_Handler: /* get current context */ - MRS r0, psp /* get fault thread stack pointer */ - PUSH {lr} + MRS r0, msp /* get fault context from handler. */ + TST lr, #0x04 /* if(!EXC_RETURN[2]) */ + BEQ _get_sp_done + MRS r0, psp /* get fault context from thread. */ +_get_sp_done: + + STMFD r0!, {r4 - r11} /* push r4 - r11 register */ +#if defined (__VFP_FP__) && !defined(__SOFTFP__) + STMFD r0!, {lr} /* push dummy for flag */ +#endif + STMFD r0!, {lr} /* push exec_return register */ + + TST lr, #0x04 /* if(!EXC_RETURN[2]) */ + BEQ _update_msp + MSR psp, r0 /* update stack pointer to PSP. */ + B _update_done +_update_msp: + MSR msp, r0 /* update stack pointer to MSP. */ +_update_done: + + PUSH {LR} BL rt_hw_hard_fault_exception - POP {lr} + POP {LR} ORR lr, lr, #0x04 BX lr |
