mirror of https://github.com/acidanthera/audk.git
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 <eugene@hp.com> Tested-by: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
parent
0b6249f590
commit
82ea9a6b59
|
@ -27,8 +27,6 @@
|
||||||
#include <Protocol/DebugSupport.h>
|
#include <Protocol/DebugSupport.h>
|
||||||
#include <Protocol/LoadedImage.h>
|
#include <Protocol/LoadedImage.h>
|
||||||
|
|
||||||
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL;
|
|
||||||
|
|
||||||
STATIC CHAR8 *gExceptionTypeString[] = {
|
STATIC CHAR8 *gExceptionTypeString[] = {
|
||||||
"Synchronous",
|
"Synchronous",
|
||||||
"IRQ",
|
"IRQ",
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include <Protocol/DebugSupport.h>
|
#include <Protocol/DebugSupport.h>
|
||||||
#include <Library/DefaultExceptionHandlerLib.h>
|
#include <Library/DefaultExceptionHandlerLib.h>
|
||||||
|
|
||||||
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT32 BIT;
|
UINT32 BIT;
|
||||||
CHAR8 Char;
|
CHAR8 Char;
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = DefaultExceptionHandlerLib
|
LIBRARY_CLASS = DefaultExceptionHandlerLib
|
||||||
CONSTRUCTOR = DefaultExceptionHandlerConstructor
|
|
||||||
|
|
||||||
[Sources.common]
|
[Sources.common]
|
||||||
DefaultExceptionHandlerUefi.c
|
DefaultExceptionHandlerUefi.c
|
||||||
|
|
|
@ -18,34 +18,6 @@
|
||||||
|
|
||||||
#include <Guid/DebugImageInfoTable.h>
|
#include <Guid/DebugImageInfoTable.h>
|
||||||
|
|
||||||
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
|
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
|
it came from. As long as the PE/COFF image contains a debug directory entry a
|
||||||
|
@ -67,17 +39,24 @@ GetImageName (
|
||||||
OUT UINTN *PeCoffSizeOfHeaders
|
OUT UINTN *PeCoffSizeOfHeaders
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_DEBUG_IMAGE_INFO *DebugTable;
|
EFI_STATUS Status;
|
||||||
UINTN Entry;
|
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugTableHeader;
|
||||||
CHAR8 *Address;
|
EFI_DEBUG_IMAGE_INFO *DebugTable;
|
||||||
|
UINTN Entry;
|
||||||
|
CHAR8 *Address;
|
||||||
|
|
||||||
DebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable;
|
Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&DebugTableHeader);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugTable = DebugTableHeader->EfiDebugImageInfoTable;
|
||||||
if (DebugTable == NULL) {
|
if (DebugTable == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Address = (CHAR8 *)(UINTN)FaultAddress;
|
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 != NULL) {
|
||||||
if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
|
if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
|
||||||
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
|
(DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
|
||||||
|
|
Loading…
Reference in New Issue