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