From 7ceec0ee063215f59ccfd6a931ff8ae6f3e98278 Mon Sep 17 00:00:00 2001 From: Julien CLEMENT Date: Mon, 26 Jul 2021 00:24:04 +0200 Subject: [PATCH] working on ocw2 Signed-off-by: Julien CLEMENT --- k/idt.c | 3 +++ k/pic.c | 10 ++++++++++ k/pic.h | 1 + 3 files changed, 14 insertions(+) diff --git a/k/idt.c b/k/idt.c index 90d4503..3ec5f32 100644 --- a/k/idt.c +++ b/k/idt.c @@ -43,6 +43,9 @@ static struct idt_entry_descriptor idt_entries_descriptors[IDT_NB_ENTRIES] = { void interrupt_handler(struct isr_param *isr_param) { printf("Oh no %d!\r\n", isr_param->int_vector); + if (isr_param->int_vector > IDT_RESERVED_ENTRIES + && isr_param->int_vector < IDT_RESERVED_ENTRIES + 16) + acknowledge(isr_param->int_vector); } struct idt_entry create_idt_entry(struct idt_entry_descriptor descriptor) diff --git a/k/pic.c b/k/pic.c index 6045094..e04d533 100644 --- a/k/pic.c +++ b/k/pic.c @@ -1,6 +1,7 @@ #include "idt.h" #include "io.h" #include "pic.h" +#include "stdio.h" static void send_icw1(void) { @@ -42,3 +43,12 @@ void init_pic(void) mask_irqs(); asm volatile("sti"); } + +void acknowledge(uint32_t int_vector) +{ + printf("acknowledging %d\r\n", int_vector); + uint8_t ocw2 = 0x20; + if (int_vector >= IDT_RESERVED_ENTRIES + 8) + outb(SLAVE_PIC_A, ocw2); + outb(MASTER_PIC_A, ocw2); +} diff --git a/k/pic.h b/k/pic.h index c5cb2d8..40b44cc 100644 --- a/k/pic.h +++ b/k/pic.h @@ -9,5 +9,6 @@ #define ICW1 0x11 void init_pic(void); +void acknowledge(uint32_t int_vector); #endif /* !PIC_H */