Similar to m48t59_init(), add a mem_base value so that NVRAM can be mapped via
MMIO rather than ioport if required.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk>
---
 hw/ppc/prep.c             |    2 +-
 hw/sparc64/sun4u.c        |    2 +-
 hw/timer/m48t59.c         |    9 +++++++--
 include/hw/timer/m48t59.h |    4 ++--
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 378a368..4ed22ba 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -543,7 +543,7 @@ static void ppc_prep_init(MachineState *machine)
         pci_create_simple(pci_bus, -1, "pci-ohci");
     }
 
-    m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 0, 59);
+    m48t59 = m48t59_init_isa(isa_bus, 0, 0x0074, NVRAM_SIZE, 0, 59);
     if (m48t59 == NULL)
         return;
     sysctrl->nvram = m48t59;
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 6b46511..86f5861 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -873,7 +873,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
         fd[i] = drive_get(IF_FLOPPY, 0, i);
     }
     fdctrl_init_isa(isa_bus, fd);
-    nvram = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 0, 59);
+    nvram = m48t59_init_isa(isa_bus, 0, 0x0074, NVRAM_SIZE, 0, 59);
 
     initrd_size = 0;
     initrd_addr = 0;
diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index 0a05100..dc52ce3 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -664,8 +664,8 @@ M48t59State *m48t59_init(qemu_irq IRQ, hwaddr mem_base, 
uint32_t io_base,
     return state;
 }
 
-M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
-                             uint32_t year_offset, int model)
+M48t59State *m48t59_init_isa(ISABus *bus, hwaddr mem_base, uint32_t io_base,
+                             uint16_t size, uint32_t year_offset, int model)
 {
     M48t59ISAState *d;
     ISADevice *isadev;
@@ -686,6 +686,11 @@ M48t59State *m48t59_init_isa(ISABus *bus, uint32_t 
io_base, uint16_t size,
     if (io_base != 0) {
         isa_register_ioport(isadev, &d->io, io_base);
     }
+    if (mem_base != 0) {
+        memory_region_init_io(&s->iomem, OBJECT(d), &nvram_ops, s,
+                              "m48t59.nvram", s->size);
+        isa_register_ioport(isadev, &s->iomem, mem_base);
+    }
 
     return s;
 }
diff --git a/include/hw/timer/m48t59.h b/include/hw/timer/m48t59.h
index 08252b6..4bcd8fc 100644
--- a/include/hw/timer/m48t59.h
+++ b/include/hw/timer/m48t59.h
@@ -29,8 +29,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(ISABus *bus, uint32_t io_base, uint16_t size,
-                             uint32_t year_offset, int type);
+M48t59State *m48t59_init_isa(ISABus *bus, hwaddr mem_base, uint32_t io_base,
+                             uint16_t size, uint32_t year_offset, int type);
 M48t59State *m48t59_init(qemu_irq IRQ, hwaddr mem_base,
                          uint32_t io_base, uint16_t size,
                          uint32_t year_offset, int type);
-- 
1.7.10.4


Reply via email to