//! Initialize pic void i86_pic_initialize (uint8_t base0, uint8_t base1) { uint8_t icw = 0; //! disable hardware interrupts disable (); //! Begin initialization of PIC icw = (icw & ~I86_PIC_ICW1_MASK_INIT) | I86_PIC_ICW1_INIT_YES; icw = (icw & ~I86_PIC_ICW1_MASK_IC4) | I86_PIC_ICW1_IC4_EXPECT; i86_pic_send_command (icw, 0); i86_pic_send_command (icw, 1); //! Send initialization control word 2. This is the base addresses of the irq's i86_pic_send_data (base0, 0); i86_pic_send_data (base1, 1); //! Send initialization control word 3. This is the connection between master and slave. //! ICW3 for master PIC is the IR that connects to secondary pic in binary format //! ICW3 for secondary PIC is the IR that connects to master pic in decimal format i86_pic_send_data (0x04, 0); i86_pic_send_data (0x02, 1); //! Send Initialization control word 4. Enables i86 mode icw = (icw & ~I86_PIC_ICW4_MASK_UPM) | I86_PIC_ICW4_UPM_86MODE; i86_pic_send_data (icw, 0); i86_pic_send_data (icw, 1); }
//! notifies hal interrupt is done void InterruptDone(unsigned int intno) { //! insure its a valid hardware irq if (intno > 16) return; //! test if we need to send end-of-interrupt to second pic if (intno >= 8) i86_pic_send_command(I86_PIC_OCW2_MASK_EOI, 1); //! always send end-of-interrupt to primary pic i86_pic_send_command(I86_PIC_OCW2_MASK_EOI, 0); }