thermosphere: add ExceptionSyndromeRegister definition

This commit is contained in:
TuxSH 2019-07-22 22:01:21 +02:00
parent 4e0eef2784
commit b5c6b06dad
2 changed files with 64 additions and 13 deletions

View file

@ -21,30 +21,30 @@ static void dumpStackFrame(const ExceptionStackFrame *frame, bool sameEl)
{ {
#ifndef NDEBUG #ifndef NDEBUG
for (u32 i = 0; i < 30; i += 2) { for (u32 i = 0; i < 30; i += 2) {
serialLog("x%d\t\t%08lx\t\tx%d\t\t%08lx\r\n", i, frame->x[i], i + 1, frame->x[i + 1]); serialLog("x%u\t\t%08llx\t\tx%u\t\t%08llx\r\n", i, frame->x[i], i + 1, frame->x[i + 1]);
} }
serialLog("x30\t\t%08lx\r\n\r\n", frame->x[30]); serialLog("x30\t\t%08llx\r\n\r\n", frame->x[30]);
serialLog("elr_el2\t\t%08lx\r\n", frame->elr_el2); serialLog("elr_el2\t\t%08llx\r\n", frame->elr_el2);
serialLog("spsr_el2\t%08lx\r\n", frame->spsr_el2); serialLog("spsr_el2\t%08llx\r\n", frame->spsr_el2);
if (sameEl) { if (sameEl) {
serialLog("sp_el2\t\t%08lx\r\n", frame->sp_el2); serialLog("sp_el2\t\t%08llx\r\n", frame->sp_el2);
} else { } else {
serialLog("sp_el0\t\t%08lx\r\n", frame->sp_el0); serialLog("sp_el0\t\t%08llx\r\n", frame->sp_el0);
} }
serialLog("sp_el1\t\t%08lx\r\n", frame->sp_el1); serialLog("sp_el1\t\t%08llx\r\n", frame->sp_el1);
#endif #endif
} }
void handleLowerElSyncException(ExceptionStackFrame *frame, u32 esr) void handleLowerElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
{ {
serialLog("Lower EL sync exception, ESR = 0x%08lx\r\n", esr); serialLog("Lower EL sync exception, EC = 0x%02llx IL=%llu ISS=0x%06llx\r\n", (u64)esr.ec, esr.il, esr.iss);
dumpStackFrame(frame, false); dumpStackFrame(frame, false);
} }
void handleSameElSyncException(ExceptionStackFrame *frame, u32 esr) void handleSameElSyncException(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
{ {
serialLog("Same EL sync exception, ESR = 0x%08lx\r\n", esr); serialLog("Same EL sync exception, EC = 0x%02llx IL=%llu ISS=0x%06llx\r\n", (u64)esr.ec, esr.il, esr.iss);
dumpStackFrame(frame, true); dumpStackFrame(frame, true);
} }

View file

@ -27,3 +27,54 @@ typedef struct ExceptionStackFrame {
u64 elr_el2; u64 elr_el2;
u64 spsr_el2; u64 spsr_el2;
} ExceptionStackFrame; } ExceptionStackFrame;
// Adapted from https://developer.arm.com/docs/ddi0596/a/a64-shared-pseudocode-functions/shared-exceptions-pseudocode
typedef enum ExceptionClass {
Exception_Uncategorized = 0x0,
Exception_WFxTrap = 0x1,
Exception_CP15RTTrap = 0x3,
Exception_CP15RRTTrap = 0x4,
Exception_CP14RTTrap = 0x5,
Exception_CP14DTTrap = 0x6,
Exception_AdvSIMDFPAccessTrap = 0x7,
Exception_FPIDTrap = 0x8,
Exception_PACTrap = 0x9,
Exception_CP14RRTTrap = 0xC,
Exception_BranchTargetException = 0xD, // No official enum field name from Arm yet
Exception_IllegalState = 0xE,
Exception_SupervisorCallA32 = 0x11,
Exception_HypervisorCallA32 = 0x12,
Exception_MonitorCallA32 = 0x13,
Exception_SupervisorCallA64 = 0x15,
Exception_HypervisorCallA64 = 0x16,
Exception_MonitorCallA64 = 0x17,
Exception_SystemRegisterTrap = 0x18,
Exception_SVEAccessTrap = 0x19,
Exception_ERetTrap = 0x1A,
Exception_El3_ImplementationDefined = 0x1F,
Exception_InstructionAbortLowerEl = 0x20,
Exception_InstructionAbortSameEl = 0x21,
Exception_PCAlignment = 0x22,
Exception_DataAbortLowerEl = 0x24,
Exception_DataAbortSameEl = 0x25,
Exception_SPAlignment = 0x26,
Exception_FPTrappedExceptionA32 = 0x28,
Exception_FPTrappedExceptionA64 = 0x2C,
Exception_SError = 0x2F,
Exception_BreakpointLowerEl = 0x30,
Exception_BreakpointSameEl = 0x31,
Exception_SoftwareStepLowerEl = 0x32,
Exception_SoftwareStepSameEl = 0x33,
Exception_WatchpointLowerEl = 0x34,
Exception_WatchpointSameEl = 0x35,
Exception_SoftwareBreakpointA32 = 0x38,
Exception_VectorCatchA32 = 0x3A,
Exception_SoftwareBreakpointA64 = 0x3C,
} ExceptionClass;
typedef struct ExceptionSyndromeRegister {
u32 iss : 25; // Instruction Specific Syndrome
u32 il : 1; // Instruction Length (16 or 32-bit)
ExceptionClass ec : 6; // Exception Class
u32 res0 : 32;
} ExceptionSyndromeRegister;