From nobody Tue Feb 14 07:29:08 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 4PGCWT11Q1z3rLC4; Tue, 14 Feb 2023 07:29: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 4PGCWS6q2vz4NWM; Tue, 14 Feb 2023 07:29:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676359749; 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=xobRijXbgXnAlxqj3wYckmTL4lS1veJs5u7w1eZkxZI=; b=AyqRuAJx0Vsy98pP0XP/zQDD9kYBc9mBW+ta2sfOLPyjSzIui4qvODV3NjsbQl2SkYA5fy PSZkahWJrpmi+RVs38ohb437ljQsrrjnRJSU5GP3obnojJSXocO4apx73PYLdxEGy20zx1 B8aUO6Omx1V7kIT6cu2SzoFKuuAyYyWF3ggkQI7SDcIPxlYxVDqJ6skWaEQ0CmEWLT84sm oIlhcYGXXmGyySTgBOwCCokRTXmn+yYNUOVopwJbVROsHCyJY7IP+1xnZ14+KdkGrFeTJG imYcRxW4nXoGDhdFLmRqttFlupZzZwa8HLe8NzIGet5mw7W8cUbMvG42g9tNoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676359749; 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=xobRijXbgXnAlxqj3wYckmTL4lS1veJs5u7w1eZkxZI=; b=LDYNCob8ojxsI6k2dQi3D8MIrU5LnPDndiy/pb/qxrLw9q/EwuhMXmHkdghXJw8LM/ZMwq hfRMqlo/LB07ZphS3UZk3a6pPwFiWgj9qOLS0WBF95yLITiGoE4VlDfeGpYJTi1gXls1FT XRfHrflLHMnXKaGVrv2uVWl7TIXzsGvojY88/6dA5bkwB3PTLZH27K9+ige+6N06UIkwZl mH6MtU2bAyosZVzae5Z8biAOuYQ0HcU76rzfSSz31o1fam7fNRMZRXBSOi2NKJVh9qwqn4 60T7zX6EwSjYY5HgXxNTylejm/1EEXY+jzaNZxNpVyg47HaYknfNBjSdp673TA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676359749; a=rsa-sha256; cv=none; b=XKvndGRnXYDvbuAdE379dqfKiiTlgkGsABUdUlxCjiWB1kZJMBctMS7y8BHnfBDWbbOTCN 1hivf+PKMDKzp0nR91CNfVKySr5l7MMUXrMq3A6WFm9GGQB2IU6zXps4NtFbS8aYXmmHW3 OmcNJ/gMo+CdiTIsTO23hWthYSCTZTgxN5v+I0TeyS0jSbAjsyH1DOHosLR+LOKK0JJpNF oNA97sCSzpBUvdx8oQMvth75sQN3dlhPyeP+n9QVuUW1x6aMdA9bZaDjgLkRGvwMCfTsDT /KS6SM0f1poZDe5dGVLjVltLwSwJljWYHD+eHW6cwnbVDCOBGiy2L81P8jLN9Q== 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 4PGCWS5RmFzqql; Tue, 14 Feb 2023 07:29:08 +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 31E7T8L1043976; Tue, 14 Feb 2023 07:29:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31E7T8wM043975; Tue, 14 Feb 2023 07:29:08 GMT (envelope-from git) Date: Tue, 14 Feb 2023 07:29:08 GMT Message-Id: <202302140729.31E7T8wM043975@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: 13a1df5b85e9 - main - bhyve: add helper func to add acpi resources 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: 13a1df5b85e992570f45248bfe9d581dc182b755 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=13a1df5b85e992570f45248bfe9d581dc182b755 commit 13a1df5b85e992570f45248bfe9d581dc182b755 Author: Corvin Köhne AuthorDate: 2021-10-07 13:57:01 +0000 Commit: Corvin Köhne CommitDate: 2023-02-14 07:28:21 +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 --- 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);