Add printf, gdb support, fix gdt
diff --git a/src/log.c b/src/log.c
new file mode 100644
index 0000000..19959e7
--- /dev/null
+++ b/src/log.c
@@ -0,0 +1,63 @@
+#include "log.h"
+#include "kint.h"
+#include "vga.h"
+#include "stdarg.h"
+
+void kprintf(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+
+ while (*format)
+ {
+ if (*format == '%')
+ {
+ format++;
+
+ switch (*format)
+ {
+ case 'd':
+ {
+ uint x = (uint) va_arg(args, uint);
+ vga_putd(x);
+ break;
+ }
+
+ case 'x':
+ {
+ // consider hex always unsigned
+ uint x = (uint) va_arg(args, uint);
+ vga_putx(x);
+ break;
+ }
+
+ case 's':
+ {
+ char *s = va_arg(args, char *);
+ vga_write(s);
+ break;
+ }
+ }
+ format++;
+ }
+ else
+ {
+ vga_put(*format);
+ format++;
+ }
+ }
+
+ va_end(args);
+}
+
+void kassert_int(bool condition, const char *message, const char *file, const int line)
+{
+ if (!condition)
+ {
+ vga_set_color(LIGHT_RED, BLACK);
+ kprintf("ASSERTION FAILED: %s:%d\n%s\n", file, line, message);
+
+ while (1)
+ {}
+ }
+}