The Linux Kernel Module Programming Guide

Peter Jay Salzman
Michael Burian
Ori Pomerantz

The Linux Kernel Module Programming Guide is a free book; you may reproduce and/or modify it under the terms of the Open Software License, version 1.1. You can obtain a copy of this license at http://opensource.org/licenses/osl.php.

This book is distributed in the hope it will be useful, but without any warranty, without even the implied warranty of merchantability or fitness for a particular purpose.

The author encourages wide distribution of this book for personal or commercial use, provided the above copyright notice remains intact and the method adheres to the provisions of the Open Software License. In summary, you may copy and distribute this book free of charge or for a profit. No explicit permission is required from the author for reproduction of this book in any medium, physical or electronic.

Derivative works and translations of this document must be placed under the Open Software License, and the original copyright notice must remain intact. If you have contributed new material to this book, you must make the material and source code available for your revisions. Please make revisions and updates available directly to the document maintainer, Peter Jay Salzman . This will allow for the merging of updates and provide consistent revisions to the Linux community.

If you publish or distribute this book commercially, donations, royalties, and/or printed copies are greatly appreciated by the author and the Linux Documentation Project (LDP). Contributing in this way shows your support for free software and the LDP. If you have questions or comments, please contact the address above.


Table of Contents
Foreword
作者声明
版本和注意
感谢
译者注
1. Introduction
什么是内核模块?
内核模块是如何被调入内核工作的?
在开始前
2. Hello World
Hello, World (part 1): 最简单的内核模块
介绍printk()
编译内核模块
Hello World (part 2)
Hello World (part 3): 关于__init__exit
Hello World (part 4): 内核模块证书和内核模块文档说明
从命令行传递参数给内核模块
由多个文件构成的内核模块
为已编译的内核编译模块
3. Preliminaries
内核模块和用户程序的比较
内核模块是如何开始和结束的
模块可调用的函数
用户空间和内核空间
命名空间
代码空间
Device Drivers
4. Character Device Files
字符设备文件
关于file_operations结构体
关于file结构体
注册一个设备
注销一个设备
chardev.c
为多个版本的内核编写内核模块
5. The /proc File System
关于 /proc 文件系统
6. Using /proc For Input
使用 /proc 作为输入
7. Talking To Device Files
与设备文件对话 (writes and IOCTLs)
8. System Calls
系统调用
9. Blocking Processes
阻塞进程
Enter Sandman
10. Replacing Printks
替换printk
让你的键盘指示灯闪起来
11. Scheduling Tasks
任务调度
12. Interrupt Handlers
Interrupt Handlers
Interrupt Handlers
Intel架构中的键盘
13. Symmetric Multi Processing
对称多线程处理
14. Common Pitfalls
注意
A. Changes: 2.0 To 2.2
从2.0到2.2的变化
从2.0到2.2的变化
B. Where To Go From Here
为什么这样写?
Index
List of Examples
2-1. hello-1.c
2-2. 一个基本的Makefile
2-3. hello-2.c
2-4. 两个内核模块使用的Makefile
2-5. hello-3.c
2-6. hello-4.c
2-7. hello-5.c
2-8. start.c
2-9. stop.c
2-10. Makefile
4-1. chardev.c
5-1. procfs.c
6-1. procfs.c
7-1. chardev.c
7-2. chardev.h
7-3. ioctl.c
8-1. syscall.c
9-1. sleep.c
10-1. print_string.c
10-2. kbleds.c
11-1. sched.c
12-1. intrpt.c