[SeaBIOS] [PATCH 11/20] vgabios: Introduce stdvga_get_crtc() and use it consistently.
Kevin O'Connor
kevin at koconnor.net
Sun Jan 1 18:22:28 CET 2012
The low level VGA code shouldn't depend on the crtc address stored in
the BDA - it can find the address on its own.
The cirrus_get_crtc() function is the same - replace it with
stdvga_get_crtc().
Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
vgasrc/clext.c | 22 +++++++---------------
vgasrc/stdvga.c | 23 ++++++++++++-----------
vgasrc/stdvga.h | 1 +
3 files changed, 20 insertions(+), 26 deletions(-)
diff --git a/vgasrc/clext.c b/vgasrc/clext.c
index 7987d28..7774ba3 100644
--- a/vgasrc/clext.c
+++ b/vgasrc/clext.c
@@ -327,14 +327,6 @@ cirrus_switch_mode_setregs(u16 *data, u16 port)
}
}
-static u16
-cirrus_get_crtc(void)
-{
- if (inb(VGAREG_READ_MISC_OUTPUT) & 1)
- return VGAREG_VGA_CRTC_ADDRESS;
- return VGAREG_MDA_CRTC_ADDRESS;
-}
-
static void
cirrus_switch_mode(struct cirrus_mode_s *table)
{
@@ -342,7 +334,7 @@ cirrus_switch_mode(struct cirrus_mode_s *table)
outw(0x1206, VGAREG_SEQU_ADDRESS);
cirrus_switch_mode_setregs(GET_GLOBAL(table->seq), VGAREG_SEQU_ADDRESS);
cirrus_switch_mode_setregs(GET_GLOBAL(table->graph), VGAREG_GRDC_ADDRESS);
- cirrus_switch_mode_setregs(GET_GLOBAL(table->crtc), cirrus_get_crtc());
+ cirrus_switch_mode_setregs(GET_GLOBAL(table->crtc), stdvga_get_crtc());
outb(0x00, VGAREG_PEL_MASK);
inb(VGAREG_PEL_MASK);
@@ -433,7 +425,7 @@ cirrus_check(void)
static void
cirrus_extbios_80h(struct bregs *regs)
{
- u16 crtc_addr = cirrus_get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x27, crtc_addr);
u8 v = inb(crtc_addr + 1);
if (v == 0xa0)
@@ -458,7 +450,7 @@ cirrus_extbios_81h(struct bregs *regs)
static void
cirrus_extbios_82h(struct bregs *regs)
{
- u16 crtc_addr = cirrus_get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x27, crtc_addr);
regs->al = inb(crtc_addr + 1) & 0x03;
regs->ah = 0xAF;
@@ -596,7 +588,7 @@ cirrus_get_bpp_bytes(void)
static void
cirrus_set_line_offset(u16 new_line_offset)
{
- u16 crtc_addr = cirrus_get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x13, crtc_addr);
outb(new_line_offset / 8, crtc_addr + 1);
@@ -608,7 +600,7 @@ cirrus_set_line_offset(u16 new_line_offset)
static u16
cirrus_get_line_offset(void)
{
- u16 crtc_addr = cirrus_get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x13, crtc_addr);
u8 reg13 = inb(crtc_addr + 1);
outb(0x1b, crtc_addr);
@@ -648,7 +640,7 @@ cirrus_get_line_offset_entry(struct cirrus_mode_s *table_g)
static void
cirrus_set_start_addr(u32 addr)
{
- u16 crtc_addr = cirrus_get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x0d, crtc_addr);
outb(addr, crtc_addr + 1);
@@ -668,7 +660,7 @@ cirrus_set_start_addr(u32 addr)
static u32
cirrus_get_start_addr(void)
{
- u16 crtc_addr = cirrus_get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x0c, crtc_addr);
u8 b2 = inb(crtc_addr + 1);
diff --git a/vgasrc/stdvga.c b/vgasrc/stdvga.c
index 8622d0c..f40c172 100644
--- a/vgasrc/stdvga.c
+++ b/vgasrc/stdvga.c
@@ -8,8 +8,7 @@
#include "stdvga.h" // stdvga_init
#include "ioport.h" // outb
#include "farptr.h" // SET_FARVAR
-#include "biosvar.h" // GET_BDA
-#include "vgabios.h" // VGAREG_*
+#include "biosvar.h" // GET_GLOBAL
#include "util.h" // memcpy_far
// TODO
@@ -338,16 +337,18 @@ stdvga_load_font(u16 seg, void *src_far, u16 count
* CRTC registers
****************************************************************/
-static u16
-get_crtc(void)
+u16
+stdvga_get_crtc(void)
{
- return GET_BDA(crtc_address);
+ if (inb(VGAREG_READ_MISC_OUTPUT) & 1)
+ return VGAREG_VGA_CRTC_ADDRESS;
+ return VGAREG_MDA_CRTC_ADDRESS;
}
void
stdvga_set_cursor_shape(u8 start, u8 end)
{
- u16 crtc_addr = get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x0a, crtc_addr);
outb(start, crtc_addr + 1);
outb(0x0b, crtc_addr);
@@ -357,7 +358,7 @@ stdvga_set_cursor_shape(u8 start, u8 end)
void
stdvga_set_active_page(u16 address)
{
- u16 crtc_addr = get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x0c, crtc_addr);
outb((address & 0xff00) >> 8, crtc_addr + 1);
outb(0x0d, crtc_addr);
@@ -367,7 +368,7 @@ stdvga_set_active_page(u16 address)
void
stdvga_set_cursor_pos(u16 address)
{
- u16 crtc_addr = get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x0e, crtc_addr);
outb((address & 0xff00) >> 8, crtc_addr + 1);
outb(0x0f, crtc_addr);
@@ -377,7 +378,7 @@ stdvga_set_cursor_pos(u16 address)
void
stdvga_set_scan_lines(u8 lines)
{
- u16 crtc_addr = get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x09, crtc_addr);
u8 crtc_r9 = inb(crtc_addr + 1);
crtc_r9 = (crtc_r9 & 0xe0) | (lines - 1);
@@ -388,7 +389,7 @@ stdvga_set_scan_lines(u8 lines)
u16
stdvga_get_vde(void)
{
- u16 crtc_addr = get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
outb(0x12, crtc_addr);
u16 vde = inb(crtc_addr + 1);
outb(0x07, crtc_addr);
@@ -405,7 +406,7 @@ stdvga_get_vde(void)
void
stdvga_save_state(u16 seg, struct saveVideoHardware *info)
{
- u16 crtc_addr = get_crtc();
+ u16 crtc_addr = stdvga_get_crtc();
SET_FARVAR(seg, info->sequ_index, inb(VGAREG_SEQU_ADDRESS));
SET_FARVAR(seg, info->crtc_index, inb(crtc_addr));
SET_FARVAR(seg, info->grdc_index, inb(VGAREG_GRDC_ADDRESS));
diff --git a/vgasrc/stdvga.h b/vgasrc/stdvga.h
index 0d5f59b..fb98304 100644
--- a/vgasrc/stdvga.h
+++ b/vgasrc/stdvga.h
@@ -129,6 +129,7 @@ void stdvga_grdc_write(u8 index, u8 value);
void stdvga_set_text_block_specifier(u8 spec);
void stdvga_load_font(u16 seg, void *src_far, u16 count
, u16 start, u8 destflags, u8 fontsize);
+u16 stdvga_get_crtc(void);
void stdvga_set_cursor_shape(u8 start, u8 end);
void stdvga_set_active_page(u16 address);
void stdvga_set_cursor_pos(u16 address);
--
1.7.6.4
More information about the SeaBIOS
mailing list