上传者: d418368326
|
上传时间: 2019-12-21 19:37:36
|
文件大小: 11.54MB
|
文件类型: pdf
Linux Device Driver (3edtion)原版
1. An Introduction to Device Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
The Role of the Device Driver 2
Splitting the Kernel 4
Classes of Devices and Modules 5
Security Issues 8
Version Numbering 10
License Terms 11
Joining the Kernel Development Community 12
Overview of the Book 12
2. Building and Running Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Setting Up Your Test System 15
The Hello World Module 16
Kernel Modules Versus Applications 18
Compiling and Loading 22
The Kernel Symbol Table 28
Preliminaries 30
Initialization and Shutdown 31
Module Parameters 35
Doing It in User Space 37
Quick Reference 39
3. Char Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
The Design of scull 42
Major and Minor Numbers 43
Some Important Data Structures 49
,ldr3TOC.fm.4587 Page v Thursday, January 20, 2005 9:30 AMvi | Table of Contents
Char Device Registration 55
open and release 58
scull’s Memory Usage 60
read and write 63
Playing with the New Devices 70
Quick Reference 70
4. Debugging Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Debugging Support in the Kernel 73
Debugging by Printing 75
Debugging by Querying 82
Debugging by Watching 91
Debugging System Faults 93
Debuggers and Related Tools 99
5. Concurrency and Race Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Pitfalls in scull 107
Concurrency and Its Management 107
Semaphores and Mutexes 109
Completions 114
Spinlocks 116
Locking Traps 121
Alternatives to Locking 123
Quick Reference 130
6. Advanced Char Driver Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
ioctl 135
Blocking I/O 147
poll and select 163
Asynchronous Notification 169
Seeking a Device 171
Access Control on a Device File 173
Quick Reference 179