From d246fc036887fc456b2aa77fa46d45c83e7a7632 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 21 Jun 2010 00:58:43 +0200 Subject: [PATCH] Improve macroification of VGA registers. --- include/grub/vga.h | 64 +++++++++++++++++++++++++++++++---------- term/i386/pc/vga_text.c | 8 ++++-- 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/include/grub/vga.h b/include/grub/vga.h index d05ddd69b..a33cf2b67 100644 --- a/include/grub/vga.h +++ b/include/grub/vga.h @@ -21,6 +21,7 @@ enum { + GRUB_VGA_IO_ARX = 0x3c0, GRUB_VGA_IO_SR_INDEX = 0x3c4, GRUB_VGA_IO_SR_DATA = 0x3c5, GRUB_VGA_IO_PIXEL_MASK = 0x3c6, @@ -41,7 +42,8 @@ enum GRUB_VGA_CR_WIDTH = 0x01, GRUB_VGA_CR_OVERFLOW = 0x07, GRUB_VGA_CR_CELL_HEIGHT = 0x09, - GRUB_VGA_CR_CURSOR = 0x0a, + GRUB_VGA_CR_CURSOR_START = 0x0a, + GRUB_VGA_CR_CURSOR_END = 0x0b, GRUB_VGA_CR_START_ADDR_HIGH_REGISTER = 0x0c, GRUB_VGA_CR_START_ADDR_LOW_REGISTER = 0x0d, GRUB_VGA_CR_CURSOR_ADDR_HIGH = 0x0e, @@ -64,36 +66,68 @@ enum #define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_MASK 0x40 #define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_SHIFT 3 -#define GRUB_VGA_CR_CURSOR_DISABLE (1 << 5) +enum + { + GRUB_VGA_CR_CURSOR_START_DISABLE = (1 << 5) + }; #define GRUB_VGA_CR_PITCH_DIVISOR 8 -#define GRUB_VGA_CR_MODE_TIMING_ENABLE 0x80 -#define GRUB_VGA_CR_MODE_BYTE_MODE 0x40 -#define GRUB_VGA_CR_MODE_NO_HERCULES 0x02 -#define GRUB_VGA_CR_MODE_NO_CGA 0x01 - enum { - GRUB_VGA_SR_MAP_MASK_REGISTER = 0x02, - GRUB_VGA_SR_MEMORY_MODE = 0x04, + GRUB_VGA_CR_MODE_NO_CGA = 0x01, + GRUB_VGA_CR_MODE_NO_HERCULES = 0x02, + GRUB_VGA_CR_MODE_BYTE_MODE = 0x40, + GRUB_VGA_CR_MODE_TIMING_ENABLE = 0x80 }; -#define GRUB_VGA_SR_MEMORY_MODE_CHAIN4 8 -#define GRUB_VGA_SR_MEMORY_MODE_NORMAL 0 +enum + { + GRUB_VGA_SR_CLOCKING_MODE = 1, + GRUB_VGA_SR_MAP_MASK_REGISTER = 2, + GRUB_VGA_SR_MEMORY_MODE = 4, + }; enum { - GRUB_VGA_GR_READ_MAP_REGISTER = 0x04, + GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK = 1 + }; + +enum + { + GRUB_VGA_SR_MEMORY_MODE_NORMAL = 0, + GRUB_VGA_SR_MEMORY_MODE_CHAIN4 = 8 + }; + +enum + { + GRUB_VGA_GR_DATA_ROTATE = 3, + GRUB_VGA_GR_READ_MAP_REGISTER = 4, GRUB_VGA_GR_MODE = 5, GRUB_VGA_GR_GR6 = 6, + GRUB_VGA_GR_BITMASK = 8, GRUB_VGA_GR_MAX }; -#define GRUB_VGA_GR_GR6_GRAPHICS_MODE 1 +enum + { + GRUB_VGA_TEXT_TEXT_PLANE = 0, + GRUB_VGA_TEXT_ATTR_PLANE = 1, + GRUB_VGA_TEXT_FONT_PLANE = 2 + }; -#define GRUB_VGA_GR_MODE_256_COLOR 0x40 -#define GRUB_VGA_GR_MODE_READ_MODE1 0x08 +enum + { + GRUB_VGA_GR_GR6_GRAPHICS_MODE = 1, + GRUB_VGA_GR_GR6_MMAP_CGA = (3 << 2) + }; + +enum + { + GRUB_VGA_GR_MODE_READ_MODE1 = 0x08, + GRUB_VGA_GR_MODE_ODD_EVEN = 0x10, + GRUB_VGA_GR_MODE_256_COLOR = 0x40 + }; static inline void grub_vga_gr_write (grub_uint8_t val, grub_uint8_t addr) diff --git a/term/i386/pc/vga_text.c b/term/i386/pc/vga_text.c index 8bc14cb61..bfa934a40 100644 --- a/term/i386/pc/vga_text.c +++ b/term/i386/pc/vga_text.c @@ -124,11 +124,13 @@ static void grub_vga_text_setcursor (int on) { grub_uint8_t old; - old = grub_vga_cr_read (GRUB_VGA_CR_CURSOR); + old = grub_vga_cr_read (GRUB_VGA_CR_CURSOR_START); if (on) - grub_vga_cr_write (old & ~GRUB_VGA_CR_CURSOR_DISABLE, GRUB_VGA_CR_CURSOR); + grub_vga_cr_write (old & ~GRUB_VGA_CR_CURSOR_START_DISABLE, + GRUB_VGA_CR_CURSOR_START); else - grub_vga_cr_write (old | GRUB_VGA_CR_CURSOR_DISABLE, GRUB_VGA_CR_CURSOR); + grub_vga_cr_write (old | GRUB_VGA_CR_CURSOR_START_DISABLE, + GRUB_VGA_CR_CURSOR_START); } static grub_err_t