From 41bfd1f8997faad827d811dd29dc3e7e81111c64 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Mon, 18 Apr 2022 23:52:13 +0200 Subject: [PATCH] Stuff --- kernel/idt.c | 4 ++-- kernel/idt.h | 2 +- kernel/isr.asm | 2 +- kernel/kernel.c | 7 +++++-- kernel/pic.c | 5 +++++ kernel/pic.h | 1 + 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/kernel/idt.c b/kernel/idt.c index ef9937b..5c00ea5 100644 --- a/kernel/idt.c +++ b/kernel/idt.c @@ -23,10 +23,10 @@ void exception_handler() { char* buf; - print("[exc] ", INT_COLOR); + print("[exc] ", EXC_COLOR); buf = itoa(debug, buf, 10); - println(buf, 0x0f); + println(buf, 0x0c); __asm__ __volatile__("cli; hlt"); } diff --git a/kernel/idt.h b/kernel/idt.h index f66c3ed..34cddf6 100644 --- a/kernel/idt.h +++ b/kernel/idt.h @@ -1,7 +1,7 @@ #include "../lib/types.h" #define IDT_MAX_DESCS 256 -#define INT_COLOR 0x08 +#define EXC_COLOR 0x08 __attribute__((noreturn)) void exception_handler(); diff --git a/kernel/isr.asm b/kernel/isr.asm index 2bd44f0..42c30c4 100644 --- a/kernel/isr.asm +++ b/kernel/isr.asm @@ -10,7 +10,7 @@ isr_stub_%+%1: %macro isr_no_err_stub 1 isr_stub_%+%1: mov [isr_debug_ptr], byte %1 - ;call exception_handler + call exception_handler iret %endmacro diff --git a/kernel/kernel.c b/kernel/kernel.c index 2edff12..11d6bb5 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -54,6 +54,7 @@ void print_kernel_stats() { } void kernel_init() { + pic_init(); // Init the PIC and remap it idt_init(); // Enable interupts vga_init(); // Initialize the screen @@ -61,11 +62,11 @@ void kernel_init() { pm_malloc_range(VGA_ADDRESS, VGA_ADDRESS_MAX, true); // force alloc the VGA range // ENABLE PAGING // TODO: make this work - // enable_paging(); + //enable_paging(); clear_screen(); print_kernel_motd(); - print_kernel_stats(); + //print_kernel_stats(); char* buf; uint i = 0; @@ -77,4 +78,6 @@ void kernel_init() { printalign(buf, 0x0f, MIDDLE); ++i; } + + while(true) { __asm__("hlt"); } // never escape this function } diff --git a/kernel/pic.c b/kernel/pic.c index 3e5c072..879175b 100644 --- a/kernel/pic.c +++ b/kernel/pic.c @@ -38,6 +38,11 @@ void pic_disable() { outb(PIC2_DATA, 0xff); } + +void pic_init() { + pic_remap(PIC1, PIC2); +} + // (un)set a specific irq void irq(uint8 idx, bool t) { uint16 port; diff --git a/kernel/pic.h b/kernel/pic.h index 27d1017..3d3a691 100644 --- a/kernel/pic.h +++ b/kernel/pic.h @@ -37,6 +37,7 @@ void pic_send_eoi(uint8); void pic_remap(uint, uint); void pic_disable(); +void pic_init(); // IRQs void irq(uint8, bool);