Add colors for debug output and todo and panic functions

This commit is contained in:
g1n 2022-02-10 10:01:43 +02:00
parent 472a220b40
commit d083a9ef7c
Signed by: g1n
GPG Key ID: 8D352193D65D4E2C
3 changed files with 31 additions and 3 deletions

View File

@ -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

View File

@ -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");
}

View File

@ -1,6 +1,7 @@
#include <serial.h>
#include <asm.h>
#include <stdio.h>
#include <vga.h>
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
}