From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mx.groups.io with SMTP id smtpd.web09.4579.1627995809991146234 for ; Tue, 03 Aug 2021 06:03:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IC7P4UF5; spf=pass (domain: kernel.org, ip: 198.145.29.99, mailfrom: ardb@kernel.org) Received: by mail.kernel.org (Postfix) with ESMTPSA id 721DD61050 for ; Tue, 3 Aug 2021 13:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627995809; bh=kvy98NtXiaw+wH756IhTR7azE3Q1BxgPo8BjeNIAWsU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IC7P4UF5DsLY8ArPFAiWrck/KftTAX/IRiP8ao6FtuyU3QzV2oGLaVFrIBDj+t8A7 GFU+ftquHzl03Yid94CEnI9uxk1RtQH54Rf8fW+I0w2LBNKtLAlc4gxGrAw1c0HHZv yd2a5ATrfwwUQY2Ig63L1uvAkbY0WCqu+i8p2ufNmrPQiNugxI70Ilb2ZnZl8P9usr v3H9pSTTPpEp14INcupyDw2T/NNh1nj3H0dBDwo6joRDOci7/SD1R11x1vwKTpFwrg kPGH7r6FeVy9Yglp/24gv9mYDrTlpgC8DwNn4scuHnjZgpn9N/pWGETtPtTnu729QX wagDaLpTn893Q== Received: by mail-ot1-f49.google.com with SMTP id h63-20020a9d14450000b02904ce97efee36so9916762oth.7 for ; Tue, 03 Aug 2021 06:03:29 -0700 (PDT) X-Gm-Message-State: AOAM530BDOHKKwD7FaeRU59nm0WY0LbXCuSZ5wf1ccyNM0wCHDqrYazC zhyMTRvoeh489iyPFWOIDx28MQYX6sq1hMfzaPY= X-Google-Smtp-Source: ABdhPJyu4oVNW+PXdnG2akOl36ukyPunXsIdgC+fgVhYUwY9q4Puwhvb/vkO/8ALrM4TW/EAKMpvrdv/hXTdEn1CJZc= X-Received: by 2002:a05:6830:34a6:: with SMTP id c38mr14810235otu.108.1627995808662; Tue, 03 Aug 2021 06:03:28 -0700 (PDT) MIME-Version: 1.0 References: <20210802121837.2913575-1-gjb@semihalf.com> <20210802121837.2913575-3-gjb@semihalf.com> In-Reply-To: From: "Ard Biesheuvel" Date: Tue, 3 Aug 2021 15:03:17 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-platforms PATCH v5 1/2] Platform/RaspberryPi: Enable Boot Discovery Policy. To: Samer El-Haj-Mahmoud Cc: Grzegorz Bernacki , "devel@edk2.groups.io" , "ardb+tianocore@kernel.org" , "leif@nuviainc.com" , Sunny Wang , "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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 3 Aug 2021 at 15:00, Samer El-Haj-Mahmoud wrote: > > Ard, > > Now that the EDK2 changes are merged (aaecef38b9440a65809cbdaf9d97029f4ee= b), I think these RPi specific changes are ready to be merged as well. > I only see acks from Sunny though. This is why I asked Pete and Andrei to chime in as well. > > -----Original Message----- > > From: Grzegorz Bernacki > > Sent: Monday, August 2, 2021 8:19 AM > > To: devel@edk2.groups.io > > Cc: leif@nuviainc.com; ardb+tianocore@kernel.org; Samer El-Haj-Mahmoud > > ; Sunny Wang > > ; 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-platforms PATCH v5 1/2] Platform/RaspberryPi: Enable Boo= t > > Discovery Policy. > > > > 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/PlatformBootManag > > erLib.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"|gRasp > > berryPiTokenSpaceGuid|0x0|80 > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|L"Rows"|gRaspb > > erryPiTokenSpaceGuid|0x0|25 > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Rows"|gRaspberryPi > > TokenSpaceGuid|0x0|25 > > + > > gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy|L"BootDiscove > > ryPolicy"|gBootDiscoveryPolicyMgrFormsetGuid|0 > > > > [PcdsDynamicDefault.common] > > # > > @@ -682,6 +683,7 @@ > > # > > # Bds > > # > > + > > MdeModulePkg/Universal/BootManagerPolicyDxe/BootManagerPolicyDxe.i > > nf > > 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/BootDiscoveryPolic > > yUiLib.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.i > > nf > > 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/PlatformBootMan > > agerLib.inf > > b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootMan > > agerLib.inf > > index fbf510ab96..4ef2f791ae 100644 > > --- > > a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootMan > > agerLib.inf > > +++ > > b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootMan > > agerLib.inf > > @@ -61,11 +61,13 @@ > > gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType > > > > [Pcd] > > + gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy > > gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut > > gRaspberryPiTokenSpaceGuid.PcdSdIsArasan > > gRaspberryPiTokenSpaceGuid.PcdBootPolicy > > > > [Guids] > > + gBootDiscoveryPolicyMgrFormsetGuid > > gEfiFileInfoGuid > > gEfiFileSystemInfoGuid > > gEfiFileSystemVolumeLabelInfoIdGuid > > @@ -73,8 +75,11 @@ > > gEfiTtyTermGuid > > gUefiShellFileGuid > > gEfiEventExitBootServicesGuid > > + gEfiBootManagerPolicyNetworkGuid > > + gEfiBootManagerPolicyConnectAllGuid > > > > [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); > > } > > > > +/** > > + 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(), LocateProtoc= ol() > > + 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 > > (PcdBootDiscoveryPolicy)); > > + 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 > > Policy\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 > > gEfiBootManagerPolicyProtocolGuid - %r\n", __FUNCTION__, Status)); > > + return Status; > > + } > > + > > + Status =3D BMPolicy->ConnectDeviceClass (BMPolicy, Class); > > + if (EFI_ERROR (Status)){ > > + DEBUG ((DEBUG_ERROR, "%a - ConnectDeviceClass returns - %r\n", > > __FUNCTION__, 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 > > devices\n")); > > } > > > > + Status =3D BootDiscoveryPolicyHandler (); > > + if (EFI_ERROR(Status)) { > > + DEBUG ((DEBUG_INFO, "Error applying Boot Discovery Policy:%r\n", > > Status)); > > + } > > + > > Status =3D gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, > > (VOID**)&EsrtManagement); > > if (!EFI_ERROR (Status)) { > > EsrtManagement->SyncEsrtFmp (); > > -- > > 2.25.1 > > IMPORTANT NOTICE: The contents of this email and any attachments are conf= idential and may also be privileged. If you are not the intended recipient,= please notify the sender immediately and do not disclose the contents to a= ny other person, use it for any purpose, or store or copy the information i= n any medium. Thank you.