Skip to content
HN On Hacker News ↗

GitHub - ebrandi/FDD-book: FreeBSD Device Driver Book

▲ 148 points 43 comments by myth_drannon 3w ago HN discussion ↗

Pangram verdict · v3.3

We believe that this document is primarily AI-generated with some human-written content

70 %

AI likelihood · overall

AI
13% human-written 87% AI-generated
SEGMENTS · HUMAN 0 of 5
SEGMENTS · AI 4 of 5
WORD COUNT 1,513
PEAK AI % 100% · §1
Analyzed
Apr 27
backend: pangram/v3.3
Segments scanned
5 windows
avg 303 words each
Distribution
13 / 87%
human / AI fraction
Verdict
AI
Pangram v3.3

Article text · 1,513 words · 5 segments analyzed

Human AI-generated
§1 AI · 100%

FreeBSD Device Drivers From First Steps to Kernel Mastery by Edson Brandi · Version 2.0 (April 2026)

About This Book FreeBSD Device Drivers: From First Steps to Kernel Mastery is a free, open-source book that takes you from "I've never written kernel code" to "I can write, debug, and submit production-quality FreeBSD drivers." It is a guided course rather than a reference, structured around 38 chapters, 6 appendices, and dozens of hands-on labs that compile and load on a real FreeBSD 14.x system. The book is aimed at readers who are willing to learn rather than are already qualified. It begins with UNIX fundamentals and the C language, walks step by step through every concept the kernel will demand of you, and only then opens the door to driver development. By the time you reach DMA, interrupts, and PCI work, the vocabulary feels earned, not imposed.

"Kernel programming is still programming, only with more explicit rules, greater responsibility, and a bit more power. Once you understand that, the fear gives way to excitement." (from Chapter 1)

Why This Book? There are excellent FreeBSD kernel references already, including man 9, the Architecture Handbook, and the Newbus papers. What has been missing is a single text that:

Starts from zero. UNIX, C, and the FreeBSD environment are taught before any kernel code is written. Targets FreeBSD 14.x specifically. Every API, every example, every lab was verified against the FreeBSD 14.3 source tree. Treats labs as first-class. Roughly half of the recommended study time is hands-on. The same patterns (attach, cleanup, locking) recur across chapters until they become reflex. Builds one driver across the whole book. The myfirst driver evolves chapter by chapter, gaining synchronisation, then hardware access, then interrupts, then DMA. You see the same code mature in your own hands. Covers the full lifecycle. From "Hello Kernel Module" all the way to submitting a Phabricator review and shepherding a driver into the FreeBSD tree.

Who This Book Is For

Beginners who know little about C, UNIX, or kernels but are willing to learn. Developers curious about how operating systems actually work under the hood.

§2 AI · 100%

Professionals who already use FreeBSD (or similar systems) and want to deepen their knowledge by learning how drivers are built in practice.

Who This Book Isn't For

Readers looking for a quick copy-and-paste manual. The book emphasises understanding over shortcuts. Seasoned kernel developers who don't need the foundations. The pace starts from the ground up. Readers wanting an encyclopaedic hardware reference. The focus is real-world FreeBSD driver development, not exhaustive bus or device specifications.

What You'll Learn The book is organised into seven parts that build on each other:

Part Title Focus

1 Foundations: FreeBSD, C, and the Kernel Lab setup, UNIX, C for kernel work, driver anatomy

2 Building Your First Driver Character drivers, device files, read/write, I/O

3 Concurrency and Synchronization Threads, mutexes, condvars, timers, taskqueues, semaphores

4 Hardware and Platform-Level Integration PCI, interrupts, MSI/MSI-X, DMA, power management

5 Debugging, Tools, and Real-World Practices Tracing, KGDB, advanced debugging, performance tuning

6 Writing Transport-Specific Drivers USB, serial, storage/VFS, network drivers

7 Mastery Topics: Special Scenarios and Edge Cases Portability, virtualisation, security, embedded, reverse engineering, upstream submission

By the end, you will have written and loaded your own kernel modules, built a character driver, handled real interrupts and DMA, debugged kernel panics, profiled your driver under load, and walked through every step of contributing your work back to the FreeBSD Project. Book Stats

Pages 4,500+

Chapters 38

Appendices 6

Reading time ~100 hours

Lab time ~100 hours

Total study time ~200 hours (≈6 months at 5 hrs/week)

Target FreeBSD release 14.3

Languages English (original) · Brazilian Portuguese (AI-translated) · Spanish

§3 AI · 100%

(AI-translated)

Formats PDF · EPUB · HTML · Markdown source

Full Table of Contents

Click to expand the complete chapter list Part 1: Foundations of FreeBSD, C, and the Kernel

Introduction: From Curiosity to Contribution Setting Up Your Lab A Gentle Introduction to UNIX A First Look at the C Programming Language Understanding C for FreeBSD Kernel Programming The Anatomy of a FreeBSD Driver

