diff --git a/k/idt.c b/k/idt.c index 4c5cb73..9bbd243 100644 --- a/k/idt.c +++ b/k/idt.c @@ -1,8 +1,9 @@ #include "idt.h" -#include "stdio.h" -#include "pic/pic.h" #include "io.h" #include "pic/keyboard.h" +#include "pic/pic.h" +#include "pic/pit.h" +#include "stdio.h" static struct idt idt = { 0 }; @@ -25,17 +26,21 @@ static struct idt_entry_info infos[] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, // user-defined (32-255) - {0, INTERRUPT_TYPE}, {pic_keyboard, INTERRUPT_TYPE} + {pic_pit, INTERRUPT_TYPE}, {pic_keyboard, INTERRUPT_TYPE} }; void handle_interrupt(struct int_args *args) { - if (args->int_code >= 32) + switch (args->int_code) { - add_key_to_buffer(); - - outb(MASTER_PORT_A, OCW2_EOI); - return; + case 32: // PIT + pit_handler(); + outb(MASTER_PORT_A, OCW2_EOI); + return; + case 33: // keyboard + keyboard_handler(); + outb(MASTER_PORT_A, OCW2_EOI); + return; } printf("INTERRUPT: %d, error code: %d\r\n", args->int_code, args->err_code); diff --git a/k/isr.S b/k/isr.S index 5ca0fee..81fe440 100644 --- a/k/isr.S +++ b/k/isr.S @@ -48,4 +48,5 @@ ISR_NO_ERRCODE(int_xm, 19) ISR_NO_ERRCODE(int_ve, 20) // user-defined +ISR_NO_ERRCODE(pic_pit, 32) ISR_NO_ERRCODE(pic_keyboard, 33) diff --git a/k/isr.h b/k/isr.h index f0e9d9d..e537d67 100644 --- a/k/isr.h +++ b/k/isr.h @@ -24,6 +24,8 @@ void int_xm(void); // SIMD Floating-Point Exception void int_ve(void); // Virtualization Exception // ISR for PIC interrupts. + +void pic_pit(void); void pic_keyboard(void); #endif /* !ISR_H */