Patchwork [v3,10/16] isa: give bus to isa_create() and isa_try_create() methods

login
register
mail settings
Submitter Hervé Poussineau
Date Oct. 2, 2011, 4:10 p.m.
Message ID <1317571828-9059-11-git-send-email-hpoussin@reactos.org>
Download mbox | patch
Permalink /patch/117344/
State New
Headers show

Comments

Hervé Poussineau - Oct. 2, 2011, 4:10 p.m.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/cs4231a.c       |    2 +-
 hw/fdc.h           |    4 ++--
 hw/gus.c           |    2 +-
 hw/ide.h           |    2 +-
 hw/ide/isa.c       |    4 ++--
 hw/isa-bus.c       |    8 ++++----
 hw/isa.h           |    6 +++---
 hw/m48t59.c        |    5 +++--
 hw/mc146818rtc.c   |    4 ++--
 hw/mc146818rtc.h   |    2 +-
 hw/mips_fulong2e.c |   18 +++++++++---------
 hw/mips_jazz.c     |    4 ++--
 hw/mips_malta.c    |   19 ++++++++++---------
 hw/mips_r4k.c      |   17 +++++++++--------
 hw/nvram.h         |    3 ++-
 hw/pc.c            |   34 +++++++++++++++++-----------------
 hw/pc.h            |   34 ++++++++++++++++++----------------
 hw/pc_piix.c       |    9 +++++----
 hw/piix4.c         |    6 ++++--
 hw/ppc_prep.c      |   16 +++++++++-------
 hw/sb16.c          |    2 +-
 hw/sun4u.c         |   19 +++++++++++--------
 hw/vt82c686.c      |    4 ++--
 hw/vt82c686.h      |    2 +-
 24 files changed, 120 insertions(+), 106 deletions(-)

Patch

diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index e697634..4f5e21c 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -661,7 +661,7 @@  static int cs4231a_initfn (ISADevice *dev)
 
 int cs4231a_init (ISABus *bus)
 {
-    isa_create_simple ("cs4231a");
+    isa_create_simple (bus, "cs4231a");
     return 0;
 }
 
diff --git a/hw/fdc.h b/hw/fdc.h
index 09f73c6..30bd56e 100644
--- a/hw/fdc.h
+++ b/hw/fdc.h
@@ -7,11 +7,11 @@ 
 /* fdc.c */
 #define MAX_FD 2
 
-static inline void fdctrl_init_isa(DriveInfo **fds)
+static inline void fdctrl_init_isa(ISABus *bus, DriveInfo **fds)
 {
     ISADevice *dev;
 
-    dev = isa_try_create("isa-fdc");
+    dev = isa_try_create(bus, "isa-fdc");
     if (!dev) {
         return;
     }
diff --git a/hw/gus.c b/hw/gus.c
index 2f40fcd..dc8a757 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -296,7 +296,7 @@  static int gus_initfn (ISADevice *dev)
 
 int GUS_init (ISABus *bus)
 {
-    isa_create_simple ("gus");
+    isa_create_simple (bus, "gus");
     return 0;
 }
 
diff --git a/hw/ide.h b/hw/ide.h
index 9059aae..7075170 100644
--- a/hw/ide.h
+++ b/hw/ide.h
@@ -7,7 +7,7 @@ 
 #define MAX_IDE_DEVS	2
 
 /* ide-isa.c */
-ISADevice *isa_ide_init(int iobase, int iobase2, int isairq,
+ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
                         DriveInfo *hd0, DriveInfo *hd1);
 
 /* ide-pci.c */
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 28b69d2..fb51b84 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -75,13 +75,13 @@  static int isa_ide_initfn(ISADevice *dev)
     return 0;
 };
 
-ISADevice *isa_ide_init(int iobase, int iobase2, int isairq,
+ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
                         DriveInfo *hd0, DriveInfo *hd1)
 {
     ISADevice *dev;
     ISAIDEState *s;
 
-    dev = isa_create("isa-ide");
+    dev = isa_create(bus, "isa-ide");
     qdev_prop_set_uint32(&dev->qdev, "iobase",  iobase);
     qdev_prop_set_uint32(&dev->qdev, "iobase2", iobase2);
     qdev_prop_set_uint32(&dev->qdev, "irq",     isairq);
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index e783a7f..ecc5375 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -147,7 +147,7 @@  void isa_qdev_register(ISADeviceInfo *info)
     qdev_register(&info->qdev);
 }
 
