]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiServicesLib/PeiServicesLib.c
remove some comments introduced by tools.
[mirror_edk2.git] / MdePkg / Library / PeiServicesLib / PeiServicesLib.c
CommitLineData
738ec565 1/** @file\r
2 Implementation for PEI Services Library.\r
3\r
4 Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
738ec565 13**/\r
14\r
15//\r
c7d265a9 16// The package level header files this module uses\r
738ec565 17//\r
c7d265a9 18#include <PiPei.h>\r
19//\r
20// The protocols, PPI and GUID defintions for this module\r
21//\r
22//\r
23// The Library classes this module consumes\r
24//\r
25#include <Library/PeiServicesLib.h>\r
26#include <Library/PeiServicesTablePointerLib.h>\r
738ec565 27\r
28/**\r
29 This service enables a given PEIM to register an interface into the PEI Foundation.\r
30\r
31 @param PpiList A pointer to the list of interfaces that the caller shall install.\r
32\r
33 @retval EFI_SUCCESS The interface was successfully installed.\r
34 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r
35 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
36 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
37 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r
38\r
39**/\r
40EFI_STATUS\r
41EFIAPI\r
42PeiServicesInstallPpi (\r
43 IN EFI_PEI_PPI_DESCRIPTOR *PpiList\r
44 )\r
45{\r
46 EFI_PEI_SERVICES **PeiServices;\r
47\r
48 PeiServices = GetPeiServicesTablePointer ();\r
49 return (*PeiServices)->InstallPpi (PeiServices, PpiList);\r
50}\r
51\r
52/**\r
53 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r
54\r
55 @param OldPpi Pointer to the old PEI PPI Descriptors.\r
56 @param NewPpi Pointer to the new PEI PPI Descriptors.\r
57\r
58 @retval EFI_SUCCESS The interface was successfully installed.\r
59 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r
60 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
61 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
62 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r
63 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been\r
64 installed.\r
65\r
66**/\r
67EFI_STATUS\r
68EFIAPI\r
69PeiServicesReInstallPpi (\r
70 IN EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
71 IN EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
72 )\r
73{\r
74 EFI_PEI_SERVICES **PeiServices;\r
75\r
76 PeiServices = GetPeiServicesTablePointer ();\r
77 return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi);\r
78}\r
79\r
80/**\r
81 This service enables PEIMs to discover a given instance of an interface.\r
82\r
83 @param Guid A pointer to the GUID whose corresponding interface needs to be\r
84 found.\r
85 @param Instance The N-th instance of the interface that is required.\r
86 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r
87 @param Ppi A pointer to the instance of the interface.\r
88\r
89 @retval EFI_SUCCESS The interface was successfully returned.\r
90 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.\r
91\r
92**/\r
93EFI_STATUS\r
94EFIAPI\r
95PeiServicesLocatePpi (\r
96 IN EFI_GUID *Guid,\r
97 IN UINTN Instance,\r
98 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
99 IN OUT VOID **Ppi\r
100 )\r
101{\r
102 EFI_PEI_SERVICES **PeiServices;\r
103\r
104 PeiServices = GetPeiServicesTablePointer ();\r
105 return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);\r
106}\r
107\r
108/**\r
109 This service enables PEIMs to register a given service to be invoked when another service is\r
110 installed or reinstalled.\r
111\r
112 @param NotifyList A pointer to the list of notification interfaces that the caller\r
113 shall install.\r
114\r
115 @retval EFI_SUCCESS The interface was successfully installed.\r
116 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r
117 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the\r
118 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.\r
119 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r
120\r
121**/\r
122EFI_STATUS\r
123EFIAPI\r
124PeiServicesNotifyPpi (\r
125 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
126 )\r
127{\r
128 EFI_PEI_SERVICES **PeiServices;\r
129\r
130 PeiServices = GetPeiServicesTablePointer ();\r
131 return (*PeiServices)->NotifyPpi (PeiServices, NotifyList);\r
132}\r
133\r
134/**\r
135 This service enables PEIMs to ascertain the present value of the boot mode.\r
136\r
137 @param BootMode A pointer to contain the value of the boot mode.\r
138\r
139 @retval EFI_SUCCESS The boot mode was returned successfully.\r
140 @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
141\r
142**/\r
143EFI_STATUS\r
144EFIAPI\r
145PeiServicesGetBootMode (\r
146 IN OUT EFI_BOOT_MODE *BootMode\r
147 )\r
148{\r
149 EFI_PEI_SERVICES **PeiServices;\r
150\r
151 PeiServices = GetPeiServicesTablePointer ();\r
152 return (*PeiServices)->GetBootMode (PeiServices, BootMode);\r
153}\r
154\r
155/**\r
156 This service enables PEIMs to update the boot mode variable.\r
157\r
158 @param BootMode The value of the boot mode to set.\r
159\r
160 @retval EFI_SUCCESS The value was successfully updated\r
161\r
162**/\r
163EFI_STATUS\r
164EFIAPI\r
165PeiServicesSetBootMode (\r
166 IN EFI_BOOT_MODE BootMode\r
167 )\r
168{\r
169 EFI_PEI_SERVICES **PeiServices;\r
170\r
171 PeiServices = GetPeiServicesTablePointer ();\r
172 return (*PeiServices)->SetBootMode (PeiServices, BootMode);\r
173}\r
174\r
175/**\r
176 This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r
177\r
178 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.\r
179\r
180 @retval EFI_SUCCESS The list was successfully returned.\r
181 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r
182\r
183**/\r
184EFI_STATUS\r
185EFIAPI\r
186PeiServicesGetHobList (\r
187 IN OUT VOID **HobList\r
188 )\r
189{\r
190 EFI_PEI_SERVICES **PeiServices;\r
191\r
192 PeiServices = GetPeiServicesTablePointer ();\r
193 return (*PeiServices)->GetHobList (PeiServices, HobList);\r
194}\r
195\r
196/**\r
197 This service enables PEIMs to create various types of HOBs.\r
198\r
199 @param Type The type of HOB to be installed.\r
200 @param Length The length of the HOB to be added.\r
201 @param Hob The address of a pointer that will contain the HOB header.\r
202\r
203 @retval EFI_SUCCESS The HOB was successfully created.\r
204 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r
205\r
206**/\r
207EFI_STATUS\r
208EFIAPI\r
209PeiServicesCreateHob (\r
210 IN UINT16 Type,\r
211 IN UINT16 Length,\r
212 IN OUT VOID **Hob\r
213 )\r
214{\r
215 EFI_PEI_SERVICES **PeiServices;\r
216\r
217 PeiServices = GetPeiServicesTablePointer ();\r
218 return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob);\r
219}\r
220\r
221/**\r
222 This service enables PEIMs to discover additional firmware volumes.\r
223\r
224 @param Instance This instance of the firmware volume to find. The value 0 is the\r
225 Boot Firmware Volume (BFV).\r
226 @param FwVolHeader Pointer to the firmware volume header of the volume to return.\r
227\r
228 @retval EFI_SUCCESS The volume was found.\r
229 @retval EFI_NOT_FOUND The volume was not found.\r
230 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r
231\r
232**/\r
233EFI_STATUS\r
234EFIAPI\r
235PeiServicesFfsFindNextVolume (\r
236 IN UINTN Instance,\r
237 IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader\r
238 )\r
239{\r
240 EFI_PEI_SERVICES **PeiServices;\r
241\r
242 PeiServices = GetPeiServicesTablePointer ();\r
243 return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, FwVolHeader);\r
244}\r
245\r
246/**\r
247 This service enables PEIMs to discover additional firmware files.\r
248\r
249 @param SearchType A filter to find files only of this type.\r
250 @param FwVolHeader Pointer to the firmware volume header of the volume to search.\r
251 This parameter must point to a valid FFS volume.\r
252 @param FileHeader Pointer to the current file from which to begin searching.\r
253\r
254 @retval EFI_SUCCESS The file was found.\r
255 @retval EFI_NOT_FOUND The file was not found.\r
256 @retval EFI_NOT_FOUND The header checksum was not zero.\r
257\r
258**/\r
259EFI_STATUS\r
260EFIAPI\r
261PeiServicesFfsFindNextFile (\r
262 IN EFI_FV_FILETYPE SearchType,\r
263 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,\r
264 IN OUT EFI_FFS_FILE_HEADER **FileHeader\r
265 )\r
266{\r
267 EFI_PEI_SERVICES **PeiServices;\r
268\r
269 PeiServices = GetPeiServicesTablePointer ();\r
270 return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FwVolHeader, FileHeader);\r
271}\r
272\r
273/**\r
274 This service enables PEIMs to discover sections of a given type within a valid FFS file.\r
275\r
276 @param SearchType The value of the section type to find.\r
277 @param FfsFileHeader A pointer to the file header that contains the set of sections to\r
278 be searched.\r
279 @param SectionData A pointer to the discovered section, if successful.\r
280\r
281 @retval EFI_SUCCESS The section was found.\r
282 @retval EFI_NOT_FOUND The section was not found.\r
283\r
284**/\r
285EFI_STATUS\r
286EFIAPI\r
287PeiServicesFfsFindSectionData (\r
288 IN EFI_SECTION_TYPE SectionType,\r
289 IN EFI_FFS_FILE_HEADER *FfsFileHeader,\r
290 IN OUT VOID **SectionData\r
291 )\r
292{\r
293 EFI_PEI_SERVICES **PeiServices;\r
294\r
295 PeiServices = GetPeiServicesTablePointer ();\r
296 return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FfsFileHeader, SectionData);\r
297}\r
298\r
299/**\r
300 This service enables PEIMs to register the permanent memory configuration\r
301 that has been initialized with the PEI Foundation.\r
302\r
303 @param MemoryBegin The value of a region of installed memory.\r
304 @param MemoryLength The corresponding length of a region of installed memory.\r
305\r
306 @retval EFI_SUCCESS The region was successfully installed in a HOB.\r
307 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r
308 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r
309\r
310**/\r
311EFI_STATUS\r
312EFIAPI\r
313PeiServicesInstallPeiMemory (\r
314 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
315 IN UINT64 MemoryLength\r
316 )\r
317{\r
318 EFI_PEI_SERVICES **PeiServices;\r
319\r
320 PeiServices = GetPeiServicesTablePointer ();\r
321 return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);\r
322}\r
323\r
324/**\r
325 This service enables PEIMs to allocate memory after the permanent memory has been installed by a\r
326 PEIM.\r
327\r
328 @param MemoryType Type of memory to allocate.\r
329 @param Pages Number of pages to allocate.\r
330 @param Memory Pointer of memory allocated.\r
331\r
332 @retval EFI_SUCCESS The memory range was successfully allocated.\r
333 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.\r
334 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.\r
335 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r
336\r
337**/\r
338EFI_STATUS\r
339EFIAPI\r
340PeiServicesAllocatePages (\r
341 IN EFI_MEMORY_TYPE MemoryType,\r
342 IN UINTN Pages,\r
343 IN OUT EFI_PHYSICAL_ADDRESS *Memory\r
344 )\r
345{\r
346 EFI_PEI_SERVICES **PeiServices;\r
347\r
348 PeiServices = GetPeiServicesTablePointer ();\r
349 return (*PeiServices)->AllocatePages (PeiServices, MemoryType, Pages, Memory);\r
350}\r
351\r
352/**\r
353 This service allocates memory from the Hand-Off Block (HOB) heap.\r
354\r
355 @param Size The number of bytes to allocate from the pool.\r
356 @param Buffer If the call succeeds, a pointer to a pointer to the allocate\r
357 buffer; undefined otherwise.\r
358\r
359 @retval EFI_SUCCESS The allocation was successful\r
360 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.\r
361\r
362**/\r
363EFI_STATUS\r
364EFIAPI\r
365PeiServicesAllocatePool (\r
366 IN UINTN Size,\r
367 OUT VOID **Buffer\r
368 )\r
369{\r
370 EFI_PEI_SERVICES **PeiServices;\r
371\r
372 PeiServices = GetPeiServicesTablePointer ();\r
373 return (*PeiServices)->AllocatePool (PeiServices, Size, Buffer);\r
374}\r
375\r
376/**\r
377 This service resets the entire platform, including all processors and devices, and reboots the\r
378 system.\r
379\r
380 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r
381\r
382**/\r
383EFI_STATUS\r
384EFIAPI\r
385PeiServicesResetSystem (\r
386 VOID\r
387 )\r
388{\r
389 EFI_PEI_SERVICES **PeiServices;\r
390\r
391 PeiServices = GetPeiServicesTablePointer ();\r
392 return (*PeiServices)->ResetSystem (PeiServices);\r
393}\r