X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkModulePkg%2FBus%2FPci%2FPciBusDxe%2FPciDeviceSupport.c;h=e205fe9dc88cb696d32f9b4dcbb350f18aee7f73;hp=3f72a71d731c6ffbbf96f091ea5b769715f351e0;hb=0170af58e038038d4bbe6c9b9b5436f5456dafaf;hpb=97404058f1752da8fa2ba531e592491c65cb29f1 diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c index 3f72a71d73..e205fe9dc8 100644 --- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c +++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2006, Intel Corporation +Copyright (c) 2006 - 2009, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -220,6 +220,7 @@ RegisterPciDevice ( UINT8 PciExpressCapRegOffset; EFI_PCI_IO_PROTOCOL *PciIo; UINT8 Data8; + BOOLEAN HasEfiImage; // // Install the pciio protocol, device path protocol @@ -261,7 +262,6 @@ RegisterPciDevice ( // Process OpRom // if (!PciIoDevice->AllOpRomProcessed) { - PciIoDevice->AllOpRomProcessed = TRUE; // // Get the OpRom provided by platform @@ -279,7 +279,7 @@ RegisterPciDevice ( PciIoDevice->PciIo.RomImage = PlatformOpRomBuffer; // // For OpROM read from gPciPlatformProtocol: - // Add the Rom Image to internal database for later PCI light enumeration + // Add the Rom Image to internal database for later PCI light enumeration // PciRomAddImageMapping ( NULL, @@ -290,16 +290,46 @@ RegisterPciDevice ( (UINT64) (UINTN) PciIoDevice->PciIo.RomImage, PciIoDevice->PciIo.RomSize ); - } } + } + + // + // Determine if there are EFI images in the option rom + // + HasEfiImage = ContainEfiImage (PciIoDevice->PciIo.RomImage, PciIoDevice->PciIo.RomSize); + + if (HasEfiImage) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &PciIoDevice->Handle, + &gEfiLoadFile2ProtocolGuid, + &PciIoDevice->LoadFile2, + NULL + ); + if (EFI_ERROR (Status)) { + gBS->UninstallMultipleProtocolInterfaces ( + &PciIoDevice->Handle, + &gEfiDevicePathProtocolGuid, + PciIoDevice->DevicePath, + &gEfiPciIoProtocolGuid, + &PciIoDevice->PciIo, + NULL + ); + return Status; + } + } + + + if (!PciIoDevice->AllOpRomProcessed) { + + PciIoDevice->AllOpRomProcessed = TRUE; // // Dispatch the EFI OpRom for the PCI device. // The OpRom is got from platform in the above code - // or loaded from device in previous bus enumeration + // or loaded from device in the previous round of bus enumeration // - if (PciIoDevice->RomSize > 0) { + if (HasEfiImage) { ProcessOpRomImage (PciIoDevice); } } @@ -323,6 +353,14 @@ RegisterPciDevice ( &PciIoDevice->PciIo, NULL ); + if (HasEfiImage) { + gBS->UninstallMultipleProtocolInterfaces ( + &PciIoDevice->Handle, + &gEfiLoadFile2ProtocolGuid, + &PciIoDevice->LoadFile2, + NULL + ); + } return Status; } @@ -340,12 +378,6 @@ RegisterPciDevice ( return Status; } - // - // Install Pccard Hotplug GUID for Pccard device so that - // to notify CardBus driver to stop the device when de-register happens - // - InstallPciHotplugGuid (PciIoDevice); - if (Handle != NULL) { *Handle = PciIoDevice->Handle; } @@ -467,10 +499,6 @@ DeRegisterPciDevice ( CurrentLink = CurrentLink->ForwardLink; } } - // - // Uninstall Pccard Hotplug GUID for Pccard device - // - UninstallPciHotplugGuid (PciIoDevice); // // Close the child handle @@ -507,6 +535,33 @@ DeRegisterPciDevice ( ); } + if (!EFI_ERROR (Status)) { + // + // Try to uninstall LoadFile2 protocol if exists + // + Status = gBS->OpenProtocol ( + Handle, + &gEfiLoadFile2ProtocolGuid, + NULL, + gPciBusDriverBinding.DriverBindingHandle, + Controller, + EFI_OPEN_PROTOCOL_TEST_PROTOCOL + ); + if (!EFI_ERROR (Status)) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + Handle, + &gEfiLoadFile2ProtocolGuid, + &PciIoDevice->LoadFile2, + NULL + ); + } + // + // Restore Status + // + Status = EFI_SUCCESS; + } + + if (EFI_ERROR (Status)) { gBS->OpenProtocol ( Controller, @@ -825,8 +880,9 @@ CreateRootBridge ( // // Initialize the PCI I/O instance structure // - Status = InitializePciIoInstance (Dev); - Status = InitializePciDriverOverrideInstance (Dev); + InitializePciIoInstance (Dev); + InitializePciDriverOverrideInstance (Dev); + InitializePciLoadFile2 (Dev); // // Initialize reserved resource list and @@ -1136,7 +1192,11 @@ GetHpcPciAddressFromRootBridge ( return EFI_NOT_FOUND; } - *PciAddress = EFI_PCI_ADDRESS (Temp->BusNumber, Temp->DeviceNumber, Temp->FunctionNumber, 0); + if (Temp != NULL) { + *PciAddress = EFI_PCI_ADDRESS (Temp->BusNumber, Temp->DeviceNumber, Temp->FunctionNumber, 0); + } else { + return EFI_NOT_FOUND; + } return EFI_SUCCESS;