IOServiceAddMatchingNotification

Function IOServiceAddMatchingNotification 

Source
pub unsafe extern "C-unwind" fn IOServiceAddMatchingNotification(
    notify_port: IONotificationPortRef,
    notification_type: *mut [c_char; 128],
    matching: Option<CFRetained<CFDictionary>>,
    callback: IOServiceMatchingCallback,
    ref_con: *mut c_void,
    notification: *mut io_iterator_t,
) -> kern_return_t
Available on crate feature libc only.
Expand description

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

This is the preferred method of finding IOService objects that may arrive at any time. The type of notification specifies the state change the caller is interested in, on IOService’s that match the match dictionary. Notification types are identified by name, and are defined in IOKitKeys.h. The matching information used in the matching dictionary may vary depending on the class of service being looked up.

Parameter notifyPort: A IONotificationPortRef object that controls how messages will be sent when the armed notification is fired. When the notification is delivered, the io_iterator_t representing the notification should be iterated through to pick up all outstanding objects. When the iteration is finished the notification is rearmed. See IONotificationPortCreate.

Parameter notificationType: A notification type from IOKitKeys.h
kIOPublishNotification Delivered when an IOService is registered.
kIOFirstPublishNotification Delivered when an IOService is registered, but only once per IOService instance. Some IOService’s may be reregistered when their state is changed.
kIOMatchedNotification Delivered when an IOService has had all matching drivers in the kernel probed and started.
kIOFirstMatchNotification Delivered when an IOService has had all matching drivers in the kernel probed and started, but only once per IOService instance. Some IOService’s may be reregistered when their state is changed.
kIOTerminatedNotification Delivered after an IOService has been terminated.

Parameter matching: A CF dictionary containing matching information, of which one reference is always consumed by this function (Note prior to the Tiger release there was a small chance that the dictionary might not be released if there was an error attempting to serialize the dictionary). IOKitLib can construct matching dictionaries for common criteria with helper functions such as IOServiceMatching, IOServiceNameMatching, IOBSDNameMatching.

Parameter callback: A callback function called when the notification fires.

Parameter refCon: A reference constant for the callbacks use.

Parameter notification: An iterator handle is returned on success, and should be released by the caller when the notification is to be destroyed. The notification is armed when the iterator is emptied by calls to IOIteratorNext - when no more objects are returned, the notification is armed. Note the notification is not armed when first created.

Returns: A kern_return_t error code.