Add colors for debug output and todo and panic functions
This commit is contained in:
parent
472a220b40
commit
d083a9ef7c
|
@ -12,5 +12,7 @@ int dbgf(const char *restrict format, ...);
|
||||||
int warn(const char *restrict format, ...);
|
int warn(const char *restrict format, ...);
|
||||||
int error(const char *restrict format, ...);
|
int error(const char *restrict format, ...);
|
||||||
int fixme(const char *restrict format, ...);
|
int fixme(const char *restrict format, ...);
|
||||||
|
int todo(const char *restrict format, ...);
|
||||||
|
void panic(const char *restrict format, ...);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,4 +9,6 @@ void kernel_main() {
|
||||||
warn("test warning debug %d\n", 42);
|
warn("test warning debug %d\n", 42);
|
||||||
error("test error debug %d\n", 42);
|
error("test error debug %d\n", 42);
|
||||||
fixme("test fixme debug %d\n", 42);
|
fixme("test fixme debug %d\n", 42);
|
||||||
|
todo("test todo debug %d\n", 42);
|
||||||
|
panic("test panic\n");
|
||||||
}
|
}
|
||||||
|
|
30
src/serial.c
30
src/serial.c
|
@ -1,6 +1,7 @@
|
||||||
#include <serial.h>
|
#include <serial.h>
|
||||||
#include <asm.h>
|
#include <asm.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <vga.h>
|
||||||
|
|
||||||
int serial_init() {
|
int serial_init() {
|
||||||
outb(PORT + 1, 0x00); // Disable all interrupts
|
outb(PORT + 1, 0x00); // Disable all interrupts
|
||||||
|
@ -58,7 +59,7 @@ int warn(const char *restrict format, ...) {
|
||||||
int size;
|
int size;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
dbgf("WARNING: ");
|
dbgf("\033[1;33mWARNING:\033[0m ");
|
||||||
size = vdbgf(format, ap);
|
size = vdbgf(format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return size;
|
return size;
|
||||||
|
@ -68,7 +69,7 @@ int error(const char *restrict format, ...) {
|
||||||
int size;
|
int size;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
dbgf("ERROR: ");
|
dbgf("\033[1;31mERROR:\033[0m ");
|
||||||
size = vdbgf(format, ap);
|
size = vdbgf(format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return size;
|
return size;
|
||||||
|
@ -78,8 +79,31 @@ int fixme(const char *restrict format, ...) {
|
||||||
int size;
|
int size;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
dbgf("FIXME: ");
|
dbgf("\033[32mFIXME:\033[0m ");
|
||||||
size = vdbgf(format, ap);
|
size = vdbgf(format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return size;
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue