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 @@ -28,13 +28,14 @@ * Creates an ACPI device. * * @param[out] new_dev Returns the newly create ACPI device. + * @param[in] parent Pointer to the parent object which is an ACPI device. * @param[in] vm_ctx VM context the ACPI device is created in. * @param[in] emul Device emulation struct. It contains some information * like the name of the ACPI device and some device specific * functions. */ -int acpi_device_create(struct acpi_device **new_dev, struct vmctx *vm_ctx, - const struct acpi_device_emul *emul); +int acpi_device_create(struct acpi_device **new_dev, void *parent, + struct vmctx *vm_ctx, const struct acpi_device_emul *emul); void acpi_device_destroy(struct acpi_device *dev); int acpi_device_add_res_fixed_ioport(struct acpi_device *dev, UINT16 port, @@ -42,5 +43,7 @@ int acpi_device_add_res_fixed_memory32(struct acpi_device *dev, UINT8 write_protected, UINT32 address, UINT32 length); +void *acpi_device_get_parent(const struct acpi_device *dev); + 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 @@ -41,12 +41,13 @@ */ struct acpi_device { struct vmctx *vm_ctx; + void *parent; const struct acpi_device_emul *emul; SLIST_HEAD(acpi_resource_list, acpi_resource_list_entry) crs; }; int -acpi_device_create(struct acpi_device **const new_dev, +acpi_device_create(struct acpi_device **const new_dev, void *const parent, struct vmctx *const vm_ctx, const struct acpi_device_emul *const emul) { if (new_dev == NULL || vm_ctx == NULL || emul == NULL) { @@ -59,6 +60,7 @@ } dev->vm_ctx = vm_ctx; + dev->parent = parent; dev->emul = emul; SLIST_INIT(&dev->crs); if (dev->name == NULL || dev->hid == NULL) { @@ -141,6 +143,16 @@ return (0); } +void * +acpi_device_get_parent(const struct acpi_device *const dev) +{ + if (dev == NULL) { + return (NULL); + } + + return (dev->parent); +} + int acpi_device_build_table(const struct acpi_device *const dev) { diff --git a/usr.sbin/bhyve/qemu_fwcfg.c b/usr.sbin/bhyve/qemu_fwcfg.c --- a/usr.sbin/bhyve/qemu_fwcfg.c +++ b/usr.sbin/bhyve/qemu_fwcfg.c @@ -366,7 +366,7 @@ * tables and register io ports for fwcfg, if it's used. */ if (strcmp(lpc_fwcfg(), "qemu") == 0) { - error = acpi_device_create(&sc.acpi_dev, ctx, + error = acpi_device_create(&sc.acpi_dev, NULL, ctx, &qemu_fwcfg_acpi_device_emul); if (error) { warnx("%s: failed to create ACPI device for QEMU FwCfg",