The Zenith Data Systems Forum on CompuServe
File: IRQ.ZIP

                                 IRQS

                   by Ralph E. Griffin [70323,1440]


What is an IRQ line:

Some adapter cards which are designed to be installed in an IBM PC,
PC/XT, PC/AT, or compatible computer require an Interrupt Request (IRQ)
line. These cards usually give the user a narrow selection of IRQ lines
and the accompanying documentation gives little advice on which IRQ line
to use. If you choose the wrong line, it will interfere with the
operation of some other hardware on your system such as the COM ports or
printer ports. This document explains how to use IRQ lines.

It will be helpful to review the function of the IRQ lines. The IBM PC,
and PC/XT have 8 IRQ lines (numbered IRQ0 through IRQ7). The IBM PC/AT
and the non-IBM 386/ATs have 16 IRQ lines (numbered IRQ0 through IRQ15).
The IRQ lines are physical connections in the computer. When a hardware
device such as an adapter card activates the IRQ line it is detected by
the programmable interrupt controller (PIC). The PIC then activates the
interrupt pin on the processor. The processor responds by stopping
whatever it is doing and then asks the PIC which interrupt should by
executed. The PIC responds by telling the processor which interrupt to
execute depending on which IRQ line was activated. The processor then
gets the vector for that interrupt by looking in the interrupt vector
table in memory. The processor then starts executing the procedure at the
address that is pointed to by the vector. When the procedure is finished,
the processor resumes doing whatever it was doing before it was
interrupted.

Every IRQ line has a designated interrupt, and many IRQ lines have
designated functions. Some of these functional designations are a little
flexible. The following list shows the interrupt number and function of
all the IRQ lines:

line     interrupt  function

IRQ0      08        system timer
IRQ1      09        keyboard
IRQ2      0A        PC/XT: EGA vertical retrace or maybe available
                    PC/AT: see explanation below
IRQ3      0B        COM2 or maybe available
IRQ4      0C        COM1
IRQ5      0D        PC/XT: hard disk drive
                    PC/AT: LPT2 or maybe available
IRQ6      0E        floppy disk drive
IRQ7      0F        LPT1
IRQ8      70        PC/AT: CMOS Real Time Clock
IRQ9      71        PC/AT: see explanation below
IRQ10     72        PC/AT: probably available
IRQ11     73        PC/AT: probably available
IRQ12     74        PC/AT: probably available
                    PS/2: mouse
IRQ13     75        PC/AT: numeric coprocessor
IRQ14     76        PC/AT: hard disk drive
IRQ15     77        PC/AT: probably available


As you can see from the above table, it appears that all of the lower 8
IRQ lines are all reserved for something, and that makes it hard to add
anything. But you may not actually have all the equipment that uses all
those lines which means that the lines are free to be used for something
else.


IRQ5:

On PC/XT's, the IRQ5 line is reserved for the hard disk drive. On
PC/AT's, it is reserved for the second parallel printer port (LPT2), but
most PC/AT's have only one parallel printer port (LPT1), so the IRQ5 line
is in fact available for other uses. If you do have a second parallel
port, you may be able to disable it and the IRQ5 line, which would make
the IRQ5 line available for other uses.


IRQ3:

If a computer has only one serial port, or uses only one serial port,
then IRQ3 may be available. If the computer has two serial ports but only
one of them is being used, it may be possible to disable the IRQ3 line of
the second serial port (COM2). If the IRQ3 line is unused or can be made
available, then it is available for other uses.


IRQ2:

The IRQ2 line has no predetermined function, but it is commonly used by
EGA and VGA adaptors, network adaptors, and bus mouse adaptors. The IRQ2
line can be used for any one of these purposes or for any other purpose,
as long as there is no conflict with other adaptors. If the IRQ2 line is
already being used by an EGA or VGA adaptor, you may be able to disable
it for reasons explained below, and that would free it up for some other
use. On a PC/AT the IRQ9 line may be considered the same as the IRQ2 line
(more on that later). So if one adaptor uses the IRQ2 line and another
uses the IRQ9 line, then there is a conflict.

Many of the old style of EGA adaptor cards have the problem that snow may
appear on the display if you right directly to the display memory in
graphics mode. To get around the snow problem, the EGA card generates an
interrupt every time the display goes into a vertical retrace. Any
software that uses the EGA display in graphics mode can set up an
interrupt handler to write to the display only while the display is in
vertical retrace, and that eliminates the snow problem. The EGA adaptor
uses IRQ2 for this purposes. If your EGA adaptor does not have a jumper
that enables or disables the IRQ2 line, then chances are that the IRQ2
line is enabled (and there is nothing you can do about it). If your EGA
adaptor has a jumper that enables or disables the IRQ2 line, then you
could disable it, and you may not notice any change in performance,
especially if you do not have any software that utilizes it. There is
also a chance that your EGA adaptor does not have the snow problem
anyway, and the IRQ2 jumper is there only for the remote possibility that
you may be running some software that won't work properly without the
IRQ2.

