TianoCore EDK2 master
Loading...
Searching...
No Matches
FwVolDriver.h File Reference

Go to the source code of this file.

Data Structures

struct  FFS_FILE_LIST_ENTRY
 
struct  FV_DEVICE
 

Macros

#define FV2_DEVICE_SIGNATURE   SIGNATURE_32 ('_', 'F', 'V', '2')
 
#define FV_DEVICE_FROM_THIS(a)   CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)
 

Functions

EFI_STATUS EFIAPI FvGetVolumeAttributes (IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, OUT EFI_FV_ATTRIBUTES *Attributes)
 
EFI_STATUS EFIAPI FvSetVolumeAttributes (IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, IN OUT EFI_FV_ATTRIBUTES *Attributes)
 
EFI_STATUS EFIAPI FvGetNextFile (IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, IN OUT VOID *Key, IN OUT EFI_FV_FILETYPE *FileType, OUT EFI_GUID *NameGuid, OUT EFI_FV_FILE_ATTRIBUTES *Attributes, OUT UINTN *Size)
 
EFI_STATUS EFIAPI FvReadFile (IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, IN CONST EFI_GUID *NameGuid, IN OUT VOID **Buffer, IN OUT UINTN *BufferSize, OUT EFI_FV_FILETYPE *FoundType, OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes, OUT UINT32 *AuthenticationStatus)
 
EFI_STATUS EFIAPI FvReadFileSection (IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, IN OUT VOID **Buffer, IN OUT UINTN *BufferSize, OUT UINT32 *AuthenticationStatus)
 
EFI_STATUS EFIAPI FvWriteFile (IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, IN UINT32 NumberOfFiles, IN EFI_FV_WRITE_POLICY WritePolicy, IN EFI_FV_WRITE_FILE_DATA *FileData)
 
