Chapter 9. Writing FreeBSD Device Drivers

Written by Murray Stokely.
Based on intro(4) manual page by Jörg Wunsch.
Table of Contents
9.1. Introduction
9.2. Dynamic Kernel Linker Facility - KLD
9.3. Character Devices
9.4. Block Devices (Are Gone)
9.5. Network Drivers

9.1. Introduction

This chapter provides a brief introduction to writing device drivers for FreeBSD. A device in this context is a term used mostly for hardware-related stuff that belongs to the system, like disks, printers, or a graphics display with its keyboard. A device driver is the software component of the operating system that controls a specific device. There are also so-called pseudo-devices where a device driver emulates the behavior of a device in software without any particular underlying hardware. Device drivers can be compiled into the system statically or loaded on demand through the dynamic kernel linker facility `kld'.

Most devices in a UNIX®-like operating system are accessed through device-nodes, sometimes also called special files. These files are usually located under the directory /dev in the filesystem hierarchy.

Device drivers can roughly be broken down into two categories; character and network device drivers.

All FreeBSD documents are available for download at

Questions that are not answered by the documentation may be sent to <>.
Send questions about this document to <>.