diff --git a/arch/Makefile b/arch/Makefile index 695d2a0..4c493f2 100644 --- a/arch/Makefile +++ b/arch/Makefile @@ -29,6 +29,8 @@ OBJS += exception.c.o OBJS += hwint.c.o OBJS += syscall.c.o +OBJS += pic.c.o + all: kernel clean: diff --git a/arch/pic.c b/arch/pic.c new file mode 100644 index 0000000..352e787 --- /dev/null +++ b/arch/pic.c @@ -0,0 +1,20 @@ +#include "pic.h" + +#include "logger.h" +#include "asm.h" + +void pic_initialize() +{ + logger_info_from("pic", "Remap the IRQ table."); + + outportb(0x20, 0x11); + outportb(0xA0, 0x11); + outportb(0x21, 0x20); + outportb(0xA1, 0x28); + outportb(0x21, 0x04); + outportb(0xA1, 0x02); + outportb(0x21, 0x01); + outportb(0xA1, 0x01); + outportb(0x21, 0x00); + outportb(0xA1, 0x00); +} diff --git a/arch/pic.h b/arch/pic.h new file mode 100644 index 0000000..3073209 --- /dev/null +++ b/arch/pic.h @@ -0,0 +1,6 @@ +#ifndef KERNELMQ_INCLUDED_PIC +#define KERNELMQ_INCLUDED_PIC 1 + +void pic_initialize(); + +#endif diff --git a/arch/protected.c b/arch/protected.c index 53465de..2c9f000 100644 --- a/arch/protected.c +++ b/arch/protected.c @@ -2,10 +2,10 @@ #include "config.h" #include "logger.h" -#include "asm.h" #include "interrupt.h" #include "hwint.h" #include "tss.h" +#include "pic.h" #include @@ -53,18 +53,7 @@ void idt_flush(const struct IdtPointer *pointer); void protected_initialize(const struct KernelMQ_Info *const kinfo) { - logger_info_from("protected", "Remap the IRQ table."); - - outportb(0x20, 0x11); - outportb(0xA0, 0x11); - outportb(0x21, 0x20); - outportb(0xA1, 0x28); - outportb(0x21, 0x04); - outportb(0xA1, 0x02); - outportb(0x21, 0x01); - outportb(0xA1, 0x01); - outportb(0x21, 0x00); - outportb(0xA1, 0x00); + pic_initialize(); logger_info_from("protected", "Setup GDT.");