From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by mx.groups.io with SMTP id smtpd.web10.1436.1587434690195463604 for ; Mon, 20 Apr 2020 19:04:50 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: bsdio.com, ip: 166.70.13.232, mailfrom: rebecca@bsdio.com) Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jQiHJ-0004DD-AP; Mon, 20 Apr 2020 20:04:49 -0600 Received: from mta4.zcs.xmission.com ([166.70.13.68]) by in02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jQiHI-00075O-Hv; Mon, 20 Apr 2020 20:04:49 -0600 Received: from localhost (localhost [127.0.0.1]) by mta4.zcs.xmission.com (Postfix) with ESMTP id 5ECCD5003D8; Mon, 20 Apr 2020 20:04:48 -0600 (MDT) X-Amavis-Modified: Mail body modified (using disclaimer) - mta4.zcs.xmission.com Received: from mta4.zcs.xmission.com ([127.0.0.1]) by localhost (mta4.zcs.xmission.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qRb9RUSwifsL; Mon, 20 Apr 2020 20:04:48 -0600 (MDT) Received: from photon.int.bluestop.org (muon.bluestop.org [65.103.231.193]) by mta4.zcs.xmission.com (Postfix) with ESMTPSA id D39EE500324; Mon, 20 Apr 2020 20:04:47 -0600 (MDT) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Leif Lindholm , Michael Kinney , Andrew Fish , Rebecca Cran Date: Mon, 20 Apr 2020 20:04:34 -0600 Message-Id: <20200421020441.34175-2-rebecca@bsdio.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200421020441.34175-1-rebecca@bsdio.com> References: <20200421020441.34175-1-rebecca@bsdio.com> MIME-Version: 1.0 X-XM-SPF: eid=1jQiHI-00075O-Hv;;;mid=<20200421020441.34175-2-rebecca@bsdio.com>;;;hst=in02.mta.xmission.com;;;ip=166.70.13.68;;;frm=rebecca@bsdio.com;;;spf=pass X-SA-Exim-Connect-IP: 166.70.13.68 X-SA-Exim-Mail-From: rebecca@bsdio.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: * X-Spam-Status: No, score=1.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,LotsOfNums_01 autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.2 LotsOfNums_01 BODY: Lots of long strings of numbers * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; IP=ok Body=1 Fuz1=1] [Fuz2=1] X-Spam-DCC: XMission; sa07 1397; IP=ok Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;devel@edk2.groups.io X-Spam-Relay-Country: X-Spam-Timing: total 498 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 10 (2.0%), b_tie_ro: 8 (1.7%), parse: 1.29 (0.3%), extract_message_metadata: 19 (3.7%), get_uri_detail_list: 3.3 (0.7%), tests_pri_-1000: 22 (4.3%), tests_pri_-950: 1.23 (0.2%), tests_pri_-900: 1.02 (0.2%), tests_pri_-90: 83 (16.7%), check_bayes: 80 (16.1%), b_tokenize: 11 (2.3%), b_tok_get_all: 10 (1.9%), b_comp_prob: 2.8 (0.6%), b_tok_touch_all: 53 (10.6%), b_finish: 0.99 (0.2%), tests_pri_0: 347 (69.7%), check_dkim_signature: 0.58 (0.1%), check_dkim_adsp: 37 (7.5%), poll_dns_idle: 35 (7.1%), tests_pri_10: 2.9 (0.6%), tests_pri_500: 8 (1.6%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH v2 1/8] OvmfPkg: Add bhyve support into AcpiTimerLib X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/IndustryStandard/Bhyve.h | 16 ++++++++++ OvmfPkg/Include/OvmfPlatforms.h | 1 + .../AcpiTimerLib/BaseAcpiTimerLibBhyve.c | 32 +++++++++++++++++++ .../AcpiTimerLib/BaseAcpiTimerLibBhyve.inf | 30 +++++++++++++++++ 4 files changed, 79 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/IndustryStandard/Bhyve.h new file mode 100644 index 000000000000..02ce5587ee0f --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/Bhyve.h @@ -0,0 +1,16 @@ +/** @file + Various register numbers and value bits based on FreeBSD's bhyve + at r359530. + - https://svnweb.freebsd.org/base?view=revision&revision=359530 + + Copyright (C) 2020, Rebecca Cran + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef __BHYVE_H__ +#define __BHYVE_H__ + +#define BHYVE_ACPI_TIMER_IO_ADDR 0x408 + +#endif // __BHYVE_H__ diff --git a/OvmfPkg/Include/OvmfPlatforms.h b/OvmfPkg/Include/OvmfPlatforms.h index 59459231e83d..77dd818e3002 100644 --- a/OvmfPkg/Include/OvmfPlatforms.h +++ b/OvmfPkg/Include/OvmfPlatforms.h @@ -14,6 +14,7 @@ #include #include #include +#include // // OVMF Host Bridge DID Address diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.c b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.c new file mode 100644 index 000000000000..f927e27188da --- /dev/null +++ b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.c @@ -0,0 +1,32 @@ +/** @file + Provide InternalAcpiGetTimerTick for the bhyve instance of the + Base ACPI Timer Library + + Copyright (C) 2020, Rebecca Cran + Copyright (C) 2014, Gabriel L. Somlo + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include + +/** + Internal function to read the current tick counter of ACPI. + + Read the current ACPI tick counter using the counter address cached + by this instance's constructor. + + @return The tick counter read. + +**/ +UINT32 +InternalAcpiGetTimerTick ( + VOID + ) +{ + // + // Return the current ACPI timer value. + // + return IoRead32 (BHYVE_ACPI_TIMER_IO_ADDR); +} diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.inf b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.inf new file mode 100644 index 000000000000..14b7479e6743 --- /dev/null +++ b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.inf @@ -0,0 +1,30 @@ +## @file +# Base ACPI Timer Library Instance for Bhyve. +# +# Copyright (C) 2020, Rebecca Cran +# Copyright (C) 2014, Gabriel L. Somlo +# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BaseAcpiTimerLibBhyve + FILE_GUID = A5E3B247-7302-11EA-9C04-3CECEF0C1C08 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = TimerLib + +[Sources] + AcpiTimerLib.c + AcpiTimerLib.h + BaseAcpiTimerLibBhyve.c + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + IoLib -- 2.20.1