]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Update PeiCore to handle specific child FV
authorLiming Gao <liming.gao@intel.com>
Thu, 25 Jun 2015 03:29:38 +0000 (03:29 +0000)
committerlgao4 <lgao4@Edk2>
Thu, 25 Jun 2015 03:29:38 +0000 (03:29 +0000)
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.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17704 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Pei/FwVol/FwVol.c

index 22098c9c3e9e77c05de6734c2525e278fd7be422..363ff7e694a2321d48010ef1dc1dc8ace630e03b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Firmware File System service routines.\r
   \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -203,16 +203,34 @@ FileHandleToVolume (
   UINTN                       Index;\r
   PEI_CORE_INSTANCE           *PrivateData;\r
   EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;\r
+  UINTN                       BestIndex;\r
 \r
   PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());\r
+  BestIndex   = PrivateData->FvCount;\r
   \r
+  //\r
+  // Find the best matched FV image that includes this FileHandle.\r
+  // FV may include the child FV, and they are in the same continuous space. \r
+  // If FileHandle is from the child FV, the updated logic can find its matched FV.\r
+  //\r
   for (Index = 0; Index < PrivateData->FvCount; Index++) {\r
     FwVolHeader = PrivateData->Fv[Index].FvHeader;\r
     if (((UINT64) (UINTN) FileHandle > (UINT64) (UINTN) FwVolHeader ) &&   \\r
         ((UINT64) (UINTN) FileHandle <= ((UINT64) (UINTN) FwVolHeader + FwVolHeader->FvLength - 1))) {\r
-      return &PrivateData->Fv[Index];\r
+      if (BestIndex == PrivateData->FvCount) {\r
+        BestIndex = Index;\r
+      } else {\r
+        if ((UINT64) (UINTN) PrivateData->Fv[BestIndex].FvHeader < (UINT64) (UINTN) FwVolHeader) {\r
+          BestIndex = Index;\r
+        }\r
+      }\r
     }\r
   }\r
+\r
+  if (BestIndex < PrivateData->FvCount) {\r
+    return &PrivateData->Fv[BestIndex];\r
+  }\r
+\r
   return NULL;\r
 }\r
 \r