]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
ArmPkg: DefaultExceptionHandler fixes for use with DxeCore
[mirror_edk2.git] / ArmPkg / Library / DefaultExceptionHandlerLib / DefaultExceptionHandlerUefi.c
CommitLineData
619b3998 1/** @file\r
2\r
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
4\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <Uefi.h>\r
16#include <Library/PeCoffGetEntryPointLib.h>\r
17#include <Library/UefiLib.h>\r
18\r
19#include <Guid/DebugImageInfoTable.h>\r
20\r
619b3998 21/**\r
22 Use the EFI Debug Image Table to lookup the FaultAddress and find which PE/COFF image\r
23 it came from. As long as the PE/COFF image contains a debug directory entry a\r
24 string can be returned. For ELF and Mach-O images the string points to the Mach-O or ELF\r
25 image. Microsoft tools contain a pointer to the PDB file that contains the debug information.\r
26\r
27 @param FaultAddress Address to find PE/COFF image for.\r
28 @param ImageBase Return load address of found image\r
29 @param PeCoffSizeOfHeaders Return the size of the PE/COFF header for the image that was found\r
30\r
31 @retval NULL FaultAddress not in a loaded PE/COFF image.\r
32 @retval Path and file name of PE/COFF image.\r
33\r
34**/\r
35CHAR8 *\r
36GetImageName (\r
c63626b7 37 IN UINTN FaultAddress,\r
38 OUT UINTN *ImageBase,\r
39 OUT UINTN *PeCoffSizeOfHeaders\r
619b3998 40 )\r
41{\r
82ea9a6b
EC
42 EFI_STATUS Status;\r
43 EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugTableHeader;\r
44 EFI_DEBUG_IMAGE_INFO *DebugTable;\r
45 UINTN Entry;\r
46 CHAR8 *Address;\r
47\r
48 Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&DebugTableHeader);\r
49 if (EFI_ERROR (Status)) {\r
50 return NULL;\r
51 }\r
619b3998 52\r
82ea9a6b 53 DebugTable = DebugTableHeader->EfiDebugImageInfoTable;\r
619b3998 54 if (DebugTable == NULL) {\r
55 return NULL;\r
56 }\r
57\r
58 Address = (CHAR8 *)(UINTN)FaultAddress;\r
82ea9a6b 59 for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {\r
619b3998 60 if (DebugTable->NormalImage != NULL) {\r
61 if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&\r
62 (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {\r
63 if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&\r
64 (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {\r
c63626b7 65 *ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;\r
619b3998 66 *PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase);\r
67 return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);\r
68 }\r
69 }\r
70 }\r
71 }\r
72\r
73 return NULL;\r
74}\r
c63626b7 75\r