]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiServicesLib/PeiServicesLib.c
Remove tabs in MdePkg source code
[mirror_edk2.git] / MdePkg / Library / PeiServicesLib / PeiServicesLib.c
CommitLineData
738ec565 1/** @file\r
2 Implementation for PEI Services Library.\r
3\r
60bd4ccd 4 Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
738ec565 5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
738ec565 13**/\r
14\r
c892d846 15\r
c7d265a9 16#include <PiPei.h>\r
c892d846 17\r
729675ae 18#include <Ppi/FirmwareVolumeInfo.h>\r
19#include <Guid/FirmwareFileSystem2.h>\r
c892d846 20\r
c7d265a9 21#include <Library/PeiServicesLib.h>\r
22#include <Library/PeiServicesTablePointerLib.h>\r
729675ae 23#include <Library/DebugLib.h>\r
24#include <Library/MemoryAllocationLib.h>\r
25#include <Library/BaseMemoryLib.h>\r
26\r
27\r
367573d3 28GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_PEI_PPI_DESCRIPTOR mPpiListTemplate[] = {\r
729675ae 29 {\r
30 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
31 &gEfiPeiFirmwareVolumeInfoPpiGuid,\r
32 NULL\r
33 }\r
34};\r
738ec565 35\r
36/**\r
37 This service enables a given PEIM to register an interface into the PEI Foundation.\r
38\r
39 @param PpiList A pointer to the list of interfaces that the caller shall install.\r
40\r
41 @retval EFI_SUCCESS The interface was successfully installed.\r
42 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r
43 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
44 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
45 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r
46\r
47**/\r
48EFI_STATUS\r
49EFIAPI\r
50PeiServicesInstallPpi (\r
1c280088 51 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
738ec565 52 )\r
53{\r
1c280088 54 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 55\r
5240b97c 56 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 57 return (*PeiServices)->InstallPpi (PeiServices, PpiList);\r
58}\r
59\r
60/**\r
61 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r
62\r
63 @param OldPpi Pointer to the old PEI PPI Descriptors.\r
64 @param NewPpi Pointer to the new PEI PPI Descriptors.\r
65\r
66 @retval EFI_SUCCESS The interface was successfully installed.\r
67 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r
68 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
69 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
70 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r
71 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been\r
72 installed.\r
73\r
74**/\r
75EFI_STATUS\r
76EFIAPI\r
77PeiServicesReInstallPpi (\r
1c280088 78 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
79 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
738ec565 80 )\r
81{\r
1c280088 82 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 83\r
5240b97c 84 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 85 return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi);\r
86}\r
87\r
88/**\r
89 This service enables PEIMs to discover a given instance of an interface.\r
90\r
91 @param Guid A pointer to the GUID whose corresponding interface needs to be\r
92 found.\r
93 @param Instance The N-th instance of the interface that is required.\r
94 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r
95 @param Ppi A pointer to the instance of the interface.\r
96\r
97 @retval EFI_SUCCESS The interface was successfully returned.\r
98 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.\r
99\r
100**/\r
101EFI_STATUS\r
102EFIAPI\r
103PeiServicesLocatePpi (\r
1c280088 104 IN CONST EFI_GUID *Guid,\r
738ec565 105 IN UINTN Instance,\r
106 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
107 IN OUT VOID **Ppi\r
108 )\r
109{\r
1c280088 110 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 111\r
5240b97c 112 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 113 return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);\r
114}\r
115\r
116/**\r
117 This service enables PEIMs to register a given service to be invoked when another service is\r
118 installed or reinstalled.\r
119\r
120 @param NotifyList A pointer to the list of notification interfaces that the caller\r
121 shall install.\r
122\r
123 @retval EFI_SUCCESS The interface was successfully installed.\r
124 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r
125 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the\r
126 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.\r
127 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r
128\r
129**/\r
130EFI_STATUS\r
131EFIAPI\r
132PeiServicesNotifyPpi (\r
1c280088 133 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
738ec565 134 )\r
135{\r
1c280088 136 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 137\r
5240b97c 138 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 139 return (*PeiServices)->NotifyPpi (PeiServices, NotifyList);\r
140}\r
141\r
142/**\r
143 This service enables PEIMs to ascertain the present value of the boot mode.\r
144\r
145 @param BootMode A pointer to contain the value of the boot mode.\r
146\r
147 @retval EFI_SUCCESS The boot mode was returned successfully.\r
148 @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
149\r
150**/\r
151EFI_STATUS\r
152EFIAPI\r
153PeiServicesGetBootMode (\r
c3363c92 154 OUT EFI_BOOT_MODE *BootMode\r
738ec565 155 )\r
156{\r
1c280088 157 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 158\r
5240b97c 159 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 160 return (*PeiServices)->GetBootMode (PeiServices, BootMode);\r
161}\r
162\r
163/**\r
164 This service enables PEIMs to update the boot mode variable.\r
165\r
166 @param BootMode The value of the boot mode to set.\r
167\r
168 @retval EFI_SUCCESS The value was successfully updated\r
169\r
170**/\r
171EFI_STATUS\r
172EFIAPI\r
173PeiServicesSetBootMode (\r
174 IN EFI_BOOT_MODE BootMode\r
175 )\r
176{\r
1c280088 177 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 178\r
5240b97c 179 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 180 return (*PeiServices)->SetBootMode (PeiServices, BootMode);\r
181}\r
182\r
183/**\r
184 This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r
185\r
186 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.\r
187\r
188 @retval EFI_SUCCESS The list was successfully returned.\r
189 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r
190\r
191**/\r
192EFI_STATUS\r
193EFIAPI\r
194PeiServicesGetHobList (\r
f38fdc74 195 OUT VOID **HobList\r
738ec565 196 )\r
197{\r
1c280088 198 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 199\r
5240b97c 200 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 201 return (*PeiServices)->GetHobList (PeiServices, HobList);\r
202}\r
203\r
204/**\r
205 This service enables PEIMs to create various types of HOBs.\r
206\r
207 @param Type The type of HOB to be installed.\r
208 @param Length The length of the HOB to be added.\r
209 @param Hob The address of a pointer that will contain the HOB header.\r
210\r
211 @retval EFI_SUCCESS The HOB was successfully created.\r
212 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r
213\r
214**/\r
215EFI_STATUS\r
216EFIAPI\r
217PeiServicesCreateHob (\r
218 IN UINT16 Type,\r
219 IN UINT16 Length,\r
dd652088 220 OUT VOID **Hob\r
738ec565 221 )\r
222{\r
1c280088 223 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 224\r
5240b97c 225 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 226 return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob);\r
227}\r
228\r
229/**\r
230 This service enables PEIMs to discover additional firmware volumes.\r
231\r
232 @param Instance This instance of the firmware volume to find. The value 0 is the\r
233 Boot Firmware Volume (BFV).\r
42eedea9 234 @param VolumeHandle Handle of the firmware volume header of the volume to return.\r
738ec565 235\r
236 @retval EFI_SUCCESS The volume was found.\r
237 @retval EFI_NOT_FOUND The volume was not found.\r
238 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r
239\r
240**/\r
241EFI_STATUS\r
242EFIAPI\r
243PeiServicesFfsFindNextVolume (\r
244 IN UINTN Instance,\r
1c280088 245 IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r
738ec565 246 )\r
247{\r
1c280088 248 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 249\r
5240b97c 250 PeiServices = GetPeiServicesTablePointer ();\r
1c280088 251 return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, VolumeHandle);\r
738ec565 252}\r
253\r
254/**\r
255 This service enables PEIMs to discover additional firmware files.\r
256\r
257 @param SearchType A filter to find files only of this type.\r
42eedea9 258 @param VolumeHandle Pointer to the firmware volume header of the volume to search.\r
738ec565 259 This parameter must point to a valid FFS volume.\r
42eedea9 260 @param FileHandle Handle of the current file from which to begin searching.\r
738ec565 261\r
262 @retval EFI_SUCCESS The file was found.\r
263 @retval EFI_NOT_FOUND The file was not found.\r
264 @retval EFI_NOT_FOUND The header checksum was not zero.\r
265\r
266**/\r
267EFI_STATUS\r
268EFIAPI\r
269PeiServicesFfsFindNextFile (\r
270 IN EFI_FV_FILETYPE SearchType,\r
1c280088 271 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
272 IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
738ec565 273 )\r
274{\r
1c280088 275 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 276\r
5240b97c 277 PeiServices = GetPeiServicesTablePointer ();\r
1c280088 278 return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, VolumeHandle, FileHandle);\r
738ec565 279}\r
280\r
281/**\r
282 This service enables PEIMs to discover sections of a given type within a valid FFS file.\r
283\r
42eedea9 284 @param SectionType The value of the section type to find.\r
122e2191 285 @param FileHandle A pointer to the file header that contains the set of sections to\r
738ec565 286 be searched.\r
287 @param SectionData A pointer to the discovered section, if successful.\r
288\r
289 @retval EFI_SUCCESS The section was found.\r
290 @retval EFI_NOT_FOUND The section was not found.\r
291\r
292**/\r
293EFI_STATUS\r
294EFIAPI\r
295PeiServicesFfsFindSectionData (\r
296 IN EFI_SECTION_TYPE SectionType,\r
122e2191 297 IN EFI_PEI_FILE_HANDLE FileHandle,\r
67c89a21 298 OUT VOID **SectionData\r
738ec565 299 )\r
300{\r
1c280088 301 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 302\r
5240b97c 303 PeiServices = GetPeiServicesTablePointer ();\r
122e2191 304 return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FileHandle, SectionData);\r
738ec565 305}\r
306\r
307/**\r
308 This service enables PEIMs to register the permanent memory configuration\r
309 that has been initialized with the PEI Foundation.\r
310\r
311 @param MemoryBegin The value of a region of installed memory.\r
312 @param MemoryLength The corresponding length of a region of installed memory.\r
313\r
314 @retval EFI_SUCCESS The region was successfully installed in a HOB.\r
315 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r
316 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r
317\r
318**/\r
319EFI_STATUS\r
320EFIAPI\r
321PeiServicesInstallPeiMemory (\r
322 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
323 IN UINT64 MemoryLength\r
324 )\r
325{\r
1c280088 326 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 327\r
5240b97c 328 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 329 return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);\r
330}\r
331\r
332/**\r
333 This service enables PEIMs to allocate memory after the permanent memory has been installed by a\r
334 PEIM.\r
335\r
336 @param MemoryType Type of memory to allocate.\r
337 @param Pages Number of pages to allocate.\r
338 @param Memory Pointer of memory allocated.\r
339\r
340 @retval EFI_SUCCESS The memory range was successfully allocated.\r
341 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.\r
342 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.\r
343 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r
344\r
345**/\r
346EFI_STATUS\r
347EFIAPI\r
348PeiServicesAllocatePages (\r
349 IN EFI_MEMORY_TYPE MemoryType,\r
350 IN UINTN Pages,\r
67c89a21 351 OUT EFI_PHYSICAL_ADDRESS *Memory\r
738ec565 352 )\r
353{\r
1c280088 354 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 355\r
5240b97c 356 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 357 return (*PeiServices)->AllocatePages (PeiServices, MemoryType, Pages, Memory);\r
358}\r
359\r
360/**\r
361 This service allocates memory from the Hand-Off Block (HOB) heap.\r
362\r
363 @param Size The number of bytes to allocate from the pool.\r
364 @param Buffer If the call succeeds, a pointer to a pointer to the allocate\r
365 buffer; undefined otherwise.\r
366\r
367 @retval EFI_SUCCESS The allocation was successful\r
368 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.\r
369\r
370**/\r
371EFI_STATUS\r
372EFIAPI\r
373PeiServicesAllocatePool (\r
374 IN UINTN Size,\r
375 OUT VOID **Buffer\r
376 )\r
377{\r
1c280088 378 CONST EFI_PEI_SERVICES **PeiServices;\r
738ec565 379\r
5240b97c 380 PeiServices = GetPeiServicesTablePointer ();\r
738ec565 381 return (*PeiServices)->AllocatePool (PeiServices, Size, Buffer);\r
382}\r
383\r
384/**\r
67c89a21 385 Resets the entire platform.\r
738ec565 386\r
67c89a21 387 @retval EFI_SUCCESS The function completed successfully.\r
738ec565 388 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r
389\r
390**/\r
391EFI_STATUS\r
392EFIAPI\r
393PeiServicesResetSystem (\r
394 VOID\r
395 )\r
b0d803fe 396{\r
397 CONST EFI_PEI_SERVICES **PeiServices;\r
398\r
5240b97c 399 PeiServices = GetPeiServicesTablePointer ();\r
b0d803fe 400 return (*PeiServices)->ResetSystem (PeiServices);\r
401}\r
402\r
67c89a21 403/**\r
404 This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services \r
405 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface \r
406 Specification for details. \r
407\r
408 @param FileHandle PEIM's file handle. Must be the currently\r
409 executing PEIM.\r
410 \r
411 @retval EFI_SUCCESS The PEIM was successfully registered for\r
412 shadowing.\r
413\r
414 @retval EFI_ALREADY_STARTED The PEIM was previously\r
415 registered for shadowing.\r
416\r
417 @retval EFI_NOT_FOUND The FileHandle does not refer to a\r
418 valid file handle.\r
419**/\r
b0d803fe 420EFI_STATUS\r
421EFIAPI\r
422PeiServicesRegisterForShadow (\r
423 IN EFI_PEI_FILE_HANDLE FileHandle\r
424 )\r
738ec565 425{\r
484c7785 426 return (*GetPeiServicesTablePointer())->RegisterForShadow (FileHandle);\r
738ec565 427}\r
b0d803fe 428\r
67c89a21 429/**\r
430 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services \r
431 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface \r
432 Specification for details. \r
433\r
434 @param FileHandle Handle of the file.\r
435\r
436 @param FileInfo Upon exit, points to the file's\r
437 information.\r
438\r
439 @retval EFI_SUCCESS File information returned.\r
440 \r
441 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
442 represent a valid file.\r
443 \r
444 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
445 \r
446**/\r
b0d803fe 447EFI_STATUS\r
f38fdc74 448EFIAPI \r
b0d803fe 449PeiServicesFfsGetFileInfo (\r
450 IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r
451 OUT EFI_FV_FILE_INFO *FileInfo\r
452 )\r
453{\r
484c7785 454 return (*GetPeiServicesTablePointer())->FfsGetFileInfo (FileHandle, FileInfo);\r
b0d803fe 455}\r
456\r
457\r
67c89a21 458/**\r
459 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services \r
460 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface \r
461 Specification for details. \r
462\r
463 @param FileName A pointer to the name of the file to\r
464 find within the firmware volume.\r
465\r
466 @param VolumeHandle The firmware volume to search FileHandle\r
467 Upon exit, points to the found file's\r
468 handle or NULL if it could not be found.\r
f38fdc74 469 @param FileHandle Pointer to found file handle \r
42eedea9 470\r
67c89a21 471 @retval EFI_SUCCESS File was found.\r
472\r
473 @retval EFI_NOT_FOUND File was not found.\r
474\r
475 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or\r
476 FileName was NULL.\r
477\r
478**/\r
b0d803fe 479EFI_STATUS\r
480EFIAPI\r
481PeiServicesFfsFindFileByName (\r
482 IN CONST EFI_GUID *FileName,\r
483 IN CONST EFI_PEI_FV_HANDLE VolumeHandle,\r
484 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
485 )\r
486{\r
487 return (*GetPeiServicesTablePointer())->FfsFindFileByName (FileName, VolumeHandle, FileHandle);\r
488}\r
489\r
490\r
67c89a21 491/**\r
492 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services \r
493 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface \r
494 Specification for details. \r
495\r
496 @param VolumeHandle Handle of the volume.\r
497\r
498 @param VolumeInfo Upon exit, points to the volume's\r
499 information.\r
500\r
501 @retval EFI_SUCCESS File information returned.\r
502 \r
503 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
504 represent a valid file.\r
505 \r
506 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
507\r
508**/\r
b0d803fe 509EFI_STATUS\r
510EFIAPI\r
511PeiServicesFfsGetVolumeInfo (\r
512 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
513 OUT EFI_FV_INFO *VolumeInfo\r
514 )\r
515{\r
516 return (*GetPeiServicesTablePointer())->FfsGetVolumeInfo (VolumeHandle, VolumeInfo);\r
517}\r
518\r
729675ae 519/**\r
b75a165d 520 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.\r
729675ae 521 \r
b75a165d
LG
522 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using \r
523 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.\r
524 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().\r
525 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().\r
526\r
729675ae 527 \r
b75a165d
LG
528 @param FvFormat Unique identifier of the format of the memory-mapped firmware volume.\r
529 This parameter is optional and may be NULL. \r
530 If NULL is specified, the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r
531 @param FvInfo Points to a buffer which allows the EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume. \r
532 The format of this buffer is specific to the FvFormat. For memory-mapped firmware volumes, \r
533 this typically points to the first byte of the firmware volume.\r
534 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped firmware volumes, \r
535 this is typically the size of the firmware volume.\r
536 @param ParentFvName If the new firmware volume originated from a file in a different firmware volume, \r
537 then this parameter specifies the GUID name of the originating firmware volume.\r
538 Otherwise, this parameter must be NULL.\r
539 @param ParentFileName If the new firmware volume originated from a file in a different firmware volume, \r
540 then this parameter specifies the GUID file name of the originating firmware file.\r
541 Otherwise, this parameter must be NULL.\r
729675ae 542**/\r
543VOID\r
544EFIAPI\r
545PeiServicesInstallFvInfoPpi (\r
546 IN CONST EFI_GUID *FvFormat, OPTIONAL\r
547 IN CONST VOID *FvInfo,\r
548 IN UINT32 FvInfoSize,\r
549 IN CONST EFI_GUID *ParentFvName, OPTIONAL\r
550 IN CONST EFI_GUID *ParentFileName OPTIONAL\r
551 )\r
552{\r
553 EFI_STATUS Status; \r
554 EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;\r
555 EFI_PEI_PPI_DESCRIPTOR *FvInfoPpiDescriptor;\r
3831f3e9
LG
556 EFI_GUID *ParentFvNameValue;\r
557 EFI_GUID *ParentFileNameValue;\r
729675ae 558\r
3831f3e9
LG
559 ParentFvNameValue = NULL;\r
560 ParentFileNameValue = NULL;\r
729675ae 561 FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));\r
3831f3e9 562 ASSERT(FvInfoPpi != NULL);\r
729675ae 563\r
564 if (FvFormat != NULL) {\r
565 CopyGuid (&FvInfoPpi->FvFormat, FvFormat);\r
566 } else {\r
567 CopyGuid (&FvInfoPpi->FvFormat, &gEfiFirmwareFileSystem2Guid);\r
568 }\r
569 FvInfoPpi->FvInfo = (VOID *) FvInfo;\r
570 FvInfoPpi->FvInfoSize = FvInfoSize;\r
3831f3e9
LG
571 if (ParentFvName != NULL) {\r
572 ParentFvNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFvName);\r
60bd4ccd 573 ASSERT (ParentFvNameValue != NULL);\r
3831f3e9
LG
574 FvInfoPpi->ParentFvName = ParentFvNameValue;\r
575 }\r
576 if (ParentFileName != NULL) {\r
577 ParentFileNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFileName);\r
578 ASSERT (ParentFileNameValue != NULL);\r
579 FvInfoPpi->ParentFileName = ParentFileNameValue;\r
580 }\r
729675ae 581\r
582 FvInfoPpiDescriptor = AllocateCopyPool (sizeof(EFI_PEI_PPI_DESCRIPTOR), mPpiListTemplate);\r
583 ASSERT (FvInfoPpiDescriptor != NULL);\r
584\r
585 FvInfoPpiDescriptor->Ppi = (VOID *) FvInfoPpi;\r
586 Status = PeiServicesInstallPpi (FvInfoPpiDescriptor);\r
587 ASSERT_EFI_ERROR (Status);\r
588\r
589}\r
590\r