hazel/include/kernel/vga.h

68 lines
1.4 KiB
C
Raw Permalink Normal View History

#ifndef HAZEL_VGA_H_
#define HAZEL_VGA_H_
#include <stdint.h>
/*
* Location of the linear text buffer
* Used to directly modify text on screen
* 80 columns by 25 rows
*/
#define VGA_MEMORY_ADDR 0xb8000
#define VGA_MAX_COLS 80
#define VGA_MAX_ROWS 25
#define CRTC_ADDR_PORT 0x3d4
#define CRTC_DATA_PORT 0x3d5
#define CRTC_CURSOR_LO_REGISTER 0x0f
#define CRTC_CURSOR_HI_REGISTER 0x0e
enum VGA_COLOR {
VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
VGA_COLOR_GREEN = 2,
VGA_COLOR_CYAN = 3,
VGA_COLOR_RED = 4,
VGA_COLOR_MAGENTA = 5,
VGA_COLOR_BROWN = 6,
VGA_COLOR_LIGHT_GREY = 7,
VGA_COLOR_DARK_GREY = 8,
VGA_COLOR_LIGHT_BLUE = 9,
VGA_COLOR_LIGHT_GREEN = 10,
VGA_COLOR_LIGHT_CYAN = 11,
VGA_COLOR_LIGHT_RED = 12,
VGA_COLOR_LIGHT_MAGENTA = 13,
VGA_COLOR_LIGHT_BROWN = 14,
VGA_COLOR_WHITE = 15
};
/**
* @brief Gets the text-mode cursor's position.
*
* @return The position, not offset, of the cursor. Multiply this by two for the offset.
*/
uint16_t get_cursor_pos();
/**
* @brief Sets the cursor's position in VGA text-mode.
*
* @param pos The position, not offset, of the cursor. Multiply by two for the offset.
*/
void set_cursor_pos(uint16_t pos);
/**
* @brief Clears the screen in VGA text-mode by overwriting every character with a zero, then resets the cursor position.
*/
void clear_screen(void);
void vga_putc(char c);
void popchar();
void set_color(enum VGA_COLOR col);
#endif