Chapter 9 Writing FreeBSD Device Drivers

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

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.