From: Patrick Rudolph <patrick.rudo...@9elements.com> This allows EFI applications to iterate over those devices. An example is iPXE.efi that requires those devices to be present.
Signed-off-by: Patrick Rudolph <patrick.rudo...@9elements.com> Signed-off-by: Marcello Sylvester Bauer <marcello.ba...@9elements.com> Cc: Patrick Rudolph <patrick.rudo...@9elements.com> Cc: Christian Walter <christian.wal...@9elements.com> Cc: Maurice Ma <maurice...@intel.com> Cc: Nate DeSimone <nathaniel.l.desim...@intel.com> Cc: Star Zeng <star.z...@intel.com> --- UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 1 + UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c | 76 ++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index 1f5a0bcad038..a7c6bc2d6440 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -57,6 +57,7 @@ [Protocols] gEfiBootLogoProtocolGuid ## CONSUMES gEfiDxeSmmReadyToLockProtocolGuid gEfiSmmAccess2ProtocolGuid + gEfiPciRootBridgeIoProtocolGuid ## CONSUMES [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c index c5c6af0abcb2..ff7df53231ce 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c @@ -138,6 +138,79 @@ PlatformRegisterFvBootOption ( } } +STATIC +EFI_STATUS +VisitAllInstancesOfProtocol ( + IN EFI_GUID *Id, + IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction, + IN VOID *Context + ) +{ + EFI_STATUS Status; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + UINTN Index; + VOID *Instance; + + // + // Start to check all the PciIo to find all possible device + // + HandleCount = 0; + HandleBuffer = NULL; + Status = gBS->LocateHandleBuffer ( + ByProtocol, + Id, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance); + if (EFI_ERROR (Status)) { + continue; + } + + Status = (*CallBackFunction) ( + HandleBuffer[Index], + Instance, + Context + ); + } + + gBS->FreePool (HandleBuffer); + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +EFIAPI +ConnectRootBridge ( + IN EFI_HANDLE RootBridgeHandle, + IN VOID *Instance, + IN VOID *Context + ) +{ + EFI_STATUS Status; + + // + // Make the PCI bus driver connect the root bridge, non-recursively. This + // will produce a number of child handles with PciIo on them. + // + Status = gBS->ConnectController ( + RootBridgeHandle, // ControllerHandle + NULL, // DriverImageHandle + NULL, // RemainingDevicePath -- produce all + // children + FALSE // Recursive + ); + return Status; +} + /** Do the platform specific action before the console is connected. @@ -157,6 +230,9 @@ PlatformBootManagerBeforeConsole ( EFI_INPUT_KEY Down; EFI_BOOT_MANAGER_LOAD_OPTION BootOption; + VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid, + ConnectRootBridge, NULL); + PlatformConsoleInit (); // -- 2.27.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62679): https://edk2.groups.io/g/devel/message/62679 Mute This Topic: https://groups.io/mt/75539006/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-