]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
MdeModulePkg/UefiBootManagerLib: Generate boot description for NVME
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / BmBoot.c
index ecd0ae3822d05b26c862149f4b5813d304ca6a46..8a3a4027eec0139d8203eee14a080eaf95cec3df 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Library functions which relates with booting.\r
 \r
-Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -991,9 +991,13 @@ BmExpandMediaDevicePath (
     return FileBuffer;\r
   }\r
 \r
+  Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath, &Handle);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   //\r
-  // For device boot option only pointing to the removable device handle, \r
-  // should make sure all its children handles (its child partion or media handles) are created and connected. \r
+  // For device boot option only pointing to the removable device handle,\r
+  // should make sure all its children handles (its child partion or media handles)\r
+  // are created and connected.\r
   //\r
   gBS->ConnectController (Handle, NULL, NULL, TRUE);\r
 \r
@@ -1004,8 +1008,6 @@ BmExpandMediaDevicePath (
   // returned. After the Block IO protocol is reinstalled, subsequent\r
   // Block IO read/write will success.\r
   //\r
-  Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath, &Handle);\r
-  ASSERT_EFI_ERROR (Status);\r
   Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
   ASSERT_EFI_ERROR (Status);\r
   Buffer = AllocatePool (BlockIo->Media->BlockSize);\r
@@ -1530,15 +1532,15 @@ EfiBootManagerGetLoadOptionBuffer (
 }\r
 \r
 /**\r
-  Check if it's a Device Path pointing to BootMenuApp.\r
+  Check if it's a Device Path pointing to BootManagerMenu.\r
 \r
   @param  DevicePath     Input device path.\r
 \r
-  @retval TRUE   The device path is BootMenuApp File Device Path.\r
-  @retval FALSE  The device path is NOT BootMenuApp File Device Path.\r
+  @retval TRUE   The device path is BootManagerMenu File Device Path.\r
+  @retval FALSE  The device path is NOT BootManagerMenu File Device Path.\r
 **/\r
 BOOLEAN\r
-BmIsBootMenuAppFilePath (\r
+BmIsBootManagerMenuFilePath (\r
   EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
 )\r
 {\r
@@ -1645,7 +1647,7 @@ EfiBootManagerBoot (
   // 3. Signal the EVT_SIGNAL_READY_TO_BOOT event when we are about to load and execute\r
   //    the boot option.\r
   //\r
-  if (BmIsBootMenuAppFilePath (BootOption->FilePath)) {\r
+  if (BmIsBootManagerMenuFilePath (BootOption->FilePath)) {\r
     DEBUG ((EFI_D_INFO, "[Bds] Booting Boot Manager Menu.\n"));\r
     BmStopHotkeyService (NULL, NULL);\r
   } else {\r
@@ -1940,7 +1942,6 @@ BmEnumerateBootOptions (
   UINTN                                 Removable;\r
   UINTN                                 Index;\r
   CHAR16                                *Description;\r
-  UINT32                                BootAttributes;\r
 \r
   ASSERT (BootOptionCount != NULL);\r
 \r
@@ -2070,6 +2071,12 @@ BmEnumerateBootOptions (
          &Handles\r
          );\r
   for (Index = 0; Index < HandleCount; Index++) {\r
+    //\r
+    // Ignore BootManagerMenu. its boot option will be created by EfiBootManagerGetBootManagerMenu().\r
+    //\r
+    if (BmIsBootManagerMenuFilePath (DevicePathFromHandle (Handles[Index]))) {\r
+      continue;\r
+    }\r
 \r
     Description = BmGetBootDescription (Handles[Index]);\r
     BootOptions = ReallocatePool (\r
@@ -2079,19 +2086,11 @@ BmEnumerateBootOptions (
                     );\r
     ASSERT (BootOptions != NULL);\r
 \r
-    //\r
-    // If LoadFile includes BootMenuApp, its boot attribue will be set to APP and HIDDEN.\r
-    //\r
-    BootAttributes = LOAD_OPTION_ACTIVE;\r
-    if (BmIsBootMenuAppFilePath (DevicePathFromHandle (Handles[Index]))) {\r
-      BootAttributes = LOAD_OPTION_CATEGORY_APP | LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN;\r
-    }\r
-\r
     Status = EfiBootManagerInitializeLoadOption (\r
                &BootOptions[(*BootOptionCount)++],\r
                LoadOptionNumberUnassigned,\r
                LoadOptionTypeBoot,\r
-               BootAttributes,\r
+               LOAD_OPTION_ACTIVE,\r
                Description,\r
                DevicePathFromHandle (Handles[Index]),\r
                NULL,\r
@@ -2155,7 +2154,7 @@ EfiBootManagerRefreshAllBootOption (
       // Only check those added by BDS\r
       // so that the boot options added by end-user or OS installer won't be deleted\r
       //\r
-      if (EfiBootManagerFindLoadOption (&NvBootOptions[Index], BootOptions, BootOptionCount) == (UINTN) -1) {\r
+      if (EfiBootManagerFindLoadOption (&NvBootOptions[Index], BootOptions, BootOptionCount) == -1) {\r
         Status = EfiBootManagerDeleteLoadOptionVariable (NvBootOptions[Index].OptionNumber, LoadOptionTypeBoot);\r
         //\r
         // Deleting variable with current variable implementation shouldn't fail.\r
@@ -2169,7 +2168,7 @@ EfiBootManagerRefreshAllBootOption (
   // Add new EFI boot options to NV\r
   //\r
   for (Index = 0; Index < BootOptionCount; Index++) {\r
-    if (EfiBootManagerFindLoadOption (&BootOptions[Index], NvBootOptions, NvBootOptionCount) == (UINTN) -1) {\r
+    if (EfiBootManagerFindLoadOption (&BootOptions[Index], NvBootOptions, NvBootOptionCount) == -1) {\r
       EfiBootManagerAddLoadOptionVariable (&BootOptions[Index], (UINTN) -1);\r
       //\r
       // Try best to add the boot options so continue upon failure.\r
@@ -2215,7 +2214,7 @@ BmRegisterBootManagerMenu (
   DevicePath = NULL;\r
   Description = NULL;\r
   //\r
-  // Try to find BootMenuApp from LoadFile protocol\r
+  // Try to find BootManagerMenu from LoadFile protocol\r
   //\r
   gBS->LocateHandleBuffer (\r
          ByProtocol,\r
@@ -2225,7 +2224,7 @@ BmRegisterBootManagerMenu (
          &Handles\r
          );\r
   for (Index = 0; Index < HandleCount; Index++) {\r
-    if (BmIsBootMenuAppFilePath (DevicePathFromHandle (Handles[Index]))) {\r
+    if (BmIsBootManagerMenuFilePath (DevicePathFromHandle (Handles[Index]))) {\r
       DevicePath  = DuplicateDevicePath (DevicePathFromHandle (Handles[Index]));\r
       Description = BmGetBootDescription (Handles[Index]);\r
       break;\r
@@ -2334,7 +2333,7 @@ EfiBootManagerGetBootManagerMenu (
   BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
 \r
   for (Index = 0; Index < BootOptionCount; Index++) {\r
-    if (BmIsBootMenuAppFilePath (BootOptions[Index].FilePath)) {\r
+    if (BmIsBootManagerMenuFilePath (BootOptions[Index].FilePath)) {\r
         Status = EfiBootManagerInitializeLoadOption (\r
                    BootOption,\r
                    BootOptions[Index].OptionNumber,\r