-ISADevice *isa_create(const char *name)
+ISADevice *isa_create(ISABus *bus, const char *name)
 {
     DeviceState *dev;
 
@@ -159,7 +159,7 @@  ISADevice *isa_create(const char *name)
     return DO_UPCAST(ISADevice, qdev, dev);
 }
 
-ISADevice *isa_try_create(const char *name)
+ISADevice *isa_try_create(ISABus *bus, const char *name)
 {
     DeviceState *dev;
 
@@ -171,11 +171,11 @@  ISADevice *isa_try_create(const char *name)
     return DO_UPCAST(ISADevice, qdev, dev);
 }
 
-ISADevice *isa_create_simple(const char *name)
+ISADevice *isa_create_simple(ISABus *bus, const char *name)
 {
     ISADevice *dev;
 
-    dev = isa_create(name);
+    dev = isa_create(bus, name);
     qdev_init_nofail(&dev->qdev);
     return dev;
 }
diff --git a/hw/isa.h b/hw/isa.h
index 551f3c4..484180c 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -53,9 +53,9 @@  void isa_init_ioport(ISADevice *dev, uint16_t ioport);
 void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);
 void isa_qdev_register(ISADeviceInfo *info);
 MemoryRegion *isa_address_space(ISADevice *dev);
-ISADevice *isa_create(const char *name);
-ISADevice *isa_try_create(const char *name);
-ISADevice *isa_create_simple(const char *name);
+ISADevice *isa_create(ISABus *bus, const char *name);
+ISADevice *isa_try_create(ISABus *bus, const char *name);
+ISADevice *isa_create_simple(ISABus *bus, const char *name);
 
 static inline ISABus *isa_bus_from_device(ISADevice *d)
 {
diff --git a/hw/m48t59.c b/hw/m48t59.c
index 0cc361e..582b0d7 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -655,13 +655,14 @@  M48t59State *m48t59_init(qemu_irq IRQ, target_phys_addr_t mem_base,
     return state;
 }
 
-M48t59State *m48t59_init_isa(uint32_t io_base, uint16_t size, int type)
+M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
+                             int type)
 {
     M48t59ISAState *d;
     ISADevice *dev;
     M48t59State *s;
 
-    dev = isa_create("m48t59_isa");
+    dev = isa_create(bus, "m48t59_isa");
     qdev_prop_set_uint32(&dev->qdev, "type", type);
     qdev_prop_set_uint32(&dev->qdev, "size", size);
     qdev_prop_set_uint32(&dev->qdev, "io_base", io_base);
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index feb3b25..c0e6853 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -641,12 +641,12 @@  static int rtc_initfn(ISADevice *dev)
     return 0;
 }
 
-ISADevice *rtc_init(int base_year, qemu_irq intercept_irq)
+ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
 {
     ISADevice *dev;
     RTCState *s;
 
-    dev = isa_create("mc146818rtc");
+    dev = isa_create(bus, "mc146818rtc");
     s = DO_UPCAST(RTCState, dev, dev);
     qdev_prop_set_int32(&dev->qdev, "base_year", base_year);
     qdev_init_nofail(&dev->qdev);
diff --git a/hw/mc146818rtc.h b/hw/mc146818rtc.h
index 575968c..f119930 100644
--- a/hw/mc146818rtc.h
+++ b/hw/mc146818rtc.h
@@ -5,7 +5,7 @@ 
 
 #define RTC_ISA_IRQ 8
 
-ISADevice *rtc_init(int base_year, qemu_irq intercept_irq);
+ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq);
 void rtc_set_memory(ISADevice *dev, int addr, int val);
 void rtc_set_date(ISADevice *dev, const struct tm *tm);
 
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index 3034a9c..f509b67 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -263,8 +263,8 @@  static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
     long bios_size;
     int64_t kernel_entry;
     qemu_irq *cpu_exit_irq;
-    int via_devfn;
     PCIBus *pci_bus;
+    ISABus *isa_bus;
     i2c_bus *smbus;
     int i;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
@@ -336,9 +336,9 @@  static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
     /* South bridge */
     ide_drive_get(hd, MAX_IDE_BUS);
 
