From nobody Tue Feb 28 10:14:08 2023 X-Original-To: dev-commits-src-branches@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 4PQtWP2rcyz3vGhQ; Tue, 28 Feb 2023 10:14:09 +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 4PQtWP1L24z3ql4; Tue, 28 Feb 2023 10:14:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677579249; 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=zYUGIjwTwodeeCHauOwbPSxPeZ947YnQ7Ac/Rb5pSwE=; b=lL5SxdF5Gti2d/4VSKyocSsPV0b9y2re5QkWdmyfHD6o5tsFaWRUblTaslM4P4viLNnKgf f5CeGJj87op+S4QOenxBT4wpGGn4VXx1BtDHosglis5FEtKQEdtWp1QK5tGRhhVhfc3s1M 5IondbB5ft/7C6HclqZ9ELQ/ZaR78RrWEhSi+FeAynty7vZiULu00wq15eA+MZ5F0QTvkk P9Js8tY0Y3iNDCRVGWkYyD8SfbeNcjmA7w1XYGQaNV9cL1o1xbeEW87uQ+AVkRCeStprzS WhER8kKeCKL4UAJfmCCVnbPT646Mq8qCPr6ZQHvsIzebG84G2Bq8qHlUn0zrdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677579249; 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=zYUGIjwTwodeeCHauOwbPSxPeZ947YnQ7Ac/Rb5pSwE=; b=mj/DMhBiq0MS286bn4Z7WtfdjQ/vzN/Si9EhrFmxe2WBdAE6dJB1l7Mr9P7TL84A7lB9DV XuT+RyjWsGQ5eN51/SbqJBELZZklAPGoMjLwCRLukOH/xSEGsYvILaRY3q0AxmCo92uyPm VQoVMiMOfZlx2uoJ6jy9QlRCt48+i0SDZ8QVvAKNID5SIHsRYmhJT/bJomOl8CGpdXM58J DiBz6+7KvUU0YCTSTfIl32um00BtLLlUZcmXPLiCcsxhReap0Bx2AN0BgjvF+LEWXiRERt MB6Zstyb09BHWih1dZ1bBctspS/jd4iPHfEl9YFk9BqQjODqUEh//a7ESb64pQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677579249; a=rsa-sha256; cv=none; b=gPPOWU2PzTn1CyPt2+NrRg1d5nptupkuDfF2wS1QWBF6ddgWAItjaohADZXdJCxFnAmGHv m9B7WJC9bBwtsMgzaNBk0p6aEYV0/thQrWW7/xSKbxHoyM0etCfe6Et2ysyTcS5stn4HwC 4kTpUFlWjXLy9f7XlkldnUfGtYm1Qmre8RuZe91Mp7Q0SDYBeA7FAEoAO3Sloy1KsfJLZr LWjUagm4elNBE/UaZNyXjhY43X7KNX0lMINh0uyjJAtb5MLqyOmbS7pnWFUr4mVimDaIVH wZ/4NByf1OOnyUko6s2FE3fpFU6q2yy6xCivHj4hgW+BkbU5/R8aLr3olnXuQQ== 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 4PQtWP0779z13lX; Tue, 28 Feb 2023 10:14:09 +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 31SAE8L7013717; Tue, 28 Feb 2023 10:14:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31SAE8HD013716; Tue, 28 Feb 2023 10:14:08 GMT (envelope-from git) Date: Tue, 28 Feb 2023 10:14:08 GMT Message-Id: <202302281014.31SAE8HD013716@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: eb8931d77cee - stable/13 - bhyve: add helper func to add acpi resources List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: eb8931d77cee0af57578159297f95571a2d723f8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=eb8931d77cee0af57578159297f95571a2d723f8 commit eb8931d77cee0af57578159297f95571a2d723f8 Author: Corvin Köhne AuthorDate: 2021-10-07 13:57:01 +0000 Commit: Corvin Köhne CommitDate: 2023-02-28 10:04:33 +0000 bhyve: add helper func to add acpi resources These helper function can be used to assign acpi resources to an acpi_device. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D38328 (cherry picked from commit 13a1df5b85e992570f45248bfe9d581dc182b755) --- usr.sbin/bhyve/acpi_device.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ usr.sbin/bhyve/acpi_device.h | 5 +++++ 2 files changed, 50 insertions(+) diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c index 66d50de814fd..402e32faa93a 100644 --- a/usr.sbin/bhyve/acpi_device.c +++ b/usr.sbin/bhyve/acpi_device.c @@ -90,3 +90,48 @@ acpi_device_destroy(struct acpi_device *const dev) free(__DECONST(void *, dev->name)); free(dev); } + +int +acpi_device_add_res_fixed_ioport(struct acpi_device *const dev, + const UINT16 port, const UINT8 length) +{ + if (dev == NULL) { + return (EINVAL); + } + + struct acpi_resource_list_entry *const res = calloc(1, sizeof(*res)); + if (res == NULL) { + return (ENOMEM); + } + + res->type = ACPI_RESOURCE_TYPE_FIXED_IO; + res->data.FixedIo.Address = port; + res->data.FixedIo.AddressLength = length; + + SLIST_INSERT_HEAD(&dev->crs, res, chain); + + return (0); +} + +int +acpi_device_add_res_fixed_memory32(struct acpi_device *const dev, + const UINT8 write_protected, const UINT32 address, const UINT32 length) +{ + if (dev == NULL) { + return (EINVAL); + } + + struct acpi_resource_list_entry *const res = calloc(1, sizeof(*res)); + if (res == NULL) { + return (ENOMEM); + } + + res->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; + res->data.FixedMemory32.WriteProtect = write_protected; + res->data.FixedMemory32.Address = address; + res->data.FixedMemory32.AddressLength = length; + + SLIST_INSERT_HEAD(&dev->crs, res, chain); + + return (0); +} diff --git a/usr.sbin/bhyve/acpi_device.h b/usr.sbin/bhyve/acpi_device.h index 1728acd4cdcd..d9618d7e0a43 100644 --- a/usr.sbin/bhyve/acpi_device.h +++ b/usr.sbin/bhyve/acpi_device.h @@ -29,3 +29,8 @@ struct acpi_device; int acpi_device_create(struct acpi_device **const new_dev, struct vmctx *const vm_ctx, const char *const name, const char *const hid); void acpi_device_destroy(struct acpi_device *const dev); + +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);