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