implements the PIT

This commit is contained in:
2025-06-08 13:22:09 -04:00
parent c6cc318c69
commit ac3dc4d48a
4 changed files with 26 additions and 4 deletions

View File

@ -6,6 +6,7 @@
#include <kernel/_kernel.h>
#include <kernel/x86/idt.h>
#include <kernel/x86/pic.h>
#include <kernel/x86/pit.h>
#include <kernel/x86/io.h>
#include <kernel/x86/keyb.h>
@ -16,8 +17,7 @@ static idtr_t idtr;
static bool vectors[IDT_MAX_DESCRIPTORS];
extern struct keyboard_state keyb_state;
extern struct pit_state pit;
#define EXTERNAL_BIT (0x1)
@ -229,6 +229,10 @@ void exception_handler(struct cpu_state __attribute__((unused)) cpu, uint32_t in
/** EXCEPTIONS END **/
/** PIC BEGIN **/
case PIC_PIT:
pit.interrupts++;
PIC_sendEOI(0);
break;
case PIC_KEYB:
inbyte = inb(0x60);
do_keypress(decode_scancode(inbyte));
@ -276,6 +280,7 @@ void idt_init(void)
PIC_remap(0x20, 0x28);
pic_disable(); // mask everything
IRQ_clear_mask(0);
IRQ_clear_mask(1);
__asm__ volatile("sti"); // set the interrupt flag