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
10 #include <Library/EmuMagicPageLib.h>
11 #include <Library/PeiServicesLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/BaseMemoryLib.h>
17 IN EFI_FV_FILETYPE SearchType
,
18 IN EFI_PEI_FV_HANDLE VolumeHandle
,
19 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
23 SecFfsFindSectionData (
24 IN EFI_SECTION_TYPE SectionType
,
25 IN EFI_PEI_FILE_HANDLE FileHandle
,
26 OUT VOID
**SectionData
30 This service enables a given PEIM to register an interface into the PEI Foundation.
32 @param PpiList A pointer to the list of interfaces that the caller shall install.
34 @retval EFI_SUCCESS The interface was successfully installed.
35 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
36 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
37 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
38 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
43 PeiServicesInstallPpi (
44 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
48 return EFI_OUT_OF_RESOURCES
;
52 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
54 @param OldPpi The pointer to the old PEI PPI Descriptors.
55 @param NewPpi The pointer to the new PEI PPI Descriptors.
57 @retval EFI_SUCCESS The interface was successfully installed.
58 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
59 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
60 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
61 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
62 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
68 PeiServicesReInstallPpi (
69 IN CONST EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
70 IN CONST EFI_PEI_PPI_DESCRIPTOR
*NewPpi
74 return EFI_OUT_OF_RESOURCES
;
78 This service enables PEIMs to discover a given instance of an interface.
80 So this is, well a hack, so we can reuse the same libraries as the PEI Core
83 @param Guid A pointer to the GUID whose corresponding interface needs to be
85 @param Instance The N-th instance of the interface that is required.
86 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
87 @param Ppi A pointer to the instance of the interface.
89 @retval EFI_SUCCESS The interface was successfully returned.
90 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
95 PeiServicesLocatePpi (
96 IN CONST EFI_GUID
*Guid
,
98 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
102 EFI_PEI_PPI_DESCRIPTOR
*PpiList
;
105 return EFI_NOT_FOUND
;
108 for (PpiList
= EMU_MAGIC_PAGE ()->PpiList
; ; PpiList
++) {
109 if (CompareGuid (PpiList
->Guid
, Guid
)) {
110 if (PpiDescriptor
!= NULL
) {
111 *PpiDescriptor
= PpiList
;
121 if ((PpiList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) {
126 return EFI_NOT_FOUND
;
130 This service enables PEIMs to register a given service to be invoked when another service is
131 installed or reinstalled.
133 @param NotifyList A pointer to the list of notification interfaces
134 that the caller shall install.
136 @retval EFI_SUCCESS The interface was successfully installed.
137 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
138 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do
139 not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES
140 bit set in the Flags field.
141 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
146 PeiServicesNotifyPpi (
147 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
151 return EFI_OUT_OF_RESOURCES
;
155 This service enables PEIMs to ascertain the present value of the boot mode.
157 @param BootMode A pointer to contain the value of the boot mode.
159 @retval EFI_SUCCESS The boot mode was returned successfully.
160 @retval EFI_INVALID_PARAMETER BootMode is NULL.
165 PeiServicesGetBootMode (
166 OUT EFI_BOOT_MODE
*BootMode
170 return EFI_OUT_OF_RESOURCES
;
174 This service enables PEIMs to update the boot mode variable.
176 @param BootMode The value of the boot mode to set.
178 @retval EFI_SUCCESS The value was successfully updated
183 PeiServicesSetBootMode (
184 IN EFI_BOOT_MODE BootMode
188 return EFI_OUT_OF_RESOURCES
;
192 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
194 @param HobList A pointer to the list of HOBs that the PEI Foundation
197 @retval EFI_SUCCESS The list was successfully returned.
198 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
203 PeiServicesGetHobList (
208 return EFI_OUT_OF_RESOURCES
;
212 This service enables PEIMs to create various types of HOBs.
214 @param Type The type of HOB to be installed.
215 @param Length The length of the HOB to be added.
216 @param Hob The address of a pointer that will contain the
219 @retval EFI_SUCCESS The HOB was successfully created.
220 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
225 PeiServicesCreateHob (
232 return EFI_OUT_OF_RESOURCES
;
236 This service enables PEIMs to discover additional firmware volumes.
238 @param Instance This instance of the firmware volume to find. The
239 value 0 is the Boot Firmware Volume (BFV).
240 @param VolumeHandle Handle of the firmware volume header of the volume
243 @retval EFI_SUCCESS The volume was found.
244 @retval EFI_NOT_FOUND The volume was not found.
245 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
250 PeiServicesFfsFindNextVolume (
252 IN OUT EFI_PEI_FV_HANDLE
*VolumeHandle
256 return EFI_OUT_OF_RESOURCES
;
260 This service enables PEIMs to discover additional firmware files.
262 @param SearchType A filter to find files only of this type.
263 @param VolumeHandle The pointer to the firmware volume header of the
264 volume to search. This parameter must point to a
266 @param FileHandle Handle of the current file from which to begin searching.
268 @retval EFI_SUCCESS The file was found.
269 @retval EFI_NOT_FOUND The file was not found.
270 @retval EFI_NOT_FOUND The header checksum was not zero.
275 PeiServicesFfsFindNextFile (
276 IN EFI_FV_FILETYPE SearchType
,
277 IN EFI_PEI_FV_HANDLE VolumeHandle
,
278 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
281 return SecFfsFindNextFile (SearchType
, VolumeHandle
, FileHandle
);
285 This service enables PEIMs to discover sections of a given type within a valid FFS file.
287 @param SectionType The value of the section type to find.
288 @param FileHandle A pointer to the file header that contains the set
289 of sections to be searched.
290 @param SectionData A pointer to the discovered section, if successful.
292 @retval EFI_SUCCESS The section was found.
293 @retval EFI_NOT_FOUND The section was not found.
298 PeiServicesFfsFindSectionData (
299 IN EFI_SECTION_TYPE SectionType
,
300 IN EFI_PEI_FILE_HANDLE FileHandle
,
301 OUT VOID
**SectionData
304 return SecFfsFindSectionData (SectionType
, FileHandle
, SectionData
);
308 This service enables PEIMs to register the permanent memory configuration
309 that has been initialized with the PEI Foundation.
311 @param MemoryBegin The value of a region of installed memory.
312 @param MemoryLength The corresponding length of a region of installed memory.
314 @retval EFI_SUCCESS The region was successfully installed in a HOB.
315 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
316 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
321 PeiServicesInstallPeiMemory (
322 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
323 IN UINT64 MemoryLength
327 return EFI_OUT_OF_RESOURCES
;
331 This service enables PEIMs to allocate memory after the permanent memory has been
334 @param MemoryType Type of memory to allocate.
335 @param Pages The number of pages to allocate.
336 @param Memory Pointer of memory allocated.
338 @retval EFI_SUCCESS The memory range was successfully allocated.
339 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
340 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
341 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
346 PeiServicesAllocatePages (
347 IN EFI_MEMORY_TYPE MemoryType
,
349 OUT EFI_PHYSICAL_ADDRESS
*Memory
353 return EFI_OUT_OF_RESOURCES
;
357 This service allocates memory from the Hand-Off Block (HOB) heap.
359 @param Size The number of bytes to allocate from the pool.
360 @param Buffer If the call succeeds, a pointer to a pointer to
361 the allocate buffer; otherwise, undefined.
363 @retval EFI_SUCCESS The allocation was successful
364 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
369 PeiServicesAllocatePool (
375 return EFI_OUT_OF_RESOURCES
;
379 Resets the entire platform.
381 @retval EFI_SUCCESS The function completed successfully.
382 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
387 PeiServicesResetSystem (
392 return EFI_OUT_OF_RESOURCES
;
396 This service is a wrapper for the PEI Service RegisterForShadow(), except the
397 pointer to the PEI Services Table has been removed. See the Platform
398 Initialization Pre-EFI Initialization Core Interface Specification for details.
400 @param FileHandle PEIM's file handle. Must be the currently
403 @retval EFI_SUCCESS The PEIM was successfully registered for
406 @retval EFI_ALREADY_STARTED The PEIM was previously
407 registered for shadowing.
409 @retval EFI_NOT_FOUND The FileHandle does not refer to a
414 PeiServicesRegisterForShadow (
415 IN EFI_PEI_FILE_HANDLE FileHandle
419 return EFI_OUT_OF_RESOURCES
;
423 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
424 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
425 Specification for details.
427 @param FileHandle The handle of the file.
429 @param FileInfo Upon exit, points to the file's
432 @retval EFI_SUCCESS File information returned.
434 @retval EFI_INVALID_PARAMETER If FileHandle does not
435 represent a valid file.
437 @retval EFI_INVALID_PARAMETER FileInfo is NULL.
442 PeiServicesFfsGetFileInfo (
443 IN CONST EFI_PEI_FILE_HANDLE FileHandle
,
444 OUT EFI_FV_FILE_INFO
*FileInfo
448 return EFI_OUT_OF_RESOURCES
;
452 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
453 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
454 Specification for details.
456 @param FileName A pointer to the name of the file to
457 find within the firmware volume.
459 @param VolumeHandle The firmware volume to search FileHandle
460 Upon exit, points to the found file's
461 handle or NULL if it could not be found.
462 @param FileHandle The pointer to found file handle
464 @retval EFI_SUCCESS File was found.
466 @retval EFI_NOT_FOUND File was not found.
468 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
474 PeiServicesFfsFindFileByName (
475 IN CONST EFI_GUID
*FileName
,
476 IN CONST EFI_PEI_FV_HANDLE VolumeHandle
,
477 OUT EFI_PEI_FILE_HANDLE
*FileHandle
481 return EFI_OUT_OF_RESOURCES
;
485 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
486 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
487 Specification for details.
489 @param VolumeHandle Handle of the volume.
491 @param VolumeInfo Upon exit, points to the volume's
494 @retval EFI_SUCCESS File information returned.
496 @retval EFI_INVALID_PARAMETER If FileHandle does not
497 represent a valid file.
499 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
504 PeiServicesFfsGetVolumeInfo (
505 IN EFI_PEI_FV_HANDLE VolumeHandle
,
506 OUT EFI_FV_INFO
*VolumeInfo
510 return EFI_OUT_OF_RESOURCES
;
514 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
516 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
517 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
518 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
519 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
522 @param FvFormat Unique identifier of the format of the memory-mapped
523 firmware volume. This parameter is optional and
524 may be NULL. If NULL is specified, the
525 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
526 @param FvInfo Points to a buffer which allows the
527 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
528 The format of this buffer is specific to the FvFormat.
529 For memory-mapped firmware volumes, this typically
530 points to the first byte of the firmware volume.
531 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
532 firmware volumes, this is typically the size of
534 @param ParentFvName If the new firmware volume originated from a file
535 in a different firmware volume, then this parameter
536 specifies the GUID name of the originating firmware
537 volume. Otherwise, this parameter must be NULL.
538 @param ParentFileName If the new firmware volume originated from a file
539 in a different firmware volume, then this parameter
540 specifies the GUID file name of the originating
541 firmware file. Otherwise, this parameter must be NULL.
545 PeiServicesInstallFvInfoPpi (
546 IN CONST EFI_GUID
*FvFormat OPTIONAL
,
547 IN CONST VOID
*FvInfo
,
548 IN UINT32 FvInfoSize
,
549 IN CONST EFI_GUID
*ParentFvName OPTIONAL
,
550 IN CONST EFI_GUID
*ParentFileName OPTIONAL