Before walking through an example of a programmed I/O driver, it is helpful to look at some actual hardware. This serves the dual purpose of showing what kinds of devices tend to perform programmed I/O and providing a hardware example for the minimal driver to control. How the Parallel Port WorksThe parallel interface found on most PCs is based on an ancient standard from the Centronics Company. Although its original purpose was to communicate with printers, clever people have found many ways of attaching everything from disks to optical scanners to the parallel port. The DB-25 connector on this port carries a number of signals, the most important ones being
The following sequence of events occurs during a data transfer from the CPU to a printer attached to the parallel port:
As is apparent from this description, the parallel port offers a very low-level interface to the outside world. Most of the signaling protocol involved in a data transfer has to be implemented by the CPU itself. A driver for a legacy parallel port must be designed for this primitive operation. Device RegistersThe software interface to the parallel port is through a set of three registers, described in Table 8.8. Since the parallel port is one of the things detected by autoconfiguration (even on an ISA system), the driver is able to use the Configuration Manager to find the base address of the data register.
Interrupt BehaviorTraditionally, the parallel port designated as LPT1 is assigned IRQ 7, and LPT2 is assigned IRQ 5. A device connected to a parallel port generates an interrupt by momentarily forcing the ACK# to zero. Real printers force an interrupt for any of the following reasons:
Driving real printers requires considerable experimentation with the real device. In fact, it is not the purpose of the driver example in this chapter to drive a real peripheral device. Instead, the example is intended to demonstrate the use of interrupts and programmed I/O in a generic way. A Loopback Connector for the Parallel PortFor the purposes of this example driver, it is suggested that a special loopback cable be created or purchased for the parallel port. The loopback connector precludes the need to connect to a real printer, and therefore eliminates the need to adjust the example code to the idiosyncrasies of different printers. The example code assumes a parallel port loopback connector wired according to the TouchStone CheckIt specification. The loopback connector wiring is shown in Table 8.9.
The loopback connector can be purchased directly from Touchstone or can be self-made from a simple DB-25 connector.
|