]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / FwVol / FwVolDriver.h
... / ...
CommitLineData
1/** @file\r
2 Firmware File System protocol. Layers on top of Firmware\r
3 Block protocol to produce a file abstraction of FV based files.\r
4\r
5Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
6SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9\r
10#ifndef __FW_VOL_DRIVER_H_\r
11#define __FW_VOL_DRIVER_H_\r
12\r
13\r
14#define FV2_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '2')\r
15\r
16//\r
17// Used to track all non-deleted files\r
18//\r
19typedef struct {\r
20 LIST_ENTRY Link;\r
21 EFI_FFS_FILE_HEADER *FfsHeader;\r
22 UINTN StreamHandle;\r
23 BOOLEAN FileCached;\r
24} FFS_FILE_LIST_ENTRY;\r
25\r
26typedef struct {\r
27 UINTN Signature;\r
28 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r
29 EFI_HANDLE Handle;\r
30 EFI_FIRMWARE_VOLUME2_PROTOCOL Fv;\r
31\r
32 EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
33 UINT8 *CachedFv;\r
34 UINT8 *EndOfCachedFv;\r
35\r
36 FFS_FILE_LIST_ENTRY *LastKey;\r
37\r
38 LIST_ENTRY FfsFileListHeader;\r
39\r
40 UINT32 AuthenticationStatus;\r
41 UINT8 ErasePolarity;\r
42 BOOLEAN IsFfs3Fv;\r
43 BOOLEAN IsMemoryMapped;\r
44} FV_DEVICE;\r
45\r
46#define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)\r
47\r
48/**\r
49 Retrieves attributes, insures positive polarity of attribute bits, returns\r
50 resulting attributes in output parameter.\r
51\r
52 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
53 @param Attributes output buffer which contains attributes.\r
54\r
55 @retval EFI_SUCCESS Successfully got volume attributes.\r
56\r
57**/\r
58EFI_STATUS\r
59EFIAPI\r
60FvGetVolumeAttributes (\r
61 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
62 OUT EFI_FV_ATTRIBUTES *Attributes\r
63 );\r
64\r
65\r
66/**\r
67 Sets current attributes for volume\r
68\r
69 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
70 @param Attributes At input, contains attributes to be set. At output\r
71 contains new value of FV.\r
72\r
73 @retval EFI_UNSUPPORTED Could not be set.\r
74\r
75**/\r
76EFI_STATUS\r
77EFIAPI\r
78FvSetVolumeAttributes (\r
79 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
80 IN OUT EFI_FV_ATTRIBUTES *Attributes\r
81 );\r
82\r
83\r
84/**\r
85 Given the input key, search for the next matching file in the volume.\r
86\r
87 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
88 @param Key Key is a pointer to a caller allocated\r
89 buffer that contains implementation specific\r
90 data that is used to track where to begin\r
91 the search for the next file. The size of\r
92 the buffer must be at least This->KeySize\r
93 bytes long. To reinitialize the search and\r
94 begin from the beginning of the firmware\r
95 volume, the entire buffer must be cleared to\r
96 zero. Other than clearing the buffer to\r
97 initiate a new search, the caller must not\r
98 modify the data in the buffer between calls\r
99 to GetNextFile().\r
100 @param FileType FileType is a pointer to a caller allocated\r
101 EFI_FV_FILETYPE. The GetNextFile() API can\r
102 filter it's search for files based on the\r
103 value of *FileType input. A *FileType input\r
104 of 0 causes GetNextFile() to search for\r
105 files of all types. If a file is found, the\r
106 file's type is returned in *FileType.\r
107 *FileType is not modified if no file is\r
108 found.\r
109 @param NameGuid NameGuid is a pointer to a caller allocated\r
110 EFI_GUID. If a file is found, the file's\r
111 name is returned in *NameGuid. *NameGuid is\r
112 not modified if no file is found.\r
113 @param Attributes Attributes is a pointer to a caller\r
114 allocated EFI_FV_FILE_ATTRIBUTES. If a file\r
115 is found, the file's attributes are returned\r
116 in *Attributes. *Attributes is not modified\r
117 if no file is found.\r
118 @param Size Size is a pointer to a caller allocated\r
119 UINTN. If a file is found, the file's size\r
120 is returned in *Size. *Size is not modified\r
121 if no file is found.\r
122\r
123 @retval EFI_SUCCESS Successfully find the file.\r
124 @retval EFI_DEVICE_ERROR Device error.\r
125 @retval EFI_ACCESS_DENIED Fv could not read.\r
126 @retval EFI_NOT_FOUND No matching file found.\r
127 @retval EFI_INVALID_PARAMETER Invalid parameter\r
128\r
129**/\r
130EFI_STATUS\r
131EFIAPI\r
132FvGetNextFile (\r
133 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
134 IN OUT VOID *Key,\r
135 IN OUT EFI_FV_FILETYPE *FileType,\r
136 OUT EFI_GUID *NameGuid,\r
137 OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r
138 OUT UINTN *Size\r
139 );\r
140\r
141\r
142\r
143/**\r
144 Locates a file in the firmware volume and\r
145 copies it to the supplied buffer.\r
146\r
147 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
148 @param NameGuid Pointer to an EFI_GUID, which is the\r
149 filename.\r
150 @param Buffer Buffer is a pointer to pointer to a buffer\r
151 in which the file or section contents or are\r
152 returned.\r
153 @param BufferSize BufferSize is a pointer to caller allocated\r
154 UINTN. On input *BufferSize indicates the\r
155 size in bytes of the memory region pointed\r
156 to by Buffer. On output, *BufferSize\r
157 contains the number of bytes required to\r
158 read the file.\r
159 @param FoundType FoundType is a pointer to a caller allocated\r
160 EFI_FV_FILETYPE that on successful return\r
161 from Read() contains the type of file read.\r
162 This output reflects the file type\r
163 irrespective of the value of the SectionType\r
164 input.\r
165 @param FileAttributes FileAttributes is a pointer to a caller\r
166 allocated EFI_FV_FILE_ATTRIBUTES. On\r
167 successful return from Read(),\r
168 *FileAttributes contains the attributes of\r
169 the file read.\r
170 @param AuthenticationStatus AuthenticationStatus is a pointer to a\r
171 caller allocated UINTN in which the\r
172 authentication status is returned.\r
173\r
174 @retval EFI_SUCCESS Successfully read to memory buffer.\r
175 @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.\r
176 @retval EFI_NOT_FOUND Not found.\r
177 @retval EFI_DEVICE_ERROR Device error.\r
178 @retval EFI_ACCESS_DENIED Could not read.\r
179 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
180 @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.\r
181\r
182**/\r
183EFI_STATUS\r
184EFIAPI\r
185FvReadFile (\r
186 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
187 IN CONST EFI_GUID *NameGuid,\r
188 IN OUT VOID **Buffer,\r
189 IN OUT UINTN *BufferSize,\r
190 OUT EFI_FV_FILETYPE *FoundType,\r
191 OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r
192 OUT UINT32 *AuthenticationStatus\r
193 );\r
194\r
195\r
196/**\r
197 Locates a section in a given FFS File and\r
198 copies it to the supplied buffer (not including section header).\r
199\r
200 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
201 @param NameGuid Pointer to an EFI_GUID, which is the\r
202 filename.\r
203 @param SectionType Indicates the section type to return.\r
204 @param SectionInstance Indicates which instance of sections with a\r
205 type of SectionType to return.\r
206 @param Buffer Buffer is a pointer to pointer to a buffer\r
207 in which the file or section contents or are\r
208 returned.\r
209 @param BufferSize BufferSize is a pointer to caller allocated\r
210 UINTN.\r
211 @param AuthenticationStatus AuthenticationStatus is a pointer to a\r
212 caller allocated UINT32 in which the\r
213 authentication status is returned.\r
214\r
215 @retval EFI_SUCCESS Successfully read the file section into\r
216 buffer.\r
217 @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.\r
218 @retval EFI_NOT_FOUND Section not found.\r
219 @retval EFI_DEVICE_ERROR Device error.\r
220 @retval EFI_ACCESS_DENIED Could not read.\r
221 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
222\r
223**/\r
224EFI_STATUS\r
225EFIAPI\r
226FvReadFileSection (\r
227 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
228 IN CONST EFI_GUID *NameGuid,\r
229 IN EFI_SECTION_TYPE SectionType,\r
230 IN UINTN SectionInstance,\r
231 IN OUT VOID **Buffer,\r
232 IN OUT UINTN *BufferSize,\r
233 OUT UINT32 *AuthenticationStatus\r
234 );\r
235\r
236\r
237/**\r
238 Writes one or more files to the firmware volume.\r
239\r
240 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
241 @param NumberOfFiles Number of files.\r
242 @param WritePolicy WritePolicy indicates the level of reliability\r
243 for the write in the event of a power failure or\r
244 other system failure during the write operation.\r
245 @param FileData FileData is an pointer to an array of\r
246 EFI_FV_WRITE_DATA. Each element of array\r
247 FileData represents a file to be written.\r
248\r
249 @retval EFI_SUCCESS Files successfully written to firmware volume\r
250 @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.\r
251 @retval EFI_DEVICE_ERROR Device error.\r
252 @retval EFI_WRITE_PROTECTED Write protected.\r
253 @retval EFI_NOT_FOUND Not found.\r
254 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
255 @retval EFI_UNSUPPORTED This function not supported.\r
256\r
257**/\r
258EFI_STATUS\r
259EFIAPI\r
260FvWriteFile (\r
261 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
262 IN UINT32 NumberOfFiles,\r
263 IN EFI_FV_WRITE_POLICY WritePolicy,\r
264 IN EFI_FV_WRITE_FILE_DATA *FileData\r
265 );\r
266\r
267\r
268/**\r
269 Return information of type InformationType for the requested firmware\r
270 volume.\r
271\r
272 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
273 @param InformationType InformationType for requested.\r
274 @param BufferSize On input, size of Buffer.On output, the amount of data\r
275 returned in Buffer.\r
276 @param Buffer A poniter to the data buffer to return.\r
277\r
278 @retval EFI_SUCCESS Successfully got volume Information.\r
279\r
280**/\r
281EFI_STATUS\r
282EFIAPI\r
283FvGetVolumeInfo (\r
284 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
285 IN CONST EFI_GUID *InformationType,\r
286 IN OUT UINTN *BufferSize,\r
287 OUT VOID *Buffer\r
288 );\r
289\r
290\r
291\r
292/**\r
293 Set information of type InformationType for the requested firmware\r
294 volume.\r
295\r
296 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
297 @param InformationType InformationType for requested.\r
298 @param BufferSize On input, size of Buffer.On output, the amount of data\r
299 returned in Buffer.\r
300 @param Buffer A poniter to the data buffer to return.\r
301\r
302 @retval EFI_SUCCESS Successfully set volume Information.\r
303\r
304**/\r
305EFI_STATUS\r
306EFIAPI\r
307FvSetVolumeInfo (\r
308 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
309 IN CONST EFI_GUID *InformationType,\r
310 IN UINTN BufferSize,\r
311 IN CONST VOID *Buffer\r
312 );\r
313\r
314\r
315\r
316/**\r
317 Check if a block of buffer is erased.\r
318\r
319 @param ErasePolarity Erase polarity attribute of the firmware volume\r
320 @param InBuffer The buffer to be checked\r
321 @param BufferSize Size of the buffer in bytes\r
322\r
323 @retval TRUE The block of buffer is erased\r
324 @retval FALSE The block of buffer is not erased\r
325\r
326**/\r
327BOOLEAN\r
328IsBufferErased (\r
329 IN UINT8 ErasePolarity,\r
330 IN VOID *InBuffer,\r
331 IN UINTN BufferSize\r
332 );\r
333\r
334\r
335/**\r
336 Get the FFS file state by checking the highest bit set in the header's state field.\r
337\r
338 @param ErasePolarity Erase polarity attribute of the firmware volume\r
339 @param FfsHeader Points to the FFS file header\r
340\r
341 @return FFS File state\r
342\r
343**/\r
344EFI_FFS_FILE_STATE\r
345GetFileState (\r
346 IN UINT8 ErasePolarity,\r
347 IN EFI_FFS_FILE_HEADER *FfsHeader\r
348 );\r
349\r
350\r
351/**\r
352 Set the FFS file state.\r
353\r
354 @param State The state to be set.\r
355 @param FfsHeader Points to the FFS file header\r
356\r
357 @return None.\r
358\r
359**/\r
360VOID\r
361SetFileState (\r
362 IN UINT8 State,\r
363 IN EFI_FFS_FILE_HEADER *FfsHeader\r
364 );\r
365\r
366/**\r
367 Check if it's a valid FFS file header.\r
368\r
369 @param ErasePolarity Erase polarity attribute of the firmware volume\r
370 @param FfsHeader Points to the FFS file header to be checked\r
371 @param FileState FFS file state to be returned\r
372\r
373 @retval TRUE Valid FFS file header\r
374 @retval FALSE Invalid FFS file header\r
375\r
376**/\r
377BOOLEAN\r
378IsValidFfsHeader (\r
379 IN UINT8 ErasePolarity,\r
380 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
381 OUT EFI_FFS_FILE_STATE *FileState\r
382 );\r
383\r
384\r
385/**\r
386 Check if it's a valid FFS file.\r
387 Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.\r
388\r
389 @param ErasePolarity Erase polarity attribute of the firmware volume\r
390 @param FfsHeader Points to the FFS file to be checked\r
391\r
392 @retval TRUE Valid FFS file\r
393 @retval FALSE Invalid FFS file\r
394\r
395**/\r
396BOOLEAN\r
397IsValidFfsFile (\r
398 IN UINT8 ErasePolarity,\r
399 IN EFI_FFS_FILE_HEADER *FfsHeader\r
400 );\r
401\r
402#endif\r