2 Implementation for PEI Services Library.
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/EmuMagicPageLib.h>
12 #include <Library/PeiServicesLib.h>
13 #include <Library/DebugLib.h>
14 #include <Library/BaseMemoryLib.h>
20 IN EFI_FV_FILETYPE SearchType
,
21 IN EFI_PEI_FV_HANDLE VolumeHandle
,
22 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
26 SecFfsFindSectionData (
27 IN EFI_SECTION_TYPE SectionType
,
28 IN EFI_PEI_FILE_HANDLE FileHandle
,
29 OUT VOID
**SectionData
34 This service enables a given PEIM to register an interface into the PEI Foundation.
36 @param PpiList A pointer to the list of interfaces that the caller shall install.
38 @retval EFI_SUCCESS The interface was successfully installed.
39 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
40 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
41 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
42 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
47 PeiServicesInstallPpi (
48 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
52 return EFI_OUT_OF_RESOURCES
;
56 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
58 @param OldPpi The pointer to the old PEI PPI Descriptors.
59 @param NewPpi The pointer to the new PEI PPI Descriptors.
61 @retval EFI_SUCCESS The interface was successfully installed.
62 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
63 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
64 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
65 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
66 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
72 PeiServicesReInstallPpi (
73 IN CONST EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
74 IN CONST EFI_PEI_PPI_DESCRIPTOR
*NewPpi
78 return EFI_OUT_OF_RESOURCES
;
82 This service enables PEIMs to discover a given instance of an interface.
84 So this is, well a hack, so we can reuse the same libraries as the PEI Core
87 @param Guid A pointer to the GUID whose corresponding interface needs to be
89 @param Instance The N-th instance of the interface that is required.
90 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
91 @param Ppi A pointer to the instance of the interface.
93 @retval EFI_SUCCESS The interface was successfully returned.
94 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
99 PeiServicesLocatePpi (
100 IN CONST EFI_GUID
*Guid
,
102 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
106 EFI_PEI_PPI_DESCRIPTOR
*PpiList
;
109 return EFI_NOT_FOUND
;
112 for (PpiList
= EMU_MAGIC_PAGE()->PpiList
; ; PpiList
++) {
113 if (CompareGuid (PpiList
->Guid
, Guid
)) {
114 if (PpiDescriptor
!= NULL
) {
115 *PpiDescriptor
= PpiList
;
123 if ((PpiList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) {
129 return EFI_NOT_FOUND
;
133 This service enables PEIMs to register a given service to be invoked when another service is
134 installed or reinstalled.
136 @param NotifyList A pointer to the list of notification interfaces
137 that the caller shall install.
139 @retval EFI_SUCCESS The interface was successfully installed.
140 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
141 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do
142 not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES
143 bit set in the Flags field.
144 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
149 PeiServicesNotifyPpi (
150 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
154 return EFI_OUT_OF_RESOURCES
;
158 This service enables PEIMs to ascertain the present value of the boot mode.
160 @param BootMode A pointer to contain the value of the boot mode.
162 @retval EFI_SUCCESS The boot mode was returned successfully.
163 @retval EFI_INVALID_PARAMETER BootMode is NULL.
168 PeiServicesGetBootMode (
169 OUT EFI_BOOT_MODE
*BootMode
173 return EFI_OUT_OF_RESOURCES
;
177 This service enables PEIMs to update the boot mode variable.
179 @param BootMode The value of the boot mode to set.
181 @retval EFI_SUCCESS The value was successfully updated
186 PeiServicesSetBootMode (
187 IN EFI_BOOT_MODE BootMode
191 return EFI_OUT_OF_RESOURCES
;
195 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
197 @param HobList A pointer to the list of HOBs that the PEI Foundation
200 @retval EFI_SUCCESS The list was successfully returned.
201 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
206 PeiServicesGetHobList (
211 return EFI_OUT_OF_RESOURCES
;
215 This service enables PEIMs to create various types of HOBs.
217 @param Type The type of HOB to be installed.
218 @param Length The length of the HOB to be added.
219 @param Hob The address of a pointer that will contain the
222 @retval EFI_SUCCESS The HOB was successfully created.
223 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
228 PeiServicesCreateHob (
235 return EFI_OUT_OF_RESOURCES
;
239 This service enables PEIMs to discover additional firmware volumes.
241 @param Instance This instance of the firmware volume to find. The
242 value 0 is the Boot Firmware Volume (BFV).
243 @param VolumeHandle Handle of the firmware volume header of the volume
246 @retval EFI_SUCCESS The volume was found.
247 @retval EFI_NOT_FOUND The volume was not found.
248 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
253 PeiServicesFfsFindNextVolume (
255 IN OUT EFI_PEI_FV_HANDLE
*VolumeHandle
259 return EFI_OUT_OF_RESOURCES
;
263 This service enables PEIMs to discover additional firmware files.
265 @param SearchType A filter to find files only of this type.
266 @param VolumeHandle The pointer to the firmware volume header of the
267 volume to search. This parameter must point to a
269 @param FileHandle Handle of the current file from which to begin searching.
271 @retval EFI_SUCCESS The file was found.
272 @retval EFI_NOT_FOUND The file was not found.
273 @retval EFI_NOT_FOUND The header checksum was not zero.
278 PeiServicesFfsFindNextFile (
279 IN EFI_FV_FILETYPE SearchType
,
280 IN EFI_PEI_FV_HANDLE VolumeHandle
,
281 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
284 return SecFfsFindNextFile (SearchType
, VolumeHandle
, FileHandle
);
288 This service enables PEIMs to discover sections of a given type within a valid FFS file.
290 @param SectionType The value of the section type to find.
291 @param FileHandle A pointer to the file header that contains the set
292 of sections to be searched.
293 @param SectionData A pointer to the discovered section, if successful.
295 @retval EFI_SUCCESS The section was found.
296 @retval EFI_NOT_FOUND The section was not found.
301 PeiServicesFfsFindSectionData (
302 IN EFI_SECTION_TYPE SectionType
,
303 IN EFI_PEI_FILE_HANDLE FileHandle
,
304 OUT VOID
**SectionData
307 return SecFfsFindSectionData (SectionType
, FileHandle
, SectionData
);
311 This service enables PEIMs to register the permanent memory configuration
312 that has been initialized with the PEI Foundation.
314 @param MemoryBegin The value of a region of installed memory.
315 @param MemoryLength The corresponding length of a region of installed memory.
317 @retval EFI_SUCCESS The region was successfully installed in a HOB.
318 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
319 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
324 PeiServicesInstallPeiMemory (
325 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
326 IN UINT64 MemoryLength
330 return EFI_OUT_OF_RESOURCES
;
334 This service enables PEIMs to allocate memory after the permanent memory has been
337 @param MemoryType Type of memory to allocate.
338 @param Pages The number of pages to allocate.
339 @param Memory Pointer of memory allocated.
341 @retval EFI_SUCCESS The memory range was successfully allocated.
342 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
343 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
344 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
349 PeiServicesAllocatePages (
350 IN EFI_MEMORY_TYPE MemoryType
,
352 OUT EFI_PHYSICAL_ADDRESS
*Memory
356 return EFI_OUT_OF_RESOURCES
;
360 This service allocates memory from the Hand-Off Block (HOB) heap.
362 @param Size The number of bytes to allocate from the pool.
363 @param Buffer If the call succeeds, a pointer to a pointer to
364 the allocate buffer; otherwise, undefined.
366 @retval EFI_SUCCESS The allocation was successful
367 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
372 PeiServicesAllocatePool (
378 return EFI_OUT_OF_RESOURCES
;
382 Resets the entire platform.
384 @retval EFI_SUCCESS The function completed successfully.
385 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
390 PeiServicesResetSystem (
395 return EFI_OUT_OF_RESOURCES
;
399 This service is a wrapper for the PEI Service RegisterForShadow(), except the
400 pointer to the PEI Services Table has been removed. See the Platform
401 Initialization Pre-EFI Initialization Core Interface Specification for details.
403 @param FileHandle PEIM's file handle. Must be the currently
406 @retval EFI_SUCCESS The PEIM was successfully registered for
409 @retval EFI_ALREADY_STARTED The PEIM was previously
410 registered for shadowing.
412 @retval EFI_NOT_FOUND The FileHandle does not refer to a
417 PeiServicesRegisterForShadow (
418 IN EFI_PEI_FILE_HANDLE FileHandle
422 return EFI_OUT_OF_RESOURCES
;
426 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
427 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
428 Specification for details.
430 @param FileHandle The handle of the file.
432 @param FileInfo Upon exit, points to the file's
435 @retval EFI_SUCCESS File information returned.
437 @retval EFI_INVALID_PARAMETER If FileHandle does not
438 represent a valid file.
440 @retval EFI_INVALID_PARAMETER FileInfo is NULL.
445 PeiServicesFfsGetFileInfo (
446 IN CONST EFI_PEI_FILE_HANDLE FileHandle
,
447 OUT EFI_FV_FILE_INFO
*FileInfo
451 return EFI_OUT_OF_RESOURCES
;
456 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
457 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
458 Specification for details.
460 @param FileName A pointer to the name of the file to
461 find within the firmware volume.
463 @param VolumeHandle The firmware volume to search FileHandle
464 Upon exit, points to the found file's
465 handle or NULL if it could not be found.
466 @param FileHandle The pointer to found file handle
468 @retval EFI_SUCCESS File was found.
470 @retval EFI_NOT_FOUND File was not found.
472 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
478 PeiServicesFfsFindFileByName (
479 IN CONST EFI_GUID
*FileName
,
480 IN CONST EFI_PEI_FV_HANDLE VolumeHandle
,
481 OUT EFI_PEI_FILE_HANDLE
*FileHandle
485 return EFI_OUT_OF_RESOURCES
;
490 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
491 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
492 Specification for details.
494 @param VolumeHandle Handle of the volume.
496 @param VolumeInfo Upon exit, points to the volume's
499 @retval EFI_SUCCESS File information returned.
501 @retval EFI_INVALID_PARAMETER If FileHandle does not
502 represent a valid file.
504 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
509 PeiServicesFfsGetVolumeInfo (
510 IN EFI_PEI_FV_HANDLE VolumeHandle
,
511 OUT EFI_FV_INFO
*VolumeInfo
515 return EFI_OUT_OF_RESOURCES
;
519 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
521 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
522 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
523 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
524 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
527 @param FvFormat Unique identifier of the format of the memory-mapped
528 firmware volume. This parameter is optional and
529 may be NULL. If NULL is specified, the
530 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
531 @param FvInfo Points to a buffer which allows the
532 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
533 The format of this buffer is specific to the FvFormat.
534 For memory-mapped firmware volumes, this typically
535 points to the first byte of the firmware volume.
536 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
537 firmware volumes, this is typically the size of
539 @param ParentFvName If the new firmware volume originated from a file
540 in a different firmware volume, then this parameter
541 specifies the GUID name of the originating firmware
542 volume. Otherwise, this parameter must be NULL.
543 @param ParentFileName If the new firmware volume originated from a file
544 in a different firmware volume, then this parameter
545 specifies the GUID file name of the originating
546 firmware file. Otherwise, this parameter must be NULL.
550 PeiServicesInstallFvInfoPpi (
551 IN CONST EFI_GUID
*FvFormat
, OPTIONAL
552 IN CONST VOID
*FvInfo
,
553 IN UINT32 FvInfoSize
,
554 IN CONST EFI_GUID
*ParentFvName
, OPTIONAL
555 IN CONST EFI_GUID
*ParentFileName OPTIONAL