-    via_devfn = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0),
-                               env->irq[5]);
-    if (via_devfn < 0) {
+    isa_bus = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0),
+                             env->irq[5]);
+    if (!isa_bus) {
         fprintf(stderr, "vt82c686b_init error\n");
         exit(1);
     }
@@ -353,23 +353,23 @@  static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
     smbus_eeprom_init(smbus, 1, eeprom_spd, sizeof(eeprom_spd));
 
     /* init other devices */
-    pit = pit_init(0x40, 0);
+    pit = pit_init(isa_bus, 0x40, 0);
     cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
     DMA_init(0, cpu_exit_irq);
 
     /* Super I/O */
-    isa_create_simple("i8042");
+    isa_create_simple(isa_bus, "i8042");
 
-    rtc_init(2000, NULL);
+    rtc_init(isa_bus, 2000, NULL);
 
     for(i = 0; i < MAX_SERIAL_PORTS; i++) {
         if (serial_hds[i]) {
-            serial_isa_init(i, serial_hds[i]);
+            serial_isa_init(isa_bus, i, serial_hds[i]);
         }
     }
 
     if (parallel_hds[0]) {
-        parallel_init(0, parallel_hds[0]);
+        parallel_init(isa_bus, 0, parallel_hds[0]);
     }
 
     /* Sound card */
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 3be9136..172df66 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -188,7 +188,7 @@  static void mips_jazz_init(MemoryRegion *address_space,
     isa_bus_irqs(i8259);
     cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
     DMA_init(0, cpu_exit_irq);
-    pit = pit_init(0x40, 0);
+    pit = pit_init(isa_bus, 0x40, 0);
     pcspk_init(pit);
 
     /* ISA IO space at 0x90000000 */
@@ -255,7 +255,7 @@  static void mips_jazz_init(MemoryRegion *address_space,
     fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds);
 
     /* Real time clock */
-    rtc_init(1980, NULL);
+    rtc_init(isa_bus, 1980, NULL);
     memory_region_init_io(rtc, &rtc_ops, NULL, "rtc", 0x1000);
     memory_region_add_subregion(address_space, 0x80004000, rtc);
 
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 67e666d..8126ca7 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -777,6 +777,7 @@  void mips_malta_init (ram_addr_t ram_size,
     target_long bios_size;
     int64_t kernel_entry;
     PCIBus *pci_bus;
+    ISABus *isa_bus;
     CPUState *env;
     qemu_irq *i8259 = NULL, *isa_irq;
     qemu_irq *cpu_exit_irq;
@@ -946,7 +947,7 @@  void mips_malta_init (ram_addr_t ram_size,
     /* Interrupt controller */
     /* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */
     i8259 = i8259_init(env->irq[2]);
-    piix4_devfn = piix4_init(pci_bus, 80, i8259);
+    isa_bus = piix4_init(pci_bus, 80, i8259, &piix4_devfn);
 
     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
     usb_uhci_piix4_init(pci_bus, piix4_devfn + 2);
@@ -954,25 +955,25 @@  void mips_malta_init (ram_addr_t ram_size,
                           NULL, NULL, 0);
     /* TODO: Populate SPD eeprom data.  */
     smbus_eeprom_init(smbus, 8, NULL, 0);
-    pit = pit_init(0x40, 0);
+    pit = pit_init(isa_bus, 0x40, 0);
     cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
     DMA_init(0, cpu_exit_irq);
 
     /* Super I/O */
-    isa_create_simple("i8042");
+    isa_create_simple(isa_bus, "i8042");
 
-    rtc_init(2000, NULL);
-    serial_isa_init(0, serial_hds[0]);
-    serial_isa_init(1, serial_hds[1]);
+    rtc_init(isa_bus, 2000, NULL);
+    serial_isa_init(isa_bus, 0, serial_hds[0]);
+    serial_isa_init(isa_bus, 1, serial_hds[1]);
     if (parallel_hds[0])
-        parallel_init(0, parallel_hds[0]);
+        parallel_init(isa_bus, 0, parallel_hds[0]);
     for(i = 0; i < MAX_FD; i++) {
         fd[i] = drive_get(IF_FLOPPY, 0, i);
     }
-    fdctrl_init_isa(fd);
+    fdctrl_init_isa(isa_bus, fd);
 
     /* Sound card */
-    audio_init(NULL, pci_bus);
+    audio_init(isa_bus, pci_bus);
 
     /* Network card */
     network_init();
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 3fdde27..cb099ab 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -164,6 +164,7 @@  void mips_r4k_init (ram_addr_t ram_size,
     CPUState *env;
     ResetData *reset_info;
     int i;
+    ISABus *isa_bus;
     qemu_irq *i8259;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     DriveInfo *dinfo;
@@ -256,36 +257,36 @@  void mips_r4k_init (ram_addr_t ram_size,
     cpu_mips_clock_init(env);
 
     /* The PIC is attached to the MIPS CPU INT0 pin */
-    isa_bus_bridge_init(get_system_io());
+    isa_bus = isa_bus_bridge_init(get_system_io());
     i8259 = i8259_init(env->irq[2]);
     isa_bus_irqs(i8259);
 
-    rtc_init(2000, NULL);
+    rtc_init(isa_bus, 2000, NULL);
 
     /* Register 64 KB of ISA IO space at 0x14000000 */
     isa_mmio_init(0x14000000, 0x00010000);
     isa_mem_base = 0x10000000;
 
-    pit = pit_init(0x40, 0);
+    pit = pit_init(isa_bus, 0x40, 0);
 
     for(i = 0; i < MAX_SERIAL_PORTS; i++) {
         if (serial_hds[i]) {
-            serial_isa_init(i, serial_hds[i]);
+            serial_isa_init(isa_bus, i, serial_hds[i]);
         }
     }
 
-    isa_vga_init();
+    isa_vga_init(isa_bus);
 
     if (nd_table[0].vlan)
-        isa_ne2000_init(0x300, 9, &nd_table[0]);
+        isa_ne2000_init(isa_bus, 0x300, 9, &nd_table[0]);
 
     ide_drive_get(hd, MAX_IDE_BUS);
     for(i = 0; i < MAX_IDE_BUS; i++)
-        isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
+        isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i],
                      hd[MAX_IDE_DEVS * i],
 		     hd[MAX_IDE_DEVS * i + 1]);
 
-    isa_create_simple("i8042");
+    isa_create_simple(isa_bus, "i8042");
 }
 
 static QEMUMachine mips_machine = {
diff --git a/hw/nvram.h b/hw/nvram.h
index 0f55b24..8924da4 100644
--- a/hw/nvram.h
+++ b/hw/nvram.h
@@ -34,7 +34,8 @@  typedef struct M48t59State M48t59State;
 void m48t59_write (void *private, uint32_t addr, uint32_t val);
 uint32_t m48t59_read (void *private, uint32_t addr);
 void m48t59_toggle_lock (void *private, int lock);
-M48t59State *m48t59_init_isa(uint32_t io_base, uint16_t size, int type);
+M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
+                             int type);
 M48t59State *m48t59_init(qemu_irq IRQ, target_phys_addr_t mem_base,
                          uint32_t io_base, uint16_t size, int type);
 void m48t59_set_addr (void *opaque, uint32_t addr);
diff --git a/hw/pc.c b/hw/pc.c
index 203627d..c17218b 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -843,13 +843,13 @@  static const int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 };
 static const int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
 static const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
 
-void pc_init_ne2k_isa(NICInfo *nd)
+void pc_init_ne2k_isa(ISABus *isa_bus, NICInfo *nd)
 {
     static int nb_ne2k = 0;
 
     if (nb_ne2k == NE2000_NB_MAX)
         return;
-    isa_ne2000_init(ne2000_io[nb_ne2k],
+    isa_ne2000_init(isa_bus, ne2000_io[nb_ne2k],
                     ne2000_irq[nb_ne2k], nd);
     nb_ne2k++;
 }
@@ -1064,12 +1064,12 @@  qemu_irq *pc_allocate_cpu_irq(void)
     return qemu_allocate_irqs(pic_irq_request, NULL, 1);
 }
 
-void pc_vga_init(PCIBus *pci_bus)
+void pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)
 {
     if (cirrus_vga_enabled) {
         if (pci_bus) {
             pci_cirrus_vga_init(pci_bus);
-        } else {
+        } else if (isa_bus) {
             isa_cirrus_vga_init(get_system_memory());
         }
     } else if (vmsvga_enabled) {
@@ -1092,8 +1092,8 @@  void pc_vga_init(PCIBus *pci_bus)
     } else if (std_vga_enabled) {
         if (pci_bus) {
             pci_vga_init(pci_bus);
-        } else {
-            isa_vga_init();
+        } else if (isa_bus) {
+            isa_vga_init(isa_bus);
         }
     }
 
@@ -1103,7 +1103,7 @@  void pc_vga_init(PCIBus *pci_bus)
      * For nographic case, sga is enabled at all times
      */
     if (display_type == DT_NOGRAPHIC) {
-        isa_create_simple("sga");
+        isa_create_simple(isa_bus, "sga");
     }
 }
 
