HardFault: preserve locals from optimization in Fault handlers (#5466)
This commit is contained in:
parent
3c5636d26f
commit
8282962db5
|
@ -39,18 +39,18 @@ void HardFault_Handler_C(void* sp) {
|
||||||
memcpy(&ctx, sp, sizeof(struct port_extctx));
|
memcpy(&ctx, sp, sizeof(struct port_extctx));
|
||||||
|
|
||||||
//Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
|
//Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
|
||||||
FaultType faultType = (FaultType)__get_IPSR();
|
volatile FaultType faultType = (FaultType)__get_IPSR();
|
||||||
(void)faultType;
|
(void)faultType;
|
||||||
//For HardFault/BusFault this is the address that was accessed causing the error
|
//For HardFault/BusFault this is the address that was accessed causing the error
|
||||||
uint32_t faultAddress = SCB->BFAR;
|
volatile uint32_t faultAddress = SCB->BFAR;
|
||||||
|
|
||||||
//Flags about hardfault / busfault
|
//Flags about hardfault / busfault
|
||||||
//See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
|
//See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
|
||||||
bool isFaultPrecise = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 1) ? true : false);
|
volatile bool isFaultPrecise = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 1) ? true : false);
|
||||||
bool isFaultImprecise = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 2) ? true : false);
|
volatile bool isFaultImprecise = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 2) ? true : false);
|
||||||
bool isFaultOnUnstacking = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 3) ? true : false);
|
volatile bool isFaultOnUnstacking = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 3) ? true : false);
|
||||||
bool isFaultOnStacking = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 4) ? true : false);
|
volatile bool isFaultOnStacking = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 4) ? true : false);
|
||||||
bool isFaultAddressValid = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 7) ? true : false);
|
volatile bool isFaultAddressValid = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 7) ? true : false);
|
||||||
(void)isFaultPrecise;
|
(void)isFaultPrecise;
|
||||||
(void)isFaultImprecise;
|
(void)isFaultImprecise;
|
||||||
(void)isFaultOnUnstacking;
|
(void)isFaultOnUnstacking;
|
||||||
|
@ -71,16 +71,16 @@ void UsageFault_Handler_C(void* sp) {
|
||||||
memcpy(&ctx, sp, sizeof(struct port_extctx));
|
memcpy(&ctx, sp, sizeof(struct port_extctx));
|
||||||
|
|
||||||
//Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
|
//Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
|
||||||
FaultType faultType = (FaultType)__get_IPSR();
|
volatile FaultType faultType = (FaultType)__get_IPSR();
|
||||||
(void)faultType;
|
(void)faultType;
|
||||||
//Flags about hardfault / busfault
|
//Flags about hardfault / busfault
|
||||||
//See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
|
//See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
|
||||||
bool isUndefinedInstructionFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 0) ? true : false);
|
volatile bool isUndefinedInstructionFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 0) ? true : false);
|
||||||
bool isEPSRUsageFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 1) ? true : false);
|
volatile bool isEPSRUsageFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 1) ? true : false);
|
||||||
bool isInvalidPCFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 2) ? true : false);
|
volatile bool isInvalidPCFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 2) ? true : false);
|
||||||
bool isNoCoprocessorFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 3) ? true : false);
|
volatile bool isNoCoprocessorFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 3) ? true : false);
|
||||||
bool isUnalignedAccessFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 8) ? true : false);
|
volatile bool isUnalignedAccessFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 8) ? true : false);
|
||||||
bool isDivideByZeroFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 9) ? true : false);
|
volatile bool isDivideByZeroFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 9) ? true : false);
|
||||||
(void)isUndefinedInstructionFault;
|
(void)isUndefinedInstructionFault;
|
||||||
(void)isEPSRUsageFault;
|
(void)isEPSRUsageFault;
|
||||||
(void)isInvalidPCFault;
|
(void)isInvalidPCFault;
|
||||||
|
@ -104,15 +104,15 @@ void MemManage_Handler_C(void* sp) {
|
||||||
FaultType faultType = (FaultType)__get_IPSR();
|
FaultType faultType = (FaultType)__get_IPSR();
|
||||||
(void)faultType;
|
(void)faultType;
|
||||||
//For HardFault/BusFault this is the address that was accessed causing the error
|
//For HardFault/BusFault this is the address that was accessed causing the error
|
||||||
uint32_t faultAddress = SCB->MMFAR;
|
volatile uint32_t faultAddress = SCB->MMFAR;
|
||||||
|
|
||||||
//Flags about hardfault / busfault
|
//Flags about hardfault / busfault
|
||||||
//See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
|
//See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
|
||||||
bool isInstructionAccessViolation = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 0) ? true : false);
|
volatile bool isInstructionAccessViolation = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 0) ? true : false);
|
||||||
bool isDataAccessViolation = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 1) ? true : false);
|
volatile bool isDataAccessViolation = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 1) ? true : false);
|
||||||
bool isExceptionUnstackingFault = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 3) ? true : false);
|
volatile bool isExceptionUnstackingFault = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 3) ? true : false);
|
||||||
bool isExceptionStackingFault = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 4) ? true : false);
|
volatile bool isExceptionStackingFault = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 4) ? true : false);
|
||||||
bool isFaultAddressValid = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 7) ? true : false);
|
volatile bool isFaultAddressValid = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 7) ? true : false);
|
||||||
(void)isInstructionAccessViolation;
|
(void)isInstructionAccessViolation;
|
||||||
(void)isDataAccessViolation;
|
(void)isDataAccessViolation;
|
||||||
(void)isExceptionUnstackingFault;
|
(void)isExceptionUnstackingFault;
|
||||||
|
|
Loading…
Reference in New Issue