qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API.
@ 2011-11-15 11:13 Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 01/14] slavio_misc: convert apc " Benoît Canet
                   ` (14 more replies)
  0 siblings, 15 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

.valid was used where the access size is specified like in
http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
.impl was used when the behavior is not known.

Benoît Canet (14):
  slavio_misc: convert apc to memory API
  slavio_misc: convert configuration to memory API
  slavio_misc: convert diagnostic to memory API
  slavio_misc: convert modem to memory API
  slavio_misc: convert leds to memory API
  slavio_misc: convert system control to memory API
  slavio_misc: convert aux1 to memory API
  slavio_misc: convert aux2 to memory API
  slavio_intctl: convert master interrupt controller to memory API
  slavio_intctl: convert slaves interrupt controllers to memory API
  sun4c_intctl: convert to memory API
  slavio_timer: convert to memory API
  sun4m_iommu: convert to memory API
  esp: Fix memory API conversion

 hw/esp.c           |    1 +
 hw/slavio_intctl.c |   67 +++++++-------
 hw/slavio_misc.c   |  250 +++++++++++++++++++++++++---------------------------
 hw/slavio_timer.c  |   41 ++++-----
 hw/sun4c_intctl.c  |   32 +++----
 hw/sun4m_iommu.c   |   31 +++----
 6 files changed, 205 insertions(+), 217 deletions(-)

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 01/14] slavio_misc: convert apc to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
@ 2011-11-15 11:13 ` Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 02/14] slavio_misc: convert configuration " Benoît Canet
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/slavio_misc.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index 1f5a2d7..7d427f7 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -48,6 +48,7 @@ typedef struct MiscState {
 
 typedef struct APCState {
     SysBusDevice busdev;
+    MemoryRegion iomem;
     qemu_irq cpu_halt;
 } APCState;
 
@@ -270,7 +271,8 @@ static CPUWriteMemoryFunc * const slavio_aux2_mem_write[3] = {
     NULL,
 };
 
-static void apc_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
+static void apc_mem_writeb(void *opaque, target_phys_addr_t addr,
+                           uint64_t val, unsigned size)
 {
     APCState *s = opaque;
 
@@ -278,7 +280,8 @@ static void apc_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
     qemu_irq_raise(s->cpu_halt);
 }
 
-static uint32_t apc_mem_readb(void *opaque, target_phys_addr_t addr)
+static uint64_t apc_mem_readb(void *opaque, target_phys_addr_t addr,
+                              unsigned size)
 {
     uint32_t ret = 0;
 
@@ -286,16 +289,14 @@ static uint32_t apc_mem_readb(void *opaque, target_phys_addr_t addr)
     return ret;
 }
 
-static CPUReadMemoryFunc * const apc_mem_read[3] = {
-    apc_mem_readb,
-    NULL,
-    NULL,
-};
-
-static CPUWriteMemoryFunc * const apc_mem_write[3] = {
-    apc_mem_writeb,
-    NULL,
-    NULL,
+static const MemoryRegionOps apc_mem_ops = {
+    .read = apc_mem_readb,
+    .write = apc_mem_writeb,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    }
 };
 
 static uint32_t slavio_sysctrl_mem_readl(void *opaque, target_phys_addr_t addr)
@@ -407,14 +408,13 @@ static const VMStateDescription vmstate_misc = {
 static int apc_init1(SysBusDevice *dev)
 {
     APCState *s = FROM_SYSBUS(APCState, dev);
-    int io;
 
     sysbus_init_irq(dev, &s->cpu_halt);
 
     /* Power management (APC) XXX: not a Slavio device */
-    io = cpu_register_io_memory(apc_mem_read, apc_mem_write, s,
-                                DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, MISC_SIZE, io);
+    memory_region_init_io(&s->iomem, &apc_mem_ops, s,
+                          "apc", MISC_SIZE);
+    sysbus_init_mmio_region(dev, &s->iomem);
     return 0;
 }
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 02/14] slavio_misc: convert configuration to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 01/14] slavio_misc: convert apc " Benoît Canet
@ 2011-11-15 11:13 ` Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 03/14] slavio_misc: convert diagnostic " Benoît Canet
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

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

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,
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 03/14] slavio_misc: convert diagnostic to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 01/14] slavio_misc: convert apc " Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 02/14] slavio_misc: convert configuration " Benoît Canet
@ 2011-11-15 11:13 ` Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 04/14] slavio_misc: convert modem " Benoît Canet
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

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

diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index 7b98f11..60a115d 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -37,6 +37,7 @@
 typedef struct MiscState {
     SysBusDevice busdev;
     MemoryRegion cfg_iomem;
+    MemoryRegion diag_iomem;
     qemu_irq irq;
     qemu_irq fdc_tc;
     uint32_t dummy;
@@ -133,7 +134,7 @@ static const MemoryRegionOps slavio_cfg_mem_ops = {
 };
 
 static void slavio_diag_mem_writeb(void *opaque, target_phys_addr_t addr,
-                                   uint32_t val)
+                                   uint64_t val, unsigned size)
 {
     MiscState *s = opaque;
 
@@ -141,7 +142,8 @@ static void slavio_diag_mem_writeb(void *opaque, target_phys_addr_t addr,
     s->diag = val & 0xff;
 }
 
-static uint32_t slavio_diag_mem_readb(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_diag_mem_readb(void *opaque, target_phys_addr_t addr,
+                                      unsigned size)
 {
     MiscState *s = opaque;
     uint32_t ret = 0;
@@ -151,16 +153,14 @@ static uint32_t slavio_diag_mem_readb(void *opaque, target_phys_addr_t addr)
     return ret;
 }
 
-static CPUReadMemoryFunc * const slavio_diag_mem_read[3] = {
-    slavio_diag_mem_readb,
-    NULL,
-    NULL,
-};
-
-static CPUWriteMemoryFunc * const slavio_diag_mem_write[3] = {
-    slavio_diag_mem_writeb,
-    NULL,
-    NULL,
+static const MemoryRegionOps slavio_diag_mem_ops = {
+    .read = slavio_diag_mem_readb,
+    .write = slavio_diag_mem_writeb,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
 };
 
 static void slavio_mdm_mem_writeb(void *opaque, target_phys_addr_t addr,
@@ -433,10 +433,9 @@ static int slavio_misc_init1(SysBusDevice *dev)
     sysbus_init_mmio_region(dev, &s->cfg_iomem);
 
     /* Diagnostics */
-    io = cpu_register_io_memory(slavio_diag_mem_read,
-                                slavio_diag_mem_write, s,
-                                DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, MISC_SIZE, io);
+    memory_region_init_io(&s->diag_iomem, &slavio_diag_mem_ops, s,
+                          "diagnostic", MISC_SIZE);
+    sysbus_init_mmio_region(dev, &s->diag_iomem);
 
     /* Modem control */
     io = cpu_register_io_memory(slavio_mdm_mem_read,
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 04/14] slavio_misc: convert modem to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (2 preceding siblings ...)
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 03/14] slavio_misc: convert diagnostic " Benoît Canet
@ 2011-11-15 11:13 ` Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 05/14] slavio_misc: convert leds " Benoît Canet
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

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

diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index 60a115d..9110c64 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -38,6 +38,7 @@ typedef struct MiscState {
     SysBusDevice busdev;
     MemoryRegion cfg_iomem;
     MemoryRegion diag_iomem;
+    MemoryRegion mdm_iomem;
     qemu_irq irq;
     qemu_irq fdc_tc;
     uint32_t dummy;
@@ -164,7 +165,7 @@ static const MemoryRegionOps slavio_diag_mem_ops = {
 };
 
 static void slavio_mdm_mem_writeb(void *opaque, target_phys_addr_t addr,
-                                  uint32_t val)
+                                  uint64_t val, unsigned size)
 {
     MiscState *s = opaque;
 
@@ -172,7 +173,8 @@ static void slavio_mdm_mem_writeb(void *opaque, target_phys_addr_t addr,
     s->mctrl = val & 0xff;
 }
 
-static uint32_t slavio_mdm_mem_readb(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_mdm_mem_readb(void *opaque, target_phys_addr_t addr,
+                                     unsigned size)
 {
     MiscState *s = opaque;
     uint32_t ret = 0;
@@ -182,16 +184,14 @@ static uint32_t slavio_mdm_mem_readb(void *opaque, target_phys_addr_t addr)
     return ret;
 }
 
-static CPUReadMemoryFunc * const slavio_mdm_mem_read[3] = {
-    slavio_mdm_mem_readb,
-    NULL,
-    NULL,
-};
-
-static CPUWriteMemoryFunc * const slavio_mdm_mem_write[3] = {
-    slavio_mdm_mem_writeb,
-    NULL,
-    NULL,
+static const MemoryRegionOps slavio_mdm_mem_ops = {
+    .read = slavio_mdm_mem_readb,
+    .write = slavio_mdm_mem_writeb,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
 };
 
 static void slavio_aux1_mem_writeb(void *opaque, target_phys_addr_t addr,
@@ -438,10 +438,9 @@ static int slavio_misc_init1(SysBusDevice *dev)
     sysbus_init_mmio_region(dev, &s->diag_iomem);
 
     /* Modem control */
-    io = cpu_register_io_memory(slavio_mdm_mem_read,
-                                slavio_mdm_mem_write, s,
-                                DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, MISC_SIZE, io);
+    memory_region_init_io(&s->mdm_iomem, &slavio_mdm_mem_ops, s,
+                          "modem", MISC_SIZE);
+    sysbus_init_mmio_region(dev, &s->mdm_iomem);
 
     /* 16 bit registers */
     /* ss600mp diag LEDs */
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 05/14] slavio_misc: convert leds to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (3 preceding siblings ...)
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 04/14] slavio_misc: convert modem " Benoît Canet
@ 2011-11-15 11:13 ` Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 06/14] slavio_misc: convert system control " Benoît Canet
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

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

diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index 9110c64..db266ba 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -39,6 +39,7 @@ typedef struct MiscState {
     MemoryRegion cfg_iomem;
     MemoryRegion diag_iomem;
     MemoryRegion mdm_iomem;
+    MemoryRegion led_iomem;
     qemu_irq irq;
     qemu_irq fdc_tc;
     uint32_t dummy;
@@ -345,7 +346,8 @@ static CPUWriteMemoryFunc * const slavio_sysctrl_mem_write[3] = {
     slavio_sysctrl_mem_writel,
 };
 
-static uint32_t slavio_led_mem_readw(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_led_mem_readw(void *opaque, target_phys_addr_t addr,
+                                     unsigned size)
 {
     MiscState *s = opaque;
     uint32_t ret = 0;
@@ -362,7 +364,7 @@ static uint32_t slavio_led_mem_readw(void *opaque, target_phys_addr_t addr)
 }
 
 static void slavio_led_mem_writew(void *opaque, target_phys_addr_t addr,
-                                  uint32_t val)
+                                  uint64_t val, unsigned size)
 {
     MiscState *s = opaque;
 
@@ -376,16 +378,14 @@ static void slavio_led_mem_writew(void *opaque, target_phys_addr_t addr,
     }
 }
 
-static CPUReadMemoryFunc * const slavio_led_mem_read[3] = {
-    NULL,
-    slavio_led_mem_readw,
-    NULL,
-};
-
-static CPUWriteMemoryFunc * const slavio_led_mem_write[3] = {
-    NULL,
-    slavio_led_mem_writew,
-    NULL,
+static const MemoryRegionOps slavio_led_mem_ops = {
+    .read = slavio_led_mem_readw,
+    .write = slavio_led_mem_writew,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 2,
+        .max_access_size = 2,
+    },
 };
 
 static const VMStateDescription vmstate_misc = {
@@ -444,10 +444,9 @@ static int slavio_misc_init1(SysBusDevice *dev)
 
     /* 16 bit registers */
     /* ss600mp diag LEDs */
-    io = cpu_register_io_memory(slavio_led_mem_read,
-                                slavio_led_mem_write, s,
-                                DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, MISC_SIZE, io);
+    memory_region_init_io(&s->led_iomem, &slavio_led_mem_ops, s,
+                          "leds", MISC_SIZE);
+    sysbus_init_mmio_region(dev, &s->led_iomem);
 
     /* 32 bit registers */
     /* System control */
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 06/14] slavio_misc: convert system control to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (4 preceding siblings ...)
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 05/14] slavio_misc: convert leds " Benoît Canet
@ 2011-11-15 11:13 ` Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 07/14] slavio_misc: convert aux1 " Benoît Canet
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

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

diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index db266ba..29eca9b 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -40,6 +40,7 @@ typedef struct MiscState {
     MemoryRegion diag_iomem;
     MemoryRegion mdm_iomem;
     MemoryRegion led_iomem;
+    MemoryRegion sysctrl_iomem;
     qemu_irq irq;
     qemu_irq fdc_tc;
     uint32_t dummy;
@@ -300,7 +301,8 @@ static const MemoryRegionOps apc_mem_ops = {
     }
 };
 
-static uint32_t slavio_sysctrl_mem_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_sysctrl_mem_readl(void *opaque, target_phys_addr_t addr,
+                                         unsigned size)
 {
     MiscState *s = opaque;
     uint32_t ret = 0;
@@ -317,7 +319,7 @@ static uint32_t slavio_sysctrl_mem_readl(void *opaque, target_phys_addr_t addr)
 }
 
 static void slavio_sysctrl_mem_writel(void *opaque, target_phys_addr_t addr,
-                                      uint32_t val)
+                                      uint64_t val, unsigned size)
 {
     MiscState *s = opaque;
 
@@ -334,16 +336,14 @@ static void slavio_sysctrl_mem_writel(void *opaque, target_phys_addr_t addr,
     }
 }
 
-static CPUReadMemoryFunc * const slavio_sysctrl_mem_read[3] = {
-    NULL,
-    NULL,
-    slavio_sysctrl_mem_readl,
-};
-
-static CPUWriteMemoryFunc * const slavio_sysctrl_mem_write[3] = {
-    NULL,
-    NULL,
-    slavio_sysctrl_mem_writel,
+static const MemoryRegionOps slavio_sysctrl_mem_ops = {
+    .read = slavio_sysctrl_mem_readl,
+    .write = slavio_sysctrl_mem_writel,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
 };
 
 static uint64_t slavio_led_mem_readw(void *opaque, target_phys_addr_t addr,
@@ -450,10 +450,9 @@ static int slavio_misc_init1(SysBusDevice *dev)
 
     /* 32 bit registers */
     /* System control */
-    io = cpu_register_io_memory(slavio_sysctrl_mem_read,
-                                slavio_sysctrl_mem_write, s,
-                                DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, SYSCTRL_SIZE, io);
+    memory_region_init_io(&s->sysctrl_iomem, &slavio_sysctrl_mem_ops, s,
+                          "system-control", MISC_SIZE);
+    sysbus_init_mmio_region(dev, &s->sysctrl_iomem);
 
     /* AUX 1 (Misc System Functions) */
     io = cpu_register_io_memory(slavio_aux1_mem_read,
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 07/14] slavio_misc: convert aux1 to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (5 preceding siblings ...)
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 06/14] slavio_misc: convert system control " Benoît Canet
@ 2011-11-15 11:13 ` Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 08/14] slavio_misc: convert aux2 " Benoît Canet
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

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

diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index 29eca9b..7a51e1b 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -41,6 +41,7 @@ typedef struct MiscState {
     MemoryRegion mdm_iomem;
     MemoryRegion led_iomem;
     MemoryRegion sysctrl_iomem;
+    MemoryRegion aux1_iomem;
     qemu_irq irq;
     qemu_irq fdc_tc;
     uint32_t dummy;
@@ -197,7 +198,7 @@ static const MemoryRegionOps slavio_mdm_mem_ops = {
 };
 
 static void slavio_aux1_mem_writeb(void *opaque, target_phys_addr_t addr,
-                                   uint32_t val)
+                                   uint64_t val, unsigned size)
 {
     MiscState *s = opaque;
 
@@ -213,7 +214,8 @@ static void slavio_aux1_mem_writeb(void *opaque, target_phys_addr_t addr,
     s->aux1 = val & 0xff;
 }
 
-static uint32_t slavio_aux1_mem_readb(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_aux1_mem_readb(void *opaque, target_phys_addr_t addr,
+                                      unsigned size)
 {
     MiscState *s = opaque;
     uint32_t ret = 0;
@@ -223,16 +225,14 @@ static uint32_t slavio_aux1_mem_readb(void *opaque, target_phys_addr_t addr)
     return ret;
 }
 
-static CPUReadMemoryFunc * const slavio_aux1_mem_read[3] = {
-    slavio_aux1_mem_readb,
-    NULL,
-    NULL,
-};
-
-static CPUWriteMemoryFunc * const slavio_aux1_mem_write[3] = {
-    slavio_aux1_mem_writeb,
-    NULL,
-    NULL,
+static const MemoryRegionOps slavio_aux1_mem_ops = {
+    .read = slavio_aux1_mem_readb,
+    .write = slavio_aux1_mem_writeb,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
 };
 
 static void slavio_aux2_mem_writeb(void *opaque, target_phys_addr_t addr,
@@ -455,10 +455,9 @@ static int slavio_misc_init1(SysBusDevice *dev)
     sysbus_init_mmio_region(dev, &s->sysctrl_iomem);
 
     /* AUX 1 (Misc System Functions) */
-    io = cpu_register_io_memory(slavio_aux1_mem_read,
-                                slavio_aux1_mem_write, s,
-                                DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, MISC_SIZE, io);
+    memory_region_init_io(&s->aux1_iomem, &slavio_aux1_mem_ops, s,
+                          "misc-system-functions", MISC_SIZE);
+    sysbus_init_mmio_region(dev, &s->aux1_iomem);
 
     /* AUX 2 (Software Powerdown Control) */
     io = cpu_register_io_memory(slavio_aux2_mem_read,
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 08/14] slavio_misc: convert aux2 to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (6 preceding siblings ...)
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 07/14] slavio_misc: convert aux1 " Benoît Canet
@ 2011-11-15 11:13 ` Benoît Canet
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 09/14] slavio_intctl: convert master interrupt controller " Benoît Canet
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/slavio_misc.c |   32 +++++++++++++++-----------------
 1 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index 7a51e1b..ccc1c53 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -42,6 +42,7 @@ typedef struct MiscState {
     MemoryRegion led_iomem;
     MemoryRegion sysctrl_iomem;
     MemoryRegion aux1_iomem;
+    MemoryRegion aux2_iomem;
     qemu_irq irq;
     qemu_irq fdc_tc;
     uint32_t dummy;
@@ -236,7 +237,7 @@ static const MemoryRegionOps slavio_aux1_mem_ops = {
 };
 
 static void slavio_aux2_mem_writeb(void *opaque, target_phys_addr_t addr,
-                                   uint32_t val)
+                                   uint64_t val, unsigned size)
 {
     MiscState *s = opaque;
 
@@ -251,7 +252,8 @@ static void slavio_aux2_mem_writeb(void *opaque, target_phys_addr_t addr,
     slavio_misc_update_irq(s);
 }
 
-static uint32_t slavio_aux2_mem_readb(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_aux2_mem_readb(void *opaque, target_phys_addr_t addr,
+                                      unsigned size)
 {
     MiscState *s = opaque;
     uint32_t ret = 0;
@@ -261,16 +263,14 @@ static uint32_t slavio_aux2_mem_readb(void *opaque, target_phys_addr_t addr)
     return ret;
 }
 
-static CPUReadMemoryFunc * const slavio_aux2_mem_read[3] = {
-    slavio_aux2_mem_readb,
-    NULL,
-    NULL,
-};
-
-static CPUWriteMemoryFunc * const slavio_aux2_mem_write[3] = {
-    slavio_aux2_mem_writeb,
-    NULL,
-    NULL,
+static const MemoryRegionOps slavio_aux2_mem_ops = {
+    .read = slavio_aux2_mem_readb,
+    .write = slavio_aux2_mem_writeb,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
 };
 
 static void apc_mem_writeb(void *opaque, target_phys_addr_t addr,
@@ -421,7 +421,6 @@ static int apc_init1(SysBusDevice *dev)
 static int slavio_misc_init1(SysBusDevice *dev)
 {
     MiscState *s = FROM_SYSBUS(MiscState, dev);
-    int io;
 
     sysbus_init_irq(dev, &s->irq);
     sysbus_init_irq(dev, &s->fdc_tc);
@@ -460,10 +459,9 @@ static int slavio_misc_init1(SysBusDevice *dev)
     sysbus_init_mmio_region(dev, &s->aux1_iomem);
 
     /* AUX 2 (Software Powerdown Control) */
-    io = cpu_register_io_memory(slavio_aux2_mem_read,
-                                slavio_aux2_mem_write, s,
-                                DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, MISC_SIZE, io);
+    memory_region_init_io(&s->aux2_iomem, &slavio_aux2_mem_ops, s,
+                          "software-powerdown-control", MISC_SIZE);
+    sysbus_init_mmio_region(dev, &s->aux2_iomem);
 
     qdev_init_gpio_in(&dev->qdev, slavio_set_power_fail, 1);
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 09/14] slavio_intctl: convert master interrupt controller to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (7 preceding siblings ...)
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 08/14] slavio_misc: convert aux2 " Benoît Canet
@ 2011-11-15 11:13 ` Benoît Canet
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 10/14] slavio_intctl: convert slaves interrupt controllers " Benoît Canet
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/slavio_intctl.c |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c
index 329c251..0bc2a0b 100644
--- a/hw/slavio_intctl.c
+++ b/hw/slavio_intctl.c
@@ -54,6 +54,7 @@ typedef struct SLAVIO_CPUINTCTLState {
 
 typedef struct SLAVIO_INTCTLState {
     SysBusDevice busdev;
+    MemoryRegion iomem;
 #ifdef DEBUG_IRQ_COUNT
     uint64_t irq_count[32];
 #endif
@@ -134,7 +135,8 @@ static CPUWriteMemoryFunc * const slavio_intctl_mem_write[3] = {
 };
 
 // master system interrupt controller
-static uint32_t slavio_intctlm_mem_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_intctlm_mem_readl(void *opaque, target_phys_addr_t addr,
+                                         unsigned size)
 {
     SLAVIO_INTCTLState *s = opaque;
     uint32_t saddr, ret;
@@ -160,7 +162,7 @@ static uint32_t slavio_intctlm_mem_readl(void *opaque, target_phys_addr_t addr)
 }
 
 static void slavio_intctlm_mem_writel(void *opaque, target_phys_addr_t addr,
-                                      uint32_t val)
+                                      uint64_t val, unsigned size)
 {
     SLAVIO_INTCTLState *s = opaque;
     uint32_t saddr;
@@ -192,16 +194,14 @@ static void slavio_intctlm_mem_writel(void *opaque, target_phys_addr_t addr,
     }
 }
 
-static CPUReadMemoryFunc * const slavio_intctlm_mem_read[3] = {
-    NULL,
-    NULL,
-    slavio_intctlm_mem_readl,
-};
-
-static CPUWriteMemoryFunc * const slavio_intctlm_mem_write[3] = {
-    NULL,
-    NULL,
-    slavio_intctlm_mem_writel,
+static const MemoryRegionOps slavio_intctlm_mem_ops = {
+    .read = slavio_intctlm_mem_readl,
+    .write = slavio_intctlm_mem_writel,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
 };
 
 void slavio_pic_info(Monitor *mon, DeviceState *dev)
@@ -426,10 +426,9 @@ static int slavio_intctl_init1(SysBusDevice *dev)
     unsigned int i, j;
 
     qdev_init_gpio_in(&dev->qdev, slavio_set_irq_all, 32 + MAX_CPUS);
-    io_memory = cpu_register_io_memory(slavio_intctlm_mem_read,
-                                       slavio_intctlm_mem_write, s,
-                                       DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, INTCTLM_SIZE, io_memory);
+    memory_region_init_io(&s->iomem, &slavio_intctlm_mem_ops, s,
+                          "master-interrupt-controller", INTCTLM_SIZE);
+    sysbus_init_mmio_region(dev, &s->iomem);
 
     for (i = 0; i < MAX_CPUS; i++) {
         for (j = 0; j < MAX_PILS; j++) {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 10/14] slavio_intctl: convert slaves interrupt controllers to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (8 preceding siblings ...)
  2011-11-15 11:13 ` [Qemu-devel] [PATCH 09/14] slavio_intctl: convert master interrupt controller " Benoît Canet
@ 2011-11-15 11:14 ` Benoît Canet
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 11/14] sun4c_intctl: convert " Benoît Canet
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/slavio_intctl.c |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c
index 0bc2a0b..e7812ed 100644
--- a/hw/slavio_intctl.c
+++ b/hw/slavio_intctl.c
@@ -46,6 +46,7 @@
 struct SLAVIO_INTCTLState;
 
 typedef struct SLAVIO_CPUINTCTLState {
+    MemoryRegion iomem;
     struct SLAVIO_INTCTLState *master;
     uint32_t intreg_pending;
     uint32_t cpu;
@@ -77,7 +78,8 @@ typedef struct SLAVIO_INTCTLState {
 static void slavio_check_interrupts(SLAVIO_INTCTLState *s, int set_irqs);
 
 // per-cpu interrupt controller
-static uint32_t slavio_intctl_mem_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_intctl_mem_readl(void *opaque, target_phys_addr_t addr,
+                                        unsigned size)
 {
     SLAVIO_CPUINTCTLState *s = opaque;
     uint32_t saddr, ret;
@@ -97,7 +99,7 @@ static uint32_t slavio_intctl_mem_readl(void *opaque, target_phys_addr_t addr)
 }
 
 static void slavio_intctl_mem_writel(void *opaque, target_phys_addr_t addr,
-                                     uint32_t val)
+                                     uint64_t val, unsigned size)
 {
     SLAVIO_CPUINTCTLState *s = opaque;
     uint32_t saddr;
@@ -122,16 +124,14 @@ static void slavio_intctl_mem_writel(void *opaque, target_phys_addr_t addr,
     }
 }
 
-static CPUReadMemoryFunc * const slavio_intctl_mem_read[3] = {
-    NULL,
-    NULL,
-    slavio_intctl_mem_readl,
-};
-
-static CPUWriteMemoryFunc * const slavio_intctl_mem_write[3] = {
-    NULL,
-    NULL,
-    slavio_intctl_mem_writel,
+static const MemoryRegionOps slavio_intctl_mem_ops = {
+    .read = slavio_intctl_mem_readl,
+    .write = slavio_intctl_mem_writel,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
 };
 
 // master system interrupt controller
@@ -422,8 +422,8 @@ static void slavio_intctl_reset(DeviceState *d)
 static int slavio_intctl_init1(SysBusDevice *dev)
 {
     SLAVIO_INTCTLState *s = FROM_SYSBUS(SLAVIO_INTCTLState, dev);
-    int io_memory;
     unsigned int i, j;
+    char slave_name[45];
 
     qdev_init_gpio_in(&dev->qdev, slavio_set_irq_all, 32 + MAX_CPUS);
     memory_region_init_io(&s->iomem, &slavio_intctlm_mem_ops, s,
@@ -431,14 +431,14 @@ static int slavio_intctl_init1(SysBusDevice *dev)
     sysbus_init_mmio_region(dev, &s->iomem);
 
     for (i = 0; i < MAX_CPUS; i++) {
+        snprintf(slave_name, sizeof(slave_name),
+                 "slave-interrupt-controller-%i", i);
         for (j = 0; j < MAX_PILS; j++) {
             sysbus_init_irq(dev, &s->cpu_irqs[i][j]);
         }
-        io_memory = cpu_register_io_memory(slavio_intctl_mem_read,
-                                           slavio_intctl_mem_write,
-                                           &s->slaves[i],
-                                           DEVICE_NATIVE_ENDIAN);
-        sysbus_init_mmio(dev, INTCTL_SIZE, io_memory);
+        memory_region_init_io(&s->slaves[i].iomem, &slavio_intctl_mem_ops,
+                              &s->slaves[i], slave_name, INTCTL_SIZE);
+        sysbus_init_mmio_region(dev, &s->slaves[i].iomem);
         s->slaves[i].cpu = i;
         s->slaves[i].master = s;
     }
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 11/14] sun4c_intctl: convert to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (9 preceding siblings ...)
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 10/14] slavio_intctl: convert slaves interrupt controllers " Benoît Canet
@ 2011-11-15 11:14 ` Benoît Canet
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 12/14] slavio_timer: " Benoît Canet
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/sun4c_intctl.c |   32 +++++++++++++++-----------------
 1 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/hw/sun4c_intctl.c b/hw/sun4c_intctl.c
index 5c7fdef..4d01d1c 100644
--- a/hw/sun4c_intctl.c
+++ b/hw/sun4c_intctl.c
@@ -46,6 +46,7 @@
 
 typedef struct Sun4c_INTCTLState {
     SysBusDevice busdev;
+    MemoryRegion iomem;
 #ifdef DEBUG_IRQ_COUNT
     uint64_t irq_count;
 #endif
@@ -60,7 +61,8 @@ typedef struct Sun4c_INTCTLState {
 
 static void sun4c_check_interrupts(void *opaque);
 
-static uint32_t sun4c_intctl_mem_readb(void *opaque, target_phys_addr_t addr)
+static uint64_t sun4c_intctl_mem_readb(void *opaque, target_phys_addr_t addr,
+                                       unsigned size)
 {
     Sun4c_INTCTLState *s = opaque;
     uint32_t ret;
@@ -72,7 +74,7 @@ static uint32_t sun4c_intctl_mem_readb(void *opaque, target_phys_addr_t addr)
 }
 
 static void sun4c_intctl_mem_writeb(void *opaque, target_phys_addr_t addr,
-                                    uint32_t val)
+                                    uint64_t val, unsigned size)
 {
     Sun4c_INTCTLState *s = opaque;
 
@@ -82,16 +84,14 @@ static void sun4c_intctl_mem_writeb(void *opaque, target_phys_addr_t addr,
     sun4c_check_interrupts(s);
 }
 
-static CPUReadMemoryFunc * const sun4c_intctl_mem_read[3] = {
-    sun4c_intctl_mem_readb,
-    NULL,
-    NULL,
-};
-
-static CPUWriteMemoryFunc * const sun4c_intctl_mem_write[3] = {
-    sun4c_intctl_mem_writeb,
-    NULL,
-    NULL,
+static const MemoryRegionOps sun4c_intctl_mem_ops = {
+    .read = sun4c_intctl_mem_readb,
+    .write = sun4c_intctl_mem_writeb,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .impl = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
 };
 
 void sun4c_pic_info(Monitor *mon, void *opaque)
@@ -192,13 +192,11 @@ static void sun4c_intctl_reset(DeviceState *d)
 static int sun4c_intctl_init1(SysBusDevice *dev)
 {
     Sun4c_INTCTLState *s = FROM_SYSBUS(Sun4c_INTCTLState, dev);
-    int io_memory;
     unsigned int i;
 
-    io_memory = cpu_register_io_memory(sun4c_intctl_mem_read,
-                                       sun4c_intctl_mem_write, s,
-                                       DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, INTCTL_SIZE, io_memory);
+    memory_region_init_io(&s->iomem, &sun4c_intctl_mem_ops, s,
+                          "interrupt-controller", INTCTL_SIZE);
+    sysbus_init_mmio_region(dev, &s->iomem);
     qdev_init_gpio_in(&dev->qdev, sun4c_set_irq, 8);
 
     for (i = 0; i < MAX_PILS; i++) {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 12/14] slavio_timer: convert to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (10 preceding siblings ...)
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 11/14] sun4c_intctl: convert " Benoît Canet
@ 2011-11-15 11:14 ` Benoît Canet
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 13/14] sun4m_iommu: " Benoît Canet
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/slavio_timer.c |   41 ++++++++++++++++++++---------------------
 1 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c
index 84449ba..c23f990 100644
--- a/hw/slavio_timer.c
+++ b/hw/slavio_timer.c
@@ -61,6 +61,7 @@ typedef struct SLAVIO_TIMERState {
 } SLAVIO_TIMERState;
 
 typedef struct TimerContext {
+    MemoryRegion iomem;
     SLAVIO_TIMERState *s;
     unsigned int timer_index; /* 0 for system, 1 ... MAX_CPUS for CPU timers */
 } TimerContext;
@@ -128,7 +129,8 @@ static void slavio_timer_irq(void *opaque)
     }
 }
 
-static uint32_t slavio_timer_mem_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_timer_mem_readl(void *opaque, target_phys_addr_t addr,
+                                       unsigned size)
 {
     TimerContext *tc = opaque;
     SLAVIO_TIMERState *s = tc->s;
@@ -188,7 +190,7 @@ static uint32_t slavio_timer_mem_readl(void *opaque, target_phys_addr_t addr)
 }
 
 static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
-                                    uint32_t val)
+                                    uint64_t val, unsigned size)
 {
     TimerContext *tc = opaque;
     SLAVIO_TIMERState *s = tc->s;
@@ -311,16 +313,14 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
     }
 }
 
-static CPUReadMemoryFunc * const slavio_timer_mem_read[3] = {
-    NULL,
-    NULL,
-    slavio_timer_mem_readl,
-};
-
-static CPUWriteMemoryFunc * const slavio_timer_mem_write[3] = {
-    NULL,
-    NULL,
-    slavio_timer_mem_writel,
+static const MemoryRegionOps slavio_timer_mem_ops = {
+    .read = slavio_timer_mem_readl,
+    .write = slavio_timer_mem_writel,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
 };
 
 static const VMStateDescription vmstate_timer = {
@@ -374,13 +374,15 @@ static void slavio_timer_reset(DeviceState *d)
 
 static int slavio_timer_init1(SysBusDevice *dev)
 {
-    int io;
     SLAVIO_TIMERState *s = FROM_SYSBUS(SLAVIO_TIMERState, dev);
     QEMUBH *bh;
     unsigned int i;
     TimerContext *tc;
 
     for (i = 0; i <= MAX_CPUS; i++) {
+        uint64_t size;
+        char timer_name[20];
+
         tc = g_malloc0(sizeof(TimerContext));
         tc->s = s;
         tc->timer_index = i;
@@ -389,14 +391,11 @@ static int slavio_timer_init1(SysBusDevice *dev)
         s->cputimer[i].timer = ptimer_init(bh);
         ptimer_set_period(s->cputimer[i].timer, TIMER_PERIOD);
 
-        io = cpu_register_io_memory(slavio_timer_mem_read,
-                                    slavio_timer_mem_write, tc,
-                                    DEVICE_NATIVE_ENDIAN);
-        if (i == 0) {
-            sysbus_init_mmio(dev, SYS_TIMER_SIZE, io);
-        } else {
-            sysbus_init_mmio(dev, CPU_TIMER_SIZE, io);
-        }
+        size = i == 0 ? SYS_TIMER_SIZE : CPU_TIMER_SIZE;
+        snprintf(timer_name, sizeof(timer_name), "timer-%i", i);
+        memory_region_init_io(&tc->iomem, &slavio_timer_mem_ops, tc,
+                              timer_name, size);
+        sysbus_init_mmio_region(dev, &tc->iomem);
 
         sysbus_init_irq(dev, &s->cputimer[i].irq);
     }
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 13/14] sun4m_iommu: convert to memory API
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (11 preceding siblings ...)
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 12/14] slavio_timer: " Benoît Canet
@ 2011-11-15 11:14 ` Benoît Canet
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 14/14] esp: Fix memory API conversion Benoît Canet
  2011-11-15 12:20 ` [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Avi Kivity
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/sun4m_iommu.c |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/hw/sun4m_iommu.c b/hw/sun4m_iommu.c
index 6eeadfa..86d135a 100644
--- a/hw/sun4m_iommu.c
+++ b/hw/sun4m_iommu.c
@@ -128,13 +128,15 @@
 
 typedef struct IOMMUState {
     SysBusDevice busdev;
+    MemoryRegion iomem;
     uint32_t regs[IOMMU_NREGS];
     target_phys_addr_t iostart;
     qemu_irq irq;
     uint32_t version;
 } IOMMUState;
 
-static uint32_t iommu_mem_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t iommu_mem_readl(void *opaque, target_phys_addr_t addr,
+                                unsigned size)
 {
     IOMMUState *s = opaque;
     target_phys_addr_t saddr;
@@ -156,7 +158,7 @@ static uint32_t iommu_mem_readl(void *opaque, target_phys_addr_t addr)
 }
 
 static void iommu_mem_writel(void *opaque, target_phys_addr_t addr,
-                             uint32_t val)
+                             uint64_t val, unsigned size)
 {
     IOMMUState *s = opaque;
     target_phys_addr_t saddr;
@@ -237,16 +239,14 @@ static void iommu_mem_writel(void *opaque, target_phys_addr_t addr,
     }
 }
 
-static CPUReadMemoryFunc * const iommu_mem_read[3] = {
-    NULL,
-    NULL,
-    iommu_mem_readl,
-};
-
-static CPUWriteMemoryFunc * const iommu_mem_write[3] = {
-    NULL,
-    NULL,
-    iommu_mem_writel,
+static const MemoryRegionOps iommu_mem_ops = {
+    .read = iommu_mem_readl,
+    .write = iommu_mem_writel,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .impl = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
 };
 
 static uint32_t iommu_page_get_flags(IOMMUState *s, target_phys_addr_t addr)
@@ -347,13 +347,12 @@ static void iommu_reset(DeviceState *d)
 static int iommu_init1(SysBusDevice *dev)
 {
     IOMMUState *s = FROM_SYSBUS(IOMMUState, dev);
-    int io;
 
     sysbus_init_irq(dev, &s->irq);
 
-    io = cpu_register_io_memory(iommu_mem_read, iommu_mem_write, s,
-                                DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, IOMMU_NREGS * sizeof(uint32_t), io);
+    memory_region_init_io(&s->iomem, &iommu_mem_ops, s,
+                          "iommu", IOMMU_NREGS * sizeof(uint32_t));
+    sysbus_init_mmio_region(dev, &s->iomem);
 
     return 0;
 }
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH 14/14] esp: Fix memory API conversion
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (12 preceding siblings ...)
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 13/14] sun4m_iommu: " Benoît Canet
@ 2011-11-15 11:14 ` Benoît Canet
  2011-11-15 12:20 ` [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Avi Kivity
  14 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 11:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, Benoît Canet, avi

Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
 hw/esp.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/hw/esp.c b/hw/esp.c
index 2f23df9..9ab41ba 100644
--- a/hw/esp.c
+++ b/hw/esp.c
@@ -745,6 +745,7 @@ static int esp_init1(SysBusDevice *dev)
 
     memory_region_init_io(&s->iomem, &esp_mem_ops, s,
                           "esp", ESP_REGS << s->it_shift);
+    sysbus_init_mmio_region(dev, &s->iomem);
 
     qdev_init_gpio_in(&dev->qdev, esp_gpio_demux, 2);
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API.
  2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
                   ` (13 preceding siblings ...)
  2011-11-15 11:14 ` [Qemu-devel] [PATCH 14/14] esp: Fix memory API conversion Benoît Canet
@ 2011-11-15 12:20 ` Avi Kivity
  2011-11-15 15:22   ` Benoît Canet
  14 siblings, 1 reply; 19+ messages in thread
From: Avi Kivity @ 2011-11-15 12:20 UTC (permalink / raw)
  To: Benoît Canet; +Cc: blauwirbel, qemu-devel

On 11/15/2011 01:13 PM, Benoît Canet wrote:
> .valid was used where the access size is specified like in
> http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
> .impl was used when the behavior is not known.

Thanks, all applied except:

>   sun4c_intctl: convert to memory API
>   sun4m_iommu: convert to memory API

Where we had raced - I just wrote those two conversions as well.  As it
happens, these were the only two patches that used .impl, which is a
behaviour change; please avoid behaviour changes and do them as separate
patches.

Note I don't think .impl works well when .min_access_size = 4 - it
requires RMW which we don't do yet.

>   esp: Fix memory API conversion
>

Thanks for that too.  Will fold it into the bad patch.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API.
  2011-11-15 12:20 ` [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Avi Kivity
@ 2011-11-15 15:22   ` Benoît Canet
  2011-11-15 17:48     ` Avi Kivity
  0 siblings, 1 reply; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 15:22 UTC (permalink / raw)
  To: Avi Kivity; +Cc: blauwirbel, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1877 bytes --]

When converting lines like :

-    cpu_register_physical_memory_offset(0x1f800000, 0x1000,
-                                        sh7750_io_memory, 0x1f800000);
-    cpu_register_physical_memory_offset(0xff800000, 0x1000,
-                                        sh7750_io_memory, 0x1f800000);

I'm tempted to do :

+    memory_region_init_alias(&s->iomem_1f8, "memory-1f8",
+                             &s->iomem, 0x1f800000, 0x1000);
+    memory_region_add_subregion(sysmem, 0x1f800000, &s->iomem_1f8);
+
+    memory_region_init_alias(&s->iomem_ff8, "memory-ff8",
+                             &s->iomem, 0xff800000, 0x1000);
+    memory_region_add_subregion(sysmem, 0xff800000, &s->iomem_ff8);

but I'm affraid to loose some information contained in the offset different
from the base address (0xff800000 != 0x1f800000).

What is the current recommendation regarding such conversions ?

Benoît


2011/11/15 Avi Kivity <avi@redhat.com>

> On 11/15/2011 01:13 PM, Benoît Canet wrote:
> > .valid was used where the access size is specified like in
> >
> http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
> > .impl was used when the behavior is not known.
>
> Thanks, all applied except:
>
> >   sun4c_intctl: convert to memory API
> >   sun4m_iommu: convert to memory API
>
> Where we had raced - I just wrote those two conversions as well.  As it
> happens, these were the only two patches that used .impl, which is a
> behaviour change; please avoid behaviour changes and do them as separate
> patches.
>
> Note I don't think .impl works well when .min_access_size = 4 - it
> requires RMW which we don't do yet.
>
> >   esp: Fix memory API conversion
> >
>
> Thanks for that too.  Will fold it into the bad patch.
>
> --
> error compiling committee.c: too many arguments to function
>
>

[-- Attachment #2: Type: text/html, Size: 2844 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API.
  2011-11-15 15:22   ` Benoît Canet
@ 2011-11-15 17:48     ` Avi Kivity
  2011-11-15 20:03       ` Benoît Canet
  0 siblings, 1 reply; 19+ messages in thread
From: Avi Kivity @ 2011-11-15 17:48 UTC (permalink / raw)
  To: Benoît Canet; +Cc: blauwirbel, qemu-devel

On 11/15/2011 05:22 PM, Benoît Canet wrote:
> When converting lines like :
>
> -    cpu_register_physical_memory_offset(0x1f800000, 0x1000,
> -                                        sh7750_io_memory, 0x1f800000);
> -    cpu_register_physical_memory_offset(0xff800000, 0x1000,
> -                                        sh7750_io_memory, 0x1f800000);
>
> I'm tempted to do :
>
> +    memory_region_init_alias(&s->iomem_1f8, "memory-1f8",
> +                             &s->iomem, 0x1f800000, 0x1000);
> +    memory_region_add_subregion(sysmem, 0x1f800000, &s->iomem_1f8);
> +
> +    memory_region_init_alias(&s->iomem_ff8, "memory-ff8",
> +                             &s->iomem, 0xff800000, 0x1000);
> +    memory_region_add_subregion(sysmem, 0xff800000, &s->iomem_ff8);
>
> but I'm affraid to loose some information contained in the offset
> different from the base address (0xff800000 != 0x1f800000).
>

I think the last lines need to be

    memory_region_init_alias(&s->iomem_ff8, "memory-ff8",
                             &s->iomem, 0x1f800000, 0x1000);
    memory_region_add_subregion(sysmem, 0xff800000, &s->iomem_ff8);

This redirects writes to 0xff800xxx in sysmem to 0x1f800xxx in iomem,
which is what I think the original code intends.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API.
  2011-11-15 17:48     ` Avi Kivity
@ 2011-11-15 20:03       ` Benoît Canet
  0 siblings, 0 replies; 19+ messages in thread
From: Benoît Canet @ 2011-11-15 20:03 UTC (permalink / raw)
  To: Avi Kivity; +Cc: blauwirbel, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1465 bytes --]

Thanks

2011/11/15 Avi Kivity <avi@redhat.com>

> On 11/15/2011 05:22 PM, Benoît Canet wrote:
> > When converting lines like :
> >
> > -    cpu_register_physical_memory_offset(0x1f800000, 0x1000,
> > -                                        sh7750_io_memory, 0x1f800000);
> > -    cpu_register_physical_memory_offset(0xff800000, 0x1000,
> > -                                        sh7750_io_memory, 0x1f800000);
> >
> > I'm tempted to do :
> >
> > +    memory_region_init_alias(&s->iomem_1f8, "memory-1f8",
> > +                             &s->iomem, 0x1f800000, 0x1000);
> > +    memory_region_add_subregion(sysmem, 0x1f800000, &s->iomem_1f8);
> > +
> > +    memory_region_init_alias(&s->iomem_ff8, "memory-ff8",
> > +                             &s->iomem, 0xff800000, 0x1000);
> > +    memory_region_add_subregion(sysmem, 0xff800000, &s->iomem_ff8);
> >
> > but I'm affraid to loose some information contained in the offset
> > different from the base address (0xff800000 != 0x1f800000).
> >
>
> I think the last lines need to be
>
>    memory_region_init_alias(&s->iomem_ff8, "memory-ff8",
>                             &s->iomem, 0x1f800000, 0x1000);
>    memory_region_add_subregion(sysmem, 0xff800000, &s->iomem_ff8);
>
> This redirects writes to 0xff800xxx in sysmem to 0x1f800xxx in iomem,
> which is what I think the original code intends.
>
> --
> error compiling committee.c: too many arguments to function
>
>

[-- Attachment #2: Type: text/html, Size: 2091 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-11-15 20:03 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 01/14] slavio_misc: convert apc " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 02/14] slavio_misc: convert configuration " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 03/14] slavio_misc: convert diagnostic " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 04/14] slavio_misc: convert modem " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 05/14] slavio_misc: convert leds " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 06/14] slavio_misc: convert system control " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 07/14] slavio_misc: convert aux1 " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 08/14] slavio_misc: convert aux2 " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 09/14] slavio_intctl: convert master interrupt controller " Benoît Canet
2011-11-15 11:14 ` [Qemu-devel] [PATCH 10/14] slavio_intctl: convert slaves interrupt controllers " Benoît Canet
2011-11-15 11:14 ` [Qemu-devel] [PATCH 11/14] sun4c_intctl: convert " Benoît Canet
2011-11-15 11:14 ` [Qemu-devel] [PATCH 12/14] slavio_timer: " Benoît Canet
2011-11-15 11:14 ` [Qemu-devel] [PATCH 13/14] sun4m_iommu: " Benoît Canet
2011-11-15 11:14 ` [Qemu-devel] [PATCH 14/14] esp: Fix memory API conversion Benoît Canet
2011-11-15 12:20 ` [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Avi Kivity
2011-11-15 15:22   ` Benoît Canet
2011-11-15 17:48     ` Avi Kivity
2011-11-15 20:03       ` Benoît Canet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).