]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enabling EFI_PEI_FIRMWARE_VOLUME_PPI introduced by PI1.2.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 11 Nov 2009 03:27:39 +0000 (03:27 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 11 Nov 2009 03:27:39 +0000 (03:27 +0000)
1, Implement EFI_PEI_FIRMWARE_VOLUME_PPI for FFS2 format as build-in supporting FV format in PeiCore.
2, Reduce the assumption of memory-mapped FV in PeiCore. PeiCore should access FV via EFI_PEI_FIRMWARE_VOLUME_PPI interface but not cast FvHandle/FileHandle to EFI_FIRMWARE_VOLUME_HEADER/EFI_FV_FILE_HEADER directly.
3, Reduce AllFv[] and AllFvCount in PEI_CORE_INSTANCE structure. Original PEI_CORE_INSTANCE use AllFv[] and Fv[] array to manage discovered FV and dispatched FV. But not need to make thing too complex. Now PEI_CORE_FV_HANDLE array of Fv[] will take responsibility to manage all FV instance and status.
4, Fix the bug use PeiDispatcher use wrong index for PeiFfsFindNextVolume(),
5, Fix the bug in PeiFfsFindNextVolume(), if instance is not found, *VolumeHandle should be set to NULL but not VolumeHandle was set to NULL.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9407 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
MdeModulePkg/Core/Pei/FwVol/FwVol.c
MdeModulePkg/Core/Pei/FwVol/FwVol.h [new file with mode: 0644]
MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg/Core/Pei/PeiMain.inf
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c

index f64003db38d925c0a2ed8b8ebbcddb53d3f46203..067096c5954b4600a1ea9ecfc19875f463d03a14 100644 (file)
@@ -30,14 +30,14 @@ typedef struct {
   Apriori file in one FV.\r
 \r
 \r
-  @param Private         - Pointer to the private data passed in from caller\r
-  @param VolumeHandle    - Fv handle.\r
+  @param Private          Pointer to the private data passed in from caller\r
+  @param CoreFileHandle   The instance of PEI_CORE_FV_HANDLE.\r
 \r
 **/\r
 VOID\r
 DiscoverPeimsAndOrderWithApriori (\r
   IN  PEI_CORE_INSTANCE    *Private,\r
-  IN  EFI_PEI_FV_HANDLE    VolumeHandle\r
+  IN  PEI_CORE_FV_HANDLE   *CoreFileHandle\r
   )\r
 {\r
   EFI_STATUS                          Status;\r
@@ -51,7 +51,11 @@ DiscoverPeimsAndOrderWithApriori (
   EFI_GUID                            *Guid;\r
   EFI_PEI_FV_HANDLE                   TempFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
   EFI_GUID                            FileGuid[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
-\r
+  EFI_PEI_FIRMWARE_VOLUME_PPI         *FvPpi;\r
+  EFI_FV_FILE_INFO                    FileInfo;\r
+  \r
+  FvPpi = CoreFileHandle->FvPpi;\r
+  \r
   //\r
   // Walk the FV and find all the PEIMs and the Apriori file.\r
   //\r
@@ -72,13 +76,7 @@ DiscoverPeimsAndOrderWithApriori (
   // Go ahead to scan this Fv, and cache FileHandles within it.\r
   //\r
   for (PeimCount = 0; PeimCount < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv); PeimCount++) {\r
-    Status = PeiFindFileEx (\r
-                VolumeHandle,\r
-                NULL,\r
-                PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE,\r
-                &FileHandle,\r
-                &AprioriFileHandle\r
-                );\r
+    Status = FvPpi->FindFileByType (FvPpi, PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle, &FileHandle);\r
     if (Status != EFI_SUCCESS) {\r
       break;\r
     }\r
@@ -92,17 +90,23 @@ DiscoverPeimsAndOrderWithApriori (
   //\r
   ASSERT (PeimCount < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv));\r
 \r
+  //\r
+  // Get Apriori File handle\r
+  //\r
   Private->AprioriCount = 0;\r
-  if (AprioriFileHandle != NULL) {\r
+  Status = FvPpi->FindFileByName (FvPpi, &gPeiAprioriFileNameGuid, &CoreFileHandle->FvHandle, &AprioriFileHandle);\r
+  if (!EFI_ERROR(Status) && AprioriFileHandle != NULL) {\r
     //\r
     // Read the Apriori file\r
     //\r
-    Status = PeiServicesFfsFindSectionData (EFI_SECTION_RAW, AprioriFileHandle, (VOID **) &Apriori);\r
+    Status = FvPpi->FindSectionByType (FvPpi, EFI_SECTION_RAW, AprioriFileHandle, (VOID **) &Apriori);\r
     if (!EFI_ERROR (Status)) {\r
       //\r
       // Calculate the number of PEIMs in the A Priori list\r
       //\r
-      Private->AprioriCount = *(UINT32 *)(((EFI_FFS_FILE_HEADER *)AprioriFileHandle)->Size) & 0x00FFFFFF;\r
+      Status = FvPpi->GetFileInfo (FvPpi, AprioriFileHandle, &FileInfo);\r
+      ASSERT_EFI_ERROR (Status);\r
+      Private->AprioriCount = FileInfo.BufferSize & 0x00FFFFFF;\r
       Private->AprioriCount -= sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_COMMON_SECTION_HEADER);\r
       Private->AprioriCount /= sizeof (EFI_GUID);\r
 \r
@@ -112,7 +116,8 @@ DiscoverPeimsAndOrderWithApriori (
         // Make an array of file name guids that matches the FileHandle array so we can convert\r
         // quickly from file name to file handle\r
         //\r
-        CopyMem (&FileGuid[Index], &((EFI_FFS_FILE_HEADER *)Private->CurrentFvFileHandles[Index])->Name,sizeof(EFI_GUID));\r
+        Status = FvPpi->GetFileInfo (FvPpi, Private->CurrentFvFileHandles[Index], &FileInfo);\r
+        CopyMem (&FileGuid[Index], &FileInfo.FileName, sizeof(EFI_GUID));\r
       }\r
 \r
       //\r
@@ -202,13 +207,12 @@ ShadowPeiCore(
   //\r
   // Find the PEI Core in the BFV\r
   //\r
-  Status = PeiFindFileEx (\r
-             (EFI_PEI_FV_HANDLE)PrivateInMem->Fv[0].FvHeader,\r
-             NULL,\r
-             EFI_FV_FILETYPE_PEI_CORE,\r
-             &PeiCoreFileHandle,\r
-             NULL\r
-             );\r
+  Status = PrivateInMem->Fv[0].FvPpi->FindFileByType (\r
+                                        PrivateInMem->Fv[0].FvPpi,\r
+                                        EFI_FV_FILETYPE_PEI_CORE,\r
+                                        PrivateInMem->Fv[0].FvHandle,\r
+                                        &PeiCoreFileHandle\r
+                                        );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
@@ -248,7 +252,6 @@ PeiDispatcher (
   UINT32                              Index1;\r
   UINT32                              Index2;\r
   CONST EFI_PEI_SERVICES              **PeiServices;\r
-  EFI_PEI_FV_HANDLE                   VolumeHandle;\r
   EFI_PEI_FILE_HANDLE                 PeimFileHandle;\r
   UINTN                               FvCount;\r
   UINTN                               PeimCount;\r
@@ -272,7 +275,7 @@ PeiDispatcher (
   EFI_FV_FILE_INFO                    FvFileInfo;\r
   UINTN                               OldCheckingTop;\r
   UINTN                               OldCheckingBottom;\r
-\r
+  PEI_CORE_FV_HANDLE                  *CoreFvHandle;\r
 \r
   PeiServices = (CONST EFI_PEI_SERVICES **) &Private->PS;\r
   PeimEntryPoint = NULL;\r
@@ -349,11 +352,17 @@ PeiDispatcher (
     }\r
     \r
     for (FvCount = Private->CurrentPeimFvCount; FvCount < Private->FvCount; FvCount++) {\r
-      Private->CurrentPeimFvCount = FvCount;\r
+      CoreFvHandle = FindNextCoreFvHandle (Private, FvCount);\r
+      ASSERT (CoreFvHandle != NULL);\r
+      \r
       //\r
-      // Get this Fv Handle by PeiService FvFindNextVolume.\r
+      // If the FV has corresponding EFI_PEI_FIRMWARE_VOLUME_PPI instance, then dispatch it.\r
       //\r
-      PeiFvFindNextVolume (PeiServices, FvCount, &VolumeHandle);\r
+      if (CoreFvHandle->FvPpi == NULL) {\r
+        continue;\r
+      }\r
+      \r
+      Private->CurrentPeimFvCount = FvCount;\r
 \r
       if (Private->CurrentPeimCount == 0) {\r
         //\r
@@ -361,7 +370,7 @@ PeiDispatcher (
         // reorder all PEIMs to ensure the PEIMs in Apriori file to get\r
         // dispatch at first.\r
         //\r
-        DiscoverPeimsAndOrderWithApriori (Private, VolumeHandle);\r
+        DiscoverPeimsAndOrderWithApriori (Private, CoreFvHandle);\r
       }\r
 \r
       //\r
@@ -377,13 +386,14 @@ PeiDispatcher (
           if (!DepexSatisfied (Private, PeimFileHandle, PeimCount)) {\r
             Private->PeimNeedingDispatch = TRUE;\r
           } else {\r
-            Status = PeiFfsGetFileInfo (PeimFileHandle, &FvFileInfo);\r
+            Status = CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi, PeimFileHandle, &FvFileInfo);\r
             ASSERT_EFI_ERROR (Status);\r
             if (FvFileInfo.FileType == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r
               //\r
               // For Fv type file, Produce new FV PPI and FV hob\r
               //\r
-              Status = ProcessFvFile (PeiServices, VolumeHandle, PeimFileHandle, &AuthenticationState);\r
+              Status = ProcessFvFile (&Private->Fv[FvCount], PeimFileHandle);\r
+              AuthenticationState = 0;\r
             } else {\r
               //\r
               // For PEIM driver, Load its entry point\r
@@ -412,7 +422,7 @@ PeiDispatcher (
                 sizeof (ExtendedData)\r
                 );\r
 \r
-              Status = VerifyPeim (Private, VolumeHandle, PeimFileHandle);\r
+              Status = VerifyPeim (Private, CoreFvHandle->FvHandle, PeimFileHandle);\r
               if (Status != EFI_SECURITY_VIOLATION && (AuthenticationState == 0)) {\r
                 //\r
                 // PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED\r
@@ -807,3 +817,4 @@ PeiRegisterForShadow (
   return EFI_SUCCESS;\r
 }\r
 \r
+\r
index a86e4e55788d9e8aa5a633b03ef140221802e49a..b5f2812a0962ebe75db9a1a9c8732ada02d43648 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Firmware File System service routines.\r
   \r
-Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
 All rights reserved. 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
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include "PeiMain.h"\r
+#include "FwVol.h"\r
 \r
 EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = {\r
   (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
@@ -20,10 +20,21 @@ EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = {
   FirmwareVolmeInfoPpiNotifyCallback \r
 };\r
 \r
-\r
-#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \\r
-  ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))\r
-\r
+EFI_PEI_FIRMWARE_VOLUME_PPI mPeiFfs2FvPpi = {\r
+  PeiFfs2FvPpiProcessVolume,\r
+  PeiFfs2FvPpiFindFileByType,\r
+  PeiFfs2FvPpiFindFileByName,\r
+  PeiFfs2FvPpiGetFileInfo,\r
+  PeiFfs2FvPpiGetVolumeInfo,\r
+  PeiFfs2FvPpiFindSectionByType\r
+};\r
+            \r
+EFI_PEI_PPI_DESCRIPTOR  mPeiFfs2FvPpiList = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiFirmwareFileSystem2Guid,\r
+  &mPeiFfs2FvPpi\r
+};\r
\r
 /**\r
   Returns the file state set by the highest zero bit in the State field\r
 \r
@@ -87,20 +98,15 @@ CalculateHeaderChecksum (
 }\r
 \r
 /**\r
-  Find FV handler according some FileHandle in that FV.\r
+  Find FV handler according to FileHandle in that FV.\r
 \r
   @param FileHandle      Handle of file image\r
-  @param VolumeHandle    Handle of the found FV, if not found, NULL will be set.\r
-\r
-  @retval TRUE           The corresponding FV handler is found.\r
-  @retval FALSE          The corresponding FV handler is not found.\r
-\r
+  \r
+  @return Pointer to instance of PEI_CORE_FV_HANDLE.\r
 **/\r
-BOOLEAN\r
-EFIAPI\r
-PeiFileHandleToVolume (\r
-  IN   EFI_PEI_FILE_HANDLE     FileHandle,\r
-  OUT  EFI_PEI_FV_HANDLE       *VolumeHandle\r
+PEI_CORE_FV_HANDLE*\r
+FileHandleToVolume (\r
+  IN   EFI_PEI_FILE_HANDLE          FileHandle\r
   )\r
 {\r
   UINTN                       Index;\r
@@ -108,16 +114,15 @@ PeiFileHandleToVolume (
   EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;\r
 \r
   PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());\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
-      *VolumeHandle = (EFI_PEI_FV_HANDLE)FwVolHeader;\r
-      return TRUE;\r
+      return &PrivateData->Fv[Index];\r
     }\r
   }\r
-  *VolumeHandle = NULL;\r
-  return FALSE;\r
+  return NULL;\r
 }\r
 \r
 /**\r
@@ -140,7 +145,7 @@ PeiFileHandleToVolume (
 \r
 **/\r
 EFI_STATUS\r
-PeiFindFileEx (\r
+FindFileEx (\r
   IN  CONST EFI_PEI_FV_HANDLE        FvHandle,\r
   IN  CONST EFI_GUID                 *FileName,   OPTIONAL\r
   IN        EFI_FV_FILETYPE          SearchType,\r
@@ -157,8 +162,11 @@ PeiFindFileEx (
   UINT64                                FvLength;\r
   UINT8                                 ErasePolarity;\r
   UINT8                                 FileState;\r
-\r
-  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvHandle;\r
+  \r
+  //\r
+  // Convert the handle of FV to FV header for memory-mapped firmware volume\r
+  //\r
+  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvHandle;\r
   FileHeader  = (EFI_FFS_FILE_HEADER **)FileHandle;\r
 \r
   FvLength = FwVolHeader->FvLength;\r
@@ -269,18 +277,39 @@ PeiInitializeFv (
   IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
+  EFI_STATUS                    Status;\r
+  EFI_PEI_FIRMWARE_VOLUME_PPI   *FvPpi;\r
+  EFI_PEI_FV_HANDLE             FvHandle;\r
+  EFI_FIRMWARE_VOLUME_HEADER    *BfvHeader;\r
+  \r
   //\r
-  // The BFV must be the first entry. The Core FV support is stateless \r
-  // The AllFV list has a single entry per FV in PEI. \r
-  // The Fv list only includes FV that PEIMs will be dispatched from and\r
-  // its File System Format is PI 1.0 definition.\r
+  // Install FV_PPI for FFS2 file system.\r
   //\r
-  PrivateData->FvCount = 1;\r
-  PrivateData->Fv[0].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)SecCoreData->BootFirmwareVolumeBase;\r
-\r
-  PrivateData->AllFvCount = 1;\r
-  PrivateData->AllFv[0] = (EFI_PEI_FV_HANDLE)PrivateData->Fv[0].FvHeader;\r
+  PeiServicesInstallPpi (&mPeiFfs2FvPpiList);\r
+  \r
+  BfvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)SecCoreData->BootFirmwareVolumeBase;\r
+  \r
+  //\r
+  // The FV_PPI in BFV's format should be installed.\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &BfvHeader->FileSystemGuid,\r
+             0,\r
+             NULL,\r
+             (VOID**)&FvPpi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+    \r
+  //\r
+  // Get handle of BFV\r
+  //\r
+  FvPpi->ProcessVolume (\r
+           FvPpi, \r
+           SecCoreData->BootFirmwareVolumeBase,\r
+           (UINTN)BfvHeader->FvLength,\r
+           &FvHandle\r
+           );\r
+                        \r
   //\r
   // Post a call-back for the FvInfoPPI services to expose\r
   // additional Fvs to PeiCore.\r
@@ -289,7 +318,7 @@ PeiInitializeFv (
   ASSERT_EFI_ERROR (Status);\r
 \r
 }\r
-\r
+  \r
 /**\r
   Process Firmware Volum Information once FvInfoPPI install.\r
   The FV Info will be registered into PeiCore private data structure.\r
@@ -311,16 +340,13 @@ FirmwareVolmeInfoPpiNotifyCallback (
   IN VOID                          *Ppi\r
   )\r
 {\r
-  UINT8                                 FvCount;\r
-  EFI_PEI_FIRMWARE_VOLUME_INFO_PPI      *Fv;\r
+  EFI_PEI_FIRMWARE_VOLUME_INFO_PPI      *FvInfoPpi;\r
+  EFI_PEI_FIRMWARE_VOLUME_PPI           *FvPpi;\r
   PEI_CORE_INSTANCE                     *PrivateData;\r
-  EFI_PEI_FILE_HANDLE                   FileHandle;\r
-  VOID                                  *DepexData;\r
-  UINT32                                AuthenticationStatus;\r
   EFI_STATUS                            Status;\r
+  EFI_PEI_FV_HANDLE                     FvHandle;\r
+  UINTN                                 FvIndex;\r
   \r
-  FileHandle   = NULL;\r
-  DepexData    = NULL;\r
   Status       = EFI_SUCCESS;\r
   PrivateData  = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
 \r
@@ -330,63 +356,52 @@ FirmwareVolmeInfoPpiNotifyCallback (
     ASSERT (FALSE);\r
   }\r
 \r
-  Fv = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *)Ppi;\r
+  FvInfoPpi = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *)Ppi;\r
 \r
   //\r
-  // Only add FileSystem2 Fv to Fv list\r
+  // Locate the corresponding FV_PPI according to founded FV's format guid\r
   //\r
-  if (CompareGuid (&Fv->FvFormat, &gEfiFirmwareFileSystem2Guid)) {\r
-    for (FvCount = 0; FvCount < PrivateData->FvCount; FvCount ++) {\r
-      if ((UINTN)PrivateData->Fv[FvCount].FvHeader == (UINTN)Fv->FvInfo) {\r
-        return EFI_SUCCESS;\r
-      }\r
-    }\r
-    \r
-    Status = VerifyFv ((EFI_FIRMWARE_VOLUME_HEADER*)Fv->FvInfo);\r
-    if (EFI_ERROR(Status)) {\r
-      DEBUG ((EFI_D_ERROR, "Fail to verify FV which address is 0x%11p", (VOID *) Fv->FvInfo));\r
+  Status = PeiServicesLocatePpi (\r
+             &FvInfoPpi->FvFormat, \r
+             0, \r
+             NULL,\r
+             (VOID**)&FvPpi\r
+             );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Process new found FV and get FV handle.\r
+    //\r
+    Status = FvPpi->ProcessVolume (FvPpi, FvInfoPpi->FvInfo, FvInfoPpi->FvInfoSize, &FvHandle);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "Fail to process new found FV, FV may be corrupted!"));\r
       return Status;\r
     }\r
+    DEBUG ((EFI_D_INFO, "Found and process new FV %p, all fv's count is %d\n", FvHandle, PrivateData->FvCount));\r
+  } else {\r
+    DEBUG ((EFI_D_ERROR, "Fail to process FV %p because no corresponding EFI_FIRMWARE_VOLUME_PPI is found!\n", FvInfoPpi->FvInfo));\r
     \r
-    PrivateData->Fv[PrivateData->FvCount++].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Fv->FvInfo;\r
-\r
-    PrivateData->AllFv[PrivateData->AllFvCount++] = (EFI_PEI_FV_HANDLE)Fv->FvInfo;\r
+    //\r
+    // If can not find EFI_FIRMWARE_VOLUME_PPI to process firmware to get FvHandle, \r
+    // use the address of FV buffer as its handle.\r
+    //\r
+    FvHandle = FvInfoPpi->FvInfo;\r
     \r
-    DEBUG ((EFI_D_INFO, "The %dth FvImage start address is 0x%11p and size is 0x%08x\n", (UINT32)PrivateData->AllFvCount, (VOID *) Fv->FvInfo, Fv->FvInfoSize));\r
     //\r
-    // Preprocess all FV type files in this new FileSystem2 Fv image\r
+    // Check whether the FV has already been processed.\r
     //\r
-    do {\r
-      Status = PeiFindFileEx (\r
-                 (EFI_PEI_FV_HANDLE)Fv->FvInfo, \r
-                 NULL, \r
-                 EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, \r
-                 &FileHandle, \r
-                 NULL\r
-                 );\r
-      if (!EFI_ERROR (Status)) {\r
-        Status = PeiFfsFindSectionData (\r
-                    (CONST EFI_PEI_SERVICES **) PeiServices,\r
-                    EFI_SECTION_PEI_DEPEX,\r
-                    FileHandle, \r
-                    (VOID **)&DepexData\r
-                    );\r
-        if (!EFI_ERROR (Status)) {\r
-          if (!PeimDispatchReadiness (PeiServices, DepexData)) {\r
-            //\r
-            // Dependency is not satisfied.\r
-            //\r
-            continue;\r
-          }\r
-        }\r
-        //\r
-        // Process FvFile to install FvInfo ppi and build FvHob\r
-        // \r
-        ProcessFvFile ((CONST EFI_PEI_SERVICES **) PeiServices, (EFI_PEI_FV_HANDLE)Fv->FvInfo, FileHandle, &AuthenticationStatus);\r
+    for (FvIndex = 0; FvIndex < PrivateData->FvCount; FvIndex ++) {\r
+      if (PrivateData->Fv[FvIndex].FvHandle == FvHandle) {\r
+        DEBUG ((EFI_D_INFO, "The Fv %p has already been processed!\n", FvHandle));\r
+        return EFI_SUCCESS;\r
       }\r
-    } while (FileHandle != NULL);\r
+    }    \r
+    \r
+    PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) FvInfoPpi->FvInfo;\r
+    PrivateData->Fv[PrivateData->FvCount].FvPpi    = NULL;\r
+    PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;\r
+    PrivateData->FvCount ++;\r
   }\r
-\r
+  \r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -395,11 +410,11 @@ FirmwareVolmeInfoPpiNotifyCallback (
   Search within encapsulation sections (compression and GUIDed) recursively, \r
   until the match section is found.\r
   \r
-  @param PeiServices     - An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param SectionType     - Filter to find only section of this type.\r
-  @param Section         - From where to search.\r
-  @param SectionSize     - The file size to search.\r
-  @param OutputBuffer    - A pointer to the discovered section, if successful.\r
+  @param PeiServices       An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param SectionType       Filter to find only section of this type.\r
+  @param Section           From where to search.\r
+  @param SectionSize       The file size to search.\r
+  @param OutputBuffer      A pointer to the discovered section, if successful.\r
                            NULL if section not found\r
 \r
   @return EFI_NOT_FOUND    The match section is not found.\r
@@ -407,7 +422,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
 \r
 **/\r
 EFI_STATUS\r
-PeiFfsProcessSection (\r
+ProcessSection (\r
   IN CONST EFI_PEI_SERVICES     **PeiServices,\r
   IN EFI_SECTION_TYPE           SectionType,\r
   IN EFI_COMMON_SECTION_HEADER  *Section,\r
@@ -448,13 +463,13 @@ PeiFfsProcessSection (
           //\r
           // Search section directly from the cache data.\r
           //\r
-          return PeiFfsProcessSection (\r
-                  PeiServices,\r
-                  SectionType, \r
-                  PpiOutput, \r
-                  PpiOutputSize, \r
-                  OutputBuffer \r
-                  );\r
+          return ProcessSection (\r
+                   PeiServices,\r
+                   SectionType, \r
+                   PpiOutput, \r
+                   PpiOutputSize, \r
+                   OutputBuffer \r
+                   );\r
         }\r
       }\r
       \r
@@ -468,12 +483,12 @@ PeiFfsProcessSection (
                    );\r
         if (!EFI_ERROR (Status)) {\r
           Status = GuidSectionPpi->ExtractSection (\r
-                                    GuidSectionPpi,\r
-                                    Section,\r
-                                    &PpiOutput,\r
-                                    &PpiOutputSize,\r
-                                    &Authentication\r
-                                    );\r
+                                     GuidSectionPpi,\r
+                                     Section,\r
+                                     &PpiOutput,\r
+                                     &PpiOutputSize,\r
+                                     &Authentication\r
+                                     );\r
         }\r
       } else if (Section->Type == EFI_SECTION_COMPRESSION) {\r
         Status = PeiServicesLocatePpi (&gEfiPeiDecompressPpiGuid, 0, NULL, (VOID **) &DecompressPpi);\r
@@ -499,13 +514,13 @@ PeiFfsProcessSection (
         PrivateData->CacheSection.SectionSize [PrivateData->CacheSection.SectionIndex] = PpiOutputSize;\r
         PrivateData->CacheSection.SectionIndex = (PrivateData->CacheSection.SectionIndex + 1)%CACHE_SETION_MAX_NUMBER;\r
         \r
-        return PeiFfsProcessSection (\r
-                PeiServices,\r
-                SectionType, \r
-                PpiOutput, \r
-                PpiOutputSize, \r
-                OutputBuffer \r
-                );\r
+        return ProcessSection (\r
+                 PeiServices,\r
+                 SectionType, \r
+                 PpiOutput, \r
+                 PpiOutputSize, \r
+                 OutputBuffer \r
+                 );\r
       }\r
     }\r
 \r
@@ -526,8 +541,7 @@ PeiFfsProcessSection (
 \r
 \r
 /**\r
-  Given the input file pointer, search for the first matching section in the\r
-  FFS volume.\r
+  Searches for the next matching section within the specified file.\r
 \r
   @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
   @param SectionType     Filter to find only sections of this type.\r
@@ -535,57 +549,43 @@ PeiFfsProcessSection (
   @param SectionData     A pointer to the discovered section, if successful.\r
                          NULL if section not found\r
 \r
-  @retval EFI_NOT_FOUND  No files matching the search criteria were found\r
-  @retval EFI_SUCCESS    Success to find section data in given file\r
+  @retval EFI_NOT_FOUND  The section was not found.\r
+  @retval EFI_SUCCESS    The section was found.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiFfsFindSectionData (\r
-  IN CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN CONST EFI_PEI_SERVICES    **PeiServices,\r
   IN     EFI_SECTION_TYPE      SectionType,\r
   IN     EFI_PEI_FILE_HANDLE   FileHandle,\r
-  IN OUT VOID                  **SectionData\r
+  OUT VOID                     **SectionData\r
   )\r
 {\r
-  EFI_FFS_FILE_HEADER                     *FfsFileHeader;\r
-  UINT32                                  FileSize;\r
-  EFI_COMMON_SECTION_HEADER               *Section;\r
-\r
-  FfsFileHeader = (EFI_FFS_FILE_HEADER *)(FileHandle);\r
-\r
-  //\r
-  // Size is 24 bits wide so mask upper 8 bits. \r
-  // Does not include FfsFileHeader header size\r
-  // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.\r
-  //\r
-  Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);\r
-  FileSize = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;\r
-  FileSize -= sizeof (EFI_FFS_FILE_HEADER);\r
-\r
-  return PeiFfsProcessSection (\r
-          PeiServices,\r
-          SectionType, \r
-          Section, \r
-          FileSize, \r
-          SectionData\r
-          );\r
+  PEI_CORE_FV_HANDLE           *CoreFvHandle;\r
+  \r
+  CoreFvHandle = FileHandleToVolume (FileHandle);\r
+  if ((CoreFvHandle == NULL) || (CoreFvHandle->FvPpi == NULL)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  return CoreFvHandle->FvPpi->FindSectionByType (CoreFvHandle->FvPpi, SectionType, FileHandle, SectionData);\r
 }\r
 \r
 /**\r
-  Given the input file pointer, search for the next matching file in the\r
-  FFS volume as defined by SearchType. The search starts from FileHeader inside\r
-  the Firmware Volume defined by FwVolHeader.\r
-\r
+  Searches for the next matching file in the firmware volume.\r
 \r
   @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param SearchType      Filter to find only files of this type.\r
                          Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
-  @param VolumeHandle    Pointer to the FV header of the volume to search.\r
-  @param FileHandle      Pointer to the current file from which to begin searching.\r
-                         This pointer will be updated upon return to reflect the file found.\r
-  @retval EFI_NOT_FOUND  No files matching the search criteria were found\r
-  @retval EFI_SUCCESS    Success to find next file in given volume\r
+  @param VolumeHandle    Handle of firmware volume in which to search.\r
+  @param FileHandle      On entry, points to the current handle from which to begin searching or NULL to start\r
+                         at the beginning of the firmware volume. On exit, points the file handle of the next file\r
+                         in the volume or NULL if there are no more files.\r
+\r
+  @retval EFI_NOT_FOUND  The file was not found.\r
+  @retval EFI_NOT_FOUND  The header checksum was not zero.\r
+  @retval EFI_SUCCESS    The file was found.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -593,11 +593,19 @@ EFIAPI
 PeiFfsFindNextFile (\r
   IN CONST EFI_PEI_SERVICES      **PeiServices,\r
   IN UINT8                       SearchType,\r
-  IN EFI_PEI_FV_HANDLE           VolumeHandle,\r
+  IN EFI_PEI_FV_HANDLE           FvHandle,\r
   IN OUT EFI_PEI_FILE_HANDLE     *FileHandle\r
   )\r
 {\r
-  return PeiFindFileEx (VolumeHandle, NULL, SearchType, FileHandle, NULL);\r
+  PEI_CORE_FV_HANDLE      *CoreFvHandle;\r
+  \r
+  CoreFvHandle = FvHandleToCoreHandle (FvHandle);\r
+  \r
+  if ((CoreFvHandle == NULL) || CoreFvHandle->FvPpi == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  return CoreFvHandle->FvPpi->FindFileByType (CoreFvHandle->FvPpi, SearchType, FvHandle, FileHandle);\r
 }\r
 \r
 \r
@@ -605,68 +613,36 @@ PeiFfsFindNextFile (
   Search the firmware volumes by index\r
 \r
   @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
-  @param Instance        Instance of FV to find\r
-  @param VolumeHandle    Pointer to found Volume.\r
+  @param Instance        This instance of the firmware volume to find. The value 0 is the Boot Firmware\r
+                         Volume (BFV).\r
+  @param VolumeHandle    On exit, points to the next volume handle or NULL if it does not exist.\r
 \r
-  @retval EFI_INVALID_PARAMETER  FwVolHeader is NULL\r
-  @retval EFI_SUCCESS            Firmware volume instance successfully found.\r
+  @retval EFI_INVALID_PARAMETER  VolumeHandle is NULL\r
+  @retval EFI_NOT_FOUND          The volume was not found.\r
+  @retval EFI_SUCCESS            The volume was found.\r
 \r
 **/\r
 EFI_STATUS \r
 EFIAPI\r
-PeiFvFindNextVolume (\r
+PeiFfsFindNextVolume (\r
   IN CONST EFI_PEI_SERVICES         **PeiServices,\r
   IN     UINTN                      Instance,\r
   IN OUT EFI_PEI_FV_HANDLE          *VolumeHandle\r
   )\r
 {\r
-  PEI_CORE_INSTANCE        *Private;\r
-  UINTN                    Index;\r
-  BOOLEAN                  Match;\r
-  EFI_HOB_FIRMWARE_VOLUME  *FvHob;\r
-\r
+  PEI_CORE_INSTANCE  *Private;\r
+  PEI_CORE_FV_HANDLE *CoreFvHandle;\r
+  \r
   Private = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
-  if (VolumeHandle == NULL) {\r
-   return EFI_INVALID_PARAMETER;\r
-  }\r
   \r
-  //\r
-  // Handle Framework FvHob and Install FvInfo Ppi for it.\r
-  //\r
-  if (FeaturePcdGet (PcdFrameworkCompatibilitySupport)) {\r
-    //\r
-    // Loop to search the wanted FirmwareVolume which supports FFS\r
-    //\r
-    FvHob = (EFI_HOB_FIRMWARE_VOLUME *)GetFirstHob (EFI_HOB_TYPE_FV);\r
-    while (FvHob != NULL) {\r
-      for (Index = 0, Match = FALSE; Index < Private->AllFvCount; Index++) {\r
-        if ((EFI_PEI_FV_HANDLE)(UINTN)FvHob->BaseAddress == Private->AllFv[Index]) {\r
-          Match = TRUE;\r
-          break;\r
-        }\r
-      }\r
-      //\r
-      // If Not Found, Install FvInfo Ppi for it.\r
-      //\r
-      if (!Match) {\r
-        PeiServicesInstallFvInfoPpi (\r
-          &(((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHob->BaseAddress)->FileSystemGuid),\r
-          (VOID *)(UINTN)FvHob->BaseAddress,\r
-          (UINT32)FvHob->Length,\r
-          NULL,\r
-          NULL\r
-          );\r
-      }\r
-      FvHob = (EFI_HOB_FIRMWARE_VOLUME *)GetNextHob (EFI_HOB_TYPE_FV, (VOID *)((UINTN)FvHob + FvHob->Header.HobLength)); \r
-    }\r
+  CoreFvHandle = FindNextCoreFvHandle (Private, Instance);\r
+  if (CoreFvHandle == NULL) {\r
+    *VolumeHandle = NULL;\r
+    return EFI_NOT_FOUND;\r
   }\r
-\r
-  if (Instance >= Private->AllFvCount) {\r
-   VolumeHandle = NULL;\r
-   return EFI_NOT_FOUND;\r
-  }\r
-\r
-  *VolumeHandle = Private->AllFv[Instance];\r
+  \r
+  *VolumeHandle = CoreFvHandle->FvHandle;\r
+  \r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -692,27 +668,29 @@ PeiFfsFindFileByName (
   OUT EFI_PEI_FILE_HANDLE   *FileHandle\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
+  PEI_CORE_FV_HANDLE            *CoreFvHandle;\r
+  \r
   if ((VolumeHandle == NULL) || (FileName == NULL) || (FileHandle == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  Status = PeiFindFileEx (VolumeHandle, FileName, 0, FileHandle, NULL);\r
-  if (Status == EFI_NOT_FOUND) {\r
-    *FileHandle = NULL;\r
+  \r
+  CoreFvHandle = FvHandleToCoreHandle (VolumeHandle);\r
+  if ((CoreFvHandle == NULL) || (CoreFvHandle->FvPpi == NULL)) {\r
+    return EFI_NOT_FOUND;\r
   }\r
-  return Status;\r
+  \r
+  return CoreFvHandle->FvPpi->FindFileByName (CoreFvHandle->FvPpi, FileName, &VolumeHandle, FileHandle);\r
 }\r
 \r
 /**\r
-\r
   Returns information about a specific file.\r
 \r
+  @param FileHandle       Handle of the file.\r
+  @param FileInfo         Upon exit, points to the file’s information.\r
 \r
-  @param FileHandle      - The handle to file.\r
-  @param FileInfo        - Pointer to the file information.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid FileHandle or FileInfo.\r
-  @retval EFI_SUCCESS           Success to collect file info.\r
+  @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
+  @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
+  @retval EFI_SUCCESS           File information returned.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -722,61 +700,33 @@ PeiFfsGetFileInfo (
   OUT EFI_FV_FILE_INFO    *FileInfo\r
   )\r
 {\r
-  UINT8                       FileState;\r
-  UINT8                       ErasePolarity;\r
-  EFI_FFS_FILE_HEADER         *FileHeader;\r
-  EFI_PEI_FV_HANDLE           VolumeHandle;\r
-\r
+  PEI_CORE_FV_HANDLE          *CoreFvHandle;\r
+  \r
   if ((FileHandle == NULL) || (FileInfo == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  VolumeHandle = 0;\r
   //\r
   // Retrieve the FirmwareVolume which the file resides in.\r
   //\r
-  if (!PeiFileHandleToVolume(FileHandle, &VolumeHandle)) {\r
+  CoreFvHandle = FileHandleToVolume (FileHandle);\r
+  if ((CoreFvHandle == NULL) || (CoreFvHandle->FvPpi == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (((EFI_FIRMWARE_VOLUME_HEADER*)VolumeHandle)->Attributes & EFI_FVB2_ERASE_POLARITY) {\r
-    ErasePolarity = 1;\r
-  } else {\r
-    ErasePolarity = 0;\r
-  }\r
-\r
-  //\r
-  // Get FileState which is the highest bit of the State \r
-  //\r
-  FileState = GetFileState (ErasePolarity, (EFI_FFS_FILE_HEADER*)FileHandle);\r
-\r
-  switch (FileState) {\r
-    case EFI_FILE_DATA_VALID:\r
-    case EFI_FILE_MARKED_FOR_UPDATE:\r
-      break;  \r
-    default:\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-  FileHeader = (EFI_FFS_FILE_HEADER *)FileHandle;\r
-  CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));\r
-  FileInfo->FileType = FileHeader->Type;\r
-  FileInfo->FileAttributes = FileHeader->Attributes;\r
-  FileInfo->BufferSize = ((*(UINT32 *)FileHeader->Size) & 0x00FFFFFF) -  sizeof (EFI_FFS_FILE_HEADER);\r
-  FileInfo->Buffer = (FileHeader + 1);\r
-  return EFI_SUCCESS;\r
+  return CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi, FileHandle, FileInfo);\r
 }\r
 \r
 \r
 /**\r
+  Returns information about the specified volume.\r
 \r
-  Collect information of given Fv Volume.\r
-\r
-  @param VolumeHandle    - The handle to Fv Volume.\r
-  @param VolumeInfo      - The pointer to volume information.\r
+  @param VolumeHandle    Handle of the volume.\r
+  @param VolumeInfo      Upon exit, points to the volume’s information.\r
 \r
-  @retval EFI_INVALID_PARAMETER VolumeInfo is NULL\r
-  @retval EFI_SUCCESS           Success to collect fv info.\r
+  @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.\r
+  @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.\r
+  @retval EFI_SUCCESS           Volume information returned.\r
 **/\r
 EFI_STATUS\r
 EFIAPI \r
@@ -785,46 +735,26 @@ PeiFfsGetVolumeInfo (
   OUT EFI_FV_INFO       *VolumeInfo\r
   )\r
 {\r
-  EFI_FIRMWARE_VOLUME_HEADER             FwVolHeader;\r
-  EFI_FIRMWARE_VOLUME_EXT_HEADER         *FwVolExHeaderInfo;\r
-\r
+  PEI_CORE_FV_HANDLE                     *CoreHandle;\r
+  \r
   if (VolumeInfo == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   \r
-  //\r
-  // VolumeHandle may not align at 8 byte, \r
-  // but FvLength is UINT64 type, which requires FvHeader align at least 8 byte. \r
-  // So, Copy FvHeader into the local FvHeader structure.\r
-  //\r
-  CopyMem (&FwVolHeader, VolumeHandle, sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
-  //\r
-  // Check Fv Image Signature\r
-  //\r
-  if (FwVolHeader.Signature != EFI_FVH_SIGNATURE) {\r
+  CoreHandle = FvHandleToCoreHandle (VolumeHandle);\r
+  \r
+  if ((CoreHandle == NULL) || (CoreHandle->FvPpi == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  ZeroMem (VolumeInfo, sizeof (EFI_FV_INFO));\r
-  VolumeInfo->FvAttributes = FwVolHeader.Attributes;\r
-  VolumeInfo->FvStart = (VOID *) VolumeHandle;\r
-  VolumeInfo->FvSize = FwVolHeader.FvLength;\r
-  CopyMem (&VolumeInfo->FvFormat, &FwVolHeader.FileSystemGuid, sizeof(EFI_GUID));\r
-\r
-  if (FwVolHeader.ExtHeaderOffset != 0) {\r
-    FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER*)(((UINT8 *)VolumeHandle) + FwVolHeader.ExtHeaderOffset);\r
-    CopyMem (&VolumeInfo->FvName, &FwVolExHeaderInfo->FvName, sizeof(EFI_GUID));\r
-  }\r
-  return EFI_SUCCESS;\r
+  \r
+  return CoreHandle->FvPpi->GetVolumeInfo (CoreHandle->FvPpi, VolumeHandle, VolumeInfo);\r
 }\r
 \r
 /**\r
   Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
 \r
-  @param PeiServices          An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param ParentFvHandle       Fv handle to parent Fv image that contain this Fv image.\r
+  @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
   @param ParentFvFileHandle   File handle of a Fv type file that contain this Fv image.\r
-  @param AuthenticationState  Pointer to attestation authentication state of image.\r
-\r
 \r
   @retval EFI_NOT_FOUND         FV image can't be found.\r
   @retval EFI_SUCCESS           Successfully to process it.\r
@@ -834,23 +764,20 @@ PeiFfsGetVolumeInfo (
 **/\r
 EFI_STATUS\r
 ProcessFvFile (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  EFI_PEI_FV_HANDLE           ParentFvHandle,\r
-  IN  EFI_PEI_FILE_HANDLE         ParentFvFileHandle,\r
-  OUT UINT32                      *AuthenticationState\r
+  IN  PEI_CORE_FV_HANDLE          *ParentFvCoreHandle,\r
+  IN  EFI_PEI_FILE_HANDLE         ParentFvFileHandle\r
   )\r
 {\r
-  EFI_STATUS            Status;\r
-  EFI_PEI_FV_HANDLE     FvImageHandle;\r
-  EFI_FV_INFO           FvImageInfo;\r
-  EFI_FV_INFO           ParentFvImageInfo;\r
-  UINT32                FvAlignment;\r
-  VOID                  *FvBuffer;\r
-  EFI_PEI_HOB_POINTERS  HobPtr;\r
-\r
-  FvBuffer             = NULL;\r
-  *AuthenticationState = 0;\r
-\r
+  EFI_STATUS                    Status;\r
+  EFI_FV_INFO                   ParentFvImageInfo;\r
+  UINT32                        FvAlignment;\r
+  VOID                          *NewFvBuffer;\r
+  EFI_PEI_HOB_POINTERS          HobPtr;\r
+  EFI_PEI_FIRMWARE_VOLUME_PPI   *ParentFvPpi;\r
+  EFI_PEI_FV_HANDLE             ParentFvHandle;\r
+  EFI_FIRMWARE_VOLUME_HEADER    *FvHeader;\r
+  EFI_FV_FILE_INFO              FileInfo;\r
+  \r
   //\r
   // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already\r
   // been extracted.\r
@@ -861,41 +788,33 @@ ProcessFvFile (
       //\r
       // this FILE has been dispatched, it will not be dispatched again.\r
       //\r
+      DEBUG ((EFI_D_INFO, "FV file %p has been dispatched!\r\n", ParentFvFileHandle));\r
       return EFI_SUCCESS;\r
     }\r
     HobPtr.Raw = GET_NEXT_HOB (HobPtr);\r
   }\r
 \r
+  ParentFvHandle = ParentFvCoreHandle->FvHandle;\r
+  ParentFvPpi    = ParentFvCoreHandle->FvPpi;\r
+  \r
   //\r
   // Find FvImage in FvFile\r
   //\r
-  Status = PeiFfsFindSectionData (\r
-             PeiServices,\r
-             EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r
-             ParentFvFileHandle,\r
-             (VOID **)&FvImageHandle\r
-             );\r
-\r
+  Status = ParentFvPpi->FindSectionByType (\r
+                          ParentFvPpi,\r
+                          EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r
+                          ParentFvFileHandle,\r
+                          (VOID **)&FvHeader\r
+                          );\r
+             \r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
   //\r
-  // Collect Parent FvImage Info.\r
-  //\r
-  Status = PeiFfsGetVolumeInfo (ParentFvHandle, &ParentFvImageInfo);\r
-  ASSERT_EFI_ERROR (Status); \r
\r
-  //\r
-  // Collect FvImage Info.\r
-  //\r
-  Status = PeiFfsGetVolumeInfo (FvImageHandle, &FvImageInfo);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  //\r
-  // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.\r
+  // FvAlignment must be more than 8 bytes required by FvHeader structure.\r
   //\r
-  FvAlignment = 1 << ((FvImageInfo.FvAttributes & EFI_FVB2_ALIGNMENT) >> 16);\r
+  FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
   if (FvAlignment < 8) {\r
     FvAlignment = 8;\r
   }\r
@@ -903,36 +822,38 @@ ProcessFvFile (
   //\r
   // Check FvImage\r
   //\r
-  if ((UINTN) FvImageInfo.FvStart % FvAlignment != 0) {\r
-    FvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvImageInfo.FvSize), FvAlignment);\r
-    if (FvBuffer == NULL) {\r
+  if ((UINTN) FvHeader % FvAlignment != 0) {\r
+    NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvHeader->FvLength), FvAlignment);\r
+    if (NewFvBuffer == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
-    CopyMem (FvBuffer, FvImageInfo.FvStart, (UINTN) FvImageInfo.FvSize);\r
-    //\r
-    // Update FvImageInfo after reload FvImage to new aligned memory\r
-    //\r
-    Status = PeiFfsGetVolumeInfo ((EFI_PEI_FV_HANDLE) FvBuffer, &FvImageInfo);\r
-    ASSERT_EFI_ERROR (Status);\r
+    CopyMem (NewFvBuffer, FvHeader, (UINTN) FvHeader->FvLength);\r
+    FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;\r
   }\r
-\r
+  \r
+  Status = ParentFvPpi->GetVolumeInfo (ParentFvPpi, ParentFvHandle, &ParentFvImageInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+  Status = ParentFvPpi->GetFileInfo (ParentFvPpi, ParentFvFileHandle, &FileInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
   //\r
   // Install FvPpi and Build FvHob\r
   //\r
   PeiServicesInstallFvInfoPpi (\r
-    NULL,\r
-    FvImageInfo.FvStart,\r
-    (UINT32) FvImageInfo.FvSize,\r
+    &FvHeader->FileSystemGuid,\r
+    (VOID**) FvHeader,\r
+    (UINT32) FvHeader->FvLength,\r
     &ParentFvImageInfo.FvName,\r
-    &(((EFI_FFS_FILE_HEADER*)ParentFvFileHandle)->Name)\r
+    &FileInfo.FileName\r
     );\r
 \r
   //\r
   // Inform the extracted FvImage to Fv HOB consumer phase, i.e. DXE phase\r
   //\r
   BuildFvHob (\r
-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r
-    FvImageInfo.FvSize\r
+    (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,\r
+    FvHeader->FvLength\r
     );\r
 \r
   //\r
@@ -940,13 +861,494 @@ ProcessFvFile (
   // encapsulated file again.\r
   //\r
   BuildFv2Hob (\r
-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r
-    FvImageInfo.FvSize,\r
+    (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,\r
+    FvHeader->FvLength,\r
     &ParentFvImageInfo.FvName,\r
-    &(((EFI_FFS_FILE_HEADER *)ParentFvFileHandle)->Name)\r
+    &FileInfo.FileName\r
     );\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Process a firmware volume and create a volume handle.\r
+\r
+  Create a volume handle from the information in the buffer. For\r
+  memory-mapped firmware volumes, Buffer and BufferSize refer to\r
+  the start of the firmware volume and the firmware volume size.\r
+  For non memory-mapped firmware volumes, this points to a\r
+  buffer which contains the necessary information for creating\r
+  the firmware volume handle. Normally, these values are derived\r
+  from the EFI_FIRMWARE_VOLUME_INFO_PPI.\r
+  \r
+  \r
+  @param This                   Points to this instance of the\r
+                                EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param Buffer                 Points to the start of the buffer.\r
+  @param BufferSize             Size of the buffer.\r
+  @param FvHandle               Points to the returned firmware volume\r
+                                handle. The firmware volume handle must\r
+                                be unique within the system. \r
+\r
+  @retval EFI_SUCCESS           Firmware volume handle created.\r
+  @retval EFI_VOLUME_CORRUPTED  Volume was corrupt.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiProcessVolume (\r
+  IN  CONST  EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
+  IN  VOID                               *Buffer,\r
+  IN  UINTN                              BufferSize,\r
+  OUT EFI_PEI_FV_HANDLE                  *FvHandle\r
+  )\r
+{\r
+  EFI_STATUS          Status;\r
+  PEI_CORE_INSTANCE   *PrivateData;\r
+  EFI_PEI_FILE_HANDLE FileHandle;\r
+  VOID                *DepexData;\r
+  EFI_PEI_SERVICES    **PeiServices;\r
+  UINTN               FvIndex;\r
+  \r
+  PeiServices = (EFI_PEI_SERVICES**) GetPeiServicesTablePointer ();\r
+  PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
+  \r
+  //\r
+  // The build-in EFI_PEI_FIRMWARE_VOLUME_PPI for FFS2 support memory-mapped\r
+  // FV image and the handle is pointed to Fv image's buffer.\r
+  //\r
+  *FvHandle = (EFI_PEI_FV_HANDLE) Buffer;\r
+  \r
+  //\r
+  // Do verify for given FV buffer.\r
+  //\r
+  Status = VerifyFv ((EFI_FIRMWARE_VOLUME_HEADER*) Buffer);\r
+  if (EFI_ERROR(Status)) {\r
+    DEBUG ((EFI_D_ERROR, "Fail to verify FV which address is 0x%11p", Buffer));\r
+    return EFI_VOLUME_CORRUPTED;\r
+  }\r
+\r
+  //\r
+  // Check whether the FV has already been processed.\r
+  //\r
+  for (FvIndex = 0; FvIndex < PrivateData->FvCount; FvIndex ++) {\r
+    if (PrivateData->Fv[FvIndex].FvHandle == *FvHandle) {\r
+      DEBUG ((EFI_D_INFO, "The Fv %p has already been processed!", Buffer));\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+  \r
+  //\r
+  // Update internal PEI_CORE_FV array.\r
+  //\r
+  PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) Buffer;\r
+  PrivateData->Fv[PrivateData->FvCount].FvPpi    = (EFI_PEI_FIRMWARE_VOLUME_PPI*) This;\r
+  PrivateData->Fv[PrivateData->FvCount].FvHandle = *FvHandle;\r
+  \r
+  DEBUG ((EFI_D_INFO, \r
+          "The %dth FV start address is 0x%11p and size is 0x%08x\n", \r
+          (UINT32) PrivateData->FvCount, \r
+          (VOID *) Buffer, \r
+          BufferSize\r
+          ));\r
+  PrivateData->FvCount ++;\r
+  \r
+  do {\r
+    Status = This->FindFileByType (\r
+                     This,\r
+                     EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,\r
+                     *FvHandle,\r
+                     &FileHandle\r
+                     );\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = This->FindSectionByType (\r
+                       This,\r
+                       EFI_SECTION_PEI_DEPEX,\r
+                       FileHandle,\r
+                       (VOID**)&DepexData\r
+                       );\r
+      if (!EFI_ERROR (Status)) {\r
+        if (!PeimDispatchReadiness (PeiServices, DepexData)) {\r
+          //\r
+          // Dependency is not satisfied.\r
+          //\r
+          continue;\r
+        }\r
+      }\r
+      \r
+      DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p", FileHandle, PrivateData->FvCount - 1, *FvHandle));\r
+      ProcessFvFile (&PrivateData->Fv[PrivateData->FvCount - 1], FileHandle);\r
+    }\r
+  } while (FileHandle != NULL);\r
+\r
+  return EFI_SUCCESS;\r
+}  \r
+\r
+/**\r
+  Finds the next file of the specified type.\r
+\r
+  This service enables PEI modules to discover additional firmware files. \r
+  The FileHandle must be unique within the system.\r
+\r
+  @param This           Points to this instance of the\r
+                        EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param SearchType     A filter to find only files of this type. Type\r
+                        EFI_FV_FILETYPE_ALL causes no filtering to be\r
+                        done.\r
+  @param FvHandle       Handle of firmware volume in which to\r
+                        search.\r
+  @param FileHandle     Points to the current handle from which to\r
+                        begin searching or NULL to start at the\r
+                        beginning of the firmware volume. Updated\r
+                        upon return to reflect the file found.\r
+\r
+  @retval EFI_SUCCESS   The file was found.\r
+  @retval EFI_NOT_FOUND The file was not found. FileHandle contains NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiFindFileByType (\r
+  IN CONST  EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
+  IN        EFI_FV_FILETYPE             SearchType,\r
+  IN        EFI_PEI_FV_HANDLE           FvHandle,\r
+  IN OUT    EFI_PEI_FILE_HANDLE         *FileHandle\r
+  )\r
+{ \r
+  return FindFileEx (FvHandle, NULL, SearchType, FileHandle, NULL);\r
+}\r
+\r
+/**\r
+  Find a file within a volume by its name. \r
+  \r
+  This service searches for files with a specific name, within\r
+  either the specified firmware volume or all firmware volumes.\r
+\r
+  @param This                   Points to this instance of the\r
+                                EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param FileName               A pointer to the name of the file to find\r
+                                within the firmware volume.\r
+  @param FvHandle               Upon entry, the pointer to the firmware\r
+                                volume to search or NULL if all firmware\r
+                                volumes should be searched. Upon exit, the\r
+                                actual firmware volume in which the file was\r
+                                found.\r
+  @param FileHandle             Upon exit, points to the found file's\r
+                                handle or NULL if it could not be found.\r
+\r
+  @retval EFI_SUCCESS           File was found.\r
+  @retval EFI_NOT_FOUND         File was not found.\r
+  @retval EFI_INVALID_PARAMETER FvHandle or FileHandle or\r
+                                FileName was NULL.\r
+\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiFindFileByName (\r
+  IN  CONST  EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
+  IN  CONST  EFI_GUID                    *FileName,\r
+  IN  EFI_PEI_FV_HANDLE                  *FvHandle,\r
+  OUT EFI_PEI_FILE_HANDLE                *FileHandle  \r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  PEI_CORE_INSTANCE *PrivateData;\r
+  UINTN             Index;\r
+  \r
+  if ((FvHandle == NULL) || (FileName == NULL) || (FileHandle == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  if (*FvHandle != NULL) {\r
+    Status = FindFileEx (*FvHandle, FileName, 0, FileHandle, NULL);\r
+    if (Status == EFI_NOT_FOUND) {\r
+      *FileHandle = NULL;\r
+    }\r
+  } else {   \r
+    //\r
+    // If *FvHandle = NULL, so search all FV for given filename\r
+    //\r
+    Status = EFI_NOT_FOUND;\r
+    \r
+    PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer());\r
+    for (Index = 0; Index < PrivateData->FvCount; Index ++) {\r
+      //\r
+      // Only search the FV which is associated with a EFI_PEI_FIRMWARE_VOLUME_PPI instance.\r
+      //\r
+      if (PrivateData->Fv[Index].FvPpi != NULL) {\r
+        Status = FindFileEx (PrivateData->Fv[Index].FvHandle, FileName, 0, FileHandle, NULL);\r
+        if (!EFI_ERROR (Status)) {\r
+          *FvHandle = PrivateData->Fv[Index].FvHandle;\r
+        }\r
+      }\r
+    }\r
+  }\r
+  \r
+  return Status;  \r
+}  \r
+\r
+/**\r
+  Returns information about a specific file.\r
+\r
+  This function returns information about a specific\r
+  file, including its file name, type, attributes, starting\r
+  address and size. \r
+   \r
+  @param This                     Points to this instance of the\r
+                                  EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param FileHandle               Handle of the file.\r
+  @param FileInfo                 Upon exit, points to the file's\r
+                                  information.\r
+\r
+  @retval EFI_SUCCESS             File information returned.\r
+  @retval EFI_INVALID_PARAMETER   If FileHandle does not\r
+                                  represent a valid file.\r
+  @retval EFI_INVALID_PARAMETER   If FileInfo is NULL.\r
+  \r
+**/ \r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiGetFileInfo (\r
+  IN  CONST EFI_PEI_FIRMWARE_VOLUME_PPI   *This, \r
+  IN        EFI_PEI_FILE_HANDLE           FileHandle, \r
+  OUT       EFI_FV_FILE_INFO              *FileInfo\r
+  )\r
+{\r
+  UINT8                       FileState;\r
+  UINT8                       ErasePolarity;\r
+  EFI_FFS_FILE_HEADER         *FileHeader;\r
+  PEI_CORE_FV_HANDLE          *CoreFvHandle;\r
+  \r
+  if ((FileHandle == NULL) || (FileInfo == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Retrieve the FirmwareVolume which the file resides in.\r
+  //\r
+  CoreFvHandle = FileHandleToVolume (FileHandle);\r
+  if (CoreFvHandle == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (CoreFvHandle->FvHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {\r
+    ErasePolarity = 1;\r
+  } else {\r
+    ErasePolarity = 0;\r
+  }\r
+\r
+  //\r
+  // Get FileState which is the highest bit of the State \r
+  //\r
+  FileState = GetFileState (ErasePolarity, (EFI_FFS_FILE_HEADER*)FileHandle);\r
+\r
+  switch (FileState) {\r
+    case EFI_FILE_DATA_VALID:\r
+    case EFI_FILE_MARKED_FOR_UPDATE:\r
+      break;  \r
+    default:\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+  FileHeader = (EFI_FFS_FILE_HEADER *)FileHandle;\r
+  CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));\r
+  FileInfo->FileType = FileHeader->Type;\r
+  FileInfo->FileAttributes = FileHeader->Attributes;\r
+  FileInfo->BufferSize = ((*(UINT32 *)FileHeader->Size) & 0x00FFFFFF) -  sizeof (EFI_FFS_FILE_HEADER);\r
+  FileInfo->Buffer = (FileHeader + 1);\r
+  return EFI_SUCCESS;  \r
+}  \r
+  \r
+/**\r
+  This function returns information about the firmware volume.\r
+  \r
+  @param This                     Points to this instance of the\r
+                                  EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param FvHandle                 Handle to the firmware handle.\r
+  @param VolumeInfo               Points to the returned firmware volume\r
+                                  information.\r
+\r
+  @retval EFI_SUCCESS             Information returned successfully.\r
+  @retval EFI_INVALID_PARAMETER   FvHandle does not indicate a valid\r
+                                  firmware volume or VolumeInfo is NULL.\r
+\r
+**/   \r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiGetVolumeInfo (\r
+  IN  CONST  EFI_PEI_FIRMWARE_VOLUME_PPI   *This, \r
+  IN  EFI_PEI_FV_HANDLE                    FvHandle, \r
+  OUT EFI_FV_INFO                          *VolumeInfo\r
+  )\r
+{\r
+  EFI_FIRMWARE_VOLUME_HEADER             FwVolHeader;\r
+  EFI_FIRMWARE_VOLUME_EXT_HEADER         *FwVolExHeaderInfo;\r
+\r
+  if (VolumeInfo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  //\r
+  // VolumeHandle may not align at 8 byte, \r
+  // but FvLength is UINT64 type, which requires FvHeader align at least 8 byte. \r
+  // So, Copy FvHeader into the local FvHeader structure.\r
+  //\r
+  CopyMem (&FwVolHeader, FvHandle, sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
+\r
+  //\r
+  // Check Fv Image Signature\r
+  //\r
+  if (FwVolHeader.Signature != EFI_FVH_SIGNATURE) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  ZeroMem (VolumeInfo, sizeof (EFI_FV_INFO));\r
+  VolumeInfo->FvAttributes  = FwVolHeader.Attributes;\r
+  VolumeInfo->FvStart       = (VOID *) FvHandle;\r
+  VolumeInfo->FvSize        = FwVolHeader.FvLength;\r
+  CopyMem (&VolumeInfo->FvFormat, &FwVolHeader.FileSystemGuid, sizeof(EFI_GUID));\r
+\r
+  if (FwVolHeader.ExtHeaderOffset != 0) {\r
+    FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER*)(((UINT8 *)FvHandle) + FwVolHeader.ExtHeaderOffset);\r
+    CopyMem (&VolumeInfo->FvName, &FwVolExHeaderInfo->FvName, sizeof(EFI_GUID));\r
+  }\r
+  \r
+  return EFI_SUCCESS;  \r
+}    \r
+\r
+/**\r
+  Find the next matching section in the firmware file.\r
+  \r
+  This service enables PEI modules to discover sections\r
+  of a given type within a valid file.\r
+  \r
+  @param This             Points to this instance of the\r
+                          EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param SearchType       A filter to find only sections of this\r
+                          type.\r
+  @param FileHandle       Handle of firmware file in which to\r
+                          search.\r
+  @param SectionData      Updated upon  return to point to the\r
+                          section found.\r
+  \r
+  @retval EFI_SUCCESS     Section was found.\r
+  @retval EFI_NOT_FOUND   Section of the specified type was not\r
+                          found. SectionData contains NULL.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiFindSectionByType (\r
+  IN  CONST EFI_PEI_FIRMWARE_VOLUME_PPI    *This,\r
+  IN        EFI_SECTION_TYPE               SearchType,\r
+  IN        EFI_PEI_FILE_HANDLE            FileHandle,\r
+  OUT VOID                                 **SectionData\r
+  )\r
+{\r
+  EFI_FFS_FILE_HEADER                     *FfsFileHeader;\r
+  UINT32                                  FileSize;\r
+  EFI_COMMON_SECTION_HEADER               *Section;\r
+  \r
+  FfsFileHeader = (EFI_FFS_FILE_HEADER *)(FileHandle);\r
+\r
+  //\r
+  // Size is 24 bits wide so mask upper 8 bits. \r
+  // Does not include FfsFileHeader header size\r
+  // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.\r
+  //\r
+  Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);\r
+  FileSize = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;\r
+  FileSize -= sizeof (EFI_FFS_FILE_HEADER);\r
+\r
+  return ProcessSection (\r
+           GetPeiServicesTablePointer (),\r
+           SearchType, \r
+           Section, \r
+           FileSize, \r
+           SectionData\r
+           );  \r
+}  \r
+\r
+/**\r
+  Convert the handle of FV to pointer of corresponding PEI_CORE_FV_HANDLE.\r
+  \r
+  @param FvHandle   The handle of a FV.\r
+  \r
+  @retval NULL if can not find.\r
+  @return Pointer of corresponding PEI_CORE_FV_HANDLE. \r
+**/\r
+PEI_CORE_FV_HANDLE *\r
+FvHandleToCoreHandle (\r
+  IN EFI_PEI_FV_HANDLE  FvHandle\r
+  )\r
+{\r
+  UINTN             Index;\r
+  PEI_CORE_INSTANCE *PrivateData;\r
+  \r
+  PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer());  \r
+  for (Index = 0; Index < PrivateData->FvCount; Index ++) {\r
+    if (FvHandle == PrivateData->Fv[Index].FvHandle) {\r
+      return &PrivateData->Fv[Index];\r
+    }\r
+  }\r
+  \r
+  return NULL;\r
+}  \r
+\r
+/**\r
+  Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.\r
+  \r
+  This routine also will install FvInfo ppi for FV hob in PI ways.\r
+  \r
+  @param Private    Pointer of PEI_CORE_INSTANCE\r
+  @param Instance   The index of FV want to be searched.\r
+  \r
+  @return Instance of PEI_CORE_FV_HANDLE.\r
+**/\r
+PEI_CORE_FV_HANDLE *\r
+FindNextCoreFvHandle (\r
+  IN PEI_CORE_INSTANCE  *Private,\r
+  IN UINTN              Instance\r
+  )\r
+{\r
+  UINTN                    Index;\r
+  BOOLEAN                  Match;\r
+  EFI_HOB_FIRMWARE_VOLUME  *FvHob;\r
+  \r
+  //\r
+  // Handle Framework FvHob and Install FvInfo Ppi for it.\r
+  //\r
+  if (FeaturePcdGet (PcdFrameworkCompatibilitySupport)) {\r
+    //\r
+    // Loop to search the wanted FirmwareVolume which supports FFS\r
+    //\r
+    FvHob = (EFI_HOB_FIRMWARE_VOLUME *)GetFirstHob (EFI_HOB_TYPE_FV);\r
+    while (FvHob != NULL) {\r
+      for (Index = 0, Match = FALSE; Index < Private->FvCount; Index++) {\r
+        if ((EFI_PEI_FV_HANDLE)(UINTN)FvHob->BaseAddress == Private->Fv[Index].FvHeader) {\r
+          Match = TRUE;\r
+          break;\r
+        }\r
+      }\r
+      //\r
+      // If Not Found, Install FvInfo Ppi for it.\r
+      //\r
+      if (!Match) {\r
+        PeiServicesInstallFvInfoPpi (\r
+          &(((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHob->BaseAddress)->FileSystemGuid),\r
+          (VOID *)(UINTN)FvHob->BaseAddress,\r
+          (UINT32)FvHob->Length,\r
+          NULL,\r
+          NULL\r
+          );\r
+      }\r
+      FvHob = (EFI_HOB_FIRMWARE_VOLUME *)GetNextHob (EFI_HOB_TYPE_FV, (VOID *)((UINTN)FvHob + FvHob->Header.HobLength)); \r
+    }\r
+  }\r
+\r
+  if (Instance >= Private->FvCount) {\r
+    return NULL;\r
+  }\r
 \r
+  return &Private->Fv[Instance];\r
+}  \r
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.h b/MdeModulePkg/Core/Pei/FwVol/FwVol.h
new file mode 100644 (file)
index 0000000..65c17e3
--- /dev/null
@@ -0,0 +1,238 @@
+/** @file\r
+  The internal header file for firmware volume related definitions.\r
+  \r
+Copyright (c) 2009, Intel Corporation                                                         \r
+All rights reserved. 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef _FWVOL_H_\r
+#define _FWVOL_H_\r
+\r
+#include "PeiMain.h"\r
+\r
+#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \\r
+  ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))\r
+\r
+\r
+/**\r
+  Process a firmware volume and create a volume handle.\r
+\r
+  Create a volume handle from the information in the buffer. For\r
+  memory-mapped firmware volumes, Buffer and BufferSize refer to\r
+  the start of the firmware volume and the firmware volume size.\r
+  For non memory-mapped firmware volumes, this points to a\r
+  buffer which contains the necessary information for creating\r
+  the firmware volume handle. Normally, these values are derived\r
+  from the EFI_FIRMWARE_VOLUME_INFO_PPI.\r
+  \r
+  \r
+  @param This                   Points to this instance of the\r
+                                EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param Buffer                 Points to the start of the buffer.\r
+  @param BufferSize             Size of the buffer.\r
+  @param FvHandle               Points to the returned firmware volume\r
+                                handle. The firmware volume handle must\r
+                                be unique within the system. \r
+\r
+  @retval EFI_SUCCESS           Firmware volume handle created.\r
+  @retval EFI_VOLUME_CORRUPTED  Volume was corrupt.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiProcessVolume (\r
+  IN  CONST  EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
+  IN  VOID                               *Buffer,\r
+  IN  UINTN                              BufferSize,\r
+  OUT EFI_PEI_FV_HANDLE                  *FvHandle\r
+  );\r
+  \r
+/**\r
+  Finds the next file of the specified type.\r
+\r
+  This service enables PEI modules to discover additional firmware files. \r
+  The FileHandle must be unique within the system.\r
+\r
+  @param This           Points to this instance of the\r
+                        EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param SearchType     A filter to find only files of this type. Type\r
+                        EFI_FV_FILETYPE_ALL causes no filtering to be\r
+                        done.\r
+  @param FvHandle       Handle of firmware volume in which to\r
+                        search.\r
+  @param FileHandle     Points to the current handle from which to\r
+                        begin searching or NULL to start at the\r
+                        beginning of the firmware volume. Updated\r
+                        upon return to reflect the file found.\r
+\r
+  @retval EFI_SUCCESS   The file was found.\r
+  @retval EFI_NOT_FOUND The file was not found. FileHandle contains NULL.\r
+\r
+**/  \r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiFindFileByType (\r
+  IN CONST  EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
+  IN        EFI_FV_FILETYPE             SearchType,\r
+  IN        EFI_PEI_FV_HANDLE           FvHandle,\r
+  IN OUT    EFI_PEI_FILE_HANDLE         *FileHandle\r
+  );\r
+\r
+/**\r
+  Find a file within a volume by its name. \r
+  \r
+  This service searches for files with a specific name, within\r
+  either the specified firmware volume or all firmware volumes.\r
+\r
+  @param This                   Points to this instance of the\r
+                                EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param FileName               A pointer to the name of the file to find\r
+                                within the firmware volume.\r
+  @param FvHandle               Upon entry, the pointer to the firmware\r
+                                volume to search or NULL if all firmware\r
+                                volumes should be searched. Upon exit, the\r
+                                actual firmware volume in which the file was\r
+                                found.\r
+  @param FileHandle             Upon exit, points to the found file's\r
+                                handle or NULL if it could not be found.\r
+\r
+  @retval EFI_SUCCESS           File was found.\r
+  @retval EFI_NOT_FOUND         File was not found.\r
+  @retval EFI_INVALID_PARAMETER FvHandle or FileHandle or\r
+                                FileName was NULL.\r
+\r
+\r
+**/    \r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiFindFileByName (\r
+  IN  CONST  EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
+  IN  CONST  EFI_GUID                    *FileName,\r
+  IN  EFI_PEI_FV_HANDLE                  *FvHandle,\r
+  OUT EFI_PEI_FILE_HANDLE                *FileHandle  \r
+  );\r
+\r
+/**\r
+  Find the next matching section in the firmware file.\r
+  \r
+  This service enables PEI modules to discover sections\r
+  of a given type within a valid file.\r
+  \r
+  @param This             Points to this instance of the\r
+                          EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param SearchType       A filter to find only sections of this\r
+                          type.\r
+  @param FileHandle       Handle of firmware file in which to\r
+                          search.\r
+  @param SectionData      Updated upon  return to point to the\r
+                          section found.\r
+  \r
+  @retval EFI_SUCCESS     Section was found.\r
+  @retval EFI_NOT_FOUND   Section of the specified type was not\r
+                          found. SectionData contains NULL.\r
+**/      \r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiFindSectionByType (\r
+  IN  CONST EFI_PEI_FIRMWARE_VOLUME_PPI    *This,\r
+  IN        EFI_SECTION_TYPE               SearchType,\r
+  IN        EFI_PEI_FILE_HANDLE            FileHandle,\r
+  OUT VOID                                 **SectionData\r
+  );\r
+\r
+/**\r
+  Returns information about a specific file.\r
+\r
+  This function returns information about a specific\r
+  file, including its file name, type, attributes, starting\r
+  address and size. \r
+   \r
+  @param This                     Points to this instance of the\r
+                                  EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param FileHandle               Handle of the file.\r
+  @param FileInfo                 Upon exit, points to the file's\r
+                                  information.\r
+\r
+  @retval EFI_SUCCESS             File information returned.\r
+  @retval EFI_INVALID_PARAMETER   If FileHandle does not\r
+                                  represent a valid file.\r
+  @retval EFI_INVALID_PARAMETER   If FileInfo is NULL.\r
+  \r
+**/         \r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiGetFileInfo (\r
+  IN  CONST EFI_PEI_FIRMWARE_VOLUME_PPI   *This, \r
+  IN        EFI_PEI_FILE_HANDLE           FileHandle, \r
+  OUT       EFI_FV_FILE_INFO              *FileInfo\r
+  );\r
+\r
+/**\r
+  This function returns information about the firmware volume.\r
+  \r
+  @param This                     Points to this instance of the\r
+                                  EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param FvHandle                 Handle to the firmware handle.\r
+  @param VolumeInfo               Points to the returned firmware volume\r
+                                  information.\r
+\r
+  @retval EFI_SUCCESS             Information returned successfully.\r
+  @retval EFI_INVALID_PARAMETER   FvHandle does not indicate a valid\r
+                                  firmware volume or VolumeInfo is NULL.\r
+\r
+**/            \r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfs2FvPpiGetVolumeInfo (\r
+  IN  CONST  EFI_PEI_FIRMWARE_VOLUME_PPI   *This, \r
+  IN  EFI_PEI_FV_HANDLE                    FvHandle, \r
+  OUT EFI_FV_INFO                          *VolumeInfo\r
+  );\r
+\r
+/**\r
+  Convert the handle of FV to pointer of corresponding PEI_CORE_FV_HANDLE.\r
+  \r
+  @param FvHandle   The handle of a FV.\r
+  \r
+  @retval NULL if can not find.\r
+  @return Pointer of corresponding PEI_CORE_FV_HANDLE. \r
+**/\r
+PEI_CORE_FV_HANDLE *\r
+FvHandleToCoreHandle (\r
+  IN EFI_PEI_FV_HANDLE  FvHandle\r
+  );\r
+  \r
+/**\r
+  Given the input file pointer, search for the next matching file in the\r
+  FFS volume as defined by SearchType. The search starts from FileHeader inside\r
+  the Firmware Volume defined by FwVolHeader.\r
+\r
+\r
+  @param FvHandle        Pointer to the FV header of the volume to search\r
+  @param FileName        File name\r
+  @param SearchType      Filter to find only files of this type.\r
+                         Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
+  @param FileHandle      This parameter must point to a valid FFS volume.\r
+  @param AprioriFile     Pointer to AprioriFile image in this FV if has\r
+\r
+  @return EFI_NOT_FOUND  No files matching the search criteria were found\r
+  @retval EFI_SUCCESS    Success to search given file\r
+\r
+**/\r
+EFI_STATUS\r
+FindFileEx (\r
+  IN  CONST EFI_PEI_FV_HANDLE        FvHandle,\r
+  IN  CONST EFI_GUID                 *FileName,   OPTIONAL\r
+  IN        EFI_FV_FILETYPE          SearchType,\r
+  IN OUT    EFI_PEI_FILE_HANDLE      *FileHandle,\r
+  IN OUT    EFI_PEI_FV_HANDLE        *AprioriFile  OPTIONAL\r
+  );\r
+\r
+#endif \r
index 1d96cc43f8e3a4ffb55f1f966e290ee105fb3f44..c8561d52e1cfffba738fd91fe2e038ff6432acfa 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definition of Pei Core Structures and Services\r
   \r
-Copyright (c) 2006 - 2008, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
 All rights reserved. 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
@@ -105,6 +105,8 @@ typedef struct {
 \r
 typedef struct {\r
   EFI_FIRMWARE_VOLUME_HEADER          *FvHeader;\r
+  EFI_PEI_FIRMWARE_VOLUME_PPI         *FvPpi;\r
+  EFI_PEI_FV_HANDLE                   FvHandle;\r
   UINT8                               PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
   EFI_PEI_FILE_HANDLE                 FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
   BOOLEAN                             ScanFv;\r
@@ -127,10 +129,23 @@ typedef struct {
 ///\r
 typedef struct{\r
   UINTN                              Signature;\r
-  EFI_PEI_SERVICES                   *PS;     // Point to ServiceTableShadow\r
+  \r
+  ///\r
+  /// Point to ServiceTableShadow\r
+  ///\r
+  EFI_PEI_SERVICES                   *PS;\r
   PEI_PPI_DATABASE                   PpiData;\r
+  \r
+  ///\r
+  /// The count of FVs which contains FFS and could be dispatched by PeiCore.\r
+  ///\r
   UINTN                              FvCount;\r
+  \r
+  ///\r
+  /// The instance arrary for FVs which contains FFS and could be dispatched by PeiCore.\r
+  ///\r
   PEI_CORE_FV_HANDLE                 Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
+\r
   EFI_PEI_FILE_HANDLE                CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
   UINTN                              AprioriCount;\r
   UINTN                              CurrentPeimFvCount;\r
@@ -139,8 +154,6 @@ typedef struct{
   BOOLEAN                            PeimNeedingDispatch;\r
   BOOLEAN                            PeimDispatchOnThisPass;\r
   BOOLEAN                            PeimDispatcherReenter;\r
-  UINTN                              AllFvCount;\r
-  EFI_PEI_FV_HANDLE                  AllFv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
   EFI_PEI_HOB_POINTERS               HobList;\r
   BOOLEAN                            SwitchStackSignal;\r
   BOOLEAN                            PeiMemoryInstalled;\r
@@ -629,19 +642,19 @@ PeiCoreBuildHobHandoffInfoTable (
 // FFS Fw Volume support functions\r
 //\r
 /**\r
-  Given the input file pointer, search for the next matching file in the\r
-  FFS volume as defined by SearchType. The search starts from FileHeader inside\r
-  the Firmware Volume defined by FwVolHeader.\r
-\r
+  Searches for the next matching file in the firmware volume.\r
 \r
   @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param SearchType      Filter to find only files of this type.\r
                          Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
-  @param FwVolHeader     Pointer to the FV header of the volume to search.\r
-  @param FileHeader      Pointer to the current file from which to begin searching.\r
-                         This pointer will be updated upon return to reflect the file found.\r
-  @retval EFI_NOT_FOUND  No files matching the search criteria were found\r
-  @retval EFI_SUCCESS    Success to find next file in given volume\r
+  @param VolumeHandle    Handle of firmware volume in which to search.\r
+  @param FileHandle      On entry, points to the current handle from which to begin searching or NULL to start\r
+                         at the beginning of the firmware volume. On exit, points the file handle of the next file\r
+                         in the volume or NULL if there are no more files.\r
+\r
+  @retval EFI_NOT_FOUND  The file was not found.\r
+  @retval EFI_NOT_FOUND  The header checksum was not zero.\r
+  @retval EFI_SUCCESS    The file was found.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -649,47 +662,48 @@ EFIAPI
 PeiFfsFindNextFile (\r
   IN CONST EFI_PEI_SERVICES      **PeiServices,\r
   IN UINT8                       SearchType,\r
-  IN EFI_PEI_FV_HANDLE           FwVolHeader,\r
-  IN OUT EFI_PEI_FILE_HANDLE     *FileHeader\r
+  IN EFI_PEI_FV_HANDLE           FvHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE     *FileHandle\r
   );\r
 \r
 /**\r
-  Given the input file pointer, search for the next matching section in the\r
-  FFS volume.\r
+  Searches for the next matching section within the specified file.\r
 \r
-  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
   @param SectionType     Filter to find only sections of this type.\r
-  @param FfsFileHeader   Pointer to the current file to search.\r
-  @param SectionData     Pointer to the Section matching SectionType in FfsFileHeader.\r
+  @param FileHandle      Pointer to the current file to search.\r
+  @param SectionData     A pointer to the discovered section, if successful.\r
                          NULL if section not found\r
 \r
-  @retval EFI_NOT_FOUND  No files matching the search criteria were found\r
-  @retval EFI_SUCCESS    Success to find section data in given file\r
+  @retval EFI_NOT_FOUND  The section was not found.\r
+  @retval EFI_SUCCESS    The section was found.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiFfsFindSectionData (\r
-  IN CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN EFI_SECTION_TYPE            SectionType,\r
-  IN EFI_PEI_FILE_HANDLE         FfsFileHeader,\r
-  IN OUT VOID                    **SectionData\r
+  IN CONST EFI_PEI_SERVICES    **PeiServices,\r
+  IN     EFI_SECTION_TYPE      SectionType,\r
+  IN     EFI_PEI_FILE_HANDLE   FileHandle,\r
+  OUT VOID                     **SectionData\r
   );\r
 \r
 /**\r
-  search the firmware volumes by index\r
+  Search the firmware volumes by index\r
 \r
-  @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param Instance               Instance of FV to find\r
-  @param FwVolHeader            Pointer to found Volume.\r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
+  @param Instance        This instance of the firmware volume to find. The value 0 is the Boot Firmware\r
+                         Volume (BFV).\r
+  @param VolumeHandle    On exit, points to the next volume handle or NULL if it does not exist.\r
 \r
-  @retval EFI_INVALID_PARAMETER FwVolHeader is NULL\r
-  @retval EFI_SUCCESS           Firmware volume instance successfully found.\r
+  @retval EFI_INVALID_PARAMETER  VolumeHandle is NULL\r
+  @retval EFI_NOT_FOUND          The volume was not found.\r
+  @retval EFI_SUCCESS            The volume was found.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-PeiFvFindNextVolume (\r
+PeiFfsFindNextVolume (\r
   IN CONST EFI_PEI_SERVICES          **PeiServices,\r
   IN UINTN                           Instance,\r
   IN OUT EFI_PEI_FV_HANDLE           *FwVolHeader\r
@@ -908,15 +922,14 @@ PeiFfsFindFileByName (
   );\r
 \r
 /**\r
-\r
   Returns information about a specific file.\r
 \r
+  @param FileHandle       Handle of the file.\r
+  @param FileInfo         Upon exit, points to the file’s information.\r
 \r
-  @param FileHandle         The handle to file.\r
-  @param FileInfo           Pointer to the file information.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid FileHandle or FileInfo.\r
-  @retval EFI_SUCCESS           Success to collect file info.\r
+  @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
+  @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
+  @retval EFI_SUCCESS           File information returned.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -927,14 +940,14 @@ PeiFfsGetFileInfo (
   );\r
 \r
 /**\r
+  Returns information about the specified volume.\r
 \r
-  Collect information of given Fv Volume.\r
-\r
-  @param VolumeHandle           The handle to Fv Volume.\r
-  @param VolumeInfo             The pointer to volume information.\r
+  @param VolumeHandle    Handle of the volume.\r
+  @param VolumeInfo      Upon exit, points to the volume’s information.\r
 \r
-  @retval EFI_INVALID_PARAMETER VolumeInfo is NULL\r
-  @retval EFI_SUCCESS           Success to collect fv info.\r
+  @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.\r
+  @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.\r
+  @retval EFI_SUCCESS           Volume information returned.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -960,32 +973,6 @@ PeiRegisterForShadow (
   IN EFI_PEI_FILE_HANDLE       FileHandle\r
   );\r
 \r
-/**\r
-  Given the input file pointer, search for the next matching file in the\r
-  FFS volume as defined by SearchType. The search starts from FileHeader inside\r
-  the Firmware Volume defined by FwVolHeader.\r
-\r
-\r
-  @param FvHandle        Pointer to the FV header of the volume to search\r
-  @param FileName        File name\r
-  @param SearchType      Filter to find only files of this type.\r
-                         Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
-  @param FileHandle      This parameter must point to a valid FFS volume.\r
-  @param AprioriFile     Pointer to AprioriFile image in this FV if has\r
-\r
-  @return EFI_NOT_FOUND  No files matching the search criteria were found\r
-  @retval EFI_SUCCESS    Success to search given file\r
-\r
-**/\r
-EFI_STATUS\r
-PeiFindFileEx (\r
-  IN  CONST EFI_PEI_FV_HANDLE        FvHandle,\r
-  IN  CONST EFI_GUID                 *FileName,   OPTIONAL\r
-  IN        EFI_FV_FILETYPE          SearchType,\r
-  IN OUT    EFI_PEI_FILE_HANDLE      *FileHandle,\r
-  IN OUT    EFI_PEI_FV_HANDLE        *AprioriFile  OPTIONAL\r
-  );\r
-\r
 /**\r
   Initialize image service that install PeiLoadFilePpi.\r
 \r
@@ -1002,27 +989,6 @@ InitializeImageServices (
   IN  PEI_CORE_INSTANCE   *OldCoreData\r
   );\r
 \r
-/**\r
-  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
-\r
-  @param PeiServices          An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param ParentFvHandle       Fv handle to parent Fv image that contain this Fv file.\r
-  @param ParentFvFileHandle   File handle of a Fv type file that contain this Fv image.\r
-  @param AuthenticationState  Pointer to attestation authentication state of image.\r
-                              If return 0, means pass security checking.\r
-\r
-  @retval EFI_NOT_FOUND       FV image can't be found.\r
-  @retval EFI_SUCCESS         Successfully to process it.\r
-\r
-**/\r
-EFI_STATUS\r
-ProcessFvFile (\r
-  IN  CONST EFI_PEI_SERVICES **PeiServices,\r
-  IN  EFI_PEI_FV_HANDLE      ParentFvHandle,\r
-  IN  EFI_PEI_FILE_HANDLE    ParentFvFileHandle,\r
-  OUT UINT32                 *AuthenticationState\r
-  );\r
-\r
 /**\r
   The wrapper function of PeiLoadImageLoadImage().\r
 \r
@@ -1066,4 +1032,38 @@ SecurityPpiNotifyCallback (
   IN VOID                       *Ppi\r
   );\r
 \r
+/**\r
+  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
+\r
+  @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
+  @param ParentFvFileHandle   File handle of a Fv type file that contain this Fv image.\r
+\r
+  @retval EFI_NOT_FOUND         FV image can't be found.\r
+  @retval EFI_SUCCESS           Successfully to process it.\r
+  @retval EFI_OUT_OF_RESOURCES  Can not allocate page when aligning FV image\r
+  @retval Others                Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
+  \r
+**/\r
+EFI_STATUS\r
+ProcessFvFile (\r
+  IN  PEI_CORE_FV_HANDLE          *ParentFvCoreHandle,\r
+  IN  EFI_PEI_FILE_HANDLE         ParentFvFileHandle\r
+  );\r
+  \r
+/**\r
+  Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.\r
+  \r
+  This routine also will install FvInfo ppi for FV hob in PI ways.\r
+  \r
+  @param Private    Pointer of PEI_CORE_INSTANCE\r
+  @param Instance   The index of FV want to be searched.\r
+  \r
+  @return Instance of PEI_CORE_FV_HANDLE.\r
+**/\r
+PEI_CORE_FV_HANDLE *\r
+FindNextCoreFvHandle (\r
+  IN PEI_CORE_INSTANCE  *Private,\r
+  IN UINTN              Instance\r
+  );\r
+    \r
 #endif\r
index 7a95ce0ae3d560c6f68d905469776409ae9e2de8..a60c76054f550a3860c35a1da3176651a95c3dff 100644 (file)
@@ -4,7 +4,7 @@
 # 2) Dispatch PEIM from discovered FV.\r
 # 3) Handoff control to DxeIpl to load DXE core and enter DXE phase.\r
 #\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
+# Copyright (c) 2006 - 2009, Intel Corporation\r
 #\r
 #  All rights reserved. This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -42,6 +42,7 @@
   Image/Image.c\r
   Hob/Hob.c\r
   FwVol/FwVol.c\r
+  FwVol/FwVol.h\r
   Dispatcher/Dispatcher.c\r
   Dependency/Dependency.c\r
   Dependency/Dependency.h\r
@@ -70,9 +71,9 @@
   \r
 \r
 [Guids]\r
-  gPeiAprioriFileNameGuid     ## CONSUMES ## GUID\r
-  gEfiFirmwareFileSystem2Guid ## CONSUMES ## FV\r
-\r
+  gPeiAprioriFileNameGuid       ## CONSUMES ## GUID\r
+  gEfiFirmwareFileSystem2Guid   ## CONSUMES ## FV\r
+  \r
 [Ppis]\r
   gEfiPeiStatusCodePpiGuid                      ## SOMETIMES_CONSUMES (PeiReportStatusService is not ready if this PPI doesn't exist)\r
   gEfiPeiResetPpiGuid                           ## SOMETIMES_CONSUMES (PeiResetService is not ready if this PPI doesn't exist) \r
index 2f61e8c92492c13b9335a77dbf2c68c9d255dc49..5a6a313fdc62984ff1b3ab3900843f256de63ee7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Main Entry Point\r
   \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
 All rights reserved. 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
@@ -42,7 +42,7 @@ EFI_PEI_SERVICES  gPs = {
   PeiGetHobList,\r
   PeiCreateHob,\r
 \r
-  PeiFvFindNextVolume,\r
+  PeiFfsFindNextVolume,\r
   PeiFfsFindNextFile,\r
   PeiFfsFindSectionData,\r
 \r