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.2216.1587438605677298623 for ; Mon, 20 Apr 2020 20:10:05 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: bsdio.com, ip: 166.70.13.232, mailfrom: rebecca@bsdio.com) Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jQjIR-0000Cq-QF; Mon, 20 Apr 2020 21:10:03 -0600 Received: from mta4.zcs.xmission.com ([166.70.13.68]) by in01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jQjIQ-0001Gr-Q7; Mon, 20 Apr 2020 21:10:03 -0600 Received: from localhost (localhost [127.0.0.1]) by mta4.zcs.xmission.com (Postfix) with ESMTP id 5A7515003DA; Mon, 20 Apr 2020 21:10:02 -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 YjMt4tBd2A6i; Mon, 20 Apr 2020 21:10:02 -0600 (MDT) Received: from photon.int.bluestop.org (c-174-52-16-57.hsd1.ut.comcast.net [174.52.16.57]) by mta4.zcs.xmission.com (Postfix) with ESMTPSA id F07515002C5; Mon, 20 Apr 2020 21:10:01 -0600 (MDT) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Leif Lindholm , Michael Kinney , Andrew Fish , Peter Grehan , Rebecca Cran Date: Mon, 20 Apr 2020 21:09:50 -0600 Message-Id: <20200421030955.114850-2-rebecca@bsdio.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200421030955.114850-1-rebecca@bsdio.com> References: <20200421030955.114850-1-rebecca@bsdio.com> MIME-Version: 1.0 X-XM-SPF: eid=1jQjIQ-0001Gr-Q7;;;mid=<20200421030955.114850-2-rebecca@bsdio.com>;;;hst=in01.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 sa08.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 * [sa08 1397; IP=ok Body=1 Fuz1=1] [Fuz2=3] X-Spam-DCC: XMission; sa08 1397; IP=ok Body=1 Fuz1=1 Fuz2=3 X-Spam-Combo: *;devel@edk2.groups.io X-Spam-Relay-Country: X-Spam-Timing: total 372 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 11 (2.9%), b_tie_ro: 9 (2.5%), parse: 1.03 (0.3%), extract_message_metadata: 15 (4.1%), get_uri_detail_list: 2.1 (0.6%), tests_pri_-1000: 15 (4.1%), tests_pri_-950: 1.33 (0.4%), tests_pri_-900: 1.10 (0.3%), tests_pri_-90: 77 (20.7%), check_bayes: 75 (20.3%), b_tokenize: 9 (2.5%), b_tok_get_all: 10 (2.7%), b_comp_prob: 2.1 (0.6%), b_tok_touch_all: 49 (13.3%), b_finish: 1.20 (0.3%), tests_pri_0: 238 (64.0%), check_dkim_signature: 0.54 (0.1%), check_dkim_adsp: 2.5 (0.7%), poll_dns_idle: 1.12 (0.3%), tests_pri_10: 1.96 (0.5%), tests_pri_500: 8 (2.0%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH v3 1/6] 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 in01.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 0000000000..02ce5587ee --- /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 59459231e8..77dd818e30 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 0000000000..f927e27188 --- /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 0000000000..14b7479e67 --- /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