This chapter assumes you have an application or other user-space code that needs to access one or more specific types of device and that you:
Have determined that your application can’t satisfy its hardware needs with the higher-level APIs described in “Hardware-Access Options”
Are familiar with the I/O Kit summary information in “Device Access and the I/O Kit”
Want to know how to access hardware with an I/O Kit device interface or using the POSIX API
This chapter provides a generic blueprint for accessing devices with I/O Kit device interfaces and device files. It describes several ways to find devices in the I/O Registry and how to examine each device you find. It then describes how to access a device through a device interface or a device file.
Your code will implement many of the functions discussed in this chapter because some actions, such as getting a Mach port to communicate with the I/O Kit and looking up your devices in the I/O Registry, are common to all applications that use the I/O Kit API to access hardware.
Important: Bear in mind that individual I/O Kit families are free to define access to their devices as they choose. Although your application will follow the steps this chapter outlines, some of the particulars, such as determining matching keys and values, vary by family. Be sure to consult the documentation for the device family you’ll be working with.
This chapter describes how to use several I/O Kit and Core Foundation functions. You can view the header file describing the I/O Kit functions in /System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h and the Core Foundation functions in various files in /System/Library/Frameworks/CoreFoundation.framework/Headers. You can also view header documentation for these files on disk in /Developer/Documentation or on the web in the Device Drivers Reference Library. Complete sample projects are available in Sample Code > Hardware & Drivers and, when you install the Developer package, in /Developer/Examples/IOKit.
Finding Devices in the I/O Registry
Examining Matching Objects
Putting It All Together: Accessing a Device
Last updated: 2007-02-08