From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smic.int.bsdio.com (smic.int.bsdio.com [65.103.231.193]) by mx.groups.io with SMTP id smtpd.web11.795.1586992281924117491 for ; Wed, 15 Apr 2020 16:11:22 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: smic.int.bsdio.com, ip: 65.103.231.193, mailfrom: bcran@smic.int.bsdio.com) Received: from smic.int.bsdio.com (localhost [127.0.0.1]) by smic.int.bsdio.com (8.15.2/8.15.2) with ESMTPS id 03FNA3Ax046055 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 15 Apr 2020 17:10:03 -0600 (MDT) (envelope-from bcran@smic.int.bsdio.com) Received: (from bcran@localhost) by smic.int.bsdio.com (8.15.2/8.15.2/Submit) id 03FNA3fb045291; Wed, 15 Apr 2020 17:10:03 -0600 (MDT) (envelope-from bcran) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran Subject: [PATCH 01/13] OvmfPkg: Add bhyve support into AcpiTimerLib Date: Wed, 15 Apr 2020 17:09:27 -0600 Message-Id: <0b1d5644e175225839828e9a919152aff89491ba.1586991816.git.rebecca@bsdio.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- OvmfPkg/Include/IndustryStandard/Bhyve.h | 21 ++++++++++++ OvmfPkg/Include/OvmfPlatforms.h | 1 + .../AcpiTimerLib/BaseAcpiTimerLibBhyve.c | 33 +++++++++++++++++++ .../AcpiTimerLib/BaseAcpiTimerLibBhyve.inf | 29 ++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 OvmfPkg/Include/IndustryStandard/Bhyve.h create mode 100644 OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.c create mode 100644 OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.inf diff --git a/OvmfPkg/Include/IndustryStandard/Bhyve.h b/OvmfPkg/Include/Ind= ustryStandard/Bhyve.h new file mode 100644 index 0000000000..950f87048b --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/Bhyve.h @@ -0,0 +1,21 @@ +/** @file=0D + Various register numbers and value bits based on FreeBSD's bhyve=0D + at r359530.=0D + - https://svnweb.freebsd.org/base?view=3Drevision&revision=3D359530=0D +=0D + Copyright (C) 2020, Rebecca Cran =0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#ifndef __BHYVE_H__=0D +#define __BHYVE_H__=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#define BHYVE_ACPI_TIMER_IO_ADDR 0x408=0D +=0D +#endif // __BHYVE_H__=0D diff --git a/OvmfPkg/Include/OvmfPlatforms.h b/OvmfPkg/Include/OvmfPlatform= s.h index 59459231e8..77dd818e30 100644 --- a/OvmfPkg/Include/OvmfPlatforms.h +++ b/OvmfPkg/Include/OvmfPlatforms.h @@ -14,6 +14,7 @@ #include =0D #include =0D #include =0D +#include =0D =0D //=0D // OVMF Host Bridge DID Address=0D diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.c b/OvmfPkg= /Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.c new file mode 100644 index 0000000000..58ebffac86 --- /dev/null +++ b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.c @@ -0,0 +1,33 @@ +/** @file=0D + Provide InternalAcpiGetTimerTick for the bhyve instance of the=0D + Base ACPI Timer Library=0D +=0D + Copyright (C) 2020, Rebecca Cran =0D + Copyright (C) 2014, Gabriel L. Somlo =0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Internal function to read the current tick counter of ACPI.=0D +=0D + Read the current ACPI tick counter using the counter address cached=0D + by this instance's constructor.=0D +=0D + @return The tick counter read.=0D +=0D +**/=0D +UINT32=0D +InternalAcpiGetTimerTick (=0D + VOID=0D + )=0D +{=0D + //=0D + // Return the current ACPI timer value.=0D + //=0D + return IoRead32 (BHYVE_ACPI_TIMER_IO_ADDR);=0D +}=0D diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.inf b/OvmfP= kg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.inf new file mode 100644 index 0000000000..1e48718f3d --- /dev/null +++ b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.inf @@ -0,0 +1,29 @@ +## @file=0D +# Base ACPI Timer Library Instance for Bhyve.=0D +#=0D +# Copyright (C) 2020, Rebecca Cran =0D +# Copyright (C) 2014, Gabriel L. Somlo =0D +# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D BaseAcpiTimerLibBhyve=0D + FILE_GUID =3D A5E3B247-7302-11EA-9C04-3CECEF0C1C08=0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D TimerLib=0D +=0D +[Sources]=0D + AcpiTimerLib.c=0D + BaseAcpiTimerLibBhyve.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + OvmfPkg/OvmfPkg.dec=0D +=0D +[LibraryClasses]=0D + IoLib=0D --=20 2.26.1