diff options
Diffstat (limited to '')
| -rw-r--r-- | kernel/drivers/vga_text_buffer.c (renamed from kernel/drivers/vga_text_buffer.cc) | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/kernel/drivers/vga_text_buffer.cc b/kernel/drivers/vga_text_buffer.c index 69b1fe3..47ccb76 100644 --- a/kernel/drivers/vga_text_buffer.cc +++ b/kernel/drivers/vga_text_buffer.c @@ -16,27 +16,20 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdbool.h> -#include <stddef.h> -#include <stdint.h> - #include <common.h> - +#include <drivers/vga_text_buffer.h> +#include <kernel/halt.h> +#include <kernel/io.h> #include <libk/stdio.h> #include <libk/string.h> - -#include <kernel/io.h> - -#include <drivers/vga_text_buffer.h> - -namespace VGATextBuffer -{ +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> static uint16_t *l_buffer = (uint16_t *) 0xB8000; static uint8_t l_row = 0; static uint8_t l_column = 0; -static uint8_t l_color = vga_entry_color(VGATextBuffer::COLOR_LIGHT_GREY, - VGATextBuffer::COLOR_BLACK); +static uint8_t l_color = VGA_ENTRY_COLOR(COLOR_LIGHT_GREY, COLOR_BLACK); ALWAYS_INLINE static void write_entry_at(const char c, @@ -45,11 +38,11 @@ write_entry_at(const char c, const uint8_t y) { size_t index = y * VGA_WIDTH + x; - l_buffer[index] = vga_entry(c, color); + l_buffer[index] = VGA_ENTRY(c, color); } void -initialize(void) +vgatb_initialize(void) { /* * Disable the cursor @@ -64,7 +57,7 @@ initialize(void) } void -write_char(const char c) +vgatb_write_char(const char c) { if (c == '\n') { l_row++; @@ -81,16 +74,19 @@ write_char(const char c) } void -write_string(const char *string) +vgatb_write_string(const char *string) { size_t size = strlen(string); for (size_t i = 0; i < size; i++) - write_char(string[i]); + vgatb_write_char(string[i]); } void -printf(const char *string, ...) +vgatb_printf(const char *string, ...) { + if (strlen(string) >= 256) + ASSERT_NOT_REACHED(); + /* TODO: Dynamic Memory Allocation */ char str[256]; @@ -99,7 +95,5 @@ printf(const char *string, ...) vsnprintf(str, sizeof(str), string, ap); va_end(ap); - write_string(str); -} - + vgatb_write_string(str); } |
