Define and use a few more constants

This commit is contained in:
Pierre Pronchery 2018-07-21 03:32:07 +02:00
parent 9f7b7dd810
commit a56ae53260
2 changed files with 30 additions and 23 deletions

View File

@ -156,7 +156,7 @@ static void _vga_cursor_set(VGAConsole * console, bool enabled,
/* disable the cursor if necessary */
if(data->cursor == false)
return;
data->bus->write8(data->bus, 0x3d4, 0x0a);
data->bus->write8(data->bus, 0x3d4, VGA_REGISTER_CURSOR_START);
data->bus->read8(data->bus, 0x3d5, &u8);
data->bus->write8(data->bus, 0x3d5, u8 | 0x20);
}
@ -165,14 +165,17 @@ static void _vga_cursor_set(VGAConsole * console, bool enabled,
else
{
/* position the cursor */
data->bus->write8(data->bus, 0x3d4, 0x0f);
data->bus->write8(data->bus, 0x3d4,
VGA_REGISTER_CURSOR_LOCATION_LOW);
data->bus->write8(data->bus, 0x3d5, pos & 0xff);
data->bus->write8(data->bus, 0x3d4, 0x0e);
data->bus->write8(data->bus, 0x3d4,
VGA_REGISTER_CURSOR_LOCATION_HIGH);
data->bus->write8(data->bus, 0x3d5, pos >> 8);
/* enable the cursor if necessary */
if(data->cursor == false)
{
data->bus->write8(data->bus, 0x3d4, 0x0a);
data->bus->write8(data->bus, 0x3d4,
VGA_REGISTER_CURSOR_START);
data->bus->read8(data->bus, 0x3d5, &u8);
data->bus->write8(data->bus, 0x3d5, u8 & ~0x20);
}

View File

@ -9,26 +9,30 @@
/* constants */
# define VGA_ADDRESS_BASE 0xb8000
# define VGA_ADDRESS_BASE 0xb8000
# define VGA_TEXT_COLUMNS 80
# define VGA_TEXT_ROWS 25
# define VGA_REGISTER_CURSOR_LOCATION_HIGH 0x0e
# define VGA_REGISTER_CURSOR_LOCATION_LOW 0x0f
# define VGA_REGISTER_CURSOR_START 0x0a
# define VGA_TEXT_COLOR_BLACK 0x00
# define VGA_TEXT_COLOR_BLUE 0x01
# define VGA_TEXT_COLOR_GREEN 0x02
# define VGA_TEXT_COLOR_CYAN 0x03
# define VGA_TEXT_COLOR_RED 0x04
# define VGA_TEXT_COLOR_MAGENTA 0x05
# define VGA_TEXT_COLOR_BROWN 0x06
# define VGA_TEXT_COLOR_LIGHT_GREY 0x07
# define VGA_TEXT_COLOR_DARK_GREY 0x08
# define VGA_TEXT_COLOR_LIGHT_BLUE 0x09
# define VGA_TEXT_COLOR_LIGHT_GREEN 0x0a
# define VGA_TEXT_COLOR_LIGHT_CYAN 0x0b
# define VGA_TEXT_COLOR_LIGHT_RED 0x0c
# define VGA_TEXT_COLOR_LIGHT_MAGENTA 0x0d
# define VGA_TEXT_COLOR_LIGHT_BROWN 0x0e
# define VGA_TEXT_COLOR_WHITE 0x0f
# define VGA_TEXT_COLUMNS 80
# define VGA_TEXT_ROWS 25
# define VGA_TEXT_COLOR_BLACK 0x00
# define VGA_TEXT_COLOR_BLUE 0x01
# define VGA_TEXT_COLOR_GREEN 0x02
# define VGA_TEXT_COLOR_CYAN 0x03
# define VGA_TEXT_COLOR_RED 0x04
# define VGA_TEXT_COLOR_MAGENTA 0x05
# define VGA_TEXT_COLOR_BROWN 0x06
# define VGA_TEXT_COLOR_LIGHT_GREY 0x07
# define VGA_TEXT_COLOR_DARK_GREY 0x08
# define VGA_TEXT_COLOR_LIGHT_BLUE 0x09
# define VGA_TEXT_COLOR_LIGHT_GREEN 0x0a
# define VGA_TEXT_COLOR_LIGHT_CYAN 0x0b
# define VGA_TEXT_COLOR_LIGHT_RED 0x0c
# define VGA_TEXT_COLOR_LIGHT_MAGENTA 0x0d
# define VGA_TEXT_COLOR_LIGHT_BROWN 0x0e
# define VGA_TEXT_COLOR_WHITE 0x0f
#endif /* !UKERNEL_DRIVERS_CONSOLE_VGA_H */