arm: cortex-m: move synchronous SVC assessment in a separate function
Move the assessment of a synchronous SVC error into a separate function. This commit does not introduce any behavioral changes. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
a8d6c14d30
commit
7930829826
1 changed files with 20 additions and 11 deletions
|
@ -632,6 +632,25 @@ static void debug_monitor(z_arch_esf_t *esf, bool *recoverable)
|
||||||
#error Unknown ARM architecture
|
#error Unknown ARM architecture
|
||||||
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
|
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
|
||||||
|
|
||||||
|
static inline bool z_arm_is_synchronous_svc(z_arch_esf_t *esf)
|
||||||
|
{
|
||||||
|
uint16_t *ret_addr = (uint16_t *)esf->basic.pc;
|
||||||
|
/* SVC is a 16-bit instruction. On a synchronous SVC
|
||||||
|
* escalated to Hard Fault, the return address is the
|
||||||
|
* next instruction, i.e. after the SVC.
|
||||||
|
*/
|
||||||
|
#define _SVC_OPCODE 0xDF00
|
||||||
|
|
||||||
|
uint16_t fault_insn = *(ret_addr - 1);
|
||||||
|
|
||||||
|
if (((fault_insn & 0xff00) == _SVC_OPCODE) &&
|
||||||
|
((fault_insn & 0x00ff) == _SVC_CALL_RUNTIME_EXCEPT)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#undef _SVC_OPCODE
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Dump hard fault information
|
* @brief Dump hard fault information
|
||||||
|
@ -655,21 +674,11 @@ static uint32_t hard_fault(z_arch_esf_t *esf, bool *recoverable)
|
||||||
* priority. We handle the case of Kernel OOPS and Stack
|
* priority. We handle the case of Kernel OOPS and Stack
|
||||||
* Fail here.
|
* Fail here.
|
||||||
*/
|
*/
|
||||||
uint16_t *ret_addr = (uint16_t *)esf->basic.pc;
|
if (z_arm_is_synchronous_svc(esf)) {
|
||||||
/* SVC is a 16-bit instruction. On a synchronous SVC
|
|
||||||
* escalated to Hard Fault, the return address is the
|
|
||||||
* next instruction, i.e. after the SVC.
|
|
||||||
*/
|
|
||||||
#define _SVC_OPCODE 0xDF00
|
|
||||||
|
|
||||||
uint16_t fault_insn = *(ret_addr - 1);
|
|
||||||
if (((fault_insn & 0xff00) == _SVC_OPCODE) &&
|
|
||||||
((fault_insn & 0x00ff) == _SVC_CALL_RUNTIME_EXCEPT)) {
|
|
||||||
|
|
||||||
PR_EXC("ARCH_EXCEPT with reason %x\n", esf->basic.r0);
|
PR_EXC("ARCH_EXCEPT with reason %x\n", esf->basic.r0);
|
||||||
reason = esf->basic.r0;
|
reason = esf->basic.r0;
|
||||||
}
|
}
|
||||||
#undef _SVC_OPCODE
|
|
||||||
|
|
||||||
*recoverable = memory_fault_recoverable(esf, true);
|
*recoverable = memory_fault_recoverable(esf, true);
|
||||||
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
|
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue