Code: Select all
#define EPC ((u32 *)(0x404)) // that's where the kernel's handler stores EPC.
#define USER_HANDLER ((u32 *)(0x5F0)) // that's where the kernel's handler reads the custom handler.
int my_handler(void * arg) {
EPC[0] = 0; // remove the defective instruction
return 0; // the kernel's exception handler should go back to epc afterward.
}
void install_and_stuff(void) {
int intrStat;
CpuDisableIntr(&intrStat);
USER_HANDLER[0] = my_handler;
CpuEnableIntr(&intrStat);
printf("Before?\n");
__asm__("lw $a0, 1($0)\n"); // let's crash
printf("After?"\n");
}
I am now out of ideas. Does somebody have some spare for me ? :P