[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v5 28/86] cirrus: simplify vga window mmio access func
From: |
Avi Kivity |
Subject: |
[Qemu-devel] [RFC v5 28/86] cirrus: simplify vga window mmio access functions |
Date: |
Wed, 20 Jul 2011 19:49:38 +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 | 79 +++++++-----------------------------------------------
1 files changed, 11 insertions(+), 68 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 607d76a..d236aee 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1955,7 +1955,9 @@ static void
cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s,
*
***************************************/
-static uint32_t cirrus_vga_mem_readb(void *opaque, target_phys_addr_t addr)
+static uint64_t cirrus_vga_mem_read(void *opaque,
+ target_phys_addr_t addr,
+ uint32_t size)
{
CirrusVGAState *s = opaque;
unsigned bank_index;
@@ -1966,8 +1968,6 @@ static uint32_t cirrus_vga_mem_readb(void *opaque,
target_phys_addr_t addr)
return vga_mem_readb(s, addr);
}
- addr &= 0x1ffff;
-
if (addr < 0x10000) {
/* XXX handle bitblt */
/* video memory */
@@ -1999,28 +1999,10 @@ static uint32_t cirrus_vga_mem_readb(void *opaque,
target_phys_addr_t addr)
return val;
}
-static uint32_t cirrus_vga_mem_readw(void *opaque, target_phys_addr_t addr)
-{
- uint32_t v;
-
- v = cirrus_vga_mem_readb(opaque, addr);
- v |= cirrus_vga_mem_readb(opaque, addr + 1) << 8;
- return v;
-}
-
-static uint32_t cirrus_vga_mem_readl(void *opaque, target_phys_addr_t addr)
-{
- uint32_t v;
-
- v = cirrus_vga_mem_readb(opaque, addr);
- v |= cirrus_vga_mem_readb(opaque, addr + 1) << 8;
- v |= cirrus_vga_mem_readb(opaque, addr + 2) << 16;
- v |= cirrus_vga_mem_readb(opaque, addr + 3) << 24;
- return v;
-}
-
-static void cirrus_vga_mem_writeb(void *opaque, target_phys_addr_t addr,
- uint32_t mem_value)
+static void cirrus_vga_mem_write(void *opaque,
+ target_phys_addr_t addr,
+ uint64_t mem_value,
+ uint32_t size)
{
CirrusVGAState *s = opaque;
unsigned bank_index;
@@ -2032,8 +2014,6 @@ static void cirrus_vga_mem_writeb(void *opaque,
target_phys_addr_t addr,
return;
}
- addr &= 0x1ffff;
-
if (addr < 0x10000) {
if (s->cirrus_srcptr != s->cirrus_srcptr_end) {
/* bitblt */
@@ -2083,51 +2063,14 @@ static void cirrus_vga_mem_writeb(void *opaque,
target_phys_addr_t addr,
}
}
-static void cirrus_vga_mem_writew(void *opaque, target_phys_addr_t addr,
uint32_t val)
-{
- cirrus_vga_mem_writeb(opaque, addr, val & 0xff);
- cirrus_vga_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff);
-}
-
-static void cirrus_vga_mem_writel(void *opaque, target_phys_addr_t addr,
uint32_t val)
-{
- cirrus_vga_mem_writeb(opaque, addr, val & 0xff);
- cirrus_vga_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff);
- cirrus_vga_mem_writeb(opaque, addr + 2, (val >> 16) & 0xff);
- cirrus_vga_mem_writeb(opaque, addr + 3, (val >> 24) & 0xff);
-}
-
-static uint64_t cirrus_vga_mem_read(void *opaque,
- target_phys_addr_t addr,
- uint32_t size)
-{
- CirrusVGAState *s = opaque;
-
- switch (size) {
- case 1: return cirrus_vga_mem_readb(s, addr);
- case 2: return cirrus_vga_mem_readw(s, addr);
- case 4: return cirrus_vga_mem_readl(s, addr);
- default: abort();
- }
-}
-
-static void cirrus_vga_mem_write(void *opaque, target_phys_addr_t addr,
- uint64_t data, unsigned size)
-{
- CirrusVGAState *s = opaque;
-
- switch (size) {
- case 1: return cirrus_vga_mem_writeb(s, addr, data);
- case 2: return cirrus_vga_mem_writew(s, addr, data);
- case 4: return cirrus_vga_mem_writel(s, addr, data);
- default: abort();
- }
-};
-
static const MemoryRegionOps cirrus_vga_mem_ops = {
.read = cirrus_vga_mem_read,
.write = cirrus_vga_mem_write,
.endianness = DEVICE_LITTLE_ENDIAN,
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 1,
+ },
};
/***************************************
--
1.7.5.3
- [Qemu-devel] [RFC v5 02/86] Hierarchical memory region API, (continued)
- [Qemu-devel] [RFC v5 02/86] Hierarchical memory region API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 41/86] ivshmem: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 82/86] sysbus: remove sysbus_init_mmio_cb(), Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 70/86] tusb6010: move declarations to new file tusb6010.h, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 17/86] pc: convert pc_memory_init() to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 07/86] memory: rename MemoryRegion::has_ram_addr to ::terminates, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 48/86] pcnet: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 09/86] memory: I/O address space support, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 43/86] ahci: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 56/86] pci: remove pci_register_bar_simple(), Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 28/86] cirrus: simplify vga window mmio access functions,
Avi Kivity <=
- [Qemu-devel] [RFC v5 47/86] ne2000: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 58/86] pci: remove pci_register_bar(), Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 29/86] vga: simplify vga window mmio access functions, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 05/86] Internal interfaces for memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 79/86] arm11mpcore: use sysbus_init_mmio_cb2, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 67/86] arm_timer: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 10/86] memory: add backward compatibility for old portio registration, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 53/86] uhci: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 59/86] pci: fold BAR mapping function into its caller, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 73/86] pcie_host: convert to memory API, Avi Kivity, 2011/07/20