]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/PlatformPei/Fv.c
BaseTools: Library hashing fix and optimization for --hash feature
[mirror_edk2.git] / OvmfPkg / PlatformPei / Fv.c
1 /** @file
2 Build FV related hobs for platform.
3
4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "PiPei.h"
10 #include "Platform.h"
11 #include <Library/DebugLib.h>
12 #include <Library/HobLib.h>
13 #include <Library/PeiServicesLib.h>
14 #include <Library/PcdLib.h>
15
16
17 /**
18 Publish PEI & DXE (Decompressed) Memory based FVs to let PEI
19 and DXE know about them.
20
21 @retval EFI_SUCCESS Platform PEI FVs were initialized successfully.
22
23 **/
24 EFI_STATUS
25 PeiFvInitialization (
26 VOID
27 )
28 {
29 BOOLEAN SecureS3Needed;
30
31 DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));
32
33 //
34 // Create a memory allocation HOB for the PEI FV.
35 //
36 // Allocate as ACPI NVS is S3 is supported
37 //
38 BuildMemoryAllocationHob (
39 PcdGet32 (PcdOvmfPeiMemFvBase),
40 PcdGet32 (PcdOvmfPeiMemFvSize),
41 mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
42 );
43
44 //
45 // Let DXE know about the DXE FV
46 //
47 BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
48
49 SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire);
50
51 //
52 // Create a memory allocation HOB for the DXE FV.
53 //
54 // If "secure" S3 is needed, then SEC will decompress both PEI and DXE
55 // firmware volumes at S3 resume too, hence we need to keep away the OS from
56 // DXEFV as well. Otherwise we only need to keep away DXE itself from the
57 // DXEFV area.
58 //
59 BuildMemoryAllocationHob (
60 PcdGet32 (PcdOvmfDxeMemFvBase),
61 PcdGet32 (PcdOvmfDxeMemFvSize),
62 SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData
63 );
64
65 //
66 // Additionally, said decompression will use temporary memory above the end
67 // of DXEFV, so let's keep away the OS from there too.
68 //
69 if (SecureS3Needed) {
70 UINT32 DxeMemFvEnd;
71
72 DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) +
73 PcdGet32 (PcdOvmfDxeMemFvSize);
74 BuildMemoryAllocationHob (
75 DxeMemFvEnd,
76 PcdGet32 (PcdOvmfDecompressionScratchEnd) - DxeMemFvEnd,
77 EfiACPIMemoryNVS
78 );
79 }
80
81 //
82 // Let PEI know about the DXE FV so it can find the DXE Core
83 //
84 PeiServicesInstallFvInfoPpi (
85 NULL,
86 (VOID *)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase),
87 PcdGet32 (PcdOvmfDxeMemFvSize),
88 NULL,
89 NULL
90 );
91
92 return EFI_SUCCESS;
93 }
94