IOKitLib.h

Overview

IOKitLib implements non-kernel task access to common IOKit object types - IORegistryEntry, IOService, IOIterator etc. These functions are generic - families may provide API that is more specific.

IOKitLib represents IOKit objects outside the kernel with the types io_object_t, io_registry_entry_t, io_service_t, & io_connect_t. Function names usually begin with the type of object they are compatible with - eg. IOObjectRelease can be used with any io_object_t. Inside the kernel, the c++ class hierarchy allows the subclasses of each object type to receive the same requests from user level clients, for example in the kernel, IOService is a subclass of IORegistryEntry, which means any of the IORegistryEntryXXX functions in IOKitLib may be used with io_service_t's as well as io_registry_t's. There are functions available to introspect the class of the kernel object which any io_object_t et al. represents. IOKit objects returned by all functions should be released with IOObjectRelease.

Included Headers

  • <sys/cdefs.h>

  • types.h

  • <mach/mach_types.h>

  • <mach/mach_init.h>

  • <CoreFoundation/CFBase.h>

  • <CoreFoundation/CFDictionary.h>

  • <CoreFoundation/CFRunLoop.h>

  • <IOKit/IOTypes.h>

  • <IOKit/IOKitKeys.h>

  • <IOKit/OSMessageNotification.h>

  • <AvailabilityMacros.h>

  • <dispatch/dispatch.h>

Topics

Miscellaneous

func IOBSDNameMatching(mach_port_t, UInt32, UnsafePointer<Int8>!)

Create a matching dictionary that specifies an IOService match based on BSD device name.

func IOConnectAddClient(io_connect_t, io_connect_t)

Inform a connection of a second connection.

func IOConnectAddRef(io_connect_t)

Adds a reference to the connect handle.

func IOConnectGetService(io_connect_t, UnsafeMutablePointer<io_service_t>!)

Returns the IOService a connect handle was opened on.

func IOConnectRelease(io_connect_t)

Remove a reference to the connect handle.

func IOConnectSetCFProperties(io_connect_t, CFTypeRef!)

Set CF container based properties on a connection.

func IOConnectSetCFProperty(io_connect_t, CFString!, CFTypeRef!)

Set a CF container based property on a connection.

func IOConnectSetNotificationPort(io_connect_t, UInt32, mach_port_t, UInt)

Set a port to receive family specific notifications.

func IOCreateReceivePort(UInt32, UnsafeMutablePointer<mach_port_t>!)

Creates and returns a mach port suitable for receiving IOKit messages of the specified type.

func IOIteratorIsValid(io_iterator_t)

Checks an iterator is still valid.

func IOIteratorNext(io_iterator_t)

Returns the next object in an iteration.

func IOIteratorReset(io_iterator_t)

Resets an iteration back to the beginning.

func IOKitWaitQuiet(mach_port_t, UnsafeMutablePointer<mach_timespec_t>!)

Wait for a all IOServices' busyState to be zero.

func IOMasterPort(mach_port_t, UnsafeMutablePointer<mach_port_t>!)

Returns the mach port used to initiate communication with IOKit.

func IONotificationPortCreate(mach_port_t)

Creates and returns a notification object for receiving IOKit notifications of new devices or state changes.

func IONotificationPortDestroy(IONotificationPortRef!)

Destroys a notification object created with IONotificationPortCreate. Also destroys any mach_port's or CFRunLoopSources obatined from IONotificationPortGetRunLoopSource(_:) or IONotificationPortGetMachPort(_:)

func IONotificationPortGetMachPort(IONotificationPortRef!)

Returns a mach_port to be used to listen for notifications.

func IONotificationPortGetRunLoopSource(IONotificationPortRef!)

Returns a CFRunLoopSource to be used to listen for notifications.

func IONotificationPortSetDispatchQueue(IONotificationPortRef!, DispatchQueue!)

Sets a dispatch queue to be used to listen for notifications.

func IOObjectConformsTo(io_object_t, UnsafePointer<Int8>!)

Performs an OSDynamicCast operation on an IOKit object.

func IOObjectCopyBundleIdentifierForClass(CFString!)

Return the bundle identifier of the given class.

func IOObjectCopyClass(io_object_t)

Return the class name of an IOKit object.

func IOObjectCopySuperclassForClass(CFString!)

