2 Provides library functions for all PEI Services.
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __PEI_SERVICES_LIB_H__
10 #define __PEI_SERVICES_LIB_H__
13 This service enables a given PEIM to register an interface into the PEI Foundation.
15 @param PpiList A pointer to the list of interfaces that the caller shall install.
17 @retval EFI_SUCCESS The interface was successfully installed.
18 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
19 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
20 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
21 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
26 PeiServicesInstallPpi (
27 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
31 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
33 @param OldPpi Pointer to the old PEI PPI Descriptors.
34 @param NewPpi Pointer to the new PEI PPI Descriptors.
36 @retval EFI_SUCCESS The interface was successfully installed.
37 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
38 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
39 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
40 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
41 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
47 PeiServicesReInstallPpi (
48 IN CONST EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
49 IN CONST EFI_PEI_PPI_DESCRIPTOR
*NewPpi
53 This service enables PEIMs to discover a given instance of an interface.
55 @param Guid A pointer to the GUID whose corresponding interface needs to be
57 @param Instance The N-th instance of the interface that is required.
58 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
59 @param Ppi A pointer to the instance of the interface.
61 @retval EFI_SUCCESS The interface was successfully returned.
62 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
67 PeiServicesLocatePpi (
68 IN CONST EFI_GUID
*Guid
,
70 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
, OPTIONAL
75 This service enables PEIMs to register a given service to be invoked when another service is
76 installed or reinstalled.
78 @param NotifyList A pointer to the list of notification interfaces that the caller
81 @retval EFI_SUCCESS The interface was successfully installed.
82 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
83 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the
84 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.
85 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
90 PeiServicesNotifyPpi (
91 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
95 This service enables PEIMs to ascertain the present value of the boot mode.
97 @param BootMode A pointer to contain the value of the boot mode.
99 @retval EFI_SUCCESS The boot mode was returned successfully.
100 @retval EFI_INVALID_PARAMETER BootMode is NULL.
105 PeiServicesGetBootMode (
106 OUT EFI_BOOT_MODE
*BootMode
110 This service enables PEIMs to update the boot mode variable.
112 @param BootMode The value of the boot mode to set.
114 @retval EFI_SUCCESS The value was successfully updated
119 PeiServicesSetBootMode (
120 IN EFI_BOOT_MODE BootMode
124 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
126 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.
128 @retval EFI_SUCCESS The list was successfully returned.
129 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
134 PeiServicesGetHobList (
139 This service enables PEIMs to create various types of HOBs.
141 @param Type The type of HOB to be installed.
142 @param Length The length of the HOB to be added.
143 @param Hob The address of a pointer that will contain the HOB header.
145 @retval EFI_SUCCESS The HOB was successfully created.
146 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
151 PeiServicesCreateHob (
158 This service enables PEIMs to discover additional firmware volumes.
160 @param Instance This instance of the firmware volume to find. The value 0 is the
161 Boot Firmware Volume (BFV).
162 @param VolumeHandle Handle of the firmware volume header of the volume to return.
164 @retval EFI_SUCCESS The volume was found.
165 @retval EFI_NOT_FOUND The volume was not found.
166 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
171 PeiServicesFfsFindNextVolume (
173 IN OUT EFI_PEI_FV_HANDLE
*VolumeHandle
177 This service enables PEIMs to discover additional firmware files.
179 @param SearchType A filter to find files only of this type.
180 @param VolumeHandle Pointer to the firmware volume header of the volume to search.
181 This parameter must point to a valid FFS volume.
182 @param FileHandle Handle of the current file from which to begin searching.
184 @retval EFI_SUCCESS The file was found.
185 @retval EFI_NOT_FOUND The file was not found.
186 @retval EFI_NOT_FOUND The header checksum was not zero.
191 PeiServicesFfsFindNextFile (
192 IN EFI_FV_FILETYPE SearchType
,
193 IN EFI_PEI_FV_HANDLE VolumeHandle
,
194 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
198 This service enables PEIMs to discover sections of a given type within a valid FFS file.
200 @param SectionType The value of the section type to find.
201 @param FileHandle A pointer to the file header that contains the set of sections to
203 @param SectionData A pointer to the discovered section, if successful.
205 @retval EFI_SUCCESS The section was found.
206 @retval EFI_NOT_FOUND The section was not found.
211 PeiServicesFfsFindSectionData (
212 IN EFI_SECTION_TYPE SectionType
,
213 IN EFI_PEI_FILE_HANDLE FileHandle
,
214 OUT VOID
**SectionData
218 This service enables PEIMs to discover sections of a given instance and type within a valid FFS file.
220 @param SectionType The value of the section type to find.
221 @param SectionInstance Section instance to find.
222 @param FileHandle A pointer to the file header that contains the set
223 of sections to be searched.
224 @param SectionData A pointer to the discovered section, if successful.
225 @param AuthenticationStatus A pointer to the authentication status for this section.
227 @retval EFI_SUCCESS The section was found.
228 @retval EFI_NOT_FOUND The section was not found.
233 PeiServicesFfsFindSectionData3 (
234 IN EFI_SECTION_TYPE SectionType
,
235 IN UINTN SectionInstance
,
236 IN EFI_PEI_FILE_HANDLE FileHandle
,
237 OUT VOID
**SectionData
,
238 OUT UINT32
*AuthenticationStatus
242 This service enables PEIMs to register the permanent memory configuration
243 that has been initialized with the PEI Foundation.
245 @param MemoryBegin The value of a region of installed memory.
246 @param MemoryLength The corresponding length of a region of installed memory.
248 @retval EFI_SUCCESS The region was successfully installed in a HOB.
249 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
250 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
255 PeiServicesInstallPeiMemory (
256 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
257 IN UINT64 MemoryLength
261 This service enables PEIMs to allocate memory.
263 @param MemoryType Type of memory to allocate.
264 @param Pages The number of pages to allocate.
265 @param Memory Pointer of memory allocated.
267 @retval EFI_SUCCESS The memory range was successfully allocated.
268 @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,
269 EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,
270 EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.
271 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
276 PeiServicesAllocatePages (
277 IN EFI_MEMORY_TYPE MemoryType
,
279 OUT EFI_PHYSICAL_ADDRESS
*Memory
283 This service enables PEIMs to free memory.
285 @param Memory Memory to be freed.
286 @param Pages The number of pages to free.
288 @retval EFI_SUCCESS The requested pages were freed.
289 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.
290 @retval EFI_NOT_FOUND The requested memory pages were not allocated with
296 PeiServicesFreePages (
297 IN EFI_PHYSICAL_ADDRESS Memory
,
302 This service allocates memory from the Hand-Off Block (HOB) heap.
304 @param Size The number of bytes to allocate from the pool.
305 @param Buffer If the call succeeds, a pointer to a pointer to the allocate
306 buffer; undefined otherwise.
308 @retval EFI_SUCCESS The allocation was successful
309 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
314 PeiServicesAllocatePool (
320 Resets the entire platform.
322 @retval EFI_SUCCESS The function completed successfully.
323 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
328 PeiServicesResetSystem (
334 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
335 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
336 Specification for details.
338 @param FileName A pointer to the name of the file to
339 find within the firmware volume.
341 @param VolumeHandle The firmware volume to search FileHandle
342 Upon exit, points to the found file's
343 handle or NULL if it could not be found.
344 @param FileHandle Pointer to found file handle
346 @retval EFI_SUCCESS File was found.
348 @retval EFI_NOT_FOUND File was not found.
350 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
356 PeiServicesFfsFindFileByName (
357 IN CONST EFI_GUID
*FileName
,
358 IN CONST EFI_PEI_FV_HANDLE VolumeHandle
,
359 OUT EFI_PEI_FILE_HANDLE
*FileHandle
364 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
365 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
366 Specification for details.
368 @param FileHandle Handle of the file.
370 @param FileInfo Upon exit, points to the file's
373 @retval EFI_SUCCESS File information returned.
375 @retval EFI_INVALID_PARAMETER If FileHandle does not
376 represent a valid file.
378 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
383 PeiServicesFfsGetFileInfo (
384 IN CONST EFI_PEI_FILE_HANDLE FileHandle
,
385 OUT EFI_FV_FILE_INFO
*FileInfo
389 This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services
390 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
391 Specification for details.
393 @param FileHandle Handle of the file.
395 @param FileInfo Upon exit, points to the file's
398 @retval EFI_SUCCESS File information returned.
400 @retval EFI_INVALID_PARAMETER If FileHandle does not
401 represent a valid file.
403 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
408 PeiServicesFfsGetFileInfo2 (
409 IN CONST EFI_PEI_FILE_HANDLE FileHandle
,
410 OUT EFI_FV_FILE_INFO2
*FileInfo
414 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
415 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
416 Specification for details.
418 @param VolumeHandle Handle of the volume.
420 @param VolumeInfo Upon exit, points to the volume's
423 @retval EFI_SUCCESS File information returned.
425 @retval EFI_INVALID_PARAMETER If FileHandle does not
426 represent a valid file.
428 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
433 PeiServicesFfsGetVolumeInfo (
434 IN EFI_PEI_FV_HANDLE VolumeHandle
,
435 OUT EFI_FV_INFO
*VolumeInfo
440 This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services
441 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
442 Specification for details.
444 @param FileHandle PEIM's file handle. Must be the currently
447 @retval EFI_SUCCESS The PEIM was successfully registered for
450 @retval EFI_ALREADY_STARTED The PEIM was previously
451 registered for shadowing.
453 @retval EFI_NOT_FOUND The FileHandle does not refer to a
458 PeiServicesRegisterForShadow (
459 IN EFI_PEI_FILE_HANDLE FileHandle
463 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
465 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
466 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
467 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
468 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
471 @param FvFormat Unique identifier of the format of the memory-mapped firmware volume.
472 This parameter is optional and may be NULL.
473 If NULL is specified, the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
474 @param FvInfo Points to a buffer which allows the EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
475 The format of this buffer is specific to the FvFormat. For memory-mapped firmware volumes,
476 this typically points to the first byte of the firmware volume.
477 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped firmware volumes,
478 this is typically the size of the firmware volume.
479 @param ParentFvName If the new firmware volume originated from a file in a different firmware volume,
480 then this parameter specifies the GUID name of the originating firmware volume.
481 Otherwise, this parameter must be NULL.
482 @param ParentFileName If the new firmware volume originated from a file in a different firmware volume,
483 then this parameter specifies the GUID file name of the originating firmware file.
484 Otherwise, this parameter must be NULL.
488 PeiServicesInstallFvInfoPpi (
489 IN CONST EFI_GUID
*FvFormat
, OPTIONAL
490 IN CONST VOID
*FvInfo
,
491 IN UINT32 FvInfoSize
,
492 IN CONST EFI_GUID
*ParentFvName
, OPTIONAL
493 IN CONST EFI_GUID
*ParentFileName OPTIONAL
497 Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.
499 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using
500 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.
501 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().
502 If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().
504 @param FvFormat Unique identifier of the format of the memory-mapped
505 firmware volume. This parameter is optional and
506 may be NULL. If NULL is specified, the
507 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
508 @param FvInfo Points to a buffer which allows the
509 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
510 The format of this buffer is specific to the FvFormat.
511 For memory-mapped firmware volumes, this typically
512 points to the first byte of the firmware volume.
513 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
514 firmware volumes, this is typically the size of
516 @param ParentFvName If the new firmware volume originated from a file
517 in a different firmware volume, then this parameter
518 specifies the GUID name of the originating firmware
519 volume. Otherwise, this parameter must be NULL.
520 @param ParentFileName If the new firmware volume originated from a file
521 in a different firmware volume, then this parameter
522 specifies the GUID file name of the originating
523 firmware file. Otherwise, this parameter must be NULL.
524 @param AuthenticationStatus Authentication Status
528 PeiServicesInstallFvInfo2Ppi (
529 IN CONST EFI_GUID
*FvFormat
, OPTIONAL
530 IN CONST VOID
*FvInfo
,
531 IN UINT32 FvInfoSize
,
532 IN CONST EFI_GUID
*ParentFvName
, OPTIONAL
533 IN CONST EFI_GUID
*ParentFileName
, OPTIONAL
534 IN UINT32 AuthenticationStatus
538 Resets the entire platform.
540 @param[in] ResetType The type of reset to perform.
541 @param[in] ResetStatus The status code for the reset.
542 @param[in] DataSize The size, in bytes, of ResetData.
543 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
544 the data buffer starts with a Null-terminated string, optionally
545 followed by additional binary data. The string is a description
546 that the caller may use to further indicate the reason for the
552 PeiServicesResetSystem2 (
553 IN EFI_RESET_TYPE ResetType
,
554 IN EFI_STATUS ResetStatus
,
556 IN VOID
*ResetData OPTIONAL