/** @file\r
Pei Core Firmware File System service routines.\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation \r
+Copyright (c) 2006 - 2010, 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
\r
**/\r
\r
-#include <PeiMain.h>\r
+#include "FwVol.h"\r
\r
-STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = {\r
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = {\r
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
&gEfiPeiFirmwareVolumeInfoPpiGuid,\r
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 highest bit set of the State field\r
+ Returns the file state set by the highest zero bit in the State field\r
\r
@param ErasePolarity Erase Polarity as defined by EFI_FVB2_ERASE_POLARITY\r
in the Attributes field.\r
@param FfsHeader Pointer to FFS File Header.\r
\r
- @return Returns the highest bit in the State field\r
-\r
+ @retval EFI_FFS_FILE_STATE File state is set by the highest none zero bit \r
+ in the header State field.\r
**/\r
EFI_FFS_FILE_STATE\r
GetFileState(\r
if (ErasePolarity != 0) {\r
FileState = (EFI_FFS_FILE_STATE)~FileState;\r
}\r
-\r
+ \r
+ //\r
+ // Get file state set by its highest none zero bit.\r
+ //\r
HighestBit = 0x80;\r
while (HighestBit != 0 && (HighestBit & FileState) == 0) {\r
HighestBit >>= 1;\r
@param FileHeader Pointer to FFS File Header.\r
\r
@return Checksum of the header.\r
- The header is zero byte checksum.\r
Zero means the header is good.\r
Non-zero means the header is bad.\r
**/\r
IN EFI_FFS_FILE_HEADER *FileHeader\r
)\r
{\r
- UINT8 *Ptr;\r
- UINTN Index;\r
- UINT8 Sum;\r
+ EFI_FFS_FILE_HEADER TestFileHeader;\r
\r
- Sum = 0;\r
- Ptr = (UINT8 *)FileHeader;\r
-\r
- for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER) - 3; Index += 4) {\r
- Sum = (UINT8)(Sum + Ptr[Index]);\r
- Sum = (UINT8)(Sum + Ptr[Index+1]);\r
- Sum = (UINT8)(Sum + Ptr[Index+2]);\r
- Sum = (UINT8)(Sum + Ptr[Index+3]);\r
- }\r
-\r
- for (; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) {\r
- Sum = (UINT8)(Sum + Ptr[Index]);\r
- }\r
- \r
- //\r
- // State field (since this indicates the different state of file). \r
+ CopyMem (&TestFileHeader, FileHeader, sizeof (EFI_FFS_FILE_HEADER));\r
//\r
- Sum = (UINT8)(Sum - FileHeader->State);\r
+ // Ingore State and File field in FFS header.\r
//\r
- // Checksum field of the file is not part of the header checksum.\r
- //\r
- Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);\r
+ TestFileHeader.State = 0;\r
+ TestFileHeader.IntegrityCheck.Checksum.File = 0;\r
\r
- return Sum;\r
+ return CalculateSum8 ((CONST UINT8 *) &TestFileHeader, sizeof (EFI_FFS_FILE_HEADER));\r
}\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 FV\r
-\r
- @return EDES_TODO: Add description for return value\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
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
- return FALSE;\r
+ return NULL;\r
}\r
\r
/**\r
- Given the input file pointer, search for the next matching file in the\r
+ Given the input file pointer, search for the first 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
+ If SearchType is EFI_FV_FILETYPE_ALL, the first FFS file will return without check its file type.\r
+ If SearchType is PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, \r
+ the first PEIM, or COMBINED PEIM or FV file type FFS file will return. \r
\r
@param FvHandle Pointer to the FV header of the volume to search\r
@param FileName File name\r
\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
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
EFI_FFS_FILE_HEADER **FileHeader;\r
EFI_FFS_FILE_HEADER *FfsFileHeader;\r
- EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;\r
UINT32 FileLength;\r
UINT32 FileOccupiedSize;\r
UINT32 FileOffset;\r
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
- if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {\r
+ if ((FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) != 0) {\r
ErasePolarity = 1;\r
} else {\r
ErasePolarity = 0;\r
//\r
if ((*FileHeader == NULL) || (FileName != NULL)) {\r
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);\r
- if (FwVolHeader->ExtHeaderOffset != 0) {\r
- FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)(((UINT8 *)FwVolHeader) + FwVolHeader->ExtHeaderOffset);\r
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)(((UINT8 *)FwVolExHeaderInfo) + FwVolExHeaderInfo->ExtHeaderSize);\r
- }\r
} else {\r
//\r
// Length is 24 bits wide so mask upper 8 bits\r
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
-\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
+ // Update internal PEI_CORE_FV array.\r
+ //\r
+ PrivateData->Fv[PrivateData->FvCount].FvHeader = BfvHeader;\r
+ PrivateData->Fv[PrivateData->FvCount].FvPpi = FvPpi;\r
+ PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;\r
+ DEBUG ((\r
+ EFI_D_INFO, \r
+ "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n", \r
+ (UINT32) PrivateData->FvCount, \r
+ (VOID *) BfvHeader, \r
+ BfvHeader->FvLength,\r
+ FvHandle\r
+ )); \r
+ PrivateData->FvCount ++;\r
+ \r
//\r
// Post a call-back for the FvInfoPPI services to expose\r
// additional Fvs to PeiCore.\r
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
+ And search the inside FV image, if found, the new FV INFO PPI will be installed.\r
\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
+ @param NotifyDescriptor Address of the notification descriptor data structure.\r
+ @param Ppi Address of the PPI that was installed.\r
\r
- @param PeiServices - General purpose services available to every PEIM.\r
- @param NotifyDescriptor EDES_TODO: Add parameter description\r
- @param Ppi EDES_TODO: Add parameter description\r
-\r
- @retval EFI_SUCCESS if the interface could be successfully installed\r
+ @retval EFI_SUCCESS The FV Info is registered into PeiCore private data structure.\r
+ @return if not EFI_SUCESS, fail to verify FV.\r
\r
**/\r
EFI_STATUS\r
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_STATUS Status;\r
+ EFI_PEI_FV_HANDLE FvHandle;\r
+ UINTN FvIndex;\r
EFI_PEI_FILE_HANDLE FileHandle;\r
VOID *DepexData;\r
- UINT32 AuthenticationStatus;\r
- EFI_STATUS Status;\r
\r
- FileHandle = NULL;\r
- DepexData = NULL;\r
Status = EFI_SUCCESS;\r
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
\r
if (PrivateData->FvCount >= FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
+ DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, FixedPcdGet32 (PcdPeiCoreMaxFvSupported)));\r
+ DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC"));\r
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
+ // Locate the corresponding FV_PPI according to founded FV's format guid\r
+ //\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!\n"));\r
+ return Status;\r
+ }\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
+ //\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!\n", FvInfoPpi->FvInfo));\r
return EFI_SUCCESS;\r
}\r
}\r
- PrivateData->Fv[PrivateData->FvCount++].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Fv->FvInfo;\r
\r
//\r
- // Only add FileSystem2 Fv to the All list\r
+ // Update internal PEI_CORE_FV array.\r
//\r
- PrivateData->AllFv[PrivateData->AllFvCount++] = (EFI_PEI_FV_HANDLE)Fv->FvInfo;\r
- \r
- DEBUG ((EFI_D_INFO, "The %dth FvImage start address is 0x%10p and size is 0x%08x\n", PrivateData->AllFvCount, (VOID *) Fv->FvInfo, Fv->FvInfoSize));\r
+ PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) FvInfoPpi->FvInfo;\r
+ PrivateData->Fv[PrivateData->FvCount].FvPpi = FvPpi;\r
+ PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;\r
+ DEBUG ((\r
+ EFI_D_INFO, \r
+ "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n", \r
+ (UINT32) PrivateData->FvCount, \r
+ (VOID *) FvInfoPpi->FvInfo, \r
+ FvInfoPpi->FvInfoSize,\r
+ FvHandle\r
+ )); \r
+ PrivateData->FvCount ++;\r
+\r
//\r
- // Preprocess all FV type files in this new FileSystem2 Fv image\r
+ // Scan and process the new discoveried FV for EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE \r
//\r
+ FileHandle = NULL;\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
+ Status = FvPpi->FindFileByType (\r
+ FvPpi,\r
+ EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,\r
+ FvHandle,\r
+ &FileHandle\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
+ Status = FvPpi->FindSectionByType (\r
+ FvPpi,\r
+ EFI_SECTION_PEI_DEPEX,\r
+ FileHandle,\r
+ (VOID**)&DepexData\r
+ );\r
if (!EFI_ERROR (Status)) {\r
if (!PeimDispatchReadiness (PeiServices, DepexData)) {\r
//\r
continue;\r
}\r
}\r
- //\r
- // Process FvFile to install FvInfo ppi and build FvHob\r
- // \r
- ProcessFvFile (PeiServices, FileHandle, &AuthenticationStatus);\r
+ \r
+ DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, PrivateData->FvCount - 1, FvHandle));\r
+ ProcessFvFile (&PrivateData->Fv[PrivateData->FvCount - 1], FileHandle);\r
}\r
} while (FileHandle != NULL);\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
+ AddUnknownFormatFvInfo (PrivateData, &FvInfoPpi->FvFormat, FvInfoPpi->FvInfo, FvInfoPpi->FvInfoSize);\r
}\r
-\r
+ \r
return EFI_SUCCESS;\r
}\r
\r
/**\r
+ Go through the file to search SectionType section. \r
+ 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
+ NULL if section not found\r
\r
- Go through the file to search SectionType section,\r
- when meeting an encapsuled section.\r
-\r
-\r
- @param PeiServices - General purpose services available to every PEIM.\r
- SearchType - Filter to find only section of this type.\r
- @param SectionType EDES_TODO: Add parameter description\r
- @param Section - From where to search.\r
- @param SectionSize - The file size to search.\r
- @param OutputBuffer - Pointer to the section to search.\r
-\r
- @return EFI_STATUS\r
+ @return EFI_NOT_FOUND The match section is not found.\r
+ @return EFI_SUCCESS The match section is found.\r
\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
//\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
);\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
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
\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
-\r
- @param PeiServices Pointer to the PEI Core Services Table.\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 FileHandle Pointer to the current file to search.\r
- @param SectionData Pointer to the Section matching SectionType in FfsFileHeader.\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 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
+ Searches for the next matching file in the firmware volume.\r
\r
-\r
- @param PeiServices Pointer to the PEI Core Services Table.\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 FvHandle 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
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
+ //\r
+ // To make backward compatiblity, if can not find corresponding the handle of FV\r
+ // then treat FV as build-in FFS2 format and memory mapped FV that FV handle is pointed\r
+ // to the address of first byte of FV.\r
+ //\r
+ if ((CoreFvHandle == NULL) && FeaturePcdGet (PcdFrameworkCompatibilitySupport)) {\r
+ return FindFileEx (FvHandle, NULL, SearchType, FileHandle, NULL);\r
+ } \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
/**\r
- search the firmware volumes by index\r
+ Search the firmware volumes by index\r
\r
- @param PeiServices The PEI core services table.\r
- @param Instance Instance of FV to find\r
- @param VolumeHandle 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
- IN CONST EFI_PEI_SERVICES **PeiServices,\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
-\r
- Private = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
+ PEI_CORE_INSTANCE *Private;\r
+ PEI_CORE_FV_HANDLE *CoreFvHandle;\r
+ \r
if (VolumeHandle == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- } \r
-\r
- if (Instance >= Private->AllFvCount) {\r
- VolumeHandle = NULL;\r
- return EFI_NOT_FOUND;\r
+ return EFI_INVALID_PARAMETER;\r
}\r
-\r
- *VolumeHandle = Private->AllFv[Instance];\r
+ \r
+ Private = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
+ \r
+ CoreFvHandle = FindNextCoreFvHandle (Private, Instance);\r
+ if (CoreFvHandle == NULL) {\r
+ *VolumeHandle = NULL;\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ \r
+ *VolumeHandle = CoreFvHandle->FvHandle;\r
+ \r
return EFI_SUCCESS;\r
}\r
\r
\r
/**\r
+ Find a file within a volume by its name.\r
\r
- Given the input VolumeHandle, search for the next matching name file.\r
+ @param FileName A pointer to the name of the file to find within the firmware volume.\r
+ @param VolumeHandle The firmware volume to search\r
+ @param FileHandle Upon exit, points to the found file's handle \r
+ or NULL if it could not be found.\r
\r
-\r
- @param FileName - File name to search.\r
- @param VolumeHandle - The current FV to search.\r
- @param FileHandle - Pointer to the file matching name in VolumeHandle.\r
- - NULL if file not found\r
-\r
- @return EFI_STATUS\r
+ @retval EFI_SUCCESS File was found.\r
+ @retval EFI_NOT_FOUND File was not found.\r
+ @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or FileName was NULL.\r
\r
**/\r
EFI_STATUS\r
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
IN EFI_PEI_FILE_HANDLE FileHandle,\r
OUT EFI_FV_FILE_INFO *FileInfo\r
)\r
+{\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) || (CoreFvHandle->FvPpi == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi, FileHandle, FileInfo);\r
+}\r
+\r
+\r
+/**\r
+ Returns information about the specified volume.\r
+\r
+ This function returns information about a specific firmware\r
+ volume, including its name, type, attributes, starting address\r
+ and size.\r
+\r
+ @param VolumeHandle Handle of the volume.\r
+ @param VolumeInfo Upon exit, points to the volume's information.\r
+\r
+ @retval EFI_SUCCESS Volume information returned.\r
+ @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.\r
+ @retval EFI_INVALID_PARAMETER If VolumeHandle is NULL.\r
+ @retval EFI_SUCCESS Information successfully returned.\r
+ @retval EFI_INVALID_PARAMETER The volume designated by the VolumeHandle is not available.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+PeiFfsGetVolumeInfo (\r
+ IN EFI_PEI_FV_HANDLE VolumeHandle,\r
+ OUT EFI_FV_INFO *VolumeInfo\r
+ )\r
+{\r
+ PEI_CORE_FV_HANDLE *CoreHandle;\r
+ \r
+ if ((VolumeInfo == NULL) || (VolumeHandle == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ \r
+ CoreHandle = FvHandleToCoreHandle (VolumeHandle);\r
+ \r
+ if ((CoreHandle == NULL) || (CoreHandle->FvPpi == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\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 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
+ 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
+ UINT64 FvLength;\r
+ \r
+ //\r
+ // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already\r
+ // been extracted.\r
+ //\r
+ HobPtr.Raw = GetHobList ();\r
+ while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobPtr.Raw)) != NULL) {\r
+ if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)ParentFvFileHandle)->Name), &HobPtr.FirmwareVolume2->FileName)) {\r
+ //\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 = 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
+ // FvAlignment must be more than 8 bytes required by FvHeader structure.\r
+ //\r
+ FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);\r
+ if (FvAlignment < 8) {\r
+ FvAlignment = 8;\r
+ }\r
+ \r
+ //\r
+ // Check FvImage\r
+ //\r
+ if ((UINTN) FvHeader % FvAlignment != 0) {\r
+ FvLength = ReadUnaligned64 (&FvHeader->FvLength);\r
+ NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvLength), FvAlignment);\r
+ if (NewFvBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);\r
+ FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;\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
+ &FvHeader->FileSystemGuid,\r
+ (VOID**) FvHeader,\r
+ (UINT32) FvHeader->FvLength,\r
+ &ParentFvImageInfo.FvName,\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) FvHeader,\r
+ FvHeader->FvLength\r
+ );\r
+\r
+ //\r
+ // Makes the encapsulated volume show up in DXE phase to skip processing of\r
+ // encapsulated file again.\r
+ //\r
+ BuildFv2Hob (\r
+ (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,\r
+ FvHeader->FvLength,\r
+ &ParentFvImageInfo.FvName,\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
+ \r
+ ASSERT (FvHandle != NULL);\r
+ \r
+ if (Buffer == NULL) {\r
+ return EFI_VOLUME_CORRUPTED;\r
+ }\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
+ 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
+ break;\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
- 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) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- if (((EFI_FIRMWARE_VOLUME_HEADER*)VolumeHandle)->Attributes & EFI_FVB2_ERASE_POLARITY) {\r
+ if ((CoreFvHandle->FvHeader->Attributes & EFI_FVB2_ERASE_POLARITY) != 0) {\r
ErasePolarity = 1;\r
} else {\r
ErasePolarity = 0;\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
+ 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
- Collect information of given Fv Volume.\r
-\r
- @param VolumeHandle - The handle to Fv Volume.\r
- @param VolumeInfo - The pointer to volume information.\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
- @retval EFI_INVALID_PARAMETER VolumeInfo is NULL\r
- @retval EFI_SUCCESS Success to collect fv info.\r
-**/\r
+**/ \r
EFI_STATUS\r
-EFIAPI \r
-PeiFfsGetVolumeInfo (\r
- IN EFI_PEI_FV_HANDLE VolumeHandle,\r
- OUT EFI_FV_INFO *VolumeInfo\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
+ if ((VolumeInfo == NULL) || (FvHandle == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\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
+ 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
- VolumeInfo->FvAttributes = FwVolHeader.Attributes;\r
- VolumeInfo->FvStart = (VOID *) VolumeHandle;\r
- VolumeInfo->FvSize = FwVolHeader.FvLength;\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 *)VolumeHandle) + FwVolHeader.ExtHeaderOffset);\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
+ //\r
+ // Search whether FvHob has been installed into PeiCore's FV database.\r
+ // If found, no need install new FvInfoPpi for it.\r
+ //\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
+ //\r
+ // Search whether FvHob has been cached into PeiCore's Unknown FV database.\r
+ // If found, no need install new FvInfoPpi for it.\r
+ //\r
+ if (!Match) {\r
+ for (Index = 0; Index < Private->UnknownFvInfoCount; Index ++) {\r
+ if ((UINTN)FvHob->BaseAddress == (UINTN)Private->UnknownFvInfo[Index].FvInfo) {\r
+ Match = TRUE;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // If the Fv in FvHob has not been installed into PeiCore's FV database and has\r
+ // not been cached into PeiCore's Unknown FV database, install a new FvInfoPpi\r
+ // for it then PeiCore will dispatch it in callback of FvInfoPpi.\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
+ \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
+\r
+/**\r
+ After PeiCore image is shadowed into permanent memory, all build-in FvPpi should\r
+ be re-installed with the instance in permanent memory and all cached FvPpi pointers in \r
+ PrivateData->Fv[] array should be fixed up to be pointed to the one in permenant\r
+ memory.\r
+ \r
+ @param PrivateData Pointer to PEI_CORE_INSTANCE.\r
+**/ \r
+VOID\r
+PeiReinitializeFv (\r
+ IN PEI_CORE_INSTANCE *PrivateData\r
+ )\r
+{\r
+ VOID *OldFfs2FvPpi;\r
+ EFI_PEI_PPI_DESCRIPTOR *OldDescriptor;\r
+ UINTN Index;\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Locate old build-in Ffs2 EFI_PEI_FIRMWARE_VOLUME_PPI which\r
+ // in flash.\r
+ //\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiFirmwareFileSystem2Guid,\r
+ 0,\r
+ &OldDescriptor,\r
+ &OldFfs2FvPpi\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Re-install the EFI_PEI_FIRMWARE_VOLUME_PPI for build-in Ffs2\r
+ // which is shadowed from flash to permanent memory within PeiCore image.\r
+ //\r
+ Status = PeiServicesReInstallPpi (OldDescriptor, &mPeiFfs2FvPpiList);\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ //\r
+ // Fixup all FvPpi pointers for the implementation in flash to permanent memory.\r
+ //\r
+ for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
+ if (PrivateData->Fv[Index].FvPpi == OldFfs2FvPpi) {\r
+ PrivateData->Fv[Index].FvPpi = &mPeiFfs2FvPpi;\r
+ }\r
+ }\r
+} \r
+\r
+/**\r
+ Report the information for a new discoveried FV in unknown third-party format.\r
+ \r
+ If the EFI_PEI_FIRMWARE_VOLUME_PPI has not been installed for third-party FV format, but\r
+ the FV in this format has been discoveried, then this FV's information will be cached into \r
+ PEI_CORE_INSTANCE's UnknownFvInfo array.\r
+ Also a notification would be installed for unknown third-party FV format guid, if EFI_PEI_FIRMWARE_VOLUME_PPI\r
+ is installed later by platform's PEIM, the original unknown third-party FV will be processed by\r
+ using new installed EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+ \r
+ @param PrivateData Point to instance of PEI_CORE_INSTANCE\r
+ @param Format Point to the unknown third-party format guid.\r
+ @param FvInfo Point to FvInfo buffer.\r
+ @param FvInfoSize The size of FvInfo buffer.\r
+ \r
+ @retval EFI_OUT_OF_RESOURCES The FV info array in PEI_CORE_INSTANCE has no more spaces.\r
+ @retval EFI_SUCCESS Success to add the information for unknown FV.\r
+**/\r
+EFI_STATUS\r
+AddUnknownFormatFvInfo (\r
+ IN PEI_CORE_INSTANCE *PrivateData,\r
+ IN EFI_GUID *Format,\r
+ IN VOID *FvInfo,\r
+ IN UINT32 FvInfoSize\r
+ )\r
+{\r
+ PEI_CORE_UNKNOW_FORMAT_FV_INFO *NewUnknownFv;\r
+ \r
+ if (PrivateData->UnknownFvInfoCount + 1 >= FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ \r
+ NewUnknownFv = &PrivateData->UnknownFvInfo[PrivateData->UnknownFvInfoCount];\r
+ PrivateData->UnknownFvInfoCount ++;\r
+ \r
+ CopyGuid (&NewUnknownFv->FvFormat, Format);\r
+ NewUnknownFv->FvInfo = FvInfo;\r
+ NewUnknownFv->FvInfoSize = FvInfoSize;\r
+ NewUnknownFv->NotifyDescriptor.Flags = (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);\r
+ NewUnknownFv->NotifyDescriptor.Guid = &NewUnknownFv->FvFormat;\r
+ NewUnknownFv->NotifyDescriptor.Notify = ThirdPartyFvPpiNotifyCallback;\r
+ \r
+ PeiServicesNotifyPpi (&NewUnknownFv->NotifyDescriptor);\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Find the FV information according to third-party FV format guid.\r
+ \r
+ This routine also will remove the FV information found by given FV format guid from\r
+ PrivateData->UnknownFvInfo[].\r
+ \r
+ @param PrivateData Point to instance of PEI_CORE_INSTANCE\r
+ @param Format Point to given FV format guid\r
+ @param FvInfo On return, the pointer of FV information buffer\r
+ @param FvInfoSize On return, the size of FV information buffer.\r
+ \r
+ @retval EFI_NOT_FOUND The FV is not found for new installed EFI_PEI_FIRMWARE_VOLUME_PPI\r
+ @retval EFI_SUCCESS Success to find a FV which could be processed by new installed EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+**/\r
+EFI_STATUS\r
+FindUnknownFormatFvInfo (\r
+ IN PEI_CORE_INSTANCE *PrivateData,\r
+ IN EFI_GUID *Format,\r
+ OUT VOID **FvInfo,\r
+ OUT UINT32 *FvInfoSize\r
+ )\r
+{\r
+ UINTN Index;\r
+ UINTN Index2;\r
+\r
+ Index = 0;\r
+ for (; Index < PrivateData->UnknownFvInfoCount; Index ++) {\r
+ if (CompareGuid (Format, &PrivateData->UnknownFvInfo[Index].FvFormat)) {\r
+ break;\r
+ }\r
+ }\r
+ \r
+ if (Index == PrivateData->UnknownFvInfoCount) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ \r
+ *FvInfo = PrivateData->UnknownFvInfo[Index].FvInfo;\r
+ *FvInfoSize = PrivateData->UnknownFvInfo[Index].FvInfoSize;\r
+ \r
+ //\r
+ // Remove an entry from UnknownFvInfo array.\r
+ //\r
+ Index2 = Index + 1;\r
+ for (;Index2 < PrivateData->UnknownFvInfoCount; Index2 ++, Index ++) {\r
+ CopyMem (&PrivateData->UnknownFvInfo[Index], &PrivateData->UnknownFvInfo[Index2], sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO));\r
+ }\r
+ PrivateData->UnknownFvInfoCount --;\r
+ return EFI_SUCCESS;\r
+} \r
+\r
+/**\r
+ Notification callback function for EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+ \r
+ When a EFI_PEI_FIRMWARE_VOLUME_PPI is installed to support new FV format, this \r
+ routine is called to process all discoveried FVs in this format.\r
+ \r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
+ @param NotifyDescriptor Address of the notification descriptor data structure.\r
+ @param Ppi Address of the PPI that was installed.\r
+ \r
+ @retval EFI_SUCCESS The notification callback is processed correctly.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ThirdPartyFvPpiNotifyCallback (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
+ IN VOID *Ppi\r
+ )\r
+{\r
+ PEI_CORE_INSTANCE *PrivateData;\r
+ EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;\r
+ VOID *FvInfo;\r
+ UINT32 FvInfoSize;\r
+ EFI_STATUS Status;\r
+ EFI_PEI_FV_HANDLE FvHandle;\r
+ BOOLEAN IsProcessed;\r
+ UINTN FvIndex;\r
+ EFI_PEI_FILE_HANDLE FileHandle;\r
+ VOID *DepexData; \r
+ \r
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
+ FvPpi = (EFI_PEI_FIRMWARE_VOLUME_PPI*) Ppi;\r
+ \r
+ do {\r
+ Status = FindUnknownFormatFvInfo (PrivateData, NotifyDescriptor->Guid, &FvInfo, &FvInfoSize);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_SUCCESS;\r
+ }\r
+ \r
+ //\r
+ // Process new found FV and get FV handle.\r
+ //\r
+ Status = FvPpi->ProcessVolume (FvPpi, FvInfo, FvInfoSize, &FvHandle);\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "Fail to process the FV 0x%p, FV may be corrupted!\n", FvInfo));\r
+ continue;\r
+ }\r
+\r
+ //\r
+ // Check whether the FV has already been processed.\r
+ //\r
+ IsProcessed = FALSE;\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", FvInfo));\r
+ IsProcessed = TRUE;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ if (IsProcessed) {\r
+ continue;\r
+ }\r
+ \r
+ //\r
+ // Update internal PEI_CORE_FV array.\r
+ //\r
+ PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) FvInfo;\r
+ PrivateData->Fv[PrivateData->FvCount].FvPpi = FvPpi;\r
+ PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;\r
+ DEBUG ((\r
+ EFI_D_INFO, \r
+ "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n", \r
+ (UINT32) PrivateData->FvCount, \r
+ (VOID *) FvInfo, \r
+ FvInfoSize,\r
+ FvHandle\r
+ )); \r
+ PrivateData->FvCount ++;\r
+\r
+ //\r
+ // Scan and process the new discoveried FV for EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE \r
+ //\r
+ FileHandle = NULL;\r
+ do {\r
+ Status = FvPpi->FindFileByType (\r
+ FvPpi,\r
+ EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,\r
+ FvHandle,\r
+ &FileHandle\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = FvPpi->FindSectionByType (\r
+ FvPpi,\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\n", FileHandle, PrivateData->FvCount - 1, FvHandle));\r
+ ProcessFvFile (&PrivateData->Fv[PrivateData->FvCount - 1], FileHandle);\r
+ }\r
+ } while (FileHandle != NULL);\r
+ } while (TRUE);\r
+}\r