]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkPkg/Include/Protocol/FirmwareVolume.h
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8511 6f19259b...
[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
192 @retval EFI_WARN_BUFFER_TOO_SMALL
193 @retval EFI_OUT_OF_RESOURCES
194 @retval EFI_NOT_FOUND
195 @retval EFI_DEVICE_ERROR
196 @retval EFI_ACCESS_DENIED
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
236 @retval EFI_OUT_OF_RESOURCES
237 @retval EFI_DEVICE_ERROR
238 @retval EFI_WRITE_PROTECTED
239 @retval EFI_NOT_FOUND
240 @retval EFI_INVALID_PARAMETER
241
242 **/
243 typedef
244 EFI_STATUS
245 (EFIAPI *FRAMEWORK_EFI_FV_WRITE_FILE)(
246 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
247 IN UINT32 NumberOfFiles,
248 IN FRAMEWORK_EFI_FV_WRITE_POLICY WritePolicy,
249 IN FRAMEWORK_EFI_FV_WRITE_FILE_DATA *FileData
250 );
251
252 /**
253 Given the input key, search for the next matching file in the volume.
254
255 @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
256 @param Key Pointer to a caller allocated buffer that contains an implementation
257 specific key that is used to track where to begin searching on
258 successive calls.
259 @param FileType pointer to the file type to filter for
260 @param NameGuid pointer to Guid filename of the file found
261 @param Attributes pointer to Attributes of the file found
262 @param Size pointer to Size in bytes of the file found
263
264 @retval EFI_SUCCESS
265 @retval EFI_NOT_FOUND
266 @retval EFI_DEVICE_ERROR
267 @retval EFI_ACCESS_DENIED
268
269 **/
270 typedef
271 EFI_STATUS
272 (EFIAPI *FRAMEWORK_EFI_FV_GET_NEXT_FILE)(
273 IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
274 IN OUT VOID *Key,
275 IN OUT EFI_FV_FILETYPE *FileType,
276 OUT EFI_GUID *NameGuid,
277 OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
278 OUT UINTN *Size
279 );
280
281 //
282 // Protocol interface structure
283 //
284 struct _EFI_FIRMWARE_VOLUME_PROTOCOL {
285 ///
286 /// Retrieves volume capabilities and current settings.
287 ///
288 FRAMEWORK_EFI_FV_GET_ATTRIBUTES GetVolumeAttributes;
289 ///
290 /// Modifies the current settings of the firmware volume.
291 ///
292 FRAMEWORK_EFI_FV_SET_ATTRIBUTES SetVolumeAttributes;
293 ///
294 /// Reads an entire file from the firmware volume.
295 ///
296 FRAMEWORK_EFI_FV_READ_FILE ReadFile;
297 ///
298 /// Reads a single section from a file into a buffer.
299 ///
300 FRAMEWORK_EFI_FV_READ_SECTION ReadSection;
301 ///
302 /// Writes an entire file into the firmware volume.
303 ///
304 FRAMEWORK_EFI_FV_WRITE_FILE WriteFile;
305 ///
306 /// Provides service to allow searching the firmware volume.
307 ///
308 FRAMEWORK_EFI_FV_GET_NEXT_FILE GetNextFile;
309 ///
310 /// Data field that indicates the size in bytes of the Key input buffer for
311 /// the GetNextFile() API.
312 ///
313 UINT32 KeySize;
314 ///
315 /// Handle of the parent firmware volume.
316 ///
317 EFI_HANDLE ParentHandle;
318 };
319
320 extern EFI_GUID gEfiFirmwareVolumeProtocolGuid;
321
322 #endif