From nobody Tue Feb 28 10:14:10 2023 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 4PQtWQ4ptGz3vGvJ; Tue, 28 Feb 2023 10:14:10 +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 4PQtWQ1qLkz3qZ8; Tue, 28 Feb 2023 10:14:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677579250; 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=VmEIMYM8+SuBxrEmELMNvkdTqrJfVOGPxr5wd/jIXzs=; b=JhnPFec/uJFZcgtu2ziL+zVJjHztpceuefKefdUa303IgBX3CERTnp9TSzMD24clL81Xc8 HxFZpwCB1CNt9fPlHSKj/y7GweOHUDyUiamAzwgDgW9pQCw30hfwxiKTJQlx11othCHD8t b9GWYpbsxOcc7fZXh4gOYF2JcscajqI2Ja5bh689YCC8lRuuk03vSZw4aOazWpUkSS8z99 oJUv3Uy4ag31gusrQeP7eB/6AXRtRSgdPEBJOvPuHJ84YTdJ9xiHO5qIsVXGFsXW75Eh3E CW+WHWqS+oeGf/0vBKXGDXJSjaKJZubvCWxSqo6nTrJft2VVVJyYJh7rKy04Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677579250; 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=VmEIMYM8+SuBxrEmELMNvkdTqrJfVOGPxr5wd/jIXzs=; b=JM5NJ5K7jatm6EaiTJzOFfltxe73K9i4o9SQZPihGbEx3/rGw4rMJfuIzb+f37VcD48tHN mAejY42ZNNAbe7If/AdmGxm3e1bOYupRcTWeALG56LzT40RqvEf9L9Hnupb+VQ4T9Ep4ea FOxe0xndg0YfCH/oZ6zOb9wc0FBKYbaKWXMjbBnU8AXBK8yo0i6XQwLKrCISIaveTVcpHs tGmXRX3P4Vh8YA84ybdXQehmhT8/hwUzc/ATenv3io87MmzAyPsBlPrbVQKA/ov3twRWjD GIlrw82ru8/uyL6OOVgNco09PCPARsosPAjoYq2CgxsYk/Ns0wapd2DYOYvA/g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677579250; a=rsa-sha256; cv=none; b=LDdZYsK+kswxp6pFKUl+nAAHQwW6s1f1up2tOFvAYlVM6vcZYEM8hCcmxQDyiu8kfyXyC1 owl1+qJx8TWo4Zzfs/6Z5594c6Ml1//B6dJq0iSIkotTQ0uEV+VQtWBl1suCIjPK3j3lYk VnE86U+2ATOHCP6eDzHwrWvgyURHy01YruEbFEMllXXcJM/aDfCzOPx8xN5mhMYJJmJ2Rh sOkpW7KgZfHLdoByujlAp/AS718B6AawuPLB2xu6f/4iC57XMjU6WccTbKi+YwVfNUO6Em jtYvdnl6qGjgT1kjhZNt8T5ZjyT6dHfj9dpIwaLnGOAUGPjvRI/ysR0TLxtN3w== 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 4PQtWQ0xDLz13p0; Tue, 28 Feb 2023 10:14:10 +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 31SAEAgA013748; Tue, 28 Feb 2023 10:14:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31SAEAkQ013747; Tue, 28 Feb 2023 10:14:10 GMT (envelope-from git) Date: Tue, 28 Feb 2023 10:14:10 GMT Message-Id: <202302281014.31SAEAkQ013747@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 6726130d6860 - stable/13 - bhyve: add helper func to write a dsdt entry 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 6726130d6860fa5a19181e69546976eafb044538 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=6726130d6860fa5a19181e69546976eafb044538 commit 6726130d6860fa5a19181e69546976eafb044538 Author: Corvin Köhne AuthorDate: 2021-10-07 13:58:27 +0000 Commit: Corvin Köhne CommitDate: 2023-02-28 10:04:34 +0000 bhyve: add helper func to write a dsdt entry The guest will check the dsdt to detect acpi devices. Therefore, add a helper function to create such a dsdt entry for an acpi device. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D38329 (cherry picked from commit 682a522d61223920f23a202aa57901f38bdfd8dd) --- usr.sbin/bhyve/acpi_device.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ usr.sbin/bhyve/acpi_device.h | 2 ++ 2 files changed, 48 insertions(+) diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c index 402e32faa93a..10259006c619 100644 --- a/usr.sbin/bhyve/acpi_device.c +++ b/usr.sbin/bhyve/acpi_device.c @@ -10,6 +10,7 @@ #include +#include #include #include #include @@ -135,3 +136,48 @@ acpi_device_add_res_fixed_memory32(struct acpi_device *const dev, return (0); } + +static void +acpi_device_write_dsdt_crs(const struct acpi_device *const dev) +{ + const struct acpi_resource_list_entry *res; + SLIST_FOREACH(res, &dev->crs, chain) { + switch (res->type) { + case ACPI_RESOURCE_TYPE_FIXED_IO: + dsdt_fixed_ioport(res->data.FixedIo.Address, + res->data.FixedIo.AddressLength); + break; + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: + dsdt_fixed_mem32(res->data.FixedMemory32.Address, + res->data.FixedMemory32.AddressLength); + break; + default: + assert(0); + break; + } + } +} + +void +acpi_device_write_dsdt(const struct acpi_device *const dev) +{ + if (dev == NULL) { + return; + } + + dsdt_line(""); + dsdt_line(" Scope (\\_SB)"); + dsdt_line(" {"); + dsdt_line(" Device (%s)", dev->name); + dsdt_line(" {"); + dsdt_line(" Name (_HID, \"%s\")", dev->hid); + dsdt_line(" Name (_STA, 0x0F)"); + dsdt_line(" Name (_CRS, ResourceTemplate ()"); + dsdt_line(" {"); + dsdt_indent(4); + acpi_device_write_dsdt_crs(dev); + dsdt_unindent(4); + dsdt_line(" })"); + dsdt_line(" }"); + dsdt_line(" }"); +} diff --git a/usr.sbin/bhyve/acpi_device.h b/usr.sbin/bhyve/acpi_device.h index d9618d7e0a43..5fb3ea18e481 100644 --- a/usr.sbin/bhyve/acpi_device.h +++ b/usr.sbin/bhyve/acpi_device.h @@ -34,3 +34,5 @@ int acpi_device_add_res_fixed_ioport(struct acpi_device *const dev, const UINT16 port, UINT8 length); int acpi_device_add_res_fixed_memory32(struct acpi_device *const dev, const UINT8 write_protected, const UINT32 address, const UINT32 length); + +void acpi_device_write_dsdt(const struct acpi_device *const dev);