Master the fundamental concepts of device drivers & interrupts through this focused micro-challenge.
The dual 8259 PICs cascade IRQ 8-15 through IRQ2. Initialization (ICW1-4) sets vector offsets, edge/level mode, and master/slave wiring. For example, remapping IRQ0-7 to vectors 0x20-0x27 avoids conflicts with CPU exceptions at vectors 0-31.
nasmLoading…
0x21/0xA1: Bit set disables IRQ line0x20 to master; slave IRQ also needs 0x20 to port 0xA0IRQ7 can fire spuriously when noise hits the cascade line; read ISR to see if a real interrupt is in service. Slave PIC sits on IRQ2 of the master; forgetting cascade ICW2 leaves keyboard and timer dead. Unmask only the IRQ lines you have ISRs for; leaving all unmasked without handlers causes nested fault storms. Document the vector base you choose so IDT indices match remap values.
You will remap the PIC and unmask only the IRQ lines your handler needs. This exercise requires writing the ICW sequence and matching IDT vector bases to the remap values.
Implement PIC initialization and control in C.
Requirements:
Test:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github