miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
vt.c File Reference
Include dependency graph for vt.c:

Classes

struct  vt_attr_state_t
struct  vt_state_t

Enumerations

enum  vt_parser_state { VT_STATE_NORMAL = 0 , VT_STATE_ESC , VT_STATE_CSI }

Functions

static void serial_init (void)
static void serial_putchar (char c)
static uint8_tvt_vga_cell (uint16_t row, uint16_t col)
static void vt_reset_parser (void)
static void vt_reset_attr (void)
static uint8_t vt_attr_byte (void)
static void vt_write_cell (uint16_t row, uint16_t col, uint16_t ch, uint8_t attr)
static void vt_clear_row_range (uint16_t row, uint16_t col_start, uint16_t col_end, uint8_t attr)
static void vt_scroll_if_needed (void)
static void vt_update_cursor_hw (void)
static void vt_clamp_cursor (void)
static int vt_csi_param (uint8_t index, int default_value)
static void vt_erase_in_display (int mode)
static void vt_erase_in_line (int mode)
static uint8_t vt_map_256_to_vga (int color)
static uint8_t vt_sgr_16_color (int code, bool background)
static void vt_apply_sgr (void)
static void vt_put_printable (uint16_t ch)
static uint8_t latin1_to_cp437 (uint8_t c)
static void vt_put_codepoint (uint32_t cp)
static void utf8_flush_raw (void)
static void utf8_emit_codepoint (uint32_t cp)
static void vt_handle_normal_char (char c)
void vt_handle_csi (char final)
void vt_init (void)
 Clears the VGA framebuffer, resets cursor position to (0,0), sets default attribute (light gray on black), and initialises the ANSI escape parser state machine. Called once during kernel boot before any console output.
void vt_clear (void)
 Fills all 80x25 VGA cells with space characters using the current default attribute, resets the cursor position to row 0 column 0, and updates the hardware cursor via VGA CRT registers.
void vt_write_byte (char c)
 If inside an ANSI escape sequence, feeds to the CSI parser and applies the completed command (cursor movement, erase, SGR color). Otherwise:
void vt_write (const char *buf, size_t len)
 Calls vt_write_byte() for each byte in [buf, buf+len). Efficient for bulk output from tty_write() or printk().
void vt_set_cursor_visible (bool visible)
 Writes to VGA CRT registers VGA_CUR_START_REG (index 0x0A): sets VGA_CUR_DISABLE bit to hide, clears it and sets scanline range to show.
void vt_get_winsize (uint16_t *rows, uint16_t *cols)
 Used by tty_ioctl TIOCGWINSZ to fill struct minios_winsize.ws_row/ws_col.
uint8_t vt_current_attr (void)
 The attribute byte encodes foreground color (bits 3:0), background color (bits 6:4), and blink (bit 7) as set by the most recent SGR sequence.

Variables

static uint16_t vt_rows = SCREEN_ROWS
static uint16_t vt_cols = SCREEN_COLS
static spinlock_t vt_fb_lock = SPINLOCK_INIT
static vt_state_t vt_state
static uint8_t vt_palette_rgb [16][3]
static int utf8_rem
static uint32_t utf8_cp
static uint8_t utf8_buf [4]
static int utf8_buf_len

Enumeration Type Documentation

◆ vt_parser_state

Enumerator
VT_STATE_NORMAL 
VT_STATE_ESC 
VT_STATE_CSI 

Function Documentation

◆ latin1_to_cp437()

uint8_t latin1_to_cp437 ( uint8_t c)
static
Here is the caller graph for this function:

◆ serial_init()

void serial_init ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serial_putchar()

void serial_putchar ( char c)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ utf8_emit_codepoint()

void utf8_emit_codepoint ( uint32_t cp)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ utf8_flush_raw()

void utf8_flush_raw ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_apply_sgr()

void vt_apply_sgr ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_attr_byte()

uint8_t vt_attr_byte ( void )
static
Here is the caller graph for this function:

◆ vt_clamp_cursor()

void vt_clamp_cursor ( void )
static
Here is the caller graph for this function:

◆ vt_clear_row_range()

void vt_clear_row_range ( uint16_t row,
uint16_t col_start,
uint16_t col_end,
uint8_t attr )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_csi_param()

int vt_csi_param ( uint8_t index,
int default_value )
static
Here is the caller graph for this function:

◆ vt_erase_in_display()

void vt_erase_in_display ( int mode)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_erase_in_line()

void vt_erase_in_line ( int mode)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_handle_csi()

void vt_handle_csi ( char final)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_handle_normal_char()

void vt_handle_normal_char ( char c)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_map_256_to_vga()

uint8_t vt_map_256_to_vga ( int color)
static
Here is the caller graph for this function:

◆ vt_put_codepoint()

void vt_put_codepoint ( uint32_t cp)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_put_printable()

void vt_put_printable ( uint16_t ch)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_reset_attr()

void vt_reset_attr ( void )
static
Here is the caller graph for this function:

◆ vt_reset_parser()

void vt_reset_parser ( void )
static
Here is the caller graph for this function:

◆ vt_scroll_if_needed()

void vt_scroll_if_needed ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_sgr_16_color()

uint8_t vt_sgr_16_color ( int code,
bool background )
static
Here is the caller graph for this function:

◆ vt_update_cursor_hw()

void vt_update_cursor_hw ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_vga_cell()

uint8_t * vt_vga_cell ( uint16_t row,
uint16_t col )
static
Here is the caller graph for this function:

◆ vt_write_cell()

void vt_write_cell ( uint16_t row,
uint16_t col,
uint16_t ch,
uint8_t attr )
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ utf8_buf

uint8_t utf8_buf[4]
static

◆ utf8_buf_len

int utf8_buf_len
static

◆ utf8_cp

uint32_t utf8_cp
static

◆ utf8_rem

int utf8_rem
static

◆ vt_cols

uint16_t vt_cols = SCREEN_COLS
static

◆ vt_fb_lock

spinlock_t vt_fb_lock = SPINLOCK_INIT
static

◆ vt_palette_rgb

uint8_t vt_palette_rgb[16][3]
static
Initial value:
= {
{0x00, 0x00, 0x00}, {0x00, 0x00, 0xaa}, {0x00, 0xaa, 0x00}, {0x00, 0xaa, 0xaa},
{0xaa, 0x00, 0x00}, {0xaa, 0x00, 0xaa}, {0xaa, 0x55, 0x00}, {0xaa, 0xaa, 0xaa},
{0x55, 0x55, 0x55}, {0x55, 0x55, 0xff}, {0x55, 0xff, 0x55}, {0x55, 0xff, 0xff},
{0xff, 0x55, 0x55}, {0xff, 0x55, 0xff}, {0xff, 0xff, 0x55}, {0xff, 0xff, 0xff},
}

◆ vt_rows

uint16_t vt_rows = SCREEN_ROWS
static

◆ vt_state

vt_state_t vt_state
static