diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-02-24 15:15:02 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-03-04 16:00:50 +0800 |
commit | f5c12172f1e23b8906dc12702de31078d44c023e (patch) | |
tree | 06f631419d30e82f04c48f97b274d7b9f1f3a2b1 /MdeModulePkg | |
parent | 4a285ec18d432dae62e018a5df2a264ef969d16b (diff) | |
download | edk2-platforms-f5c12172f1e23b8906dc12702de31078d44c023e.tar.xz |
MdeModulePkg/Bds: Support booting from remote file system.
Enhance BDS to support booting from a remote file system exposed
by a HTTP boot option.
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.c | 72 | ||||
-rw-r--r-- | MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h | 18 |
2 files changed, 89 insertions, 1 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));
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h index fa4d5af004..cfaeefe181 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h @@ -1,7 +1,7 @@ /** @file
BDS library definition, include the file and data structure
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -456,4 +456,20 @@ BmCharToUint ( IN CHAR16 Char
);
+
+/**
+ 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
+ );
#endif // _INTERNAL_BM_H_
|