arm: convert a couple of devices away from old_mmio
cover arm: convert a couple of devices away from old_mmio
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(-)
Signature · 1 line
2.17.0
PATCH 1/2 hw/usb/tusb6010: Convert away from old_mmio
Convert the tusb6010 device away from using the old_mmio field of MemoryRegionOps. This device is used only in the n800 and n810 boards.
--- hw/usb/tusb6010.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-)
hw/usb/tusb6010.c +36 -4
@@ -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 , };
Signature · 1 line
2.17.0
Re: [Qemu-arm] [Qemu-devel] [PATCH 1/2] hw/usb/tusb6010: Convert away from old_mmio
Quoted 8 lines · Peter Maydell
Convert the tusb6010 device away from using the
old_mmiofield of MemoryRegionOps. This device is used only in the n800 and n810 boards.Signed-off-by Peter Maydell <[email protected]>--- hw/usb/tusb6010.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-)
r~
PATCH 2/2 hw/net/smc91c111: Convert away from old_mmio
In reply to Peter MaydellConvert the smc91c111 device away from using the old_mmio field of MemoryRegionOps. This device is used by several Arm board models.
--- hw/net/smc91c111.c | 54 +++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 29 deletions(-)
hw/net/smc91c111.c +25 -29
@@ -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, };
Signature · 1 line
2.17.0
Re: [Qemu-devel] [PATCH 2/2] hw/net/smc91c111: Convert away from old_mmio
Quoted 7 lines · Peter Maydell
Convert the smc91c111 device away from using the
old_mmiofield of MemoryRegionOps. This device is used by several Arm board models.Signed-off-by Peter Maydell <[email protected]>--- hw/net/smc91c111.c | 54 +++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 29 deletions(-)
r~