Some VGA adaptor cards also have a jumper that allows you to enable or
disable the IRQ2 line. VGA adaptors are not supposed to have the snow
problem even when the IRQ2 line is disabled, so it is very unlikely that
you need to enable it. The IRQ2 jumper is there only for the remote
possibility that you may be running some software that won't work
properly without the IRQ2. Most software that uses the IRQ2 can
automatically detect it and adjust its operations to work with or without
it. Some software that uses the IRQ2 selects the mode of operation during
installation, so you may have to reinstall or resetup after disabling the
IRQ2 line of the EGA or VGA adaptor. If the VGA adaptor has a 16 bit
interface instead of an 8 bit interface, then the jumper will be referred
to as IRQ9 enable instead of IRQ2 enable. It is really the same line as
explained below.


IRQ2 and IRQ9 Working Together:

On PC/AT's and 386/AT's the IRQ2 and IRQ9 lines are used in mysterious
ways which require lengthy explanation. Most technical references provide
confusing, scant and contradictory information about this line and its
interrupt. The following is an attempt to clear up the confusion.

A comparison of the pinout diagrams for the adapter interface of the
PC/XT and PC/AT shows that the IRQ9 terminal on the PC/AT is in the same
location as the IRQ2 terminal on the PC/XT. Furthermore, the PC/AT does
not even have an IRQ2 terminal. If a card is designed to work in the
PC/XT, it has an 8 bit interface and it may use the IRQ2 line. If the
card is plugged into a PC/XT system and if it activates its IRQ2 line,
then it will activate the IRQ2 line on the computer mother board and that
will cause the computer to execute interrupt 0A. If the same card is
plugged into a PC/AT and if it activates (what it thinks is) the IRQ2
line, then it will actually be activating the IRQ9 line on the computer
motherboard (the IRQ2 terminal of the card contacts the IRQ9 terminal of
the interface connector) and that will cause the computer to execute
interrupt 71. The procedure for interrupt 71 is set up by the BOIS and it
includes a software call to interrupt 0A (the interrupt for IRQ2).

In other words, the PC/AT computer uses hardware to redirect the IRQ2
line of an adaptor card onto the IRQ9 line of the motherboard, and it
uses software to redirect interrupt 71 (the procedure for IRQ9) back to
interrupt 0A (the procedure for IRQ2). Thus the real IRQ2 line on the
motherboard is uninvolved, except for an indirect way (cascading) which
is discussed below. You can install an 8 bit card in a PC/AT computer and
enable IRQ2. It is possible to run software which is specifically
designed to work with that card (it expects to see interrupt 0A executed
every time the card activates the IRQ2 line) and it should work (provided
that there are no conflicts with other adaptor cards).

Many technical references state that the PC/AT computer uses the IRQ2
line as a cascade for IRQ8 through IRQ15. That is true. It means that
whenever any one of the IRQ8 through IRQ15 lines is activated, it
triggers a slave PIC which then activates the IRQ2 line going into the
master PIC. The master PIC then activates the interrupt pin of the
processor. However, that IRQ2 line is not accessible by the adaptor
interface, so it is not interfered with by using the IRQ2 line of an 8
bit adaptor card. Furthermore, the cascading process is based on hardware
protocol and it does not involve the use of interrupt 0A.

Many technical references state that the IRQ2 line or int 0A is reserved.
That is not true. It may be that IBM wanted to reserve IRQ2 for its own
use, but the only things that IBM ever commonly used it for are listed
above. Currently, IBM has abandoned the AT architecture in favor of the
PS/2. It may be that the technical references are referring to the IRQ2
line which is used for cascade and which is not even accessible to the
adapter cards of the PC/AT. But that is misleading because it leaves the
reader with the untrue impression that it would be hazardous to enable
the IRQ2 line on an 8 bit adaptor card which is plugged into a PC/AT.


Printing without an IRQ line:

It is possible to operate a printer port without an IRQ line. By
disabling the IRQ7 line of LPT1, or the IRQ5 line of LPT2, you can make
that IRQ line available for other uses. The parallel printer port needs
an IRQ line only if it is performing true bidirectional data transfer. If
you disable the IRQ line of the parallel printer port, your programs can
still send data to the printer and it will be printed. The parallel
interface still has status lines which enables your programs to avoid
overflowing the printers input buffer and detect basic errors such as
"Out of Paper" and "Device not Ready".


Sharing an IRQ line:

It is also possible for more than one device to share an IRQ line. For
example, you could have a scanner and a modem both using the IRQ3 line.
As long as you don't try to run the scanner program and the modem program
at the same time, you may be able to make it work. The most likely
problem that may arise here is a software incompatibility. For example,
you may need to load a driver for the scanner in the CONFIG.SYS file, and
that may conflict with the modem program even when you are not running
the scanner program. It may be that you will have to change the
configuration and reboot in order to switch between the scanner and the
modem. You may find that you can run the scanner just fine, and then run
the modem just fine, but you can't run the scanner after running the
modem because the modem program does not restore the state of the
interrupt vectors and the state of the PIC enable/disable masking bit for
that IRQ line. Such an incompatibility can be overcome without rebooting,
but it requires that the modem program be run from a batch file. The
batch file would contain commands to run the modem program and then a
custom program that restores the interrupt vectors and PIC mask to the
proper values for compatibility with the scanner (this solution is most
elegant once you get it working but it is not for novices).
