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.
16 // The package level header files this module uses
20 // The protocols, PPI and GUID defintions for this module
23 // The Library classes this module consumes
25 #include <Library/PeiServicesLib.h>
26 #include <Library/PeiServicesTablePointerLib.h>
29 This service enables a given PEIM to register an interface into the PEI Foundation.
31 @param PpiList A pointer to the list of interfaces that the caller shall install.
33 @retval EFI_SUCCESS The interface was successfully installed.
34 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
35 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
36 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
37 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
42 PeiServicesInstallPpi (
43 IN EFI_PEI_PPI_DESCRIPTOR
*PpiList
46 EFI_PEI_SERVICES
**PeiServices
;
48 PeiServices
= GetPeiServicesTablePointer ();
49 return (*PeiServices
)->InstallPpi (PeiServices
, PpiList
);
53 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
55 @param OldPpi Pointer to the old PEI PPI Descriptors.
56 @param NewPpi Pointer to the new PEI PPI Descriptors.
58 @retval EFI_SUCCESS The interface was successfully installed.
59 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
60 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
61 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
62 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
63 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
69 PeiServicesReInstallPpi (
70 IN EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
71 IN EFI_PEI_PPI_DESCRIPTOR
*NewPpi
74 EFI_PEI_SERVICES
**PeiServices
;
76 PeiServices
= GetPeiServicesTablePointer ();
77 return (*PeiServices
)->ReInstallPpi (PeiServices
, OldPpi
, NewPpi
);
81 This service enables PEIMs to discover a given instance of an interface.
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 (
98 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
102 EFI_PEI_SERVICES
**PeiServices
;
104 PeiServices
= GetPeiServicesTablePointer ();
105 return (*PeiServices
)->LocatePpi (PeiServices
, Guid
, Instance
, PpiDescriptor
, Ppi
);
109 This service enables PEIMs to register a given service to be invoked when another service is
110 installed or reinstalled.
112 @param NotifyList A pointer to the list of notification interfaces that the caller
115 @retval EFI_SUCCESS The interface was successfully installed.
116 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
117 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the
118 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.
119 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
124 PeiServicesNotifyPpi (
125 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
128 EFI_PEI_SERVICES
**PeiServices
;
130 PeiServices
= GetPeiServicesTablePointer ();
131 return (*PeiServices
)->NotifyPpi (PeiServices
, NotifyList
);
135 This service enables PEIMs to ascertain the present value of the boot mode.
137 @param BootMode A pointer to contain the value of the boot mode.
139 @retval EFI_SUCCESS The boot mode was returned successfully.
140 @retval EFI_INVALID_PARAMETER BootMode is NULL.
145 PeiServicesGetBootMode (
146 IN OUT EFI_BOOT_MODE
*BootMode
149 EFI_PEI_SERVICES
**PeiServices
;
151 PeiServices
= GetPeiServicesTablePointer ();
152 return (*PeiServices
)->GetBootMode (PeiServices
, BootMode
);
156 This service enables PEIMs to update the boot mode variable.
158 @param BootMode The value of the boot mode to set.
160 @retval EFI_SUCCESS The value was successfully updated
165 PeiServicesSetBootMode (
166 IN EFI_BOOT_MODE BootMode
169 EFI_PEI_SERVICES
**PeiServices
;
171 PeiServices
= GetPeiServicesTablePointer ();
172 return (*PeiServices
)->SetBootMode (PeiServices
, BootMode
);
176 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
178 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.
180 @retval EFI_SUCCESS The list was successfully returned.
181 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
186 PeiServicesGetHobList (
187 IN OUT VOID
**HobList
190 EFI_PEI_SERVICES
**PeiServices
;
192 PeiServices
= GetPeiServicesTablePointer ();
193 return (*PeiServices
)->GetHobList (PeiServices
, HobList
);
197 This service enables PEIMs to create various types of HOBs.
199 @param Type The type of HOB to be installed.
200 @param Length The length of the HOB to be added.
201 @param Hob The address of a pointer that will contain the HOB header.
203 @retval EFI_SUCCESS The HOB was successfully created.
204 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
209 PeiServicesCreateHob (
215 EFI_PEI_SERVICES
**PeiServices
;
217 PeiServices
= GetPeiServicesTablePointer ();
218 return (*PeiServices
)->CreateHob (PeiServices
, Type
, Length
, Hob
);
222 This service enables PEIMs to discover additional firmware volumes.
224 @param Instance This instance of the firmware volume to find. The value 0 is the
225 Boot Firmware Volume (BFV).
226 @param FwVolHeader Pointer to the firmware volume header of the volume to return.
228 @retval EFI_SUCCESS The volume was found.
229 @retval EFI_NOT_FOUND The volume was not found.
230 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
235 PeiServicesFfsFindNextVolume (
237 IN OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
240 EFI_PEI_SERVICES
**PeiServices
;
242 PeiServices
= GetPeiServicesTablePointer ();
243 return (*PeiServices
)->FfsFindNextVolume (PeiServices
, Instance
, FwVolHeader
);
247 This service enables PEIMs to discover additional firmware files.
249 @param SearchType A filter to find files only of this type.
250 @param FwVolHeader Pointer to the firmware volume header of the volume to search.
251 This parameter must point to a valid FFS volume.
252 @param FileHeader Pointer to the current file from which to begin searching.
254 @retval EFI_SUCCESS The file was found.
255 @retval EFI_NOT_FOUND The file was not found.
256 @retval EFI_NOT_FOUND The header checksum was not zero.
261 PeiServicesFfsFindNextFile (
262 IN EFI_FV_FILETYPE SearchType
,
263 IN EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
,
264 IN OUT EFI_FFS_FILE_HEADER
**FileHeader
267 EFI_PEI_SERVICES
**PeiServices
;
269 PeiServices
= GetPeiServicesTablePointer ();
270 return (*PeiServices
)->FfsFindNextFile (PeiServices
, SearchType
, FwVolHeader
, FileHeader
);
274 This service enables PEIMs to discover sections of a given type within a valid FFS file.
276 @param SearchType The value of the section type to find.
277 @param FfsFileHeader A pointer to the file header that contains the set of sections to
279 @param SectionData A pointer to the discovered section, if successful.
281 @retval EFI_SUCCESS The section was found.
282 @retval EFI_NOT_FOUND The section was not found.
287 PeiServicesFfsFindSectionData (
288 IN EFI_SECTION_TYPE SectionType
,
289 IN EFI_FFS_FILE_HEADER
*FfsFileHeader
,
290 IN OUT VOID
**SectionData
293 EFI_PEI_SERVICES
**PeiServices
;
295 PeiServices
= GetPeiServicesTablePointer ();
296 return (*PeiServices
)->FfsFindSectionData (PeiServices
, SectionType
, FfsFileHeader
, SectionData
);
300 This service enables PEIMs to register the permanent memory configuration
301 that has been initialized with the PEI Foundation.
303 @param MemoryBegin The value of a region of installed memory.
304 @param MemoryLength The corresponding length of a region of installed memory.
306 @retval EFI_SUCCESS The region was successfully installed in a HOB.
307 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
308 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
313 PeiServicesInstallPeiMemory (
314 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
315 IN UINT64 MemoryLength
318 EFI_PEI_SERVICES
**PeiServices
;
320 PeiServices
= GetPeiServicesTablePointer ();
321 return (*PeiServices
)->InstallPeiMemory (PeiServices
, MemoryBegin
, MemoryLength
);
325 This service enables PEIMs to allocate memory after the permanent memory has been installed by a
328 @param MemoryType Type of memory to allocate.
329 @param Pages Number of pages to allocate.
330 @param Memory Pointer of memory allocated.
332 @retval EFI_SUCCESS The memory range was successfully allocated.
333 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
334 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
335 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
340 PeiServicesAllocatePages (
341 IN EFI_MEMORY_TYPE MemoryType
,
343 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
346 EFI_PEI_SERVICES
**PeiServices
;
348 PeiServices
= GetPeiServicesTablePointer ();
349 return (*PeiServices
)->AllocatePages (PeiServices
, MemoryType
, Pages
, Memory
);
353 This service allocates memory from the Hand-Off Block (HOB) heap.
355 @param Size The number of bytes to allocate from the pool.
356 @param Buffer If the call succeeds, a pointer to a pointer to the allocate
357 buffer; undefined otherwise.
359 @retval EFI_SUCCESS The allocation was successful
360 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
365 PeiServicesAllocatePool (
370 EFI_PEI_SERVICES
**PeiServices
;
372 PeiServices
= GetPeiServicesTablePointer ();
373 return (*PeiServices
)->AllocatePool (PeiServices
, Size
, Buffer
);
377 This service resets the entire platform, including all processors and devices, and reboots the
380 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
385 PeiServicesResetSystem (
389 EFI_PEI_SERVICES
**PeiServices
;
391 PeiServices
= GetPeiServicesTablePointer ();
392 return (*PeiServices
)->ResetSystem (PeiServices
);