]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiPiLib/PeiPiLib.c
follow up code review
[mirror_edk2.git] / MdePkg / Library / PeiPiLib / PeiPiLib.c
1 /** @file
2 MDE PI library functions and macros for PEI phase
3
4 Copyright (c) 2007 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <PiPei.h>
16 #include <Ppi/FirmwareVolumeInfo.h>
17 #include <Guid/FirmwareFileSystem2.h>
18
19
20 #include <Library/DebugLib.h>
21 #include <Library/MemoryAllocationLib.h>
22 #include <Library/PeiServicesLib.h>
23 #include <Library/PeiPiLib.h>
24 #include <Library/BaseMemoryLib.h>
25
26 CONST EFI_PEI_PPI_DESCRIPTOR mPpiListTemplate [] = {
27 {
28 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
29 &gEfiPeiFirmwareVolumeInfoPpiGuid,
30 NULL
31 }
32 };
33
34 /**
35 Install a EFI_PEI_FIRMWARE_VOLUME_INFO PPI to inform PEI core about the existence of a new Firmware Volume.
36
37 The function allocate the EFI_PEI_PPI_DESCRIPTOR structure and update the fields accordingly to parameter passed
38 in and install the PPI.
39
40 @param FvFormat Unique identifier of the format of the memory-mapped firmware volume.
41 If NULL is specified, EFI_FIRMWARE_FILE_SYSTEM2_GUID is used as the Format GUID.
42 @param FvInfo Points to a buffer which allows the EFI_PEI_FIRMWARE_VOLUME_PPI to
43 process the volume. The format of this buffer is specific to the FvFormat. For
44 memory-mapped firmware volumes, this typically points to the first byte of the
45 firmware volume.
46 @param FvInfoSize Size of the data provided by FvInfo. For memory-mapped firmware volumes, this is
47 typically the size of the firmware volume.
48 @param ParentFvName If the firmware volume originally came from a firmware file, then these point to the
49 parent firmware volume name. If it did not originally come from a firmware file,
50 these should be NULL.
51 @param ParentFileName If the firmware volume originally came from a firmware file, then these point to the
52 firmware volume file. If it did not originally come from a firmware file,
53 these should be NULL.
54
55 **/
56 VOID
57 EFIAPI
58 PiLibInstallFvInfoPpi (
59 IN CONST EFI_GUID *FvFormat, OPTIONAL
60 IN CONST VOID *FvInfo,
61 IN UINT32 FvInfoSize,
62 IN CONST EFI_GUID *ParentFvName, OPTIONAL
63 IN CONST EFI_GUID *ParentFileName OPTIONAL
64 )
65 {
66 EFI_STATUS Status;
67 EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;
68 EFI_PEI_PPI_DESCRIPTOR *FvInfoPpiDescriptor;
69
70 FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));
71 ASSERT( FvInfoPpi != NULL);
72
73 if (FvFormat != NULL) {
74 CopyGuid (&FvInfoPpi->FvFormat, FvFormat);
75 } else {
76 CopyGuid (&FvInfoPpi->FvFormat, &gEfiFirmwareFileSystem2Guid);
77 }
78 FvInfoPpi->FvInfo = (VOID *) FvInfo;
79 FvInfoPpi->FvInfoSize = FvInfoSize;
80 FvInfoPpi->ParentFvName = (EFI_GUID *) ParentFvName;
81 FvInfoPpi->ParentFileName = (EFI_GUID *) ParentFileName;
82
83
84 FvInfoPpiDescriptor = AllocateCopyPool (sizeof(EFI_PEI_PPI_DESCRIPTOR), mPpiListTemplate);
85 ASSERT (FvInfoPpiDescriptor != NULL);
86
87 FvInfoPpiDescriptor->Ppi = (VOID *) FvInfoPpi;
88 Status = PeiServicesInstallPpi (FvInfoPpiDescriptor);
89 ASSERT_EFI_ERROR (Status);
90
91 }
92