I've just been reading about operating system development for the past week or so out of interest. I haven't started anything (yet), if I do I'd like to have a very clear plan before I start.
I just got caught up on programming the PIC. In particular I'm looking at two articles:
http://www.osdever.net/bkerndev/Docs/irqs.htm and
http://www.osdever.net/tutorials/pic.php
The first article says:
And the second article says:Remember that the slave controller is connected to the primary controller through IRQ2: This means that every time an IRQ from 8 to 15 occurs, IRQ2 fires at exactly the same time.
My question at this point: Does this mean that I can decide some IRQ other than IRQ2 is triggered by the slave controller? I guess this is trivial, but it leads me to my next question:ICW3 is used for telling the PICs which IRQ to use for the communication between each other
Both articles handle ICW3 exactly the same - they send the data 4 to the master PIC, and 2 to the slave PIC. This leads me to believe that this is how things must be done, no?
(I added space around the first code segment's ICW3 since it wasn't commented.)
From Article 1:
Code: Select all
void irq_remap(void)
{
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);
}
Code: Select all
void init_pics(int pic1, int pic2)
{
/* send ICW1 */
outb(PIC1, ICW1);
outb(PIC2, ICW1);
/* send ICW2 */
outb(PIC1 + 1, pic1); /* remap */
outb(PIC2 + 1, pic2); /* pics */
/* send ICW3 */
outb(PIC1 + 1, 4); /* IRQ2 -> connection to slave */
outb(PIC2 + 1, 2);
/* send ICW4 */
outb(PIC1 + 1, ICW4);
outb(PIC2 + 1, ICW4);
/* disable all IRQs */
outb(PIC1 + 1, 0xFF);
}
Thanks for your help!