From patchwork Mon Aug 31 14:07:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 32646 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id AB158B70CF for ; Tue, 1 Sep 2009 00:32:15 +1000 (EST) Received: from localhost ([127.0.0.1]:51189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mi7vV-0003so-Vc for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2009 10:32:10 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mi7aV-0004q3-1p for qemu-devel@nongnu.org; Mon, 31 Aug 2009 10:10:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mi7aP-0004mG-HT for qemu-devel@nongnu.org; Mon, 31 Aug 2009 10:10:26 -0400 Received: from [199.232.76.173] (port=43332 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mi7aP-0004m0-1G for qemu-devel@nongnu.org; Mon, 31 Aug 2009 10:10:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8409) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mi7aO-0003El-Ja for qemu-devel@nongnu.org; Mon, 31 Aug 2009 10:10:20 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7VEAJ6G009314; Mon, 31 Aug 2009 10:10:19 -0400 Received: from localhost.localdomain (vpn1-4-222.ams2.redhat.com [10.36.4.222]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7VEA0oT003480; Mon, 31 Aug 2009 10:10:17 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 31 Aug 2009 16:07:19 +0200 Message-Id: <57f3c8b69e27bfbae1cb99832253734e1e70f67d.1251725415.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 09/23] vga and cirrus_vga: create vga_ioport_invalid() and use it everywhere X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- hw/cirrus_vga.c | 11 +++-------- hw/vga.c | 20 ++++++++++++++------ hw/vga_int.h | 2 ++ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index 5f57107..7e63399 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -2661,10 +2661,7 @@ static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr) CirrusVGAState *s = opaque; int val, index; - /* check port range access depending on color/monochrome mode */ - if ((addr >= 0x3b0 && addr <= 0x3bf && (s->vga.msr & MSR_COLOR_EMULATION)) - || (addr >= 0x3d0 && addr <= 0x3df - && !(s->vga.msr & MSR_COLOR_EMULATION))) { + if (vga_ioport_invalid(&s->vga, addr)) { val = 0xff; } else { switch (addr) { @@ -2768,11 +2765,9 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val) int index; /* check port range access depending on color/monochrome mode */ - if ((addr >= 0x3b0 && addr <= 0x3bf && (s->vga.msr & MSR_COLOR_EMULATION)) - || (addr >= 0x3d0 && addr <= 0x3df - && !(s->vga.msr & MSR_COLOR_EMULATION))) + if (vga_ioport_invalid(&s->vga, addr)) { return; - + } #ifdef DEBUG_VGA printf("VGA: write addr=0x%04x data=0x%02x\n", addr, val); #endif diff --git a/hw/vga.c b/hw/vga.c index 8cd1117..b4c31ce 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -284,14 +284,23 @@ static uint8_t vga_dumb_retrace(VGAState *s) return s->st01 ^ (ST01_V_RETRACE | ST01_DISP_ENABLE); } +int vga_ioport_invalid(VGACommonState *s, uint32_t addr) +{ + if (s->msr & MSR_COLOR_EMULATION) { + /* Color */ + return (addr >= 0x3b0 && addr <= 0x3bf); + } else { + /* Monochrome */ + return (addr >= 0x3d0 && addr <= 0x3df); + } +} + uint32_t vga_ioport_read(void *opaque, uint32_t addr) { VGACommonState *s = opaque; int val, index; - /* check port range access depending on color/monochrome mode */ - if ((addr >= 0x3b0 && addr <= 0x3bf && (s->msr & MSR_COLOR_EMULATION)) || - (addr >= 0x3d0 && addr <= 0x3df && !(s->msr & MSR_COLOR_EMULATION))) { + if (vga_ioport_invalid(s, addr)) { val = 0xff; } else { switch(addr) { @@ -383,10 +392,9 @@ void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val) int index; /* check port range access depending on color/monochrome mode */ - if ((addr >= 0x3b0 && addr <= 0x3bf && (s->msr & MSR_COLOR_EMULATION)) || - (addr >= 0x3d0 && addr <= 0x3df && !(s->msr & MSR_COLOR_EMULATION))) + if (vga_ioport_invalid(s, addr)) { return; - + } #ifdef DEBUG_VGA printf("VGA: write addr=0x%04x data=0x%02x\n", addr, val); #endif diff --git a/hw/vga_int.h b/hw/vga_int.h index 9ff205d..c162c07 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -214,6 +214,8 @@ void vga_draw_cursor_line_32(uint8_t *d1, const uint8_t *src1, unsigned int color0, unsigned int color1, unsigned int color_xor); +int vga_ioport_invalid(VGACommonState *s, uint32_t addr); + extern const uint8_t sr_mask[8]; extern const uint8_t gr_mask[16];