Specifications

D
evice Driver Programming
2-10
Devices need not use all the entry points provided by the switch table. For instance, printer
drivers do not need read routines. The operating system provides place holders in the
switch tables for unneeded routines.
Interrupt Entry Points 2
The operating system must handle many kinds of system interrupts (such as clock and
software interrupts), system exceptions (such as page faults), and interrupts from periph-
eral devices controlled by drivers. Interrupts cause the processor to stop its current process
and to immediately begin to service the interrupt. Peripheral devices typically generate
interrupts when an I/O transfer encounters an error or completes successfully.
When it receives an interrupt from a hardware device, the kernel determines the interrupt
vector number of the device and passes control to the appropriate driver's interrupt han-
dling routines. It does this by accessing the interrupt vector table, populated during system
initialization. The interrupt handler must determine the reason for the interrupt (device
connect, write acknowledge, data available) and set or clear device state bits as appropri-
ate. It can also awaken processes that sleep while awaiting an event corresponding to the
interrupt.
Kernel Support Routines 2
UNIX system device drivers call kernel support routines to do system-level work such as:
Chapter 9 (“Understanding the Kernel Environment”) describes these routines and their
use in device drivers. Section D3 of the on-line Device Driver Reference contains manual
pages for all of these routines.
Driver Environment 2
Installation and Configuration 2
To integrate a driver into the system requires adding information to the system configura-
tion files about it, such as type, location of object code, and interrupt priority level.
Four phases comprise the process of adding a device driver to a working system:
accessing memory adjusting processor levels allocating interrupt vectors
allocating memory debugging managing virtual address
synchronizing timing and timeout transferring data