<< Back to man.ChinaUnix.net

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. In releases of FreeBSD older than 5.0-RELEASE, where devfs(5) support is not integrated into FreeBSD, each device node must be created statically and independent of the existence of the associated device driver. Most device nodes on the system are created by running MAKEDEV.

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

This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.