4 Copyright (c) 2006, 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.
13 Module Name: PeiCoreLib.c
18 This service enables a given PEIM to register an interface into the PEI Foundation.
20 @param PpiList A pointer to the list of interfaces that the caller shall install.
22 @retval EFI_SUCCESS The interface was successfully installed.
23 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
24 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have
25 the EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
26 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
32 IN EFI_PEI_PPI_DESCRIPTOR
*PpiList
35 EFI_PEI_SERVICES
**PeiServices
;
37 PeiServices
= GetPeiServicesTablePointer ();
38 return (*PeiServices
)->InstallPpi (PeiServices
, PpiList
);
42 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
44 @param OldPpi Pointer to the old PEI PPI Descriptors.
45 @param NewPpi Pointer to the new PEI PPI Descriptors.
47 @retval EFI_SUCCESS The interface was successfully installed.
48 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
49 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have
50 the EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
51 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
52 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been installed.
58 IN EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
59 IN EFI_PEI_PPI_DESCRIPTOR
*NewPpi
62 EFI_PEI_SERVICES
**PeiServices
;
64 PeiServices
= GetPeiServicesTablePointer ();
65 return (*PeiServices
)->ReInstallPpi (PeiServices
, OldPpi
, NewPpi
);
69 This service enables PEIMs to discover a given instance of an interface.
71 @param Guid A pointer to the GUID whose corresponding interface needs to be found.
72 @param Instance The N-th instance of the interface that is required.
73 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
74 @param Ppi A pointer to the instance of the interface.
76 @retval EFI_SUCCESS The interface was successfully returned.
77 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
85 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
89 EFI_PEI_SERVICES
**PeiServices
;
91 PeiServices
= GetPeiServicesTablePointer ();
92 return (*PeiServices
)->LocatePpi (PeiServices
, Guid
, Instance
, PpiDescriptor
, Ppi
);
96 This service enables PEIMs to register a given service to be invoked
97 when another service is installed or reinstalled.
99 @param NotifyList A pointer to the list of notification interfaces that the caller shall install.
101 @retval EFI_SUCCESS The interface was successfully installed.
102 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
103 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have
104 the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.
105 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
111 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
114 EFI_PEI_SERVICES
**PeiServices
;
116 PeiServices
= GetPeiServicesTablePointer ();
117 return (*PeiServices
)->NotifyPpi (PeiServices
, NotifyList
);
121 This service enables PEIMs to ascertain the present value of the boot mode.
123 @param BootMode A pointer to contain the value of the boot mode.
125 @retval EFI_SUCCESS The boot mode was returned successfully.
126 @retval EFI_INVALID_PARAMETER BootMode is NULL.
132 IN OUT EFI_BOOT_MODE
*BootMode
135 EFI_PEI_SERVICES
**PeiServices
;
137 PeiServices
= GetPeiServicesTablePointer ();
138 return (*PeiServices
)->GetBootMode (PeiServices
, BootMode
);
142 This service enables PEIMs to update the boot mode variable.
144 @param BootMode The value of the boot mode to set.
146 @retval EFI_SUCCESS The value was successfully updated
152 IN EFI_BOOT_MODE BootMode
155 EFI_PEI_SERVICES
**PeiServices
;
157 PeiServices
= GetPeiServicesTablePointer ();
158 return (*PeiServices
)->SetBootMode (PeiServices
, BootMode
);
162 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
164 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.
166 @retval EFI_SUCCESS The list was successfully returned.
167 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
173 IN OUT VOID
**HobList
176 EFI_PEI_SERVICES
**PeiServices
;
178 PeiServices
= GetPeiServicesTablePointer ();
179 return (*PeiServices
)->GetHobList (PeiServices
, HobList
);
183 This service enables PEIMs to create various types of HOBs.
185 @param Type The type of HOB to be installed.
186 @param Length The length of the HOB to be added.
187 @param Hob The address of a pointer that will contain the HOB header.
189 @retval EFI_SUCCESS The HOB was successfully created.
190 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
201 EFI_PEI_SERVICES
**PeiServices
;
203 PeiServices
= GetPeiServicesTablePointer ();
204 return (*PeiServices
)->CreateHob (PeiServices
, Type
, Length
, Hob
);
208 This service enables PEIMs to discover additional firmware volumes.
210 @param Instance This instance of the firmware volume to find.
211 The value 0 is the Boot Firmware Volume (BFV).
212 @param FwVolHeader Pointer to the firmware volume header of the volume to return.
214 @retval EFI_SUCCESS The volume was found.
215 @retval EFI_NOT_FOUND The volume was not found.
216 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
221 PeiCoreFfsFindNextVolume (
223 IN OUT EFI_FIRMWARE_VOLUME_HEADER
**FwVolHeader
226 EFI_PEI_SERVICES
**PeiServices
;
228 PeiServices
= GetPeiServicesTablePointer ();
229 return (*PeiServices
)->FfsFindNextVolume (PeiServices
, Instance
, FwVolHeader
);
233 This service enables PEIMs to discover additional firmware files.
235 @param SearchType A filter to find files only of this type.
236 @param FwVolHeader Pointer to the firmware volume header of the volume to search.
237 This parameter must point to a valid FFS volume.
238 @param FileHeader Pointer to the current file from which to begin searching.
240 @retval EFI_SUCCESS The file was found.
241 @retval EFI_NOT_FOUND The file was not found.
242 @retval EFI_NOT_FOUND The header checksum was not zero.
247 PeiCoreFfsFindNextFile (
248 IN EFI_FV_FILETYPE SearchType
,
249 IN EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
,
250 IN OUT EFI_FFS_FILE_HEADER
**FileHeader
253 EFI_PEI_SERVICES
**PeiServices
;
255 PeiServices
= GetPeiServicesTablePointer ();
256 return (*PeiServices
)->FfsFindNextFile (PeiServices
, SearchType
, FwVolHeader
, FileHeader
);
260 This service enables PEIMs to discover sections of a given type within a valid FFS file.
262 @param SearchType The value of the section type to find.
263 @param FfsFileHeader A pointer to the file header that contains the set of sections to be searched.
264 @param SectionData A pointer to the discovered section, if successful.
266 @retval EFI_SUCCESS The section was found.
267 @retval EFI_NOT_FOUND The section was not found.
272 PeiCoreFfsFindSectionData (
273 IN EFI_SECTION_TYPE SectionType
,
274 IN EFI_FFS_FILE_HEADER
*FfsFileHeader
,
275 IN OUT VOID
**SectionData
278 EFI_PEI_SERVICES
**PeiServices
;
280 PeiServices
= GetPeiServicesTablePointer ();
281 return (*PeiServices
)->FfsFindSectionData (PeiServices
, SectionType
, FfsFileHeader
, SectionData
);
285 This service enables PEIMs to register the permanent memory configuration
286 that has been initialized with the PEI Foundation.
288 @param MemoryBegin The value of a region of installed memory.
289 @param MemoryLength The corresponding length of a region of installed memory.
291 @retval EFI_SUCCESS The region was successfully installed in a HOB.
292 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
293 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
298 PeiCoreInstallPeiMemory (
299 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
300 IN UINT64 MemoryLength
303 EFI_PEI_SERVICES
**PeiServices
;
305 PeiServices
= GetPeiServicesTablePointer ();
306 return (*PeiServices
)->InstallPeiMemory (PeiServices
, MemoryBegin
, MemoryLength
);
310 This service enables PEIMs to allocate memory after the permanent memory has been installed by a PEIM.
312 @param MemoryType Type of memory to allocate.
313 @param Pages Number of pages to allocate.
314 @param Memory Pointer of memory allocated.
316 @retval EFI_SUCCESS The memory range was successfully allocated.
317 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
318 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
319 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
324 PeiCoreAllocatePages (
325 IN EFI_MEMORY_TYPE MemoryType
,
327 IN OUT EFI_PHYSICAL_ADDRESS
*Memory
330 EFI_PEI_SERVICES
**PeiServices
;
332 PeiServices
= GetPeiServicesTablePointer ();
333 return (*PeiServices
)->AllocatePages (PeiServices
, MemoryType
, Pages
, Memory
);
337 This service allocates memory from the Hand-Off Block (HOB) heap.
339 @param Size The number of bytes to allocate from the pool.
340 @param Buffer If the call succeeds, a pointer to a pointer to the allocated buffer;
343 @retval EFI_SUCCESS The allocation was successful
344 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
349 PeiCoreAllocatePool (
354 EFI_PEI_SERVICES
**PeiServices
;
356 PeiServices
= GetPeiServicesTablePointer ();
357 return (*PeiServices
)->AllocatePool (PeiServices
, Size
, Buffer
);
361 This service resets the entire platform, including all processors and devices, and reboots the system.
363 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
372 EFI_PEI_SERVICES
**PeiServices
;
374 PeiServices
= GetPeiServicesTablePointer ();
375 return (*PeiServices
)->PeiResetSystem (PeiServices
);