Commit 9d5e77a22f1b8b502a11aa6288334c2787d8dbc8

Authored by Isaku Yamahata
Committed by Anthony Liguori
1 parent 30868442

acpi.c: make qemu_system_device_hot_add piix independent.

introruce piix4_device_hot_add() for piix4 specific code
and make qemu_system_device_hot_add() generic.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/acpi.c
... ... @@ -714,7 +714,9 @@ static void pciej_write(void *opaque, uint32_t addr, uint32_t val)
714 714 #endif
715 715 }
716 716  
717   -void qemu_system_hot_add_init(void)
  717 +static void piix4_device_hot_add(int bus, int slot, int state);
  718 +
  719 +void piix4_acpi_system_hot_add_init(void)
718 720 {
719 721 register_ioport_write(GPE_BASE, 4, 1, gpe_writeb, &gpe);
720 722 register_ioport_read(GPE_BASE, 4, 1, gpe_readb, &gpe);
... ... @@ -724,6 +726,8 @@ void qemu_system_hot_add_init(void)
724 726  
725 727 register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, NULL);
726 728 register_ioport_read(PCI_EJ_BASE, 4, 4, pciej_read, NULL);
  729 +
  730 + qemu_system_device_hot_add_register(piix4_device_hot_add);
727 731 }
728 732  
729 733 static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot)
... ... @@ -738,7 +742,7 @@ static void disable_device(struct pci_status *p, struct gpe_regs *g, int slot)
738 742 p->down |= (1 << slot);
739 743 }
740 744  
741   -void qemu_system_device_hot_add(int bus, int slot, int state)
  745 +static void piix4_device_hot_add(int bus, int slot, int state)
742 746 {
743 747 pci0_status.up = 0;
744 748 pci0_status.down = 0;
... ... @@ -752,6 +756,18 @@ void qemu_system_device_hot_add(int bus, int slot, int state)
752 756 }
753 757 }
754 758  
  759 +static qemu_system_device_hot_add_t device_hot_add_callback;
  760 +void qemu_system_device_hot_add_register(qemu_system_device_hot_add_t callback)
  761 +{
  762 + device_hot_add_callback = callback;
  763 +}
  764 +
  765 +void qemu_system_device_hot_add(int pcibus, int slot, int state)
  766 +{
  767 + if (device_hot_add_callback)
  768 + device_hot_add_callback(pcibus, slot, state);
  769 +}
  770 +
755 771 struct acpi_table_header
756 772 {
757 773 char signature [4]; /* ACPI signature (4 ASCII characters) */
... ...
... ... @@ -1081,7 +1081,7 @@ static void pc_init1(ram_addr_t ram_size,
1081 1081 pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
1082 1082 }
1083 1083  
1084   - qemu_system_hot_add_init();
  1084 + piix4_acpi_system_hot_add_init();
1085 1085  
1086 1086 if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
1087 1087 fprintf(stderr, "qemu: too many IDE bus\n");
... ...
... ... @@ -108,11 +108,14 @@ extern int acpi_enabled;
108 108 extern char *acpi_tables;
109 109 extern size_t acpi_tables_len;
110 110  
  111 +void acpi_bios_init(void);
  112 +int acpi_table_add(const char *table_desc);
  113 +
  114 +/* acpi_piix.c */
111 115 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
112 116 qemu_irq sci_irq);
113 117 void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
114   -void acpi_bios_init(void);
115   -int acpi_table_add(const char *table_desc);
  118 +void piix4_acpi_system_hot_add_init(void);
116 119  
117 120 /* hpet.c */
118 121 extern int no_hpet;
... ...
sysemu.h
... ... @@ -194,7 +194,8 @@ extern int drive_add(const char *file, const char *fmt, ...);
194 194 extern int drive_init(struct drive_opt *arg, int snapshot, void *machine);
195 195  
196 196 /* acpi */
197   -void qemu_system_hot_add_init(void);
  197 +typedef void (*qemu_system_device_hot_add_t)(int pcibus, int slot, int state);
  198 +void qemu_system_device_hot_add_register(qemu_system_device_hot_add_t callback);
198 199 void qemu_system_device_hot_add(int pcibus, int slot, int state);
199 200  
200 201 /* device-hotplug */
... ...