summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
diff options
context:
space:
mode:
Diffstat (limited to 'ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c')
-rw-r--r--ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
index 13b321e456..accad647d6 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
@@ -24,6 +24,12 @@
#include <Library/DefaultExceptionHandlerLib.h>
//
+// Maximum number of characters to print to serial (UINT8s) and to console if
+// available (as UINT16s)
+//
+#define MAX_PRINT_CHARS 100
+
+//
// The number of elements in a CHAR8 array, including the terminating NUL, that
// is meant to hold the string rendering of the CPSR.
//
@@ -198,7 +204,8 @@ DefaultExceptionHandler (
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
- CHAR8 Buffer[100];
+ CHAR8 Buffer[MAX_PRINT_CHARS];
+ CHAR16 UnicodeBuffer[MAX_PRINT_CHARS];
UINTN CharCount;
UINT32 DfsrStatus;
UINT32 IfsrStatus;
@@ -216,9 +223,10 @@ DefaultExceptionHandler (
SystemContext.SystemContextArm->CPSR
);
SerialPortWrite ((UINT8 *)Buffer, CharCount);
- if (gST->ConOut != NULL) {
- AsciiPrint (Buffer);
- }
+
+ // Prepare a unicode buffer for ConOut, if applicable, as Buffer is used
+ // below.
+ UnicodeSPrintAsciiFormat (UnicodeBuffer, MAX_PRINT_CHARS, Buffer);
DEBUG_CODE_BEGIN ();
CHAR8 *Pdb;
@@ -289,6 +297,14 @@ DefaultExceptionHandler (
}
DEBUG ((DEBUG_ERROR, "\n"));
+
+ // Attempt to print that we had a synchronous exception to ConOut. We do
+ // this after the serial logging as ConOut's logging is more complex and we
+ // aren't guaranteed to succeed.
+ if (gST->ConOut != NULL) {
+ gST->ConOut->OutputString (gST->ConOut, UnicodeBuffer);
+ }
+
ASSERT (FALSE);
CpuDeadLoop (); // may return if executing under a debugger