Framework

DriverKit

Develop device drivers that run in user space.

Overview

The DriverKit framework defines the fundamental behaviors for device drivers on macOS. The C++ classes of this framework define your driver's basic structure, and provide support for handling events and allocating memory. This framework also supports appropriate types for examining the numbers, strings, and other types of data found in your driver's I/O registry entry. Other frameworks such as USBDriverKit, HIDDriverKit, NetworkingDriverKit, PCIDriverKit, SerialDriverKit, and USBSerialDriverKit provide the specific behaviors you need to support different types of devices.

The drivers you build with DriverKit run in user space, rather than as kernel extensions, which improves system stability and security. You create your driver as an app extension and deliver it inside your existing app. Use the SystemExtensions framework to install and upgrade your driver.

Topics

Essentials

Requesting Entitlements for DriverKit Development

Request the entitlement for DriverKit development, and request other entitlements your driver needs to interact with specific devices and interfaces.

Creating a Driver Using the DriverKit SDK

Create a driver that supports proprietary features of your company’s hardware devices.

Debugging and Testing System Extensions

Debug your system extensions by temporarily disabling the security checks that macOS performs during the installation process.

com.apple.developer.driverkit

A Boolean value that indicates whether your extension has permission to run as a user-space driver.

IOService

The base class for managing the setup and registration of your driver.

Event Management

IODispatchQueue

An object that manages the serial execution of blocks.

IOInterruptDispatchSource

A dispatch source that reports hardware-related interrupt events to your driver.

IOTimerDispatchSource

A dispatch source that notifies your driver at a specific time.

IODataQueueDispatchSource

A dispatch source that manages a shared-memory data queue.

IODispatchSource

The common base class for dispatch sources.

OSAction

An object that executes your driver's custom behavior.

Memory Management

IOBufferMemoryDescriptor

A memory buffer allocated in the caller's address space.

IOMemoryDescriptor

The base class for describing a location in memory.

IOMemoryMap

A reference to an existing block of memory in the current process or in a different process.

Memory Utilities

Allocate and deallocate memory and manage memory pointers in different address spaces.

Registry Data Types

OSArray

A container for an ordered, random-access collection of objects.

OSDictionary

A container for a collection whose elements are key-value pairs.

OSBoolean

A container for a true or false value.

OSData

A container for untyped data.

OSNumber

A container for an integer value.

OSString

A container for managing an array of characters.

OSSerialization

A container for one or more objects, serialized in a binary data format that is suitable for messaging.

OSCollection

The base class for DriverKit collection objects.

OSContainer

The base class for DriverKit data objects.

OSObject

The base class for DriverKit objects

OSSymbol

A container for managing an array of characters.

IOFixed

A fixed-point number.

External Drivers

IOUserClient

A connection to another service managed by the system.

IOUserServer

A system-managed service.

com.apple.developer.driverkit.userclient-access

A Boolean value that indicates whether your code may communicate with other DriverKit services.

Runtime Support

OSDynamicCast

Casts an object safely to the specified type, returning NULL if the object is not the correct type.

OSRequiredCast

Casts the object to the specified type, killing the process if the object is not of the correct type.

IMPL

Tells the system that the superclass implementation of this method runs in the kernel.

TYPE

Annotates a method declaration to indicate that it conforms to an existing method signature.

QUEUENAME

Tells the system to execute a method on the dispatch queue with the specified name.

SUPERDISPATCH

Tells the system to execute the superclass' implementation of the current method in the kernel.

KERNEL

Tells the system that the class or method runs inside the kernel.

LOCAL

Tells the system that the method runs locally in the driver extension's process space.

LOCALONLY

Tells the system that the class or method runs locally in the driver extension's process space.

Error Codes

Determine the reason an operation failed.

C++ Runtime Support

Examine low-level types that DriverKit uses to support kernel-level operations.