]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c
Arm Packages: Fixed coding style/Line endings to follow EDK2 coding convention
[mirror_edk2.git] / ArmPkg / Library / DefaultExceptionHandlerLib / DefaultExceptionHandler.c
index 927a66b915ab76ac3ad421992261ffc91166599c..07e31ea597b5b995290e0696c3537d42a1eae19a 100644 (file)
@@ -1,9 +1,9 @@
 /** @file\r
   Default exception handler\r
 \r
-  Copyright (c) 2008-2010, Apple Inc. All rights reserved.\r
+  Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
   \r
-  All rights reserved. This program and the accompanying materials\r
+  This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   http://opensource.org/licenses/bsd-license.php\r
@@ -33,8 +33,6 @@ typedef struct {
   CHAR8   Char;\r
 } CPSR_CHAR;\r
 \r
-\r
-\r
  \r
 /**\r
   Use the EFI Debug Image Table to lookup the FaultAddress and find which PE/COFF image \r
@@ -61,7 +59,6 @@ GetImageName (
   UINTN                 Entry;\r
   CHAR8                 *Address;\r
 \r
-  \r
   DebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable;\r
   if (DebugTable == NULL) {\r
     return NULL;\r
@@ -102,9 +99,9 @@ CpsrString (
   OUT CHAR8   *ReturnStr\r
   )\r
 {\r
-  UINTN Index;\r
-  CHAR8 *Str = ReturnStr;\r
-  CHAR8 *ModeStr;\r
+  UINTN     Index;\r
+  CHAR8*    Str;\r
+  CHAR8*    ModeStr;\r
   CPSR_CHAR CpsrChar[] = {\r
     { 31, 'n' },\r
     { 30, 'z' },\r
@@ -119,6 +116,8 @@ CpsrString (
     { 0,  '?' }\r
   };\r
   \r
+  Str = ReturnStr;\r
+\r
   for (Index = 0; CpsrChar[Index].BIT != 0; Index++, Str++) {\r
     *Str = CpsrChar[Index].Char;\r
     if ((Cpsr & (1 << CpsrChar[Index].BIT)) != 0) {\r
@@ -194,8 +193,7 @@ FaultStatusToString (
   return FaultSource;\r
 }\r
 \r
-\r
-CHAR8 *gExceptionTypeString[] = {\r
+STATIC CHAR8 *gExceptionTypeString[] = {\r
   "Reset",\r
   "Undefined OpCode",\r
   "SWI",\r
@@ -206,7 +204,6 @@ CHAR8 *gExceptionTypeString[] = {
   "FIQ"\r
 };\r
 \r
-\r
 /**\r
   This is the default action to take on an unexpected exception\r
   \r
@@ -228,7 +225,7 @@ DefaultExceptionHandler (
   BOOLEAN   DfsrWrite;\r
   UINT32    PcAdjust = 0;\r
 \r
-  DEBUG ((EFI_D_ERROR, "\n%a Exception PC at 0x%08x  CPSR 0x%08x ", gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR));\r
+  Print(L"\n%a Exception PC at 0x%08x  CPSR 0x%08x ", gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);\r
   DEBUG_CODE_BEGIN ();\r
     CHAR8   *Pdb;\r
     UINT32  ImageBase;\r
@@ -249,10 +246,10 @@ DefaultExceptionHandler (
 \r
       //\r
       // A PE/COFF image loads its headers into memory so the headers are \r
-      // included in the linked addressess. ELF and Mach-O images do not\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 subtact out the size of the PE/COFF header to get\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 ((EFI_D_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));\r
@@ -299,6 +296,10 @@ DefaultExceptionHandler (
   DEBUG ((EFI_D_ERROR, "\n"));\r
   ASSERT (FALSE);\r
   \r
+  // Clear the error registers that we have already displayed incase some one wants to keep going\r
+  SystemContext.SystemContextArm->DFSR = 0;\r
+  SystemContext.SystemContextArm->IFSR = 0;\r
+\r
   // If some one is stepping past the exception handler adjust the PC to point to the next instruction \r
   SystemContext.SystemContextArm->PC += PcAdjust;\r
 }\r