From: Isaku Yamahata Date: Fri, 14 May 2010 07:29:19 +0000 (+0900) Subject: pci hotplug: add argument to pci hot plug callback. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~4957 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=337bbc057b2297e0e3015bfe86a64918e3c870f1;p=sdk%2Femulator%2Fqemu.git pci hotplug: add argument to pci hot plug callback. Add argument, DeviceState*, to pci hot plug callback. The argument will be used later to remove global variable. Signed-off-by: Isaku Yamahata Acked-by: Gerd Hoffmann Signed-off-by: Blue Swirl --- diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index d4f46620f4..c3e71e3211 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -568,7 +568,7 @@ static void pciej_write(void *opaque, uint32_t addr, uint32_t val) #endif } -static int piix4_device_hotplug(PCIDevice *dev, int state); +static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, int state); void piix4_acpi_system_hot_add_init(PCIBus *bus) { @@ -581,7 +581,7 @@ void piix4_acpi_system_hot_add_init(PCIBus *bus) register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, bus); register_ioport_read(PCI_EJ_BASE, 4, 4, pciej_read, bus); - pci_bus_hotplug(bus, piix4_device_hotplug); + pci_bus_hotplug(bus, piix4_device_hotplug, NULL); } static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot) @@ -596,7 +596,7 @@ static void disable_device(struct pci_status *p, struct gpe_regs *g, int slot) p->down |= (1 << slot); } -static int piix4_device_hotplug(PCIDevice *dev, int state) +static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, int state) { int slot = PCI_SLOT(dev->devfn); diff --git a/hw/pci.c b/hw/pci.c index f167436edc..679f06737f 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -42,6 +42,7 @@ struct PCIBus { pci_set_irq_fn set_irq; pci_map_irq_fn map_irq; pci_hotplug_fn hotplug; + DeviceState *hotplug_qdev; void *irq_opaque; PCIDevice *devices[256]; PCIDevice *parent_dev; @@ -233,10 +234,11 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, bus->irq_count = qemu_mallocz(nirq * sizeof(bus->irq_count[0])); } -void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug) +void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *qdev) { bus->qbus.allow_hotplug = 1; bus->hotplug = hotplug; + bus->hotplug_qdev = qdev; } void pci_bus_set_mem_base(PCIBus *bus, target_phys_addr_t base) @@ -1661,7 +1663,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_add_option_rom(pci_dev); if (qdev->hotplugged) - bus->hotplug(pci_dev, 1); + bus->hotplug(bus->hotplug_qdev, pci_dev, 1); return 0; } @@ -1669,7 +1671,7 @@ static int pci_unplug_device(DeviceState *qdev) { PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev); - dev->bus->hotplug(dev, 0); + dev->bus->hotplug(dev->bus->hotplug_qdev, dev, 0); return 0; } diff --git a/hw/pci.h b/hw/pci.h index 625188c0e6..f6e6c5f419 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -209,13 +209,13 @@ int pci_device_load(PCIDevice *s, QEMUFile *f); typedef void (*pci_set_irq_fn)(void *opaque, int irq_num, int level); typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num); -typedef int (*pci_hotplug_fn)(PCIDevice *pci_dev, int state); +typedef int (*pci_hotplug_fn)(DeviceState *qdev, PCIDevice *pci_dev, int state); void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent, const char *name, int devfn_min); PCIBus *pci_bus_new(DeviceState *parent, const char *name, int devfn_min); void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, void *irq_opaque, int nirq); -void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug); +void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *dev); PCIBus *pci_register_bus(DeviceState *parent, const char *name, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, void *irq_opaque, int devfn_min, int nirq);