]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
MdeModulePkg: Add EDK2 Platform Boot Manager Protocol
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / BmBoot.c
index 760d7647b8b3ad392edb2da5bef3c3b3ea5e2607..62c5b2dc94ab309449513a3344432d2a1cdf2820 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
   Library functions which relates with booting.\r
 \r
+Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.\r
 Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
@@ -2258,12 +2259,15 @@ EfiBootManagerRefreshAllBootOption (
   VOID\r
   )\r
 {\r
-  EFI_STATUS                    Status;\r
-  EFI_BOOT_MANAGER_LOAD_OPTION  *NvBootOptions;\r
-  UINTN                         NvBootOptionCount;\r
-  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOptions;\r
-  UINTN                         BootOptionCount;\r
-  UINTN                         Index;\r
+  EFI_STATUS                           Status;\r
+  EFI_BOOT_MANAGER_LOAD_OPTION         *NvBootOptions;\r
+  UINTN                                NvBootOptionCount;\r
+  EFI_BOOT_MANAGER_LOAD_OPTION         *BootOptions;\r
+  UINTN                                BootOptionCount;\r
+  EFI_BOOT_MANAGER_LOAD_OPTION         *UpdatedBootOptions;\r
+  UINTN                                UpdatedBootOptionCount;\r
+  UINTN                                Index;\r
+  EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL *PlatformBootManager;\r
 \r
   //\r
   // Optionally refresh the legacy boot option\r
@@ -2273,7 +2277,6 @@ EfiBootManagerRefreshAllBootOption (
   }\r
 \r
   BootOptions   = BmEnumerateBootOptions (&BootOptionCount);\r
-  NvBootOptions = EfiBootManagerGetLoadOptions (&NvBootOptionCount, LoadOptionTypeBoot);\r
 \r
   //\r
   // Mark the boot option as added by BDS by setting OptionalData to a special GUID\r
@@ -2283,6 +2286,30 @@ EfiBootManagerRefreshAllBootOption (
     BootOptions[Index].OptionalDataSize = sizeof (EFI_GUID);\r
   }\r
 \r
+  //\r
+  // Locate Platform Boot Options Protocol\r
+  //\r
+  Status = gBS->LocateProtocol (&gEdkiiPlatformBootManagerProtocolGuid,\r
+                                NULL,\r
+                                (VOID **)&PlatformBootManager);\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // If found, call platform specific refresh to all auto enumerated and NV\r
+    // boot options.\r
+    //\r
+    Status = PlatformBootManager->RefreshAllBootOptions ((CONST EFI_BOOT_MANAGER_LOAD_OPTION *)BootOptions,\r
+                                                         (CONST UINTN)BootOptionCount,\r
+                                                         &UpdatedBootOptions,\r
+                                                         &UpdatedBootOptionCount);\r
+    if (!EFI_ERROR (Status)) {\r
+      EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);\r
+      BootOptions = UpdatedBootOptions;\r
+      BootOptionCount = UpdatedBootOptionCount;\r
+    }\r
+  }\r
+\r
+  NvBootOptions = EfiBootManagerGetLoadOptions (&NvBootOptionCount, LoadOptionTypeBoot);\r
+\r
   //\r
   // Remove invalid EFI boot options from NV\r
   //\r