\r
**/\r
\r
-#include <Base.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/PciLib.h>\r
#include <Library/DebugLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <IndustryStandard/Pci22.h>\r
+#include <Library/BaseLib.h>\r
#include <IndustryStandard/Acpi.h>\r
\r
-//\r
-// PCI Location of PIIX4 Power Management PCI Configuration Registers\r
-//\r
-#define PIIX4_POWER_MANAGEMENT_BUS 0x00\r
-#define PIIX4_POWER_MANAGEMENT_DEVICE 0x01\r
-#define PIIX4_POWER_MANAGEMENT_FUNCTION 0x03\r
-\r
-//\r
-// Macro to access PIIX4 Power Management PCI Configuration Registers\r
-//\r
-#define PIIX4_PCI_POWER_MANAGEMENT_REGISTER(Register) \\r
- PCI_LIB_ADDRESS ( \\r
- PIIX4_POWER_MANAGEMENT_BUS, \\r
- PIIX4_POWER_MANAGEMENT_DEVICE, \\r
- PIIX4_POWER_MANAGEMENT_FUNCTION, \\r
- Register \\r
- )\r
-\r
-//\r
-// PCI Location of Q35 Power Management PCI Configuration Registers\r
-//\r
-#define Q35_POWER_MANAGEMENT_BUS 0x00\r
-#define Q35_POWER_MANAGEMENT_DEVICE 0x1f\r
-#define Q35_POWER_MANAGEMENT_FUNCTION 0x00\r
-\r
-//\r
-// Macro to access Q35 Power Management PCI Configuration Registers\r
-//\r
-#define Q35_PCI_POWER_MANAGEMENT_REGISTER(Register) \\r
- PCI_LIB_ADDRESS ( \\r
- Q35_POWER_MANAGEMENT_BUS, \\r
- Q35_POWER_MANAGEMENT_DEVICE, \\r
- Q35_POWER_MANAGEMENT_FUNCTION, \\r
- Register \\r
- )\r
-\r
-//\r
-// PCI Location of Host Bridge PCI Configuration Registers\r
-//\r
-#define HOST_BRIDGE_BUS 0x00\r
-#define HOST_BRIDGE_DEVICE 0x00\r
-#define HOST_BRIDGE_FUNCTION 0x00\r
-\r
-//\r
-// Macro to access Host Bridge Configuration Registers\r
-//\r
-#define HOST_BRIDGE_REGISTER(Register) \\r
- PCI_LIB_ADDRESS ( \\r
- HOST_BRIDGE_BUS, \\r
- HOST_BRIDGE_DEVICE, \\r
- HOST_BRIDGE_FUNCTION, \\r
- Register \\r
- )\r
-\r
-//\r
-// Host Bridge Device ID (DID) Register\r
-//\r
-#define HOST_BRIDGE_DID HOST_BRIDGE_REGISTER (0x02)\r
-\r
-//\r
-// Host Bridge DID Register values\r
-//\r
-#define PCI_DEVICE_ID_INTEL_82441 0x1237 // DID value for PIIX4\r
-#define PCI_DEVICE_ID_INTEL_Q35_MCH 0x29C0 // DID value for Q35\r
-\r
-//\r
-// Access Power Management PCI Config Regs based on Host Bridge type\r
-//\r
-#define PCI_POWER_MANAGEMENT_REGISTER(Register) \\r
- ((PciRead16 (HOST_BRIDGE_DID) == PCI_DEVICE_ID_INTEL_Q35_MCH) ? \\r
- Q35_PCI_POWER_MANAGEMENT_REGISTER (Register) : \\r
- PIIX4_PCI_POWER_MANAGEMENT_REGISTER (Register))\r
-\r
-//\r
-// Power Management PCI Configuration Registers\r
-//\r
-#define PMBA PCI_POWER_MANAGEMENT_REGISTER (0x40)\r
-#define PMBA_RTE BIT0\r
-#define PMREGMISC PCI_POWER_MANAGEMENT_REGISTER (0x80)\r
-#define PMIOSE BIT0\r
+#include "AcpiTimerLib.h"\r
\r
//\r
// The ACPI Time is a 24-bit counter\r
//\r
#define ACPI_TIMER_COUNT_SIZE BIT24\r
\r
-//\r
-// Offset in the Power Management Base Address to the ACPI Timer\r
-//\r
-#define ACPI_TIMER_OFFSET 0x8\r
-\r
-/**\r
- The constructor function enables ACPI IO space.\r
-\r
- If ACPI I/O space not enabled, this function will enable it.\r
- It will always return RETURN_SUCCESS.\r
-\r
- @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-AcpiTimerLibConstructor (\r
- VOID\r
- )\r
-{\r
- //\r
- // Check to see if the Power Management Base Address is already enabled\r
- //\r
- if ((PciRead8 (PMREGMISC) & PMIOSE) == 0) {\r
- //\r
- // If the Power Management Base Address is not programmed,\r
- // then program the Power Management Base Address from a PCD.\r
- //\r
- PciAndThenOr32 (PMBA, (UINT32)(~0x0000FFC0), PcdGet16 (PcdAcpiPmBaseAddress));\r
-\r
- //\r
- // Enable PMBA I/O port decodes in PMREGMISC\r
- //\r
- PciOr8 (PMREGMISC, PMIOSE);\r
- }\r
- \r
- return RETURN_SUCCESS;\r
-}\r
-\r
-/**\r
- Internal function to read the current tick counter of ACPI.\r
-\r
- Internal function to read the current tick counter of ACPI.\r
-\r
- @return The tick counter read.\r
-\r
-**/\r
-UINT32\r
-InternalAcpiGetTimerTick (\r
- VOID\r
- )\r
-{\r
- //\r
- // Read PMBA to read and return the current ACPI timer value.\r
- //\r
- return IoRead32 ((PciRead32 (PMBA) & ~PMBA_RTE) + ACPI_TIMER_OFFSET);\r
-}\r
-\r
/**\r
Stalls the CPU for at least the given number of ticks.\r
\r
--- /dev/null
+/** @file\r
+ Internal definitions for ACPI Timer Library\r
+\r
+ Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>\r
+\r
+ This program and the accompanying materials are licensed and made\r
+ available under the terms and conditions of the BSD License which\r
+ accompanies this distribution. The full text of the license may\r
+ be found at http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef _ACPI_TIMER_LIB_INTERNAL_H_\r
+#define _ACPI_TIMER_LIB_INTERNAL_H_\r
+\r
+/**\r
+ Internal function to read the current tick counter of ACPI.\r
+\r
+ @return The tick counter read.\r
+\r
+**/\r
+UINT32\r
+InternalAcpiGetTimerTick (\r
+ VOID\r
+ );\r
+\r
+#endif // _ACPI_TIMER_LIB_INTERNAL_H_\r
+++ /dev/null
-## @file\r
-# ACPI Timer Library Instance.\r
-#\r
-# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-##\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = AcpiTimerLib\r
- FILE_GUID = CDD9D74F-213E-4c28-98F7-8B4A167DB936\r
- MODULE_TYPE = BASE\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = TimerLib\r
-\r
- CONSTRUCTOR = AcpiTimerLibConstructor\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
- AcpiTimerLib.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- OvmfPkg/OvmfPkg.dec\r
-\r
-[Pcd]\r
- gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress\r
-\r
-[LibraryClasses]\r
- BaseLib\r
- PciLib\r
- IoLib\r
--- /dev/null
+/** @file\r
+ Provide constructor and GetTick for Base instance of ACPI Timer Library\r
+\r
+ Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>\r
+\r
+ This program and the accompanying materials are licensed and made\r
+ available under the terms and conditions of the BSD License which\r
+ accompanies this distribution. The full text of the license may\r
+ be found at http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/PciLib.h>\r
+#include <OvmfPlatforms.h>\r
+\r
+//\r
+// Power Management PCI Configuration Register fields\r
+//\r
+#define PMBA_RTE BIT0\r
+\r
+//\r
+// Offset in the Power Management Base Address to the ACPI Timer\r
+//\r
+#define ACPI_TIMER_OFFSET 0x8\r
+\r
+//\r
+// Cached ACPI Timer IO Address\r
+//\r
+STATIC UINT32 mAcpiTimerIoAddr;\r
+\r
+/**\r
+ The constructor function caches the ACPI tick counter address\r
+\r
+ At the time this constructor runs (DXE_CORE or later), ACPI IO space\r
+ has already been enabled by either PlatformPei or by the "Base"\r
+ instance of this library.\r
+ In order to avoid querying the underlying platform type during each\r
+ tick counter read operation, we cache the counter address during\r
+ initialization of this instance of the Timer Library.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AcpiTimerLibConstructor (\r
+ VOID\r
+ )\r
+{\r
+ UINT16 HostBridgeDevId;\r
+ UINTN Pmba;\r
+\r
+ //\r
+ // Query Host Bridge DID to determine platform type\r
+ //\r
+ HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r
+ switch (HostBridgeDevId) {\r
+ case INTEL_82441_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_PIIX4 (0x40);\r
+ break;\r
+ case INTEL_Q35_MCH_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_Q35 (0x40);\r
+ break;\r
+ default:\r
+ DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",\r
+ __FUNCTION__, HostBridgeDevId));\r
+ ASSERT (FALSE);\r
+ return RETURN_UNSUPPORTED;\r
+ }\r
+\r
+ mAcpiTimerIoAddr = (PciRead32 (Pmba) & ~PMBA_RTE) + ACPI_TIMER_OFFSET;\r
+\r
+ return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+ Internal function to read the current tick counter of ACPI.\r
+\r
+ Read the current ACPI tick counter using the counter address cached\r
+ by this instance's constructor.\r
+\r
+ @return The tick counter read.\r
+\r
+**/\r
+UINT32\r
+InternalAcpiGetTimerTick (\r
+ VOID\r
+ )\r
+{\r
+ //\r
+ // Return the current ACPI timer value.\r
+ //\r
+ return IoRead32 (mAcpiTimerIoAddr);\r
+}\r
--- /dev/null
+## @file\r
+# Base ACPI Timer Library Instance.\r
+#\r
+# Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>\r
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.\r
+#\r
+# This program and the accompanying materials are licensed and made\r
+# available under the terms and conditions of the BSD License which\r
+# accompanies this distribution. The full text of the license may\r
+# be found at http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = BaseAcpiTimerLib\r
+ FILE_GUID = FB648CF5-91BE-4737-9023-FD807AC6D96D\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = TimerLib|DXE_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION SMM_CORE\r
+ CONSTRUCTOR = AcpiTimerLibConstructor\r
+\r
+[Sources]\r
+ AcpiTimerLib.c\r
+ BaseAcpiTimerLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ PciLib\r
+ IoLib\r
--- /dev/null
+/** @file\r
+ Provide constructor and GetTick for BaseRom instance of ACPI Timer Library\r
+\r
+ Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.\r
+ Copyright (c) 2011, Andrei Warkentin <andreiw@motorola.com>\r
+\r
+ This program and the accompanying materials are licensed and made\r
+ available under the terms and conditions of the BSD License which\r
+ accompanies this distribution. The full text of the license may\r
+ be found at http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/PciLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <OvmfPlatforms.h>\r
+\r
+//\r
+// Power Management PCI Configuration Register fields\r
+//\r
+#define PMBA_RTE BIT0\r
+#define PMIOSE BIT0\r
+\r
+//\r
+// Offset in the Power Management Base Address to the ACPI Timer\r
+//\r
+#define ACPI_TIMER_OFFSET 0x8\r
+\r
+/**\r
+ The constructor function enables ACPI IO space.\r
+\r
+ If ACPI I/O space not enabled, this function will enable it.\r
+ It will always return RETURN_SUCCESS.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AcpiTimerLibConstructor (\r
+ VOID\r
+ )\r
+{\r
+ UINT16 HostBridgeDevId;\r
+ UINTN Pmba;\r
+ UINTN PmRegMisc;\r
+\r
+ //\r
+ // Query Host Bridge DID to determine platform type\r
+ //\r
+ HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r
+ switch (HostBridgeDevId) {\r
+ case INTEL_82441_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_PIIX4 (0x40);\r
+ PmRegMisc = POWER_MGMT_REGISTER_PIIX4 (0x80);\r
+ break;\r
+ case INTEL_Q35_MCH_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_Q35 (0x40);\r
+ PmRegMisc = POWER_MGMT_REGISTER_Q35 (0x80);\r
+ break;\r
+ default:\r
+ DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",\r
+ __FUNCTION__, HostBridgeDevId));\r
+ ASSERT (FALSE);\r
+ return RETURN_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Check to see if the Power Management Base Address is already enabled\r
+ //\r
+ if ((PciRead8 (PmRegMisc) & PMIOSE) == 0) {\r
+ //\r
+ // If the Power Management Base Address is not programmed,\r
+ // then program the Power Management Base Address from a PCD.\r
+ //\r
+ PciAndThenOr32 (Pmba, (UINT32) ~0xFFC0, PcdGet16 (PcdAcpiPmBaseAddress));\r
+\r
+ //\r
+ // Enable PMBA I/O port decodes in PMREGMISC\r
+ //\r
+ PciOr8 (PmRegMisc, PMIOSE);\r
+ }\r
+\r
+ return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+ Internal function to read the current tick counter of ACPI.\r
+\r
+ Dynamically compute the address of the ACPI tick counter based on the\r
+ properties of the underlying platform, to avoid relying on global variables.\r
+\r
+ @return The tick counter read.\r
+\r
+**/\r
+UINT32\r
+InternalAcpiGetTimerTick (\r
+ VOID\r
+ )\r
+{\r
+ UINT16 HostBridgeDevId;\r
+ UINTN Pmba;\r
+\r
+ //\r
+ // Query Host Bridge DID to determine platform type\r
+ //\r
+ HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r
+ switch (HostBridgeDevId) {\r
+ case INTEL_82441_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_PIIX4 (0x40);\r
+ break;\r
+ case INTEL_Q35_MCH_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_Q35 (0x40);\r
+ break;\r
+ default:\r
+ DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",\r
+ __FUNCTION__, HostBridgeDevId));\r
+ ASSERT (FALSE);\r
+ return 0;\r
+ }\r
+\r
+ //\r
+ // Read PMBA to read and return the current ACPI timer value.\r
+ //\r
+ return IoRead32 ((PciRead32 (Pmba) & ~PMBA_RTE) + ACPI_TIMER_OFFSET);\r
+}\r
--- /dev/null
+## @file\r
+# BaseRom ACPI Timer Library Instance.\r
+#\r
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.\r
+#\r
+# This program and the accompanying materials are licensed and made\r
+# available under the terms and conditions of the BSD License which\r
+# accompanies this distribution. The full text of the license may\r
+# be found at http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = BaseRomAcpiTimerLib\r
+ FILE_GUID = CDD9D74F-213E-4c28-98F7-8B4A167DB936\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = TimerLib|SEC PEI_CORE PEIM\r
+ CONSTRUCTOR = AcpiTimerLibConstructor\r
+\r
+[Sources]\r
+ AcpiTimerLib.c\r
+ BaseRomAcpiTimerLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
+\r
+[Pcd]\r
+ gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ PciLib\r
+ IoLib\r
--- /dev/null
+/** @file\r
+ Provide constructor and GetTick for Dxe instance of ACPI Timer Library\r
+\r
+ Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>\r
+\r
+ This program and the accompanying materials are licensed and made\r
+ available under the terms and conditions of the BSD License which\r
+ accompanies this distribution. The full text of the license may\r
+ be found at http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PciLib.h>\r
+#include <OvmfPlatforms.h>\r
+\r
+//\r
+// Power Management PCI Configuration Register fields\r
+//\r
+#define PMBA_RTE BIT0\r
+\r
+//\r
+// Offset in the Power Management Base Address to the ACPI Timer\r
+//\r
+#define ACPI_TIMER_OFFSET 0x8\r
+\r
+//\r
+// Cached ACPI Timer IO Address\r
+//\r
+STATIC UINT32 mAcpiTimerIoAddr;\r
+\r
+/**\r
+ The constructor function caches the ACPI tick counter address\r
+\r
+ At the time this constructor runs (DXE_CORE or later), ACPI IO space\r
+ has already been enabled by either PlatformPei or by the "Base"\r
+ instance of this library.\r
+ In order to avoid querying the underlying platform type during each\r
+ tick counter read operation, we cache the counter address during\r
+ initialization of this instance of the Timer Library.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AcpiTimerLibConstructor (\r
+ VOID\r
+ )\r
+{\r
+ UINT16 HostBridgeDevId;\r
+ UINTN Pmba;\r
+\r
+ //\r
+ // Query Host Bridge DID to determine platform type\r
+ //\r
+ HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);\r
+ switch (HostBridgeDevId) {\r
+ case INTEL_82441_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_PIIX4 (0x40);\r
+ break;\r
+ case INTEL_Q35_MCH_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_Q35 (0x40);\r
+ break;\r
+ default:\r
+ DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",\r
+ __FUNCTION__, HostBridgeDevId));\r
+ ASSERT (FALSE);\r
+ return RETURN_UNSUPPORTED;\r
+ }\r
+\r
+ mAcpiTimerIoAddr = (PciRead32 (Pmba) & ~PMBA_RTE) + ACPI_TIMER_OFFSET;\r
+\r
+ return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+ Internal function to read the current tick counter of ACPI.\r
+\r
+ Read the current ACPI tick counter using the counter address cached\r
+ by this instance's constructor.\r
+\r
+ @return The tick counter read.\r
+\r
+**/\r
+UINT32\r
+InternalAcpiGetTimerTick (\r
+ VOID\r
+ )\r
+{\r
+ //\r
+ // Return the current ACPI timer value.\r
+ //\r
+ return IoRead32 (mAcpiTimerIoAddr);\r
+}\r
--- /dev/null
+## @file\r
+# DXE ACPI Timer Library Instance.\r
+#\r
+# Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>\r
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.\r
+#\r
+# This program and the accompanying materials are licensed and made\r
+# available under the terms and conditions of the BSD License which\r
+# accompanies this distribution. The full text of the license may\r
+# be found at http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = DxeAcpiTimerLib\r
+ FILE_GUID = 52DECA02-2EE8-4EAA-8EAD-1AB83F8A5955\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = TimerLib|DXE_DRIVER DXE_RUNTIME_DRIVER\r
+ CONSTRUCTOR = AcpiTimerLibConstructor\r
+\r
+[Sources]\r
+ AcpiTimerLib.c\r
+ DxeAcpiTimerLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
+\r
+[Pcd]\r
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ PciLib\r
+ IoLib\r
################################################################################\r
[LibraryClasses]\r
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf\r
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf\r
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
!endif\r
\r
[LibraryClasses.common.SEC]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf\r
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf\r
!ifdef $(DEBUG_ON_SERIAL_PORT)\r
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf\r
\r
[LibraryClasses.common.PEI_CORE]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf\r
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf\r
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
\r
[LibraryClasses.common.PEIM]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf\r
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf\r
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf\r
\r
[LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf\r
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf\r
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
\r
[LibraryClasses.common.DXE_DRIVER]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf\r
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
}\r
PcAtChipsetPkg/KbcResetDxe/Reset.inf\r
- MdeModulePkg/Universal/Metronome/Metronome.inf {\r
- <LibraryClasses>\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
- }\r
-\r
- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf {\r
- <LibraryClasses>\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
- }\r
-\r
+ MdeModulePkg/Universal/Metronome/Metronome.inf\r
+ PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {\r
<LibraryClasses>\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
!ifdef $(CSM_ENABLE)\r
NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf\r
!endif\r
################################################################################\r
[LibraryClasses]\r
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf\r
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf\r
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
!endif\r
\r
[LibraryClasses.common.SEC]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf\r
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf\r
!ifdef $(DEBUG_ON_SERIAL_PORT)\r
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf\r
\r
[LibraryClasses.common.PEI_CORE]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf\r
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf\r
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
\r
[LibraryClasses.common.PEIM]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf\r
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf\r
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf\r
\r
[LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf\r
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf\r
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
\r
[LibraryClasses.common.DXE_DRIVER]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf\r
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
}\r
PcAtChipsetPkg/KbcResetDxe/Reset.inf\r
- MdeModulePkg/Universal/Metronome/Metronome.inf {\r
- <LibraryClasses>\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
- }\r
-\r
- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf {\r
- <LibraryClasses>\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
- }\r
-\r
+ MdeModulePkg/Universal/Metronome/Metronome.inf\r
+ PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {\r
<LibraryClasses>\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
!ifdef $(CSM_ENABLE)\r
NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf\r
!endif\r
################################################################################\r
[LibraryClasses]\r
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf\r
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf\r
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
!endif\r
\r
[LibraryClasses.common.SEC]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf\r
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf\r
!ifdef $(DEBUG_ON_SERIAL_PORT)\r
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf\r
\r
[LibraryClasses.common.PEI_CORE]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf\r
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf\r
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
\r
[LibraryClasses.common.PEIM]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf\r
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf\r
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf\r
\r
[LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf\r
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf\r
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
\r
[LibraryClasses.common.DXE_DRIVER]\r
+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf\r
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
}\r
PcAtChipsetPkg/KbcResetDxe/Reset.inf\r
- MdeModulePkg/Universal/Metronome/Metronome.inf {\r
- <LibraryClasses>\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
- }\r
-\r
- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf {\r
- <LibraryClasses>\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
- }\r
-\r
+ MdeModulePkg/Universal/Metronome/Metronome.inf\r
+ PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {\r
<LibraryClasses>\r
- TimerLib|OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
!ifdef $(CSM_ENABLE)\r
NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf\r
!endif\r