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 7 #define TYPE_ACPI_DEV_AML_IF "acpi-dev-aml-interface" 8 typedef struct AcpiDevAmlIfClass AcpiDevAmlIfClass; 9 DECLARE_CLASS_CHECKERS(AcpiDevAmlIfClass, ACPI_DEV_AML_IF, TYPE_ACPI_DEV_AML_IF) 10 #define ACPI_DEV_AML_IF(obj) \ 11 INTERFACE_CHECK(AcpiDevAmlIf, (obj), TYPE_ACPI_DEV_AML_IF) 12 13 typedef struct AcpiDevAmlIf AcpiDevAmlIf; 14 typedef void (*dev_aml_fn)(AcpiDevAmlIf *adev, Aml *scope); 15 16 /** 17 * AcpiDevAmlIfClass: 18 * 19 * build_dev_aml: adds device specific AML blob to provided scope 20 * 21 * Interface is designed for providing generic callback that builds device 22 * specific AML blob. 23 */ 24 struct AcpiDevAmlIfClass { 25 /* <private> */ 26 InterfaceClass parent_class; 27 28 /* <public> */ 29 dev_aml_fn build_dev_aml; 30 }; 31 32 static inline void call_dev_aml_func(DeviceState *dev, Aml *scope) 33 { 34 if (object_dynamic_cast(OBJECT(dev), TYPE_ACPI_DEV_AML_IF)) { 35 AcpiDevAmlIfClass *klass = ACPI_DEV_AML_IF_GET_CLASS(dev); 36 klass->build_dev_aml(ACPI_DEV_AML_IF(dev), scope); 37 } 38 } 39 40 #endif 41