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