I/O Kit Device Driver Design Guidelines
PDF
Introduction
The libkern C++ Runtime
Creation of the Runtime System
Object Creation and Destruction
Using the OSMetaClass Constructor Macros
Allocating Objects Dynamically
Global Initializers
Object Scope and Constructor Invocation
An Example of a Global Initializer
Object Introspection and Dynamic Casting
Binary Compatibility
The Fragile Base Class Problem
Reserving Future Data Members
Padding the Virtual Table
libkern Collection and Container Classes
The libkern Classes and Your Driver
libkern Collection and Container Class Overview
libkern Container Classes
libkern Collection Classes
Using the libkern Collection and Container Classes
Container Object Creation and Initialization
Container Object Introspection and Access
Collection Object Creation and Initialization
Collection Object Introspection and Access
Reference Counting for Collection and Container Classes
Thread Safety and the Container and Collection Classes
libkern Objects and XML
Configuring Your Driver Using the libkern Classes
Configuring a Subclass of IOAudioDevice
Configuring a Subclass of IOUSBMassStorageClass
The IOService API
Driver Life-Cycle and Matching Functionality
Driver Matching
Passive-Matching Keys
Driver State
Resources
User Clients
Probing
Notifications and Driver Messaging
Notification Methods
Messaging Methods
Access Methods
Getting Work Loops
Getting Clients and Providers
Getting Other I/O Kit Objects
Power Management
Power-Management Entities
Using the Power Management Methods
Memory Mapping and Interrupt Handling
Accessing Device Memory
Handling Interrupts
Miscellaneous IOService Methods
Making Hardware Accessible to Applications
Transferring Data Into and Out of the Kernel
Issues With Cross-Boundary I/O
Mac OS 9 Compared
Programming Alternatives
I/O Kit Family Device Interfaces
Using POSIX APIs
Accessing Device Properties
Custom User Clients
Writing a Custom User Client
The Architecture of User Clients
Types of User-Client Transport
Synchronous Versus Asynchronous Data Transfer
Factors in User Client Design
Range of Accessibility
Design of Legacy Applications
Hardware
Task Files
A Design Scenario
Implementing the User Side of the Connection
The Basic Connection and I/O Procedure
Defining Common Types
Get the I/O Kit Master Port
Obtain an Instance of the Driver
Create a Connection
Open the User Client
Send and Receive Data
Close the Connection
Aspects of Design for Device Interfaces
Creating a User Client Subclass
User-Client Project Basics
Initialization
Exclusive Device Access and the open Method
Cleaning Up
Passing Untyped Data Synchronously
Scalar and Structure
Including the Header File of Common Types
Constructing the IOExternalMethod Array
Implementing getTargetAndMethodForIndex
Validation
Passing Untyped Data Asynchronously
Application Procedure Using CFRunLoop
User Client Procedure
Mapping Device Registers and RAM Into User Space
A Guided Tour Through a User Client
Common Type Definitions
The Device Interface Library
The User Client
Kernel-User Notification
Presenting Notification Dialogs
Launching User-Space Executables
Presenting Bundled Dialogs
Displaying Localized Information About Drivers
Internationalizing Kernel Extensions
Creating and Populating the Localization Directories
Internationalizing Strings
Getting the Path to a KEXT From User Space
Debugging Drivers
Some Debugging Basics
General Tips
Issues With 64-Bit Architectures
Driver-Debugging Tools
Debugging Matching and Loading Problems
Driver Dependencies
Using kextload, kextunload, and kextstat
Loading Your Driver
Unloading Your Driver
Debugging Your Driver’s start and probe Methods
Debugging Matching Problems
Two-Machine Debugging
Setting Up for Two-Machine Debugging
Using the Kernel Debugging Macros
Tips on Using gdb
Examining Computer Instructions
Breakpoints
Single-Stepping
Debugging Kernel Panics
General Procedure
Tips on Debugging Panics
Debugging System Hangs
Debugging Boot Drivers
Logging
Using IOLog
Custom Event Logging
Testing and Deploying Drivers
Testing Strategies
Basic Quality Control
Configuration Testing
Power-Management Testing
Other Testing Strategies and Goals
Packaging Drivers for Installation
Package Contents
Package Validation and Installation
Developing a Device Driver to Run on an Intel-Based Macintosh
Byte Swapping
Handling Architectural Differences
Viewing Values in the Device Tree Plane
Interrupt Sharing in an Intel-Based Macintosh
Using the OSSynchronizeIO Function
Accessing I/O Space
Debugging on an Intel-Based Macintosh
Glossary
Revision History
Index