Course LIN485
Linux Internals and Device Drivers
Linux Internals and Device Drivers
Duration: 5 Days
Course Overview
In this workshop the structure and functioning of the Linux Kernel and the design and implementation of Linux Device Drivers will be explored in depth.
The course will be taught, mainly, using Intel based PCs, but will also include cross-compiling code for embedded ARM platforms.
Because of the extent of the subject area attendees will be given a copy of
- Linux Device Drivers 3/e by Rubini, Corbet and Kroah-Hartman
These will be supplemented with a collection of more recent articles and white papers on the course handout CD.
Intended Audience
The course is aimed at programmers and technical managers who need to gain a sound basic understanding of Linux internals and Linux Device Drivers. The course is aimed at experienced C programmers who have a good working knowledge of Linux and the Gnu Compiler Collection.
Key Skills
After taking this course you will be able to:
- Understand the issues involved in porting Linux to non Intel platforms
- Understand the Linux build process, and the Linux versioning model.
- Appreciate the changes to Linux from 2.4 to 2.6, and also, more recent changes in the newest 2.6 Kernels
- Make sense of key Linux Kernel data structures and functions behind memory management, signals, process scheduling, I/O device management
- Implement , troubleshoot and modify char and block device drivers
- Implement , troubleshoot and modify network device drivers
- Understand how the latest versions of Linux support multi-threading and Symmetric Multi-Processing.
Practical Work
Extensive hands-on exercises help you develop your skills and understanding:
- Finding your way around the Linux Documentation Project documents
- Developing some Intel assembler programs to better understand the machine specific parts of Linux
- Investigating process creation and management in Linux
- Investigating inter-process communication mechanisms in Linux
- Implementing and testing a loadable module
- Building a char block device driver as a loadable module
- Building and testing a block device driver as a loadable module
- Building and testing a network interface driver
- Case study 1 - USB bus driver
- Case study 2 - CAN bus driver
- Case study 3 - driver for a stepper motor controller
Course Contents
Background
- The evolution of Linux
- Linux and the POSIX API
- Understanding how the Linux Kernel is split up
- The major differences between Linux 1.x and Linux 2.x
- Key changes between Linux 2.4 and Linux 2.6
Linux Internals - the key parts
- Memory addressing - segmentation and paging (hardware and software aspects)
- Process creation, process switching, process destruction
- Interrupts and Exception Handling
- Time, timing and timer interrupts
- Memory management and the Process Address Space
- System calls, Signals and the POSIX API
- I/O Devices
- File systems - VFS, EXT2,
- Inter-process communication
- Program loading and execution
Modules
- Loadable modules and insmod
- Security issues with loadable modules
- Applications compared to Kernel modules
- User space, Kernel space
- Compiling and loading a module
- Initialisation, shutdown and error handling by a module
- Usage counting and module unloading
- How a module accesses and acquires system resources (I/O Ports, I/O memory)
- Automatic and manual configuration
- User space drivers
Char Drivers
- major and minor device numbers
- dynamic allocation of major numbers
- file operations - the file_operations structure and the file structure
- Case study - Rubini and Corbet's scull device
- Getting applications to use new devices
- Device drivers and the devfs filesystem
- Device driver testing and debugging
- Using ioctl commands
- Blocking vs. non-blocking I/O
- Access Control to a device
Time and the Linux Kernel
- Timer interrupts and Kernel time
- Kernel time and the jiffies variable
- Task queues
- Understanding Kernel timers
Memory management - basics
- kmalloc
- Lookaside caches
- vmalloc
- Boot time memory allocation
Hardware management and usage - basics
- I/O Ports and I/O Memory
- Interrupts and Interrupt handling
- The /proc interface
- Circular buffers
- Spinlocks
- Race conditions
- Sysfs
Block drivers
- Registering
- Handling requests - and data transfer
- Queuing and block drivers
- The ioctl command and block drivers
/proc and syfs - Advanced Topics
- Exploring the /proc file system
- Implementing /proc capable device drivers
- Understanding the purpose and architecture of sysfs
- Examining USB and I2C device driver sysfs related details
