+++ /dev/null
-/** @file\r
- Common defines and definitions for a FwVolDxe driver.\r
-\r
- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _FWVOL_DRIVER_H_\r
-#define _FWVOL_DRIVER_H_\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Guid/FirmwareFileSystem2.h>\r
-#include <Guid/FirmwareFileSystem3.h>\r
-#include <Protocol/SectionExtraction.h>\r
-#include <Protocol/FaultTolerantWrite.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/HobLib.h>\r
-\r
-#define FV_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '_')\r
-\r
-//\r
-// Define two helper macro to extract the Capability field or Status field in FVB\r
-// bit fields\r
-//\r
-#define EFI_FVB2_CAPABILITIES (EFI_FVB2_READ_DISABLED_CAP | \\r
- EFI_FVB2_READ_ENABLED_CAP | \\r
- EFI_FVB2_WRITE_DISABLED_CAP | \\r
- EFI_FVB2_WRITE_ENABLED_CAP | \\r
- EFI_FVB2_LOCK_CAP \\r
- )\r
-\r
-#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)\r
-\r
-#define MAX_FILES 32\r
-\r
-//\r
-// Used to calculate from address -> Lba\r
-//\r
-typedef struct {\r
- LIST_ENTRY Link;\r
- EFI_LBA LbaIndex;\r
- UINT8 *StartingAddress;\r
- UINTN BlockLength;\r
-} LBA_ENTRY;\r
-\r
-//\r
-// Used to track free space in the Fv\r
-//\r
-typedef struct {\r
- LIST_ENTRY Link;\r
- UINT8 *StartingAddress;\r
- UINTN Length;\r
-} FREE_SPACE_ENTRY;\r
-\r
-//\r
-// Used to track all non-deleted files\r
-//\r
-typedef struct {\r
- LIST_ENTRY Link;\r
- UINT8 *FfsHeader;\r
-} FFS_FILE_LIST_ENTRY;\r
-\r
-typedef struct {\r
- UINTN Signature;\r
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL Fv;\r
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
- UINT8 *Key;\r
- EFI_HANDLE Handle;\r
-\r
- UINT8 ErasePolarity;\r
- EFI_PHYSICAL_ADDRESS CachedFv;\r
- LIST_ENTRY LbaHeader;\r
- LIST_ENTRY FreeSpaceHeader;\r
- LIST_ENTRY FfsFileListHeader;\r
-\r
- FFS_FILE_LIST_ENTRY *CurrentFfsFile;\r
- BOOLEAN IsFfs3Fv;\r
- UINT32 AuthenticationStatus;\r
-} FV_DEVICE;\r
-\r
-#define FV_DEVICE_FROM_THIS(a) CR (a, FV_DEVICE, Fv, FV_DEVICE_SIGNATURE)\r
-\r
-/**\r
- Retrieves attributes, insures positive polarity of attribute bits, returns\r
- resulting attributes in output parameter.\r
-\r
- @param This Calling context\r
- @param Attributes output buffer which contains attributes\r
-\r
- @retval EFI_SUCCESS Successfully got volume attributes\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetVolumeAttributes (\r
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
- OUT EFI_FV_ATTRIBUTES *Attributes\r
- );\r
-\r
-/**\r
- Sets current attributes for volume.\r
-\r
- @param This Calling context\r
- @param Attributes On input, FvAttributes is a pointer to\r
- an EFI_FV_ATTRIBUTES containing the\r
- desired firmware volume settings. On\r
- successful return, it contains the new\r
- settings of the firmware volume. On\r
- unsuccessful return, FvAttributes is not\r
- modified and the firmware volume\r
- settings are not changed.\r
-\r
- @retval EFI_SUCCESS The requested firmware volume attributes\r
- were set and the resulting\r
- EFI_FV_ATTRIBUTES is returned in\r
- FvAttributes.\r
- @retval EFI_ACCESS_DENIED Atrribute is locked down.\r
- @retval EFI_INVALID_PARAMETER Atrribute is not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvSetVolumeAttributes (\r
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
- IN OUT EFI_FV_ATTRIBUTES *Attributes\r
- );\r
-\r
-/**\r
- Given the input key, search for the next matching file in the volume.\r
-\r
- @param This Indicates the calling context.\r
- @param Key Key is a pointer to a caller allocated\r
- buffer that contains implementation specific\r
- data that is used to track where to begin\r
- the search for the next file. The size of\r
- the buffer must be at least This->KeySize\r
- bytes long. To reinitialize the search and\r
- begin from the beginning of the firmware\r
- volume, the entire buffer must be cleared to\r
- zero. Other than clearing the buffer to\r
- initiate a new search, the caller must not\r
- modify the data in the buffer between calls\r
- to GetNextFile().\r
- @param FileType FileType is a pointer to a caller allocated\r
- EFI_FV_FILETYPE. The GetNextFile() API can\r
- filter it's search for files based on the\r
- value of *FileType input. A *FileType input\r
- of 0 causes GetNextFile() to search for\r
- files of all types. If a file is found, the\r
- file's type is returned in *FileType.\r
- *FileType is not modified if no file is\r
- found.\r
- @param NameGuid NameGuid is a pointer to a caller allocated\r
- EFI_GUID. If a file is found, the file's\r
- name is returned in *NameGuid. *NameGuid is\r
- not modified if no file is found.\r
- @param Attributes Attributes is a pointer to a caller\r
- allocated EFI_FV_FILE_ATTRIBUTES. If a file\r
- is found, the file's attributes are returned\r
- in *Attributes. *Attributes is not modified\r
- if no file is found.\r
- @param Size Size is a pointer to a caller allocated\r
- UINTN. If a file is found, the file's size\r
- is returned in *Size. *Size is not modified\r
- if no file is found.\r
-\r
- @retval EFI_SUCCESS Successfully find the file.\r
- @retval EFI_DEVICE_ERROR Device error.\r
- @retval EFI_ACCESS_DENIED Fv could not read.\r
- @retval EFI_NOT_FOUND No matching file found.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetNextFile (\r
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
- IN OUT VOID *Key,\r
- IN OUT EFI_FV_FILETYPE *FileType,\r
- OUT EFI_GUID *NameGuid,\r
- OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r
- OUT UINTN *Size\r
- );\r
-\r
-/**\r
- Locates a file in the firmware volume and\r
- copies it to the supplied buffer.\r
-\r
- @param This Indicates the calling context.\r
- @param NameGuid Pointer to an EFI_GUID, which is the\r
- filename.\r
- @param Buffer Buffer is a pointer to pointer to a buffer\r
- in which the file or section contents or are\r
- returned.\r
- @param BufferSize BufferSize is a pointer to caller allocated\r
- UINTN. On input *BufferSize indicates the\r
- size in bytes of the memory region pointed\r
- to by Buffer. On output, *BufferSize\r
- contains the number of bytes required to\r
- read the file.\r
- @param FoundType FoundType is a pointer to a caller allocated\r
- EFI_FV_FILETYPE that on successful return\r
- from Read() contains the type of file read.\r
- This output reflects the file type\r
- irrespective of the value of the SectionType\r
- input.\r
- @param FileAttributes FileAttributes is a pointer to a caller\r
- allocated EFI_FV_FILE_ATTRIBUTES. On\r
- successful return from Read(),\r
- *FileAttributes contains the attributes of\r
- the file read.\r
- @param AuthenticationStatus AuthenticationStatus is a pointer to a\r
- caller allocated UINTN in which the\r
- authentication status is returned.\r
-\r
- @retval EFI_SUCCESS Successfully read to memory buffer.\r
- @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.\r
- @retval EFI_NOT_FOUND Not found.\r
- @retval EFI_DEVICE_ERROR Device error.\r
- @retval EFI_ACCESS_DENIED Could not read.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter.\r
- @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvReadFile (\r
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
- IN CONST EFI_GUID *NameGuid,\r
- IN OUT VOID **Buffer,\r
- IN OUT UINTN *BufferSize,\r
- OUT EFI_FV_FILETYPE *FoundType,\r
- OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r
- OUT UINT32 *AuthenticationStatus\r
- );\r
-\r
-/**\r
- Locates a section in a given FFS File and\r
- copies it to the supplied buffer (not including section header).\r
-\r
- @param This Indicates the calling context.\r
- @param NameGuid Pointer to an EFI_GUID, which is the\r
- filename.\r
- @param SectionType Indicates the section type to return.\r
- @param SectionInstance Indicates which instance of sections with a\r
- type of SectionType to return.\r
- @param Buffer Buffer is a pointer to pointer to a buffer\r
- in which the file or section contents or are\r
- returned.\r
- @param BufferSize BufferSize is a pointer to caller allocated\r
- UINTN.\r
- @param AuthenticationStatus AuthenticationStatus is a pointer to a\r
- caller allocated UINT32 in which the\r
- authentication status is returned.\r
-\r
- @retval EFI_SUCCESS Successfully read the file section into\r
- buffer.\r
- @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.\r
- @retval EFI_NOT_FOUND Section not found.\r
- @retval EFI_DEVICE_ERROR Device error.\r
- @retval EFI_ACCESS_DENIED Could not read.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvReadFileSection (\r
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
- IN CONST EFI_GUID *NameGuid,\r
- IN EFI_SECTION_TYPE SectionType,\r
- IN UINTN SectionInstance,\r
- IN OUT VOID **Buffer,\r
- IN OUT UINTN *BufferSize,\r
- OUT UINT32 *AuthenticationStatus\r
- );\r
-\r
-/**\r
- Writes one or more files to the firmware volume.\r
-\r
- @param This Indicates the calling context.\r
- @param NumberOfFiles Number of files.\r
- @param WritePolicy WritePolicy indicates the level of reliability\r
- for the write in the event of a power failure or\r
- other system failure during the write operation.\r
- @param FileData FileData is an pointer to an array of\r
- EFI_FV_WRITE_DATA. Each element of array\r
- FileData represents a file to be written.\r
-\r
- @retval EFI_SUCCESS Files successfully written to firmware volume\r
- @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.\r
- @retval EFI_DEVICE_ERROR Device error.\r
- @retval EFI_WRITE_PROTECTED Write protected.\r
- @retval EFI_NOT_FOUND Not found.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter.\r
- @retval EFI_UNSUPPORTED This function not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvWriteFile (\r
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
- IN UINT32 NumberOfFiles,\r
- IN EFI_FV_WRITE_POLICY WritePolicy,\r
- IN EFI_FV_WRITE_FILE_DATA *FileData\r
- );\r
-\r
-/**\r
- Return information of type InformationType for the requested firmware\r
- volume.\r
-\r
- @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
- @param InformationType InformationType for requested.\r
- @param BufferSize On input, size of Buffer.On output, the amount of\r
- data returned in Buffer.\r
- @param Buffer A poniter to the data buffer to return.\r
-\r
- @return EFI_UNSUPPORTED Could not get.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetVolumeInfo (\r
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
- IN CONST EFI_GUID *InformationType,\r
- IN OUT UINTN *BufferSize,\r
- OUT VOID *Buffer\r
- );\r
-\r
-\r
-/**\r
- Set information with InformationType into the requested firmware volume.\r
-\r
- @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
- @param InformationType InformationType for requested.\r
- @param BufferSize Size of Buffer data.\r
- @param Buffer A poniter to the data buffer to be set.\r
-\r
- @retval EFI_UNSUPPORTED Could not set.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvSetVolumeInfo (\r
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
- IN CONST EFI_GUID *InformationType,\r
- IN UINTN BufferSize,\r
- IN CONST VOID *Buffer\r
- );\r
-\r
-/**\r
- Writes data beginning at Lba:Offset from FV. The write terminates either\r
- when *NumBytes of data have been written, or when the firmware end is\r
- reached. *NumBytes is updated to reflect the actual number of bytes\r
- written.\r
-\r
- @param FvDevice Cached Firmware Volume\r
- @param Offset Offset in the block at which to begin write\r
- @param NumBytes At input, indicates the requested write size.\r
- At output, indicates the actual number of bytes written.\r
- @param Buffer Buffer containing source data for the write.\r
-\r
- @retval EFI_SUCCESS Data is successfully written into FV.\r
- @return error Data is failed written.\r
-\r
-**/\r
-EFI_STATUS\r
-FvcWrite (\r
- IN FV_DEVICE *FvDevice,\r
- IN UINTN Offset,\r
- IN OUT UINTN *NumBytes,\r
- IN UINT8 *Buffer\r
- );\r
-\r
-\r
-/**\r
- Check if a block of buffer is erased.\r
-\r
- @param ErasePolarity Erase polarity attribute of the firmware volume\r
- @param Buffer The buffer to be checked\r
- @param BufferSize Size of the buffer in bytes\r
-\r
- @retval TRUE The block of buffer is erased\r
- @retval FALSE The block of buffer is not erased\r
-\r
-**/\r
-BOOLEAN\r
-IsBufferErased (\r
- IN UINT8 ErasePolarity,\r
- IN UINT8 *Buffer,\r
- IN UINTN BufferSize\r
- );\r
-\r
-/**\r
- Get the FFS file state by checking the highest bit set in the header's state field.\r
-\r
- @param ErasePolarity Erase polarity attribute of the firmware volume\r
- @param FfsHeader Points to the FFS file header\r
-\r
- @return FFS File state\r
-\r
-**/\r
-EFI_FFS_FILE_STATE\r
-GetFileState (\r
- IN UINT8 ErasePolarity,\r
- IN EFI_FFS_FILE_HEADER *FfsHeader\r
- );\r
-\r
-/**\r
- Verify checksum of the firmware volume header.\r
-\r
- @param FvHeader Points to the firmware volume header to be checked\r
-\r
- @retval TRUE Checksum verification passed\r
- @retval FALSE Checksum verification failed\r
-\r
-**/\r
-BOOLEAN\r
-VerifyFvHeaderChecksum (\r
- IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader\r
- );\r
-\r
-/**\r
- Check if it's a valid FFS file header.\r
-\r
- @param ErasePolarity Erase polarity attribute of the firmware volume\r
- @param FfsHeader Points to the FFS file header to be checked\r
-\r
- @retval TRUE Valid FFS file header\r
- @retval FALSE Invalid FFS file header\r
-\r
-**/\r
-BOOLEAN\r
-IsValidFFSHeader (\r
- IN UINT8 ErasePolarity,\r
- IN EFI_FFS_FILE_HEADER *FfsHeader\r
- );\r
-\r
-/**\r
- Check if it's a valid FFS file.\r
- Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.\r
-\r
- @param FvDevice Cached FV image.\r
- @param FfsHeader Points to the FFS file to be checked\r
-\r
- @retval TRUE Valid FFS file\r
- @retval FALSE Invalid FFS file\r
-\r
-**/\r
-BOOLEAN\r
-IsValidFFSFile (\r
- IN FV_DEVICE *FvDevice,\r
- IN EFI_FFS_FILE_HEADER *FfsHeader\r
- );\r
-\r
-/**\r
- Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and\r
- copy the real length volume header into it.\r
-\r
- @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to\r
- read the volume header\r
- @param FwVolHeader Pointer to pointer to allocated buffer in which\r
- the volume header is returned.\r
-\r
- @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.\r
- @retval EFI_SUCCESS Successfully read volume header to the allocated\r
- buffer.\r
- @retval EFI_ACCESS_DENIED Read status of FV is not enabled.\r
- @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
- the file system could not be understood.\r
-**/\r
-EFI_STATUS\r
-GetFwVolHeader (\r
- IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,\r
- OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader\r
- );\r
-\r
-/**\r
- Convert the Buffer Address to LBA Entry Address.\r
-\r
- @param FvDevice Cached FvDevice\r
- @param BufferAddress Address of Buffer\r
- @param LbaListEntry Pointer to the got LBA entry that contains the address.\r
-\r
- @retval EFI_NOT_FOUND Buffer address is out of FvDevice.\r
- @retval EFI_SUCCESS LBA entry is found for Buffer address.\r
-\r
-**/\r
-EFI_STATUS\r
-Buffer2LbaEntry (\r
- IN FV_DEVICE *FvDevice,\r
- IN EFI_PHYSICAL_ADDRESS BufferAddress,\r
- OUT LBA_ENTRY **LbaListEntry\r
- );\r
-\r
-/**\r
- Convert the Buffer Address to LBA Address & Offset.\r
-\r
- @param FvDevice Cached FvDevice\r
- @param BufferAddress Address of Buffer\r
- @param Lba Pointer to the gob Lba value\r
- @param Offset Pointer to the got Offset\r
-\r
- @retval EFI_NOT_FOUND Buffer address is out of FvDevice.\r
- @retval EFI_SUCCESS LBA and Offset is found for Buffer address.\r
-\r
-**/\r
-EFI_STATUS\r
-Buffer2Lba (\r
- IN FV_DEVICE *FvDevice,\r
- IN EFI_PHYSICAL_ADDRESS BufferAddress,\r
- OUT EFI_LBA *Lba,\r
- OUT UINTN *Offset\r
- );\r
-\r
-/**\r
- Set File State in the FfsHeader.\r
-\r
- @param State File state to be set into FFS header.\r
- @param FfsHeader Points to the FFS file header\r
-\r
-**/\r
-VOID\r
-SetFileState (\r
- IN UINT8 State,\r
- IN EFI_FFS_FILE_HEADER *FfsHeader\r
- );\r
-\r
-/**\r
- Create a PAD File in the Free Space.\r
-\r
- @param FvDevice Firmware Volume Device.\r
- @param FreeSpaceEntry Indicating in which Free Space(Cache) the Pad file will be inserted.\r
- @param Size Pad file Size, not include the header.\r
- @param PadFileEntry The Ffs File Entry that points to this Pad File.\r
-\r
- @retval EFI_SUCCESS Successfully create a PAD file.\r
- @retval EFI_OUT_OF_RESOURCES No enough free space to create a PAD file.\r
- @retval EFI_INVALID_PARAMETER Size is not 8 byte alignment.\r
- @retval EFI_DEVICE_ERROR Free space is not erased.\r
-**/\r
-EFI_STATUS\r
-FvCreatePadFileInFreeSpace (\r
- IN FV_DEVICE *FvDevice,\r
- IN FREE_SPACE_ENTRY *FreeSpaceEntry,\r
- IN UINTN Size,\r
- OUT FFS_FILE_LIST_ENTRY **PadFileEntry\r
- );\r
-\r
-/**\r
- Create a new file within a PAD file area.\r
-\r
- @param FvDevice Firmware Volume Device.\r
- @param FfsFileBuffer A buffer that holds an FFS file,(it contains a File Header which is in init state).\r
- @param BufferSize The size of FfsFileBuffer.\r
- @param ActualFileSize The actual file length, it may not be multiples of 8.\r
- @param FileName The FFS File Name.\r
- @param FileType The FFS File Type.\r
- @param FileAttributes The Attributes of the FFS File to be created.\r
-\r
- @retval EFI_SUCCESS Successfully create a new file within the found PAD file area.\r
- @retval EFI_OUT_OF_RESOURCES No suitable PAD file is found.\r
- @retval other errors New file is created failed.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCreateNewFileInsidePadFile (\r
- IN FV_DEVICE *FvDevice,\r
- IN UINT8 *FfsFileBuffer,\r
- IN UINTN BufferSize,\r
- IN UINTN ActualFileSize,\r
- IN EFI_GUID *FileName,\r
- IN EFI_FV_FILETYPE FileType,\r
- IN EFI_FV_FILE_ATTRIBUTES FileAttributes\r
- );\r
-\r
-/**\r
- Write multiple files into FV in reliable method.\r
-\r
- @param FvDevice Firmware Volume Device.\r
- @param NumOfFiles Total File number to be written.\r
- @param FileData The array of EFI_FV_WRITE_FILE_DATA structure,\r
- used to get name, attributes, type, etc\r
- @param FileOperation The array of operation for each file.\r
-\r
- @retval EFI_SUCCESS Files are added into FV.\r
- @retval EFI_OUT_OF_RESOURCES No enough free PAD files to add the input files.\r
- @retval EFI_INVALID_PARAMETER File number is less than or equal to 1.\r
- @retval EFI_UNSUPPORTED File number exceeds the supported max numbers of files.\r
-\r
-**/\r
-EFI_STATUS\r
-FvCreateMultipleFiles (\r
- IN FV_DEVICE *FvDevice,\r
- IN UINTN NumOfFiles,\r
- IN EFI_FV_WRITE_FILE_DATA *FileData,\r
- IN BOOLEAN *FileOperation\r
- );\r
-\r
-/**\r
- Calculate the checksum for the FFS header.\r
-\r
- @param FfsHeader FFS File Header which needs to calculate the checksum\r
-\r
-**/\r
-VOID\r
-SetHeaderChecksum (\r
- IN EFI_FFS_FILE_HEADER *FfsHeader\r
- );\r
-\r
-/**\r
- Calculate the checksum for the FFS File.\r
-\r
- @param FfsHeader FFS File Header which needs to calculate the checksum\r
- @param ActualFileSize The whole Ffs File Length.\r
-\r
-**/\r
-VOID\r
-SetFileChecksum (\r
- IN EFI_FFS_FILE_HEADER *FfsHeader,\r
- IN UINTN ActualFileSize\r
- );\r
-\r
-/**\r
- Get the alignment value from File Attributes.\r
-\r
- @param FfsAttributes FFS attribute\r
-\r
- @return Alignment value.\r
-\r
-**/\r
-UINTN\r
-GetRequiredAlignment (\r
- IN EFI_FV_FILE_ATTRIBUTES FfsAttributes\r
- );\r
-\r
-/**\r
- Locate Pad File for writing, this is got from FV Cache.\r
-\r
- @param FvDevice Cached Firmware Volume.\r
- @param Size The required FFS file size.\r
- @param RequiredAlignment FFS File Data alignment requirement.\r
- @param PadSize Pointer to the size of leading Pad File.\r
- @param PadFileEntry Pointer to the Pad File Entry that meets the requirement.\r
-\r
- @retval EFI_SUCCESS The required pad file is found.\r
- @retval EFI_NOT_FOUND The required pad file can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvLocatePadFile (\r
- IN FV_DEVICE *FvDevice,\r
- IN UINTN Size,\r
- IN UINTN RequiredAlignment,\r
- OUT UINTN *PadSize,\r
- OUT FFS_FILE_LIST_ENTRY **PadFileEntry\r
- );\r
-\r
-/**\r
- Locate a suitable pad file for multiple file writing.\r
-\r
- @param FvDevice Cached Firmware Volume.\r
- @param NumOfFiles The number of Files that needed updating\r
- @param BufferSize The array of each file size.\r
- @param RequiredAlignment The array of of FFS File Data alignment requirement.\r
- @param PadSize The array of size of each leading Pad File.\r
- @param TotalSizeNeeded The totalsize that can hold these files.\r
- @param PadFileEntry Pointer to the Pad File Entry that meets the requirement.\r
-\r
- @retval EFI_SUCCESS The required pad file is found.\r
- @retval EFI_NOT_FOUND The required pad file can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvSearchSuitablePadFile (\r
- IN FV_DEVICE *FvDevice,\r
- IN UINTN NumOfFiles,\r
- IN UINTN *BufferSize,\r
- IN UINTN *RequiredAlignment,\r
- OUT UINTN *PadSize,\r
- OUT UINTN *TotalSizeNeeded,\r
- OUT FFS_FILE_LIST_ENTRY **PadFileEntry\r
- );\r
-\r
-/**\r
- Locate a Free Space entry which can hold these files, including\r
- meeting the alignment requirements.\r
-\r
- @param FvDevice Cached Firmware Volume.\r
- @param NumOfFiles The number of Files that needed updating\r
- @param BufferSize The array of each file size.\r
- @param RequiredAlignment The array of of FFS File Data alignment requirement.\r
- @param PadSize The array of size of each leading Pad File.\r
- @param TotalSizeNeeded The got total size that can hold these files.\r
- @param FreeSpaceEntry The Free Space Entry that can hold these files.\r
-\r
- @retval EFI_SUCCESS The free space entry is found.\r
- @retval EFI_NOT_FOUND The free space entry can't be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FvSearchSuitableFreeSpace (\r
- IN FV_DEVICE *FvDevice,\r
- IN UINTN NumOfFiles,\r
- IN UINTN *BufferSize,\r
- IN UINTN *RequiredAlignment,\r
- OUT UINTN *PadSize,\r
- OUT UINTN *TotalSizeNeeded,\r
- OUT FREE_SPACE_ENTRY **FreeSpaceEntry\r
- );\r
-\r
-/**\r
- Change FFS file header state and write to FV.\r
-\r
- @param FvDevice Cached FV image.\r
- @param FfsHeader Points to the FFS file header to be updated.\r
- @param State FFS file state to be set.\r
-\r
- @retval EFI_SUCCESS File state is writen into FV.\r
- @retval others File state can't be writen into FV.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateHeaderBit (\r
- IN FV_DEVICE *FvDevice,\r
- IN EFI_FFS_FILE_HEADER *FfsHeader,\r
- IN EFI_FFS_FILE_STATE State\r
- );\r
-\r
-/**\r
- Convert EFI_FV_FILE_ATTRIBUTES to FFS_FILE_ATTRIBUTES.\r
-\r
- @param FvFileAttrib The value of EFI_FV_FILE_ATTRIBUTES\r
- @param FfsFileAttrib Pointer to the got FFS_FILE_ATTRIBUTES value.\r
-\r
-**/\r
-VOID\r
-FvFileAttrib2FfsFileAttrib (\r
- IN EFI_FV_FILE_ATTRIBUTES FvFileAttrib,\r
- OUT UINT8 *FfsFileAttrib\r
- );\r
-\r
-#endif\r