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