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