pc: add acpi-device link to PCMachineState
the link will used later to access device implementing ACPI functions instead of adhoc lookup in QOM tree. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
		
							parent
							
								
									f816a62daa
								
							
						
					
					
						commit
						781bbd6bec
					
				@ -483,13 +483,17 @@ Object *piix4_pm_find(void)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 | 
					I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 | 
				
			||||||
                      qemu_irq sci_irq, qemu_irq smi_irq,
 | 
					                      qemu_irq sci_irq, qemu_irq smi_irq,
 | 
				
			||||||
                      int kvm_enabled, FWCfgState *fw_cfg)
 | 
					                      int kvm_enabled, FWCfgState *fw_cfg,
 | 
				
			||||||
 | 
					                      DeviceState **piix4_pm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    DeviceState *dev;
 | 
					    DeviceState *dev;
 | 
				
			||||||
    PIIX4PMState *s;
 | 
					    PIIX4PMState *s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dev = DEVICE(pci_create(bus, devfn, TYPE_PIIX4_PM));
 | 
					    dev = DEVICE(pci_create(bus, devfn, TYPE_PIIX4_PM));
 | 
				
			||||||
    qdev_prop_set_uint32(dev, "smb_io_base", smb_io_base);
 | 
					    qdev_prop_set_uint32(dev, "smb_io_base", smb_io_base);
 | 
				
			||||||
 | 
					    if (piix4_pm) {
 | 
				
			||||||
 | 
					        *piix4_pm = dev;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    s = PIIX4_PM(dev);
 | 
					    s = PIIX4_PM(dev);
 | 
				
			||||||
    s->irq = sci_irq;
 | 
					    s->irq = sci_irq;
 | 
				
			||||||
 | 
				
			|||||||
@ -74,6 +74,7 @@ static void pc_init1(MachineState *machine,
 | 
				
			|||||||
                     int pci_enabled,
 | 
					                     int pci_enabled,
 | 
				
			||||||
                     int kvmclock_enabled)
 | 
					                     int kvmclock_enabled)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    PCMachineState *pc_machine = PC_MACHINE(machine);
 | 
				
			||||||
    MemoryRegion *system_memory = get_system_memory();
 | 
					    MemoryRegion *system_memory = get_system_memory();
 | 
				
			||||||
    MemoryRegion *system_io = get_system_io();
 | 
					    MemoryRegion *system_io = get_system_io();
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
@ -246,14 +247,23 @@ static void pc_init1(MachineState *machine,
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pci_enabled && acpi_enabled) {
 | 
					    if (pci_enabled && acpi_enabled) {
 | 
				
			||||||
 | 
					        DeviceState *piix4_pm;
 | 
				
			||||||
        I2CBus *smbus;
 | 
					        I2CBus *smbus;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
 | 
					        smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
 | 
				
			||||||
        /* TODO: Populate SPD eeprom data.  */
 | 
					        /* TODO: Populate SPD eeprom data.  */
 | 
				
			||||||
        smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
 | 
					        smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
 | 
				
			||||||
                              gsi[9], *smi_irq,
 | 
					                              gsi[9], *smi_irq,
 | 
				
			||||||
                              kvm_enabled(), fw_cfg);
 | 
					                              kvm_enabled(), fw_cfg, &piix4_pm);
 | 
				
			||||||
        smbus_eeprom_init(smbus, 8, NULL, 0);
 | 
					        smbus_eeprom_init(smbus, 8, NULL, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
 | 
				
			||||||
 | 
					                                 TYPE_HOTPLUG_HANDLER,
 | 
				
			||||||
 | 
					                                 (Object **)&pc_machine->acpi_dev,
 | 
				
			||||||
 | 
					                                 object_property_allow_set_link,
 | 
				
			||||||
 | 
					                                 OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
 | 
				
			||||||
 | 
					        object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
 | 
				
			||||||
 | 
					                                 PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pci_enabled) {
 | 
					    if (pci_enabled) {
 | 
				
			||||||
 | 
				
			|||||||
@ -62,6 +62,7 @@ static bool has_reserved_memory = true;
 | 
				
			|||||||
/* PC hardware initialisation */
 | 
					/* PC hardware initialisation */
 | 
				
			||||||
static void pc_q35_init(MachineState *machine)
 | 
					static void pc_q35_init(MachineState *machine)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    PCMachineState *pc_machine = PC_MACHINE(machine);
 | 
				
			||||||
    ram_addr_t below_4g_mem_size, above_4g_mem_size;
 | 
					    ram_addr_t below_4g_mem_size, above_4g_mem_size;
 | 
				
			||||||
    Q35PCIHost *q35_host;
 | 
					    Q35PCIHost *q35_host;
 | 
				
			||||||
    PCIHostState *phb;
 | 
					    PCIHostState *phb;
 | 
				
			||||||
@ -178,6 +179,15 @@ static void pc_q35_init(MachineState *machine)
 | 
				
			|||||||
    lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
 | 
					    lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
 | 
				
			||||||
                                          ICH9_LPC_FUNC), true,
 | 
					                                          ICH9_LPC_FUNC), true,
 | 
				
			||||||
                                          TYPE_ICH9_LPC_DEVICE);
 | 
					                                          TYPE_ICH9_LPC_DEVICE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
 | 
				
			||||||
 | 
					                             TYPE_HOTPLUG_HANDLER,
 | 
				
			||||||
 | 
					                             (Object **)&pc_machine->acpi_dev,
 | 
				
			||||||
 | 
					                             object_property_allow_set_link,
 | 
				
			||||||
 | 
					                             OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
 | 
				
			||||||
 | 
					    object_property_set_link(OBJECT(machine), OBJECT(lpc),
 | 
				
			||||||
 | 
					                             PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ich9_lpc = ICH9_LPC_DEVICE(lpc);
 | 
					    ich9_lpc = ICH9_LPC_DEVICE(lpc);
 | 
				
			||||||
    ich9_lpc->pic = gsi;
 | 
					    ich9_lpc->pic = gsi;
 | 
				
			||||||
    ich9_lpc->ioapic = gsi_state->ioapic_irq;
 | 
					    ich9_lpc->ioapic = gsi_state->ioapic_irq;
 | 
				
			||||||
 | 
				
			|||||||
@ -1104,7 +1104,7 @@ void mips_malta_init(MachineState *machine)
 | 
				
			|||||||
    pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
 | 
					    pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
 | 
				
			||||||
    pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
 | 
					    pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
 | 
				
			||||||
    smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
 | 
					    smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
 | 
				
			||||||
                          isa_get_irq(NULL, 9), NULL, 0, NULL);
 | 
					                          isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);
 | 
				
			||||||
    smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size);
 | 
					    smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size);
 | 
				
			||||||
    g_free(smbus_eeprom_buf);
 | 
					    g_free(smbus_eeprom_buf);
 | 
				
			||||||
    pit = pit_init(isa_bus, 0x40, 0, NULL);
 | 
					    pit = pit_init(isa_bus, 0x40, 0, NULL);
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,7 @@
 | 
				
			|||||||
 * @hotplug_memory_base: address in guest RAM address space where hotplug memory
 | 
					 * @hotplug_memory_base: address in guest RAM address space where hotplug memory
 | 
				
			||||||
 * address space begins.
 | 
					 * address space begins.
 | 
				
			||||||
 * @hotplug_memory: hotplug memory addess space container
 | 
					 * @hotplug_memory: hotplug memory addess space container
 | 
				
			||||||
 | 
					 * @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct PCMachineState {
 | 
					struct PCMachineState {
 | 
				
			||||||
    /*< private >*/
 | 
					    /*< private >*/
 | 
				
			||||||
@ -29,8 +30,12 @@ struct PCMachineState {
 | 
				
			|||||||
    /* <public> */
 | 
					    /* <public> */
 | 
				
			||||||
    ram_addr_t hotplug_memory_base;
 | 
					    ram_addr_t hotplug_memory_base;
 | 
				
			||||||
    MemoryRegion hotplug_memory;
 | 
					    MemoryRegion hotplug_memory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    HotplugHandler *acpi_dev;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * PCMachineClass:
 | 
					 * PCMachineClass:
 | 
				
			||||||
 * @get_hotplug_handler: pointer to parent class callback @get_hotplug_handler
 | 
					 * @get_hotplug_handler: pointer to parent class callback @get_hotplug_handler
 | 
				
			||||||
@ -210,7 +215,8 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 | 
					I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 | 
				
			||||||
                      qemu_irq sci_irq, qemu_irq smi_irq,
 | 
					                      qemu_irq sci_irq, qemu_irq smi_irq,
 | 
				
			||||||
                      int kvm_enabled, FWCfgState *fw_cfg);
 | 
					                      int kvm_enabled, FWCfgState *fw_cfg,
 | 
				
			||||||
 | 
					                      DeviceState **piix4_pm);
 | 
				
			||||||
void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
 | 
					void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* hpet.c */
 | 
					/* hpet.c */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user