summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arch/generic.h2
-rw-r--r--src/arch/i386/boot.c7
-rw-r--r--src/arch/i386/interrupts/isr.c6
-rw-r--r--src/arch/i386/log.c6
-rw-r--r--src/arch/i386/tty.h2
-rw-r--r--src/arch/log.h7
-rw-r--r--src/kernel/main.c8
-rw-r--r--src/kernel/panic.h7
8 files changed, 29 insertions, 16 deletions
diff --git a/src/arch/generic.h b/src/arch/generic.h
index 7807316..f9617ab 100644
--- a/src/arch/generic.h
+++ b/src/arch/generic.h
@@ -1,5 +1,7 @@
#pragma once
+#include <arch/log.h>
+
// i have no idea where else to put it
#define PAGE_SIZE 4096
diff --git a/src/arch/i386/boot.c b/src/arch/i386/boot.c
index b2b84f0..37e1aff 100644
--- a/src/arch/i386/boot.c
+++ b/src/arch/i386/boot.c
@@ -1,3 +1,4 @@
+#include <arch/generic.h>
#include <arch/i386/gdt.h>
#include <arch/i386/interrupts/idt.h>
#include <arch/i386/sysenter.h>
@@ -6,11 +7,11 @@
void kmain_early() {
tty_clear();
- tty_const("gdt...");
+ log_const("gdt...");
gdt_init();
- tty_const("idt...");
+ log_const("idt...");
idt_init();
- tty_const("sysenter...");
+ log_const("sysenter...");
sysenter_setup();
kmain();
}
diff --git a/src/arch/i386/interrupts/isr.c b/src/arch/i386/interrupts/isr.c
index 03399ea..1603fba 100644
--- a/src/arch/i386/interrupts/isr.c
+++ b/src/arch/i386/interrupts/isr.c
@@ -1,5 +1,5 @@
#include <arch/i386/interrupts/isr.h>
-#include <arch/i386/tty.h>
+#include <arch/log.h>
#include <kernel/panic.h>
#include <stdbool.h>
#include <stdint.h>
@@ -8,13 +8,13 @@ bool isr_test_interrupt_called = false;
__attribute__((interrupt))
void isr_double_fault(struct interrupt_frame *frame) {
- tty_const("#DF");
+ log_const("#DF");
panic();
}
__attribute__((interrupt))
void isr_general_protection_fault(struct interrupt_frame *frame) {
- tty_const("#GP");
+ log_const("#GP");
panic();
}
diff --git a/src/arch/i386/log.c b/src/arch/i386/log.c
new file mode 100644
index 0000000..fc82023
--- /dev/null
+++ b/src/arch/i386/log.c
@@ -0,0 +1,6 @@
+#include <arch/i386/tty.h>
+#include <arch/log.h>
+
+void log_write(const char *buf, size_t len) {
+ tty_write(buf, len);
+}
diff --git a/src/arch/i386/tty.h b/src/arch/i386/tty.h
index 3dc1525..cbb8efc 100644
--- a/src/arch/i386/tty.h
+++ b/src/arch/i386/tty.h
@@ -4,5 +4,3 @@
void tty_putchar(char c);
void tty_write(const char *buf, size_t len);
void tty_clear();
-
-#define tty_const(str) tty_write(str, sizeof(str) - 1)
diff --git a/src/arch/log.h b/src/arch/log.h
new file mode 100644
index 0000000..6365c20
--- /dev/null
+++ b/src/arch/log.h
@@ -0,0 +1,7 @@
+#pragma once
+#include <stddef.h>
+
+void log_write(const char *buf, size_t len);
+
+// used for static strings
+#define log_const(str) log_write(str, sizeof(str) - 1)
diff --git a/src/kernel/main.c b/src/kernel/main.c
index aa67d7c..d2d7dda 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -6,17 +6,17 @@
void r3_test();
void kmain() {
- tty_const("mem...");
+ log_const("mem...");
mem_init();
- tty_const("creating process...");
+ log_const("creating process...");
struct process *proc = process_new(r3_test);
- tty_const("switching...");
+ log_const("switching...");
process_switch(proc);
}
void r3_test() {
- tty_const("ok");
+ log_const("ok");
asm("cli");
panic();
}
diff --git a/src/kernel/panic.h b/src/kernel/panic.h
index 54a0b8b..12d26fd 100644
--- a/src/kernel/panic.h
+++ b/src/kernel/panic.h
@@ -1,14 +1,13 @@
#pragma once
#include <arch/generic.h>
-#include <arch/i386/tty.h> // TODO abstract away
// dumb c shit
#define panic_tostr2(x) #x
#define panic_tostr(x) panic_tostr2(x)
#define panic() do { \
- tty_const(" PANIC! at the "); \
- tty_const(__func__); \
- tty_const(" (" __FILE__ ":" panic_tostr(__LINE__) ") "); \
+ log_const(" PANIC! at the "); \
+ log_const(__func__); \
+ log_const(" (" __FILE__ ":" panic_tostr(__LINE__) ") "); \
halt_cpu(); \
} while (0)