Log In
Or create an account -> 
Imperial Library
  • Home
  • About
  • News
  • Upload
  • Forum
  • Help
  • Login/SignUp

Index
Title Page Copyright
Linux Device Drivers Development
Credits About the Author About the Reviewer www.PacktPub.com
Why subscribe?
Customer Feedback Dedication Preface
What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support
Downloading the example code Downloading the color images of this book Errata Piracy Questions
Introduction to Kernel Development
Environment setup
Getting the sources
Source organization
Kernel configuration Building your kernel
Kernel habits
Coding style Kernel structure allocation/initialization Classes, objects, and OOP
Summary
Device Driver Basis
User space and kernel space
The concept of modules Module dependencies
depmod utility
Module loading and unloading
Manual loading
modprobe and insmod /etc/modules-load.d/<filename>.conf
Auto-loading Module unload
Driver skeletons
Module entry and exit point
__init and __exit attributes
Module information
Licensing Module author(s) Module description
Errors and message printing
Error handling Handling null pointer errors Message printing – printk()
Module parameters Building your first module
The module's makefile In the kernel tree Out of the tree Building the module
Summary
Kernel Facilities and Helper Functions
Understanding the container_of macro Linked lists
Creating and initializing a list
Dynamic method Static method
Creating a list node Adding a list node Deleting a node from the list Linked list traversal
The kernel sleeping mechanism
Wait queue
Delay and timer management
Standard timers
Jiffies and HZ The timer API
Timer setup initialization Standard timer example
High-resolution timers (HRTs)
HRT API
HRT setup initialization
Dynamic tick/tickless kernel Delays and sleep in the kernel
Atomic context Nonatomic context
Kernel locking mechanism
Mutex
Mutex API
Declare Acquire and release
Spinlock
Spinlock versus mutexes
Work deferring mechanism
Softirqs and ksoftirqd
ksoftirqd
Tasklets
Declaring a tasklet Enabling and disabling a tasklet
Tasklet scheduling Work queues
Kernel-global work queue – the shared queue Dedicated work queue
Programming syntax
Predefined (shared) workqueue and standard workqueue functions
Kernel threads
Kernel interruption mechanism
Registering an interrupt handler
Interrupt handler and lock
Concept of bottom halves
The problem – interrupt handler design limitations The solution – bottom halves Tasklets as bottom halves Workqueue as bottom halves Softirqs as bottom half
Threaded IRQs
Threaded bottom half
Invoking user space applications from the kernel Summary
Character Device Drivers
The concept behind major and minor
Device number allocation and freeing
Introduction to device file operations
File representation in the kernel
Allocating and registering a character device Writing file operations
Exchanging data between kernel space and user space
A single value copy
The open method
Per-device data
The release method The write method
Steps to write
The read method
Steps to read
The llseek method
Steps to llseek
The poll method
Steps to poll
The ioctl method
Generating ioctl numbers (command) Steps for ioctl
Filling the file_operations structure
Summary
Platform Device Drivers
Platform drivers Platform devices
Resources and platform data
Device provisioning – the old and deprecated way
Resources Platform data Where to declare platform devices?
Device provisioning – the new and recommended way
Devices, drivers, and bus matching
How can platform devices and platform drivers match?
Kernel devices and drivers-matching function
OF style and ACPI match ID table matching Per device-specific data on ID table matching Name matching – platform device name matching
Summary
The Concept of a Device Tree
Device tree mechanisms
Naming convention Aliases, labels, and phandle DT compiler
Representing and addressing devices
SPI and I2C addressing Platform device addressing
Handling resources
Concept of named resources Accessing registers Handling interrupts
The interrupt handler Interrupt controller code
Extract application-specific data
Text string Cells and unsigned 32-bit integers Boolean Extracting and parsing sub-nodes
Platform drivers and DTs
OF match style
Dealing with non-device tree platforms Support multiple hardware devices with per device-specific data
Match style mixing
Platform resources and DTs
Platform data versus DTs
Summary
I2C Client Drivers
The driver architecture
The i2c_driver structure
The probe() function
Per-device data
The remove() function
Driver initialization and registration Driver and device provisioning
Accessing the client
Plain I2C communication System Management Bus (SMBus) compatible functions Instantiating I2C devices in the board configuration file (old and deprecated way)
I2C and device trees
Defining and registering the I2C driver
Remark
Instantiating I2C devices in a DT – the new way Putting it all together
Summary
SPI Device Drivers
The driver architecture
The device structure spi_driver structure
The probe() function
Per-device data
The remove() function
Driver initialization and registration Driver and device provisioning
Instantiating SPI devices in board configuration file – old and deprecated way SPI and device tree
Instantiate SPI devices in device tree – the new way Define and register SPI driver
Accessing and talking to the client Putting it all together SPI user mode driver
With IOCTL
Summary
Regmap API - A Register Map Abstraction
Programming with the regmap API
regmap_config structure regmap initialization
SPI initialization I2C initialization
Device access functions
regmap_update_bits function Special regmap_multi_reg_write function Other device access functions
regmap and cache Putting it all together A regmap example
Summary
IIO Framework
IIO data structures
iio_dev structure iio_info structure IIO channels
Channel attribute naming conventions
Distinguishing channels
Putting it all together
Triggered buffer support
IIO trigger and sysfs (user space)
Sysfs trigger interface
add_trigger file remove_trigger file Tying a device with a trigger
The interrupt trigger interface The hrtimer trigger interface
IIO buffers
IIO buffer sysfs interface IIO buffer setup
Putting it all together
IIO data access
One-shot capture Buffer data access
Capturing using the sysfs trigger Capturing using the hrtimer trigger
IIO tools Summary
Kernel Memory Management
System memory layout – kernel space and user space
Kernel addresses – concept of low and high memory
Low memory High memory
User space addresses Virtual memory area (VMA)
Address translation and MMU
Page lookup and TLB
How does the TLB work?
Memory allocation mechanism
Page allocator
Page allocation API Conversion functions
Slab allocator
The buddy algorithm A journey into the slab allocator
kmalloc family allocation vmalloc allocator Process memory allocation under the hood
The copy-on-write (CoW) case
Working with I/O memory to talk with hardware
PIO devices access MMIO device access
__iomem cookie
Memory (re)mapping
kmap Mapping kernel memory to user space
Using remap_pfn_range Using io_remap_pfn_range The mmap file operation
Implementing mmap in the kernel
Linux caching system
What is a cache?
CPU cache – memory caching The Linux page cache – disk caching Specialized caches (user space caching)
Why delay writing data to disk?
Write caching strategies
The flusher threads
Device-managed resources – Devres Summary
DMA - Direct Memory Access
Setting up DMA mappings
Cache coherency and DMA DMA mappings
Coherent mapping Streaming DMA mapping
Single-buffer mapping Scatter/gather mapping
The concept of completion The DMA engine API
Allocating a DMA slave channel Setting slave- and controller-specific parameters Getting a descriptor for transaction Submitting the transaction Issuing pending DMA requests and waiting for callback notification
Putting it all together – NXP SDMA (i.MX6) DMA DT binding
Consumer binding
Summary
The Linux Device Model
LDM data structures
The bus
Bus registration
The device driver
Device driver registration
The device
Device registration
Deep inside LDM
kobject structure kobj_type ksets Attributes
The attributes group
The device model and sysfs
Sysfs files and attributes
Current interfaces
Device attributes Bus attributes Device driver attributes Class attributes
Allowing sysfs attribute files to be pollable
Summary
Pin Control and GPIO Subsystem
The pin control subsystem
Pinctrl and the device tree
The GPIO subsystem
The integer-based GPIO interface – legacy
Claiming and configuring the GPIO Accessing the GPIO – getting/setting the value
In atomic context In a non-atomic context (that may sleep)
GPIOs mapped to IRQ Putting it all together
The descriptor-based GPIO interface – the new and recommended way
GPIO descriptor mapping - the device tree Allocating and using GPIO Putting it all together
The GPIO interface and the device tree
The legacy integer-based interface and device tree GPIO mapping to IRQ in the device tree
GPIO and sysfs
Exporting a GPIO from kernel code
Summary
GPIO Controller Drivers - gpio_chip
Driver architecture and data structures Pin controller guidelines Sysfs interface for GPIO controller GPIO controllers and the DT Summary
Advanced IRQ Management
Multiplexing interrupts and interrupt controllers Advanced peripheral IRQ management Interrupt request and propagation
Chaining IRQs
Chained interrupts Nested interrupts
A case study – the GPIO and IRQ chip
The legacy GPIO and IRQ chip The new gpiolib irqchip API The interrupt controller and DT
Summary
Input Devices Drivers
Inputting device structures Allocating and registering an input device
The polled input device sub-class
Generating and reporting an input event The user space interface Putting it all together
Driver examples
Summary
RTC Drivers
RTC framework data structures
RTC API
Reading and setting time
Driver example
Playing with alarms
RTCs and user space
The sysfs interface The hwclock utility
Summary
PWM Drivers
PWM controller driver
Driver example PWM controller binding
The PWM consumer interface
PWM client binding
Using PWMs with the sysfs interface Summary
Regulator Framework
PMIC/producer driver interface
Driver data structures
Description structure Constraints structure init data structure
Feeding init data into a board file Feeding init data into the DT
Configuration structure Device operation structure
Driver methods
The probe function The remove function Case study – Intersil ISL6271A voltage regulator
Driver example
Regulators consumer interface
Regulator device requesting Controlling the regulator device
Enabling and disabling regulator output Voltage control and status Current limit control and status Operating mode control and status
Regulator binding Summary
Framebuffer Drivers
Driver data structures Device methods Driver methods
Detailed fb_ops
Checking information Setting the controller's parameters Screen blanking Accelerated methods
Putting it all together
Framebuffer from user space Summary
Network Interface Card Drivers
Driver data structures
The socket buffer structure
Socket buffer allocation
Network interface structure
Device methods
Opening and closing Packet handling
Packet reception Packet transmission
Driver example Status and control
The interrupt handler Ethtool support
Driver methods
The probe function Module unloading
Summary
  • ← Prev
  • Back
  • Next →
  • ← Prev
  • Back
  • Next →

Chief Librarian: Las Zenow <zenow@riseup.net>
Fork the source code from gitlab
.

This is a mirror of the Tor onion service:
http://kx5thpx2olielkihfyo4jgjqfb7zx7wxr3sd4xzt26ochei4m6f7tayd.onion