Essential Linux Device Drivers

Hardcover (Print)
Buy New
Buy New from BN.com
$38.44
Used and New from Other Sellers
Used and New from Other Sellers
from $21.60
Usually ships in 1-2 business days
(Save 60%)
Other sellers (Hardcover)
  • All (9) from $21.60   
  • New (6) from $38.43   
  • Used (3) from $21.60   

Overview

“Probably the most wide ranging and complete Linux device driver book I’ve read.”

--Alan Cox, Linux Guru and Key Kernel Developer

“Very comprehensive and detailed, covering almost every single Linux device driver type.”

--Theodore Ts’o, First Linux Kernel Developer in North America and Chief Platform Strategist of the Linux Foundation

The Most Practical Guide to Writing Linux Device Drivers

Linux now offers an exceptionally robust environment for driver development: with today’s kernels, what once required years of development time can be accomplished in days. In this practical, example-driven book, one of the world’s most experienced Linux driver developers systematically demonstrates how to develop reliable Linux drivers for virtually any device. Essential Linux Device Drivers is for any programmer with a working knowledge of operating systems and C, including programmers who have never written drivers before. Sreekrishnan Venkateswaran focuses on the essentials, bringing together all the concepts and techniques you need, while avoiding topics that only matter in highly specialized situations. Venkateswaran begins by reviewing the Linux 2.6 kernel capabilities that are most relevant to driver developers. He introduces simple device classes; then turns to serial buses such as I2C and SPI; external buses such as PCMCIA, PCI, and USB; video, audio, block, network, and wireless device drivers; user-space drivers; and drivers for embedded Linux–one of today’s fastest growing areas of Linux development. For each, Venkateswaran explains the technology, inspects relevant kernel source files, and walks through developing a complete example.

• Addresses drivers discussed in no other book, including drivers for I2C, video, sound, PCMCIA, and different types of flash memory

• Demystifies essential kernel services and facilities, including kernel threads and helper interfaces

• Teaches polling, asynchronous notification, and I/O control

• Introduces the Inter-Integrated Circuit Protocol for embedded Linux drivers

• Covers multimedia device drivers using the Linux-Video subsystem and Linux-Audio framework

• Shows how Linux implements support for wireless technologies such as Bluetooth, Infrared, WiFi, and cellular networking

• Describes the entire driver development lifecycle, through debugging and maintenance

• Includes reference appendixes covering Linux assembly, BIOS calls, and Seq files

Read More Show Less

Product Details

Meet the Author

Sreekrishnan Venkateswaran has spent more than a decade working in IBM product development laboratories. He has ported Linux to devices ranging from wristwatches and music players to PDAs, VoIP phones, and even pacemaker programmers. He was a Contributing Editor and kernel columnist for Linux Magazine for more than two years.

Read More Show Less

Read an Excerpt

PrefaceEssential Linux Device Drivers

by Sreekrishnan VenkiteswaranPreface

It was the late nineties and at IBM, we were putting the Linux kernel on a wrist watch. The target device was tiny, but the task was turning out to be tough. The Memory Technology Devices subsystem didn't exist in the kernel, which meant that before a filesystem could start life on the watch's flash memory, we had to develop the necessary storage driver from scratch. Interfacing the watch's touch screen with user applications was complicated since the kernel's input event driver interface hadn't been conceived yet. Getting X-Windows to run on the watch's LCD wasn't easy since it didn't work well with framebuffer drivers. Of what use is a water-proof Linux wrist watch if you can't stream stock quotes from your bath tub? Bluetooth integration with Linux was several years away, and months were spent porting a proprietary Bluetooth stack to Internet-enable the watch. Power management support was good enough only to squeeze a few hours of juice from the watch's battery, hence we had work cut out on that front too. Linux-Infrared was still unstable, so we had to coax the stack before we could use an Infrared keyboard for data entry. And we had to compile the compiler and cross-compile a compact application-set since there were no accepted distributions in the consumer electronics space.

Fast forward to the present: The baby penguin has grown into a healthy teenager. What took thousands of lines of code and a year in development back then, can be accomplished in a few days with the current kernels. But to become a versatilekernel engineer who can magically weave solutions, you need to understand the myriad features and facilities that Linux offers today.About the Book

