Table of Contents
Forewor d . .............................................................................................................................................................1
1. Authorship...........................................................................................................................................1
2. Versioning and Note s . ..........................................................................................................................1
3. Acknowledgement s . .............................................................................................................................1
Chapter 1. Introductio n . .....................................................................................................................................2
1.1. What Is A Kernel Module ? ...............................................................................................................2
1.2. How Do Modules Get Into The Kernel ? . ..........................................................................................2
1.2.1. Before We Begi n .....................................................................................................................3
Chapter 2. Hello Worl d ......................................................................................................................................5
2.1. Hello, World (part 1): The Simplest Modul e . ...................................................................................5
2.1.1. Introducing printk( ) .................................................................................................................6
2.2. Compiling Kernel Modules..............................................................................................................6
2.3. Hello World (part 2)..........................................................................................................................7
2.4. Hello World (part 3): The
init and exit Macros........................................................................8
2.5. Hello World (part 4): Licensing and Module Documentatio n . .........................................................9
2.6. Passing Command Line Arguments to a Modul e ...........................................................................11
2.7. Modules Spanning Multiple File s ...................................................................................................13
2.8. Building modules for a precompiled kerne l . ...................................................................................15
Chapter 3. Preliminarie s ..................................................................................................................................17
3.1. Modules vs Program s . .....................................................................................................................17
3.1.1. How modules begin and en d .................................................................................................17
3.1.2. Functions available to module s .............................................................................................17
3.1.3. User Space vs Kernel Spac e ..................................................................................................18
3.1.4. Name Spac e ...........................................................................................................................18
3.1.5. Code spac e . ............................................................................................................................19
3.1.6. Device Driver s . ......................................................................................................................19
Chapter 4. Character Device Files..................................................................................................................21
4.1. Character Device Driver s . ...............................................................................................................21
4.1.1. The file_operations Structur e ................................................................................................21
4.1.2. The file structur e ...................................................................................................................22
4.1.3. Registering A Devic e ............................................................................................................22
4.1.4. Unregistering A Devic e . ........................................................................................................23
4.1.5. chardev. c . ...............................................................................................................................23
4.1.6. Writing Modules for Multiple Kernel Version s ....................................................................26
Chapter 5. The /proc File Syste m ....................................................................................................................28
5.1. The /proc File Syste m .....................................................................................................................28
5.2. Read and Write a /proc Fil e ............................................................................................................30
5.3. Manage /proc file with standard filesyste m ....................................................................................33
5.4. Manage /proc file with seq_fil e ......................................................................................................37
Chapter 6. Using /proc For Inpu t ....................................................................................................................40
6.1. TODO: Write a chapter about sysf s . ...............................................................................................40
i
评论0
最新资源