Files
claude-os/src/vga.h
AI 313aeb5872 Implement VGA text-mode driver with memory statistics display (AI)
- Created VGA driver that writes to the 0xB8000 text-mode framebuffer.
  Supports 80x25 display with 16 foreground/background colors, scrolling,
  hardware cursor updates, and special characters (\n, \r, \t, \b).
- Provides vga_puts, vga_putchar, vga_put_hex, vga_put_dec, vga_set_color.
- Displays boot banner ("ClaudeOS v0.1 booting...") on screen clear.
- vga_show_mem_stats() prints total RAM, kernel start/end addresses, and
  kernel size on the VGA display during boot.
- Registered as the first driver using REGISTER_DRIVER, proving the
  driver framework works end-to-end (probe -> init lifecycle).

Tested: driver loads successfully, debug port confirms vga probe/init.
2026-02-23 11:10:48 +00:00

98 lines
1.9 KiB
C

/**
* @file vga.h
* @brief VGA text-mode driver interface.
*
* Provides functions to write text to the VGA text-mode framebuffer
* (typically at 0xB8000). Supports an 80x25 character display with
* 16 foreground and 16 background colors.
*/
#ifndef VGA_H
#define VGA_H
#include <stdint.h>
#include <stddef.h>
/** VGA color constants. */
typedef enum {
VGA_BLACK = 0,
VGA_BLUE = 1,
VGA_GREEN = 2,
VGA_CYAN = 3,
VGA_RED = 4,
VGA_MAGENTA = 5,
VGA_BROWN = 6,
VGA_LIGHT_GREY = 7,
VGA_DARK_GREY = 8,
VGA_LIGHT_BLUE = 9,
VGA_LIGHT_GREEN = 10,
VGA_LIGHT_CYAN = 11,
VGA_LIGHT_RED = 12,
VGA_LIGHT_MAGENTA = 13,
VGA_YELLOW = 14,
VGA_WHITE = 15,
} vga_color_t;
/** VGA screen dimensions. */
#define VGA_WIDTH 80
#define VGA_HEIGHT 25
/**
* Initialize the VGA driver.
*
* Clears the screen and sets the default colors.
*
* @return 0 on success.
*/
int vga_init(void);
/**
* Clear the VGA screen.
*/
void vga_clear(void);
/**
* Set the foreground and background color for subsequent writes.
*
* @param fg Foreground color.
* @param bg Background color.
*/
void vga_set_color(vga_color_t fg, vga_color_t bg);
/**
* Write a single character at the current cursor position.
*
* @param c Character to write.
*/
void vga_putchar(char c);
/**
* Write a null-terminated string at the current cursor position.
*
* @param str String to write.
*/
void vga_puts(const char *str);
/**
* Write a 32-bit value in hexadecimal to the VGA display.
*
* @param val Value to display.
*/
void vga_put_hex(uint32_t val);
/**
* Write a 32-bit value in decimal to the VGA display.
*
* @param val Value to display.
*/
void vga_put_dec(uint32_t val);
/**
* Display boot memory statistics on VGA.
*
* Shows detected memory, kernel size, and free pages.
*/
void vga_show_mem_stats(void);
#endif /* VGA_H */