提交 9d5e77a2 编写于 作者: I Isaku Yamahata 提交者: Anthony Liguori

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: NIsaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 30868442
...@@ -714,7 +714,9 @@ static void pciej_write(void *opaque, uint32_t addr, uint32_t val) ...@@ -714,7 +714,9 @@ static void pciej_write(void *opaque, uint32_t addr, uint32_t val)
#endif #endif
} }
void qemu_system_hot_add_init(void) static void piix4_device_hot_add(int bus, int slot, int state);
void piix4_acpi_system_hot_add_init(void)
{ {
register_ioport_write(GPE_BASE, 4, 1, gpe_writeb, &gpe); register_ioport_write(GPE_BASE, 4, 1, gpe_writeb, &gpe);
register_ioport_read(GPE_BASE, 4, 1, gpe_readb, &gpe); register_ioport_read(GPE_BASE, 4, 1, gpe_readb, &gpe);
...@@ -724,6 +726,8 @@ void qemu_system_hot_add_init(void) ...@@ -724,6 +726,8 @@ void qemu_system_hot_add_init(void)
register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, NULL); register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, NULL);
register_ioport_read(PCI_EJ_BASE, 4, 4, pciej_read, NULL); register_ioport_read(PCI_EJ_BASE, 4, 4, pciej_read, NULL);
qemu_system_device_hot_add_register(piix4_device_hot_add);
} }
static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot) 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,7 +742,7 @@ static void disable_device(struct pci_status *p, struct gpe_regs *g, int slot)
p->down |= (1 << slot); p->down |= (1 << slot);
} }
void qemu_system_device_hot_add(int bus, int slot, int state) static void piix4_device_hot_add(int bus, int slot, int state)
{ {
pci0_status.up = 0; pci0_status.up = 0;
pci0_status.down = 0; pci0_status.down = 0;
...@@ -752,6 +756,18 @@ void qemu_system_device_hot_add(int bus, int slot, int state) ...@@ -752,6 +756,18 @@ void qemu_system_device_hot_add(int bus, int slot, int state)
} }
} }
static qemu_system_device_hot_add_t device_hot_add_callback;
void qemu_system_device_hot_add_register(qemu_system_device_hot_add_t callback)
{
device_hot_add_callback = callback;
}
void qemu_system_device_hot_add(int pcibus, int slot, int state)
{
if (device_hot_add_callback)
device_hot_add_callback(pcibus, slot, state);
}
struct acpi_table_header struct acpi_table_header
{ {
char signature [4]; /* ACPI signature (4 ASCII characters) */ char signature [4]; /* ACPI signature (4 ASCII characters) */
......
...@@ -1081,7 +1081,7 @@ static void pc_init1(ram_addr_t ram_size, ...@@ -1081,7 +1081,7 @@ static void pc_init1(ram_addr_t ram_size,
pci_nic_init(pci_bus, nd, -1, "ne2k_pci"); pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
} }
qemu_system_hot_add_init(); piix4_acpi_system_hot_add_init();
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n"); fprintf(stderr, "qemu: too many IDE bus\n");
......
...@@ -108,11 +108,14 @@ extern int acpi_enabled; ...@@ -108,11 +108,14 @@ extern int acpi_enabled;
extern char *acpi_tables; extern char *acpi_tables;
extern size_t acpi_tables_len; extern size_t acpi_tables_len;
void acpi_bios_init(void);
int acpi_table_add(const char *table_desc);
/* acpi_piix.c */
i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
qemu_irq sci_irq); qemu_irq sci_irq);
void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr); void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
void acpi_bios_init(void); void piix4_acpi_system_hot_add_init(void);
int acpi_table_add(const char *table_desc);
/* hpet.c */ /* hpet.c */
extern int no_hpet; extern int no_hpet;
......
...@@ -194,7 +194,8 @@ extern int drive_add(const char *file, const char *fmt, ...); ...@@ -194,7 +194,8 @@ extern int drive_add(const char *file, const char *fmt, ...);
extern int drive_init(struct drive_opt *arg, int snapshot, void *machine); extern int drive_init(struct drive_opt *arg, int snapshot, void *machine);
/* acpi */ /* acpi */
void qemu_system_hot_add_init(void); typedef void (*qemu_system_device_hot_add_t)(int pcibus, int slot, int state);
void qemu_system_device_hot_add_register(qemu_system_device_hot_add_t callback);
void qemu_system_device_hot_add(int pcibus, int slot, int state); void qemu_system_device_hot_add(int pcibus, int slot, int state);
/* device-hotplug */ /* device-hotplug */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册