From nobody Mon Apr 29 06:43:32 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+52292+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+52292+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=nvidia.com ARC-Seal: i=1; a=rsa-sha256; t=1576614993; cv=none; d=zohomail.com; s=zohoarc; b=maRF0PjN0TpYNOvgG6yGPdXt9Xz87T7LsZ4nY8O7wMYVphtU+AZcNCZsulOUZ9weq59sF7v/FZliIQVGr/PCclpTRexawQiU08xs7dN7UIMbZuKaN0i6Fw+NCYXGJZdjZMb419a15WGhUpAht/z9+etK58DGYVBWQlyHEl7YOa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576614993; h=Content-Type:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=U34v1XsR5ShwrF/+oDsVLiuUf5QCG+vpfGF3JOYDEWA=; b=nCzTsbDQF5gJKrPbtDlitHTGDE5CDLdixnJjDfzGR3qLtj74KC9jOL4MfJ2TTc1Xp0gGyAe/EP2n60uUtGVZ1WZ9YEmbViCbtIrZNtvDk9Zwf3Dt6RVAuYx+pdASM/y0f99QTFVGv7zV2+6AbVJjn3DwEevx2bMb/LK6F9y6HWc= 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+52292+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 1576614993715463.1879818208255; Tue, 17 Dec 2019 12:36:33 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5PNpYY1788612xhfPJGlNXiK; Tue, 17 Dec 2019 12:36:33 -0800 X-Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com [216.228.121.143]) by mx.groups.io with SMTP id smtpd.web12.1688.1576614992703966729 for ; Tue, 17 Dec 2019 12:36:32 -0800 X-Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 17 Dec 2019 12:36:04 -0800 X-Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 17 Dec 2019 12:36:32 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 17 Dec 2019 12:36:32 -0800 X-Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 17 Dec 2019 20:36:31 +0000 X-Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 17 Dec 2019 20:36:31 +0000 X-Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 17 Dec 2019 20:36:31 +0000 X-Received: from ashishsingha-lnx.nvidia.com (Not Verified[10.28.48.147]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 17 Dec 2019 12:36:31 -0800 From: "Ashish Singhal" To: , , , , CC: Ashish Singhal Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Add Platform Boot Options Protocol Date: Tue, 17 Dec 2019 13:36:28 -0700 Message-ID: <6f24dc6e1495eded1c77fa35aff40b574a75d7be.1576614938.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: ARcmn5JyAwJVHuzuXDn67Jqxx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576614993; bh=4G80OXuXAJbk8AGPD4IqA1/Hz01xdS4C5lvx699y+0E=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=nAzHecnlZiP9o9WJFKWoBpUDEbJbJ/xwjH/Pz4anbaTLFuegn4Lj+Ik6k6sS4eoxaLW MSybkF09RmzbB8kEAAzrKMps0VHRltk12A19+t/UgXAl+OMBnj7PCHhw1rqm1m0O0Gy0F VuH3sSr0cc3JBXpfitmolNyK8jhQ5Mci5Xk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add platform boot options protocol which would have platform specific overrides to the auto enumerated boot options during the call to EfiBootManagerRefreshAllBootOption function in UefiBootManagerLib. Signed-off-by: Ashish Singhal --- .../Include/Protocol/PlatformBootOptions.h | 116 +++++++++++++++++= ++++ MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 52 +++++++-- .../Library/UefiBootManagerLib/InternalBm.h | 2 + .../UefiBootManagerLib/UefiBootManagerLib.inf | 2 + MdeModulePkg/MdeModulePkg.dec | 4 + 5 files changed, 170 insertions(+), 6 deletions(-) create mode 100644 MdeModulePkg/Include/Protocol/PlatformBootOptions.h diff --git a/MdeModulePkg/Include/Protocol/PlatformBootOptions.h b/MdeModul= ePkg/Include/Protocol/PlatformBootOptions.h new file mode 100644 index 0000000..3e08155 --- /dev/null +++ b/MdeModulePkg/Include/Protocol/PlatformBootOptions.h @@ -0,0 +1,116 @@ +/** @file + + Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __PLATFORM_BOOT_OPTIONS_PROTOCOL_H__ +#define __PLATFORM_BOOT_OPTIONS_PROTOCOL_H__ + +#include + +// +// Platform Boot Options Protocol GUID value +// +#define EDKII_PLATFORM_BOOT_OPTIONS_PROTOCOL_GUID \ + { \ + 0xaa17add4, 0x756c, 0x460d, { 0x94, 0xb8, 0x43, 0x88, 0xd7, 0xfb, 0x= 3e, 0x59 } \ + } + +// +// Protocol interface structure +// +typedef struct _PLATFORM_BOOT_OPTIONS_PROTOCOL PLATFORM_BOOT_OPTIONS_PROTO= COL; + +// +// 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_OPTIONS_PROTOCOL_REVISION 0x00000001 + +// +// Function Prototypes +// + +/* + This function allows overrides to auto enumerated boot options for platf= orm. + + @param[in const] BootOptionsCount The number of elements in BootO= ptions. + + @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[out] UpdatedBootOptionsCount The number of elements in Updat= edBootOptions. + + @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 OVE= RRIDE_PLATFORM_BOOT_OPTIONS + and would be freed by caller af= ter consuming it. + + + @retval EFI_SUCCESS Platform overrides to input Boo= tOptions 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 *OVERRIDE_PLATFORM_BOOT_OPTIONS) ( + IN CONST UINTN BootOptionsCount, + IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions, + OUT UINTN *UpdatedBootOptionsCount, + OUT EFI_BOOT_MANAGER_LOAD_OPTION **UpdatedBootOptions + ); + +/* + This function allows to remove invalid platform specific boot options fr= om NV. + + @param[in const] NvBootOptionsCount The number of elements in NvB= ootOptions. + + @param[in const] NvBootOptions An array of current boot opti= ons in NV store. + This array will be freed by c= aller upon successful + exit of this function and out= put array would be used. + + @param[out] UpdatedBootOptionsCount The number of elements in Upd= atedBootOptions. + + @param[out] UpdatedBootOptions An array of NV boot options t= hat have been cleaned up + for the platform on top of in= put NV boot options. This + array would be allocated by R= EMOVE_INVALID_PLATFORM_NV_BOOT_OPTIONS + and would be freed by caller = after consuming it. + + + @retval EFI_SUCCESS Platform cleanup to input NvB= ootOptions and + NvBootCount 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 a= re not supported. +*/ +typedef +EFI_STATUS +(EFIAPI *REMOVE_INVALID_PLATFORM_NV_BOOT_OPTIONS) ( + IN CONST UINTN NvBootOptionsCount, + IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions, + OUT UINTN *UpdatedBootOptionsCount, + OUT EFI_BOOT_MANAGER_LOAD_OPTION **UpdatedBootOptions + ); + +struct _PLATFORM_BOOT_OPTIONS_PROTOCOL { + UINT64 Revision; + OVERRIDE_PLATFORM_BOOT_OPTIONS OverridePlatformBootOptions; + REMOVE_INVALID_PLATFORM_NV_BOOT_OPTIONS RemoveInvalidPlatformNvBootOptio= ns; +}; + +extern EFI_GUID gEdkiiPlatformBootOptionsProtocolGuid; + +#endif /* __PLATFORM_BOOT_OPTIONS_PROTOCOL_H__ */ diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePk= g/Library/UefiBootManagerLib/BmBoot.c index 760d764..41e09d5 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; + PLATFORM_BOOT_OPTIONS_PROTOCOL *PlatformBootOptions; =20 // // Optionally refresh the legacy boot option @@ -2284,6 +2288,42 @@ EfiBootManagerRefreshAllBootOption ( } =20 // + // Locate Platform Boot Options Protocol + // + PlatformBootOptions =3D NULL; + Status =3D gBS->LocateProtocol (&gEdkiiPlatformBootOptionsProtocolGuid, + NULL, + (VOID **)&PlatformBootOptions); + if (!EFI_ERROR (Status)) { + // + // If found, call platform specific overrides to auto enumerated + // boot options. + // + Status =3D PlatformBootOptions->OverridePlatformBootOptions ((CONST UI= NTN)BootOptionCount, + (CONST EFI_= BOOT_MANAGER_LOAD_OPTION *)BootOptions, + &UpdatedBoo= tOptionCount, + &UpdatedBoo= tOptions); + if (!EFI_ERROR (Status)) { + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); + BootOptions =3D UpdatedBootOptions; + BootOptionCount =3D UpdatedBootOptionCount; + } + + // + // Call platform specific override to remove invalid boot options from= NV + // + Status =3D PlatformBootOptions->RemoveInvalidPlatformNvBootOptions ((C= ONST UINTN)NvBootOptionCount, + (CON= ST EFI_BOOT_MANAGER_LOAD_OPTION *)NvBootOptions, + &Upd= atedBootOptionCount, + &Upd= atedBootOptions); + if (!EFI_ERROR (Status)) { + EfiBootManagerFreeLoadOptions (NvBootOptions, NvBootOptionCount); + NvBootOptions =3D UpdatedBootOptions; + NvBootOptionCount =3D UpdatedBootOptionCount; + } + } + + // // 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..1f65860 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..d839252 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 + gEdkiiPlatformBootOptionsProtocolGuid ## SOMETIMES_CONSUMES =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange = ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 41b9e70..bb9fa8b 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/PlatformBootOptions.h + gEdkiiPlatformBootOptionsProtocolGuid =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 (#52292): https://edk2.groups.io/g/devel/message/52292 Mute This Topic: https://groups.io/mt/68770160/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-