Patchwork [02/14] slavio_misc: convert configuration to memory API

login
register
mail settings
Submitter Benoit Canet
Date Nov. 15, 2011, 11:13 a.m.
Message ID <1321355644-1982-3-git-send-email-benoit.canet@gmail.com>
Download mbox | patch
Permalink /patch/125768/
State New
Headers show

Comments

Benoit Canet - Nov. 15, 2011, 11:13 a.m.
Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/slavio_misc.c |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

Patch

diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index 7d427f7..7b98f11 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -36,6 +36,7 @@ 
 
 typedef struct MiscState {
     SysBusDevice busdev;
+    MemoryRegion cfg_iomem;
     qemu_irq irq;
     qemu_irq fdc_tc;
     uint32_t dummy;
@@ -101,7 +102,7 @@  static void slavio_set_power_fail(void *opaque, int irq, int power_failing)
 }
 
 static void slavio_cfg_mem_writeb(void *opaque, target_phys_addr_t addr,
-                                  uint32_t val)
+                                  uint64_t val, unsigned size)
 {
     MiscState *s = opaque;
 
@@ -110,7 +111,8 @@  static void slavio_cfg_mem_writeb(void *opaque, target_phys_addr_t addr,
     slavio_misc_update_irq(s);
 }
 
-static uint32_t slavio_cfg_mem_readb(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_cfg_mem_readb(void *opaque, target_phys_addr_t addr,
+                                     unsigned size)
 {
     MiscState *s = opaque;
     uint32_t ret = 0;
@@ -120,16 +122,14 @@  static uint32_t slavio_cfg_mem_readb(void *opaque, target_phys_addr_t addr)
     return ret;
 }
 
-static CPUReadMemoryFunc * const slavio_cfg_mem_read[3] = {
-    slavio_cfg_mem_readb,
-    NULL,
-    NULL,
-};
-
-static CPUWriteMemoryFunc * const slavio_cfg_mem_write[3] = {
-    slavio_cfg_mem_writeb,
-    NULL,
-    NULL,
+static const MemoryRegionOps slavio_cfg_mem_ops = {
+    .read = slavio_cfg_mem_readb,
+    .write = slavio_cfg_mem_writeb,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
 };
 
 static void slavio_diag_mem_writeb(void *opaque, target_phys_addr_t addr,
@@ -428,10 +428,9 @@  static int slavio_misc_init1(SysBusDevice *dev)
 
     /* 8 bit registers */
     /* Slavio control */
-    io = cpu_register_io_memory(slavio_cfg_mem_read,
-                                slavio_cfg_mem_write, s,
-                                DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, MISC_SIZE, io);
+    memory_region_init_io(&s->cfg_iomem, &slavio_cfg_mem_ops, s,
+                          "configuration", MISC_SIZE);
+    sysbus_init_mmio_region(dev, &s->cfg_iomem);
 
     /* Diagnostics */
     io = cpu_register_io_memory(slavio_diag_mem_read,