mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-05-28 01:51:00 +08:00
fixed get sp in HardFault_Handler. close #1646
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
;/*
|
;/*
|
||||||
; * File : context_rvds.S
|
; * File : context_rvds.S
|
||||||
; * This file is part of RT-Thread RTOS
|
; * This file is part of RT-Thread RTOS
|
||||||
; * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
|
; * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||||
; *
|
; *
|
||||||
; * The license and distribution terms for this file may be
|
; * The license and distribution terms for this file may be
|
||||||
; * found in the file LICENSE in this distribution or at
|
; * found in the file LICENSE in this distribution or at
|
||||||
@@ -186,14 +186,17 @@ HardFault_Handler PROC
|
|||||||
|
|
||||||
; get current context
|
; get current context
|
||||||
TST lr, #0x04 ; if(!EXC_RETURN[2])
|
TST lr, #0x04 ; if(!EXC_RETURN[2])
|
||||||
MRSNE r0, msp ; get fault context from handler.
|
ITE EQ
|
||||||
MRSEQ r0, psp ; get fault context from thread.
|
MRSEQ r0, msp ; [2]=0 ==> Z=1, get fault context from handler.
|
||||||
|
MRSNE r0, psp ; [2]=1 ==> Z=0, get fault context from thread.
|
||||||
|
|
||||||
STMFD r0!, {r4 - r11} ; push r4 - r11 register
|
STMFD r0!, {r4 - r11} ; push r4 - r11 register
|
||||||
STMFD r0!, {lr} ; push exec_return register
|
STMFD r0!, {lr} ; push exec_return register
|
||||||
|
|
||||||
MSRNE msp, r0 ; update stack pointer to MSP.
|
TST lr, #0x04 ; if(!EXC_RETURN[2])
|
||||||
MSREQ psp, r0 ; update stack pointer to PSP.
|
ITE EQ
|
||||||
|
MSREQ msp, r0 ; [2]=0 ==> Z=1, update stack pointer to MSP.
|
||||||
|
MSRNE psp, r0 ; [2]=1 ==> Z=0, update stack pointer to PSP.
|
||||||
|
|
||||||
PUSH {lr}
|
PUSH {lr}
|
||||||
BL rt_hw_hard_fault_exception
|
BL rt_hw_hard_fault_exception
|
||||||
|
|||||||
Reference in New Issue
Block a user