]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/CpuDxe/Exception.c
Missed a fix in the Cpu Driver. Added some more debug for Execption handling and...
[mirror_edk2.git] / ArmPkg / Drivers / CpuDxe / Exception.c
index bc67fc44ceb179a482f97a1ba623e236e6be23e2..d46971b33cc6e05636c0c4c938096818081ef3bd 100644 (file)
@@ -164,20 +164,6 @@ typedef struct {
   CHAR8   Char;\r
 } CPSR_CHAR;\r
 \r
-CPSR_CHAR gCpsrChar[] = {\r
-  { 31, 'n' },\r
-  { 30, 'z' },\r
-  { 29, 'c' },\r
-  { 28, 'v' },\r
-  { 27, 'q' },\r
-\r
-  { 8, 'a' },\r
-  { 7, 'i' },\r
-  { 6, 'f' },\r
-  { 5, 't' },\r
-  { 0, '?' }\r
-};\r
-\r
 \r
 VOID\r
 CpsrString (\r
@@ -188,10 +174,23 @@ CpsrString (
   UINTN Index;\r
   CHAR8 *Str = ReturnStr;\r
   CHAR8 *ModeStr;\r
+  CPSR_CHAR CpsrChar[] = {\r
+    { 31, 'n' },\r
+    { 30, 'z' },\r
+    { 29, 'c' },\r
+    { 28, 'v' },\r
+\r
+    { 9,  'e' },\r
+    { 8,  'a' },\r
+    { 7,  'i' },\r
+    { 6,  'f' },\r
+    { 5,  't' },\r
+    { 0,  '?' }\r
+  };\r
   \r
-  for (Index = 0; gCpsrChar[Index].Bit != 0; Index++, Str++) {\r
-    *Str = gCpsrChar[Index].Char;\r
-    if ((Cpsr & (1 << gCpsrChar[Index].Bit)) != 0) {\r
+  for (Index = 0; CpsrChar[Index].Bit != 0; Index++, Str++) {\r
+    *Str = CpsrChar[Index].Char;\r
+    if ((Cpsr & (1 << CpsrChar[Index].Bit)) != 0) {\r
       // Concert to upper case if bit is set\r
       *Str &= ~0x20;\r
     }\r
@@ -312,7 +311,16 @@ CommonCExceptionHandler (
       // you need to subtact out the size of the PE/COFF header to get\r
       // get the offset that matches the link map. \r
       //\r
-      DEBUG ((EFI_D_ERROR, "loadded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));\r
+      DEBUG ((EFI_D_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
+      if ((SystemContext.SystemContextArm->CPSR & 0x20) == 0) {\r
+        // ARM\r
+        DEBUG ((EFI_D_ERROR, "\nFaulting Instruction 0x%08x", *(UINT32 *)(UINTN)SystemContext.SystemContextArm->PC));\r
+      } else {\r
+        // Thumb\r
+        DEBUG ((EFI_D_ERROR, "\nFaulting Instruction 0x%04x", *(UINT16 *)(UINTN)SystemContext.SystemContextArm->PC));\r
+      }\r
     }\r
   DEBUG_CODE_END ();\r
   DEBUG ((EFI_D_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