diff options
Diffstat (limited to 'src/kernel/arch')
-rw-r--r-- | src/kernel/arch/i386/boot.c | 11 | ||||
-rw-r--r-- | src/kernel/arch/i386/interrupts/isr.c | 6 | ||||
-rw-r--r-- | src/kernel/arch/i386/tty/log.c | 6 | ||||
-rw-r--r-- | src/kernel/arch/i386/tty/tty.c | 10 | ||||
-rw-r--r-- | src/kernel/arch/i386/tty/vga.c | 12 | ||||
-rw-r--r-- | src/kernel/arch/i386/tty/vga.h | 6 | ||||
-rw-r--r-- | src/kernel/arch/log.h | 11 |
7 files changed, 32 insertions, 30 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)) |