summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-02-24 15:04:44 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2016-03-04 16:00:50 +0800
commit4a285ec18d432dae62e018a5df2a264ef969d16b (patch)
tree486c97ca18d9fe1afbbc9c115456534c5f62e73f /MdeModulePkg
parentbf5328f08877254f9ae30de5001e06cb6b0386da (diff)
downloadedk2-4a285ec18d432dae62e018a5df2a264ef969d16b.tar.gz
edk2-4a285ec18d432dae62e018a5df2a264ef969d16b.tar.bz2
edk2-4a285ec18d432dae62e018a5df2a264ef969d16b.zip
MdeModulePkg/Bds: Support short-form URI boot.
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>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 35234bac19..0b7b43b9ea 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1182,6 +1182,72 @@ BmExpandFileDevicePath (
}
/**
+ Expand URI device path node to be full device path in platform.
+
+ @param FilePath The device path pointing to a load option.
+ It could be a short-form device path.
+ @param FullPath Return the full device path of the load option after
+ short-form device path expanding.
+ Caller is responsible to free it.
+ @param FileSize Return the load option size.
+
+ @return The load option buffer. Caller is responsible to free the memory.
+**/
+VOID *
+BmExpandUriDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
+ OUT UINTN *FileSize
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ EFI_LOAD_FILE_PROTOCOL *LoadFile;
+ VOID *FileBuffer;
+
+ EfiBootManagerConnectAll ();
+ Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiLoadFileProtocolGuid, NULL, &HandleCount, &Handles);
+ if (EFI_ERROR (Status)) {
+ HandleCount = 0;
+ Handles = NULL;
+ }
+
+ FileBuffer = NULL;
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiLoadFileProtocolGuid, (VOID *) &LoadFile);
+ ASSERT_EFI_ERROR (Status);
+
+ FileBuffer = NULL;
+ Status = LoadFile->LoadFile (LoadFile, FilePath, TRUE, FileSize, FileBuffer);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ FileBuffer = AllocatePool (*FileSize);
+ if (FileBuffer == NULL) {
+ break;
+ }
+ Status = LoadFile->LoadFile (LoadFile, FilePath, TRUE, FileSize, FileBuffer);
+ }
+
+ if (!EFI_ERROR (Status)) {
+ *FullPath = DuplicateDevicePath (DevicePathFromHandle (Handles[Index]));
+ break;
+ }
+
+ if (FileBuffer != NULL) {
+ FreePool (FileBuffer);
+ }
+ }
+
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
+
+ return FileBuffer;
+}
+
+/**
Save the partition DevicePath to the CachedDevicePath as the first instance.
@param CachedDevicePath The device path cache.
@@ -1718,6 +1784,12 @@ BmGetLoadOptionBuffer (
// Expand the File-path device path
//
return BmExpandFileDevicePath (FilePath, FullPath, FileSize);
+ } else if ((DevicePathType (FilePath) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType (FilePath) == MSG_URI_DP)) {
+ //
+ // Expand the URI device path
+ //
+ return BmExpandUriDevicePath (FilePath, FullPath, FileSize);
} else {
for (Node = FilePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&