bhyve: allow building device specific ACPI tables

Some ACPI devices require a device specific acpi table. E.g. a TPM2
device requires a TPM2 table. Use the acpi_device_emul struct to define
such a device specific table.

Reviewed by:		markj
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39320
This commit is contained in:
Corvin Köhne 2022-07-22 10:09:01 +02:00
parent c3c5e6c3e6
commit 0926566f6f
No known key found for this signature in database
GPG Key ID: D854DA56315E026A
3 changed files with 31 additions and 0 deletions

View File

@ -810,6 +810,13 @@ acpi_build(struct vmctx *ctx, int ncpu)
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());

View File

@ -135,6 +135,19 @@ acpi_device_add_res_fixed_memory32(struct acpi_device *const dev,
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)
{

View File

@ -16,9 +16,19 @@ struct vmctx;
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_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);
int acpi_device_build_table(const struct acpi_device *dev);
void acpi_device_write_dsdt(const struct acpi_device *dev);