mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 21:52:48 +00:00
Beautified exception handler
This commit is contained in:
parent
e8b34a90be
commit
f46a88c9ff
@ -6,6 +6,9 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "fsinit.h"
|
#include "fsinit.h"
|
||||||
#include "fsutil.h"
|
#include "fsutil.h"
|
||||||
|
#include "power.h"
|
||||||
|
#include "rtc.h"
|
||||||
|
#include "hid.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
#include <arm.h>
|
#include <arm.h>
|
||||||
@ -42,47 +45,57 @@ extern char __stack_top;
|
|||||||
|
|
||||||
void XRQ_DumpRegisters(u32 xrq, u32 *regs)
|
void XRQ_DumpRegisters(u32 xrq, u32 *regs)
|
||||||
{
|
{
|
||||||
int y;
|
|
||||||
u32 sp, st, pc;
|
u32 sp, st, pc;
|
||||||
char dumpstr[2048], *wstr = dumpstr;
|
char dumpstr[2048], *wstr = dumpstr;
|
||||||
|
|
||||||
|
DsTime dstime;
|
||||||
|
get_dstime(&dstime);
|
||||||
|
|
||||||
ClearScreen(MAIN_SCREEN, COLOR_BLACK);
|
|
||||||
|
/* Dump registers */
|
||||||
/* Print registers on screen */
|
|
||||||
wstr += sprintf(wstr, "Exception: %s (%lu)\n", XRQ_Name[xrq&7], xrq);
|
wstr += sprintf(wstr, "Exception: %s (%lu)\n", XRQ_Name[xrq&7], xrq);
|
||||||
|
wstr += sprintf(wstr, "20%02lX-%02lX-%02lX %02lX:%02lX:%02lX\n \n",
|
||||||
|
(u32) dstime.bcd_Y, (u32) dstime.bcd_M, (u32) dstime.bcd_D,
|
||||||
|
(u32) dstime.bcd_h, (u32) dstime.bcd_m, (u32) dstime.bcd_s);
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
int i_ = i*2;
|
int i_ = i*2;
|
||||||
wstr += sprintf(wstr,
|
wstr += sprintf(wstr,
|
||||||
"R%02d: %08lX | R%02d: %08lX\n", i_, regs[i_], i_+1, regs[i_+1]);
|
"R%02d: %08lX | R%02d: %08lX\n", i_, regs[i_], i_+1, regs[i_+1]);
|
||||||
}
|
}
|
||||||
wstr += sprintf(wstr, "CPSR: %08lX\n", regs[16]);
|
wstr += sprintf(wstr, "CPSR: %08lX\n\n", regs[16]);
|
||||||
|
|
||||||
DrawStringF(MAIN_SCREEN, 10, 0, COLOR_WHITE, COLOR_BLACK, dumpstr);
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Output registers to main screen */
|
||||||
|
u32 draw_width = GetDrawStringWidth(dumpstr);
|
||||||
|
u32 draw_height = GetDrawStringHeight(dumpstr);
|
||||||
|
u32 draw_x = (SCREEN_WIDTH_MAIN - draw_width) / 2;
|
||||||
|
u32 draw_y = (SCREEN_HEIGHT - draw_height) / 2;
|
||||||
|
u32 draw_y_upd = draw_y + draw_height - 10;
|
||||||
|
|
||||||
|
ClearScreen(MAIN_SCREEN, COLOR_STD_BG);
|
||||||
|
DrawStringF(MAIN_SCREEN, draw_x, draw_y, COLOR_STD_FONT, COLOR_STD_BG, dumpstr);
|
||||||
|
|
||||||
|
|
||||||
/* Reinitialize SD */
|
/* Reinitialize SD */
|
||||||
y = GetDrawStringHeight(dumpstr);
|
DrawStringF(MAIN_SCREEN, draw_x, draw_y_upd, COLOR_STD_FONT, COLOR_STD_BG,
|
||||||
DrawString(MAIN_SCREEN, "Reinitializing SD subsystem...", 10, y,
|
"%-29.29s", "Reinitializing SD card...");
|
||||||
COLOR_WHITE, COLOR_BLACK);
|
while (!InitSDCardFS()) {
|
||||||
y+=FONT_HEIGHT_EXT;
|
if (InputWait(1) & BUTTON_POWER) PowerOff();
|
||||||
|
|
||||||
while(!InitSDCardFS()) {
|
|
||||||
DeinitSDCardFS();
|
DeinitSDCardFS();
|
||||||
}
|
}
|
||||||
DrawString(MAIN_SCREEN, "Done", 10, y, COLOR_WHITE, COLOR_BLACK);
|
|
||||||
y+=FONT_HEIGHT_EXT;
|
|
||||||
|
|
||||||
|
|
||||||
/* Dump STACK */
|
/* Dump STACK */
|
||||||
sp = regs[13] & ~0xF;
|
sp = regs[13] & ~0xF;
|
||||||
st = (u32)&__stack_top;
|
st = (u32)&__stack_top;
|
||||||
wstr += sprintf(wstr, "\nStack dump:\n\n");
|
wstr += sprintf(wstr, "Stack dump:\n");
|
||||||
wstr += XRQ_DumpData_u8(wstr, sp, min(sp+SP_DUMPLEN, st));
|
wstr += XRQ_DumpData_u8(wstr, sp, min(sp+SP_DUMPLEN, st));
|
||||||
|
wstr += sprintf(wstr, "\n");
|
||||||
|
|
||||||
|
|
||||||
/* Dump TEXT */
|
/* Dump TEXT */
|
||||||
pc = regs[15] & ~0xF;
|
pc = regs[15] & ~0xF;
|
||||||
wstr += sprintf(wstr, "\nCode dump:\n\n");
|
wstr += sprintf(wstr, "Code dump:\n");
|
||||||
if (regs[16] & SR_THUMB) {
|
if (regs[16] & SR_THUMB) {
|
||||||
wstr += XRQ_DumpData_u16(wstr, pc-PC_DUMPRAD, pc+PC_DUMPRAD);
|
wstr += XRQ_DumpData_u16(wstr, pc-PC_DUMPRAD, pc+PC_DUMPRAD);
|
||||||
} else {
|
} else {
|
||||||
@ -91,13 +104,25 @@ void XRQ_DumpRegisters(u32 xrq, u32 *regs)
|
|||||||
|
|
||||||
|
|
||||||
/* Dump to SD */
|
/* Dump to SD */
|
||||||
DrawString(MAIN_SCREEN, "Dumping state to SD...", 10, y,
|
char path[64];
|
||||||
COLOR_WHITE, COLOR_BLACK);
|
snprintf(path, 64, "%s/exception_dump_%02lX%02lX%02lX%02lX%02lX%02lX.txt", OUTPUT_PATH,
|
||||||
y+=FONT_HEIGHT_EXT;
|
(u32) dstime.bcd_Y, (u32) dstime.bcd_M, (u32) dstime.bcd_D,
|
||||||
|
(u32) dstime.bcd_h, (u32) dstime.bcd_m, (u32) dstime.bcd_s);
|
||||||
FileSetData(OUTPUT_PATH"/exception_dump.txt", dumpstr, wstr - dumpstr, 0, true);
|
DrawStringF(MAIN_SCREEN, draw_x, draw_y_upd, COLOR_STD_FONT, COLOR_STD_BG,
|
||||||
DrawString(MAIN_SCREEN, "Done", 10, y, COLOR_WHITE, COLOR_BLACK);
|
"%-29.29s", "Dumping state to SD card...");
|
||||||
|
FileSetData(path, dumpstr, wstr - dumpstr, 0, true);
|
||||||
|
|
||||||
|
|
||||||
|
/* Deinit SD */
|
||||||
DeinitSDCardFS();
|
DeinitSDCardFS();
|
||||||
|
|
||||||
|
/* Done, wait for user power off */
|
||||||
|
DrawStringF(MAIN_SCREEN, draw_x, draw_y_upd, COLOR_STD_FONT, COLOR_STD_BG,
|
||||||
|
"%-29.29s", "Press POWER to turn off");
|
||||||
|
while (!(InputWait(0) & BUTTON_POWER));
|
||||||
|
PowerOff();
|
||||||
|
|
||||||
|
|
||||||
|
/* We will not return */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user