TianoCore EDK2 master
Loading...
Searching...
No Matches
FwVol.c File Reference

Go to the source code of this file.

Macros

#define GET_OCCUPIED_SIZE(ActualSize, Alignment)    (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
 

Functions

STATIC EFI_FFS_FILE_STATE GetFileState (IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader)
 
STATIC UINT8 CalculateHeaderChecksum (IN EFI_FFS_FILE_HEADER *FileHeader)
 
STATIC BOOLEAN EFIAPI FileHandleToVolume (IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_PEI_FV_HANDLE *VolumeHandle)
 
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)
 
EFI_STATUS FfsProcessSection (IN EFI_SECTION_TYPE SectionType, IN FFS_CHECK_SECTION_HOOK SectionCheckHook, IN EFI_COMMON_SECTION_HEADER *Section, IN UINTN SectionSize, OUT VOID **OutputBuffer)
 
EFI_STATUS EFIAPI FfsFindSectionDataWithHook (IN EFI_SECTION_TYPE SectionType, IN FFS_CHECK_SECTION_HOOK SectionCheckHook, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData)
 
EFI_STATUS EFIAPI FfsFindSectionData (IN EFI_SECTION_TYPE SectionType, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData)
 
EFI_STATUS EFIAPI FfsFindNextFile (IN UINT8 SearchType, IN EFI_PEI_FV_HANDLE VolumeHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle)
 
EFI_STATUS EFIAPI FfsFindNextVolume (IN UINTN Instance, IN OUT EFI_PEI_FV_HANDLE *VolumeHandle)
 
EFI_STATUS EFIAPI FfsFindFileByName (IN CONST EFI_GUID *FileName, IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
 
EFI_STATUS EFIAPI FfsGetFileInfo (IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO *FileInfo)
 
EFI_STATUS EFIAPI FfsGetVolumeInfo (IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_FV_INFO *VolumeInfo)
 
EFI_STATUS EFIAPI FfsAnyFvFindFirstFile (IN EFI_FV_FILETYPE FileType, OUT EFI_PEI_FV_HANDLE *VolumeHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
 
EFI_STATUS EFIAPI FfsProcessFvFile (IN EFI_PEI_FILE_HANDLE FvFileHandle)
 

Detailed Description

Implementation of the 6 PEI Ffs (FV) APIs in library form.

This code only knows about a FV if it has a EFI_HOB_TYPE_FV entry in the HOB list

Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file FwVol.c.

Macro Definition Documentation

◆ GET_OCCUPIED_SIZE

#define GET_OCCUPIED_SIZE (   ActualSize,
  Alignment 
)     (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))

Definition at line 15 of file FwVol.c.

Function Documentation

◆ CalculateHeaderChecksum()

STATIC UINT8 CalculateHeaderChecksum ( IN EFI_FFS_FILE_HEADER FileHeader)

Calculates the checksum of the header of a file. The header is a zero byte checksum, so zero means header is good

Parameters
FfsHeaderPointer to FFS File Header
Return values
Checksumof the header

Definition at line 64 of file FwVol.c.

◆ FfsAnyFvFindFirstFile()

EFI_STATUS EFIAPI FfsAnyFvFindFirstFile ( IN EFI_FV_FILETYPE  FileType,
OUT EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_PEI_FILE_HANDLE FileHandle 
)

Search through every FV until you find a file of type FileType

Parameters
FileTypeFile handle of a Fv type file.
VolumehandleOn success Volume Handle of the match
FileHandleOn success File Handle of the match
Return values
EFI_NOT_FOUNDFV image can't be found.
EFI_SUCCESSSuccessfully found FileType

Definition at line 771 of file FwVol.c.

◆ FfsFindFileByName()

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

Find a file in the volume by name

Parameters
FileNameA pointer to the name of the file to find within the firmware volume.
VolumeHandleThe firmware volume to search FileHandle Upon 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 614 of file FwVol.c.

◆ FfsFindNextFile()

EFI_STATUS EFIAPI FfsFindNextFile ( IN UINT8  SearchType,
IN EFI_PEI_FV_HANDLE  VolumeHandle,
IN OUT EFI_PEI_FILE_HANDLE FileHandle 
)

This service enables discovery of additional firmware files.

Parameters
SearchTypeA filter to find files only of this type.
FwVolHeaderPointer to the firmware volume header of the volume to search. This parameter must point to a valid FFS volume.
FileHeaderPointer to the current file from which to begin searching.
Return values
EFI_SUCCESSThe file was found.
EFI_NOT_FOUNDThe file was not found.
EFI_NOT_FOUNDThe header checksum was not zero.

Definition at line 545 of file FwVol.c.

◆ FfsFindNextVolume()