Among the various subsystems residing in the kernel source tree, the drivers/directory constitutes the single largest chunk and is several times bigger than the others. With new and diverse technologies arriving in popular form factors, the development of new device drivers in the kernel is accelerating steadily. The latest kernels support over 50 device driver families.

This book is about writing Linux device drivers. It covers the design and development of major device classes supported by the kernel, including those I missed during my Linux-on-Watch days. The discussion of each driver family starts by looking at the corresponding technology, moves on to develop a practical example, and ends by looking at relevant kernel source files. But before foraying into the world of device drivers, the book introduces you to the kernel and discusses the important features of 2.6 Linux, emphasizing those portions that are of special interest to device driver writers.Audience

This book is intended for the intermediate-level programmer eager to tweak the kernel to enable new devices. You should have a working knowledge of operating system concepts. For example, you should know what a system call is, and why concurrency issues have to be factored in while writing kernel code. The book assumes that you have downloaded Linux on your system, poked through the kernel sources, and at least skimmed through some related documentation. And you should be pretty good in C. Summary of Chapters

The first three chapters prepare you to digest the rest of the book. Each of the next fifteen chapters discusses drivers for a specific device family. The following chapter is a hold-all for driver classes not covered thus far. The penultimate chapter discusses device driver debugging. The last chapter gives some perspective on delivery and maintenance.

Chapter 1, "Introduction," starts our tryst with Linux. It hurries you through downloading the kernel sources, making trivial code changes, and building a bootable kernel image.

Chapter 2, "A Peek Inside the Kernel," takes a brisk peek into the innards of the Linux kernel and teaches you some must-know kernel concepts. It first takes you through the boot process and then describes kernel services particularly relevant to driver development such as kernel threads, timers, concurrency, and memory management.

Chapter 3, "Getting Started with Device Drivers," gets you started with the art of writing Linux device drivers. It looks at interrupt handling, the new Linux device model, and Linux assembly. In this chapter, you'll also learn to use kernel helper interfaces such as linked lists, work queues, completion functions, and notifier chains. These helper facilities simplify your code, weed out redundancies from the kernel, and help long-term maintenance.

Chapter 4, "Character Drivers," looks at the architecture of character device drivers. Several concepts introduced in this chapter such as polling, asynchronous notification, and I/O control, are relevant to subsequent chapters as well, since many device classes discussed in the rest of the book are 'super' character devices.

Chapter 5, "Serial Drivers," explains the kernel layer that handles serial devices. The serial layer consists of low-level drivers, the TTY layer, and line disciplines.

Chapter 6, "Input Drivers," discusses the kernel's input subsystem that is responsible for servicing devices such as keyboards, mice, and touch panels.

Chapter 7, "The Inter-Integrated Circuit Protocol," dissects drivers for devices such as EEPROMs that are connected to the system I2C bus or SMBus. The chapter also looks at other serial technologies such as the SPI bus and one-wire bus.

Chapter 8,"PCMCIA and Compact Flash," delves into the PCMCIA subsystem. It teaches you to write drivers for devices having a PCMCIA or Compact Flash form factor.

Chapter 9, "Peripheral Component Interconnect," looks at kernel support for PCI and its derivatives such as CardBus and PCI Express.

Chapter 10, "Universal Serial Bus," explores USB architecture and device drivers.

Chapter 11, "Video Drivers," explains the Linux video family.

Chapter 12, "Audio Drivers," describes the Linux audio family.

Chapter 13, "Block Drivers," covers drivers for devices such as IDE and SCSI. It also looks at filesystem drivers.

Chapter 14, "Network Interface Cards," is dedicated to network devices. You'll learn about kernel networking data structures and how to interface network drivers with protocol layers.

Chapter 15, "Linux Without Wires," looks at driving different wireless technologies such as Bluetooth, Infrared, WiFi and cellular communication.

Chapter 16, "Memory Technology Devices," discusses flash memory enablement. This chapter first looks at flash-based protocols and chipsets primarily used on embedded devices. It ends by examining drivers for the Firmware Hub found on desktops and laptops.

