Skip to content
프로젝트

d0u9/Linux-Device-Driver

GitHub에서 보기

소개

Linux 디바이스 드라이버(LDD3)의 고급 예제와 가상 PCI, USB, 직렬 장치를 지원하도록 패치한 QEMU에서 예제를 실행하는 방법을 담은 자세한 매뉴얼을 제공합니다. 현재 Linux 커널의 드라이버 개발에 관한 새 책을 집필하고 있습니다.

시스템 및 인프라

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Linux-Device-Driver

Examples of Linux device drivers, currently targeting Linux 7.2.x.

Repository layout

  • docs/: tutorial chapters, in reading order.
  • examples/: kernel module examples and userspace test programs.
  • tools/: workspace scripts, custom QEMU devices, and tool tests.

The tutorial checkout is separate from the runtime workspace (LDD_ROOT). Start with the workspace setup to create the workspace and install the helper scripts.

Before start

Current test baseline:

  • Kernel: Linux 7.2.x.
  • QEMU: 11.1.x, with the devices from tools/qemu.
  • Host system: Fedora release 44 (Forty Four).

Other kernel and QEMU versions and host distributions are not tested.

The examples target 64-bit kernels (x86_64). Differences on 32-bit kernels, such as 64-bit MMIO accessors that are missing or split in two, are not covered.

Set KDIR environment variable to the Linux kernel source dir, and export it to your local shell.

export KDIR=/path/to/kernel/source/

This environment variable is mainly used in Makefile to determine which kernel source tree the drivers are built against.

Examples

Driver examples are in examples/. Numbered directories preserve the learning sequence; rbtree is a supplemental example. Except for 01_hello_world, which spells out the full double-entering Makefile, each example's Makefile holds only its kbuild lines and includes the shared examples/common.mk for the modules and clean targets.

To build an example after setting KDIR, enter its directory:

cd examples/01_hello_world
make

To build every finished example at once, in parallel, from the repository root:

make -C examples -j"$(nproc)"

Introduction

This repo demonstrates basic examples of Linux Device Driver(LDD) for the purpose of studying and sharing.

Some of the examples in this repo are excerpted from the book of LDD3(Linux Device Drivers, Third Edition), and the other examples are written by myself in necessary to illustrate some important data structures or details.

LDD3 is a great book, which is authored by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman, I give my sincere appreciation to all these authors for their great work.

LDD3 is available online, and you may request a copy of the PDF from https://lwn.net/Kernel/LDD3/. It is still an excellent book to reference for the development of Linux device module. However, due to its old age, first published in 2005, some of the APIs and data structures have drastically changed after its first publication.

Compare to the Kernel 2.6.10, which is the base of the LDD3 book, I rewrite all the examples for a brand new Kernel version 5.10, released in December 2020. Besides the kernel version, the hardware also has evolved a lot in recent years. The parallel port, which is used as an example in I/O operations in LDD3, can be barely found in any computer now. I moved these examples to a QEMU(A generic and open source machine emulator and virtualizer) virtual machine, in which a virtual parallel port device is implemented for convenient debugging.

This is the opening of my whole project, I hope you will enjoy in the tour of reading my book.

Thanks a lot.

Sincerely, Douglas.


License

Linux-Device-Driver by d0u9 is licensed under a GNU General Public License, version 2.


¶ The end

관련 프로젝트 살펴보기

불러오는 중…