Linux Device Drivers
Author: Alessandro Rubini
Publisher: O'Reilly & Associates, Inc.
Price: $29.95 US
Reviewer: Mark Bishop
In the last few years, we have seen an explosion in the number of devices supported by Linux. If you ever want to know how device drivers work or add kernel support for a particular device, Linux Device Drivers is the book for you. Be forewarned, though; if you are not comfortable with C, you won't understand the examples that are amply spread throughout. Also note that no matter how good a Linux device driver book really is, it will become outdated simply due to the rate at which the Linux kernel is developed. Mr. Rubini is aware of this fact, and throughout the book, he generously notes the differences between kernel versions when applicable. He even goes so far as to devote an entire chapter to recent developments in the Linux kernel.
I found Linux Device Drivers to be very complete in its description of the Linux kernel versions for which it was written—2.0.x to 2.1.43, which were the most recent at the time of its initial printing.
This book is roughly divided into two parts. Part One includes chapters 1 through 10 and starts out with a simple “Hello World” module, then moves on to describe how kernel modules are properly set up. Part One continues through the entire gambit of modular device programming needed to write a full-featured driver for a character-oriented device.
Since the audience may not have any experience writing modular device drivers, a chapter on debugging techniques is included. I found these to be quite useful, and they helped me to accelerate the development of several kernel drivers I was writing. One thing I did find baffling is the order in which several chapters are presented. The one that stands out most is Chapter 10, which deals primarily with portability issues. This chapter could have been presented earlier in the book to help maintain the flow the author had sustained early on.
I found Chapter 9 to be the most useful and the most fun; it covers interrupt handling. To help facilitate the reader's understanding of how interrupts are processed and handled, it requires the reader to modify his parallel port by connecting two pins together. (The parts can be found at your local computer hardware store for about $3.) Once my parallel port was modified, I was able to make full use of the examples. Mr. Rubini takes a difficult subject and breaks it into manageable parts. He does this quite effectively, moving through very technical topics with great fluidity.
Part Two of Linux Device Drivers covers more advanced topics. These include block drivers and network interfaces, and how one would write device drivers specific to them. Part Two also covers memory management and device access on peripheral buses such as the PCI and ISA bus. It also delves deeper into topics briefly mentioned in Part One.
Also in Part Two is something I have rarely seen described in other Linux kernel books—a description of the actual physical layout of the kernel source. Mr. Rubini approaches this by following the path in which the kernel boots from the first architecture-independent function (start_kernel) through the init process. This is also one of those chapters which might have been better placed earlier in the book, but no matter where it's located, its inclusion is greatly appreciated.
Linux Device Drivers serves many different purposes. This book will always serve the developer who wants to expand the number of devices which work with Linux. Also, you need not have the desire to write a device driver to learn something from it. All you need is an interest in knowing more about how devices work with the kernel to provide the services and stability we want. It is a great piece of work, where the one major drawback is time—this book was published in February of 1998. Changes made in subsequent printings may be found at http://www.oreilly.com/catalog/linuxdrive/errata/. I urge Mr. Rubini to follow up with a second edition, and I plan to be first in line for my copy.