DMA and I/O
Every expansion card on a
system needs to be configured so that it is correctly assigned certain system
resource. The card needs to be allocated memory space so that it can talk
to the rest of the computer and it's driver needs to be able to find it.
Also, it is normal for a device to transfer bytes to and from RAM via the
CPU. In some cases the CPU can be bypassed, speeding up transfer
operations. Configuring a card is now usually done by the BIOS or the
operating system and the resources that need to be allocated are IRQ
number, DMA channel and I/O address.
IRQ stands for interrupt
request. Basically, it is a way for an ISA expansion card to get the attention
of the CPU and through the CPU, it's device driver. Why would a device
want to tell it's device driver something? Well, as an example, perhaps
it has finished with some task such as sending some bytes somewhere and now
wants some more bytes from the driver.
Now, we know there are physical lines running from an ISA slot to the CPU. If the ISA slot is 16
bit then there are 16 lines running from the slot to the CPU. One of these lines will
be assigned as the slot's IRQ line and will be used if the peripheral device attached
to the expansion card needs to talk it's driver through the CPU.
Thus, an IRQ is a hardware interrupt.
It is actually a voltage on a wire and signals a chip called the interrupt controller that a certain device needs attention. The interrupt controller then signals the CPU.
What now? The CPU then interrupts whatever it was doing, finds the driver for
the device and runs the part of the driver known as an "interrupt service
routine." The routine runs and deals with whatever the
Now, only one IRQ line can be
assigned per ISA slot. Every separate ISA slot is assigned its own IRQ
line. As an example, a modem may be assigned IRQ5 and a COM port may be
assigned IRQ4. A particular IRQ can only be assigned to one
device. Two devices cannot have the same IRQ number or there will be a
CONFLICT. If say two devices are assigned IRQ5 then the CPU will become
confused; it will not know which of the two devices is trying to get it's
attention when IRQ5 becomes active. This can cause your computer to
Here are the IRQ
assignments on my own PC.
Now, the actual IRQ assignments will depend on
the devices you have.
What about the PCI
IRQ assignments I can almost hear you say. There are PCI devices listed
above with the same IRQ numbers. You can see I have a sound card and a
graphics card sharing IRQ12 and IRQ11 looks rather oversubscribed too.
How come I don't get CONFLICTS?
We know that every device must
use the correct line for it's interrupt and that the device driver must listen for the interrupt on the
same line. On the ISA bus each device usually needs its own unique IRQ number. For the PCI bus and other special cases the
sharing of IRQ's is allowed.
PCI interrupts are different
to ISA interrupts, they can share the same IRQ number. You should note
that the same IRQ number cannot be shared between an ISA bus and a PCI bus.
So, how does a PCI bus manage this IRQ sharing?
Let's suppose we have three
PCI cards on our motherboard and each PCI card has four pins on the connector
edge that can be used as interrupts. Then altogether we have 12
possible interrupts. However, perhaps we have only four actual interrupt
lines on the motherboard bus. We can call the bus lines P, Q, R, S.
While we are at it, let's number each card 1 to 3 and label each of the four
pins on a card A, B, C, D. Now we can identify each pin on each
card. For example, the third pin on the second PCI card would be
identified as 2C.
we could connect each pin A interrupt on each card to line P and each pin B
interrupt on each card to line Q. However, this is not a good solution
because all the cards use pin A preferentially for their interrupts. This
would mean the line P would be busy and lines Q, R and S would not be doing
anything much at all.
would prefer each bus line to share the work load. So, lets have line P
deal with pin 1A, 2B, 3C. Then line Q could deal with pin 1D, 2A, 3B and
picture might help.
on startup, the BIOS maps the line P, Q, R, S to particular IRQ's. After that it writes the IRQ that each device uses into a hardware configuration register in each device. From then on any
driver interrogating this register can find out what IRQ the device uses.
stands for Direct Memory Allocation. In effect, this is where a
device is allowed to take over the main motherboard bus and access main
memory directly; bypassing the CPU. Normally, bytes are transferred
from the I/O memory space of the device to the CPU and then to RAM.
ISA devices can do this and only if DMA capability is built into the
card. PCI cards use a different technique for bypassing the CPU called
'bus mastering.' This is a similar thing. Many new drives are labeled
UltraDMA. Really they are bus mastering devices. Bus mastering
allows a device to temporarily become the master of the bus. While DMA
or bus mastering is going on the CPU cannot do much since it does not have
access to the main bus.
when an ISA device wants to do the DMA thing it issues a request along
special DMA lines, (similar to IRQ lines). Just like IRQ lines,
DMA-request lines are numbered so the CPU knows will be able to identify
which device is making the request. Only one device can be master of
the bus at any one time.
device needs memory space so it can exchange information with it's device
driver and the rest of the computer. This memory space is called I/O memory. The actual
I/O memory space may be located on the card itself or in main memory. It
doesn't really matter which. However, every device must have it's own unique
I/O address so that it's driver can communicate with it. I/O
addresses are also known as I/O ports.
Allocating an I/O address
the I/O address into a register on the card
it's device driver of the address
Here are some I/O ranges on
my own PC.
It should be fairly obvious
by now that different devices shouldn't have the same IRQ, DMA channel, or I/O address.
So how do these resources get allocated for each card and how are conflicts
When the computer boots up, the BIOS checks
each installed card for any jumper settings The BIOS then may allocate system
resources such as IRQ number to each installed device. It places that configuration information into a specific area in memory known as the vector
table and this is where the CPU looks to find card configurations.
Also, card configuration can be done through Plug And Play
which is supposed to assign these resources automatically when your computer boots
up. The requirements for PNP to operate
your device must be
your BIOS must be
your operating system must be Plug And Play compatible (Windows95+).
problems and resource conflicts can arise with Plug And Play, say when all the requirements for PNP are not
met or the user tries to set resources manually.
A device that is not Plug And Play is called a
legacy device. When a computer boots up, the settings for these devices are allocated first (forced settings) so that the system knows what resources are left for Plug And Play devices.