![]() |
|
So why would you bother reading a book on the general topic of UNIX device drivers, when each flavor of UNIX is different and most platforms have fairly good documentation?
For one reason, apart from each vendor's idiosyncratic features (such as Solaris's symbolic links in the /dev directory and AIX's lack of difference between block and character device nodes), common methods and features prevail. Certain aspects of driver development change very little between platforms; there is always kernel address space and user address space. Driver entry points are often different but a common thread of similarity exists. There is always a device switch table (on systems other than AIX there is usually a character device switch and a block device switch), which is a jump table for driver routines indexed by the device's major number.
Minor numbers always indicate an instance of a device. Character devices usually support open, read, write, close and ioctl routines; block devices usually additionally support a strategy routine that interacts with the file system's buffer cache. Understanding these topics after reading an introductory text is a good foundation for deciphering vendor's manuals. Writing a UNIX Device Driver, Second Edition, by Janet Egan and Tom Teixeira, covers UNIX and its I/O subsystem, the device-driver entry points, I/O hardware and device drivers, system configuration, basic driver operations, examples of driver logic, driver development methods, template drivers, SCSI and STREAMS drivers, kernel I/O support, and porting considerations.
Considering that the book was last updated in 1992, it is no surprise that everything in this book is dated. The main focus is on XENIX and the 386 processor, although there are segues to other systems such as 4.3BSD. There is no mention of multiprocessor systems, spin locks, kernel threads, or modern kernel features.
Still, some of the core advice in driver-development methods are applicable in most modern situations. Using assert, analyzing trace dumps, running lint on the source, and using crash and debuggers are all popular techniques. One technique I never thought of until reading this book is using the system console (Such as Sun's Forth-based PROM monitor or the Alpha's SRM console) to dump useful information during the debugging phase after a crash.
The chapter on examples of driver logic covers: definition of the device, device data structure, error retry logic, magnetic tape drivers, synchronous character output, characters buffered in a list, DMA output from system space buffers, synchronous DMA from user space, and synchronous I/O multiplexing. This chapter expands on the topics from the chapter on basic device driver operations.
The basic device-driver operations chapter is the meatiest chapter of the book, with 54 pages of data transfer between user and kernel address space, data structures passed to and from the driver, and synchronization of driver routines with other kernel/user code. Data structures discussed common to many platforms including uio and user, buf iovec and iobuf. The optimization techniques are okay for RISC system but not for Intel CISC (Pre Merced). The need for locking pages into memory is covered but this is different on other systems.
In the chapter on system configuration, the approach taken is very VAX and SystemV/386 oriented. All systems need an entry for the driver's routines in the device switch. Such kernel data structures are discussed, as well as system configuration programs, configuration databases, and the mknod command. Many other systems use much the same technique. For example, for statically linked drivers, Digital Unix (AKA OSF/1) uses a configuration database that looks a lot like the nexus entries for the 4BSD VAX. But to a certain extent, in this time of loadable kernel modules (Solaris, Linux, Digital Unix, HP-UX, AIX, and so on) and run-time dynamic configuration, many modern systems are configured in a very different manner from what is described.
The I/O hardware chapter is a very short -- a sparse 11 pages. A paragraph or two each is devoted to VME bus, ISA and the micro channel bus, and the SCSI bus. Coverage of memory-mapped registers, processor interupts, programmed I/O and DMA is limited to about a page each. Some vendor's manuals contain more coverage.
The first two chapters introduce UNIX and give trivial explanation of I/O from a user's perspective. The chapter on SCSI drivers is extremely weak and possibly confusing. There is inadequate discussion of command data blocks (CDBs).
In short, Writing a UNIX Device Driver is useful as background on the topic, perhaps on the further reading list for an operating systems course. It is simple and does not cover advanced topics. It is a building block upon which advanced techniques can be applied.
-- Regan Russell
| Readability |
|
| Originality |
|
| Organization |
|
| Accuracy |
|
| Consistency |
|
| Depth |
|
| Timeliness |
|
| Editing |
|
| Design |
|
| Overall Value |
|
Explanation of ERCB rating scale: No stars = unacceptable, 1 Star = marginal, 2 Stars = average, 3 Stars = above average, 4 Stars = exceptional.