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