Chapter 17, "Embedding Linux," steps into the world of embedded Linux. It takes you through the main firmware components of an embedded solution, such as bootloader, kernel, and device drivers. Given the soaring popularity of Linux in the embedded space, it's likely that you'll use the device driver skills that you acquire from this book, to enable embedded devices.

Chapter 18, "User Mode Drivers," looks at driving different types of devices from user space. Some device drivers, especially ones that are heavy on policy and light on performance requirements, are better off residing in user land. This chapter also explains how the new ultra-scalable process scheduler improves response times of user mode drivers.

Chapter 19, "More Devices and Drivers," takes a tour of a potpourri of driver families not covered thus far, such as Error Detection And Correction (EDAC), cpufreq, FireWire and ACPI.

Chapter 20, "Debugging Device Drivers," teaches about different types of debuggers that you can use to debug kernel code. In this chapter, you'll also learn to use trace tools, kernel probes, crash-dump, and profilers. When you develop a driver, be armed with the driver debugging skills that you learn in this chapter.

Chapter 21, "Delivery and Maintenance," provides perspective on the software life cycle and ponders What next?

The book is generally organized according to device and bus complexity, coupled with practical reasons of dependencies between chapters. So, we start off with basic device classes such as character, serial, and input. Next, we look at simple serial buses such as I2C and SMBus. External buses such as PCMCIA, PCI and USB follow. Video, audio, block, and network devices usually interface with the system via I/O buses, so we look at them soon after. The next three chapters are oriented towards embedded Linux, and cover technologies such as wireless networking and flash memory. User space drivers are distilled out towards the end of the book.Conventions Used

Source code, function names and shell commands are written like this. The shell prompt used is "bash>". Filename are written in italics like this. Italics are also used to introduce new terms.

Some chapters modify original kernel source files while implementing code examples. To clearly point out the changes, newly inserted code lines are prefixed with '+', and any deleted code lines with '-'.

Sometimes, for simplicity, the book uses generic references. So if the text points you to the arch/your-arch/ directory, it should be translated for example, to arch/i386/ if you are compiling the kernel for the x86 architecture. Similarly, any mention of the include/asm-your-arch/ directory should be read as include/asm-ppc/ if you are for instance, building the kernel for the POWER architecture. The '*' symbol and 'X' are occasionally used as a wild card character in filenames. So, if a chapter asks you to look at include/linux/time*.h, look at the header files, time.h, timer.h, times.h and timex.h, residing in the include/linux/ directory. If a section talks about /dev/input/eventX or /sys/devices/platform/i8042/serioX/, X is the interface number assigned to your device in the context of your system configuration.

Simple regular expressions are occasionally used to compactly list function prototypes. For example, the section "Direct Memory Access" in Chapter 9, "Peripheral Component Interconnect", refers to pci_mapunmapdma_sync_single() instead of explicitly citing pci_map_single(), pci_umap_single(), and pci_dma_sync_single().

Several chapters refer you to user space configuration files. For example, the section that describes the boot process opens /etc/rc.sysinit, while the chapter on PCMCIA drivers flips through /etc/pcmcia/config. The exact names and locations of such files might, however, vary according to the Linux distribution you use.Dedication

This book is dedicated to the ten million visually impaired citizens of India. All author proceeds will go to their cause.

© Copyright Pearson Education. All rights reserved.

Read More Show Less

Table of Contents

Foreword xxi

Preface xxiii

Acknowledgments xxix

About the Author xxx

Chapter 1 Introduction 1

Evolution 2

The GNU Copyleft 3

Kernelorg 4

Mailing Lists and Forums 4

Linux Distributions 5

Looking at the Sources 6

Building the Kernel 10

Loadable Modules 12

Before Starting 14

Chapter 2 A Peek Inside the Kernel 17

Booting Up 18

Kernel Mode and User Mode 30

Process Context and Interrupt Context 30

Kernel Timers 31

HZ and Jiffies 31

Long Delays 33

Short Delays 36

Pentium Time Stamp Counter 36

Real Time Clock 37

Concurrency in the Kernel 39

