From nobody Tue May 7 11:04:26 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+52485+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+52485+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=nvidia.com ARC-Seal: i=1; a=rsa-sha256; t=1577067998; cv=none; d=zohomail.com; s=zohoarc; b=MhNfBUNSab+kk2V7+DM+KRqoWxVCzcCN8Bm1zOy+fl7C6Ji/0txJDko2XWULBQc3bwFJKLCTFCzv9wdKR4R2REuEBoGbpyzo4YVXO2O/DJkqSpq4U3KwBHuwZ+f7WAkbmHggaW42O/lJ2EPK7MnqqbjMEtIB+Fc5UIv7uIs520o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577067998; h=Content-Type:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=co4LzFVEGXzEL0yGxRBO1deegDefa2seTsUNCy5aph0=; b=iGEAVm4fRrThlbalTPDR7Xvy0f9HzpzF/f27vIADpFiqpj613cEGma8bZIg4TsByB4VC40MEQFSed1ItoKLZfe2R96niOR8b1BB4eeJiJoEjvVzeGmL3AmYRZ8X3Y75j7pNxosJZHb3SP1qHhrhQIUxrkKWAKFHQuGRLxDHDQZc= 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+52485+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 1577067998729737.9941132854175; Sun, 22 Dec 2019 18:26:38 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ev4xYY1788612xQ8dXSvhbLY; Sun, 22 Dec 2019 18:26:34 -0800 X-Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by mx.groups.io with SMTP id smtpd.web10.5465.1577067993919066006 for ; Sun, 22 Dec 2019 18:26:34 -0800 X-Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 22 Dec 2019 18:26:22 -0800 X-Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Sun, 22 Dec 2019 18:26:33 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Sun, 22 Dec 2019 18:26:33 -0800 X-Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 23 Dec 2019 02:26:32 +0000 X-Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 23 Dec 2019 02:26:32 +0000 X-Received: from ashishsingha-lnx.nvidia.com (Not Verified[10.28.48.147]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Sun, 22 Dec 2019 18:26:32 -0800 From: "Ashish Singhal" To: , , , , , , CC: Ashish Singhal Subject: [edk2-devel] [PATCH v6] MdeModulePkg: Add EDK2 Platform Boot Manager Protocol Date: Sun, 22 Dec 2019 19:26:30 -0700 Message-ID: <99d69ff17a4ca86b23a889b9ac84832d7f7a13b1.1577067900.git.ashishsingha@nvidia.com> X-NVConfidentiality: public 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,ashishsingha@nvidia.com X-Gm-Message-State: 3CZM3JMhp6myhCFzWKefZe5bx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1577067994; bh=cPmm0ohYQxzpK7buxE2SloimWO7hg19992d9lgtcCmU=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=a9aR6N4sgLKSh8mhVM3bRAwK28Yporgcn4eqoGexRsUHZGPkhpMzt1ulMPzwYX9h9G2 DPspe8pT3fQFAjdKVDhJeUYcQiUZ0D8vihnioT8+Z5+EtXOVCV7qp/iLMrgzigcP3fzBR k+vObvB7TPrh8UTx5ha7kOMzj6AtvnR7K+U= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add edk2 platform boot manager protocol which would have platform specific refreshes to the auto enumerated as well as NV boot options for the platform. Signed-off-by: Ashish Singhal --- .../Include/Protocol/PlatformBootManager.h | 82 ++++++++++++++++++= ++++ MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 41 +++++++++-- .../Library/UefiBootManagerLib/InternalBm.h | 2 + .../UefiBootManagerLib/UefiBootManagerLib.inf | 2 + MdeModulePkg/MdeModulePkg.dec | 4 ++ 5 files changed, 124 insertions(+), 7 deletions(-) create mode 100644 MdeModulePkg/Include/Protocol/PlatformBootManager.h diff --git a/MdeModulePkg/Include/Protocol/PlatformBootManager.h b/MdeModul= ePkg/Include/Protocol/PlatformBootManager.h new file mode 100644 index 0000000..0354c60 --- /dev/null +++ b/MdeModulePkg/Include/Protocol/PlatformBootManager.h @@ -0,0 +1,82 @@ +/** @file + + Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __PLATFORM_BOOT_MANAGER_PROTOCOL_H__ +#define __PLATFORM_BOOT_MANAGER_PROTOCOL_H__ + +#include + +// +// Platform Boot Manager Protocol GUID value +// +#define EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL_GUID \ + { \ + 0xaa17add4, 0x756c, 0x460d, { 0x94, 0xb8, 0x43, 0x88, 0xd7, 0xfb, 0x= 3e, 0x59 } \ + } + +// +// Protocol interface structure +// +typedef struct _EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL EDKII_PLATFORM_BOOT_M= ANAGER_PROTOCOL; + +// +// Revision The revision to which the protocol interface adheres. +// All future revisions must be backwards compatible. +// If a future version is not back wards compatible it is not the= same GUID. +// +#define EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL_REVISION 0x00000001 + +// +// Function Prototypes +// + +/* + This function allows platform to refresh all boot options specific to th= e platform. Within + this function, platform can make modifications to the auto enumerated pl= atform boot options + as well as NV boot options. + + @param[in const] BootOptions An array of auto enumerated pla= tform boot options. + This array will be freed by cal= ler upon successful + exit of this function and outpu= t array would be used. + + @param[in const] BootOptionsCount The number of elements in BootO= ptions. + + @param[out] UpdatedBootOptions An array of boot options that h= ave been customized + for the platform on top of inpu= t boot options. This + array would be allocated by REF= RESH_ALL_BOOT_OPTIONS + and would be freed by caller af= ter consuming it. + + @param[out] UpdatedBootOptionsCount The number of elements in Updat= edBootOptions. + + + @retval EFI_SUCCESS Platform refresh to input BootO= ptions and + BootCount have been done. + + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. + + @retval EFI_INVALID_PARAMETER Input is not correct. + + @retval EFI_UNSUPPORTED Platform specific overrides are= not supported. +*/ +typedef +EFI_STATUS +(EFIAPI *REFRESH_ALL_BOOT_OPTIONS) ( + IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions, + IN CONST UINTN BootOptionsCount, + OUT EFI_BOOT_MANAGER_LOAD_OPTION **UpdatedBootOptions, + OUT UINTN *UpdatedBootOptionsCount + ); + +struct _EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL { + UINT64 Revision; + REFRESH_ALL_BOOT_OPTIONS RefreshAllBootOptions; +}; + +extern EFI_GUID gEdkiiPlatformBootManagerProtocolGuid; + +#endif /* __PLATFORM_BOOT_MANAGER_PROTOCOL_H__ */ diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePk= g/Library/UefiBootManagerLib/BmBoot.c index 760d764..62c5b2dc 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -1,6 +1,7 @@ /** @file Library functions which relates with booting. =20 +Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -2258,12 +2259,15 @@ EfiBootManagerRefreshAllBootOption ( VOID ) { - EFI_STATUS Status; - EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions; - UINTN NvBootOptionCount; - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; - UINTN BootOptionCount; - UINTN Index; + EFI_STATUS Status; + EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions; + UINTN NvBootOptionCount; + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; + UINTN BootOptionCount; + EFI_BOOT_MANAGER_LOAD_OPTION *UpdatedBootOptions; + UINTN UpdatedBootOptionCount; + UINTN Index; + EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL *PlatformBootManager; =20 // // Optionally refresh the legacy boot option @@ -2273,7 +2277,6 @@ EfiBootManagerRefreshAllBootOption ( } =20 BootOptions =3D BmEnumerateBootOptions (&BootOptionCount); - NvBootOptions =3D EfiBootManagerGetLoadOptions (&NvBootOptionCount, Load= OptionTypeBoot); =20 // // Mark the boot option as added by BDS by setting OptionalData to a spe= cial GUID @@ -2284,6 +2287,30 @@ EfiBootManagerRefreshAllBootOption ( } =20 // + // Locate Platform Boot Options Protocol + // + Status =3D gBS->LocateProtocol (&gEdkiiPlatformBootManagerProtocolGuid, + NULL, + (VOID **)&PlatformBootManager); + if (!EFI_ERROR (Status)) { + // + // If found, call platform specific refresh to all auto enumerated and= NV + // boot options. + // + Status =3D PlatformBootManager->RefreshAllBootOptions ((CONST EFI_BOOT= _MANAGER_LOAD_OPTION *)BootOptions, + (CONST UINTN)Boot= OptionCount, + &UpdatedBootOptio= ns, + &UpdatedBootOptio= nCount); + if (!EFI_ERROR (Status)) { + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); + BootOptions =3D UpdatedBootOptions; + BootOptionCount =3D UpdatedBootOptionCount; + } + } + + NvBootOptions =3D EfiBootManagerGetLoadOptions (&NvBootOptionCount, Load= OptionTypeBoot); + + // // Remove invalid EFI boot options from NV // for (Index =3D 0; Index < NvBootOptionCount; Index++) { diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModu= lePkg/Library/UefiBootManagerLib/InternalBm.h index 027eb25..ac866ac 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h @@ -1,6 +1,7 @@ /** @file BDS library definition, include the file and data structure =20 +Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -41,6 +42,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 #include #include diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf= b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf index ed6b467..cf59086 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf +++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf @@ -5,6 +5,7 @@ # manipulation, hotkey registration, UEFI boot, connect/disconnect, conso= le # manipulation, driver health checking and etc. # +# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
# SPDX-License-Identifier: BSD-2-Clause-Patent @@ -107,6 +108,7 @@ gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES gEfiRamDiskProtocolGuid ## SOMETIMES_CONSUMES gEfiDeferredImageLoadProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiPlatformBootManagerProtocolGuid ## SOMETIMES_CONSUMES =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange = ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 41b9e70..cc238e9 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -3,6 +3,7 @@ # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs and libr= ary classes) # and libraries instances, which are used for those modules. # +# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
# Copyright (c) 2016, Linaro Ltd. All rights reserved.
# (C) Copyright 2016 - 2019 Hewlett Packard Enterprise Development LP
@@ -609,6 +610,9 @@ ## Include/Protocol/PeCoffImageEmulator.h gEdkiiPeCoffImageEmulatorProtocolGuid =3D { 0x96f46153, 0x97a7, 0x4793, = { 0xac, 0xc1, 0xfa, 0x19, 0xbf, 0x78, 0xea, 0x97 } } =20 + ## Include/Protocol/PlatformBootManager.h + gEdkiiPlatformBootManagerProtocolGuid =3D { 0xaa17add4, 0x756c, 0x460d, = { 0x94, 0xb8, 0x43, 0x88, 0xd7, 0xfb, 0x3e, 0x59 } } + # # [Error.gEfiMdeModulePkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. --=20 2.7.4 -=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 (#52485): https://edk2.groups.io/g/devel/message/52485 Mute This Topic: https://groups.io/mt/69220966/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-