Sun Microsystems
Products & Services
 
Support & Training
 
 

     Contents     Index     Next Next

Device Driver Tutorial

Preface

This Device Driver Tutorial is a hands-on guide that shows you how to develop a simple device driver for the Solaris™ Operating System (Solaris OS). Device Driver Tutorial also explains how device drivers work in the Solaris OS. This book is a companion to Writing Device Drivers. Writing Device Drivers is a thorough reference document that discusses many types of devices and drivers. Device Driver Tutorial examines complete drivers but does not provide a comprehensive treatment of all driver types. Device Driver Tutorial often points to Writing Device Drivers and other books for further information.


Note - This Solaris release supports systems that use the SPARC® and x86 families of processor architectures: UltraSPARC®, SPARC64, AMD64, Pentium, and Xeon EM64T. For supported systems, see the Solaris OS Hardware Compatibility List at http://www.sun.com/bigadmin/hcl. This document cites any implementation differences between the platform types.


Who Should Use This Book

You should read this tutorial if you need to develop, install, and configure device drivers for the Solaris OS. You also should read this book if you need to maintain existing drivers or add new functionality to existing Solaris OS drivers. Information about the kernel provided in this book also will help you troubleshoot any problems you might encounter installing or configuring Solaris systems.

User Background

To write device drivers for the Solaris OS, you should have the following background:

  • Be a confident C programmer

  • Have experience with data structures, especially with linked lists

  • Understand bit operations

  • Understand indirect function calls

  • Understand caching

  • Understand multithreading (see the Multithreaded Programming Guide)

  • Be familiar with a UNIX® shell

  • Understand the basics of UNIX system and I/O architecture

The most important information you need to have to write a device driver are the characteristics of the device. Get a detailed specification for the device you want to drive.

Experience with Solaris OS compilers, debuggers, and other tools will be very helpful to you. You also need to understand where the file system fits with the kernel and the application layer. These topics are discussed in this tutorial.

How This Book Is Organized

This book is organized into the following chapters:

Chapter 1, Introduction to Device Drivers provides an overview of the Solaris Operating System and kernel. This chapter also discusses the driver development environment and tools.

Chapter 2, Template Driver Example shows a simple template driver. This chapter shows in detail the steps to develop, build, install, load, and test this simple driver.

Chapter 3, Reading and Writing Data in Kernel Memory describes how to develop a driver that reads data from and writes data to kernel memory.

Chapter 4, Tips for Developing Device Drivers discusses some common errors in driver development and how to avoid them or handle them. This chapter also introduces driver analysis and debugging tools.

Related Books

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.

For information on other driver-related tools and issues, see these books from Sun Microsystems:

  • Writing Device Drivers. Sun Microsystems, Inc., 2005.

  • Multithreaded Programming Guide. Sun Microsystems, Inc., 2005.

  • STREAMS Programming Guide. Sun Microsystems, Inc., 2005.

  • Solaris Modular Debugger Guide. Sun Microsystems, Inc., 2005.

  • Solaris Dynamic Tracing Guide. Sun Microsystems, Inc., 2005.

  • Application Packaging Developer's Guide. Sun Microsystems, Inc., 2005.

  • Solaris 64-bit Developer's Guide. Sun Microsystems, Inc., 2005.

  • Sun Studio 11: C User's Guide. Sun Microsystems, Inc., 2005.

    Click Sun Studio 11 Collection at the top left of this page to see Sun Studio books about dbx, dmake, Performance Analyzer, and other software development topics.

Documentation, Support, and Training

The Sun web site provides information about the following additional resources:

Typographic Conventions

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

Table P-1 Typographic Conventions

Typeface

Meaning

Example

AaBbCc123

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.

AaBbCc123

What you type, contrasted with onscreen computer output

machine_name% su

Password:

aabbcc123

Placeholder: replace with a real name or value

The command to remove a file is rm filename.

AaBbCc123

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.

Table P-2 Shell Prompts

Shell

Prompt

C shell

machine_name%

C shell for superuser

machine_name#

Bourne shell and Korn shell

$

Bourne shell and Korn shell for superuser

#

     Contents     Index     Next Next