2021-10-07 13:54:46 +00:00
|
|
|
/*-
|
2023-05-10 15:40:58 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-10-07 13:54:46 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
|
|
|
|
* Author: Corvin Köhne <c.koehne@beckhoff.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
|
|
|
#include <contrib/dev/acpica/include/acpi.h>
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
|
|
|
struct vmctx;
|
|
|
|
|
|
|
|
struct acpi_device;
|
|
|
|
|
2022-07-22 08:09:01 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2022-07-22 08:11:14 +00:00
|
|
|
* @param write_dsdt Called to append the DSDT with device specific
|
|
|
|
* information.
|
2022-07-22 08:09:01 +00:00
|
|
|
*/
|
2022-07-22 08:00:10 +00:00
|
|
|
struct acpi_device_emul {
|
|
|
|
const char *name;
|
|
|
|
const char *hid;
|
2022-07-22 08:09:01 +00:00
|
|
|
|
|
|
|
int (*build_table)(const struct acpi_device *dev);
|
2022-07-22 08:11:14 +00:00
|
|
|
int (*write_dsdt)(const struct acpi_device *dev);
|
2022-07-22 08:00:10 +00:00
|
|
|
};
|
|
|
|
|
2021-10-07 13:54:46 +00:00
|
|
|
/**
|
|
|
|
* Creates an ACPI device.
|
|
|
|
*
|
|
|
|
* @param[out] new_dev Returns the newly create ACPI device.
|
2022-07-22 08:15:28 +00:00
|
|
|
* @param[in] softc Pointer to the software context of the ACPI device.
|
2021-10-07 13:54:46 +00:00
|
|
|
* @param[in] vm_ctx VM context the ACPI device is created in.
|
2022-07-22 08:00:10 +00:00
|
|
|
* @param[in] emul Device emulation struct. It contains some information
|
|
|
|
* like the name of the ACPI device and some device specific
|
|
|
|
* functions.
|
2021-10-07 13:54:46 +00:00
|
|
|
*/
|
2022-07-22 08:15:28 +00:00
|
|
|
int acpi_device_create(struct acpi_device **new_dev, void *softc,
|
|
|
|
struct vmctx *vm_ctx, const struct acpi_device_emul *emul);
|
2023-03-29 13:13:03 +00:00
|
|
|
void acpi_device_destroy(struct acpi_device *dev);
|
2021-10-07 13:57:01 +00:00
|
|
|
|
2023-03-29 13:13:03 +00:00
|
|
|
int acpi_device_add_res_fixed_ioport(struct acpi_device *dev, UINT16 port,
|
|
|
|
UINT8 length);
|
|
|
|
int acpi_device_add_res_fixed_memory32(struct acpi_device *dev,
|
|
|
|
UINT8 write_protected, UINT32 address, UINT32 length);
|
2021-10-07 13:58:27 +00:00
|
|
|
|
2022-07-22 08:15:28 +00:00
|
|
|
void *acpi_device_get_softc(const struct acpi_device *dev);
|
|
|
|
|
2022-07-22 08:09:01 +00:00
|
|
|
int acpi_device_build_table(const struct acpi_device *dev);
|
2023-04-05 06:45:22 +00:00
|
|
|
int acpi_device_write_dsdt(const struct acpi_device *dev);
|