qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 09/23] vga and cirrus_vga: create vga_ioport_invalid() and use it everywhere
Date: Mon, 31 Aug 2009 16:07:19 +0200	[thread overview]
Message-ID: <57f3c8b69e27bfbae1cb99832253734e1e70f67d.1251725415.git.quintela@redhat.com> (raw)
In-Reply-To: <cover.1251725415.git.quintela@redhat.com>
In-Reply-To: <cover.1251725415.git.quintela@redhat.com>


Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 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];

-- 
1.6.2.5

  parent reply	other threads:[~2009-08-31 14:10 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 01/23] vga: remove useless cast from void * Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 02/23] cirrus_vga: prefix vga_ioport_{read, write} with cirrus Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 03/23] vga: export vga_ioport_{read,write} Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 04/23] vga: split vga_{load, save} into pci and common parts Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 05/23] vga: split pci bits into vga-pci.c Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 06/23] vga: split isa bits inco vga-isa.c Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 07/23] vga: export vga_mem_{read,write} Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 08/23] vga: split vga-isa-mm.o Juan Quintela
2009-08-31 14:07 ` Juan Quintela [this message]
2009-08-31 14:07 ` [Qemu-devel] [PATCH 10/23] cirrus_vga: Add a VGACommonState local var to cirrus_vga_ioport_{read, write} Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 11/23] vga: change tabs to spaces Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 12/23] cirrus_vga: make cirrus_read_hidden_dac() return its result Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 13/23] vga and cirrus_vga: substitute switch for equivalent assigntment Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 14/23] vga: Rename last VGAState occurrences to VGACommonState Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 15/23] cirrus_vga: rename cirrus_hook_read_sr() cirrus_vga_read_sr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 16/23] cirrus_vga: rename cirrus_hook_write_sr() cirrus_vga_write_sr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 17/23] cirrus_vga: rename cirrus_hook_read_palette() cirrus_vga_read_palette() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 18/23] cirrus_vga: rename cirrus_hook_write_palette() cirrus_vga_write_palette() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 19/23] cirrus_vga: rename cirrus_hook_read_gr() cirrus_vga_read_gr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 20/23] cirrus_vga: rename cirrus_hook_write_gr() cirrus_vga_write_gr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 21/23] cirrus_vga: rename cirrus_hook_read_cr() cirrus_vga_read_cr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 22/23] cirrus_vga: rename cirrus_hook_write_cr() cirrus_vga_write_cr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 23/23] cirrus_vga: CIRRUS_HOOK_* is not used anymore Juan Quintela
2009-09-16 12:43 ` [Qemu-devel] [PATCH 00/23] VGA cleanup Pierre Riteau
2009-09-16 12:52   ` [Qemu-devel] " Juan Quintela
2009-09-16 13:17     ` Pierre Riteau
2009-09-16 13:45       ` Juan Quintela
2009-09-16 14:21         ` Pierre Riteau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57f3c8b69e27bfbae1cb99832253734e1e70f67d.1251725415.git.quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).