3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Firmware File System protocol. Layers on top of Firmware
19 Block protocol to produce a file abstraction of FV based files.
27 #define FV2_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '2')
30 // Used to track all non-deleted files
34 EFI_FFS_FILE_HEADER
*FfsHeader
;
36 EFI_SECTION_EXTRACTION_PROTOCOL
*Sep
;
37 } FFS_FILE_LIST_ENTRY
;
41 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
;
43 EFI_FIRMWARE_VOLUME2_PROTOCOL Fv
;
45 EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
;
49 FFS_FILE_LIST_ENTRY
*LastKey
;
51 LIST_ENTRY FfsFileListHeader
;
56 #define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)
61 FvGetVolumeAttributes (
62 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
63 OUT EFI_FV_ATTRIBUTES
*Attributes
68 Retrieves attributes, insures positive polarity of attribute bits, returns
69 resulting attributes in output parameter
72 This - Calling context
73 Attributes - output buffer which contains attributes
76 EFI_SUCCESS - Successfully got volume attributes
83 FvSetVolumeAttributes (
84 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
85 IN OUT EFI_FV_ATTRIBUTES
*Attributes
90 Sets current attributes for volume
93 This - Calling context
94 Attributes - At input, contains attributes to be set. At output contains
98 EFI_UNSUPPORTED - Could not be set.
105 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
107 IN OUT EFI_FV_FILETYPE
*FileType
,
108 OUT EFI_GUID
*NameGuid
,
109 OUT EFI_FV_FILE_ATTRIBUTES
*Attributes
,
115 Given the input key, search for the next matching file in the volume.
118 This - Indicates the calling context.
119 FileType - FileType is a pointer to a caller allocated
120 EFI_FV_FILETYPE. The GetNextFile() API can filter it's
121 search for files based on the value of *FileType input.
122 A *FileType input of 0 causes GetNextFile() to search for
123 files of all types. If a file is found, the file's type
124 is returned in *FileType. *FileType is not modified if
126 Key - Key is a pointer to a caller allocated buffer that
127 contains implementation specific data that is used to
128 track where to begin the search for the next file.
129 The size of the buffer must be at least This->KeySize
130 bytes long. To reinitialize the search and begin from
131 the beginning of the firmware volume, the entire buffer
132 must be cleared to zero. Other than clearing the buffer
133 to initiate a new search, the caller must not modify the
134 data in the buffer between calls to GetNextFile().
135 NameGuid - NameGuid is a pointer to a caller allocated EFI_GUID.
136 If a file is found, the file's name is returned in
137 *NameGuid. *NameGuid is not modified if no file is
139 Attributes - Attributes is a pointer to a caller allocated
140 EFI_FV_FILE_ATTRIBUTES. If a file is found, the file's
141 attributes are returned in *Attributes. *Attributes is
142 not modified if no file is found.
143 Size - Size is a pointer to a caller allocated UINTN.
144 If a file is found, the file's size is returned in *Size.
145 *Size is not modified if no file is found.
148 EFI_SUCCESS - Successfully find the file.
149 EFI_DEVICE_ERROR - Device error.
150 EFI_ACCESS_DENIED - Fv could not read.
151 EFI_NOT_FOUND - No matching file found.
152 EFI_INVALID_PARAMETER - Invalid parameter
161 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
162 IN CONST EFI_GUID
*NameGuid
,
163 IN OUT VOID
**Buffer
,
164 IN OUT UINTN
*BufferSize
,
165 OUT EFI_FV_FILETYPE
*FoundType
,
166 OUT EFI_FV_FILE_ATTRIBUTES
*FileAttributes
,
167 OUT UINT32
*AuthenticationStatus
172 Locates a file in the firmware volume and
173 copies it to the supplied buffer.
176 This - Indicates the calling context.
177 NameGuid - Pointer to an EFI_GUID, which is the filename.
178 Buffer - Buffer is a pointer to pointer to a buffer in
179 which the file or section contents or are returned.
180 BufferSize - BufferSize is a pointer to caller allocated
181 UINTN. On input *BufferSize indicates the size
182 in bytes of the memory region pointed to by
183 Buffer. On output, *BufferSize contains the number
184 of bytes required to read the file.
185 FoundType - FoundType is a pointer to a caller allocated
186 EFI_FV_FILETYPE that on successful return from Read()
187 contains the type of file read. This output reflects
188 the file type irrespective of the value of the
190 FileAttributes - FileAttributes is a pointer to a caller allocated
191 EFI_FV_FILE_ATTRIBUTES. On successful return from
192 Read(), *FileAttributes contains the attributes of
194 AuthenticationStatus - AuthenticationStatus is a pointer to a caller
195 allocated UINTN in which the authentication status
198 EFI_SUCCESS - Successfully read to memory buffer.
199 EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
200 EFI_NOT_FOUND - Not found.
201 EFI_DEVICE_ERROR - Device error.
202 EFI_ACCESS_DENIED - Could not read.
203 EFI_INVALID_PARAMETER - Invalid parameter.
204 EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
212 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
213 IN CONST EFI_GUID
*NameGuid
,
214 IN EFI_SECTION_TYPE SectionType
,
215 IN UINTN SectionInstance
,
216 IN OUT VOID
**Buffer
,
217 IN OUT UINTN
*BufferSize
,
218 OUT UINT32
*AuthenticationStatus
223 Locates a section in a given FFS File and
224 copies it to the supplied buffer (not including section header).
227 This - Indicates the calling context.
228 NameGuid - Pointer to an EFI_GUID, which is the filename.
229 SectionType - Indicates the section type to return.
230 SectionInstance - Indicates which instance of sections with a type of
231 SectionType to return.
232 Buffer - Buffer is a pointer to pointer to a buffer in which
233 the file or section contents or are returned.
234 BufferSize - BufferSize is a pointer to caller allocated UINTN.
235 AuthenticationStatus -AuthenticationStatus is a pointer to a caller
236 allocated UINT32 in which the authentication status
240 EFI_SUCCESS - Successfully read the file section into buffer.
241 EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
242 EFI_NOT_FOUND - Section not found.
243 EFI_DEVICE_ERROR - Device error.
244 EFI_ACCESS_DENIED - Could not read.
245 EFI_INVALID_PARAMETER - Invalid parameter.
253 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
254 IN UINT32 NumberOfFiles
,
255 IN EFI_FV_WRITE_POLICY WritePolicy
,
256 IN EFI_FV_WRITE_FILE_DATA
*FileData
261 Writes one or more files to the firmware volume.
264 This - Indicates the calling context.
265 WritePolicy - WritePolicy indicates the level of reliability for
266 the write in the event of a power failure or other
267 system failure during the write operation.
268 FileData - FileData is an pointer to an array of EFI_FV_WRITE_DATA.
269 Each element of FileData[] represents a file to be written.
272 EFI_SUCCESS - Files successfully written to firmware volume
273 EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
274 EFI_DEVICE_ERROR - Device error.
275 EFI_WRITE_PROTECTED - Write protected.
276 EFI_NOT_FOUND - Not found.
277 EFI_INVALID_PARAMETER - Invalid parameter.
278 EFI_UNSUPPORTED - This function not supported.
286 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
287 IN CONST EFI_GUID
*InformationType
,
288 IN OUT UINTN
*BufferSize
,
294 Return information of type InformationType for the requested firmware
298 This - Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
299 InformationType - InformationType for requested.
300 BufferSize - On input, size of Buffer.On output, the amount of
301 data returned in Buffer.
302 Buffer - A poniter to the data buffer to return.
304 EFI_SUCCESS - Successfully got volume Information.
313 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
314 IN CONST EFI_GUID
*InformationType
,
316 IN CONST VOID
*Buffer
321 Set information of type InformationType for the requested firmware
325 This - Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
326 InformationType - InformationType for requested.
327 BufferSize - On input, size of Buffer.On output, the amount of
328 data returned in Buffer.
329 Buffer - A poniter to the data buffer to return.
331 EFI_SUCCESS - Successfully set volume Information.
340 EfiCheckSumUint8
= 0,
341 EfiCheckSumUint16
= 1,
342 EfiCheckSumUint32
= 2,
343 EfiCheckSumUint64
= 3,
344 EfiCheckSumMaximum
= 4
350 IN UINT8 ErasePolarity
,
357 Check if a block of buffer is erased
360 ErasePolarity - Erase polarity attribute of the firmware volume
361 Buffer - The buffer to be checked
362 BufferSize - Size of the buffer in bytes
365 TRUE - The block of buffer is erased
366 FALSE - The block of buffer is not erased
373 IN UINT8 ErasePolarity
,
374 IN EFI_FFS_FILE_HEADER
*FfsHeader
379 Get the FFS file state by checking the highest bit set in the header's state field
382 ErasePolarity - Erase polarity attribute of the firmware volume
383 FfsHeader - Points to the FFS file header
394 IN EFI_FFS_FILE_HEADER
*FfsHeader
399 Set the FFS file state.
402 State - The state to be set.
403 FfsHeader - Points to the FFS file header
412 VerifyFvHeaderChecksum (
413 IN EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
418 Verify checksum of the firmware volume header
421 FvHeader - Points to the firmware volume header to be checked
424 TRUE - Checksum verification passed
425 FALSE - Checksum verification failed
432 IN UINT8 ErasePolarity
,
433 IN EFI_FFS_FILE_HEADER
*FfsHeader
,
434 OUT EFI_FFS_FILE_STATE
*FileState
439 Check if it's a valid FFS file header
442 ErasePolarity - Erase polarity attribute of the firmware volume
443 FfsHeader - Points to the FFS file header to be checked
444 FileState - FFS file state to be returned
447 TRUE - Valid FFS file header
448 FALSE - Invalid FFS file header
455 IN UINT8 ErasePolarity
,
456 IN EFI_FFS_FILE_HEADER
*FfsHeader
461 Check if it's a valid FFS file.
462 Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.
465 ErasePolarity - Erase polarity attribute of the firmware volume
466 FfsHeader - Points to the FFS file to be checked
469 TRUE - Valid FFS file
470 FALSE - Invalid FFS file
477 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
,
478 OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
483 given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
484 copy the volume header into it.
487 Fvb - The FW_VOL_BLOCK_PROTOCOL instance from which to read the volume
489 FwVolHeader - Pointer to pointer to allocated buffer in which the volume
501 IN OUT FV_DEVICE
*FvDevice
506 Check if a FV is consistent and allocate cache
509 FvDevice - pointer to the FvDevice to be checked.
512 EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
513 EFI_SUCCESS - FV is consistent and cache is allocated.
514 EFI_VOLUME_CORRUPTED - File system is corrupted.