2 Implementation for PEI Services Library.
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/PeiServicesLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/PpiListLib.h>
27 IN EFI_FV_FILETYPE SearchType
,
28 IN EFI_PEI_FV_HANDLE VolumeHandle
,
29 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
33 SecFfsFindSectionData (
34 IN EFI_SECTION_TYPE SectionType
,
35 IN EFI_PEI_FILE_HANDLE FileHandle
,
36 OUT VOID
**SectionData
41 This service enables a given PEIM to register an interface into the PEI Foundation.
43 @param PpiList A pointer to the list of interfaces that the caller shall install.
45 @retval EFI_SUCCESS The interface was successfully installed.
46 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
47 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
48 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
49 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
54 PeiServicesInstallPpi (
55 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
59 return EFI_OUT_OF_RESOURCES
;
63 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
65 @param OldPpi The pointer to the old PEI PPI Descriptors.
66 @param NewPpi The pointer to the new PEI PPI Descriptors.
68 @retval EFI_SUCCESS The interface was successfully installed.
69 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
70 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
71 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
72 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
73 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
79 PeiServicesReInstallPpi (
80 IN CONST EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
81 IN CONST EFI_PEI_PPI_DESCRIPTOR
*NewPpi
85 return EFI_OUT_OF_RESOURCES
;
89 This service enables PEIMs to discover a given instance of an interface.
91 So this is, well a hack, so we can reuse the same libraries as the PEI Core
94 @param Guid A pointer to the GUID whose corresponding interface needs to be
96 @param Instance The N-th instance of the interface that is required.
97 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
98 @param Ppi A pointer to the instance of the interface.
100 @retval EFI_SUCCESS The interface was successfully returned.
101 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
106 PeiServicesLocatePpi (
107 IN CONST EFI_GUID
*Guid
,
109 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
113 EFI_PEI_PPI_DESCRIPTOR
*PpiList
;
116 return EFI_NOT_FOUND
;
120 for (PpiList
= (EFI_PEI_PPI_DESCRIPTOR
*)gPpiList
; ; PpiList
++) {
121 if (CompareGuid (PpiList
->Guid
, Guid
)) {
122 if (PpiDescriptor
!= NULL
) {
123 *PpiDescriptor
= PpiList
;
131 if ((PpiList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) {
137 return EFI_NOT_FOUND
;
141 This service enables PEIMs to register a given service to be invoked when another service is
142 installed or reinstalled.
144 @param NotifyList A pointer to the list of notification interfaces
145 that the caller shall install.
147 @retval EFI_SUCCESS The interface was successfully installed.
148 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
149 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do
150 not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES
151 bit set in the Flags field.
152 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
157 PeiServicesNotifyPpi (
158 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
162 return EFI_OUT_OF_RESOURCES
;
166 This service enables PEIMs to ascertain the present value of the boot mode.
168 @param BootMode A pointer to contain the value of the boot mode.
170 @retval EFI_SUCCESS The boot mode was returned successfully.
171 @retval EFI_INVALID_PARAMETER BootMode is NULL.
176 PeiServicesGetBootMode (
177 OUT EFI_BOOT_MODE
*BootMode
181 return EFI_OUT_OF_RESOURCES
;
185 This service enables PEIMs to update the boot mode variable.
187 @param BootMode The value of the boot mode to set.
189 @retval EFI_SUCCESS The value was successfully updated
194 PeiServicesSetBootMode (
195 IN EFI_BOOT_MODE BootMode
199 return EFI_OUT_OF_RESOURCES
;
203 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
205 @param HobList A pointer to the list of HOBs that the PEI Foundation
208 @retval EFI_SUCCESS The list was successfully returned.
209 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
214 PeiServicesGetHobList (
219 return EFI_OUT_OF_RESOURCES
;
223 This service enables PEIMs to create various types of HOBs.
225 @param Type The type of HOB to be installed.
226 @param Length The length of the HOB to be added.
227 @param Hob The address of a pointer that will contain the
230 @retval EFI_SUCCESS The HOB was successfully created.
231 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
236 PeiServicesCreateHob (
243 return EFI_OUT_OF_RESOURCES
;
247 This service enables PEIMs to discover additional firmware volumes.
249 @param Instance This instance of the firmware volume to find. The
250 value 0 is the Boot Firmware Volume (BFV).
251 @param VolumeHandle Handle of the firmware volume header of the volume
254 @retval EFI_SUCCESS The volume was found.
255 @retval EFI_NOT_FOUND The volume was not found.
256 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
261 PeiServicesFfsFindNextVolume (
263 IN OUT EFI_PEI_FV_HANDLE
*VolumeHandle
267 return EFI_OUT_OF_RESOURCES
;
271 This service enables PEIMs to discover additional firmware files.
273 @param SearchType A filter to find files only of this type.
274 @param VolumeHandle The pointer to the firmware volume header of the
275 volume to search. This parameter must point to a
277 @param FileHandle Handle of the current file from which to begin searching.
279 @retval EFI_SUCCESS The file was found.
280 @retval EFI_NOT_FOUND The file was not found.
281 @retval EFI_NOT_FOUND The header checksum was not zero.
286 PeiServicesFfsFindNextFile (
287 IN EFI_FV_FILETYPE SearchType
,
288 IN EFI_PEI_FV_HANDLE VolumeHandle
,
289 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
292 return SecFfsFindNextFile (SearchType
, VolumeHandle
, FileHandle
);
296 This service enables PEIMs to discover sections of a given type within a valid FFS file.
298 @param SectionType The value of the section type to find.
299 @param FileHandle A pointer to the file header that contains the set
300 of sections to be searched.
301 @param SectionData A pointer to the discovered section, if successful.
303 @retval EFI_SUCCESS The section was found.
304 @retval EFI_NOT_FOUND The section was not found.
309 PeiServicesFfsFindSectionData (
310 IN EFI_SECTION_TYPE SectionType
,
311 IN EFI_PEI_FILE_HANDLE FileHandle
,
312 OUT VOID
**SectionData
315 return SecFfsFindSectionData (SectionType
, FileHandle
, SectionData
);
319 This service enables PEIMs to register the permanent memory configuration
320 that has been initialized with the PEI Foundation.
322 @param MemoryBegin The value of a region of installed memory.
323 @param MemoryLength The corresponding length of a region of installed memory.
325 @retval EFI_SUCCESS The region was successfully installed in a HOB.
326 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
327 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
332 PeiServicesInstallPeiMemory (
333 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
334 IN UINT64 MemoryLength
338 return EFI_OUT_OF_RESOURCES
;
342 This service enables PEIMs to allocate memory after the permanent memory has been
345 @param MemoryType Type of memory to allocate.
346 @param Pages The number of pages to allocate.
347 @param Memory Pointer of memory allocated.
349 @retval EFI_SUCCESS The memory range was successfully allocated.
350 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
351 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
352 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
357 PeiServicesAllocatePages (
358 IN EFI_MEMORY_TYPE MemoryType
,
360 OUT EFI_PHYSICAL_ADDRESS
*Memory
364 return EFI_OUT_OF_RESOURCES
;
368 This service allocates memory from the Hand-Off Block (HOB) heap.
370 @param Size The number of bytes to allocate from the pool.
371 @param Buffer If the call succeeds, a pointer to a pointer to
372 the allocate buffer; otherwise, undefined.
374 @retval EFI_SUCCESS The allocation was successful
375 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
380 PeiServicesAllocatePool (
386 return EFI_OUT_OF_RESOURCES
;
390 Resets the entire platform.
392 @retval EFI_SUCCESS The function completed successfully.
393 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
398 PeiServicesResetSystem (
403 return EFI_OUT_OF_RESOURCES
;
407 This service is a wrapper for the PEI Service RegisterForShadow(), except the
408 pointer to the PEI Services Table has been removed. See the Platform
409 Initialization Pre-EFI Initialization Core Interface Specification for details.
411 @param FileHandle PEIM's file handle. Must be the currently
414 @retval EFI_SUCCESS The PEIM was successfully registered for
417 @retval EFI_ALREADY_STARTED The PEIM was previously
418 registered for shadowing.
420 @retval EFI_NOT_FOUND The FileHandle does not refer to a
425 PeiServicesRegisterForShadow (
426 IN EFI_PEI_FILE_HANDLE FileHandle
430 return EFI_OUT_OF_RESOURCES
;
434 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
435 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
436 Specification for details.
438 @param FileHandle The handle of the file.
440 @param FileInfo Upon exit, points to the file's
443 @retval EFI_SUCCESS File information returned.
445 @retval EFI_INVALID_PARAMETER If FileHandle does not
446 represent a valid file.
448 @retval EFI_INVALID_PARAMETER FileInfo is NULL.
453 PeiServicesFfsGetFileInfo (
454 IN CONST EFI_PEI_FILE_HANDLE FileHandle
,
455 OUT EFI_FV_FILE_INFO
*FileInfo
459 return EFI_OUT_OF_RESOURCES
;
464 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
465 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
466 Specification for details.
468 @param FileName A pointer to the name of the file to
469 find within the firmware volume.
471 @param VolumeHandle The firmware volume to search FileHandle
472 Upon exit, points to the found file's
473 handle or NULL if it could not be found.
474 @param FileHandle The pointer to found file handle
476 @retval EFI_SUCCESS File was found.
478 @retval EFI_NOT_FOUND File was not found.
480 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
486 PeiServicesFfsFindFileByName (
487 IN CONST EFI_GUID
*FileName
,
488 IN CONST EFI_PEI_FV_HANDLE VolumeHandle
,
489 OUT EFI_PEI_FILE_HANDLE
*FileHandle
493 return EFI_OUT_OF_RESOURCES
;
498 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
499 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
500 Specification for details.
502 @param VolumeHandle Handle of the volume.
504 @param VolumeInfo Upon exit, points to the volume's
507 @retval EFI_SUCCESS File information returned.
509 @retval EFI_INVALID_PARAMETER If FileHandle does not
510 represent a valid file.
512 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
517 PeiServicesFfsGetVolumeInfo (
518 IN EFI_PEI_FV_HANDLE VolumeHandle
,
519 OUT EFI_FV_INFO
*VolumeInfo
523 return EFI_OUT_OF_RESOURCES
;
527 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
529 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
530 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
531 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
532 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
535 @param FvFormat Unique identifier of the format of the memory-mapped
536 firmware volume. This parameter is optional and
537 may be NULL. If NULL is specified, the
538 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
539 @param FvInfo Points to a buffer which allows the
540 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
541 The format of this buffer is specific to the FvFormat.
542 For memory-mapped firmware volumes, this typically
543 points to the first byte of the firmware volume.
544 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
545 firmware volumes, this is typically the size of
547 @param ParentFvName If the new firmware volume originated from a file
548 in a different firmware volume, then this parameter
549 specifies the GUID name of the originating firmware
550 volume. Otherwise, this parameter must be NULL.
551 @param ParentFileName If the new firmware volume originated from a file
552 in a different firmware volume, then this parameter
553 specifies the GUID file name of the originating
554 firmware file. Otherwise, this parameter must be NULL.
558 PeiServicesInstallFvInfoPpi (
559 IN CONST EFI_GUID
*FvFormat
, OPTIONAL
560 IN CONST VOID
*FvInfo
,
561 IN UINT32 FvInfoSize
,
562 IN CONST EFI_GUID
*ParentFvName
, OPTIONAL
563 IN CONST EFI_GUID
*ParentFileName OPTIONAL