Specifications
D
evice Driver Programming
2-6
Types of Device Driver Interfaces 2
A device driver interface is the set of structures, routines, and optional functions used to
implement a device driver. UNIX systems provide three device driver interfaces, all based
on one specification, the Device Driver Interface/Driver Kernel Interface (DDI/DKI).
Block and Character Interfaces 2
Block and character are the two traditional UNIX system device driver interfaces, corre-
sponding to the two basic ways drivers move data. Block drivers, using the system buffer
cache, service random-access devices such as disk drives and other mass storage devices
capable of handling data in independently addressable blocks. Character drivers service
devices that send and receive information one character at a time, such as interactive ter-
minals.
It is the individual device and goal of the implementation, not the device type, that deter-
mines whether a driver should be the block or character type. For example, for a 9-track
tape drive one developer codes a block driver to mount file system images, even though
the drive performs random block accesses poorly. Another developer codes a character
driver to sequentially store and retrieve data.
A device can have more than one interface (only one interface at a time can access a
device.) The tape drive mentioned previously had both block and character interfaces. The
DDI/DKI sections of the on-line Device Driver Reference contain the manual pages for
the block and character interfaces.
STREAMS Interface 2
Early UNIX network drivers demonstrated a limitation of block and character interfaces;
they could not divide network protocols into layered modules. A new kind of interface,
STREAMS, has no such limitation.
A stream is a structure made of linked modules, each of which processes the transmitted
information and passes it to the next module. One of these queues of modules connects the
user process to the device, and another provides a data path from the device to the process.
This layered structure accommodates layered network protocols and increases the flexibil-
ity of the interface, making modules more usable by more than one driver.
For more information about STREAMS drivers, refer to STREAMS Modules and Drivers.