aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/system.c
diff options
context:
space:
mode:
authorMarvin Borner2019-10-26 22:15:29 +0200
committerMarvin Borner2019-10-26 22:15:29 +0200
commit5d4180c67cea08bb76eebde6b41b8935e60fed98 (patch)
tree1f3bd2be8e20dc754dcc73af36684fdc3642d7ba /src/kernel/system.c
parentb2cf27bb1d8239a7ccc55c29df996370c8f1bed6 (diff)
Improved VESA and fixed warnings
Diffstat (limited to 'src/kernel/system.c')
-rw-r--r--src/kernel/system.c52
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