1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-05 19:51:45 +00:00

Fix exception handlers (thanks @fincs)

This commit is contained in:
TuxSH 2018-05-21 03:39:18 +02:00
parent 43d1816ac2
commit ea2693dd2d
2 changed files with 10 additions and 9 deletions

View file

@ -37,10 +37,11 @@ void exception_handler_main(uint32_t *registers, unsigned int exception_type) {
uint32_t instr_addr = pc + ((cpsr & 0x20) ? 2 : 4) - CODE_DUMP_SIZE; uint32_t instr_addr = pc + ((cpsr & 0x20) ? 2 : 4) - CODE_DUMP_SIZE;
code_dump_size =0;// safecpy(code_dump, (const void *)instr_addr, CODE_DUMP_SIZE);
stack_dump_size = safecpy(stack_dump, (const void *)registers[14], STACK_DUMP_SIZE);
printk("Something went wrong...\n"); printk("Something went wrong...\n");
code_dump_size = safecpy(code_dump, (const void *)instr_addr, CODE_DUMP_SIZE);
stack_dump_size = safecpy(stack_dump, (const void *)registers[13], STACK_DUMP_SIZE);
printk("\nException type: %s\n", exception_names[exception_type]); printk("\nException type: %s\n", exception_names[exception_type]);
printk("\nRegisters:\n\n"); printk("\nRegisters:\n\n");
@ -55,6 +56,7 @@ void exception_handler_main(uint32_t *registers, unsigned int exception_type) {
printk("\nCode dump:\n"); printk("\nCode dump:\n");
hexdump(code_dump, code_dump_size, instr_addr); hexdump(code_dump, code_dump_size, instr_addr);
printk("\nStack dump:\n"); printk("\nStack dump:\n");
hexdump(stack_dump, stack_dump_size, registers[14]); hexdump(stack_dump, stack_dump_size, registers[13]);
printk("\n");
fatal_error("An exception occured!\n"); fatal_error("An exception occured!\n");
} }

View file

@ -55,12 +55,10 @@ _exception_handler_data_abort:
/* Mask interrupts (abort mode). */ /* Mask interrupts (abort mode). */
msr cpsr_cx, #0xD7 msr cpsr_cx, #0xD7
adr sp, safecpy adr sp, safecpy+8
add sp, sp, #8
cmp lr, sp cmp lr, sp
blo _exception_handler_data_abort_normal blo _exception_handler_data_abort_normal
adr sp, _safecpy_end adr sp, _safecpy_end+8
add sp, sp, #8
cmp lr, sp cmp lr, sp
bhs _exception_handler_data_abort_normal bhs _exception_handler_data_abort_normal
@ -87,7 +85,8 @@ safecpy:
_safecpy_loop_end: _safecpy_loop_end:
mov r0, r3 mov r0, r3
pop {r4, pc} pop {r4, lr}
bx lr /* Need to do that separately on ARMv4. */
_safecpy_end: _safecpy_end: