ArmPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the ArmPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Andrew Fish <afish@apple.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:53:50 -08:00
committed by mergify[bot]
parent 7c2a6033c1
commit 429309e0c6
142 changed files with 6020 additions and 5216 deletions

View File

@@ -22,14 +22,14 @@
#include <Protocol/DebugSupport.h>
#include <Protocol/LoadedImage.h>
STATIC CHAR8 *gExceptionTypeString[] = {
STATIC CHAR8 *gExceptionTypeString[] = {
"Synchronous",
"IRQ",
"FIQ",
"SError"
};
STATIC BOOLEAN mRecursiveException;
STATIC BOOLEAN mRecursiveException;
CHAR8 *
GetImageName (
@@ -41,47 +41,79 @@ GetImageName (
STATIC
VOID
DescribeInstructionOrDataAbort (
IN CHAR8 *AbortType,
IN UINTN Iss
IN CHAR8 *AbortType,
IN UINTN Iss
)
{
CHAR8 *AbortCause;
CHAR8 *AbortCause;
switch (Iss & 0x3f) {
case 0x0: AbortCause = "Address size fault, zeroth level of translation or translation table base register"; break;
case 0x1: AbortCause = "Address size fault, first level"; break;
case 0x2: AbortCause = "Address size fault, second level"; break;
case 0x3: AbortCause = "Address size fault, third level"; break;
case 0x4: AbortCause = "Translation fault, zeroth level"; break;
case 0x5: AbortCause = "Translation fault, first level"; break;
case 0x6: AbortCause = "Translation fault, second level"; break;
case 0x7: AbortCause = "Translation fault, third level"; break;
case 0x9: AbortCause = "Access flag fault, first level"; break;
case 0xa: AbortCause = "Access flag fault, second level"; break;
case 0xb: AbortCause = "Access flag fault, third level"; break;
case 0xd: AbortCause = "Permission fault, first level"; break;
case 0xe: AbortCause = "Permission fault, second level"; break;
case 0xf: AbortCause = "Permission fault, third level"; break;
case 0x10: AbortCause = "Synchronous external abort"; break;
case 0x18: AbortCause = "Synchronous parity error on memory access"; break;
case 0x11: AbortCause = "Asynchronous external abort"; break;
case 0x19: AbortCause = "Asynchronous parity error on memory access"; break;
case 0x14: AbortCause = "Synchronous external abort on translation table walk, zeroth level"; break;
case 0x15: AbortCause = "Synchronous external abort on translation table walk, first level"; break;
case 0x16: AbortCause = "Synchronous external abort on translation table walk, second level"; break;
case 0x17: AbortCause = "Synchronous external abort on translation table walk, third level"; break;
case 0x1c: AbortCause = "Synchronous parity error on memory access on translation table walk, zeroth level"; break;
case 0x1d: AbortCause = "Synchronous parity error on memory access on translation table walk, first level"; break;
case 0x1e: AbortCause = "Synchronous parity error on memory access on translation table walk, second level"; break;
case 0x1f: AbortCause = "Synchronous parity error on memory access on translation table walk, third level"; break;
case 0x21: AbortCause = "Alignment fault"; break;
case 0x22: AbortCause = "Debug event"; break;
case 0x30: AbortCause = "TLB conflict abort"; break;
case 0x0: AbortCause = "Address size fault, zeroth level of translation or translation table base register";
break;
case 0x1: AbortCause = "Address size fault, first level";
break;
case 0x2: AbortCause = "Address size fault, second level";
break;
case 0x3: AbortCause = "Address size fault, third level";
break;
case 0x4: AbortCause = "Translation fault, zeroth level";
break;
case 0x5: AbortCause = "Translation fault, first level";
break;
case 0x6: AbortCause = "Translation fault, second level";
break;
case 0x7: AbortCause = "Translation fault, third level";
break;
case 0x9: AbortCause = "Access flag fault, first level";
break;
case 0xa: AbortCause = "Access flag fault, second level";
break;
case 0xb: AbortCause = "Access flag fault, third level";
break;
case 0xd: AbortCause = "Permission fault, first level";
break;
case 0xe: AbortCause = "Permission fault, second level";
break;
case 0xf: AbortCause = "Permission fault, third level";
break;
case 0x10: AbortCause = "Synchronous external abort";
break;
case 0x18: AbortCause = "Synchronous parity error on memory access";
break;
case 0x11: AbortCause = "Asynchronous external abort";
break;
case 0x19: AbortCause = "Asynchronous parity error on memory access";
break;
case 0x14: AbortCause = "Synchronous external abort on translation table walk, zeroth level";
break;
case 0x15: AbortCause = "Synchronous external abort on translation table walk, first level";
break;
case 0x16: AbortCause = "Synchronous external abort on translation table walk, second level";
break;
case 0x17: AbortCause = "Synchronous external abort on translation table walk, third level";
break;
case 0x1c: AbortCause = "Synchronous parity error on memory access on translation table walk, zeroth level";
break;
case 0x1d: AbortCause = "Synchronous parity error on memory access on translation table walk, first level";
break;
case 0x1e: AbortCause = "Synchronous parity error on memory access on translation table walk, second level";
break;
case 0x1f: AbortCause = "Synchronous parity error on memory access on translation table walk, third level";
break;
case 0x21: AbortCause = "Alignment fault";
break;
case 0x22: AbortCause = "Debug event";
break;
case 0x30: AbortCause = "TLB conflict abort";
break;
case 0x33:
case 0x34: AbortCause = "IMPLEMENTATION DEFINED"; break;
case 0x34: AbortCause = "IMPLEMENTATION DEFINED";
break;
case 0x35:
case 0x36: AbortCause = "Domain fault"; break;
default: AbortCause = ""; break;
case 0x36: AbortCause = "Domain fault";
break;
default: AbortCause = "";
break;
}
DEBUG ((DEBUG_ERROR, "\n%a: %a\n", AbortType, AbortCause));
@@ -90,24 +122,29 @@ DescribeInstructionOrDataAbort (
STATIC
VOID
DescribeExceptionSyndrome (
IN UINT32 Esr
IN UINT32 Esr
)
{
CHAR8 *Message;
UINTN Ec;
UINTN Iss;
CHAR8 *Message;
UINTN Ec;
UINTN Iss;
Ec = Esr >> 26;
Ec = Esr >> 26;
Iss = Esr & 0x00ffffff;
switch (Ec) {
case 0x15: Message = "SVC executed in AArch64"; break;
case 0x15: Message = "SVC executed in AArch64";
break;
case 0x20:
case 0x21: DescribeInstructionOrDataAbort ("Instruction abort", Iss); return;
case 0x22: Message = "PC alignment fault"; break;
case 0x23: Message = "SP alignment fault"; break;
case 0x21: DescribeInstructionOrDataAbort ("Instruction abort", Iss);
return;
case 0x22: Message = "PC alignment fault";
break;
case 0x23: Message = "SP alignment fault";
break;
case 0x24:
case 0x25: DescribeInstructionOrDataAbort ("Data abort", Iss); return;
case 0x25: DescribeInstructionOrDataAbort ("Data abort", Iss);
return;
default: return;
}
@@ -118,20 +155,22 @@ DescribeExceptionSyndrome (
STATIC
CONST CHAR8 *
BaseName (
IN CONST CHAR8 *FullName
IN CONST CHAR8 *FullName
)
{
CONST CHAR8 *Str;
CONST CHAR8 *Str;
Str = FullName + AsciiStrLen (FullName);
while (--Str > FullName) {
if (*Str == '/' || *Str == '\\') {
if ((*Str == '/') || (*Str == '\\')) {
return Str + 1;
}
}
return Str;
}
#endif
/**
@@ -145,8 +184,8 @@ BaseName (
**/
VOID
DefaultExceptionHandler (
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
CHAR8 Buffer[100];
@@ -154,75 +193,93 @@ DefaultExceptionHandler (
INT32 Offset;
if (mRecursiveException) {
STATIC CHAR8 CONST Message[] = "\nRecursive exception occurred while dumping the CPU state\n";
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);
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;
UINTN ImageBase;
UINTN PeCoffSizeOfHeader;
UINT64 *Fp;
UINT64 RootFp[2];
UINTN Idx;
CHAR8 *Pdb, *PrevPdb;
UINTN ImageBase;
UINTN PeCoffSizeOfHeader;
UINT64 *Fp;
UINT64 RootFp[2];
UINTN Idx;
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL) {
DEBUG ((
DEBUG_ERROR,
"PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n",
SystemContext.SystemContextAArch64->ELR,
ImageBase,
SystemContext.SystemContextAArch64->ELR - ImageBase,
BaseName (Pdb)
));
} else {
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAArch64->ELR));
}
if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) {
Idx = 0;
RootFp[0] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[0];
RootFp[1] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[1];
if (RootFp[1] != SystemContext.SystemContextAArch64->LR) {
RootFp[0] = SystemContext.SystemContextAArch64->FP;
RootFp[1] = SystemContext.SystemContextAArch64->LR;
}
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL) {
if (Pdb != PrevPdb) {
Idx++;
PrevPdb = Pdb;
}
DEBUG ((
DEBUG_ERROR,
"PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n",
Fp[1],
ImageBase,
Fp[1] - ImageBase,
Idx,
BaseName (Pdb)
));
} else {
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", Fp[1]));
}
}
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL) {
DEBUG ((DEBUG_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n",
SystemContext.SystemContextAArch64->ELR, ImageBase,
SystemContext.SystemContextAArch64->ELR - ImageBase, BaseName (Pdb)));
} else {
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAArch64->ELR));
DEBUG ((DEBUG_ERROR, "\n[ 0] %a\n", Pdb));
}
if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) {
Idx = 0;
RootFp[0] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[0];
RootFp[1] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[1];
if (RootFp[1] != SystemContext.SystemContextAArch64->LR) {
RootFp[0] = SystemContext.SystemContextAArch64->FP;
RootFp[1] = SystemContext.SystemContextAArch64->LR;
}
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL) {
if (Pdb != PrevPdb) {
Idx++;
PrevPdb = Pdb;
}
DEBUG ((DEBUG_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n",
Fp[1], ImageBase, Fp[1] - ImageBase, Idx, BaseName (Pdb)));
} else {
DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", Fp[1]));
}
}
PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL) {
DEBUG ((DEBUG_ERROR, "\n[ 0] %a\n", Pdb));
}
Idx = 0;
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL && Pdb != PrevPdb) {
DEBUG ((DEBUG_ERROR, "[% 2d] %a\n", ++Idx, Pdb));
PrevPdb = Pdb;
}
Idx = 0;
for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
if ((Pdb != NULL) && (Pdb != PrevPdb)) {
DEBUG ((DEBUG_ERROR, "[% 2d] %a\n", ++Idx, Pdb));
PrevPdb = Pdb;
}
}
}
DEBUG_CODE_END ();
DEBUG ((DEBUG_ERROR, "\n X0 0x%016lx X1 0x%016lx X2 0x%016lx X3 0x%016lx\n", SystemContext.SystemContextAArch64->X0, SystemContext.SystemContextAArch64->X1, SystemContext.SystemContextAArch64->X2, SystemContext.SystemContextAArch64->X3));
@@ -255,19 +312,22 @@ DefaultExceptionHandler (
DEBUG ((DEBUG_ERROR, "\n SP 0x%016lx ELR 0x%016lx SPSR 0x%08lx FPSR 0x%08lx\n ESR 0x%08lx FAR 0x%016lx\n", SystemContext.SystemContextAArch64->SP, SystemContext.SystemContextAArch64->ELR, SystemContext.SystemContextAArch64->SPSR, SystemContext.SystemContextAArch64->FPSR, SystemContext.SystemContextAArch64->ESR, SystemContext.SystemContextAArch64->FAR));
DEBUG ((DEBUG_ERROR, "\n ESR : EC 0x%02x IL 0x%x ISS 0x%08x\n", (SystemContext.SystemContextAArch64->ESR & 0xFC000000) >> 26, (SystemContext.SystemContextAArch64->ESR >> 25) & 0x1, SystemContext.SystemContextAArch64->ESR & 0x1FFFFFF ));
DEBUG ((DEBUG_ERROR, "\n ESR : EC 0x%02x IL 0x%x ISS 0x%08x\n", (SystemContext.SystemContextAArch64->ESR & 0xFC000000) >> 26, (SystemContext.SystemContextAArch64->ESR >> 25) & 0x1, SystemContext.SystemContextAArch64->ESR & 0x1FFFFFF));
DescribeExceptionSyndrome (SystemContext.SystemContextAArch64->ESR);
DEBUG ((DEBUG_ERROR, "\nStack dump:\n"));
for (Offset = -256; Offset < 256; Offset += 32) {
DEBUG ((DEBUG_ERROR, "%c %013lx: %016lx %016lx %016lx %016lx\n",
DEBUG ((
DEBUG_ERROR,
"%c %013lx: %016lx %016lx %016lx %016lx\n",
Offset == 0 ? '>' : ' ',
SystemContext.SystemContextAArch64->SP + Offset,
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset),
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 8),
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 16),
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 24)));
*(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 24)
));
}
ASSERT (FALSE);

