From nobody Mon Nov 21 08:31:38 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NG0wq0g5hz4j45W; Mon, 21 Nov 2022 08:31:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NG0wq07nBz3ML5; Mon, 21 Nov 2022 08:31:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669019499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PtR6DAdZkzyadUtKrAOGpoc5qnO5FMHdWJJM1eNpZwE=; b=ix+MB9qmPXBUSxSYzT2QqvZuS4fWRz0soSpTQ7F6Wa0fZXX0jvp7bkNlV3ydWLdM4mKx2U YkRi1csFP/JFc0Nkk0Rc6X8+L+ZZy4cLE352z4c1bgijFnGnIPxKPQM6ApWV4m/zAOjkR8 u3DGIiInnfs5FSvGppjfA/YQEhuiYFsl98FZyvTh5nm8hy1r/XqukW2/N7NN5Ddhe4Y00F yAuCeKOPuhtjLlJfdbfPXne1w1pU1Kp5RBcb8dZBUqL+qktZBGtrFboOim3Q7EbCdowWlB p9MyoQRUZyofhnGyRmbLvR9/Fv/SjWZzn816tUtJGTZ8ykrbzfrJ122lTzWRJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669019499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PtR6DAdZkzyadUtKrAOGpoc5qnO5FMHdWJJM1eNpZwE=; b=eu0eUQ+6PxBEBCvLdvrY3GqWmXRRHmcRRULCImRRgVBL3lVfFwbA3B39b6TJeo6yDR3/qP Hm8b+9wed/uzx7p8Eqmsx7OHAXVOUSOU++CCKSMPAaaD/qH+AXlipIqVsXtg2ZeEzTD+BH z+1NNcCl/fjFYfl++TV0oMHtsWXWfMTjmZLyKiw3BngDbKEf+cHz7oHK3FMqvX8o4WYm3v AXwyDsKnEJaAJMNVxPLzPdBl+cDz/WL1JSI73Cg+aeF2W748SIhvRfImSAFR+wJVy+N988 zzzTAm9M1EVEx6XntNrUHyWOxBN0Gqno/XzOzRd7LQmq8/2hGpLD6i52PCv2fQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669019499; a=rsa-sha256; cv=none; b=Kx4931dW03s6WzsyC1LTdyom7iIX2zYrUczZEG7CcKJots4Wi8E3w4x1J1OTYm/EFkfFhC cnFEGQwm4bH6xNcPVxHjr7bjGEuQ3jlPxaR02A/XBkJnOt/OEdSS4ZSVq5Ytp+scxKbrq/ yNsP3UHQpJFrV8x8lMFVOiyoeuPTNdZ7jt7rYaE2OILILdOrNpvUmyS0mkK6rofh012dy2 Q2YHxoQYCw1nnCvn+DXq3Ux75nHmWTDH2idSay6n5EQ6J1hF4AxrKPFrPs6ngMOZLc7z1X aEYyqoXA4By6k8eiamAk3Cw1fpD12bewAtgyYHL1B67bzTYK7lVperLhkpi5Dg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NG0wp6HMmzwyB; Mon, 21 Nov 2022 08:31:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AL8VcKk026483; Mon, 21 Nov 2022 08:31:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AL8Vck6026482; Mon, 21 Nov 2022 08:31:38 GMT (envelope-from git) Date: Mon, 21 Nov 2022 08:31:38 GMT Message-Id: <202211210831.2AL8Vck6026482@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: d61d71229902 - main - bhyve: build HPET table by basl List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: corvink X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d61d71229902f4963e269a394b36ce67ba910cab Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=d61d71229902f4963e269a394b36ce67ba910cab commit d61d71229902f4963e269a394b36ce67ba910cab Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:41 +0000 Commit: Corvin Köhne CommitDate: 2022-11-21 08:27:55 +0000 bhyve: build HPET table by basl Building the HPET table by basl will allow it to be loaded by qemu's ACPI table loader in the future. Reviewed by: jhb, markj (older version) Approved by: manu (mentor) MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36996 --- usr.sbin/bhyve/acpi.c | 69 +++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 46 deletions(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index 04ee843075c1..61dde6338242 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -109,6 +109,8 @@ __FBSDID("$FreeBSD$"); #define BHYVE_ASL_SUFFIX ".aml" #define BHYVE_ASL_COMPILER "/usr/sbin/iasl" +#define BHYVE_ADDRESS_HPET 0xFED00000 + static int basl_keep_temps; static int basl_verbose_iasl; static int basl_ncpu; @@ -544,51 +546,6 @@ err_exit: return (errno); } -static int -basl_fwrite_hpet(FILE *fp) -{ - EFPRINTF(fp, "/*\n"); - EFPRINTF(fp, " * bhyve HPET template\n"); - EFPRINTF(fp, " */\n"); - EFPRINTF(fp, "[0004]\t\tSignature : \"HPET\"\n"); - EFPRINTF(fp, "[0004]\t\tTable Length : 00000000\n"); - EFPRINTF(fp, "[0001]\t\tRevision : 01\n"); - EFPRINTF(fp, "[0001]\t\tChecksum : 00\n"); - EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n"); - EFPRINTF(fp, "[0008]\t\tOem Table ID : \"BVHPET \"\n"); - EFPRINTF(fp, "[0004]\t\tOem Revision : 00000001\n"); - - /* iasl will fill in the compiler ID/revision fields */ - EFPRINTF(fp, "[0004]\t\tAsl Compiler ID : \"xxxx\"\n"); - EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : 00000000\n"); - EFPRINTF(fp, "\n"); - - EFPRINTF(fp, "[0004]\t\tHardware Block ID : %08X\n", hpet_capabilities); - EFPRINTF(fp, - "[0012]\t\tTimer Block Register : [Generic Address Structure]\n"); - EFPRINTF(fp, "[0001]\t\tSpace ID : 00 [SystemMemory]\n"); - EFPRINTF(fp, "[0001]\t\tBit Width : 00\n"); - EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n"); - EFPRINTF(fp, - "[0001]\t\tEncoded Access Width : 00 [Undefined/Legacy]\n"); - EFPRINTF(fp, "[0008]\t\tAddress : 00000000FED00000\n"); - EFPRINTF(fp, "\n"); - - EFPRINTF(fp, "[0001]\t\tSequence Number : 00\n"); - EFPRINTF(fp, "[0002]\t\tMinimum Clock Ticks : 0000\n"); - EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 00000001\n"); - EFPRINTF(fp, "\t\t\t4K Page Protect : 1\n"); - EFPRINTF(fp, "\t\t\t64K Page Protect : 0\n"); - EFPRINTF(fp, "\n"); - - EFFLUSH(fp); - - return (0); - -err_exit: - return (errno); -} - /* * Helper routines for writing to the DSDT from other modules. */ @@ -919,6 +876,26 @@ build_facs(struct vmctx *const ctx) return (0); } +static int +build_hpet(struct vmctx *const ctx) +{ + ACPI_TABLE_HPET hpet; + struct basl_table *table; + + BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_HPET, + BASL_TABLE_ALIGNMENT, HPET_OFFSET)); + + memset(&hpet, 0, sizeof(hpet)); + BASL_EXEC(basl_table_append_header(table, ACPI_SIG_HPET, 1, 1)); + hpet.Id = htole32(hpet_capabilities); + basl_fill_gas(&hpet.Address, ACPI_ADR_SPACE_SYSTEM_MEMORY, 0, 0, + ACPI_GAS_ACCESS_WIDTH_LEGACY, BHYVE_ADDRESS_HPET); + hpet.Flags = ACPI_HPET_PAGE_PROTECT4; + BASL_EXEC(basl_table_append_content(table, &hpet, sizeof(hpet))); + + return (0); +} + static int build_mcfg(struct vmctx *const ctx) { @@ -980,7 +957,7 @@ acpi_build(struct vmctx *ctx, int ncpu) BASL_EXEC(basl_compile(ctx, basl_fwrite_xsdt, XSDT_OFFSET)); BASL_EXEC(basl_compile(ctx, basl_fwrite_madt, MADT_OFFSET)); BASL_EXEC(basl_compile(ctx, basl_fwrite_fadt, FADT_OFFSET)); - BASL_EXEC(basl_compile(ctx, basl_fwrite_hpet, HPET_OFFSET)); + BASL_EXEC(build_hpet(ctx)); BASL_EXEC(build_mcfg(ctx)); BASL_EXEC(build_facs(ctx)); BASL_EXEC(build_dsdt(ctx));