ArmPkg/DefaultExceptionHandlerLib: use console if available

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>
This commit is contained in:
Ard Biesheuvel 2018-12-20 18:31:04 +01:00
parent 1e32c49718
commit 31f5388006
3 changed files with 16 additions and 3 deletions

View File

@ -22,6 +22,7 @@
#include <Library/PrintLib.h>
#include <Library/ArmDisassemblerLib.h>
#include <Library/SerialPortLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Guid/DebugImageInfoTable.h>
#include <Protocol/DebugSupport.h>
@ -159,14 +160,21 @@ DefaultExceptionHandler (
INT32 Offset;
if (mRecursiveException) {
CharCount = AsciiSPrint (Buffer, sizeof (Buffer),"\nRecursive exception occurred while dumping the CPU state\n");
SerialPortWrite ((UINT8 *) Buffer, CharCount);
STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while dumping the CPU state\n";
SerialPortWrite ((UINT8 *)Message, sizeof Message - 1);
if (gST->ConOut != NULL) {
AsciiPrint (Message);
}
CpuDeadLoop ();
}
mRecursiveException = TRUE;
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR);
SerialPortWrite ((UINT8 *) Buffer, CharCount);
if (gST->ConOut != NULL) {
AsciiPrint (Buffer);
}
DEBUG_CODE_BEGIN ();
CHAR8 *Pdb, *PrevPdb;

View File

@ -21,6 +21,7 @@
#include <Library/PrintLib.h>
#include <Library/ArmDisassemblerLib.h>
#include <Library/SerialPortLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Guid/DebugImageInfoTable.h>
@ -194,7 +195,10 @@ DefaultExceptionHandler (
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x CPSR 0x%08x ",
gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);
SerialPortWrite ((UINT8 *) Buffer, CharCount);
SerialPortWrite ((UINT8 *)Buffer, CharCount);
if (gST->ConOut != NULL) {
AsciiPrint (Buffer);
}
DEBUG_CODE_BEGIN ();
CHAR8 *Pdb;

View File

@ -42,6 +42,7 @@
PeCoffGetEntryPointLib
ArmDisassemblerLib
SerialPortLib
UefiBootServicesTableLib
[Guids]
gEfiDebugImageInfoTableGuid