Synopses & Reviews
This book is for anyone who wants to support computer peripherals under the Linux operating system or who wants to develop new hardware and run it under Linux. Linux is the fastest-growing segment of the Unix market, is winning over enthusiastic adherents in many application areas, and is being viewed more and more as a good platform for embedded systems. Linux Device Drivers, already a classic in its second edition, reveals information that heretofore has been shared by word of mouth or in cryptic source code comments, on how to write drivers for a wide range of devices.Version 2.4 of the Linux kernel includes significant changes to device drivers, simplifying many activities, but providing subtle new features that can make a driver both more efficient and more flexible. The second edition of this book thoroughly covers these changes, as well as new processors and buses.You don't have to be a kernel hacker to understand and enjoy this book; all you need is an understanding of C and some background in Unix system calls. You'll learn how to write drivers for character devices, block devices, and network interfaces, guided by full-featured examples that you can compile and run without special hardware. Major changes in the second edition include discussions of symmetric multiprocessing (SMP) and locking, new CPUs, and recently supported buses. For those who are curious about how an operating system does its job, this book provides insights into address spaces, asynchronous events, and I/O.Portability is a major concern in the text. The book is centered on version 2.4, but includes information for kernels back to 2.0 where feasible. Linux Device Driver also shows how to maximize portability among hardware platforms; examples were tested on IA32 (PC) and IA64, PowerPC, SPARC and SPARC64, Alpha, ARM, and MIPS.Contents include:
- Building a driver and loading modules
- Complete character, block, and network drivers
- Debugging a driver
- Timing
- Handling symmetric multiprocessing (SMP) systems
- Memory management and DMA
- Interrupts
- Portability issues
- Peripheral Component Interconnect (PCI)
Synopsis
This book is for anyone who wants to support computer peripherals under the Linux operating system or who wants to develop new hardware and run it under Linux. Linux is the fastest-growing segment of the UNIX market and is winning over enthusiastic adherents in many application areas. This book reveals information that heretofore has been passed by word-of-mouth or in cryptic source code comments, showing how to write a driver for a wide range of devices.
You don't have to be a kernel hacker to understand and enjoy this book; all you need is an understanding of C and some background in UNIX system calls. Drivers for character devices, block devices, and network interfaces are all described in step-by-step form and are illustrated with full-featured examples that show driver design issues, which can be executed without special hardware.
For those who are curious about how an operating system does its job, this book provides insights into address spaces, asynchronous events, and I/O.
Portability is a major concern in the text. The book is centered on version 2.0, but also covers 1.2.13 and experimental versions up to 2.1.43. You are also told how to maximize portability among hardware platforms.
Synopsis
This book is for anyone who wants to support computer peripherals under the Linux operating system or who wants to develop new hardware and run it under Linux. Linux is the fastest-growing segment of the Unix market, is winning over enthusiast
About the Author
Jonathan Corbet got his first look at the BSD Unix source back in 1981, when an instructor at the University of Colorado let him "fix" the paging algorithm. He has been digging around inside every system he could get his hands on ever since, working on drivers for VAX, Sun, Ardent, and x86 systems on the way. He got his first Linux system in 1993, and has never looked back. Mr. Corbet is the co-founder and executive editor of Linux Weekly News; he lives in Boulder, Colorado with his wife and two children.
Alessandro Rubini installed Linux 0.99.14 soon after getting his degree as an electronic engineer. He then received a Ph.D in computer science at the University of Pavia despite his aversion toward modern technology. Alas, he still enjoys digging in technology and discovering the intelligence of people who created it: that's why he now works in his apartment with three PCs, an Alpha, a SPARC, and an Apple2 -- the last without Linux. But you might find him roaming around in the north of Italy on his bike, which doesn't carry an electronic cyclometer.
Table of Contents
Preface; Alessandro's Introduction; Jon's Introduction; Audience of This Book; Organization of the Material; Background Information; Sources of Further Information; Online Version and License; Conventions Used in This Book; We'd Like to Hear from You; Acknowledgments; Chapter 1: An Introduction to Device Drivers; 1.1 The Role of the Device Driver; 1.2 Splitting the Kernel; 1.3 Classes of Devices and Modules; 1.4 Security Issues; 1.5 Version Numbering; 1.6 License Terms; 1.7 Joining the Kernel Development Community; 1.8 Overview of the Book; Chapter 2: Building and Running Modules; 2.1 Kernel Modules Versus Applications; 2.2 Compiling and Loading; 2.3 The Kernel Symbol Table; 2.4 Initialization and Shutdown; 2.5 Using Resources; 2.6 Automatic and Manual Configuration; 2.7 Doing It in User Space; 2.8 Backward Compatibility; 2.9 Quick Reference; Chapter 3: Char Drivers; 3.1 The Design of scull; 3.2 Major and Minor Numbers; 3.3 File Operations; 3.4 The file Structure; 3.5 open and release; 3.6 scull's Memory Usage; 3.7 A Brief Introduction to Race Conditions; 3.8 read and write; 3.9 Playing with the New Devices; 3.10 The Device Filesystem; 3.11 Backward Compatibility; 3.12 Quick Reference; Chapter 4: Debugging Techniques; 4.1 Debugging by Printing; 4.2 Debugging by Querying; 4.3 Debugging by Watching; 4.4 Debugging System Faults; 4.5 Debuggers and Related Tools; Chapter 5: Enhanced Char Driver Operations; 5.1 ioctl; 5.2 Blocking I/O; 5.3 poll and select; 5.4 Asynchronous Notification; 5.5 Seeking a Device; 5.6 Access Control on a Device File; 5.7 Backward Compatibility; 5.8 Quick Reference; Chapter 6: Flow of Time; 6.1 Time Intervals in the Kernel; 6.2 Knowing the Current Time; 6.3 Delaying Execution; 6.4 Task Queues; 6.5 Kernel Timers; 6.6 Backward Compatibility; 6.7 Quick Reference; Chapter 7: Getting Hold of Memory; 7.1 The Real Story of kmalloc; 7.2 Lookaside Caches; 7.3 get_free_page and Friends; 7.4 vmalloc and Friends; 7.5 Boot-Time Allocation; 7.6 Backward Compatibility; 7.7 Quick Reference; Chapter 8: Hardware Management; 8.1 I/O Ports and I/O Memory; 8.2 Using I/O Ports; 8.3 Using Digital I/O Ports; 8.4 Using I/O Memory; 8.5 Backward Compatibility; 8.6 Quick Reference; Chapter 9: Interrupt Handling; 9.1 Overall Control of Interrupts; 9.2 Preparing the Parallel Port; 9.3 Installing an Interrupt Handler; 9.4 Implementing a Handler; 9.5 Tasklets and Bottom-Half Processing; 9.6 Interrupt Sharing; 9.7 Interrupt-Driven I/O; 9.8 Race Conditions; 9.9 Backward Compatibility; 9.10 Quick Reference; Chapter 10: Judicious Use of Data Types; 10.1 Use of Standard C Types; 10.2 Assigning an Explicit Size to Data Items; 10.3 Interface-Specific Types; 10.4 Other Portability Issues; 10.5 Linked Lists; 10.6 Quick Reference; Chapter 11: kmod and Advanced Modularization; 11.1 Loading Modules on Demand; 11.2 Intermodule Communication; 11.3 Version Control in Modules; 11.4 Backward Compatibility; 11.5 Quick Reference; Chapter 12: Loading Block Drivers; 12.1 Registering the Driver; 12.2 The Header File blk.h; 12.3 Handling Requests: A Simple Introduction; 12.4 Handling Requests: The Detailed View; 12.5 How Mounting and Unmounting Works; 12.6 The ioctl Method; 12.7 Removable Devices; 12.8 Partitionable Devices; 12.9 Interrupt-Driven Block Drivers; 12.10 Backward Compatibility; 12.11 Quick Reference; Chapter 13: mmap and DMA; 13.1 Memory Management in Linux; 13.2 The mmap Device Operation; 13.3 The kiobuf Interface; 13.4 Direct Memory Access and Bus Mastering; 13.5 Backward Compatibility; 13.6 Quick Reference; Chapter 14: Network Drivers; 14.1 How snull Is Designed; 14.2 Connecting to the Kernel; 14.3 The net_device Structure in Detail; 14.4 Opening and Closing; 14.5 Packet Transmission; 14.6 Packet Reception; 14.7 The Interrupt Handler; 14.8 Changes in Link State; 14.9 The Socket Buffers; 14.10 MAC Address Resolution; 14.11 Custom ioctl Commands; 14.12 Statistical Information; 14.13 Multicasting; 14.14 Backward Compatibility; 14.15 Quick Reference; Chapter 15: Overview of Peripheral Buses; 15.1 The PCI Interface; 15.2 A Look Back: ISA; 15.3 PC/104 and PC/104+; 15.4 Other PC Buses; 15.5 SBus; 15.6 NuBus; 15.7 External Buses; 15.8 Backward Compatibility; 15.9 Quick Reference; Chapter 16: Physical Layout of the Kernel Source; 16.1 Booting the Kernel; 16.2 Before Booting; 16.3 The init Process; 16.4 The kernel Directory; 16.5 The fs Directory; 16.6 The mm Directory; 16.7 The net directory; 16.8 ipc and lib; 16.9 include and arch; 16.10 Drivers; Bibliography; Colophon;