next up previous
Next: Interrupt Processing Up: Input/Output Previous: XINU I/O Primitives

Implementation

We now study (device-independent aspects of the) implementation of the Xinu I/O primitives.

Device Drivers

Each device is associated with several device drivers that implement the abstract I/O primitives for the device. For instance, a terminal device is associated with the device drivers ttygetc, ttyputc, ttyread ..., which implement the getc, putc, read ... abstract operations on terminal devices.

A device driver provides a device-specific implementation of an abstract operation. Different device types are associated with different device drivers, while devices of the same type can share device drivers.

Device Switch Table
Xinu provides a device switch table which maps abstract operations to device drivers, maps device descriptors to device addresses, and specifies contents of interrupt vectors. Each device is associated with an entry in the table which contains the following information about the device:

the device descriptor,

the addresses of the device drivers of the device,

device address,

addresses of input and output interrupt vectors,

addresses of input and output interrupt routines,

buffer pointer, and

minor number, which distinguishes between different devices of the same type and allows them to share the same device drivers.

The device switch table is indexed by device descriptors.

Mapping Abstract Operations to Device Drivers

The device switch table is used to map abstract operations such as read into calls to device drivers such as ttyread. For instance the body of the procedure read(descrp, buff, count) uses descrp to locate the appropriate device switch table entry, get the address of the `read' driver for the device and calls the driver with the arguments devptr, buff, and count, where devptr is the address of the device table entry, and can be used by the device driver to access information in the entry. The bodies of other operations are similar.

Null and Error Entries in Device Table

A device table entry contains a procedure address for every abstract operation. However, some operations are not necessary for certain devices and others are erroneous. Therefore Xinu provides two routines ionull and ioerr. The former does nothing and returns a status of OK. Entries for unnecessary operations such as an open of a terminal device point to this procedure. The latter returns an error status. Entries for erroneous operations such as a seek of a terminal device point to this procedure.

Initializing the Device Table

The declaration of both the device table and its initial values (which do not change) is contained in a file called conf.c (see pages 154-155 of text). This file is automatically generated at system generation time. Thus the device table is initialized by the time the system is compiled.

Note that conf.c does not declare the structure of a device table entry, but only the contents. The former is found in another file ( conf.h).




next up previous
Next: Interrupt Processing Up: Input/Output Previous: XINU I/O Primitives



Prasun Dewan
Tue Feb 12 13:32:55 EST 2002