2 Implementation for PEI Services Library.
4 Copyright (c) 2006 - 2007, 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
= (CONST EFI_PEI_SERVICES
**) 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
= (CONST EFI_PEI_SERVICES
**) 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
= (CONST EFI_PEI_SERVICES
**) 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
= (CONST EFI_PEI_SERVICES
**) 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
= (CONST EFI_PEI_SERVICES
**) 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
= (CONST EFI_PEI_SERVICES
**) 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 (
181 IN OUT VOID
**HobList
184 CONST EFI_PEI_SERVICES
**PeiServices
;
186 PeiServices
= (CONST EFI_PEI_SERVICES
**) 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
= (CONST EFI_PEI_SERVICES
**) 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 FwVolHeader Pointer to 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
= (CONST EFI_PEI_SERVICES
**) 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 FwVolHeader Pointer to the firmware volume header of the volume to search.
245 This parameter must point to a valid FFS volume.
246 @param FileHeader Pointer to 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
= (CONST EFI_PEI_SERVICES
**) 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 SearchType 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 IN OUT VOID
**SectionData
287 CONST EFI_PEI_SERVICES
**PeiServices
;
289 PeiServices
= (CONST EFI_PEI_SERVICES
**) 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
= (CONST EFI_PEI_SERVICES
**) 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 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
340 CONST EFI_PEI_SERVICES
**PeiServices
;
342 PeiServices
= (CONST EFI_PEI_SERVICES
**) 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
= (CONST EFI_PEI_SERVICES
**) GetPeiServicesTablePointer ();
367 return (*PeiServices
)->AllocatePool (PeiServices
, Size
, Buffer
);
371 This service resets the entire platform, including all processors and devices, and reboots the
374 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
379 PeiServicesResetSystem (
383 CONST EFI_PEI_SERVICES
**PeiServices
;
385 PeiServices
= (CONST EFI_PEI_SERVICES
**) GetPeiServicesTablePointer ();
386 return (*PeiServices
)->ResetSystem (PeiServices
);
391 PeiServicesRegisterForShadow (
392 IN EFI_PEI_FILE_HANDLE FileHandle
395 EFI_PEI_SERVICES
**PeiServices
;
397 PeiServices
= GetPeiServicesTablePointer ();
398 return (*PeiServices
)->RegisterForShadow (FileHandle
);
403 PeiServicesFfsGetFileInfo (
404 IN CONST EFI_PEI_FILE_HANDLE FileHandle
,
405 OUT EFI_FV_FILE_INFO
*FileInfo
408 EFI_PEI_SERVICES
**PeiServices
;
410 PeiServices
= GetPeiServicesTablePointer ();
411 return (*PeiServices
)->FfsGetFileInfo (FileHandle
, FileInfo
);
417 PeiServicesFfsFindFileByName (
418 IN CONST EFI_GUID
*FileName
,
419 IN CONST EFI_PEI_FV_HANDLE VolumeHandle
,
420 OUT EFI_PEI_FILE_HANDLE
*FileHandle
423 return (*GetPeiServicesTablePointer())->FfsFindFileByName (FileName
, VolumeHandle
, FileHandle
);
429 PeiServicesFfsGetVolumeInfo (
430 IN EFI_PEI_FV_HANDLE VolumeHandle
,
431 OUT EFI_FV_INFO
*VolumeInfo
434 return (*GetPeiServicesTablePointer())->FfsGetVolumeInfo (VolumeHandle
, VolumeInfo
);