From: jljusten Date: Wed, 27 Jul 2011 15:13:54 +0000 (+0000) Subject: OvmfPkg/Library/AcpiTimerLib: Modified to support Xen HVM X-Git-Tag: edk2-stable201903~14472 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=550486ed3be702a9bd759fedd4e23e4d89c58432 OvmfPkg/Library/AcpiTimerLib: Modified to support Xen HVM If PIIX4 Power Management Base Address (PMBA) is already programmed, then read and use it's current setting. Signed-off-by: Andrei Warkentin Reviewed-by: gavinguan Signed-off-by: jljusten git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12053 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c index 7f41a869d8..6c5cccc273 100644 --- a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c +++ b/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c @@ -1,7 +1,9 @@ /** @file ACPI Timer implements one instance of Timer Library. - Copyright (c) 2008, Intel Corporation. All rights reserved.
+ Copyright (c) 2008 - 2011, 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 @@ -17,9 +19,17 @@ #include #include #include +#include + +// +// PIIX4 Power Management Base Address +// +UINT32 mPmba = 0x401; +#define PCI_BAR_IO 0x1 #define ACPI_TIMER_FREQUENCY 3579545 #define ACPI_TIMER_COUNT_SIZE 0x01000000 +#define ACPI_TIMER_OFFSET 0x8 /** The constructor function enables ACPI IO space. @@ -41,12 +51,21 @@ AcpiTimerLibConstructor ( Device = 1; // Device = 7; + if (PciRead8 (PCI_LIB_ADDRESS (0,Device,3,0x80)) & 1) { + mPmba = PciRead32 (PCI_LIB_ADDRESS (0,Device,3,0x40)); + ASSERT (mPmba & PCI_BAR_IO); + mPmba &= ~PCI_BAR_IO; + } else { + PciAndThenOr32 (PCI_LIB_ADDRESS (0,Device,3,0x40), + (UINT32) ~0xfc0, mPmba); + PciOr8 (PCI_LIB_ADDRESS (0,Device,3,0x04), 0x01); + } + // // ACPI Timer enable is in Bus 0, Device ?, Function 3 // - PciOr8 (PCI_LIB_ADDRESS (0,Device,3,0x04), 0x01); - PciAndThenOr32 (PCI_LIB_ADDRESS (0,Device,3,0x40), (UINT32) ~0xfc0, 0x400); - PciOr8 (PCI_LIB_ADDRESS (0,Device,3,0x80), 0x01); return RETURN_SUCCESS; + PciOr8 (PCI_LIB_ADDRESS (0,Device,3,0x80), 0x01); + return RETURN_SUCCESS; } /** @@ -63,7 +82,7 @@ InternalAcpiGetTimerTick ( VOID ) { - return IoRead32 (0x408); + return IoRead32 (mPmba + ACPI_TIMER_OFFSET); } /**