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