"Linux Gazette...making Linux just a little more fun!"


Introduction to IRQs, DMAs and Base Addresses

by Eugene Blanchard


This article will discuss the function and assignment of IRQs, DMAs and Base Addresses (IOPorts) used by IBM compatible computers. I've found that the documentation, with IBM compatible PCs and peripheral devices, list the resources that the device can use but do not give any guidelines as to standard resource assignments. Hopefully this article will shed some light on this troublesome area and provide some guidance as to the selection of IRQs, DMAs and Base Addresses.


IRQ - Interrupt Requests

IRQ stands for Interrupt ReQuest. It is a "tap on the shoulder" to the CPU by a peripheral card plugged in an ISA slot to tell the CPU that the peripheral has something to say (also used by EISA and MCA slots). Common peripherals are modems, NICs (network interface cards), sound cards, SCSI adapters, hard-drive controllers, floppy drive controllers, COM ports and printer ports.

An IRQ is a hardware interrupt, this means that there is a physical line run to each of the ISA slots on the motherboard. There are 2 types of ISA slots: 8 bit and 16 bit. The 16 bit consists of the 8 bit slot plus a 16 bit extension slot.

There are 8 IRQ (IRQ0-7) lines that run to the 8 bit ISA slot. There are 8 more (IRQ8-15) that run to the 16 bit ISA extension slot. For a total of 16 IRQs in a typical ISA bus PC. IRQ0 has the highest priority and IRQ7 the lowest priority. IRQ8-15 have "special" priority as will be explained.

When IBM introduced the AT computer, they added IRQ8-15. Now, in order to make AT (286) PCs backward compatible with 8 bit XT (8088) PCs and to "up" the priority of the new IRQ lines, they cascaded two interrupt controllers. This results in IRQ8-15 having the same priority as IRQ2. Priority means if two IRQs are active at the same time, the one with the higher priority is serviced first.

IMPORTANT: An IRQ can be assigned to only one active device at a time. If 2 devices share the same IRQ, this is called a CONFLICT. This means that when the IRQ line becomes active, the CPU does not know which device needs to "talk". For example, if a modem used IRQ5 and a NIC used IRQ5. If the modem had some information that needed to be passed on to the CPU, it would set IRQ5 active. The CPU would not know whether to talk to the NIC or modem. The computer may hang, or nothing would happen.

*** IRQ conflicts are the NUMBER 1 source of PC problems! ***

Here is a table that is used as a rule of thumb (guideline) in selecting IRQs for PCs. The IRQs are listed in order of priority. (Note that I lied earlier when I said that all IRQ lines go to the card slots)

IRQ	Function			Physical Line	ISA Bus

IRQ0	System Timer			No		-			
IRQ1	Keyboard Controller		No		-
IRQ2	Cascaded to IRQ8-15		No		-
IRQ8	Real-time clock			No		-
IRQ9	*-Available(IRQ2)		Yes		8/16 bit
IRQ10	NIC				Yes		16 bit
IRQ11	SCSI adapter			Yes		16 bit
IRQ12	Motherboard mouse/available	Yes		16 bit
IRQ13	Math coprocessor		No		-
IRQ14	Primary IDE controller		Yes		16 bit
IRQ15	Secondary IDE controller	Yes		16 bit
IRQ3	Com2/Com4			Yes		8 bit
IRQ4	Com1/Com3			Yes		8 bit
IRQ5	Sound card/LPT2			Yes		8 bit
IRQ6	Floppy drive controller		Yes		8 bit
IRQ7	Parallel port LPT1		Yes		8 bit
*- IRQ9 appears as if it is IRQ2. Normally not used because it can cause interesting problems to appear. Is it really IRQ9 or is it the IRQ2 cascaded to IRQ9? Which do you set it to? What if you are using an 8 bit ISA modem in a 16 bit ISA slot? See what I mean...

