Vocademy

I/O Device Configuration

Interrupt requests (IRQs)  

The interrupt request is a specific wire on the microprocessor. This tells the microprocessor to go to the interrupt request service routine as soon as it finishes any critical processes.  

On modern computers, extra chips process multiple interrupt requests from different sources. These are called programmable interrupt controllers (PIC). In x86 computers, two PIC chips have eight interrupt wires (IRQ lines). Each wire is assigned to a particular hardware device. For example, IRQ 1 is assigned to the keyboard controller. Whenever a key is pressed, a signal is sent on this IRQ 1 to be handled by the PIC.

The PIC prioritizes the IRQs (lower numbers have higher priority) and sends a signal to the processor on its single interrupt request wire. When the processor receives the IRQ, it goes through the IRQ process, querying the PIC as to what address to go to in order to service the device that initiated the IRQ[1].

The PIC circuits are designed to be cascaded. That means one PIC's output can go to another's input. Theoretically, 64 interrupt lines could be handled this way. One PIC would have eight other PICs connected to its eight inputs. Each of those PIC have eight inputs for a total of 64. The original IBM PC had only eight IRQs, but a second PIC was added to the IBM AT so 15 IRQs could be handled. The output of one PIC is connected to input 2 of the other. This arrangement leaves 15 available IRQ wires for hardware to use.  

The rule at the hardware level is that no two devices can use the same IRQ[2]. Before the advent of Plug and Play systems, PC technicians had to be careful not to assign two devices to the same IRQ. This is a problem that PC technicians don't have to deal with anymore. However, embedded systems, etc., may still use manually-assigned hardware interrupts. Therefore it is crucial to know the following rules

Rules for assigning IRQs  

1.    No two devices can use the same IRQ.  

2.    The hardware driver must be configured to use the same IRQ that the hardware is configured to use.

Older hardware used jumpers to configure IRQs. Newer non-plug-and-play devices use software programs to store such configurations in non-volatile RAM on the device.  

Some interrupts are reserved for devices on the motherboard, such as the system timer, the keyboard, and the real-time clock. Others go to the expansion bus and are available to devices connected to the bus.

I/O Addresses  

A device can use the IRQ to tell the processor it needs attention. Once that happens, the processor needs to know where in the memory space the hardware is wired-in so that it can communicate with it (see port-mapped and memory-mapped I/O).  

The I/O address is the start of a memory block where a particular piece of hardware is wired into the memory space. The rules for assigning an I/O address are the same as for assigning an IRQ.

Direct Memory Access (DMA)  

The x86 computer has a system where external hardware can access memory without the aid of the processor. The onboard DMA subsystem is only used by a limited number of devices. DMA is handled through eight DMA channels that are assigned much like IRQs with the same rules.  

ROM Addresses  

Some devices have their own ROM chips with custom programming for the processor. If a device has such ROM, it must be configured to map in (be wired into the memory space) where no other ROM is assigned. There is limited space between the video card and the BIOS for such ROMs. ROM addresses follow the same rules as I/O addresses.

Before Plug and Play  

Before the Plug and Play system became the norm, each I/O device had to be configured to be visible to the computer. At the very least, an I/O address had to be selected. This was usually done with jumper blocks.    

 

Jumpers on a serial port to set the speed (300 to 9600 bits per second).

To configure an I/O device, the technician had to determine what resources were available. Once this was done, the jumpers on the I/O device could be set. For example, a serial port usually had certain choices of I/O address to choose from, typically 02E8, 02F8, 03E8, and 03F8.   Most devices also require an IRQ configuration. This was also done by setting jumpers. For example, a serial port could usually be set to IRQ 2 or IRQ 3. In addition, some devices use a DMA channel, and some also have onboard ROM, which could be configured with jumpers if necessary.

Most devices also require an IRQ configuration. This was also done by setting jumpers. For example, a serial port could usually be set to IRQ 2 or IRQ 3. In addition, some devices use a DMA channel, and some also have onboard ROM, which could be configured with jumpers if necessary.  

Once an I/O device was configured, the operating system or device driver needed to be told which resources it used. Early SoundBlaster cards required an environment variable to tell the driver what resources to use. For example, the following DOS command was used to set the variable: "SET BLASTER=I5;A250,D1". The driver could read this variable and see that the sound card used IRQ 5, I/O address 0250, and DMA channel 1.  

If the I/O device or the operating system were not correctly configured, the device would not work. If there was a conflict between two devices, for example, two devices using IRQ 5, neither device was likely to work.  

To recap, you would have to set the I/O address and probably an IRQ number, DMA channel, and ROM address to configure a peripheral. These resources would have to be unused by any other peripheral. Then you would have to tell the computer the same information. If you got any of it wrong, your peripheral wouldn't work.

Plug and Play  

Modern computers and operating systems use the Plug and Play system to configure I/O devices. When Plug and Play is available and working correctly[3], the technician does nothing to configure devices.

—————————
1The PIC is itself an I/O device. When the CPU receives an interrupt signal it goes to an address that connects to the PIC. That address will contain the address of the interrupt service routine for the device generating the interrupt.
2In protected mode IRQs are virtualized so you may find devices using the same IRQ.
3When originally introduced, Plug and Play had reliability problems so many people called it ''Plug and Pray.'' This has not been an issue for some time
Vocademy