]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Library/PeiServicesLib.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Library / PeiServicesLib.h
... / ...
CommitLineData
1/** @file\r
2 Provides library functions for all PEI Services.\r
3\r
4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#ifndef __PEI_SERVICES_LIB_H__\r
10#define __PEI_SERVICES_LIB_H__\r
11\r
12/**\r
13 This service enables a given PEIM to register an interface into the PEI Foundation.\r
14\r
15 @param PpiList A pointer to the list of interfaces that the caller shall install.\r
16\r
17 @retval EFI_SUCCESS The interface was successfully installed.\r
18 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r
19 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
20 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
21 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r
22\r
23**/\r
24EFI_STATUS\r
25EFIAPI\r
26PeiServicesInstallPpi (\r
27 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
28 );\r
29\r
30/**\r
31 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r
32\r
33 @param OldPpi Pointer to the old PEI PPI Descriptors.\r
34 @param NewPpi Pointer to the new PEI PPI Descriptors.\r
35\r
36 @retval EFI_SUCCESS The interface was successfully installed.\r
37 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r
38 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
39 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
40 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r
41 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been\r
42 installed.\r
43\r
44**/\r
45EFI_STATUS\r
46EFIAPI\r
47PeiServicesReInstallPpi (\r
48 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
49 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
50 );\r
51\r
52/**\r
53 This service enables PEIMs to discover a given instance of an interface.\r
54\r
55 @param Guid A pointer to the GUID whose corresponding interface needs to be\r
56 found.\r
57 @param Instance The N-th instance of the interface that is required.\r
58 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r
59 @param Ppi A pointer to the instance of the interface.\r
60\r
61 @retval EFI_SUCCESS The interface was successfully returned.\r
62 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.\r
63\r
64**/\r
65EFI_STATUS\r
66EFIAPI\r
67PeiServicesLocatePpi (\r
68 IN CONST EFI_GUID *Guid,\r
69 IN UINTN Instance,\r
70 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, OPTIONAL\r
71 IN OUT VOID **Ppi\r
72 );\r
73\r
74/**\r
75 This service enables PEIMs to register a given service to be invoked when another service is\r
76 installed or reinstalled.\r
77\r
78 @param NotifyList A pointer to the list of notification interfaces that the caller\r
79 shall install.\r
80\r
81 @retval EFI_SUCCESS The interface was successfully installed.\r
82 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r
83 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the\r
84 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.\r
85 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r
86\r
87**/\r
88EFI_STATUS\r
89EFIAPI\r
90PeiServicesNotifyPpi (\r
91 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
92 );\r
93\r
94/**\r
95 This service enables PEIMs to ascertain the present value of the boot mode.\r
96\r
97 @param BootMode A pointer to contain the value of the boot mode.\r
98\r
99 @retval EFI_SUCCESS The boot mode was returned successfully.\r
100 @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
101\r
102**/\r
103EFI_STATUS\r
104EFIAPI\r
105PeiServicesGetBootMode (\r
106 OUT EFI_BOOT_MODE *BootMode\r
107 );\r
108\r
109/**\r
110 This service enables PEIMs to update the boot mode variable.\r
111\r
112 @param BootMode The value of the boot mode to set.\r
113\r
114 @retval EFI_SUCCESS The value was successfully updated\r
115\r
116**/\r
117EFI_STATUS\r
118EFIAPI\r
119PeiServicesSetBootMode (\r
120 IN EFI_BOOT_MODE BootMode\r
121 );\r
122\r
123/**\r
124 This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r
125\r
126 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.\r
127\r
128 @retval EFI_SUCCESS The list was successfully returned.\r
129 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r
130\r
131**/\r
132EFI_STATUS\r
133EFIAPI\r
134PeiServicesGetHobList (\r
135 OUT VOID **HobList\r
136 );\r
137\r
138/**\r
139 This service enables PEIMs to create various types of HOBs.\r
140\r
141 @param Type The type of HOB to be installed.\r
142 @param Length The length of the HOB to be added.\r
143 @param Hob The address of a pointer that will contain the HOB header.\r
144\r
145 @retval EFI_SUCCESS The HOB was successfully created.\r
146 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r
147\r
148**/\r
149EFI_STATUS\r
150EFIAPI\r
151PeiServicesCreateHob (\r
152 IN UINT16 Type,\r
153 IN UINT16 Length,\r
154 OUT VOID **Hob\r
155 );\r
156\r
157/**\r
158 This service enables PEIMs to discover additional firmware volumes.\r
159\r
160 @param Instance This instance of the firmware volume to find. The value 0 is the\r
161 Boot Firmware Volume (BFV).\r
162 @param VolumeHandle Handle of the firmware volume header of the volume to return.\r
163\r
164 @retval EFI_SUCCESS The volume was found.\r
165 @retval EFI_NOT_FOUND The volume was not found.\r
166 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r
167\r
168**/\r
169EFI_STATUS\r
170EFIAPI\r
171PeiServicesFfsFindNextVolume (\r
172 IN UINTN Instance,\r
173 IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r
174 );\r
175\r
176/**\r
177 This service enables PEIMs to discover additional firmware files.\r
178\r
179 @param SearchType A filter to find files only of this type.\r
180 @param VolumeHandle Pointer to the firmware volume header of the volume to search.\r
181 This parameter must point to a valid FFS volume.\r
182 @param FileHandle Handle of the current file from which to begin searching.\r
183\r
184 @retval EFI_SUCCESS The file was found.\r
185 @retval EFI_NOT_FOUND The file was not found.\r
186 @retval EFI_NOT_FOUND The header checksum was not zero.\r
187\r
188**/\r
189EFI_STATUS\r
190EFIAPI\r
191PeiServicesFfsFindNextFile (\r
192 IN EFI_FV_FILETYPE SearchType,\r
193 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
194 IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
195 );\r
196\r
197/**\r
198 This service enables PEIMs to discover sections of a given type within a valid FFS file.\r
199\r
200 @param SectionType The value of the section type to find.\r
201 @param FileHandle A pointer to the file header that contains the set of sections to\r
202 be searched.\r
203 @param SectionData A pointer to the discovered section, if successful.\r
204\r
205 @retval EFI_SUCCESS The section was found.\r
206 @retval EFI_NOT_FOUND The section was not found.\r
207\r
208**/\r
209EFI_STATUS\r
210EFIAPI\r
211PeiServicesFfsFindSectionData (\r
212 IN EFI_SECTION_TYPE SectionType,\r
213 IN EFI_PEI_FILE_HANDLE FileHandle,\r
214 OUT VOID **SectionData\r
215 );\r
216\r
217/**\r
218 This service enables PEIMs to discover sections of a given instance and type within a valid FFS file.\r
219\r
220 @param SectionType The value of the section type to find.\r
221 @param SectionInstance Section instance to find.\r
222 @param FileHandle A pointer to the file header that contains the set\r
223 of sections to be searched.\r
224 @param SectionData A pointer to the discovered section, if successful.\r
225 @param AuthenticationStatus A pointer to the authentication status for this section.\r
226\r
227 @retval EFI_SUCCESS The section was found.\r
228 @retval EFI_NOT_FOUND The section was not found.\r
229\r
230**/\r
231EFI_STATUS\r
232EFIAPI\r
233PeiServicesFfsFindSectionData3 (\r
234 IN EFI_SECTION_TYPE SectionType,\r
235 IN UINTN SectionInstance,\r
236 IN EFI_PEI_FILE_HANDLE FileHandle,\r
237 OUT VOID **SectionData,\r
238 OUT UINT32 *AuthenticationStatus\r
239 );\r
240\r
241/**\r
242 This service enables PEIMs to register the permanent memory configuration\r
243 that has been initialized with the PEI Foundation.\r
244\r
245 @param MemoryBegin The value of a region of installed memory.\r
246 @param MemoryLength The corresponding length of a region of installed memory.\r
247\r
248 @retval EFI_SUCCESS The region was successfully installed in a HOB.\r
249 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r
250 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r
251\r
252**/\r
253EFI_STATUS\r
254EFIAPI\r
255PeiServicesInstallPeiMemory (\r
256 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
257 IN UINT64 MemoryLength\r
258 );\r
259\r
260/**\r
261 This service enables PEIMs to allocate memory.\r
262\r
263 @param MemoryType Type of memory to allocate.\r
264 @param Pages The number of pages to allocate.\r
265 @param Memory Pointer of memory allocated.\r
266\r
267 @retval EFI_SUCCESS The memory range was successfully allocated.\r
268 @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,\r
269 EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,\r
270 EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.\r
271 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r
272\r
273**/\r
274EFI_STATUS\r
275EFIAPI\r
276PeiServicesAllocatePages (\r
277 IN EFI_MEMORY_TYPE MemoryType,\r
278 IN UINTN Pages,\r
279 OUT EFI_PHYSICAL_ADDRESS *Memory\r
280 );\r
281\r
282/**\r
283 This service enables PEIMs to free memory.\r
284\r
285 @param Memory Memory to be freed.\r
286 @param Pages The number of pages to free.\r
287\r
288 @retval EFI_SUCCESS The requested pages were freed.\r
289 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.\r
290 @retval EFI_NOT_FOUND The requested memory pages were not allocated with\r
291 AllocatePages().\r
292\r
293**/\r
294EFI_STATUS\r
295EFIAPI\r
296PeiServicesFreePages (\r
297 IN EFI_PHYSICAL_ADDRESS Memory,\r
298 IN UINTN Pages\r
299 );\r
300\r
301/**\r
302 This service allocates memory from the Hand-Off Block (HOB) heap.\r
303\r
304 @param Size The number of bytes to allocate from the pool.\r
305 @param Buffer If the call succeeds, a pointer to a pointer to the allocate\r
306 buffer; undefined otherwise.\r
307\r
308 @retval EFI_SUCCESS The allocation was successful\r
309 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.\r
310\r
311**/\r
312EFI_STATUS\r
313EFIAPI\r
314PeiServicesAllocatePool (\r
315 IN UINTN Size,\r
316 OUT VOID **Buffer\r
317 );\r
318\r
319/**\r
320 Resets the entire platform.\r
321\r
322 @retval EFI_SUCCESS The function completed successfully.\r
323 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r
324\r
325**/\r
326EFI_STATUS\r
327EFIAPI\r
328PeiServicesResetSystem (\r
329 VOID\r
330 );\r
331\r
332\r
333/**\r
334 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services\r
335 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r
336 Specification for details.\r
337\r
338 @param FileName A pointer to the name of the file to\r
339 find within the firmware volume.\r
340\r
341 @param VolumeHandle The firmware volume to search FileHandle\r
342 Upon exit, points to the found file's\r
343 handle or NULL if it could not be found.\r
344 @param FileHandle Pointer to found file handle\r
345\r
346 @retval EFI_SUCCESS File was found.\r
347\r
348 @retval EFI_NOT_FOUND File was not found.\r
349\r
350 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or\r
351 FileName was NULL.\r
352\r
353**/\r
354EFI_STATUS\r
355EFIAPI\r
356PeiServicesFfsFindFileByName (\r
357 IN CONST EFI_GUID *FileName,\r
358 IN CONST EFI_PEI_FV_HANDLE VolumeHandle,\r
359 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
360 );\r
361\r
362\r
363/**\r
364 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services\r
365 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r
366 Specification for details.\r
367\r
368 @param FileHandle Handle of the file.\r
369\r
370 @param FileInfo Upon exit, points to the file's\r
371 information.\r
372\r
373 @retval EFI_SUCCESS File information returned.\r
374\r
375 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
376 represent a valid file.\r
377\r
378 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
379\r
380**/\r
381EFI_STATUS\r
382EFIAPI\r
383PeiServicesFfsGetFileInfo (\r
384 IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r
385 OUT EFI_FV_FILE_INFO *FileInfo\r
386 );\r
387\r
388/**\r
389 This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services\r
390 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r
391 Specification for details.\r
392\r
393 @param FileHandle Handle of the file.\r
394\r
395 @param FileInfo Upon exit, points to the file's\r
396 information.\r
397\r
398 @retval EFI_SUCCESS File information returned.\r
399\r
400 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
401 represent a valid file.\r
402\r
403 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
404\r
405**/\r
406EFI_STATUS\r
407EFIAPI\r
408PeiServicesFfsGetFileInfo2 (\r
409 IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r
410 OUT EFI_FV_FILE_INFO2 *FileInfo\r
411 );\r
412\r
413/**\r
414 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services\r
415 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r
416 Specification for details.\r
417\r
418 @param VolumeHandle Handle of the volume.\r
419\r
420 @param VolumeInfo Upon exit, points to the volume's\r
421 information.\r
422\r
423 @retval EFI_SUCCESS File information returned.\r
424\r
425 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
426 represent a valid file.\r
427\r
428 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
429\r
430**/\r
431EFI_STATUS\r
432EFIAPI\r
433PeiServicesFfsGetVolumeInfo (\r
434 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
435 OUT EFI_FV_INFO *VolumeInfo\r
436 );\r
437\r
438\r
439/**\r
440 This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services\r
441 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r
442 Specification for details.\r
443\r
444 @param FileHandle PEIM's file handle. Must be the currently\r
445 executing PEIM.\r
446\r
447 @retval EFI_SUCCESS The PEIM was successfully registered for\r
448 shadowing.\r
449\r
450 @retval EFI_ALREADY_STARTED The PEIM was previously\r
451 registered for shadowing.\r
452\r
453 @retval EFI_NOT_FOUND The FileHandle does not refer to a\r
454 valid file handle.\r
455**/\r
456EFI_STATUS\r
457EFIAPI\r
458PeiServicesRegisterForShadow (\r
459 IN EFI_PEI_FILE_HANDLE FileHandle\r
460 );\r
461\r
462/**\r
463 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.\r
464\r
465 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using\r
466 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.\r
467 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().\r
468 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().\r
469\r
470\r
471 @param FvFormat Unique identifier of the format of the memory-mapped firmware volume.\r
472 This parameter is optional and may be NULL.\r
473 If NULL is specified, the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r
474 @param FvInfo Points to a buffer which allows the EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r
475 The format of this buffer is specific to the FvFormat. For memory-mapped firmware volumes,\r
476 this typically points to the first byte of the firmware volume.\r
477 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped firmware volumes,\r
478 this is typically the size of the firmware volume.\r
479 @param ParentFvName If the new firmware volume originated from a file in a different firmware volume,\r
480 then this parameter specifies the GUID name of the originating firmware volume.\r
481 Otherwise, this parameter must be NULL.\r
482 @param ParentFileName If the new firmware volume originated from a file in a different firmware volume,\r
483 then this parameter specifies the GUID file name of the originating firmware file.\r
484 Otherwise, this parameter must be NULL.\r
485**/\r
486VOID\r
487EFIAPI\r
488PeiServicesInstallFvInfoPpi (\r
489 IN CONST EFI_GUID *FvFormat, OPTIONAL\r
490 IN CONST VOID *FvInfo,\r
491 IN UINT32 FvInfoSize,\r
492 IN CONST EFI_GUID *ParentFvName, OPTIONAL\r
493 IN CONST EFI_GUID *ParentFileName OPTIONAL\r
494 );\r
495\r
496/**\r
497 Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.\r
498\r
499 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using\r
500 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.\r
501 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().\r
502 If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().\r
503\r
504 @param FvFormat Unique identifier of the format of the memory-mapped\r
505 firmware volume. This parameter is optional and\r
506 may be NULL. If NULL is specified, the\r
507 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r
508 @param FvInfo Points to a buffer which allows the\r
509 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r
510 The format of this buffer is specific to the FvFormat.\r
511 For memory-mapped firmware volumes, this typically\r
512 points to the first byte of the firmware volume.\r
513 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r
514 firmware volumes, this is typically the size of\r
515 the firmware volume.\r
516 @param ParentFvName If the new firmware volume originated from a file\r
517 in a different firmware volume, then this parameter\r
518 specifies the GUID name of the originating firmware\r
519 volume. Otherwise, this parameter must be NULL.\r
520 @param ParentFileName If the new firmware volume originated from a file\r
521 in a different firmware volume, then this parameter\r
522 specifies the GUID file name of the originating\r
523 firmware file. Otherwise, this parameter must be NULL.\r
524 @param AuthenticationStatus Authentication Status\r
525**/\r
526VOID\r
527EFIAPI\r
528PeiServicesInstallFvInfo2Ppi (\r
529 IN CONST EFI_GUID *FvFormat, OPTIONAL\r
530 IN CONST VOID *FvInfo,\r
531 IN UINT32 FvInfoSize,\r
532 IN CONST EFI_GUID *ParentFvName, OPTIONAL\r
533 IN CONST EFI_GUID *ParentFileName, OPTIONAL\r
534 IN UINT32 AuthenticationStatus\r
535 );\r
536\r
537/**\r
538 Resets the entire platform.\r
539\r
540 @param[in] ResetType The type of reset to perform.\r
541 @param[in] ResetStatus The status code for the reset.\r
542 @param[in] DataSize The size, in bytes, of ResetData.\r
543 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
544 the data buffer starts with a Null-terminated string, optionally\r
545 followed by additional binary data. The string is a description\r
546 that the caller may use to further indicate the reason for the\r
547 system reset. ResetData is only valid if ResetStatus is something\r
548 other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific\r
549 where a minimum amount of ResetData is always required.\r
550\r
551**/\r
552VOID\r
553EFIAPI\r
554PeiServicesResetSystem2 (\r
555 IN EFI_RESET_TYPE ResetType,\r
556 IN EFI_STATUS ResetStatus,\r
557 IN UINTN DataSize,\r
558 IN VOID *ResetData OPTIONAL\r
559 );\r
560\r
561#endif\r