diff --git a/kernel/idt.c b/kernel/idt.c index e352010..72adcbb 100644 --- a/kernel/idt.c +++ b/kernel/idt.c @@ -17,16 +17,16 @@ __attribute__((aligned(16))) static idt_entry IDT[IDT_MAX_DESCS]; static idtr IDTR; -void exception_handler() { +void interupt_handler(uint interupt) { uint* exc_ptr = 0xe222; uint8 exc = *exc_ptr; - pic_send_eoi(exc); + pic_send_eoi(interupt); char* buf; set_cursor_pos(0, 0); print("[exc] ", EXC_COLOR); - buf = itoa(exc, buf, 10); + buf = itoa(interupt, buf, 10); print(buf, 0x0c); } @@ -52,9 +52,10 @@ void idt_init() { idt_set_desc(idx, isr_stub_table[idx], 0x8e); + /* outb_w(PIC1, 0xfd); outb_w(PIC2, 0xfd); + */ __asm__ __volatile__("lidt %0" : : "m"(IDTR)); - - //__asm__ __volatile__("sti"); + __asm__ __volatile__("sti"); } diff --git a/kernel/idt.h b/kernel/idt.h index df1e639..b931ecc 100644 --- a/kernel/idt.h +++ b/kernel/idt.h @@ -5,7 +5,7 @@ #define EXC_COLOR 0x08 __attribute__((noreturn)) -void exception_handler(); +void interupt_handler(uint); void idt_set_desc(uint8, void*, uint8); void idt_init(); diff --git a/kernel/isr.asm b/kernel/isr.asm index 8d789e1..12a8942 100644 --- a/kernel/isr.asm +++ b/kernel/isr.asm @@ -2,23 +2,31 @@ isr_debug_ptr equ 0xe222 %macro isr_err_stub 1 isr_stub_%+%1: - mov [isr_debug_ptr], byte %1 - call exception_handler - hlt cli + pusha + push dword %1 + call interupt_handler + pop eax + popa + ;hlt + sti iret %endmacro %macro isr_no_err_stub 1 isr_stub_%+%1: - mov [isr_debug_ptr], byte %1 - call exception_handler - hlt cli + pusha + push dword %1 + call interupt_handler + pop eax + popa + ;hlt + sti iret %endmacro -extern exception_handler +extern interupt_handler isr_err_stub 0 isr_err_stub 1 isr_no_err_stub 2 diff --git a/kernel/pic.c b/kernel/pic.c index efd7899..18bbb81 100644 --- a/kernel/pic.c +++ b/kernel/pic.c @@ -8,10 +8,6 @@ void pic_send_eoi(uint8 irq) { } void pic_remap(uint offset_1, uint offset_2) { - uint8 a1, a2; - a1 = inb(PIC1_DATA); - a2 = inb(PIC2_DATA); - // Start the init sequance outb_w(PIC1_CMD, ICW_INIT_MASK); @@ -26,9 +22,8 @@ void pic_remap(uint offset_1, uint offset_2) { outb_w(PIC1_DATA, ICW4_8086); outb_w(PIC2_DATA, ICW4_8086); - // restore old masks - outb(PIC1_DATA, a1); - outb(PIC2_DATA, a2); + outb(PIC1_DATA, 0xff); + outb(PIC2_DATA, 0xff); } // disable the PIC @@ -44,7 +39,7 @@ void pic_init() { } // (un)set a specific irq -void irq(uint8 idx, bool t) { +void irq_mask(uint8 idx, bool t) { uint16 port; uint8 data; diff --git a/kernel/pic.h b/kernel/pic.h index 3d3a691..f4ff743 100644 --- a/kernel/pic.h +++ b/kernel/pic.h @@ -40,7 +40,7 @@ void pic_disable(); void pic_init(); // IRQs -void irq(uint8, bool); +void irq_mask(uint8, bool); static uint16 irq_reg(int ocw3); uint16 get_irr();