aboutsummaryrefslogtreecommitdiff
path: root/hw/vga.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-08-31 16:07:19 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-09-09 14:55:13 -0500
commit25a18cbd27d1556aafe268d48bffbb3c883de081 (patch)
tree046283453fc067a1bac2acc8a508836e922f685a /hw/vga.c
parent79b97bf2e7f33ca4338fe3d83f2a38c97450d350 (diff)
vga and cirrus_vga: create vga_ioport_invalid() and use it everywhere
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/vga.c')
-rw-r--r--hw/vga.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/hw/vga.c b/hw/vga.c
index 8cd1117787..b4c31ce330 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