// The number of elements in a CHAR8 array, including the terminating NUL, that\r
// is meant to hold the string rendering of the CPSR.\r
//\r
-#define CPSR_STRING_SIZE 32\r
+#define CPSR_STRING_SIZE 32\r
\r
typedef struct {\r
- UINT32 BIT;\r
- CHAR8 Char;\r
+ UINT32 BIT;\r
+ CHAR8 Char;\r
} CPSR_CHAR;\r
\r
-STATIC CONST CPSR_CHAR mCpsrChar[] = {\r
+STATIC CONST CPSR_CHAR mCpsrChar[] = {\r
{ 31, 'n' },\r
{ 30, 'z' },\r
{ 29, 'c' },\r
OUT CHAR8 *ReturnStr\r
)\r
{\r
- UINTN Index;\r
- CHAR8* Str;\r
- CHAR8* ModeStr;\r
+ UINTN Index;\r
+ CHAR8 *Str;\r
+ CHAR8 *ModeStr;\r
\r
Str = ReturnStr;\r
\r
}\r
\r
*Str++ = '_';\r
- *Str = '\0';\r
+ *Str = '\0';\r
\r
switch (Cpsr & 0x1f) {\r
- case 0x10:\r
- ModeStr = "usr";\r
- break;\r
- case 0x011:\r
- ModeStr = "fiq";\r
- break;\r
- case 0x12:\r
- ModeStr = "irq";\r
- break;\r
- case 0x13:\r
- ModeStr = "svc";\r
- break;\r
- case 0x16:\r
- ModeStr = "mon";\r
- break;\r
- case 0x17:\r
- ModeStr = "abt";\r
- break;\r
- case 0x1b:\r
- ModeStr = "und";\r
- break;\r
- case 0x1f:\r
- ModeStr = "sys";\r
- break;\r
-\r
- default:\r
- ModeStr = "???";\r
- break;\r
+ case 0x10:\r
+ ModeStr = "usr";\r
+ break;\r
+ case 0x011:\r
+ ModeStr = "fiq";\r
+ break;\r
+ case 0x12:\r
+ ModeStr = "irq";\r
+ break;\r
+ case 0x13:\r
+ ModeStr = "svc";\r
+ break;\r
+ case 0x16:\r
+ ModeStr = "mon";\r
+ break;\r
+ case 0x17:\r
+ ModeStr = "abt";\r
+ break;\r
+ case 0x1b:\r
+ ModeStr = "und";\r
+ break;\r
+ case 0x1f:\r
+ ModeStr = "sys";\r
+ break;\r
+\r
+ default:\r
+ ModeStr = "???";\r
+ break;\r
}\r
\r
//\r
IN UINT32 Status\r
)\r
{\r
- CHAR8 *FaultSource;\r
+ CHAR8 *FaultSource;\r
\r
switch (Status) {\r
- case 0x01: FaultSource = "Alignment fault"; break;\r
- case 0x02: FaultSource = "Debug event fault"; break;\r
- case 0x03: FaultSource = "Access Flag fault on Section"; break;\r
- case 0x04: FaultSource = "Cache maintenance operation fault[2]"; break;\r
- case 0x05: FaultSource = "Translation fault on Section"; break;\r
- case 0x06: FaultSource = "Access Flag fault on Page"; break;\r
- case 0x07: FaultSource = "Translation fault on Page"; break;\r
- case 0x08: FaultSource = "Precise External Abort"; break;\r
- case 0x09: FaultSource = "Domain fault on Section"; break;\r
- case 0x0b: FaultSource = "Domain fault on Page"; break;\r
- case 0x0c: FaultSource = "External abort on translation, first level"; break;\r
- case 0x0d: FaultSource = "Permission fault on Section"; break;\r
- case 0x0e: FaultSource = "External abort on translation, second level"; break;\r
- case 0x0f: FaultSource = "Permission fault on Page"; break;\r
- case 0x16: FaultSource = "Imprecise External Abort"; break;\r
- default: FaultSource = "No function"; break;\r
- }\r
+ case 0x01: FaultSource = "Alignment fault";\r
+ break;\r
+ case 0x02: FaultSource = "Debug event fault";\r
+ break;\r
+ case 0x03: FaultSource = "Access Flag fault on Section";\r
+ break;\r
+ case 0x04: FaultSource = "Cache maintenance operation fault[2]";\r
+ break;\r
+ case 0x05: FaultSource = "Translation fault on Section";\r
+ break;\r
+ case 0x06: FaultSource = "Access Flag fault on Page";\r
+ break;\r
+ case 0x07: FaultSource = "Translation fault on Page";\r
+ break;\r
+ case 0x08: FaultSource = "Precise External Abort";\r
+ break;\r
+ case 0x09: FaultSource = "Domain fault on Section";\r
+ break;\r
+ case 0x0b: FaultSource = "Domain fault on Page";\r
+ break;\r
+ case 0x0c: FaultSource = "External abort on translation, first level";\r
+ break;\r
+ case 0x0d: FaultSource = "Permission fault on Section";\r
+ break;\r
+ case 0x0e: FaultSource = "External abort on translation, second level";\r
+ break;\r
+ case 0x0f: FaultSource = "Permission fault on Page";\r
+ break;\r
+ case 0x16: FaultSource = "Imprecise External Abort";\r
+ break;\r
+ default: FaultSource = "No function";\r
+ break;\r
+ }\r
\r
return FaultSource;\r
}\r
\r
-STATIC CHAR8 *gExceptionTypeString[] = {\r
+STATIC CHAR8 *gExceptionTypeString[] = {\r
"Reset",\r
"Undefined OpCode",\r
"SVC",\r
**/\r
VOID\r
DefaultExceptionHandler (\r
- IN EFI_EXCEPTION_TYPE ExceptionType,\r
- IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
+ IN EFI_EXCEPTION_TYPE ExceptionType,\r
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
)\r
{\r
- CHAR8 Buffer[100];\r
- UINTN CharCount;\r
- UINT32 DfsrStatus;\r
- UINT32 IfsrStatus;\r
- BOOLEAN DfsrWrite;\r
- UINT32 PcAdjust;\r
+ CHAR8 Buffer[100];\r
+ UINTN CharCount;\r
+ UINT32 DfsrStatus;\r
+ UINT32 IfsrStatus;\r
+ BOOLEAN DfsrWrite;\r
+ UINT32 PcAdjust;\r
\r
PcAdjust = 0;\r
\r
- CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x CPSR 0x%08x ",\r
- gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);\r
+ CharCount = AsciiSPrint (\r
+ Buffer,\r
+ sizeof (Buffer),\r
+ "\n%a Exception PC at 0x%08x CPSR 0x%08x ",\r
+ gExceptionTypeString[ExceptionType],\r
+ SystemContext.SystemContextArm->PC,\r
+ SystemContext.SystemContextArm->CPSR\r
+ );\r
SerialPortWrite ((UINT8 *)Buffer, CharCount);\r
if (gST->ConOut != NULL) {\r
AsciiPrint (Buffer);\r
}\r
\r
DEBUG_CODE_BEGIN ();\r
- CHAR8 *Pdb;\r
- UINT32 ImageBase;\r
- UINT32 PeCoffSizeOfHeader;\r
- UINT32 Offset;\r
- CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode\r
+ CHAR8 *Pdb;\r
+ UINT32 ImageBase;\r
+ UINT32 PeCoffSizeOfHeader;\r
+ UINT32 Offset;\r
+ CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode\r
// that is a 3 char string\r
- CHAR8 Buffer[80];\r
- UINT8 *DisAsm;\r
- UINT32 ItBlock;\r
-\r
- CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);\r
- DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr));\r
-\r
- Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);\r
- Offset = SystemContext.SystemContextArm->PC - ImageBase;\r
- if (Pdb != NULL) {\r
- DEBUG ((DEBUG_ERROR, "%a\n", Pdb));\r
-\r
- //\r
- // A PE/COFF image loads its headers into memory so the headers are\r
- // included in the linked addresses. ELF and Mach-O images do not\r
- // include the headers so the first byte of the image is usually\r
- // text (code). If you look at link maps from ELF or Mach-O images\r
- // you need to subtract out the size of the PE/COFF header to get\r
- // get the offset that matches the link map.\r
- //\r
- DEBUG ((DEBUG_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));\r
-\r
- // If we come from an image it is safe to show the instruction. We know it should not fault\r
- DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;\r
- ItBlock = 0;\r
- DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));\r
- DEBUG ((DEBUG_ERROR, "\n%a", Buffer));\r
-\r
- switch (ExceptionType) {\r
+ CHAR8 Buffer[80];\r
+ UINT8 *DisAsm;\r
+ UINT32 ItBlock;\r
+\r
+ CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);\r
+ DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr));\r
+\r
+ Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);\r
+ Offset = SystemContext.SystemContextArm->PC - ImageBase;\r
+ if (Pdb != NULL) {\r
+ DEBUG ((DEBUG_ERROR, "%a\n", Pdb));\r
+\r
+ //\r
+ // A PE/COFF image loads its headers into memory so the headers are\r
+ // included in the linked addresses. ELF and Mach-O images do not\r
+ // include the headers so the first byte of the image is usually\r
+ // text (code). If you look at link maps from ELF or Mach-O images\r
+ // you need to subtract out the size of the PE/COFF header to get\r
+ // get the offset that matches the link map.\r
+ //\r
+ DEBUG ((DEBUG_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));\r
+\r
+ // If we come from an image it is safe to show the instruction. We know it should not fault\r
+ DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;\r
+ ItBlock = 0;\r
+ DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));\r
+ DEBUG ((DEBUG_ERROR, "\n%a", Buffer));\r
+\r
+ switch (ExceptionType) {\r
case EXCEPT_ARM_UNDEFINED_INSTRUCTION:\r
case EXCEPT_ARM_SOFTWARE_INTERRUPT:\r
case EXCEPT_ARM_PREFETCH_ABORT:\r
\r
default:\r
break;\r
- }\r
-\r
}\r
+ }\r
+\r
DEBUG_CODE_END ();\r
DEBUG ((DEBUG_ERROR, "\n R0 0x%08x R1 0x%08x R2 0x%08x R3 0x%08x\n", SystemContext.SystemContextArm->R0, SystemContext.SystemContextArm->R1, SystemContext.SystemContextArm->R2, SystemContext.SystemContextArm->R3));\r
DEBUG ((DEBUG_ERROR, " R4 0x%08x R5 0x%08x R6 0x%08x R7 0x%08x\n", SystemContext.SystemContextArm->R4, SystemContext.SystemContextArm->R5, SystemContext.SystemContextArm->R6, SystemContext.SystemContextArm->R7));\r
\r
// Bit10 is Status[4] Bit3:0 is Status[3:0]\r
DfsrStatus = (SystemContext.SystemContextArm->DFSR & 0xf) | ((SystemContext.SystemContextArm->DFSR >> 6) & 0x10);\r
- DfsrWrite = (SystemContext.SystemContextArm->DFSR & BIT11) != 0;\r
+ DfsrWrite = (SystemContext.SystemContextArm->DFSR & BIT11) != 0;\r
if (DfsrStatus != 0x00) {\r
DEBUG ((DEBUG_ERROR, " %a: %a 0x%08x\n", FaultStatusToString (DfsrStatus), DfsrWrite ? "write to" : "read from", SystemContext.SystemContextArm->DFAR));\r
}\r