From: Cohen, Eugene Date: Wed, 10 Feb 2016 23:05:18 +0000 (+0000) Subject: ArmPkg: DefaultExceptionHandler fixes for use with DxeCore X-Git-Tag: edk2-stable201903~7871 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=82ea9a6b59b5f4f48712644d9b32d4d52a097a2e ArmPkg: DefaultExceptionHandler fixes for use with DxeCore Modify the DefaultExceptionHandler (uefi-variant) so it can be used by DxeCore (via CpuExceptionHandlerLib) where the debug info table is not yet published at library constructor time. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eugene Cohen Tested-by: Ryan Harkin Reviewed-by: Ard Biesheuvel --- diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index 49d36ed693..37fd578757 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -27,8 +27,6 @@ #include #include -EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL; - STATIC CHAR8 *gExceptionTypeString[] = { "Synchronous", "IRQ", diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c index 179fc224be..aece26355e 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c @@ -27,8 +27,6 @@ #include #include -EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL; - typedef struct { UINT32 BIT; CHAR8 Char; diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf index da8190bd3c..5d3ce892ff 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf @@ -20,7 +20,6 @@ MODULE_TYPE = UEFI_DRIVER VERSION_STRING = 1.0 LIBRARY_CLASS = DefaultExceptionHandlerLib - CONSTRUCTOR = DefaultExceptionHandlerConstructor [Sources.common] DefaultExceptionHandlerUefi.c diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c index b2d630cb33..4e87a1005d 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c @@ -18,34 +18,6 @@ #include -extern EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader; - -/** - The constructor function caches EFI Debug table information for use in the exception handler. - - - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -DefaultExceptionHandlerConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader); - if (EFI_ERROR (Status)) { - gDebugImageTableHeader = NULL; - } - return Status; -} - /** Use the EFI Debug Image Table to lookup the FaultAddress and find which PE/COFF image it came from. As long as the PE/COFF image contains a debug directory entry a @@ -67,17 +39,24 @@ GetImageName ( OUT UINTN *PeCoffSizeOfHeaders ) { - 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)) { + return NULL; + } - DebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable; + DebugTable = DebugTableHeader->EfiDebugImageInfoTable; if (DebugTable == NULL) { return NULL; } Address = (CHAR8 *)(UINTN)FaultAddress; - for (Entry = 0; Entry < gDebugImageTableHeader->TableSize; Entry++, DebugTable++) { + 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)) {