Spinlocks and Mutexes 39

Atomic Operators 45

Reader-Writer Locks 46

Debugging 48

Process Filesystem 49

Allocating Memory 49

Looking at the Sources 52

Chapter 3 Kernel Facilities 55

Kernel Threads 56

Creating a Kernel Thread 56

Process States and Wait Queues 61

User Mode Helpers 63

Helper Interfaces 65

Linked Lists 65

Hash Lists 72

Work Queues 72

Notifier Chains 74

Completion Interface 78

Kthread Helpers 81

Error-Handling Aids 83

Looking at the Sources 85

Chapter 4 Laying the Groundwork 89

Introducing Devices and Drivers 90

Interrupt Handling 92

Interrupt Context 92

Assigning IRQs 94

Device Example: Roller Wheel 94

Softirqs and Tasklets 99

The Linux Device Model 103

Udev 103

Sysfs, Kobjects, and Device Classes 106

Hotplug and Coldplug 110

Microcode Download 111

Module Autoload 112

Memory Barriers 114

Power Management 114

Looking at the Sources 115

Chapter 5 Character Drivers 119

Char Driver Basics 120

Device Example: System CMOS 121

Driver Initialization 122

Open and Release 127

Exchanging Data 129

Seek 136

Control 137

Sensing Data Availability 139

Poll 139

Fasync 142

Talking to the Parallel Port 145

Device Example: Parallel Port LED Board 146

RTC Subsystem 156

Pseudo Char Drivers 157

Misc Drivers 160

Device Example: Watchdog Timer 160

Character Caveats 166

Looking at the Sources 167

6556_Bookindb i6556_ix 3/4/08 9:31:21 AM

Chapter 6 Serial Drivers 171

Layered Architecture 173

UART Drivers 176

Device Example: Cell Phone 178

RS-485 191

TTY Drivers 192

Line Disciplines 194

Device Example: Touch Controller 195

Looking at the Sources 205

Chapter 7 Input Drivers 207

Input Event Drivers 210

The Evdev Interface 210

Input Device Drivers 216

Serio 217

Keyboards 217

Mice 220

Touch Controllers 227

Accelerometers 228

Output Events 228

Debugging 230

Looking at the Sources 231

Chapter 8 The Inter-Integrated Circuit Protocol 233

What’s I2C/SMBus? 234

I2C Core 235

Bus Transactions 237

Device Example: EEPROM 238

Initializing 238

Probing the Device 241

Checking Adapter Capabilities 244

Accessing the Device 244

More Methods 246

Device Example: Real Time Clock 247

I2C-dev 251

Hardware Monitoring Using LM-Sensors 251

The Serial Peripheral Interface Bus 251

The 1-Wire Bus 254

Debugging 254

Looking at the Sources 255

Chapter 9 PCMCIA and Compact Flash 257

What’s PCMCIA/CF? 258

Linux-PCMCIA Subsystem 260

Host Controller Drivers 262

PCMCIA Core 263

Driver Services 263

Client Drivers 264

Data Structures 264

Device Example: PCMCIA Card 267

Tying the Pieces Together 271

PCMCIA Storage 272

Serial PCMCIA 272

Debugging 273

Looking at the Sources 275

Chapter 10 Peripheral Component Interconnect 277

The PCI Family 278

Addressing and Identification 281

Accessing PCI Regions 285

Configuration Space 285

I/O and Memory 286

Direct Memory Access 288

Device Example: Ethernet-Modem Card 292

Initializing and Probing 293

Data Transfer 301

Debugging 308

Looking at the Sources 308

Chapter 11 Universal Serial Bus 311

USB Architecture 312

Bus Speeds 314

Host Controllers 315

Transfer Types 315

Addressing 316

Linux-USB Subsystem 317

Driver Data Structures 317

The usb_device Structure 318

USB Request Blocks 319

Pipes 321

Descriptor Structures 322

Enumeration 324

Device Example: Telemetry Card 324

Initializing and Probing 325

Accessing Registers 332

Data Transfer 335

Class Drivers 338

Mass Storage 339

USB-Serial 345

Human Interface Devices 348

Bluetooth 348

