arm: refactor fault handling stack pointer passing
Find out on which stack the stack frame for an exception is in the assembly code (__fault()) rather than in C (_Fault()). This will allow pushing more registers on the stack when debugging is enabled. Change-Id: I1c510b83098536f8930392b17df27511ccd04d80 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
c4a093a24e
commit
cfac189f98
2 changed files with 13 additions and 6 deletions
|
@ -332,14 +332,13 @@ static void _FaultDump(const NANO_ESF *esf, int fault)
|
||||||
* interrupt was already being handled, it is passed a pointer to both and has
|
* interrupt was already being handled, it is passed a pointer to both and has
|
||||||
* to find out on which the ESP is present.
|
* to find out on which the ESP is present.
|
||||||
*
|
*
|
||||||
* @param msp pointer to potential ESF on MSP
|
* @param esf ESF on the stack, either MSP or PSP depending at what processor
|
||||||
* @param psp pointer to potential ESF on PSP
|
* state the exception was taken.
|
||||||
*
|
*
|
||||||
* @return This function does not return.
|
* @return This function does not return.
|
||||||
*/
|
*/
|
||||||
void _Fault(const NANO_ESF *msp, const NANO_ESF *psp)
|
void _Fault(const NANO_ESF *esf)
|
||||||
{
|
{
|
||||||
const NANO_ESF *esf = _ScbIsNestedExc() ? msp : psp;
|
|
||||||
int fault = _ScbActiveVectorGet();
|
int fault = _ScbActiveVectorGet();
|
||||||
|
|
||||||
FAULT_DUMP(esf, fault);
|
FAULT_DUMP(esf, fault);
|
||||||
|
|
|
@ -74,8 +74,16 @@ SECTION_SUBSEC_FUNC(TEXT,__fault,__reserved)
|
||||||
eors.n r0, r0
|
eors.n r0, r0
|
||||||
msr BASEPRI, r0
|
msr BASEPRI, r0
|
||||||
|
|
||||||
mrs r0, MSP
|
/* this reimplements _ScbIsNestedExc() */
|
||||||
mrs r1, PSP
|
ldr ip, =_SCS_ICSR
|
||||||
|
ldr ip, [ip]
|
||||||
|
ands.w ip, #_SCS_ICSR_RETTOBASE
|
||||||
|
|
||||||
|
ite eq /* is the RETTOBASE bit zero ? */
|
||||||
|
mrseq r0, MSP /* if so, we're not returning to thread mode, thus this
|
||||||
|
* is a nested exception: the stack frame is on the MSP */
|
||||||
|
mrsne r0, PSP /* if not, we are returning to thread mode, thus this is
|
||||||
|
* not a nested exception: the stack frame is on the PSP */
|
||||||
|
|
||||||
push {lr}
|
push {lr}
|
||||||
bl _Fault
|
bl _Fault
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue