src/kernel/interrupts/irqs.c
/**
 * Normally, IRQs 0 to 7 are mapped to entries 8 to 15. 
 * This is a problem in protected mode, because IDT entry 8 is a Double Fault! 
 * Without remapping, every time IRQ0 fires, you get a Double Fault Exception, 
 * which is NOT actually what's happening. 
 * We send commands to the Programmable Interrupt Controller (PICs - also called the 8259's) 
 * in order to make IRQ0 to 15 be remapped to IDT entries 32 to 47 
 */
Normally, IRQs 0 to 7 are mapped to entries 8 to 15.
This is a problem in protected mode, because IDT entry 8 is a Double Fault.
Without remapping, every time IRQ0 fires, you get a Double Fault Exception,
which is NOT actually what's happening.
We send commands to the Programmable Interrupt Controller (PICs - also called the 8259's)
in order to make IRQ0 to 15 be remapped to IDT entries 32 to 47
Normally IRQs 0 to 7 are mapped to entries 8 to 15 . This is a problem in protected mode because IDT entry 8 is a Double Fault . Without remapping every time IRQ0 fires you get a Double Fault Exception which is NOT actually what ' s happening . We send commands to the Programmable Interrupt Controller ( PICs - also called the 8259 ' s ) in order to make IRQ0 to 15 be remapped to IDT entries 32 to 47
void pic_init() {
    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, 0x0);
    outportb(0xA1, 0x0);
}
void pic_init ( ) { 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 , 0x0 ) ; outportb ( 0xA1 , 0x0 ) ; }
Normally, IRQs 0 to 7 are mapped to entries 8 to 15.
Normally IRQs 0 to 7 are mapped to entries 8 to 15 .
// ICW1 // ICW2, irq 0 to 7 is mapped to 0x20 to 0x27, irq 8 to F is mapped to 28 to 2F // ICW3, connect master pic with slave pic // ICW4, set x86 mode // clear the mask register