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