]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Bds: Support booting from remote file system.
authorRuiyu Ni <ruiyu.ni@intel.com>
Wed, 24 Feb 2016 07:15:02 +0000 (15:15 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Fri, 4 Mar 2016 08:00:50 +0000 (16:00 +0800)
Enhance BDS to support booting from a remote file system exposed
by a HTTP boot option.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h

index 0b7b43b9eab5248bf8a304c75b9bd3c559e53ecd..18f835a9a973ee725f7332dc786bce34a813275a 100644 (file)
@@ -1231,6 +1231,14 @@ BmExpandUriDevicePath (
     }\r
 \r
     if (!EFI_ERROR (Status)) {\r
+      //\r
+      // LoadFile() returns a file buffer mapping to a file system.\r
+      //\r
+      if (Status == EFI_WARN_FILE_SYSTEM) {\r
+        return BmGetFileBufferFromLoadFileFileSystem (Handles[Index], FullPath, FileSize);\r
+      }\r
+\r
+      ASSERT (Status == EFI_SUCCESS);\r
       *FullPath = DuplicateDevicePath (DevicePathFromHandle (Handles[Index]));\r
       break;\r
     }\r
@@ -1625,6 +1633,62 @@ BmMatchHttpBootDevicePath (
   return (BOOLEAN) (IsDevicePathEnd (Left) && IsDevicePathEnd (Right));\r
 }\r
 \r
+/**\r
+  Get the file buffer from the file system produced by Load File instance.\r
+\r
+  @param LoadFileHandle The handle of LoadFile instance.\r
+  @param FullPath       Return the full device path pointing to the load option.\r
+  @param FileSize       Return the size of the load option.\r
+\r
+  @return  The load option buffer.\r
+**/\r
+VOID *\r
+BmGetFileBufferFromLoadFileFileSystem (\r
+  IN  EFI_HANDLE                      LoadFileHandle,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL        **FullPath,\r
+  OUT UINTN                           *FileSize\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_HANDLE                      Handle;\r
+  EFI_HANDLE                      *Handles;\r
+  UINTN                           HandleCount;\r
+  UINTN                           Index;\r
+  EFI_DEVICE_PATH_PROTOCOL        *Node;\r
+\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &Handles\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    Handles = NULL;\r
+    HandleCount = 0;\r
+  }\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    Node = DevicePathFromHandle (Handles[Index]);\r
+    Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);\r
+    if (!EFI_ERROR (Status) &&\r
+        (Handle == LoadFileHandle) &&\r
+        (DevicePathType (Node) == MEDIA_DEVICE_PATH) && (DevicePathSubType (Node) == MEDIA_RAM_DISK_DP)) {\r
+      Handle = Handles[Index];\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (Handles != NULL) {\r
+    FreePool (Handles);\r
+  }\r
+\r
+  if (Index != HandleCount) {\r
+    return BmExpandMediaDevicePath (DevicePathFromHandle (Handle), FullPath, FileSize);\r
+  } else {\r
+    return NULL;\r
+  }\r
+}\r
+\r
 /**\r
   Get the file buffer from Load File instance.\r
 \r
@@ -1712,6 +1776,14 @@ BmGetFileBufferFromLoadFile (
   }\r
 \r
   if (!EFI_ERROR (Status)) {\r
+    //\r
+    // LoadFile() returns a file buffer mapping to a file system.\r
+    //\r
+    if (Status == EFI_WARN_FILE_SYSTEM) {\r
+      return BmGetFileBufferFromLoadFileFileSystem (Handle, FullPath, FileSize);\r
+    }\r
+\r
+    ASSERT (Status == EFI_SUCCESS);\r
     //\r
     // LoadFile () may cause the device path of the Handle be updated.\r
     //\r
index fa4d5af0049246fb7cf79c135d054780a88b40bb..cfaeefe181955eb7642305f4422e69f3132d5a36 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   BDS library definition, include the file and data structure\r
 \r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015 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
@@ -456,4 +456,20 @@ BmCharToUint (
   IN CHAR16                           Char\r
   );\r
 \r
+\r
+/**\r
+  Get the file buffer from the file system produced by Load File instance.\r
+\r
+  @param LoadFileHandle The handle of LoadFile instance.\r
+  @param FullPath       Return the full device path pointing to the load option.\r
+  @param FileSize       Return the size of the load option.\r
+\r
+  @return  The load option buffer.\r
+**/\r
+VOID *\r
+BmGetFileBufferFromLoadFileFileSystem (\r
+  IN  EFI_HANDLE                      LoadFileHandle,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL        **FullPath,\r
+  OUT UINTN                           *FileSize\r
+  );\r
 #endif // _INTERNAL_BM_H_\r