From: eepjm@wombat.newcastle.edu.au (Peter Moylan)
Subject: Re: IRQ questions.
Organization: University of Newcastle, AUSTRALIA
Date: Wed, 7 Oct 1992 07:22:27 GMT

In article <ardtlong.718439244@adam.adelaide.edu.au>, ardtlong@adam.adelaide.edu.au (Dale T. Long) writes:
> 
> On examining my system (a HT12A (286) based machine) I was given the following
> results. I used two programs; QA Plus and MSD (Microsoft's, of course).
> 
> IRQ     QA Plus                 MSD
> -----------------------------------------------------
> 0       Timer                   Timer
> 1       Keyboard                Keyboard
> 2       [Cascade]               Second 8259A  (through the BIOS)
> 3       COM2                    COM2
> 4       COM1                    COM1
> 5       available               LPT2  (not installed)
> 6       Floppy Disk             Floppy Disk
> 7       LPT1                    LPT1
> 8       Clock/Calendar          Clock/Calendar
> 9       available               Redirected IRQ 2

    [etc.]

> I would like to know what the [cascade] of IRQ2 means and why MSD shows it as
> a 'second 8259A'. As well as why MSD shows IRQ9 as being a redirected IRQ2.
> What does this all mean? Why is it redirected? Is this something all 286
> achines have or is it something particular to my machine (HT12A)?
> What tricks does an 8259A do?

This is something (well, one of the many things) for which typical
PC documentation is incredibly bad, so it's not surprising that it
confuses lots of people.  I'll try to keep this as clear as possible,
but it's hard to avoid confusion.

The 8259A is an interrupt controller, and it can handle eight different
interrupt sources.  On a computer with only one 8259A, the operation
is not too complex: interrupt requests from up to 8 devices come into
the 8259A, which queues them up as necessary (possibly in priority
order - the 8259A is programmable and has a variety of options),
sending on the interrupt request to the SINGLE interrupt request pin
of the 80x86 processor.  That is, you can think of the 8259A as a
multiplexor which funnels 8 different interrupt sources into a single
processor interrupt line.  If two or more simultaneous interrupt
requests arrive, the 8259A buffers the second request until the first
has been acknowledged, and so on.

Now, the PC uses two of these devices in a master-slave configuration.
Seven of the possible 15 interrupt request lines go directly to the
master 8259A controller, which deals with interrupt numbers 0, 1, and
3..7 (note that 2 is missing from this list).  The remainder, i.e.
interrupt requests 8..15, go to the slave 8259A.  The output of the
slave, instead of going directly to the processor, goes to the IRQ2
input of the master 8259A

The end result is that IRQ2 is unavailable for the use of "normal"
devices, since it is reserved for the use of the slave 8259A.

To complicate matters, what IBM calls IRQ 0..15 actually map to
different interrupt numbers in the processor.  IRQ 0..7 become
processor interrupts 8..15, and IRQ 8..15 maps to some higher numbers
(I've forgotten which).

Furthermore, there's some circuitry which allows a device to
generate what looks like an IRQ2 on the bus (this is for compatibility
for devices designed to work with the XT, which didn't have a
second interrupt controller), but maps this to the IRQ9 input on the
slave interrupt controller.  The end result is to make you completely
lose track of which interrupt number is which ...

All this, by the way, is for any machine compatible with the IBM PC/AT
- i.e. most of the PC-compatibles on the market now.

-- 
Peter Moylan                      eepjm@wombat.newcastle.edu.au
Newsgroups: aus.computers.ibm-pc