1 /** @file 2 These functions assist in parsing and manipulating a Firmware Volume. 3 4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR> 5 SPDX-License-Identifier: BSD-2-Clause-Patent 6 7 **/ 8 9 #ifndef _EFI_FV_LIB_H 10 #define _EFI_FV_LIB_H 11 12 // 13 // Include files 14 // 15 #include <string.h> 16 17 #include <Common/UefiBaseTypes.h> 18 #include <Common/PiFirmwareFile.h> 19 #include <Common/PiFirmwareVolume.h> 20 21 EFI_STATUS 22 InitializeFvLib ( 23 IN VOID *Fv, 24 IN UINT32 FvLength 25 ) 26 ; 27 28 EFI_STATUS 29 GetFvHeader ( 30 OUT EFI_FIRMWARE_VOLUME_HEADER **FvHeader, 31 OUT UINT32 *FvLength 32 ) 33 ; 34 35 EFI_STATUS 36 GetNextFile ( 37 IN EFI_FFS_FILE_HEADER *CurrentFile, 38 OUT EFI_FFS_FILE_HEADER **NextFile 39 ) 40 ; 41 42 EFI_STATUS 43 GetFileByName ( 44 IN EFI_GUID *FileName, 45 OUT EFI_FFS_FILE_HEADER **File 46 ) 47 ; 48 49 EFI_STATUS 50 GetFileByType ( 51 IN EFI_FV_FILETYPE FileType, 52 IN UINTN Instance, 53 OUT EFI_FFS_FILE_HEADER **File 54 ) 55 ; 56 57 EFI_STATUS 58 GetSectionByType ( 59 IN EFI_FFS_FILE_HEADER *File, 60 IN EFI_SECTION_TYPE SectionType, 61 IN UINTN Instance, 62 OUT EFI_FILE_SECTION_POINTER *Section 63 ) 64 ; 65 // 66 // will not parse compressed sections 67 // 68 EFI_STATUS 69 VerifyFv ( 70 IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader 71 ) 72 ; 73 74 EFI_STATUS 75 VerifyFfsFile ( 76 IN EFI_FFS_FILE_HEADER *FfsHeader 77 ) 78 ; 79 80 UINT32 81 GetFfsFileLength ( 82 EFI_FFS_FILE_HEADER *FfsHeader 83 ) 84 ; 85 86 UINT32 87 GetSectionFileLength ( 88 EFI_COMMON_SECTION_HEADER *SectionHeader 89 ) 90 ; 91 92 UINT32 93 GetFfsHeaderLength( 94 IN EFI_FFS_FILE_HEADER *FfsHeader 95 ) 96 ; 97 98 UINT32 99 GetSectionHeaderLength( 100 IN EFI_COMMON_SECTION_HEADER *SectionHeader 101 ) 102 ; 103 104 /*++ 105 106 Routine Description: 107 108 Verify the current pointer points to a FFS file header. 109 110 Arguments: 111 112 FfsHeader Pointer to an alleged FFS file. 113 114 Returns: 115 116 EFI_SUCCESS The Ffs header is valid. 117 EFI_NOT_FOUND This "file" is the beginning of free space. 118 EFI_VOLUME_CORRUPTED The Ffs header is not valid. 119 120 --*/ 121 UINT32 122 GetLength ( 123 UINT8 *ThreeByteLength 124 ) 125 ; 126 127 /*++ 128 129 Routine Description: 130 131 Converts a three byte length value into a UINT32. 132 133 Arguments: 134 135 ThreeByteLength Pointer to the first of the 3 byte length. 136 137 Returns: 138 139 UINT32 Size of the section 140 141 --*/ 142 EFI_STATUS 143 GetErasePolarity ( 144 OUT BOOLEAN *ErasePolarity 145 ) 146 ; 147 148 /*++ 149 150 Routine Description: 151 152 This function returns with the FV erase polarity. If the erase polarity 153 for a bit is 1, the function return TRUE. 154 155 Arguments: 156 157 ErasePolarity A pointer to the erase polarity. 158 159 Returns: 160 161 EFI_SUCCESS The function completed successfully. 162 EFI_INVALID_PARAMETER One of the input parameters was invalid. 163 164 --*/ 165 UINT8 166 GetFileState ( 167 IN BOOLEAN ErasePolarity, 168 IN EFI_FFS_FILE_HEADER *FfsHeader 169 ) 170 ; 171 172 /*++ 173 174 Routine Description: 175 176 This function returns a the highest state bit in the FFS that is set. 177 It in no way validate the FFS file. 178 179 Arguments: 180 181 ErasePolarity The erase polarity for the file state bits. 182 FfsHeader Pointer to a FFS file. 183 184 Returns: 185 186 UINT8 The hightest set state of the file. 187 188 --*/ 189 #endif 190