[1/6] hw/sh/sh7750: Convert away from old_mmio

Message ID 20180601141223.26630-2-peter.maydell@linaro.org
State Superseded
Headers show
Series
  • More conversions away from old_mmio
Related show

Commit Message

Peter Maydell June 1, 2018, 2:12 p.m.
Convert the sh7750 device away from using the old_mmio field
of MemoryRegionOps. This device is used by the sh4 r2d board.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 hw/sh4/sh7750.c | 44 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 36 insertions(+), 8 deletions(-)

-- 
2.17.1

Comments

Philippe Mathieu-Daudé June 11, 2018, 3:47 p.m. | #1
On 06/01/2018 11:12 AM, Peter Maydell wrote:
> Convert the sh7750 device away from using the old_mmio field

> of MemoryRegionOps. This device is used by the sh4 r2d board.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> ---

>  hw/sh4/sh7750.c | 44 ++++++++++++++++++++++++++++++++++++--------

>  1 file changed, 36 insertions(+), 8 deletions(-)

> 

> diff --git a/hw/sh4/sh7750.c b/hw/sh4/sh7750.c

> index 5a7d47d31e..b932f33409 100644

> --- a/hw/sh4/sh7750.c

> +++ b/hw/sh4/sh7750.c

> @@ -451,15 +451,43 @@ static void sh7750_mem_writel(void *opaque, hwaddr addr,

>      }

>  }

>  

> +static uint64_t sh7750_mem_readfn(void *opaque, hwaddr addr, unsigned size)

> +{

> +    switch (size) {

> +    case 1:

> +        return sh7750_mem_readb(opaque, addr);

> +    case 2:

> +        return sh7750_mem_readw(opaque, addr);

> +    case 4:

> +        return sh7750_mem_readl(opaque, addr);

> +    default:

> +        g_assert_not_reached();

> +    }

> +}

> +

> +static void sh7750_mem_writefn(void *opaque, hwaddr addr,

> +                               uint64_t value, unsigned size)

> +{

> +    switch (size) {

> +    case 1:

> +        sh7750_mem_writeb(opaque, addr, value);

> +        break;

> +    case 2:

> +        sh7750_mem_writew(opaque, addr, value);

> +        break;

> +    case 4:

> +        sh7750_mem_writel(opaque, addr, value);

> +        break;

> +    default:

> +        g_assert_not_reached();

> +    }

> +}

> +

>  static const MemoryRegionOps sh7750_mem_ops = {

> -    .old_mmio = {

> -        .read = {sh7750_mem_readb,

> -                 sh7750_mem_readw,

> -                 sh7750_mem_readl },

> -        .write = {sh7750_mem_writeb,

> -                  sh7750_mem_writew,

> -                  sh7750_mem_writel },

> -    },

> +    .read = sh7750_mem_readfn,

> +    .write = sh7750_mem_writefn,

> +    .valid.min_access_size = 1,

> +    .valid.max_access_size = 4,

>      .endianness = DEVICE_NATIVE_ENDIAN,

>  };

>  

>

Patch

diff --git a/hw/sh4/sh7750.c b/hw/sh4/sh7750.c
index 5a7d47d31e..b932f33409 100644
--- a/hw/sh4/sh7750.c
+++ b/hw/sh4/sh7750.c
@@ -451,15 +451,43 @@  static void sh7750_mem_writel(void *opaque, hwaddr addr,
     }
 }
 
+static uint64_t sh7750_mem_readfn(void *opaque, hwaddr addr, unsigned size)
+{
+    switch (size) {
+    case 1:
+        return sh7750_mem_readb(opaque, addr);
+    case 2:
+        return sh7750_mem_readw(opaque, addr);
+    case 4:
+        return sh7750_mem_readl(opaque, addr);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+static void sh7750_mem_writefn(void *opaque, hwaddr addr,
+                               uint64_t value, unsigned size)
+{
+    switch (size) {
+    case 1:
+        sh7750_mem_writeb(opaque, addr, value);
+        break;
+    case 2:
+        sh7750_mem_writew(opaque, addr, value);
+        break;
+    case 4:
+        sh7750_mem_writel(opaque, addr, value);
+        break;
+    default:
+        g_assert_not_reached();
+    }
+}
+
 static const MemoryRegionOps sh7750_mem_ops = {
-    .old_mmio = {
-        .read = {sh7750_mem_readb,
-                 sh7750_mem_readw,
-                 sh7750_mem_readl },
-        .write = {sh7750_mem_writeb,
-                  sh7750_mem_writew,
-                  sh7750_mem_writel },
-    },
+    .read = sh7750_mem_readfn,
+    .write = sh7750_mem_writefn,
+    .valid.min_access_size = 1,
+    .valid.max_access_size = 4,
     .endianness = DEVICE_NATIVE_ENDIAN,
 };