]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
MdeModulePkg/Bds: Support booting from remote file system.
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / BmBoot.c
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