summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordzwdz2021-08-09 21:21:56 +0200
committerdzwdz2021-08-09 21:21:56 +0200
commitab1843f5de80752ba40fb1ea5075eb7e3dad8171 (patch)
tree9c01d71eef5abc6c5d66c1110e8a7c6ccb0c0281 /src
parent5836c7df10d48b9c3241f2fbdb9ea3a37313a6fd (diff)
rename `log_` to `tty_`, `tty_` to `vga_`
Diffstat (limited to 'src')
-rw-r--r--src/kernel/arch/i386/boot.c11
-rw-r--r--src/kernel/arch/i386/interrupts/isr.c6
-rw-r--r--src/kernel/arch/i386/tty/log.c6
-rw-r--r--src/kernel/arch/i386/tty/tty.c10
-rw-r--r--src/kernel/arch/i386/tty/vga.c12
-rw-r--r--src/kernel/arch/i386/tty/vga.h6
-rw-r--r--src/kernel/arch/log.h11
-rw-r--r--src/kernel/main.c10
-rw-r--r--src/kernel/panic.h6
-rw-r--r--src/kernel/syscalls.c6
-rw-r--r--src/kernel/tests/base.h2
11 files changed, 44 insertions, 42 deletions
diff --git a/src/kernel/arch/i386/boot.c b/src/kernel/arch/i386/boot.c
index e782246..522361e 100644
--- a/src/kernel/arch/i386/boot.c
+++ b/src/kernel/arch/i386/boot.c
@@ -3,7 +3,6 @@
#include <kernel/arch/i386/interrupts/idt.h>
#include <kernel/arch/i386/multiboot.h>
#include <kernel/arch/i386/sysenter.h>
-#include <kernel/arch/i386/tty/vga.h>
#include <kernel/main.h>
#include <kernel/panic.h>
@@ -11,18 +10,18 @@ void kmain_early(struct multiboot_info *multiboot) {
struct kmain_info info;
// setup some basic stuff
- tty_clear();
- log_const("gdt...");
+ tty_init();
+ tty_const("gdt...");
gdt_init();
- log_const("idt...");
+ tty_const("idt...");
idt_init();
- log_const("sysenter...");
+ tty_const("sysenter...");
sysenter_setup();
{ // find the init module
struct multiboot_mod *module = &multiboot->mods[0];
if (multiboot->mods_count < 1) {
- log_const("can't find init! ");
+ tty_const("can't find init! ");
panic();
}
info.init.at = module->start;
diff --git a/src/kernel/arch/i386/interrupts/isr.c b/src/kernel/arch/i386/interrupts/isr.c
index 800bdba..96d053e 100644
--- a/src/kernel/arch/i386/interrupts/isr.c
+++ b/src/kernel/arch/i386/interrupts/isr.c
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <stdint.h>
-#define log_n_panic(x) {log_const(x); panic();}
+#define log_n_panic(x) {tty_const(x); panic();}
bool isr_test_interrupt_called = false;
@@ -18,8 +18,6 @@ void isr_stage3(int interrupt) {
isr_test_interrupt_called = true;
return;
- default:
- log_const("unknown interrupt");
- panic();
+ default: log_n_panic("unknown interrupt");
}
}
diff --git a/src/kernel/arch/i386/tty/log.c b/src/kernel/arch/i386/tty/log.c
deleted file mode 100644
index 1a2d874..0000000
--- a/src/kernel/arch/i386/tty/log.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <kernel/arch/i386/tty/vga.h>
-#include <kernel/arch/log.h>
-
-void log_write(const char *buf, size_t len) {
- tty_write(buf, len);
-}
diff --git a/src/kernel/arch/i386/tty/tty.c b/src/kernel/arch/i386/tty/tty.c
new file mode 100644
index 0000000..670dd5b
--- /dev/null
+++ b/src/kernel/arch/i386/tty/tty.c
@@ -0,0 +1,10 @@
+#include <kernel/arch/i386/tty/vga.h>
+#include <kernel/arch/log.h>
+
+void tty_init() {
+ vga_clear();
+}
+
+void tty_write(const char *buf, size_t len) {
+ vga_write(buf, len);
+}
diff --git a/src/kernel/arch/i386/tty/vga.c b/src/kernel/arch/i386/tty/vga.c
index db4b47f..0acf1cb 100644
--- a/src/kernel/arch/i386/tty/vga.c
+++ b/src/kernel/arch/i386/tty/vga.c
@@ -9,24 +9,24 @@ static const size_t vga_len = 80 * 25;
static struct vga_cell *vga = (void*) 0xB8000;
static size_t vga_pos = 0;
-static void tty_scroll() {
+static void vga_scroll() {
for (size_t i = 0; i < vga_len - 80; i++)
vga[i] = vga[i + 80];
vga_pos -= 80;
}
-void tty_putchar(char c) {
+void vga_putchar(char c) {
if (vga_pos >= vga_len - 80)
- tty_scroll();
+ vga_scroll();
vga[vga_pos++].c = c;
}
-void tty_write(const char *buf, size_t len) {
+void vga_write(const char *buf, size_t len) {
for (size_t i = 0; i < len; i++)
- tty_putchar(buf[i]);
+ vga_putchar(buf[i]);
}
-void tty_clear() {
+void vga_clear() {
for (size_t i = 0; i < vga_len; i++)
vga[i].c = ' ';
vga_pos = 0;
diff --git a/src/kernel/arch/i386/tty/vga.h b/src/kernel/arch/i386/tty/vga.h
index cbb8efc..f2e3ff9 100644
--- a/src/kernel/arch/i386/tty/vga.h
+++ b/src/kernel/arch/i386/tty/vga.h
@@ -1,6 +1,6 @@
#pragma once
#include <stddef.h>
-void tty_putchar(char c);
-void tty_write(const char *buf, size_t len);
-void tty_clear();
+void vga_putchar(char c);
+void vga_write(const char *buf, size_t len);
+void vga_clear();
diff --git a/src/kernel/arch/log.h b/src/kernel/arch/log.h
index 0a5d5a0..fbef7a5 100644
--- a/src/kernel/arch/log.h
+++ b/src/kernel/arch/log.h
@@ -1,9 +1,10 @@
#pragma once
#include <stddef.h>
-void log_write(const char *buf, size_t len);
+void tty_init();
+void tty_write(const char *buf, size_t len);
-inline void log_hex(const char *buf, size_t len) {
+inline void _tty_hex(const char *buf, size_t len) {
char hex[2];
for (size_t i = 0; i < len; i++) {
hex[0] = (buf[i] & 0xF0) >> 4;
@@ -16,13 +17,13 @@ inline void log_hex(const char *buf, size_t len) {
if (hex[1] > '9')
hex[1] += 'a' - '9' - 1;
- log_write(hex, 2);
+ tty_write(hex, 2);
}
}
// used for static strings
-#define log_const(str) log_write(str, sizeof(str) - 1)
+#define tty_const(str) tty_write(str, sizeof(str) - 1)
// very hacky, shouldn't be actually used - only for debugging
// prints backwards
-#define log_var_dont_use(var) log_hex((void*)&var, sizeof(var))
+#define _tty_var(var) tty_hex((void*)&var, sizeof(var))
diff --git a/src/kernel/main.c b/src/kernel/main.c
index effdd45..3fee5c9 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -17,20 +17,20 @@ static void run_init(struct kmain_info *info) {
true, true);
proc->regs.eip = (int) init_base;
- log_const("switching...");
+ tty_const("switching...");
process_switch(proc);
}
void kmain(struct kmain_info info) {
- log_const("\x03 ");
+ tty_const("\x03 ");
- log_const("mem...");
+ tty_const("mem...");
mem_init(&info);
- log_const("tests...");
+ tty_const("tests...");
tests_all();
- log_const("loading init...");
+ tty_const("loading init...");
run_init(&info);
panic();
diff --git a/src/kernel/panic.h b/src/kernel/panic.h
index 3f48c22..1e25a83 100644
--- a/src/kernel/panic.h
+++ b/src/kernel/panic.h
@@ -3,8 +3,8 @@
#include <kernel/util.h>
#define panic() do { \
- log_const(" PANIC! at the "); \
- log_const(__func__); \
- log_const(" (" __FILE__ ":" NUM2STR(__LINE__) ") "); \
+ tty_const(" PANIC! at the "); \
+ tty_const(__func__); \
+ tty_const(" (" __FILE__ ":" NUM2STR(__LINE__) ") "); \
halt_cpu(); \
} while (0)
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index ece21db..47f8b2b 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -11,7 +11,7 @@ _Noreturn void _syscall_exit(const char *msg, size_t len) {
if (process_current)
process_switch(process_current);
- log_const("last process returned. ");
+ tty_const("last process returned. ");
panic();
}
@@ -31,7 +31,7 @@ int _syscall_debuglog(const char *msg, size_t len) {
if (((uintptr_t)msg & PAGE_MASK) + len > PAGE_SIZE)
panic(); // just in case I made an off by 1 error
- log_write(phys, len);
+ tty_write(phys, len);
return len;
}
@@ -44,7 +44,7 @@ int syscall_handler(int num, int a, int b, int c) {
case _SYSCALL_DEBUGLOG:
return _syscall_debuglog((void*)a, b);
default:
- log_const("unknown syscall ");
+ tty_const("unknown syscall ");
panic();
}
}
diff --git a/src/kernel/tests/base.h b/src/kernel/tests/base.h
index 4c91d10..e08e59a 100644
--- a/src/kernel/tests/base.h
+++ b/src/kernel/tests/base.h
@@ -17,7 +17,7 @@ extern bool _did_tests_fail;
#define TEST_COND(cond) \
if (!(cond)) { \
_did_tests_fail = true; \
- log_const("test failed at " \
+ tty_const("test failed at " \
__FILE__ ":" NUM2STR(__LINE__) \
" "); \
}