TianoCore EDK2 master
Loading...
Searching...
No Matches
FwVol.c File Reference
#include "FwVol.h"

Go to the source code of this file.

Functions

EFI_FV_FILE_ATTRIBUTES FfsAttributes2FvFileAttributes (IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes)
 
EFI_FFS_FILE_STATE GetFileState (IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader)
 
UINT8 CalculateHeaderChecksum (IN EFI_FFS_FILE_HEADER *FileHeader)
 
PEI_CORE_FV_HANDLEFileHandleToVolume (IN EFI_PEI_FILE_HANDLE FileHandle)
 
EFI_STATUS FindFileEx (IN CONST EFI_PEI_FV_HANDLE FvHandle, IN CONST EFI_GUID *FileName OPTIONAL, IN EFI_FV_FILETYPE SearchType, IN OUT EFI_PEI_FILE_HANDLE *FileHandle, IN OUT EFI_PEI_FILE_HANDLE *AprioriFile OPTIONAL)
 
EFI_GUIDGetFvName (IN CONST EFI_FIRMWARE_VOLUME_HEADER *FvHeader)
 
VOID PeiInitializeFv (IN PEI_CORE_INSTANCE *PrivateData, IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData)
 
EFI_STATUS EFIAPI FirmwareVolumeInfoPpiNotifyCallback (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
 
BOOLEAN VerifyGuidedSectionGuid (IN EFI_GUID *GuidedSectionGuid, OUT EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI **GuidedSectionExtraction)
 
EFI_STATUS ProcessSection (IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_SECTION_TYPE SectionType, IN OUT UINTN *SectionInstance, IN EFI_COMMON_SECTION_HEADER *Section, IN UINTN SectionSize, OUT VOID **OutputBuffer, OUT UINT32 *AuthenticationStatus, IN BOOLEAN IsFfs3Fv)
 
EFI_STATUS EFIAPI PeiFfsFindSectionData (IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_SECTION_TYPE SectionType, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData)
 
EFI_STATUS EFIAPI PeiFfsFindSectionData3 (IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData, OUT UINT32 *AuthenticationStatus)
 
EFI_STATUS EFIAPI PeiFfsFindNextFile (IN CONST EFI_PEI_SERVICES **PeiServices, IN UINT8 SearchType, IN EFI_PEI_FV_HANDLE FvHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle)
 
EFI_STATUS EFIAPI PeiFfsFindNextVolume (IN CONST EFI_PEI_SERVICES **PeiServices, IN UINTN Instance, IN OUT EFI_PEI_FV_HANDLE *VolumeHandle)
 
EFI_STATUS EFIAPI PeiFfsFindFileByName (IN CONST EFI_GUID *FileName, IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
 
EFI_STATUS EFIAPI PeiFfsGetFileInfo (IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO *FileInfo)
 
EFI_STATUS EFIAPI PeiFfsGetFileInfo2 (IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO2 *FileInfo)
 
EFI_STATUS EFIAPI PeiFfsGetVolumeInfo (IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_FV_INFO *VolumeInfo)
 
BOOLEAN GetFvUsedSize (IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader, OUT UINT32 *FvUsedSize, OUT UINT8 *EraseByte)
 
EFI_STATUS ProcessFvFile (IN PEI_CORE_INSTANCE *PrivateData, IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle, IN EFI_PEI_FILE_HANDLE ParentFvFileHandle)
 
EFI_STATUS EFIAPI PeiFfsFvPpiProcessVolume (IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN VOID *Buffer, IN UINTN BufferSize, OUT EFI_PEI_FV_HANDLE *FvHandle)
 
EFI_STATUS EFIAPI PeiFfsFvPpiFindFileByType (IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_FV_FILETYPE SearchType, IN EFI_PEI_FV_HANDLE FvHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle)
 
EFI_STATUS EFIAPI PeiFfsFvPpiFindFileByName (IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN CONST EFI_GUID *FileName, IN EFI_PEI_FV_HANDLE *FvHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
 
EFI_STATUS EFIAPI PeiFfsFvPpiGetFileInfo (IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO *FileInfo)
 
EFI_STATUS EFIAPI PeiFfsFvPpiGetFileInfo2 (IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO2 *FileInfo)
 
EFI_STATUS EFIAPI PeiFfsFvPpiGetVolumeInfo (IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_PEI_FV_HANDLE FvHandle, OUT EFI_FV_INFO *VolumeInfo)
 
EFI_STATUS EFIAPI PeiFfsFvPpiFindSectionByType (IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_SECTION_TYPE SearchType, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData)
 
EFI_STATUS EFIAPI PeiFfsFvPpiFindSectionByType2 (IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_SECTION_TYPE SearchType, IN UINTN SearchInstance, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData, OUT UINT32 *AuthenticationStatus)
 
PEI_CORE_FV_HANDLEFvHandleToCoreHandle (IN EFI_PEI_FV_HANDLE FvHandle)
 
PEI_CORE_FV_HANDLEFindNextCoreFvHandle (IN PEI_CORE_INSTANCE *Private, IN UINTN Instance)
 
VOID PeiReinitializeFv (IN PEI_CORE_INSTANCE *PrivateData)
 
EFI_STATUS AddUnknownFormatFvInfo (IN PEI_CORE_INSTANCE *PrivateData, IN EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *FvInfo2Ppi)
 
EFI_STATUS FindUnknownFormatFvInfo (IN PEI_CORE_INSTANCE *PrivateData, IN EFI_GUID *Format, OUT VOID **FvInfo, OUT UINT32 *FvInfoSize, OUT UINT32 *AuthenticationStatus)
 
EFI_STATUS EFIAPI ThirdPartyFvPpiNotifyCallback (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
 

Variables

EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList []
 
PEI_FW_VOL_INSTANCE mPeiFfs2FwVol
 
PEI_FW_VOL_INSTANCE mPeiFfs3FwVol
 
EFI_PEI_PPI_DESCRIPTOR mPeiFfs2FvPpiList
 
EFI_PEI_PPI_DESCRIPTOR mPeiFfs3FvPpiList
 
UINT8 mFvAttributes [] = { 0, 4, 7, 9, 10, 12, 15, 16 }
 
UINT8 mFvAttributes2 [] = { 17, 18, 19, 20, 21, 22, 23, 24 }
 

Detailed Description

Pei Core Firmware File System service routines.

Copyright (c) 2015 HP Development Company, L.P. Copyright (c) 2006 - 2025, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file FwVol.c.

Function Documentation

◆ AddUnknownFormatFvInfo()

EFI_STATUS AddUnknownFormatFvInfo ( IN PEI_CORE_INSTANCE PrivateData,
IN EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI FvInfo2Ppi 
)

Report the information for a newly discovered FV in an unknown format.

If the EFI_PEI_FIRMWARE_VOLUME_PPI has not been installed for a third-party FV format, but the FV has been discovered, then the information of this FV will be cached into PEI_CORE_INSTANCE's UnknownFvInfo array.

Also a notification would be installed for unknown FV format GUID, if EFI_PEI_FIRMWARE_VOLUME_PPI is installed later by platform's PEIM, the original unknown FV will be processed by using new installed EFI_PEI_FIRMWARE_VOLUME_PPI.

Parameters
PrivateDataPoint to instance of PEI_CORE_INSTANCE
FvInfo2PpiPoint to FvInfo2 PPI.
Return values
EFI_OUT_OF_RESOURCESThe FV info array in PEI_CORE_INSTANCE has no more spaces.
EFI_SUCCESSSuccess to add the information for unknown FV.

Definition at line 2273 of file FwVol.c.

◆ CalculateHeaderChecksum()

UINT8 CalculateHeaderChecksum ( IN EFI_FFS_FILE_HEADER FileHeader)

Calculates the checksum of the header of a file.

Parameters
FileHeaderPointer to FFS File Header.
Returns
Checksum of the header. Zero means the header is good. Non-zero means the header is bad.

Definition at line 172 of file FwVol.c.

◆ FfsAttributes2FvFileAttributes()

EFI_FV_FILE_ATTRIBUTES FfsAttributes2FvFileAttributes ( IN EFI_FFS_FILE_ATTRIBUTES  FfsAttributes)

Convert the FFS File Attributes to FV File Attributes

Parameters
FfsAttributesThe attributes of UINT8 type.
Returns
The attributes of EFI_FV_FILE_ATTRIBUTES

Definition at line 103 of file FwVol.c.

◆ FileHandleToVolume()

PEI_CORE_FV_HANDLE * FileHandleToVolume ( IN EFI_PEI_FILE_HANDLE  FileHandle)

Find FV handler according to FileHandle in that FV.

Parameters
FileHandleHandle of file image
Returns
Pointer to instance of PEI_CORE_FV_HANDLE.

Definition at line 207 of file FwVol.c.

◆ FindFileEx()

EFI_STATUS FindFileEx ( IN CONST EFI_PEI_FV_HANDLE  FvHandle,
IN CONST EFI_GUID *FileName  OPTIONAL,
IN EFI_FV_FILETYPE  SearchType,
IN OUT EFI_PEI_FILE_HANDLE FileHandle,
IN OUT EFI_PEI_FILE_HANDLE *AprioriFile  OPTIONAL 
)

Given the input file pointer, search for the first matching file in the FFS volume as defined by SearchType. The search starts from FileHeader inside the Firmware Volume defined by FwVolHeader. If SearchType is EFI_FV_FILETYPE_ALL, the first FFS file will return without check its file type. If SearchType is PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, the first PEIM, or COMBINED PEIM or FV file type FFS file will return.

Parameters
FvHandlePointer to the FV header of the volume to search
FileNameFile name
SearchTypeFilter to find only files of this type. Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
FileHandleThis parameter must point to a valid FFS volume.
AprioriFilePointer to AprioriFile image in this FV if has
Returns
EFI_NOT_FOUND No files matching the search criteria were found
Return values
EFI_SUCCESSSuccess to search given file

Definition at line 266 of file FwVol.c.

◆ FindNextCoreFvHandle()

PEI_CORE_FV_HANDLE * FindNextCoreFvHandle ( IN PEI_CORE_INSTANCE Private,
IN UINTN  Instance 
)

Gets a PEI_CORE_FV_HANDLE instance for the next volume according to the given index.

This routine also will install an instance of the FvInfo PPI for the FV HOB as defined in the PI specification.

Parameters
PrivatePointer of PEI_CORE_INSTANCE
InstanceIndex of the FV to search
Returns
Instance of PEI_CORE_FV_HANDLE.

Definition at line 2168 of file FwVol.c.

◆ FindUnknownFormatFvInfo()

EFI_STATUS FindUnknownFormatFvInfo ( IN PEI_CORE_INSTANCE PrivateData,
IN EFI_GUID Format,
OUT VOID **  FvInfo,
OUT UINT32 *  FvInfoSize,
OUT UINT32 *  AuthenticationStatus 
)

Find the FV information according to third-party FV format GUID.

This routine also will remove the FV information found by given FV format GUID from PrivateData->UnknownFvInfo[].

Parameters
PrivateDataPoint to instance of PEI_CORE_INSTANCE
FormatPoint to given FV format GUID
FvInfoOn return, the pointer of FV information buffer
FvInfoSizeOn return, the size of FV information buffer.
AuthenticationStatusOn return, the authentication status of FV information buffer.
Return values
EFI_NOT_FOUNDThe FV is not found for new installed EFI_PEI_FIRMWARE_VOLUME_PPI
EFI_SUCCESSSuccess to find a FV which could be processed by new installed EFI_PEI_FIRMWARE_VOLUME_PPI.

Definition at line 2329 of file FwVol.c.

◆ FirmwareVolumeInfoPpiNotifyCallback()

EFI_STATUS EFIAPI FirmwareVolumeInfoPpiNotifyCallback ( IN EFI_PEI_SERVICES **  PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor,
IN VOID Ppi 
)

Process Firmware Volume Information once FvInfoPPI or FvInfo2PPI install. The FV Info will be registered into PeiCore private data structure. And search the inside FV image, if found, the new FV INFO(2) PPI will be installed.

Parameters
PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
NotifyDescriptorAddress of the notification descriptor data structure.
PpiAddress of the PPI that was installed.
Return values
EFI_SUCCESSThe FV Info is registered into PeiCore private data structure.
Returns
if not EFI_SUCCESS, fail to verify FV.

Measure and record the Firmware Volume Information once FvInfoPPI install.

Parameters
[in]PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in]NotifyDescriptorAddress of the notification descriptor data structure.
[in]PpiAddress of the PPI that was installed.
Return values
EFI_SUCCESSThe FV Info is measured and recorded to TPM.
Returns
Others Fail to measure FV.

Definition at line 577 of file FwVol.c.

◆ FvHandleToCoreHandle()

PEI_CORE_FV_HANDLE * FvHandleToCoreHandle ( IN EFI_PEI_FV_HANDLE  FvHandle)

Convert the handle of FV to pointer of corresponding PEI_CORE_FV_HANDLE.

Parameters
FvHandleThe handle of a FV.
Return values
NULLif can not find.
Returns
Pointer of corresponding PEI_CORE_FV_HANDLE.

Definition at line 2139 of file FwVol.c.

◆ GetFileState()

EFI_FFS_FILE_STATE GetFileState ( IN UINT8  ErasePolarity,
IN EFI_FFS_FILE_HEADER FfsHeader 
)

Returns the file state set by the highest zero bit in the State field

Parameters
ErasePolarityErase Polarity as defined by EFI_FVB2_ERASE_POLARITY in the Attributes field.
FfsHeaderPointer to FFS File Header.
Return values
EFI_FFS_FILE_STATEFile state is set by the highest none zero bit in the header State field.

Definition at line 137 of file FwVol.c.

◆ GetFvName()

EFI_GUID * GetFvName ( IN CONST EFI_FIRMWARE_VOLUME_HEADER FvHeader)

Return the pointer to the Firmware Volume GUID name in the FV header.

Parameters
[in]FvHeaderPointer to the header of the Firmware Volume.
Return values
Pointerto the Firmware Volume GUID name in the FV header. NULL if the FV is anonymous without an extended header.

Definition at line 467 of file FwVol.c.

◆ GetFvUsedSize()

BOOLEAN GetFvUsedSize ( IN EFI_FIRMWARE_VOLUME_HEADER FvHeader,
OUT UINT32 *  FvUsedSize,
OUT UINT8 *  EraseByte 
)

Find USED_SIZE FV_EXT_TYPE entry in FV extension header and get the FV used size.

Parameters
[in]FvHeaderPointer to FV header.
[out]FvUsedSizePointer to FV used size returned, only valid if USED_SIZE FV_EXT_TYPE entry is found.
[out]EraseBytePointer to erase byte returned, only valid if USED_SIZE FV_EXT_TYPE entry is found.
Return values
TRUEUSED_SIZE FV_EXT_TYPE entry is found, FV used size and erase byte are returned.
FALSENo USED_SIZE FV_EXT_TYPE entry found.

Definition at line 1367 of file FwVol.c.

◆ PeiFfsFindFileByName()

EFI_STATUS EFIAPI PeiFfsFindFileByName ( IN CONST EFI_GUID FileName,
IN EFI_PEI_FV_HANDLE  VolumeHandle,
OUT EFI_PEI_FILE_HANDLE FileHandle 
)

Find a file within a volume by its name.

Parameters
FileNameA pointer to the name of the file to find within the firmware volume.
VolumeHandleThe firmware volume to search
FileHandleUpon exit, points to the found file's handle or NULL if it could not be found.
Return values
EFI_SUCCESSFile was found.
EFI_NOT_FOUNDFile was not found.
EFI_INVALID_PARAMETERVolumeHandle or FileHandle or FileName was NULL.

Definition at line 1213 of file FwVol.c.

◆ PeiFfsFindNextFile()

EFI_STATUS EFIAPI PeiFfsFindNextFile ( IN CONST EFI_PEI_SERVICES **  PeiServices,
IN UINT8  SearchType,
IN EFI_PEI_FV_HANDLE  FvHandle,
IN OUT EFI_PEI_FILE_HANDLE FileHandle 
)

Searches for the next matching file in the firmware volume.

Parameters
PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
SearchTypeFilter to find only files of this type. Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
FvHandleHandle of firmware volume in which to search.
FileHandleOn entry, points to the current handle from which to begin searching or NULL to start at the beginning of the firmware volume. On exit, points the file handle of the next file in the volume or NULL if there are no more files.
Return values
EFI_NOT_FOUNDThe file was not found.
EFI_NOT_FOUNDThe header checksum was not zero.
EFI_SUCCESSThe file was found.

Definition at line 1139 of file FwVol.c.

◆ PeiFfsFindNextVolume()

EFI_STATUS EFIAPI PeiFfsFindNextVolume ( IN CONST EFI_PEI_SERVICES **  PeiServices,
IN UINTN  Instance,
IN OUT EFI_PEI_FV_HANDLE VolumeHandle 
)

Search the firmware volumes by index

Parameters
PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
InstanceThis instance of the firmware volume to find. The value 0 is the Boot Firmware Volume (BFV).
VolumeHandleOn exit, points to the next volume handle or NULL if it does not exist.
Return values
EFI_INVALID_PARAMETERVolumeHandle is NULL
EFI_NOT_FOUNDThe volume was not found.
EFI_SUCCESSThe volume was found.

Definition at line 1172 of file FwVol.c.

◆ PeiFfsFindSectionData()

EFI_STATUS EFIAPI PeiFfsFindSectionData ( IN CONST EFI_PEI_SERVICES **  PeiServices,
IN EFI_SECTION_TYPE  SectionType,
IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT VOID **  SectionData 
)

Searches for the next matching section within the specified file.

Parameters
PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
SectionTypeFilter to find only sections of this type.
FileHandlePointer to the current file to search.
SectionDataA pointer to the discovered section, if successful. NULL if section not found
Return values
EFI_NOT_FOUNDThe section was not found.
EFI_SUCCESSThe section was found.

Definition at line 1059 of file FwVol.c.

◆ PeiFfsFindSectionData3()

EFI_STATUS EFIAPI PeiFfsFindSectionData3 ( IN CONST EFI_PEI_SERVICES **  PeiServices,
IN EFI_SECTION_TYPE  SectionType,
IN UINTN  SectionInstance,
IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT VOID **  SectionData,
OUT UINT32 *  AuthenticationStatus 
)

Searches for the next matching section within the specified file.

Parameters
PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
SectionTypeThe value of the section type to find.
SectionInstanceSection instance to find.
FileHandleHandle of the firmware file to search.
SectionDataA pointer to the discovered section, if successful.
AuthenticationStatusA pointer to the authentication status for this section.
Return values
EFI_SUCCESSThe section was found.
EFI_NOT_FOUNDThe section was not found.

Definition at line 1092 of file FwVol.c.

◆ PeiFfsFvPpiFindFileByName()

EFI_STATUS EFIAPI PeiFfsFvPpiFindFileByName ( IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI This,
IN CONST EFI_GUID FileName,
IN EFI_PEI_FV_HANDLE FvHandle,
OUT EFI_PEI_FILE_HANDLE FileHandle 
)

Find a file within a volume by its name.

This service searches for files with a specific name, within either the specified firmware volume or all firmware volumes.

Parameters
ThisPoints to this instance of the EFI_PEI_FIRMWARE_VOLUME_PPI.
FileNameA pointer to the name of the file to find within the firmware volume.
FvHandleUpon entry, the pointer to the firmware volume to search or NULL if all firmware volumes should be searched. Upon exit, the actual firmware volume in which the file was found.
FileHandleUpon exit, points to the found file's handle or NULL if it could not be found.
Return values
EFI_SUCCESSFile was found.
EFI_NOT_FOUNDFile was not found.
EFI_INVALID_PARAMETERFvHandle or FileHandle or FileName was NULL.

Definition at line 1760 of file FwVol.c.

◆ PeiFfsFvPpiFindFileByType()

EFI_STATUS EFIAPI PeiFfsFvPpiFindFileByType ( IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI This,
IN EFI_FV_FILETYPE  SearchType,
IN EFI_PEI_FV_HANDLE  FvHandle,
IN OUT EFI_PEI_FILE_HANDLE FileHandle 
)

Finds the next file of the specified type.

This service enables PEI modules to discover additional firmware files. The FileHandle must be unique within the system.

Parameters
ThisPoints to this instance of the EFI_PEI_FIRMWARE_VOLUME_PPI.
SearchTypeA filter to find only files of this type. Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
FvHandleHandle of firmware volume in which to search.
FileHandlePoints to the current handle from which to begin searching or NULL to start at the beginning of the firmware volume. Updated upon return to reflect the file found.
Return values
EFI_SUCCESSThe file was found.
EFI_NOT_FOUNDThe file was not found. FileHandle contains NULL.

Definition at line 1723 of file FwVol.c.

◆ PeiFfsFvPpiFindSectionByType()

EFI_STATUS EFIAPI PeiFfsFvPpiFindSectionByType ( IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI This,
IN EFI_SECTION_TYPE  SearchType,
IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT VOID **  SectionData 
)

Find the next matching section in the firmware file.

This service enables PEI modules to discover sections of a given type within a valid file.

Parameters
ThisPoints to this instance of the EFI_PEI_FIRMWARE_VOLUME_PPI.
SearchTypeA filter to find only sections of this type.
FileHandleHandle of firmware file in which to search.
SectionDataUpdated upon return to point to the section found.
Return values
EFI_SUCCESSSection was found.
EFI_NOT_FOUNDSection of the specified type was not found. SectionData contains NULL.

Definition at line 2023 of file FwVol.c.

◆ PeiFfsFvPpiFindSectionByType2()

EFI_STATUS EFIAPI PeiFfsFvPpiFindSectionByType2 ( IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI This,
IN EFI_SECTION_TYPE  SearchType,
IN UINTN  SearchInstance,
IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT VOID **  SectionData,
OUT UINT32 *  AuthenticationStatus 
)

Find the next matching section in the firmware file.

This service enables PEI modules to discover sections of a given instance and type within a valid file.

Parameters
ThisPoints to this instance of the EFI_PEI_FIRMWARE_VOLUME_PPI.
SearchTypeA filter to find only sections of this type.
SearchInstanceA filter to find the specific instance of sections.
FileHandleHandle of firmware file in which to search.
SectionDataUpdated upon return to point to the section found.
AuthenticationStatusUpdated upon return to point to the authentication status for this section.
Return values
EFI_SUCCESSSection was found.
EFI_NOT_FOUNDSection of the specified type was not found. SectionData contains NULL.

Definition at line 2060 of file FwVol.c.

◆ PeiFfsFvPpiGetFileInfo()

EFI_STATUS EFIAPI PeiFfsFvPpiGetFileInfo ( IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI This,
IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT EFI_FV_FILE_INFO FileInfo 
)

Returns information about a specific file.

This function returns information about a specific file, including its file name, type, attributes, starting address and size.

Parameters
ThisPoints to this instance of the EFI_PEI_FIRMWARE_VOLUME_PPI.
FileHandleHandle of the file.
FileInfoUpon exit, points to the file's information.
Return values
EFI_SUCCESSFile information returned.
EFI_INVALID_PARAMETERIf FileHandle does not represent a valid file.
EFI_INVALID_PARAMETERIf FileInfo is NULL.

Definition at line 1825 of file FwVol.c.

◆ PeiFfsFvPpiGetFileInfo2()

EFI_STATUS EFIAPI PeiFfsFvPpiGetFileInfo2 ( IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI This,
IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT EFI_FV_FILE_INFO2 FileInfo 
)

Returns information about a specific file.

This function returns information about a specific file, including its file name, type, attributes, starting address, size and authentication status.

Parameters
ThisPoints to this instance of the EFI_PEI_FIRMWARE_VOLUME_PPI.
FileHandleHandle of the file.
FileInfoUpon exit, points to the file's information.
Return values
EFI_SUCCESSFile information returned.
EFI_INVALID_PARAMETERIf FileHandle does not represent a valid file.
EFI_INVALID_PARAMETERIf FileInfo is NULL.

Definition at line 1916 of file FwVol.c.

◆ PeiFfsFvPpiGetVolumeInfo()

EFI_STATUS EFIAPI PeiFfsFvPpiGetVolumeInfo ( IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI This,
IN EFI_PEI_FV_HANDLE  FvHandle,
OUT EFI_FV_INFO VolumeInfo 
)

This function returns information about the firmware volume.

Parameters
ThisPoints to this instance of the EFI_PEI_FIRMWARE_VOLUME_PPI.
FvHandleHandle to the firmware handle.
VolumeInfoPoints to the returned firmware volume information.
Return values
EFI_SUCCESSInformation returned successfully.
EFI_INVALID_PARAMETERFvHandle does not indicate a valid firmware volume or VolumeInfo is NULL.

Definition at line 1961 of file FwVol.c.

◆ PeiFfsFvPpiProcessVolume()

EFI_STATUS EFIAPI PeiFfsFvPpiProcessVolume ( IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI This,
IN VOID Buffer,
IN UINTN  BufferSize,
OUT EFI_PEI_FV_HANDLE FvHandle 
)

Process a firmware volume and create a volume handle.

Create a volume handle from the information in the buffer. For memory-mapped firmware volumes, Buffer and BufferSize refer to the start of the firmware volume and the firmware volume size. For non memory-mapped firmware volumes, this points to a buffer which contains the necessary information for creating the firmware volume handle. Normally, these values are derived from the EFI_FIRMWARE_VOLUME_INFO_PPI.

Parameters
ThisPoints to this instance of the EFI_PEI_FIRMWARE_VOLUME_PPI.
BufferPoints to the start of the buffer.
BufferSizeSize of the buffer.
FvHandlePoints to the returned firmware volume handle. The firmware volume handle must be unique within the system.
Return values
EFI_SUCCESSFirmware volume handle created.
EFI_VOLUME_CORRUPTEDVolume was corrupt.

Definition at line 1666 of file FwVol.c.

◆ PeiFfsGetFileInfo()

EFI_STATUS EFIAPI PeiFfsGetFileInfo ( IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT EFI_FV_FILE_INFO FileInfo 
)

Returns information about a specific file.

Parameters
FileHandleHandle of the file.
FileInfoUpon exit, points to the file's information.
Return values
EFI_INVALID_PARAMETERIf FileInfo is NULL.
EFI_INVALID_PARAMETERIf FileHandle does not represent a valid file.
EFI_SUCCESSFile information returned.

Definition at line 1246 of file FwVol.c.

◆ PeiFfsGetFileInfo2()

EFI_STATUS EFIAPI PeiFfsGetFileInfo2 ( IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT EFI_FV_FILE_INFO2 FileInfo 
)

Returns information about a specific file.

Parameters
FileHandleHandle of the file.
FileInfoUpon exit, points to the file's information.
Return values
EFI_INVALID_PARAMETERIf FileInfo is NULL.
EFI_INVALID_PARAMETERIf FileHandle does not represent a valid file.
EFI_SUCCESSFile information returned.

Definition at line 1281 of file FwVol.c.

◆ PeiFfsGetVolumeInfo()

EFI_STATUS EFIAPI PeiFfsGetVolumeInfo ( IN EFI_PEI_FV_HANDLE  VolumeHandle,
OUT EFI_FV_INFO VolumeInfo 
)

Returns information about the specified volume.

This function returns information about a specific firmware volume, including its name, type, attributes, starting address and size.

Parameters
VolumeHandleHandle of the volume.
VolumeInfoUpon exit, points to the volume's information.
Return values
EFI_SUCCESSVolume information returned.
EFI_INVALID_PARAMETERIf VolumeHandle does not represent a valid volume.
EFI_INVALID_PARAMETERIf VolumeHandle is NULL.
EFI_SUCCESSInformation successfully returned.
EFI_INVALID_PARAMETERThe volume designated by the VolumeHandle is not available.

Definition at line 1332 of file FwVol.c.

◆ PeiInitializeFv()

VOID PeiInitializeFv ( IN PEI_CORE_INSTANCE PrivateData,
IN CONST EFI_SEC_PEI_HAND_OFF SecCoreData 
)

Initialize PeiCore FV List.

Parameters
PrivateData- Pointer to PEI_CORE_INSTANCE.
SecCoreData- Pointer to EFI_SEC_PEI_HAND_OFF.

Definition at line 488 of file FwVol.c.

◆ PeiReinitializeFv()

VOID PeiReinitializeFv ( IN PEI_CORE_INSTANCE PrivateData)

After PeiCore image is shadowed into permanent memory, all build-in FvPpi should be re-installed with the instance in permanent memory and all cached FvPpi pointers in PrivateData->Fv[] array should be fixed up to be pointed to the one in permanent memory.

Parameters
PrivateDataPointer to PEI_CORE_INSTANCE.

Definition at line 2189 of file FwVol.c.

◆ ProcessFvFile()

EFI_STATUS ProcessFvFile ( IN PEI_CORE_INSTANCE PrivateData,
IN PEI_CORE_FV_HANDLE ParentFvCoreHandle,
IN EFI_PEI_FILE_HANDLE  ParentFvFileHandle 
)

Get FV image(s) from the FV type file, then install FV INFO(2) PPI, Build FV(2, 3) HOB.

Parameters
PrivateDataPeiCore's private data structure
ParentFvCoreHandlePointer of EFI_CORE_FV_HANDLE to parent FV image that contain this FV image.
ParentFvFileHandleFile handle of a FV type file that contain this FV image.
Return values
EFI_NOT_FOUNDFV image can't be found.
EFI_SUCCESSSuccessfully to process it.
EFI_OUT_OF_RESOURCESCan not allocate page when aligning FV image
EFI_SECURITY_VIOLATIONImage is illegal
OthersCan not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section

Definition at line 1431 of file FwVol.c.

◆ ProcessSection()

EFI_STATUS ProcessSection ( IN CONST EFI_PEI_SERVICES **  PeiServices,
IN EFI_SECTION_TYPE  SectionType,
IN OUT UINTN SectionInstance,
IN EFI_COMMON_SECTION_HEADER Section,
IN UINTN  SectionSize,
OUT VOID **  OutputBuffer,
OUT UINT32 *  AuthenticationStatus,
IN BOOLEAN  IsFfs3Fv 
)

Go through the file to search SectionType section. Search within encapsulation sections (compression and GUIDed) recursively, until the match section is found.

Parameters
PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
SectionTypeFilter to find only section of this type.
SectionInstancePointer to the filter to find the specific instance of section.
SectionFrom where to search.
SectionSizeThe file size to search.
OutputBufferA pointer to the discovered section, if successful. NULL if section not found
AuthenticationStatusUpdated upon return to point to the authentication status for this section.
IsFfs3FvIndicates the FV format.
Returns
EFI_NOT_FOUND The match section is not found.
EFI_SUCCESS The match section is found.

Definition at line 807 of file FwVol.c.

◆ ThirdPartyFvPpiNotifyCallback()

EFI_STATUS EFIAPI ThirdPartyFvPpiNotifyCallback ( IN EFI_PEI_SERVICES **  PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor,
IN VOID Ppi 
)

Notification callback function for EFI_PEI_FIRMWARE_VOLUME_PPI.

When a EFI_PEI_FIRMWARE_VOLUME_PPI is installed to support new FV format, this routine is called to process all discovered FVs in this format.

Parameters
PeiServicesAn indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
NotifyDescriptorAddress of the notification descriptor data structure.
PpiAddress of the PPI that was installed.
Return values
EFI_SUCCESSThe notification callback is processed correctly.

Definition at line 2381 of file FwVol.c.

◆ VerifyGuidedSectionGuid()

BOOLEAN VerifyGuidedSectionGuid ( IN EFI_GUID GuidedSectionGuid,
OUT EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI **  GuidedSectionExtraction 
)

Verify the Guided Section GUID by checking if there is the Guided Section GUID HOB recorded the GUID itself.

Parameters
GuidedSectionGuidThe Guided Section GUID.
GuidedSectionExtractionA pointer to the pointer to the supported Guided Section Extraction Ppi for the Guided Section.
Returns
TRUE The GuidedSectionGuid could be identified, and the pointer to the Guided Section Extraction Ppi will be returned to *GuidedSectionExtraction.
FALSE The GuidedSectionGuid could not be identified, or the Guided Section Extraction Ppi has not been installed yet.

Definition at line 751 of file FwVol.c.

Variable Documentation

◆ mFvAttributes

UINT8 mFvAttributes[] = { 0, 4, 7, 9, 10, 12, 15, 16 }

Required Alignment Alignment Value in FFS FFS_ATTRIB_DATA_ALIGNMENT2 Alignment Value in (bytes) Attributes Field in FFS Attributes Field Firmware Volume Interfaces 1 0 0 0 16 1 0 4 128 2 0 7 512 3 0 9 1 KB 4 0 10 4 KB 5 0 12 32 KB 6 0 15 64 KB 7 0 16 128 KB 0 1 17 256 KB 1 1 18 512 KB 2 1 19 1 MB 3 1 20 2 MB 4 1 21 4 MB 5 1 22 8 MB 6 1 23 16 MB 7 1 24

Definition at line 91 of file FwVol.c.

◆ mFvAttributes2

UINT8 mFvAttributes2[] = { 17, 18, 19, 20, 21, 22, 23, 24 }

Definition at line 92 of file FwVol.c.

◆ mNotifyOnFvInfoList

EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList[]
Initial value:
= {
{
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
&gEfiPeiFirmwareVolumeInfoPpiGuid,
},
{
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiFirmwareVolumeInfo2PpiGuid,
}
}
EFI_STATUS EFIAPI FirmwareVolumeInfoPpiNotifyCallback(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
Definition: FwVol.c:577

Definition at line 12 of file FwVol.c.

◆ mPeiFfs2FvPpiList

EFI_PEI_PPI_DESCRIPTOR mPeiFfs2FvPpiList
Initial value:
= {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiFirmwareFileSystem2Guid,
&mPeiFfs2FwVol.Fv
}

Definition at line 59 of file FwVol.c.

◆ mPeiFfs2FwVol

PEI_FW_VOL_INSTANCE mPeiFfs2FwVol
Initial value:
= {
PEI_FW_VOL_SIGNATURE,
{
EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE,
EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION
}
}
EFI_STATUS EFIAPI PeiFfsFvPpiGetFileInfo2(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO2 *FileInfo)
Definition: FwVol.c:1916
EFI_STATUS EFIAPI PeiFfsFvPpiFindSectionByType2(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_SECTION_TYPE SearchType, IN UINTN SearchInstance, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData, OUT UINT32 *AuthenticationStatus)
Definition: FwVol.c:2060
EFI_STATUS EFIAPI PeiFfsFvPpiFindFileByType(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_FV_FILETYPE SearchType, IN EFI_PEI_FV_HANDLE FvHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle)
Definition: FwVol.c:1723
EFI_STATUS EFIAPI PeiFfsFvPpiProcessVolume(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN VOID *Buffer, IN UINTN BufferSize, OUT EFI_PEI_FV_HANDLE *FvHandle)
Definition: FwVol.c:1666
EFI_STATUS EFIAPI PeiFfsFvPpiGetFileInfo(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO *FileInfo)
Definition: FwVol.c:1825
EFI_STATUS EFIAPI PeiFfsFvPpiFindSectionByType(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_SECTION_TYPE SearchType, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData)
Definition: FwVol.c:2023
EFI_STATUS EFIAPI PeiFfsFvPpiGetVolumeInfo(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN EFI_PEI_FV_HANDLE FvHandle, OUT EFI_FV_INFO *VolumeInfo)
Definition: FwVol.c:1961
EFI_STATUS EFIAPI PeiFfsFvPpiFindFileByName(IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, IN CONST EFI_GUID *FileName, IN EFI_PEI_FV_HANDLE *FvHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
Definition: FwVol.c:1760
#define FALSE
Definition: Base.h:307

Definition at line 25 of file FwVol.c.

◆ mPeiFfs3FvPpiList

EFI_PEI_PPI_DESCRIPTOR mPeiFfs3FvPpiList
Initial value:
= {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiFirmwareFileSystem3Guid,
&mPeiFfs3FwVol.Fv
}

Definition at line 65 of file FwVol.c.

◆ mPeiFfs3FwVol

PEI_FW_VOL_INSTANCE mPeiFfs3FwVol
Initial value:
= {
PEI_FW_VOL_SIGNATURE,
{
EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE,
EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION
}
}
#define TRUE
Definition: Base.h:301

Definition at line 42 of file FwVol.c.