From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by mx.groups.io with SMTP id smtpd.web12.12966.1594897860832670652 for ; Thu, 16 Jul 2020 04:11:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@9elements.com header.s=google header.b=U/d2vOW0; spf=pass (domain: 9elements.com, ip: 209.85.128.45, mailfrom: marcello.bauer@9elements.com) Received: by mail-wm1-f45.google.com with SMTP id g10so5109365wmc.1 for ; Thu, 16 Jul 2020 04:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pGLo7eygKtz36PLasmPdMSBMymOKdToV71EFq4nVo9s=; b=U/d2vOW009bDCkdZmVT63bVej+Bz7fUMqsASr2HMBnFfcCTDfjIrIMLHsHlhP4dPdz 89aHvlJrRzTp3/fD9GfgFnWYewDkX+1Rd/BERqve5UD79gbU75aRj5PRmXmeSGU14tWg 2NwUl7OgLBfkwUFdOcs7PNgu41rqjxKci6dG5oQnb6+zjKShOyC3qCF1g1f1S2LpW/9V 4OviRcyi9hT/U7+TOGn47+ikiX1EXw74rTMbcJpC6wlTD/4WfWPlxJP+/ciy7kGYIsgr uSpGBxihjg6lgcQRdCjxSub4COrhtRUayEwJ8zCpRlVS/QdscNpXrZSuUqqgIaSdo+Oo hLBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pGLo7eygKtz36PLasmPdMSBMymOKdToV71EFq4nVo9s=; b=fPbAhv0HrY3zDR98F6NOBSwp2T7sseJD/tnSkUD4miR5WhqbsLSIJd67wcHmIjbuee A9ArsoBCp0Xh1J7sMvF+BO+H7L+rSSwM0jRafoTdz6jWD5N6JRMsZ14nHqK0kvufhJb0 YaGs2tLXEwRM/myZ4EOtLZ3t4ofjMUwoMgGBg1z3dNe4Iyj5OwZQlrPYzrqikC4AeN2E 1KdzByGIZ4yT+c6ADcwyXpIYJy6TaFt9rx42WzobDYLZ6AedFf1I60dWLCYLGu0mKvNn O6ftM4laDAUMiUw/xgEdE7gq1fO2OCy4WEXJoEvPsHvN9Mjb87bH+L1yZdCob/YbrFyE grQQ== X-Gm-Message-State: AOAM531CCP5A7Q5MLY88ltHKD3FFy5t4ewYDTLBFMGTK39mqbsAbYAqp vZRe85C4knhzKAawgUL/3M/wfZdzOMw= X-Google-Smtp-Source: ABdhPJx0Yzx7NunFnsBBrFkFU/k6V6JvTT9WjShGc5vgoRDBvMOFLvQ86gGAF8A3fZKeOLiwBTxRTg== X-Received: by 2002:a05:600c:2949:: with SMTP id n9mr3268714wmd.69.1594897859151; Thu, 16 Jul 2020 04:10:59 -0700 (PDT) Return-Path: Received: from T580.dut.n1ce.space ([2a02:908:e851:d750:f570:655a:1f30:429f]) by smtp.gmail.com with ESMTPSA id j24sm9077123wrd.43.2020.07.16.04.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 04:10:58 -0700 (PDT) From: "Marcello Sylvester Bauer" To: devel@edk2.groups.io Cc: Patrick Rudolph , Christian Walter , Maurice Ma , Nate DeSimone , Star Zeng Subject: [PATCH v1 1/1] UefiPayloadPkg: Scan for PCI devices after end of DXE Date: Thu, 16 Jul 2020 13:10:10 +0200 Message-Id: <20200716111011.22538-2-marcello.bauer@9elements.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200716111011.22538-1-marcello.bauer@9elements.com> References: <20200716111011.22538-1-marcello.bauer@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Patrick Rudolph 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 Signed-off-by: Marcello Sylvester Bauer Cc: Patrick Rudolph Cc: Christian Walter Cc: Maurice Ma Cc: Nate DeSimone Cc: Star Zeng --- UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |= 1 + UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c |= 76 ++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf index 1f5a0bcad038..a7c6bc2d6440 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf @@ -57,6 +57,7 @@ [Protocols] gEfiBootLogoProtocolGuid ## CONSUMES=0D gEfiDxeSmmReadyToLockProtocolGuid=0D gEfiSmmAccess2ProtocolGuid=0D + gEfiPciRootBridgeIoProtocolGuid ## CONSUMES=0D =0D [Pcd]=0D gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut=0D diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= ger.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 ( }=0D }=0D =0D +STATIC=0D +EFI_STATUS=0D +VisitAllInstancesOfProtocol (=0D + IN EFI_GUID *Id,=0D + IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,=0D + IN VOID *Context=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINTN HandleCount;=0D + EFI_HANDLE *HandleBuffer;=0D + UINTN Index;=0D + VOID *Instance;=0D +=0D + //=0D + // Start to check all the PciIo to find all possible device=0D + //=0D + HandleCount =3D 0;=0D + HandleBuffer =3D NULL;=0D + Status =3D gBS->LocateHandleBuffer (=0D + ByProtocol,=0D + Id,=0D + NULL,=0D + &HandleCount,=0D + &HandleBuffer=0D + );=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + for (Index =3D 0; Index < HandleCount; Index++) {=0D + Status =3D gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);=0D + if (EFI_ERROR (Status)) {=0D + continue;=0D + }=0D +=0D + Status =3D (*CallBackFunction) (=0D + HandleBuffer[Index],=0D + Instance,=0D + Context=0D + );=0D + }=0D +=0D + gBS->FreePool (HandleBuffer);=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +STATIC=0D +EFI_STATUS=0D +EFIAPI=0D +ConnectRootBridge (=0D + IN EFI_HANDLE RootBridgeHandle,=0D + IN VOID *Instance,=0D + IN VOID *Context=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + //=0D + // Make the PCI bus driver connect the root bridge, non-recursively. Thi= s=0D + // will produce a number of child handles with PciIo on them.=0D + //=0D + Status =3D gBS->ConnectController (=0D + RootBridgeHandle, // ControllerHandle=0D + NULL, // DriverImageHandle=0D + NULL, // RemainingDevicePath -- produce all= =0D + // children=0D + FALSE // Recursive=0D + );=0D + return Status;=0D +}=0D +=0D /**=0D Do the platform specific action before the console is connected.=0D =0D @@ -157,6 +230,9 @@ PlatformBootManagerBeforeConsole ( EFI_INPUT_KEY Down;=0D EFI_BOOT_MANAGER_LOAD_OPTION BootOption;=0D =0D + VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,=0D + ConnectRootBridge, NULL);=0D +=0D PlatformConsoleInit ();=0D =0D //=0D --=20 2.27.0