Linux Program Development
             a guide with exercises

© COPYRIGHT Jerry Cooperstein 2009

Table of Contents


Chapter 00: Preface
Chapter 01: Preliminaries
  • Procedures
  • Linux Distributions
  • Kernel Versions
  • Platforms
  • Hardware
  • Linux Driver Project
  • Documentation and Links

Chapter 02: Device Drivers
  • Types of Devices
  • Mechanism vs. Policy
  • Avoiding Binary Blobs
  • How Applications Use Device Drivers
  • Walking Through a System Call
  • Error Numbers
  • printk()
  • Labs

Chapter 03: Modules I: Basics
  • What is a Module?
  • A Trivial Example - Hello World
  • Module Utilities
  • Passing Parameters
  • Compiling a Module
  • Modules and Hot Plug
  • Labs

Chapter 04: Character Devices
  • Device Nodes
  • Major and Minor Numbers
  • Reserving Major/Minor Numbers
  • Accessing the Device Node
  • Registering the Device
  • udev and HAL
  • file_operations Structure
  • Driver Entry Points
  • The file and inode Structures
  • Module Usage Count
  • Labs

Chapter 05: Kernel Configuration and Compilation
  • Installation and Layout of the Kernel Source
  • Kernel Browsers
  • Kernel Configuration Files
  • Rolling Your Own Kernel
  • initrd and initramfs
  • Labs

Chapter 06: Kernel Features
  • Components of the Kernel
  • User-Space vs. Kernel-Space
  • Scheduling Algorithms and Task Structures
  • Process Context
  • Labs

Chapter 07: Kernel Style and General Considerations
  • Coding Style
  • kernel-doc
  • Using Generic Kernel Routines and Methods
  • Making a Kernel Patch
  • sparse
  • Using likely() and unlikely()
  • Linked Lists
  • Writing Portable Code - 32/64-bit, Endianness
  • Writing for SMP
  • Writing for High Memory Systems
  • Keeping Security in Mind
  • Mixing User- and Kernel-Space Headers
  • Labs

Chapter 08: Interrupts and Exceptions
  • What are Interrupts and Exceptions?
  • Exceptions
  • Interrupts
  • MSI
  • Enabling/Disabling Interrupts
  • What You Cannot Do at Interrupt Time
  • IRQ Data Structures
  • Installing an Interrupt Handler
  • Labs

Chapter 09: Modules II: Exporting, Licensing and Dynamic Loading
  • Exporting Symbols
  • Module Licensing
  • Automatic Loading/Unloading of Modules
  • Built-in Drivers
  • Kernel Building and Makefiles
  • Labs

Chapter 10: Debugging Techniques
  • oops Messages
  • Kernel Debuggers
  • debugfs
  • kprobes and jprobes
  • Labs

Chapter 11: Timing and Timers
  • Jiffies
  • Time Stamp Counter
  • Inserting Delays
  • What are Dynamic Timers?
  • Timer Functions
  • Timer Implementation
  • High Resolution Timers
  • Using High Resolution Timers
  • Labs

Chapter 12: Race Conditions and Synchronization Methods
  • Concurrency and Synchronization Methods
  • Atomic Operations
  • Bit Operations
  • Spinlocks
  • Big Kernel Lock
  • Mutexes
  • Semaphores
  • Completion Functions
  • Reference Counts
  • Labs

Chapter 13: ioctl's
  • What are ioctls?
  • Driver Entry point for ioctls
  • Lockless ioctls
  • Defining ioctls
  • Labs

Chapter 14: The proc Filesystem
  • What is the proc Filesystem?
  • Creating Entries
  • Reading Entries
  • Writing Entries
  • The seq_file Interface
  • Labs

Chapter 15: Unified Device Model and sysfs
  • Unified Device Model
  • Basic Structures
  • Real Devices
  • sysfs
  • Labs

Chapter 16: Firmware
  • What is Firmware?
  • Loading Firmware
  • Labs

Chapter 17: Memory Management and Allocation
  • Virtual and Physical Memory
  • Memory Zones
  • Page Tables
  • kmalloc()
  • __get_free_pages()
  • vmalloc()
  • Early Allocations and bootmem()
  • Slabs and Cache Allocations
  • Labs

