From 5668d7cfc5bb05057c5368eceb2bbb8a6a45a8c3 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 26 Oct 2019 16:37:33 +0200 Subject: Removed VGA driver support --- src/kernel/graphics/vga.c | 162 ---------------------------------------------- 1 file changed, 162 deletions(-) delete mode 100644 src/kernel/graphics/vga.c (limited to 'src/kernel/graphics/vga.c') diff --git a/src/kernel/graphics/vga.c b/src/kernel/graphics/vga.c deleted file mode 100644 index a470af8..0000000 --- a/src/kernel/graphics/vga.c +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include -#include "../io/io.h" -#include "../lib/lib.h" -#include "../commands/command.h" -#include "../interrupts/interrupts.h" - -// Hardware text mode color constants -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, -}; - -inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) { - return fg | bg << 4; -} - -inline uint16_t vga_entry(unsigned char uc, uint8_t color) { - return (uint16_t) uc | (uint16_t) color << 8; -} - -static const size_t VGA_WIDTH = 80; -static const size_t VGA_HEIGHT = 25; - -size_t terminal_row; -size_t terminal_column; -uint8_t terminal_color; -uint16_t *terminal_buffer; - -char text[1024] = {0}; - -void terminal_clear() { - terminal_row = 0; - terminal_column = 0; - for (size_t y = 0; y < VGA_HEIGHT; y++) { - for (size_t x = 0; x < VGA_WIDTH; x++) { - const size_t index = y * VGA_WIDTH + x; - terminal_buffer[index] = vga_entry(' ', terminal_color); - } - } -} - -void terminal_enable_cursor(uint8_t cursor_start, uint8_t cursor_end) { - send_b(0x3D4, 0x0A); - send_b(0x3D5, (receive_b(0x3D5) & 0xC0) | cursor_start); - send_b(0x3D4, 0x0B); - send_b(0x3D5, (receive_b(0x3D5) & 0xE0) | cursor_end); -} - -void terminal_update_cursor(void) { - unsigned temp = terminal_row * VGA_WIDTH + terminal_column; - send_b(0x3D4, 14); - send_b(0x3D5, temp >> 8); - send_b(0x3D4, 15); - send_b(0x3D5, temp); -} - -void terminal_initialize(void) { - // terminal_enable_cursor(0, 15); - terminal_row = 0; - terminal_column = 0; - terminal_color = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK); - terminal_buffer = (uint16_t *) 0xB8000; - terminal_clear(); -} - -void terminal_scroll(void) { - if (terminal_row >= VGA_HEIGHT) { - terminal_row = VGA_HEIGHT - 1; - for (size_t x = 0; x < VGA_WIDTH; x++) - for (size_t y = 0; y < VGA_HEIGHT; y++) { - uint16_t c = terminal_buffer[y * VGA_WIDTH + x]; - terminal_buffer[(y - 1) * VGA_WIDTH + x] = c; - terminal_buffer[y * VGA_WIDTH + x] = vga_entry(' ', terminal_color); - } - } -} - -void terminal_set_color(uint8_t color) { - terminal_color = color; -} - -void terminal_put_entry_at(char c, uint8_t color, size_t x, size_t y) { - // const size_t index = y * VGA_WIDTH + x; - // terminal_buffer[index] = vga_entry(c, color); -} - -void terminal_put_char(char c) { - if (c == 0x08) { - if (terminal_column != 0) terminal_column--; - } else if (c == 0x09) { - terminal_column = (terminal_column + 8) & ~(8 - 1); - } else if (c == '\r') { - terminal_column = 0; - } else if (c == '\n') { - terminal_row++; - terminal_column = 0; - // terminal_scroll(); - } else if (c >= ' ') { // Any printable character - // terminal_put_entry_at(c, terminal_color, terminal_column, terminal_row); - terminal_column++; - } - - // Add new line on overflow - if (terminal_column >= VGA_WIDTH) { - terminal_column = 0; - terminal_row++; - } - - // terminal_scroll(); - // terminal_update_cursor(); -} - -void terminal_write(const char *data, size_t size) { - for (size_t i = 0; i < size; i++) - terminal_put_char(data[i]); -} - -void terminal_put_keyboard_char(char c) { - terminal_put_char(c); - if (c == '\n' && irq_is_installed(1)) { - // exec_command(text); - // memory_set(text, 0, sizeof(text)); - terminal_column = 0; - terminal_row++; - // terminal_scroll(); - terminal_put_entry_at('$', terminal_color, terminal_column, terminal_row); - terminal_column = 2; - // terminal_update_cursor(); - } else if (c >= ' ' && irq_is_installed(1)) strcat(text, &c); -} - -void terminal_write_string(const char *data) { - // terminal_write(data, strlen(data)); - serial_write(data); -} - -void terminal_write_number(int data) { - serial_write_dec(data); - // terminal_write(converted, strlen(converted)); -} - -void terminal_write_line(const char *data) { - serial_write(data); - terminal_column = 0; - // terminal_write_string(data); - terminal_column = 0; -} -- cgit v1.2.3