static void init_pic(int offset)
{
    /* send ICW1 saying we'll follow with ICW4 later on */
    outb(ICW1_INIT | ICW1_ICW4_NEEDED, PIC1_CMD);
    outb(ICW1_INIT | ICW1_ICW4_NEEDED, PIC2_CMD);
    /* send ICW2 with IRQ remapping */
    outb(offset, PIC1_DATA);
    outb(offset + 8, PIC2_DATA);
    /* send ICW3 to setup the master/slave relationship */
    /* ... set bit3 = 3rd interrupt input has a slave */
    outb(4, PIC1_DATA);
    /* ... set slave ID to 2 */
    outb(2, PIC2_DATA);
    /* send ICW4 to set 8086 mode (no calls generated) */
    outb(ICW4_8086, PIC1_DATA);
    outb(ICW4_8086, PIC2_DATA);
    /* done, just reset the data port to 0 */
    outb(0, PIC1_DATA);
    outb(0, PIC2_DATA);
}