EFI_STATUS EFIAPI FvGetVolumeInfo (IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, IN CONST EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI FvSetVolumeInfo (IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, IN CONST EFI_GUID *InformationType, IN UINTN BufferSize, IN CONST VOID *Buffer)
 
BOOLEAN IsBufferErased (IN UINT8 ErasePolarity, IN VOID *InBuffer, IN UINTN BufferSize)
 
EFI_FFS_FILE_STATE GetFileState (IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader)
 
VOID SetFileState (IN UINT8 State, IN EFI_FFS_FILE_HEADER *FfsHeader)
 
BOOLEAN IsValidFfsHeader (IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader, OUT EFI_FFS_FILE_STATE *FileState)
 
BOOLEAN IsValidFfsFile (IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader)
 

Detailed Description

Firmware File System protocol. Layers on top of Firmware Block protocol to produce a file abstraction of FV based files.

Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file FwVolDriver.h.

Macro Definition Documentation

◆ FV2_DEVICE_SIGNATURE

#define FV2_DEVICE_SIGNATURE   SIGNATURE_32 ('_', 'F', 'V', '2')

Definition at line 13 of file FwVolDriver.h.

◆ FV_DEVICE_FROM_THIS

#define FV_DEVICE_FROM_THIS (   a)    CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)

Definition at line 45 of file FwVolDriver.h.

Function Documentation

◆ FvGetNextFile()

EFI_STATUS EFIAPI FvGetNextFile ( IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL This,
IN OUT VOID *  Key,
IN OUT EFI_FV_FILETYPE *  FileType,
OUT EFI_GUID NameGuid,
OUT EFI_FV_FILE_ATTRIBUTES Attributes,
OUT UINTN Size 
)

Given the input key, search for the next matching file in the volume.

Parameters
ThisPointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
KeyKey is a pointer to a caller allocated buffer that contains implementation specific data that is used to track where to begin the search for the next file. The size of the buffer must be at least This->KeySize bytes long. To reinitialize the search and begin from the beginning of the firmware volume, the entire buffer must be cleared to zero. Other than clearing the buffer to initiate a new search, the caller must not modify the data in the buffer between calls to GetNextFile().
FileTypeFileType is a pointer to a caller allocated EFI_FV_FILETYPE. The GetNextFile() API can filter it's search for files based on the value of *FileType input. A *FileType input of 0 causes GetNextFile() to search for files of all types. If a file is found, the file's type is returned in *FileType. FileType is not modified if no file is found.
NameGuidNameGuid is a pointer to a caller allocated EFI_GUID. If a file is found, the file's name is returned in *NameGuid. *NameGuid is not modified if no file is found.
AttributesAttributes is a pointer to a caller allocated EFI_FV_FILE_ATTRIBUTES. If a file is found, the file's attributes are returned in *Attributes. *Attributes is not modified if no file is found.
SizeSize is a pointer to a caller allocated UINTN. If a file is found, the file's size is returned in *Size. *Size is not modified if no file is found.
Return values
EFI_SUCCESSSuccessfully find the file.
EFI_DEVICE_ERRORDevice error.
EFI_ACCESS_DENIEDFv could not read.
EFI_NOT_FOUNDNo matching file found.
EFI_INVALID_PARAMETERInvalid parameter

Given the input key, search for the next matching file in the volume.

Parameters
ThisIndicates the calling context.
KeyKey is a pointer to a caller allocated buffer that contains implementation specific data that is used to track where to begin the search for the next file. The size of the buffer must be at least This->KeySize bytes long. To reinitialize the search and begin from the beginning of the firmware volume, the entire buffer must be cleared to zero. Other than clearing the buffer to initiate a new search, the caller must not modify the data in the buffer between calls to GetNextFile().
FileTypeFileType is a pointer to a caller allocated EFI_FV_FILETYPE. The GetNextFile() API can filter it's search for files based on the value of *FileType input. A *FileType input of 0 causes GetNextFile() to search for files of all types. If a file is found, the file's type is returned in *FileType. FileType is not modified if no file is found.
NameGuidNameGuid is a pointer to a caller allocated EFI_GUID. If a file is found, the file's name is returned in *NameGuid. *NameGuid is not modified if no file is found.
AttributesAttributes is a pointer to a caller allocated EFI_FV_FILE_ATTRIBUTES. If a file is found, the file's attributes are returned in *Attributes. *Attributes is not modified if no file is found.
SizeSize is a pointer to a caller allocated UINTN. If a file is found, the file's size is returned in *Size. *Size is not modified if no file is found.
Return values
EFI_SUCCESSSuccessfully find the file.
EFI_DEVICE_ERRORDevice error.
EFI_ACCESS_DENIEDFv could not read.
EFI_NOT_FOUNDNo matching file found.
EFI_INVALID_PARAMETERInvalid parameter

Definition at line 115 of file FwVolRead.c.

◆ FvGetVolumeAttributes()

EFI_STATUS EFIAPI FvGetVolumeAttributes ( IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL This,
OUT EFI_FV_ATTRIBUTES Attributes 
)

Retrieves attributes, insures positive polarity of attribute bits, returns resulting attributes in output parameter.

Parameters
ThisPointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
Attributesoutput buffer which contains attributes.
Return values
EFI_SUCCESSSuccessfully got volume attributes.

Retrieves attributes, insures positive polarity of attribute bits, returns resulting attributes in output parameter.

Parameters
ThisCalling context
Attributesoutput buffer which contains attributes
Return values
EFI_SUCCESSSuccessfully got volume attributes

Definition at line 24 of file FwVolAttrib.c.

◆ FvGetVolumeInfo()

EFI_STATUS EFIAPI FvGetVolumeInfo ( IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL This,
IN CONST EFI_GUID InformationType,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

Return information of type InformationType for the requested firmware volume.

Parameters
ThisPointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
InformationTypeInformationType for requested.
BufferSizeOn input, size of Buffer.On output, the amount of data returned in Buffer.
BufferA poniter to the data buffer to return.
Return values
EFI_SUCCESSSuccessfully got volume Information.

Definition at line 87 of file FwVolAttrib.c.

◆ FvReadFile()

EFI_STATUS EFIAPI FvReadFile ( IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL This,
IN CONST EFI_GUID NameGuid,
IN OUT VOID **  Buffer,
IN OUT UINTN BufferSize,
OUT EFI_FV_FILETYPE *  FoundType,
OUT EFI_FV_FILE_ATTRIBUTES FileAttributes,
OUT UINT32 *  AuthenticationStatus 
)

Locates a file in the firmware volume and copies it to the supplied buffer.

Parameters
ThisPointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
NameGuidPointer to an EFI_GUID, which is the filename.
BufferBuffer is a pointer to pointer to a buffer in which the file or section contents or are returned.
BufferSizeBufferSize is a pointer to caller allocated UINTN. On input *BufferSize indicates the size in bytes of the memory region pointed to by Buffer. On output, *BufferSize contains the number of bytes required to read the file.
FoundTypeFoundType is a pointer to a caller allocated EFI_FV_FILETYPE that on successful return from Read() contains the type of file read. This output reflects the file type irrespective of the value of the SectionType input.
FileAttributesFileAttributes is a pointer to a caller allocated EFI_FV_FILE_ATTRIBUTES. On successful return from Read(), FileAttributes contains the attributes of the file read.
AuthenticationStatusAuthenticationStatus is a pointer to a caller allocated UINTN in which the authentication status is returned.
Return values
EFI_SUCCESSSuccessfully read to memory buffer.
EFI_WARN_BUFFER_TOO_SMALLBuffer too small.
EFI_NOT_FOUNDNot found.
EFI_DEVICE_ERRORDevice error.
EFI_ACCESS_DENIEDCould not read.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESNot enough buffer to be allocated.

Locates a file in the firmware volume and copies it to the supplied buffer.

Parameters
ThisIndicates the calling context.
NameGuidPointer to an EFI_GUID, which is the filename.
BufferBuffer is a pointer to pointer to a buffer in which the file or section contents or are returned.
BufferSizeBufferSize is a pointer to caller allocated UINTN. On input *BufferSize indicates the size in bytes of the memory region pointed to by Buffer. On output, *BufferSize contains the number of bytes required to read the file.
FoundTypeFoundType is a pointer to a caller allocated EFI_FV_FILETYPE that on successful return from Read() contains the type of file read. This output reflects the file type irrespective of the value of the SectionType input.
FileAttributesFileAttributes is a pointer to a caller allocated EFI_FV_FILE_ATTRIBUTES. On successful return from Read(), FileAttributes contains the attributes of the file read.
AuthenticationStatusAuthenticationStatus is a pointer to a caller allocated UINTN in which the authentication status is returned.
Return values
EFI_SUCCESSSuccessfully read to memory buffer.
EFI_WARN_BUFFER_TOO_SMALLBuffer too small.
EFI_NOT_FOUNDNot found.
EFI_DEVICE_ERRORDevice error.
EFI_ACCESS_DENIEDCould not read.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESNot enough buffer to be allocated.

Definition at line 268 of file FwVolRead.c.

◆ FvReadFileSection()

EFI_STATUS EFIAPI FvReadFileSection ( IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL This,
IN CONST EFI_GUID NameGuid,
IN EFI_SECTION_TYPE  SectionType,
IN UINTN  SectionInstance,
IN OUT VOID **  Buffer,
IN OUT UINTN BufferSize,
OUT UINT32 *  AuthenticationStatus 
)

Locates a section in a given FFS File and copies it to the supplied buffer (not including section header).

Parameters
ThisPointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
NameGuidPointer to an EFI_GUID, which is the filename.
SectionTypeIndicates the section type to return.
SectionInstanceIndicates which instance of sections with a type of SectionType to return.
BufferBuffer is a pointer to pointer to a buffer in which the file or section contents or are returned.
BufferSizeBufferSize is a pointer to caller allocated UINTN.
AuthenticationStatusAuthenticationStatus is a pointer to a caller allocated UINT32 in which the authentication status is returned.
Return values
EFI_SUCCESSSuccessfully read the file section into buffer.
EFI_WARN_BUFFER_TOO_SMALLBuffer too small.
EFI_NOT_FOUNDSection not found.
EFI_DEVICE_ERRORDevice error.
EFI_ACCESS_DENIEDCould not read.
EFI_INVALID_PARAMETERInvalid parameter.

Locates a section in a given FFS File and copies it to the supplied buffer (not including section header).

Parameters
ThisIndicates the calling context.
NameGuidPointer to an EFI_GUID, which is the filename.
SectionTypeIndicates the section type to return.
SectionInstanceIndicates which instance of sections with a type of SectionType to return.
BufferBuffer is a pointer to pointer to a buffer in which the file or section contents or are returned.
BufferSizeBufferSize is a pointer to caller allocated UINTN.
AuthenticationStatusAuthenticationStatus is a pointer to a caller allocated UINT32 in which the authentication status is returned.
Return values
EFI_SUCCESSSuccessfully read the file section into buffer.
EFI_WARN_BUFFER_TOO_SMALLBuffer too small.
EFI_NOT_FOUNDSection not found.
EFI_DEVICE_ERRORDevice error.
EFI_ACCESS_DENIEDCould not read.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 432 of file FwVolRead.c.

◆ FvSetVolumeAttributes()

EFI_STATUS EFIAPI FvSetVolumeAttributes ( IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL This,
IN OUT EFI_FV_ATTRIBUTES Attributes 
)

Sets current attributes for volume

Parameters
ThisPointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
AttributesAt input, contains attributes to be set. At output contains new value of FV.
Return values
EFI_UNSUPPORTEDCould not be set.

Sets current attributes for volume

Parameters
ThisCalling context
AttributesAt input, contains attributes to be set. At output contains new value of FV
Return values
EFI_UNSUPPORTEDCould not be set.

Definition at line 64 of file FwVolAttrib.c.

◆ FvSetVolumeInfo()

EFI_STATUS EFIAPI FvSetVolumeInfo ( IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL This,
IN CONST EFI_GUID InformationType,
IN UINTN  BufferSize,
IN CONST VOID *  Buffer 
)

Set information of type InformationType for the requested firmware volume.

Parameters
ThisPointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
InformationTypeInformationType for requested.
BufferSizeOn input, size of Buffer.On output, the amount of data returned in Buffer.
BufferA poniter to the data buffer to return.
Return values
EFI_SUCCESSSuccessfully set volume Information.

Definition at line 112 of file FwVolAttrib.c.

◆ FvWriteFile()

EFI_STATUS EFIAPI FvWriteFile ( IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL This,
IN UINT32  NumberOfFiles,
IN EFI_FV_WRITE_POLICY  WritePolicy,
IN EFI_FV_WRITE_FILE_DATA FileData 
)

Writes one or more files to the firmware volume.

Parameters
ThisPointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
NumberOfFilesNumber of files.
WritePolicyWritePolicy indicates the level of reliability for the write in the event of a power failure or other system failure during the write operation.
FileDataFileData is an pointer to an array of EFI_FV_WRITE_DATA. Each element of array FileData represents a file to be written.
Return values
EFI_SUCCESSFiles successfully written to firmware volume
EFI_OUT_OF_RESOURCESNot enough buffer to be allocated.
EFI_DEVICE_ERRORDevice error.
EFI_WRITE_PROTECTEDWrite protected.
EFI_NOT_FOUNDNot found.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_UNSUPPORTEDThis function not supported.

Writes one or more files to the firmware volume.

Parameters
ThisIndicates the calling context.
NumberOfFilesNumber of files.
WritePolicyWritePolicy indicates the level of reliability for the write in the event of a power failure or other system failure during the write operation.
FileDataFileData is an pointer to an array of EFI_FV_WRITE_DATA. Each element of array FileData represents a file to be written.
Return values
EFI_SUCCESSFiles successfully written to firmware volume
EFI_OUT_OF_RESOURCESNot enough buffer to be allocated.
EFI_DEVICE_ERRORDevice error.
EFI_WRITE_PROTECTEDWrite protected.
EFI_NOT_FOUNDNot found.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_UNSUPPORTEDThis function not supported.

Definition at line 35 of file FwVolWrite.c.

◆ GetFileState()

EFI_FFS_FILE_STATE GetFileState ( IN UINT8  ErasePolarity,
IN EFI_FFS_FILE_HEADER FfsHeader 
)

Get the FFS file state by checking the highest bit set in the header's state field.

Parameters
ErasePolarityErase polarity attribute of the firmware volume
FfsHeaderPoints to the FFS file header
Returns
FFS File state

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

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.

Returns the highest bit set of the State field

Parameters
ErasePolarityErase Polarity as defined by EFI_FVB_ERASE_POLARITY in the Attributes field.
FfsHeaderPointer to FFS File Header.
Returns
the highest bit in the State field

Definition at line 44 of file DebugAgentSymbolsBaseLib.c.

◆ IsBufferErased()

BOOLEAN IsBufferErased ( IN UINT8  ErasePolarity,
IN VOID *  InBuffer,
IN UINTN  BufferSize 
)

Check if a block of buffer is erased.

Parameters
ErasePolarityErase polarity attribute of the firmware volume
InBufferThe buffer to be checked
BufferSizeSize of the buffer in bytes
Return values
TRUEThe block of buffer is erased
FALSEThe block of buffer is not erased

Check if a block of buffer is erased.

Parameters
[in]ErasePolarityErase polarity attribute of the firmware volume
[in]InBufferThe buffer to be checked
[in]BufferSizeSize of the buffer in bytes
Return values
TRUEThe block of buffer is erased
FALSEThe block of buffer is not erased

Definition at line 56 of file Ffs.c.

◆ IsValidFfsFile()

BOOLEAN IsValidFfsFile ( IN UINT8  ErasePolarity,
IN EFI_FFS_FILE_HEADER FfsHeader 
)

Check if it's a valid FFS file. Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.

Parameters
ErasePolarityErase polarity attribute of the firmware volume
FfsHeaderPoints to the FFS file to be checked
Return values
TRUEValid FFS file
FALSEInvalid FFS file

Definition at line 187 of file Ffs.c.

◆ IsValidFfsHeader()

BOOLEAN IsValidFfsHeader ( IN UINT8  ErasePolarity,
IN EFI_FFS_FILE_HEADER FfsHeader,
OUT EFI_FFS_FILE_STATE *  FileState 
)

Check if it's a valid FFS file header.

Parameters
ErasePolarityErase polarity attribute of the firmware volume
FfsHeaderPoints to the FFS file header to be checked
FileStateFFS file state to be returned
Return values
TRUEValid FFS file header
FALSEInvalid FFS file header

Definition at line 150 of file Ffs.c.

◆ SetFileState()

VOID SetFileState ( IN UINT8  State,
IN EFI_FFS_FILE_HEADER FfsHeader 
)

Set the FFS file state.

Parameters
StateThe state to be set.
FfsHeaderPoints to the FFS file header
Returns
None.