From nobody Sun May 5 10:47:42 2024 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+78791+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+78791+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1628238650; cv=none; d=zohomail.com; s=zohoarc; b=G+jPGnQQuVBpCUfrtfSCxDPcFpJiu9UfvymZP6+RijUcIVymmzpjJl/ESjOQmUkthfZXSmZ19p+QiNyjSElp6MRWzuLYKzlohKq6mQplNXaaE99Qzy0lOiPutrPznhVOhOUXbvciKQhayuzC5eppezt3JEqXWKKFtJaMVGLJTNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628238650; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=dV0sGIynP9IuSQgrcULd7PMk237rJ7wR2faboGEo2KM=; b=FMNCL73rp2716y/nJuBifM6rAXB3ZN8x+IYGAWSxvAlr/MfGFJAVMy2eDmhktp698eOY7WimaftAsPh5hK5uRFFDAFMWggVJbeF31FCtq5mlLHoTLJt0dvdjHePzWIedOQAcm1+73sO6zzHLRYt2xbX/4KCMA2A23Lf+ncQPKmk= 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+78791+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1628238650841729.9564464347303; Fri, 6 Aug 2021 01:30:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id KXY9YY1788612xV2NmDGK90t; Fri, 06 Aug 2021 01:30:50 -0700 X-Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by mx.groups.io with SMTP id smtpd.web11.2355.1628238648524628310 for ; Fri, 06 Aug 2021 01:30:49 -0700 X-Received: by mail-lj1-f169.google.com with SMTP id x7so10798658ljn.10 for ; Fri, 06 Aug 2021 01:30:48 -0700 (PDT) X-Gm-Message-State: Ek4QgvmOjiJS1aKCAswNNl1Ax1787277AA= X-Google-Smtp-Source: ABdhPJxGWbc57ayLX6B8huFk8UD63jx9x0/9nMZhCxJTQDC5bskKTjmuxUQlZMMkut9DaeySQvbuxA== X-Received: by 2002:a2e:b0c8:: with SMTP id g8mr3213920ljl.444.1628238646375; Fri, 06 Aug 2021 01:30:46 -0700 (PDT) X-Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id t30sm764185lft.152.2021.08.06.01.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Aug 2021 01:30:46 -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, Grzegorz Bernacki Subject: [edk2-devel] [PATCH] ArmPkg: Enable boot discovery policy for ARM package. Date: Fri, 6 Aug 2021 10:30:26 +0200 Message-Id: <20210806083026.3295056-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=1628238650; bh=BwLBdBgAPTUwLIrnOqzGKx3Aq6dODd5gbx08KhB7HcU=; h=Cc:Date:From:Reply-To:Subject:To; b=ksgki6+pMh1mb/aGDaDR7HG6lFAywyXC692Ubo1jWepNzvLi8o2F8tobqwgdCfgRVgM HXdfPtmuSAZiC64X+RAyOrdoTTYlK9GnqLDiyhJ2KrYG2n/ZFqACQwz2rbClXS+zuIAKb lrgFkxCTlXLQnPIstosudhs0amqVNUbVxu8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1628238651411100002 Content-Type: text/plain; charset="utf-8" This commit adds code which check BootDiscoveryPolicy variable and calls Boot Policy Manager Protocol to connect device specified by the variable. To enable that mechanism for platform EfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy PCD must be added to DSC file and BootDiscoveryPolicyUiLib should be added to UiApp libraries. Signed-off-by: Grzegorz Bernacki Reviewed-by: Sunny Wang --- ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 5 + ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 96 ++++= +++++++++++++++- 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.i= nf b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index 353d7a967b..86751b45f8 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -65,11 +65,15 @@ =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut + gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy =20 [Guids] + gBootDiscoveryPolicyMgrFormsetGuid gEdkiiNonDiscoverableEhciDeviceGuid gEdkiiNonDiscoverableUhciDeviceGuid gEdkiiNonDiscoverableXhciDeviceGuid + gEfiBootManagerPolicyNetworkGuid + gEfiBootManagerPolicyConnectAllGuid gEfiFileInfoGuid gEfiFileSystemInfoGuid gEfiFileSystemVolumeLabelInfoIdGuid @@ -79,6 +83,7 @@ =20 [Protocols] gEdkiiNonDiscoverableDeviceProtocolGuid + gEfiBootManagerPolicyProtocolGuid gEfiDevicePathProtocolGuid gEfiGraphicsOutputProtocolGuid gEfiLoadedImageProtocolGuid diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Li= brary/PlatformBootManagerLib/PlatformBm.c index 5ceb23d822..4332c45bb7 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -2,9 +2,10 @@ Implementation for PlatformBootManagerLib library class interfaces. =20 Copyright (C) 2015-2016, Red Hat, Inc. - Copyright (c) 2014 - 2019, ARM Ltd. All rights reserved.
+ Copyright (c) 2014 - 2021, ARM Ltd. All rights reserved.
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
Copyright (c) 2016, Linaro Ltd. All rights reserved.
+ Copyright (c) 2021, Semihalf All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -19,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -703,6 +706,91 @@ HandleCapsules ( =20 #define VERSION_STRING_PREFIX L"Tianocore/EDK2 firmware version " =20 +/** + This functions checks the value of BootDiscoverPolicy variable and + connect devices of class specified by that variable. Then it refreshes + 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)); + if (Status =3D=3D EFI_NOT_FOUND) { + return EFI_SUCCESS; + } else if (EFI_ERROR (Status)) { + return Status; + } + DiscoveryPolicy =3D PcdGet32 (PcdBootDiscoveryPolicy); + } 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_INFO, "%a - Failed to locate gEfiBootManagerPolicyProtoc= olGuid." + "Driver connect will be skipped.\n", __FUNCTION__)); + 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: @@ -753,6 +841,12 @@ PlatformBootManagerAfterConsole ( } } =20 + // + // Connect device specified by BootDiscoverPolicy variable and + // refresh Boot order for newly discovered boot devices + // + BootDiscoveryPolicyHandler (); + // // On ARM, there is currently no reason to use the phased capsule // update approach where some capsules are dispatched before EndOfDxe --=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 (#78791): https://edk2.groups.io/g/devel/message/78791 Mute This Topic: https://groups.io/mt/84704033/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-