@@ -1116,7 +1116,7 @@  static void cpu_request_exit(void *opaque, int irq, int level)
     }
 }
 
-void pc_basic_device_init(qemu_irq *isa_irq,
+void pc_basic_device_init(ISABus *isa_bus, qemu_irq *isa_irq,
                           ISADevice **rtc_state,
                           bool no_vmport)
 {
@@ -1141,31 +1141,31 @@  void pc_basic_device_init(qemu_irq *isa_irq,
             rtc_irq = qdev_get_gpio_in(hpet, 0);
         }
     }
-    *rtc_state = rtc_init(2000, rtc_irq);
+    *rtc_state = rtc_init(isa_bus, 2000, rtc_irq);
 
     qemu_register_boot_set(pc_boot_set, *rtc_state);
 
-    pit = pit_init(0x40, 0);
+    pit = pit_init(isa_bus, 0x40, 0);
     pcspk_init(pit);
 
     for(i = 0; i < MAX_SERIAL_PORTS; i++) {
         if (serial_hds[i]) {
-            serial_isa_init(i, serial_hds[i]);
+            serial_isa_init(isa_bus, i, serial_hds[i]);
         }
     }
 
     for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
         if (parallel_hds[i]) {
-            parallel_init(i, parallel_hds[i]);
+            parallel_init(isa_bus, i, parallel_hds[i]);
         }
     }
 
     a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