View File

@@ -27,14 +27,14 @@
// The number of elements in a CHAR8 array, including the terminating NUL, that
// is meant to hold the string rendering of the CPSR.
//
#define CPSR_STRING_SIZE 32
#define CPSR_STRING_SIZE 32
typedef struct {
UINT32 BIT;
CHAR8 Char;
UINT32 BIT;
CHAR8 Char;
} CPSR_CHAR;
STATIC CONST CPSR_CHAR mCpsrChar[] = {
STATIC CONST CPSR_CHAR mCpsrChar[] = {
{ 31, 'n' },
{ 30, 'z' },
{ 29, 'c' },
@@ -72,9 +72,9 @@ CpsrString (
OUT CHAR8 *ReturnStr
)
{
UINTN Index;
CHAR8* Str;
CHAR8* ModeStr;
UINTN Index;
CHAR8 *Str;
CHAR8 *ModeStr;
Str = ReturnStr;
@@ -87,37 +87,37 @@ CpsrString (
}
*Str++ = '_';
*Str = '\0';
*Str = '\0';
switch (Cpsr & 0x1f) {
case 0x10:
ModeStr = "usr";
break;
case 0x011:
ModeStr = "fiq";
break;
case 0x12:
ModeStr = "irq";
break;
case 0x13:
ModeStr = "svc";
break;
case 0x16:
ModeStr = "mon";
break;
case 0x17:
ModeStr = "abt";
break;
case 0x1b:
ModeStr = "und";
break;
case 0x1f:
ModeStr = "sys";
break;
case 0x10:
ModeStr = "usr";
break;
case 0x011:
ModeStr = "fiq";
break;
case 0x12:
ModeStr = "irq";
break;
case 0x13:
ModeStr = "svc";
break;
case 0x16:
ModeStr = "mon";
break;
case 0x17:
ModeStr = "abt";
break;
case 0x1b:
ModeStr = "und";
break;
case 0x1f:
ModeStr = "sys";
break;
default:
ModeStr = "???";
break;
default:
ModeStr = "???";
break;
}
//
@@ -131,31 +131,47 @@ FaultStatusToString (
IN UINT32 Status
)
{
CHAR8 *FaultSource;
CHAR8 *FaultSource;
switch (Status) {
case 0x01: FaultSource = "Alignment fault"; break;
case 0x02: FaultSource = "Debug event fault"; break;
case 0x03: FaultSource = "Access Flag fault on Section"; break;
case 0x04: FaultSource = "Cache maintenance operation fault[2]"; break;
case 0x05: FaultSource = "Translation fault on Section"; break;
case 0x06: FaultSource = "Access Flag fault on Page"; break;
case 0x07: FaultSource = "Translation fault on Page"; break;
case 0x08: FaultSource = "Precise External Abort"; break;
case 0x09: FaultSource = "Domain fault on Section"; break;
case 0x0b: FaultSource = "Domain fault on Page"; break;
case 0x0c: FaultSource = "External abort on translation, first level"; break;
case 0x0d: FaultSource = "Permission fault on Section"; break;
case 0x0e: FaultSource = "External abort on translation, second level"; break;
case 0x0f: FaultSource = "Permission fault on Page"; break;
case 0x16: FaultSource = "Imprecise External Abort"; break;
default: FaultSource = "No function"; break;
}
case 0x01: FaultSource = "Alignment fault";
break;
case 0x02: FaultSource = "Debug event fault";
break;
case 0x03: FaultSource = "Access Flag fault on Section";
break;
case 0x04: FaultSource = "Cache maintenance operation fault[2]";
break;
case 0x05: FaultSource = "Translation fault on Section";
break;
case 0x06: FaultSource = "Access Flag fault on Page";
break;
case 0x07: FaultSource = "Translation fault on Page";
break;
case 0x08: FaultSource = "Precise External Abort";
break;
case 0x09: FaultSource = "Domain fault on Section";
break;
case 0x0b: FaultSource = "Domain fault on Page";
break;
case 0x0c: FaultSource = "External abort on translation, first level";
break;
case 0x0d: FaultSource = "Permission fault on Section";
break;
case 0x0e: FaultSource = "External abort on translation, second level";
break;
case 0x0f: FaultSource = "Permission fault on Page";
break;
case 0x16: FaultSource = "Imprecise External Abort";
break;
default: FaultSource = "No function";
break;
}
return FaultSource;
}
STATIC CHAR8 *gExceptionTypeString[] = {
STATIC CHAR8 *gExceptionTypeString[] = {
"Reset",
"Undefined OpCode",
"SVC",
@@ -178,62 +194,68 @@ STATIC CHAR8 *gExceptionTypeString[] = {
**/
VOID
DefaultExceptionHandler (
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
CHAR8 Buffer[100];
UINTN CharCount;
UINT32 DfsrStatus;
UINT32 IfsrStatus;
BOOLEAN DfsrWrite;
UINT32 PcAdjust;
CHAR8 Buffer[100];
UINTN CharCount;
UINT32 DfsrStatus;
UINT32 IfsrStatus;
BOOLEAN DfsrWrite;
UINT32 PcAdjust;
PcAdjust = 0;
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x CPSR 0x%08x ",
gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);
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);
if (gST->ConOut != NULL) {
AsciiPrint (Buffer);
}
DEBUG_CODE_BEGIN ();
CHAR8 *Pdb;
UINT32 ImageBase;
UINT32 PeCoffSizeOfHeader;
UINT32 Offset;
CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode
CHAR8 *Pdb;
UINT32 ImageBase;
UINT32 PeCoffSizeOfHeader;
UINT32 Offset;
CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode
// that is a 3 char string
CHAR8 Buffer[80];
UINT8 *DisAsm;
UINT32 ItBlock;
CHAR8 Buffer[80];
UINT8 *DisAsm;
UINT32 ItBlock;
CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr));
CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
DEBUG ((DEBUG_ERROR, "%a\n", CpsrStr));
Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);
Offset = SystemContext.SystemContextArm->PC - ImageBase;
if (Pdb != NULL) {
DEBUG ((DEBUG_ERROR, "%a\n", Pdb));
Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);
Offset = SystemContext.SystemContextArm->PC - ImageBase;
if (Pdb != NULL) {
DEBUG ((DEBUG_ERROR, "%a\n", Pdb));
//
// A PE/COFF image loads its headers into memory so the headers are
// included in the linked addresses. ELF and Mach-O images do not
// include the headers so the first byte of the image is usually
// text (code). If you look at link maps from ELF or Mach-O images
// you need to subtract out the size of the PE/COFF header to get
// get the offset that matches the link map.
//
DEBUG ((DEBUG_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));
//
// A PE/COFF image loads its headers into memory so the headers are
// included in the linked addresses. ELF and Mach-O images do not
// include the headers so the first byte of the image is usually
// text (code). If you look at link maps from ELF or Mach-O images
// you need to subtract out the size of the PE/COFF header to get
// get the offset that matches the link map.
//
DEBUG ((DEBUG_ERROR, "loaded at 0x%08x (PE/COFF offset) 0x%x (ELF or Mach-O offset) 0x%x", ImageBase, Offset, Offset - PeCoffSizeOfHeader));
// If we come from an image it is safe to show the instruction. We know it should not fault
DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;
ItBlock = 0;
DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));
DEBUG ((DEBUG_ERROR, "\n%a", Buffer));
// If we come from an image it is safe to show the instruction. We know it should not fault
DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;
ItBlock = 0;
DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, &ItBlock, Buffer, sizeof (Buffer));
DEBUG ((DEBUG_ERROR, "\n%a", Buffer));
switch (ExceptionType) {
switch (ExceptionType) {
case EXCEPT_ARM_UNDEFINED_INSTRUCTION:
case EXCEPT_ARM_SOFTWARE_INTERRUPT:
case EXCEPT_ARM_PREFETCH_ABORT:
@@ -244,9 +266,9 @@ DefaultExceptionHandler (
default:
break;
}
}
}
DEBUG_CODE_END ();
DEBUG ((DEBUG_ERROR, "\n R0 0x%08x R1 0x%08x R2 0x%08x R3 0x%08x\n", SystemContext.SystemContextArm->R0, SystemContext.SystemContextArm->R1, SystemContext.SystemContextArm->R2, SystemContext.SystemContextArm->R3));
DEBUG ((DEBUG_ERROR, " R4 0x%08x R5 0x%08x R6 0x%08x R7 0x%08x\n", SystemContext.SystemContextArm->R4, SystemContext.SystemContextArm->R5, SystemContext.SystemContextArm->R6, SystemContext.SystemContextArm->R7));
@@ -256,7 +278,7 @@ DefaultExceptionHandler (
// Bit10 is Status[4] Bit3:0 is Status[3:0]
DfsrStatus = (SystemContext.SystemContextArm->DFSR & 0xf) | ((SystemContext.SystemContextArm->DFSR >> 6) & 0x10);
DfsrWrite = (SystemContext.SystemContextArm->DFSR & BIT11) != 0;
DfsrWrite = (SystemContext.SystemContextArm->DFSR & BIT11) != 0;
if (DfsrStatus != 0x00) {
DEBUG ((DEBUG_ERROR, " %a: %a 0x%08x\n", FaultStatusToString (DfsrStatus), DfsrWrite ? "write to" : "read from", SystemContext.SystemContextArm->DFAR));
}

View File

@@ -33,11 +33,11 @@ GetImageName (
OUT UINTN *PeCoffSizeOfHeaders
)
{
EFI_STATUS Status;
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugTableHeader;
EFI_DEBUG_IMAGE_INFO *DebugTable;
UINTN Entry;
CHAR8 *Address;
EFI_STATUS Status;
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugTableHeader;
EFI_DEBUG_IMAGE_INFO *DebugTable;
UINTN Entry;
CHAR8 *Address;
Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&DebugTableHeader);
if (EFI_ERROR (Status)) {
@@ -53,10 +53,12 @@ GetImageName (
for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {
if (DebugTable->NormalImage != NULL) {
if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL))
{
if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
(Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {
*ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
(Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize)))
{
*ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
*PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase);
return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);
}
@@ -66,4 +68,3 @@ GetImageName (
return NULL;
}