git: fbd045021d9f - main - bhyve: maintain a list of acpi devices
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Feb 2023 07:29:10 UTC
The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=fbd045021d9ffdae5e5bb20e1d1890fd4b46498e commit fbd045021d9ffdae5e5bb20e1d1890fd4b46498e Author: Corvin Köhne <corvink@FreeBSD.org> AuthorDate: 2021-10-07 14:14:31 +0000 Commit: Corvin Köhne <corvink@FreeBSD.org> CommitDate: 2023-02-14 07:28:31 +0000 bhyve: maintain a list of acpi devices The list is used to generate the dsdt entry for every acpi device. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D3830 --- usr.sbin/bhyve/acpi.c | 29 +++++++++++++++++++++++++++++ usr.sbin/bhyve/acpi.h | 3 +++ usr.sbin/bhyve/acpi_device.c | 6 ++++++ 3 files changed, 38 insertions(+) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index bdb0e97076ad..84a54cc485c5 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -106,6 +106,30 @@ struct basl_fio { #define EFFLUSH(x) \ if (fflush(x) != 0) goto err_exit; +/* + * A list for additional ACPI devices like a TPM. + */ +struct acpi_device_list_entry { + SLIST_ENTRY(acpi_device_list_entry) chain; + const struct acpi_device *dev; +}; +static SLIST_HEAD(acpi_device_list, + acpi_device_list_entry) acpi_devices = SLIST_HEAD_INITIALIZER(acpi_devices); + +int +acpi_tables_add_device(const struct acpi_device *const dev) +{ + struct acpi_device_list_entry *const entry = calloc(1, sizeof(*entry)); + if (entry == NULL) { + return (ENOMEM); + } + + entry->dev = dev; + SLIST_INSERT_HEAD(&acpi_devices, entry, chain); + + return (0); +} + /* * Helper routines for writing to the DSDT from other modules. */ @@ -219,6 +243,11 @@ basl_fwrite_dsdt(FILE *fp) vmgenc_write_dsdt(); + const struct acpi_device_list_entry *entry; + SLIST_FOREACH(entry, &acpi_devices, chain) { + acpi_device_write_dsdt(entry->dev); + } + dsdt_line("}"); if (dsdt_error != 0) diff --git a/usr.sbin/bhyve/acpi.h b/usr.sbin/bhyve/acpi.h index 50e5337f332a..98479913732c 100644 --- a/usr.sbin/bhyve/acpi.h +++ b/usr.sbin/bhyve/acpi.h @@ -31,6 +31,8 @@ #ifndef _ACPI_H_ #define _ACPI_H_ +#include "acpi_device.h" + #define SCI_INT 9 #define SMI_CMD 0xb2 @@ -55,6 +57,7 @@ struct vmctx; int acpi_build(struct vmctx *ctx, int ncpu); void acpi_raise_gpe(struct vmctx *ctx, unsigned bit); +int acpi_tables_add_device(const struct acpi_device *const dev); void dsdt_line(const char *fmt, ...); void dsdt_fixed_ioport(uint16_t iobase, uint16_t length); void dsdt_fixed_irq(uint8_t irq); diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c index 10259006c619..047d411deec2 100644 --- a/usr.sbin/bhyve/acpi_device.c +++ b/usr.sbin/bhyve/acpi_device.c @@ -68,6 +68,12 @@ acpi_device_create(struct acpi_device **const new_dev, return (ENOMEM); } + const int error = acpi_tables_add_device(dev); + if (error) { + acpi_device_destroy(dev); + return (error); + } + *new_dev = dev; return (0);