]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiPiLib/PeiPiLib.c
cbdc92b6ab478d1175875907d95ebd9e83915238
[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, 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
27 CONST EFI_PEI_FIRMWARE_VOLUME_INFO_PPI mFvInfoPpiTemplate = {
28 EFI_FIRMWARE_FILE_SYSTEM2_GUID,
29 NULL,
30 0, //FvInfoSize
31 NULL, //ParentFvName
32 NULL //ParentFileName;
33 };
34
35 /**
36 Install a EFI_PEI_FIRMWARE_VOLUME_INFO PPI to inform PEI core about the existence of a new Firmware Volume.
37
38 The function allocate the EFI_PEI_PPI_DESCRIPTOR structure and update the fields accordingly to parameter passed
39 in and install the PPI.
40
41 @param FvFormat Unique identifier of the format of the memory-mapped firmware volume. If NULL is specified,
42 EFI_FIRMWARE_FILE_SYSTEM2_GUID is used as the Format GUID.
43 @param FvInfo Points to a buffer which allows the EFI_PEI_FIRMWARE_VOLUME_PPI to
44 process the volume. The format of this buffer is specific to the FvFormat. For
45 memory-mapped firmware volumes, this typically points to the first byte of the
46 firmware volume.
47 @param FvInfoSize Size of the data provided by FvInfo. For memory-mapped firmware volumes, this is
48 typically the size of the firmware volume.
49 @param ParentFvName If the firmware volume originally came from a firmware file, then these point to the
50 parent firmware volume name. If it did not originally come
51 from a firmware file, these should be NULL.
52 @param ParentFileName If the firmware volume originally came from a firmware file, then these point to the
53 firmware volume file. If it did not originally come
54 from a firmware file, these should be NULL.
55
56 **/
57 VOID
58 EFIAPI
59 PiLibInstallFvInfoPpi (
60 IN EFI_GUID *FvFormat, OPTIONAL
61 IN VOID *FvInfo,
62 IN UINT32 FvInfoSize,
63 IN EFI_GUID *ParentFvName, OPTIONAL
64 IN EFI_GUID *ParentFileName OPTIONAL
65 )
66 {
67
68 EFI_STATUS Status;
69 EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;
70 EFI_PEI_PPI_DESCRIPTOR *FvInfoPpiDescriptor;
71
72 FvInfoPpi = AllocateCopyPool (sizeof (*FvInfoPpi), &mFvInfoPpiTemplate);
73 ASSERT( FvInfoPpi != NULL);
74
75 if (FvFormat != NULL) {
76 CopyMem (&FvInfoPpi->FvFormat, FvFormat, sizeof (*FvFormat));
77 }
78 FvInfoPpi->FvInfo = (VOID *) (UINTN) FvInfo;
79 FvInfoPpi->FvInfoSize = (UINT32) FvInfoSize;
80 FvInfoPpi->ParentFvName = ParentFvName;
81 FvInfoPpi->ParentFileName = ParentFileName;
82
83
84 FvInfoPpiDescriptor = AllocatePool (sizeof(EFI_PEI_PPI_DESCRIPTOR));
85 ASSERT (FvInfoPpiDescriptor != NULL);
86
87 FvInfoPpiDescriptor->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
88 FvInfoPpiDescriptor->Guid = &gEfiPeiFirmwareVolumeInfoPpiGuid;
89 FvInfoPpiDescriptor->Ppi = (VOID *) FvInfoPpi;
90 Status = PeiServicesInstallPpi (FvInfoPpiDescriptor);
91 ASSERT_EFI_ERROR (Status);
92
93 }
94