The above table is a rule of thumb or guideline to selecting IRQs for your peripherals. For example if the PC does not use a SCSI adapter then IRQ11 is available for use for another NIC card or another device.

Most autodetecting software or operating systems like Linux expect to see the IRQs assigned as above.

COM Port Conflicts

Note that COM1 (DB9 on the back of the PC) and COM3 share IRQ4. This is allowed as long as only one device is active at a time. This means that if you are running a mouse on COM1 then you cannot use COM3 for an internal modem. You will run into a conflict. Some communication packages will allow you to do this but most will choke or cause flaky operation. A common symptom is if you move the mouse, you see garbage on your terminal program.

COM2 (DB25 on the back of the PC) and COM4 have a similar problem except that most people don't use COM2. It is usually safe to configure an internal modem to COM4. If COM2 is used, it is typically used for an external modem or a plotter. Usually, both are not active at the same time.

Standard COM Port Assignment

Port	IRQ	Function
COM1	4	Mouse
COM2	3	Plotter / external modem / not used
COM3	4	Not used (conflicts with mouse)
COM4	3	Internal modem / not used

DMA -Direct Memory Access

DMA stands for Direct Memory Access. This is a method that allows channels to be opened by the peripheral to read/write directly to memory without going through the CPU. This offloads some of the work from the CPU to allow it to do more important tasks.

There are 8 DMA channels available in the PC: DMA0-7. They are divided into 8 bit channels and 16 bit channels based on the 8 bit ISA slot and 16 bit ISA slot.

Here is a table that is used as a rule of thumb for selecting DMA channels:

DMA	Function		Physical Line	ISA Bus		Channel Width

DMA0	Available		Yes		16 bit		8 bits
DMA1	Sound			Yes		8 bit		8 bits
DMA2	Floppy Disk controller	Yes		8 bit		8 bits
DMA3	ECP Parallel Port	Yes		8 bit		8 bits
DMA4	* - Not used		No		-		16 bit
DMA5	Sound			Yes		16 bit		16 bit
DMA6	SCSI			Yes		16 bit		16 bit
DMA7	Available		Yes		16 bit		16 bit
NOTES:
DMA0 is on the 16 bit ISA bus but only 8 bits wide.
DMA4 is cascaded to the 1st 8 bit DMA controller and is not available.

*** DMA conflicts are the NUMBER 2 source of PC problems! ***

Like IRQs, you are only allowed to assign one DMA channel to an active device at a time. Otherwise you will have a conflict appear and things will not work properly. Notice the word active - this means turned on and a software program accessing the device. You may have one DMA channel assigned to two devices ONLY if one device is active at a time - risky but allowed.


Base Addresses

Base addresses are also called I/O ports, I/O addresses, I/O port addresses and base ports. They are memory locations that provide an interface between the operating system and the I/O device (peripheral). The peripheral communicates with the operating system through the base address. Each peripheral must have a UNIQUE base address.

Standard Base Address assignments (h - hexadecimal):

060h + 064h		Keyboard controller
170h + 376h		Secondary IDE Hard-drive controller
1F0h + 3F6h		Primary IDE Hard-drive controller
220h			Sound Card
300h			NIC card
330h			SCSI adapter
3F2h			Floppy Drive Controller
3F8h			COM1
2F8h			COM2
3E8h			COM3
2E8h			COM4
378h			LPT1
278h			LPT2
*** Base Address conflicts are the NUMBER 3 source of PC problems! ***

Unfortunately, the above table is only a small part of the Base Addresses used. The base addresses used will depend on what has been installed on the PC.


Resource Information on Linux

To view your Linux configuration, look in the /proc directory for the following text files:

cat  /proc/interrupts		lists the current interrupts in use
cat  /proc/ioports		lists the ioports (base addresses) in use
cat  /proc/dma			lists the current dmas in use


Copyright © 1999, Eugene Blanchard
Published in Issue 38 of Linux Gazette, March 1999


[ TABLE OF CONTENTS ] [ FRONT PAGE ]  Back  Next