add: pic work

This commit is contained in:
Starnakin 2024-10-09 16:09:45 +02:00
parent a4411b0581
commit f3db3060af
2 changed files with 12 additions and 9 deletions

View File

@ -53,6 +53,9 @@ void irq_handler(void)
int8_t index = -1;
__asm__ volatile("movb %%bl, %0" ::"m"(index));
pic_send_eoi(NTMFDP);
kpanic("cramptés\n");
if (index == 0) {
pic_send_eoi(index);
return;
}
kpanic("%d\n", index);
}

View File

@ -5,6 +5,7 @@
#include "apic.h"
#include "gdt.h"
#include "idt.h"
#include "kprintf.h"
#define PIC1 0x20 /* IO base address for master PIC */
#define PIC2 0xA0 /* IO base address for slave PIC */
@ -37,13 +38,12 @@ void init_idt(void)
idtr.offset = (uintptr_t)&idt_entries[0];
idtr.size = (uint16_t)sizeof(struct idt_entry) * IDT_SIZE - 1;
for (uint8_t i = 0; i < 32; i++)
uint8_t i;
for (i = 0; i < 32; i++)
idt_set_descriptor(i, isr_stub_table[i], 0x8E);
for (uint8_t i = 32; i < 48; i++)
idt_set_descriptor(i, irq_stub_table[i], 0x8E);
load_idt(&idtr);
// https://wiki.osdev.org/8259_PIC#Programming_with_the_8259_PIC
pic_remap(0x20, 0x28);
pic_disable();
enable_apic();
for (uint8_t j = 0; j < 16; j++)
idt_set_descriptor(i + j, irq_stub_table[j], 0x8E);
load_idt(&idtr);
asm volatile("sti");
}