[ Pobierz całość w formacie PDF ]
,TITLE.9502 Page i Thursday, January 27, 2005 12:06 PM
LINUX
DEVICE
DRIVERS
,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.
 ,TITLE.9502 Page iii Thursday, January 27, 2005 12:06 PM
LINUX
DEVICE
DRIVERS
THIRD EDITION
Jonathan Corbet, Alessandro
Rubini, and Greg Kroah-Hartman
Beijing
Cambridge
Farnham
Köln
Paris
Sebastopol
Taipei
Tokyo
•
•
•
•
•
•
•
,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
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]
,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
[ Pobierz całość w formacie PDF ]