Gadget Drivers 348

Debugging 349

Looking at the Sources 351

Chapter 12 Video Drivers 355

Display Architecture 356

Linux-Video Subsystem 359

Display Parameters 361

The Frame Buffer API 362

Frame Buffer Drivers 365

Device Example: Navigation System 365

Console Drivers 380

Device Example: Cell Phone Revisited 382

Boot Logo 387

Debugging 387

Looking at the Sources 388

Chapter 13 Audio Drivers 391

Audio Architecture 392

Linux-Sound Subsystem 394

Device Example: MP3 Player 396

Driver Methods and Structures 399

ALSA Programming 409

Debugging 412

Looking at the Sources 412

Chapter 14 Block Drivers 415

Storage Technologies 416

Linux Block I/O Layer 421

I/O Schedulers 422

Block Driver Data Structures and Methods 423

Device Example: Simple Storage Controller 426

Initialization 427

Block Device Operations 430

Disk Access 432

Advanced Topics 434

Debugging 436

Looking at the Sources 437

Chapter 15 Network Interface Cards 439

Driver Data Structures 440

Socket Buffers 441

The Net Device Interface 443

Activation 444

Data Transfer 444

Watchdog 445

Statistics 445

Configuration 446

Bus Specific 448

Talking with Protocol Layers 448

Receive Path 448

Transmit Path 449

Flow Control 449

Buffer Management and Concurrency Control 450

Device Example: Ethernet NIC 451

ISA Network Drivers 457

Asynchronous Transfer Mode 458

Network Throughput 459

Driver Performance 459

Protocol Performance 461

Looking at the Sources 461

Chapter 16 Linux Without Wires 465

Bluetooth 467

BlueZ 469

Device Example: CF Card 471

Device Example: USB Adapter 471

RFCOMM 473

Networking 475

Human Interface Devices 477

Audio 477

Debugging 478

Looking at the Sources 478

Infrared 478

Linux-IrDA 480

Device Example: Super I/O Chip 482

Device Example: IR Dongle 483

IrComm 486

Networking 486

IrDA Sockets 487

Linux Infrared Remote Control 488

Looking at the Sources 489

WiFi 489

Configuration 490

Device Drivers 494

Looking at the Sources 496

Cellular Networking 496

GPRS 496

CDMA 498

Current Trends 500

Chapter 17 Memory Technology Devices 503

What’s Flash Memory? 504

Linux-MTD Subsystem 505

Map Drivers 506

Device Example: Handheld 506

NOR Chip Drivers 511

NAND Chip Drivers 513

User Modules 516

Block Device Emulation 516

Char Device Emulation 517

JFFS2 517

YAFFS2 518

MTD-Utils 518

Configuring MTD 519

eXecute In Place 520

The Firmware Hub 520

Debugging 524

Looking at the Sources 524

Chapter 18 Embedding Linux 527

Challenges 528

Component Selection 530

Tool Chains 531

Embedded Bootloaders 531

Memory Layout 535

Kernel Porting 537

Embedded Drivers 538

Flash Memory 538

UART 539

Buttons and Wheels 539

PCMCIA/CF 540

SD/MMC 540

USB 540

RTC 541

Audio 541

Touch Screen 541

Video 541

CPLD/FPGA 542

Connectivity 542

Domain-Specific Electronics 542

More Drivers 543

The Root Filesystem 544

NFS-Mounted Root 544

Compact Middleware 546

Test Infrastructure 548

Debugging 548

Board Rework 549

Debuggers 550

Chapter 19 Drivers in User Space 551

Process Scheduling and Response Times 553

The Original Scheduler 553

The O(1) Scheduler 553

The CFS Scheduler 555

Response Times 555

Accessing I/O Regions 558

Accessing Memory Regions 562

User Mode SCSI 565

User Mode USB 567

User Mode I2C 571

UIO 573

Looking at the Sources 574

Chapter 20 More Devices and Drivers 577

ECC Reporting 578

Device Example: ECC-Aware Memory Controller 579

Frequency Scaling 583

Embedded Controllers 584

ACPI 585

ISA and MCA 587

FireWire 588

