miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
VGA Text Console (low-level)

Direct VGA text-mode framebuffer driver used before VT initialises. More...

Macros

#define TEXT_STATIC   0
#define TEXT_BLINKING   1
#define TEXT_BLACK   0 /* 0000 */
#define TEXT_BLUE   1 /* 0001 */
#define TEXT_GREEN   2 /* 0010 */
#define TEXT_CYAN   3 /* 0011 */
#define TEXT_RED   4 /* 0100 */
#define TEXT_MAGENTA   5 /* 0101 */
#define TEXT_BROWN   6 /* 0110 */
#define TEXT_LIGHT_GRAY   7 /* 0111 */
#define TEXT_DARK_GRAY   8 /* 1000 */
#define TEXT_LIGHT_BLUE   9 /* 1001 */
#define TEXT_LIGHT_GREEN   10 /* 1010 */
#define TEXT_LIGHT_CYAN   11 /* 1011 */
#define TEXT_LIGHT_RED   12 /* 1100 */
#define TEXT_LIGHT_MAGENTA   13 /* 1101 */
#define TEXT_YELLOW   14 /* 1110 */
#define TEXT_WHITE   15 /* 1111 */
#define TEXT_ATTR(textcolor, bgcolor, blinking)
#define DEFAULT_TEXT_ATTR   (TEXT_ATTR(TEXT_LIGHT_GRAY, TEXT_BLACK, TEXT_STATIC))
#define SCREEN_ROWS   25 /* VGA text mode rows */
#define SCREEN_COLS   80 /* VGA text mode columns */
#define VGA_CURSOR_PORT_IDX   0x3D4 /* CRT index register */
#define VGA_CURSOR_PORT_DATA   0x3D5 /* CRT data register */
#define VGA_CUR_START_REG   0x0A /* cursor start scanline register */
#define VGA_CUR_HIGH_REG   0x0E /* cursor high byte register */
#define VGA_CUR_LOW_REG   0x0F /* cursor low byte register */
#define VGA_CUR_DISABLE   (1 << 5) /* bit 5 of start register disables cursor */
#define VGA_CUR_END_REG   0x0B /* cursor end scanline register */
#define VGA_CUR_START_LINE   14 /* underline style: start scanline */
#define VGA_CUR_END_LINE   15 /* underline style: end scanline */
#define COM1_PORT   0x3F8 /* COM1 base I/O port */
#define COM_LSR_OFFSET   5 /* Line Status Register offset from COM1_PORT */
#define COM_LSR_THRE   0x20 /* Transmitter Holding Register Empty (TX ready) */

Functions

void console_init (void)
 Sets cursor position to (0,0), initialises the 16550 UART at COM1_PORT (0x3F8) to 9600 baud 8N1, clears the VGA framebuffer using vt_init(), and enables the hardware cursor. Called once at boot before any printk output.
void console_clear (void)
 Fills all 80x25 cells with DEFAULT_TEXT_ATTR space characters and calls vt_clear() to reset the VT parser state and hardware cursor.
void console_putchar (char c)
 Handles newline, carriage return, backspace, and scrolling via the VT core.
void console_puts (char *s)
 Iterates over @s until the null terminator, calling console_putchar() for each character.
void console_show_cursor (void)
 Writes scanline range VGA_CUR_START_LINE..VGA_CUR_END_LINE to CRT registers 0x0A and 0x0B, making an underline cursor visible at the current position.
void console_hide_cursor (void)
 Sets VGA_CUR_DISABLE (bit 5) in CRT register 0x0A, making the hardware cursor invisible. Used when the terminal is in an intermediate state.

Detailed Description

Direct VGA text-mode framebuffer driver used before VT initialises.

Provides simple VGA 80x25 text-mode output: clear screen, single-character and string output with automatic scrolling, and hardware cursor control. Also mirrors output to COM1 (0x3F8) for serial logging. This driver is used during early boot; after vt_init() the VT core takes over terminal I/O.

Macro Definition Documentation

◆ COM1_PORT

#define COM1_PORT   0x3F8 /* COM1 base I/O port */

◆ COM_LSR_OFFSET

#define COM_LSR_OFFSET   5 /* Line Status Register offset from COM1_PORT */

◆ COM_LSR_THRE

#define COM_LSR_THRE   0x20 /* Transmitter Holding Register Empty (TX ready) */

◆ DEFAULT_TEXT_ATTR

#define DEFAULT_TEXT_ATTR   (TEXT_ATTR(TEXT_LIGHT_GRAY, TEXT_BLACK, TEXT_STATIC))

◆ SCREEN_COLS

#define SCREEN_COLS   80 /* VGA text mode columns */

◆ SCREEN_ROWS

#define SCREEN_ROWS   25 /* VGA text mode rows */

◆ TEXT_ATTR

#define TEXT_ATTR ( textcolor,
bgcolor,
blinking )
Value:
((blinking << 7) | (bgcolor << 4) | textcolor)

