Preface
Writing Device Drivers provides information on developing device drivers for character-oriented devices, block-oriented devices, and small computer system interface (SCSI) target devices. This book discusses the development of a dynamically loadable and unloadable, multithreaded re-entrant device driver applicable to all architectures that conform to the Solaris 9 DDI/DKI. A common driver programming approach is taken so that drivers can be written without concern for platform-specific issues, such as endianness and data ordering.
Who Should Use This Book
The audience for this book is UNIX® programmers familiar with UNIX device drivers. Several overview chapters at the beginning of the book provide background information for the detailed technical chapters that follow, but they are not intended as a general tutorial on device drivers.
Note - The Solaris operating environment runs on two types of hardware, or platforms--SPARC and IA. The Solaris operating environment also runs on both 64-bit and 32-bit address spaces. The information in this document pertains to both platforms and address spaces unless called out in a special chapter, section, note, bullet, figure, table, example, or code example.
How This Book Is Organized
This book is organized into the following chapters.
Chapter 1, Solaris Kernel and Device Tree provides an overview of the Solaris kernel and the manner in which it represents devices as nodes in a device tree.
Chapter 2, Overview of Solaris Device Drivers gives an outline of the kinds of device drivers and their basic structure. It points out the common data access routines and concludes with an illustrated roadmap of common driver entry points and structures.
Chapter 3, Multithreading describes the mechanisms of the Solaris multithreaded kernel that are of interest to driver writers.
Chapter 4, Properties and Events describes the set of interfaces used to read an update device node properties. It also contains information on events and name-value pairs.
Chapter 5, Driver Autoconfiguration explains the support a driver must provide for autoconfiguration.
Chapter 6, Device Access -- Programmed I/O describes the interfaces and methodologies for drivers to use to access (read or write) device memory.
Chapter 7, Interrupt Handlers describes the interrupt handling mechanisms. These include registering, servicing, and removing interrupts.
Chapter 8, Direct Memory Access (DMA) describes direct memory access (DMA) and the DMA interfaces.
Chapter 9, Power Management explains the interfaces for Power Management, a framework designed to regulate and reduce the power consumed by computer systems and devices.
Chapter 10, Drivers for Character Devices describes the structure and functions of a driver for a character-oriented device.
Chapter 11, Drivers for Block Devices describes the structure and functions of a driver for a block-oriented device.
Chapter 12, Mapping Device and Kernel Memory describes the set of interfaces that enable device drivers to manage access to memory, control the context of user processes accessing a device, and take advantage of large data transfers using new MMU hardware.
Chapter 13, Device Context Management describes the set of interfaces that enable device drivers to manage user access to devices.
Chapter 14, SCSI Target Drivers outlines the Sun Common SCSI Architecture and describes the additional requirements of SCSI target drivers.
Chapter 15, SCSI Host Bus Adapter Drivers explains how to write a SCSI Host Bus Adapter (HBA) driver using the Sun Common SCSI Architecture (SCSA).
Chapter 16, Drivers for Network Devices describes the Generic LAN driver (GLD), which is used for Solaris network drivers. GLD uses STREAMS technology, along with the Data Link Provider Interface (DLPI) for communicating with network protocol stacks.
Chapter 17, Compiling, Loading, Packaging, and Testing Drivers provides information on compiling and linking a driver, and for installing it in the system.
Chapter 18, Debugging gives hints, a simple mdb/kadb tutorial, and some hints on testing the driver.
Chapter 19, Recommended Coding Practices describes the recommended coding practices for writing drivers.
Appendix A, Hardware Overview discusses multi-platform hardware issues related to device drivers.
Appendix B, Summary of Solaris 9 DDI/DKI Services summarizes, by topic, the kernel functions that device driver can use.
Appendix C, Making a Device Driver 64-Bit Ready provides guidelines for updating a device driver to run in a 64-bit environment.