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