]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg UefiBootManagerLib: Support LoadFile Protocol based on FV
authorLiming Gao <liming.gao@intel.com>
Mon, 25 Jul 2016 14:00:22 +0000 (22:00 +0800)
committerLiming Gao <liming.gao@intel.com>
Mon, 1 Aug 2016 04:58:23 +0000 (12:58 +0800)
New LoadFileOnFv2 driver will install LoadFile protocol based on FV file.
Update UefiBootManagerLib to find BootMenuApp with LoadFile protocol.

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 18259e9a302d952a621c50a095844d51ff336569..d5818ca0698520ee93e47b3949285fc7bafaf7a4 100644 (file)
@@ -1940,6 +1940,7 @@ BmEnumerateBootOptions (
   UINTN                                 Removable;\r
   UINTN                                 Index;\r
   CHAR16                                *Description;\r
+  UINT32                                BootAttributes;\r
 \r
   ASSERT (BootOptionCount != NULL);\r
 \r
@@ -2059,7 +2060,7 @@ BmEnumerateBootOptions (
   }\r
 \r
   //\r
-  // Parse load file, assuming UEFI Network boot option\r
+  // Parse load file protocol\r
   //\r
   gBS->LocateHandleBuffer (\r
          ByProtocol,\r
@@ -2078,11 +2079,19 @@ 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
-               LOAD_OPTION_ACTIVE,\r
+               BootAttributes,\r
                Description,\r
                DevicePathFromHandle (Handles[Index]),\r
                NULL,\r
@@ -2197,51 +2206,78 @@ BmRegisterBootManagerMenu (
   EFI_DEVICE_PATH_PROTOCOL           *DevicePath;\r
   EFI_LOADED_IMAGE_PROTOCOL          *LoadedImage;\r
   MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;\r
+  UINTN                              HandleCount;\r
+  EFI_HANDLE                         *Handles;\r
+  UINTN                              Index;\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
+  DevicePath = NULL;\r
   //\r
-  // Get BootManagerMenu application's description from EFI User Interface Section.\r
+  // Try to find BootMenuApp from LoadFile protocol\r
   //\r
-  Status = GetSectionFromFv (\r
-             PcdGetPtr (PcdBootManagerMenuFile),\r
-             EFI_SECTION_USER_INTERFACE,\r
-             0,\r
-             (VOID **) &Description,\r
-             &DescriptionLength\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    Description = NULL;\r
+  gBS->LocateHandleBuffer (\r
+         ByProtocol,\r
+         &gEfiLoadFileProtocolGuid,\r
+         NULL,\r
+         &HandleCount,\r
+         &Handles\r
+         );\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    if (BmIsBootMenuAppFilePath (DevicePathFromHandle (Handles[Index]))) {\r
+      DevicePath  = DuplicateDevicePath (DevicePathFromHandle (Handles[Index]));\r
+      Description = BmGetBootDescription (Handles[Index]);\r
+      break;\r
+    }\r
+  }\r
+  if (HandleCount != 0) {\r
+    FreePool (Handles);\r
   }\r
 \r
-  EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr (PcdBootManagerMenuFile));\r
-  Status = gBS->HandleProtocol (\r
-                  gImageHandle,\r
-                  &gEfiLoadedImageProtocolGuid,\r
-                  (VOID **) &LoadedImage\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-  DevicePath = AppendDevicePathNode (\r
-                 DevicePathFromHandle (LoadedImage->DeviceHandle),\r
-                 (EFI_DEVICE_PATH_PROTOCOL *) &FileNode\r
-                 );\r
-  ASSERT (DevicePath != NULL);\r
+  if (DevicePath == NULL) {\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
+               0,\r
+               (VOID **) &Description,\r
+               &DescriptionLength\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      Description = NULL;\r
+    }\r
+\r
+    EfiInitializeFwVolDevicepathNode (&FileNode, PcdGetPtr (PcdBootManagerMenuFile));\r
+    Status = gBS->HandleProtocol (\r
+                    gImageHandle,\r
+                    &gEfiLoadedImageProtocolGuid,\r
+                    (VOID **) &LoadedImage\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+    DevicePath = AppendDevicePathNode (\r
+                   DevicePathFromHandle (LoadedImage->DeviceHandle),\r
+                   (EFI_DEVICE_PATH_PROTOCOL *) &FileNode\r
+                   );\r
+    ASSERT (DevicePath != NULL);\r
+  }\r
 \r
   Status = EfiBootManagerInitializeLoadOption (\r
              BootOption,\r