/**@file\r
Platform PEI driver\r
\r
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
Copyright (c) 2011, Andrei Warkentin <andreiw@motorola.com>\r
\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
//\r
// The Library classes this module consumes\r
//\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/HobLib.h>\r
#include <Library/IoLib.h>\r
#include <Library/PciLib.h>\r
#include <Library/PeimEntryPoint.h>\r
#include <Library/PeiServicesLib.h>\r
+#include <Library/QemuFwCfgLib.h>\r
+#include <Library/QemuFwCfgS3Lib.h>\r
+#include <Library/QemuFwCfgSimpleParserLib.h>\r
#include <Library/ResourcePublicationLib.h>\r
-#include <Guid/MemoryTypeInformation.h>\r
#include <Ppi/MasterBootMode.h>\r
+#include <IndustryStandard/I440FxPiix4.h>\r
+#include <IndustryStandard/Microvm.h>\r
#include <IndustryStandard/Pci22.h>\r
+#include <IndustryStandard/Q35MchIch9.h>\r
+#include <IndustryStandard/QemuCpuHotplug.h>\r
+#include <Library/MemEncryptSevLib.h>\r
+#include <OvmfPlatforms.h>\r
\r
#include "Platform.h"\r
-#include "Cmos.h"\r
-\r
-EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {\r
- { EfiACPIMemoryNVS, 0x004 },\r
- { EfiACPIReclaimMemory, 0x008 },\r
- { EfiReservedMemoryType, 0x004 },\r
- { EfiRuntimeServicesData, 0x024 },\r
- { EfiRuntimeServicesCode, 0x030 },\r
- { EfiBootServicesCode, 0x180 },\r
- { EfiBootServicesData, 0xF00 },\r
- { EfiMaxMemoryType, 0x000 }\r
-};\r
\r
-\r
-EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {\r
+EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {\r
{\r
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
&gEfiPeiMasterBootModePpiGuid,\r
}\r
};\r
\r
-\r
VOID\r
-AddIoMemoryBaseSizeHob (\r
- EFI_PHYSICAL_ADDRESS MemoryBase,\r
- UINT64 MemorySize\r
+MemMapInitialization (\r
+ IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
)\r
{\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_MEMORY_MAPPED_IO,\r
- EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_TESTED,\r
- MemoryBase,\r
- MemorySize\r
- );\r
-}\r
+ RETURN_STATUS PcdStatus;\r
\r
-VOID\r
-AddReservedMemoryBaseSizeHob (\r
- EFI_PHYSICAL_ADDRESS MemoryBase,\r
- UINT64 MemorySize\r
- )\r
-{\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_MEMORY_RESERVED,\r
- EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_TESTED,\r
- MemoryBase,\r
- MemorySize\r
- );\r
-}\r
+ PlatformMemMapInitialization (PlatformInfoHob);\r
\r
-VOID\r
-AddIoMemoryRangeHob (\r
- EFI_PHYSICAL_ADDRESS MemoryBase,\r
- EFI_PHYSICAL_ADDRESS MemoryLimit\r
- )\r
-{\r
- AddIoMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));\r
-}\r
+ if (PlatformInfoHob->HostBridgeDevId == 0xffff /* microvm */) {\r
+ return;\r
+ }\r
\r
+ PcdStatus = PcdSet64S (PcdPciMmio32Base, PlatformInfoHob->PcdPciMmio32Base);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet64S (PcdPciMmio32Size, PlatformInfoHob->PcdPciMmio32Size);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
\r
-VOID\r
-AddMemoryBaseSizeHob (\r
- EFI_PHYSICAL_ADDRESS MemoryBase,\r
- UINT64 MemorySize\r
- )\r
-{\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_SYSTEM_MEMORY,\r
- EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_TESTED,\r
- MemoryBase,\r
- MemorySize\r
- );\r
+ PcdStatus = PcdSet64S (PcdPciIoBase, PlatformInfoHob->PcdPciIoBase);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet64S (PcdPciIoSize, PlatformInfoHob->PcdPciIoSize);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
}\r
\r
-\r
+STATIC\r
VOID\r
-AddMemoryRangeHob (\r
- EFI_PHYSICAL_ADDRESS MemoryBase,\r
- EFI_PHYSICAL_ADDRESS MemoryLimit\r
+NoexecDxeInitialization (\r
+ IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
)\r
{\r
- AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));\r
+ RETURN_STATUS Status;\r
+\r
+ Status = PlatformNoexecDxeInitialization (PlatformInfoHob);\r
+ if (!RETURN_ERROR (Status)) {\r
+ Status = PcdSetBoolS (PcdSetNxForStack, PlatformInfoHob->PcdSetNxForStack);\r
+ ASSERT_RETURN_ERROR (Status);\r
+ }\r
}\r
\r
+static const UINT8 EmptyFdt[] = {\r
+ 0xd0, 0x0d, 0xfe, 0xed, 0x00, 0x00, 0x00, 0x48,\r
+ 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x48,\r
+ 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x11,\r
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\r
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\r
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,\r
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09,\r
+};\r
\r
VOID\r
-AddUntestedMemoryBaseSizeHob (\r
- EFI_PHYSICAL_ADDRESS MemoryBase,\r
- UINT64 MemorySize\r
+MicrovmInitialization (\r
+ VOID\r
)\r
{\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_SYSTEM_MEMORY,\r
- EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE,\r
- MemoryBase,\r
- MemorySize\r
- );\r
-}\r
+ FIRMWARE_CONFIG_ITEM FdtItem;\r
+ UINTN FdtSize;\r
+ UINTN FdtPages;\r
+ EFI_STATUS Status;\r
+ UINT64 *FdtHobData;\r
+ VOID *NewBase;\r
+\r
+ Status = QemuFwCfgFindFile ("etc/fdt", &FdtItem, &FdtSize);\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg, using dummy\n", __FUNCTION__));\r
+ FdtItem = 0;\r
+ FdtSize = sizeof (EmptyFdt);\r
+ }\r
\r
+ FdtPages = EFI_SIZE_TO_PAGES (FdtSize);\r
+ NewBase = AllocatePages (FdtPages);\r
+ if (NewBase == NULL) {\r
+ DEBUG ((DEBUG_INFO, "%a: AllocatePages failed\n", __FUNCTION__));\r
+ return;\r
+ }\r
\r
-VOID\r
-AddUntestedMemoryRangeHob (\r
- EFI_PHYSICAL_ADDRESS MemoryBase,\r
- EFI_PHYSICAL_ADDRESS MemoryLimit\r
- )\r
-{\r
- AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));\r
+ if (FdtItem) {\r
+ QemuFwCfgSelectItem (FdtItem);\r
+ QemuFwCfgReadBytes (FdtSize, NewBase);\r
+ } else {\r
+ CopyMem (NewBase, EmptyFdt, FdtSize);\r
+ }\r
+\r
+ FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData));\r
+ if (FdtHobData == NULL) {\r
+ DEBUG ((DEBUG_INFO, "%a: BuildGuidHob failed\n", __FUNCTION__));\r
+ return;\r
+ }\r
+\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "%a: fdt at 0x%x (size %d)\n",\r
+ __FUNCTION__,\r
+ NewBase,\r
+ FdtSize\r
+ ));\r
+ *FdtHobData = (UINTN)NewBase;\r
}\r
\r
VOID\r
-MemMapInitialization (\r
- VOID\r
+MiscInitializationForMicrovm (\r
+ IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
)\r
{\r
- //\r
- // Create Memory Type Information HOB\r
- //\r
- BuildGuidDataHob (\r
- &gEfiMemoryTypeInformationGuid,\r
- mDefaultMemoryTypeInformation,\r
- sizeof(mDefaultMemoryTypeInformation)\r
- );\r
+ RETURN_STATUS PcdStatus;\r
\r
+ ASSERT (PlatformInfoHob->HostBridgeDevId == 0xffff);\r
+\r
+ DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__));\r
//\r
- // Add PCI IO Port space available for PCI resource allocations.\r
+ // Disable A20 Mask\r
//\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_IO,\r
- EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED,\r
- 0xC000,\r
- 0x4000\r
- );\r
+ IoOr8 (0x92, BIT1);\r
\r
//\r
- // Video memory + Legacy BIOS region\r
+ // Build the CPU HOB with guest RAM size dependent address width and 16-bits\r
+ // of IO space. (Side note: unlike other HOBs, the CPU HOB is needed during\r
+ // S3 resume as well, so we build it unconditionally.)\r
//\r
- AddIoMemoryRangeHob (0x0A0000, BASE_1MB);\r
-\r
- if (!mXen) {\r
- UINT32 TopOfLowRam;\r
- TopOfLowRam = GetSystemMemorySizeBelow4gb ();\r
-\r
- //\r
- // address purpose size\r
- // ------------ -------- -------------------------\r
- // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g)\r
- // 0xFC000000 gap 44 MB\r
- // 0xFEC00000 IO-APIC 4 KB\r
- // 0xFEC01000 gap 1020 KB\r
- // 0xFED00000 HPET 1 KB\r
- // 0xFED00400 gap 1023 KB\r
- // 0xFEE00000 LAPIC 1 MB\r
- //\r
- AddIoMemoryRangeHob (TopOfLowRam < BASE_2GB ?\r
- BASE_2GB : TopOfLowRam, 0xFC000000);\r
- AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);\r
- AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);\r
- AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB);\r
- }\r
+ BuildCpuHob (PlatformInfoHob->PhysMemAddressWidth, 16);\r
+\r
+ MicrovmInitialization ();\r
+ PcdStatus = PcdSet16S (\r
+ PcdOvmfHostBridgePciDevId,\r
+ MICROVM_PSEUDO_DEVICE_ID\r
+ );\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
}\r
\r
-\r
VOID\r
MiscInitialization (\r
- VOID\r
+ IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
)\r
{\r
- //\r
- // Disable A20 Mask\r
- //\r
- IoOr8 (0x92, BIT1);\r
+ RETURN_STATUS PcdStatus;\r
\r
- //\r
- // Build the CPU hob with 36-bit addressing and 16-bits of IO space.\r
- //\r
- BuildCpuHob (36, 16);\r
+ PlatformMiscInitialization (PlatformInfoHob);\r
\r
- //\r
- // If PMREGMISC/PMIOSE is set, assume the ACPI PMBA has been configured (for\r
- // example by Xen) and skip the setup here. This matches the logic in\r
- // AcpiTimerLibConstructor ().\r
- //\r
- if ((PciRead8 (PCI_LIB_ADDRESS (0, 1, 3, 0x80)) & 0x01) == 0) {\r
- //\r
- // The PEI phase should be exited with fully accessibe PIIX4 IO space:\r
- // 1. set PMBA\r
- //\r
- PciAndThenOr32 (\r
- PCI_LIB_ADDRESS (0, 1, 3, 0x40),\r
- (UINT32) ~0xFFC0,\r
- PcdGet16 (PcdAcpiPmBaseAddress)\r
- );\r
-\r
- //\r
- // 2. set PCICMD/IOSE\r
- //\r
- PciOr8 (\r
- PCI_LIB_ADDRESS (0, 1, 3, PCI_COMMAND_OFFSET),\r
- EFI_PCI_COMMAND_IO_SPACE\r
- );\r
-\r
- //\r
- // 3. set PMREGMISC/PMIOSE\r
- //\r
- PciOr8 (PCI_LIB_ADDRESS (0, 1, 3, 0x80), 0x01);\r
- }\r
+ PcdStatus = PcdSet16S (PcdOvmfHostBridgePciDevId, PlatformInfoHob->HostBridgeDevId);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
}\r
\r
-\r
VOID\r
BootModeInitialization (\r
+ IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+\r
+ if (PlatformCmosRead8 (0xF) == 0xFE) {\r
+ PlatformInfoHob->BootMode = BOOT_ON_S3_RESUME;\r
+ }\r
\r
- Status = PeiServicesSetBootMode (BOOT_WITH_FULL_CONFIGURATION);\r
+ PlatformCmosWrite8 (0xF, 0x00);\r
+\r
+ Status = PeiServicesSetBootMode (PlatformInfoHob->BootMode);\r
ASSERT_EFI_ERROR (Status);\r
\r
Status = PeiServicesInstallPpi (mPpiBootMode);\r
ASSERT_EFI_ERROR (Status);\r
}\r
\r
-\r
VOID\r
ReserveEmuVariableNvStore (\r
)\r
{\r
- EFI_PHYSICAL_ADDRESS VariableStore;\r
+ EFI_PHYSICAL_ADDRESS VariableStore;\r
+ RETURN_STATUS PcdStatus;\r
\r
- //\r
- // Allocate storage for NV variables early on so it will be\r
- // at a consistent address. Since VM memory is preserved\r
- // across reboots, this allows the NV variable storage to survive\r
- // a VM reboot.\r
- //\r
- VariableStore =\r
- (EFI_PHYSICAL_ADDRESS)(UINTN)\r
- AllocateAlignedRuntimePages (\r
- EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)),\r
- PcdGet32 (PcdFlashNvStorageFtwSpareSize)\r
- );\r
- DEBUG ((EFI_D_INFO,\r
- "Reserved variable store memory: 0x%lX; size: %dkb\n",\r
- VariableStore,\r
- (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024\r
- ));\r
- PcdSet64 (PcdEmuVariableNvStoreReserved, VariableStore);\r
-}\r
+ VariableStore = (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore ();\r
+ PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);\r
+\r
+ #ifdef SECURE_BOOT_FEATURE_ENABLED\r
+ PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);\r
+ #endif\r
\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+}\r
\r
+STATIC\r
VOID\r
-DebugDumpCmos (\r
- VOID\r
+S3Verification (\r
+ IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
)\r
{\r
- UINTN Loop;\r
+ #if defined (MDE_CPU_X64)\r
+ if (PlatformInfoHob->SmmSmramRequire && PlatformInfoHob->S3Supported) {\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a: S3Resume2Pei doesn't support X64 PEI + SMM yet.\n",\r
+ __FUNCTION__\r
+ ));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a: Please disable S3 on the QEMU command line (see the README),\n",\r
+ __FUNCTION__\r
+ ));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a: or build OVMF with \"OvmfPkgIa32X64.dsc\".\n",\r
+ __FUNCTION__\r
+ ));\r
+ ASSERT (FALSE);\r
+ CpuDeadLoop ();\r
+ }\r
\r
- DEBUG ((EFI_D_INFO, "CMOS:\n"));\r
+ #endif\r
+}\r
\r
- for (Loop = 0; Loop < 0x80; Loop++) {\r
- if ((Loop % 0x10) == 0) {\r
- DEBUG ((EFI_D_INFO, "%02x:", Loop));\r
- }\r
- DEBUG ((EFI_D_INFO, " %02x", CmosRead8 (Loop)));\r
- if ((Loop % 0x10) == 0xf) {\r
- DEBUG ((EFI_D_INFO, "\n"));\r
- }\r
+STATIC\r
+VOID\r
+Q35BoardVerification (\r
+ IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
+ )\r
+{\r
+ if (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {\r
+ return;\r
}\r
+\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a: no TSEG (SMRAM) on host bridge DID=0x%04x; "\r
+ "only DID=0x%04x (Q35) is supported\n",\r
+ __FUNCTION__,\r
+ PlatformInfoHob->HostBridgeDevId,\r
+ INTEL_Q35_MCH_DEVICE_ID\r
+ ));\r
+ ASSERT (FALSE);\r
+ CpuDeadLoop ();\r
+}\r
+\r
+/**\r
+ Fetch the boot CPU count and the possible CPU count from QEMU, and expose\r
+ them to UefiCpuPkg modules. Set the MaxCpuCount field in PlatformInfoHob.\r
+**/\r
+VOID\r
+MaxCpuCountInitialization (\r
+ IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
+ )\r
+{\r
+ RETURN_STATUS PcdStatus;\r
+\r
+ PlatformMaxCpuCountInitialization (PlatformInfoHob);\r
+\r
+ PcdStatus = PcdSet32S (PcdCpuBootLogicalProcessorNumber, PlatformInfoHob->PcdCpuBootLogicalProcessorNumber);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet32S (PcdCpuMaxLogicalProcessorNumber, PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
}\r
\r
+/**\r
+ * @brief Builds PlatformInfo Hob\r
+ */\r
+EFI_HOB_PLATFORM_INFO *\r
+BuildPlatformInfoHob (\r
+ VOID\r
+ )\r
+{\r
+ EFI_HOB_PLATFORM_INFO PlatformInfoHob;\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+\r
+ ZeroMem (&PlatformInfoHob, sizeof PlatformInfoHob);\r
+ BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &PlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO));\r
+ GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);\r
+ return (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob);\r
+}\r
\r
/**\r
Perform Platform PEI initialization.\r
IN CONST EFI_PEI_SERVICES **PeiServices\r
)\r
{\r
- DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n"));\r
+ EFI_HOB_PLATFORM_INFO *PlatformInfoHob;\r
+ EFI_STATUS Status;\r
+\r
+ DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));\r
+ PlatformInfoHob = BuildPlatformInfoHob ();\r
+\r
+ PlatformInfoHob->SmmSmramRequire = FeaturePcdGet (PcdSmmSmramRequire);\r
+ PlatformInfoHob->SevEsIsEnabled = MemEncryptSevEsIsEnabled ();\r
+ PlatformInfoHob->PcdPciMmio64Size = PcdGet64 (PcdPciMmio64Size);\r
+ PlatformInfoHob->DefaultMaxCpuNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);\r
\r
- DebugDumpCmos ();\r
+ PlatformDebugDumpCmos ();\r
\r
- XenDetect ();\r
+ if (QemuFwCfgS3Enabled ()) {\r
+ DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n"));\r
+ PlatformInfoHob->S3Supported = TRUE;\r
+ Status = PcdSetBoolS (PcdAcpiS3Enable, TRUE);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
\r
- BootModeInitialization ();\r
+ S3Verification (PlatformInfoHob);\r
+ BootModeInitialization (PlatformInfoHob);\r
\r
- PublishPeiMemory ();\r
+ //\r
+ // Query Host Bridge DID\r
+ //\r
+ PlatformInfoHob->HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r
+ AddressWidthInitialization (PlatformInfoHob);\r
\r
- InitializeRamRegions ();\r
+ MaxCpuCountInitialization (PlatformInfoHob);\r
\r
- if (mXen) {\r
- DEBUG ((EFI_D_INFO, "Xen was detected\n"));\r
- InitializeXen ();\r
+ if (PlatformInfoHob->SmmSmramRequire) {\r
+ Q35BoardVerification (PlatformInfoHob);\r
+ Q35TsegMbytesInitialization (PlatformInfoHob);\r
+ Q35SmramAtDefaultSmbaseInitialization (PlatformInfoHob);\r
}\r
\r
- ReserveEmuVariableNvStore ();\r
+ PublishPeiMemory (PlatformInfoHob);\r
\r
- PeiFvInitialization ();\r
+ PlatformQemuUc32BaseInitialization (PlatformInfoHob);\r
\r
- MemMapInitialization ();\r
+ InitializeRamRegions (PlatformInfoHob);\r
+\r
+ if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) {\r
+ if (!PlatformInfoHob->SmmSmramRequire) {\r
+ ReserveEmuVariableNvStore ();\r
+ }\r
+\r
+ PeiFvInitialization (PlatformInfoHob);\r
+ MemTypeInfoInitialization (PlatformInfoHob);\r
+ MemMapInitialization (PlatformInfoHob);\r
+ NoexecDxeInitialization (PlatformInfoHob);\r
+ }\r
+\r
+ InstallClearCacheCallback ();\r
+ AmdSevInitialize (PlatformInfoHob);\r
+ if (PlatformInfoHob->HostBridgeDevId == 0xffff) {\r
+ MiscInitializationForMicrovm (PlatformInfoHob);\r
+ } else {\r
+ MiscInitialization (PlatformInfoHob);\r
+ }\r
\r
- MiscInitialization ();\r
+ IntelTdxInitialize ();\r
+ InstallFeatureControlCallback ();\r
\r
return EFI_SUCCESS;\r
}\r