From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from hqemgate14.nvidia.com (hqemgate14.nvidia.com [216.228.121.143]) by mx.groups.io with SMTP id smtpd.web12.995.1572407245961704118 for ; Tue, 29 Oct 2019 20:47:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=n1 header.b=WcRBcE3Z; spf=pass (domain: nvidia.com, ip: 216.228.121.143, mailfrom: ashishsingha@nvidia.com) Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 29 Oct 2019 20:47:31 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 29 Oct 2019 20:47:25 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 29 Oct 2019 20:47:25 -0700 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; Wed, 30 Oct 2019 03:47:25 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 30 Oct 2019 03:47:25 +0000 Received: from ashishsingha-lnx.nvidia.com (Not Verified[10.28.48.147]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 29 Oct 2019 20:47:25 -0700 From: "Ashish Singhal" To: , , CC: Ashish Singhal Subject: [PATCH] MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration Date: Tue, 29 Oct 2019 21:47:23 -0600 Message-ID: <8a8ecae581eeffd193157096f09da53a3ab3a7ab.1572406843.git.ashishsingha@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-NVConfidentiality: public Return-Path: ashishsingha@nvidia.com MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1572407251; bh=bbnfWqBMCGwxG4REl/NWxObGK7QGCF253Q41g6wdFZk=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=WcRBcE3Z2XF+1OlZ/nnVpYMX28gdLGhjYfQbsEe7il3dBoSuBvB/3PiJ4Tg4fxWMD ZnObFtouQ+MrnmpIaAv4ts6XQZdqm5bQWpYU7scUeb2Uz61J/3puVL1l8yqGjak8qB 0gjWcpubtkK+hKcW53Ah6OGZ3VhsLWlF1uW1oLhkPAUXe1e5GJzfeK9nRMIgYRehqQ 6C+bsKnkqlVSzjAE6P4rs228bWWvwq46FjIh2iKY+1gS/ZIgtoS7vaDI4ky/+ifyYu dOLEHA2x694SsLK6yNk+8vtYCK2PkpQIPcrTAlSnPo8Bs18ej7Zy83CU0IG4UJIeQ3 z7gphpdqYVRMA== Content-Type: text/plain Allow support for skipping auto enumeration of a BlockIO or SimpleFileSystem or LoadFile protocol based on a new protocol installed on the same handle. EdkiiSkipBmAutoEnumerate protocol has been added for that purpose. Signed-off-by: Ashish Singhal --- .../Include/Protocol/SkipBmAutoEnumerate.h | 25 ++++++++++++++ MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 40 +++++++++++++++++++++- .../Library/UefiBootManagerLib/InternalBm.h | 1 + .../UefiBootManagerLib/UefiBootManagerLib.inf | 1 + MdeModulePkg/MdeModulePkg.dec | 3 ++ 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h diff --git a/MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h b/MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h new file mode 100644 index 0000000..7efca7a --- /dev/null +++ b/MdeModulePkg/Include/Protocol/SkipBmAutoEnumerate.h @@ -0,0 +1,25 @@ +/** @file + Skip Boot Manager Auto Enumerate protocol header file. + + This is used to skip auto boot manager enumeration. This protocol can + be installed on any handle having BlockIo or SimpleFileSystem or LoadFile + protocol and UEFI boot manager would skip its enumeration. + +Copyright (c) 2019, NVIDIA Corporation. All rights reserved. + +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _SKIP_BM_AUTO_ENUMERATE_PROTOCOL_H_ +#define _SKIP_BM_AUTO_ENUMERATE_PROTOCOL_H_ + +/// +/// Global ID for the EDKII SKIP BM AUTO ENUMERATE Protocol. +/// +#define EDKII_SKIP_BM_AUTO_ENUMERATE_PROTOCOL_GUID \ + { 0x2733f321, 0x5a7e, 0x4178, { 0x86, 0xcc, 0x21, 0x65, 0xd2, 0x0c, 0xec, 0x1e }} + +extern EFI_GUID gEdkiiSkipBmAutoEnumerateProtocolGuid; + +#endif diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index 760d764..7b5f176 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -2080,6 +2080,7 @@ BmEnumerateBootOptions ( UINTN HandleCount; EFI_HANDLE *Handles; EFI_BLOCK_IO_PROTOCOL *BlkIo; + VOID *SkipBmAutoEnumerate; UINTN Removable; UINTN Index; CHAR16 *Description; @@ -2111,6 +2112,18 @@ BmEnumerateBootOptions ( continue; } + Status = gBS->HandleProtocol ( + Handles[Index], + &gEdkiiSkipBmAutoEnumerateProtocolGuid, + (VOID **) &SkipBmAutoEnumerate + ); + if (!EFI_ERROR (Status)) { + // + // Skip if the file system handle supports a SkipBmAutoEnumerate protocol + // + continue; + } + // // Skip the logical partitions // @@ -2169,12 +2182,25 @@ BmEnumerateBootOptions ( &gEfiBlockIoProtocolGuid, (VOID **) &BlkIo ); - if (!EFI_ERROR (Status)) { + if (!EFI_ERROR (Status)) { // // Skip if the file system handle supports a BlkIo protocol, which we've handled in above // continue; } + + Status = gBS->HandleProtocol ( + Handles[Index], + &gEdkiiSkipBmAutoEnumerateProtocolGuid, + (VOID **) &SkipBmAutoEnumerate + ); + if (!EFI_ERROR (Status)) { + // + // Skip if the file system handle supports a SkipBmAutoEnumerate protocol + // + continue; + } + Description = BmGetBootDescription (Handles[Index]); BootOptions = ReallocatePool ( sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount), @@ -2212,6 +2238,18 @@ BmEnumerateBootOptions ( &Handles ); for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->HandleProtocol ( + Handles[Index], + &gEdkiiSkipBmAutoEnumerateProtocolGuid, + (VOID **) &SkipBmAutoEnumerate + ); + if (!EFI_ERROR (Status)) { + // + // Skip if the file system handle supports a SkipBmAutoEnumerate protocol + // + continue; + } + // // Ignore BootManagerMenu. its boot option will be created by EfiBootManagerGetBootManagerMenu(). // diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h index 027eb25..f95e58f 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h @@ -41,6 +41,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf index ed6b467..40c668c 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf +++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf @@ -107,6 +107,7 @@ gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES gEfiRamDiskProtocolGuid ## SOMETIMES_CONSUMES gEfiDeferredImageLoadProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiSkipBmAutoEnumerateProtocolGuid ## SOMETIMES_CONSUMES [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index d6bac97..64ef22a 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -604,6 +604,9 @@ ## Include/Protocol/PeCoffImageEmulator.h gEdkiiPeCoffImageEmulatorProtocolGuid = { 0x96f46153, 0x97a7, 0x4793, { 0xac, 0xc1, 0xfa, 0x19, 0xbf, 0x78, 0xea, 0x97 } } + ## Include/Protocol/SkipBmAutoEnumerate.h + gEdkiiSkipBmAutoEnumerateProtocolGuid = { 0x2733f321, 0x5a7e, 0x4178, { 0x86, 0xcc, 0x21, 0x65, 0xd2, 0x0c, 0xec, 0x1e } } + # # [Error.gEfiMdeModulePkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. -- 2.7.4