]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkPkg/Include/Protocol/FirmwareVolume.h
Remove IntelFrameworkModulePkg
[mirror_edk2.git] / IntelFrameworkPkg / Include / Protocol / FirmwareVolume.h
1 /** @file
2 This file declares the Firmware Volume Protocol.
3
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.
9
10 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
12
13 @par Revision Reference:
14 This protocol is defined in Firmware Volume specification.
15 Version 0.9.
16
17 **/
18
19 #ifndef _FIRMWARE_VOLUME_H_
20 #define _FIRMWARE_VOLUME_H_
21
22
23 //
24 // Firmware Volume Protocol GUID definition
25 //
26 #define EFI_FIRMWARE_VOLUME_PROTOCOL_GUID \
27 { \
28 0x389F751F, 0x1838, 0x4388, {0x83, 0x90, 0xCD, 0x81, 0x54, 0xBD, 0x27, 0xF8 } \
29 }
30
31 #define FV_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '_')
32
33 typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL EFI_FIRMWARE_VOLUME_PROTOCOL;
34
35 //
36 // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
37 //
38 typedef UINT64 FRAMEWORK_EFI_FV_ATTRIBUTES;
39
40 //
41 // ************************************************************
42 // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
43 // ************************************************************
44 //
45 #define EFI_FV_READ_DISABLE_CAP 0x0000000000000001ULL
46 #define EFI_FV_READ_ENABLE_CAP 0x0000000000000002ULL
47 #define EFI_FV_READ_STATUS 0x0000000000000004ULL
48
49 #define EFI_FV_WRITE_DISABLE_CAP 0x0000000000000008ULL
50 #define EFI_FV_WRITE_ENABLE_CAP 0x0000000000000010ULL
51 #define EFI_FV_WRITE_STATUS 0x0000000000000020ULL
52
53 #define EFI_FV_LOCK_CAP 0x0000000000000040ULL
54 #define EFI_FV_LOCK_STATUS 0x0000000000000080ULL
55 #define EFI_FV_WRITE_POLICY_RELIABLE 0x0000000000000100ULL
56
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
74
75 //
76 // Protocol API definitions
77 //
78
79 /**
80 Retrieves attributes, insures positive polarity of attribute bits, and returns
81 resulting attributes in an output parameter.
82
83 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
84 @param Attributes Output buffer containing attributes.
85
86 @retval EFI_SUCCESS The firmware volume attributes were returned.
87 **/
88 typedef
89 EFI_STATUS
90 (EFIAPI *FRAMEWORK_EFI_FV_GET_ATTRIBUTES)(
91 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
92 OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes
93 );
94
95 /**
96 Sets volume attributes
97
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.
105
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
109 Attributes.
110 @retval EFI_ACCESS_DENIED The Device is locked and does not permit modification.
111
112 **/
113 typedef
114 EFI_STATUS
115 (EFIAPI *FRAMEWORK_EFI_FV_SET_ATTRIBUTES)(
116 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
117 IN OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes
118 );
119
120 /**
121 Read the requested file (NameGuid) or file information from the firmware volume
122 and returns data in Buffer.
123
124 @param This The EFI_FIRMWARE_VOLUME_PROTOCOL instance.
125 @param NameGuid The pointer to EFI_GUID, which is the filename of
126 the file to read.
127 @param Buffer The pointer to pointer to buffer in which contents of file are returned.
128 <br>
129 If Buffer is NULL, only type, attributes, and size
130 are returned as there is no output buffer.
131 <br>
132 If Buffer != NULL and *Buffer == NULL, the output
133 buffer is allocated from BS pool by ReadFile.
134 <br>
135 If Buffer != NULL and *Buffer != NULL, the output
136 buffer has been allocated by the caller and is being
137 passed in.
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
141 is returned.
142 @param FileAttributes The pointer to attributes of the file whose data
143 is returned.
144 @param AuthenticationStatus The pointer to the authentication status of the data.
145
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.
154
155 **/
156 typedef
157 EFI_STATUS
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
166 );
167
168 /**
169 Read the requested section from the specified file and returns data in Buffer.
170
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
176 a file are returned.
177 <br>
178 If Buffer is NULL, only type, attributes, and size
179 are returned as there is no output buffer.
180 <br>
181 If Buffer != NULL and *Buffer == NULL, the output
182 buffer is allocated from BS pool by ReadFile.
183 <br>
184 If Buffer != NULL and *Buffer != NULL, the output
185 buffer has been allocated by the caller and is being
186 passed in.
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.
190
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.
199
200 **/
201 typedef
202 EFI_STATUS
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
211 );
212
213 typedef UINT32 FRAMEWORK_EFI_FV_WRITE_POLICY;
214
215 #define FRAMEWORK_EFI_FV_UNRELIABLE_WRITE 0x00000000
216 #define FRAMEWORK_EFI_FV_RELIABLE_WRITE 0x00000001
217
218 typedef struct {
219 EFI_GUID *NameGuid;
220 EFI_FV_FILETYPE Type;
221 EFI_FV_FILE_ATTRIBUTES FileAttributes;
222 VOID *Buffer;
223 UINT32 BufferSize;
224 } FRAMEWORK_EFI_FV_WRITE_FILE_DATA;
225
226 /**
227 Write the supplied file (NameGuid) to the FV.
228
229 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
230 @param NumberOfFiles Indicates the number of file records pointed to
231 by FileData.
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.
238
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.
251 **/
252 typedef
253 EFI_STATUS
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
259 );
260
261 /**
262 Given the input key, search for the next matching file in the volume.
263
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.
272
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
277 the firmware volume.
278 @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
279
280 **/
281 typedef
282 EFI_STATUS
283 (EFIAPI *FRAMEWORK_EFI_FV_GET_NEXT_FILE)(
284 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
285 IN OUT VOID *Key,
286 IN OUT EFI_FV_FILETYPE *FileType,
287 OUT EFI_GUID *NameGuid,
288 OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
289 OUT UINTN *Size
290 );
291
292 //
293 // Protocol interface structure
294 //
295 struct _EFI_FIRMWARE_VOLUME_PROTOCOL {
296 ///
297 /// Retrieves volume capabilities and current settings.
298 ///
299 FRAMEWORK_EFI_FV_GET_ATTRIBUTES GetVolumeAttributes;
300
301 ///
302 /// Modifies the current settings of the firmware volume.
303 ///
304 FRAMEWORK_EFI_FV_SET_ATTRIBUTES SetVolumeAttributes;
305
306 ///
307 /// Reads an entire file from the firmware volume.
308 ///
309 FRAMEWORK_EFI_FV_READ_FILE ReadFile;
310
311 ///
312 /// Reads a single section from a file into a buffer.
313 ///
314 FRAMEWORK_EFI_FV_READ_SECTION ReadSection;
315
316 ///
317 /// Writes an entire file into the firmware volume.
318 ///
319 FRAMEWORK_EFI_FV_WRITE_FILE WriteFile;
320
321 ///
322 /// Provides service to allow searching the firmware volume.
323 ///
324 FRAMEWORK_EFI_FV_GET_NEXT_FILE GetNextFile;
325
326 ///
327 /// Data field that indicates the size in bytes of the Key input buffer for
328 /// the GetNextFile() API.
329 ///
330 UINT32 KeySize;
331
332 ///
333 /// Handle of the parent firmware volume.
334 ///
335 EFI_HANDLE ParentHandle;
336 };
337
338 extern EFI_GUID gEfiFirmwareVolumeProtocolGuid;
339
340 #endif