-    i8042 = isa_create_simple("i8042");
+    i8042 = isa_create_simple(isa_bus, "i8042");
     i8042_setup_a20_line(i8042, &a20_line[0]);
     if (!no_vmport) {
-        vmport_init();
-        vmmouse = isa_try_create("vmmouse");
+        vmport_init(isa_bus);
+        vmmouse = isa_try_create(isa_bus, "vmmouse");
     } else {
         vmmouse = NULL;
     }
@@ -1173,7 +1173,7 @@  void pc_basic_device_init(qemu_irq *isa_irq,
         qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
         qdev_init_nofail(&vmmouse->qdev);
     }
-    port92 = isa_create_simple("port92");
+    port92 = isa_create_simple(isa_bus, "port92");
     port92_init(port92, &a20_line[1]);
 
     cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
@@ -1182,7 +1182,7 @@  void pc_basic_device_init(qemu_irq *isa_irq,
     for(i = 0; i < MAX_FD; i++) {
         fd[i] = drive_get(IF_FLOPPY, 0, i);
     }
-    fdctrl_init_isa(fd);
+    fdctrl_init_isa(isa_bus, fd);
 }
 
 void pc_pci_device_init(PCIBus *pci_bus)
diff --git a/hw/pc.h b/hw/pc.h
index df7d86a..46b2320 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -19,11 +19,12 @@  SerialState *serial_mm_init (target_phys_addr_t base, int it_shift,
                              qemu_irq irq, int baudbase,
                              CharDriverState *chr, int ioregister,
                              int be);
