[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V10 23/27] pci hotadd, acpi_piix4: remove global var
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH V10 23/27] pci hotadd, acpi_piix4: remove global variables. |
Date: |
Thu, 24 Dec 2009 17:09:16 +0900 |
remove global variables, gpe and pci0_status by moving them
into PIIX4PMState.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/acpi_piix4.c | 71 +++++++++++++++++++++++++++++-------------------------
hw/pc.h | 1 -
hw/pc_piix.c | 1 -
3 files changed, 38 insertions(+), 35 deletions(-)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 94bbe59..59a4d0f 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -31,6 +31,20 @@
#define ACPI_DBG_IO_ADDR 0xb044
+#define GPE_BASE 0xafe0
+#define PCI_BASE 0xae00
+#define PCI_EJ_BASE 0xae08
+
+struct gpe_regs {
+ uint16_t sts; /* status */
+ uint16_t en; /* enabled */
+};
+
+struct pci_status {
+ uint32_t up;
+ uint32_t down;
+};
+
typedef struct PIIX4PMState {
PCIDevice dev;
uint16_t pmsts;
@@ -47,13 +61,17 @@ typedef struct PIIX4PMState {
qemu_irq irq;
qemu_irq cmos_s3_resume;
+
+ /* for pci hotplug */
+ struct gpe_regs gpe;
+ struct pci_status pci0_status;
} PIIX4PMState;
+static void piix4_acpi_system_hot_add_init(PCIBus *bus, PIIX4PMState *s);
+
#define ACPI_ENABLE 0xf1
#define ACPI_DISABLE 0xf0
-static PIIX4PMState *pm_state;
-
static uint32_t get_pmtmr(PIIX4PMState *s)
{
uint32_t d;
@@ -323,7 +341,6 @@ static int piix4_pm_initfn(PCIDevice *dev)
PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev, dev);
uint8_t *pci_conf;
- pm_state = 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);
@@ -384,6 +401,7 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t
smb_io_base,
s = DO_UPCAST(PIIX4PMState, dev, dev);
s->irq = sci_irq;
s->cmos_s3_resume = cmos_s3_resume;
+ piix4_acpi_system_hot_add_init(bus, s);
return s->smb.smbus;
}
@@ -408,23 +426,6 @@ static void piix4_pm_register(void)
device_init(piix4_pm_register);
-#define GPE_BASE 0xafe0
-#define PCI_BASE 0xae00
-#define PCI_EJ_BASE 0xae08
-
-struct gpe_regs {
- uint16_t sts; /* status */
- uint16_t en; /* enabled */
-};
-
-struct pci_status {
- uint32_t up;
- 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)
@@ -564,18 +565,21 @@ static void pciej_write(void *opaque, uint32_t addr,
uint32_t val)
static int piix4_device_hotplug(void *opaque, PCIDevice *dev, int state);
-void piix4_acpi_system_hot_add_init(PCIBus *bus)
+static void piix4_acpi_system_hot_add_init(PCIBus *bus, 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 = &s->gpe;
+ struct pci_status *pci0_status = &s->pci0_status;
- 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, bus);
register_ioport_read(PCI_EJ_BASE, 4, 4, pciej_read, bus);
- pci_bus_hotplug(bus, piix4_device_hotplug, NULL);
+ pci_bus_hotplug(bus, piix4_device_hotplug, s);
}
static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot)
@@ -593,16 +597,17 @@ static void disable_device(struct pci_status *p, struct
gpe_regs *g, int slot)
static int piix4_device_hotplug(void *opaque, PCIDevice *dev, int state)
{
int slot = PCI_SLOT(dev->devfn);
+ PIIX4PMState *s = opaque;
- pci0_status.up = 0;
- pci0_status.down = 0;
+ s->pci0_status.up = 0;
+ s->pci0_status.down = 0;
if (state)
- enable_device(&pci0_status, &gpe, slot);
+ enable_device(&s->pci0_status, &s->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(&s->pci0_status, &s->gpe, slot);
+ if (s->gpe.en & 2) {
+ qemu_set_irq(s->irq, 1);
+ qemu_set_irq(s->irq, 0);
}
return 0;
}
diff --git a/hw/pc.h b/hw/pc.h
index 2088cfd..e27ea97 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -141,7 +141,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, qemu_irq cmos_set_s3_resume);
void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
-void piix4_acpi_system_hot_add_init(PCIBus *bus);
/* hpet.c */
extern int no_hpet;
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 682b64c..fbe9857 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -158,7 +158,6 @@ static void pc_init1(ram_addr_t ram_size,
qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
qdev_init_nofail(eeprom);
}
- piix4_acpi_system_hot_add_init(pci_bus);
}
if (i440fx_state) {
--
1.6.5.4
- [Qemu-devel] [PATCH V10 17/27] pc: split out pci device init from pc_init1() into pc_pci_device_init(), (continued)
- [Qemu-devel] [PATCH V10 17/27] pc: split out pci device init from pc_init1() into pc_pci_device_init(), Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 19/27] pc: move rtc declarations from pc.h into a dedicated header file., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 27/27] mc146818rtc: remove #ifdef DEBUG_CMOS., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 21/27] acpi_piix4: qdevfy., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 04/27] acpi: split acpi.c into the common part and the piix4 part., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 22/27] pci hotplug: add argument to pci hot plug callback., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 09/27] pc: remove a global variable, floppy_controller., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 20/27] rtc: make rtc_xxx accept/return ISADevice instead of RTCState., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 15/27] pc: split out vga initialization from pc_init1() into pc_vga_init()., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 11/27] pc: introduce a function to allocate cpu irq., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 23/27] pci hotadd, acpi_piix4: remove global variables.,
Isaku Yamahata <=
- [Qemu-devel] [PATCH V10 01/27] acpi: split out pc smbus routines from acpi.c into pc_smbus.c, Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 08/27] pc: make an unnecessary global variable, pit, local., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 25/27] acpi_piix4: remove #ifdef DEBUG., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 13/27] pc: split out cpu initialization from pc_init1() into pc_cpus_init()., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 24/27] pc_smbus: remove #ifdef DEBUG., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 26/27] pc_apm: remove #ifdef DEBUG., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 07/27] pc, i440fx: Make smm enable/disable function i440fx independent., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 02/27] acpi: split out apm register emulation from acpi.c, Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 10/27] pc: remove global variable rtc_state by using qemu_irq., Isaku Yamahata, 2009/12/24
- [Qemu-devel] [PATCH V10 06/27] pc: initialize ioapic before use., Isaku Yamahata, 2009/12/24