From patchwork Sun Jul 10 18:14:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 104127 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 17C8CB6F76 for ; Mon, 11 Jul 2011 07:32:32 +1000 (EST) Received: from localhost ([::1]:53916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qg1c4-0003d5-UT for incoming@patchwork.ozlabs.org; Sun, 10 Jul 2011 17:32:29 -0400 Received: from eggs.gnu.org ([140.186.70.92]:47086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfyXU-0004Hq-Tt for qemu-devel@nongnu.org; Sun, 10 Jul 2011 14:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QfyXG-0007a5-Fi for qemu-devel@nongnu.org; Sun, 10 Jul 2011 14:15:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63676) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfyXD-0007Wb-Sl for qemu-devel@nongnu.org; Sun, 10 Jul 2011 14:15:16 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6AIFFrB005329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 10 Jul 2011 14:15:15 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6AIFDcL004033; Sun, 10 Jul 2011 14:15:14 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 594B4250B47; Sun, 10 Jul 2011 21:15:11 +0300 (IDT) From: Avi Kivity To: qemu-devel@nongnu.org Date: Sun, 10 Jul 2011 21:14:37 +0300 Message-Id: <1310321709-30770-25-git-send-email-avi@redhat.com> In-Reply-To: <1310321709-30770-1-git-send-email-avi@redhat.com> References: <1310321709-30770-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kvm@vger.kernel.org Subject: [Qemu-devel] [RFC v3 24/56] vga: simplify vga window mmio access functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Make use of the memory API's ability to satisfy multi-byte accesses via multiple single-byte accesses. We have to keep vga_mem_{read,write}b() since they're used by cirrus. Signed-off-by: Avi Kivity --- hw/cirrus_vga.c | 4 +- hw/vga.c | 56 +++++++----------------------------------------------- hw/vga_int.h | 4 +- 3 files changed, 12 insertions(+), 52 deletions(-) diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index d7cb69e..615e101 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -1965,7 +1965,7 @@ static uint64_t cirrus_vga_mem_read(void *opaque, uint32_t val; if ((s->vga.sr[0x07] & 0x01) == 0) { - return vga_mem_readb(s, addr); + return vga_mem_readb(&s->vga, addr); } if (addr < 0x10000) { @@ -2010,7 +2010,7 @@ static void cirrus_vga_mem_write(void *opaque, unsigned mode; if ((s->vga.sr[0x07] & 0x01) == 0) { - vga_mem_writeb(s, addr, mem_value); + vga_mem_writeb(&s->vga, addr, mem_value); return; } diff --git a/hw/vga.c b/hw/vga.c index b969e9f..16c857f 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -707,9 +707,8 @@ static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val) #endif /* called for accesses between 0xa0000 and 0xc0000 */ -uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr) +uint32_t vga_mem_readb(VGACommonState *s, target_phys_addr_t addr) { - VGACommonState *s = opaque; int memory_map_mode, plane; uint32_t ret; @@ -763,28 +762,9 @@ uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr) return ret; } -static uint32_t vga_mem_readw(void *opaque, target_phys_addr_t addr) -{ - uint32_t v; - v = vga_mem_readb(opaque, addr); - v |= vga_mem_readb(opaque, addr + 1) << 8; - return v; -} - -static uint32_t vga_mem_readl(void *opaque, target_phys_addr_t addr) -{ - uint32_t v; - v = vga_mem_readb(opaque, addr); - v |= vga_mem_readb(opaque, addr + 1) << 8; - v |= vga_mem_readb(opaque, addr + 2) << 16; - v |= vga_mem_readb(opaque, addr + 3) << 24; - return v; -} - /* called for accesses between 0xa0000 and 0xc0000 */ -void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) +void vga_mem_writeb(VGACommonState *s, target_phys_addr_t addr, uint32_t val) { - VGACommonState *s = opaque; int memory_map_mode, plane, write_mode, b, func_select, mask; uint32_t write_mask, bit_mask, set_mask; @@ -916,20 +896,6 @@ void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) } } -static void vga_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val) -{ - vga_mem_writeb(opaque, addr, val & 0xff); - vga_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff); -} - -static void vga_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val) -{ - vga_mem_writeb(opaque, addr, val & 0xff); - vga_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff); - vga_mem_writeb(opaque, addr + 2, (val >> 16) & 0xff); - vga_mem_writeb(opaque, addr + 3, (val >> 24) & 0xff); -} - typedef void vga_draw_glyph8_func(uint8_t *d, int linesize, const uint8_t *font_ptr, int h, uint32_t fgcol, uint32_t bgcol); @@ -2104,12 +2070,7 @@ static uint64_t vga_mem_read(void *opaque, target_phys_addr_t addr, { VGACommonState *s = opaque; - switch (size) { - case 1: return vga_mem_readb(s, addr); - case 2: return vga_mem_readw(s, addr); - case 4: return vga_mem_readl(s, addr); - default: abort(); - } + return vga_mem_readb(s, addr); } static void vga_mem_write(void *opaque, target_phys_addr_t addr, @@ -2117,18 +2078,17 @@ static void vga_mem_write(void *opaque, target_phys_addr_t addr, { VGACommonState *s = opaque; - switch (size) { - case 1: return vga_mem_writeb(s, addr, data); - case 2: return vga_mem_writew(s, addr, data); - case 4: return vga_mem_writel(s, addr, data); - default: abort(); - } + return vga_mem_writeb(s, addr, data); } MemoryRegionOps vga_mem_ops = { .read = vga_mem_read, .write = vga_mem_write, .endianness = DEVICE_LITTLE_ENDIAN, + .impl = { + .min_access_size = 1, + .max_access_size = 1, + }, }; static int vga_common_post_load(void *opaque, int version_id) diff --git a/hw/vga_int.h b/hw/vga_int.h index f4e0d8d..485a872 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -197,8 +197,8 @@ void vga_dirty_log_restart(VGACommonState *s); extern const VMStateDescription vmstate_vga_common; uint32_t vga_ioport_read(void *opaque, uint32_t addr); void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val); -uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr); -void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val); +uint32_t vga_mem_readb(VGACommonState *s, target_phys_addr_t addr); +void vga_mem_writeb(VGACommonState *s, target_phys_addr_t addr, uint32_t val); void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2); int ppm_save(const char *filename, struct DisplaySurface *ds);