Return the superclass name of the given class.

func IOObjectGetKernelRetainCount(io_object_t)

Returns kernel retain count of an IOKit object.

func IOObjectGetRetainCount(io_object_t)

Returns kernel retain count of an IOKit object. Identical to IOObjectGetKernelRetainCount() but available prior to Mac OS 10.6.

func IOObjectGetUserRetainCount(io_object_t)

Returns the retain count for the current process of an IOKit object.

func IOObjectIsEqualTo(io_object_t, io_object_t)

Checks two object handles to see if they represent the same kernel object.

func IOObjectRelease(io_object_t)

Releases an object handle previously returned by IOKitLib.

func IOObjectRetain(io_object_t)

Retains an object handle previously returned by IOKitLib.

func IORegistryEntryGetLocationInPlane(io_registry_entry_t, UnsafePointer<Int8>!, UnsafeMutablePointer<Int8>!)

Returns a C-string location assigned to a registry entry, in a specified plane.

func IORegistryEntryGetName(io_registry_entry_t, UnsafeMutablePointer<Int8>!)

Returns a C-string name assigned to a registry entry.

func IORegistryEntryGetNameInPlane(io_registry_entry_t, UnsafePointer<Int8>!, UnsafeMutablePointer<Int8>!)

Returns a C-string name assigned to a registry entry, in a specified plane.

func IORegistryEntryGetRegistryEntryID(io_registry_entry_t, UnsafeMutablePointer<UInt64>!)

Returns an ID for the registry entry that is global to all tasks.

func IORegistryEntryIDMatching(UInt64)

Create a matching dictionary that specifies an IOService match based on a registry entry ID.

func IORegistryEntryInPlane(io_registry_entry_t, UnsafePointer<Int8>!)

Determines if the registry entry is attached in a plane.

func IORegistryEntrySetCFProperties(io_registry_entry_t, CFTypeRef!)

Set CF container based properties in a registry entry.

func IORegistryEntrySetCFProperty(io_registry_entry_t, CFString!, CFTypeRef!)

Set a CF container based property in a registry entry.

func IORegistryGetRootEntry(mach_port_t)

Return a handle to the registry root.

func IORegistryIteratorEnterEntry(io_iterator_t)

Recurse into the current entry in the registry iteration.

func IORegistryIteratorExitEntry(io_iterator_t)

Exits a level of recursion, restoring the current entry.

func IOServiceAddMatchingNotification(IONotificationPortRef!, UnsafePointer<Int8>!, CFDictionary!, IOServiceMatchingCallback!, UnsafeMutableRawPointer!, UnsafeMutablePointer<io_iterator_t>!)

Look up registered IOService objects that match a matching dictionary, and install a notification request of new IOServices that match.

func IOServiceClose(io_connect_t)

Close a connection to an IOService and destroy the connect handle.

func IOServiceGetMatchingService(mach_port_t, CFDictionary!)

Look up a registered IOService object that matches a matching dictionary.

func IOServiceGetMatchingServices(mach_port_t, CFDictionary!, UnsafeMutablePointer<io_iterator_t>!)

Look up registered IOService objects that match a matching dictionary.

func IOServiceMatching(UnsafePointer<Int8>!)

Create a matching dictionary that specifies an IOService class match.

func IOServiceNameMatching(UnsafePointer<Int8>!)

Create a matching dictionary that specifies an IOService name match.

func IOServiceRequestProbe(io_service_t, UInt32)

A request to rescan a bus for device changes.

Callbacks

See the Overview for header-level documentation.

typealias IOAsyncCallback

standard callback function for asynchronous I/O requests with lots of extra arguments beyond a refcon and result code.

typealias IOAsyncCallback0

standard callback function for asynchronous I/O requests with no extra arguments beyond a refcon and result code.

typealias IOAsyncCallback1

standard callback function for asynchronous I/O requests with one extra argument beyond a refcon and result code. This is often a count of the number of bytes transferred

typealias IOAsyncCallback2

standard callback function for asynchronous I/O requests with two extra arguments beyond a refcon and result code.

typealias IOServiceInterestCallback

Callback function to be notified of changes in state of an IOService.

typealias IOServiceMatchingCallback

Callback function to be notified of IOService publication.

Constants

See the Overview for header-level documentation.