Reviewed-by: Star Zeng <star.z...@intel.com> -----Original Message----- From: Liming Gao [mailto:liming....@intel.com] Sent: Tuesday, June 23, 2015 7:17 PM To: edk2-commits@lists.sourceforge.net Subject: [Patch] MdeModulePkg: Update PeiCore to handle specific child FV
Child FV may be placed in parent FV image without process required. Then, Child FV and parent FV will be in the same continuous space. For FileHandle, FileHandleToVolume() function needs to find the best matched FV handle. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming....@intel.com> --- MdeModulePkg/Core/Pei/FwVol/FwVol.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c index 22098c9..363ff7e 100644 --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -1,9 +1,9 @@ /** @file Pei Core Firmware File System service routines. -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -201,20 +201,38 @@ FileHandleToVolume ( ) { UINTN Index; PEI_CORE_INSTANCE *PrivateData; EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; + UINTN BestIndex; PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ()); + BestIndex = PrivateData->FvCount; + // + // Find the best matched FV image that includes this FileHandle. + // FV may include the child FV, and they are in the same continuous space. + // If FileHandle is from the child FV, the updated logic can find its matched FV. + // for (Index = 0; Index < PrivateData->FvCount; Index++) { FwVolHeader = PrivateData->Fv[Index].FvHeader; if (((UINT64) (UINTN) FileHandle > (UINT64) (UINTN) FwVolHeader ) && \ ((UINT64) (UINTN) FileHandle <= ((UINT64) (UINTN) FwVolHeader + FwVolHeader->FvLength - 1))) { - return &PrivateData->Fv[Index]; + if (BestIndex == PrivateData->FvCount) { + BestIndex = Index; + } else { + if ((UINT64) (UINTN) PrivateData->Fv[BestIndex].FvHeader < (UINT64) (UINTN) FwVolHeader) { + BestIndex = Index; + } + } } } + + if (BestIndex < PrivateData->FvCount) { + return &PrivateData->Fv[BestIndex]; } + return NULL; } /** Given the input file pointer, search for the first matching file in the -- 1.9.5.msysgit.0 ------------------------------------------------------------------------------ Monitor 25 network devices or servers for free with OpManager! OpManager is web-based network management software that monitors network devices and physical & virtual servers, alerts via email & sms for fault. Monitor 25 devices for free with no restriction. Download now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o _______________________________________________ edk2-commits mailing list edk2-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-commits ------------------------------------------------------------------------------ Monitor 25 network devices or servers for free with OpManager! OpManager is web-based network management software that monitors network devices and physical & virtual servers, alerts via email & sms for fault. Monitor 25 devices for free with no restriction. Download now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o _______________________________________________ edk2-commits mailing list edk2-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-commits