Writing Device Drivers provides information on developing drivers for character-oriented devices, block-oriented devices, network devices, SCSI target and HBA devices, and USB devices for the illumosTM Operating System (illumos). This book discusses how to develop multithreaded reentrant device drivers for all architectures that conform to the illumos DDI/DKI (Device Driver Interface, Driver-Kernel Interface). A common driver programming approach is described that enables drivers to be written without concern for platform-specific issues such as endianness and data ordering.

Additional topics include hardening illumos drivers; power management; driver autoconfiguration; programmed I/O; Direct Memory Access (DMA); device context management; compilation, installation, and testing drivers; debugging drivers; and porting illumos drivers to a 64-bit environment.

This illumos release supports systems that use the SPARCTM and x86 families of processor architectures: UltraSPARCTM, SPARC64, AMD64, Pentium, and Xeon EM64T. For supported systems, see the illumos Hardware Compatibility Lists at This document cites any implementation differences between the platform types.

What's New

SX build 96: Rewrote the description of the sleep-flag flag on page 86.

SX build 88: Added the strnlen function to Utility Functions. Added the ddi_periodic_add and ddi_periodic_delete functions to Time-Related Functions.

Who Should Use This Book

This book is written for UNIXTM programmers who are familiar with UNIX device drivers. Overview information is provided, but the book is not intended to serve as a general tutorial on device drivers.

The illumos operating system (illumos) runs on both SPARC and x86 architectures. illumos also runs on both 64-bit and 32-bit address spaces. The information in this document applies to all platforms and address spaces unless specifically noted.

How This Book Is Organized

Related Books and Papers

For detailed reference information about the device driver interfaces, see the section 9 man pages. Section 9E, Intro(9E), describes DDI/DKI (Device Driver Interface, Driver-Kernel Interface) driver entry points. Section 9F, Intro(9F), describes DDI/DKI kernel functions. Sections 9P and 9S, Intro(9S), describe DDI/DKI properties and data structures.

Typographic Conventions

The following table describes the typographic conventions that are used in this book.

Typographic Conventions





The names of commands, files, and directories, and onscreen computer output

Edit your .login file.

Use ls -a to list all files.

machine_name% you have mail.


What you type, contrasted with onscreen computer output

machine_name% su



Placeholder: replace with a real name or value

The command to remove a file is rm filename.


Book titles, new terms, and terms to be emphasized

Read Chapter 6 in the User's Guide.

A cache is a copy that is stored locally.

Do not save the file.

Note: Some emphasized items appear bold online.

Shell Prompts in Command Examples

The following table shows the default UNIX system prompt and superuser prompt for the C shell, Bourne shell, and Korn shell.

Shell Prompts



C shell


C shell for superuser


Bourne shell and Korn shell


Bourne shell and Korn shell for superuser