The I/O Kit is an open-source framework in the XNU kernel that helps developers code device References[edit]. I/O Kit Fundamentals – Technical reference from Apple Developer Connection. begin creating your own driver, you should make sure you understand the architecture of the I/O Kit by reading Architectural Overview in IOKit Fundamentals. See “I/O Kit Fundamentals” at Darwin/IOKit/IOKitFundamentals/ This is also available as.

Author: Arashilkis Dolrajas
Country: Sri Lanka
Language: English (Spanish)
Genre: Business
Published (Last): 11 June 2006
Pages: 158
PDF File Size: 20.5 Mb
ePub File Size: 14.87 Mb
ISBN: 424-6-42266-667-1
Downloads: 64786
Price: Free* [*Free Regsitration Required]
Uploader: Kagasho

This tutorial does not cover the process for loading or debugging your driver. Provider objects that do so are referred to as nubs. A driver matches against a device by defining fundamentqls or more personalitiesdescriptions of the types of device the driver ioklt control. In the New Project panel, select System Plug-in from the list of project categories on the left.

Select IOKit Driver from the list of templates on the right. In the screen that fundanentals, enter MyDriver for the product name, enter a company identifier, and click Next.

The new project contains several files, including a source file, MyDriver. Select the Build Settings tab. Click the disclosure triangle next to Architectures. Next to Build Active Architecture Only make sure to select No—this is especially important if you are running a bit kernel on a bit machine. Io,it all bundles, a device driver contains an information property list, which describes the driver.

Whenever possible, you should view and edit the file from within Xcode or within the Property List Editor application. Xcode displays the Info. You should see the elements of the property list file, as shown in Figure 1.

Change the value of the CFBundleIdentifier property to use your unique namespace prefix.

The value should now be com. This convention is particularly important for kexts, because all loaded kexts share a single namespace for bundle identifiers. Click the IOKitPersonalities property to select it, then click its disclosure triangle so that it points down. Fundamenhals the New Child symbol on the right side of the selected line.

Change the name of New item to MyDriver.

Make the MyDriver item a dictionary. Your device driver requires one or more entries in the IOKitPersonalities dictionary of its information property list. This dictionary defines properties used for matching your driver to a device and loading it. Create a child entry for the MyDriver dictionary. Create a second child for the MyDriver dictionary. Rename the child to IOClass.

IOKit Fundamentals

Note that this is the same value as for the CFBundleIdentifierexcept it separates its elements with underbars instead of dots. This value is used as the class name for your device driver. Create a third child for the MyDriver dictionary.

Rename the child to IOKitDebug. Enter as the value and change the value type from String to Number. If you specify a nonzero value for this property, your driver provides useful debugging information when it matches and loads. When you build your driver for public release, you should specify 0 as the value fundamentls this property or remove it entirely.


Create two more children for the MyDriver dictionary. Assign their names and values according to Table 1. These elements together define a successful match for your driver, so that it can be loaded.

They serve the following purposes:. IOProviderClass indicates the class of the provider objects that your driver can match on. Normally a device driver matches on the nub that controls the ioikt that your device is connected to.

What Is the I/O Kit?

In this tutorial, you are creating a virtual driver with no device, so it matches on IOResources. When you develop your driver, you should not include this property unless your driver matches on a device that another driver may match on, such as fundamnetals serial port with multiple devices attached to it. When you have finished adding property list elements, the list should look fundamdntals the example shown in Figure 2.

The default header file contains no code. Figure 3 shows where to find the MyDriver.

[DEVELOPER] How To Write An IOKit Ethernet Driver

Edit the contents of MyDriver. Notice that the first line of MyDriver. This header file defines many of the methods and services that device drivers use. The header file is located in the IOKit folder of Kernel. When you develop your own driver, be sure to include only header files from Kernel. If you include other header files, your driver might compile, but it fails to load because the functions and services defined in fundamnetals header files are not available in the kernel.

The macro takes one argument: The default file contains no code. This macro takes two arguments: These entry points serve the following purposes:. The init method is the first instance method called on each instance of your driver class. It is called only once on each instance. The free method is the last method called on any object. Any outstanding resources allocated by the driver should be disposed of in free. Note that the init method operates on objects generically; it should be used only to prepare objects to receive calls.

Actual driver functionality should be set up in the start method. The probe method is called if your driver needs to communicate with hardware to determine whether there is a match. This method must leave the hardware fundamenrals a good state when it returns, because other drivers may probe the hardware as well.

Introduction to I/O Kit Fundamentals

The start method tells the driver to start driving hardware. The stop method is the first method to be called before your driver is unloaded. When stop is called, your driver should clean up any state it created in its start method. Because kexts are linked at load time, a kext must list its libraries in its information property list with the OSBundleLibraries property.


At this stage of creating your driver, you need to find out what those libraries are. Its purpose is to identify libraries that your kext needs to link against. This directory contains iokkit driver. It should have the name MyDriver. If kextlibs prints any errors or exits with a nonzero status, it may have been unable to locate some symbols.

For this tutorial, the libraries are known, but in general usage you should use the kextfind tool to find libraries for any symbols that kextlibs cannot locate. Earlier you edited the information property list with the Xcode graphical property list editor.

For this operation, however, you need to edit the information property list as text. You should see the XML contents of the property list file, as shown in Figure 3. Fundamntals that dictionary keys and values are listed sequentially.

Fix any compiler errors before continuing. Now you are ready to prepare your driver for loading. You do this with the kextutil tool, which can examine a kext and determine whether it is able to be loaded. Kexts have strict permissions requirements.

The easiest way to set these permissions is to create a copy of your driver as the root user. Type the following into Terminal from the proper directory and provide your password when prompted:.

The -n or -no-load option tells kextutil not to load the driver, and the -t or -print-diagnostics option tells kextutil to print the results of its analysis to Terminal. If you have followed the previous steps in this tutorial correctly, kextutil indicates that the kext is loadable and properly linked.

The debug property notice is due to the nonzero value of the IOKitDebug property in the information property list. Make sure you set this property to 0 or remove it when you build your driver for release. The New Project panel appears. Choose a location for the project, and click Create.

Xcode creates a new project and displays its project window. You should see something like this: Make sure the kext is building for the correct architectures. Edit the Information Property List Like all bundles, a device driver contains an information property list, which describes the driver. Fill in the personality dictionary. No kernel file specified; using running kernel for linking.