xref: /freebsd/usr.sbin/bhyve/acpi_device.h (revision eb1feadc201ab7c4dc3aee9938e272c068179a5f)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
5  * Author: Corvin Köhne <c.koehne@beckhoff.com>
6  */
7 
8 #pragma once
9 
10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wunused-parameter"
12 #include <contrib/dev/acpica/include/acpi.h>
13 #pragma GCC diagnostic pop
14 
15 struct vmctx;
16 
17 struct acpi_device;
18 
19 struct acpi_device_emul {
20 	const char *name;
21 	const char *hid;
22 };
23 
24 /**
25  * Creates an ACPI device.
26  *
27  * @param[out] new_dev Returns the newly create ACPI device.
28  * @param[in]  vm_ctx  VM context the ACPI device is created in.
29  * @param[in]  emul    Device emulation struct. It contains some information
30  *                     like the name of the ACPI device and some device specific
31  *                     functions.
32  */
33 int acpi_device_create(struct acpi_device **new_dev, struct vmctx *vm_ctx,
34     const struct acpi_device_emul *emul);
35 void acpi_device_destroy(struct acpi_device *dev);
36 
37 int acpi_device_add_res_fixed_ioport(struct acpi_device *dev, UINT16 port,
38     UINT8 length);
39 int acpi_device_add_res_fixed_memory32(struct acpi_device *dev,
40     UINT8 write_protected, UINT32 address, UINT32 length);
41 
42 void acpi_device_write_dsdt(const struct acpi_device *dev);
43