Intelligent Input/Output 589

Amateur Radio 590

Voice over IP 590

High-Speed Interconnects 591

InfiniBand 592

RapidIO 592

Fibre Channel 592

iSCSI 593

Chapter 21 Debugging Device Drivers 595

Kernel Debuggers 596

Entering a Debugger 597

Kernel Debugger (kdb) 598

Kernel GNU Debugger (kgdb) 600

GNU Debugger (gdb) 604

JTAG Debuggers 605

Downloads 609

Kernel Probes 609

Kprobes 609

Jprobes 614

Return Probes 617

Limitations 619

Looking at the Sources 620

Kexec and Kdump 620

Kexec 620

Kexec with Kdump 621

Kdump 622

Looking at the Sources 629

Profiling 629

Kernel Profiling with OProfile 629

Application Profiling with Gprof 633

Tracing 634

Linux Trace Toolkit 634

Linux Test Project 638

User Mode Linux 638

Diagnostic Tools 638

Kernel Hacking Config Options 639

Test Equipment 640

Chapter 22 Maintenance and Delivery 641

Coding Style 642

Change Markers 642

Version Control 643

Consistent Checksums 643

Build Scripts 645

Portable Code 647

Chapter 23 Shutting Down 649

Checklist 650

What Next? 651

Appendix A Linux Assembly 653

Debugging 659

Appendix B Linux and the BIOS 661

Real Mode Calls 662

Protected Mode Calls 665

BIOS and Legacy Drivers 666

Appendix C Seq Files 669

The Seq File Advantage 670

Updating the NVRAM Driver 677

Looking at the Sources 679

Index 681

Read More Show Less

Preface

Essential Linux Device Drivers

by Sreekrishnan Venkiteswaran

Preface

It was the late nineties and at IBM, we were putting the Linux kernel on a wrist watch. The target device was tiny, but the task was turning out to be tough. The Memory Technology Devices subsystem didn't exist in the kernel, which meant that before a filesystem could start life on the watch's flash memory, we had to develop the necessary storage driver from scratch. Interfacing the watch's touch screen with user applications was complicated since the kernel's input event driver interface hadn't been conceived yet. Getting X-Windows to run on the watch's LCD wasn't easy since it didn't work well with framebuffer drivers. Of what use is a water-proof Linux wrist watch if you can't stream stock quotes from your bath tub? Bluetooth integration with Linux was several years away, and months were spent porting a proprietary Bluetooth stack to Internet-enable the watch. Power management support was good enough only to squeeze a few hours of juice from the watch's battery, hence we had work cut out on that front too. Linux-Infrared was still unstable, so we had to coax the stack before we could use an Infrared keyboard for data entry. And we had to compile the compiler and cross-compile a compact application-set since there were no accepted distributions in the consumer electronics space.

Fast forward to the present: The baby penguin has grown into a healthy teenager. What took thousands of lines of code and a year in development back then, can be accomplished in a few days with the current kernels. But to become a versatile kernel engineer who can magically weave solutions, you need to understand the myriad features and facilities that Linux offers today.

About the Book

Among the various subsystems residing in the kernel source tree, the drivers/directory constitutes the single largest chunk and is several times bigger than the others. With new and diverse technologies arriving in popular form factors, the development of new device drivers in the kernel is accelerating steadily. The latest kernels support over 50 device driver families.

This book is about writing Linux device drivers. It covers the design and development of major device classes supported by the kernel, including those I missed during my Linux-on-Watch days. The discussion of each driver family starts by looking at the corresponding technology, moves on to develop a practical example, and ends by looking at relevant kernel source files. But before foraying into the world of device drivers, the book introduces you to the kernel and discusses the important features of 2.6 Linux, emphasizing those portions that are of special interest to device driver writers.

Audience

This book is intended for the intermediate-level programmer eager to tweak the kernel to enable new devices. You should have a working knowledge of operating system concepts. For example, you should know what a system call is, and why concurrency issues have to be factored in while writing kernel code. The book assumes that you have downloaded Linux on your system, poked through the kernel sources, and at least skimmed through some related documentation. And you should be pretty good in C.

Summary of Chapters