EFI_STATUS EFIAPI FfsFindNextVolume ( IN UINTN  Instance,
IN OUT EFI_PEI_FV_HANDLE VolumeHandle 
)

This service enables discovery of additional firmware volumes.

Parameters
InstanceThis instance of the firmware volume to find. The value 0 is the Boot Firmware Volume (BFV).
FwVolHeaderPointer to the firmware volume header of the volume to return.
Return values
EFI_SUCCESSThe volume was found.
EFI_NOT_FOUNDThe volume was not found.

Definition at line 567 of file FwVol.c.

◆ FfsFindSectionData()

EFI_STATUS EFIAPI FfsFindSectionData ( IN EFI_SECTION_TYPE  SectionType,
IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT VOID **  SectionData 
)

This service enables discovery sections of a given type within a valid FFS file.

Parameters
SectionTypeThe value of the section type to find.
FileHandleA pointer to the file header that contains the set of sections to be searched.
SectionDataA pointer to the discovered section, if successful.
Return values
EFI_SUCCESSThe section was found.
EFI_NOT_FOUNDThe section was not found.

Definition at line 521 of file FwVol.c.

◆ FfsFindSectionDataWithHook()

EFI_STATUS EFIAPI FfsFindSectionDataWithHook ( IN EFI_SECTION_TYPE  SectionType,
IN FFS_CHECK_SECTION_HOOK  SectionCheckHook,
IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT VOID **  SectionData 
)

This service enables discovery sections of a given type within a valid FFS file. Caller also can provide a SectionCheckHook to do additional checking.

Parameters
SectionTypeThe value of the section type to find.
SectionCheckHookA hook which can check if the section is the target one.
FileHandleA pointer to the file header that contains the set of sections to be searched.
SectionDataA pointer to the discovered section, if successful.
Return values
EFI_SUCCESSThe section was found.
EFI_NOT_FOUNDThe section was not found.

Definition at line 476 of file FwVol.c.

◆ FfsGetFileInfo()

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

Get information about the file by name.

Parameters
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 652 of file FwVol.c.

◆ FfsGetVolumeInfo()

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

Get Information about the volume by name

Parameters
VolumeHandleHandle of the volume.
VolumeInfoUpon exit, points to the volume'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 720 of file FwVol.c.

◆ FfsProcessFvFile()

EFI_STATUS EFIAPI FfsProcessFvFile ( IN EFI_PEI_FILE_HANDLE  FvFileHandle)

Get Fv image from the FV type file, then add FV & FV2 Hob.

Parameters
FileHandleFile handle of a Fv type file.
Return values
EFI_NOT_FOUNDFV image can't be found.
EFI_SUCCESSSuccessfully to process it.

Definition at line 813 of file FwVol.c.

◆ FfsProcessSection()

EFI_STATUS FfsProcessSection ( IN EFI_SECTION_TYPE  SectionType,
IN FFS_CHECK_SECTION_HOOK  SectionCheckHook,
IN EFI_COMMON_SECTION_HEADER Section,
IN UINTN  SectionSize,
OUT VOID **  OutputBuffer 
)

Go through the file to search SectionType section, when meeting an encapsuled section.

Parameters
SectionType- Filter to find only section of this type.
SectionCheckHook- A hook which can check if the section is the target one.
Section- From where to search.
SectionSize- The file size to search.
OutputBuffer- Pointer to the section to search.
Return values
EFI_SUCCESS

Definition at line 276 of file FwVol.c.

◆ FileHandleToVolume()

STATIC BOOLEAN EFIAPI FileHandleToVolume ( IN EFI_PEI_FILE_HANDLE  FileHandle,
OUT EFI_PEI_FV_HANDLE VolumeHandle 
)

Given a FileHandle return the VolumeHandle

Parameters
FileHandleFile handle to look up
VolumeHandleMatch for FileHandle
Return values
TRUEVolumeHandle is valid

Definition at line 110 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 
)

Given the input file pointer, search for the next matching file in the FFS volume as defined by SearchType. The search starts from FileHeader inside the Firmware Volume defined by FwVolHeader.

Parameters
FileHandleFile handle to look up
VolumeHandleMatch for FileHandle

Definition at line 152 of file FwVol.c.

◆ GetFileState()

STATIC EFI_FFS_FILE_STATE GetFileState ( IN UINT8  ErasePolarity,
IN EFI_FFS_FILE_HEADER FfsHeader 
)

Returns the highest bit set of the State field

Parameters
ErasePolarityErase Polarity as defined by EFI_FVB2_ERASE_POLARITY in the Attributes field.
FfsHeaderPointer to FFS File Header
Return values
thehighest bit in the State field

Definition at line 31 of file FwVol.c.