From b7f4ac02c86911d0afda977bd14ba3f0dbe03db1 Mon Sep 17 00:00:00 2001 From: Nanquitas Date: Tue, 15 Aug 2017 14:05:32 +0200 Subject: [PATCH] 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;