]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/PlatformInitLib.h
OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported
[mirror_edk2.git] / OvmfPkg / Include / Library / PlatformInitLib.h
CommitLineData
57bcfc3b
MX
1/** @file\r
2 PlatformInitLib header file.\r
3\r
4 Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#ifndef PLATFORM_INIT_LIB_H_\r
10#define PLATFORM_INIT_LIB_H_\r
11\r
12#include <PiPei.h>\r
13\r
14#pragma pack(1)\r
15typedef struct {\r
16 EFI_HOB_GUID_TYPE GuidHeader;\r
17 UINT16 HostBridgeDevId;\r
18\r
19 UINT64 PcdConfidentialComputingGuestAttr;\r
20 BOOLEAN SevEsIsEnabled;\r
21\r
22 UINT32 BootMode;\r
23 BOOLEAN S3Supported;\r
24\r
25 BOOLEAN SmmSmramRequire;\r
26 BOOLEAN Q35SmramAtDefaultSmbase;\r
27 UINT16 Q35TsegMbytes;\r
28\r
29 UINT64 FirstNonAddress;\r
30 UINT8 PhysMemAddressWidth;\r
31 UINT32 Uc32Base;\r
32 UINT32 Uc32Size;\r
33\r
34 BOOLEAN PcdSetNxForStack;\r
35 UINT64 PcdTdxSharedBitMask;\r
36\r
37 UINT64 PcdPciMmio64Base;\r
38 UINT64 PcdPciMmio64Size;\r
39 UINT32 PcdPciMmio32Base;\r
40 UINT32 PcdPciMmio32Size;\r
41 UINT64 PcdPciIoBase;\r
42 UINT64 PcdPciIoSize;\r
43\r
44 UINT64 PcdEmuVariableNvStoreReserved;\r
45 UINT32 PcdCpuBootLogicalProcessorNumber;\r
46 UINT32 PcdCpuMaxLogicalProcessorNumber;\r
47 UINT32 DefaultMaxCpuNumber;\r
48\r
49 UINT32 S3AcpiReservedMemoryBase;\r
50 UINT32 S3AcpiReservedMemorySize;\r
f6a196c7
GH
51\r
52 UINT64 FeatureControlValue;\r
cda98df1
GH
53\r
54 BOOLEAN QemuFwCfgChecked;\r
55 BOOLEAN QemuFwCfgSupported;\r
56 BOOLEAN QemuFwCfgDmaSupported;\r
57bcfc3b
MX
57} EFI_HOB_PLATFORM_INFO;\r
58#pragma pack()\r
59\r
60/**\r
61 Reads 8-bits of CMOS data.\r
62\r
63 Reads the 8-bits of CMOS data at the location specified by Index.\r
64 The 8-bit read value is returned.\r
65\r
66 @param Index The CMOS location to read.\r
67\r
68 @return The value read.\r
69\r
70**/\r
71UINT8\r
72EFIAPI\r
73PlatformCmosRead8 (\r
74 IN UINTN Index\r
75 );\r
76\r
77/**\r
78 Writes 8-bits of CMOS data.\r
79\r
80 Writes 8-bits of CMOS data to the location specified by Index\r
81 with the value specified by Value and returns Value.\r
82\r
83 @param Index The CMOS location to write.\r
84 @param Value The value to write to CMOS.\r
85\r
86 @return The value written to CMOS.\r
87\r
88**/\r
89UINT8\r
90EFIAPI\r
91PlatformCmosWrite8 (\r
92 IN UINTN Index,\r
93 IN UINT8 Value\r
94 );\r
95\r
96/**\r
97 Dump the CMOS content\r
98 */\r
99VOID\r
100EFIAPI\r
101PlatformDebugDumpCmos (\r
102 VOID\r
103 );\r
104\r
102cafed
MX
105VOID\r
106EFIAPI\r
107PlatformAddIoMemoryBaseSizeHob (\r
108 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
109 IN UINT64 MemorySize\r
110 );\r
111\r
112VOID\r
113EFIAPI\r
114PlatformAddIoMemoryRangeHob (\r
115 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
116 IN EFI_PHYSICAL_ADDRESS MemoryLimit\r
117 );\r
118\r
119VOID\r
120EFIAPI\r
121PlatformAddMemoryBaseSizeHob (\r
122 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
123 IN UINT64 MemorySize\r
124 );\r
125\r
126VOID\r
127EFIAPI\r
128PlatformAddMemoryRangeHob (\r
129 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
130 IN EFI_PHYSICAL_ADDRESS MemoryLimit\r
131 );\r
132\r
133VOID\r
134EFIAPI\r
135PlatformAddReservedMemoryBaseSizeHob (\r
136 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
137 IN UINT64 MemorySize,\r
138 IN BOOLEAN Cacheable\r
139 );\r
140\r
10460942
MX
141VOID\r
142EFIAPI\r
143PlatformQemuUc32BaseInitialization (\r
144 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
145 );\r
146\r
147UINT32\r
148EFIAPI\r
149PlatformGetSystemMemorySizeBelow4gb (\r
150 IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
151 );\r
152\r
153/**\r
154 Initialize the PhysMemAddressWidth field in PlatformInfoHob based on guest RAM size.\r
155**/\r
156VOID\r
157EFIAPI\r
158PlatformAddressWidthInitialization (\r
159 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
160 );\r
161\r
162/**\r
163 Peform Memory Detection for QEMU / KVM\r
164\r
165**/\r
166VOID\r
167EFIAPI\r
168PlatformQemuInitializeRam (\r
169 IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
170 );\r
171\r
172VOID\r
173EFIAPI\r
174PlatformQemuInitializeRamForS3 (\r
175 IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
176 );\r
177\r
96047b66
MX
178VOID\r
179EFIAPI\r
180PlatformMemMapInitialization (\r
181 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
182 );\r
183\r
184/**\r
185 * Fetch "opt/ovmf/PcdSetNxForStack" from QEMU\r
186 *\r
187 * @param Setting The pointer to the setting of "/opt/ovmf/PcdSetNxForStack".\r
188 * @return EFI_SUCCESS Successfully fetch the settings.\r
189 */\r
190EFI_STATUS\r
191EFIAPI\r
192PlatformNoexecDxeInitialization (\r
193 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
194 );\r
195\r
196VOID\r
197EFIAPI\r
198PlatformMiscInitialization (\r
199 IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
200 );\r
201\r
202/**\r
203 Fetch the boot CPU count and the possible CPU count from QEMU, and expose\r
204 them to UefiCpuPkg modules.\r
205**/\r
206VOID\r
207EFIAPI\r
208PlatformMaxCpuCountInitialization (\r
209 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
210 );\r
211\r
b22ac35b
MX
212/**\r
213 In Tdx guest, some information need to be passed from host VMM to guest\r
214 firmware. For example, the memory resource, etc. These information are\r
215 prepared by host VMM and put in HobList which is described in TdxMetadata.\r
216\r
217 Information in HobList is treated as external input. From the security\r
218 perspective before it is consumed, it should be validated.\r
219\r
220 @retval EFI_SUCCESS Successfully process the hoblist\r
221 @retval Others Other error as indicated\r
222**/\r
223EFI_STATUS\r
224EFIAPI\r
225ProcessTdxHobList (\r
226 VOID\r
227 );\r
228\r
e23f8f52
MX
229/**\r
230 In Tdx guest, the system memory is passed in TdHob by host VMM. So\r
231 the major task of PlatformTdxPublishRamRegions is to walk thru the\r
232 TdHob list and transfer the ResourceDescriptorHob and MemoryAllocationHob\r
233 to the hobs in DXE phase.\r
234\r
235 MemoryAllocationHob should also be created for Mailbox and Ovmf work area.\r
236**/\r
237VOID\r
238EFIAPI\r
239PlatformTdxPublishRamRegions (\r
240 VOID\r
241 );\r
242\r
4f173db8
MX
243/**\r
244 Check the integrity of NvVarStore.\r
245\r
246 @param[in] NvVarStoreBase - A pointer to NvVarStore header\r
247 @param[in] NvVarStoreSize - NvVarStore size\r
248\r
249 @retval TRUE - The NvVarStore is valid.\r
250 @retval FALSE - The NvVarStore is invalid.\r
251\r
252**/\r
253BOOLEAN\r
254EFIAPI\r
255PlatformValidateNvVarStore (\r
256 IN UINT8 *NvVarStoreBase,\r
257 IN UINT32 NvVarStoreSize\r
258 );\r
259\r
260/**\r
261 Allocate storage for NV variables early on so it will be\r
262 at a consistent address. Since VM memory is preserved\r
263 across reboots, this allows the NV variable storage to survive\r
264 a VM reboot.\r
265\r
266 *\r
267 * @retval VOID* The pointer to the storage for NV Variables\r
268 */\r
269VOID *\r
270EFIAPI\r
271PlatformReserveEmuVariableNvStore (\r
272 VOID\r
273 );\r
274\r
275/**\r
276 When OVMF is lauched with -bios parameter, UEFI variables will be\r
277 partially emulated, and non-volatile variables may lose their contents\r
278 after a reboot. This makes the secure boot feature not working.\r
279\r
280 This function is used to initialize the EmuVariableNvStore\r
281 with the conent in PcdOvmfFlashNvStorageVariableBase.\r
282\r
283 @param[in] EmuVariableNvStore - A pointer to EmuVariableNvStore\r
284\r
285 @retval EFI_SUCCESS - Successfully init the EmuVariableNvStore\r
286 @retval Others - As the error code indicates\r
287 */\r
288EFI_STATUS\r
289EFIAPI\r
290PlatformInitEmuVariableNvStore (\r
291 IN VOID *EmuVariableNvStore\r
292 );\r
293\r
57bcfc3b 294#endif // PLATFORM_INIT_LIB_H_\r