Course Description
Welcome to Linux Device Drivers: Programming at the Kernel Level with Doug Abbott. If you are ready to learn with the experts, then this course is for you. Doug has over 20 years’ experience working on the operating system and device driver level with emphasis on embedded Linux applications and is here to answer your questions.
Working with Doug you will become a master Linux programmer at the Device Driver level and be able to:
- Understand how device drivers interact with the Linux kernel
- Work with the rich set of kernel APIs that provide a multitude of services to driver programmers
- See how Linux handles asynchronous I/O in a way that is totally transparent to applications
- Examine the unique problems of debugging in Kernel space
- Understand how much of a device driver involves interactions with the kernel that have nothing to do with accessing physical hardware
While taking this course you will have access to Doug’s video lectures, demos and hands on exercises where you will have ample opportunity to practice what you’ve learned. Most of the lab exercises run on a standard PC. Nevertheless, the code is easily ported to other architectures supported by Linux.
The hands-on exercises can be done using any version of the Linux Kernel. Because the Linux Kernel changes frequently, we are here to support any questions you may have on the course exercises and solutions while you take the course.
Some of the exercise are hardware dependent and require either a parallel printer port, if your computer has one, or you can purchase a single board computer to use to do the exercises – see purchase options section below.
In This Course You Will Learn:
As a result of taking this course, you will be able to:
- Create and build kernel loadable modules
- Understand the four types of devices and their properties
- Determine how device drivers interact with the Linux kernel
- Use techniques for debugging kernel-level code
- Access peripheral hardware
- Manage Asynchronous interrupts
Prerequisites
To successfully complete this course you will need to be proficient in C programming and Linux Essentials or have taken C Programming Bootcamp Part 1, C Programming Bootcamp Part 2 and Linux Essentials.
You will need a PC running a fairly recent Linux distribution such as CentOS 7. To complete the hardware-based exercises in modules 7 to 10 you will need either a standard 25-pin parallel port or a small single board computer with general purpose I/O ports. You can purchase a single board computer with your course below or directly from the instructor at www.intellimetrix.us/gogotraining. If your laptop lacks a parallel port, a compatible docking station usually has one.
Outline
Module 00: Course Introduction
Module 01: What’s a Device Driver?
- Why Device Drivers?
- User Space and Kernel Space
- Process Context and Interrupt Context
- User Space I/O Apis
- Types of Devices
- The/dev/Directory
- Exercise: Explore the /dev Directory
Module 02: Kernel Loadable Modules
- What is a Kernel Loadable Module?
- Module Utilities
- Building a Module
- Modules and the GPL
Module 03: Demo: Kernel Modules
Exercise: Build and Run a Module
Module 04: Basic Character Driver
- Registering and Initializing a Driver
- The File Operations Table, fops
- Driver Example
- Mutual Exclusion, the Mutex
- Exercise: Build and Run simple_char
Module 05: Basic Driver Code Review
- Exercise: Build and Run Basic Driver
Module 06: Debugging Kernel Code
- printk
- strace
- Pseudo file systems
- ioctl
Module 07: Debugging Demo
- strace
- /proc Files
- Create a /proc File
- Create a /debugfs File
- ioctl
Module 08: KGDB
- Configuring the Kernel for KGDB
- Set up Second Virtual Machine
- Pseudo Serial Port
- Shared Folder
- “Magic” sys Request Trigger
- Debugging Kernel Modules
Module 09: KGDB Demo
Module 10: Blocking I/O
- The Wait Queue
- Putting a Process to Sleep
- The misc Device
- The seq File Interface
- Poll and Select
- Asynchronous Notification
Module 11: Blocking I/O Demo and Code Review
- Exercise: Build and Run Blocking Driver
- Exercise: Find the Bug
Module 12: Accessing Hardware
- Side Effects and Compiler Optimization
- I/O APIs
- Barriers
Module 13: Interrupt Handling
- Interrupt Context
- Registering an Interrupt Handler, the IRQ Flags
- Probing for the Interrupt Source
- The Bottom Half – tasklets and workqueues
Module 14: I/O in User Space, the /sys file system
Module 15: /sys Demo
Module 16: The Linux Driver Model
- Overview, Motivation
- Busses
- Devices
- Drivers
- kobject
- sysfs
Module 17: Demo: lxr
Module 18: Code Review: lddbus.c
- Exercise: Build and run lddbus.c
Module 19: Managing Time
- jiffies
- Current Time
- Implementing Time Delays
- The Timer Callback
Module 20: Demo: Time
- Exercise: Build and Run jit.c
Module 21: Synchronization
Module 22: Memory Allocation
- kmalloc() and kfree()
- kmalloc() flags
- The Slab Allocator
- get_free_pages()
- The Buddy Algorithm
- vmalloc()
Module 23: Demo: Memory Allocation
Module 24: Block Devices
- The Block Subsystem
- I/O Schedulers
- Device Registration
- The Request Queue and Function
Module 25: Code Review: simple_block.c
- Exercise: Build and Run simple_block.c
Module 26: PCI Devices
- PCI Addressing and Bridging
- PCI Tools
- Accessing Configuration Space
- PCI Data Structures and Macros
Module 27: Code Review: ne2kpci.c
Module 28: Network Devices
- Device Registration
- The Socket Buffer
- NAPI – the “New” API
Module 29: 29: Code Review: lib8390.c, 8390.c & ne2kpci.c
Module 30: USB Devices
- USB Structure and Characteristics
- USB Tools
- Device Classes
- USB Data Structures and Macros
- USB Request Block, URB
Module 31: Device Trees
- The Problem
- Background
- Device Tree Structure
- “Compatible” Property
- Device Tree and Linux
Module 32: Review