]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/FwVolDriver.h
Re-generated because of AutoGen changed
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / FwVolDriver.h
CommitLineData
28a00297 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 FwVolDriver.h\r
15\r
16Abstract:\r
17\r
18 Firmware File System protocol. Layers on top of Firmware\r
19 Block protocol to produce a file abstraction of FV based files.\r
20\r
21--*/\r
22\r
23#ifndef __FWVOL_H\r
24#define __FWVOL_H\r
25\r
26\r
0c2b5da8 27#define FV2_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '2')\r
28\r
28a00297 29//\r
30// Used to track all non-deleted files\r
31//\r
32typedef struct {\r
33 LIST_ENTRY Link;\r
34 EFI_FFS_FILE_HEADER *FfsHeader;\r
35 UINTN StreamHandle;\r
36 EFI_SECTION_EXTRACTION_PROTOCOL *Sep;\r
37} FFS_FILE_LIST_ENTRY;\r
38\r
39typedef struct {\r
40 UINTN Signature;\r
41 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r
42 EFI_HANDLE Handle;\r
0c2b5da8 43 EFI_FIRMWARE_VOLUME2_PROTOCOL Fv;\r
28a00297 44\r
45 EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
46 UINT8 *CachedFv;\r
47 UINT8 *EndOfCachedFv;\r
48\r
49 FFS_FILE_LIST_ENTRY *LastKey;\r
50\r
51 LIST_ENTRY FfsFileListHeader;\r
52\r
53 UINT8 ErasePolarity;\r
54} FV_DEVICE;\r
55\r
0c2b5da8 56#define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)\r
28a00297 57\r
58\r
59EFI_STATUS\r
60EFIAPI\r
61FvGetVolumeAttributes (\r
0c2b5da8 62 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
63 OUT EFI_FV_ATTRIBUTES *Attributes\r
28a00297 64 )\r
65/*++\r
66\r
67Routine Description:\r
68 Retrieves attributes, insures positive polarity of attribute bits, returns\r
69 resulting attributes in output parameter\r
70\r
71Arguments:\r
72 This - Calling context\r
73 Attributes - output buffer which contains attributes\r
74\r
75Returns:\r
76 EFI_SUCCESS - Successfully got volume attributes\r
77\r
78--*/\r
79;\r
80\r
81EFI_STATUS\r
82EFIAPI\r
83FvSetVolumeAttributes (\r
0c2b5da8 84 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
85 IN OUT EFI_FV_ATTRIBUTES *Attributes\r
28a00297 86 )\r
87/*++\r
88\r
89Routine Description:\r
90 Sets current attributes for volume\r
91\r
92Arguments:\r
93 This - Calling context\r
94 Attributes - At input, contains attributes to be set. At output contains\r
95 new value of FV\r
96\r
97Returns:\r
98 EFI_UNSUPPORTED - Could not be set.\r
99--*/\r
100;\r
101\r
102EFI_STATUS\r
103EFIAPI\r
104FvGetNextFile (\r
0c2b5da8 105 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
106 IN OUT VOID *Key,\r
107 IN OUT EFI_FV_FILETYPE *FileType,\r
108 OUT EFI_GUID *NameGuid,\r
109 OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r
110 OUT UINTN *Size\r
28a00297 111 )\r
112/*++\r
113\r
114Routine Description:\r
115 Given the input key, search for the next matching file in the volume.\r
116\r
117Arguments:\r
118 This - Indicates the calling context.\r
119 FileType - FileType is a pointer to a caller allocated\r
120 EFI_FV_FILETYPE. The GetNextFile() API can filter it's\r
121 search for files based on the value of *FileType input.\r
122 A *FileType input of 0 causes GetNextFile() to search for\r
123 files of all types. If a file is found, the file's type\r
124 is returned in *FileType. *FileType is not modified if\r
125 no file is found.\r
126 Key - Key is a pointer to a caller allocated buffer that\r
127 contains implementation specific data that is used to\r
128 track where to begin the search for the next file.\r
129 The size of the buffer must be at least This->KeySize\r
130 bytes long. To reinitialize the search and begin from\r
131 the beginning of the firmware volume, the entire buffer\r
132 must be cleared to zero. Other than clearing the buffer\r
133 to initiate a new search, the caller must not modify the\r
134 data in the buffer between calls to GetNextFile().\r
135 NameGuid - NameGuid is a pointer to a caller allocated EFI_GUID.\r
136 If a file is found, the file's name is returned in\r
137 *NameGuid. *NameGuid is not modified if no file is\r
138 found.\r
139 Attributes - Attributes is a pointer to a caller allocated\r
140 EFI_FV_FILE_ATTRIBUTES. If a file is found, the file's\r
141 attributes are returned in *Attributes. *Attributes is\r
142 not modified if no file is found.\r
143 Size - Size is a pointer to a caller allocated UINTN.\r
144 If a file is found, the file's size is returned in *Size.\r
145 *Size is not modified if no file is found.\r
146\r
147Returns: \r
148 EFI_SUCCESS - Successfully find the file.\r
149 EFI_DEVICE_ERROR - Device error.\r
150 EFI_ACCESS_DENIED - Fv could not read.\r
151 EFI_NOT_FOUND - No matching file found.\r
152 EFI_INVALID_PARAMETER - Invalid parameter\r
153\r
154--*/\r
155;\r
156\r
157\r
158EFI_STATUS\r
159EFIAPI\r
160FvReadFile (\r
0c2b5da8 161 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
162 IN CONST EFI_GUID *NameGuid,\r
163 IN OUT VOID **Buffer,\r
164 IN OUT UINTN *BufferSize,\r
165 OUT EFI_FV_FILETYPE *FoundType,\r
166 OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r
167 OUT UINT32 *AuthenticationStatus\r
28a00297 168 )\r
169/*++\r
170\r
171Routine Description:\r
172 Locates a file in the firmware volume and\r
173 copies it to the supplied buffer.\r
174\r
175Arguments:\r
176 This - Indicates the calling context.\r
177 NameGuid - Pointer to an EFI_GUID, which is the filename.\r
178 Buffer - Buffer is a pointer to pointer to a buffer in\r
179 which the file or section contents or are returned.\r
180 BufferSize - BufferSize is a pointer to caller allocated\r
181 UINTN. On input *BufferSize indicates the size\r
182 in bytes of the memory region pointed to by\r
183 Buffer. On output, *BufferSize contains the number\r
184 of bytes required to read the file.\r
185 FoundType - FoundType is a pointer to a caller allocated\r
186 EFI_FV_FILETYPE that on successful return from Read()\r
187 contains the type of file read. This output reflects\r
188 the file type irrespective of the value of the\r
189 SectionType input.\r
190 FileAttributes - FileAttributes is a pointer to a caller allocated\r
191 EFI_FV_FILE_ATTRIBUTES. On successful return from\r
192 Read(), *FileAttributes contains the attributes of\r
193 the file read.\r
194 AuthenticationStatus - AuthenticationStatus is a pointer to a caller\r
195 allocated UINTN in which the authentication status\r
196 is returned.\r
197Returns:\r
198 EFI_SUCCESS - Successfully read to memory buffer.\r
199 EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.\r
200 EFI_NOT_FOUND - Not found.\r
201 EFI_DEVICE_ERROR - Device error.\r
202 EFI_ACCESS_DENIED - Could not read.\r
203 EFI_INVALID_PARAMETER - Invalid parameter.\r
204 EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.\r
205\r
206--*/\r
207;\r
208\r
209EFI_STATUS\r
210EFIAPI\r
211FvReadFileSection (\r
0c2b5da8 212 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
213 IN CONST EFI_GUID *NameGuid,\r
214 IN EFI_SECTION_TYPE SectionType,\r
215 IN UINTN SectionInstance,\r
216 IN OUT VOID **Buffer,\r
217 IN OUT UINTN *BufferSize,\r
218 OUT UINT32 *AuthenticationStatus\r
28a00297 219 )\r
220/*++\r
221\r
222 Routine Description:\r
223 Locates a section in a given FFS File and\r
224 copies it to the supplied buffer (not including section header).\r
225\r
226 Arguments:\r
227 This - Indicates the calling context.\r
228 NameGuid - Pointer to an EFI_GUID, which is the filename.\r
229 SectionType - Indicates the section type to return.\r
230 SectionInstance - Indicates which instance of sections with a type of\r
231 SectionType to return.\r
232 Buffer - Buffer is a pointer to pointer to a buffer in which\r
233 the file or section contents or are returned.\r
234 BufferSize - BufferSize is a pointer to caller allocated UINTN.\r
235 AuthenticationStatus -AuthenticationStatus is a pointer to a caller\r
236 allocated UINT32 in which the authentication status\r
237 is returned.\r
238\r
239 Returns:\r
240 EFI_SUCCESS - Successfully read the file section into buffer.\r
241 EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.\r
242 EFI_NOT_FOUND - Section not found.\r
243 EFI_DEVICE_ERROR - Device error.\r
244 EFI_ACCESS_DENIED - Could not read.\r
245 EFI_INVALID_PARAMETER - Invalid parameter.\r
246\r
247--*/\r
248;\r
249\r
250EFI_STATUS\r
251EFIAPI\r
252FvWriteFile (\r
0c2b5da8 253 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
254 IN UINT32 NumberOfFiles,\r
255 IN EFI_FV_WRITE_POLICY WritePolicy,\r
256 IN EFI_FV_WRITE_FILE_DATA *FileData\r
28a00297 257 )\r
258/*++\r
259\r
260 Routine Description:\r
261 Writes one or more files to the firmware volume.\r
262\r
263 Arguments:\r
264 This - Indicates the calling context.\r
265 WritePolicy - WritePolicy indicates the level of reliability for\r
266 the write in the event of a power failure or other\r
267 system failure during the write operation.\r
268 FileData - FileData is an pointer to an array of EFI_FV_WRITE_DATA.\r
269 Each element of FileData[] represents a file to be written.\r
270\r
271 Returns:\r
272 EFI_SUCCESS - Files successfully written to firmware volume\r
273 EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.\r
274 EFI_DEVICE_ERROR - Device error.\r
275 EFI_WRITE_PROTECTED - Write protected.\r
276 EFI_NOT_FOUND - Not found.\r
277 EFI_INVALID_PARAMETER - Invalid parameter.\r
278 EFI_UNSUPPORTED - This function not supported.\r
279\r
280--*/\r
281;\r
282\r
0c2b5da8 283EFI_STATUS\r
284EFIAPI\r
285FvGetVolumeInfo (\r
286 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
287 IN CONST EFI_GUID *InformationType,\r
288 IN OUT UINTN *BufferSize,\r
289 OUT VOID *Buffer\r
290 )\r
291/*++\r
292\r
293Routine Description:\r
294 Return information of type InformationType for the requested firmware\r
295 volume.\r
296 \r
297Arguments:\r
298 This - Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
299 InformationType - InformationType for requested.\r
300 BufferSize - On input, size of Buffer.On output, the amount of\r
301 data returned in Buffer.\r
302 Buffer - A poniter to the data buffer to return.\r
303Returns:\r
304 EFI_SUCCESS - Successfully got volume Information.\r
305\r
306--*/\r
307;\r
308\r
28a00297 309\r
0c2b5da8 310EFI_STATUS\r
311EFIAPI\r
312FvSetVolumeInfo (\r
313 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
314 IN CONST EFI_GUID *InformationType,\r
315 IN UINTN BufferSize,\r
316 IN CONST VOID *Buffer\r
317 )\r
318/*++\r
319\r
320Routine Description:\r
321 Set information of type InformationType for the requested firmware\r
322 volume.\r
323\r
324Arguments:\r
325 This - Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
326 InformationType - InformationType for requested.\r
327 BufferSize - On input, size of Buffer.On output, the amount of\r
328 data returned in Buffer.\r
329 Buffer - A poniter to the data buffer to return.\r
330Returns:\r
331 EFI_SUCCESS - Successfully set volume Information.\r
332\r
333--*/\r
334;\r
28a00297 335 \r
336//\r
337//Internal functions\r
338//\r
339typedef enum {\r
340 EfiCheckSumUint8 = 0,\r
341 EfiCheckSumUint16 = 1,\r
342 EfiCheckSumUint32 = 2,\r
343 EfiCheckSumUint64 = 3,\r
344 EfiCheckSumMaximum = 4\r
345} EFI_CHECKSUM_TYPE;\r
346\r
347\r
348BOOLEAN\r
349IsBufferErased (\r
350 IN UINT8 ErasePolarity,\r
351 IN VOID *Buffer,\r
352 IN UINTN BufferSize\r
353 )\r
354/*++\r
355\r
356Routine Description:\r
357 Check if a block of buffer is erased\r
358\r
359Arguments:\r
360 ErasePolarity - Erase polarity attribute of the firmware volume\r
361 Buffer - The buffer to be checked\r
362 BufferSize - Size of the buffer in bytes\r
363 \r
364Returns:\r
365 TRUE - The block of buffer is erased\r
366 FALSE - The block of buffer is not erased\r
367 \r
368--*/\r
369;\r
370\r
371EFI_FFS_FILE_STATE \r
372GetFileState (\r
373 IN UINT8 ErasePolarity,\r
374 IN EFI_FFS_FILE_HEADER *FfsHeader\r
375 )\r
376/*++\r
377\r
378Routine Description:\r
379 Get the FFS file state by checking the highest bit set in the header's state field\r
380\r
381Arguments:\r
382 ErasePolarity - Erase polarity attribute of the firmware volume\r
383 FfsHeader - Points to the FFS file header\r
384 \r
385Returns:\r
386 FFS File state \r
387 \r
388--*/\r
389;\r
390\r
391VOID\r
392SetFileState (\r
393 IN UINT8 State,\r
394 IN EFI_FFS_FILE_HEADER *FfsHeader\r
395 )\r
396/*++\r
397\r
398Routine Description:\r
399 Set the FFS file state.\r
400\r
401Arguments:\r
402 State - The state to be set.\r
403 FfsHeader - Points to the FFS file header\r
404 \r
405Returns:\r
406 None.\r
407 \r
408--*/\r
409;\r
410\r
411BOOLEAN\r
412VerifyFvHeaderChecksum (\r
413 IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader\r
414 )\r
415/*++\r
416\r
417Routine Description:\r
418 Verify checksum of the firmware volume header \r
419\r
420Arguments:\r
421 FvHeader - Points to the firmware volume header to be checked\r
422 \r
423Returns:\r
424 TRUE - Checksum verification passed\r
425 FALSE - Checksum verification failed\r
426 \r
427--*/\r
428;\r
429 \r
430BOOLEAN\r
431IsValidFfsHeader (\r
432 IN UINT8 ErasePolarity,\r
433 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
434 OUT EFI_FFS_FILE_STATE *FileState\r
435 )\r
436/*++\r
437\r
438Routine Description:\r
439 Check if it's a valid FFS file header\r
440\r
441Arguments:\r
442 ErasePolarity - Erase polarity attribute of the firmware volume\r
443 FfsHeader - Points to the FFS file header to be checked\r
444 FileState - FFS file state to be returned\r
445 \r
446Returns:\r
447 TRUE - Valid FFS file header\r
448 FALSE - Invalid FFS file header\r
449 \r
450--*/\r
451;\r
452\r
453BOOLEAN\r
454IsValidFfsFile (\r
455 IN UINT8 ErasePolarity,\r
456 IN EFI_FFS_FILE_HEADER *FfsHeader\r
457 )\r
458/*++\r
459\r
460Routine Description:\r
461 Check if it's a valid FFS file. \r
462 Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.\r
463\r
464Arguments:\r
465 ErasePolarity - Erase polarity attribute of the firmware volume\r
466 FfsHeader - Points to the FFS file to be checked\r
467 \r
468Returns:\r
469 TRUE - Valid FFS file\r
470 FALSE - Invalid FFS file\r
471 \r
472--*/\r
473;\r
474\r
475EFI_STATUS\r
476GetFwVolHeader (\r
477 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,\r
478 OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader\r
479 )\r
480/*++\r
481\r
482Routine Description:\r
483 given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and\r
484 copy the volume header into it.\r
485\r
486Arguments:\r
487 Fvb - The FW_VOL_BLOCK_PROTOCOL instance from which to read the volume\r
488 header\r
489 FwVolHeader - Pointer to pointer to allocated buffer in which the volume\r
490 header is returned.\r
491\r
492Returns:\r
493 Status code.\r
494\r
495--*/\r
496;\r
497\r
498\r
499EFI_STATUS\r
500FvCheck (\r
501 IN OUT FV_DEVICE *FvDevice\r
502 )\r
503/*++\r
504\r
505Routine Description:\r
506 Check if a FV is consistent and allocate cache\r
507\r
508Arguments:\r
509 FvDevice - pointer to the FvDevice to be checked.\r
510\r
511Returns:\r
512 EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.\r
513 EFI_SUCCESS - FV is consistent and cache is allocated.\r
514 EFI_VOLUME_CORRUPTED - File system is corrupted.\r
515\r
516--*/\r
517;\r
518\r
519#endif\r