From nobody Mon Feb 9 23:01:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+77788+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77788+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1626268883; cv=none; d=zohomail.com; s=zohoarc; b=R4p6m+Cd4LaC7hbiIfqS4l42+NzISwENbEy11ExmJeC/wuMdwCQPaugabzbhMGSxRsaKsH9MZJQ0yb3y+99oxNboofu74UsqTPN/BeO0dNPPy7G4Cug72/CBO7SAF4XVtpEQe+JzvOxjSOpJHv0Vnj+dX5jM+jNZ0tQCUCVz3Zw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626268883; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=PJrJ7W0+x3kc/AVbWlMx12E/HX6Puo1igDQO5+QGdqw=; b=ezL9X8cZkrOXXoSa/JZQxXyzt7vu2vCCbVz8RTgOBBXSQ3PDrbeyVZuZvScS9zbjet1eQGm2V3r+wj279MLsV6NgzfhmHn2hXYfC3eOh/LyOQDSzPS1hUtxARtuoljdsbrD2FPvtbzjGs8QLxAGBTq/jC3cv+CM6rmSLII/S2sM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77788+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1626268883921693.9533474638345; Wed, 14 Jul 2021 06:21:23 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BXzeYY1788612x2iR9cE9OJd; Wed, 14 Jul 2021 06:21:23 -0700 X-Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mx.groups.io with SMTP id smtpd.web08.6569.1626268882651716446 for ; Wed, 14 Jul 2021 06:21:23 -0700 X-Received: by mail-lf1-f47.google.com with SMTP id a12so3547894lfb.7 for ; Wed, 14 Jul 2021 06:21:22 -0700 (PDT) X-Gm-Message-State: MBjohKGjCDI7uStDJme0MOy5x1787277AA= X-Google-Smtp-Source: ABdhPJyVwlg2BWqr1Nnrnatg6NgxwMp2W8cTzG/X/LSD8mFnfs2Uc/WZDDvJA7tpiup589p3f2+sLA== X-Received: by 2002:ac2:58e1:: with SMTP id v1mr7947040lfo.616.1626268880366; Wed, 14 Jul 2021 06:21:20 -0700 (PDT) X-Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e22sm237931ljl.31.2021.07.14.06.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 06:21:20 -0700 (PDT) From: "Grzegorz Bernacki" To: devel@edk2.groups.io Cc: leif@nuviainc.com, ardb+tianocore@kernel.org, Samer.El-Haj-Mahmoud@arm.com, sunny.Wang@arm.com, mw@semihalf.com, upstream@semihalf.com, pete@akeo.ie, jian.j.wang@intel.com, hao.a.wu@intel.com, dandan.bi@intel.com, eric.dong@intel.com, Grzegorz Bernacki , Sunny Wang Subject: [edk2-devel] [edk2-platforms PATCH v3 1/2] Platform/RaspberryPi: Enable Boot Discovery Policy. Date: Wed, 14 Jul 2021 15:21:02 +0200 Message-Id: <20210714132103.1341207-3-gjb@semihalf.com> In-Reply-To: <20210714132103.1341207-1-gjb@semihalf.com> References: <20210714132103.1341207-1-gjb@semihalf.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,gjb@semihalf.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=1626268883; bh=uRhb5hyNQsrdrR1PmdROZvnsLu+myMmyTPwalkU94YQ=; h=Cc:Date:From:Reply-To:Subject:To; b=lpx+I8N/IKcShQqoSwjmVB2Ovs+o/N0rgSk/dv8iOxpU77lsP804wDimeutqpYGQDQf bYCC5OTMT8Fp1BNGAAr1C3NhuQvSzehqKW7wihaYAMcF9ID7crcfkHX+gDME2PIUBgra1 IQRJN1ziexdvxxvcSLJ4dUEZEjDw07sJYqI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1626268885584100002 Content-Type: text/plain; charset="utf-8" This commit modify platform boot to check the value of BootDiscoveryPolicy variable and use BootPolicyManager Protocol to connect devices specified by the variable. Signed-off-by: Grzegorz Bernacki Reviewed-by: Sunny Wang --- Platform/RaspberryPi/RPi4/RPi4.dsc = | 3 + Platform/RaspberryPi/RPi4/RPi4.fdf = | 1 + Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib= .inf | 5 ++ Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c = | 91 ++++++++++++++++++++ 4 files changed, 100 insertions(+) diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index fd73c4d14b..8b9beac64a 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -555,6 +555,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Columns"|gRaspberryPiTo= kenSpaceGuid|0x0|80 gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|L"Rows"|gRaspberryPiTok= enSpaceGuid|0x0|25 gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Rows"|gRaspberryPiTokenSpa= ceGuid|0x0|25 + gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy|L"BootDiscoveryPol= icy"|gBootDiscoveryPolicyMgrFormsetGuid|0 =20 [PcdsDynamicDefault.common] # @@ -682,6 +683,7 @@ # # Bds # + MdeModulePkg/Universal/BootManagerPolicyDxe/BootManagerPolicyDxe.inf MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf @@ -690,6 +692,7 @@ Platform/RaspberryPi/Drivers/LogoDxe/LogoDxe.inf MdeModulePkg/Application/UiApp/UiApp.inf { + NULL|MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPoli= cyUiLib.inf NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf NULL|Platform/RaspberryPi/Library/PlatformUiAppLib/PlatformUiAppLib.= inf diff --git a/Platform/RaspberryPi/RPi4/RPi4.fdf b/Platform/RaspberryPi/RPi4= /RPi4.fdf index 1e13909a57..371197a93e 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.fdf +++ b/Platform/RaspberryPi/RPi4/RPi4.fdf @@ -253,6 +253,7 @@ READ_LOCK_STATUS =3D TRUE # # Bds # + INF MdeModulePkg/Universal/BootManagerPolicyDxe/BootManagerPolicyDxe.inf INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBo= otManagerLib.inf b/Platform/RaspberryPi/Library/PlatformBootManagerLib/Plat= formBootManagerLib.inf index fbf510ab96..4ef2f791ae 100644 --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManag= erLib.inf +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManag= erLib.inf @@ -61,11 +61,13 @@ gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType =20 [Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy=20 gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut gRaspberryPiTokenSpaceGuid.PcdSdIsArasan gRaspberryPiTokenSpaceGuid.PcdBootPolicy =20 [Guids] + gBootDiscoveryPolicyMgrFormsetGuid gEfiFileInfoGuid gEfiFileSystemInfoGuid gEfiFileSystemVolumeLabelInfoIdGuid @@ -73,8 +75,11 @@ gEfiTtyTermGuid gUefiShellFileGuid gEfiEventExitBootServicesGuid + gEfiBootManagerPolicyNetworkGuid + gEfiBootManagerPolicyConnectAllGuid =20 [Protocols] + gEfiBootManagerPolicyProtocolGuid gEfiDevicePathProtocolGuid gEfiGraphicsOutputProtocolGuid gEfiLoadedImageProtocolGuid diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm= .c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c index d081fdae63..d944d1a38d 100644 --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c @@ -6,6 +6,7 @@ * Copyright (c) 2015-2016, Red Hat, Inc. * Copyright (c) 2014-2021, ARM Ltd. All rights reserved. * Copyright (c) 2004-2016, Intel Corporation. All rights reserved. + * Copyright (c) 2021, Semihalf All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -19,10 +20,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -598,6 +601,89 @@ PlatformBootManagerBeforeConsole ( FilterAndProcess (&gEfiUsb2HcProtocolGuid, NULL, Connect); } =20 +/** + Connect device specified by BootDiscoverPolicy variable and refresh + Boot order for newly discovered boot device. + + @retval EFI_SUCCESS Devices connected succesfully or connection + not required. + @retval others Return values from GetVariable(), LocateProtocol() + and ConnectDeviceClass(). +--*/ +STATIC +EFI_STATUS +BootDiscoveryPolicyHandler ( + VOID + ) +{ + EFI_STATUS Status; + UINT32 DiscoveryPolicy; + UINTN Size; + EFI_BOOT_MANAGER_POLICY_PROTOCOL *BMPolicy; + EFI_GUID *Class; + + Size =3D sizeof (DiscoveryPolicy); + Status =3D gRT->GetVariable ( + BOOT_DISCOVERY_POLICY_VAR, + &gBootDiscoveryPolicyMgrFormsetGuid, + NULL, + &Size, + &DiscoveryPolicy + ); + if (Status =3D=3D EFI_NOT_FOUND) { + Status =3D PcdSet32S (PcdBootDiscoveryPolicy, PcdGet32 (PcdBootDiscove= ryPolicy)); + DiscoveryPolicy =3D PcdGet32 (PcdBootDiscoveryPolicy); + if (Status =3D=3D EFI_NOT_FOUND) { + return EFI_SUCCESS; + } else if (EFI_ERROR (Status)) { + return Status; + } + } else if (EFI_ERROR (Status)) { + return Status; + } + + if (DiscoveryPolicy =3D=3D BDP_CONNECT_MINIMAL) { + return EFI_SUCCESS; + } + + switch (DiscoveryPolicy) { + case BDP_CONNECT_NET: + Class =3D &gEfiBootManagerPolicyNetworkGuid; + break; + case BDP_CONNECT_ALL: + Class =3D &gEfiBootManagerPolicyConnectAllGuid; + break; + default: + DEBUG (( + DEBUG_INFO, + "%a - Unexpected DiscoveryPolicy (0x%x). Run Minimal Discovery Pol= icy\n", + __FUNCTION__, + DiscoveryPolicy + )); + return EFI_SUCCESS; + } + + Status =3D gBS->LocateProtocol ( + &gEfiBootManagerPolicyProtocolGuid, + NULL, + (VOID **)&BMPolicy + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a - Failed to locate gEfiBootManagerPolicyProto= colGuid - %r\n", __FUNCTION__, Status)); + return Status; + } + + Status =3D BMPolicy->ConnectDeviceClass (BMPolicy, Class); + if (EFI_ERROR (Status)){ + DEBUG ((DEBUG_ERROR, "%a - ConnectDeviceClass returns - %r\n", __FUNCT= ION__, Status)); + return Status; + } + + EfiBootManagerRefreshAllBootOption(); + + return EFI_SUCCESS; +} + /** Do the platform specific action after the console is ready Possible things that can be done in PlatformBootManagerAfterConsole: @@ -644,6 +730,11 @@ PlatformBootManagerAfterConsole ( DEBUG ((DEBUG_INFO, "Boot Policy is Fast Boot. Skip connecting all dev= ices\n")); } =20 + Status =3D BootDiscoveryPolicyHandler (); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_INFO, "Error applying Boot Discovery Policy:%r\n", Statu= s)); + } + Status =3D gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, (VOI= D**)&EsrtManagement); if (!EFI_ERROR (Status)) { EsrtManagement->SyncEsrtFmp (); --=20 2.25.1 -=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 (#77788): https://edk2.groups.io/g/devel/message/77788 Mute This Topic: https://groups.io/mt/84201224/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-