The branch main has been updated by corvink:

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

commit dece4f2d875a3964e1d6438dafa108dda8a7a1d0
Author:     Corvin Köhne <[email protected]>
AuthorDate: 2023-05-15 11:24:14 +0000
Commit:     Corvin Köhne <[email protected]>
CommitDate: 2023-06-12 11:04:37 +0000

    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
---
 usr.sbin/bhyve/tpm_device.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/usr.sbin/bhyve/tpm_device.c b/usr.sbin/bhyve/tpm_device.c
index 77fd1ccf6a52..56df6ab0e30c 100644
--- a/usr.sbin/bhyve/tpm_device.c
+++ b/usr.sbin/bhyve/tpm_device.c
@@ -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);

Reply via email to