DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Device driver overview

What are device drivers?

Device drivers are the software that provides an interface between the operating system and the specific hardware devices such as terminals, disks, tape drives, and network media. The device driver brings the device into and out of service, sets hardware parameters in the device, transmits data from the kernel to the device, receives data from the device and passes it back to the kernel, and handles device errors.

To most application programmers, a device driver is simply part of the operating system. The application programmer usually sees devices only as files that can be opened and closed, read from and written to. These functions are accomplished through standard system calls from a high-level language. The system call gives the application program access to the kernel services, which identify the device containing the file and the type of I/O requested. The kernel then executes the device driver routine provided to perform that function.

Device drivers isolate low-level, device-specific details from the system calls, which can remain general and uncomplicated. Because there are so many details for each device, it is impractical to design the kernel to handle all possible devices. Instead, a device driver is included for each configured device. When a new device or capability is added to the system, a new driver must be installed.

The following illustration shows how a driver provides a link between the user level and the hardware level. By issuing system calls from the user level, a program accesses the file and process control subsystems, which, in turn, access the device driver. The driver provides and manages a path for the data to or from the hardware device, and services interrupts issued by the device's controller.

Driver placement in the kernel

Every device on a UNIX system looks like a file. In fact, the user-level interface to the device is called a ``special file.'' The device special files reside in the /dev directory, and a simple ls will tell you quite a bit about the device. For example, the command ls -l /dev/lp might yield the following information:

   crw-rw-rw-   1 root     root     4,  0 Jul 26 12:45 /dev/lp
This says that the lp (line printer) is a character type device (the first letter of the file mode field is c), so I/O operations do not use the buffer cache. 4, 0 is a device number in two parts that the operating system uses to identify the device driver that controls the device and the specific peripheral device that is being accessed. Traditionally, this pair represented the major and minor numbers. Beginning with DDI 8, the major and minor numbers are replaced with driver instances and channel numbers to identify the driver and specific hardware being addressed. Major and minor numbers still appear at user level, but they are an artificial representation of the instance and channel number that are used by the kernel.

© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005