summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4f0f231)
Change BmGetFileBufferByMemmapFv to BmGetFileBufferByFvFilePath.
The original function gets the file buffer only from memory mapped
FV device path and leaves GUIDed FV device path to the code below;
The new function gets the file buffer from both formats of FV device
paths.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
/** @file\r
Library functions which relates with booting.\r
\r
/** @file\r
Library functions which relates with booting.\r
\r
-Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
\r
FV address may change across reboot. This routine promises the FV file device path is right.\r
\r
\r
FV address may change across reboot. This routine promises the FV file device path is right.\r
\r
- @param DevicePath The Memory Mapped Device Path to get the file buffer.\r
+ @param FilePath The Memory Mapped Device Path to get the file buffer.\r
@param FullPath Receive the updated FV Device Path pointint to the file.\r
@param FileSize Receive the file buffer size.\r
\r
@return The file buffer.\r
**/\r
VOID *\r
@param FullPath Receive the updated FV Device Path pointint to the file.\r
@param FileSize Receive the file buffer size.\r
\r
@return The file buffer.\r
**/\r
VOID *\r
-BmGetFileBufferByMemmapFv (\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+BmGetFileBufferByFvFilePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,\r
OUT UINTN *FileSize\r
)\r
OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,\r
OUT UINTN *FileSize\r
)\r
EFI_HANDLE *FvHandles;\r
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
VOID *FileBuffer;\r
EFI_HANDLE *FvHandles;\r
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
VOID *FileBuffer;\r
- \r
- FvFileNode = DevicePath;\r
+\r
+ //\r
+ // Get the file buffer by using the exactly FilePath.\r
+ //\r
+ FvFileNode = FilePath;\r
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &FvFileNode, &FvHandle);\r
if (!EFI_ERROR (Status)) {\r
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &FvFileNode, &FvHandle);\r
if (!EFI_ERROR (Status)) {\r
- FileBuffer = GetFileBufferByFilePath (TRUE, DevicePath, FileSize, &AuthenticationStatus);\r
+ FileBuffer = GetFileBufferByFilePath (TRUE, FilePath, FileSize, &AuthenticationStatus);\r
if (FileBuffer != NULL) {\r
if (FileBuffer != NULL) {\r
- *FullPath = DuplicateDevicePath (DevicePath);\r
+ *FullPath = DuplicateDevicePath (FilePath);\r
}\r
return FileBuffer;\r
}\r
\r
}\r
return FileBuffer;\r
}\r
\r
- FvFileNode = NextDevicePathNode (DevicePath);\r
+ //\r
+ // Only wide match other FVs if it's a memory mapped FV file path.\r
+ //\r
+ if ((DevicePathType (FilePath) != HARDWARE_DEVICE_PATH) || (DevicePathSubType (FilePath) != HW_MEMMAP_DP)) {\r
+ return NULL;\r
+ }\r
+\r
+ FvFileNode = NextDevicePathNode (FilePath);\r
\r
//\r
// Firstly find the FV file in current FV\r
\r
//\r
// Firstly find the FV file in current FV\r
(VOID **) &LoadedImage\r
);\r
NewDevicePath = AppendDevicePathNode (DevicePathFromHandle (LoadedImage->DeviceHandle), FvFileNode);\r
(VOID **) &LoadedImage\r
);\r
NewDevicePath = AppendDevicePathNode (DevicePathFromHandle (LoadedImage->DeviceHandle), FvFileNode);\r
- FileBuffer = BmGetFileBufferByMemmapFv (NewDevicePath, FullPath, FileSize);\r
+ FileBuffer = BmGetFileBufferByFvFilePath (NewDevicePath, FullPath, FileSize);\r
FreePool (NewDevicePath);\r
\r
if (FileBuffer != NULL) {\r
FreePool (NewDevicePath);\r
\r
if (FileBuffer != NULL) {\r
continue;\r
}\r
NewDevicePath = AppendDevicePathNode (DevicePathFromHandle (FvHandles[Index]), FvFileNode);\r
continue;\r
}\r
NewDevicePath = AppendDevicePathNode (DevicePathFromHandle (FvHandles[Index]), FvFileNode);\r
- FileBuffer = BmGetFileBufferByMemmapFv (NewDevicePath, FullPath, FileSize);\r
+ FileBuffer = BmGetFileBufferByFvFilePath (NewDevicePath, FullPath, FileSize);\r
FreePool (NewDevicePath);\r
}\r
\r
FreePool (NewDevicePath);\r
}\r
\r
- Check if it's a Memory Mapped FV Device Path.\r
+ Check if it's a Device Path pointing to FV file.\r
\r
The function doesn't garentee the device path points to existing FV file.\r
\r
@param DevicePath Input device path.\r
\r
\r
The function doesn't garentee the device path points to existing FV file.\r
\r
@param DevicePath Input device path.\r
\r
- @retval TRUE The device path is a Memory Mapped FV Device Path.\r
- @retval FALSE The device path is NOT a Memory Mapped FV Device Path.\r
+ @retval TRUE The device path is a FV File Device Path.\r
+ @retval FALSE The device path is NOT a FV File Device Path.\r
-BmIsMemmapFvFilePath (\r
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
)\r
{\r
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
)\r
{\r
- EFI_DEVICE_PATH_PROTOCOL *FileNode;\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE Handle;\r
+ EFI_DEVICE_PATH_PROTOCOL *Node;\r
+\r
+ Node = DevicePath;\r
+ Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &Node, &Handle);\r
+ if (!EFI_ERROR (Status)) {\r
+ return TRUE;\r
+ }\r
\r
if ((DevicePathType (DevicePath) == HARDWARE_DEVICE_PATH) && (DevicePathSubType (DevicePath) == HW_MEMMAP_DP)) {\r
\r
if ((DevicePathType (DevicePath) == HARDWARE_DEVICE_PATH) && (DevicePathSubType (DevicePath) == HW_MEMMAP_DP)) {\r
- FileNode = NextDevicePathNode (DevicePath);\r
- if ((DevicePathType (FileNode) == MEDIA_DEVICE_PATH) && (DevicePathSubType (FileNode) == MEDIA_PIWG_FW_FILE_DP)) {\r
- return IsDevicePathEnd (NextDevicePathNode (FileNode));\r
+ DevicePath = NextDevicePathNode (DevicePath);\r
+ if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && (DevicePathSubType (DevicePath) == MEDIA_PIWG_FW_FILE_DP)) {\r
+ return IsDevicePathEnd (NextDevicePathNode (DevicePath));\r
- // Fix up the boot option path if it points to a FV in memory map style of device path\r
+ // Get file buffer from FV file path.\r
- if (BmIsMemmapFvFilePath (FilePath)) {\r
- return BmGetFileBufferByMemmapFv (FilePath, FullPath, FileSize);\r
+ if (BmIsFvFilePath (FilePath)) {\r
+ return BmGetFileBufferByFvFilePath (FilePath, FullPath, FileSize);\r