Page 1 of 1

PIC ICW3 explanation

Posted: Wed Jul 09, 2025 1:36 pm
by CeriseSky
I'm having trouble understanding this line on the wiki for the 8259 pic initialisation:
outb(PIC1_DATA, 4); // ICW3: tell Master PIC that there is a slave PIC at IRQ2 (0000 0100)
It say's that to tell the master pic that the slave is at irq2, you for some reason have to send 4 to it instead. The manual vaguely mentions a "PIC number" to send as icw3 which I assumed meant the irq number, i.e. 2 not 4. I've looked in the technical reference for the IBM AT and it doesn't mention anything that it's doing that could cause this and at this point I just have no idea what it could be

Re: PIC ICW3 explanation

Posted: Wed Jul 09, 2025 2:39 pm
by JohnSwag

Re: PIC ICW3 explanation

Posted: Wed Jul 09, 2025 3:22 pm
by sandras
I think each bit represents an IRQ line - 100b sets the second bit (counting from zero) to represent which IRQ line the PIC2 connects to.

Re: PIC ICW3 explanation

Posted: Wed Jul 09, 2025 4:37 pm
by CeriseSky
sandras wrote: Wed Jul 09, 2025 3:22 pm I think each bit represents an IRQ line - 100b sets the second bit (counting from zero) to represent which IRQ line the PIC2 connects to.
Oh right that does make sense. Documentation was vague so I thought it meant the actual IRQ number

Re: PIC ICW3 explanation

Posted: Wed Jul 09, 2025 4:41 pm
by CeriseSky
Given that I said that my struggle was with why the value was 4 and not 2 should tell you that I understand how to read binary numbers. I was looking for help about the information that the PIC was expecting due to finding the documentation difficult to read.

Re: PIC ICW3 explanation

Posted: Wed Jul 09, 2025 11:34 pm
by iansjack
It is possible to have more than one slave attached to a master. It would be difficult to represent this with a single number so a bitmap is used. Much like the mask enabling/disabling individual interrupts.