From nobody Fri Apr 28 10:40:21 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 4Q78JQ0GTvz48Jgx; Fri, 28 Apr 2023 10:40:22 +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 4Q78JP6y0vz3H5s; Fri, 28 Apr 2023 10:40:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682678422; 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=sXDT36Higimq79f96l860tF1Em+OxppOIgD8EK85kGA=; b=wNRVAIQDb8oG5GNLok9A9a+u1QncUmXt70E9R6XloOwrFdFErlBrAfmGIPEY7qWMEG/a1Y 62yIyyzvSPQkIopCfdYdveYQeT1RndatIuDsBFFYIT4aJROWG/0QmU91ObOqcQdt63fobl KmQ6d3Du1og/u/SFuDtaK0/AvxWkGlgbauCKe68mjlm/OvCujZXEcclj3apTMuoxtHNDYR xmESpb6ccydRb3Ns09PW8BI4V8aTyr8V2Eql/taYQUaa+dbKn6o3Sy26F6kksyEll8nmFT 7/w/EwS8CGKCKhZmNGgqf1Wq5JLpXXgoEpqM2zF3cI7CThgvLm/HxCh1Zr3cDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682678422; 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=sXDT36Higimq79f96l860tF1Em+OxppOIgD8EK85kGA=; b=aqLg08Ng4/08t5wFKDl/+ee1Sr+axfmWbmR9VFV3pTfgHphHbNEpXvMDVowIrwft27jLIC Fn2aICxzegFYm4UNTnt9yQPaXZsx9KJ1iDrWPcFgfIO9KKobu4UkvOT1W5XM0c/zrBmOyx OckFSXJBUEPKNjsn5AZR+fnpIykwMDUhev4LBqGthy167dJhGloGLZtxscPSzXAZKUrVMT g90AW0DWjTT9XY1ZrWUTwsBsg+MQExy6IsQd7RE4yOGFaOtDStE32exJo3qwYVFn57w+Nz 8xrB8+xDeYKDzZnjV/4ls90oqibUeN+0QnKj+nkmM2pd4EIZLJqi0q0dZiSeEQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682678422; a=rsa-sha256; cv=none; b=HRp5lBLRX+YRGkTDajoP8Vao5j5t1+wHrAkDLtnbtZrR+cyoil5lx+WFFs2HrRHzEUp6qI gUIZzr90qjEK+ITaSJvdRNrZpfEQsYM3l11N3DOF72XmFzrDD+ZW7EJdjsutIbwMklnlPX 6MhWXORIS/F/xx2NbLBSctzxg/2P0EIZBa+uJcnwoCDARDT87JyrgkU5LeRiCe6oZtyhoW paolcYpT42a1WuXR67gp0b0TvdKJLwfCJE7PegB11iIQorvvTWAW7t+Pwe2W+L1y1RM11J r+QIPb/jmxVJ+EKCqpFTjTx04L7uMGuXczgZTepkw0s+5yAaVMgYuJ1AvK2hIg== 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 4Q78JP5rTZzwp7; Fri, 28 Apr 2023 10:40:21 +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 33SAeL9l092583; Fri, 28 Apr 2023 10:40:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33SAeLJP092582; Fri, 28 Apr 2023 10:40:21 GMT (envelope-from git) Date: Fri, 28 Apr 2023 10:40:21 GMT Message-Id: <202304281040.33SAeLJP092582@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: 9c8a0c311a96 - stable/13 - bhyve: save softc of ACPI devices 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: 9c8a0c311a961d0a4026ba1d817fcdd3a5e1c929 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=9c8a0c311a961d0a4026ba1d817fcdd3a5e1c929 commit 9c8a0c311a961d0a4026ba1d817fcdd3a5e1c929 Author: Corvin Köhne AuthorDate: 2022-07-22 08:15:28 +0000 Commit: Corvin Köhne CommitDate: 2023-04-28 07:28:34 +0000 bhyve: save softc of ACPI devices This will be useful for writing device specific ACPI tables or DSDT methods. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D39322 (cherry picked from commit 158adced65f844682d26e1e64f247de94212f135) --- usr.sbin/bhyve/acpi_device.c | 13 ++++++++++++- usr.sbin/bhyve/acpi_device.h | 7 +++++-- usr.sbin/bhyve/qemu_fwcfg.c | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c index 51603e138fba..e37fc50b8c91 100644 --- a/usr.sbin/bhyve/acpi_device.c +++ b/usr.sbin/bhyve/acpi_device.c @@ -36,18 +36,20 @@ struct acpi_resource_list_entry { * Holds information about an ACPI device. * * @param vm_ctx VM context the ACPI device was created in. + * @param softc A pointer to the software context of the ACPI device. * @param emul Device emulation struct. It contains some information like the name of the ACPI device and some device specific functions. * @param crs Current resources used by the ACPI device. */ struct acpi_device { struct vmctx *vm_ctx; + void *softc; const struct acpi_device_emul *emul; SLIST_HEAD(acpi_resource_list, acpi_resource_list_entry) crs; }; int -acpi_device_create(struct acpi_device **const new_dev, +acpi_device_create(struct acpi_device **const new_dev, void *const softc, struct vmctx *const vm_ctx, const struct acpi_device_emul *const emul) { assert(new_dev != NULL); @@ -60,6 +62,7 @@ acpi_device_create(struct acpi_device **const new_dev, } dev->vm_ctx = vm_ctx; + dev->softc = softc; dev->emul = emul; SLIST_INIT(&dev->crs); @@ -136,6 +139,14 @@ acpi_device_add_res_fixed_memory32(struct acpi_device *const dev, return (0); } +void * +acpi_device_get_softc(const struct acpi_device *const dev) +{ + assert(dev != NULL); + + return (dev->softc); +} + int acpi_device_build_table(const struct acpi_device *const dev) { diff --git a/usr.sbin/bhyve/acpi_device.h b/usr.sbin/bhyve/acpi_device.h index 4d734b422ec5..32e299f2da86 100644 --- a/usr.sbin/bhyve/acpi_device.h +++ b/usr.sbin/bhyve/acpi_device.h @@ -38,13 +38,14 @@ struct acpi_device_emul { * Creates an ACPI device. * * @param[out] new_dev Returns the newly create ACPI device. + * @param[in] softc Pointer to the software context of the ACPI device. * @param[in] vm_ctx VM context the ACPI device is created in. * @param[in] emul Device emulation struct. It contains some information * like the name of the ACPI device and some device specific * functions. */ -int acpi_device_create(struct acpi_device **new_dev, struct vmctx *vm_ctx, - const struct acpi_device_emul *emul); +int acpi_device_create(struct acpi_device **new_dev, void *softc, + struct vmctx *vm_ctx, const struct acpi_device_emul *emul); void acpi_device_destroy(struct acpi_device *dev); int acpi_device_add_res_fixed_ioport(struct acpi_device *dev, UINT16 port, @@ -52,5 +53,7 @@ int acpi_device_add_res_fixed_ioport(struct acpi_device *dev, UINT16 port, int acpi_device_add_res_fixed_memory32(struct acpi_device *dev, UINT8 write_protected, UINT32 address, UINT32 length); +void *acpi_device_get_softc(const struct acpi_device *dev); + int acpi_device_build_table(const struct acpi_device *dev); int acpi_device_write_dsdt(const struct acpi_device *dev); diff --git a/usr.sbin/bhyve/qemu_fwcfg.c b/usr.sbin/bhyve/qemu_fwcfg.c index e35d63d09795..e76ff3620586 100644 --- a/usr.sbin/bhyve/qemu_fwcfg.c +++ b/usr.sbin/bhyve/qemu_fwcfg.c @@ -380,7 +380,7 @@ qemu_fwcfg_init(struct vmctx *const ctx) * tables and register io ports for fwcfg, if it's used. */ if (strcmp(lpc_fwcfg(), "qemu") == 0) { - error = acpi_device_create(&fwcfg_sc.acpi_dev, ctx, + error = acpi_device_create(&fwcfg_sc.acpi_dev, &fwcfg_sc, ctx, &qemu_fwcfg_acpi_device_emul); if (error) { warnx("%s: failed to create ACPI device for QEMU FwCfg",