Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux Kernel Modules and Device Drivers

Hands-on Linux kernel module and character device driver development, working through the boundary between user space and kernel space.

Language Platform

What's here

The modules build up from a bare "hello world" in kernel space to a working character device driver. Each one isolates a single idea so it's clear what changed.

Module What it demonstrates
hello_kernel A minimal loadable module with init/exit and printk
hello_mod Module metadata, licensing, and the build basics
mod_parameter Passing parameters at insmod time
dev_num Registering and allocating device numbers (major/minor)
chardev A full character device driver: dynamic major/minor allocation plus open, read, write, and release

Concepts covered

  • Loadable kernel modules and the module lifecycle
  • Dynamic device-number allocation
  • The file_operations interface and the VFS entry points
  • Moving data across the user/kernel boundary with copy_to_user and copy_from_user
  • Kernel logging through printk and dmesg

Prerequisites

  • Linux kernel headers (linux-headers-$(uname -r))
  • gcc and make

Build and test

cd chardev            # or any module folder
make                  # builds the .ko against the running kernel
sudo insmod chardev.ko
dmesg | tail          # view the kernel log output
sudo rmmod chardev

A word of caution: build against a matching kernel-headers version, and load modules on a VM or test machine rather than anything you care about.

Skills demonstrated

Linux kernel, device drivers, character devices, kernel modules, the file_operations interface, user and kernel space, system calls, and C.

About

Linux kernel modules and a character device driver with dynamic major/minor allocation

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages