X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=OvmfPkg%2FPlatformPei%2FPlatform.c;h=11b4cb7a14800aa75e3f69ba6977092546dfb331;hp=ce149e4f979e2c6589fa383ebc2b4232e9df99dc;hb=bd386eaf86f1f55dd28d2c5b26a8c80b2a9002a8;hpb=931a0c74ed405a9b61afaa7ce1796f3e656d90b9 diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index ce149e4f97..11b4cb7a14 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -1,7 +1,7 @@ /**@file Platform PEI driver - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
Copyright (c) 2011, Andrei Warkentin This program and the accompanying materials @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,11 @@ EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = { }; +EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION; + +BOOLEAN mS3Supported = FALSE; + + VOID AddIoMemoryBaseSizeHob ( EFI_PHYSICAL_ADDRESS MemoryBase, @@ -163,10 +169,9 @@ AddUntestedMemoryRangeHob ( AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase)); } - VOID MemMapInitialization ( - EFI_PHYSICAL_ADDRESS TopOfMemory + VOID ) { // @@ -194,27 +199,33 @@ MemMapInitialization ( // AddIoMemoryRangeHob (0x0A0000, BASE_1MB); - // - // address purpose size - // ------------ -------- ------------------------- - // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g) - // 0xFC000000 gap 44 MB - // 0xFEC00000 IO-APIC 4 KB - // 0xFEC01000 gap 1020 KB - // 0xFED00000 HPET 1 KB - // 0xFED00400 gap 1023 KB - // 0xFEE00000 LAPIC 1 MB - // - AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory, 0xFC000000); - AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB); - AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB); - AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB); + if (!mXen) { + UINT32 TopOfLowRam; + TopOfLowRam = GetSystemMemorySizeBelow4gb (); + + // + // address purpose size + // ------------ -------- ------------------------- + // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g) + // 0xFC000000 gap 44 MB + // 0xFEC00000 IO-APIC 4 KB + // 0xFEC01000 gap 1020 KB + // 0xFED00000 HPET 1 KB + // 0xFED00400 gap 1023 KB + // 0xFEE00000 LAPIC 1 MB + // + AddIoMemoryRangeHob (TopOfLowRam < BASE_2GB ? + BASE_2GB : TopOfLowRam, 0xFC000000); + AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB); + AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB); + AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB); + } } VOID MiscInitialization ( - BOOLEAN Xen + VOID ) { // @@ -227,7 +238,12 @@ MiscInitialization ( // BuildCpuHob (36, 16); - if (!Xen) { + // + // If PMREGMISC/PMIOSE is set, assume the ACPI PMBA has been configured (for + // example by Xen) and skip the setup here. This matches the logic in + // AcpiTimerLibConstructor (). + // + if ((PciRead8 (PCI_LIB_ADDRESS (0, 1, 3, 0x80)) & 0x01) == 0) { // // The PEI phase should be exited with fully accessibe PIIX4 IO space: // 1. set PMBA @@ -256,11 +272,16 @@ MiscInitialization ( VOID BootModeInitialization ( + VOID ) { - EFI_STATUS Status; + EFI_STATUS Status; + + if (CmosRead8 (0xF) == 0xFE) { + mBootMode = BOOT_ON_S3_RESUME; + } - Status = PeiServicesSetBootMode (BOOT_WITH_FULL_CONFIGURATION); + Status = PeiServicesSetBootMode (mBootMode); ASSERT_EFI_ERROR (Status); Status = PeiServicesInstallPpi (mPpiBootMode); @@ -282,8 +303,9 @@ ReserveEmuVariableNvStore ( // VariableStore = (EFI_PHYSICAL_ADDRESS)(UINTN) - AllocateRuntimePool ( - 2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize) + AllocateAlignedRuntimePages ( + EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)), + PcdGet32 (PcdFlashNvStorageFtwSpareSize) ); DEBUG ((EFI_D_INFO, "Reserved variable store memory: 0x%lX; size: %dkb\n", @@ -331,28 +353,37 @@ InitializePlatform ( IN CONST EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS TopOfMemory; - BOOLEAN Xen; - DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n")); DebugDumpCmos (); - TopOfMemory = MemDetect (); + XenDetect (); - Status = InitializeXen (); - Xen = EFI_ERROR (Status) ? FALSE : TRUE; + if (QemuFwCfgS3Enabled ()) { + DEBUG ((EFI_D_INFO, "S3 support was detected on QEMU\n")); + mS3Supported = TRUE; + } - ReserveEmuVariableNvStore (); + BootModeInitialization (); - PeiFvInitialization (); + PublishPeiMemory (); - MemMapInitialization (TopOfMemory); + InitializeRamRegions (); - MiscInitialization (Xen); + if (mXen) { + DEBUG ((EFI_D_INFO, "Xen was detected\n")); + InitializeXen (); + } - BootModeInitialization (); + if (mBootMode != BOOT_ON_S3_RESUME) { + ReserveEmuVariableNvStore (); + + PeiFvInitialization (); + + MemMapInitialization (); + } + + MiscInitialization (); return EFI_SUCCESS; }