* [Qemu-devel] [PATCH 0/2] arm: convert a couple of devices away from old_mmio
@ 2018-04-27 17:36 Peter Maydell
2018-04-27 17:36 ` [Qemu-devel] [PATCH 1/2] hw/usb/tusb6010: Convert " Peter Maydell
2018-04-27 17:36 ` [Qemu-devel] [PATCH 2/2] hw/net/smc91c111: " Peter Maydell
0 siblings, 2 replies; 5+ messages in thread
From: Peter Maydell @ 2018-04-27 17:36 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
We've had an API transition running for years for MemoryRegionOps
away from the old_mmio function-per-width to the new-style single
function each for read and write. This patchset converts a couple
of devices used in Arm machines to the new style.
This leaves us with:
* hw/char/parallel
* hw/block/pflash_cfi02
* hw/display/vga-isa-mm
* hw/input/pckbd
* hw/intc/apic
* hw/m68k/mcf5206
* hw/net/pcinet-pci
* hw/pci-host/bonito
* hw/ppc/ppc405_boards
* hw/ppc/ppc405_uc
* hw/ppc/prep
* hw/sh4/sh7750
* hw/timer/m48t59
* hw/watchdog/wdt_i6300esb
for 17 uses in total.
The conversions are fairly simple, so it would be nice to get
this transition done for the next release -- then we can delete
the code in memory.c that has to consider old_mmio.
thanks
-- PMM
Peter Maydell (2):
hw/usb/tusb6010: Convert away from old_mmio
hw/net/smc91c111: Convert away from old_mmio
hw/net/smc91c111.c | 54 +++++++++++++++++++++-------------------------
hw/usb/tusb6010.c | 40 ++++++++++++++++++++++++++++++----
2 files changed, 61 insertions(+), 33 deletions(-)
--
2.17.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/2] hw/usb/tusb6010: Convert away from old_mmio
2018-04-27 17:36 [Qemu-devel] [PATCH 0/2] arm: convert a couple of devices away from old_mmio Peter Maydell
@ 2018-04-27 17:36 ` Peter Maydell
2018-05-01 19:16 ` Richard Henderson
2018-04-27 17:36 ` [Qemu-devel] [PATCH 2/2] hw/net/smc91c111: " Peter Maydell
1 sibling, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2018-04-27 17:36 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
Convert the tusb6010 device away from using the old_mmio field
of MemoryRegionOps. This device is used only in the n800 and n810
boards.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/usb/tusb6010.c | 40 ++++++++++++++++++++++++++++++++++++----
1 file changed, 36 insertions(+), 4 deletions(-)
diff --git a/hw/usb/tusb6010.c b/hw/usb/tusb6010.c
index 2662c060ed..a2128024c1 100644
--- a/hw/usb/tusb6010.c
+++ b/hw/usb/tusb6010.c
@@ -641,11 +641,43 @@ static void tusb_async_writew(void *opaque, hwaddr addr,
}
}
+static uint64_t tusb_async_readfn(void *opaque, hwaddr addr, unsigned size)
+{
+ switch (size) {
+ case 1:
+ return tusb_async_readb(opaque, addr);
+ case 2:
+ return tusb_async_readh(opaque, addr);
+ case 4:
+ return tusb_async_readw(opaque, addr);
+ default:
+ g_assert_not_reached();
+ }
+}
+
+static void tusb_async_writefn(void *opaque, hwaddr addr,
+ uint64_t value, unsigned size)
+{
+ switch (size) {
+ case 1:
+ tusb_async_writeb(opaque, addr, value);
+ break;
+ case 2:
+ tusb_async_writeh(opaque, addr, value);
+ break;
+ case 4:
+ tusb_async_writew(opaque, addr, value);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
static const MemoryRegionOps tusb_async_ops = {
- .old_mmio = {
- .read = { tusb_async_readb, tusb_async_readh, tusb_async_readw, },
- .write = { tusb_async_writeb, tusb_async_writeh, tusb_async_writew, },
- },
+ .read = tusb_async_readfn,
+ .write = tusb_async_writefn,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
.endianness = DEVICE_NATIVE_ENDIAN,
};
--
2.17.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/2] hw/net/smc91c111: Convert away from old_mmio
2018-04-27 17:36 [Qemu-devel] [PATCH 0/2] arm: convert a couple of devices away from old_mmio Peter Maydell
2018-04-27 17:36 ` [Qemu-devel] [PATCH 1/2] hw/usb/tusb6010: Convert " Peter Maydell
@ 2018-04-27 17:36 ` Peter Maydell
2018-05-01 19:17 ` Richard Henderson
1 sibling, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2018-04-27 17:36 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
Convert the smc91c111 device away from using the old_mmio field of
MemoryRegionOps. This device is used by several Arm board models.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/net/smc91c111.c | 54 +++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 29 deletions(-)
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
index 3b16dcf5a1..c8cc5379b7 100644
--- a/hw/net/smc91c111.c
+++ b/hw/net/smc91c111.c
@@ -625,37 +625,33 @@ static uint32_t smc91c111_readb(void *opaque, hwaddr offset)
return 0;
}
-static void smc91c111_writew(void *opaque, hwaddr offset,
- uint32_t value)
+static uint64_t smc91c111_readfn(void *opaque, hwaddr addr, unsigned size)
{
- smc91c111_writeb(opaque, offset, value & 0xff);
- smc91c111_writeb(opaque, offset + 1, value >> 8);
+ int i;
+ uint32_t val = 0;
+
+ for (i = 0; i < size; i++) {
+ val |= smc91c111_readb(opaque, addr + i) << (i * 8);
+ }
+ return val;
}
-static void smc91c111_writel(void *opaque, hwaddr offset,
- uint32_t value)
+static void smc91c111_writefn(void *opaque, hwaddr addr,
+ uint64_t value, unsigned size)
{
+ int i = 0;
+
/* 32-bit writes to offset 0xc only actually write to the bank select
- register (offset 0xe) */
- if (offset != 0xc)
- smc91c111_writew(opaque, offset, value & 0xffff);
- smc91c111_writew(opaque, offset + 2, value >> 16);
-}
+ * register (offset 0xe), so skip the first two bytes we would write.
+ */
+ if (addr == 0xc && size == 4) {
+ i += 2;
+ }
-static uint32_t smc91c111_readw(void *opaque, hwaddr offset)
-{
- uint32_t val;
- val = smc91c111_readb(opaque, offset);
- val |= smc91c111_readb(opaque, offset + 1) << 8;
- return val;
-}
-
-static uint32_t smc91c111_readl(void *opaque, hwaddr offset)
-{
- uint32_t val;
- val = smc91c111_readw(opaque, offset);
- val |= smc91c111_readw(opaque, offset + 2) << 16;
- return val;
+ for (; i < size; i++) {
+ smc91c111_writeb(opaque, addr + i,
+ extract32(value, i * 8, 8));
+ }
}
static int smc91c111_can_receive_nc(NetClientState *nc)
@@ -747,10 +743,10 @@ static const MemoryRegionOps smc91c111_mem_ops = {
/* The special case for 32 bit writes to 0xc means we can't just
* set .impl.min/max_access_size to 1, unfortunately
*/
- .old_mmio = {
- .read = { smc91c111_readb, smc91c111_readw, smc91c111_readl, },
- .write = { smc91c111_writeb, smc91c111_writew, smc91c111_writel, },
- },
+ .read = smc91c111_readfn,
+ .write = smc91c111_writefn,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
.endianness = DEVICE_NATIVE_ENDIAN,
};
--
2.17.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] hw/usb/tusb6010: Convert away from old_mmio
2018-04-27 17:36 ` [Qemu-devel] [PATCH 1/2] hw/usb/tusb6010: Convert " Peter Maydell
@ 2018-05-01 19:16 ` Richard Henderson
0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2018-05-01 19:16 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches
On 04/27/2018 10:36 AM, Peter Maydell wrote:
> Convert the tusb6010 device away from using the old_mmio field
> of MemoryRegionOps. This device is used only in the n800 and n810
> boards.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/usb/tusb6010.c | 40 ++++++++++++++++++++++++++++++++++++----
> 1 file changed, 36 insertions(+), 4 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] hw/net/smc91c111: Convert away from old_mmio
2018-04-27 17:36 ` [Qemu-devel] [PATCH 2/2] hw/net/smc91c111: " Peter Maydell
@ 2018-05-01 19:17 ` Richard Henderson
0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2018-05-01 19:17 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches
On 04/27/2018 10:36 AM, Peter Maydell wrote:
> Convert the smc91c111 device away from using the old_mmio field of
> MemoryRegionOps. This device is used by several Arm board models.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/net/smc91c111.c | 54 +++++++++++++++++++++-------------------------
> 1 file changed, 25 insertions(+), 29 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-01 19:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-27 17:36 [Qemu-devel] [PATCH 0/2] arm: convert a couple of devices away from old_mmio Peter Maydell
2018-04-27 17:36 ` [Qemu-devel] [PATCH 1/2] hw/usb/tusb6010: Convert " Peter Maydell
2018-05-01 19:16 ` Richard Henderson
2018-04-27 17:36 ` [Qemu-devel] [PATCH 2/2] hw/net/smc91c111: " Peter Maydell
2018-05-01 19:17 ` Richard Henderson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.