[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/39] cirrus: simplify mmio BAR access functions
From: |
Avi Kivity |
Subject: |
[Qemu-devel] [PATCH 04/39] cirrus: simplify mmio BAR access functions |
Date: |
Sun, 31 Jul 2011 20:57:27 +0300 |
Make use of the memory API's ability to satisfy multi-byte accesses via
multiple single-byte accesses.
Signed-off-by: Avi Kivity <address@hidden>
---
hw/cirrus_vga.c | 78 +++++-------------------------------------------------
1 files changed, 8 insertions(+), 70 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index d1475dd..6e1aa75 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2828,12 +2828,11 @@ static void cirrus_vga_ioport_write(void *opaque,
uint32_t addr, uint32_t val)
*
***************************************/
-static uint32_t cirrus_mmio_readb(void *opaque, target_phys_addr_t addr)
+static uint64_t cirrus_mmio_read(void *opaque, target_phys_addr_t addr,
+ unsigned size)
{
CirrusVGAState *s = opaque;
- addr &= CIRRUS_PNPMMIO_SIZE - 1;
-
if (addr >= 0x100) {
return cirrus_mmio_blt_read(s, addr - 0x100);
} else {
@@ -2841,33 +2840,11 @@ static uint32_t cirrus_mmio_readb(void *opaque,
target_phys_addr_t addr)
}
}
-static uint32_t cirrus_mmio_readw(void *opaque, target_phys_addr_t addr)
-{
- uint32_t v;
-
- v = cirrus_mmio_readb(opaque, addr);
- v |= cirrus_mmio_readb(opaque, addr + 1) << 8;
- return v;
-}
-
-static uint32_t cirrus_mmio_readl(void *opaque, target_phys_addr_t addr)
-{
- uint32_t v;
-
- v = cirrus_mmio_readb(opaque, addr);
- v |= cirrus_mmio_readb(opaque, addr + 1) << 8;
- v |= cirrus_mmio_readb(opaque, addr + 2) << 16;
- v |= cirrus_mmio_readb(opaque, addr + 3) << 24;
- return v;
-}
-
-static void cirrus_mmio_writeb(void *opaque, target_phys_addr_t addr,
- uint32_t val)
+static void cirrus_mmio_write(void *opaque, target_phys_addr_t addr,
+ uint64_t val, unsigned size)
{
CirrusVGAState *s = opaque;
- addr &= CIRRUS_PNPMMIO_SIZE - 1;
-
if (addr >= 0x100) {
cirrus_mmio_blt_write(s, addr - 0x100, val);
} else {
@@ -2875,53 +2852,14 @@ static void cirrus_mmio_writeb(void *opaque,
target_phys_addr_t addr,
}
}
-static void cirrus_mmio_writew(void *opaque, target_phys_addr_t addr,
- uint32_t val)
-{
- cirrus_mmio_writeb(opaque, addr, val & 0xff);
- cirrus_mmio_writeb(opaque, addr + 1, (val >> 8) & 0xff);
-}
-
-static void cirrus_mmio_writel(void *opaque, target_phys_addr_t addr,
- uint32_t val)
-{
- cirrus_mmio_writeb(opaque, addr, val & 0xff);
- cirrus_mmio_writeb(opaque, addr + 1, (val >> 8) & 0xff);
- cirrus_mmio_writeb(opaque, addr + 2, (val >> 16) & 0xff);
- cirrus_mmio_writeb(opaque, addr + 3, (val >> 24) & 0xff);
-}
-
-
-static uint64_t cirrus_mmio_read(void *opaque, target_phys_addr_t addr,
- unsigned size)
-{
- CirrusVGAState *s = opaque;
-
- switch (size) {
- case 1: return cirrus_mmio_readb(s, addr);
- case 2: return cirrus_mmio_readw(s, addr);
- case 4: return cirrus_mmio_readl(s, addr);
- default: abort();
- }
-};
-
-static void cirrus_mmio_write(void *opaque, target_phys_addr_t addr,
- uint64_t data, unsigned size)
-{
- CirrusVGAState *s = opaque;
-
- switch (size) {
- case 1: return cirrus_mmio_writeb(s, addr, data);
- case 2: return cirrus_mmio_writew(s, addr, data);
- case 4: return cirrus_mmio_writel(s, addr, data);
- default: abort();
- }
-};
-
static const MemoryRegionOps cirrus_mmio_io_ops = {
.read = cirrus_mmio_read,
.write = cirrus_mmio_write,
.endianness = DEVICE_LITTLE_ENDIAN,
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 1,
+ },
};
/* load/save state */
--
1.7.5.3
- [Qemu-devel] [PATCH 02/39] vmsvga: don't remember pci BAR address in callback any more, (continued)
- [Qemu-devel] [PATCH 02/39] vmsvga: don't remember pci BAR address in callback any more, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 36/39] pci: remove pci_register_bar(), Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 15/39] e1000: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 10/39] exec.c: fix initialization of system I/O memory region, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 27/39] i6300esb: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 39/39] pci: remove support for pre memory API BARs, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 13/39] rtl8139: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 21/39] ahci: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 12/39] pci: allow I/O BARs to be registered with pci_register_bar_region(), Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 05/39] cirrus: simplify bitblt BAR access functions, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 04/39] cirrus: simplify mmio BAR access functions,
Avi Kivity <=
- [Qemu-devel] [PATCH 25/39] ne2000: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 31/39] uhci: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 09/39] Integrate I/O memory regions into qemu, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 22/39] intel-hda: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 30/39] ehci: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 08/39] cirrus: simplify linear framebuffer access functions, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 06/39] cirrus: simplify vga window mmio access functions, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 16/39] eepro100: convert to memory API, Avi Kivity, 2011/07/31
- [Qemu-devel] [PATCH 20/39] virtio-pci: convert to memory API, Avi Kivity, 2011/07/31