Skip to content
Snippets Groups Projects
Commit 5cbe0e79 authored by rahix's avatar rahix
Browse files

feat(l0dables): Exit in case of CPU exception

Currently, misbehaving l0dables which trigger some kind of CPU exception
will busy-spin in the exception handler with no way to return to another
app without a full reboot.

Fix this by calling epic_exit() in case of an exception to hopefully
allow a return to menu in most situations.
parent ceaec9bc
No related branches found
No related tags found
1 merge request!447A few improvements of the l0dable runtime
......@@ -188,15 +188,6 @@ DefaultHandler:
/*
* Declare all default ISRs.
*/
def_irq_handler NMI_Handler
def_irq_handler HardFault_Handler
def_irq_handler MemManage_Handler
def_irq_handler BusFault_Handler
def_irq_handler UsageFault_Handler
def_irq_handler SVC_Handler
def_irq_handler DebugMon_Handler
def_irq_handler PendSV_Handler
def_irq_handler PF_IRQHandler
def_irq_handler WDT0_IRQHandler
def_irq_handler RTC_IRQHandler
......
......@@ -128,3 +128,25 @@ uint32_t _sbrk(int incr)
brk += incr;
return (uint32_t)prev_brk;
}
void HardFault_Handler(void)
{
/*
* We pray that we're not currently in an API call and attempt
* returning. This is okay because a HardFault during an API call is
* extremely unlikely.
*
* In the future, we could improve this by "finishing" an ongoing API
* call before firing epic_exit().
*/
epic_exit(255);
}
/* Alias all other exception handlers to the HardFault_Handler. */
void NMI_Handler(void) __attribute__((alias("HardFault_Handler")));
void MemManage_Handler(void) __attribute__((alias("HardFault_Handler")));
void BusFault_Handler(void) __attribute__((alias("HardFault_Handler")));
void UsageFault_Handler(void) __attribute__((alias("HardFault_Handler")));
void SVC_Handler(void) __attribute__((alias("HardFault_Handler")));
void DebugMon_Handler(void) __attribute__((alias("HardFault_Handler")));
void PendSV_Handler(void) __attribute__((alias("HardFault_Handler")));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment