From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.4785.1576720765501709477 for ; Wed, 18 Dec 2019 17:59:25 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ray.ni@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2019 17:59:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,330,1571727600"; d="scan'208";a="212875161" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga007.fm.intel.com with ESMTP; 18 Dec 2019 17:59:25 -0800 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 18 Dec 2019 17:59:25 -0800 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 18 Dec 2019 17:59:24 -0800 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 18 Dec 2019 17:59:24 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.90]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.236]) with mapi id 14.03.0439.000; Thu, 19 Dec 2019 09:59:21 +0800 From: "Ni, Ray" To: "Wang, Jian J" , "Wu, Hao A" , "Gao, Zhichao" , "Kinney, Michael D" , "'Andrew Fish (afish@apple.com)'" CC: "devel@edk2.groups.io" , Ashish Singhal Subject: Re: [PATCH v4] MdeModulePkg: Add EDK2 Platform Boot Manager Protocol Thread-Topic: [PATCH v4] MdeModulePkg: Add EDK2 Platform Boot Manager Protocol Thread-Index: AQHVtdbjDTqRtxi1sUCba08r6L+ncKfAsmlw Date: Thu, 19 Dec 2019 01:59:21 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C3A269D@SHSMSX104.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable All, The new EDKII Platform Boot Manager protocol provides a platform hook to so= lve below problem. Can you please review and think about: 1. Is it a proper solution to the problem? 2. Is the new protocol/function name proper? 3. Are the parameters in the function proper? **Problem: Platform requires certain BlockIo/SimpleFileSystem/LoadFile = instances don't cause Boot#### created. It's a need of platform customizati= on. **Details: Boot#### for BlockIo/SimpleFileSystem/LoadFile are created b= y API EfiBootMangerRefreshAllBootOptions(). There are 2 places that call th= is API: 1. Platform Boot Manager calls the API (usually in the full configuration b= oot path) 2. UiApp calls the API when entering "Boot Manager" page and "Boot Maintena= nce Manager" page. Platform can change Platform Boot Manager library to remove the unneeded Bo= ot#### in case #1. But platform has no way to remove the Boot#### created in case #2 . Thanks, Ray > -----Original Message----- > From: Ashish Singhal > Sent: Thursday, December 19, 2019 3:11 AM > To: devel@edk2.groups.io; Wang, Jian J ; Wu, Hao A > ; Gao, Zhichao ; Ni, Ray > > Cc: Ashish Singhal > Subject: [PATCH v4] MdeModulePkg: Add EDK2 Platform Boot Manager > Protocol >=20 > 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. >=20 > 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 >=20 > diff --git a/MdeModulePkg/Include/Protocol/PlatformBootManager.h > b/MdeModulePkg/Include/Protocol/PlatformBootManager.h > new file mode 100644 > index 0000000..ec32215 > --- /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, = 0x3e, > 0x59 } \ > + } > + > +// > +// Protocol interface structure > +// > +typedef struct _PLATFORM_BOOT_MANAGER_PROTOCOL > 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 t= he same > GUID. > +// > +#define EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL_REVISION > 0x00000001 > + > +// > +// Function Prototypes > +// > + > +/* > + This function allows platform to refresh all boot options specific to = the > platform. Within > + this function, platform can make modifications to the auto enumerated > platform boot options > + as well as NV boot options. > + > + @param[in const] BootOptions An array of auto enumerated > platform boot options. > + This array will be freed by c= aller upon successful > + exit of this function and out= put array would be used. > + > + @param[in const] BootOptionsCount The number of elements in > BootOptions. > + > + @param[out] UpdatedBootOptions An array of boot options that > have been customized > + for the platform on top of in= put boot options. This > + array would be allocated by > REFRESH_ALL_BOOT_OPTIONS > + and would be freed by caller = after consuming it. > + > + @param[out] UpdatedBootOptionsCount The number of elements in > UpdatedBootOptions. > + > + > + @retval EFI_SUCCESS Platform refresh 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 a= re 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 _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/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c > index 760d764..8b9a76d 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_MANAGER_PROTOCOL *PlatformBootManager; >=20 > // > // Optionally refresh the legacy boot option > @@ -2273,7 +2277,6 @@ EfiBootManagerRefreshAllBootOption ( > } >=20 > BootOptions =3D BmEnumerateBootOptions (&BootOptionCount); > - NvBootOptions =3D EfiBootManagerGetLoadOptions (&NvBootOptionCount, > LoadOptionTypeBoot); >=20 > // > // Mark the boot option as added by BDS by setting OptionalData to a > special 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 a= nd NV > + // boot options. > + // > + Status =3D PlatformBootManager->RefreshAllBootOptions ((CONST > EFI_BOOT_MANAGER_LOAD_OPTION *)BootOptions, > + (CONST UINTN)Bo= otOptionCount, > + &UpdatedBootOpt= ions, > + &UpdatedBootOpt= ionCount); > + if (!EFI_ERROR (Status)) { > + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); > + BootOptions =3D UpdatedBootOptions; > + BootOptionCount =3D UpdatedBootOptionCount; > + } > + } > + > + NvBootOptions =3D EfiBootManagerGetLoadOptions (&NvBootOptionCount, > LoadOptionTypeBoot); > + > + // > // Remove invalid EFI boot options from NV > // > for (Index =3D 0; Index < NvBootOptionCount; Index++) { > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h > b/MdeModulePkg/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, con= sole > # 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] >=20 > gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC > hange ## 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 > library 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. > -- > 2.7.4