mirror of https://github.com/acidanthera/audk.git
OvmfPkg: PciHostBridgeDxe: shorten search for extra root buses
QEMU provides an fw_cfg file called "etc/extra-pci-roots", containing a little-endian UINT64 value that exposes the number of extra root buses. We can use this value to terminate the scan as soon as we find the last extra root bus. Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Gabriel Somlo <somlo@cmu.edu> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17963 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
bdb1c98f03
commit
68306ac2f2
|
@ -15,6 +15,8 @@
|
|||
|
||||
**/
|
||||
|
||||
#include <Library/QemuFwCfgLib.h>
|
||||
|
||||
#include "PciHostBridge.h"
|
||||
|
||||
STATIC
|
||||
|
@ -207,6 +209,9 @@ InitializePciHostBridge (
|
|||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
FIRMWARE_CONFIG_ITEM FwCfgItem;
|
||||
UINTN FwCfgSize;
|
||||
UINT64 ExtraRootBridgesLeft;
|
||||
UINTN LastRootBridgeNumber;
|
||||
UINTN RootBridgeNumber;
|
||||
PCI_HOST_BRIDGE_INSTANCE *HostBridge;
|
||||
|
@ -236,6 +241,20 @@ InitializePciHostBridge (
|
|||
goto FreeHostBridge;
|
||||
}
|
||||
|
||||
//
|
||||
// QEMU provides the number of extra root buses, shortening the exhaustive
|
||||
// search below. If there is no hint, the feature is missing.
|
||||
//
|
||||
Status = QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, &FwCfgSize);
|
||||
if (EFI_ERROR (Status) || FwCfgSize != sizeof ExtraRootBridgesLeft) {
|
||||
ExtraRootBridgesLeft = 0;
|
||||
} else {
|
||||
QemuFwCfgSelectItem (FwCfgItem);
|
||||
QemuFwCfgReadBytes (FwCfgSize, &ExtraRootBridgesLeft);
|
||||
DEBUG ((EFI_D_INFO, "%a: %Lu extra root buses reported by QEMU\n",
|
||||
__FUNCTION__, ExtraRootBridgesLeft));
|
||||
}
|
||||
|
||||
//
|
||||
// The "main" root bus is always there.
|
||||
//
|
||||
|
@ -247,7 +266,7 @@ InitializePciHostBridge (
|
|||
// alive.
|
||||
//
|
||||
for (RootBridgeNumber = 1;
|
||||
RootBridgeNumber < 256;
|
||||
RootBridgeNumber < 256 && ExtraRootBridgesLeft > 0;
|
||||
++RootBridgeNumber) {
|
||||
UINTN Device;
|
||||
|
||||
|
@ -271,6 +290,7 @@ InitializePciHostBridge (
|
|||
}
|
||||
InsertTailList (&HostBridge->Head, &RootBus->Link);
|
||||
LastRootBridgeNumber = RootBridgeNumber;
|
||||
--ExtraRootBridgesLeft;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
OvmfPkg/OvmfPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
UefiDriverEntryPoint
|
||||
|
@ -39,6 +40,7 @@
|
|||
DevicePathLib
|
||||
IoLib
|
||||
PciLib
|
||||
QemuFwCfgLib
|
||||
|
||||
[Sources]
|
||||
PciHostBridge.c
|
||||
|
|
Loading…
Reference in New Issue