◆ TEXT_BLACK

#define TEXT_BLACK   0 /* 0000 */

◆ TEXT_BLINKING

#define TEXT_BLINKING   1

◆ TEXT_BLUE

#define TEXT_BLUE   1 /* 0001 */

◆ TEXT_BROWN

#define TEXT_BROWN   6 /* 0110 */

◆ TEXT_CYAN

#define TEXT_CYAN   3 /* 0011 */

◆ TEXT_DARK_GRAY

#define TEXT_DARK_GRAY   8 /* 1000 */

◆ TEXT_GREEN

#define TEXT_GREEN   2 /* 0010 */

◆ TEXT_LIGHT_BLUE

#define TEXT_LIGHT_BLUE   9 /* 1001 */

◆ TEXT_LIGHT_CYAN

#define TEXT_LIGHT_CYAN   11 /* 1011 */

◆ TEXT_LIGHT_GRAY

#define TEXT_LIGHT_GRAY   7 /* 0111 */

◆ TEXT_LIGHT_GREEN

#define TEXT_LIGHT_GREEN   10 /* 1010 */

◆ TEXT_LIGHT_MAGENTA

#define TEXT_LIGHT_MAGENTA   13 /* 1101 */

◆ TEXT_LIGHT_RED

#define TEXT_LIGHT_RED   12 /* 1100 */

◆ TEXT_MAGENTA

#define TEXT_MAGENTA   5 /* 0101 */

◆ TEXT_RED

#define TEXT_RED   4 /* 0100 */

◆ TEXT_STATIC

#define TEXT_STATIC   0

◆ TEXT_WHITE

#define TEXT_WHITE   15 /* 1111 */

◆ TEXT_YELLOW

#define TEXT_YELLOW   14 /* 1110 */

◆ VGA_CUR_DISABLE

#define VGA_CUR_DISABLE   (1 << 5) /* bit 5 of start register disables cursor */

◆ VGA_CUR_END_LINE

#define VGA_CUR_END_LINE   15 /* underline style: end scanline */

◆ VGA_CUR_END_REG

#define VGA_CUR_END_REG   0x0B /* cursor end scanline register */

◆ VGA_CUR_HIGH_REG

#define VGA_CUR_HIGH_REG   0x0E /* cursor high byte register */

◆ VGA_CUR_LOW_REG

#define VGA_CUR_LOW_REG   0x0F /* cursor low byte register */

◆ VGA_CUR_START_LINE

#define VGA_CUR_START_LINE   14 /* underline style: start scanline */

◆ VGA_CUR_START_REG

#define VGA_CUR_START_REG   0x0A /* cursor start scanline register */

◆ VGA_CURSOR_PORT_DATA

#define VGA_CURSOR_PORT_DATA   0x3D5 /* CRT data register */

◆ VGA_CURSOR_PORT_IDX

#define VGA_CURSOR_PORT_IDX   0x3D4 /* CRT index register */

Function Documentation

◆ console_clear()

void console_clear ( void )

Fills all 80x25 cells with DEFAULT_TEXT_ATTR space characters and calls vt_clear() to reset the VT parser state and hardware cursor.

console_clear() - Clear the VGA screen and reset cursor to row 0, column 0.

Here is the call graph for this function:

◆ console_hide_cursor()

void console_hide_cursor ( void )

Sets VGA_CUR_DISABLE (bit 5) in CRT register 0x0A, making the hardware cursor invisible. Used when the terminal is in an intermediate state.

console_hide_cursor() - Disable the VGA hardware cursor.

Here is the call graph for this function:

◆ console_init()

void console_init ( void )

Sets cursor position to (0,0), initialises the 16550 UART at COM1_PORT (0x3F8) to 9600 baud 8N1, clears the VGA framebuffer using vt_init(), and enables the hardware cursor. Called once at boot before any printk output.

console_init() - Initialise the VGA console and COM1 serial port.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ console_putchar()

void console_putchar ( char c)

Handles newline, carriage return, backspace, and scrolling via the VT core.

console_putchar() - Output one character to the VGA console and COM1.

Parameters
cCharacter to write. Routed through vt_write_byte() for ANSI processing and simultaneously written to COM1 for serial capture.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ console_puts()

void console_puts ( char * s)

Iterates over @s until the null terminator, calling console_putchar() for each character.

console_puts() - Output a null-terminated string to the VGA console.

Parameters
sNull-terminated string to write. Each byte is passed to console_putchar().
Here is the call graph for this function:

◆ console_show_cursor()

void console_show_cursor ( void )

Writes scanline range VGA_CUR_START_LINE..VGA_CUR_END_LINE to CRT registers 0x0A and 0x0B, making an underline cursor visible at the current position.

console_show_cursor() - Enable the VGA hardware underline cursor.

Here is the call graph for this function: