Overview of the Book

From here on, we enter the world of kernel programming. Chapter 2 introduces modularization, explaining the secrets of the art and showing the code for running modules. Chapter 3, talks about char drivers and shows the complete code for a memory-based device driver that can be read and written for fun. Using memory as the hardware base for the device allows anyone to run the sample code without the need to acquire special hardware.

Debugging techniques are vital tools for the programmer and are introduced in Chapter 4. Then, with our new debugging skills, we’ll move to advanced features of char drivers, such as blocking operations, the use of select and the ever-popular ioctl call; these topics are the subject of Chapter 5.

Before dealing with hardware management, we’ll dissect a few more of the kernel’s software interfaces: Chapter 6, shows how time is managed in the kernel, and Chapter 7, explains memory allocation.

Next we focus on hardware: Chapter 8, describes the management of I/O ports and memory buffers that live on the device; after that comes interrupt handling, in Chapter 9. Unfortunately, not everyone will be able to run the sample code for these chapters, because some hardware support is actually needed to test the software interface to interrupts. I’ve tried my best to keep required hardware support to a minimum, but you still need to put your hands on the soldering iron to build your hardware ``device.'' The device is a single jumper wire that plugs into the parallel port, so I hope this is not a problem.

Chapter 10, offers some additional suggestions about writing kernel software and about portability issues.

In the second part of this book, we get more ambitious; thus Chapter 11 starts over with modularization issues, going deeper into the topic.

Chapter 12, then describes how block drivers are implemented, outlining the aspects that differentiate them from char drivers. Following that, Chapter 13, explains what we left out from the previous treatment of memory management: mmap and DMA. At this point, everything about char and block drivers has been introduced.

The third main class of drivers is introduced next: Chapter 14, talks in some detail about network interfaces and dissects the code of the sample network driver.

A few features of device drivers depend directly on the interface bus where the peripheral fits, so Chapter 15, provides an overview of the main features of the bus implementations most frequently found nowadays, with a special focus on PCI support offered in the kernel.

Finally, Chapter 16 is a sort of tour of the kernel source: it is meant to be a starting point for people who want to understand the overall design, but who may be scared by the huge amount of source code that makes up Linux.

Soon after Linux 2.0 was released, the 2.1 development tree began introducing incompatibilities; the most important ones were introduced in the first months. Chapter 17, which can be considered almost an appendix, gathers all the known incompatibilities introduced before 2.1.43 and offers software fixes for them. By the end of the chapter, you’ll be able to write device drivers that compile and run on 1.2.13 and all kernels between 2.0 and 2.1.43. Hopefully, 2.2 will turn out to be quite similar to 2.1.43, and your software will be ready for the event.

Get Linux Device Drivers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.