]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/PlatformInitLib.h
OvmfPkg: Update PlatformInitLib for Tdx guest
[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
51} EFI_HOB_PLATFORM_INFO;\r
52#pragma pack()\r
53\r
54/**\r
55 Reads 8-bits of CMOS data.\r
56\r
57 Reads the 8-bits of CMOS data at the location specified by Index.\r
58 The 8-bit read value is returned.\r
59\r
60 @param Index The CMOS location to read.\r
61\r
62 @return The value read.\r
63\r
64**/\r
65UINT8\r
66EFIAPI\r
67PlatformCmosRead8 (\r
68 IN UINTN Index\r
69 );\r
70\r
71/**\r
72 Writes 8-bits of CMOS data.\r
73\r
74 Writes 8-bits of CMOS data to the location specified by Index\r
75 with the value specified by Value and returns Value.\r
76\r
77 @param Index The CMOS location to write.\r
78 @param Value The value to write to CMOS.\r
79\r
80 @return The value written to CMOS.\r
81\r
82**/\r
83UINT8\r
84EFIAPI\r
85PlatformCmosWrite8 (\r
86 IN UINTN Index,\r
87 IN UINT8 Value\r
88 );\r
89\r
90/**\r
91 Dump the CMOS content\r
92 */\r
93VOID\r
94EFIAPI\r
95PlatformDebugDumpCmos (\r
96 VOID\r
97 );\r
98\r
102cafed
MX
99VOID\r
100EFIAPI\r
101PlatformAddIoMemoryBaseSizeHob (\r
102 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
103 IN UINT64 MemorySize\r
104 );\r
105\r
106VOID\r
107EFIAPI\r
108PlatformAddIoMemoryRangeHob (\r
109 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
110 IN EFI_PHYSICAL_ADDRESS MemoryLimit\r
111 );\r
112\r
113VOID\r
114EFIAPI\r
115PlatformAddMemoryBaseSizeHob (\r
116 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
117 IN UINT64 MemorySize\r
118 );\r
119\r
120VOID\r
121EFIAPI\r
122PlatformAddMemoryRangeHob (\r
123 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
124 IN EFI_PHYSICAL_ADDRESS MemoryLimit\r
125 );\r
126\r
127VOID\r
128EFIAPI\r
129PlatformAddReservedMemoryBaseSizeHob (\r
130 IN EFI_PHYSICAL_ADDRESS MemoryBase,\r
131 IN UINT64 MemorySize,\r
132 IN BOOLEAN Cacheable\r
133 );\r
134\r
10460942
MX
135VOID\r
136EFIAPI\r
137PlatformQemuUc32BaseInitialization (\r
138 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
139 );\r
140\r
141UINT32\r
142EFIAPI\r
143PlatformGetSystemMemorySizeBelow4gb (\r
144 IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
145 );\r
146\r
147/**\r
148 Initialize the PhysMemAddressWidth field in PlatformInfoHob based on guest RAM size.\r
149**/\r
150VOID\r
151EFIAPI\r
152PlatformAddressWidthInitialization (\r
153 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
154 );\r
155\r
156/**\r
157 Peform Memory Detection for QEMU / KVM\r
158\r
159**/\r
160VOID\r
161EFIAPI\r
162PlatformQemuInitializeRam (\r
163 IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
164 );\r
165\r
166VOID\r
167EFIAPI\r
168PlatformQemuInitializeRamForS3 (\r
169 IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
170 );\r
171\r
96047b66
MX
172VOID\r
173EFIAPI\r
174PlatformMemMapInitialization (\r
175 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
176 );\r
177\r
178/**\r
179 * Fetch "opt/ovmf/PcdSetNxForStack" from QEMU\r
180 *\r
181 * @param Setting The pointer to the setting of "/opt/ovmf/PcdSetNxForStack".\r
182 * @return EFI_SUCCESS Successfully fetch the settings.\r
183 */\r
184EFI_STATUS\r
185EFIAPI\r
186PlatformNoexecDxeInitialization (\r
187 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
188 );\r
189\r
190VOID\r
191EFIAPI\r
192PlatformMiscInitialization (\r
193 IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
194 );\r
195\r
196/**\r
197 Fetch the boot CPU count and the possible CPU count from QEMU, and expose\r
198 them to UefiCpuPkg modules.\r
199**/\r
200VOID\r
201EFIAPI\r
202PlatformMaxCpuCountInitialization (\r
203 IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
204 );\r
205\r
b22ac35b
MX
206/**\r
207 In Tdx guest, some information need to be passed from host VMM to guest\r
208 firmware. For example, the memory resource, etc. These information are\r
209 prepared by host VMM and put in HobList which is described in TdxMetadata.\r
210\r
211 Information in HobList is treated as external input. From the security\r
212 perspective before it is consumed, it should be validated.\r
213\r
214 @retval EFI_SUCCESS Successfully process the hoblist\r
215 @retval Others Other error as indicated\r
216**/\r
217EFI_STATUS\r
218EFIAPI\r
219ProcessTdxHobList (\r
220 VOID\r
221 );\r
222\r
e23f8f52
MX
223/**\r
224 In Tdx guest, the system memory is passed in TdHob by host VMM. So\r
225 the major task of PlatformTdxPublishRamRegions is to walk thru the\r
226 TdHob list and transfer the ResourceDescriptorHob and MemoryAllocationHob\r
227 to the hobs in DXE phase.\r
228\r
229 MemoryAllocationHob should also be created for Mailbox and Ovmf work area.\r
230**/\r
231VOID\r
232EFIAPI\r
233PlatformTdxPublishRamRegions (\r
234 VOID\r
235 );\r
236\r
57bcfc3b 237#endif // PLATFORM_INIT_LIB_H_\r