Linux Kernel Module Programming Guide

image_pdfimage_print

Using /proc For Input,

Talking To Device Files,

System Calls,

Blocking Processes,

Replacing Printks,

Character Device Files,

Preliminaries,

Scheduling Tasks,

Symmetric Multi Processing,

Common Pitfalls

Please Download file from here : CLICK >> lkmpg_kutayzorlu

 

Foreword…………………………………………………………………………………………………………………………………………..1 1. Authorship………………………………………………………………………………………………………………………….1 2. Versioning and Notes……………………………………………………………………………………………………………1 3. Acknowledgements………………………………………………………………………………………………………………1 Chapter 1. Introduction……………………………………………………………………………………………………………………..2 1.1. What Is A Kernel Module?…………………………………………………………………………………………………2 1.2. How Do Modules Get Into The Kernel?……………………………………………………………………………….2 1.2.1. Before We Begin………………………………………………………………………………………………………3 Chapter 2. Hello World……………………………………………………………………………………………………………………..5 2.1. Hello, World (part 1): The Simplest Module…………………………………………………………………………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 Documentation………………………………………………….9 2.6. Passing Command Line Arguments to a Module…………………………………………………………………11 2.7. Modules Spanning Multiple Files………………………………………………………………………………………13 2.8. Building modules for a precompiled kernel…………………………………………………………………………15 Chapter 3. Preliminaries………………………………………………………………………………………………………………….17 3.1. Modules vs Programs……………………………………………………………………………………………………….17 3.1.1. How modules begin and end…………………………………………………………………………………….17 3.1.2. Functions available to modules…………………………………………………………………………………17 3.1.3. User Space vs Kernel Space……………………………………………………………………………………..18 3.1.4. Name Space……………………………………………………………………………………………………………18 3.1.5. Code space……………………………………………………………………………………………………………..19 3.1.6. Device Drivers………………………………………………………………………………………………………..19 Chapter 4. Character Device Files……………………………………………………………………………………………………21 4.1. Character Device Drivers………………………………………………………………………………………………….21 4.1.1. The file_operations Structure……………………………………………………………………………………21 4.1.2. The file structure…………………………………………………………………………………………………….22 4.1.3. Registering A Device………………………………………………………………………………………………22 4.1.4. Unregistering A Device……………………………………………………………………………………………23 4.1.5. chardev.c………………………………………………………………………………………………………………..23 4.1.6. Writing Modules for Multiple Kernel Versions…………………………………………………………..26 Chapter 5. The /proc File System……………………………………………………………………………………………………..28 5.1. The /proc File System………………………………………………………………………………………………………28 5.2. Read and Write a /proc File………………………………………………………………………………………………30 5.3. Manage /proc file with standard filesystem…………………………………………………………………………33 5.4. Manage /proc file with seq_file…………………………………………………………………………………………37 Chapter 6. Using /proc For Input……………………………………………………………………………………………………..40 6.1. TODO: Write a chapter about sysfs……………………………………………………………………………………40 The Linux Kernel Module Programming Guide i Table of Contents Chapter 7. Talking To Device Files…………………………………………………………………………………………………..41 7.1. Talking to Device Files (writes and IOCTLs)……………………………………………………………………..41 Chapter 8. System Calls…………………………………………………………………………………………………………………..50 8.1. System Calls…………………………………………………………………………………………………………………..50 Chapter 9. Blocking Processes………………………………………………………………………………………………………….55 9.1. Blocking Processes………………………………………………………………………………………………………….55 Chapter 10. Replacing Printks………………………………………………………………………………………………………….63 10.1. Replacing printk…………………………………………………………………………………………………………….63 10.2. Flashing keyboard LEDs…………………………………………………………………………………………………65 Chapter 11. Scheduling Tasks………………………………………………………………………………………………………….68 11.1. Scheduling Tasks…………………………………………………………………………………………………………..68 Chapter 12. Interrupt Handlers……………………………………………………………………………………………………….72 12.1. Interrupt Handlers………………………………………………………………………………………………………….72 12.1.1. Interrupt Handlers………………………………………………………………………………………………….72 12.1.2. Keyboards on the Intel Architecture………………………………………………………………………..72 Chapter 13. Symmetric Multi Processing………………………………………………………………………………………….76 13.1. Symmetrical Multi−Processing………………………………………………………………………………………..76 Chapter 14. Common Pitfalls……………………………………………………………………………………………………………77 14.1. Common Pitfalls……………………………………………………………………………………………………………77 Appendix A. Changes: 2.0 To 2.2……………………………………………………………………………………………………..78 A.1. Changes between 2.4 and 2.6……………………………………………………………………………………………78 A.1.1. Changes between 2.4 and 2.6…………………………………………………………………………………..78 Appendix B. Where To Go From Here……………………………………………………………………………………………..79 B.1. Where From Here?………………………………………………………………………………………………………….79

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.