From 5d4180c67cea08bb76eebde6b41b8935e60fed98 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 26 Oct 2019 22:15:29 +0200 Subject: Improved VESA and fixed warnings --- src/kernel/system.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/kernel/system.c (limited to 'src/kernel/system.c') 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 -- cgit v1.2.3