Linux Kernel Driver Tutorial

Martin Waitz

Friedrich-Alexander-University of Erlangen-Nuremberg, Informatik 3

Copyright 2004 Martin Waitz, Licensed under a Creative Commons License


Table of Contents

Introduction
Allgemeines
Error checking
Webseiten
Tipps
Adding new files to the build infrastructure
Configuration
Building
Building out-of-tree modules
The Hello World module
Basic Kernel Infrastructure
Printing Messages
Allocating Memory
Accessing userspace memory
Listing Objects
Error codes
Files and stuff
VFS overview
Character devices
Hardware access
ISA I/O
Interrupt handling
Tasklets
Processes
work queues
Waiting & locking
Spinlocks
Semaphores
Wait queues
poll
Staying awake
atomic
Timer
kfifo
Driver-Model
sysfs
hotplug
udev
Kernel infrastructure
How to export information from the driver

Introduction

This tutorial was written for a course in Hardware and Linux driver development (DHWKLINUX) at the Friedrich-Alexander-University of Erlangen-Nuremberg. I hope it is interesting for other Kernel developers, too.

And well, sorry for the parts that are still unfinished...

Wozu braucht man ein Betriebssystem? Koordinierung von verschiedenen Programmen. Abstrahierung und Virtualisierung von Hardware.

BS bieten meist zwei unterschiedliche Schnittstellen an: eine zur Hardware und eine zu User-space Software Kernel reagiert immer nur auf Events, die jeweils aus dem Userspace oder von der Hardware kommen.

Walkthrough

arch/i386/kernel/entry.S

syscalltable, irqs

kernel/irq/handle.c

__do_IRQ, handle_IRQ_event

fs/read_write.c

sys_read, vfs_read