Chapter 18: Transferring Between User and Kernel Space
  • Transferring Between Spaces
  • put(get)_user() and copy_to(from)_user()
  • Direct transfer - Kernel I/O and Memory Mapping
  • Kernel I/O
  • Mapping User Pages
  • Memory Mapping
  • User-Space Functions for mmap()
  • Driver Entry Point for mmap()
  • Relay Channels
  • Relay API
  • Accessing Files from the Kernel
  • Labs

Chapter 19: Sleeping and Wait Queues
  • What are Wait Queues?
  • Going to Sleep and Waking Up
  • Going to Sleep Details
  • Exclusive Sleeping
  • Waking Up Details
  • Polling
  • Interrupt Handling in User-Space
  • Labs

Chapter 20: Interrupt Handling and Deferrable Functions
  • Top and Bottom Halves
  • Deferrable Functions and softirqs
  • Tasklets
  • Work Queues
  • Creating Kernel Threads
  • Threaded Interrupt Handlers
  • Labs

Chapter 21: Hardware I/O
  • Buses and Ports
  • Memory Barriers
  • Registering I/O Ports
  • Resource Management
  • Reading and Writing Data from I/O Registers
  • Slowing I/O Calls to the Hardware
  • Allocating and Mapping I/O Memory
  • Accessing I/O Memory
  • Access by User - ioperm(), iopl(), /dev/port
  • Labs

Chapter 22: PCI
  • What is PCI?
  • PCI Device Drivers
  • PCI Structures and Functions
  • Accessing Configuration Space
  • Accessing I/O and Memory Spaces
  • PCI Express
  • Labs

Chapter 23: Direct Memory Access (DMA)
  • What is DMA?
  • DMA and Interrupts
  • DMA Memory Constraints
  • DMA Directly to User
  • DMA under PCI
  • DMA Pools
  • Scatter/Gather Mappings
  • DMA under ISA
  • Labs

Chapter 24: Network Drivers I: Basics
  • Network Layers and Data Encapsulation
  • Datalink Layer
  • Network Device Drivers
  • Loading/Unloading
  • Opening and Closing
  • Labs

Chapter 25: Network Drivers II: Data Structures
  • net_device Structure
  • net_device_ops Structure
  • sk_buff Structure
  • Socket Buffer Functions
  • Labs

Chapter 26: Network Drivers III: Transmission and Reception
  • Transmitting Data and Timeouts
  • Receiving Data
  • Statistics
  • Labs

Chapter 27: Network Drivers IV: Selected Topics
  • Multicasting
  • Changes in Link State
  • ioctls
  • NAPI and Interrupt Mitigation
  • NAPI Details
  • TSO and TOE
  • MII and ethtool

Chapter 28: USB Drivers
  • What is USB?
  • USB Topology
  • Descriptors
  • USB Device Classes
  • Data Transfer
  • USB under Linux
  • Registering USB Devices
  • Example of a USB Driver
  • Labs

Chapter 29: Memory Technology Devices
  • What are MTD Devices?
  • NAND vs. NOR
  • Driver and User Modules
  • Flash Filesystems
  • Labs

Chapter 30: Power Management
  • Power Management
  • APM and ACPI
  • System Power States
  • Callback Functions
  • Labs

Chapter 31: Notifiers
  • What are Notifiers?
  • Data Structures
  • Callbacks and Notifications
  • Creating Notifier Chains
  • Labs

Chapter 32: CPU Frequency Scaling
  • What is Frequency and Voltage Scaling?
  • Notifiers
  • Drivers
  • Governors
  • Labs

Chapter 33: Asynchronous I/O
  • What is Asynchronous I/O?
  • The Posix Asynchronous I/O API
  • Linux Implementation
  • Labs

Chapter 34: I/O Scheduling
  • I/O Scheduling
  • Tunables
  • noop I/O Scheduler
  • Deadline I/O Scheduler
  • Completely Fair Queue Scheduler
  • Anticipatory I/O Scheduler
  • Labs

Chapter 35: Block Drivers
  • What are Block Drivers?
  • Buffering
  • Registering a Block Driver
  • gendisk Structure
  • Request Handling
  • Labs

Linux Device Drivers

© COPYRIGHT Jerry Cooperstein 2009
LDD:1.0