The first three chapters prepare you to digest the rest of the book. Each of the next fifteen chapters discusses drivers for a specific device family. The following chapter is a hold-all for driver classes not covered thus far. The penultimate chapter discusses device driver debugging. The last chapter gives some perspective on delivery and maintenance.

Chapter 1, "Introduction," starts our tryst with Linux. It hurries you through downloading the kernel sources, making trivial code changes, and building a bootable kernel image.

Chapter 2, "A Peek Inside the Kernel," takes a brisk peek into the innards of the Linux kernel and teaches you some must-know kernel concepts. It first takes you through the boot process and then describes kernel services particularly relevant to driver development such as kernel threads, timers, concurrency, and memory management.

Chapter 3, "Getting Started with Device Drivers," gets you started with the art of writing Linux device drivers. It looks at interrupt handling, the new Linux device model, and Linux assembly. In this chapter, you'll also learn to use kernel helper interfaces such as linked lists, work queues, completion functions, and notifier chains. These helper facilities simplify your code, weed out redundancies from the kernel, and help long-term maintenance.

Chapter 4, "Character Drivers," looks at the architecture of character device drivers. Several concepts introduced in this chapter such as polling, asynchronous notification, and I/O control, are relevant to subsequent chapters as well, since many device classes discussed in the rest of the book are 'super' character devices.

Chapter 5, "Serial Drivers," explains the kernel layer that handles serial devices. The serial layer consists of low-level drivers, the TTY layer, and line disciplines.

Chapter 6, "Input Drivers," discusses the kernel's input subsystem that is responsible for servicing devices such as keyboards, mice, and touch panels.

Chapter 7, "The Inter-Integrated Circuit Protocol," dissects drivers for devices such as EEPROMs that are connected to the system I2C bus or SMBus. The chapter also looks at other serial technologies such as the SPI bus and one-wire bus.

Chapter 8,"PCMCIA and Compact Flash," delves into the PCMCIA subsystem. It teaches you to write drivers for devices having a PCMCIA or Compact Flash form factor.

Chapter 9, "Peripheral Component Interconnect," looks at kernel support for PCI and its derivatives such as CardBus and PCI Express.

Chapter 10, "Universal Serial Bus," explores USB architecture and device drivers.

Chapter 11, "Video Drivers," explains the Linux video family.

Chapter 12, "Audio Drivers," describes the Linux audio family.

Chapter 13, "Block Drivers," covers drivers for devices such as IDE and SCSI. It also looks at filesystem drivers.

Chapter 14, "Network Interface Cards," is dedicated to network devices. You'll learn about kernel networking data structures and how to interface network drivers with protocol layers.

Chapter 15, "Linux Without Wires," looks at driving different wireless technologies such as Bluetooth, Infrared, WiFi and cellular communication.

Chapter 16, "Memory Technology Devices," discusses flash memory enablement. This chapter first looks at flash-based protocols and chipsets primarily used on embedded devices. It ends by examining drivers for the Firmware Hub found on desktops and laptops.

Chapter 17, "Embedding Linux," steps into the world of embedded Linux. It takes you through the main firmware components of an embedded solution, such as bootloader, kernel, and device drivers. Given the soaring popularity of Linux in the embedded space, it's likely that you'll use the device driver skills that you acquire from this book, to enable embedded devices.

Chapter 18, "User Mode Drivers," looks at driving different types of devices from user space. Some device drivers, especially ones that are heavy on policy and light on performance requirements, are better off residing in user land. This chapter also explains how the new ultra-scalable process scheduler improves response times of user mode drivers.

Chapter 19, "More Devices and Drivers," takes a tour of a potpourri of driver families not covered thus far, such as Error Detection And Correction (EDAC), cpufreq, FireWire and ACPI.

Chapter 20, "Debugging Device Drivers," teaches about different types of debuggers that you can use to debug kernel code. In this chapter, you'll also learn to use trace tools, kernel probes, crash-dump, and profilers. When you develop a driver, be armed with the driver debugging skills that you learn in this chapter.

Chapter 21, "Delivery and Maintenance," provides perspective on the software life cycle and ponders What next?

