Home Page Icon
Home Page
Table of Contents for
Cover
Close
Cover
by Alessandro Rubini
Linux Device Drivers
Linux Device Drivers
Preface
Audience of This Book
Organization of the Material
Background Information
Sources for Further Information
Relevant Books
Conventions Used in This Book
We’d Like to Hear from You
Acknowledgments
1. An Introduction to the Linux Kernel
The Role of the Driver Writer
Splitting the Kernel
Classes of Devices and Modules
Security Issues
Version Numbering
License Terms
Overview of the Book
2. Building and Running Modules
Modules Versus Applications
User Space and Kernel Space
Concurrency in the Kernel
Compiling and Loading
Version Dependency
The Kernel Symbol Table
Registering Symbol Tables
Initialization and Shutdown
Error Handling in init_module
The Usage Count
Unloading
Using Resources
Ports
ISA Memory
Automatic and Manual Configuration
Doing It in User Space
Quick Reference
3. Char Drivers
The Design of scull
Major and Minor Numbers
Dynamic Allocation of Major Numbers
Removing a Driver from the System
dev_t and kdev_t
File Operations
Overview of the Different Operations
The file Structure
Open and Release
The open Method
The release Method
Scull’s Memory Usage
Read and Write
The read Method
The write Method
Playing with the New Devices
Quick Reference
4. Debugging Techniques
Debugging by Printing
Printk
How Messages Get Logged
Using the Preprocessor to Ease Monitoring
Debugging by Querying
Using the /proc Filesystem
The ioctl Method
Debugging by Watching
Debugging System Faults
Oops Messages
Using ksymoops
Using oops
Using klogd
System Hangs
Using a Debugger
Using gdb
Using kdebug
Remote Debugging
5. Enhanced Char Driver Operations
ioctl
Choosing the ioctl Commands
The Return Value
The Predefined Commands
Using the ioctl Argument
Device Control Without ioctl
Blocking I/O
Going to Sleep and Awakening
Writing Reentrant Code
Wait Queues
Blocking and Nonblocking Operations
A Sample Implementation: scullpipe
Select
Interaction with read and write
Reading data from the device
Writing to the device
Flushing pending output
The Underlying Data Structure
Asynchronous Notification
The Driver’s Point of View
Seeking a Device
The lseek Implementation
Access Control on a Device File
Single-Open Devices
Restricting Access to a Single User at a Time
Blocking Open as an Alternative to EBUSY
Cloning the Device on Open
Quick Reference
6. Flow of Time
Time Intervals in the Kernel
Knowing the Current Time
Delaying Execution
Long Delays
Short Delays
Task Queues
The Nature of Task Queues
Predefined Task Queues
How the examples work
The scheduler queue
The timer queue
The immediate queue
Running Your Own Task Queues
Kernel Timers
The New Timer List
Quick Reference
7. Getting Hold of Memory
The Real Story of kmalloc
The Priority Argument
The Size Argument
get_free_page and Friends
A scull Using Whole Pages: scullp
vmalloc and Friends
A scull Using Virtual Addresses: scullv
Playing Dirty
Quick Reference
8. Hardware Management
Using I/O Ports
Platform Dependencies
Pausing I/O
String Operations
Using the Parallel Port
Basics of the Parallel Port
A Sample Driver
Accessing Memory on Device Boards
ISA Memory Below 1M
ISA Memory Above 1M
High PCI Memory
Accessing the Text-Mode Video Buffer
Quick Reference
9. Interrupt Handling
Preparing the Parallel Port
Installing an Interrupt Handler
The /proc Interface
Autodetecting the IRQ Number
Kernel-helped probing
Do-it-yourself probing
Fast and Slow Handlers
The internals of interrupt handling on the x86
Implementing a Handler
Using Arguments
Enabling and Disabling Interrupts
Bottom Halves
The Design of Bottom Halves
Writing a Bottom Half
Interrupt Sharing
Installing a Shared Handler
Running the Handler
The /proc Interface
Interrupt-Driven I/O
Race Conditions
Using Circular Buffers
Disabling Interrupts
Using Lock Variables
Bit operations
Atomic integer operations
Going to Sleep Without Races
Version Dependencies of IRQ Handling
Different Prototypes for request_irq
Probing the IRQ Line
Quick Reference
10. Judicious Use of Data Types
Use of Standard C Types
Assigning an Explicit Size to Data Items
Interface-Specific Types
Other Portability Issues
Quick Reference
11. Kerneld and Advanced Modularization
Loading Modules on Demand
The User-Level Side
The Kernel-Level Side
Version Control in Modules
Using Version Support in Modules
Exporting Versioned Symbols
Persistent Storage Across Unload/Load
Quick Reference
12. Loading Block Drivers
Registering the Driver
The Header File blk.h
Handling Requests
Performing the Actual Data Transfer
Clustered Requests
How Mounting Works
The ioctl Method
Removable Devices
check_media_change
revalidate
Extra Care
Partitionable Devices
The Generic Hard Disk
Partition Detection in the Kernel
Partition Detection in Modules
Partition Detection Using Initrd
The Device Methods for spull
Interrupt-Driven Block Drivers
Quick Reference
13. Mmap and DMA
Memory Management in Linux
Page Tables
Virtual Memory Areas
The Memory Map
The mmap Device Operation
A Simple Implementation
Maintaining the Usage Count
Supporting the mremap System Call
Remapping Specific I/O Regions
Remapping RAM
Playing with the reserved bit
Implementing the nopage method
Remapping Virtual Addresses
Direct Memory Access
Overview of a DMA Data Transfer
Allocating the DMA Buffer
Do-it-yourself allocation
Bus Addresses
DMA for ISA devices
Registering DMA usage
Talking to the DMA controller
DMA and PCI Devices
Quick Reference
14. Network Drivers
How snull Is Designed
Assigning IP Numbers
The Physical Transport of Packets
Connecting to the Kernel
Module Loading
Initializing Each Device
Module Unloading
Modularized and Non-Modularized Drivers
The device Structure in Detail
The Visible Head
The Hidden Fields
Interface information
The device methods
Utility fields
Opening and Closing
Packet Transmission
Packet Reception
Interrupt-Driven Operation
The Socket Buffers
The Important Fields
Functions Acting on Socket Buffers
Address Resolution
Using ARP with Ethernet
Overriding ARP
Non-Ethernet Headers
Load-Time Configuration
Run-Time Configuration
Custom ioctl Commands
Statistical Information
Multicasting
Kernel Support for Multicasting
A Typical Implementation
Quick Reference
15. Overview of Peripheral Buses
The PCI Interface
PCI Addressing
Boot Time
Detecting the Device
Accessing the Configuration Space
Looking at a configuration snapshot
Accessing the I/O and Memory Spaces
PCI Interrupts
A Look Back: ISA
Hardware Resources
ISA Programming
The ``Plug and Play'' Specification
Other PC Buses
MCA
EISA
VLB
Sbus
Quick Reference
16. Physical Layout of the Kernel Source
Booting the Kernel
Before Booting
Setting Up the X86 Processors
Booting a bare-bones zImage kernel
Booting a bare-bones bzImage kernel
Using lilo
Using loadlin
Other booters
Setting Up Alpha Processors
Setting Up Sparc Processors
The Init Process
The kernel Directory
sched.c
Process Control
Modularization
Other Operations
The mm Directory
Paging and Swapping
Allocation and Deallocation
Other Interfaces
The fs Directory
Exec and Binary Formats
devices.c and block_dev.c
The VFS: Superblocks
Inodes and Caching Techniques
open.c
read_write.c and readdir.c
select.c
Pipes and fifos
Control Functions
File Locks
Minor Files
Networking
IPC and lib Functions
Drivers
Char, Block, and Network Drivers
SCSI Drivers
Other Subdirectories
Architecture Dependencies
17. Recent Developments
Modularization
Exporting Symbols
Declaring Parameters
/proc/modules
File Operations
Prototype Differences
The poll Method
Accessing User Space
Using the New Interface
Task Queues
Interrupt Management
Bit Operations
Conversion Functions
vremap
Virtual Memory
Handling Kernel-Space Faults
Other Changes
Index
Colophon
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Linux Device Drivers
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset