}\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
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
+\r
+ Handle = NULL;\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
}\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