From ef2a7507b7110e71fa33e0cff499fec7a8de7e7c Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Mon, 6 Nov 2017 10:32:46 +0000 Subject: [PATCH] Some refactoring --- arch/pic.c | 6 +++--- arch/pic.h | 2 +- arch/protected.c | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/pic.c b/arch/pic.c index cc800db..f0e5223 100644 --- a/arch/pic.c +++ b/arch/pic.c @@ -9,15 +9,15 @@ #define PIC_SLAVE_COMMAND 0xA0 #define PIC_SLAVE_DATA 0xA1 -void pic_initialize() +void pic_remap(const unsigned char master_irq_start, const unsigned char slave_irq_start) { logger_info_from("pic", "Remap the IRQ table."); outportb(PIC_MASTER_COMMAND, 0x11); outportb(PIC_SLAVE_COMMAND, 0x11); - outportb(PIC_MASTER_DATA, 0x20); - outportb(PIC_SLAVE_DATA, 0x28); + outportb(PIC_MASTER_DATA, master_irq_start); + outportb(PIC_SLAVE_DATA, slave_irq_start); outportb(PIC_MASTER_DATA, 0x04); outportb(PIC_SLAVE_DATA, 0x02); diff --git a/arch/pic.h b/arch/pic.h index 3073209..c1caa68 100644 --- a/arch/pic.h +++ b/arch/pic.h @@ -1,6 +1,6 @@ #ifndef KERNELMQ_INCLUDED_PIC #define KERNELMQ_INCLUDED_PIC 1 -void pic_initialize(); +void pic_remap(unsigned char master_irq_start, unsigned char slave_irq_start); #endif diff --git a/arch/protected.c b/arch/protected.c index 2c9f000..33ae965 100644 --- a/arch/protected.c +++ b/arch/protected.c @@ -53,7 +53,7 @@ void idt_flush(const struct IdtPointer *pointer); void protected_initialize(const struct KernelMQ_Info *const kinfo) { - pic_initialize(); + pic_remap(32, 40); logger_info_from("protected", "Setup GDT."); @@ -102,6 +102,7 @@ void protected_initialize(const struct KernelMQ_Info *const kinfo) idt_set_gate(30, (unsigned int)interrupt_30, 0x08, 0x8E); idt_set_gate(31, (unsigned int)interrupt_31, 0x08, 0x8E); + // Master PIC idt_set_gate(32, (unsigned int)interrupt_32, 0x08, 0x8E); idt_set_gate(33, (unsigned int)interrupt_33, 0x08, 0x8E); idt_set_gate(34, (unsigned int)interrupt_34, 0x08, 0x8E); @@ -110,6 +111,8 @@ void protected_initialize(const struct KernelMQ_Info *const kinfo) idt_set_gate(37, (unsigned int)interrupt_37, 0x08, 0x8E); idt_set_gate(38, (unsigned int)interrupt_38, 0x08, 0x8E); idt_set_gate(39, (unsigned int)interrupt_39, 0x08, 0x8E); + + // Slave PIC idt_set_gate(40, (unsigned int)interrupt_40, 0x08, 0x8E); idt_set_gate(41, (unsigned int)interrupt_41, 0x08, 0x8E); idt_set_gate(42, (unsigned int)interrupt_42, 0x08, 0x8E);