X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=OvmfPkg%2FPlatformPei%2FPlatform.c;h=01460639b1d399d15bce5c485d54e2256a0dfb4d;hp=ce149e4f979e2c6589fa383ebc2b4232e9df99dc;hb=869b17ccdc05f7bad76b3dd61ebc6e5d7466e577;hpb=931a0c74ed405a9b61afaa7ce1796f3e656d90b9
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index ce149e4f97..01460639b1 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
@@ -34,6 +34,10 @@
#include
#include
#include
+#include
+#include
+#include
+#include
#include "Platform.h"
#include "Cmos.h"
@@ -163,6 +167,74 @@ AddUntestedMemoryRangeHob (
AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
}
+VOID
+XenMemMapInitialization (
+ VOID
+ )
+{
+ EFI_E820_ENTRY64 *E820Map;
+ UINT32 E820EntriesCount;
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n"));
+
+ //
+ // Create Memory Type Information HOB
+ //
+ BuildGuidDataHob (
+ &gEfiMemoryTypeInformationGuid,
+ mDefaultMemoryTypeInformation,
+ sizeof(mDefaultMemoryTypeInformation)
+ );
+
+ //
+ // Add PCI IO Port space available for PCI resource allocations.
+ //
+ BuildResourceDescriptorHob (
+ EFI_RESOURCE_IO,
+ EFI_RESOURCE_ATTRIBUTE_PRESENT |
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED,
+ 0xC000,
+ 0x4000
+ );
+
+ //
+ // Video memory + Legacy BIOS region
+ //
+ AddIoMemoryRangeHob (0x0A0000, BASE_1MB);
+
+ //
+ // Parse RAM in E820 map
+ //
+ Status = XenGetE820Map(&E820Map, &E820EntriesCount);
+
+ ASSERT_EFI_ERROR (Status);
+
+ if (E820EntriesCount > 0) {
+ EFI_E820_ENTRY64 *Entry;
+ UINT32 Loop;
+
+ for (Loop = 0; Loop < E820EntriesCount; Loop++) {
+ Entry = E820Map + Loop;
+
+ //
+ // Only care about RAM
+ //
+ if (Entry->Type != EfiAcpiAddressRangeMemory) {
+ continue;
+ }
+
+ if (Entry->BaseAddr >= BASE_4GB) {
+ AddUntestedMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
+ } else {
+ AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
+ }
+
+ MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, CacheWriteBack);
+ }
+ }
+}
+
VOID
MemMapInitialization (
@@ -214,7 +286,7 @@ MemMapInitialization (
VOID
MiscInitialization (
- BOOLEAN Xen
+ VOID
)
{
//
@@ -227,7 +299,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
@@ -282,8 +359,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 +409,43 @@ InitializePlatform (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS TopOfMemory;
- BOOLEAN Xen;
+ UINT32 XenLeaf;
+
+ TopOfMemory = 0;
DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n"));
DebugDumpCmos ();
- TopOfMemory = MemDetect ();
+ XenLeaf = XenDetect ();
+
+ BootModeInitialization ();
+
+ PublishPeiMemory ();
+
+ if (XenLeaf != 0) {
+ PcdSetBool (PcdPciDisableBusEnumeration, TRUE);
+ } else {
+ TopOfMemory = MemDetect ();
+ }
- Status = InitializeXen ();
- Xen = EFI_ERROR (Status) ? FALSE : TRUE;
+ if (XenLeaf != 0) {
+ DEBUG ((EFI_D_INFO, "Xen was detected\n"));
+ InitializeXen (XenLeaf);
+ }
ReserveEmuVariableNvStore ();
PeiFvInitialization ();
- MemMapInitialization (TopOfMemory);
-
- MiscInitialization (Xen);
+ if (XenLeaf != 0) {
+ XenMemMapInitialization ();
+ } else {
+ MemMapInitialization (TopOfMemory);
+ }
- BootModeInitialization ();
+ MiscInitialization ();
return EFI_SUCCESS;
}