Function

IOServiceGetMatchingService

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

Declaration

io_service_t IOServiceGetMatchingService(mach_port_t masterPort, CFDictionaryRef matching);

Parameters

masterPort

The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.

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.

Return Value

The first service matched is returned on success. The service must be released by the caller.

Discussion

This is the preferred method of finding IOService objects currently registered by IOKit (that is, objects that have had their registerService() methods invoked). To find IOService objects that aren't yet registered, use an iterator as created by IORegistryEntryCreateIterator(). IOServiceAddMatchingNotification can also supply this information and install a notification of new IOServices. The matching information used in the matching dictionary may vary depending on the class of service being looked up.