bhyve: register TPM device as ACPI device

The TPM device is an ACPI device with some custom ACPI tables.

Reviewed by:		markj
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D40453
This commit is contained in:
Corvin Köhne 2023-05-15 13:24:14 +02:00
parent d5edf13d01
commit dece4f2d87
No known key found for this signature in database
GPG Key ID: D854DA56315E026A

View File

@ -13,11 +13,21 @@
#include <string.h>
#include <vmmapi.h>
#include "acpi_device.h"
#include "config.h"
#include "tpm_device.h"
#define TPM_ACPI_DEVICE_NAME "TPM"
#define TPM_ACPI_HARDWARE_ID "MSFT0101"
struct tpm_device {
struct vmctx *vm_ctx;
struct acpi_device *acpi_dev;
};
static const struct acpi_device_emul tpm_acpi_device_emul = {
.name = TPM_ACPI_DEVICE_NAME,
.hid = TPM_ACPI_HARDWARE_ID,
};
void
@ -26,6 +36,7 @@ tpm_device_destroy(struct tpm_device *const dev)
if (dev == NULL)
return;
acpi_device_destroy(dev->acpi_dev);
free(dev);
}
@ -57,6 +68,11 @@ tpm_device_create(struct tpm_device **const new_dev, struct vmctx *const vm_ctx,
dev->vm_ctx = vm_ctx;
error = acpi_device_create(&dev->acpi_dev, dev, dev->vm_ctx,
&tpm_acpi_device_emul);
if (error)
goto err_out;
*new_dev = dev;
return (0);