From 2d9d2abf04f53a5a747bcd8cfe363bf0592319ae Mon Sep 17 00:00:00 2001 From: mdkinney Date: Fri, 14 Sep 2007 21:29:45 +0000 Subject: Build a valid device path to an EFI driver loaded from a PCI Option ROM git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3852 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Bus/Pci/PciBusDxe/PciOptionRomSupport.c | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'IntelFrameworkModulePkg') diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c index c76c3ebd17..99c34d5bf5 100644 --- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c +++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c @@ -16,6 +16,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include +// +// Module global for a template of the PCI option ROM Image Device Path Node +// +MEMMAP_DEVICE_PATH mPciOptionRomImageDevicePathNodeTemplate = { + { + HARDWARE_DEVICE_PATH, + HW_MEMMAP_DP, + sizeof (MEMMAP_DEVICE_PATH) + }, + EfiMemoryMappedIO, + 0, + 0 +}; + EFI_STATUS GetOpRomInfo ( IN PCI_IO_DEVICE *PciIoDevice @@ -415,6 +429,7 @@ Returns: EFI_DECOMPRESS_PROTOCOL *Decompress; EFI_PCI_EXPANSION_ROM_HEADER *EfiRomHeader; PCI_DATA_STRUCTURE *Pcir; + EFI_DEVICE_PATH_PROTOCOL *PciOptionRomImageDevicePath; Indicator = 0; @@ -505,17 +520,31 @@ Returns: } if (!SkipImage) { + // + // Build full device path to the PCI Option ROM Image being loaded + // + mPciOptionRomImageDevicePathNodeTemplate.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)RomBarOffset; + mPciOptionRomImageDevicePathNodeTemplate.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)(RomBarOffset + ImageSize - 1); + PciOptionRomImageDevicePath = AppendDevicePathNode (PciDevice->DevicePath, (const EFI_DEVICE_PATH_PROTOCOL *)&mPciOptionRomImageDevicePathNodeTemplate); + ASSERT (PciOptionRomImageDevicePath != NULL); + // // load image and start image // Status = gBS->LoadImage ( FALSE, gPciBusDriverBinding.DriverBindingHandle, - PciDevice->Handle, + PciOptionRomImageDevicePath, ImageBuffer, ImageLength, &ImageHandle ); + + // + // Free the device path after it has been used by LoadImage + // + gBS->FreePool (PciOptionRomImageDevicePath); + if (!EFI_ERROR (Status)) { Status = gBS->StartImage (ImageHandle, NULL, NULL); if (!EFI_ERROR (Status)) { -- cgit v1.2.3