git: 1c7053169d9d - stable/13 - bhyve: allow device specific DSDT entries

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Fri, 28 Apr 2023 10:40:20 UTC
The branch stable/13 has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=1c7053169d9d35b419b4d9ba6116bca83ecd4a68

commit 1c7053169d9d35b419b4d9ba6116bca83ecd4a68
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2022-07-22 08:11:14 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-04-28 07:28:34 +0000

    bhyve: allow device specific DSDT entries
    
    This feature will be used by future commits to implement a device
    specific method (_DSM) for TPM devices.
    
    Reviewed by:            markj
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D39321
    
    (cherry picked from commit e976464a50aceebf97fb3cc6b94058111fc40de1)
---
 usr.sbin/bhyve/acpi_device.c | 5 +++++
 usr.sbin/bhyve/acpi_device.h | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c
index dffb73ba9023..51603e138fba 100644
--- a/usr.sbin/bhyve/acpi_device.c
+++ b/usr.sbin/bhyve/acpi_device.c
@@ -190,6 +190,11 @@ acpi_device_write_dsdt(const struct acpi_device *const dev)
 	BASL_EXEC(acpi_device_write_dsdt_crs(dev));
 	dsdt_unindent(4);
 	dsdt_line("      })");
+	if (dev->emul->write_dsdt != NULL) {
+		dsdt_indent(3);
+		BASL_EXEC(dev->emul->write_dsdt(dev));
+		dsdt_unindent(3);
+	}
 	dsdt_line("    }");
 	dsdt_line("  }");
 
diff --git a/usr.sbin/bhyve/acpi_device.h b/usr.sbin/bhyve/acpi_device.h
index de72ce1e5370..4d734b422ec5 100644
--- a/usr.sbin/bhyve/acpi_device.h
+++ b/usr.sbin/bhyve/acpi_device.h
@@ -23,12 +23,15 @@ struct acpi_device;
  * @param hid         Used as _HID in the DSDT.
  * @param build_table Called to build a device specific ACPI table like the TPM2
  *                    table.
+ * @param write_dsdt  Called to append the DSDT with device specific
+ *                    information.
  */
 struct acpi_device_emul {
 	const char *name;
 	const char *hid;
 
 	int (*build_table)(const struct acpi_device *dev);
+	int (*write_dsdt)(const struct acpi_device *dev);
 };
 
 /**