Next Previous Contents

5. Appendix

5.1 Addresses

There are three types of addresses: main memory addresses, I/O addresses and configuration addresses (only on the PCI bus). The term "address" is sometimes used in this document to mean a contiguous range of addresses. Since addresses are given in bytes, a single address only contains one byte but I/O (and main memory) addresses need more than this. So a range of say 8 bytes is often used for I/O address while the range for main memory address allocated to a device is much larger. For a serial port (an I/O device) it's sufficient to give the starting I/O address of the device (such as 3F8) since it's well known that the range of addresses for this device is only 8 bytes. The starting address is known as the "base address".

To access both I/O and (main) memory address "spaces" the same address bus is used (the wires used for the address are shared). How does the device know whether or not an address which appears on the address bus is a memory address or I/O address? Well, there are 4 dedicated wires on the bus that convey this information and more. If a certain one of these 4 wires is asserted, it says that the CPU wants to read from an I/O address, and the main memory ignores the address on the bus. The other 3 wires serve similar purposes. In summary: Read and write wires exist for both main memory and I/O addresses (4 wires in all).

Traditionally, most I/O devices used only I/O memory to communicate with the CPU. For example, the serial port does this. The device driver, running on the CPU would read and write data to/from the I/O address space and usually put this data in main memory. A faster way would be for the device to put the data directly into main memory. One way to do this is by using DMA Channels. Another way is to allocate some space in main memory to the device. This way the device reads and writes directly to main memory without having to bother with DMA. Such device normally have both an I/O address and a main memory address.

5.2 Interrupts --Details

Interrupts convey a lot of information but only indirectly. The interrupt signal (a voltage on a wire) just tells a chip called the interrupt controller that a certain device needs attention. The interrupt controller then signals the CPU. The CPU runs a special program (part of the serial driver software) know as an "interrupt service routine". This "routine" tries to find out what has happened and then deals with the problem such a transferring bytes from (or to) the device. This program (routine) can easily find out what has happened since the device has registers at addresses known to the the driver software (provided the IRQ number and the I/O address of the device has been set correctly). These registers contain status information about the device . The software reads the contents of these registers and by inspecting the contents, finds out what happened, and takes appropriate action..

5.3 Isolation

This is only for the ISA bus. Isolation is a complex method of assigning a temporary handle (id number) to each PnP device on the ISA bus. Since there are more efficient (but more complex) ways to do this, some might claim that it's a simple method. Only one write address is used for PnP writes to all PnP devices so that writing to this address goes to all PnP device that are listening. This write address is used to send (assign) a unique handle to each PnP device. To assign this handle requires that only one device be listening when the handle is sent (written) to this common address. All PnP devices have a unique serial number which they use for the process of isolation. Doing isolation is something like a game. It's done using the equivalent of just one common bus wire connecting all PnP devices and the isolation program.

For the first round of the "game" all PnP devices listen on this wire and send out simultaneously a sequence of bits to the wire. The allowed bits are either a 1 (positive voltage) or an "open 0" of no voltage (open circuit or tri-state). Each PnP device just starts to sequentially send out its serial number, bit-by-bit, starting with the high-order bit, on this wire. If any device sends a 1, a 1 will be heard on the wire by all other devices. If all devices send an "open 0" nothing will be heard on the wire. The object is to eliminate (by the end of this first round) all but highest serial number device. (Note that all serial numbers are of the same length.)

First consider only the high order bit. If any PnP device sends out a 0 (open 0) but hears a 1, this means that some other PnP device has a higher serial number, so it temporarily drops out of this round and doesn't listen anymore until the round is finished (when a handle is assigned to the winner: the highest serial number). Now the devices still in the game all have the same leading digit (a 1) so we may strip off this digit and consider only the resulting "stripped serial number" for future participation in this round. Then go to the start of this paragraph and repeat until the entire serial number has been examined for each device (see below for the all-0 case).

What happens if the leading digits (of the possibly stripped serial numbers) are all 0? Then an "open 0" is sent on the line and all participants stay in the game. If they all have a leading 0 then this is a tie and the 0's are stripped off just like the 1's were in the above paragraph. The game then continues as the next digit (of the serial number) is sent out.

At the end of the round (after the low-order bit of the serial number has been sent out by whatever participants remain) only one PnP device with the highest serial number remains. It then gets assigned a handle and drops out of the game permanently. Then all the dropouts from the last round (that don't have a handle yet) reenter the game and a new round begins with one less participant. Eventually, all PnP devices are assigned handles. It's easy to prove that this algorithm works.

Once all handles are assigned, they are used to address each PnP device and send it a configuration as well as to read configuration info from the PnP device. Note that these handles are only used for PnP configuration and are not used for normal communication with the PnP device. When the computer starts up, all of the handles are lost so that the BIOS usually does the isolation process again each time you start your PC.


Next Previous Contents