Linux Device Drivers 3rd Edition.pdf

(7249 KB) Pobierz
,TITLE.9502
,TITLE.9502 Page i Thursday, January 27, 2005 12:06 PM
LINUX
DRIVERS
DEVICE
736052002.147.png 736052002.158.png 736052002.169.png 736052002.180.png 736052002.001.png 736052002.012.png 736052002.023.png 736052002.034.png 736052002.045.png 736052002.056.png 736052002.067.png 736052002.078.png 736052002.089.png 736052002.100.png 736052002.107.png 736052002.108.png 736052002.109.png 736052002.110.png 736052002.111.png 736052002.112.png 736052002.113.png 736052002.114.png 736052002.115.png 736052002.116.png 736052002.117.png 736052002.118.png 736052002.119.png 736052002.120.png 736052002.121.png 736052002.122.png 736052002.123.png 736052002.124.png 736052002.125.png 736052002.126.png 736052002.127.png 736052002.128.png 736052002.129.png
,TITLE.9502 Page ii Thursday, January 27, 2005 12:06 PM
Other Linux resources from O’Reilly
Related titles Understanding the Linux
Kernel
Linux in a Nutshell
Running Linux
Linux Network
Administrator’s Guide
Linux Pocket Guide
Building Embedded Linux
Systems
Designing Embedded
Hardware
Linux Books
Resource Center
linux.oreilly.com is a complete catalog of O’Reilly’s books on
Linux and Unix and related technologies, including sample
chapters and code examples.
ONLamp.com is the premier site for the open source web plat-
form: Linux, Apache, MySQL, and either Perl, Python, or PHP.
Conferences O’Reilly brings diverse innovators together to nurture the ideas
that spark revolutionary industries. We specialize in document-
ing the latest tools and systems, translating the innovator’s
knowledge into useful skills for those in the trenches. Visit con-
ferences.oreilly.com for our upcoming events.
Safari Bookshelf ( safari.oreilly.com ) is the premier online refer-
ence library for programmers and IT professionals. Conduct
searches across more than 1,000 books. Subscribers can zero in
on answers to time-critical questions in a matter of seconds.
Read the books on your Bookshelf from cover to cover or sim-
ply flip to the page you need. Try it today with a free trial.
736052002.130.png 736052002.131.png 736052002.132.png 736052002.133.png 736052002.134.png 736052002.135.png 736052002.136.png 736052002.137.png 736052002.138.png 736052002.139.png 736052002.140.png 736052002.141.png 736052002.142.png 736052002.143.png 736052002.144.png 736052002.145.png 736052002.146.png 736052002.148.png 736052002.149.png 736052002.150.png 736052002.151.png 736052002.152.png 736052002.153.png 736052002.154.png 736052002.155.png 736052002.156.png 736052002.157.png 736052002.159.png 736052002.160.png 736052002.161.png 736052002.162.png 736052002.163.png 736052002.164.png 736052002.165.png 736052002.166.png 736052002.167.png 736052002.168.png 736052002.170.png 736052002.171.png 736052002.172.png 736052002.173.png
,TITLE.9502 Page iii Thursday, January 27, 2005 12:06 PM
LINUX
DRIVERS
THIRD EDITION
Jonathan Corbet, Alessandro
Rubini, and Greg Kroah-Hartman
Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo
DEVICE
736052002.174.png 736052002.175.png 736052002.176.png 736052002.177.png 736052002.178.png 736052002.179.png 736052002.181.png 736052002.182.png 736052002.183.png 736052002.184.png 736052002.185.png 736052002.186.png 736052002.187.png 736052002.188.png 736052002.189.png 736052002.190.png 736052002.002.png 736052002.003.png 736052002.004.png 736052002.005.png 736052002.006.png 736052002.007.png 736052002.008.png 736052002.009.png 736052002.010.png 736052002.011.png 736052002.013.png 736052002.014.png 736052002.015.png 736052002.016.png 736052002.017.png 736052002.018.png 736052002.019.png 736052002.020.png 736052002.021.png 736052002.022.png 736052002.024.png 736052002.025.png
,COPYRIGHT.10321 Page iv Thursday, January 27, 2005 12:09 PM
Linux Device Drivers, Third Edition
by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman
Copyright © 2005, 2001, 1998 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles ( safari.oreilly.com ). For more information, contact our corporate/insti-
tutional sales department: (800) 998-9938 or corporate@oreilly.com .
Editor: Andy Oram
Production Editor: Matt Hutchinson
Production Services: Octal Publishing, Inc.
Cover Designer: Edie Freedman
Interior Designer: Melanie Wang
Printing History:
February 1998: First Edition.
June 2001: Second Edition.
February 2005: Third Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. The Linux series designations, Linux Device Drivers , images of the American West,
and related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors
assume no responsibility for errors or omissions, or for damages resulting from the use of the
information contained herein.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.0
License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.0/ or send a
letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
This book uses RepKover , a durable and flexible lay-flat binding.
ISBN: 0-596-00590-3
[M]
736052002.026.png 736052002.027.png 736052002.028.png 736052002.029.png 736052002.030.png 736052002.031.png 736052002.032.png 736052002.033.png 736052002.035.png 736052002.036.png 736052002.037.png 736052002.038.png 736052002.039.png 736052002.040.png 736052002.041.png 736052002.042.png 736052002.043.png 736052002.044.png 736052002.046.png 736052002.047.png 736052002.048.png 736052002.049.png 736052002.050.png 736052002.051.png 736052002.052.png 736052002.053.png 736052002.054.png 736052002.055.png 736052002.057.png 736052002.058.png 736052002.059.png 736052002.060.png 736052002.061.png 736052002.062.png 736052002.063.png 736052002.064.png 736052002.065.png
,ldr3TOC.fm.4587 Page v Thursday, January 20, 2005 9:30 AM
Table of Contents
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xi
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
v
736052002.066.png 736052002.068.png 736052002.069.png 736052002.070.png 736052002.071.png 736052002.072.png 736052002.073.png 736052002.074.png 736052002.075.png 736052002.076.png 736052002.077.png 736052002.079.png 736052002.080.png 736052002.081.png 736052002.082.png 736052002.083.png 736052002.084.png 736052002.085.png 736052002.086.png 736052002.087.png 736052002.088.png 736052002.090.png 736052002.091.png 736052002.092.png 736052002.093.png 736052002.094.png 736052002.095.png 736052002.096.png 736052002.097.png 736052002.098.png 736052002.099.png 736052002.101.png 736052002.102.png 736052002.103.png 736052002.104.png 736052002.105.png 736052002.106.png
Zgłoś jeśli naruszono regulamin