]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Csm/Include/Protocol/FirmwareVolume.h
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Csm / 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 // Firmware Volume Protocol GUID definition
24 //
25 #define EFI_FIRMWARE_VOLUME_PROTOCOL_GUID \
26 { \
27 0x389F751F, 0x1838, 0x4388, {0x83, 0x90, 0xCD, 0x81, 0x54, 0xBD, 0x27, 0xF8 } \
28 }
29
30 #define FV_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '_')
31
32 typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL EFI_FIRMWARE_VOLUME_PROTOCOL;
33
34 //
35 // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
36 //
37 typedef UINT64 FRAMEWORK_EFI_FV_ATTRIBUTES;
38
39 //
40 // ************************************************************
41 // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
42 // ************************************************************
43 //
44 #define EFI_FV_READ_DISABLE_CAP 0x0000000000000001ULL
45 #define EFI_FV_READ_ENABLE_CAP 0x0000000000000002ULL
46 #define EFI_FV_READ_STATUS 0x0000000000000004ULL
47
48 #define EFI_FV_WRITE_DISABLE_CAP 0x0000000000000008ULL
49 #define EFI_FV_WRITE_ENABLE_CAP 0x0000000000000010ULL
50 #define EFI_FV_WRITE_STATUS 0x0000000000000020ULL
51
52 #define EFI_FV_LOCK_CAP 0x0000000000000040ULL
53 #define EFI_FV_LOCK_STATUS 0x0000000000000080ULL
54 #define EFI_FV_WRITE_POLICY_RELIABLE 0x0000000000000100ULL
55
56 #define EFI_FV_ALIGNMENT_CAP 0x0000000000008000ULL
57 #define EFI_FV_ALIGNMENT_2 0x0000000000010000ULL
58 #define EFI_FV_ALIGNMENT_4 0x0000000000020000ULL
59 #define EFI_FV_ALIGNMENT_8 0x0000000000040000ULL
60 #define EFI_FV_ALIGNMENT_16 0x0000000000080000ULL
61 #define EFI_FV_ALIGNMENT_32 0x0000000000100000ULL
62 #define EFI_FV_ALIGNMENT_64 0x0000000000200000ULL
63 #define EFI_FV_ALIGNMENT_128 0x0000000000400000ULL
64 #define EFI_FV_ALIGNMENT_256 0x0000000000800000ULL
65 #define EFI_FV_ALIGNMENT_512 0x0000000001000000ULL
66 #define EFI_FV_ALIGNMENT_1K 0x0000000002000000ULL
67 #define EFI_FV_ALIGNMENT_2K 0x0000000004000000ULL
68 #define EFI_FV_ALIGNMENT_4K 0x0000000008000000ULL
69 #define EFI_FV_ALIGNMENT_8K 0x0000000010000000ULL
70 #define EFI_FV_ALIGNMENT_16K 0x0000000020000000ULL
71 #define EFI_FV_ALIGNMENT_32K 0x0000000040000000ULL
72 #define EFI_FV_ALIGNMENT_64K 0x0000000080000000ULL
73
74 //
75 // Protocol API definitions
76 //
77
78 /**
79 Retrieves attributes, insures positive polarity of attribute bits, and returns
80 resulting attributes in an output parameter.
81
82 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
83 @param Attributes Output buffer containing attributes.
84
85 @retval EFI_SUCCESS The firmware volume attributes were returned.
86 **/
87 typedef
88 EFI_STATUS
89 (EFIAPI *FRAMEWORK_EFI_FV_GET_ATTRIBUTES)(
90 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
91 OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes
92 );
93
94 /**
95 Sets volume attributes
96
97 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
98 @param Attributes On input, Attributes is a pointer to an
99 EFI_FV_ATTRIBUTES containing the desired firmware
100 volume settings. On successful return, it contains
101 the new settings of the firmware volume. On
102 unsuccessful return, Attributes is not modified
103 and the firmware volume settings are not changed.
104
105 @retval EFI_INVALID_PARAMETER A bit in Attributes was invalid.
106 @retval EFI_SUCCESS The requested firmware volume attributes were set
107 and the resulting EFI_FV_ATTRIBUTES is returned in
108 Attributes.
109 @retval EFI_ACCESS_DENIED The Device is locked and does not permit modification.
110
111 **/
112 typedef
113 EFI_STATUS
114 (EFIAPI *FRAMEWORK_EFI_FV_SET_ATTRIBUTES)(
115 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
116 IN OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes
117 );
118
119 /**
120 Read the requested file (NameGuid) or file information from the firmware volume
121 and returns data in Buffer.
122
123 @param This The EFI_FIRMWARE_VOLUME_PROTOCOL instance.
124 @param NameGuid The pointer to EFI_GUID, which is the filename of
125 the file to read.
126 @param Buffer The pointer to pointer to buffer in which contents of file are returned.
127 <br>
128 If Buffer is NULL, only type, attributes, and size
129 are returned as there is no output buffer.
130 <br>
131 If Buffer != NULL and *Buffer == NULL, the output
132 buffer is allocated from BS pool by ReadFile.
133 <br>
134 If Buffer != NULL and *Buffer != NULL, the output
135 buffer has been allocated by the caller and is being
136 passed in.
137 @param BufferSize On input: The buffer size. On output: The size
138 required to complete the read.
139 @param FoundType The pointer to the type of the file whose data
140 is returned.
141 @param FileAttributes The pointer to attributes of the file whose data
142 is returned.
143 @param AuthenticationStatus The pointer to the authentication status of the data.
144
145 @retval EFI_SUCCESS The call completed successfully.
146 @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to contain the requested output.
147 The buffer filled, and the output is truncated.
148 @retval EFI_NOT_FOUND NameGuid was not found in the firmware volume.
149 @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to
150 access the firmware volume.
151 @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
152 @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.
153
154 **/
155 typedef
156 EFI_STATUS
157 (EFIAPI *FRAMEWORK_EFI_FV_READ_FILE)(
158 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
159 IN EFI_GUID *NameGuid,
160 IN OUT VOID **Buffer,
161 IN OUT UINTN *BufferSize,
162 OUT EFI_FV_FILETYPE *FoundType,
163 OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
164 OUT UINT32 *AuthenticationStatus
165 );
166
167 /**
168 Read the requested section from the specified file and returns data in Buffer.
169
170 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
171 @param NameGuid Filename identifying the file from which to read.
172 @param SectionType The section type to retrieve.
173 @param SectionInstance The instance of SectionType to retrieve.
174 @param Buffer Pointer to pointer to buffer in which contents of
175 a file are returned.
176 <br>
177 If Buffer is NULL, only type, attributes, and size
178 are returned as there is no output buffer.
179 <br>
180 If Buffer != NULL and *Buffer == NULL, the output
181 buffer is allocated from BS pool by ReadFile.
182 <br>
183 If Buffer != NULL and *Buffer != NULL, the output
184 buffer has been allocated by the caller and is being
185 passed in.
186 @param BufferSize The pointer to the buffer size passed in, and on
187 output the size required to complete the read.
188 @param AuthenticationStatus The pointer to the authentication status of the data.
189
190 @retval EFI_SUCCESS The call completed successfully.
191 @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to contain the requested output.
192 The buffer is filled and the output is truncated.
193 @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.
194 @retval EFI_NOT_FOUND The name was not found in the firmware volume.
195 @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to
196 access the firmware volume.
197 @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
198
199 **/
200 typedef
201 EFI_STATUS
202 (EFIAPI *FRAMEWORK_EFI_FV_READ_SECTION)(
203 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
204 IN EFI_GUID *NameGuid,
205 IN EFI_SECTION_TYPE SectionType,
206 IN UINTN SectionInstance,
207 IN OUT VOID **Buffer,
208 IN OUT UINTN *BufferSize,
209 OUT UINT32 *AuthenticationStatus
210 );
211
212 typedef UINT32 FRAMEWORK_EFI_FV_WRITE_POLICY;
213
214 #define FRAMEWORK_EFI_FV_UNRELIABLE_WRITE 0x00000000
215 #define FRAMEWORK_EFI_FV_RELIABLE_WRITE 0x00000001
216
217 typedef struct {
218 EFI_GUID *NameGuid;
219 EFI_FV_FILETYPE Type;
220 EFI_FV_FILE_ATTRIBUTES FileAttributes;
221 VOID *Buffer;
222 UINT32 BufferSize;
223 } FRAMEWORK_EFI_FV_WRITE_FILE_DATA;
224
225 /**
226 Write the supplied file (NameGuid) to the FV.
227
228 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
229 @param NumberOfFiles Indicates the number of file records pointed to
230 by FileData.
231 @param WritePolicy Indicates the level of reliability of the write
232 with respect to things like power failure events.
233 @param FileData A pointer to an array of EFI_FV_WRITE_FILE_DATA
234 structures. Each element in the array indicates
235 a file to write, and there are NumberOfFiles
236 elements in the input array.
237
238 @retval EFI_SUCCESS The write completed successfully.
239 @retval EFI_OUT_OF_RESOURCES The firmware volume does not have enough free
240 space to store file(s).
241 @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to
242 access the firmware volume.
243 @retval EFI_WRITE_PROTECTED The firmware volume is configured to disallow writes.
244 @retval EFI_NOT_FOUND A delete was requested, but the requested file was
245 not found in the firmware volume.
246 @retval EFI_INVALID_PARAMETER A delete was requested with a multiple file write.
247 An unsupported WritePolicy was requested.
248 An unknown file type was specified.
249 A file system specific error has occurred.
250 **/
251 typedef
252 EFI_STATUS
253 (EFIAPI *FRAMEWORK_EFI_FV_WRITE_FILE)(
254 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
255 IN UINT32 NumberOfFiles,
256 IN FRAMEWORK_EFI_FV_WRITE_POLICY WritePolicy,
257 IN FRAMEWORK_EFI_FV_WRITE_FILE_DATA *FileData
258 );
259
260 /**
261 Given the input key, search for the next matching file in the volume.
262
263 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
264 @param Key Pointer to a caller allocated buffer that contains
265 an implementation-specific key that is used to track
266 where to begin searching on successive calls.
267 @param FileType The pointer to the file type to filter for.
268 @param NameGuid The pointer to Guid filename of the file found.
269 @param Attributes The pointer to Attributes of the file found.
270 @param Size The pointer to Size in bytes of the file found.
271
272 @retval EFI_SUCCESS The output parameters are filled with data obtained from
273 the first matching file that was found.
274 @retval EFI_NOT_FOUND No files of type FileType were found.
275 @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to access
276 the firmware volume.
277 @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
278
279 **/
280 typedef
281 EFI_STATUS
282 (EFIAPI *FRAMEWORK_EFI_FV_GET_NEXT_FILE)(
283 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
284 IN OUT VOID *Key,
285 IN OUT EFI_FV_FILETYPE *FileType,
286 OUT EFI_GUID *NameGuid,
287 OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
288 OUT UINTN *Size
289 );
290
291 //
292 // Protocol interface structure
293 //
294 struct _EFI_FIRMWARE_VOLUME_PROTOCOL {
295 ///
296 /// Retrieves volume capabilities and current settings.
297 ///
298 FRAMEWORK_EFI_FV_GET_ATTRIBUTES GetVolumeAttributes;
299
300 ///
301 /// Modifies the current settings of the firmware volume.
302 ///
303 FRAMEWORK_EFI_FV_SET_ATTRIBUTES SetVolumeAttributes;
304
305 ///
306 /// Reads an entire file from the firmware volume.
307 ///
308 FRAMEWORK_EFI_FV_READ_FILE ReadFile;
309
310 ///
311 /// Reads a single section from a file into a buffer.
312 ///
313 FRAMEWORK_EFI_FV_READ_SECTION ReadSection;
314
315 ///
316 /// Writes an entire file into the firmware volume.
317 ///
318 FRAMEWORK_EFI_FV_WRITE_FILE WriteFile;
319
320 ///
321 /// Provides service to allow searching the firmware volume.
322 ///
323 FRAMEWORK_EFI_FV_GET_NEXT_FILE GetNextFile;
324
325 ///
326 /// Data field that indicates the size in bytes of the Key input buffer for
327 /// the GetNextFile() API.
328 ///
329 UINT32 KeySize;
330
331 ///
332 /// Handle of the parent firmware volume.
333 ///
334 EFI_HANDLE ParentHandle;
335 };
336
337 extern EFI_GUID gEfiFirmwareVolumeProtocolGuid;
338
339 #endif