public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ashish Singhal" <ashishsingha@nvidia.com>
To: <devel@edk2.groups.io>, <jian.j.wang@intel.com>, <hao.a.wu@intel.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>
Subject: [PATCH] MdeModulePkg/UefiBootManagerLib: Support skipping BM enumeration
Date: Tue, 29 Oct 2019 21:47:23 -0600	[thread overview]
Message-ID: <8a8ecae581eeffd193157096f09da53a3ab3a7ab.1572406843.git.ashishsingha@nvidia.com> (raw)
In-Reply-To: <cover.1572406843.git.ashishsingha@nvidia.com>

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 <ashishsingha@nvidia.com>
---
 .../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 <Protocol/VariableLock.h>
 #include <Protocol/RamDisk.h>
 #include <Protocol/DeferredImageLoad.h>
+#include <Protocol/SkipBmAutoEnumerate.h>
 
 #include <Guid/MemoryTypeInformation.h>
 #include <Guid/FileInfo.h>
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


  reply	other threads:[~2019-10-30  3:47 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30  3:47 [PATCH] Support skipping automatic BM enumeration Ashish Singhal
2019-10-30  3:47 ` Ashish Singhal [this message]
2019-10-31 10:14 ` [edk2-devel] " Laszlo Ersek
     [not found]   ` <DM6PR12MB33249A87560B32B0155D4FE0BA630@DM6PR12MB3324.namprd12.prod.outlook.com>
2019-11-01 21:42     ` Laszlo Ersek
2019-11-01 22:05       ` Ashish Singhal
2019-11-01 22:57         ` Laszlo Ersek
2019-11-04 17:51           ` Ashish Singhal
2019-11-05  2:42   ` Ni, Ray
2019-11-05  3:24     ` Ashish Singhal
2019-11-05  5:00       ` Andrew Fish
2019-11-05  5:06         ` Ashish Singhal
2019-11-05  5:21           ` Andrew Fish
2019-11-05  5:42             ` Ashish Singhal
2019-11-05  6:15               ` Andrew Fish
2019-11-05  9:54                 ` Laszlo Ersek
2019-11-05 16:52                   ` Andrew Fish
2019-11-05 18:00                     ` Ashish Singhal
2019-11-05 19:23                       ` Laszlo Ersek
2019-11-05 23:19                         ` Jeff Brasen
2019-11-06  0:20                           ` Andrew Fish
2019-11-06  9:56                           ` Laszlo Ersek
2019-11-06 16:15                             ` Andrew Fish
2019-11-06 19:58                               ` Laszlo Ersek
2019-11-06  1:07                         ` Ashish Singhal
2019-11-06  1:34                           ` Jeff Brasen
2019-11-06  2:47                             ` Andrew Fish
2019-11-06  3:20                               ` Ni, Ray
2019-11-06 16:19                                 ` Andrew Fish
2019-11-07  4:12                                   ` Jeff Brasen
2019-11-07  6:59                                     ` Ni, Ray
2019-11-07  7:02                                       ` Jeff Brasen
2019-11-07  7:21                                         ` Ni, Ray
2019-11-07 17:46                                           ` Jeff Brasen
2019-11-08 16:37                                             ` Laszlo Ersek
2019-11-11 22:57                                               ` Jeff Brasen
2019-11-11 23:58                                                 ` Ni, Ray
2019-11-12  0:00                                                   ` Jeff Brasen
2019-11-13 18:42                                                     ` Jeff Brasen
2019-11-14  2:09                                                       ` Ni, Ray
2019-11-14 17:04                                                         ` Jeff Brasen
2019-12-10 20:46                                                           ` Jeff Brasen
2019-12-11  9:54                                                             ` [edk2-discuss] " Wang, Sunny (HPS SW)
2019-12-11 14:00                                                             ` Ni, Ray
2019-12-12 17:52                                                               ` Jeff Brasen
2019-12-17 20:15                                                                 ` Ashish Singhal
2019-12-18  3:54                                                                   ` [edk2-discuss] " Wang, Sunny (HPS SW)
2019-12-18  8:43                                                                     ` Ni, Ray
2019-11-07  7:01                                   ` Ni, Ray
2019-11-05  9:33       ` Laszlo Ersek
  -- strict thread matches above, loose matches on Subject: below --
2019-11-04 17:51 [PATCH] MdeModulePkg/UefiBootManagerLib: Support skipping " Ashish Singhal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8a8ecae581eeffd193157096f09da53a3ab3a7ab.1572406843.git.ashishsingha@nvidia.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox