Improve macroification of VGA registers.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-06-21 00:58:43 +02:00
parent 6d5a33c9ac
commit d246fc0368
2 changed files with 54 additions and 18 deletions

View file

@ -21,6 +21,7 @@
enum enum
{ {
GRUB_VGA_IO_ARX = 0x3c0,
GRUB_VGA_IO_SR_INDEX = 0x3c4, GRUB_VGA_IO_SR_INDEX = 0x3c4,
GRUB_VGA_IO_SR_DATA = 0x3c5, GRUB_VGA_IO_SR_DATA = 0x3c5,
GRUB_VGA_IO_PIXEL_MASK = 0x3c6, GRUB_VGA_IO_PIXEL_MASK = 0x3c6,
@ -41,7 +42,8 @@ enum
GRUB_VGA_CR_WIDTH = 0x01, GRUB_VGA_CR_WIDTH = 0x01,
GRUB_VGA_CR_OVERFLOW = 0x07, GRUB_VGA_CR_OVERFLOW = 0x07,
GRUB_VGA_CR_CELL_HEIGHT = 0x09, 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_HIGH_REGISTER = 0x0c,
GRUB_VGA_CR_START_ADDR_LOW_REGISTER = 0x0d, GRUB_VGA_CR_START_ADDR_LOW_REGISTER = 0x0d,
GRUB_VGA_CR_CURSOR_ADDR_HIGH = 0x0e, 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_MASK 0x40
#define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_SHIFT 3 #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_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 enum
{ {
GRUB_VGA_SR_MAP_MASK_REGISTER = 0x02, GRUB_VGA_CR_MODE_NO_CGA = 0x01,
GRUB_VGA_SR_MEMORY_MODE = 0x04, 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 enum
#define GRUB_VGA_SR_MEMORY_MODE_NORMAL 0 {
GRUB_VGA_SR_CLOCKING_MODE = 1,
GRUB_VGA_SR_MAP_MASK_REGISTER = 2,
GRUB_VGA_SR_MEMORY_MODE = 4,
};
enum 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_MODE = 5,
GRUB_VGA_GR_GR6 = 6, GRUB_VGA_GR_GR6 = 6,
GRUB_VGA_GR_BITMASK = 8,
GRUB_VGA_GR_MAX 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 enum
#define GRUB_VGA_GR_MODE_READ_MODE1 0x08 {
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 static inline void
grub_vga_gr_write (grub_uint8_t val, grub_uint8_t addr) grub_vga_gr_write (grub_uint8_t val, grub_uint8_t addr)

View file

@ -124,11 +124,13 @@ static void
grub_vga_text_setcursor (int on) grub_vga_text_setcursor (int on)
{ {
grub_uint8_t old; 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) 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 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 static grub_err_t