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, some information need to be passed from host VMM to guest
215 firmware. For example, the memory resource, etc. These information are
216 prepared by host VMM and put in HobList which is described in TdxMetadata.
218 Information in HobList is treated as external input. From the security
219 perspective before it is consumed, it should be validated.
221 @retval EFI_SUCCESS Successfully process the hoblist
222 @retval Others Other error as indicated
231 In Tdx guest, the system memory is passed in TdHob by host VMM. So
232 the major task of PlatformTdxPublishRamRegions is to walk thru the
233 TdHob list and transfer the ResourceDescriptorHob and MemoryAllocationHob
234 to the hobs in DXE phase.
236 MemoryAllocationHob should also be created for Mailbox and Ovmf work area.
240 PlatformTdxPublishRamRegions (
245 Check the integrity of NvVarStore.
247 @param[in] NvVarStoreBase - A pointer to NvVarStore header
248 @param[in] NvVarStoreSize - NvVarStore size
250 @retval TRUE - The NvVarStore is valid.
251 @retval FALSE - The NvVarStore is invalid.
256 PlatformValidateNvVarStore (
257 IN UINT8
*NvVarStoreBase
,
258 IN UINT32 NvVarStoreSize
262 Allocate storage for NV variables early on so it will be
263 at a consistent address. Since VM memory is preserved
264 across reboots, this allows the NV variable storage to survive
268 * @retval VOID* The pointer to the storage for NV Variables
272 PlatformReserveEmuVariableNvStore (
277 When OVMF is lauched with -bios parameter, UEFI variables will be
278 partially emulated, and non-volatile variables may lose their contents
279 after a reboot. This makes the secure boot feature not working.
281 This function is used to initialize the EmuVariableNvStore
282 with the conent in PcdOvmfFlashNvStorageVariableBase.
284 @param[in] EmuVariableNvStore - A pointer to EmuVariableNvStore
286 @retval EFI_SUCCESS - Successfully init the EmuVariableNvStore
287 @retval Others - As the error code indicates
291 PlatformInitEmuVariableNvStore (
292 IN VOID
*EmuVariableNvStore
295 #endif // PLATFORM_INIT_LIB_H_