> ## Documentation Index
> Fetch the complete documentation index at: https://kernel.mvhcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MVH Kernel VGA Text Driver: Display and Cursor Output

> The VGA text driver gives MVH Kernel an 80×25 display with 16-color support, hardware cursor sync, and automatic scrolling for shell and panic output.

The VGA text driver (`vga-text-cursor`) gives MVH Kernel a full 80-column, 25-row text display backed by the standard VGA memory-mapped framebuffer at `0xB8000`. It supports 16 foreground and 16 background colors, keeps the hardware cursor in sync with the shell prompt, and automatically scrolls the screen when output reaches the bottom. The driver is active for every text surface the kernel exposes — the interactive shell, the full-screen statics monitor, and the kernel panic display.

## Features

<CardGroup cols={2}>
  <Card title="80×25 Text Mode" icon="display">
    The driver writes directly to the VGA framebuffer in standard 80-column by 25-row mode. Each cell stores a character byte and an attribute byte encoding foreground and background color.
  </Card>

  <Card title="16-Color Palette" icon="palette">
    You get 16 foreground colors and 16 background colors from the standard VGA text-mode palette. Colors are set per-character using the attribute byte.
  </Card>

  <Card title="Hardware Cursor" icon="i-cursor">
    The driver synchronizes the blinking hardware text cursor with the shell prompt position via VGA CRTC register writes (`vga_cursor_enable` / `vga_cursor_disable`). The `statics` monitor disables the cursor for a clean full-screen view.
  </Card>

  <Card title="Auto-Scrolling" icon="arrow-down">
    When output reaches row 24, the driver scrolls the entire buffer up by one row and clears the bottom line, so the shell never overflows the visible area.
  </Card>
</CardGroup>

## Where the VGA Driver Is Used

The VGA driver is the primary output surface for all visible kernel output. Every component that writes text goes through `vga_put` and `vga_set_color`.

<AccordionGroup>
  <Accordion title="Interactive Shell">
    All shell command output — `ls`, `cat`, `cpuinfo`, `lspci`, `date`, `dmesg`, and every other command — is written to the VGA framebuffer. The hardware cursor tracks your input position at the `mvh>` prompt.
  </Accordion>

  <Accordion title="Full-Screen Statics Monitor">
    The `statics` command takes over the full 80×25 display to show a live system monitor. The hardware cursor is hidden during this mode. Press `Q` or `Ctrl+C` to return to the shell.
  </Accordion>

  <Accordion title="Kernel Panic Display">
    When the kernel panics, the VGA driver renders the panic output in high-visibility colors directly to the framebuffer. This includes the panic code, decoded exception name and error code, RIP, RFLAGS, all general-purpose registers, control registers, and a frame-pointer stack trace.
  </Accordion>
</AccordionGroup>

## Shell Commands That Use VGA Output

Every shell command produces VGA output. A few commands are specifically relevant to display behavior:

| Command         | Effect                                                              |
| --------------- | ------------------------------------------------------------------- |
| `clear` / `cls` | Clears the VGA framebuffer and resets the cursor to row 0, column 0 |
| `statics`       | Enters the full-screen system monitor; hides the hardware cursor    |
| `paniccodes`    | Lists all stable kernel panic codes with descriptions               |
| `dmesg`         | Scrolls the 16 KiB kernel log ring to the VGA output                |

## API Reference

The VGA driver exposes the following functions from `include/mvh/vga.h`:

```c theme={null}
void    vga_init(void);           // Initialize the VGA framebuffer and cursor
void    vga_clear(void);          // Clear the screen and reset cursor to (0, 0)
void    vga_put(char value);      // Write one character at the current cursor position
void    vga_set_color(uint8_t color); // Set the active foreground/background color attribute
uint8_t vga_get_color(void);      // Read the current color attribute byte
void    vga_cursor_enable(void);  // Enable and sync the hardware blinking cursor
void    vga_cursor_disable(void); // Hide the hardware cursor (used by statics)
```

The `color` attribute byte follows the standard VGA text-mode format: bits 3–0 are the foreground color index and bits 6–4 are the background color index (bit 7 is the blink flag).

## Driver ID

The device manager registers this driver under the ID `vga-text-cursor`. Run `devices` in the shell to confirm it is online.
