On bhyve, the ACPI timer is located at a fixed IO address; it need
not be programmed into, nor fetched from, the PMBA -- power
management base address -- register of the PCI host bridge.
Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Message-Id: <
20200430011212.612386-1-rebecca@bsdio.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
--- /dev/null
+/** @file\r
+ Various register numbers and value bits based on FreeBSD's bhyve\r
+ at r359530.\r
+ - https://svnweb.freebsd.org/base?view=revision&revision=359530\r
+\r
+ Copyright (C) 2020, Rebecca Cran <rebecca@bsdio.com>\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#ifndef __BHYVE_H__\r
+#define __BHYVE_H__\r
+\r
+#define BHYVE_ACPI_TIMER_IO_ADDR 0x408\r
+\r
+#endif // __BHYVE_H__\r
#include <IndustryStandard/Pci22.h>\r
#include <IndustryStandard/Q35MchIch9.h>\r
#include <IndustryStandard/I440FxPiix4.h>\r
+#include <IndustryStandard/Bhyve.h>\r
\r
//\r
// OVMF Host Bridge DID Address\r
--- /dev/null
+/** @file\r
+ Provide InternalAcpiGetTimerTick for the bhyve instance of the\r
+ Base ACPI Timer Library\r
+\r
+ Copyright (C) 2020, Rebecca Cran <rebecca@bsdio.com>\r
+ Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#include <Library/IoLib.h>\r
+#include <OvmfPlatforms.h>\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 (BHYVE_ACPI_TIMER_IO_ADDR);\r
+}\r
--- /dev/null
+## @file\r
+# Base ACPI Timer Library Instance for Bhyve.\r
+#\r
+# Copyright (C) 2020, Rebecca Cran <rebecca@bsdio.com>\r
+# Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>\r
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = BaseAcpiTimerLibBhyve\r
+ FILE_GUID = A5E3B247-7302-11EA-9C04-3CECEF0C1C08\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = TimerLib\r
+\r
+[Sources]\r
+ AcpiTimerLib.c\r
+ AcpiTimerLib.h\r
+ BaseAcpiTimerLibBhyve.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+ IoLib\r