MentOS
0.8.0
The Mentoring Operating System
|
Implementation of Video Graphics Array (VGA) drivers. More...
Classes | |
struct | vga_ops_t |
VGA pointers for drawing operations. More... | |
struct | vga_font_t |
VGA font details. More... | |
struct | vga_driver_t |
VGA driver details. More... | |
Macros | |
#define | __DEBUG_HEADER__ "[VGA ]" |
Change header. | |
#define | __DEBUG_LEVEL__ LOGLEVEL_NOTICE |
Set log level. | |
#define | AC_INDEX 0x03C0 |
Attribute Controller index port. | |
#define | AC_WRITE 0x03C0 |
Attribute Controller write port. | |
#define | AC_READ 0x03C1 |
Attribute Controller data port. | |
#define | MISC_WRITE 0x03C2 |
Miscellaneous output register. | |
#define | MISC_READ 0x03CC |
Miscellaneous input register. | |
#define | SC_INDEX 0x03C4 |
Sequence controller index. | |
#define | SC_DATA 0x03C5 |
Sequence controller data. | |
#define | PALETTE_MASK 0x03C6 |
DAC Mask Register. | |
#define | PALETTE_READ 0x03C7 |
Controls the DAC. | |
#define | PALETTE_INDEX 0x03C8 |
Controls the DAC index. | |
#define | PALETTE_DATA 0x03C9 |
Controls the DAC data. | |
#define | GC_INDEX 0x03CE |
Graphics controller index. | |
#define | GC_DATA 0x03CF |
Graphics controller data. | |
#define | CRTC_INDEX 0x03D4 |
CRT controller index. | |
#define | CRTC_DATA 0x03D5 |
CRT controller data. | |
#define | INPUT_STATUS_READ 0x03DA |
By reading this port it'll go to the index state. | |
#define | MODE_NUM_SEQ_REGS 5 |
Number of sequencer registers. | |
#define | MODE_NUM_CRTC_REGS 25 |
Number of CRTC registers. | |
#define | MODE_NUM_GC_REGS 9 |
Number of Graphics Controller (GC) registers. | |
#define | MODE_NUM_AC_REGS (16 + 5) |
Number of Attribute Controller (AC) registers. | |
#define | MODE_NUM_REGS (1 + MODE_NUM_SEQ_REGS + MODE_NUM_CRTC_REGS + MODE_NUM_GC_REGS + MODE_NUM_AC_REGS) |
Total number of registers. | |
Functions | |
static char * | __get_seg (void) |
Returns the video address. More... | |
void | __vga_set_color_map (unsigned int index, unsigned char r, unsigned char g, unsigned char b) |
Sets the color at the given index. More... | |
void | __vga_get_color_map (unsigned int index, unsigned char *r, unsigned char *g, unsigned char *b) |
Gets the color at the given index. More... | |
static void | __save_palette (palette_entry_t *p, size_t size) |
Saves the current palette in p. More... | |
static void | __load_palette (palette_entry_t *p, size_t size) |
Loads the palette p. More... | |
static void | __set_plane (unsigned int plane) |
Sets the current plane. More... | |
static unsigned | __get_plane (void) |
Returns the current plane. More... | |
static unsigned char | __read_byte (unsigned int offset) |
Reads from the video memory. More... | |
static void | __write_byte (unsigned int offset, unsigned char value) |
Writes onto the video memory. More... | |
static void | __set_mode (vga_mode_t *vga_mode) |
Sets the given mode. More... | |
static void | __read_registers (vga_mode_t *vga_mode) |
Reads the VGA registers. More... | |
static void | __write_font (unsigned char *buf, unsigned font_height) |
Writes the font. More... | |
static unsigned int | __reverse_bits (char num) |
Reverses the bits of the given number. More... | |
static void | __write_pixel_1 (int x, int y, unsigned char c) |
Writes a pixel. More... | |
static unsigned | __read_pixel_1 (unsigned x, unsigned y) |
Reads a pixel. More... | |
static void | __write_pixel_2 (int x, int y, unsigned char c) |
Writes a pixel. More... | |
static unsigned | __read_pixel_2 (unsigned x, unsigned y) |
Reads a pixel. More... | |
static void | __write_pixel_4 (int x, int y, unsigned char color) |
Writes a pixel. More... | |
static unsigned | __read_pixel_4 (int x, int y) |
Reads a pixel. More... | |
static void | __write_pixel_8 (int x, int y, unsigned char color) |
Writes a pixel. More... | |
static unsigned | __read_pixel_8 (int x, int y) |
Reads a pixel. More... | |
int | vga_is_enabled (void) |
Checks if the VGA is enabled. More... | |
int | vga_width (void) |
Returns the width of the screen. More... | |
int | vga_height (void) |
Returns the height of the screen. More... | |
void | vga_draw_pixel (int x, int y, unsigned char color) |
Draws a pixel at the given position. More... | |
unsigned int | vga_read_pixel (int x, int y) |
Reads a pixel at the given position. More... | |
void | vga_draw_char (int x, int y, unsigned char c, unsigned char color) |
Draws a character at the given position. More... | |
void | vga_draw_string (int x, int y, const char *str, unsigned char color) |
Draws a string at the given position. More... | |
void | vga_draw_line (int x0, int y0, int x1, int y1, unsigned char color) |
Draws a line from point 1 to point 2. More... | |
void | vga_draw_rectangle (int sx, int sy, int w, int h, unsigned char color) |
Draws a rectangle provided the position of the starting corner and the ending corner. More... | |
void | vga_draw_circle (int xc, int yc, int r, unsigned char color) |
Draws a circle provided the position of the center and the radius. More... | |
void | vga_draw_triangle (int x1, int y1, int x2, int y2, int x3, int y3, unsigned char color) |
Draws a triangle. More... | |
void | vga_run_test (void) |
Run some VGA tests. | |
void | vga_initialize (void) |
Initializes the VGA. | |
void | vga_finalize (void) |
Finalizes the VGA. | |
static void | __vga_clear_cursor (void) |
Clears the character at the cursor. | |
static void | __vga_draw_cursor (void) |
Draws the cursor. | |
void | vga_putc (int c) |
Print the given character on the screen. More... | |
void | vga_puts (const char *str) |
Prints the given string on the screen. More... | |
void | vga_move_cursor (unsigned int x, unsigned int y) |
Move the cursor at the position x, y on the screen. More... | |
void | vga_get_cursor_position (unsigned int *x, unsigned int *y) |
Returns cursor's position on the screen. More... | |
void | vga_get_screen_size (unsigned int *width, unsigned int *height) |
Returns screen size. More... | |
void | vga_clear_screen (void) |
Clears the screen. | |
void | vga_new_line (void) |
Move to the following line (the effect of character). | |
void | vga_update (void) |
Updates the graphic elements. | |
void | vga_set_color (unsigned int color) |
Change the color. More... | |
Variables | |
static bool_t | vga_enable = false |
Is VGA enabled. | |
palette_entry_t | stored_palette [256] |
The stored palette. | |
char | vidmem [262144] |
A buffer for storing a copy of the video memory. | |
static vga_driver_t * | driver = NULL |
Current driver. | |
static vga_ops_t | ops_720_480_16 |
Operations for 720*480, and 16-bit color video. More... | |
static vga_ops_t | ops_640_480_16 |
Operations for 640*480, and 16-bit color video. More... | |
static vga_ops_t | ops_320_200_256 |
Operations for 320*200, and 256-bit color video. More... | |
static vga_font_t | font_4x6 |
4x6 font. More... | |
static vga_font_t | font_5x6 |
5x6 font. More... | |
static vga_font_t | font_8x8 |
8x8 font. More... | |
static vga_font_t | font_8x14 |
8x14 font. More... | |
static vga_font_t | font_8x16 |
8x16 font. More... | |
static vga_driver_t | driver_720_480_16 |
Drivers for 720*480, and 16-bit color video. More... | |
static vga_driver_t | driver_640_480_16 |
Drivers for 640*480, and 16-bit color video. More... | |
static vga_driver_t | driver_320_200_256 |
Drivers for 320*200, and 16-bit color video. More... | |
static int | _x = 0 |
Current x coordinate of the cursor. | |
static int | _y = 0 |
Current y coordinate of the cursor. | |
static unsigned char | _color = 7 |
Current color. | |
static int | _cursor_state = 0 |
Current state of the cursor. | |
Implementation of Video Graphics Array (VGA) drivers.
|
inlinestatic |
Returns the current plane.
|
inlinestatic |
Returns the video address.
|
static |
Loads the palette p.
p | palette we are going to load. |
size | the size of the palette. |
|
static |
Reads from the video memory.
offset | where we are going to read. |
|
inlinestatic |
Reads a pixel.
x | x coordinates. |
y | y coordinates. |
|
inlinestatic |
Reads a pixel.
x | x coordinates. |
y | y coordinates. |
|
inlinestatic |
Reads a pixel.
x | x coordinates. |
y | y coordinates. |
|
inlinestatic |
Reads a pixel.
x | x coordinates. |
y | y coordinates. |
|
static |
Reads the VGA registers.
vga_mode | the current VGA mode. |
|
inlinestatic |
Reverses the bits of the given number.
num | the number of which we want to reverse the bits. |
|
static |
Saves the current palette in p.
p | output variable where we save the palette. |
size | the size of the palette. |
|
static |
Sets the given mode.
vga_mode | the new mode we set. |
|
inlinestatic |
Sets the current plane.
plane | the plane to set. |
void __vga_get_color_map | ( | unsigned int | index, |
unsigned char * | r, | ||
unsigned char * | g, | ||
unsigned char * | b | ||
) |
Gets the color at the given index.
index | index of the palette we want to read. |
r | output value for red. |
g | output value for green. |
b | output value for blue. |
void __vga_set_color_map | ( | unsigned int | index, |
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b | ||
) |
Sets the color at the given index.
index | index of the palette we want to change. |
r | red. |
g | green. |
b | blue. |
|
static |
Writes onto the video memory.
offset | where we are going to write. |
value | the value to write. |
|
static |
Writes the font.
buf | buffer where the font resides. |
font_height | the height of the font. |
|
inlinestatic |
Writes a pixel.
x | x coordinates. |
y | y coordinates. |
c | color. |
|
inlinestatic |
Writes a pixel.
x | x coordinates. |
y | y coordinates. |
c | color. |
|
inlinestatic |
Writes a pixel.
x | x coordinates. |
y | y coordinates. |
color | the color. |
|
inlinestatic |
Writes a pixel.
x | x coordinates. |
y | y coordinates. |
color | the color. |
void vga_draw_char | ( | int | x, |
int | y, | ||
unsigned char | c, | ||
unsigned char | color | ||
) |
Draws a character at the given position.
x | x-axis position. |
y | y-axis position. |
c | character to draw. |
color | color of the character. |
void vga_draw_circle | ( | int | xc, |
int | yc, | ||
int | r, | ||
unsigned char | color | ||
) |
Draws a circle provided the position of the center and the radius.
xc | x-axis position. |
yc | y-axis position. |
r | radius. |
color | used to draw the circle. |
void vga_draw_line | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
unsigned char | color | ||
) |
Draws a line from point 1 to point 2.
x0 | point 1 x-axis position. |
y0 | point 1 y-axis position. |
x1 | point 2 x-axis position. |
y1 | point 2 y-axis position. |
color | color of the line. |
void vga_draw_pixel | ( | int | x, |
int | y, | ||
unsigned char | color | ||
) |
Draws a pixel at the given position.
x | x-axis position. |
y | y-axis position. |
color | color of the character. |
void vga_draw_rectangle | ( | int | sx, |
int | sy, | ||
int | w, | ||
int | h, | ||
unsigned char | color | ||
) |
Draws a rectangle provided the position of the starting corner and the ending corner.
sx | top-left corner x-axis position. |
sy | top-left corner y-axis position. |
w | width. |
h | height. |
color | color of the rectangle. |
void vga_draw_string | ( | int | x, |
int | y, | ||
const char * | str, | ||
unsigned char | color | ||
) |
Draws a string at the given position.
x | x-axis position. |
y | y-axis position. |
str | string to draw. |
color | color of the character. |
void vga_draw_triangle | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | x3, | ||
int | y3, | ||
unsigned char | color | ||
) |
Draws a triangle.
x1 | 1st point x-axis position. |
y1 | 1st point y-axis position. |
x2 | 2nd point x-axis position. |
y2 | 2nd point y-axis position. |
x3 | 3rd point x-axis position. |
y3 | 3rd point y-axis position. |
color | used to draw the triangle. |
void vga_get_cursor_position | ( | unsigned int * | x, |
unsigned int * | y | ||
) |
Returns cursor's position on the screen.
x | The output x coordinate. |
y | The output y coordinate. |
void vga_get_screen_size | ( | unsigned int * | width, |
unsigned int * | height | ||
) |
Returns screen size.
width | The screen width. |
height | The screen height. |
int vga_height | ( | void | ) |
Returns the height of the screen.
int vga_is_enabled | ( | void | ) |
Checks if the VGA is enabled.
void vga_move_cursor | ( | unsigned int | x, |
unsigned int | y | ||
) |
Move the cursor at the position x, y on the screen.
x | The x coordinate. |
y | The y coordinate. |
void vga_putc | ( | int | c | ) |
Print the given character on the screen.
c | The character to print. |
void vga_puts | ( | const char * | str | ) |
Prints the given string on the screen.
str | The string to print. |
unsigned int vga_read_pixel | ( | int | x, |
int | y | ||
) |
Reads a pixel at the given position.
x | x-axis position. |
y | y-axis position. |
void vga_set_color | ( | unsigned int | color | ) |
Change the color.
color | the color to set. |
int vga_width | ( | void | ) |
Returns the width of the screen.
|
static |
Drivers for 320*200, and 16-bit color video.
|
static |
Drivers for 640*480, and 16-bit color video.
|
static |
Drivers for 720*480, and 16-bit color video.
|
static |
4x6 font.
|
static |
5x6 font.
|
static |
8x14 font.
|
static |
8x16 font.
|
static |
8x8 font.
|
static |
Operations for 320*200, and 256-bit color video.
|
static |
Operations for 640*480, and 16-bit color video.
|
static |
Operations for 720*480, and 16-bit color video.