]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiServicesLib/PeiServicesLib.c
MdeModule PeiCore: Support pre memory page allocation
[mirror_edk2.git] / MdePkg / Library / PeiServicesLib / PeiServicesLib.c
CommitLineData
738ec565 1/** @file\r
2 Implementation for PEI Services Library.\r
3\r
f66ad5d2 4 Copyright (c) 2006 - 2016, 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
98 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
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
58380e9c 112 @param NotifyList A pointer to the list of notification interfaces \r
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
58380e9c 179 @param HobList A pointer to the list of HOBs that the PEI Foundation \r
180 will initialize.\r
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
58380e9c 203 @param Hob The address of a pointer that will contain the \r
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
58380e9c 227 @param Instance This instance of the firmware volume to find. The \r
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
58380e9c 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
58380e9c 282 @param FileHandle A pointer to the file header that contains the set \r
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
309 @param FileHandle A pointer to the file header that contains the set \r
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
58380e9c 360 This service enables PEIMs to allocate memory after the permanent memory has been\r
361 installed by a PEIM.\r
738ec565 362\r
363 @param MemoryType Type of memory to allocate.\r
2fc59a00 364 @param Pages The number of pages to allocate.\r
738ec565 365 @param Memory Pointer of memory allocated.\r
366\r
367 @retval EFI_SUCCESS The memory range was successfully allocated.\r
368 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.\r
369 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.\r
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
387/**\r
388 This service allocates memory from the Hand-Off Block (HOB) heap.\r
389\r
390 @param Size The number of bytes to allocate from the pool.\r
58380e9c 391 @param Buffer If the call succeeds, a pointer to a pointer to \r
392 the allocate buffer; otherwise, undefined.\r
738ec565 393\r
394 @retval EFI_SUCCESS The allocation was successful\r
395 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.\r
396\r
397**/\r
398EFI_STATUS\r
399EFIAPI\r
400PeiServicesAllocatePool (\r
401 IN UINTN Size,\r
402 OUT VOID **Buffer\r
403 )\r
404{\r
1c280088 405 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 406\r
5240b97c 407 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 408 return (*PeiServices)->AllocatePool (PeiServices, Size, Buffer);\r
409}\r
410\r
411/**\r
67c89a21 412 Resets the entire platform.\r
738ec565 413\r
67c89a21 414 @retval EFI_SUCCESS The function completed successfully.\r
738ec565 415 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r
416\r
417**/\r
418EFI_STATUS\r
419EFIAPI\r
420PeiServicesResetSystem (\r
421 VOID\r
422 )\r
b0d803fe 423{\r
424 CONST EFI_PEI_SERVICES **PeiServices;\r
425\r
5240b97c 426 PeiServices = GetPeiServicesTablePointer ();\r
b0d803fe 427 return (*PeiServices)->ResetSystem (PeiServices);\r
428}\r
429\r
67c89a21 430/**\r
58380e9c 431 This service is a wrapper for the PEI Service RegisterForShadow(), except the \r
432 pointer to the PEI Services Table has been removed. See the Platform \r
433 Initialization Pre-EFI Initialization Core Interface Specification for details. \r
67c89a21 434\r
58380e9c 435 @param FileHandle PEIM's file handle. Must be the currently\r
436 executing PEIM.\r
67c89a21 437 \r
58380e9c 438 @retval EFI_SUCCESS The PEIM was successfully registered for\r
439 shadowing.\r
67c89a21 440\r
441 @retval EFI_ALREADY_STARTED The PEIM was previously\r
442 registered for shadowing.\r
443\r
58380e9c 444 @retval EFI_NOT_FOUND The FileHandle does not refer to a\r
445 valid file handle.\r
67c89a21 446**/\r
b0d803fe 447EFI_STATUS\r
448EFIAPI\r
449PeiServicesRegisterForShadow (\r
450 IN EFI_PEI_FILE_HANDLE FileHandle\r
451 )\r
738ec565 452{\r
484c7785 453 return (*GetPeiServicesTablePointer())->RegisterForShadow (FileHandle);\r
738ec565 454}\r
b0d803fe 455\r
67c89a21 456/**\r
457 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services \r
458 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface \r
459 Specification for details. \r
460\r
58380e9c 461 @param FileHandle The handle of the file.\r
67c89a21 462\r
58380e9c 463 @param FileInfo Upon exit, points to the file's\r
464 information.\r
67c89a21 465\r
466 @retval EFI_SUCCESS File information returned.\r
467 \r
468 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
469 represent a valid file.\r
470 \r
58380e9c 471 @retval EFI_INVALID_PARAMETER FileInfo is NULL.\r
67c89a21 472 \r
473**/\r
b0d803fe 474EFI_STATUS\r
f38fdc74 475EFIAPI \r
b0d803fe 476PeiServicesFfsGetFileInfo (\r
477 IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r
478 OUT EFI_FV_FILE_INFO *FileInfo\r
479 )\r
480{\r
484c7785 481 return (*GetPeiServicesTablePointer())->FfsGetFileInfo (FileHandle, FileInfo);\r
b0d803fe 482}\r
483\r
c7935105
SZ
484/**\r
485 This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services\r
486 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r
487 Specification for details.\r
488\r
489 @param FileHandle The handle of the file.\r
490 @param FileInfo Upon exit, points to the file's\r
491 information.\r
492\r
493 @retval EFI_SUCCESS File information returned.\r
494 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
495 represent a valid file.\r
496 @retval EFI_INVALID_PARAMETER FileInfo is NULL.\r
497\r
498**/\r
499EFI_STATUS\r
500EFIAPI\r
501PeiServicesFfsGetFileInfo2 (\r
502 IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r
503 OUT EFI_FV_FILE_INFO2 *FileInfo\r
504 )\r
505{\r
506 return (*GetPeiServicesTablePointer())->FfsGetFileInfo2 (FileHandle, FileInfo);\r
507}\r
b0d803fe 508\r
67c89a21 509/**\r
510 This service is a wrapper for the PEI Service FfsFindByName(), 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
58380e9c 514 @param FileName A pointer to the name of the file to\r
515 find within the firmware volume.\r
67c89a21 516\r
58380e9c 517 @param VolumeHandle The firmware volume to search FileHandle\r
518 Upon exit, points to the found file's\r
519 handle or NULL if it could not be found.\r
520 @param FileHandle The pointer to found file handle \r
42eedea9 521\r
67c89a21 522 @retval EFI_SUCCESS File was found.\r
523\r
524 @retval EFI_NOT_FOUND File was not found.\r
525\r
526 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or\r
527 FileName was NULL.\r
528\r
529**/\r
b0d803fe 530EFI_STATUS\r
531EFIAPI\r
532PeiServicesFfsFindFileByName (\r
533 IN CONST EFI_GUID *FileName,\r
534 IN CONST EFI_PEI_FV_HANDLE VolumeHandle,\r
535 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
536 )\r
537{\r
538 return (*GetPeiServicesTablePointer())->FfsFindFileByName (FileName, VolumeHandle, FileHandle);\r
539}\r
540\r
541\r
67c89a21 542/**\r
543 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services \r
544 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface \r
545 Specification for details. \r
546\r
58380e9c 547 @param VolumeHandle Handle of the volume.\r
67c89a21 548\r
58380e9c 549 @param VolumeInfo Upon exit, points to the volume's\r
550 information.\r
67c89a21 551\r
552 @retval EFI_SUCCESS File information returned.\r
553 \r
554 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
555 represent a valid file.\r
556 \r
557 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
558\r
559**/\r
b0d803fe 560EFI_STATUS\r
561EFIAPI\r
562PeiServicesFfsGetVolumeInfo (\r
563 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
564 OUT EFI_FV_INFO *VolumeInfo\r
565 )\r
566{\r
567 return (*GetPeiServicesTablePointer())->FfsGetVolumeInfo (VolumeHandle, VolumeInfo);\r
568}\r
569\r
729675ae 570/**\r
c7935105 571 Install a EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance so the PEI Core will be notified about a new firmware volume.\r
b75a165d 572\r
c7935105
SZ
573 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI using\r
574 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance.\r
575 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI, then ASSERT().\r
576 If the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI can not be installed, then ASSERT().\r
f66ad5d2 577 If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r
c7935105
SZ
578\r
579 @param InstallFvInfoPpi Install FvInfo Ppi if it is TRUE. Otherwise, install FvInfo2 Ppi.\r
580 @param FvFormat Unique identifier of the format of the memory-mapped\r
581 firmware volume. This parameter is optional and\r
582 may be NULL. If NULL is specified, the\r
58380e9c 583 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r
c7935105
SZ
584 @param FvInfo Points to a buffer which allows the\r
585 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r
586 The format of this buffer is specific to the FvFormat.\r
587 For memory-mapped firmware volumes, this typically\r
58380e9c 588 points to the first byte of the firmware volume.\r
c7935105
SZ
589 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r
590 firmware volumes, this is typically the size of\r
58380e9c 591 the firmware volume.\r
c7935105
SZ
592 @param ParentFvName If the new firmware volume originated from a file\r
593 in a different firmware volume, then this parameter\r
58380e9c 594 specifies the GUID name of the originating firmware\r
595 volume. Otherwise, this parameter must be NULL.\r
c7935105
SZ
596 @param ParentFileName If the new firmware volume originated from a file\r
597 in a different firmware volume, then this parameter\r
598 specifies the GUID file name of the originating\r
58380e9c 599 firmware file. Otherwise, this parameter must be NULL.\r
c7935105 600 @param AuthenticationStatus Authentication Status, it will be ignored if InstallFvInfoPpi is TRUE.\r
729675ae 601**/\r
602VOID\r
603EFIAPI\r
c7935105
SZ
604InternalPeiServicesInstallFvInfoPpi (\r
605 IN BOOLEAN InstallFvInfoPpi,\r
729675ae 606 IN CONST EFI_GUID *FvFormat, OPTIONAL\r
607 IN CONST VOID *FvInfo,\r
608 IN UINT32 FvInfoSize,\r
609 IN CONST EFI_GUID *ParentFvName, OPTIONAL\r
c7935105
SZ
610 IN CONST EFI_GUID *ParentFileName, OPTIONAL\r
611 IN UINT32 AuthenticationStatus\r
729675ae 612 )\r
613{\r
614 EFI_STATUS Status; \r
615 EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;\r
616 EFI_PEI_PPI_DESCRIPTOR *FvInfoPpiDescriptor;\r
3831f3e9
LG
617 EFI_GUID *ParentFvNameValue;\r
618 EFI_GUID *ParentFileNameValue;\r
c7935105 619 EFI_GUID *PpiGuid;\r
729675ae 620\r
3831f3e9
LG
621 ParentFvNameValue = NULL;\r
622 ParentFileNameValue = NULL;\r
c7935105
SZ
623 if (InstallFvInfoPpi) {\r
624 //\r
625 // To install FvInfo Ppi.\r
626 //\r
627 FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));\r
ed84519c 628 ASSERT (FvInfoPpi != NULL);\r
c7935105
SZ
629 PpiGuid = &gEfiPeiFirmwareVolumeInfoPpiGuid;\r
630 } else {\r
631 //\r
632 // To install FvInfo2 Ppi.\r
633 //\r
634 FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI));\r
ed84519c 635 ASSERT (FvInfoPpi != NULL);\r
c7935105
SZ
636 ((EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *) FvInfoPpi)->AuthenticationStatus = AuthenticationStatus;\r
637 PpiGuid = &gEfiPeiFirmwareVolumeInfo2PpiGuid;\r
638 }\r
729675ae 639\r
640 if (FvFormat != NULL) {\r
641 CopyGuid (&FvInfoPpi->FvFormat, FvFormat);\r
642 } else {\r
643 CopyGuid (&FvInfoPpi->FvFormat, &gEfiFirmwareFileSystem2Guid);\r
f66ad5d2
SZ
644 //\r
645 // Since the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed if NULL is specified for FvFormat,\r
646 // check the FileSystemGuid pointed by FvInfo against EFI_FIRMWARE_FILE_SYSTEM2_GUID to make sure\r
647 // FvInfo has the firmware file system 2 format.\r
648 // If the ASSERT really appears, FvFormat needs to be specified correctly, for example,\r
649 // EFI_FIRMWARE_FILE_SYSTEM3_GUID can be used for firmware file system 3 format, or\r
650 // ((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid can be just used for both\r
651 // firmware file system 2 and 3 format.\r
652 //\r
653 ASSERT (CompareGuid (&(((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid), &gEfiFirmwareFileSystem2Guid));\r
729675ae 654 }\r
655 FvInfoPpi->FvInfo = (VOID *) FvInfo;\r
656 FvInfoPpi->FvInfoSize = FvInfoSize;\r
3831f3e9
LG
657 if (ParentFvName != NULL) {\r
658 ParentFvNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFvName);\r
60bd4ccd 659 ASSERT (ParentFvNameValue != NULL);\r
3831f3e9
LG
660 FvInfoPpi->ParentFvName = ParentFvNameValue;\r
661 }\r
662 if (ParentFileName != NULL) {\r
663 ParentFileNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFileName);\r
664 ASSERT (ParentFileNameValue != NULL);\r
665 FvInfoPpi->ParentFileName = ParentFileNameValue;\r
666 }\r
729675ae 667\r
c7935105 668 FvInfoPpiDescriptor = AllocatePool (sizeof (EFI_PEI_PPI_DESCRIPTOR));\r
729675ae 669 ASSERT (FvInfoPpiDescriptor != NULL);\r
670\r
c7935105
SZ
671 FvInfoPpiDescriptor->Guid = PpiGuid;\r
672 FvInfoPpiDescriptor->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
729675ae 673 FvInfoPpiDescriptor->Ppi = (VOID *) FvInfoPpi;\r
674 Status = PeiServicesInstallPpi (FvInfoPpiDescriptor);\r
675 ASSERT_EFI_ERROR (Status);\r
676\r
677}\r
678\r
c7935105
SZ
679/**\r
680 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.\r
681\r
682 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using\r
683 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.\r
684 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().\r
685 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().\r
f66ad5d2 686 If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r
c7935105
SZ
687\r
688 @param FvFormat Unique identifier of the format of the memory-mapped\r
689 firmware volume. This parameter is optional and\r
690 may be NULL. If NULL is specified, the\r
691 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r
692 @param FvInfo Points to a buffer which allows the\r
693 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r
694 The format of this buffer is specific to the FvFormat.\r
695 For memory-mapped firmware volumes, this typically\r
696 points to the first byte of the firmware volume.\r
697 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r
698 firmware volumes, this is typically the size of\r
699 the firmware volume.\r
700 @param ParentFvName If the new firmware volume originated from a file\r
701 in a different firmware volume, then this parameter\r
702 specifies the GUID name of the originating firmware\r
703 volume. Otherwise, this parameter must be NULL.\r
704 @param ParentFileName If the new firmware volume originated from a file\r
705 in a different firmware volume, then this parameter\r
706 specifies the GUID file name of the originating\r
707 firmware file. Otherwise, this parameter must be NULL.\r
708**/\r
709VOID\r
710EFIAPI\r
711PeiServicesInstallFvInfoPpi (\r
712 IN CONST EFI_GUID *FvFormat, OPTIONAL\r
713 IN CONST VOID *FvInfo,\r
714 IN UINT32 FvInfoSize,\r
715 IN CONST EFI_GUID *ParentFvName, OPTIONAL\r
716 IN CONST EFI_GUID *ParentFileName OPTIONAL\r
717 )\r
718{\r
719 InternalPeiServicesInstallFvInfoPpi (TRUE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, 0);\r
720}\r
721\r
722/**\r
723 Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.\r
724\r
725 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using\r
726 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.\r
727 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().\r
728 If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().\r
f66ad5d2 729 If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r
c7935105
SZ
730\r
731 @param FvFormat Unique identifier of the format of the memory-mapped\r
732 firmware volume. This parameter is optional and\r
733 may be NULL. If NULL is specified, the\r
734 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r
735 @param FvInfo Points to a buffer which allows the\r
736 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r
737 The format of this buffer is specific to the FvFormat.\r
738 For memory-mapped firmware volumes, this typically\r
739 points to the first byte of the firmware volume.\r
740 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r
741 firmware volumes, this is typically the size of\r
742 the firmware volume.\r
743 @param ParentFvName If the new firmware volume originated from a file\r
744 in a different firmware volume, then this parameter\r
745 specifies the GUID name of the originating firmware\r
746 volume. Otherwise, this parameter must be NULL.\r
747 @param ParentFileName If the new firmware volume originated from a file\r
748 in a different firmware volume, then this parameter\r
749 specifies the GUID file name of the originating\r
750 firmware file. Otherwise, this parameter must be NULL.\r
751 @param AuthenticationStatus Authentication Status\r
752**/\r
753VOID\r
754EFIAPI\r
755PeiServicesInstallFvInfo2Ppi (\r
756 IN CONST EFI_GUID *FvFormat, OPTIONAL\r
757 IN CONST VOID *FvInfo,\r
758 IN UINT32 FvInfoSize,\r
759 IN CONST EFI_GUID *ParentFvName, OPTIONAL\r
760 IN CONST EFI_GUID *ParentFileName, OPTIONAL\r
761 IN UINT32 AuthenticationStatus\r
762 )\r
763{\r
764 InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, AuthenticationStatus);\r
765}\r
766\r