Patchwork [14/20,MIPS] qdev: add an isa bus device

login
register
mail settings
Submitter Hervé Poussineau
Date Aug. 1, 2010, 5:37 p.m.
Message ID <1280684242-19611-14-git-send-email-hpoussin@reactos.org>
Download mbox | patch
Permalink /patch/60484/
State New
Headers show

Comments

Hervé Poussineau - Aug. 1, 2010, 5:37 p.m.
Use it in Jazz emulation

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/isa-bus.c   |   29 +++++++++++++++++++++++++++++
 hw/mips_jazz.c |   12 ++----------
 2 files changed, 31 insertions(+), 10 deletions(-)

Patch

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 4e306de..c245151 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -21,6 +21,7 @@ 
 #include "monitor.h"
 #include "sysbus.h"
 #include "isa.h"
+#include "qdev-addr.h"
 
 struct ISABus {
     BusState qbus;
@@ -53,6 +54,22 @@  ISABus *isa_bus_new(DeviceState *dev)
     return isabus;
 }
 
+typedef struct IsaBusState {
+    SysBusDevice dev;
+    target_phys_addr_t iobase;
+    uint32_t size;
+} IsaBusState;
+
+static int isabus_init(SysBusDevice *dev)
+{
+    IsaBusState *bus = DO_UPCAST(IsaBusState, dev, dev);
+
+    if (isa_bus_new(NULL) == NULL)
+        return -1;
+    isa_mmio_init(bus->iobase, bus->size, 0);
+    return 0;
+}
+
 void isa_bus_irqs(qemu_irq *irqs)
 {
     isabus->irqs = irqs;
@@ -157,9 +174,21 @@  static SysBusDeviceInfo isabus_bridge_info = {
     .qdev.no_user = 1,
 };
 
+static SysBusDeviceInfo isabus_info = {
+    .init = isabus_init,
+    .qdev.name  = "isabus",
+    .qdev.size  = sizeof(IsaBusState),
+    .qdev.props = (Property[]) {
+        DEFINE_PROP_TADDR("iobase", IsaBusState, iobase, 0x90000000),
+        DEFINE_PROP_HEX32("size", IsaBusState, size, 0x1000000),
+        DEFINE_PROP_END_OF_LIST(),
+    },
+};
+
 static void isabus_register_devices(void)
 {
     sysbus_register_withprop(&isabus_bridge_info);
+    sysbus_register_withprop(&isabus_info);
 }
 
 device_init(isabus_register_devices)
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index b9c6b62..cf0001e 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -163,23 +163,15 @@  void mips_jazz_init (ram_addr_t ram_size,
     cpu_register_physical_memory(0x8000d000, 0x00001000, s_dma_dummy);
 
     /* ISA devices */
+    dev = qdev_create(NULL, "isabus");
+    qdev_init_nofail(dev);
     i8259 = i8259_init(qdev_get_gpio_in(cpu->parent, 4));
-    isa_bus_new(NULL);
     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, i8259[0]);
     pcspk_init(pit);
 
-    /* ISA IO space at 0x90000000 */
-#ifdef TARGET_WORDS_BIGENDIAN
-    isa_mmio_init(0x90000000, 0x01000000, 1);
-#else
-    isa_mmio_init(0x90000000, 0x01000000, 0);
-#endif
-
-    isa_mem_base = 0x11000000;
-
     /* Optional video card */
     if (vga_interface_type != VGA_NONE) {
         switch (jazz_model) {