2 Implementation for PEI Services Library.
4 Copyright (c) 2006 - 2008, Intel Corporation<BR>
5 All rights reserved. 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.
19 #include <Library/PeiServicesLib.h>
20 #include <Library/PeiServicesTablePointerLib.h>
23 This service enables a given PEIM to register an interface into the PEI Foundation.
25 @param PpiList A pointer to the list of interfaces that the caller shall install.
27 @retval EFI_SUCCESS The interface was successfully installed.
28 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
29 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
30 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
31 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
36 PeiServicesInstallPpi (
37 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
40 CONST EFI_PEI_SERVICES
**PeiServices
;
42 PeiServices
= GetPeiServicesTablePointer ();
43 return (*PeiServices
)->InstallPpi (PeiServices
, PpiList
);
47 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
49 @param OldPpi Pointer to the old PEI PPI Descriptors.
50 @param NewPpi Pointer to the new PEI PPI Descriptors.
52 @retval EFI_SUCCESS The interface was successfully installed.
53 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
54 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
55 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
56 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
57 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
63 PeiServicesReInstallPpi (
64 IN CONST EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
65 IN CONST EFI_PEI_PPI_DESCRIPTOR
*NewPpi
68 CONST EFI_PEI_SERVICES
**PeiServices
;
70 PeiServices
= GetPeiServicesTablePointer ();
71 return (*PeiServices
)->ReInstallPpi (PeiServices
, OldPpi
, NewPpi
);
75 This service enables PEIMs to discover a given instance of an interface.
77 @param Guid A pointer to the GUID whose corresponding interface needs to be
79 @param Instance The N-th instance of the interface that is required.
80 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
81 @param Ppi A pointer to the instance of the interface.
83 @retval EFI_SUCCESS The interface was successfully returned.
84 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
89 PeiServicesLocatePpi (
90 IN CONST EFI_GUID
*Guid
,
92 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
96 CONST EFI_PEI_SERVICES
**PeiServices
;
98 PeiServices
= GetPeiServicesTablePointer ();
99 return (*PeiServices
)->LocatePpi (PeiServices
, Guid
, Instance
, PpiDescriptor
, Ppi
);
103 This service enables PEIMs to register a given service to be invoked when another service is
104 installed or reinstalled.
106 @param NotifyList A pointer to the list of notification interfaces that the caller
109 @retval EFI_SUCCESS The interface was successfully installed.
110 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
111 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the
112 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.
113 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
118 PeiServicesNotifyPpi (
119 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
122 CONST EFI_PEI_SERVICES
**PeiServices
;
124 PeiServices
= GetPeiServicesTablePointer ();
125 return (*PeiServices
)->NotifyPpi (PeiServices
, NotifyList
);
129 This service enables PEIMs to ascertain the present value of the boot mode.
131 @param BootMode A pointer to contain the value of the boot mode.
133 @retval EFI_SUCCESS The boot mode was returned successfully.
134 @retval EFI_INVALID_PARAMETER BootMode is NULL.
139 PeiServicesGetBootMode (
140 IN OUT EFI_BOOT_MODE
*BootMode
143 CONST EFI_PEI_SERVICES
**PeiServices
;
145 PeiServices
= GetPeiServicesTablePointer ();
146 return (*PeiServices
)->GetBootMode (PeiServices
, BootMode
);
150 This service enables PEIMs to update the boot mode variable.
152 @param BootMode The value of the boot mode to set.
154 @retval EFI_SUCCESS The value was successfully updated
159 PeiServicesSetBootMode (
160 IN EFI_BOOT_MODE BootMode
163 CONST EFI_PEI_SERVICES
**PeiServices
;
165 PeiServices
= GetPeiServicesTablePointer ();
166 return (*PeiServices
)->SetBootMode (PeiServices
, BootMode
);
170 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
172 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.
174 @retval EFI_SUCCESS The list was successfully returned.
175 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
180 PeiServicesGetHobList (
184 CONST EFI_PEI_SERVICES
**PeiServices
;
186 PeiServices
= GetPeiServicesTablePointer ();
187 return (*PeiServices
)->GetHobList (PeiServices
, HobList
);
191 This service enables PEIMs to create various types of HOBs.
193 @param Type The type of HOB to be installed.
194 @param Length The length of the HOB to be added.
195 @param Hob The address of a pointer that will contain the HOB header.
197 @retval EFI_SUCCESS The HOB was successfully created.
198 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
203 PeiServicesCreateHob (
209 CONST EFI_PEI_SERVICES
**PeiServices
;
211 PeiServices
= GetPeiServicesTablePointer ();
212 return (*PeiServices
)->CreateHob (PeiServices
, Type
, Length
, Hob
);
216 This service enables PEIMs to discover additional firmware volumes.
218 @param Instance This instance of the firmware volume to find. The value 0 is the
219 Boot Firmware Volume (BFV).
220 @param VolumeHandle Handle of the firmware volume header of the volume to return.
222 @retval EFI_SUCCESS The volume was found.
223 @retval EFI_NOT_FOUND The volume was not found.
224 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
229 PeiServicesFfsFindNextVolume (
231 IN OUT EFI_PEI_FV_HANDLE
*VolumeHandle
234 CONST EFI_PEI_SERVICES
**PeiServices
;
236 PeiServices
= GetPeiServicesTablePointer ();
237 return (*PeiServices
)->FfsFindNextVolume (PeiServices
, Instance
, VolumeHandle
);
241 This service enables PEIMs to discover additional firmware files.
243 @param SearchType A filter to find files only of this type.
244 @param VolumeHandle Pointer to the firmware volume header of the volume to search.
245 This parameter must point to a valid FFS volume.
246 @param FileHandle Handle of the current file from which to begin searching.
248 @retval EFI_SUCCESS The file was found.
249 @retval EFI_NOT_FOUND The file was not found.
250 @retval EFI_NOT_FOUND The header checksum was not zero.
255 PeiServicesFfsFindNextFile (
256 IN EFI_FV_FILETYPE SearchType
,
257 IN EFI_PEI_FV_HANDLE VolumeHandle
,
258 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
261 CONST EFI_PEI_SERVICES
**PeiServices
;
263 PeiServices
= GetPeiServicesTablePointer ();
264 return (*PeiServices
)->FfsFindNextFile (PeiServices
, SearchType
, VolumeHandle
, FileHandle
);
268 This service enables PEIMs to discover sections of a given type within a valid FFS file.
270 @param SectionType The value of the section type to find.
271 @param FfsFileHeader A pointer to the file header that contains the set of sections to
273 @param SectionData A pointer to the discovered section, if successful.
275 @retval EFI_SUCCESS The section was found.
276 @retval EFI_NOT_FOUND The section was not found.
281 PeiServicesFfsFindSectionData (
282 IN EFI_SECTION_TYPE SectionType
,
283 IN EFI_PEI_FILE_HANDLE FfsFileHeader
,
284 OUT VOID
**SectionData
287 CONST EFI_PEI_SERVICES
**PeiServices
;
289 PeiServices
= GetPeiServicesTablePointer ();
290 return (*PeiServices
)->FfsFindSectionData (PeiServices
, SectionType
, FfsFileHeader
, SectionData
);
294 This service enables PEIMs to register the permanent memory configuration
295 that has been initialized with the PEI Foundation.
297 @param MemoryBegin The value of a region of installed memory.
298 @param MemoryLength The corresponding length of a region of installed memory.
300 @retval EFI_SUCCESS The region was successfully installed in a HOB.
301 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
302 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
307 PeiServicesInstallPeiMemory (
308 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
309 IN UINT64 MemoryLength
312 CONST EFI_PEI_SERVICES
**PeiServices
;
314 PeiServices
= GetPeiServicesTablePointer ();
315 return (*PeiServices
)->InstallPeiMemory (PeiServices
, MemoryBegin
, MemoryLength
);
319 This service enables PEIMs to allocate memory after the permanent memory has been installed by a
322 @param MemoryType Type of memory to allocate.
323 @param Pages Number of pages to allocate.
324 @param Memory Pointer of memory allocated.
326 @retval EFI_SUCCESS The memory range was successfully allocated.
327 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
328 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
329 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
334 PeiServicesAllocatePages (
335 IN EFI_MEMORY_TYPE MemoryType
,
337 OUT EFI_PHYSICAL_ADDRESS
*Memory
340 CONST EFI_PEI_SERVICES
**PeiServices
;
342 PeiServices
= GetPeiServicesTablePointer ();
343 return (*PeiServices
)->AllocatePages (PeiServices
, MemoryType
, Pages
, Memory
);
347 This service allocates memory from the Hand-Off Block (HOB) heap.
349 @param Size The number of bytes to allocate from the pool.
350 @param Buffer If the call succeeds, a pointer to a pointer to the allocate
351 buffer; undefined otherwise.
353 @retval EFI_SUCCESS The allocation was successful
354 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
359 PeiServicesAllocatePool (
364 CONST EFI_PEI_SERVICES
**PeiServices
;
366 PeiServices
= GetPeiServicesTablePointer ();
367 return (*PeiServices
)->AllocatePool (PeiServices
, Size
, Buffer
);
371 Resets the entire platform.
375 @retval EFI_SUCCESS The function completed successfully.
376 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
381 PeiServicesResetSystem (
385 CONST EFI_PEI_SERVICES
**PeiServices
;
387 PeiServices
= GetPeiServicesTablePointer ();
388 return (*PeiServices
)->ResetSystem (PeiServices
);
392 This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services
393 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
394 Specification for details.
396 @param FileHandle PEIM's file handle. Must be the currently
399 @retval EFI_SUCCESS The PEIM was successfully registered for
402 @retval EFI_ALREADY_STARTED The PEIM was previously
403 registered for shadowing.
405 @retval EFI_NOT_FOUND The FileHandle does not refer to a
410 PeiServicesRegisterForShadow (
411 IN EFI_PEI_FILE_HANDLE FileHandle
414 return (*GetPeiServicesTablePointer())->RegisterForShadow (FileHandle
);
418 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
419 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
420 Specification for details.
422 @param FileHandle Handle of the file.
424 @param FileInfo Upon exit, points to the file's
427 @retval EFI_SUCCESS File information returned.
429 @retval EFI_INVALID_PARAMETER If FileHandle does not
430 represent a valid file.
432 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
437 PeiServicesFfsGetFileInfo (
438 IN CONST EFI_PEI_FILE_HANDLE FileHandle
,
439 OUT EFI_FV_FILE_INFO
*FileInfo
442 return (*GetPeiServicesTablePointer())->FfsGetFileInfo (FileHandle
, FileInfo
);
447 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
448 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
449 Specification for details.
451 @param FileName A pointer to the name of the file to
452 find within the firmware volume.
454 @param VolumeHandle The firmware volume to search FileHandle
455 Upon exit, points to the found file's
456 handle or NULL if it could not be found.
458 @param FileHandle The filehandle found in volume.
460 @retval EFI_SUCCESS File was found.
462 @retval EFI_NOT_FOUND File was not found.
464 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
470 PeiServicesFfsFindFileByName (
471 IN CONST EFI_GUID
*FileName
,
472 IN CONST EFI_PEI_FV_HANDLE VolumeHandle
,
473 OUT EFI_PEI_FILE_HANDLE
*FileHandle
476 return (*GetPeiServicesTablePointer())->FfsFindFileByName (FileName
, VolumeHandle
, FileHandle
);
481 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
482 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
483 Specification for details.
485 @param VolumeHandle Handle of the volume.
487 @param VolumeInfo Upon exit, points to the volume's
490 @retval EFI_SUCCESS File information returned.
492 @retval EFI_INVALID_PARAMETER If FileHandle does not
493 represent a valid file.
495 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
500 PeiServicesFfsGetVolumeInfo (
501 IN EFI_PEI_FV_HANDLE VolumeHandle
,
502 OUT EFI_FV_INFO
*VolumeInfo
505 return (*GetPeiServicesTablePointer())->FfsGetVolumeInfo (VolumeHandle
, VolumeInfo
);