From 2fb718b0641735e130baf677d19cb0c046c4f908 Mon Sep 17 00:00:00 2001 From: mdkinney Date: Thu, 5 Feb 2009 19:32:40 +0000 Subject: [PATCH] Update PCI Bus Driver to use the PeCoffLib instead of paring the PE/COFF image itself git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7440 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Bus/Pci/PciBusDxe/PciBus.h | 1 + .../Bus/Pci/PciBusDxe/PciBusDxe.inf | 2 +- .../Bus/Pci/PciBusDxe/PciDriverOverride.c | 18 +++++++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.h b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.h index 74a4abf4df..2c09061695 100644 --- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.h +++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBus.h @@ -45,6 +45,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf index 3c8b63cd78..8fa69ec729 100644 --- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf +++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf @@ -86,7 +86,7 @@ BaseLib UefiDriverEntryPoint DebugLib - + PeCoffLib [Guids] gEfiPciOptionRomTableGuid # SOMETIMES_CONSUMED System Table diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDriverOverride.c b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDriverOverride.c index 6c9d6f8079..6ec208453e 100644 --- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDriverOverride.c +++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDriverOverride.c @@ -101,9 +101,8 @@ AddDriver ( ) { EFI_STATUS Status; - EFI_IMAGE_DOS_HEADER *DosHdr; - EFI_IMAGE_NT_HEADERS *PeHdr; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; PCI_DRIVER_OVERRIDE_LIST *Node; Status = gBS->HandleProtocol (DriverImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage); @@ -123,16 +122,21 @@ AddDriver ( PciIoDevice->BusOverride = TRUE; - DosHdr = (EFI_IMAGE_DOS_HEADER *) LoadedImage->ImageBase; - if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) { + ImageContext.Handle = LoadedImage->ImageBase; + ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory; + + // + // Get information about the image + // + Status = PeCoffLoaderGetImageInfo (&ImageContext); + if (EFI_ERROR (Status)) { return EFI_SUCCESS; } - PeHdr = (EFI_IMAGE_NT_HEADERS *) ((UINTN) LoadedImage->ImageBase + DosHdr->e_lfanew); - - if (PeHdr->FileHeader.Machine != EFI_IMAGE_MACHINE_EBC) { + if (ImageContext.Machine != EFI_IMAGE_MACHINE_EBC) { return EFI_SUCCESS; } + return EFI_SUCCESS; }