From f3db3060af00f86d1cda3f83542831b626d4f36c Mon Sep 17 00:00:00 2001 From: Starnakin Date: Wed, 9 Oct 2024 16:09:45 +0200 Subject: [PATCH] add: pic work --- src/interrupt/handler.c | 7 +++++-- src/interrupt/idt.c | 14 +++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/interrupt/handler.c b/src/interrupt/handler.c index 94b2d07..87c8e9c 100644 --- a/src/interrupt/handler.c +++ b/src/interrupt/handler.c @@ -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); } diff --git a/src/interrupt/idt.c b/src/interrupt/idt.c index 7ddac7a..e8c6f74 100644 --- a/src/interrupt/idt.c +++ b/src/interrupt/idt.c @@ -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"); }