From d083a9ef7ca2989566fdc42bb660741e0c9be93c Mon Sep 17 00:00:00 2001 From: g1n Date: Thu, 10 Feb 2022 10:01:43 +0200 Subject: [PATCH] Add colors for debug output and todo and panic functions --- src/include/serial.h | 2 ++ src/kernel.c | 2 ++ src/serial.c | 30 +++++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/include/serial.h b/src/include/serial.h index 717aa35..e8d63fc 100644 --- a/src/include/serial.h +++ b/src/include/serial.h @@ -12,5 +12,7 @@ int dbgf(const char *restrict format, ...); int warn(const char *restrict format, ...); int error(const char *restrict format, ...); int fixme(const char *restrict format, ...); +int todo(const char *restrict format, ...); +void panic(const char *restrict format, ...); #endif diff --git a/src/kernel.c b/src/kernel.c index 4ede7ba..12f7aab 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -9,4 +9,6 @@ void kernel_main() { warn("test warning debug %d\n", 42); error("test error debug %d\n", 42); fixme("test fixme debug %d\n", 42); + todo("test todo debug %d\n", 42); + panic("test panic\n"); } diff --git a/src/serial.c b/src/serial.c index 80b3901..85912bf 100644 --- a/src/serial.c +++ b/src/serial.c @@ -1,6 +1,7 @@ #include #include #include +#include int serial_init() { outb(PORT + 1, 0x00); // Disable all interrupts @@ -58,7 +59,7 @@ int warn(const char *restrict format, ...) { int size; va_list ap; va_start(ap, format); - dbgf("WARNING: "); + dbgf("\033[1;33mWARNING:\033[0m "); size = vdbgf(format, ap); va_end(ap); return size; @@ -68,7 +69,7 @@ int error(const char *restrict format, ...) { int size; va_list ap; va_start(ap, format); - dbgf("ERROR: "); + dbgf("\033[1;31mERROR:\033[0m "); size = vdbgf(format, ap); va_end(ap); return size; @@ -78,8 +79,31 @@ int fixme(const char *restrict format, ...) { int size; va_list ap; va_start(ap, format); - dbgf("FIXME: "); + dbgf("\033[32mFIXME:\033[0m "); size = vdbgf(format, ap); va_end(ap); return size; } + +int todo(const char *restrict format, ...) { + int size; + va_list ap; + va_start(ap, format); + dbgf("\033[92mTODO:\033[0m "); + size = vdbgf(format, ap); + va_end(ap); + return size; +} + +// FIXME: maybe this function shouldn't be here +void panic(const char *restrict format, ...) { + va_list ap; + va_start(ap, format); + terminal_setcolor(VGA_COLOR_RED); + kprintf("PANIC: "); + terminal_setcolor(VGA_COLOR_LIGHT_GREY); + dbgf("\033[31mPANIC:\033[0m "); + kvprintf(format, ap); + vdbgf(format, ap); + va_end(ap); // FIXME: not return from this function +}