From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web09.1612.1577162619965970326 for ; Mon, 23 Dec 2019 20:43:40 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0261e1ca74=sunnywang@hpe.com) Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBO4cRrS001352; Tue, 24 Dec 2019 04:43:37 GMT Received: from g4t3425.houston.hpe.com (g4t3425.houston.hpe.com [15.241.140.78]) by mx0b-002e3701.pphosted.com with ESMTP id 2x33402c14-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Dec 2019 04:43:37 +0000 Received: from G4W10204.americas.hpqcorp.net (g4w10204.houston.hpecorp.net [16.207.82.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3425.houston.hpe.com (Postfix) with ESMTPS id A21109D; Tue, 24 Dec 2019 04:43:36 +0000 (UTC) Received: from G1W8106.americas.hpqcorp.net (16.193.72.61) by G4W10204.americas.hpqcorp.net (16.207.82.16) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 24 Dec 2019 04:43:36 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (15.241.52.12) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Tue, 24 Dec 2019 04:43:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jhknD2b7Oa3yP5zFGn5LbiJnrvAfLogW1u4jbjm9R1CvQdy6L5wRs6F082xbLZse0d4jjq1odKm5el1fBP6WZgl0PDcgyK1X3uwdvXlksEOyqC8rV5uim84XV+KlPUv0qsFPi7fe5IEY2BFb2M09OxRFFXmvQYI43WRxCSZe85WEVx2WM2uan7NnkfXkgMIeTDquvbbGT8IPlexTYld+XxBJX6hoKX6q+TEXSjyAp0++5Y9byfqPvG3/ewi/sGGscExCP81pG8mLgJtbp1zHZam3T2lveGe/5HQS0fOArWpsz7/dID+CmQLBi93LProw3nSH05Yi/EqwIzR6vxqAfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dlthKAGZlXYHrxj2qAtwroQbEQIndJwXgA3BO/gg7sQ=; b=HEz5yGPm1s2doGAxMJd6Vjn8A8HVKr50pW+Ric3Yh8U+UlR5kB7Yy7Nl7FESRJ2cpvAMg6zIsJgVAU5UGvFn5oShzBxiaP8dyYdM1gxkjrI8gw772LyKQxwxIO+rqcOJ7wqyI6AQhza/vMe7o45tr7Fky5N7Nhg/GVfvXunAxYDO8Fw1P8LUZhBTNvu61f4nNt8dUyV4Eotbrf2TcScmXmhP+Ah2PRQrAKeH7o7zU7tOol8d4PS41DOS5wYZBI6x5sdDLu8EuJOXJ6ZaxUqGDAjNnVcJ8kxDGcueouy7WeUWVrhitkfhIB0CVqSDyOwQEYTUI2uxvehBeIi0VWYHMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from DF4PR8401MB1307.NAMPRD84.PROD.OUTLOOK.COM (10.169.93.143) by DF4PR8401MB1146.NAMPRD84.PROD.OUTLOOK.COM (10.169.92.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14; Tue, 24 Dec 2019 04:43:34 +0000 Received: from DF4PR8401MB1307.NAMPRD84.PROD.OUTLOOK.COM ([fe80::7969:cbbd:6156:5fb4]) by DF4PR8401MB1307.NAMPRD84.PROD.OUTLOOK.COM ([fe80::7969:cbbd:6156:5fb4%4]) with mapi id 15.20.2559.017; Tue, 24 Dec 2019 04:43:34 +0000 From: "Wang, Sunny (HPS SW)" To: "devel@edk2.groups.io" , "ashishsingha@nvidia.com" , "ray.ni@intel.com" , "jian.j.wang@intel.com" , "hao.a.wu@intel.com" , "zhichao.gao@intel.com" , "michael.d.kinney@intel.com" , "afish@apple.com" CC: "Wang, Sunny (HPS SW)" , "Spottswood, Jason" Subject: Re: [edk2-devel] [PATCH v7] MdeModulePkg: Add EDK2 Platform Boot Manager Protocol Thread-Topic: [edk2-devel] [PATCH v7] MdeModulePkg: Add EDK2 Platform Boot Manager Protocol Thread-Index: AQHVugXzyMKZSbYKCk+6P44hprTvxqfItLKw Date: Tue, 24 Dec 2019 04:43:34 +0000 Message-ID: References: <2fa4a9e68aca6e56ba948ba612b75601d33d279f.1577156123.git.ashishsingha@nvidia.com> In-Reply-To: <2fa4a9e68aca6e56ba948ba612b75601d33d279f.1577156123.git.ashishsingha@nvidia.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [16.242.247.133] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 78a0ac67-d124-4176-b224-08d7882bd59c x-ms-traffictypediagnostic: DF4PR8401MB1146: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:284; x-forefront-prvs: 0261CCEEDF x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(346002)(39860400002)(376002)(189003)(13464003)(199004)(6506007)(53546011)(66446008)(966005)(52536014)(33656002)(81166006)(81156014)(30864003)(19627235002)(86362001)(8676002)(66946007)(110136005)(55016002)(4326008)(64756008)(71200400001)(7696005)(66476007)(66556008)(54906003)(76116006)(186003)(5660300002)(26005)(8936002)(316002)(9686003)(2906002)(478600001);DIR:OUT;SFP:1102;SCL:1;SRVR:DF4PR8401MB1146;H:DF4PR8401MB1307.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dOiiT2MiuheRymXXY1gJLZsXwdHhv5r7W8HsEJg415rkhjsUXdld1KWN53vyMlcIMS2qz9WOhJdyv6pHmprTB+851HcEoX6Naf8dSOymgJknHguzEmS9O6VA0FdkFoaEz4oraYcNSPE4nPJbFyO1uzpHhQ0GM2ikAwteRwwHkHWwqaH3dM24eYff132tyyiaTFN3I6mNdp6xe60HwO8zTh5zRS8gDUU3CgkUbcWxxyaytZMIso6lTIr82D8Co5rurZKZKkEsuIox+LvqkERBojSKFKqYkPFS2vBpYr5fxmL3ZSWEkI+uLUmYP985amOnpLF7ibI/5YdR360PMj8vI7T9XjKlI6dEis2+nBLsbQyfkSDx9VzVe92ZRXaMkJP+LBU0ZsD1sXZpeznrj4tYcGfPDC5RtYydBNGnoX4KSjyRk8kJ0xll4Y8QP/z51o1GW7N3deoVfhUSP7EiT9UiOCrEaWRHXBLqv+rwQWJXL2Xu5cZurl+jI76JtYW/a9JKD21k9yi9EBv31fS7vXKaGojHG0pp/v4yi4A2c4v3rNE= X-MS-Exchange-CrossTenant-Network-Message-Id: 78a0ac67-d124-4176-b224-08d7882bd59c X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Dec 2019 04:43:34.3244 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: O9db5ocg+Zl2Kx206vWnKG5USvhjTFvkB1C0AmK4WxwELbK4rXLD8q5jpeOvrRCtOWFDXGmZsMxgbq40JT3wzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB1146 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 3 URL's were un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-23_10:2019-12-23,2019-12-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912240038 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Looks good enough to me. Thanks for addressing my comments, Ashish. Reviewed-by: Sunny Wang -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Ashi= sh Singhal Sent: Tuesday, December 24, 2019 10:58 AM To: devel@edk2.groups.io; ray.ni@intel.com; jian.j.wang@intel.com; hao.a.w= u@intel.com; zhichao.gao@intel.com; michael.d.kinney@intel.com; afish@apple= .com Cc: Ashish Singhal Subject: [edk2-devel] [PATCH v7] MdeModulePkg: Add EDK2 Platform Boot Mana= ger Protocol Add edk2 platform boot manager protocol which would have platform specific= refreshes to the auto enumerated as well as NV boot options for the platfo= rm. 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 Md= eModulePkg/Include/Protocol/PlatformBootManager.h diff --git a/MdeModulePkg/Include/Protocol/PlatformBootManager.h b/MdeModu= lePkg/Include/Protocol/PlatformBootManager.h new file mode 100644 index 0000000..26b9ce4 --- /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=20 +EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL_GUID \ + { \ + 0xaa17add4, 0x756c, 0x460d, { 0x94, 0xb8, 0x43, 0x88, 0xd7, 0xfb, 0= x3e, 0x59 } \ + } + +// +// Protocol interface structure +// +typedef struct _EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL=20 +EDKII_PLATFORM_BOOT_MANAGER_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 th= e same GUID. +// +#define EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL_REVISION 0x00000001 + +// +// Function Prototypes +// + +/* + This function allows platform to refresh all boot options specific to= =20 +the platform. Within + this function, platform can make modifications to the auto enumerated= =20 +platform boot options + as well as NV boot options. + + @param[in const] BootOptions An array of auto enumerated pl= atform boot options. + This array will be freed by ca= ller upon successful + exit of this function and outp= ut array would be used. + + @param[in const] BootOptionsCount The number of elements in Boot= Options. + + @param[out] UpdatedBootOptions An array of boot options that = have been customized + for the platform on top of inp= ut boot options. This + array would be allocated by RE= FRESH_ALL_BOOT_OPTIONS + and would be freed by caller a= fter consuming it. + + @param[out] UpdatedBootOptionsCount The number of elements in Upda= tedBootOptions. + + + @retval EFI_SUCCESS Platform refresh to input Boot= Options 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 ar= e not supported. +*/ +typedef +EFI_STATUS +(EFIAPI *PLATFORM_BOOT_MANAGER_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; + PLATFORM_BOOT_MANAGER_REFRESH_ALL_BOOT_OPTIONS RefreshAllBootOptions;= =20 +}; + +extern EFI_GUID gEdkiiPlatformBootManagerProtocolGuid; + +#endif /* __PLATFORM_BOOT_MANAGER_PROTOCOL_H__ */ diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModuleP= kg/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 @@ EfiB= ootManagerRefreshAllBootOption ( 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 @@ EfiB= ootManagerRefreshAllBootOption ( } =20 BootOptions =3D BmEnumerateBootOptions (&BootOptionCount); - NvBootOptions =3D EfiBootManagerGetLoadOptions (&NvBootOptionCount, Loa= dOptionTypeBoot); =20 // // Mark the boot option as added by BDS by setting OptionalData to a sp= ecial GUID @@ -2284,6 +2287,30 @@ EfiBootManagerRefreshAllBootOption ( } =20 // + // Locate Platform Boot Options Protocol // Status =3D=20 + gBS->LocateProtocol (&gEdkiiPlatformBootManagerProtocolGuid, + NULL, + (VOID **)&PlatformBootManager); if=20 + (!EFI_ERROR (Status)) { + // + // If found, call platform specific refresh to all auto enumerated an= d NV + // boot options. + // + Status =3D PlatformBootManager->RefreshAllBootOptions ((CONST EFI_BOO= T_MANAGER_LOAD_OPTION *)BootOptions, + (CONST UINTN)Boo= tOptionCount, + &UpdatedBootOpti= ons, + &UpdatedBootOpti= onCount); + if (!EFI_ERROR (Status)) { + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); + BootOptions =3D UpdatedBootOptions; + BootOptionCount =3D UpdatedBootOptionCount; + } + } + + NvBootOptions =3D EfiBootManagerGetLoadOptions (&NvBootOptionCount,=20 + LoadOptionTypeBoot); + + // // Remove invalid EFI boot options from NV // for (Index =3D 0; Index < NvBootOptionCount; Index++) { diff --git a/Md= eModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/U= efiBootManagerLib/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-Licen= se-Identifier: BSD-2-Clause-Patent #include #in= clude #include +#include =20 #include #include diff = --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf b/Md= eModulePkg/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, cons= ole # 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
# S= PDX-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 lib= rary 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) Copyrigh= t 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,= = =20 + { 0x94, 0xb8, 0x43, 0x88, 0xd7, 0xfb, 0x3e, 0x59 } } + # # [Error.gEfiMdeModulePkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. -- 2.7.4