public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pete Batard" <pete@akeo.ie>
To: Ard Biesheuvel <ardb@kernel.org>,
	Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Cc: Grzegorz Bernacki <gjb@semihalf.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"ardb+tianocore@kernel.org" <ardb+tianocore@kernel.org>,
	"leif@nuviainc.com" <leif@nuviainc.com>,
	Sunny Wang <Sunny.Wang@arm.com>,
	"mw@semihalf.com" <mw@semihalf.com>,
	"upstream@semihalf.com" <upstream@semihalf.com>,
	"jian.j.wang@intel.com" <jian.j.wang@intel.com>,
	"hao.a.wu@intel.com" <hao.a.wu@intel.com>,
	"dandan.bi@intel.com" <dandan.bi@intel.com>,
	"eric.dong@intel.com" <eric.dong@intel.com>
Subject: Re: [edk2-platforms PATCH v5 1/2] Platform/RaspberryPi: Enable Boot Discovery Policy.
Date: Tue, 3 Aug 2021 14:08:35 +0100	[thread overview]
Message-ID: <7a706c83-3851-4c25-ee05-6c720a8bbc77@akeo.ie> (raw)
In-Reply-To: <CAMj1kXHArAm=j+qnfvt-nzp3B=pCmyVAOW9H61Xig5rZdV_TKg@mail.gmail.com>

Hi Ard,

I thought the R-b from Sunny was enough.

For what is worth, I briefly tested these changes for v4.
Thus:

On 2021.08.03 14:03, Ard Biesheuvel wrote:
> On Tue, 3 Aug 2021 at 15:00, Samer El-Haj-Mahmoud
> <Samer.El-Haj-Mahmoud@arm.com> wrote:
>>
>> Ard,
>>
>> Now that the EDK2 changes are merged (aaecef38b9440a65809cbdaf9d97029f4eeb), 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 <gjb@semihalf.com>
>>> 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
>>> <Samer.El-Haj-Mahmoud@arm.com>; Sunny Wang
>>> <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
>>> <gjb@semihalf.com>; Sunny Wang <Sunny.Wang@arm.com>
>>> Subject: [edk2-platforms PATCH v5 1/2] Platform/RaspberryPi: Enable Boot
>>> 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 <gjb@semihalf.com>
>>> Reviewed-by: Sunny Wang <sunny.wang@arm.com>
>>> ---
>>>   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 {
>>>       <LibraryClasses>
>>> +
>>> 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   = 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 <Library/UefiBootManagerLib.h>
>>>   #include <Library/UefiLib.h>
>>>   #include <Library/PrintLib.h>
>>> +#include <Protocol/BootManagerPolicy.h>
>>>   #include <Protocol/DevicePath.h>
>>>   #include <Protocol/EsrtManagement.h>
>>>   #include <Protocol/GraphicsOutput.h>
>>>   #include <Protocol/LoadedImage.h>
>>> +#include <Guid/BootDiscoveryPolicy.h>
>>>   #include <Guid/EventGroup.h>
>>>   #include <Guid/TtyTerm.h>
>>>   #include <ConfigVars.h>
>>> @@ -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(), 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 = sizeof (DiscoveryPolicy);
>>> +  Status = gRT->GetVariable (
>>> +                  BOOT_DISCOVERY_POLICY_VAR,
>>> +                  &gBootDiscoveryPolicyMgrFormsetGuid,
>>> +                  NULL,
>>> +                  &Size,
>>> +                  &DiscoveryPolicy
>>> +                  );
>>> +  if (Status == EFI_NOT_FOUND) {
>>> +    Status = PcdSet32S (PcdBootDiscoveryPolicy, PcdGet32
>>> (PcdBootDiscoveryPolicy));
>>> +    DiscoveryPolicy = PcdGet32 (PcdBootDiscoveryPolicy);
>>> +    if (Status == EFI_NOT_FOUND) {
>>> +      return EFI_SUCCESS;
>>> +    } else if (EFI_ERROR (Status)) {
>>> +      return Status;
>>> +    }
>>> +  } else if (EFI_ERROR (Status)) {
>>> +    return Status;
>>> +  }
>>> +
>>> +  if (DiscoveryPolicy == BDP_CONNECT_MINIMAL) {
>>> +    return EFI_SUCCESS;
>>> +  }
>>> +
>>> +  switch (DiscoveryPolicy) {
>>> +    case BDP_CONNECT_NET:
>>> +      Class = &gEfiBootManagerPolicyNetworkGuid;
>>> +      break;
>>> +    case BDP_CONNECT_ALL:
>>> +      Class = &gEfiBootManagerPolicyConnectAllGuid;
>>> +      break;
>>> +    default:
>>> +      DEBUG ((
>>> +        DEBUG_INFO,
>>> +        "%a - Unexpected DiscoveryPolicy (0x%x). Run Minimal Discovery
>>> Policy\n",
>>> +        __FUNCTION__,
>>> +        DiscoveryPolicy
>>> +        ));
>>> +      return EFI_SUCCESS;
>>> +  }
>>> +
>>> +  Status = 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 = 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 = BootDiscoveryPolicyHandler ();
>>> +  if (EFI_ERROR(Status)) {
>>> +    DEBUG ((DEBUG_INFO, "Error applying Boot Discovery Policy:%r\n",
>>> Status));
>>> +  }
>>> +
>>>     Status = 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 confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>

  reply	other threads:[~2021-08-03 13:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 12:18 [edk2-platforms PATCH v5 0/2] Add BootDiscoveryPolicyUiLib Grzegorz Bernacki
2021-08-02 12:18 ` [PATCH v5 1/1] MdeModulePkg: " Grzegorz Bernacki
2021-08-03  0:01   ` [edk2-devel] " Wu, Hao A
2021-08-03  2:24     ` Gao, Zhichao
2021-08-03  3:02       ` Sunny Wang
2021-08-03  5:11         ` Wu, Hao A
2021-08-03  6:24           ` Grzegorz Bernacki
2021-08-02 12:18 ` [edk2-platforms PATCH v5 1/2] Platform/RaspberryPi: Enable Boot Discovery Policy Grzegorz Bernacki
2021-08-03 13:00   ` Samer El-Haj-Mahmoud
2021-08-03 13:03     ` Ard Biesheuvel
2021-08-03 13:08       ` Pete Batard [this message]
2021-08-03 13:10         ` Ard Biesheuvel
2021-08-03 16:42           ` Ard Biesheuvel
2021-08-02 12:18 ` [edk2-platforms PATCH v5 2/2] Revert "Platform/RaspberryPi: Setup option for disabling Fast Boot" Grzegorz Bernacki
2021-08-03  5:33 ` [edk2-platforms PATCH v5 0/2] Add BootDiscoveryPolicyUiLib Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7a706c83-3851-4c25-ee05-6c720a8bbc77@akeo.ie \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox