2 PlatformInitLib header file.
4 Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef PLATFORM_INIT_LIB_H_
10 #define PLATFORM_INIT_LIB_H_
16 EFI_HOB_GUID_TYPE GuidHeader
;
17 UINT16 HostBridgeDevId
;
19 UINT64 PcdConfidentialComputingGuestAttr
;
20 BOOLEAN SevEsIsEnabled
;
25 BOOLEAN SmmSmramRequire
;
26 BOOLEAN Q35SmramAtDefaultSmbase
;
29 UINT64 FirstNonAddress
;
30 UINT8 PhysMemAddressWidth
;
34 BOOLEAN PcdSetNxForStack
;
35 UINT64 PcdTdxSharedBitMask
;
37 UINT64 PcdPciMmio64Base
;
38 UINT64 PcdPciMmio64Size
;
39 UINT32 PcdPciMmio32Base
;
40 UINT32 PcdPciMmio32Size
;
44 UINT64 PcdEmuVariableNvStoreReserved
;
45 UINT32 PcdCpuBootLogicalProcessorNumber
;
46 UINT32 PcdCpuMaxLogicalProcessorNumber
;
47 UINT32 DefaultMaxCpuNumber
;
49 UINT32 S3AcpiReservedMemoryBase
;
50 UINT32 S3AcpiReservedMemorySize
;
52 UINT64 FeatureControlValue
;
54 BOOLEAN QemuFwCfgChecked
;
55 BOOLEAN QemuFwCfgSupported
;
56 BOOLEAN QemuFwCfgDmaSupported
;
57 } EFI_HOB_PLATFORM_INFO
;
61 Reads 8-bits of CMOS data.
63 Reads the 8-bits of CMOS data at the location specified by Index.
64 The 8-bit read value is returned.
66 @param Index The CMOS location to read.
68 @return The value read.
78 Writes 8-bits of CMOS data.
80 Writes 8-bits of CMOS data to the location specified by Index
81 with the value specified by Value and returns Value.
83 @param Index The CMOS location to write.
84 @param Value The value to write to CMOS.
86 @return The value written to CMOS.
101 PlatformDebugDumpCmos (
107 PlatformAddIoMemoryBaseSizeHob (
108 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
114 PlatformAddIoMemoryRangeHob (
115 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
116 IN EFI_PHYSICAL_ADDRESS MemoryLimit
121 PlatformAddMemoryBaseSizeHob (
122 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
128 PlatformAddMemoryRangeHob (
129 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
130 IN EFI_PHYSICAL_ADDRESS MemoryLimit
135 PlatformAddReservedMemoryBaseSizeHob (
136 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
137 IN UINT64 MemorySize
,
143 PlatformQemuUc32BaseInitialization (
144 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
149 PlatformGetSystemMemorySizeBelow4gb (
150 IN EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
154 Initialize the PhysMemAddressWidth field in PlatformInfoHob based on guest RAM size.
158 PlatformAddressWidthInitialization (
159 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
163 Peform Memory Detection for QEMU / KVM
168 PlatformQemuInitializeRam (
169 IN EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
174 PlatformQemuInitializeRamForS3 (
175 IN EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
180 PlatformMemMapInitialization (
181 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
185 * Fetch "opt/ovmf/PcdSetNxForStack" from QEMU
187 * @param Setting The pointer to the setting of "/opt/ovmf/PcdSetNxForStack".
188 * @return EFI_SUCCESS Successfully fetch the settings.
192 PlatformNoexecDxeInitialization (
193 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
198 PlatformMiscInitialization (
199 IN EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
203 Fetch the boot CPU count and the possible CPU count from QEMU, and expose
204 them to UefiCpuPkg modules.
208 PlatformMaxCpuCountInitialization (
209 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
213 In Tdx guest, some information need to be passed from host VMM to guest
214 firmware. For example, the memory resource, etc. These information are
215 prepared by host VMM and put in HobList which is described in TdxMetadata.
217 Information in HobList is treated as external input. From the security
218 perspective before it is consumed, it should be validated.
220 @retval EFI_SUCCESS Successfully process the hoblist
221 @retval Others Other error as indicated
230 In Tdx guest, the system memory is passed in TdHob by host VMM. So
231 the major task of PlatformTdxPublishRamRegions is to walk thru the
232 TdHob list and transfer the ResourceDescriptorHob and MemoryAllocationHob
233 to the hobs in DXE phase.
235 MemoryAllocationHob should also be created for Mailbox and Ovmf work area.
239 PlatformTdxPublishRamRegions (
244 Check the integrity of NvVarStore.
246 @param[in] NvVarStoreBase - A pointer to NvVarStore header
247 @param[in] NvVarStoreSize - NvVarStore size
249 @retval TRUE - The NvVarStore is valid.
250 @retval FALSE - The NvVarStore is invalid.
255 PlatformValidateNvVarStore (
256 IN UINT8
*NvVarStoreBase
,
257 IN UINT32 NvVarStoreSize
261 Allocate storage for NV variables early on so it will be
262 at a consistent address. Since VM memory is preserved
263 across reboots, this allows the NV variable storage to survive
267 * @retval VOID* The pointer to the storage for NV Variables
271 PlatformReserveEmuVariableNvStore (
276 When OVMF is lauched with -bios parameter, UEFI variables will be
277 partially emulated, and non-volatile variables may lose their contents
278 after a reboot. This makes the secure boot feature not working.
280 This function is used to initialize the EmuVariableNvStore
281 with the conent in PcdOvmfFlashNvStorageVariableBase.
283 @param[in] EmuVariableNvStore - A pointer to EmuVariableNvStore
285 @retval EFI_SUCCESS - Successfully init the EmuVariableNvStore
286 @retval Others - As the error code indicates
290 PlatformInitEmuVariableNvStore (
291 IN VOID
*EmuVariableNvStore
294 #endif // PLATFORM_INIT_LIB_H_