]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Implementation for PEI Services Library.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #include <PiPei.h>\r | |
10 | \r | |
11 | #include <Ppi/FirmwareVolumeInfo.h>\r | |
12 | #include <Ppi/FirmwareVolumeInfo2.h>\r | |
13 | #include <Guid/FirmwareFileSystem2.h>\r | |
14 | \r | |
15 | #include <Library/PeiServicesLib.h>\r | |
16 | #include <Library/PeiServicesTablePointerLib.h>\r | |
17 | #include <Library/DebugLib.h>\r | |
18 | #include <Library/MemoryAllocationLib.h>\r | |
19 | #include <Library/BaseMemoryLib.h>\r | |
20 | \r | |
21 | /**\r | |
22 | This service enables a given PEIM to register an interface into the PEI Foundation.\r | |
23 | \r | |
24 | @param PpiList A pointer to the list of interfaces that the caller shall install.\r | |
25 | \r | |
26 | @retval EFI_SUCCESS The interface was successfully installed.\r | |
27 | @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r | |
28 | @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r | |
29 | EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r | |
30 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r | |
31 | \r | |
32 | **/\r | |
33 | EFI_STATUS\r | |
34 | EFIAPI\r | |
35 | PeiServicesInstallPpi (\r | |
36 | IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r | |
37 | )\r | |
38 | {\r | |
39 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
40 | \r | |
41 | PeiServices = GetPeiServicesTablePointer ();\r | |
42 | return (*PeiServices)->InstallPpi (PeiServices, PpiList);\r | |
43 | }\r | |
44 | \r | |
45 | /**\r | |
46 | This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r | |
47 | \r | |
48 | @param OldPpi The pointer to the old PEI PPI Descriptors.\r | |
49 | @param NewPpi The pointer to the new PEI PPI Descriptors.\r | |
50 | \r | |
51 | @retval EFI_SUCCESS The interface was successfully installed.\r | |
52 | @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r | |
53 | @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r | |
54 | EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r | |
55 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r | |
56 | @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been\r | |
57 | installed.\r | |
58 | \r | |
59 | **/\r | |
60 | EFI_STATUS\r | |
61 | EFIAPI\r | |
62 | PeiServicesReInstallPpi (\r | |
63 | IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r | |
64 | IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r | |
65 | )\r | |
66 | {\r | |
67 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
68 | \r | |
69 | PeiServices = GetPeiServicesTablePointer ();\r | |
70 | return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi);\r | |
71 | }\r | |
72 | \r | |
73 | /**\r | |
74 | This service enables PEIMs to discover a given instance of an interface.\r | |
75 | \r | |
76 | @param Guid A pointer to the GUID whose corresponding interface needs to be\r | |
77 | found.\r | |
78 | @param Instance The N-th instance of the interface that is required.\r | |
79 | @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r | |
80 | @param Ppi A pointer to the instance of the interface.\r | |
81 | \r | |
82 | @retval EFI_SUCCESS The interface was successfully returned.\r | |
83 | @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.\r | |
84 | \r | |
85 | **/\r | |
86 | EFI_STATUS\r | |
87 | EFIAPI\r | |
88 | PeiServicesLocatePpi (\r | |
89 | IN CONST EFI_GUID *Guid,\r | |
90 | IN UINTN Instance,\r | |
91 | IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor OPTIONAL,\r | |
92 | IN OUT VOID **Ppi\r | |
93 | )\r | |
94 | {\r | |
95 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
96 | \r | |
97 | PeiServices = GetPeiServicesTablePointer ();\r | |
98 | return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);\r | |
99 | }\r | |
100 | \r | |
101 | /**\r | |
102 | This service enables PEIMs to register a given service to be invoked when another service is\r | |
103 | installed or reinstalled.\r | |
104 | \r | |
105 | @param NotifyList A pointer to the list of notification interfaces\r | |
106 | that the caller shall install.\r | |
107 | \r | |
108 | @retval EFI_SUCCESS The interface was successfully installed.\r | |
109 | @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r | |
110 | @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do\r | |
111 | not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES\r | |
112 | bit set in the Flags field.\r | |
113 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r | |
114 | \r | |
115 | **/\r | |
116 | EFI_STATUS\r | |
117 | EFIAPI\r | |
118 | PeiServicesNotifyPpi (\r | |
119 | IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r | |
120 | )\r | |
121 | {\r | |
122 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
123 | \r | |
124 | PeiServices = GetPeiServicesTablePointer ();\r | |
125 | return (*PeiServices)->NotifyPpi (PeiServices, NotifyList);\r | |
126 | }\r | |
127 | \r | |
128 | /**\r | |
129 | This service enables PEIMs to ascertain the present value of the boot mode.\r | |
130 | \r | |
131 | @param BootMode A pointer to contain the value of the boot mode.\r | |
132 | \r | |
133 | @retval EFI_SUCCESS The boot mode was returned successfully.\r | |
134 | @retval EFI_INVALID_PARAMETER BootMode is NULL.\r | |
135 | \r | |
136 | **/\r | |
137 | EFI_STATUS\r | |
138 | EFIAPI\r | |
139 | PeiServicesGetBootMode (\r | |
140 | OUT EFI_BOOT_MODE *BootMode\r | |
141 | )\r | |
142 | {\r | |
143 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
144 | \r | |
145 | PeiServices = GetPeiServicesTablePointer ();\r | |
146 | return (*PeiServices)->GetBootMode (PeiServices, BootMode);\r | |
147 | }\r | |
148 | \r | |
149 | /**\r | |
150 | This service enables PEIMs to update the boot mode variable.\r | |
151 | \r | |
152 | @param BootMode The value of the boot mode to set.\r | |
153 | \r | |
154 | @retval EFI_SUCCESS The value was successfully updated\r | |
155 | \r | |
156 | **/\r | |
157 | EFI_STATUS\r | |
158 | EFIAPI\r | |
159 | PeiServicesSetBootMode (\r | |
160 | IN EFI_BOOT_MODE BootMode\r | |
161 | )\r | |
162 | {\r | |
163 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
164 | \r | |
165 | PeiServices = GetPeiServicesTablePointer ();\r | |
166 | return (*PeiServices)->SetBootMode (PeiServices, BootMode);\r | |
167 | }\r | |
168 | \r | |
169 | /**\r | |
170 | This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r | |
171 | \r | |
172 | @param HobList A pointer to the list of HOBs that the PEI Foundation\r | |
173 | will initialize.\r | |
174 | \r | |
175 | @retval EFI_SUCCESS The list was successfully returned.\r | |
176 | @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r | |
177 | \r | |
178 | **/\r | |
179 | EFI_STATUS\r | |
180 | EFIAPI\r | |
181 | PeiServicesGetHobList (\r | |
182 | OUT VOID **HobList\r | |
183 | )\r | |
184 | {\r | |
185 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
186 | \r | |
187 | PeiServices = GetPeiServicesTablePointer ();\r | |
188 | return (*PeiServices)->GetHobList (PeiServices, HobList);\r | |
189 | }\r | |
190 | \r | |
191 | /**\r | |
192 | This service enables PEIMs to create various types of HOBs.\r | |
193 | \r | |
194 | @param Type The type of HOB to be installed.\r | |
195 | @param Length The length of the HOB to be added.\r | |
196 | @param Hob The address of a pointer that will contain the\r | |
197 | HOB header.\r | |
198 | \r | |
199 | @retval EFI_SUCCESS The HOB was successfully created.\r | |
200 | @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r | |
201 | \r | |
202 | **/\r | |
203 | EFI_STATUS\r | |
204 | EFIAPI\r | |
205 | PeiServicesCreateHob (\r | |
206 | IN UINT16 Type,\r | |
207 | IN UINT16 Length,\r | |
208 | OUT VOID **Hob\r | |
209 | )\r | |
210 | {\r | |
211 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
212 | \r | |
213 | PeiServices = GetPeiServicesTablePointer ();\r | |
214 | return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob);\r | |
215 | }\r | |
216 | \r | |
217 | /**\r | |
218 | This service enables PEIMs to discover additional firmware volumes.\r | |
219 | \r | |
220 | @param Instance This instance of the firmware volume to find. The\r | |
221 | value 0 is the Boot Firmware Volume (BFV).\r | |
222 | @param VolumeHandle Handle of the firmware volume header of the volume\r | |
223 | to return.\r | |
224 | \r | |
225 | @retval EFI_SUCCESS The volume was found.\r | |
226 | @retval EFI_NOT_FOUND The volume was not found.\r | |
227 | @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r | |
228 | \r | |
229 | **/\r | |
230 | EFI_STATUS\r | |
231 | EFIAPI\r | |
232 | PeiServicesFfsFindNextVolume (\r | |
233 | IN UINTN Instance,\r | |
234 | IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r | |
235 | )\r | |
236 | {\r | |
237 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
238 | \r | |
239 | PeiServices = GetPeiServicesTablePointer ();\r | |
240 | return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, VolumeHandle);\r | |
241 | }\r | |
242 | \r | |
243 | /**\r | |
244 | This service enables PEIMs to discover additional firmware files.\r | |
245 | \r | |
246 | @param SearchType A filter to find files only of this type.\r | |
247 | @param VolumeHandle The pointer to the firmware volume header of the\r | |
248 | volume to search. This parameter must point to a\r | |
249 | valid FFS volume.\r | |
250 | @param FileHandle Handle of the current file from which to begin searching.\r | |
251 | \r | |
252 | @retval EFI_SUCCESS The file was found.\r | |
253 | @retval EFI_NOT_FOUND The file was not found.\r | |
254 | @retval EFI_NOT_FOUND The header checksum was not zero.\r | |
255 | \r | |
256 | **/\r | |
257 | EFI_STATUS\r | |
258 | EFIAPI\r | |
259 | PeiServicesFfsFindNextFile (\r | |
260 | IN EFI_FV_FILETYPE SearchType,\r | |
261 | IN EFI_PEI_FV_HANDLE VolumeHandle,\r | |
262 | IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r | |
263 | )\r | |
264 | {\r | |
265 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
266 | \r | |
267 | PeiServices = GetPeiServicesTablePointer ();\r | |
268 | return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, VolumeHandle, FileHandle);\r | |
269 | }\r | |
270 | \r | |
271 | /**\r | |
272 | This service enables PEIMs to discover sections of a given type within a valid FFS file.\r | |
273 | \r | |
274 | @param SectionType The value of the section type to find.\r | |
275 | @param FileHandle A pointer to the file header that contains the set\r | |
276 | of sections to be searched.\r | |
277 | @param SectionData A pointer to the discovered section, if successful.\r | |
278 | \r | |
279 | @retval EFI_SUCCESS The section was found.\r | |
280 | @retval EFI_NOT_FOUND The section was not found.\r | |
281 | \r | |
282 | **/\r | |
283 | EFI_STATUS\r | |
284 | EFIAPI\r | |
285 | PeiServicesFfsFindSectionData (\r | |
286 | IN EFI_SECTION_TYPE SectionType,\r | |
287 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
288 | OUT VOID **SectionData\r | |
289 | )\r | |
290 | {\r | |
291 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
292 | \r | |
293 | PeiServices = GetPeiServicesTablePointer ();\r | |
294 | return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FileHandle, SectionData);\r | |
295 | }\r | |
296 | \r | |
297 | /**\r | |
298 | This service enables PEIMs to discover sections of a given instance and type within a valid FFS file.\r | |
299 | \r | |
300 | @param SectionType The value of the section type to find.\r | |
301 | @param SectionInstance Section instance to find.\r | |
302 | @param FileHandle A pointer to the file header that contains the set\r | |
303 | of sections to be searched.\r | |
304 | @param SectionData A pointer to the discovered section, if successful.\r | |
305 | @param AuthenticationStatus A pointer to the authentication status for this section.\r | |
306 | \r | |
307 | @retval EFI_SUCCESS The section was found.\r | |
308 | @retval EFI_NOT_FOUND The section was not found.\r | |
309 | \r | |
310 | **/\r | |
311 | EFI_STATUS\r | |
312 | EFIAPI\r | |
313 | PeiServicesFfsFindSectionData3 (\r | |
314 | IN EFI_SECTION_TYPE SectionType,\r | |
315 | IN UINTN SectionInstance,\r | |
316 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
317 | OUT VOID **SectionData,\r | |
318 | OUT UINT32 *AuthenticationStatus\r | |
319 | )\r | |
320 | {\r | |
321 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
322 | \r | |
323 | PeiServices = GetPeiServicesTablePointer ();\r | |
324 | return (*PeiServices)->FindSectionData3 (PeiServices, SectionType, SectionInstance, FileHandle, SectionData, AuthenticationStatus);\r | |
325 | }\r | |
326 | \r | |
327 | /**\r | |
328 | This service enables PEIMs to register the permanent memory configuration\r | |
329 | that has been initialized with the PEI Foundation.\r | |
330 | \r | |
331 | @param MemoryBegin The value of a region of installed memory.\r | |
332 | @param MemoryLength The corresponding length of a region of installed memory.\r | |
333 | \r | |
334 | @retval EFI_SUCCESS The region was successfully installed in a HOB.\r | |
335 | @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r | |
336 | @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r | |
337 | \r | |
338 | **/\r | |
339 | EFI_STATUS\r | |
340 | EFIAPI\r | |
341 | PeiServicesInstallPeiMemory (\r | |
342 | IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r | |
343 | IN UINT64 MemoryLength\r | |
344 | )\r | |
345 | {\r | |
346 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
347 | \r | |
348 | PeiServices = GetPeiServicesTablePointer ();\r | |
349 | return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);\r | |
350 | }\r | |
351 | \r | |
352 | /**\r | |
353 | This service enables PEIMs to allocate memory.\r | |
354 | \r | |
355 | @param MemoryType Type of memory to allocate.\r | |
356 | @param Pages The number of pages to allocate.\r | |
357 | @param Memory Pointer of memory allocated.\r | |
358 | \r | |
359 | @retval EFI_SUCCESS The memory range was successfully allocated.\r | |
360 | @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,\r | |
361 | EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,\r | |
362 | EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.\r | |
363 | @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r | |
364 | \r | |
365 | **/\r | |
366 | EFI_STATUS\r | |
367 | EFIAPI\r | |
368 | PeiServicesAllocatePages (\r | |
369 | IN EFI_MEMORY_TYPE MemoryType,\r | |
370 | IN UINTN Pages,\r | |
371 | OUT EFI_PHYSICAL_ADDRESS *Memory\r | |
372 | )\r | |
373 | {\r | |
374 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
375 | \r | |
376 | PeiServices = GetPeiServicesTablePointer ();\r | |
377 | return (*PeiServices)->AllocatePages (PeiServices, MemoryType, Pages, Memory);\r | |
378 | }\r | |
379 | \r | |
380 | /**\r | |
381 | This service enables PEIMs to free memory.\r | |
382 | \r | |
383 | @param Memory Memory to be freed.\r | |
384 | @param Pages The number of pages to free.\r | |
385 | \r | |
386 | @retval EFI_SUCCESS The requested pages were freed.\r | |
387 | @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.\r | |
388 | @retval EFI_NOT_FOUND The requested memory pages were not allocated with\r | |
389 | AllocatePages().\r | |
390 | \r | |
391 | **/\r | |
392 | EFI_STATUS\r | |
393 | EFIAPI\r | |
394 | PeiServicesFreePages (\r | |
395 | IN EFI_PHYSICAL_ADDRESS Memory,\r | |
396 | IN UINTN Pages\r | |
397 | )\r | |
398 | {\r | |
399 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
400 | \r | |
401 | PeiServices = GetPeiServicesTablePointer ();\r | |
402 | return (*PeiServices)->FreePages (PeiServices, Memory, Pages);\r | |
403 | }\r | |
404 | \r | |
405 | /**\r | |
406 | This service allocates memory from the Hand-Off Block (HOB) heap.\r | |
407 | \r | |
408 | @param Size The number of bytes to allocate from the pool.\r | |
409 | @param Buffer If the call succeeds, a pointer to a pointer to\r | |
410 | the allocate buffer; otherwise, undefined.\r | |
411 | \r | |
412 | @retval EFI_SUCCESS The allocation was successful\r | |
413 | @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.\r | |
414 | \r | |
415 | **/\r | |
416 | EFI_STATUS\r | |
417 | EFIAPI\r | |
418 | PeiServicesAllocatePool (\r | |
419 | IN UINTN Size,\r | |
420 | OUT VOID **Buffer\r | |
421 | )\r | |
422 | {\r | |
423 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
424 | \r | |
425 | PeiServices = GetPeiServicesTablePointer ();\r | |
426 | return (*PeiServices)->AllocatePool (PeiServices, Size, Buffer);\r | |
427 | }\r | |
428 | \r | |
429 | /**\r | |
430 | Resets the entire platform.\r | |
431 | \r | |
432 | @retval EFI_SUCCESS The function completed successfully.\r | |
433 | @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r | |
434 | \r | |
435 | **/\r | |
436 | EFI_STATUS\r | |
437 | EFIAPI\r | |
438 | PeiServicesResetSystem (\r | |
439 | VOID\r | |
440 | )\r | |
441 | {\r | |
442 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
443 | \r | |
444 | PeiServices = GetPeiServicesTablePointer ();\r | |
445 | return (*PeiServices)->ResetSystem (PeiServices);\r | |
446 | }\r | |
447 | \r | |
448 | /**\r | |
449 | This service is a wrapper for the PEI Service RegisterForShadow(), except the\r | |
450 | pointer to the PEI Services Table has been removed. See the Platform\r | |
451 | Initialization Pre-EFI Initialization Core Interface Specification for details.\r | |
452 | \r | |
453 | @param FileHandle PEIM's file handle. Must be the currently\r | |
454 | executing PEIM.\r | |
455 | \r | |
456 | @retval EFI_SUCCESS The PEIM was successfully registered for\r | |
457 | shadowing.\r | |
458 | \r | |
459 | @retval EFI_ALREADY_STARTED The PEIM was previously\r | |
460 | registered for shadowing.\r | |
461 | \r | |
462 | @retval EFI_NOT_FOUND The FileHandle does not refer to a\r | |
463 | valid file handle.\r | |
464 | **/\r | |
465 | EFI_STATUS\r | |
466 | EFIAPI\r | |
467 | PeiServicesRegisterForShadow (\r | |
468 | IN EFI_PEI_FILE_HANDLE FileHandle\r | |
469 | )\r | |
470 | {\r | |
471 | return (*GetPeiServicesTablePointer ())->RegisterForShadow (FileHandle);\r | |
472 | }\r | |
473 | \r | |
474 | /**\r | |
475 | This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services\r | |
476 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r | |
477 | Specification for details.\r | |
478 | \r | |
479 | @param FileHandle The handle of the file.\r | |
480 | \r | |
481 | @param FileInfo Upon exit, points to the file's\r | |
482 | information.\r | |
483 | \r | |
484 | @retval EFI_SUCCESS File information returned.\r | |
485 | \r | |
486 | @retval EFI_INVALID_PARAMETER If FileHandle does not\r | |
487 | represent a valid file.\r | |
488 | \r | |
489 | @retval EFI_INVALID_PARAMETER FileInfo is NULL.\r | |
490 | \r | |
491 | **/\r | |
492 | EFI_STATUS\r | |
493 | EFIAPI\r | |
494 | PeiServicesFfsGetFileInfo (\r | |
495 | IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r | |
496 | OUT EFI_FV_FILE_INFO *FileInfo\r | |
497 | )\r | |
498 | {\r | |
499 | return (*GetPeiServicesTablePointer ())->FfsGetFileInfo (FileHandle, FileInfo);\r | |
500 | }\r | |
501 | \r | |
502 | /**\r | |
503 | This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services\r | |
504 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r | |
505 | Specification for details.\r | |
506 | \r | |
507 | @param FileHandle The handle of the file.\r | |
508 | @param FileInfo Upon exit, points to the file's\r | |
509 | information.\r | |
510 | \r | |
511 | @retval EFI_SUCCESS File information returned.\r | |
512 | @retval EFI_INVALID_PARAMETER If FileHandle does not\r | |
513 | represent a valid file.\r | |
514 | @retval EFI_INVALID_PARAMETER FileInfo is NULL.\r | |
515 | \r | |
516 | **/\r | |
517 | EFI_STATUS\r | |
518 | EFIAPI\r | |
519 | PeiServicesFfsGetFileInfo2 (\r | |
520 | IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r | |
521 | OUT EFI_FV_FILE_INFO2 *FileInfo\r | |
522 | )\r | |
523 | {\r | |
524 | return (*GetPeiServicesTablePointer ())->FfsGetFileInfo2 (FileHandle, FileInfo);\r | |
525 | }\r | |
526 | \r | |
527 | /**\r | |
528 | This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services\r | |
529 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r | |
530 | Specification for details.\r | |
531 | \r | |
532 | @param FileName A pointer to the name of the file to\r | |
533 | find within the firmware volume.\r | |
534 | \r | |
535 | @param VolumeHandle The firmware volume to search FileHandle\r | |
536 | Upon exit, points to the found file's\r | |
537 | handle or NULL if it could not be found.\r | |
538 | @param FileHandle The pointer to found file handle\r | |
539 | \r | |
540 | @retval EFI_SUCCESS File was found.\r | |
541 | \r | |
542 | @retval EFI_NOT_FOUND File was not found.\r | |
543 | \r | |
544 | @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or\r | |
545 | FileName was NULL.\r | |
546 | \r | |
547 | **/\r | |
548 | EFI_STATUS\r | |
549 | EFIAPI\r | |
550 | PeiServicesFfsFindFileByName (\r | |
551 | IN CONST EFI_GUID *FileName,\r | |
552 | IN CONST EFI_PEI_FV_HANDLE VolumeHandle,\r | |
553 | OUT EFI_PEI_FILE_HANDLE *FileHandle\r | |
554 | )\r | |
555 | {\r | |
556 | return (*GetPeiServicesTablePointer ())->FfsFindFileByName (FileName, VolumeHandle, FileHandle);\r | |
557 | }\r | |
558 | \r | |
559 | /**\r | |
560 | This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services\r | |
561 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r | |
562 | Specification for details.\r | |
563 | \r | |
564 | @param VolumeHandle Handle of the volume.\r | |
565 | \r | |
566 | @param VolumeInfo Upon exit, points to the volume's\r | |
567 | information.\r | |
568 | \r | |
569 | @retval EFI_SUCCESS File information returned.\r | |
570 | \r | |
571 | @retval EFI_INVALID_PARAMETER If FileHandle does not\r | |
572 | represent a valid file.\r | |
573 | \r | |
574 | @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r | |
575 | \r | |
576 | **/\r | |
577 | EFI_STATUS\r | |
578 | EFIAPI\r | |
579 | PeiServicesFfsGetVolumeInfo (\r | |
580 | IN EFI_PEI_FV_HANDLE VolumeHandle,\r | |
581 | OUT EFI_FV_INFO *VolumeInfo\r | |
582 | )\r | |
583 | {\r | |
584 | return (*GetPeiServicesTablePointer ())->FfsGetVolumeInfo (VolumeHandle, VolumeInfo);\r | |
585 | }\r | |
586 | \r | |
587 | /**\r | |
588 | Install a EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance so the PEI Core will be notified about a new firmware volume.\r | |
589 | \r | |
590 | This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI using\r | |
591 | the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance.\r | |
592 | If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI, then ASSERT().\r | |
593 | If the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI can not be installed, then ASSERT().\r | |
594 | If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r | |
595 | \r | |
596 | @param InstallFvInfoPpi Install FvInfo Ppi if it is TRUE. Otherwise, install FvInfo2 Ppi.\r | |
597 | @param FvFormat Unique identifier of the format of the memory-mapped\r | |
598 | firmware volume. This parameter is optional and\r | |
599 | may be NULL. If NULL is specified, the\r | |
600 | EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r | |
601 | @param FvInfo Points to a buffer which allows the\r | |
602 | EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r | |
603 | The format of this buffer is specific to the FvFormat.\r | |
604 | For memory-mapped firmware volumes, this typically\r | |
605 | points to the first byte of the firmware volume.\r | |
606 | @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r | |
607 | firmware volumes, this is typically the size of\r | |
608 | the firmware volume.\r | |
609 | @param ParentFvName If the new firmware volume originated from a file\r | |
610 | in a different firmware volume, then this parameter\r | |
611 | specifies the GUID name of the originating firmware\r | |
612 | volume. Otherwise, this parameter must be NULL.\r | |
613 | @param ParentFileName If the new firmware volume originated from a file\r | |
614 | in a different firmware volume, then this parameter\r | |
615 | specifies the GUID file name of the originating\r | |
616 | firmware file. Otherwise, this parameter must be NULL.\r | |
617 | @param AuthenticationStatus Authentication Status, it will be ignored if InstallFvInfoPpi is TRUE.\r | |
618 | **/\r | |
619 | VOID\r | |
620 | EFIAPI\r | |
621 | InternalPeiServicesInstallFvInfoPpi (\r | |
622 | IN BOOLEAN InstallFvInfoPpi,\r | |
623 | IN CONST EFI_GUID *FvFormat OPTIONAL,\r | |
624 | IN CONST VOID *FvInfo,\r | |
625 | IN UINT32 FvInfoSize,\r | |
626 | IN CONST EFI_GUID *ParentFvName OPTIONAL,\r | |
627 | IN CONST EFI_GUID *ParentFileName OPTIONAL,\r | |
628 | IN UINT32 AuthenticationStatus\r | |
629 | )\r | |
630 | {\r | |
631 | EFI_STATUS Status;\r | |
632 | EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;\r | |
633 | EFI_PEI_PPI_DESCRIPTOR *FvInfoPpiDescriptor;\r | |
634 | EFI_GUID *ParentFvNameValue;\r | |
635 | EFI_GUID *ParentFileNameValue;\r | |
636 | EFI_GUID *PpiGuid;\r | |
637 | \r | |
638 | ParentFvNameValue = NULL;\r | |
639 | ParentFileNameValue = NULL;\r | |
640 | if (InstallFvInfoPpi) {\r | |
641 | //\r | |
642 | // To install FvInfo Ppi.\r | |
643 | //\r | |
644 | FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));\r | |
645 | ASSERT (FvInfoPpi != NULL);\r | |
646 | PpiGuid = &gEfiPeiFirmwareVolumeInfoPpiGuid;\r | |
647 | } else {\r | |
648 | //\r | |
649 | // To install FvInfo2 Ppi.\r | |
650 | //\r | |
651 | FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI));\r | |
652 | ASSERT (FvInfoPpi != NULL);\r | |
653 | ((EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *)FvInfoPpi)->AuthenticationStatus = AuthenticationStatus;\r | |
654 | PpiGuid = &gEfiPeiFirmwareVolumeInfo2PpiGuid;\r | |
655 | }\r | |
656 | \r | |
657 | if (FvFormat != NULL) {\r | |
658 | CopyGuid (&FvInfoPpi->FvFormat, FvFormat);\r | |
659 | } else {\r | |
660 | CopyGuid (&FvInfoPpi->FvFormat, &gEfiFirmwareFileSystem2Guid);\r | |
661 | //\r | |
662 | // Since the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed if NULL is specified for FvFormat,\r | |
663 | // check the FileSystemGuid pointed by FvInfo against EFI_FIRMWARE_FILE_SYSTEM2_GUID to make sure\r | |
664 | // FvInfo has the firmware file system 2 format.\r | |
665 | // If the ASSERT really appears, FvFormat needs to be specified correctly, for example,\r | |
666 | // EFI_FIRMWARE_FILE_SYSTEM3_GUID can be used for firmware file system 3 format, or\r | |
667 | // ((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid can be just used for both\r | |
668 | // firmware file system 2 and 3 format.\r | |
669 | //\r | |
670 | ASSERT (CompareGuid (&(((EFI_FIRMWARE_VOLUME_HEADER *)FvInfo)->FileSystemGuid), &gEfiFirmwareFileSystem2Guid));\r | |
671 | }\r | |
672 | \r | |
673 | FvInfoPpi->FvInfo = (VOID *)FvInfo;\r | |
674 | FvInfoPpi->FvInfoSize = FvInfoSize;\r | |
675 | if (ParentFvName != NULL) {\r | |
676 | ParentFvNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFvName);\r | |
677 | ASSERT (ParentFvNameValue != NULL);\r | |
678 | FvInfoPpi->ParentFvName = ParentFvNameValue;\r | |
679 | }\r | |
680 | \r | |
681 | if (ParentFileName != NULL) {\r | |
682 | ParentFileNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFileName);\r | |
683 | ASSERT (ParentFileNameValue != NULL);\r | |
684 | FvInfoPpi->ParentFileName = ParentFileNameValue;\r | |
685 | }\r | |
686 | \r | |
687 | FvInfoPpiDescriptor = AllocatePool (sizeof (EFI_PEI_PPI_DESCRIPTOR));\r | |
688 | ASSERT (FvInfoPpiDescriptor != NULL);\r | |
689 | \r | |
690 | FvInfoPpiDescriptor->Guid = PpiGuid;\r | |
691 | FvInfoPpiDescriptor->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r | |
692 | FvInfoPpiDescriptor->Ppi = (VOID *)FvInfoPpi;\r | |
693 | Status = PeiServicesInstallPpi (FvInfoPpiDescriptor);\r | |
694 | ASSERT_EFI_ERROR (Status);\r | |
695 | }\r | |
696 | \r | |
697 | /**\r | |
698 | Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.\r | |
699 | \r | |
700 | This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using\r | |
701 | the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.\r | |
702 | If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().\r | |
703 | If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().\r | |
704 | If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r | |
705 | \r | |
706 | @param FvFormat Unique identifier of the format of the memory-mapped\r | |
707 | firmware volume. This parameter is optional and\r | |
708 | may be NULL. If NULL is specified, the\r | |
709 | EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r | |
710 | @param FvInfo Points to a buffer which allows the\r | |
711 | EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r | |
712 | The format of this buffer is specific to the FvFormat.\r | |
713 | For memory-mapped firmware volumes, this typically\r | |
714 | points to the first byte of the firmware volume.\r | |
715 | @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r | |
716 | firmware volumes, this is typically the size of\r | |
717 | the firmware volume.\r | |
718 | @param ParentFvName If the new firmware volume originated from a file\r | |
719 | in a different firmware volume, then this parameter\r | |
720 | specifies the GUID name of the originating firmware\r | |
721 | volume. Otherwise, this parameter must be NULL.\r | |
722 | @param ParentFileName If the new firmware volume originated from a file\r | |
723 | in a different firmware volume, then this parameter\r | |
724 | specifies the GUID file name of the originating\r | |
725 | firmware file. Otherwise, this parameter must be NULL.\r | |
726 | **/\r | |
727 | VOID\r | |
728 | EFIAPI\r | |
729 | PeiServicesInstallFvInfoPpi (\r | |
730 | IN CONST EFI_GUID *FvFormat OPTIONAL,\r | |
731 | IN CONST VOID *FvInfo,\r | |
732 | IN UINT32 FvInfoSize,\r | |
733 | IN CONST EFI_GUID *ParentFvName OPTIONAL,\r | |
734 | IN CONST EFI_GUID *ParentFileName OPTIONAL\r | |
735 | )\r | |
736 | {\r | |
737 | InternalPeiServicesInstallFvInfoPpi (TRUE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, 0);\r | |
738 | }\r | |
739 | \r | |
740 | /**\r | |
741 | Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.\r | |
742 | \r | |
743 | This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using\r | |
744 | the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.\r | |
745 | If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().\r | |
746 | If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().\r | |
747 | If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r | |
748 | \r | |
749 | @param FvFormat Unique identifier of the format of the memory-mapped\r | |
750 | firmware volume. This parameter is optional and\r | |
751 | may be NULL. If NULL is specified, the\r | |
752 | EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r | |
753 | @param FvInfo Points to a buffer which allows the\r | |
754 | EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r | |
755 | The format of this buffer is specific to the FvFormat.\r | |
756 | For memory-mapped firmware volumes, this typically\r | |
757 | points to the first byte of the firmware volume.\r | |
758 | @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r | |
759 | firmware volumes, this is typically the size of\r | |
760 | the firmware volume.\r | |
761 | @param ParentFvName If the new firmware volume originated from a file\r | |
762 | in a different firmware volume, then this parameter\r | |
763 | specifies the GUID name of the originating firmware\r | |
764 | volume. Otherwise, this parameter must be NULL.\r | |
765 | @param ParentFileName If the new firmware volume originated from a file\r | |
766 | in a different firmware volume, then this parameter\r | |
767 | specifies the GUID file name of the originating\r | |
768 | firmware file. Otherwise, this parameter must be NULL.\r | |
769 | @param AuthenticationStatus Authentication Status\r | |
770 | **/\r | |
771 | VOID\r | |
772 | EFIAPI\r | |
773 | PeiServicesInstallFvInfo2Ppi (\r | |
774 | IN CONST EFI_GUID *FvFormat OPTIONAL,\r | |
775 | IN CONST VOID *FvInfo,\r | |
776 | IN UINT32 FvInfoSize,\r | |
777 | IN CONST EFI_GUID *ParentFvName OPTIONAL,\r | |
778 | IN CONST EFI_GUID *ParentFileName OPTIONAL,\r | |
779 | IN UINT32 AuthenticationStatus\r | |
780 | )\r | |
781 | {\r | |
782 | InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, AuthenticationStatus);\r | |
783 | }\r | |
784 | \r | |
785 | /**\r | |
786 | Resets the entire platform.\r | |
787 | \r | |
788 | @param[in] ResetType The type of reset to perform.\r | |
789 | @param[in] ResetStatus The status code for the reset.\r | |
790 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
791 | @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r | |
792 | the data buffer starts with a Null-terminated string, optionally\r | |
793 | followed by additional binary data. The string is a description\r | |
794 | that the caller may use to further indicate the reason for the\r | |
795 | system reset.\r | |
796 | \r | |
797 | **/\r | |
798 | VOID\r | |
799 | EFIAPI\r | |
800 | PeiServicesResetSystem2 (\r | |
801 | IN EFI_RESET_TYPE ResetType,\r | |
802 | IN EFI_STATUS ResetStatus,\r | |
803 | IN UINTN DataSize,\r | |
804 | IN VOID *ResetData OPTIONAL\r | |
805 | )\r | |
806 | {\r | |
807 | (*GetPeiServicesTablePointer ())->ResetSystem2 (ResetType, ResetStatus, DataSize, ResetData);\r | |
808 | }\r |