Patchwork [v3,28/39] isa-mmio: concert to memory API

login
register
mail settings
Submitter Avi Kivity
Date Aug. 4, 2011, 1:06 p.m.
Message ID <1312463195-13605-29-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/108506/
State New
Headers show

Comments

Avi Kivity - Aug. 4, 2011, 1:06 p.m.
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/isa.h      |    2 ++
 hw/isa_mmio.c |   30 +++++++++++++++---------------
 2 files changed, 17 insertions(+), 15 deletions(-)
Anthony Liguori - Aug. 5, 2011, 3:29 p.m.
On 08/04/2011 08:06 AM, Avi Kivity wrote:
> Reviewed-by: Richard Henderson<rth@twiddle.net>
> Signed-off-by: Avi Kivity<avi@redhat.com>

For the subject, s:concert:convert:g

Otherwise,

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

> ---
>   hw/isa.h      |    2 ++
>   hw/isa_mmio.c |   30 +++++++++++++++---------------
>   2 files changed, 17 insertions(+), 15 deletions(-)
>
> diff --git a/hw/isa.h b/hw/isa.h
> index d2b6126..f1f2181 100644
> --- a/hw/isa.h
> +++ b/hw/isa.h
> @@ -4,6 +4,7 @@
>   /* ISA bus */
>
>   #include "ioport.h"
> +#include "memory.h"
>   #include "qdev.h"
>
>   typedef struct ISABus ISABus;
> @@ -37,6 +38,7 @@ ISADevice *isa_create_simple(const char *name);
>
>   extern target_phys_addr_t isa_mem_base;
>
> +void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
>   void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
>
>   /* dma.c */
> diff --git a/hw/isa_mmio.c b/hw/isa_mmio.c
> index ca957fb..600225f 100644
> --- a/hw/isa_mmio.c
> +++ b/hw/isa_mmio.c
> @@ -58,25 +58,25 @@ static uint32_t isa_mmio_readl(void *opaque, target_phys_addr_t addr)
>       return cpu_inl(addr&  IOPORTS_MASK);
>   }
>
> -static CPUWriteMemoryFunc * const isa_mmio_write[] = {
> -&isa_mmio_writeb,
> -&isa_mmio_writew,
> -&isa_mmio_writel,
> +static const MemoryRegionOps isa_mmio_ops = {
> +    .old_mmio = {
> +        .write = { isa_mmio_writeb, isa_mmio_writew, isa_mmio_writel },
> +        .read = { isa_mmio_readb, isa_mmio_readw, isa_mmio_readl, },
> +    },
> +    .endianness = DEVICE_LITTLE_ENDIAN,
>   };
>
> -static CPUReadMemoryFunc * const isa_mmio_read[] = {
> -&isa_mmio_readb,
> -&isa_mmio_readw,
> -&isa_mmio_readl,
> -};
> +void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size)
> +{
> +    memory_region_init_io(mr,&isa_mmio_ops, NULL, "isa-mmio", size);
> +}
> +
> +#include "exec-memory.h"
>
>   void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size)
>   {
> -    int isa_mmio_iomemtype;
> +    MemoryRegion *mr = qemu_malloc(sizeof(*mr));
>
> -    isa_mmio_iomemtype = cpu_register_io_memory(isa_mmio_read,
> -                                                isa_mmio_write,
> -                                                NULL,
> -                                                DEVICE_LITTLE_ENDIAN);
> -    cpu_register_physical_memory(base, size, isa_mmio_iomemtype);
> +    isa_mmio_setup(mr, size);
> +    memory_region_add_subregion(get_system_memory(), base, mr);
>   }
Avi Kivity - Aug. 7, 2011, 9:21 a.m.
On 08/05/2011 06:29 PM, Anthony Liguori wrote:
> On 08/04/2011 08:06 AM, Avi Kivity wrote:
>> Reviewed-by: Richard Henderson<rth@twiddle.net>
>> Signed-off-by: Avi Kivity<avi@redhat.com>
>
> For the subject, s:concert:convert:g

Fixed

Patch

diff --git a/hw/isa.h b/hw/isa.h
index d2b6126..f1f2181 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -4,6 +4,7 @@ 
 /* ISA bus */
 
 #include "ioport.h"
+#include "memory.h"
 #include "qdev.h"
 
 typedef struct ISABus ISABus;
@@ -37,6 +38,7 @@  ISADevice *isa_create_simple(const char *name);
 
 extern target_phys_addr_t isa_mem_base;
 
+void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
 void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
 
 /* dma.c */
diff --git a/hw/isa_mmio.c b/hw/isa_mmio.c
index ca957fb..600225f 100644
--- a/hw/isa_mmio.c
+++ b/hw/isa_mmio.c
@@ -58,25 +58,25 @@  static uint32_t isa_mmio_readl(void *opaque, target_phys_addr_t addr)
     return cpu_inl(addr & IOPORTS_MASK);
 }
 
-static CPUWriteMemoryFunc * const isa_mmio_write[] = {
-    &isa_mmio_writeb,
-    &isa_mmio_writew,
-    &isa_mmio_writel,
+static const MemoryRegionOps isa_mmio_ops = {
+    .old_mmio = {
+        .write = { isa_mmio_writeb, isa_mmio_writew, isa_mmio_writel },
+        .read = { isa_mmio_readb, isa_mmio_readw, isa_mmio_readl, },
+    },
+    .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
-static CPUReadMemoryFunc * const isa_mmio_read[] = {
-    &isa_mmio_readb,
-    &isa_mmio_readw,
-    &isa_mmio_readl,
-};
+void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size)
+{
+    memory_region_init_io(mr, &isa_mmio_ops, NULL, "isa-mmio", size);
+}
+
+#include "exec-memory.h"
 
 void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size)
 {
-    int isa_mmio_iomemtype;
+    MemoryRegion *mr = qemu_malloc(sizeof(*mr));
 
-    isa_mmio_iomemtype = cpu_register_io_memory(isa_mmio_read,
-                                                isa_mmio_write,
-                                                NULL,
-                                                DEVICE_LITTLE_ENDIAN);
-    cpu_register_physical_memory(base, size, isa_mmio_iomemtype);
+    isa_mmio_setup(mr, size);
+    memory_region_add_subregion(get_system_memory(), base, mr);
 }