diff mbox

[v2,06/11] lm32_sys: convert to memory API

Message ID 1321979527-23921-7-git-send-email-benoit.canet@gmail.com
State New
Headers show

Commit Message

Benoit Canet Nov. 22, 2011, 4:32 p.m. UTC
Signed-off-by: Benoît Canet <benoit.canet@gmail.com>
---
 hw/lm32_sys.c |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

Comments

Avi Kivity Nov. 22, 2011, 5:36 p.m. UTC | #1
On 11/22/2011 06:32 PM, Benoît Canet wrote:
>  
> -static CPUReadMemoryFunc * const sys_read_fn[] = {
> -    NULL,
> -    NULL,
> -    NULL,
> -};
> -
> -static CPUWriteMemoryFunc * const sys_write_fn[] = {
> -    NULL,
> -    NULL,
> -    &sys_write,
> +static const MemoryRegionOps sys_ops = {
> +    .old_mmio = {
> +        .read = { NULL, NULL, NULL, },
> +        .write = { NULL, NULL, sys_write, },
> +    },
> +    .endianness = DEVICE_NATIVE_ENDIAN,
>  };

Please use .valid.accepts for cases like this.
diff mbox

Patch

diff --git a/hw/lm32_sys.c b/hw/lm32_sys.c
index e5ff962..6aa8b2e 100644
--- a/hw/lm32_sys.c
+++ b/hw/lm32_sys.c
@@ -47,6 +47,7 @@  enum {
 
 struct LM32SysState {
     SysBusDevice busdev;
+    MemoryRegion iomem;
     uint32_t base;
     uint32_t regs[R_MAX];
     uint8_t testname[MAX_TESTNAME_LEN];
@@ -89,16 +90,12 @@  static void sys_write(void *opaque, target_phys_addr_t addr, uint32_t value)
     }
 }
 
-static CPUReadMemoryFunc * const sys_read_fn[] = {
-    NULL,
-    NULL,
-    NULL,
-};
-
-static CPUWriteMemoryFunc * const sys_write_fn[] = {
-    NULL,
-    NULL,
-    &sys_write,
+static const MemoryRegionOps sys_ops = {
+    .old_mmio = {
+        .read = { NULL, NULL, NULL, },
+        .write = { NULL, NULL, sys_write, },
+    },
+    .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
 static void sys_reset(DeviceState *d)
@@ -115,11 +112,9 @@  static void sys_reset(DeviceState *d)
 static int lm32_sys_init(SysBusDevice *dev)
 {
     LM32SysState *s = FROM_SYSBUS(typeof(*s), dev);
-    int sys_regs;
 
-    sys_regs = cpu_register_io_memory(sys_read_fn, sys_write_fn, s,
-            DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, R_MAX * 4, sys_regs);
+    memory_region_init_io(&s->iomem, &sys_ops , s, "sys", R_MAX * 4);
+    sysbus_init_mmio_region(dev, &s->iomem);
 
     /* Note: This device is not created in the board initialization,
      * instead it has to be added with the -device parameter. Therefore,