diff options
Diffstat (limited to 'src/kernel/system.c')
-rw-r--r-- | src/kernel/system.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/kernel/system.c b/src/kernel/system.c new file mode 100644 index 0000000..b0ad429 --- /dev/null +++ b/src/kernel/system.c @@ -0,0 +1,52 @@ +#ifndef MELVIX_SYSTEM_H +#define MELVIX_SYSTEM_H + +#include "timer/timer.h" +#include "io/io.h" +#include "graphics/vesa.h" +#include "system.h" + +void kernel_time() { + vesa_draw_string("\n"); + vesa_draw_string("["); + vesa_draw_number(get_time()); + vesa_draw_string("] "); +} + +void info(char *msg) { + // terminal_set_color(9); + kernel_time(); + vesa_draw_string("INFO: "); + vesa_draw_string(msg); + vesa_draw_string("\n"); + // terminal_set_color(7); +} + +void warn(char *msg) { + // terminal_set_color(6); + kernel_time(); + vesa_draw_string("WARNING: "); + vesa_draw_string(msg); + vesa_draw_string("\n"); + // terminal_set_color(7); +} + +void panic(char *msg) { + asm volatile ("cli"); + // terminal_set_color(4); + kernel_time(); + serial_write("PANIC: "); + serial_write(msg); + serial_write(" - System Halted!\n"); + loop: + asm volatile ("hlt"); + goto loop; +} + +void assert(int x) { + if (x == 0) { + panic("Assertion failed"); + } +} + +#endif |