From nobody Mon May 6 09:25:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62679+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62679+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=9elements.com ARC-Seal: i=1; a=rsa-sha256; t=1594897861; cv=none; d=zohomail.com; s=zohoarc; b=QvH/NRzflR/juCCe1oOlGBd2DBGRjE1cLgSAt5Z8QHF/W5Tw+13bh9+h8N7xCDMdbXIRouH0kgkelkTQOiwmVKRtI/jJft2GMRuvbP6QmQC/htaY9dOJbUNWU7EjiN7L1A+cWlbAx7JOXw8A9LCvHnu2ayuu474AgspYqjSrI9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594897861; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=h6VHJcNKRa2mZt0bTVwr76KR/MWXyEgm50mHuKol8/U=; b=nPZXADUpBq3Z5vsqSVS5IzmJdnyKOd1u7E9QT894Fw8szLewj0oKa8rh/V/SmFdyo+ko+6XJ/k7CcOSv5WsrZvgigMT0cza5nX7Csokpvh+qLuWJXAy7TK82dtoI9h27b23n/8dMgj6DBvakTRTD05KxyFxYLM1OlcFQVWJvW+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62679+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594897861876637.6264567605507; Thu, 16 Jul 2020 04:11:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iJogYY1788612xgolawx8avW; Thu, 16 Jul 2020 04:11:01 -0700 X-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 X-Received: by mail-wm1-f45.google.com with SMTP id g10so5109365wmc.1 for ; Thu, 16 Jul 2020 04:11:00 -0700 (PDT) X-Gm-Message-State: QAl3GRMqROUrz1Qa9MFbDFARx1787277AA= 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) X-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: [edk2-devel] [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> In-Reply-To: <20200716111011.22538-1-marcello.bauer@9elements.com> References: <20200716111011.22538-1-marcello.bauer@9elements.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,marcello.bauer@9elements.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594897861; bh=wnc0OcrPtZ2yvOxIC1+iRGBllmyWUATy4CGkKXOLRZ8=; h=Cc:Date:From:Reply-To:Subject:To; b=D/bhsifecc+LV6kQ3SH02hQg7hKZIYDl2+N2POXLg3O9LLxti0u+3cxb6e2s3jttWWb noulNJWbfWv2RtcQP0xWy3HOPGTLWFgExXJU0nm7UUcB686vaTYzLxwsgoBz2/2cqfr/A hz8Q2jWgGNwfcP/sKZorXNjMBgY7K7f7cM4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 gEfiDxeSmmReadyToLockProtocolGuid gEfiSmmAccess2ProtocolGuid + gEfiPciRootBridgeIoProtocolGuid ## CONSUMES =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut 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 ( } } =20 +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 =3D 0; + HandleBuffer =3D NULL; + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + Id, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index =3D 0; Index < HandleCount; Index++) { + Status =3D gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance); + if (EFI_ERROR (Status)) { + continue; + } + + Status =3D (*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 =3D 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. =20 @@ -157,6 +230,9 @@ PlatformBootManagerBeforeConsole ( EFI_INPUT_KEY Down; EFI_BOOT_MANAGER_LOAD_OPTION BootOption; =20 + VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid, + ConnectRootBridge, NULL); + PlatformConsoleInit (); =20 // --=20 2.27.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-