2 This file declares the Firmware Volume Protocol.
4 The Firmware Volume Protocol provides file-level access to the firmware volume.
5 Each firmware volume driver must produce an instance of the Firmware Volume
6 Protocol if the firmware volume is to be visible to the system. The Firmware
7 Volume Protocol also provides mechanisms for determining and modifying some
8 attributes of the firmware volume.
10 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
13 @par Revision Reference:
14 This protocol is defined in Firmware Volume specification.
19 #ifndef _FIRMWARE_VOLUME_H_
20 #define _FIRMWARE_VOLUME_H_
24 // Firmware Volume Protocol GUID definition
26 #define EFI_FIRMWARE_VOLUME_PROTOCOL_GUID \
28 0x389F751F, 0x1838, 0x4388, {0x83, 0x90, 0xCD, 0x81, 0x54, 0xBD, 0x27, 0xF8 } \
31 #define FV_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '_')
33 typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL EFI_FIRMWARE_VOLUME_PROTOCOL
;
36 // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
38 typedef UINT64 FRAMEWORK_EFI_FV_ATTRIBUTES
;
41 // ************************************************************
42 // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
43 // ************************************************************
45 #define EFI_FV_READ_DISABLE_CAP 0x0000000000000001ULL
46 #define EFI_FV_READ_ENABLE_CAP 0x0000000000000002ULL
47 #define EFI_FV_READ_STATUS 0x0000000000000004ULL
49 #define EFI_FV_WRITE_DISABLE_CAP 0x0000000000000008ULL
50 #define EFI_FV_WRITE_ENABLE_CAP 0x0000000000000010ULL
51 #define EFI_FV_WRITE_STATUS 0x0000000000000020ULL
53 #define EFI_FV_LOCK_CAP 0x0000000000000040ULL
54 #define EFI_FV_LOCK_STATUS 0x0000000000000080ULL
55 #define EFI_FV_WRITE_POLICY_RELIABLE 0x0000000000000100ULL
57 #define EFI_FV_ALIGNMENT_CAP 0x0000000000008000ULL
58 #define EFI_FV_ALIGNMENT_2 0x0000000000010000ULL
59 #define EFI_FV_ALIGNMENT_4 0x0000000000020000ULL
60 #define EFI_FV_ALIGNMENT_8 0x0000000000040000ULL
61 #define EFI_FV_ALIGNMENT_16 0x0000000000080000ULL
62 #define EFI_FV_ALIGNMENT_32 0x0000000000100000ULL
63 #define EFI_FV_ALIGNMENT_64 0x0000000000200000ULL
64 #define EFI_FV_ALIGNMENT_128 0x0000000000400000ULL
65 #define EFI_FV_ALIGNMENT_256 0x0000000000800000ULL
66 #define EFI_FV_ALIGNMENT_512 0x0000000001000000ULL
67 #define EFI_FV_ALIGNMENT_1K 0x0000000002000000ULL
68 #define EFI_FV_ALIGNMENT_2K 0x0000000004000000ULL
69 #define EFI_FV_ALIGNMENT_4K 0x0000000008000000ULL
70 #define EFI_FV_ALIGNMENT_8K 0x0000000010000000ULL
71 #define EFI_FV_ALIGNMENT_16K 0x0000000020000000ULL
72 #define EFI_FV_ALIGNMENT_32K 0x0000000040000000ULL
73 #define EFI_FV_ALIGNMENT_64K 0x0000000080000000ULL
76 // Protocol API definitions
80 Retrieves attributes, insures positive polarity of attribute bits, and returns
81 resulting attributes in an output parameter.
83 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
84 @param Attributes Output buffer containing attributes.
86 @retval EFI_SUCCESS The firmware volume attributes were returned.
90 (EFIAPI
*FRAMEWORK_EFI_FV_GET_ATTRIBUTES
)(
91 IN EFI_FIRMWARE_VOLUME_PROTOCOL
*This
,
92 OUT FRAMEWORK_EFI_FV_ATTRIBUTES
*Attributes
96 Sets volume attributes
98 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
99 @param Attributes On input, Attributes is a pointer to an
100 EFI_FV_ATTRIBUTES containing the desired firmware
101 volume settings. On successful return, it contains
102 the new settings of the firmware volume. On
103 unsuccessful return, Attributes is not modified
104 and the firmware volume settings are not changed.
106 @retval EFI_INVALID_PARAMETER A bit in Attributes was invalid.
107 @retval EFI_SUCCESS The requested firmware volume attributes were set
108 and the resulting EFI_FV_ATTRIBUTES is returned in
110 @retval EFI_ACCESS_DENIED The Device is locked and does not permit modification.
115 (EFIAPI
*FRAMEWORK_EFI_FV_SET_ATTRIBUTES
)(
116 IN EFI_FIRMWARE_VOLUME_PROTOCOL
*This
,
117 IN OUT FRAMEWORK_EFI_FV_ATTRIBUTES
*Attributes
121 Read the requested file (NameGuid) or file information from the firmware volume
122 and returns data in Buffer.
124 @param This The EFI_FIRMWARE_VOLUME_PROTOCOL instance.
125 @param NameGuid The pointer to EFI_GUID, which is the filename of
127 @param Buffer The pointer to pointer to buffer in which contents of file are returned.
129 If Buffer is NULL, only type, attributes, and size
130 are returned as there is no output buffer.
132 If Buffer != NULL and *Buffer == NULL, the output
133 buffer is allocated from BS pool by ReadFile.
135 If Buffer != NULL and *Buffer != NULL, the output
136 buffer has been allocated by the caller and is being
138 @param BufferSize On input: The buffer size. On output: The size
139 required to complete the read.
140 @param FoundType The pointer to the type of the file whose data
142 @param FileAttributes The pointer to attributes of the file whose data
144 @param AuthenticationStatus The pointer to the authentication status of the data.
146 @retval EFI_SUCCESS The call completed successfully.
147 @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to contain the requested output.
148 The buffer filled, and the output is truncated.
149 @retval EFI_NOT_FOUND NameGuid was not found in the firmware volume.
150 @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to
151 access the firmware volume.
152 @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
153 @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.
158 (EFIAPI
*FRAMEWORK_EFI_FV_READ_FILE
)(
159 IN EFI_FIRMWARE_VOLUME_PROTOCOL
*This
,
160 IN EFI_GUID
*NameGuid
,
161 IN OUT VOID
**Buffer
,
162 IN OUT UINTN
*BufferSize
,
163 OUT EFI_FV_FILETYPE
*FoundType
,
164 OUT EFI_FV_FILE_ATTRIBUTES
*FileAttributes
,
165 OUT UINT32
*AuthenticationStatus
169 Read the requested section from the specified file and returns data in Buffer.
171 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
172 @param NameGuid Filename identifying the file from which to read.
173 @param SectionType The section type to retrieve.
174 @param SectionInstance The instance of SectionType to retrieve.
175 @param Buffer Pointer to pointer to buffer in which contents of
178 If Buffer is NULL, only type, attributes, and size
179 are returned as there is no output buffer.
181 If Buffer != NULL and *Buffer == NULL, the output
182 buffer is allocated from BS pool by ReadFile.
184 If Buffer != NULL and *Buffer != NULL, the output
185 buffer has been allocated by the caller and is being
187 @param BufferSize The pointer to the buffer size passed in, and on
188 output the size required to complete the read.
189 @param AuthenticationStatus The pointer to the authentication status of the data.
191 @retval EFI_SUCCESS The call completed successfully.
192 @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to contain the requested output.
193 The buffer is filled and the output is truncated.
194 @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.
195 @retval EFI_NOT_FOUND The name was not found in the firmware volume.
196 @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to
197 access the firmware volume.
198 @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
203 (EFIAPI
*FRAMEWORK_EFI_FV_READ_SECTION
)(
204 IN EFI_FIRMWARE_VOLUME_PROTOCOL
*This
,
205 IN EFI_GUID
*NameGuid
,
206 IN EFI_SECTION_TYPE SectionType
,
207 IN UINTN SectionInstance
,
208 IN OUT VOID
**Buffer
,
209 IN OUT UINTN
*BufferSize
,
210 OUT UINT32
*AuthenticationStatus
213 typedef UINT32 FRAMEWORK_EFI_FV_WRITE_POLICY
;
215 #define FRAMEWORK_EFI_FV_UNRELIABLE_WRITE 0x00000000
216 #define FRAMEWORK_EFI_FV_RELIABLE_WRITE 0x00000001
220 EFI_FV_FILETYPE Type
;
221 EFI_FV_FILE_ATTRIBUTES FileAttributes
;
224 } FRAMEWORK_EFI_FV_WRITE_FILE_DATA
;
227 Write the supplied file (NameGuid) to the FV.
229 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
230 @param NumberOfFiles Indicates the number of file records pointed to
232 @param WritePolicy Indicates the level of reliability of the write
233 with respect to things like power failure events.
234 @param FileData A pointer to an array of EFI_FV_WRITE_FILE_DATA
235 structures. Each element in the array indicates
236 a file to write, and there are NumberOfFiles
237 elements in the input array.
239 @retval EFI_SUCCESS The write completed successfully.
240 @retval EFI_OUT_OF_RESOURCES The firmware volume does not have enough free
241 space to store file(s).
242 @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to
243 access the firmware volume.
244 @retval EFI_WRITE_PROTECTED The firmware volume is configured to disallow writes.
245 @retval EFI_NOT_FOUND A delete was requested, but the requested file was
246 not found in the firmware volume.
247 @retval EFI_INVALID_PARAMETER A delete was requested with a multiple file write.
248 An unsupported WritePolicy was requested.
249 An unknown file type was specified.
250 A file system specific error has occurred.
254 (EFIAPI
*FRAMEWORK_EFI_FV_WRITE_FILE
)(
255 IN EFI_FIRMWARE_VOLUME_PROTOCOL
*This
,
256 IN UINT32 NumberOfFiles
,
257 IN FRAMEWORK_EFI_FV_WRITE_POLICY WritePolicy
,
258 IN FRAMEWORK_EFI_FV_WRITE_FILE_DATA
*FileData
262 Given the input key, search for the next matching file in the volume.
264 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
265 @param Key Pointer to a caller allocated buffer that contains
266 an implementation-specific key that is used to track
267 where to begin searching on successive calls.
268 @param FileType The pointer to the file type to filter for.
269 @param NameGuid The pointer to Guid filename of the file found.
270 @param Attributes The pointer to Attributes of the file found.
271 @param Size The pointer to Size in bytes of the file found.
273 @retval EFI_SUCCESS The output parameters are filled with data obtained from
274 the first matching file that was found.
275 @retval EFI_NOT_FOUND No files of type FileType were found.
276 @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to access
278 @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
283 (EFIAPI
*FRAMEWORK_EFI_FV_GET_NEXT_FILE
)(
284 IN EFI_FIRMWARE_VOLUME_PROTOCOL
*This
,
286 IN OUT EFI_FV_FILETYPE
*FileType
,
287 OUT EFI_GUID
*NameGuid
,
288 OUT EFI_FV_FILE_ATTRIBUTES
*Attributes
,
293 // Protocol interface structure
295 struct _EFI_FIRMWARE_VOLUME_PROTOCOL
{
297 /// Retrieves volume capabilities and current settings.
299 FRAMEWORK_EFI_FV_GET_ATTRIBUTES GetVolumeAttributes
;
302 /// Modifies the current settings of the firmware volume.
304 FRAMEWORK_EFI_FV_SET_ATTRIBUTES SetVolumeAttributes
;
307 /// Reads an entire file from the firmware volume.
309 FRAMEWORK_EFI_FV_READ_FILE ReadFile
;
312 /// Reads a single section from a file into a buffer.
314 FRAMEWORK_EFI_FV_READ_SECTION ReadSection
;
317 /// Writes an entire file into the firmware volume.
319 FRAMEWORK_EFI_FV_WRITE_FILE WriteFile
;
322 /// Provides service to allow searching the firmware volume.
324 FRAMEWORK_EFI_FV_GET_NEXT_FILE GetNextFile
;
327 /// Data field that indicates the size in bytes of the Key input buffer for
328 /// the GetNextFile() API.
333 /// Handle of the parent firmware volume.
335 EFI_HANDLE ParentHandle
;
338 extern EFI_GUID gEfiFirmwareVolumeProtocolGuid
;