diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -810,6 +810,13 @@ BASL_EXEC(build_mcfg(ctx)); BASL_EXEC(build_facs(ctx)); BASL_EXEC(build_spcr(ctx)); + + /* Build ACPI device-specific tables such as a TPM2 table. */ + const struct acpi_device_list_entry *entry; + SLIST_FOREACH(entry, &acpi_devices, chain) { + BASL_EXEC(acpi_device_build_table(entry->dev)); + } + BASL_EXEC(build_dsdt(ctx)); BASL_EXEC(basl_finish()); diff --git a/usr.sbin/bhyve/acpi_device.h b/usr.sbin/bhyve/acpi_device.h --- a/usr.sbin/bhyve/acpi_device.h +++ b/usr.sbin/bhyve/acpi_device.h @@ -16,9 +16,19 @@ struct acpi_device; +/** + * Device specific information and emulation. + * + * @param name Used as device name in the DSDT. + * @param hid Used as _HID in the DSDT. + * @param build_table Called to build a device specific ACPI table like the TPM2 + * table. + */ struct acpi_device_emul { const char *name; const char *hid; + + int (*build_table)(const struct acpi_device *dev); }; /** @@ -39,4 +49,5 @@ int acpi_device_add_res_fixed_memory32(struct acpi_device *dev, UINT8 write_protected, UINT32 address, UINT32 length); +int acpi_device_build_table(const struct acpi_device *dev); void acpi_device_write_dsdt(const struct acpi_device *dev); diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c --- a/usr.sbin/bhyve/acpi_device.c +++ b/usr.sbin/bhyve/acpi_device.c @@ -135,6 +135,19 @@ return (0); } +int +acpi_device_build_table(const struct acpi_device *const dev) +{ + assert(dev != NULL); + assert(dev->emul != NULL); + + if (dev->emul->build_table != NULL) { + return (dev->emul->build_table(dev)); + } + + return (0); +} + static void acpi_device_write_dsdt_crs(const struct acpi_device *const dev) {