]>
Commit | Line | Data |
---|---|---|
26a76fbc | 1 | /** @file\r |
3e5b4527 | 2 | Module produce FV2 on top of FV.\r |
3 | \r | |
4 | UEFI PI specification supersedes Inte's Framework Specification.\r | |
5 | EFI_FIRMWARE_VOLUME_PROTOCOL defined in Intel Framework Pkg is replaced by\r | |
6 | EFI_FIRMWARE_VOLUME2_PROTOCOL in MdePkg.\r | |
7 | This module produces FV2 on top of FV. This module is used on platform when both of\r | |
8 | these two conditions are true:\r | |
9 | 1) Framework module producing FV is present\r | |
10 | 2) And the rest of modules on the platform consume FV2\r | |
4259256b | 11 | \r |
584d5652 HT |
12 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r |
13 | This program and the accompanying materials\r | |
4259256b | 14 | are licensed and made available under the terms and conditions of the BSD License\r |
15 | which accompanies this distribution. The full text of the license may be found at\r | |
16 | http://opensource.org/licenses/bsd-license.php\r | |
17 | \r | |
18 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
19 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
20 | Module Name:\r | |
21 | \r | |
3e5b4527 | 22 | **/\r |
4259256b | 23 | \r |
24 | #include <PiDxe.h>\r | |
25 | #include <Protocol/FirmwareVolume2.h>\r | |
26 | #include <Protocol/FirmwareVolume.h>\r | |
27 | #include <Library/BaseLib.h>\r | |
28 | #include <Library/DebugLib.h>\r | |
29 | #include <Library/UefiBootServicesTableLib.h>\r | |
30 | #include <Library/UefiDriverEntryPoint.h>\r | |
31 | #include <Library/UefiLib.h>\r | |
32 | #include <Library/MemoryAllocationLib.h>\r | |
33 | \r | |
34 | /**\r | |
35 | \r | |
36 | Because of constraints imposed by the underlying firmware\r | |
37 | storage, an instance of the Firmware Volume Protocol may not\r | |
38 | be to able to support all possible variations of this\r | |
39 | architecture. These constraints and the current state of the\r | |
40 | firmware volume are exposed to the caller using the\r | |
41 | GetVolumeAttributes() function. GetVolumeAttributes() is\r | |
42 | callable only from TPL_NOTIFY and below. Behavior of\r | |
43 | GetVolumeAttributes() at any EFI_TPL above TPL_NOTIFY is\r | |
44 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r | |
45 | 2.0 specification.\r | |
46 | \r | |
47 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
48 | instance.\r | |
49 | \r | |
50 | @param FvAttributes Pointer to an EFI_FV_ATTRIBUTES in which\r | |
51 | the attributes and current settings are\r | |
52 | returned.\r | |
53 | \r | |
54 | \r | |
55 | @retval EFI_SUCCESS The firmware volume attributes were\r | |
56 | returned.\r | |
57 | \r | |
58 | **/\r | |
59 | EFI_STATUS\r | |
60 | EFIAPI\r | |
61 | Fv2GetVolumeAttributes (\r | |
62 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
63 | OUT EFI_FV_ATTRIBUTES *FvAttributes\r | |
64 | );\r | |
65 | \r | |
66 | \r | |
67 | /**\r | |
68 | The SetVolumeAttributes() function is used to set configurable\r | |
69 | firmware volume attributes. Only EFI_FV_READ_STATUS,\r | |
70 | EFI_FV_WRITE_STATUS, and EFI_FV_LOCK_STATUS may be modified, and\r | |
71 | then only in accordance with the declared capabilities. All\r | |
72 | other bits of FvAttributes are ignored on input. On successful\r | |
73 | return, all bits of *FvAttributes are valid and it contains the\r | |
74 | completed EFI_FV_ATTRIBUTES for the volume. To modify an\r | |
75 | attribute, the corresponding status bit in the EFI_FV_ATTRIBUTES\r | |
76 | is set to the desired value on input. The EFI_FV_LOCK_STATUS bit\r | |
77 | does not affect the ability to read or write the firmware\r | |
78 | volume. Rather, once the EFI_FV_LOCK_STATUS bit is set, it\r | |
79 | prevents further modification to all the attribute bits.\r | |
80 | SetVolumeAttributes() is callable only from TPL_NOTIFY and\r | |
81 | below. Behavior of SetVolumeAttributes() at any EFI_TPL above\r | |
82 | TPL_NOTIFY is undefined. Type EFI_TPL is defined in\r | |
83 | RaiseTPL() in the UEFI 2.0 specification.\r | |
84 | \r | |
85 | \r | |
86 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
87 | instance.\r | |
88 | \r | |
89 | @param FvAttributes On input, FvAttributes is a pointer to\r | |
90 | an EFI_FV_ATTRIBUTES containing the\r | |
91 | desired firmware volume settings. On\r | |
92 | successful return, it contains the new\r | |
93 | settings of the firmware volume. On\r | |
94 | unsuccessful return, FvAttributes is not\r | |
95 | modified and the firmware volume\r | |
96 | settings are not changed.\r | |
97 | \r | |
98 | @retval EFI_SUCCESS The requested firmware volume attributes\r | |
99 | were set and the resulting\r | |
100 | EFI_FV_ATTRIBUTES is returned in\r | |
101 | FvAttributes.\r | |
102 | \r | |
103 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_READ_STATUS\r | |
104 | is set to 1 on input, but the\r | |
105 | device does not support enabling\r | |
106 | reads\r | |
107 | (FvAttributes:EFI_FV_READ_ENABLE\r | |
108 | is clear on return from\r | |
109 | GetVolumeAttributes()). Actual\r | |
110 | volume attributes are unchanged.\r | |
111 | \r | |
112 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_READ_STATUS\r | |
113 | is cleared to 0 on input, but\r | |
114 | the device does not support\r | |
115 | disabling reads\r | |
116 | (FvAttributes:EFI_FV_READ_DISABL\r | |
117 | is clear on return from\r | |
118 | GetVolumeAttributes()). Actual\r | |
119 | volume attributes are unchanged.\r | |
120 | \r | |
121 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_WRITE_STATUS\r | |
122 | is set to 1 on input, but the\r | |
123 | device does not support enabling\r | |
124 | writes\r | |
125 | (FvAttributes:EFI_FV_WRITE_ENABL\r | |
126 | is clear on return from\r | |
127 | GetVolumeAttributes()). Actual\r | |
128 | volume attributes are unchanged.\r | |
129 | \r | |
130 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_WRITE_STATUS\r | |
131 | is cleared to 0 on input, but\r | |
132 | the device does not support\r | |
133 | disabling writes\r | |
134 | (FvAttributes:EFI_FV_WRITE_DISAB\r | |
135 | is clear on return from\r | |
136 | GetVolumeAttributes()). Actual\r | |
137 | volume attributes are unchanged.\r | |
138 | \r | |
139 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_LOCK_STATUS\r | |
140 | is set on input, but the device\r | |
141 | does not support locking\r | |
142 | (FvAttributes:EFI_FV_LOCK_CAP is\r | |
143 | clear on return from\r | |
144 | GetVolumeAttributes()). Actual\r | |
145 | volume attributes are unchanged.\r | |
146 | \r | |
147 | @retval EFI_ACCESS_DENIED Device is locked and does not\r | |
148 | allow attribute modification\r | |
149 | (FvAttributes:EFI_FV_LOCK_STATUS\r | |
150 | is set on return from\r | |
151 | GetVolumeAttributes()). Actual\r | |
152 | volume attributes are unchanged.\r | |
153 | \r | |
154 | **/\r | |
155 | EFI_STATUS\r | |
156 | EFIAPI\r | |
157 | Fv2SetVolumeAttributes (\r | |
158 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
159 | IN OUT EFI_FV_ATTRIBUTES *FvAttributes\r | |
160 | );\r | |
161 | \r | |
162 | \r | |
163 | /**\r | |
164 | ReadFile() is used to retrieve any file from a firmware volume\r | |
165 | during the DXE phase. The actual binary encoding of the file in\r | |
166 | the firmware volume media may be in any arbitrary format as long\r | |
26a76fbc LG |
167 | as it does the following: It is accessed using the Firmware\r |
168 | Volume Protocol. The image that is returned follows the image\r | |
4259256b | 169 | format defined in Code Definitions: PI Firmware File Format.\r |
170 | If the input value of Buffer==NULL, it indicates the caller is\r | |
171 | requesting only that the type, attributes, and size of the\r | |
172 | file be returned and that there is no output buffer. In this\r | |
173 | case, the following occurs:\r | |
174 | - BufferSize is returned with the size that is required to\r | |
175 | successfully complete the read.\r | |
176 | - The output parameters FoundType and *FileAttributes are\r | |
177 | returned with valid values.\r | |
178 | - The returned value of *AuthenticationStatus is undefined.\r | |
179 | \r | |
180 | If the input value of Buffer!=NULL, the output buffer is\r | |
181 | specified by a double indirection of the Buffer parameter. The\r | |
182 | input value of *Buffer is used to determine if the output\r | |
183 | buffer is caller allocated or is dynamically allocated by\r | |
184 | ReadFile(). If the input value of *Buffer!=NULL, it indicates\r | |
185 | the output buffer is caller allocated. In this case, the input\r | |
186 | value of *BufferSize indicates the size of the\r | |
187 | caller-allocated output buffer. If the output buffer is not\r | |
188 | large enough to contain the entire requested output, it is\r | |
189 | filled up to the point that the output buffer is exhausted and\r | |
190 | EFI_WARN_BUFFER_TOO_SMALL is returned, and then BufferSize is\r | |
191 | returned with the size required to successfully complete the\r | |
192 | read. All other output parameters are returned with valid\r | |
193 | values. If the input value of *Buffer==NULL, it indicates the\r | |
194 | output buffer is to be allocated by ReadFile(). In this case,\r | |
195 | ReadFile() will allocate an appropriately sized buffer from\r | |
196 | boot services pool memory, which will be returned in Buffer.\r | |
197 | The size of the new buffer is returned in BufferSize and all\r | |
198 | other output parameters are returned with valid values.\r | |
199 | ReadFile() is callable only from TPL_NOTIFY and below.\r | |
200 | Behavior of ReadFile() at any EFI_TPL above TPL_NOTIFY is\r | |
201 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r | |
202 | 2.0 specification.\r | |
203 | \r | |
204 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
205 | instance.\r | |
206 | \r | |
207 | @param NameGuid Pointer to an EFI_GUID, which is the file\r | |
208 | name. All firmware file names are EFI_GUIDs.\r | |
209 | A single firmware volume must not have two\r | |
210 | valid files with the same file name\r | |
211 | EFI_GUID.\r | |
212 | \r | |
213 | @param Buffer Pointer to a pointer to a buffer in which the\r | |
214 | file contents are returned, not including the\r | |
215 | file header.\r | |
216 | @param BufferSize Pointer to a caller-allocated UINTN. It\r | |
217 | indicates the size of the memory\r | |
218 | represented by Buffer.\r | |
219 | \r | |
220 | @param FoundType Pointer to a caller-allocated\r | |
221 | EFI_FV_FILETYPE.\r | |
222 | \r | |
223 | @param FileAttributes Pointer to a caller-allocated\r | |
224 | EFI_FV_FILE_ATTRIBUTES.\r | |
225 | \r | |
226 | @param AuthenticationStatus Pointer to a caller-allocated\r | |
227 | UINT32 in which the\r | |
228 | authentication status is\r | |
229 | returned.\r | |
230 | \r | |
231 | @retval EFI_SUCCESS The call completed successfully.\r | |
232 | \r | |
233 | @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to\r | |
234 | contain the requested\r | |
235 | output. The buffer is\r | |
236 | filled and the output is\r | |
237 | truncated.\r | |
238 | \r | |
239 | @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.\r | |
240 | \r | |
26a76fbc | 241 | @retval EFI_NOT_FOUND Name was not found in the firmware\r |
4259256b | 242 | volume.\r |
243 | \r | |
244 | @retval EFI_DEVICE_ERROR A hardware error occurred when\r | |
245 | attempting to access the firmware\r | |
246 | volume.\r | |
247 | \r | |
248 | @retval EFI_ACCESS_DENIED The firmware volume is configured to\r | |
249 | isallow reads.\r | |
250 | \r | |
251 | **/\r | |
252 | EFI_STATUS\r | |
253 | EFIAPI\r | |
254 | Fv2ReadFile (\r | |
255 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
256 | IN CONST EFI_GUID *NameGuid,\r | |
257 | IN OUT VOID **Buffer,\r | |
258 | IN OUT UINTN *BufferSize,\r | |
259 | OUT EFI_FV_FILETYPE *FoundType,\r | |
260 | OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r | |
261 | OUT UINT32 *AuthenticationStatus\r | |
262 | );\r | |
263 | \r | |
264 | /**\r | |
265 | ReadSection() is used to retrieve a specific section from a file\r | |
266 | within a firmware volume. The section returned is determined\r | |
267 | using a depth-first, left-to-right search algorithm through all\r | |
26a76fbc LG |
268 | sections found in the specified file. The output buffer is \r |
269 | specified by a double indirection of the Buffer parameter. \r | |
270 | The input value of Buffer is used to determine \r | |
271 | if the output buffer is caller allocated or is\r | |
4259256b | 272 | dynamically allocated by ReadSection(). If the input value of\r |
273 | Buffer!=NULL, it indicates that the output buffer is caller\r | |
274 | allocated. In this case, the input value of *BufferSize\r | |
275 | indicates the size of the caller-allocated output buffer. If\r | |
276 | the output buffer is not large enough to contain the entire\r | |
277 | requested output, it is filled up to the point that the output\r | |
278 | buffer is exhausted and EFI_WARN_BUFFER_TOO_SMALL is returned,\r | |
279 | and then BufferSize is returned with the size that is required\r | |
280 | to successfully complete the read. All other\r | |
281 | output parameters are returned with valid values. If the input\r | |
282 | value of *Buffer==NULL, it indicates the output buffer is to\r | |
283 | be allocated by ReadSection(). In this case, ReadSection()\r | |
284 | will allocate an appropriately sized buffer from boot services\r | |
285 | pool memory, which will be returned in *Buffer. The size of\r | |
286 | the new buffer is returned in *BufferSize and all other output\r | |
287 | parameters are returned with valid values. ReadSection() is\r | |
288 | callable only from TPL_NOTIFY and below. Behavior of\r | |
289 | ReadSection() at any EFI_TPL above TPL_NOTIFY is\r | |
290 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r | |
291 | 2.0 specification.\r | |
292 | \r | |
293 | \r | |
294 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
295 | instance.\r | |
296 | \r | |
297 | @param NameGuid Pointer to an EFI_GUID, which indicates the\r | |
298 | file name from which the requested section\r | |
299 | will be read.\r | |
300 | \r | |
301 | @param SectionType Indicates the section type to return.\r | |
302 | SectionType in conjunction with\r | |
303 | SectionInstance indicates which section to\r | |
304 | return.\r | |
305 | \r | |
306 | @param SectionInstance Indicates which instance of sections\r | |
307 | with a type of SectionType to return.\r | |
308 | SectionType in conjunction with\r | |
309 | SectionInstance indicates which\r | |
310 | section to return. SectionInstance is\r | |
311 | zero based.\r | |
312 | \r | |
313 | @param Buffer Pointer to a pointer to a buffer in which the\r | |
314 | section contents are returned, not including\r | |
315 | the section header.\r | |
316 | \r | |
317 | @param BufferSize Pointer to a caller-allocated UINTN. It\r | |
318 | indicates the size of the memory\r | |
319 | represented by Buffer.\r | |
320 | \r | |
321 | @param AuthenticationStatus Pointer to a caller-allocated\r | |
322 | UINT32 in which the authentication\r | |
323 | status is returned.\r | |
324 | \r | |
325 | \r | |
326 | @retval EFI_SUCCESS The call completed successfully.\r | |
327 | \r | |
328 | @retval EFI_WARN_BUFFER_TOO_SMALL The caller-allocated\r | |
329 | buffer is too small to\r | |
330 | contain the requested\r | |
331 | output. The buffer is\r | |
332 | filled and the output is\r | |
333 | truncated.\r | |
334 | \r | |
335 | @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.\r | |
336 | \r | |
337 | @retval EFI_NOT_FOUND The requested file was not found in\r | |
338 | the firmware volume. EFI_NOT_FOUND The\r | |
339 | requested section was not found in the\r | |
340 | specified file.\r | |
341 | \r | |
342 | @retval EFI_DEVICE_ERROR A hardware error occurred when\r | |
343 | attempting to access the firmware\r | |
344 | volume.\r | |
345 | \r | |
346 | @retval EFI_ACCESS_DENIED The firmware volume is configured to\r | |
347 | disallow reads. EFI_PROTOCOL_ERROR\r | |
348 | The requested section was not found,\r | |
349 | but the file could not be fully\r | |
350 | parsed because a required\r | |
351 | GUIDED_SECTION_EXTRACTION_PROTOCOL\r | |
352 | was not found. It is possible the\r | |
353 | requested section exists within the\r | |
354 | file and could be successfully\r | |
355 | extracted once the required\r | |
356 | GUIDED_SECTION_EXTRACTION_PROTOCOL\r | |
357 | is published.\r | |
358 | \r | |
359 | **/\r | |
360 | EFI_STATUS\r | |
361 | EFIAPI\r | |
362 | Fv2ReadSection (\r | |
363 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
364 | IN CONST EFI_GUID *NameGuid,\r | |
365 | IN EFI_SECTION_TYPE SectionType,\r | |
366 | IN UINTN SectionInstance,\r | |
367 | IN OUT VOID **Buffer,\r | |
368 | IN OUT UINTN *BufferSize,\r | |
369 | OUT UINT32 *AuthenticationStatus\r | |
370 | );\r | |
371 | \r | |
372 | /**\r | |
373 | WriteFile() is used to write one or more files to a firmware\r | |
374 | volume. Each file to be written is described by an\r | |
375 | EFI_FV_WRITE_FILE_DATA structure. The caller must ensure that\r | |
376 | any required alignment for all files listed in the FileData\r | |
377 | array is compatible with the firmware volume. Firmware volume\r | |
378 | capabilities can be determined using the GetVolumeAttributes()\r | |
379 | call. Similarly, if the WritePolicy is set to\r | |
380 | EFI_FV_RELIABLE_WRITE, the caller must check the firmware volume\r | |
381 | capabilities to ensure EFI_FV_RELIABLE_WRITE is supported by the\r | |
382 | firmware volume. EFI_FV_UNRELIABLE_WRITE must always be\r | |
383 | supported. Writing a file with a size of zero\r | |
384 | (FileData[n].BufferSize == 0) deletes the file from the firmware\r | |
385 | volume if it exists. Deleting a file must be done one at a time.\r | |
386 | Deleting a file as part of a multiple file write is not allowed.\r | |
387 | Platform Initialization Specification VOLUME 3 Shared\r | |
388 | Architectural Elements 84 August 21, 2006 Version 1.0\r | |
389 | WriteFile() is callable only from TPL_NOTIFY and below.\r | |
390 | Behavior of WriteFile() at any EFI_TPL above TPL_NOTIFY is\r | |
391 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI 2.0\r | |
392 | specification.\r | |
393 | \r | |
26a76fbc | 394 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL instance. \r |
4259256b | 395 | \r |
26a76fbc LG |
396 | @param NumberOfFiles Indicates the number of elements in the \r |
397 | array pointed to by FileData.\r | |
4259256b | 398 | \r |
399 | @param WritePolicy Indicates the level of reliability for the\r | |
400 | write in the event of a power failure or\r | |
401 | other system failure during the write\r | |
402 | operation.\r | |
403 | \r | |
404 | @param FileData Pointer to an array of\r | |
405 | EFI_FV_WRITE_FILE_DATA. Each element of\r | |
406 | FileData[] represents a file to be written.\r | |
407 | \r | |
408 | \r | |
409 | @retval EFI_SUCCESS The write completed successfully.\r | |
410 | \r | |
411 | @retval EFI_OUT_OF_RESOURCES The firmware volume does not\r | |
412 | have enough free space to\r | |
413 | storefile(s).\r | |
414 | \r | |
415 | @retval EFI_DEVICE_ERROR A hardware error occurred when\r | |
416 | attempting to access the firmware volume.\r | |
417 | \r | |
418 | @retval EFI_WRITE_PROTECTED The firmware volume is\r | |
419 | configured to disallow writes.\r | |
420 | \r | |
421 | @retval EFI_NOT_FOUND A delete was requested, but the\r | |
422 | requested file was not found in the\r | |
423 | firmware volume.\r | |
424 | \r | |
425 | @retval EFI_INVALID_PARAMETER A delete was requested with a\r | |
426 | multiple file write.\r | |
427 | \r | |
428 | @retval EFI_INVALID_PARAMETER An unsupported WritePolicy was\r | |
429 | requested.\r | |
430 | \r | |
431 | @retval EFI_INVALID_PARAMETER An unknown file type was\r | |
432 | specified.\r | |
433 | \r | |
434 | @retval EFI_INVALID_PARAMETER A file system specific error\r | |
435 | has occurred.\r | |
436 | \r | |
437 | **/\r | |
438 | EFI_STATUS \r | |
439 | EFIAPI\r | |
440 | Fv2WriteFile (\r | |
441 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
442 | IN UINT32 NumberOfFiles,\r | |
443 | IN EFI_FV_WRITE_POLICY WritePolicy,\r | |
444 | IN EFI_FV_WRITE_FILE_DATA *FileData\r | |
445 | );\r | |
446 | \r | |
447 | /**\r | |
448 | GetNextFile() is the interface that is used to search a firmware\r | |
449 | volume for a particular file. It is called successively until\r | |
450 | the desired file is located or the function returns\r | |
451 | EFI_NOT_FOUND. To filter uninteresting files from the output,\r | |
452 | the type of file to search for may be specified in FileType. For\r | |
453 | example, if *FileType is EFI_FV_FILETYPE_DRIVER, only files of\r | |
454 | this type will be returned in the output. If *FileType is\r | |
455 | EFI_FV_FILETYPE_ALL, no filtering of file types is done. The Key\r | |
456 | parameter is used to indicate a starting point of the search. If\r | |
457 | the buffer *Key is completely initialized to zero, the search\r | |
458 | re-initialized and starts at the beginning. Subsequent calls to\r | |
459 | GetNextFile() must maintain the value of *Key returned by the\r | |
460 | immediately previous call. The actual contents of *Key are\r | |
461 | implementation specific and no semantic content is implied.\r | |
462 | GetNextFile() is callable only from TPL_NOTIFY and below.\r | |
463 | Behavior of GetNextFile() at any EFI_TPL above TPL_NOTIFY is\r | |
464 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI 2.0\r | |
465 | specification. Status Codes Returned\r | |
466 | \r | |
467 | \r | |
468 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
26a76fbc LG |
469 | instance. \r |
470 | \r | |
471 | @param Key Pointer to a caller-allocated buffer\r | |
4259256b | 472 | that contains implementation-specific data that is\r |
473 | used to track where to begin the search for the\r | |
474 | next file. The size of the buffer must be at least\r | |
475 | This->KeySize bytes long. To re-initialize the\r | |
476 | search and begin from the beginning of the\r | |
477 | firmware volume, the entire buffer must be cleared\r | |
478 | to zero. Other than clearing the buffer to\r | |
479 | initiate a new search, the caller must not modify\r | |
480 | the data in the buffer between calls to\r | |
481 | GetNextFile().\r | |
482 | \r | |
483 | @param FileType Pointer to a caller-allocated\r | |
484 | EFI_FV_FILETYPE. The GetNextFile() API can\r | |
485 | filter its search for files based on the\r | |
486 | value of the FileType input. A *FileType\r | |
487 | input of EFI_FV_FILETYPE_ALL causes\r | |
488 | GetNextFile() to search for files of all\r | |
489 | types. If a file is found, the file's type\r | |
490 | is returned in FileType. *FileType is not\r | |
491 | modified if no file is found.\r | |
492 | \r | |
493 | @param NameGuid Pointer to a caller-allocated EFI_GUID. If a\r | |
494 | matching file is found, the file's name is\r | |
495 | returned in NameGuid. If no matching file is\r | |
496 | found, *NameGuid is not modified.\r | |
497 | \r | |
498 | @param Attributes Pointer to a caller-allocated\r | |
499 | EFI_FV_FILE_ATTRIBUTES. If a matching file\r | |
500 | is found, the file's attributes are returned\r | |
501 | in Attributes. If no matching file is found,\r | |
502 | Attributes is not modified. Type\r | |
503 | EFI_FV_FILE_ATTRIBUTES is defined in\r | |
504 | ReadFile().\r | |
505 | \r | |
506 | @param Size Pointer to a caller-allocated UINTN. If a\r | |
507 | matching file is found, the file's size is\r | |
508 | returned in *Size. If no matching file is found,\r | |
509 | Size is not modified.\r | |
510 | \r | |
511 | @retval EFI_SUCCESS The output parameters are filled with data\r | |
512 | obtained from the first matching file that\r | |
513 | was found.\r | |
514 | \r | |
515 | @retval FI_NOT_FOUND No files of type FileType were found.\r | |
516 | \r | |
517 | \r | |
518 | @retval EFI_DEVICE_ERROR A hardware error occurred when\r | |
519 | attempting to access the firmware\r | |
520 | volume.\r | |
521 | \r | |
522 | @retval EFI_ACCESS_DENIED The firmware volume is configured to\r | |
523 | disallow reads.\r | |
524 | \r | |
525 | \r | |
526 | **/\r | |
527 | EFI_STATUS\r | |
528 | EFIAPI\r | |
529 | Fv2GetNextFile (\r | |
530 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
531 | IN OUT VOID *Key,\r | |
532 | IN OUT EFI_FV_FILETYPE *FileType,\r | |
533 | OUT EFI_GUID *NameGuid,\r | |
534 | OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r | |
535 | OUT UINTN *Size\r | |
536 | );\r | |
537 | \r | |
538 | /**\r | |
539 | The GetInfo() function returns information of type\r | |
540 | InformationType for the requested firmware volume. If the volume\r | |
541 | does not support the requested information type, then\r | |
542 | EFI_UNSUPPORTED is returned. If the buffer is not large enough\r | |
543 | to hold the requested structure, EFI_BUFFER_TOO_SMALL is\r | |
544 | returned and the BufferSize is set to the size of buffer that is\r | |
545 | required to make the request. The information types defined by\r | |
546 | this specification are required information types that all file\r | |
547 | systems must support.\r | |
548 | \r | |
549 | @param This A pointer to the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
550 | instance that is the file handle the requested\r | |
551 | information is for.\r | |
552 | \r | |
553 | @param InformationType The type identifier for the\r | |
554 | information being requested.\r | |
555 | \r | |
556 | @param BufferSize On input, the size of Buffer. On output,\r | |
557 | the amount of data returned in Buffer. In\r | |
558 | both cases, the size is measured in bytes.\r | |
559 | \r | |
560 | @param Buffer A pointer to the data buffer to return. The\r | |
561 | buffer's type is indicated by InformationType.\r | |
562 | \r | |
563 | \r | |
564 | @retval EFI_SUCCESS The information was retrieved.\r | |
565 | \r | |
566 | @retval EFI_UNSUPPORTED The InformationType is not known.\r | |
567 | \r | |
568 | @retval EFI_NO_MEDIA The device has no medium.\r | |
569 | \r | |
570 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
571 | \r | |
572 | @retval EFI_VOLUME_CORRUPTED The file system structures are\r | |
573 | corrupted.\r | |
574 | \r | |
575 | @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to\r | |
576 | read the current directory\r | |
577 | entry. BufferSize has been\r | |
578 | updated with the size needed to\r | |
579 | complete the request.\r | |
580 | \r | |
581 | \r | |
582 | **/\r | |
583 | EFI_STATUS\r | |
584 | EFIAPI\r | |
585 | Fv2GetInfo (\r | |
586 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
587 | IN CONST EFI_GUID *InformationType,\r | |
588 | IN OUT UINTN *BufferSize,\r | |
589 | OUT VOID *Buffer\r | |
590 | );\r | |
591 | \r | |
592 | /**\r | |
593 | \r | |
594 | The SetInfo() function sets information of type InformationType\r | |
595 | on the requested firmware volume.\r | |
596 | \r | |
597 | \r | |
598 | @param This A pointer to the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
599 | instance that is the file handle the information\r | |
600 | is for.\r | |
601 | \r | |
602 | @param InformationType The type identifier for the\r | |
603 | information being set.\r | |
604 | \r | |
605 | @param BufferSize The size, in bytes, of Buffer.\r | |
606 | \r | |
607 | @param Buffer A pointer to the data buffer to write. The\r | |
608 | buffer's type is indicated by InformationType.\r | |
609 | \r | |
610 | @retval EFI_SUCCESS The information was set.\r | |
611 | \r | |
612 | @retval EFI_UNSUPPORTED The InformationType is not known.\r | |
613 | \r | |
614 | @retval EFI_NO_MEDIA The device has no medium.\r | |
615 | \r | |
616 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
617 | \r | |
618 | @retval EFI_VOLUME_CORRUPTED The file system structures are\r | |
619 | corrupted.\r | |
620 | \r | |
621 | \r | |
622 | @retval EFI_WRITE_PROTECTED The media is read only.\r | |
623 | \r | |
624 | @retval EFI_VOLUME_FULL The volume is full.\r | |
625 | \r | |
626 | @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the\r | |
627 | size of the type indicated by\r | |
628 | InformationType.\r | |
629 | \r | |
630 | **/\r | |
631 | EFI_STATUS\r | |
632 | EFIAPI\r | |
633 | Fv2SetInfo (\r | |
634 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
635 | IN CONST EFI_GUID *InformationType,\r | |
636 | IN UINTN BufferSize,\r | |
637 | IN CONST VOID *Buffer\r | |
638 | );\r | |
639 | \r | |
640 | //\r | |
641 | //\r | |
642 | //\r | |
a3a83173 | 643 | #define FIRMWARE_VOLUME2_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('f', 'v', '2', 't')\r |
4259256b | 644 | \r |
645 | typedef struct {\r | |
646 | UINTN Signature;\r | |
647 | EFI_FIRMWARE_VOLUME2_PROTOCOL FirmwareVolume2;\r | |
648 | EFI_FIRMWARE_VOLUME_PROTOCOL *FirmwareVolume;\r | |
649 | } FIRMWARE_VOLUME2_PRIVATE_DATA;\r | |
650 | \r | |
651 | #define FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS(a) CR (a, FIRMWARE_VOLUME2_PRIVATE_DATA, FirmwareVolume2, FIRMWARE_VOLUME2_PRIVATE_DATA_SIGNATURE)\r | |
652 | \r | |
653 | //\r | |
654 | // Firmware Volume Protocol template\r | |
655 | //\r | |
656 | EFI_EVENT mFv2Registration;\r | |
657 | \r | |
658 | FIRMWARE_VOLUME2_PRIVATE_DATA gFirmwareVolume2PrivateDataTemplate = {\r | |
659 | FIRMWARE_VOLUME2_PRIVATE_DATA_SIGNATURE,\r | |
660 | {\r | |
661 | Fv2GetVolumeAttributes,\r | |
662 | Fv2SetVolumeAttributes,\r | |
663 | Fv2ReadFile,\r | |
664 | Fv2ReadSection,\r | |
665 | Fv2WriteFile,\r | |
666 | Fv2GetNextFile,\r | |
667 | 0,\r | |
668 | NULL,\r | |
669 | Fv2GetInfo,\r | |
670 | Fv2SetInfo\r | |
671 | },\r | |
672 | NULL\r | |
673 | };\r | |
674 | \r | |
675 | //\r | |
676 | // Module globals\r | |
677 | //\r | |
26a76fbc LG |
678 | /**\r |
679 | This notification function is invoked when an instance of the\r | |
680 | EFI_FIRMWARE_VOLUME_PROTOCOL is produced. It installs another instance of the\r | |
681 | EFI_FIRMWARE_VOLUME2_PROTOCOL on the same handle.\r | |
682 | \r | |
683 | @param Event The event that occured\r | |
684 | @param Context Context of event. Not used in this nofication function.\r | |
4259256b | 685 | \r |
26a76fbc | 686 | **/\r |
4259256b | 687 | VOID\r |
688 | EFIAPI\r | |
689 | Fv2NotificationEvent (\r | |
690 | IN EFI_EVENT Event,\r | |
691 | IN VOID *Context\r | |
692 | )\r | |
693 | {\r | |
694 | EFI_STATUS Status;\r | |
695 | UINTN BufferSize;\r | |
696 | EFI_HANDLE Handle;\r | |
697 | FIRMWARE_VOLUME2_PRIVATE_DATA *Private;\r | |
698 | EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r | |
699 | \r | |
700 | while (TRUE) {\r | |
701 | BufferSize = sizeof (Handle);\r | |
702 | Status = gBS->LocateHandle (\r | |
703 | ByRegisterNotify,\r | |
704 | &gEfiFirmwareVolumeProtocolGuid,\r | |
705 | mFv2Registration,\r | |
706 | &BufferSize,\r | |
707 | &Handle\r | |
708 | );\r | |
709 | if (EFI_ERROR (Status)) {\r | |
710 | //\r | |
711 | // Exit Path of While Loop....\r | |
712 | //\r | |
713 | break;\r | |
714 | }\r | |
715 | \r | |
716 | //\r | |
717 | // Skip this handle if the Firmware Volume Protocol is already installed\r | |
718 | //\r | |
719 | Status = gBS->HandleProtocol (\r | |
720 | Handle,\r | |
721 | &gEfiFirmwareVolume2ProtocolGuid,\r | |
722 | (VOID **)&FirmwareVolume2\r | |
723 | );\r | |
724 | if (!EFI_ERROR (Status)) {\r | |
725 | continue;\r | |
726 | }\r | |
727 | \r | |
728 | //\r | |
729 | // Allocate private data structure\r | |
730 | //\r | |
731 | Private = AllocateCopyPool (sizeof (FIRMWARE_VOLUME2_PRIVATE_DATA), &gFirmwareVolume2PrivateDataTemplate);\r | |
732 | if (Private == NULL) {\r | |
733 | continue;\r | |
734 | }\r | |
735 | \r | |
736 | //\r | |
737 | // Retrieve the Firmware Volume2 Protocol\r | |
738 | //\r | |
739 | Status = gBS->HandleProtocol (\r | |
740 | Handle,\r | |
741 | &gEfiFirmwareVolumeProtocolGuid,\r | |
742 | (VOID **)&Private->FirmwareVolume\r | |
743 | );\r | |
744 | ASSERT_EFI_ERROR (Status);\r | |
745 | \r | |
746 | //\r | |
747 | // Fill in rest of private data structure\r | |
748 | //\r | |
749 | Private->FirmwareVolume2.KeySize = Private->FirmwareVolume->KeySize;\r | |
750 | Private->FirmwareVolume2.ParentHandle = Private->FirmwareVolume->ParentHandle;\r | |
751 | \r | |
752 | //\r | |
753 | // Install Firmware Volume Protocol onto same handle\r | |
754 | //\r | |
755 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
756 | &Handle,\r | |
757 | &gEfiFirmwareVolume2ProtocolGuid,\r | |
758 | &Private->FirmwareVolume2,\r | |
759 | NULL\r | |
760 | );\r | |
761 | ASSERT_EFI_ERROR (Status);\r | |
762 | }\r | |
763 | }\r | |
764 | \r | |
765 | \r | |
766 | /**\r | |
767 | The user Entry Point for DXE driver. The user code starts with this function\r | |
768 | as the real entry point for the image goes into a library that calls this \r | |
769 | function.\r | |
770 | \r | |
771 | @param[in] ImageHandle The firmware allocated handle for the EFI image. \r | |
772 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
773 | \r | |
774 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
775 | @retval other Some error occurs when executing this entry point.\r | |
776 | \r | |
777 | **/\r | |
778 | EFI_STATUS\r | |
779 | EFIAPI\r | |
780 | InitializeFirmwareVolume (\r | |
781 | IN EFI_HANDLE ImageHandle,\r | |
782 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
783 | )\r | |
784 | {\r | |
785 | EfiCreateProtocolNotifyEvent (\r | |
786 | &gEfiFirmwareVolumeProtocolGuid,\r | |
787 | TPL_CALLBACK,\r | |
788 | Fv2NotificationEvent,\r | |
789 | NULL,\r | |
790 | &mFv2Registration\r | |
791 | );\r | |
792 | return EFI_SUCCESS;\r | |
793 | }\r | |
794 | \r | |
cae5044b | 795 | /**\r |
796 | Convert FV attributes defined in Framework Specification\r | |
797 | to FV attributes defined in PI specification.\r | |
798 | \r | |
799 | @param FvAttributes The FV attributes defined in Framework Specification.\r | |
800 | \r | |
801 | @retval The FV attributes defined in PI Specification.\r | |
802 | **/\r | |
9e99ce32 | 803 | EFI_FV_ATTRIBUTES\r |
804 | FvAttributesToFv2Attributes (\r | |
805 | EFI_FV_ATTRIBUTES FvAttributes\r | |
806 | )\r | |
807 | {\r | |
808 | INTN Alignment;\r | |
809 | \r | |
810 | Alignment = LowBitSet64 (RShiftU64 (FvAttributes, 16) & 0xffff);\r | |
811 | if (Alignment != -1) {\r | |
812 | Alignment = Alignment << 16;\r | |
813 | } else {\r | |
814 | Alignment = 0;\r | |
815 | }\r | |
816 | FvAttributes = (FvAttributes & 0x1ff) | Alignment;\r | |
817 | \r | |
818 | return FvAttributes;\r | |
819 | }\r | |
820 | \r | |
4259256b | 821 | /**\r |
822 | \r | |
823 | Because of constraints imposed by the underlying firmware\r | |
824 | storage, an instance of the Firmware Volume Protocol may not\r | |
825 | be to able to support all possible variations of this\r | |
826 | architecture. These constraints and the current state of the\r | |
827 | firmware volume are exposed to the caller using the\r | |
828 | GetVolumeAttributes() function. GetVolumeAttributes() is\r | |
829 | callable only from TPL_NOTIFY and below. Behavior of\r | |
830 | GetVolumeAttributes() at any EFI_TPL above TPL_NOTIFY is\r | |
831 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r | |
832 | 2.0 specification.\r | |
833 | \r | |
834 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
835 | instance.\r | |
836 | \r | |
837 | @param FvAttributes Pointer to an EFI_FV_ATTRIBUTES in which\r | |
838 | the attributes and current settings are\r | |
839 | returned.\r | |
840 | \r | |
841 | \r | |
842 | @retval EFI_SUCCESS The firmware volume attributes were\r | |
843 | returned.\r | |
844 | \r | |
845 | **/\r | |
846 | EFI_STATUS\r | |
847 | EFIAPI\r | |
848 | Fv2GetVolumeAttributes (\r | |
849 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
850 | OUT EFI_FV_ATTRIBUTES *FvAttributes\r | |
851 | )\r | |
852 | {\r | |
853 | EFI_STATUS Status;\r | |
854 | FIRMWARE_VOLUME2_PRIVATE_DATA *Private;\r | |
855 | EFI_FIRMWARE_VOLUME_PROTOCOL *FirmwareVolume;\r | |
4259256b | 856 | \r |
857 | Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r | |
858 | FirmwareVolume = Private->FirmwareVolume;\r | |
859 | Status = FirmwareVolume->GetVolumeAttributes (\r | |
860 | FirmwareVolume,\r | |
861 | (FRAMEWORK_EFI_FV_ATTRIBUTES *)FvAttributes\r | |
862 | );\r | |
863 | if (!EFI_ERROR (Status)) {\r | |
cae5044b | 864 | *FvAttributes = FvAttributesToFv2Attributes (*FvAttributes);\r |
4259256b | 865 | }\r |
866 | return Status;\r | |
867 | }\r | |
868 | \r | |
869 | /**\r | |
870 | The SetVolumeAttributes() function is used to set configurable\r | |
871 | firmware volume attributes. Only EFI_FV_READ_STATUS,\r | |
872 | EFI_FV_WRITE_STATUS, and EFI_FV_LOCK_STATUS may be modified, and\r | |
873 | then only in accordance with the declared capabilities. All\r | |
874 | other bits of FvAttributes are ignored on input. On successful\r | |
875 | return, all bits of *FvAttributes are valid and it contains the\r | |
876 | completed EFI_FV_ATTRIBUTES for the volume. To modify an\r | |
877 | attribute, the corresponding status bit in the EFI_FV_ATTRIBUTES\r | |
878 | is set to the desired value on input. The EFI_FV_LOCK_STATUS bit\r | |
879 | does not affect the ability to read or write the firmware\r | |
880 | volume. Rather, once the EFI_FV_LOCK_STATUS bit is set, it\r | |
881 | prevents further modification to all the attribute bits.\r | |
882 | SetVolumeAttributes() is callable only from TPL_NOTIFY and\r | |
883 | below. Behavior of SetVolumeAttributes() at any EFI_TPL above\r | |
884 | TPL_NOTIFY is undefined. Type EFI_TPL is defined in\r | |
885 | RaiseTPL() in the UEFI 2.0 specification.\r | |
886 | \r | |
887 | \r | |
888 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
889 | instance.\r | |
890 | \r | |
891 | @param FvAttributes On input, FvAttributes is a pointer to\r | |
892 | an EFI_FV_ATTRIBUTES containing the\r | |
893 | desired firmware volume settings. On\r | |
894 | successful return, it contains the new\r | |
895 | settings of the firmware volume. On\r | |
896 | unsuccessful return, FvAttributes is not\r | |
897 | modified and the firmware volume\r | |
898 | settings are not changed.\r | |
899 | \r | |
900 | @retval EFI_SUCCESS The requested firmware volume attributes\r | |
901 | were set and the resulting\r | |
902 | EFI_FV_ATTRIBUTES is returned in\r | |
903 | FvAttributes.\r | |
904 | \r | |
905 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_READ_STATUS\r | |
906 | is set to 1 on input, but the\r | |
907 | device does not support enabling\r | |
908 | reads\r | |
909 | (FvAttributes:EFI_FV_READ_ENABLE\r | |
910 | is clear on return from\r | |
911 | GetVolumeAttributes()). Actual\r | |
912 | volume attributes are unchanged.\r | |
913 | \r | |
914 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_READ_STATUS\r | |
915 | is cleared to 0 on input, but\r | |
916 | the device does not support\r | |
917 | disabling reads\r | |
918 | (FvAttributes:EFI_FV_READ_DISABL\r | |
919 | is clear on return from\r | |
920 | GetVolumeAttributes()). Actual\r | |
921 | volume attributes are unchanged.\r | |
922 | \r | |
923 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_WRITE_STATUS\r | |
924 | is set to 1 on input, but the\r | |
925 | device does not support enabling\r | |
926 | writes\r | |
927 | (FvAttributes:EFI_FV_WRITE_ENABL\r | |
928 | is clear on return from\r | |
929 | GetVolumeAttributes()). Actual\r | |
930 | volume attributes are unchanged.\r | |
931 | \r | |
932 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_WRITE_STATUS\r | |
933 | is cleared to 0 on input, but\r | |
934 | the device does not support\r | |
935 | disabling writes\r | |
936 | (FvAttributes:EFI_FV_WRITE_DISAB\r | |
937 | is clear on return from\r | |
938 | GetVolumeAttributes()). Actual\r | |
939 | volume attributes are unchanged.\r | |
940 | \r | |
941 | @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_LOCK_STATUS\r | |
942 | is set on input, but the device\r | |
943 | does not support locking\r | |
944 | (FvAttributes:EFI_FV_LOCK_CAP is\r | |
945 | clear on return from\r | |
946 | GetVolumeAttributes()). Actual\r | |
947 | volume attributes are unchanged.\r | |
948 | \r | |
949 | @retval EFI_ACCESS_DENIED Device is locked and does not\r | |
950 | allow attribute modification\r | |
951 | (FvAttributes:EFI_FV_LOCK_STATUS\r | |
952 | is set on return from\r | |
953 | GetVolumeAttributes()). Actual\r | |
954 | volume attributes are unchanged.\r | |
955 | \r | |
956 | **/\r | |
957 | EFI_STATUS\r | |
958 | EFIAPI\r | |
959 | Fv2SetVolumeAttributes (\r | |
960 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
961 | IN OUT EFI_FV_ATTRIBUTES *FvAttributes\r | |
962 | )\r | |
963 | {\r | |
964 | FIRMWARE_VOLUME2_PRIVATE_DATA *Private;\r | |
965 | EFI_FIRMWARE_VOLUME_PROTOCOL *FirmwareVolume;\r | |
966 | FRAMEWORK_EFI_FV_ATTRIBUTES FrameworkFvAttributes; \r | |
9e99ce32 | 967 | EFI_STATUS Status;\r |
3e5b4527 | 968 | UINTN Shift;\r |
4259256b | 969 | \r |
26a76fbc | 970 | if ((*FvAttributes & (EFI_FV2_READ_LOCK_STATUS | EFI_FV2_WRITE_LOCK_STATUS)) != 0) {\r |
9e99ce32 | 971 | //\r |
972 | // Framework FV protocol does not support EFI_FV2_READ_LOCK_* | EFI_FV2_WRITE_LOCK_*\r | |
973 | //\r | |
974 | return EFI_INVALID_PARAMETER;\r | |
975 | }\r | |
976 | \r | |
977 | *FvAttributes = *FvAttributes & (EFI_FV2_READ_STATUS | EFI_FV2_WRITE_STATUS | EFI_FV2_LOCK_STATUS);\r | |
978 | \r | |
4259256b | 979 | Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r |
980 | FirmwareVolume = Private->FirmwareVolume;\r | |
981 | \r | |
3e5b4527 | 982 | FrameworkFvAttributes = (*FvAttributes & 0x1ff);\r |
983 | Shift = (UINTN) RShiftU64(*FvAttributes & EFI_FV2_ALIGNMENT, 16);\r | |
984 | FrameworkFvAttributes = FrameworkFvAttributes | LShiftU64 (EFI_FV_ALIGNMENT_2, Shift);\r | |
4259256b | 985 | \r |
9e99ce32 | 986 | Status = FirmwareVolume->SetVolumeAttributes (\r |
4259256b | 987 | FirmwareVolume,\r |
988 | &FrameworkFvAttributes\r | |
989 | );\r | |
9e99ce32 | 990 | \r |
991 | if (!EFI_ERROR (Status)) {\r | |
992 | *FvAttributes = FvAttributesToFv2Attributes (FrameworkFvAttributes);\r | |
993 | }\r | |
994 | \r | |
995 | return Status;\r | |
4259256b | 996 | }\r |
997 | \r | |
998 | /**\r | |
999 | ReadFile() is used to retrieve any file from a firmware volume\r | |
1000 | during the DXE phase. The actual binary encoding of the file in\r | |
1001 | the firmware volume media may be in any arbitrary format as long\r | |
26a76fbc LG |
1002 | as it does the following: It is accessed using the Firmware\r |
1003 | Volume Protocol. The image that is returned follows the image\r | |
4259256b | 1004 | format defined in Code Definitions: PI Firmware File Format.\r |
1005 | If the input value of Buffer==NULL, it indicates the caller is\r | |
1006 | requesting only that the type, attributes, and size of the\r | |
1007 | file be returned and that there is no output buffer. In this\r | |
1008 | case, the following occurs:\r | |
1009 | - BufferSize is returned with the size that is required to\r | |
1010 | successfully complete the read.\r | |
1011 | - The output parameters FoundType and *FileAttributes are\r | |
1012 | returned with valid values.\r | |
1013 | - The returned value of *AuthenticationStatus is undefined.\r | |
1014 | \r | |
1015 | If the input value of Buffer!=NULL, the output buffer is\r | |
1016 | specified by a double indirection of the Buffer parameter. The\r | |
1017 | input value of *Buffer is used to determine if the output\r | |
1018 | buffer is caller allocated or is dynamically allocated by\r | |
1019 | ReadFile(). If the input value of *Buffer!=NULL, it indicates\r | |
1020 | the output buffer is caller allocated. In this case, the input\r | |
1021 | value of *BufferSize indicates the size of the\r | |
1022 | caller-allocated output buffer. If the output buffer is not\r | |
1023 | large enough to contain the entire requested output, it is\r | |
1024 | filled up to the point that the output buffer is exhausted and\r | |
1025 | EFI_WARN_BUFFER_TOO_SMALL is returned, and then BufferSize is\r | |
1026 | returned with the size required to successfully complete the\r | |
1027 | read. All other output parameters are returned with valid\r | |
1028 | values. If the input value of *Buffer==NULL, it indicates the\r | |
1029 | output buffer is to be allocated by ReadFile(). In this case,\r | |
1030 | ReadFile() will allocate an appropriately sized buffer from\r | |
1031 | boot services pool memory, which will be returned in Buffer.\r | |
1032 | The size of the new buffer is returned in BufferSize and all\r | |
1033 | other output parameters are returned with valid values.\r | |
1034 | ReadFile() is callable only from TPL_NOTIFY and below.\r | |
1035 | Behavior of ReadFile() at any EFI_TPL above TPL_NOTIFY is\r | |
1036 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r | |
1037 | 2.0 specification.\r | |
1038 | \r | |
1039 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
1040 | instance.\r | |
1041 | \r | |
1042 | @param NameGuid Pointer to an EFI_GUID, which is the file\r | |
1043 | name. All firmware file names are EFI_GUIDs.\r | |
1044 | A single firmware volume must not have two\r | |
1045 | valid files with the same file name\r | |
1046 | EFI_GUID.\r | |
1047 | \r | |
1048 | @param Buffer Pointer to a pointer to a buffer in which the\r | |
1049 | file contents are returned, not including the\r | |
1050 | file header.\r | |
1051 | @param BufferSize Pointer to a caller-allocated UINTN. It\r | |
1052 | indicates the size of the memory\r | |
1053 | represented by Buffer.\r | |
1054 | \r | |
1055 | @param FoundType Pointer to a caller-allocated\r | |
1056 | EFI_FV_FILETYPE.\r | |
1057 | \r | |
1058 | @param FileAttributes Pointer to a caller-allocated\r | |
1059 | EFI_FV_FILE_ATTRIBUTES.\r | |
1060 | \r | |
1061 | @param AuthenticationStatus Pointer to a caller-allocated\r | |
1062 | UINT32 in which the\r | |
1063 | authentication status is\r | |
1064 | returned.\r | |
1065 | \r | |
1066 | @retval EFI_SUCCESS The call completed successfully.\r | |
1067 | \r | |
1068 | @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to\r | |
1069 | contain the requested\r | |
1070 | output. The buffer is\r | |
1071 | filled and the output is\r | |
1072 | truncated.\r | |
1073 | \r | |
1074 | @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.\r | |
1075 | \r | |
26a76fbc | 1076 | @retval EFI_NOT_FOUND Name was not found in the firmware\r |
4259256b | 1077 | volume.\r |
1078 | \r | |
1079 | @retval EFI_DEVICE_ERROR A hardware error occurred when\r | |
1080 | attempting to access the firmware\r | |
1081 | volume.\r | |
1082 | \r | |
1083 | @retval EFI_ACCESS_DENIED The firmware volume is configured to\r | |
1084 | isallow reads.\r | |
1085 | \r | |
1086 | **/\r | |
1087 | EFI_STATUS\r | |
1088 | EFIAPI\r | |
1089 | Fv2ReadFile (\r | |
1090 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
1091 | IN CONST EFI_GUID *NameGuid,\r | |
1092 | IN OUT VOID **Buffer,\r | |
1093 | IN OUT UINTN *BufferSize,\r | |
1094 | OUT EFI_FV_FILETYPE *FoundType,\r | |
1095 | OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r | |
1096 | OUT UINT32 *AuthenticationStatus\r | |
1097 | )\r | |
1098 | {\r | |
1099 | FIRMWARE_VOLUME2_PRIVATE_DATA *Private;\r | |
1100 | EFI_FIRMWARE_VOLUME_PROTOCOL *FirmwareVolume;\r | |
1101 | \r | |
1102 | Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r | |
1103 | FirmwareVolume = Private->FirmwareVolume;\r | |
1104 | \r | |
1105 | return FirmwareVolume->ReadFile (\r | |
1106 | FirmwareVolume,\r | |
1107 | (EFI_GUID *)NameGuid,\r | |
1108 | Buffer,\r | |
1109 | BufferSize,\r | |
1110 | FoundType,\r | |
1111 | FileAttributes,\r | |
1112 | AuthenticationStatus\r | |
1113 | );\r | |
1114 | }\r | |
1115 | \r | |
1116 | /**\r | |
1117 | ReadSection() is used to retrieve a specific section from a file\r | |
1118 | within a firmware volume. The section returned is determined\r | |
1119 | using a depth-first, left-to-right search algorithm through all\r | |
26a76fbc LG |
1120 | sections found in the specified file.The output buffer is specified \r |
1121 | by a double indirection of the Buffer parameter. The input value of Buffer \r | |
1122 | is used to determine if the output buffer is caller allocated or is\r | |
4259256b | 1123 | dynamically allocated by ReadSection(). If the input value of\r |
1124 | Buffer!=NULL, it indicates that the output buffer is caller\r | |
1125 | allocated. In this case, the input value of *BufferSize\r | |
1126 | indicates the size of the caller-allocated output buffer. If\r | |
1127 | the output buffer is not large enough to contain the entire\r | |
1128 | requested output, it is filled up to the point that the output\r | |
1129 | buffer is exhausted and EFI_WARN_BUFFER_TOO_SMALL is returned,\r | |
1130 | and then BufferSize is returned with the size that is required\r | |
1131 | to successfully complete the read. All other\r | |
1132 | output parameters are returned with valid values. If the input\r | |
1133 | value of *Buffer==NULL, it indicates the output buffer is to\r | |
1134 | be allocated by ReadSection(). In this case, ReadSection()\r | |
1135 | will allocate an appropriately sized buffer from boot services\r | |
1136 | pool memory, which will be returned in *Buffer. The size of\r | |
1137 | the new buffer is returned in *BufferSize and all other output\r | |
1138 | parameters are returned with valid values. ReadSection() is\r | |
1139 | callable only from TPL_NOTIFY and below. Behavior of\r | |
1140 | ReadSection() at any EFI_TPL above TPL_NOTIFY is\r | |
1141 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r | |
1142 | 2.0 specification.\r | |
1143 | \r | |
1144 | \r | |
1145 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
1146 | instance.\r | |
1147 | \r | |
1148 | @param NameGuid Pointer to an EFI_GUID, which indicates the\r | |
1149 | file name from which the requested section\r | |
1150 | will be read.\r | |
1151 | \r | |
1152 | @param SectionType Indicates the section type to return.\r | |
1153 | SectionType in conjunction with\r | |
1154 | SectionInstance indicates which section to\r | |
1155 | return.\r | |
1156 | \r | |
1157 | @param SectionInstance Indicates which instance of sections\r | |
1158 | with a type of SectionType to return.\r | |
1159 | SectionType in conjunction with\r | |
1160 | SectionInstance indicates which\r | |
1161 | section to return. SectionInstance is\r | |
1162 | zero based.\r | |
1163 | \r | |
1164 | @param Buffer Pointer to a pointer to a buffer in which the\r | |
1165 | section contents are returned, not including\r | |
1166 | the section header.\r | |
1167 | \r | |
1168 | @param BufferSize Pointer to a caller-allocated UINTN. It\r | |
1169 | indicates the size of the memory\r | |
1170 | represented by Buffer.\r | |
1171 | \r | |
1172 | @param AuthenticationStatus Pointer to a caller-allocated\r | |
1173 | UINT32 in which the authentication\r | |
1174 | status is returned.\r | |
1175 | \r | |
1176 | \r | |
1177 | @retval EFI_SUCCESS The call completed successfully.\r | |
1178 | \r | |
1179 | @retval EFI_WARN_BUFFER_TOO_SMALL The caller-allocated\r | |
1180 | buffer is too small to\r | |
1181 | contain the requested\r | |
1182 | output. The buffer is\r | |
1183 | filled and the output is\r | |
1184 | truncated.\r | |
1185 | \r | |
1186 | @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.\r | |
1187 | \r | |
1188 | @retval EFI_NOT_FOUND The requested file was not found in\r | |
1189 | the firmware volume. EFI_NOT_FOUND The\r | |
1190 | requested section was not found in the\r | |
1191 | specified file.\r | |
1192 | \r | |
1193 | @retval EFI_DEVICE_ERROR A hardware error occurred when\r | |
1194 | attempting to access the firmware\r | |
1195 | volume.\r | |
1196 | \r | |
1197 | @retval EFI_ACCESS_DENIED The firmware volume is configured to\r | |
1198 | disallow reads. EFI_PROTOCOL_ERROR\r | |
1199 | The requested section was not found,\r | |
1200 | but the file could not be fully\r | |
1201 | parsed because a required\r | |
1202 | GUIDED_SECTION_EXTRACTION_PROTOCOL\r | |
1203 | was not found. It is possible the\r | |
1204 | requested section exists within the\r | |
1205 | file and could be successfully\r | |
1206 | extracted once the required\r | |
1207 | GUIDED_SECTION_EXTRACTION_PROTOCOL\r | |
1208 | is published.\r | |
1209 | \r | |
1210 | **/\r | |
1211 | EFI_STATUS\r | |
1212 | EFIAPI\r | |
1213 | Fv2ReadSection (\r | |
1214 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
1215 | IN CONST EFI_GUID *NameGuid,\r | |
1216 | IN EFI_SECTION_TYPE SectionType,\r | |
1217 | IN UINTN SectionInstance,\r | |
1218 | IN OUT VOID **Buffer,\r | |
1219 | IN OUT UINTN *BufferSize,\r | |
1220 | OUT UINT32 *AuthenticationStatus\r | |
1221 | )\r | |
1222 | {\r | |
1223 | FIRMWARE_VOLUME2_PRIVATE_DATA *Private;\r | |
1224 | EFI_FIRMWARE_VOLUME_PROTOCOL *FirmwareVolume;\r | |
1225 | \r | |
1226 | Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r | |
1227 | FirmwareVolume = Private->FirmwareVolume;\r | |
1228 | \r | |
1229 | return FirmwareVolume->ReadSection (\r | |
1230 | FirmwareVolume,\r | |
1231 | (EFI_GUID *)NameGuid,\r | |
1232 | SectionType,\r | |
1233 | SectionInstance,\r | |
1234 | Buffer,\r | |
1235 | BufferSize,\r | |
1236 | AuthenticationStatus\r | |
1237 | );\r | |
1238 | }\r | |
1239 | \r | |
1240 | /**\r | |
1241 | WriteFile() is used to write one or more files to a firmware\r | |
1242 | volume. Each file to be written is described by an\r | |
1243 | EFI_FV_WRITE_FILE_DATA structure. The caller must ensure that\r | |
1244 | any required alignment for all files listed in the FileData\r | |
1245 | array is compatible with the firmware volume. Firmware volume\r | |
1246 | capabilities can be determined using the GetVolumeAttributes()\r | |
1247 | call. Similarly, if the WritePolicy is set to\r | |
1248 | EFI_FV_RELIABLE_WRITE, the caller must check the firmware volume\r | |
1249 | capabilities to ensure EFI_FV_RELIABLE_WRITE is supported by the\r | |
1250 | firmware volume. EFI_FV_UNRELIABLE_WRITE must always be\r | |
1251 | supported. Writing a file with a size of zero\r | |
1252 | (FileData[n].BufferSize == 0) deletes the file from the firmware\r | |
1253 | volume if it exists. Deleting a file must be done one at a time.\r | |
1254 | Deleting a file as part of a multiple file write is not allowed.\r | |
1255 | Platform Initialization Specification VOLUME 3 Shared\r | |
1256 | Architectural Elements 84 August 21, 2006 Version 1.0\r | |
1257 | WriteFile() is callable only from TPL_NOTIFY and below.\r | |
1258 | Behavior of WriteFile() at any EFI_TPL above TPL_NOTIFY is\r | |
1259 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI 2.0\r | |
1260 | specification.\r | |
1261 | \r | |
26a76fbc LG |
1262 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL instance. \r |
1263 | \r | |
1264 | @param NumberOfFiles Indicates the number of\r | |
1265 | elements in the array pointed to by FileData.\r | |
4259256b | 1266 | \r |
1267 | \r | |
1268 | @param WritePolicy Indicates the level of reliability for the\r | |
1269 | write in the event of a power failure or\r | |
1270 | other system failure during the write\r | |
1271 | operation.\r | |
1272 | \r | |
1273 | @param FileData Pointer to an array of\r | |
1274 | EFI_FV_WRITE_FILE_DATA. Each element of\r | |
1275 | FileData[] represents a file to be written.\r | |
1276 | \r | |
1277 | \r | |
1278 | @retval EFI_SUCCESS The write completed successfully.\r | |
1279 | \r | |
1280 | @retval EFI_OUT_OF_RESOURCES The firmware volume does not\r | |
1281 | have enough free space to\r | |
1282 | storefile(s).\r | |
1283 | \r | |
1284 | @retval EFI_DEVICE_ERROR A hardware error occurred when\r | |
1285 | attempting to access the firmware volume.\r | |
1286 | \r | |
1287 | @retval EFI_WRITE_PROTECTED The firmware volume is\r | |
1288 | configured to disallow writes.\r | |
1289 | \r | |
1290 | @retval EFI_NOT_FOUND A delete was requested, but the\r | |
1291 | requested file was not found in the\r | |
1292 | firmware volume.\r | |
1293 | \r | |
1294 | @retval EFI_INVALID_PARAMETER A delete was requested with a\r | |
1295 | multiple file write.\r | |
1296 | \r | |
1297 | @retval EFI_INVALID_PARAMETER An unsupported WritePolicy was\r | |
1298 | requested.\r | |
1299 | \r | |
1300 | @retval EFI_INVALID_PARAMETER An unknown file type was\r | |
1301 | specified.\r | |
1302 | \r | |
1303 | @retval EFI_INVALID_PARAMETER A file system specific error\r | |
1304 | has occurred.\r | |
1305 | \r | |
1306 | **/\r | |
1307 | EFI_STATUS \r | |
1308 | EFIAPI\r | |
1309 | Fv2WriteFile (\r | |
1310 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
1311 | IN UINT32 NumberOfFiles,\r | |
1312 | IN EFI_FV_WRITE_POLICY WritePolicy,\r | |
1313 | IN EFI_FV_WRITE_FILE_DATA *FileData\r | |
1314 | )\r | |
1315 | {\r | |
1316 | FIRMWARE_VOLUME2_PRIVATE_DATA *Private;\r | |
1317 | EFI_FIRMWARE_VOLUME_PROTOCOL *FirmwareVolume;\r | |
1318 | \r | |
1319 | Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r | |
1320 | FirmwareVolume = Private->FirmwareVolume;\r | |
1321 | \r | |
1322 | return FirmwareVolume->WriteFile (\r | |
1323 | FirmwareVolume,\r | |
1324 | NumberOfFiles,\r | |
1325 | WritePolicy,\r | |
1326 | (FRAMEWORK_EFI_FV_WRITE_FILE_DATA *)FileData\r | |
1327 | );\r | |
1328 | }\r | |
1329 | \r | |
1330 | /**\r | |
1331 | GetNextFile() is the interface that is used to search a firmware\r | |
1332 | volume for a particular file. It is called successively until\r | |
1333 | the desired file is located or the function returns\r | |
1334 | EFI_NOT_FOUND. To filter uninteresting files from the output,\r | |
1335 | the type of file to search for may be specified in FileType. For\r | |
1336 | example, if *FileType is EFI_FV_FILETYPE_DRIVER, only files of\r | |
1337 | this type will be returned in the output. If *FileType is\r | |
1338 | EFI_FV_FILETYPE_ALL, no filtering of file types is done. The Key\r | |
1339 | parameter is used to indicate a starting point of the search. If\r | |
1340 | the buffer *Key is completely initialized to zero, the search\r | |
1341 | re-initialized and starts at the beginning. Subsequent calls to\r | |
1342 | GetNextFile() must maintain the value of *Key returned by the\r | |
1343 | immediately previous call. The actual contents of *Key are\r | |
1344 | implementation specific and no semantic content is implied.\r | |
1345 | GetNextFile() is callable only from TPL_NOTIFY and below.\r | |
1346 | Behavior of GetNextFile() at any EFI_TPL above TPL_NOTIFY is\r | |
1347 | undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI 2.0\r | |
1348 | specification. Status Codes Returned\r | |
1349 | \r | |
1350 | \r | |
1351 | @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
26a76fbc LG |
1352 | instance. \r |
1353 | \r | |
1354 | @param Key Pointer to a caller-allocated buffer\r | |
4259256b | 1355 | that contains implementation-specific data that is\r |
1356 | used to track where to begin the search for the\r | |
1357 | next file. The size of the buffer must be at least\r | |
1358 | This->KeySize bytes long. To re-initialize the\r | |
1359 | search and begin from the beginning of the\r | |
1360 | firmware volume, the entire buffer must be cleared\r | |
1361 | to zero. Other than clearing the buffer to\r | |
1362 | initiate a new search, the caller must not modify\r | |
1363 | the data in the buffer between calls to\r | |
1364 | GetNextFile().\r | |
1365 | \r | |
1366 | @param FileType Pointer to a caller-allocated\r | |
1367 | EFI_FV_FILETYPE. The GetNextFile() API can\r | |
1368 | filter its search for files based on the\r | |
1369 | value of the FileType input. A *FileType\r | |
1370 | input of EFI_FV_FILETYPE_ALL causes\r | |
1371 | GetNextFile() to search for files of all\r | |
1372 | types. If a file is found, the file's type\r | |
1373 | is returned in FileType. *FileType is not\r | |
1374 | modified if no file is found.\r | |
1375 | \r | |
1376 | @param NameGuid Pointer to a caller-allocated EFI_GUID. If a\r | |
1377 | matching file is found, the file's name is\r | |
1378 | returned in NameGuid. If no matching file is\r | |
1379 | found, *NameGuid is not modified.\r | |
1380 | \r | |
1381 | @param Attributes Pointer to a caller-allocated\r | |
1382 | EFI_FV_FILE_ATTRIBUTES. If a matching file\r | |
1383 | is found, the file's attributes are returned\r | |
1384 | in Attributes. If no matching file is found,\r | |
1385 | Attributes is not modified. Type\r | |
1386 | EFI_FV_FILE_ATTRIBUTES is defined in\r | |
1387 | ReadFile().\r | |
1388 | \r | |
1389 | @param Size Pointer to a caller-allocated UINTN. If a\r | |
1390 | matching file is found, the file's size is\r | |
1391 | returned in *Size. If no matching file is found,\r | |
1392 | Size is not modified.\r | |
1393 | \r | |
1394 | @retval EFI_SUCCESS The output parameters are filled with data\r | |
1395 | obtained from the first matching file that\r | |
1396 | was found.\r | |
1397 | \r | |
1398 | @retval FI_NOT_FOUND No files of type FileType were found.\r | |
1399 | \r | |
1400 | \r | |
1401 | @retval EFI_DEVICE_ERROR A hardware error occurred when\r | |
1402 | attempting to access the firmware\r | |
1403 | volume.\r | |
1404 | \r | |
1405 | @retval EFI_ACCESS_DENIED The firmware volume is configured to\r | |
1406 | disallow reads.\r | |
1407 | \r | |
1408 | \r | |
1409 | **/\r | |
1410 | EFI_STATUS\r | |
1411 | EFIAPI\r | |
1412 | Fv2GetNextFile (\r | |
1413 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
1414 | IN OUT VOID *Key,\r | |
1415 | IN OUT EFI_FV_FILETYPE *FileType,\r | |
1416 | OUT EFI_GUID *NameGuid,\r | |
1417 | OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r | |
1418 | OUT UINTN *Size\r | |
1419 | )\r | |
1420 | {\r | |
1421 | FIRMWARE_VOLUME2_PRIVATE_DATA *Private;\r | |
1422 | EFI_FIRMWARE_VOLUME_PROTOCOL *FirmwareVolume;\r | |
1423 | \r | |
1424 | Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r | |
1425 | FirmwareVolume = Private->FirmwareVolume;\r | |
1426 | \r | |
1427 | return FirmwareVolume->GetNextFile (\r | |
1428 | FirmwareVolume,\r | |
1429 | Key,\r | |
1430 | FileType,\r | |
1431 | NameGuid,\r | |
1432 | Attributes,\r | |
1433 | Size\r | |
1434 | );\r | |
1435 | }\r | |
1436 | \r | |
1437 | /**\r | |
1438 | The GetInfo() function returns information of type\r | |
1439 | InformationType for the requested firmware volume. If the volume\r | |
1440 | does not support the requested information type, then\r | |
1441 | EFI_UNSUPPORTED is returned. If the buffer is not large enough\r | |
1442 | to hold the requested structure, EFI_BUFFER_TOO_SMALL is\r | |
1443 | returned and the BufferSize is set to the size of buffer that is\r | |
1444 | required to make the request. The information types defined by\r | |
1445 | this specification are required information types that all file\r | |
1446 | systems must support.\r | |
1447 | \r | |
1448 | @param This A pointer to the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
1449 | instance that is the file handle the requested\r | |
1450 | information is for.\r | |
1451 | \r | |
1452 | @param InformationType The type identifier for the\r | |
1453 | information being requested.\r | |
1454 | \r | |
1455 | @param BufferSize On input, the size of Buffer. On output,\r | |
1456 | the amount of data returned in Buffer. In\r | |
1457 | both cases, the size is measured in bytes.\r | |
1458 | \r | |
1459 | @param Buffer A pointer to the data buffer to return. The\r | |
1460 | buffer's type is indicated by InformationType.\r | |
1461 | \r | |
1462 | \r | |
1463 | @retval EFI_SUCCESS The information was retrieved.\r | |
1464 | \r | |
1465 | @retval EFI_UNSUPPORTED The InformationType is not known.\r | |
1466 | \r | |
1467 | @retval EFI_NO_MEDIA The device has no medium.\r | |
1468 | \r | |
1469 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
1470 | \r | |
1471 | @retval EFI_VOLUME_CORRUPTED The file system structures are\r | |
1472 | corrupted.\r | |
1473 | \r | |
1474 | @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to\r | |
1475 | read the current directory\r | |
1476 | entry. BufferSize has been\r | |
1477 | updated with the size needed to\r | |
1478 | complete the request.\r | |
1479 | \r | |
1480 | \r | |
1481 | **/\r | |
1482 | EFI_STATUS\r | |
1483 | EFIAPI\r | |
1484 | Fv2GetInfo (\r | |
1485 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
1486 | IN CONST EFI_GUID *InformationType,\r | |
1487 | IN OUT UINTN *BufferSize,\r | |
1488 | OUT VOID *Buffer\r | |
1489 | )\r | |
1490 | {\r | |
1491 | return EFI_UNSUPPORTED;\r | |
1492 | }\r | |
1493 | \r | |
1494 | /**\r | |
1495 | \r | |
1496 | The SetInfo() function sets information of type InformationType\r | |
1497 | on the requested firmware volume.\r | |
1498 | \r | |
1499 | \r | |
1500 | @param This A pointer to the EFI_FIRMWARE_VOLUME2_PROTOCOL\r | |
1501 | instance that is the file handle the information\r | |
1502 | is for.\r | |
1503 | \r | |
1504 | @param InformationType The type identifier for the\r | |
1505 | information being set.\r | |
1506 | \r | |
1507 | @param BufferSize The size, in bytes, of Buffer.\r | |
1508 | \r | |
1509 | @param Buffer A pointer to the data buffer to write. The\r | |
1510 | buffer's type is indicated by InformationType.\r | |
1511 | \r | |
1512 | @retval EFI_SUCCESS The information was set.\r | |
1513 | \r | |
1514 | @retval EFI_UNSUPPORTED The InformationType is not known.\r | |
1515 | \r | |
1516 | @retval EFI_NO_MEDIA The device has no medium.\r | |
1517 | \r | |
1518 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
1519 | \r | |
1520 | @retval EFI_VOLUME_CORRUPTED The file system structures are\r | |
1521 | corrupted.\r | |
1522 | \r | |
1523 | \r | |
1524 | @retval EFI_WRITE_PROTECTED The media is read only.\r | |
1525 | \r | |
1526 | @retval EFI_VOLUME_FULL The volume is full.\r | |
1527 | \r | |
1528 | @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the\r | |
1529 | size of the type indicated by\r | |
1530 | InformationType.\r | |
1531 | \r | |
1532 | **/\r | |
1533 | EFI_STATUS\r | |
1534 | EFIAPI\r | |
1535 | Fv2SetInfo (\r | |
1536 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
1537 | IN CONST EFI_GUID *InformationType,\r | |
1538 | IN UINTN BufferSize,\r | |
1539 | IN CONST VOID *Buffer\r | |
1540 | )\r | |
1541 | {\r | |
1542 | return EFI_UNSUPPORTED;\r | |
1543 | }\r |