Add simple exception handling
This adds support for exception handling. It should provide simple and fast reporting of crucial info and full restoration without powering off.
This commit is contained in:
@@ -1182,8 +1182,24 @@ static void _patched_rcm_protection()
|
||||
sdmmc_storage_end(&storage);
|
||||
}
|
||||
|
||||
#define EXCP_EN_ADDR 0x4003FFFC
|
||||
#define EXCP_MAGIC 0x30505645 // EVP0
|
||||
#define EXCP_TYPE_ADDR 0x4003FFF8
|
||||
#define EXCP_TYPE_RESET 0x545352 // RST
|
||||
#define EXCP_TYPE_UNDEF 0x464455 // UDF
|
||||
#define EXCP_TYPE_PABRT 0x54424150 // PABT
|
||||
#define EXCP_TYPE_DABRT 0x54424144 // DABT
|
||||
#define EXCP_LR_ADDR 0x4003FFF4
|
||||
|
||||
static void _show_errors()
|
||||
{
|
||||
u32 *excp_enabled = (u32 *)EXCP_EN_ADDR;
|
||||
u32 *excp_type = (u32 *)EXCP_TYPE_ADDR;
|
||||
u32 *excp_lr = (u32 *)EXCP_LR_ADDR;
|
||||
|
||||
if (*excp_enabled == EXCP_MAGIC)
|
||||
h_cfg.errors |= ERR_EXCEPT_ENB;
|
||||
|
||||
if (h_cfg.errors)
|
||||
{
|
||||
gfx_clear_grey(0x1B);
|
||||
@@ -1195,7 +1211,35 @@ static void _show_errors()
|
||||
if (h_cfg.errors & ERR_SYSOLD_MTC)
|
||||
WPRINTF("Missing or old Minerva library!\n");
|
||||
|
||||
WPRINTF("\nUpdate your bootloader folder!\n\n");
|
||||
if (h_cfg.errors & ~ERR_EXCEPT_ENB)
|
||||
{
|
||||
WPRINTF("\nUpdate your bootloader folder!\n\n");
|
||||
}
|
||||
|
||||
if (h_cfg.errors & ERR_EXCEPT_ENB)
|
||||
{
|
||||
WPRINTFARGS("An exception happened (LR %08X):\n", *excp_lr);
|
||||
switch (*excp_type)
|
||||
{
|
||||
case EXCP_TYPE_RESET:
|
||||
WPRINTF("Reset");
|
||||
break;
|
||||
case EXCP_TYPE_UNDEF:
|
||||
WPRINTF("Undefined instruction");
|
||||
break;
|
||||
case EXCP_TYPE_PABRT:
|
||||
WPRINTF("Prefetch abort");
|
||||
break;
|
||||
case EXCP_TYPE_DABRT:
|
||||
WPRINTF("Data abort");
|
||||
break;
|
||||
}
|
||||
WPRINTF("\n");
|
||||
|
||||
// Clear the exception.
|
||||
*excp_enabled = 0;
|
||||
}
|
||||
|
||||
WPRINTF("Press any key...");
|
||||
|
||||
msleep(2000);
|
||||
|
||||
Reference in New Issue
Block a user