Part 2: Building Your First Driver

Writing Your First Driver Working with Device Files Reading and Writing to Devices Handling Input and Output Efficiently

Part 3: Concurrency and Synchronization

Concurrency in Drivers Synchronization Mechanisms Timers and Delayed Work Taskqueues and Deferred Work More Synchronization: Conditions, Semaphores, and Coordination

Part 4: Hardware and Platform-Level Integration

Accessing Hardware Simulating Hardware Writing a PCI Driver Handling Interrupts Advanced Interrupt Handling DMA and High-Speed Data Transfer Power Management

Part 5: Debugging, Tools, and Real-World Practices

Debugging and Tracing Integrating with the Kernel Advanced Topics and Practical Tips

Part 6: Writing Transport-Specific Drivers

USB and Serial Drivers Working with Storage Devices and the VFS Layer Writing a Network Driver

Part 7: Mastery Topics

Portability and Driver Abstraction Virtualisation and Containerization Security Best Practices Device Tree and Embedded Development Performance Tuning and Profiling Advanced Debugging Techniques Asynchronous I/O and Event Handling Creating Drivers Without Documentation (Reverse Engineering) Submitting Your Driver to the FreeBSD Project Final Thoughts and Next Steps

Appendices

A: FreeBSD Kernel API Reference B: Algorithms and Logic for Systems Programming C: Hardware Concepts for Driver Developers D: Operating System Concepts E: Navigating FreeBSD Kernel Internals F: Benchmark Harness and Results

How to Read the Book The recommended pace is one chapter per week at roughly five hours of weekly study.

§4 Mixed · 34%

That schedule puts the whole book within reach across an academic year. Some chapters (especially Chapter 4 on C, and the Part 4 hardware chapters) naturally span multiple weeks. The labs are strongly recommended. Kernel programming rewards muscle memory in a way few disciplines do. The same attach pattern, the same cleanup chain, and the same locking shape appear chapter after chapter and driver after driver. Typing those patterns, compiling them, loading them into a running kernel, and watching them fail on purpose is the single most effective way to internalise them. If you already know C, UNIX, and the general shape of an OS kernel, fast-path notes throughout Part 1 tell you which sections to read carefully and which you can skim. Download the Book Version 2.0 is available now on the Releases page in three languages and three formats:

Language PDF EPUB HTML

English (original) PDF EPUB HTML

Português (Brasil), AI-translated PDF EPUB HTML

Español, AI-translated PDF EPUB HTML

You can also browse the Markdown source directly in the content/ directory, or build the book yourself with scripts/build-book.sh. About the translations The English version is the original and authoritative version of the book. The Brazilian Portuguese and Spanish editions were translated using AI and have not yet undergone a full human technical review. They are published to make the material accessible to more readers, but they may contain translation mistakes, awkward wording, or technical inaccuracies introduced during translation. If something in a translated edition seems unclear, inconsistent, or technically questionable, please refer to the English version as the source of truth. Help with reviewing and improving the translations is very welcome (see Contributing below). Known issues in v2.0 This is a draft release of a very large book. A few things to be aware of:

Some source-code blocks in the PDF, EPUB, and HTML editions may overflow the page or wrap awkwardly. These are presentation issues that will be improved in a future release; the content itself is correct. If a code example is hard to read in any of the rendered formats, the Markdown files in this repository are the source of truth. Open the relevant file under content/ for a clean version. Translation review for pt_BR and es_ES is planned for the near future, as the author's free time allows.

§5 AI · 100%

Repository Structure FDD-book/ ├── content/ # Book content (Markdown) │ ├── chapters/ # Chapters by Part │ └── appendices/ # Appendices A-F ├── examples/ # Source code from the book ├── translations/ │ ├── pt_BR/ # Brazilian Portuguese (AI-translated) │ └── es_ES/ # Spanish (AI-translated) └── scripts/ # Build and utility scripts

Contributing Contributions of every kind are welcome, including corrections, clarifications, new examples, translations, and reviews from FreeBSD developers and learners alike. Ways to contribute

Content: add new chapters, refine existing material Technical review: review chapters for accuracy against FreeBSD 14.x Translation review: help review and improve the AI-translated pt_BR and es_ES editions; native speakers with FreeBSD/kernel experience are especially welcome New translations: help translate the book into another language Code: improve examples, build scripts, and tooling Issues: report bugs, factual errors, unclear passages, or formatting problems

Reporting an issue When filing an issue, please include:

The language version you were reading (en_US, pt_BR, es_ES) The format used (PDF, EPUB, HTML, or Markdown) The chapter or section where the problem appears A short explanation of the issue, and a suggested correction if you have one

Workflow

Fork the repository Create a branch: git checkout -b feature/your-change Make your changes and test the build with scripts/build-book.sh Commit with a clear message: git commit -m "Chapter 18: clarify BAR mapping" Push and open a Pull Request

When you're stuck while reading the book, filing an issue helps.