diff --git a/src/console.c b/src/console.c index cb4a29f..2da505f 100644 --- a/src/console.c +++ b/src/console.c @@ -3,35 +3,6 @@ #include "stdlib.h" #include "asm.h" -static unsigned short *const console_buffer = (unsigned short*)0xB8000; - -static const unsigned int console_width = 80; -static const unsigned int console_height = 25; - -static unsigned int console_row; -static unsigned int console_column; - -static unsigned char console_color; - -static unsigned char vga_entry_color(enum vga_color fg, enum vga_color bg); -static unsigned short vga_entry(unsigned char uc, unsigned char color); -static void console_putentryat(char c, unsigned char color, unsigned int x, unsigned int y); - -static void console_scroll(); - -void console_initialize() { - console_row = 0; - console_column = 0; - console_color = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK); - - for (unsigned int y = 0; y < console_height; y++) { - for (unsigned int x = 0; x < console_width; x++) { - const unsigned int index = y * console_width + x; - console_buffer[index] = vga_entry(' ', console_color); - } - } -} - void console_print(const char *const s) { console_write(s, kstrlen(s)); @@ -39,28 +10,6 @@ void console_print(const char *const s) void console_putc(const char c) { outportb(0x3F8, c); - - if (c == '\n') { - console_column = 0; - - if (++console_row >= console_height) { - console_row = console_height - 1; - console_scroll(); - } - - return; - } - - console_putentryat(c, console_color, console_column, console_row); - - if (++console_column >= console_width) { - console_column = 0; - - if (++console_row >= console_height) { - console_row = console_height - 1; - console_scroll(); - } - } } void console_puts(const char *const s) @@ -69,38 +18,8 @@ void console_puts(const char *const s) console_putc('\n'); } -void console_setcolor(const unsigned char color) { - console_color = color; -} - void console_write(const char *const data, const unsigned int size) { for (unsigned int i = 0; i < size; i++) { console_putc(data[i]); } } - -unsigned char vga_entry_color(enum vga_color fg, enum vga_color bg) { - return fg | bg << 4; -} - -unsigned short vga_entry(unsigned char uc, unsigned char color) { - return (unsigned short) uc | (unsigned short) color << 8; -} - -void console_putentryat(char c, unsigned char color, unsigned int x, unsigned int y) { - const unsigned int index = y * console_width + x; - console_buffer[index] = vga_entry(c, color); -} - -void console_scroll() -{ - for (unsigned int row = 1; row < console_height; ++row) { - for (unsigned int col = 0; col < console_width; ++col) { - console_buffer[(row - 1) * console_width + col] = console_buffer[row * console_width + col]; - } - } - - for(unsigned int col = 0; col < console_width; ++col) { - console_buffer[(console_height - 1) * console_width + col] = ' '; - } -} diff --git a/src/console.h b/src/console.h index a19cdf0..e4f75f5 100644 --- a/src/console.h +++ b/src/console.h @@ -1,32 +1,9 @@ #ifndef KERNELMQ_INCLUDED_CONSOLE #define KERNELMQ_INCLUDED_CONSOLE 1 -// 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, -}; - -void console_initialize(); - void console_print(const char *s); void console_putc(char c); void console_puts(const char *s); -void console_setcolor(unsigned char color); void console_write(const char *data, unsigned int size); #endif diff --git a/src/init.c b/src/init.c index dd4c58b..40df7c8 100644 --- a/src/init.c +++ b/src/init.c @@ -1,4 +1,3 @@ -#include "console.h" #include "panic.h" #include "pfa.h" #include "protected.h" @@ -12,8 +11,6 @@ static struct KernelMQ_Info kinfo; void init(const struct KernelMQ_Info *const kinfo_ptr) { - console_initialize(); - kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info)); assert(kernelmq_info_validate_and_copy(&kinfo, kinfo_ptr), "Invalid kernel information."); diff --git a/src/logger.c b/src/logger.c index efbc764..c44d1b0 100644 --- a/src/logger.c +++ b/src/logger.c @@ -6,13 +6,6 @@ #define LEVELS_COUNT 4 -static const enum vga_color level_colors[LEVELS_COUNT] = { - VGA_COLOR_DARK_GREY, - VGA_COLOR_CYAN, - VGA_COLOR_MAGENTA, - VGA_COLOR_RED, -}; - static const char *const level_text[LEVELS_COUNT] = { "DBUG", "INFO", @@ -35,16 +28,11 @@ void logger_log(unsigned char level, const char *const source, const char *forma char buf[20]; arg++; - unsigned char color = VGA_COLOR_WHITE; - while ((c = *format++) != 0) { - console_setcolor(color); - if (c == '\n') { console_putc('\n'); print_prefix(level, source); - color = VGA_COLOR_LIGHT_GREY; } else if (c != '%') { console_putc(c); @@ -95,19 +83,12 @@ string: void print_prefix(const unsigned char level, const char *const source) { - console_setcolor(VGA_COLOR_LIGHT_GREY); console_putc('['); - - console_setcolor(level_colors[level]); console_print(level_text[level]); - - console_setcolor(VGA_COLOR_LIGHT_GREY); console_putc(']'); - console_putc(' '); if (source) { - console_setcolor(VGA_COLOR_BROWN); console_print(source); console_print(": "); }