1 #ifndef ACPI_AML_INTERFACE_H
2 #define ACPI_AML_INTERFACE_H
3 
4 #include "qom/object.h"
5 #include "hw/acpi/aml-build.h"
6 #include "hw/qdev-core.h"
7 
8 #define TYPE_ACPI_DEV_AML_IF "acpi-dev-aml-interface"
9 typedef struct AcpiDevAmlIfClass AcpiDevAmlIfClass;
10 DECLARE_CLASS_CHECKERS(AcpiDevAmlIfClass, ACPI_DEV_AML_IF, TYPE_ACPI_DEV_AML_IF)
11 #define ACPI_DEV_AML_IF(obj) \
12      INTERFACE_CHECK(AcpiDevAmlIf, (obj), TYPE_ACPI_DEV_AML_IF)
13 
14 typedef struct AcpiDevAmlIf AcpiDevAmlIf;
15 typedef void (*dev_aml_fn)(AcpiDevAmlIf *adev, Aml *scope);
16 
17 /**
18  * AcpiDevAmlIfClass:
19  *
20  * build_dev_aml: adds device specific AML blob to provided scope
21  *
22  * Interface is designed for providing generic callback that builds device
23  * specific AML blob.
24  */
25 struct AcpiDevAmlIfClass {
26     /* <private> */
27     InterfaceClass parent_class;
28 
29     /* <public> */
30     dev_aml_fn build_dev_aml;
31 };
32 
33 static inline dev_aml_fn get_dev_aml_func(DeviceState *dev)
34 {
35     if (object_dynamic_cast(OBJECT(dev), TYPE_ACPI_DEV_AML_IF)) {
36         AcpiDevAmlIfClass *klass = ACPI_DEV_AML_IF_GET_CLASS(dev);
37         return klass->build_dev_aml;
38     }
39     return NULL;
40 }
41 
42 static inline void call_dev_aml_func(DeviceState *dev, Aml *scope)
43 {
44     dev_aml_fn fn = get_dev_aml_func(dev);
45     if (fn) {
46         fn(ACPI_DEV_AML_IF(dev), scope);
47     }
48 }
49 
50 void qbus_build_aml(BusState *bus, Aml *scope);
51 
52 #endif
53