The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
vga.c File Reference
#include "vga.h"
#include "arch/x86/cpu/io.h"
#include "kernel/memory/phys.h"

Macros

#define VGA_TEXT_PHYS   0xB8000u
#define VGA_TEXT_BUFFER   ((volatile uint16_t *)phys_to_virt(VGA_TEXT_PHYS))
#define VGA_WIDTH   80u
#define VGA_HEIGHT   25u
#define VGA_DEFAULT_FOREGROUND   VGA_LIGHT_GREY
#define VGA_DEFAULT_BACKGROUND   VGA_BLACK
#define VGA_CRTC_INDEX_PORT   0x3D4u
#define VGA_CRTC_DATA_PORT   0x3D5u

Functions

void vga_put_at (char c, uint8_t row, uint8_t col)
 write a character at an explicit screen location.
void vga_scroll (void)
 scroll the text buffer up by one row and move the cursor to the last row.
void vga_set_color (uint8_t fg, uint8_t bg)
 sets the foreground and background colors for text output.
void vga_clear (void)
 clears the VGA text buffer and resets the cursor position to the top left corner.
void vga_putchar (char c)
 writes a single character to the VGA text buffer at the current cursor position.
void vga_write (const char *str)
 writes a null-terminated string to the VGA text buffer starting at the current cursor position.
void vga_initialize (void)
 initializes the VGA driver.
void vga_set_cursor (uint8_t row, uint8_t col)
 set the cursor position to the specified row and column.
void vga_get_cursor (uint8_t *row, uint8_t *col)
 get the current cursor position.

Macro Definition Documentation

◆ VGA_TEXT_PHYS

#define VGA_TEXT_PHYS   0xB8000u

◆ VGA_TEXT_BUFFER

#define VGA_TEXT_BUFFER   ((volatile uint16_t *)phys_to_virt(VGA_TEXT_PHYS))

◆ VGA_WIDTH

#define VGA_WIDTH   80u

◆ VGA_HEIGHT

#define VGA_HEIGHT   25u

◆ VGA_DEFAULT_FOREGROUND

#define VGA_DEFAULT_FOREGROUND   VGA_LIGHT_GREY

◆ VGA_DEFAULT_BACKGROUND

#define VGA_DEFAULT_BACKGROUND   VGA_BLACK

◆ VGA_CRTC_INDEX_PORT

#define VGA_CRTC_INDEX_PORT   0x3D4u

◆ VGA_CRTC_DATA_PORT

#define VGA_CRTC_DATA_PORT   0x3D5u

Function Documentation

◆ vga_put_at()

void vga_put_at ( char c,
uint8_t row,
uint8_t col )

write a character at an explicit screen location.

invalid row/column values are ignored.

◆ vga_scroll()

void vga_scroll ( void )

scroll the text buffer up by one row and move the cursor to the last row.

◆ vga_set_color()

void vga_set_color ( uint8_t foreground,
uint8_t background )

sets the foreground and background colors for text output.

Parameters
foregroundthe foreground color.
backgroundthe background color.

◆ vga_clear()

void vga_clear ( void )

clears the VGA text buffer and resets the cursor position to the top left corner.

◆ vga_putchar()

void vga_putchar ( char c)

writes a single character to the VGA text buffer at the current cursor position.

Parameters
cthe character to write.

◆ vga_write()

void vga_write ( const char * str)

writes a null-terminated string to the VGA text buffer starting at the current cursor position.

Parameters
strthe string to write.

◆ vga_initialize()

void vga_initialize ( void )

initializes the VGA driver.

must be called before any other VGA functions.

◆ vga_set_cursor()

void vga_set_cursor ( uint8_t row,
uint8_t col )

set the cursor position to the specified row and column.

Parameters
rowthe row to set the cursor to.
colthe column to set the cursor to.

◆ vga_get_cursor()

void vga_get_cursor ( uint8_t * row,
uint8_t * col )

get the current cursor position.

Parameters
rowpointer to a variable to receive the current cursor row.
colpointer to a variable to receive the current cursor column.