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