Patchwork [20/26] pc, i440fx: simply i440fx initialization

login
register
mail settings
Submitter Isaku Yamahata
Date March 16, 2011, 9:29 a.m.
Message ID <e8202569498089450bf20a7de0a0318f57aa22d7.1300266238.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/87198/
State New
Headers show

Comments

Isaku Yamahata - March 16, 2011, 9:29 a.m.
simply i440fx initialization by eliminating
i440fx_init_memory_mappings().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/pc.h       |    2 +-
 hw/pc_piix.c  |    8 +-------
 hw/piix_pci.c |   15 ++++++---------
 3 files changed, 8 insertions(+), 17 deletions(-)

Patch

diff --git a/hw/pc.h b/hw/pc.h
index 598747d..d382bb6 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -178,7 +178,7 @@  int pcspk_audio_init(qemu_irq *pic);
 struct PCII440FXState;
 typedef struct PCII440FXState PCII440FXState;
 
-PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq *pic, ram_addr_t ram_size);
+PCIBus *i440fx_init(int *piix_devfn, qemu_irq *pic, ram_addr_t ram_size);
 void i440fx_init_memory_mappings(PCII440FXState *d);
 
 /* piix4.c */
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index f04d58b..a3697e7 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -58,7 +58,6 @@  static void pc_init1(ram_addr_t ram_size,
     int i;
     ram_addr_t below_4g_mem_size, above_4g_mem_size;
     PCIBus *pci_bus;
-    PCII440FXState *i440fx_state;
     int piix3_devfn = -1;
     qemu_irq *isa_irq;
     qemu_irq *cmos_s3;
@@ -84,10 +83,9 @@  static void pc_init1(ram_addr_t ram_size,
     }
 
     if (pci_enabled) {
-        pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq, ram_size);
+        pci_bus = i440fx_init(&piix3_devfn, isa_irq, ram_size);
     } else {
         pci_bus = NULL;
-        i440fx_state = NULL;
         isa_bus_new(NULL);
     }
     isa_bus_irqs(isa_irq);
@@ -136,10 +134,6 @@  static void pc_init1(ram_addr_t ram_size,
         smbus_eeprom_init(smbus, 8, NULL, 0);
     }
 
-    if (i440fx_state) {
-        i440fx_init_memory_mappings(i440fx_state);
-    }
-
     if (pci_enabled) {
         pc_pci_device_init(pci_bus);
     }
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index f619162..151353c 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -84,11 +84,6 @@  static void i440fx_set_smm(int val, void *arg)
     smram_set_smm(&d->pam, val, d->dev.config[I440FX_SMRAM]);
 }
 
-void i440fx_init_memory_mappings(PCII440FXState *d)
-{
-    pam_init_memory_mappings(&d->pam);
-}
-
 static void i440fx_write_config(PCIDevice *dev,
                                 uint32_t address, uint32_t val, int len)
 {
@@ -166,15 +161,17 @@  static int i440fx_initfn(PCIDevice *dev)
     d->dev.config[I440FX_SMRAM] = 0x02;
 
     cpu_smm_register(&i440fx_set_smm, d);
+    pam_init_memory_mappings(&d->pam);
     return 0;
 }
 
-PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *pic, ram_addr_t ram_size)
+PCIBus *i440fx_init(int *piix3_devfn, qemu_irq *pic, ram_addr_t ram_size)
 {
     DeviceState *dev;
     PCIBus *b;
     PCIDevice *d;
     I440FXState *s;
+    PCII440FXState *i440fx_state;
     PIIX3State *piix3;
 
     dev = qdev_create(NULL, "i440FX-pcihost");
@@ -184,20 +181,20 @@  PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *
     qdev_init_nofail(dev);
 
     d = pci_create_simple(b, 0, "i440FX");
-    *pi440fx_state = DO_UPCAST(PCII440FXState, dev, d);
+    i440fx_state = DO_UPCAST(PCII440FXState, dev, d);
 
     piix3 = DO_UPCAST(PIIX3State, dev,
                       pci_create_simple_multifunction(b, -1, true, "PIIX3"));
     piix3->pic = pic;
     pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, 4);
-    (*pi440fx_state)->piix3 = piix3;
+    i440fx_state->piix3 = piix3;
 
     *piix3_devfn = piix3->dev.devfn;
 
     ram_size = ram_size / 8 / 1024 / 1024;
     if (ram_size > 255)
         ram_size = 255;
-    (*pi440fx_state)->dev.config[0x57]=ram_size;
+    i440fx_state->dev.config[0x57]=ram_size;
 
     return b;
 }