From 184705fc8c7d8ef75a6cfca4d61cbf35c0df0334 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 14 Jan 2012 22:17:43 -0500 Subject: [PATCH] vgabios: Use standard VGA IO wrapper functions in bochsvga. Also, this alters some of the IO port settings in bochsvga_set_mode to fix what looks like errors during the asm to C conversion. Signed-off-by: Kevin O'Connor --- vgasrc/bochsvga.c | 53 +++++++++++++++++------------------------------ vgasrc/bochsvga.h | 2 +- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c index b7b1b05..0930b46 100644 --- a/vgasrc/bochsvga.c +++ b/vgasrc/bochsvga.c @@ -238,43 +238,28 @@ bochsvga_set_mode(int mode, int flags) /* VGA compat setup */ //XXX: This probably needs some reverse engineering - u8 v; - outw(0x0011, VGAREG_VGA_CRTC_ADDRESS); - outw(((width * 4 - 1) << 8) | 0x1, VGAREG_VGA_CRTC_ADDRESS); + u16 crtc_addr = VGAREG_VGA_CRTC_ADDRESS; + stdvga_crtc_write(crtc_addr, 0x11, 0x00); + stdvga_crtc_write(crtc_addr, 0x01, width / 8 - 1); dispi_write(VBE_DISPI_INDEX_VIRT_WIDTH, width); - outw(((height - 1) << 8) | 0x12, VGAREG_VGA_CRTC_ADDRESS); - outw(((height - 1) & 0xff00) | 0x7, VGAREG_VGA_CRTC_ADDRESS); - v = inb(VGAREG_VGA_CRTC_DATA) & 0xbd; - if (v & 0x1) - v |= 0x2; - if (v & 0x2) + stdvga_crtc_write(crtc_addr, 0x12, height - 1); + u8 v = 0; + if ((height - 1) & 0x0100) + v |= 0x02; + if ((height - 1) & 0x0200) v |= 0x40; - outb(v, VGAREG_VGA_CRTC_DATA); - - outw(0x9, VGAREG_VGA_CRTC_ADDRESS); - outb(0x17, VGAREG_VGA_CRTC_ADDRESS); - outb(inb(VGAREG_VGA_CRTC_DATA) | 0x3, VGAREG_VGA_CRTC_DATA); - v = inb(VGAREG_ACTL_RESET); - outw(0x10, VGAREG_ACTL_ADDRESS); - v = inb(VGAREG_ACTL_READ_DATA) | 0x1; - outb(v, VGAREG_ACTL_ADDRESS); - outb(0x20, VGAREG_ACTL_ADDRESS); - outw(0x0506, VGAREG_GRDC_ADDRESS); - outw(0x0f02, VGAREG_SEQU_ADDRESS); + stdvga_crtc_mask(crtc_addr, 0x07, 0x42, v); + + stdvga_crtc_write(crtc_addr, 0x09, 0x00); + stdvga_crtc_mask(crtc_addr, 0x17, 0x00, 0x03); + stdvga_attr_mask(0x10, 0x00, 0x01); + stdvga_grdc_write(0x06, 0x05); + stdvga_sequ_write(0x02, 0x0f); if (depth >= 8) { - outb(0x14, VGAREG_VGA_CRTC_ADDRESS); - outb(inb(VGAREG_VGA_CRTC_DATA) | 0x40, VGAREG_VGA_CRTC_DATA); - v = inb(VGAREG_ACTL_RESET); - outw(0x10, VGAREG_ACTL_ADDRESS); - v = inb(VGAREG_ACTL_READ_DATA) | 0x40; - outb(v, VGAREG_ACTL_ADDRESS); - outb(0x20, VGAREG_ACTL_ADDRESS); - outb(0x04, VGAREG_SEQU_ADDRESS); - v = inb(VGAREG_SEQU_DATA) | 0x08; - outb(v, VGAREG_SEQU_DATA); - outb(0x05, VGAREG_GRDC_ADDRESS); - v = inb(VGAREG_GRDC_DATA) & 0x9f; - outb(v | 0x40, VGAREG_GRDC_DATA); + stdvga_crtc_mask(crtc_addr, 0x14, 0x00, 0x40); + stdvga_attr_mask(0x10, 0x00, 0x40); + stdvga_sequ_mask(0x04, 0x00, 0x08); + stdvga_grdc_mask(0x05, 0x20, 0x40); } SET_BDA(vbe_mode, mode | flags); diff --git a/vgasrc/bochsvga.h b/vgasrc/bochsvga.h index a9cedbf..81fb8f7 100644 --- a/vgasrc/bochsvga.h +++ b/vgasrc/bochsvga.h @@ -2,7 +2,7 @@ #define __BOCHSVGA_H #include "types.h" // u8 -#include "ioport.h" // outb +#include "ioport.h" // outw #define VBE_DISPI_BANK_ADDRESS 0xA0000 #define VBE_DISPI_BANK_SIZE_KB 64 -- 2.25.1