* [Qemu-devel] [PATCH 1/6] hw/arm/palm.c: Don't use old_mmio for static_ops
2017-09-16 16:46 [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio Peter Maydell
@ 2017-09-16 16:46 ` Peter Maydell
2017-09-20 20:59 ` Richard Henderson
2017-09-16 16:46 ` [Qemu-devel] [PATCH 2/6] hw/gpio/omap_gpio.c: Don't use old_mmio Peter Maydell
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2017-09-16 16:46 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
Update the static_ops functions to use new-style mmio
rather than the legacy old_mmio functions.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/palm.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
index bf070a2..264f5bd 100644
--- a/hw/arm/palm.c
+++ b/hw/arm/palm.c
@@ -30,26 +30,16 @@
#include "hw/loader.h"
#include "exec/address-spaces.h"
-static uint32_t static_readb(void *opaque, hwaddr offset)
+static uint64_t static_read(void *opaque, hwaddr offset, unsigned size)
{
- uint32_t *val = (uint32_t *) opaque;
- return *val >> ((offset & 3) << 3);
-}
+ uint32_t *val = (uint32_t *)opaque;
+ uint32_t sizemask = 7 >> size;
-static uint32_t static_readh(void *opaque, hwaddr offset)
-{
- uint32_t *val = (uint32_t *) opaque;
- return *val >> ((offset & 1) << 3);
-}
-
-static uint32_t static_readw(void *opaque, hwaddr offset)
-{
- uint32_t *val = (uint32_t *) opaque;
- return *val >> ((offset & 0) << 3);
+ return *val >> ((offset & sizemask) << 3);
}
-static void static_write(void *opaque, hwaddr offset,
- uint32_t value)
+static void static_write(void *opaque, hwaddr offset, uint64_t value,
+ unsigned size)
{
#ifdef SPY
printf("%s: value %08lx written at " PA_FMT "\n",
@@ -58,10 +48,10 @@ static void static_write(void *opaque, hwaddr offset,
}
static const MemoryRegionOps static_ops = {
- .old_mmio = {
- .read = { static_readb, static_readh, static_readw, },
- .write = { static_write, static_write, static_write, },
- },
+ .read = static_read,
+ .write = static_write,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
.endianness = DEVICE_NATIVE_ENDIAN,
};
--
2.7.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 2/6] hw/gpio/omap_gpio.c: Don't use old_mmio
2017-09-16 16:46 [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio Peter Maydell
2017-09-16 16:46 ` [Qemu-devel] [PATCH 1/6] hw/arm/palm.c: Don't use old_mmio for static_ops Peter Maydell
@ 2017-09-16 16:46 ` Peter Maydell
2017-09-20 21:00 ` Richard Henderson
2017-09-16 16:46 ` [Qemu-devel] [PATCH 3/6] hw/timer/omap_synctimer.c: " Peter Maydell
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2017-09-16 16:46 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
Drop the use of old_mmio in the omap2_gpio memory ops.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/gpio/omap_gpio.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
index 1df394e..17891e2 100644
--- a/hw/gpio/omap_gpio.c
+++ b/hw/gpio/omap_gpio.c
@@ -525,17 +525,23 @@ static void omap2_gpio_module_write(void *opaque, hwaddr addr,
}
}
-static uint32_t omap2_gpio_module_readp(void *opaque, hwaddr addr)
+static uint64_t omap2_gpio_module_readp(void *opaque, hwaddr addr,
+ unsigned size)
{
return omap2_gpio_module_read(opaque, addr & ~3) >> ((addr & 3) << 3);
}
static void omap2_gpio_module_writep(void *opaque, hwaddr addr,
- uint32_t value)
+ uint64_t value, unsigned size)
{
uint32_t cur = 0;
uint32_t mask = 0xffff;
+ if (size == 4) {
+ omap2_gpio_module_write(opaque, addr, value);
+ return;
+ }
+
switch (addr & ~3) {
case 0x00: /* GPIO_REVISION */
case 0x14: /* GPIO_SYSSTATUS */
@@ -581,18 +587,10 @@ static void omap2_gpio_module_writep(void *opaque, hwaddr addr,
}
static const MemoryRegionOps omap2_gpio_module_ops = {
- .old_mmio = {
- .read = {
- omap2_gpio_module_readp,
- omap2_gpio_module_readp,
- omap2_gpio_module_read,
- },
- .write = {
- omap2_gpio_module_writep,
- omap2_gpio_module_writep,
- omap2_gpio_module_write,
- },
- },
+ .read = omap2_gpio_module_readp,
+ .write = omap2_gpio_module_writep,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
.endianness = DEVICE_NATIVE_ENDIAN,
};
--
2.7.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 3/6] hw/timer/omap_synctimer.c: Don't use old_mmio
2017-09-16 16:46 [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio Peter Maydell
2017-09-16 16:46 ` [Qemu-devel] [PATCH 1/6] hw/arm/palm.c: Don't use old_mmio for static_ops Peter Maydell
2017-09-16 16:46 ` [Qemu-devel] [PATCH 2/6] hw/gpio/omap_gpio.c: Don't use old_mmio Peter Maydell
@ 2017-09-16 16:46 ` Peter Maydell
2017-09-20 21:02 ` Richard Henderson
2017-09-16 16:46 ` [Qemu-devel] [PATCH 4/6] hw/timer/omap_gptimer: " Peter Maydell
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2017-09-16 16:46 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
Don't use the old_mmio in the memory region ops struct.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/timer/omap_synctimer.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/hw/timer/omap_synctimer.c b/hw/timer/omap_synctimer.c
index 9ee6519..0d75a90 100644
--- a/hw/timer/omap_synctimer.c
+++ b/hw/timer/omap_synctimer.c
@@ -68,25 +68,32 @@ static uint32_t omap_synctimer_readh(void *opaque, hwaddr addr)
}
}
-static void omap_synctimer_write(void *opaque, hwaddr addr,
- uint32_t value)
+static uint64_t omap_synctimer_readfn(void *opaque, hwaddr addr,
+ unsigned size)
+{
+ switch (size) {
+ case 1:
+ return omap_badwidth_read32(opaque, addr);
+ case 2:
+ return omap_synctimer_readh(opaque, addr);
+ case 4:
+ return omap_synctimer_readw(opaque, addr);
+ default:
+ g_assert_not_reached();
+ }
+}
+
+static void omap_synctimer_writefn(void *opaque, hwaddr addr,
+ uint64_t value, unsigned size)
{
OMAP_BAD_REG(addr);
}
static const MemoryRegionOps omap_synctimer_ops = {
- .old_mmio = {
- .read = {
- omap_badwidth_read32,
- omap_synctimer_readh,
- omap_synctimer_readw,
- },
- .write = {
- omap_badwidth_write32,
- omap_synctimer_write,
- omap_synctimer_write,
- },
- },
+ .read = omap_synctimer_readfn,
+ .write = omap_synctimer_writefn,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
.endianness = DEVICE_NATIVE_ENDIAN,
};
--
2.7.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 4/6] hw/timer/omap_gptimer: Don't use old_mmio
2017-09-16 16:46 [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio Peter Maydell
` (2 preceding siblings ...)
2017-09-16 16:46 ` [Qemu-devel] [PATCH 3/6] hw/timer/omap_synctimer.c: " Peter Maydell
@ 2017-09-16 16:46 ` Peter Maydell
2017-09-20 21:02 ` Richard Henderson
2017-09-16 16:46 ` [Qemu-devel] [PATCH 5/6] hw/i2c/omap_i2c.c: " Peter Maydell
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2017-09-16 16:46 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
Don't use the old_mmio struct in memory region ops.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/timer/omap_gptimer.c | 49 +++++++++++++++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 12 deletions(-)
diff --git a/hw/timer/omap_gptimer.c b/hw/timer/omap_gptimer.c
index 5e3e8a6..6d7c8a3 100644
--- a/hw/timer/omap_gptimer.c
+++ b/hw/timer/omap_gptimer.c
@@ -450,19 +450,44 @@ static void omap_gp_timer_writeh(void *opaque, hwaddr addr,
s->writeh = (uint16_t) value;
}
+static uint64_t omap_gp_timer_readfn(void *opaque, hwaddr addr,
+ unsigned size)
+{
+ switch (size) {
+ case 1:
+ return omap_badwidth_read32(opaque, addr);
+ case 2:
+ return omap_gp_timer_readh(opaque, addr);
+ case 4:
+ return omap_gp_timer_readw(opaque, addr);
+ default:
+ g_assert_not_reached();
+ }
+}
+
+static void omap_gp_timer_writefn(void *opaque, hwaddr addr,
+ uint64_t value, unsigned size)
+{
+ switch (size) {
+ case 1:
+ omap_badwidth_write32(opaque, addr, value);
+ break;
+ case 2:
+ omap_gp_timer_writeh(opaque, addr, value);
+ break;
+ case 4:
+ omap_gp_timer_write(opaque, addr, value);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
static const MemoryRegionOps omap_gp_timer_ops = {
- .old_mmio = {
- .read = {
- omap_badwidth_read32,
- omap_gp_timer_readh,
- omap_gp_timer_readw,
- },
- .write = {
- omap_badwidth_write32,
- omap_gp_timer_writeh,
- omap_gp_timer_write,
- },
- },
+ .read = omap_gp_timer_readfn,
+ .write = omap_gp_timer_writefn,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
.endianness = DEVICE_NATIVE_ENDIAN,
};
--
2.7.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 4/6] hw/timer/omap_gptimer: Don't use old_mmio
2017-09-16 16:46 ` [Qemu-devel] [PATCH 4/6] hw/timer/omap_gptimer: " Peter Maydell
@ 2017-09-20 21:02 ` Richard Henderson
0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2017-09-20 21:02 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches
On 09/16/2017 11:46 AM, Peter Maydell wrote:
> Don't use the old_mmio struct in memory region ops.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/timer/omap_gptimer.c | 49 +++++++++++++++++++++++++++++++++++++------------
> 1 file changed, 37 insertions(+), 12 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 5/6] hw/i2c/omap_i2c.c: Don't use old_mmio
2017-09-16 16:46 [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio Peter Maydell
` (3 preceding siblings ...)
2017-09-16 16:46 ` [Qemu-devel] [PATCH 4/6] hw/timer/omap_gptimer: " Peter Maydell
@ 2017-09-16 16:46 ` Peter Maydell
2017-09-20 21:03 ` Richard Henderson
2017-09-16 16:46 ` [Qemu-devel] [PATCH 6/6] hw/arm/omap2.c: " Peter Maydell
2017-09-17 13:21 ` [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio Mark Cave-Ayland
6 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2017-09-16 16:46 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
Don't use old_mmio in the memory region ops struct.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/i2c/omap_i2c.c | 44 ++++++++++++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 12 deletions(-)
diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c
index f6e80be..12264ee 100644
--- a/hw/i2c/omap_i2c.c
+++ b/hw/i2c/omap_i2c.c
@@ -430,19 +430,39 @@ static void omap_i2c_writeb(void *opaque, hwaddr addr,
}
}
+static uint64_t omap_i2c_readfn(void *opaque, hwaddr addr,
+ unsigned size)
+{
+ switch (size) {
+ case 2:
+ return omap_i2c_read(opaque, addr);
+ default:
+ return omap_badwidth_read16(opaque, addr);
+ }
+}
+
+static void omap_i2c_writefn(void *opaque, hwaddr addr,
+ uint64_t value, unsigned size)
+{
+ switch (size) {
+ case 1:
+ /* Only the last fifo write can be 8 bit. */
+ omap_i2c_writeb(opaque, addr, value);
+ break;
+ case 2:
+ omap_i2c_write(opaque, addr, value);
+ break;
+ default:
+ omap_badwidth_write16(opaque, addr, value);
+ break;
+ }
+}
+
static const MemoryRegionOps omap_i2c_ops = {
- .old_mmio = {
- .read = {
- omap_badwidth_read16,
- omap_i2c_read,
- omap_badwidth_read16,
- },
- .write = {
- omap_i2c_writeb, /* Only the last fifo write can be 8 bit. */
- omap_i2c_write,
- omap_badwidth_write16,
- },
- },
+ .read = omap_i2c_readfn,
+ .write = omap_i2c_writefn,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
.endianness = DEVICE_NATIVE_ENDIAN,
};
--
2.7.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 5/6] hw/i2c/omap_i2c.c: Don't use old_mmio
2017-09-16 16:46 ` [Qemu-devel] [PATCH 5/6] hw/i2c/omap_i2c.c: " Peter Maydell
@ 2017-09-20 21:03 ` Richard Henderson
0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2017-09-20 21:03 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches
On 09/16/2017 11:46 AM, Peter Maydell wrote:
> Don't use old_mmio in the memory region ops struct.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/i2c/omap_i2c.c | 44 ++++++++++++++++++++++++++++++++------------
> 1 file changed, 32 insertions(+), 12 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 6/6] hw/arm/omap2.c: Don't use old_mmio
2017-09-16 16:46 [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio Peter Maydell
` (4 preceding siblings ...)
2017-09-16 16:46 ` [Qemu-devel] [PATCH 5/6] hw/i2c/omap_i2c.c: " Peter Maydell
@ 2017-09-16 16:46 ` Peter Maydell
2017-09-20 21:04 ` Richard Henderson
2017-09-17 13:21 ` [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio Mark Cave-Ayland
6 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2017-09-16 16:46 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
Don't use old_mmio in the memory region ops struct.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/omap2.c | 49 +++++++++++++++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 12 deletions(-)
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
index ece25ae..f35d265 100644
--- a/hw/arm/omap2.c
+++ b/hw/arm/omap2.c
@@ -2087,19 +2087,44 @@ static void omap_sysctl_write(void *opaque, hwaddr addr,
}
}
+static uint64_t omap_sysctl_readfn(void *opaque, hwaddr addr,
+ unsigned size)
+{
+ switch (size) {
+ case 1:
+ return omap_sysctl_read8(opaque, addr);
+ case 2:
+ return omap_badwidth_read32(opaque, addr); /* TODO */
+ case 4:
+ return omap_sysctl_read(opaque, addr);
+ default:
+ g_assert_not_reached();
+ }
+}
+
+static void omap_sysctl_writefn(void *opaque, hwaddr addr,
+ uint64_t value, unsigned size)
+{
+ switch (size) {
+ case 1:
+ omap_sysctl_write8(opaque, addr, value);
+ break;
+ case 2:
+ omap_badwidth_write32(opaque, addr, value); /* TODO */
+ break;
+ case 4:
+ omap_sysctl_write(opaque, addr, value);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
static const MemoryRegionOps omap_sysctl_ops = {
- .old_mmio = {
- .read = {
- omap_sysctl_read8,
- omap_badwidth_read32, /* TODO */
- omap_sysctl_read,
- },
- .write = {
- omap_sysctl_write8,
- omap_badwidth_write32, /* TODO */
- omap_sysctl_write,
- },
- },
+ .read = omap_sysctl_readfn,
+ .write = omap_sysctl_writefn,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
.endianness = DEVICE_NATIVE_ENDIAN,
};
--
2.7.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 6/6] hw/arm/omap2.c: Don't use old_mmio
2017-09-16 16:46 ` [Qemu-devel] [PATCH 6/6] hw/arm/omap2.c: " Peter Maydell
@ 2017-09-20 21:04 ` Richard Henderson
0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2017-09-20 21:04 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches
On 09/16/2017 11:46 AM, Peter Maydell wrote:
> Don't use old_mmio in the memory region ops struct.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/arm/omap2.c | 49 +++++++++++++++++++++++++++++++++++++------------
> 1 file changed, 37 insertions(+), 12 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio
2017-09-16 16:46 [Qemu-devel] [PATCH 0/6] convert some omap/palm devices from using old_mmio Peter Maydell
` (5 preceding siblings ...)
2017-09-16 16:46 ` [Qemu-devel] [PATCH 6/6] hw/arm/omap2.c: " Peter Maydell
@ 2017-09-17 13:21 ` Mark Cave-Ayland
6 siblings, 0 replies; 14+ messages in thread
From: Mark Cave-Ayland @ 2017-09-17 13:21 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches
On 16/09/17 17:46, Peter Maydell wrote:
> This patchset converts a handful of old devices from the old_mmio
> fields in MemoryRegionOps. We don't have very many devices still
> using old_mmio, so it would be nice to get rid of the remainder
> and drop the field entirely at some point.
That reminds me - the macio IDE controller still uses old_mmio
accessors. I'm currently working around that area so I'll see if I can
slip a conversion into my next patchset.
ATB,
Mark.
^ permalink raw reply [flat|nested] 14+ messages in thread