Introduction to Mass Storage Device Driver Programming Guide
This document introduces the architecture of the mass storage driver stack and describes how to write in-kernel drivers for mass storage devices and media filter schemes for content on mass storage media. It includes sample code that illustrates how to develop both in-kernel logical unit and protocol services drivers and in-kernel filter-scheme drivers.
Because this book focuses on kernel-resident drivers for mass storage devices that mount file systems or are bootable, it provides only a brief description of application-based drivers for other mass storage devices, such as tape drives. For general information on how to write drivers for such devices, see Accessing Hardware From Applications.
Who Should Read This Document?
You should read this document if you need to support a mass storage device that mounts a file system or is bootable, or if you need to develop a filter-scheme driver.
Writing drivers for OS X requires the I/O Kit, Apple’s object-oriented framework for driver development. Although this document presents some information on selected I/O Kit principles to provide context for the implementation of the mass storage driver stack, it does not explain these concepts in detail. If you’re not familiar with the I/O Kit, you should read I/O Kit Fundamentals before reading this document.
In addition, if you’ve never written an in-kernel device driver for OS X, you should read I/O Kit Device Driver Design Guidelines to become familiar with driver fundamentals such as driver life cycle and driver matching and loading.
Organization of This Document
This document contains the following chapters:
“Mass Storage Overview” describes how OS X supports mass storage devices and how the mass storage driver stack is built.
“Mass Storage Device Compliance” describes the various device specifications with which your device must comply to work with the built-in mass storage device drivers.
“Mass Storage Driver Matching and Loading” describes the driver matching process for protocol services, logical unit, and filter-scheme drivers.
“Developing a Universal Binary” provides some tips for developing a universal binary version of a logical unit driver, a protocol services driver, and a filter-scheme driver.
“Subclassing Logical Unit Drivers” describes how to subclass a built-in logical unit driver to provide device-specific support.
“Subclassing Protocol Services Drivers” describes how to subclass a built-in protocol services driver to provide device-specific support.
“Developing a Filter Scheme” describes how to create and test a filter-scheme driver.
“Document Revision History” lists the revisions of this document.
Kernel Extension Programming Topics contains tutorials that introduce you to the fundamental techniques you need to develop, debug, and package kernel extensions. This document also contains information on kernel extension loading and dependencies.
I/O Kit Fundamentals describes the architecture of the I/O Kit, the object-oriented framework for developing OS X device drivers.
I/O Kit Device Driver Design Guidelines provides guidelines and tips for developing, debugging, and deploying kernel-resident device drivers.
Kernel Framework Reference contains API reference for I/O Kit methods and functions and for specific families
Sample Code > Hardware & Drivers > Storage includes both application-level and in-kernel code samples.
OS X Man Pages provides access to existing reference documentation for BSD and POSIX functions and tools in a convenient HTML format.
The darwin-drivers mailing list provides a forum for discussing technical issues related to I/O Kit device driver development.
If you're ready to create a universal binary version of your device driver or filter scheme to run in an Intel-based Macintosh, see Universal Binary Programming Guidelines. The Universal Binary Programming Guidelines describes the differences between the Intel and PowerPC architectures and provides tips for developing a universal binary.
The OS X mass storage stack supports mass storage devices that comply with the SCSI Architecture Model SCSI primary commands specification, declare peripheral device types of $00, $05, $07, or $0E, and connect to ATAPI, USB, or FireWire buses. In addition, a USB device must be compliant with the USB mass storage class specification and a FireWire device must be compliant with the FireWire Serial Bus Protocol 2 (SBP-2) specification. The following websites provide more information on these specifications:
SCSI Architecture Model specifications (http://t10.org)—Provides computer interface and command set specifications and the FireWire Serial Bus Protocol 2 specification.
ATA/ATAPI standards (http://t13.org)—Provides access to the ATA/ATAPI-5 specification.
USB specifications (http://www.usb.org)—Contains the USB Mass Storage Class Specification Overview.
FireWire specifications (http://standards.ieee.org)—Provides access to FireWire standards.
1394 Trade Association (http://1394ta.org)—Provides access to new and draft specifications for the IEEE 1394 standard.