diff options
Diffstat (limited to 'OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c')
-rw-r--r-- | OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c | 147 |
1 files changed, 2 insertions, 145 deletions
diff --git a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c index 7d324cb815..938b77cdc6 100644 --- a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c +++ b/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c @@ -14,160 +14,17 @@ **/
-#include <Base.h>
-#include <Library/TimerLib.h>
-#include <Library/BaseLib.h>
-#include <Library/IoLib.h>
-#include <Library/PciLib.h>
#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <IndustryStandard/Pci22.h>
+#include <Library/BaseLib.h>
#include <IndustryStandard/Acpi.h>
-//
-// PCI Location of PIIX4 Power Management PCI Configuration Registers
-//
-#define PIIX4_POWER_MANAGEMENT_BUS 0x00
-#define PIIX4_POWER_MANAGEMENT_DEVICE 0x01
-#define PIIX4_POWER_MANAGEMENT_FUNCTION 0x03
-
-//
-// Macro to access PIIX4 Power Management PCI Configuration Registers
-//
-#define PIIX4_PCI_POWER_MANAGEMENT_REGISTER(Register) \
- PCI_LIB_ADDRESS ( \
- PIIX4_POWER_MANAGEMENT_BUS, \
- PIIX4_POWER_MANAGEMENT_DEVICE, \
- PIIX4_POWER_MANAGEMENT_FUNCTION, \
- Register \
- )
-
-//
-// PCI Location of Q35 Power Management PCI Configuration Registers
-//
-#define Q35_POWER_MANAGEMENT_BUS 0x00
-#define Q35_POWER_MANAGEMENT_DEVICE 0x1f
-#define Q35_POWER_MANAGEMENT_FUNCTION 0x00
-
-//
-// Macro to access Q35 Power Management PCI Configuration Registers
-//
-#define Q35_PCI_POWER_MANAGEMENT_REGISTER(Register) \
- PCI_LIB_ADDRESS ( \
- Q35_POWER_MANAGEMENT_BUS, \
- Q35_POWER_MANAGEMENT_DEVICE, \
- Q35_POWER_MANAGEMENT_FUNCTION, \
- Register \
- )
-
-//
-// PCI Location of Host Bridge PCI Configuration Registers
-//
-#define HOST_BRIDGE_BUS 0x00
-#define HOST_BRIDGE_DEVICE 0x00
-#define HOST_BRIDGE_FUNCTION 0x00
-
-//
-// Macro to access Host Bridge Configuration Registers
-//
-#define HOST_BRIDGE_REGISTER(Register) \
- PCI_LIB_ADDRESS ( \
- HOST_BRIDGE_BUS, \
- HOST_BRIDGE_DEVICE, \
- HOST_BRIDGE_FUNCTION, \
- Register \
- )
-
-//
-// Host Bridge Device ID (DID) Register
-//
-#define HOST_BRIDGE_DID HOST_BRIDGE_REGISTER (0x02)
-
-//
-// Host Bridge DID Register values
-//
-#define PCI_DEVICE_ID_INTEL_82441 0x1237 // DID value for PIIX4
-#define PCI_DEVICE_ID_INTEL_Q35_MCH 0x29C0 // DID value for Q35
-
-//
-// Access Power Management PCI Config Regs based on Host Bridge type
-//
-#define PCI_POWER_MANAGEMENT_REGISTER(Register) \
- ((PciRead16 (HOST_BRIDGE_DID) == PCI_DEVICE_ID_INTEL_Q35_MCH) ? \
- Q35_PCI_POWER_MANAGEMENT_REGISTER (Register) : \
- PIIX4_PCI_POWER_MANAGEMENT_REGISTER (Register))
-
-//
-// Power Management PCI Configuration Registers
-//
-#define PMBA PCI_POWER_MANAGEMENT_REGISTER (0x40)
-#define PMBA_RTE BIT0
-#define PMREGMISC PCI_POWER_MANAGEMENT_REGISTER (0x80)
-#define PMIOSE BIT0
+#include "AcpiTimerLib.h"
//
// The ACPI Time is a 24-bit counter
//
#define ACPI_TIMER_COUNT_SIZE BIT24
-//
-// Offset in the Power Management Base Address to the ACPI Timer
-//
-#define ACPI_TIMER_OFFSET 0x8
-
-/**
- The constructor function enables ACPI IO space.
-
- If ACPI I/O space not enabled, this function will enable it.
- It will always return RETURN_SUCCESS.
-
- @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
-
-**/
-RETURN_STATUS
-EFIAPI
-AcpiTimerLibConstructor (
- VOID
- )
-{
- //
- // Check to see if the Power Management Base Address is already enabled
- //
- if ((PciRead8 (PMREGMISC) & PMIOSE) == 0) {
- //
- // If the Power Management Base Address is not programmed,
- // then program the Power Management Base Address from a PCD.
- //
- PciAndThenOr32 (PMBA, (UINT32)(~0x0000FFC0), PcdGet16 (PcdAcpiPmBaseAddress));
-
- //
- // Enable PMBA I/O port decodes in PMREGMISC
- //
- PciOr8 (PMREGMISC, PMIOSE);
- }
-
- return RETURN_SUCCESS;
-}
-
-/**
- Internal function to read the current tick counter of ACPI.
-
- Internal function to read the current tick counter of ACPI.
-
- @return The tick counter read.
-
-**/
-UINT32
-InternalAcpiGetTimerTick (
- VOID
- )
-{
- //
- // Read PMBA to read and return the current ACPI timer value.
- //
- return IoRead32 ((PciRead32 (PMBA) & ~PMBA_RTE) + ACPI_TIMER_OFFSET);
-}
-
/**
Stalls the CPU for at least the given number of ticks.
|