Bring your driver to iPad with DriverKit

Description: Discover how you can easily connect Thunderbolt and USB accessories to iPad with DriverKit. We’ll show you how to convert your existing Mac drivers without any code changes, learn how to add real-time audio support with AudioDriverKit, and provide best practices and tips for developing drivers for iPad.

DriverKit Overview

  • replacement for IOKit device drivers
  • new way to extend the system that is more reliable and secure, running in userspace (no longer in the kernel)
  • these driver extensions, also known as dexts, are bundled in apps, and you can easily distribute your apps and drivers on the Mac App Store
  • support for:
    • Networking
    • Block Storage
    • Serial
    • Audio
    • USB
    • PCI
    • HID
    • SCSI controllers
    • SCSI Peripherals

AudioDriverKit updates

  • register a real-time callback
  • get a callback every time an IO operation happens
  • use for signal processing
// Declare a IOOperationHandler block to set on the IOUserAudioDevice.
// The block will be called from a real time context when a i/o operation
// occurs on the IOUserAudioStream buffers for the device.
io_operation = ^kern_return_t(IOUserAudioObjectID in_device,
                IOUserAudioIOOperation in_io_operation,
                uint32_t in_io_buffer_frame_size,
                uint64_t in_sample_time,
                uint64_t in_host_time)
{
  // Add custom code to make modifications to the buffers as necessary
  if (in_io_operation == IOUserAudioIOOperationWriteEnd) {
    ...
  } else if (in_io_operation == IOUserAudioIOOperationBeginRead) {
    ...
  }
  return kIOReturnSuccess;
};
this->SetIOOperationHandler(io_operation);

New entitlement (from macOS 12.1)

DriverKit on iPad

  • no changes required for existing macOS drivers to be ported to iPad
  • USBDriverKit, PCIDriverKit, AudioDriverKit support from iPadOS 16
  • requires M1 iPads
  • automatic discovery on iPadOS (must use SystemExtensions framework on macOS)

Missing anything? Corrections? Contributions are welcome 😃

Written by

Federico Zanetello

Federico Zanetello

Software engineer with a strong passion for well-written code, thought-out composable architectures, automation, tests, and more.