There is already ISADeviceClass::build_aml() callback which builds device specific AML blob for some ISA devices. To extend the same idea to other devices, add TYPE_ACPI_DEV_AML_IF Interface that will provide a more generic callback which will be used not only for ISA but other devices. It will allow get rid of some data-mining and ad-hoc AML building, by asking device(s) to generate its own AML blob like it's done for ISA devices. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20220608135340.3304695-2-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
		
			
				
	
	
		
			34 lines
		
	
	
		
			933 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			933 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include "qemu/osdep.h"
 | 
						|
#include "hw/acpi/acpi_dev_interface.h"
 | 
						|
#include "hw/acpi/acpi_aml_interface.h"
 | 
						|
#include "qemu/module.h"
 | 
						|
 | 
						|
void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event)
 | 
						|
{
 | 
						|
    AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(dev);
 | 
						|
    if (adevc->send_event) {
 | 
						|
        AcpiDeviceIf *adev = ACPI_DEVICE_IF(dev);
 | 
						|
        adevc->send_event(adev, event);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
static void register_types(void)
 | 
						|
{
 | 
						|
    static const TypeInfo acpi_dev_if_info = {
 | 
						|
        .name          = TYPE_ACPI_DEVICE_IF,
 | 
						|
        .parent        = TYPE_INTERFACE,
 | 
						|
        .class_size = sizeof(AcpiDeviceIfClass),
 | 
						|
    };
 | 
						|
    static const TypeInfo acpi_dev_aml_if_info = {
 | 
						|
        .name          = TYPE_ACPI_DEV_AML_IF,
 | 
						|
        .parent        = TYPE_INTERFACE,
 | 
						|
        .class_size = sizeof(AcpiDevAmlIfClass),
 | 
						|
    };
 | 
						|
 | 
						|
 | 
						|
    type_register_static(&acpi_dev_if_info);
 | 
						|
    type_register_static(&acpi_dev_aml_if_info);
 | 
						|
}
 | 
						|
 | 
						|
type_init(register_types)
 |