]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
MdeModulePkg: Skip registering BootManagerMenu if absent
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / BmBoot.c
index d0165170143f07ee557e9115dd99e0753f43b1aa..4da401d23cfd15d40afae5722a651e55cf05791a 100644 (file)
@@ -2,7 +2,7 @@
   Library functions which relates with booting.\r
 \r
 Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP<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
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -2159,7 +2159,7 @@ EfiBootManagerRefreshAllBootOption (
 }\r
 \r
 /**\r
-  This function is called to create the boot option for the Boot Manager Menu.\r
+  This function is called to get or create the boot option for the Boot Manager Menu.\r
 \r
   The Boot Manager Menu is shown after successfully booting a boot option.\r
   Assume the BootManagerMenuFile is in the same FV as the module links to this library.\r
@@ -2167,8 +2167,10 @@ EfiBootManagerRefreshAllBootOption (
   @param  BootOption    Return the boot option of the Boot Manager Menu\r
 \r
   @retval EFI_SUCCESS   Successfully register the Boot Manager Menu.\r
-  @retval Status        Return status of gRT->SetVariable (). BootOption still points\r
-                        to the Boot Manager Menu even the Status is not EFI_SUCCESS.\r
+  @retval EFI_NOT_FOUND The Boot Manager Menu cannot be found.\r
+  @retval others        Return status of gRT->SetVariable (). BootOption still points\r
+                        to the Boot Manager Menu even the Status is not EFI_SUCCESS\r
+                        and EFI_NOT_FOUND.\r
 **/\r
 EFI_STATUS\r
 BmRegisterBootManagerMenu (\r
@@ -2181,7 +2183,28 @@ BmRegisterBootManagerMenu (
   EFI_DEVICE_PATH_PROTOCOL           *DevicePath;\r
   EFI_LOADED_IMAGE_PROTOCOL          *LoadedImage;\r
   MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;\r
+  VOID                               *Data;\r
+  UINTN                              DataSize;\r
 \r
+  Data = NULL;\r
+  Status = GetSectionFromFv (\r
+             PcdGetPtr (PcdBootManagerMenuFile),\r
+             EFI_SECTION_PE32,\r
+             0,\r
+             (VOID **) &Data,\r
+             &DataSize\r
+             );\r
+  if (Data != NULL) {\r
+    FreePool (Data);\r
+  }\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n"));\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  //\r
+  // Get BootManagerMenu application's description from EFI User Interface Section.\r
+  //\r
   Status = GetSectionFromFv (\r
              PcdGetPtr (PcdBootManagerMenuFile),\r
              EFI_SECTION_USER_INTERFACE,\r
@@ -2237,12 +2260,14 @@ BmRegisterBootManagerMenu (
 /**\r
   Return the boot option corresponding to the Boot Manager Menu.\r
   It may automatically create one if the boot option hasn't been created yet.\r
-  \r
+\r
   @param BootOption    Return the Boot Manager Menu.\r
 \r
   @retval EFI_SUCCESS   The Boot Manager Menu is successfully returned.\r
-  @retval Status        Return status of gRT->SetVariable (). BootOption still points\r
-                        to the Boot Manager Menu even the Status is not EFI_SUCCESS.\r
+  @retval EFI_NOT_FOUND The Boot Manager Menu cannot be found.\r
+  @retval others        Return status of gRT->SetVariable (). BootOption still points\r
+                        to the Boot Manager Menu even the Status is not EFI_SUCCESS\r
+                        and EFI_NOT_FOUND.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r