3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #include "EdkIIGluePeim.h"
26 This service enables a given PEIM to register an interface into the PEI Foundation.
28 @param PpiList A pointer to the list of interfaces that the caller shall install.
30 @retval EFI_SUCCESS The interface was successfully installed.
31 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
32 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
33 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
34 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
39 PeiServicesInstallPpi (
40 IN EFI_PEI_PPI_DESCRIPTOR
*PpiList
43 EFI_PEI_SERVICES
**PeiServices
;
45 PeiServices
= GetPeiServicesTablePointer ();
46 return (*PeiServices
)->InstallPpi (PeiServices
, PpiList
);
50 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
52 @param OldPpi Pointer to the old PEI PPI Descriptors.
53 @param NewPpi Pointer to the new PEI PPI Descriptors.
55 @retval EFI_SUCCESS The interface was successfully installed.
56 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
57 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
58 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
59 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
60 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
66 PeiServicesReInstallPpi (
67 IN EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
68 IN EFI_PEI_PPI_DESCRIPTOR
*NewPpi
71 EFI_PEI_SERVICES
**PeiServices
;
73 PeiServices
= GetPeiServicesTablePointer ();
74 return (*PeiServices
)->ReInstallPpi (PeiServices
, OldPpi
, NewPpi
);
78 This service enables PEIMs to discover a given instance of an interface.
80 @param Guid A pointer to the GUID whose corresponding interface needs to be
82 @param Instance The N-th instance of the interface that is required.
83 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
84 @param Ppi A pointer to the instance of the interface.
86 @retval EFI_SUCCESS The interface was successfully returned.
87 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
92 PeiServicesLocatePpi (
95 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
99 EFI_PEI_SERVICES
**PeiServices
;
101 PeiServices
= GetPeiServicesTablePointer ();
102 return (*PeiServices
)->LocatePpi (PeiServices
, Guid
, Instance
, PpiDescriptor
, Ppi
);
106 This service enables PEIMs to register a given service to be invoked when another service is
107 installed or reinstalled.
109 @param NotifyList A pointer to the list of notification interfaces that the caller
112 @retval EFI_SUCCESS The interface was successfully installed.
113 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
114 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the
115 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.
116 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
121 PeiServicesNotifyPpi (
122 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
125 EFI_PEI_SERVICES
**PeiServices
;
127 PeiServices
= GetPeiServicesTablePointer ();
128 return (*PeiServices
)->NotifyPpi (PeiServices
, NotifyList
);
132 This service enables PEIMs to ascertain the present value of the boot mode.
134 @param BootMode A pointer to contain the value of the boot mode.
136 @retval EFI_SUCCESS The boot mode was returned successfully.
137 @retval EFI_INVALID_PARAMETER BootMode is NULL.
142 PeiServicesGetBootMode (
143 IN OUT EFI_BOOT_MODE
*BootMode
146 EFI_PEI_SERVICES
**PeiServices
;
148 PeiServices
= GetPeiServicesTablePointer ();
149 return (*PeiServices
)->GetBootMode (PeiServices
, BootMode
);
153 This service enables PEIMs to update the boot mode variable.
155 @param BootMode The value of the boot mode to set.
157 @retval EFI_SUCCESS The value was successfully updated
162 PeiServicesSetBootMode (
163 IN EFI_BOOT_MODE BootMode
166 EFI_PEI_SERVICES
**PeiServices
;
168 PeiServices
= GetPeiServicesTablePointer ();
169 return (*PeiServices
)->SetBootMode (PeiServices
, BootMode
);
173 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
175 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.
177 @retval EFI_SUCCESS The list was successfully returned.
178 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
183 PeiServicesGetHobList (
184 IN OUT VOID
**HobList
187 EFI_PEI_SERVICES
**PeiServices
;
189 PeiServices
= GetPeiServicesTablePointer ();
190 return (*PeiServices
)->GetHobList (PeiServices
, HobList
);
194 This service enables PEIMs to create various types of HOBs.
196 @param Type The type of HOB to be installed.
197 @param Length The length of the HOB to be added.
198 @param Hob The address of a pointer that will contain the HOB header.
200 @retval EFI_SUCCESS The HOB was successfully created.
201 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
206 PeiServicesCreateHob (
212 EFI_PEI_SERVICES
**PeiServices
;
214 PeiServices
= GetPeiServicesTablePointer ();
215 return (*PeiServices
)->CreateHob (PeiServices
, Type
, Length
, Hob
);
218 #if (PI_SPECIFICATION_VERSION < 0x00010000)
220 This service enables PEIMs to discover additional firmware volumes.
222 @param Instance This instance of the firmware volume to find. The value 0 is the
223 Boot Firmware Volume (BFV).
224 @param FwVolHeader Pointer to the firmware volume header of the volume to return.
226 @retval EFI_SUCCESS The volume was found.
227 @retval EFI_NOT_FOUND The volume was not found.
228 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
233 PeiServicesFfsFindNextVolume (
235 IN OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
238 EFI_PEI_SERVICES
**PeiServices
;
240 PeiServices
= GetPeiServicesTablePointer ();
241 return (*PeiServices
)->FfsFindNextVolume (PeiServices
, Instance
, FwVolHeader
);
245 This service enables PEIMs to discover additional firmware files.
247 @param SearchType A filter to find files only of this type.
248 @param FwVolHeader Pointer to the firmware volume header of the volume to search.
249 This parameter must point to a valid FFS volume.
250 @param FileHeader Pointer to the current file from which to begin searching.
252 @retval EFI_SUCCESS The file was found.
253 @retval EFI_NOT_FOUND The file was not found.
254 @retval EFI_NOT_FOUND The header checksum was not zero.
259 PeiServicesFfsFindNextFile (
260 IN EFI_FV_FILETYPE SearchType
,
261 IN EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
,
262 IN OUT EFI_FFS_FILE_HEADER
**FileHeader
265 EFI_PEI_SERVICES
**PeiServices
;
267 PeiServices
= GetPeiServicesTablePointer ();
268 return (*PeiServices
)->FfsFindNextFile (PeiServices
, SearchType
, FwVolHeader
, FileHeader
);
272 This service enables PEIMs to discover sections of a given type within a valid FFS file.
274 @param SearchType The value of the section type to find.
275 @param FfsFileHeader A pointer to the file header that contains the set of sections to
277 @param SectionData A pointer to the discovered section, if successful.
279 @retval EFI_SUCCESS The section was found.
280 @retval EFI_NOT_FOUND The section was not found.
285 PeiServicesFfsFindSectionData (
286 IN EFI_SECTION_TYPE SectionType
,
287 IN EFI_FFS_FILE_HEADER
*FfsFileHeader
,
288 IN OUT VOID
**SectionData
291 EFI_PEI_SERVICES
**PeiServices
;
293 PeiServices
= GetPeiServicesTablePointer ();
294 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
)->PeiResetSystem (PeiServices
);