summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c')
-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 0b7b43b9ea..18f835a9a9 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1231,6 +1231,14 @@ BmExpandUriDevicePath (
}
if (!EFI_ERROR (Status)) {
+ //
+ // LoadFile() returns a file buffer mapping to a file system.
+ //
+ if (Status == EFI_WARN_FILE_SYSTEM) {
+ return BmGetFileBufferFromLoadFileFileSystem (Handles[Index], FullPath, FileSize);
+ }
+
+ ASSERT (Status == EFI_SUCCESS);
*FullPath = DuplicateDevicePath (DevicePathFromHandle (Handles[Index]));
break;
}
@@ -1626,6 +1634,62 @@ BmMatchHttpBootDevicePath (
}
/**
+ Get the file buffer from the file system produced by Load File instance.
+
+ @param LoadFileHandle The handle of LoadFile instance.
+ @param FullPath Return the full device path pointing to the load option.
+ @param FileSize Return the size of the load option.
+
+ @return The load option buffer.
+**/
+VOID *
+BmGetFileBufferFromLoadFileFileSystem (
+ IN EFI_HANDLE LoadFileHandle,
+ OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
+ OUT UINTN *FileSize
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiBlockIoProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ Handles = NULL;
+ HandleCount = 0;
+ }
+ for (Index = 0; Index < HandleCount; Index++) {
+ Node = DevicePathFromHandle (Handles[Index]);
+ Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);
+ if (!EFI_ERROR (Status) &&
+ (Handle == LoadFileHandle) &&
+ (DevicePathType (Node) == MEDIA_DEVICE_PATH) && (DevicePathSubType (Node) == MEDIA_RAM_DISK_DP)) {
+ Handle = Handles[Index];
+ break;
+ }
+ }
+
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
+
+ if (Index != HandleCount) {
+ return BmExpandMediaDevicePath (DevicePathFromHandle (Handle), FullPath, FileSize);
+ } else {
+ return NULL;
+ }
+}
+
+/**
Get the file buffer from Load File instance.
@param FilePath The media device path pointing to a LoadFile instance.
@@ -1713,6 +1777,14 @@ BmGetFileBufferFromLoadFile (
if (!EFI_ERROR (Status)) {
//
+ // LoadFile() returns a file buffer mapping to a file system.
+ //
+ if (Status == EFI_WARN_FILE_SYSTEM) {
+ return BmGetFileBufferFromLoadFileFileSystem (Handle, FullPath, FileSize);
+ }
+
+ ASSERT (Status == EFI_SUCCESS);
+ //
// LoadFile () may cause the device path of the Handle be updated.
//
*FullPath = DuplicateDevicePath (DevicePathFromHandle (Handle));