From f235bc83a89857553cc322baa72feb682f8cc5a7 Mon Sep 17 00:00:00 2001 From: Nanquitas Date: Mon, 14 Aug 2017 16:10:50 +0200 Subject: [PATCH 1/5] Watchpoints: fix read DSCR to enable MonitorMode --- sysmodules/rosalina/source/gdb/watchpoints.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysmodules/rosalina/source/gdb/watchpoints.c b/sysmodules/rosalina/source/gdb/watchpoints.c index 3b21a42..e52a492 100644 --- a/sysmodules/rosalina/source/gdb/watchpoints.c +++ b/sysmodules/rosalina/source/gdb/watchpoints.c @@ -60,7 +60,7 @@ static void K_EnableMonitorModeDebugging(void) __asm__ __volatile__("cpsid aif"); u32 DSCR; - __asm__ __volatile__("mrc p15, 0, %[val], c0, c1, 0" : [val] "=r" (DSCR)); + __asm__ __volatile__("mrc p14, 0, %[val], c0, c1, 0" : [val] "=r" (DSCR)); DSCR |= 0x8000; __asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 0" :: [val] "r" (DSCR)); } From 26d0cafb390b504ca9128dad12fbdface302b2b1 Mon Sep 17 00:00:00 2001 From: Nanquitas Date: Tue, 15 Aug 2017 00:51:20 +0200 Subject: [PATCH 2/5] exception_parser.py: display the fault status source --- exceptions/exception_dump_parser.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/exceptions/exception_dump_parser.py b/exceptions/exception_dump_parser.py index 9220273..f9fdf2c 100644 --- a/exceptions/exception_dump_parser.py +++ b/exceptions/exception_dump_parser.py @@ -90,6 +90,13 @@ def makeRegisterLine(A, rA, B, rB): handledExceptionNames = ("FIQ", "undefined instruction", "prefetch abort", "data abort") registerNames = tuple("r{0}".format(i) for i in range(13)) + ("sp", "lr", "pc", "cpsr") + ("dfsr", "ifsr", "far") + ("fpexc", "fpinst", "fpinst2") svcBreakReasons = ("(svcBreak: panic)", "(svcBreak: assertion failed)", "(svcBreak: user-related)") +faultStatusSources = { + 0b1:'Alignment', 0b100:'Instruction cache maintenance operation fault', + 0b1100:'External Abort on translation - First-level', 0b1110:'External Abort on translation - Second-level', + 0b101:'Translation - Section', 0b111:'Translation - Page', 0b11:'Access bit - Section', 0b110:'Access bit - Page', + 0b1001:'Domain - Section', 0b1011:'Domain - Page', 0b1101:'Permission - Section', 0b1111:'Permission - Page', + 0b1000:'Precise External Abort', 0b10110:'Imprecise External Abort', 0b10:'Debug event' +} if __name__ == "__main__": parser = argparse.ArgumentParser(description="Parse Luma3DS exception dumps") @@ -146,6 +153,10 @@ if __name__ == "__main__": thumb = registers[16] & 0x20 != 0 addr = registers[15] - codeDumpSize + (2 if thumb else 4) + xfsr = registers[18] if exceptionType == 2 else registers[17] if exceptionType == 3 else 0 + if xfsr != 0: + print("\nFault Status Source: " + faultStatusSources[xfsr & 0xf]) + print("\nCode dump:\n") objdump_res = "" From b7f4ac02c86911d0afda977bd14ba3f0dbe03db1 Mon Sep 17 00:00:00 2001 From: Nanquitas Date: Tue, 15 Aug 2017 14:05:32 +0200 Subject: [PATCH 3/5] Exceptions: display more infos on screen (status, far, access type) --- source/exceptions.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/source/exceptions.c b/source/exceptions.c index 202dccb..5fd3da3 100644 --- a/source/exceptions.c +++ b/source/exceptions.c @@ -69,8 +69,21 @@ void detectAndProcessExceptionDumps(void) *registerNames[] = { "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12", "SP", "LR", "PC", "CPSR", "FPEXC" + }, + *faultStatusNames[] = { + "Alignment", "Instruction cache maintenance operation", + "External Abort on translation - First-level", "External Abort on translation - Second-level", + "Translation - Section", "Translation - Page", "Access bit - Section", "Access bit - Page", + "Domain - Section", "Domain - Page", "Permission - Section", "Permission - Page", + "Precise External Abort", "Imprecise External Abort", "Debug event" }; + static const u32 faultStatusValues[] = { + 0b1, 0b100, 0b1100, 0b1110, 0b101, 0b111, 0b11, 0b110, 0b1001, 0b1011, 0b1101, + 0b1111, 0b1000, 0b10110, 0b10 + }; + + initScreens(); drawString(true, 10, 10, COLOR_RED, "An exception occurred"); @@ -78,6 +91,17 @@ void detectAndProcessExceptionDumps(void) if(dumpHeader->processor == 11) posY = drawFormattedString(true, 10, 30, COLOR_WHITE, "Processor: ARM11 (core %u)", dumpHeader->core); else posY = drawString(true, 10, 30, COLOR_WHITE, "Processor: ARM9"); + const char *faultStatusInfos = NULL; + if (dumpHeader->type >= 2) + { + u32 xfsr = dumpHeader->type == 2 ? regs[18] : regs[17]; + xfsr &= 0xF; + for (int i = 0; i < 15; i++) + if (xfsr == faultStatusValues[i]){ + faultStatusInfos = faultStatusNames[i]; + break; + } + } if(dumpHeader->type == 2) { if((regs[16] & 0x20) == 0 && dumpHeader->codeDumpSize >= 4) @@ -101,6 +125,7 @@ void detectAndProcessExceptionDumps(void) } else posY = drawFormattedString(true, 10, posY + SPACING_Y, COLOR_WHITE, "Exception type: %s", handledExceptionNames[dumpHeader->type]); + if (faultStatusInfos != NULL) posY = drawFormattedString(true, 10, posY + SPACING_Y, COLOR_WHITE, "Fault status: %s", faultStatusInfos); if(dumpHeader->processor == 11 && dumpHeader->additionalDataSize != 0) posY = drawFormattedString(true, 10, posY + SPACING_Y, COLOR_WHITE, @@ -116,6 +141,8 @@ void detectAndProcessExceptionDumps(void) else if(dumpHeader->processor == 11) posY = drawFormattedString(true, 10 + 22 * SPACING_X, posY, COLOR_WHITE, "%-7s%08X", registerNames[i + 1], regs[20]); } + if (dumpHeader->type == 3) + posY = drawFormattedString(true, 10, posY + SPACING_Y, COLOR_WHITE, "%-7s%08X Access type: %s", "FAR", regs[19], regs[17] & (1u << 11) ? "Write":"Read"); posY += SPACING_Y; From 322a7050aa5a7055cb45ca09e4f7f61fd049feb1 Mon Sep 17 00:00:00 2001 From: Hikari-chin Date: Tue, 15 Aug 2017 09:01:48 -0400 Subject: [PATCH 4/5] Fix #791 --- sysmodules/rosalina/source/menus/miscellaneous.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysmodules/rosalina/source/menus/miscellaneous.c b/sysmodules/rosalina/source/menus/miscellaneous.c index bb9e852..7969431 100644 --- a/sysmodules/rosalina/source/menus/miscellaneous.c +++ b/sysmodules/rosalina/source/menus/miscellaneous.c @@ -224,7 +224,7 @@ void MiscellaneousMenu_SaveSettings(void) do { Draw_Lock(); - Draw_DrawString(10, 10, COLOR_TITLE, "Process patches menu"); + Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu"); if(R_SUCCEEDED(res)) Draw_DrawString(10, 30, COLOR_WHITE, "Operation succeeded."); else From 5fd5b4da89ecebecef5fcc13a23388a0f99146da Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Tue, 15 Aug 2017 11:19:00 +0100 Subject: [PATCH 5/5] Don't fix already transformed $DEVKITARM variable --- exceptions/exception_dump_parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exceptions/exception_dump_parser.py b/exceptions/exception_dump_parser.py index f9fdf2c..abcb25f 100644 --- a/exceptions/exception_dump_parser.py +++ b/exceptions/exception_dump_parser.py @@ -162,8 +162,9 @@ if __name__ == "__main__": objdump_res = "" try: path = os.path.join(os.environ["DEVKITARM"], "bin", "arm-none-eabi-objdump") - if os.name == "nt": - path = ''.join((path[1], ':', path[2:])).replace('/', '\\') + + if os.name == "nt" and path[0] == '/': + path = ''.join((path[1], ':', path[2:])) objdump_res = subprocess.check_output(( path, "-marm", "-b", "binary",