Patchwork [3/7] m48t59: move ISA ports/memory regions registration to QOM constructor

login
register
mail settings
Submitter Hervé Poussineau
Date May 2, 2013, 8:09 p.m.
Message ID <1367525344-7755-4-git-send-email-hpoussin@reactos.org>
Download mbox | patch
Permalink /patch/241071/
State New
Headers show

Comments

Hervé Poussineau - May 2, 2013, 8:09 p.m.
-device m48t59_isa can now be used to create a fully functional nvram.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/timer/m48t59.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Patch

diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index 45753d8..fb78d20 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -655,9 +655,9 @@  M48t59State *m48t59_init(qemu_irq IRQ, hwaddr mem_base,
     d = FROM_SYSBUS(M48t59SysBusState, s);
     state = &d->state;
     sysbus_connect_irq(s, 0, IRQ);
-    memory_region_init_io(&d->io, &m48t59_io_ops, state, "m48t59", 4);
     if (io_base != 0) {
-        memory_region_add_subregion(get_system_io(), io_base, &d->io);
+        memory_region_add_subregion(get_system_io(), io_base,
+                                    sysbus_mmio_get_region(dev, 1));
     }
     if (mem_base != 0) {
         sysbus_mmio_map(s, 0, mem_base);
@@ -683,11 +683,6 @@  M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
     d = ISA_M48T59(isadev);
     s = &d->state;
 
-    memory_region_init_io(&d->io, &m48t59_io_ops, s, "m48t59", 4);
-    if (io_base != 0) {
-        isa_register_ioport(isadev, &d->io, io_base);
-    }
-
     return s;
 }
 
@@ -710,6 +705,10 @@  static int m48t59_init_isa1(ISADevice *dev)
 
     isa_init_irq(dev, &s->IRQ, 8);
     m48t59_init_common(s);
+    memory_region_init_io(&d->io, &m48t59_io_ops, s, "m48t59", 4);
+    if (s->io_base != 0) {
+        isa_register_ioport(dev, &d->io, s->io_base);
+    }
 
     return 0;
 }
@@ -723,6 +722,8 @@  static int m48t59_init1(SysBusDevice *dev)
 
     memory_region_init_io(&s->iomem, &nvram_ops, s, "m48t59.nvram", s->size);
     sysbus_init_mmio(dev, &s->iomem);
+    memory_region_init_io(&d->io, &m48t59_io_ops, s, "m48t59", 4);
+    sysbus_init_mmio(dev, &d->io);
     m48t59_init_common(s);
 
     return 0;