< Previous PageNext Page > Hide TOC

Kernel Extension Dependencies

Before loading a kernel extension (KEXT), the kernel extension management facilities in Mac OS X check its compatibility with other loadable extensions it depends on and with the kernel itself. To make sure your KEXT loads, be sure you know what your KEXT depends on and how to declare those dependencies.

This document provides kernel subcomponent and loadable extension versions for Mac OS X versions 10.0 through 10.4.2. It also describes the kernel programming interface (KPI) collections introduced in Mac OS X version 10.4 and how to use them.

Contents:

KEXT Versions and Dependencies
Installing and Removing Kernel Extensions


KEXT Versions and Dependencies

Every kernel extension has a version that is stored both in its information property list (Info.plist file) and in its executable. The version number is stored as a string property in the ‘vers’ resource style named CFBundleVersion (described in http://developer.apple.com/documentation/mac/Toolbox/Toolbox-454.html and Technical Note TN1132). A KEXT or kernel component that can be depended on also declares the earliest version its current version is compatible with. This version (also in the ‘vers’ resource style) is stored in the OSBundleCompatibleVersion property at the top level of its Info.plist file.

A KEXT declares dependencies on other loadable extensions or kernel subcomponents by listing them as elements in the OSBundleLibraries dictionary at the top level of its Info.plist file. Each element in the OSBundleLibraries dictionary consists of a key/value pair. The key is the CFBundleIdentifier of the dependency (such as com.apple.kernel.mach), and the value is the required version of the dependency expressed as a ‘vers’ resource style string (such as 1.0b1). When a KEXT is about to be loaded, the required version of each element in its OSBundleLibraries dictionary is compared to the current and compatible versions of the dependency. If the required version lies between the current version of the dependency and its OSBundleCompatibleVersion value, inclusive, the KEXT and its dependencies are deemed compatible and loading proceeds.

If you fail to declare the appropriate dependencies, your KEXT will probably compile, but it will not load. To help you catch such problems early, it’s good practice to use the kextload tool to load your KEXT periodically thoughout the development cycle. The kextload tool has options that allow it to perform a wide range of tests; for more information, see Mac OS X Man Pages or type man kextload in a Terminal window.

KPIs and KEXT Dependencies in Mac OS X v10.4 and Later

In Mac OS X v10.4, Apple introduced sustainable kernel programming interfaces, or KPIs. In particular, the KPIs support the development of NKEs (network kernel extensions), file-system KEXTs, and other non-I/O Kit KEXTs. For more information on the KPIs themselves, see KPI Reference.

The KPIs are divided into collections which correspond in name to the kernel subcomponents available in earlier versions of Mac OS X. For example, the KPI collection that corresponds to the com.apple.kernel.libkern kernel subcomponent is com.apple.kpi.libkern. In Mac OS X v10.4 and later, you declare dependencies on KPI collections by creating key/value pairs in your KEXT’s OSBundleLibraries dictionary, just as you did for dependencies on kernel subcomponents (as described in “KEXT Versions and Dependencies”). The key is the KPI collection’s CFBundleIdentifier (such as com.apple.kpi.bsd) and the value is the current version of the Darwin kernel expressed as a ‘vers’ resource style string. Because you can only declare a dependency on a KPI collection in Mac OS X v10.4 and later, the minimum version number is 8.0. To get the current version of the Darwin kernel, type uname -a in a Terminal window.

For pure I/O Kit KEXTs (those that use only I/O Kit-provided APIs), no changes in declared dependencies are necessary. This is because Mac OS X v10.4 provides backward compatibility with the I/O Kit kernel subcomponents available in earlier versions of Mac OS X. Therefore, you can continue to declare your pure I/O Kit KEXT’s dependencies on the kernel subcomponent versions of the earliest version of Mac OS X you need to run in. For more information on how to do this, see “Declaring Dependencies on Kernel Subcomponents.”

Note: If you are developing a universal I/O Kit device driver, see Technical Note TN2163: Building Universal I/O Kit Drivers for information on how to configure your Xcode project and declare the correct dependencies for your situation.

You should consider, however, taking this opportunity to make sure all your pure I/O Kit KEXT’s dependencies are explicitly declared. If, for example, your KEXT uses libkern symbols, declare an explicit dependency on com.apple.kernel.libkern. This may seem obvious, but some earlier versions of Mac OS X allowed implicit dependencies on some kernel subcomponents (such as com.apple.kernel.libkern) when you declared an explicit dependency on com.apple.kernel.iokit. The KPI collections, on the other hand, do not allow any implicit dependencies. Therefore, if your KEXT declares only explicit dependencies on kernel subcomponents, it will make it much easier to switch to dependencies on KPIs at some point in the future.

If your I/O Kit-based KEXT makes non-I/O Kit BSD or Mach calls, it may not load in Mac OS X v10.4 because some non-I/O Kit symbols are no longer available. If this describes your KEXT, you must develop a new version of your KEXT for Mac OS X v10.4 that depends on the appropriate KPI collections instead of the kernel subcomponents it depended on before.

Important: You cannot combine dependencies on KPI collections and dependencies on kernel subcomponents in the same KEXT; dependencies must be all of one type or the other. If your KEXT declares dependencies on both KPI collections and kernel subcomponents, it will fail to load.

Beginning in Mac OS X v10.4, there are three, mutually exclusive ways to declare KEXT dependencies, the first two of which are discussed above. The following list summarizes the three methods, explains how to get the correct version for each type of dependency, and describes the circumstances in which you can use each method.

Declaring Dependencies on Kernel Subcomponents

The following tables show the CFBundleVersion value of each kernel subcomponent. Note that Table 1 also includes the CFBundleVersion values for select kernel extensions. This is because in versions of Mac OS X prior to 10.1, these kernel extensions were included in the kernel. In Mac OS X version 10.1, however, most of these kernel extensions were removed from the kernel and made into loadable kernel extensions. The remaining four tables do not list these loadable kernel extensions.

Table 1  Kernel subcomponent CFBundleVersion values for Mac OS X, version 10.0 through 10.1

CFBundleIdentifier

10.0

10.0.1

10.0.2

10.0.3

10.0.4 Tier 2 Language Support

10.0.4 Software Update

10.1

com.apple.kernel

1.0b1

1.0b1

1.3.2

1.3.3

1.3.5

1.3.7

1.4

com.apple.kernel.mach

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1

com.apple.kernel.bsd

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1

com.apple.kernel.libkern

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1

com.apple.kernel.iokit

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1

com.apple.iokit.IOADBFamily

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(M)

com.apple.iokit.IOCDStorageFamily

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(L)

com.apple.iokit.IODVDStorageFamily

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(L)

com.apple.iokit.IOGraphicsFamily

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(L)

com.apple.iokit.IOHIDSystem

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(L)

com.apple.iokit.IONDRVSupport

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(L)

com.apple.iokit.IONetworkingFamily

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(L)

com.apple.iokit.IOPCIFamily

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(L)

com.apple.iokit.IOStorageFamily

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(L)

com.apple.iokit.IOSystemManagementFamily

1.0b1

1.0b1

1.0.2

1.0.3

1.0.5

1.0.7

1.1(M)

Note: Component versions marked (L) in Table 1 indicate that the component was removed from the kernel and made into a loadable kernel extension.

Component versions marked (M) in Table 1 indicate that the component was moved into the System.kext PlugIns folder.

The following tables (Table 2, Table 3, Table 4, and Table 5) each list kernel subcomponent CFBundleVersion values for a range of operating system releases, beginning with Mac OS X version 10.1.1. The kernel subcomponents in these tables are:

In the interests of space, the com.apple. prefix is not included in each kernel subcomponent CFBundleIdentifier value.

Table 2  Kernel subcomponent CFBundleVersion values for Mac OS X, versions 10.1.1 through 10.1.5

System release

kernel

kernel.mach

kernel.bsd

kernel.libkern

kernel.iokit

10.1.1 (Build 5M45)

5.1

5.1

5.1

5.1

5.1

10.1.2 (Build 5P68)

5.2.2

5.2

5.2

5.2

5.2.2

10.1.3 (Builds 5Q45, 5Q83)

5.3

5.3

5.3

5.3

5.3

10.1.4 (Build 5Q125)

5.4

5.4

5.4

5.4

5.4

10.1.4 (Builds 5R48, 5R60)

5.3.2

5.3.2

5.3.2

5.3.2

5.3.2

10.1.4 (Build 5R106)

5.4.2

5.4.2

5.4.2

5.4.2

5.4.2

10.1.5 (Build 5S60)

5.5

5.5

5.5

5.5

5.5

Table 3  Kernel subcomponent CFBundleVersion values for Mac OS X, versions 10.2 through 10.2.8

System release

kernel

kernel.mach

kernel.bsd

kernel.libkern

kernel.iokit

10.2 (Build 6C115)

6.0

6.0

6.0

6.0

6.0

10.2.1 (Builds 6DF52-6E62)

6.1

6.1

6.1

6.1

6.1

10.2.2 (Builds 6F21, 6F39)

6.2

6.2

6.2

6.2

6.2

10.2.3 (Builds 6G30-6H59)

6.3

6.3

6.3

6.3

6.3

10.2.4 (Builds 6I32, 6I34)

6.4

6.4

6.4

6.4

6.4

10.2.5 (Build 6L29)

6.5

6.5

6.5

6.5

6.5

10.2.6 (Build 6L60)

6.6

6.6

6.6

6.6

6.6

10.2.6 (Builds 6R106-6R132)

6.8

6.8

6.8

6.8

6.8

10.2.7 (Builds 6R42-6R55)

6.7

6.7

6.7

6.7

6.7

10.2.8 (Builds 6R65, 6R73)

6.8

6.8

6.8

6.8

6.8

Table 4  G5 kernel subcomponent CFBundleVersion values for Mac OS X versions 10.2.7 and 10.2.8

System release

kernel

kernel.mach

kernel.bsd

kernel.libkern

kernel.iokit

10.2.7 (Builds 6S74-6S80)

6.7.5

6.7.5

6.7.5

6.7.5

6.7.5

10.2.8 (Build 6S90)

6.8.5

6.8.5

6.8.5

6.8.5

6.8.5

Table 5  Kernel subcomponent CFBundleVersion values for Mac OS X versions 10.3 through 10.3.9

System release

kernel

kernel.6.0

kernel.mach

kernel.bsd

kernel.libkern

kernel.iokit

10.3 (Build 7B85)

7.0

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.1 (Builds 7C107-7C9)

7.0

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.2 (Builds 7D24-7D28)

7.2

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.2 (Builds 7E40, 7E46)

7.2.1

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.3 (Build 7F44)

7.3

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.3 (Build 7G21)

7.3.1

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.4 (Builds 7H63-7H142)

7.4

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.4 (Builds 7L32-7L46)

7.4.1

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.5 (Builds 7M34-7P36)

7.5

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.5 (Builds 7P124-7P220)

7.5.1

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.6 (Builds 7R28-7R107)

7.6

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.7 (Build 7S215)

7.7

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.7 (Build 7T21)

7.7.1

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.7 (Builds 7T51-7T62)

7.7.2

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.8 (Build 7U16)

7.8

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

10.3.9 (Build 7W98)

7.9

6.9.9

6.9.9

6.9.9

6.9.9

6.9.9

Table 6  Kernel subcomponent CFBundleVersion values for Mac OS X versions 10.4 through 10.4.10

System release

kernel

kernel.6.0

kernel.mach

kernel.bsd

kernel.libkern

kernel.iokit

10.4 (Build 8A428)

8.0

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.1 (Build 8B15)

8.1

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.2 (Builds 8C46, 8E45, 8E90, and 8E102)

8.2

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.3 (Build 8F46)

8.3

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.4 (Builds 8G32 and 8G1165)

8.4

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.5 (Builds 8H14 and 8G1454)

8.5

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.6 (Builds 8I127 and 8I1119)

8.6

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.7 (Builds 8J135, 8J2135a, and 8K1079)

8.7

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.8 (Builds 8L127 and 8L2127)

8.8

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.9 (Builds 8P135 and 8P2137)

8.9

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

10.4.10 (Builds 8R218 and 8R2218)

8.10

7.9.9

7.9.9

7.9.9

7.9.9

7.9.9

You can also get this information by using the kextstat utility to examine the version numbers of these components. (For more information on how to use kextstat, type man kextstat in a Terminal window.) To build a KEXT that works on two different versions of Mac OS X, build the KEXT on the oldest version you want to support.

If an I/O Kit kernel extension does not declare a dependency that defines a superclass but otherwise uses no symbols within that dependency, the KEXT will load successfully but the runtime metaclass system will fail to create an instance of the class, due to the absence of the superclass. In this case, an error message to this effect will be displayed.

The identifier com.apple.kernel represents the kernel as a whole. Because every kernel extension is linked against the kernel, it may seem easier to declare your KEXT's dependency on com.apple.kernel instead of the individual kernel subcomponents. However, if any part of the kernel changes in an incompatible way, the compatible version (the OSBundleCompatibleVersion value) for com.apple.kernel will be incremented. This may prevent your KEXT from loading even if the kernel subcomponents your KEXT actually depends on remain unchanged.

To determine which of the four kernel subcomponents your KEXT depends on, examine the #include directives in your KEXT's code. Table 7 lists header directories and their corresponding kernel subcomponents.

Table 7  Header directories and corresponding kernel subcomponents

Header Directory

Module Dependency

architecture

com.apple.kernel.libkern

bsd

com.apple.kernel.bsd, com.apple.kernel.mach

crypto

com.apple.kernel.bsd, com.apple.kernel.mach

ddb

com.apple.kernel.mach

default_pager

com.apple.kernel.mach

dev

com.apple.kernel.bsd, com.apple.kernel.mach

device

com.apple.kernel.mach

hfs

com.apple.kernel.bsd, com.apple.kernel.mach

i386

com.apple.kernel.bsd, com.apple.kernel.mach

IOKit

com.apple.kernel.iokit, com.apple.kernel.libkern

ipc

com.apple.kernel.mach

isofs

com.apple.kernel.bsd, com.apple.kernel.mach

kern

com.apple.kernel.bsd, com.apple.kernel.mach

libkern

com.apple.kernel.libkern

libsa

Kernel extensions should not use this API

mach

com.apple.kernel.mach

mach-o

Kernel extensions should not use this API

mach_debug

com.apple.kernel.bsd, com.apple.kernel.mach

machine

com.apple.kernel.bsd, com.apple.kernel.mach

miscfs

com.apple.kernel.bsd, com.apple.kernel.mach

net

com.apple.kernel.bsd, com.apple.kernel.mach

netat

com.apple.kernel.bsd, com.apple.kernel.mach

netccitt

com.apple.kernel.bsd, com.apple.kernel.mach

netinet

com.apple.kernel.bsd, com.apple.kernel.mach

netinet6

com.apple.kernel.bsd, com.apple.kernel.mach

netiso

com.apple.kernel.bsd, com.apple.kernel.mach

netkey

com.apple.kernel.bsd, com.apple.kernel.mach

netns

com.apple.kernel.bsd, com.apple.kernel.mach

nfs

com.apple.kernel.bsd, com.apple.kernel.mach

pexpert

Kernel extensions should not use this API

ppc

com.apple.kernel.bsd, com.apple.kernel.mach

profile

Kernel extensions should not use this API

sys

com.apple.kernel.bsd, com.apple.kernel.mach

ufs

com.apple.kernel.bsd, com.apple.kernel.mach

UserNotification

com.apple.kernel.mach

vfs

com.apple.kernel.bsd, com.apple.kernel.mach

vm

com.apple.kernel.mach

If your KEXT can be depended on by other kernel extensions you must declare the earliest version that remains compatible with the current version in the OSBundleCompatibleVersion property at the top level of its Info.plist file. If this property is absent, no other kernel extension can declare a dependency on your KEXT. If you make changes to your KEXT that break binary compatibility with earlier versions (for example, the removal of a function or symbol) then you should change the value of the OSBundleCompatibleVersion property to equal the value of the CFBundleVersion property of the new version. It is not necessary to increment the OSBundleCompatibleVersion value every time you increment the CFBundleVersion value unless you've broken binary compatibility with a previously compatible version.

Installing and Removing Kernel Extensions

Software installers that install and remove kernel extensions can copy them to /System/Library/Extensions or remove them from that folder. To load a new, nondriver KEXT either the system must be restarted or the new KEXT must be explicitly loaded with the kextload utility. To load a driver KEXT the system must be restarted to ensure reliable matching and loading of the driver for all possible devices.

The system keeps a cache of installed KEXTs to speed up boot time. It updates this cache when it detects any change to the /System/Library/Extensions folder. If an installer installs an extension as a plug-in of another, however, only a subfolder of the /System/Library/Extensions folder is updated and the automatic cache update is not triggered. To force a cache update, you can change the modification date of the /System/Library/Extensions folder by using the UNIX command touch. For example, placing

touch /System/Library/Extensions

in a postprocessing shell script for your installer will guarantee that the cache gets updated.



< Previous PageNext Page > Hide TOC


© 2003, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-31)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.