diff options
author | AJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-01-14 16:18:02 +0000 |
---|---|---|
committer | AJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-01-14 16:18:02 +0000 |
commit | 62e797a489341b13a095b3cd7c0f7bd9eac12efe (patch) | |
tree | 2f75da867ce80104e6d15dc497c2f5edf30fd6ee /ArmPkg/Drivers/CpuDxe | |
parent | c11fa40c4e8124c7dfb8660b67aea1175e91cc13 (diff) | |
download | edk2-platforms-62e797a489341b13a095b3cd7c0f7bd9eac12efe.tar.xz |
Fix GCC build bug and add a debug library to dump load and unload commands into the RVI debugger window.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9752 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg/Drivers/CpuDxe')
-rw-r--r-- | ArmPkg/Drivers/CpuDxe/Exception.c | 112 |
1 files changed, 57 insertions, 55 deletions
diff --git a/ArmPkg/Drivers/CpuDxe/Exception.c b/ArmPkg/Drivers/CpuDxe/Exception.c index 1f84e314b4..1487fe8b2e 100644 --- a/ArmPkg/Drivers/CpuDxe/Exception.c +++ b/ArmPkg/Drivers/CpuDxe/Exception.c @@ -14,7 +14,7 @@ #include "CpuDxe.h"
-EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL; +EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL;
VOID
ExceptionHandlersStart (
@@ -122,36 +122,38 @@ RegisterDebuggerInterruptHandler ( }
-UINT32 -EFIAPI -PeCoffGetSizeOfHeaders ( - IN VOID *Pe32Data - ) -{ - EFI_IMAGE_DOS_HEADER *DosHdr; - EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; - UINTN SizeOfHeaders; - - DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data; - if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { - // - // DOS image header is present, so read the PE header after the DOS image header. - // - Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff)); - } else { - // - // DOS image header is not present, so PE header is at the image base. - // - Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data; - } - - if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { - SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize; - } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { - SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders; - } - - return SizeOfHeaders; +UINT32
+EFIAPI
+PeCoffGetSizeOfHeaders (
+ IN VOID *Pe32Data
+ )
+{
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ UINTN SizeOfHeaders;
+
+ DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
+ if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
+ }
+
+ if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
+ SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;
+ } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
+ } else {
+ SizeOfHeaders = 0;
+ }
+
+ return SizeOfHeaders;
}
@@ -162,10 +164,10 @@ GetImageName ( OUT UINT32 *PeCoffSizeOfHeaders
)
{
- EFI_DEBUG_IMAGE_INFO *DebugTable; - UINTN Entry; - CHAR8 *Address; - + EFI_DEBUG_IMAGE_INFO *DebugTable;
+ UINTN Entry;
+ CHAR8 *Address;
+
DebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable;
if (DebugTable == NULL) {
@@ -173,18 +175,18 @@ GetImageName ( }
Address = (CHAR8 *)(UINTN)FaultAddress;
- for (Entry = 0; Entry < gDebugImageTableHeader->TableSize; Entry++, DebugTable++) { - if (DebugTable->NormalImage != NULL) { - if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && - (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) { - if ((Address >= DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) && - (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) { - *ImageBase = (UINT32)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase; - *PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase); - return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase); - } - } - } + for (Entry = 0; Entry < gDebugImageTableHeader->TableSize; Entry++, DebugTable++) {
+ if (DebugTable->NormalImage != NULL) {
+ if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
+ (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
+ if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
+ (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {
+ *ImageBase = (UINT32)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
+ *PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase);
+ return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);
+ }
+ }
+ }
}
return NULL;
@@ -249,10 +251,10 @@ CommonCExceptionHandler ( //
DEBUG ((EFI_D_ERROR, "\n%a Exception from instruction at 0x%08x CPSR 0x%08x\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR));
DEBUG_CODE_BEGIN ();
- CHAR8 *Pdb; - UINT32 ImageBase; - UINT32 PeCoffSizeOfHeader; - UINT32 Offset; + CHAR8 *Pdb;
+ UINT32 ImageBase;
+ UINT32 PeCoffSizeOfHeader;
+ UINT32 Offset;
Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);
Offset = SystemContext.SystemContextArm->PC - ImageBase;
@@ -296,10 +298,10 @@ InitializeExceptions ( BOOLEAN Enabled;
EFI_PHYSICAL_ADDRESS Base;
- Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader); - if (EFI_ERROR (Status)) { - gDebugImageTableHeader = NULL; - } + Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader);
+ if (EFI_ERROR (Status)) {
+ gDebugImageTableHeader = NULL;
+ }
//
// Disable interrupts
|