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