-static inline bool serial_isa_init(int index, CharDriverState *chr)
+static inline bool serial_isa_init(ISABus *bus, int index,
+                                   CharDriverState *chr)
 {
     ISADevice *dev;
 
-    dev = isa_try_create("isa-serial");
+    dev = isa_try_create(bus, "isa-serial");
     if (!dev) {
         return false;
     }
@@ -38,11 +39,11 @@  static inline bool serial_isa_init(int index, CharDriverState *chr)
 void serial_set_frequency(SerialState *s, uint32_t frequency);
 
 /* parallel.c */
-static inline bool parallel_init(int index, CharDriverState *chr)
+static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr)
 {
     ISADevice *dev;
 
-    dev = isa_try_create("isa-parallel");
+    dev = isa_try_create(bus, "isa-parallel");
     if (!dev) {
         return false;
     }
@@ -84,11 +85,11 @@  void isa_irq_handler(void *opaque, int n, int level);
 
 #define PIT_FREQ 1193182
 
-static inline ISADevice *pit_init(int base, int irq)
+static inline ISADevice *pit_init(ISABus *bus, int base, int irq)
 {
     ISADevice *dev;
 
-    dev = isa_create("isa-pit");
+    dev = isa_create(bus, "isa-pit");
     qdev_prop_set_uint32(&dev->qdev, "iobase", base);
     qdev_prop_set_uint32(&dev->qdev, "irq", irq);
     qdev_init_nofail(&dev->qdev);
@@ -106,9 +107,9 @@  void hpet_pit_disable(void);
 void hpet_pit_enable(void);
 
 /* vmport.c */
-static inline void vmport_init(void)
+static inline void vmport_init(ISABus *bus)
 {
-    isa_create_simple("vmport");
+    isa_create_simple(bus, "vmport");
 }
 void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque);
 void vmmouse_get_data(uint32_t *data);
@@ -140,11 +141,11 @@  void pc_memory_init(MemoryRegion *system_memory,
                     MemoryRegion *rom_memory,
                     MemoryRegion **ram_memory);
 qemu_irq *pc_allocate_cpu_irq(void);
-void pc_vga_init(PCIBus *pci_bus);
-void pc_basic_device_init(qemu_irq *isa_irq,
+void pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
+void pc_basic_device_init(ISABus *isa_bus, qemu_irq *isa_irq,
                           ISADevice **rtc_state,
                           bool no_vmport);
-void pc_init_ne2k_isa(NICInfo *nd);
+void pc_init_ne2k_isa(ISABus *isa_bus, NICInfo *nd);
 void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
                   const char *boot_device,
                   BusState *ide0, BusState *ide1,
@@ -194,7 +195,8 @@  PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
 
 /* piix4.c */
 extern PCIDevice *piix4_dev;
-int piix4_init(PCIBus *bus, int devfn, qemu_irq *isa_irqs);
+ISABus *piix4_init(PCIBus *bus, int devfn, qemu_irq *isa_irqs,
+                   int *piix4_devfn);
 
 /* vga.c */
 enum vga_retrace_method {
@@ -204,11 +206,11 @@  enum vga_retrace_method {
 
 extern enum vga_retrace_method vga_retrace_method;
 
-static inline int isa_vga_init(void)
+static inline int isa_vga_init(ISABus *bus)
 {
     ISADevice *dev;
 
-    dev = isa_try_create("isa-vga");
+    dev = isa_try_create(bus, "isa-vga");
     if (!dev) {
         fprintf(stderr, "Warning: isa-vga not available\n");
         return 0;
@@ -227,13 +229,13 @@  void pci_cirrus_vga_init(PCIBus *bus);
 void isa_cirrus_vga_init(MemoryRegion *address_space);
 
 /* ne2000.c */
-static inline bool isa_ne2000_init(int base, int irq, NICInfo *nd)
+static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
 {
     ISADevice *dev;
 
     qemu_check_nic_model(nd, "ne2k_isa");
 
-    dev = isa_try_create("ne2k_isa");
+    dev = isa_try_create(bus, "ne2k_isa");
     if (!dev) {
         return false;
     }
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 85b4d34..a5f8b7a 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -166,20 +166,20 @@  static void pc_init1(MemoryRegion *system_memory,
 
     pc_register_ferr_irq(isa_get_irq(13));
 
-    pc_vga_init(pci_enabled? pci_bus: NULL);
+    pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
 
     if (xen_enabled()) {
         pci_create_simple(pci_bus, -1, "xen-platform");
     }
 
     /* init basic PC hardware */
-    pc_basic_device_init(isa_irq, &rtc_state, xen_enabled());
+    pc_basic_device_init(isa_bus, isa_irq, &rtc_state, xen_enabled());
 
     for(i = 0; i < nb_nics; i++) {
         NICInfo *nd = &nd_table[i];
 
         if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
-            pc_init_ne2k_isa(nd);
+            pc_init_ne2k_isa(isa_bus, nd);
         else
             pci_nic_init_nofail(nd, "e1000", NULL);
     }
@@ -197,7 +197,8 @@  static void pc_init1(MemoryRegion *system_memory,
     } else {
         for(i = 0; i < MAX_IDE_BUS; i++) {
             ISADevice *dev;
-            dev = isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
+            dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
+                               ide_irq[i],
                                hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
             idebus[i] = qdev_get_child_bus(&dev->qdev, "ide.0");
         }
diff --git a/hw/piix4.c b/hw/piix4.c
index ce11ef4..caada0b 100644
--- a/hw/piix4.c
+++ b/hw/piix4.c
@@ -122,7 +122,8 @@  static int piix4_initfn(PCIDevice *dev)
     return 0;
 }
 
-int piix4_init(PCIBus *bus, int devfn, qemu_irq *isa_irqs)
+ISABus *piix4_init(PCIBus *bus, int devfn, qemu_irq *isa_irqs,
+                   int *piix4_devfn)
 {
     PCIDevice *d;
     PIIX4State *s;
@@ -131,7 +132,8 @@  int piix4_init(PCIBus *bus, int devfn, qemu_irq *isa_irqs)
     s = DO_UPCAST(PIIX4State, dev, d);
     s->isa_irq = isa_irqs;
 
-    return d->devfn;
+    *piix4_devfn = d->devfn;
+    return &s->bus;
 }
 
 static PCIDeviceInfo piix4_info[] = {
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index d1e73d1..499e63f 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -544,6 +544,7 @@  static void ppc_prep_init (ram_addr_t ram_size,
     uint32_t kernel_base, initrd_base;
     long kernel_size, initrd_size;
     PCIBus *pci_bus;
+    ISABus *isa_bus;
     qemu_irq *i8259;
     qemu_irq *cpu_exit_irq;
     int ppc_boot_device;
@@ -649,7 +650,7 @@  static void ppc_prep_init (ram_addr_t ram_size,
         hw_error("Only 6xx bus is supported on PREP machine\n");
     }
     /* Hmm, prep has no pci-isa bridge ??? */
-    isa_bus_bridge_init(get_system_io());
+    isa_bus = isa_bus_bridge_init(get_system_io());
     i8259 = i8259_init(first_cpu->irq_inputs[PPC6xx_INPUT_INT]);
     pci_bus = pci_prep_init(i8259, get_system_memory(), get_system_io());
     isa_bus_irqs(i8259);
@@ -664,10 +665,10 @@  static void ppc_prep_init (ram_addr_t ram_size,
     pci_vga_init(pci_bus);
     //    openpic = openpic_init(0x00000000, 0xF0000000, 1);
     //    pit = pit_init(0x40, 0);
-    rtc_init(2000, NULL);
+    rtc_init(isa_bus, 2000, NULL);
 
     if (serial_hds[0])
-        serial_isa_init(0, serial_hds[0]);
+        serial_isa_init(isa_bus, 0, serial_hds[0]);
     nb_nics1 = nb_nics;
     if (nb_nics1 > NE2000_NB_MAX)
         nb_nics1 = NE2000_NB_MAX;
@@ -676,7 +677,8 @@  static void ppc_prep_init (ram_addr_t ram_size,
 	    nd_table[i].model = g_strdup("ne2k_isa");
         }
         if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
-            isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
+            isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i],
+                            &nd_table[i]);
         } else {
             pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
         }
@@ -684,11 +686,11 @@  static void ppc_prep_init (ram_addr_t ram_size,
 
     ide_drive_get(hd, MAX_IDE_BUS);
     for(i = 0; i < MAX_IDE_BUS; i++) {
-        isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
+        isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i],
                      hd[2 * i],
 		     hd[2 * i + 1]);
     }
-    isa_create_simple("i8042");
+    isa_create_simple(isa_bus, "i8042");
 
     cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
     DMA_init(1, cpu_exit_irq);
@@ -698,7 +700,7 @@  static void ppc_prep_init (ram_addr_t ram_size,
     for(i = 0; i < MAX_FD; i++) {
         fd[i] = drive_get(IF_FLOPPY, 0, i);
     }
-    fdctrl_init_isa(fd);
+    fdctrl_init_isa(isa_bus, fd);
 
     /* Register speaker port */
     register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
diff --git a/hw/sb16.c b/hw/sb16.c
index 15a1e61..fad664b 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -1393,7 +1393,7 @@  static int sb16_initfn (ISADevice *dev)
 
 int SB16_init (ISABus *bus)
 {
-    isa_create_simple ("sb16");
+    isa_create_simple (bus, "sb16");
     return 0;
 }
 
diff --git a/hw/sun4u.c b/hw/sun4u.c
index d8b8054..43d27db 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -536,10 +536,12 @@  static void dummy_isa_irq_handler(void *opaque, int n, int level)
 }
 
 /* EBUS (Eight bit bus) bridge */
-static void
+static ISABus *
 pci_ebus_init(PCIBus *bus, int devfn)
 {
-    pci_create_simple(bus, devfn, "ebus");
+    PCIDevice *pci = pci_create_simple(bus, devfn, "ebus");
+    BusState *isa = qdev_get_child_bus(&pci->qdev, "isa.0");
+    return DO_UPCAST(ISABus, qbus, isa);
 }
 
 static qemu_irq pci_ebus_get_irq(ISABus *bus, int isairq)
@@ -771,6 +773,7 @@  static void sun4uv_init(ram_addr_t RAM_size,
     unsigned int i;
     long initrd_size, kernel_size;
     PCIBus *pci_bus, *pci_bus2, *pci_bus3;
+    ISABus *isa_bus;
     qemu_irq *irq;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     DriveInfo *fd[MAX_FD];
@@ -791,7 +794,7 @@  static void sun4uv_init(ram_addr_t RAM_size,
     pci_vga_init(pci_bus);
 
     // XXX Should be pci_bus3
-    pci_ebus_init(pci_bus, -1);
+    isa_bus = pci_ebus_init(pci_bus, -1);
 
     i = 0;
     if (hwdef->console_serial_base) {
@@ -801,13 +804,13 @@  static void sun4uv_init(ram_addr_t RAM_size,
     }
     for(; i < MAX_SERIAL_PORTS; i++) {
         if (serial_hds[i]) {
-            serial_isa_init(i, serial_hds[i]);
+            serial_isa_init(isa_bus, i, serial_hds[i]);
         }
     }
 
     for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
         if (parallel_hds[i]) {
-            parallel_init(i, parallel_hds[i]);
+            parallel_init(isa_bus, i, parallel_hds[i]);
         }
     }
 
@@ -818,12 +821,12 @@  static void sun4uv_init(ram_addr_t RAM_size,
 
     pci_cmd646_ide_init(pci_bus, hd, 1);
 
-    isa_create_simple("i8042");
+    isa_create_simple(isa_bus, "i8042");
     for(i = 0; i < MAX_FD; i++) {
         fd[i] = drive_get(IF_FLOPPY, 0, i);
     }
-    fdctrl_init_isa(fd);
-    nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59);
+    fdctrl_init_isa(isa_bus, fd);
+    nvram = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59);
 
     initrd_size = 0;
     kernel_size = sun4u_load_kernel(kernel_filename, initrd_filename,
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 05a70da..c40423d 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -530,7 +530,7 @@  static int vt82c686b_initfn(PCIDevice *d)
     return 0;
 }
 
-int vt82c686b_init(PCIBus *bus, int devfn, qemu_irq parent_irq)
+ISABus *vt82c686b_init(PCIBus *bus, int devfn, qemu_irq parent_irq)
 {
     PCIDevice *d;
     VT82C686BState *vt82c;
@@ -540,7 +540,7 @@  int vt82c686b_init(PCIBus *bus, int devfn, qemu_irq parent_irq)
     vt82c = DO_UPCAST(VT82C686BState, dev, d);
     vt82c->pic = i8259_init(parent_irq);
 
-    return d->devfn;
+    return &vt82c->bus;
 }
 
 static PCIDeviceInfo via_info = {
diff --git a/hw/vt82c686.h b/hw/vt82c686.h
index 1a026c2..601d992 100644
--- a/hw/vt82c686.h
+++ b/hw/vt82c686.h
@@ -2,7 +2,7 @@ 
 #define HW_VT82C686_H
 
 /* vt82c686.c */
-int vt82c686b_init(PCIBus *bus, int devfn, qemu_irq parent_irq);
+ISABus *vt82c686b_init(PCIBus *bus, int devfn, qemu_irq parent_irq);
 void vt82c686b_ac97_init(PCIBus *bus, int devfn);
 void vt82c686b_mc97_init(PCIBus *bus, int devfn);
 i2c_bus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,