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