[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 50/61] pci hotadd, acpi_piix4: remove global variabl
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 50/61] pci hotadd, acpi_piix4: remove global variables. |
Date: |
Wed, 30 Sep 2009 19:18:26 +0900 |
remove global variables.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/acpi_piix4.c | 53 +++++++++++++++++++++++++++++++++--------------------
hw/pc.h | 1 -
hw/pc_piix.c | 2 --
3 files changed, 33 insertions(+), 23 deletions(-)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index c11e1b9..38c6a53 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -47,11 +47,11 @@ typedef struct PIIX4PMState {
qemu_irq irq;
} PIIX4PMState;
+static void piix4_acpi_system_hot_add_init(PIIX4PMState *s);
+
#define ACPI_ENABLE 0xf1
#define ACPI_DISABLE 0xf0
-static PIIX4PMState *pm_state;
-
static uint32_t get_pmtmr(PIIX4PMState *s)
{
uint32_t d;
@@ -328,7 +328,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t
smb_io_base,
s = (PIIX4PMState *)pci_register_device(bus,
"PM", sizeof(PIIX4PMState),
devfn, NULL, pm_write_config);
- pm_state = s;
+ piix4_acpi_system_hot_add_init(s);
+
pci_conf = s->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_3);
@@ -393,9 +394,6 @@ struct pci_status {
uint32_t down;
};
-static struct gpe_regs gpe;
-static struct pci_status pci0_status;
-
static uint32_t gpe_read_val(uint16_t val, uint32_t addr)
{
if (addr & 1)
@@ -526,20 +524,33 @@ static void pciej_write(void *opaque, uint32_t addr,
uint32_t val)
#endif
}
-static void piix4_device_hot_add(int bus, int slot, int state, void* opaque);
+static void piix4_device_hot_add(int bus, int slot, int state, void *opaque);
-void piix4_acpi_system_hot_add_init(void)
+struct piix4_hot_add {
+ struct gpe_regs *gpe;
+ struct pci_status *pci0_status;
+ PIIX4PMState *pm_state;
+};
+
+static void piix4_acpi_system_hot_add_init(PIIX4PMState *s)
{
- register_ioport_write(GPE_BASE, 4, 1, gpe_writeb, &gpe);
- register_ioport_read(GPE_BASE, 4, 1, gpe_readb, &gpe);
+ struct gpe_regs *gpe = qemu_mallocz(sizeof(*gpe));
+ struct pci_status *pci0_status = qemu_mallocz(sizeof(*pci0_status));
+ struct piix4_hot_add *hot_add_arg = qemu_malloc(sizeof(*hot_add_arg));
+ hot_add_arg->gpe = gpe;
+ hot_add_arg->pci0_status = pci0_status;
+ hot_add_arg->pm_state = s;
- register_ioport_write(PCI_BASE, 8, 4, pcihotplug_write, &pci0_status);
- register_ioport_read(PCI_BASE, 8, 4, pcihotplug_read, &pci0_status);
+ register_ioport_write(GPE_BASE, 4, 1, gpe_writeb, gpe);
+ register_ioport_read(GPE_BASE, 4, 1, gpe_readb, gpe);
+
+ register_ioport_write(PCI_BASE, 8, 4, pcihotplug_write, pci0_status);
+ register_ioport_read(PCI_BASE, 8, 4, pcihotplug_read, pci0_status);
register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, NULL);
register_ioport_read(PCI_EJ_BASE, 4, 4, pciej_read, NULL);
- qemu_system_device_hot_add_register(piix4_device_hot_add, NULL);
+ qemu_system_device_hot_add_register(piix4_device_hot_add, hot_add_arg);
}
static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot)
@@ -556,14 +567,16 @@ static void disable_device(struct pci_status *p, struct
gpe_regs *g, int slot)
static void piix4_device_hot_add(int bus, int slot, int state, void *opaque)
{
- pci0_status.up = 0;
- pci0_status.down = 0;
+ struct piix4_hot_add *hot_add_arg = opaque;
+
+ hot_add_arg->pci0_status->up = 0;
+ hot_add_arg->pci0_status->down = 0;
if (state)
- enable_device(&pci0_status, &gpe, slot);
+ enable_device(hot_add_arg->pci0_status, hot_add_arg->gpe, slot);
else
- disable_device(&pci0_status, &gpe, slot);
- if (gpe.en & 2) {
- qemu_set_irq(pm_state->irq, 1);
- qemu_set_irq(pm_state->irq, 0);
+ disable_device(hot_add_arg->pci0_status, hot_add_arg->gpe, slot);
+ if (hot_add_arg->gpe->en & 2) {
+ qemu_set_irq(hot_add_arg->pm_state->irq, 1);
+ qemu_set_irq(hot_add_arg->pm_state->irq, 0);
}
}
diff --git a/hw/pc.h b/hw/pc.h
index dcb62a4..cf34db6 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -148,7 +148,6 @@ int acpi_table_add(const char *table_desc);
i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
qemu_irq sci_irq);
void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
-void piix4_acpi_system_hot_add_init(void);
/* hpet.c */
extern int no_hpet;
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 4c8bb27..55b53d0 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -108,8 +108,6 @@ static void pc_init1(ram_addr_t ram_size,
pci_nic_init(nd, "e1000", NULL);
}
- piix4_acpi_system_hot_add_init();
-
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
fprintf(stderr, "qemu: too many IDE bus\n");
exit(1);
--
1.6.0.2
- [Qemu-devel] [PATCH 00/61] Q35 chip set and stuff., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 07/61] pc, i440fx: Make smm enable/disable function i440fx independent., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 05/61] acpi_piix4: remove unused variable in get_pmsts()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 32/61] pci: helper functions to access PCIDevice::config, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 50/61] pci hotadd, acpi_piix4: remove global variables.,
Isaku Yamahata <=
- [Qemu-devel] [PATCH 27/61] pci: clean up of pci_update_mappings(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 06/61] pc: fix file stream leak in multiboot loader., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 20/61] pci: fix PCI_DPRINTF() wrt variadic macro., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 19/61] pc_piix: initialize ioapic before use., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 31/61] pci: pcie host and mmcfg support., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 02/61] acpi: split out apm register emulation from acpi.c, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 26/61] pci: 64bit bar support., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 04/61] acpi: split acpi.c into the common part and the piix4 part., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 28/61] pci: factor out while(bus) bus->next loop logic into pci_find_bus_from()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 21/61] pci: introduce constant PCI_NUM_PINS for the number of interrupt pins, 4., Isaku Yamahata, 2009/09/30