]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Bds: Support short-form URI boot.
authorRuiyu Ni <ruiyu.ni@intel.com>
Wed, 24 Feb 2016 07:04:44 +0000 (15:04 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Fri, 4 Mar 2016 08:00:50 +0000 (16:00 +0800)
The patch adds short-form URI boot support to follow
UEFI Spec.

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

index 35234bac19c11a748e9a7c26baabbddfcc3f9ac7..0b7b43b9eab5248bf8a304c75b9bd3c559e53ecd 100644 (file)
@@ -1181,6 +1181,72 @@ BmExpandFileDevicePath (
   return NULL;\r
 }\r
 \r
   return NULL;\r
 }\r
 \r
+/**\r
+  Expand URI device path node to be full device path in platform.\r
+\r
+  @param FilePath      The device path pointing to a load option.\r
+                       It could be a short-form device path.\r
+  @param FullPath      Return the full device path of the load option after\r
+                       short-form device path expanding.\r
+                       Caller is responsible to free it.\r
+  @param FileSize      Return the load option size.\r
+\r
+  @return The load option buffer. Caller is responsible to free the memory.\r
+**/\r
+VOID *\r
+BmExpandUriDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL    *FilePath,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL    **FullPath,\r
+  OUT UINTN                       *FileSize\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  UINTN                           Index;\r
+  UINTN                           HandleCount;\r
+  EFI_HANDLE                      *Handles;\r
+  EFI_LOAD_FILE_PROTOCOL          *LoadFile;\r
+  VOID                            *FileBuffer;\r
+\r
+  EfiBootManagerConnectAll ();\r
+  Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiLoadFileProtocolGuid, NULL, &HandleCount, &Handles);\r
+  if (EFI_ERROR (Status)) {\r
+    HandleCount = 0;\r
+    Handles = NULL;\r
+  }\r
+\r
+  FileBuffer = NULL;\r
+\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    Status = gBS->HandleProtocol (Handles[Index], &gEfiLoadFileProtocolGuid, (VOID *) &LoadFile);\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    FileBuffer = NULL;\r
+    Status = LoadFile->LoadFile (LoadFile, FilePath, TRUE, FileSize, FileBuffer);\r
+    if (Status == EFI_BUFFER_TOO_SMALL) {\r
+      FileBuffer = AllocatePool (*FileSize);\r
+      if (FileBuffer == NULL) {\r
+        break;\r
+      }\r
+      Status = LoadFile->LoadFile (LoadFile, FilePath, TRUE, FileSize, FileBuffer);\r
+    }\r
+\r
+    if (!EFI_ERROR (Status)) {\r
+      *FullPath = DuplicateDevicePath (DevicePathFromHandle (Handles[Index]));\r
+      break;\r
+    }\r
+\r
+    if (FileBuffer != NULL) {\r
+      FreePool (FileBuffer);\r
+    }\r
+  }\r
+\r
+  if (Handles != NULL) {\r
+    FreePool (Handles);\r
+  }\r
+\r
+  return FileBuffer;\r
+}\r
+\r
 /**\r
   Save the partition DevicePath to the CachedDevicePath as the first instance.\r
 \r
 /**\r
   Save the partition DevicePath to the CachedDevicePath as the first instance.\r
 \r
@@ -1718,6 +1784,12 @@ BmGetLoadOptionBuffer (
     // Expand the File-path device path\r
     //\r
     return BmExpandFileDevicePath (FilePath, FullPath, FileSize);\r
     // Expand the File-path device path\r
     //\r
     return BmExpandFileDevicePath (FilePath, FullPath, FileSize);\r
+  } else if ((DevicePathType (FilePath) == MESSAGING_DEVICE_PATH) &&\r
+             (DevicePathSubType (FilePath) == MSG_URI_DP)) {\r
+    //\r
+    // Expand the URI device path\r
+    //\r
+    return BmExpandUriDevicePath (FilePath, FullPath, FileSize);\r
   } else {\r
     for (Node = FilePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {\r
       if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&\r
   } else {\r
     for (Node = FilePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {\r
       if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&\r