X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=OvmfPkg%2FPlatformPei%2FXen.c;h=89dc4143b23b6fa060ca216ca8211b2b73d65a2c;hb=b0663641c977f97bef785c86978603c3a31a3d1c;hp=0f75fa798320a4bdd8a81c38ca31d63e5678a1e3;hpb=b621bb0a3ce81cabc31e28e055e3206068d5aa77;p=mirror_edk2.git
diff --git a/OvmfPkg/PlatformPei/Xen.c b/OvmfPkg/PlatformPei/Xen.c
index 0f75fa7983..89dc4143b2 100644
--- a/OvmfPkg/PlatformPei/Xen.c
+++ b/OvmfPkg/PlatformPei/Xen.c
@@ -1,16 +1,10 @@
/**@file
Xen Platform PEI support
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
Copyright (c) 2011, Andrei Warkentin
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -27,12 +21,17 @@
#include
#include
#include
+#include
+#include
+#include
#include "Platform.h"
#include "Xen.h"
BOOLEAN mXen = FALSE;
+STATIC UINT32 mXenLeaf = 0;
+
EFI_XEN_INFO mXenInfo;
/**
@@ -114,33 +113,85 @@ XenConnect (
/**
Figures out if we are running inside Xen HVM.
- @return UINT32 CPUID index used to connect to HV.
+ @retval TRUE Xen was detected
+ @retval FALSE Xen was not detected
**/
-UINT32
+BOOLEAN
XenDetect (
VOID
)
{
-
- UINT32 XenLeaf;
UINT8 Signature[13];
- for (XenLeaf = 0x40000000; XenLeaf < 0x40010000; XenLeaf += 0x100) {
- AsmCpuid (XenLeaf, NULL, (UINT32 *) &Signature[0],
+ if (mXenLeaf != 0) {
+ return TRUE;
+ }
+
+ Signature[12] = '\0';
+ for (mXenLeaf = 0x40000000; mXenLeaf < 0x40010000; mXenLeaf += 0x100) {
+ AsmCpuid (mXenLeaf,
+ NULL,
+ (UINT32 *) &Signature[0],
(UINT32 *) &Signature[4],
(UINT32 *) &Signature[8]);
- Signature[12] = '\0';
if (!AsciiStrCmp ((CHAR8 *) Signature, "XenVMMXenVMM")) {
mXen = TRUE;
- return XenLeaf;
+ return TRUE;
}
}
- return 0;
+ mXenLeaf = 0;
+ return FALSE;
}
+
+VOID
+XenPublishRamRegions (
+ VOID
+ )
+{
+ EFI_E820_ENTRY64 *E820Map;
+ UINT32 E820EntriesCount;
+ EFI_STATUS Status;
+
+ if (!mXen) {
+ return;
+ }
+
+ DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n"));
+
+ //
+ // Parse RAM in E820 map
+ //
+ E820EntriesCount = 0;
+ 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;
+ }
+
+ AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
+
+ MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, CacheWriteBack);
+ }
+ }
+}
+
+
/**
Perform Xen PEI initialization.
@@ -150,16 +201,25 @@ XenDetect (
**/
EFI_STATUS
InitializeXen (
- UINT32 XenLeaf
+ VOID
)
{
- XenConnect (XenLeaf);
+ RETURN_STATUS PcdStatus;
+
+ if (mXenLeaf == 0) {
+ return EFI_NOT_FOUND;
+ }
+
+ XenConnect (mXenLeaf);
//
// Reserve away HVMLOADER reserved memory [0xFC000000,0xFD000000).
// This needs to match HVMLOADER RESERVED_MEMBASE/RESERVED_MEMSIZE.
//
- AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000);
+ AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000, FALSE);
+
+ PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE);
+ ASSERT_RETURN_ERROR (PcdStatus);
return EFI_SUCCESS;
}