]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg UefiBootManagerLib: Add BmIsBootMenuAppFilePath internal API
authorLiming Gao <liming.gao@intel.com>
Mon, 25 Jul 2016 14:00:21 +0000 (22:00 +0800)
committerLiming Gao <liming.gao@intel.com>
Mon, 1 Aug 2016 04:58:20 +0000 (12:58 +0800)
This function abstracts the common logic to find BootMenuApp file.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c

index bb38f0055a09669de0fa30c7c3b826a050f822a9..18259e9a302d952a621c50a095844d51ff336569 100644 (file)
@@ -1529,6 +1529,34 @@ EfiBootManagerGetLoadOptionBuffer (
   return BmGetFileBufferFromLoadFiles (FilePath, FullPath, FileSize);\r
 }\r
 \r
+/**\r
+  Check if it's a Device Path pointing to BootMenuApp.\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
+**/\r
+BOOLEAN\r
+BmIsBootMenuAppFilePath (\r
+  EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
+)\r
+{\r
+  EFI_HANDLE                      FvHandle;\r
+  VOID                            *NameGuid;\r
+  EFI_STATUS                      Status;\r
+\r
+  Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);\r
+  if (!EFI_ERROR (Status)) {\r
+    NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);\r
+    if (NameGuid != NULL) {\r
+      return CompareGuid (NameGuid, PcdGetPtr (PcdBootManagerMenuFile));\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
 /**\r
   Attempt to boot the EFI boot option. This routine sets L"BootCurent" and\r
   also signals the EFI ready to boot event. If the device path for the option\r
@@ -1562,9 +1590,7 @@ EfiBootManagerBoot (
   UINTN                     OptionNumber;\r
   UINTN                     OriginalOptionNumber;\r
   EFI_DEVICE_PATH_PROTOCOL  *FilePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
   EFI_DEVICE_PATH_PROTOCOL  *RamDiskDevicePath;\r
-  EFI_HANDLE                FvHandle;\r
   VOID                      *FileBuffer;\r
   UINTN                     FileSize;\r
   EFI_BOOT_LOGO_PROTOCOL    *BootLogo;\r
@@ -1619,12 +1645,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
-  Node   = BootOption->FilePath;\r
-  Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &Node, &FvHandle);\r
-  if (!EFI_ERROR (Status) && CompareGuid (\r
-        EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) Node),\r
-        PcdGetPtr (PcdBootManagerMenuFile)\r
-        )) {\r
+  if (BmIsBootMenuAppFilePath (BootOption->FilePath)) {\r
     DEBUG ((EFI_D_INFO, "[Bds] Booting Boot Manager Menu.\n"));\r
     BmStopHotkeyService (NULL, NULL);\r
   } else {\r
@@ -2272,20 +2293,11 @@ EfiBootManagerGetBootManagerMenu (
   UINTN                        BootOptionCount;\r
   EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;\r
   UINTN                        Index;\r
-  EFI_DEVICE_PATH_PROTOCOL     *Node;\r
-  EFI_HANDLE                   FvHandle;\r
   \r
   BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
 \r
   for (Index = 0; Index < BootOptionCount; Index++) {\r
-    Node   = BootOptions[Index].FilePath;\r
-    Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &Node, &FvHandle);\r
-    if (!EFI_ERROR (Status)) {\r
-      if (CompareGuid (\r
-            EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) Node),\r
-            PcdGetPtr (PcdBootManagerMenuFile)\r
-            )\r
-          ) {        \r
+    if (BmIsBootMenuAppFilePath (BootOptions[Index].FilePath)) {\r
         Status = EfiBootManagerInitializeLoadOption (\r
                    BootOption,\r
                    BootOptions[Index].OptionNumber,\r
@@ -2298,7 +2310,6 @@ EfiBootManagerGetBootManagerMenu (
                    );\r
         ASSERT_EFI_ERROR (Status);\r
         break;\r
-      }\r
     }\r
   }\r
 \r