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
This commit is contained in:
mdkinney 2009-02-05 19:32:40 +00:00
parent e8ba34ff3d
commit 2fb718b064
3 changed files with 13 additions and 8 deletions

View File

@ -45,6 +45,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/PciIncompatibleDeviceSupportLib.h> #include <Library/PciIncompatibleDeviceSupportLib.h>
#include <Library/PeCoffLib.h>
#include <IndustryStandard/Pci.h> #include <IndustryStandard/Pci.h>
#include <IndustryStandard/PeImage.h> #include <IndustryStandard/PeImage.h>

View File

@ -86,7 +86,7 @@
BaseLib BaseLib
UefiDriverEntryPoint UefiDriverEntryPoint
DebugLib DebugLib
PeCoffLib
[Guids] [Guids]
gEfiPciOptionRomTableGuid # SOMETIMES_CONSUMED System Table gEfiPciOptionRomTableGuid # SOMETIMES_CONSUMED System Table

View File

@ -101,9 +101,8 @@ AddDriver (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_IMAGE_DOS_HEADER *DosHdr;
EFI_IMAGE_NT_HEADERS *PeHdr;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
PCI_DRIVER_OVERRIDE_LIST *Node; PCI_DRIVER_OVERRIDE_LIST *Node;
Status = gBS->HandleProtocol (DriverImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage); Status = gBS->HandleProtocol (DriverImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
@ -123,16 +122,21 @@ AddDriver (
PciIoDevice->BusOverride = TRUE; PciIoDevice->BusOverride = TRUE;
DosHdr = (EFI_IMAGE_DOS_HEADER *) LoadedImage->ImageBase; ImageContext.Handle = LoadedImage->ImageBase;
if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) { ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
//
// Get information about the image
//
Status = PeCoffLoaderGetImageInfo (&ImageContext);
if (EFI_ERROR (Status)) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
PeHdr = (EFI_IMAGE_NT_HEADERS *) ((UINTN) LoadedImage->ImageBase + DosHdr->e_lfanew); if (ImageContext.Machine != EFI_IMAGE_MACHINE_EBC) {
if (PeHdr->FileHeader.Machine != EFI_IMAGE_MACHINE_EBC) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }