]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/FwVol/FwVol.h
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Core / Pei / FwVol / FwVol.h
CommitLineData
3b428ade 1/** @file\r
2 The internal header file for firmware volume related definitions.\r
d1102dba
LG
3\r
4Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
3b428ade 12\r
13**/\r
14\r
15#ifndef _FWVOL_H_\r
16#define _FWVOL_H_\r
17\r
18#include "PeiMain.h"\r
19\r
20#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \\r
21 ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))\r
22\r
23\r
890e5417
SZ
24#define PEI_FW_VOL_SIGNATURE SIGNATURE_32('P','F','W','V')\r
25\r
26typedef struct {\r
27 UINTN Signature;\r
28 BOOLEAN IsFfs3Fv;\r
29 EFI_PEI_FIRMWARE_VOLUME_PPI Fv;\r
30} PEI_FW_VOL_INSTANCE;\r
31\r
32#define PEI_FW_VOL_INSTANCE_FROM_FV_THIS(a) \\r
33 CR(a, PEI_FW_VOL_INSTANCE, Fv, PEI_FW_VOL_SIGNATURE)\r
34\r
35\r
3b428ade 36/**\r
37 Process a firmware volume and create a volume handle.\r
38\r
39 Create a volume handle from the information in the buffer. For\r
40 memory-mapped firmware volumes, Buffer and BufferSize refer to\r
41 the start of the firmware volume and the firmware volume size.\r
42 For non memory-mapped firmware volumes, this points to a\r
43 buffer which contains the necessary information for creating\r
44 the firmware volume handle. Normally, these values are derived\r
45 from the EFI_FIRMWARE_VOLUME_INFO_PPI.\r
d1102dba
LG
46\r
47\r
3b428ade 48 @param This Points to this instance of the\r
49 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
50 @param Buffer Points to the start of the buffer.\r
51 @param BufferSize Size of the buffer.\r
52 @param FvHandle Points to the returned firmware volume\r
53 handle. The firmware volume handle must\r
d1102dba 54 be unique within the system.\r
3b428ade 55\r
56 @retval EFI_SUCCESS Firmware volume handle created.\r
57 @retval EFI_VOLUME_CORRUPTED Volume was corrupt.\r
58\r
59**/\r
60EFI_STATUS\r
61EFIAPI\r
890e5417 62PeiFfsFvPpiProcessVolume (\r
3b428ade 63 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
64 IN VOID *Buffer,\r
65 IN UINTN BufferSize,\r
66 OUT EFI_PEI_FV_HANDLE *FvHandle\r
67 );\r
d1102dba 68\r
3b428ade 69/**\r
70 Finds the next file of the specified type.\r
71\r
d1102dba 72 This service enables PEI modules to discover additional firmware files.\r
3b428ade 73 The FileHandle must be unique within the system.\r
74\r
75 @param This Points to this instance of the\r
76 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
77 @param SearchType A filter to find only files of this type. Type\r
78 EFI_FV_FILETYPE_ALL causes no filtering to be\r
79 done.\r
80 @param FvHandle Handle of firmware volume in which to\r
81 search.\r
82 @param FileHandle Points to the current handle from which to\r
83 begin searching or NULL to start at the\r
84 beginning of the firmware volume. Updated\r
85 upon return to reflect the file found.\r
86\r
87 @retval EFI_SUCCESS The file was found.\r
88 @retval EFI_NOT_FOUND The file was not found. FileHandle contains NULL.\r
89\r
d1102dba 90**/\r
3b428ade 91EFI_STATUS\r
92EFIAPI\r
890e5417 93PeiFfsFvPpiFindFileByType (\r
3b428ade 94 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
95 IN EFI_FV_FILETYPE SearchType,\r
96 IN EFI_PEI_FV_HANDLE FvHandle,\r
97 IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
98 );\r
99\r
100/**\r
d1102dba
LG
101 Find a file within a volume by its name.\r
102\r
3b428ade 103 This service searches for files with a specific name, within\r
104 either the specified firmware volume or all firmware volumes.\r
105\r
106 @param This Points to this instance of the\r
107 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
108 @param FileName A pointer to the name of the file to find\r
109 within the firmware volume.\r
110 @param FvHandle Upon entry, the pointer to the firmware\r
111 volume to search or NULL if all firmware\r
112 volumes should be searched. Upon exit, the\r
113 actual firmware volume in which the file was\r
114 found.\r
115 @param FileHandle Upon exit, points to the found file's\r
116 handle or NULL if it could not be found.\r
117\r
118 @retval EFI_SUCCESS File was found.\r
119 @retval EFI_NOT_FOUND File was not found.\r
120 @retval EFI_INVALID_PARAMETER FvHandle or FileHandle or\r
121 FileName was NULL.\r
122\r
123\r
d1102dba 124**/\r
3b428ade 125EFI_STATUS\r
126EFIAPI\r
890e5417 127PeiFfsFvPpiFindFileByName (\r
3b428ade 128 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
129 IN CONST EFI_GUID *FileName,\r
130 IN EFI_PEI_FV_HANDLE *FvHandle,\r
d1102dba 131 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
3b428ade 132 );\r
133\r
134/**\r
135 Find the next matching section in the firmware file.\r
d1102dba 136\r
3b428ade 137 This service enables PEI modules to discover sections\r
138 of a given type within a valid file.\r
d1102dba 139\r
3b428ade 140 @param This Points to this instance of the\r
141 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
142 @param SearchType A filter to find only sections of this\r
143 type.\r
144 @param FileHandle Handle of firmware file in which to\r
145 search.\r
146 @param SectionData Updated upon return to point to the\r
147 section found.\r
d1102dba 148\r
3b428ade 149 @retval EFI_SUCCESS Section was found.\r
150 @retval EFI_NOT_FOUND Section of the specified type was not\r
151 found. SectionData contains NULL.\r
d1102dba 152**/\r
3b428ade 153EFI_STATUS\r
154EFIAPI\r
890e5417 155PeiFfsFvPpiFindSectionByType (\r
3b428ade 156 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
157 IN EFI_SECTION_TYPE SearchType,\r
158 IN EFI_PEI_FILE_HANDLE FileHandle,\r
159 OUT VOID **SectionData\r
160 );\r
161\r
c7935105
SZ
162/**\r
163 Find the next matching section in the firmware file.\r
164\r
165 This service enables PEI modules to discover sections\r
166 of a given instance and type within a valid file.\r
167\r
168 @param This Points to this instance of the\r
169 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
170 @param SearchType A filter to find only sections of this\r
171 type.\r
172 @param SearchInstance A filter to find the specific instance\r
173 of sections.\r
174 @param FileHandle Handle of firmware file in which to\r
175 search.\r
176 @param SectionData Updated upon return to point to the\r
177 section found.\r
178 @param AuthenticationStatus Updated upon return to point to the\r
179 authentication status for this section.\r
180\r
181 @retval EFI_SUCCESS Section was found.\r
182 @retval EFI_NOT_FOUND Section of the specified type was not\r
183 found. SectionData contains NULL.\r
184**/\r
185EFI_STATUS\r
186EFIAPI\r
187PeiFfsFvPpiFindSectionByType2 (\r
188 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
189 IN EFI_SECTION_TYPE SearchType,\r
190 IN UINTN SearchInstance,\r
191 IN EFI_PEI_FILE_HANDLE FileHandle,\r
192 OUT VOID **SectionData,\r
193 OUT UINT32 *AuthenticationStatus\r
194 );\r
195\r
3b428ade 196/**\r
197 Returns information about a specific file.\r
198\r
199 This function returns information about a specific\r
200 file, including its file name, type, attributes, starting\r
d1102dba
LG
201 address and size.\r
202\r
3b428ade 203 @param This Points to this instance of the\r
204 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
205 @param FileHandle Handle of the file.\r
206 @param FileInfo Upon exit, points to the file's\r
207 information.\r
208\r
209 @retval EFI_SUCCESS File information returned.\r
210 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
211 represent a valid file.\r
212 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
d1102dba
LG
213\r
214**/\r
3b428ade 215EFI_STATUS\r
216EFIAPI\r
890e5417 217PeiFfsFvPpiGetFileInfo (\r
d1102dba
LG
218 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
219 IN EFI_PEI_FILE_HANDLE FileHandle,\r
3b428ade 220 OUT EFI_FV_FILE_INFO *FileInfo\r
221 );\r
222\r
c7935105
SZ
223/**\r
224 Returns information about a specific file.\r
225\r
226 This function returns information about a specific\r
227 file, including its file name, type, attributes, starting\r
228 address, size and authentication status.\r
229\r
230 @param This Points to this instance of the\r
231 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
232 @param FileHandle Handle of the file.\r
233 @param FileInfo Upon exit, points to the file's\r
234 information.\r
235\r
236 @retval EFI_SUCCESS File information returned.\r
237 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
238 represent a valid file.\r
239 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
240\r
241**/\r
242EFI_STATUS\r
243EFIAPI\r
244PeiFfsFvPpiGetFileInfo2 (\r
245 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
246 IN EFI_PEI_FILE_HANDLE FileHandle,\r
247 OUT EFI_FV_FILE_INFO2 *FileInfo\r
248 );\r
249\r
3b428ade 250/**\r
251 This function returns information about the firmware volume.\r
d1102dba 252\r
3b428ade 253 @param This Points to this instance of the\r
254 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
255 @param FvHandle Handle to the firmware handle.\r
256 @param VolumeInfo Points to the returned firmware volume\r
257 information.\r
258\r
259 @retval EFI_SUCCESS Information returned successfully.\r
260 @retval EFI_INVALID_PARAMETER FvHandle does not indicate a valid\r
261 firmware volume or VolumeInfo is NULL.\r
262\r
d1102dba 263**/\r
3b428ade 264EFI_STATUS\r
265EFIAPI\r
890e5417 266PeiFfsFvPpiGetVolumeInfo (\r
d1102dba
LG
267 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
268 IN EFI_PEI_FV_HANDLE FvHandle,\r
3b428ade 269 OUT EFI_FV_INFO *VolumeInfo\r
270 );\r
271\r
272/**\r
273 Convert the handle of FV to pointer of corresponding PEI_CORE_FV_HANDLE.\r
d1102dba 274\r
3b428ade 275 @param FvHandle The handle of a FV.\r
d1102dba 276\r
3b428ade 277 @retval NULL if can not find.\r
d1102dba 278 @return Pointer of corresponding PEI_CORE_FV_HANDLE.\r
3b428ade 279**/\r
280PEI_CORE_FV_HANDLE *\r
281FvHandleToCoreHandle (\r
282 IN EFI_PEI_FV_HANDLE FvHandle\r
283 );\r
d1102dba 284\r
3b428ade 285/**\r
286 Given the input file pointer, search for the next matching file in the\r
287 FFS volume as defined by SearchType. The search starts from FileHeader inside\r
288 the Firmware Volume defined by FwVolHeader.\r
289\r
290\r
291 @param FvHandle Pointer to the FV header of the volume to search\r
292 @param FileName File name\r
293 @param SearchType Filter to find only files of this type.\r
294 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
295 @param FileHandle This parameter must point to a valid FFS volume.\r
296 @param AprioriFile Pointer to AprioriFile image in this FV if has\r
297\r
298 @return EFI_NOT_FOUND No files matching the search criteria were found\r
299 @retval EFI_SUCCESS Success to search given file\r
300\r
301**/\r
302EFI_STATUS\r
303FindFileEx (\r
304 IN CONST EFI_PEI_FV_HANDLE FvHandle,\r
305 IN CONST EFI_GUID *FileName, OPTIONAL\r
306 IN EFI_FV_FILETYPE SearchType,\r
307 IN OUT EFI_PEI_FILE_HANDLE *FileHandle,\r
308 IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL\r
309 );\r
310\r
f3358329 311/**\r
312 Report the information for a new discoveried FV in unknown format.\r
d1102dba 313\r
c7935105 314 If the EFI_PEI_FIRMWARE_VOLUME_PPI has not been installed for specifical FV format, but\r
f3358329 315 the FV in this FV format has been discoveried, then the information of this FV\r
316 will be cached into PEI_CORE_INSTANCE's UnknownFvInfo array.\r
317 Also a notification would be installed for unknown FV format guid, if EFI_PEI_FIRMWARE_VOLUME_PPI\r
318 is installed later by platform's PEIM, the original unknown FV will be processed by\r
319 using new installed EFI_PEI_FIRMWARE_VOLUME_PPI.\r
d1102dba 320\r
f3358329 321 @param PrivateData Point to instance of PEI_CORE_INSTANCE\r
c7935105 322 @param FvInfo2Ppi Point to FvInfo2 PPI.\r
d1102dba 323\r
f3358329 324 @retval EFI_OUT_OF_RESOURCES The FV info array in PEI_CORE_INSTANCE has no more spaces.\r
325 @retval EFI_SUCCESS Success to add the information for unknown FV.\r
326**/\r
327EFI_STATUS\r
328AddUnknownFormatFvInfo (\r
c7935105
SZ
329 IN PEI_CORE_INSTANCE *PrivateData,\r
330 IN EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *FvInfo2Ppi\r
f3358329 331 );\r
d1102dba 332\r
f3358329 333/**\r
334 Find the FV information according to FV format guid.\r
d1102dba 335\r
f3358329 336 This routine also will remove the FV information found by given FV format guid from\r
337 PrivateData->UnknownFvInfo[].\r
d1102dba 338\r
f3358329 339 @param PrivateData Point to instance of PEI_CORE_INSTANCE\r
340 @param Format Point to given FV format guid\r
341 @param FvInfo On return, the pointer of FV information buffer in given FV format guid\r
342 @param FvInfoSize On return, the size of FV information buffer.\r
c7935105 343 @param AuthenticationStatus On return, the authentication status of FV information buffer.\r
d1102dba 344\r
f3358329 345 @retval EFI_NOT_FOUND The FV is not found for new installed EFI_PEI_FIRMWARE_VOLUME_PPI\r
346 @retval EFI_SUCCESS Success to find a FV which could be processed by new installed EFI_PEI_FIRMWARE_VOLUME_PPI.\r
347**/\r
348EFI_STATUS\r
349FindUnknownFormatFvInfo (\r
350 IN PEI_CORE_INSTANCE *PrivateData,\r
351 IN EFI_GUID *Format,\r
352 OUT VOID **FvInfo,\r
c7935105
SZ
353 OUT UINT32 *FvInfoSize,\r
354 OUT UINT32 *AuthenticationStatus\r
f3358329 355 );\r
d1102dba 356\r
f3358329 357/**\r
358 Notification callback function for EFI_PEI_FIRMWARE_VOLUME_PPI.\r
d1102dba
LG
359\r
360 When a EFI_PEI_FIRMWARE_VOLUME_PPI is installed to support new FV format, this\r
f3358329 361 routine is called to process all discoveried FVs in this format.\r
d1102dba 362\r
f3358329 363 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
364 @param NotifyDescriptor Address of the notification descriptor data structure.\r
365 @param Ppi Address of the PPI that was installed.\r
d1102dba 366\r
f3358329 367 @retval EFI_SUCCESS The notification callback is processed correctly.\r
368**/\r
369EFI_STATUS\r
370EFIAPI\r
371ThirdPartyFvPpiNotifyCallback (\r
372 IN EFI_PEI_SERVICES **PeiServices,\r
373 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
374 IN VOID *Ppi\r
d1102dba
LG
375 );\r
376\r
377#endif\r