[Return to Library] [Contents] [Next Section] [Next Chapter] [Index] [Help]


About This Book

This book discusses how to write device drivers for computer systems running the Digital UNIX® operating system.


[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


Audience

This book is intended for systems engineers who:

Although the book assumes a strong background in UNIX-based operating systems and C programming, it does not assume any background in device drivers. In addition, the book assumes that the audience has no source code licenses.

A secondary audience is systems engineers who need to implement a new bus or make changes to the implementation of an existing bus. Topics of interest to this audience include descriptions of the bus structure members.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


New and Changed Features

The following sections summarize the changes and additions made to this version of the book.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Organizational Changes

The following list summarizes the organizational changes made to the book:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Miscellaneous Changes

The following list summarizes miscellaneous changes made to the book:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Terminology Changes and Issues

The following list summarizes terminology changes and issues. See the Glossary for definitions of these new terms.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Scope of the Book

The book is directed towards users of the Digital UNIX operating system on computer systems developed by Digital Equipment Corporation. However, the book provides information on designing drivers, on data structures, and kernel interfaces that would be useful to any systems engineer interested in writing UNIX-based device drivers.

The book presents a simple fictitious device driver called /dev/none that introduces the driver development process. In addition, code fragments from a fictitious driver called /dev/xx illustrate how to set up and implement device driver interfaces that are not applicable to the /dev/none driver. Both driver examples show how to use many of the kernel support interfaces that device drivers call.

The book does not emphasize any specific types of device drivers. However, mastering the concepts and examples presented in this book would be very useful preparation for writing a variety of device drivers, including drivers for disk and tape controllers as well as more specialized drivers such as array processors.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Organization

The book contains the following chapters and appendixes.


Part 1 Overview

Part 1 contains one chapter, whose goal is to provide you with an overview of device drivers.
Chapter 1 Introduction to Device Drivers
  Provides an overview of device drivers. Read this chapter to obtain introductory information on device drivers and to understand the place of a device driver in Digital UNIX.


Part 2 Anatomy of a Device Driver

Part 2 contains four chapters, whose combined goal is to provide the background information you need to write a simple Digital UNIX device driver.
Chapter 2 Developing a Device Driver
  Describes how to design a device driver. Read this chapter if you are not familiar with the driver development process on Digital UNIX.
Chapter 3 Understanding CPU and Bus Issues That Influence Device Driver Design
  Describes the CPU- and bus-related issues that influence the design of device drivers. Read this chapter to learn about issues you need to consider when you want to write device drivers that are portable across multiple Alpha CPU platforms and Digital-implemented bus architectures.
Chapter 4 Porting Digital UNIX Device Drivers
  Discusses how to port device drivers from the ULTRIX operating system to the Digital UNIX operating system. The chapter also describes the issues you need to consider when deciding whether to update device drivers from previous versions of Digital UNIX to the current version of Digital UNIX. Read this chapter to obtain information about porting tasks.
Chapter 5 Analyzing the Structure of a Device Driver
  Analyzes the sections that make up character and block device drivers. Read this chapter if you are not familiar with the sections that make up character and block drivers on Digital UNIX. If you have experience in writing UNIX device drivers, you may want to read selected sections, particularly the section that describes the header files you can include in your device drivers.


Part 3 Writing and Testing a Device Driver

Part 3 contains six chapters, whose combined goal is to provide the information you need to implement the device driver interfaces for block and character device drivers.
Chapter 6 Implementing a Configure Interface to Support Static and Dynamic Configuration
  Describes how to implement a configure interface to support static and dynamic configuration of device drivers. Read this chapter if you are not familiar with the tasks associated with implementing this interface.
Chapter 7 Implementing Device Driver Interfaces That Support Device Autoconfiguration
  Describes how to implement the probe and unattach interfaces. The chapter also shows you how to set up the attach and slave interfaces. Read this chapter if you are not familiar with the tasks associated with implementing or setting up these interfaces.
Chapter 8 Implementing Character Device Driver Interfaces
  Describes how to implement the read, write, and select interfaces. The chapter also shows you how to set up the reset, stop, and mmap interfaces. Read this chapter if you are not familiar with the tasks associated with implementing or setting up these interfaces.
Chapter 9 Implementing Block Device Driver Interfaces
  Describes how to set up the dump, psize, and strategy interfaces. Read this chapter if you are not familiar with the tasks associated with setting up these interfaces.
Chapter 10 Implementing Character and Block Device Driver Interfaces
  Describes how to implement the open, close, and ioctl interfaces. The chapter also shows you how to set up an interrupt handler. Read this chapter if you are not familiar with the tasks associated with implementing or setting up these interfaces.
Chapter 11 Testing a Device Driver
  Describes how to test a device driver. Read this chapter to learn how to write simple test programs for a device driver.


Part 4 Delivering Device Drivers

Part 4 contains three chapters, whose combined goal is to give you the information necessary to deliver device driver products to customers and to statically or dynamically configure these driver products into the Digital UNIX kernel. The Guide to Preparing Product Kits provides detailed information on how to create device driver product kits.
Chapter 12 Device Driver Kits Delivery Process
  Provides an overview of the device driver kits delivery process. The overview provides a summary of the tasks performed during the device driver development, device driver kit development, and device driver installation phases. Read this chapter to obtain a general overview of the driver kits delivery process.
Chapter 13 Device Driver Configuration Files and File Fragments
  Describes how some of the system management utilities use the files and file fragments related to device driver configuration. Read this chapter to learn how the system management utilities operate on these files and file fragments.
Chapter 14 Building a Device Driver
  Discusses how to create the single binary module from the driver source file and how to statically and dynamically configure the single binary module into the kernel. Driver writers perform these tasks during the device driver development phase. Read this chapter to learn how to create the single binary module and how to statically and dynamically configure this single binary module into the kernel.


Part 5 Hardware Environment

Part 5 contains two chapters, whose combined goal is to provide you with a view into the device drivers' hardware environment.
Chapter 15 Hardware-Independent Model and Device Drivers
  Provides an overview of the hardware-independent model and how it relates to device drivers. Read this chapter to gain an understanding of how device drivers fit into the hardware-independent model.
Chapter 16 Hardware Components and Hardware Activities
  Describes the hardware components and activities related to device drivers. Read this chapter to obtain an understanding or to refresh your knowledge about the individual hardware components you will work with when writing your drivers.


Part 6 Kernel Environment

Part 6 contains two chapters, whose combined goal is to provide information about the kernel environment.
Chapter 17 Data Structures That the Autoconfiguration Software Uses
  Discusses data structures related to device autoconfiguration. Read this chapter if you are not familiar with these data structures. If you have experience in writing UNIX device drivers, you may want to read selected sections, especially the sections that discuss data structure members that are not familiar to you.
Chapter 18 Using Kernel Interfaces with Device Drivers
  Discusses the kernel interfaces that device drivers use most commonly, including those interfaces used to copy and move data. Read this chapter if you need examples of when, how, and why you would use these kernel interfaces in device drivers.


Part 7 Appendixes

Part 7 contains three appendixes and a glossary.
Appendix A Summary Tables
  Presents tables that summarize the header files, kernel interfaces, data structures, and other interfaces that device drivers use.
Appendix B Device Driver Example Source Listings
  Contains the source code listing for the /dev/none example driver. It also contains the source code listing for a pseudodevice driver called /dev/edpseudo.
Appendix C Device Driver Development Worksheets
  Provides worksheets for use in designing and coding a device driver.
Glossary Glossary
  Provides definitions of terms used in the book.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Related Documentation


The printed version of the Digital UNIX documentation set is color coded to help specific audiences quickly find the books that meet their needs. (You can order the printed documentation from Digital.) This color coding is reinforced with the use of an icon on the spines of books. The following list describes this convention:
Audience Icon Color Code
General users G Blue
System and network administrators S Red
Programmers P Purple
Device driver writers D Orange
Reference page users R Green


Some books in the documentation set help meet the needs of several audiences. For example, the information in some system books is also used by programmers. Keep this in mind when searching for information on specific topics.

The Documentation Overview, Glossary, and Master Index provides information on all of the books in the Digital UNIX documentation set.

Writing device drivers is a complex task; driver writers require knowledge in a variety of areas. One way to acquire this knowledge is to have at least the following categories of documentation available:

The following sections list the documentation associated with each of these categories.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Hardware Documentation

You should have available the hardware manual associated with the device for which you are writing the device driver. You should also have access to the manual that describes the architecture associated with the CPU that the driver operates on, for example, the Alpha Architecture Reference Manual.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Bus-Specific Device Driver Documentation

Writing Device Drivers: Tutorial is the core manual for developing device drivers on the Digital UNIX operating system. It contains information needed for developing drivers on any bus that operates on Digital platforms. Writing Device Drivers: Advanced Topics and Writing Device Drivers: Reference are companion volumes to the tutorial.

Writing Device Drivers: Advanced Topics describes topics that are beyond the scope of the core tutorial. Systems engineers can find information on such advanced topics as kernel threads and writing device drivers in a symmetric multiprocessing (SMP) environment. This book also provides information on how to write disk device drivers.

Writing Device Drivers: Reference describes, in reference-page style, the header files, kernel interfaces, data structures, and other interfaces that device drivers use.

The following books provide information about writing device drivers for a specific bus that is beyond the scope of the core tutorial, advanced topics, and reference:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Operating System Overview Documentation

Refer to the Technical Overview for a technical introduction to the Digital UNIX operating system. This manual provides a technical overview of the Digital UNIX system, focusing on the networking subsystem, the file system, virtual memory, and the development environment. In addition, the manual lists all system limits.

This manual does not supersede the Software Product Description (SPD), which is the definitive description of the Digital UNIX system.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Programming Tools Documentation

To create your device drivers, you use a number of programming development tools and should have on hand the manuals that describe how to use these tools. The following manuals provide information related to programming tools used in the Digital UNIX operating system environment:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Network Programming Documentation

Writing Device Drivers: Tutorial does not discuss how to write streams device drivers. However, Writing Device Drivers: Reference contains reference pages for kernel interfaces that STREAMS device drivers use. Refer to the Network Programmer's Guide for general information on STREAMS programming. This manual describes the Digital UNIX network programming environment. It describes in depth the X/Open Transport Interface (XTI) and the sockets and STREAMS programming frameworks, including information about system calls, header files, and libraries. Additionally, it provides information about porting sockets-based applications to XTI.

This manual also describes the software bridge ifnet (STREAMS module and DLPI STREAMS pseudodevice driver) that the Digital UNIX operating system supports. This bridge allows programs that use sockets-based protocol stacks to access STREAMS drivers, and programs that use STREAMS-based protocol stacks to access BSD-based drivers.

This manual is for experienced UNIX programmers and the reader is familiar with the following:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


System Management Documentation

Refer to the System Administration manual for information about building a kernel and for general information on system administration. This manual describes how to configure, use, and maintain the Digital UNIX operating system. It includes information on general day-to-day activities and tasks, changing your system configuration, and locating and eliminating sources of trouble.

This manual is for the system administrators responsible for managing the operating system. It assumes a knowledge of operating system concepts, commands, and configurations.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Porting Documentation

Refer to the Digital UNIX Migration Guide for a discussion of the differences between the Digital UNIX and ULTRIX operating systems. This manual compares the Digital UNIX operating system to the ULTRIX operating system by describing the differences between the two systems.

This manual has three audiences, as follows:

This manual assumes the reader is familiar with the ULTRIX operating system.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Kernel Kit Products Documentation

Refer to the Guide to Preparing Product Kits for information on how to create kernel (device driver) products kits. This manual provides the information that kit developers need to produce kernel products and layered products kits.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Reference Pages

The following reference pages are of interest to device driver writers:



[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


Reader's Comments

Digital welcomes any comments and suggestions you have on this and other Digital UNIX manuals.

You can send your comments in the following ways:

Please include the following information along with your comments:

The Digital UNIX Publications group cannot respond to system problems or technical support inquiries. Please address technical questions to your local system vendor or to the appropriate Digital technical support office. Information provided with the software media explains how to send problem reports to Digital.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Chapter] [Index] [Help]


Conventions

The following conventions are used in this book:


.
.
.
A vertical ellipsis indicates that a portion of an example that would normally be present is not shown.
. . . In syntax definitions, a horizontal ellipsis indicates that the preceding item can be repeated one or more times.
filename In examples, syntax descriptions, and function definitions, this typeface indicates variable values.
buf In function definitions this typeface is used to indicate names that you must type exactly as shown.
[ ] In formal parameter declarations in function definitions and in structure declarations, brackets indicate arrays. Brackets are also used to specify ranges for device minor numbers and device special files in sysconfigtab file fragments.

This book uses the word kernel ``interface'' instead of kernel ``routine'' or kernel ``macro.''