]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/DefaultExceptionHandlerLib: use console if available
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 20 Dec 2018 17:31:04 +0000 (18:31 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 16 Jan 2019 20:33:35 +0000 (21:33 +0100)
Print the minimal 'exception occurred' message to the console as well
as to the serial port if the console is available. This makes such
messages visible on systems where the console is graphical and the
serial is not connected.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf

index 1024bf48c63d2fac3398f87bde09647b2f3727c9..40d4b218be360694afff5370872a5117e328af93 100644 (file)
@@ -22,6 +22,7 @@
 #include <Library/PrintLib.h>\r
 #include <Library/ArmDisassemblerLib.h>\r
 #include <Library/SerialPortLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 \r
 #include <Guid/DebugImageInfoTable.h>\r
 #include <Protocol/DebugSupport.h>\r
@@ -159,14 +160,21 @@ DefaultExceptionHandler (
   INT32  Offset;\r
 \r
   if (mRecursiveException) {\r
-    CharCount = AsciiSPrint (Buffer, sizeof (Buffer),"\nRecursive exception occurred while dumping the CPU state\n");\r
-    SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+    STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while dumping the CPU state\n";\r
+\r
+    SerialPortWrite ((UINT8 *)Message, sizeof Message - 1);\r
+    if (gST->ConOut != NULL) {\r
+      AsciiPrint (Message);\r
+    }\r
     CpuDeadLoop ();\r
   }\r
   mRecursiveException = TRUE;\r
 \r
   CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR);\r
   SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+  if (gST->ConOut != NULL) {\r
+    AsciiPrint (Buffer);\r
+  }\r
 \r
   DEBUG_CODE_BEGIN ();\r
     CHAR8  *Pdb, *PrevPdb;\r
index cc79cb2fa3017bdd33fe7de616099f18a84aeb16..2e0cfb2d4e036a3f018159fdc23e4d857a1191cb 100644 (file)
@@ -21,6 +21,7 @@
 #include <Library/PrintLib.h>\r
 #include <Library/ArmDisassemblerLib.h>\r
 #include <Library/SerialPortLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 \r
 #include <Guid/DebugImageInfoTable.h>\r
 \r
@@ -194,7 +195,10 @@ DefaultExceptionHandler (
 \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
-  SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+  SerialPortWrite ((UINT8 *)Buffer, CharCount);\r
+  if (gST->ConOut != NULL) {\r
+    AsciiPrint (Buffer);\r
+  }\r
 \r
   DEBUG_CODE_BEGIN ();\r
     CHAR8   *Pdb;\r
index 7609f82d89a15c39256fc366cad8212940f30add..6bc48714c9dc2a374c05267a44bae595eab3951b 100644 (file)
@@ -42,6 +42,7 @@
   PeCoffGetEntryPointLib\r
   ArmDisassemblerLib\r
   SerialPortLib\r
+  UefiBootServicesTableLib\r
 \r
 [Guids]\r
   gEfiDebugImageInfoTableGuid\r