]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/CpuDxe/Exception.c
Adding support for a single stack, GCC check in will follow
[mirror_edk2.git] / ArmPkg / Drivers / CpuDxe / Exception.c
index fa256e60f84fd549387c9b511c3fa9c792b8b945..8859ca8667477fac4f38ba0a9bdf5446fdc89b63 100644 (file)
@@ -15,6 +15,8 @@
 #include "CpuDxe.h" \r
 #include <Library/CacheMaintenanceLib.h>\r
 \r
+extern BOOLEAN gExceptionContext;\r
+\r
 VOID\r
 ExceptionHandlersStart (\r
   VOID\r
@@ -120,7 +122,16 @@ RegisterDebuggerInterruptHandler (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
+CHAR8 *gExceptionTypeString[] = {\r
+  "Reset",\r
+  "Undefined Instruction",\r
+  "SWI",\r
+  "Prefetch Abort",\r
+  "Data Abort",\r
+  "Undefined",\r
+  "IRQ",\r
+  "FIQ"\r
+};\r
 \r
 VOID\r
 EFIAPI\r
@@ -130,6 +141,8 @@ CommonCExceptionHandler (
   )\r
 {\r
   BOOLEAN Dispatched = FALSE;\r
\r
+  gExceptionContext = TRUE; \r
   \r
   if (ExceptionType <= MAX_ARM_EXCEPTION) {\r
     if (gDebuggerExceptionHandlers[ExceptionType]) {\r
@@ -144,8 +157,13 @@ CommonCExceptionHandler (
       gExceptionHandlers[ExceptionType] (ExceptionType, SystemContext);\r
       Dispatched = TRUE;\r
     }\r
+  } else {\r
+    DEBUG ((EFI_D_ERROR, "Unknown exception type %d from %08x\n", ExceptionType, SystemContext.SystemContextArm->PC));\r
+    ASSERT (FALSE);\r
   }\r
 \r
+  gExceptionContext = FALSE; \r
+\r
   if (Dispatched) {\r
     //\r
     // We did work so this was an expected ExceptionType\r
@@ -163,7 +181,7 @@ CommonCExceptionHandler (
   //\r
   // Code after here is the default exception handler...\r
   //\r
-  DEBUG ((EFI_D_ERROR, "Exception %d from %08x\n", ExceptionType, SystemContext.SystemContextArm->PC));\r
+  DEBUG ((EFI_D_ERROR, "%a Exception from %08x\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC));\r
   ASSERT (FALSE);\r
 \r
 }\r
@@ -200,7 +218,7 @@ InitializeExceptions (
   }\r
   \r
   //\r
-  // Copy an implementation of the ARM exception vectors to 0x0.\r
+  // Copy an implementation of the ARM exception vectors to PcdCpuVectorBaseAddress.\r
   //\r
   Length = (UINTN)ExceptionHandlersEnd - (UINTN)ExceptionHandlersStart;\r
 \r
@@ -213,7 +231,7 @@ InitializeExceptions (
   // on embedded systems, for example, we don't want to hang up.  So we'll check here for a status of \r
   // EFI_NOT_FOUND, and continue in that case.\r
   if (EFI_ERROR(Status) && (Status != EFI_NOT_FOUND)) {\r
-  ASSERT_EFI_ERROR (Status);\r
+    ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
   CopyMem ((VOID *)(UINTN)PcdGet32 (PcdCpuVectorBaseAddress), (VOID *)ExceptionHandlersStart, Length);\r
@@ -225,7 +243,7 @@ InitializeExceptions (
   *(UINTN *) ((UINT8 *)(UINTN)PcdGet32 (PcdCpuVectorBaseAddress) + Offset) = (UINTN)AsmCommonExceptionEntry;\r
 \r
   // Flush Caches since we updated executable stuff\r
-  InvalidateInstructionCacheRange((VOID *)PcdGet32(PcdCpuVectorBaseAddress), Length);\r
+  InvalidateInstructionCacheRange ((VOID *)PcdGet32(PcdCpuVectorBaseAddress), Length);\r
 \r
   if (Enabled) {\r
     // \r