The book is generally organized according to device and bus complexity, coupled with practical reasons of dependencies between chapters. So, we start off with basic device classes such as character, serial, and input. Next, we look at simple serial buses such as I2C and SMBus. External buses such as PCMCIA, PCI and USB follow. Video, audio, block, and network devices usually interface with the system via I/O buses, so we look at them soon after. The next three chapters are oriented towards embedded Linux, and cover technologies such as wireless networking and flash memory. User space drivers are distilled out towards the end of the book.

Conventions Used

Source code, function names and shell commands are written like this. The shell prompt used is "bash". Filename are written in italics like this. Italics are also used to introduce new terms.

Some chapters modify original kernel source files while implementing code examples. To clearly point out the changes, newly inserted code lines are prefixed with '+', and any deleted code lines with '-'.

Sometimes, for simplicity, the book uses generic references. So if the text points you to the arch/your-arch/ directory, it should be translated for example, to arch/i386/ if you are compiling the kernel for the x86 architecture. Similarly, any mention of the include/asm-your-arch/ directory should be read as include/asm-ppc/ if you are for instance, building the kernel for the POWER architecture. The '*' symbol and 'X' are occasionally used as a wild card character in filenames. So, if a chapter asks you to look at include/linux/time*.h, look at the header files, time.h, timer.h, times.h and timex.h, residing in the include/linux/ directory. If a section talks about /dev/input/eventX or /sys/devices/platform/i8042/serioX/, X is the interface number assigned to your device in the context of your system configuration.

Simple regular expressions are occasionally used to compactly list function prototypes. For example, the section "Direct Memory Access" in Chapter 9, "Peripheral Component Interconnect", refers to pci_mapunmapdma_sync_single() instead of explicitly citing pci_map_single(), pci_umap_single(), and pci_dma_sync_single().

Several chapters refer you to user space configuration files. For example, the section that describes the boot process opens /etc/rc.sysinit, while the chapter on PCMCIA drivers flips through /etc/pcmcia/config. The exact names and locations of such files might, however, vary according to the Linux distribution you use.

Dedication

This book is dedicated to the ten million visually impaired citizens of India. All author proceeds will go to their cause.

© Copyright Pearson Education. All rights reserved.

Read More Show Less

Customer Reviews

Average Rating 3
( 2 )
Rating Distribution

5 Star

(0)

4 Star

(1)

3 Star

(0)

2 Star

(1)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 2 Customer Reviews
  • Posted October 29, 2012

    Well written, advanced read.

    This is my favorite reference, but it may not be the best intro book. LDD3 is probably a bit better as an introduction, but it is also a little outdated. I would recommend LDD3 to start with, but add this to your library as your main reference.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted April 13, 2008

    thorough discussion

    Writing a device driver in linux is not for the faint hearted. As this book makes clear, it requires the intersection of a set of skills. C programming, for one. Apparently, all serious [ie. practical] driver coding is done in C. There is no need for the higher level object oriented languages like C++ or Java. Plus, drivers often need the utmost in efficiency, and C appears best for this. It should be said that the book does not really argue for the use of any other language. Code snippets are in C, and that's it. But an associated reason is that linux itself [not just its device drivers] is written in C. And if you want to study other device drivers, these are invariably also done in C. An important idea explicated in the book is to use prior drivers as inspiration. See how they work. Often, you can borrow as much of their source code as you wish, if those drivers were released as open source. In fact, you are shown how to find archives of drivers. Very useful. Another skill described in the book is a close acquaintance with various types of hardware that need drivers. The hardware might be a mouse, joystick or trackball. These have fairly low bandwidths. But the book also explains drivers for disks and memories [think flash cards or USB drives], where the bandwidth needs are far greater. The book also explains why linux is so popular for the writing of drivers. Turns out that the kernel abstraction has layers that insulate the upper level operating system and applications from the gritty hardware details. Alas, for those writing drivers, it is these gritty details that you must contend with. One slight puzzle is the continual reference to PCMCIA. The book came out in 2008. I thought that several years before, the computer industry agreed to drop that acronym in favour of the simpler 'PC Card'.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 2 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)