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
;
30 UINT64 FirstNonAddress
;
31 UINT8 PhysMemAddressWidth
;
35 BOOLEAN PcdSetNxForStack
;
36 UINT64 PcdTdxSharedBitMask
;
38 UINT64 PcdPciMmio64Base
;
39 UINT64 PcdPciMmio64Size
;
40 UINT32 PcdPciMmio32Base
;
41 UINT32 PcdPciMmio32Size
;
45 UINT64 PcdEmuVariableNvStoreReserved
;
46 UINT32 PcdCpuBootLogicalProcessorNumber
;
47 UINT32 PcdCpuMaxLogicalProcessorNumber
;
48 UINT32 DefaultMaxCpuNumber
;
50 UINT32 S3AcpiReservedMemoryBase
;
51 UINT32 S3AcpiReservedMemorySize
;
53 UINT64 FeatureControlValue
;
55 BOOLEAN QemuFwCfgChecked
;
56 BOOLEAN QemuFwCfgSupported
;
57 BOOLEAN QemuFwCfgDmaSupported
;
58 } EFI_HOB_PLATFORM_INFO
;
62 Reads 8-bits of CMOS data.
64 Reads the 8-bits of CMOS data at the location specified by Index.
65 The 8-bit read value is returned.
67 @param Index The CMOS location to read.
69 @return The value read.
79 Writes 8-bits of CMOS data.
81 Writes 8-bits of CMOS data to the location specified by Index
82 with the value specified by Value and returns Value.
84 @param Index The CMOS location to write.
85 @param Value The value to write to CMOS.
87 @return The value written to CMOS.
102 PlatformDebugDumpCmos (
108 PlatformAddIoMemoryBaseSizeHob (
109 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
115 PlatformAddIoMemoryRangeHob (
116 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
117 IN EFI_PHYSICAL_ADDRESS MemoryLimit
122 PlatformAddMemoryBaseSizeHob (
123 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
129 PlatformAddMemoryRangeHob (
130 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
131 IN EFI_PHYSICAL_ADDRESS MemoryLimit
136 PlatformAddReservedMemoryBaseSizeHob (
137 IN EFI_PHYSICAL_ADDRESS MemoryBase
,
138 IN UINT64 MemorySize
,
144 PlatformQemuUc32BaseInitialization (
145 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
150 PlatformGetSystemMemorySizeBelow4gb (
151 IN EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
155 Initialize the PhysMemAddressWidth field in PlatformInfoHob based on guest RAM size.
159 PlatformAddressWidthInitialization (
160 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
164 Peform Memory Detection for QEMU / KVM
169 PlatformQemuInitializeRam (
170 IN EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
175 PlatformQemuInitializeRamForS3 (
176 IN EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
181 PlatformMemMapInitialization (
182 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
186 * Fetch "opt/ovmf/PcdSetNxForStack" from QEMU
188 * @param Setting The pointer to the setting of "/opt/ovmf/PcdSetNxForStack".
189 * @return EFI_SUCCESS Successfully fetch the settings.
193 PlatformNoexecDxeInitialization (
194 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
199 PlatformMiscInitialization (
200 IN EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
204 Fetch the boot CPU count and the possible CPU count from QEMU, and expose
205 them to UefiCpuPkg modules.
209 PlatformMaxCpuCountInitialization (
210 IN OUT EFI_HOB_PLATFORM_INFO
*PlatformInfoHob
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.
219 MemoryAllocationHob should also be created for Mailbox and Ovmf work area.
223 PlatformTdxPublishRamRegions (
228 Check the integrity of NvVarStore.
230 @param[in] NvVarStoreBase - A pointer to NvVarStore header
231 @param[in] NvVarStoreSize - NvVarStore size
233 @retval TRUE - The NvVarStore is valid.
234 @retval FALSE - The NvVarStore is invalid.
239 PlatformValidateNvVarStore (
240 IN UINT8
*NvVarStoreBase
,
241 IN UINT32 NvVarStoreSize
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
251 * @retval VOID* The pointer to the storage for NV Variables
255 PlatformReserveEmuVariableNvStore (
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.
264 This function is used to initialize the EmuVariableNvStore
265 with the conent in PcdOvmfFlashNvStorageVariableBase.
267 @param[in] EmuVariableNvStore - A pointer to EmuVariableNvStore
269 @retval EFI_SUCCESS - Successfully init the EmuVariableNvStore
270 @retval Others - As the error code indicates
274 PlatformInitEmuVariableNvStore (
275 IN VOID
*EmuVariableNvStore
278 #endif // PLATFORM_INIT_LIB_H_