Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2016-4655/headers/IOKit/IOKitLib.h
Views: 11789
/*1* Copyright (c) 1998-2014 Apple Computer, Inc. All rights reserved.2*3* @APPLE_LICENSE_HEADER_START@4*5* This file contains Original Code and/or Modifications of Original Code6* as defined in and that are subject to the Apple Public Source License7* Version 2.0 (the 'License'). You may not use this file except in8* compliance with the License. Please obtain a copy of the License at9* http://www.opensource.apple.com/apsl/ and read it before using this10* file.11*12* The Original Code and all software distributed under the License are13* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER14* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,15* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.17* Please see the License for the specific language governing rights and18* limitations under the License.19*20* @APPLE_LICENSE_HEADER_END@21*/22/*23* HISTORY24*25*/2627/*28* IOKit user library29*/3031#ifndef _IOKIT_IOKITLIB_H32#define _IOKIT_IOKITLIB_H3334#ifdef KERNEL35#error This file is not for kernel use36#endif3738#include <sys/cdefs.h>39#include <sys/types.h>4041#include <mach/mach_types.h>42#include <mach/mach_init.h>4344#include <CoreFoundation/CFBase.h>45#include <CoreFoundation/CFDictionary.h>46#include <CoreFoundation/CFRunLoop.h>4748#include <IOKit/IOTypes.h>49#include <IOKit/IOKitKeys.h>5051#include <IOKit/OSMessageNotification.h>5253#include <AvailabilityMacros.h>5455#include <dispatch/dispatch.h>5657__BEGIN_DECLS5859/*! @header IOKitLib60IOKitLib 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.<br>61IOKitLib 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.62IOKit objects returned by all functions should be released with IOObjectRelease.63*/64/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */6566typedef struct IONotificationPort * IONotificationPortRef;676869/*! @typedef IOServiceMatchingCallback70@abstract Callback function to be notified of IOService publication.71@param refcon The refcon passed when the notification was installed.72@param iterator The notification iterator which now has new objects.73*/74typedef void75(*IOServiceMatchingCallback)(76void * refcon,77io_iterator_t iterator );7879/*! @typedef IOServiceInterestCallback80@abstract Callback function to be notified of changes in state of an IOService.81@param refcon The refcon passed when the notification was installed.82@param service The IOService whose state has changed.83@param messageType A messageType enum, defined by IOKit/IOMessage.h or by the IOService's family.84@param messageArgument An argument for the message, dependent on the messageType. If the message data is larger than sizeof(void*), then messageArgument contains a pointer to the message data; otherwise, messageArgument contains the message data.85*/8687typedef void88(*IOServiceInterestCallback)(89void * refcon,90io_service_t service,91uint32_t messageType,92void * messageArgument );9394/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */9596/*! @const kIOMasterPortDefault97@abstract The default mach port used to initiate communication with IOKit.98@discussion When specifying a master port to IOKit functions, the NULL argument indicates "use the default". This is a synonym for NULL, if you'd rather use a named constant.99*/100101extern102const mach_port_t kIOMasterPortDefault;103104/*! @function IOMasterPort105@abstract Returns the mach port used to initiate communication with IOKit.106@discussion Functions that don't specify an existing object require the IOKit master port to be passed. This function obtains that port.107@param bootstrapPort Pass MACH_PORT_NULL for the default.108@param masterPort The master port is returned.109@result A kern_return_t error code. */110111kern_return_t112IOMasterPort( mach_port_t bootstrapPort,113mach_port_t * masterPort );114115116/*! @function IONotificationPortCreate117@abstract Creates and returns a notification object for receiving IOKit notifications of new devices or state changes.118@discussion Creates the notification object to receive notifications from IOKit of new device arrivals or state changes. The notification object can be supply a CFRunLoopSource, or mach_port_t to be used to listen for events.119@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.120@result A reference to the notification object. */121122IONotificationPortRef123IONotificationPortCreate(124mach_port_t masterPort );125126/*! @function IONotificationPortDestroy127@abstract Destroys a notification object created with IONotificationPortCreate.128Also destroys any mach_port's or CFRunLoopSources obatined from129<code>@link IONotificationPortGetRunLoopSource @/link</code>130or <code>@link IONotificationPortGetMachPort @/link</code>131@param notify A reference to the notification object. */132133void134IONotificationPortDestroy(135IONotificationPortRef notify );136137/*! @function IONotificationPortGetRunLoopSource138@abstract Returns a CFRunLoopSource to be used to listen for notifications.139@discussion A notification object may deliver notifications to a CFRunLoop140by adding the run loop source returned by this function to the run loop.141142The caller should not release this CFRunLoopSource. Just call143<code>@link IONotificationPortDestroy @/link</code> to dispose of the144IONotificationPortRef and the CFRunLoopSource when done.145@param notify The notification object.146@result A CFRunLoopSourceRef for the notification object. */147148CFRunLoopSourceRef149IONotificationPortGetRunLoopSource(150IONotificationPortRef notify );151152/*! @function IONotificationPortGetMachPort153@abstract Returns a mach_port to be used to listen for notifications.154@discussion A notification object may deliver notifications to a mach messaging client155if they listen for messages on the port obtained from this function.156Callbacks associated with the notifications may be delivered by calling157IODispatchCalloutFromMessage with messages received.158159The caller should not release this mach_port_t. Just call160<code>@link IONotificationPortDestroy @/link</code> to dispose of the161mach_port_t and IONotificationPortRef when done.162@param notify The notification object.163@result A mach_port for the notification object. */164165mach_port_t166IONotificationPortGetMachPort(167IONotificationPortRef notify );168169/*! @function IONotificationPortSetDispatchQueue170@abstract Sets a dispatch queue to be used to listen for notifications.171@discussion A notification object may deliver notifications to a dispatch client.172@param notify The notification object.173@param queue A dispatch queue. */174175void176IONotificationPortSetDispatchQueue(177IONotificationPortRef notify, dispatch_queue_t queue )178__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_4_3);179180/*! @function IODispatchCalloutFromMessage181@abstract Dispatches callback notifications from a mach message.182@discussion A notification object may deliver notifications to a mach messaging client,183which should call this function to generate the callbacks associated with the notifications arriving on the port.184@param unused Not used, set to zero.185@param msg A pointer to the message received.186@param reference Pass the IONotificationPortRef for the object. */187188void189IODispatchCalloutFromMessage(190void *unused,191mach_msg_header_t *msg,192void *reference );193194/*! @function IOCreateReceivePort195@abstract Creates and returns a mach port suitable for receiving IOKit messages of the specified type.196@discussion In the future IOKit may use specialized messages and ports197instead of the standard ports created by mach_port_allocate(). Use this198function instead of mach_port_allocate() to ensure compatibility with future199revisions of IOKit.200@param msgType Type of message to be sent to this port201(kOSNotificationMessageID or kOSAsyncCompleteMessageID)202@param recvPort The created port is returned.203@result A kern_return_t error code. */204205kern_return_t206IOCreateReceivePort( uint32_t msgType, mach_port_t * recvPort );207208/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */209210/*211* IOObject212*/213214/*! @function IOObjectRelease215@abstract Releases an object handle previously returned by IOKitLib.216@discussion All objects returned by IOKitLib should be released with this function when access to them is no longer needed. Using the object after it has been released may or may not return an error, depending on how many references the task has to the same object in the kernel.217@param object The IOKit object to release.218@result A kern_return_t error code. */219220kern_return_t221IOObjectRelease(222io_object_t object );223224/*! @function IOObjectRetain225@abstract Retains an object handle previously returned by IOKitLib.226@discussion Gives the caller an additional reference to an existing object handle previously returned by IOKitLib.227@param object The IOKit object to retain.228@result A kern_return_t error code. */229230kern_return_t231IOObjectRetain(232io_object_t object );233234/*! @function IOObjectGetClass235@abstract Return the class name of an IOKit object.236@discussion This function uses the OSMetaClass system in the kernel to derive the name of the class the object is an instance of.237@param object The IOKit object.238@param className Caller allocated buffer to receive the name string.239@result A kern_return_t error code. */240241kern_return_t242IOObjectGetClass(243io_object_t object,244io_name_t className );245246/*! @function IOObjectCopyClass247@abstract Return the class name of an IOKit object.248@discussion This function does the same thing as IOObjectGetClass, but returns the result as a CFStringRef.249@param object The IOKit object.250@result The resulting CFStringRef. This should be released by the caller. If a valid object is not passed in, then NULL is returned.*/251252CFStringRef253IOObjectCopyClass(io_object_t object)254AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;255256/*! @function IOObjectCopySuperclassForClass257@abstract Return the superclass name of the given class.258@discussion This function uses the OSMetaClass system in the kernel to derive the name of the superclass of the class.259@param classname The name of the class as a CFString.260@result The resulting CFStringRef. This should be released by the caller. If there is no superclass, or a valid class name is not passed in, then NULL is returned.*/261262CFStringRef263IOObjectCopySuperclassForClass(CFStringRef classname)264AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;265266/*! @function IOObjectCopyBundleIdentifierForClass267@abstract Return the bundle identifier of the given class.268@discussion This function uses the OSMetaClass system in the kernel to derive the name of the kmod, which is the same as the bundle identifier.269@param classname The name of the class as a CFString.270@result The resulting CFStringRef. This should be released by the caller. If a valid class name is not passed in, then NULL is returned.*/271272CFStringRef273IOObjectCopyBundleIdentifierForClass(CFStringRef classname)274AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;275276/*! @function IOObjectConformsTo277@abstract Performs an OSDynamicCast operation on an IOKit object.278@discussion This function uses the OSMetaClass system in the kernel to determine if the object will dynamic cast to a class, specified as a C-string. In other words, if the object is of that class or a subclass.279@param object An IOKit object.280@param className The name of the class, as a C-string.281@result If the object handle is valid, and represents an object in the kernel that dynamic casts to the class true is returned, otherwise false. */282283boolean_t284IOObjectConformsTo(285io_object_t object,286const io_name_t className );287288/*! @function IOObjectIsEqualTo289@abstract Checks two object handles to see if they represent the same kernel object.290@discussion If two object handles are returned by IOKitLib functions, this function will compare them to see if they represent the same kernel object.291@param object An IOKit object.292@param anObject Another IOKit object.293@result If both object handles are valid, and represent the same object in the kernel true is returned, otherwise false. */294295boolean_t296IOObjectIsEqualTo(297io_object_t object,298io_object_t anObject );299300/*! @function IOObjectGetKernelRetainCount301@abstract Returns kernel retain count of an IOKit object.302@discussion This function may be used in diagnostics to determine the current retain count of the kernel object at the kernel level.303@param object An IOKit object.304@result If the object handle is valid, the kernel objects retain count is returned, otherwise zero is returned. */305306uint32_t307IOObjectGetKernelRetainCount(308io_object_t object )309AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;310311/*! @function IOObjectGetUserRetainCount312@abstract Returns the retain count for the current process of an IOKit object.313@discussion This function may be used in diagnostics to determine the current retain count for the calling process of the kernel object.314@param object An IOKit object.315@result If the object handle is valid, the objects user retain count is returned, otherwise zero is returned. */316317uint32_t318IOObjectGetUserRetainCount(319io_object_t object )320AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;321322/*! @function IOObjectGetRetainCount323@abstract Returns kernel retain count of an IOKit object. Identical to IOObjectGetKernelRetainCount() but available prior to Mac OS 10.6.324@discussion This function may be used in diagnostics to determine the current retain count of the kernel object at the kernel level.325@param object An IOKit object.326@result If the object handle is valid, the kernel objects retain count is returned, otherwise zero is returned. */327328uint32_t329IOObjectGetRetainCount(330io_object_t object );331332333/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */334335/*336* IOIterator, subclass of IOObject337*/338339/*! @function IOIteratorNext340@abstract Returns the next object in an iteration.341@discussion This function returns the next object in an iteration, or zero if no more remain or the iterator is invalid.342@param iterator An IOKit iterator handle.343@result If the iterator handle is valid, the next element in the iteration is returned, otherwise zero is returned. The element should be released by the caller when it is finished. */344345io_object_t346IOIteratorNext(347io_iterator_t iterator );348349/*! @function IOIteratorReset350@abstract Resets an iteration back to the beginning.351@discussion If an iterator is invalid, or if the caller wants to start over, IOIteratorReset will set the iteration back to the beginning.352@param iterator An IOKit iterator handle. */353354void355IOIteratorReset(356io_iterator_t iterator );357358/*! @function IOIteratorIsValid359@abstract Checks an iterator is still valid.360@discussion Some iterators will be made invalid if changes are made to the structure they are iterating over. This function checks the iterator is still valid and should be called when IOIteratorNext returns zero. An invalid iterator can be reset and the iteration restarted.361@param iterator An IOKit iterator handle.362@result True if the iterator handle is valid, otherwise false is returned. */363364boolean_t365IOIteratorIsValid(366io_iterator_t iterator );367368/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */369370/*371* IOService, subclass of IORegistryEntry372*/373374/*!375@function IOServiceGetMatchingService376@abstract Look up a registered IOService object that matches a matching dictionary.377@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.378@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.379@param 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.380@result The first service matched is returned on success. The service must be released by the caller.381*/382383io_service_t384IOServiceGetMatchingService(385mach_port_t masterPort,386CFDictionaryRef matching CF_RELEASES_ARGUMENT);387388/*! @function IOServiceGetMatchingServices389@abstract Look up registered IOService objects that match a matching dictionary.390@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.391@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.392@param 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.393@param existing An iterator handle is returned on success, and should be released by the caller when the iteration is finished.394@result A kern_return_t error code. */395396kern_return_t397IOServiceGetMatchingServices(398mach_port_t masterPort,399CFDictionaryRef matching CF_RELEASES_ARGUMENT,400io_iterator_t * existing );401402403kern_return_t404IOServiceAddNotification(405mach_port_t masterPort,406const io_name_t notificationType,407CFDictionaryRef matching,408mach_port_t wakePort,409uintptr_t reference,410io_iterator_t * notification ) DEPRECATED_ATTRIBUTE;411412/*! @function IOServiceAddMatchingNotification413@abstract Look up registered IOService objects that match a matching dictionary, and install a notification request of new IOServices that match.414@discussion 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.415@param 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.416@param notificationType A notification type from IOKitKeys.h417<br> kIOPublishNotification Delivered when an IOService is registered.418<br> kIOFirstPublishNotification Delivered when an IOService is registered, but only once per IOService instance. Some IOService's may be reregistered when their state is changed.419<br> kIOMatchedNotification Delivered when an IOService has had all matching drivers in the kernel probed and started.420<br> 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.421<br> kIOTerminatedNotification Delivered after an IOService has been terminated.422@param 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.423@param callback A callback function called when the notification fires.424@param refCon A reference constant for the callbacks use.425@param 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.426@result A kern_return_t error code. */427428kern_return_t429IOServiceAddMatchingNotification(430IONotificationPortRef notifyPort,431const io_name_t notificationType,432CFDictionaryRef matching CF_RELEASES_ARGUMENT,433IOServiceMatchingCallback callback,434void * refCon,435io_iterator_t * notification );436437/*! @function IOServiceAddInterestNotification438@abstract Register for notification of state changes in an IOService.439@discussion IOService objects deliver notifications of their state changes to their clients via the IOService::messageClients API, and to other interested parties including callers of this function. Message types are defined IOKit/IOMessage.h.440@param notifyPort A IONotificationPortRef object that controls how messages will be sent when the notification is fired. See IONotificationPortCreate.441@param interestType A notification type from IOKitKeys.h442<br> kIOGeneralInterest General state changes delivered via the IOService::messageClients API.443<br> kIOBusyInterest Delivered when the IOService changes its busy state to or from zero. The message argument contains the new busy state causing the notification.444@param callback A callback function called when the notification fires, with messageType and messageArgument for the state change.445@param refCon A reference constant for the callbacks use.446@param notification An object handle is returned on success, and should be released by the caller when the notification is to be destroyed.447@result A kern_return_t error code. */448449kern_return_t450IOServiceAddInterestNotification(451IONotificationPortRef notifyPort,452io_service_t service,453const io_name_t interestType,454IOServiceInterestCallback callback,455void * refCon,456io_object_t * notification );457458/*! @function IOServiceMatchPropertyTable459@abstract Match an IOService objects with matching dictionary.460@discussion This function calls the matching method of an IOService object and returns the boolean result.461@param service The IOService object to match.462@param matching A CF dictionary containing matching information. IOKitLib can construct matching dictionaries for common criteria with helper functions such as IOServiceMatching, IOServiceNameMatching, IOBSDNameMatching.463@param matches The boolean result is returned.464@result A kern_return_t error code. */465466kern_return_t467IOServiceMatchPropertyTable(468io_service_t service,469CFDictionaryRef matching,470boolean_t * matches );471472/*! @function IOServiceGetBusyState473@abstract Returns the busyState of an IOService.474@discussion Many activities in IOService are asynchronous. When registration, matching, or termination is in progress on an IOService, its busyState is increased by one. Change in busyState to or from zero also changes the IOService's provider's busyState by one, which means that an IOService is marked busy when any of the above activities is ocurring on it or any of its clients.475@param service The IOService whose busyState to return.476@param busyState The busyState count is returned.477@result A kern_return_t error code. */478479kern_return_t480IOServiceGetBusyState(481io_service_t service,482uint32_t * busyState );483484/*! @function IOServiceWaitQuiet485@abstract Wait for an IOService's busyState to be zero.486@discussion Blocks the caller until an IOService is non busy, see IOServiceGetBusyState.487@param service The IOService wait on.488@param waitTime Specifies a maximum time to wait.489@result Returns an error code if mach synchronization primitives fail, kIOReturnTimeout, or kIOReturnSuccess. */490491kern_return_t492IOServiceWaitQuiet(493io_service_t service,494mach_timespec_t * waitTime );495496/*! @function IOKitGetBusyState497@abstract Returns the busyState of all IOServices.498@discussion Many activities in IOService are asynchronous. When registration, matching, or termination is in progress on an IOService, its busyState is increased by one. Change in busyState to or from zero also changes the IOService's provider's busyState by one, which means that an IOService is marked busy when any of the above activities is ocurring on it or any of its clients. IOKitGetBusyState returns the busy state of the root of the service plane which reflects the busy state of all IOServices.499@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.500@param busyState The busyState count is returned.501@result A kern_return_t error code. */502503kern_return_t504IOKitGetBusyState(505mach_port_t masterPort,506uint32_t * busyState );507508/*! @function IOKitWaitQuiet509@abstract Wait for a all IOServices' busyState to be zero.510@discussion Blocks the caller until all IOServices are non busy, see IOKitGetBusyState.511@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.512@param waitTime Specifies a maximum time to wait.513@result Returns an error code if mach synchronization primitives fail, kIOReturnTimeout, or kIOReturnSuccess. */514515kern_return_t516IOKitWaitQuiet(517mach_port_t masterPort,518mach_timespec_t * waitTime );519520/*! @function IOServiceOpen521@abstract A request to create a connection to an IOService.522@discussion A non kernel client may request a connection be opened via the IOServiceOpen() library function, which will call IOService::newUserClient in the kernel. The rules & capabilities of user level clients are family dependent, the default IOService implementation returns kIOReturnUnsupported.523@param service The IOService object to open a connection to, usually obtained via the IOServiceGetMatchingServices or IOServiceAddNotification APIs.524@param owningTask The mach task requesting the connection.525@param type A constant specifying the type of connection to be created, interpreted only by the IOService's family.526@param connect An io_connect_t handle is returned on success, to be used with the IOConnectXXX APIs. It should be destroyed with IOServiceClose().527@result A return code generated by IOService::newUserClient. */528529kern_return_t530IOServiceOpen(531io_service_t service,532task_port_t owningTask,533uint32_t type,534io_connect_t * connect );535536/*! @function IOServiceRequestProbe537@abstract A request to rescan a bus for device changes.538@discussion A non kernel client may request a bus or controller rescan for added or removed devices, if the bus family does automatically notice such changes. For example, SCSI bus controllers do not notice device changes. The implementation of this routine is family dependent, and the default IOService implementation returns kIOReturnUnsupported.539@param service The IOService object to request a rescan, usually obtained via the IOServiceGetMatchingServices or IOServiceAddNotification APIs.540@param options An options mask, interpreted only by the IOService's family.541@result A return code generated by IOService::requestProbe. */542543kern_return_t544IOServiceRequestProbe(545io_service_t service,546uint32_t options );547548// options for IOServiceAuthorize()549enum {550kIOServiceInteractionAllowed = 0x00000001551};552553/*! @function IOServiceAuthorize554@abstract Authorize access to an IOService.555@discussion Determine whether this application is authorized to invoke IOServiceOpen() for a given IOService, either by confirming that it has been previously authorized by the user, or by soliciting the console user.556@param service The IOService object to be authorized, usually obtained via the IOServiceGetMatchingServices or IOServiceAddNotification APIs.557@param options kIOServiceInteractionAllowed may be set to permit user interaction, if required.558@result kIOReturnSuccess if the IOService is authorized, kIOReturnNotPermitted if the IOService is not authorized. */559560kern_return_t561IOServiceAuthorize(562io_service_t service,563uint32_t options );564565int566IOServiceOpenAsFileDescriptor(567io_service_t service,568int oflag );569570/* * * * * * * * * * * * * * *ff * * * * * * * * * * * * * * * * * * * * * * */571572/*573* IOService connection574*/575576/*! @function IOServiceClose577@abstract Close a connection to an IOService and destroy the connect handle.578@discussion A connection created with the IOServiceOpen should be closed when the connection is no longer to be used with IOServiceClose.579@param connect The connect handle created by IOServiceOpen. It will be destroyed by this function, and should not be released with IOObjectRelease.580@result A kern_return_t error code. */581582kern_return_t583IOServiceClose(584io_connect_t connect );585586/*! @function IOConnectAddRef587@abstract Adds a reference to the connect handle.588@discussion Adds a reference to the connect handle.589@param connect The connect handle created by IOServiceOpen.590@result A kern_return_t error code. */591592kern_return_t593IOConnectAddRef(594io_connect_t connect );595596/*! @function IOConnectRelease597@abstract Remove a reference to the connect handle.598@discussion Removes a reference to the connect handle. If the last reference is removed an implicit IOServiceClose is performed.599@param connect The connect handle created by IOServiceOpen.600@result A kern_return_t error code. */601602kern_return_t603IOConnectRelease(604io_connect_t connect );605606/*! @function IOConnectGetService607@abstract Returns the IOService a connect handle was opened on.608@discussion Finds the service object a connection was opened on.609@param connect The connect handle created by IOServiceOpen.610@param service On succes, the service handle the connection was opened on, which should be released with IOObjectRelease.611@result A kern_return_t error code. */612613kern_return_t614IOConnectGetService(615io_connect_t connect,616io_service_t * service );617618/*! @function IOConnectSetNotificationPort619@abstract Set a port to receive family specific notifications.620@discussion This is a generic method to pass a mach port send right to be be used by family specific notifications.621@param connect The connect handle created by IOServiceOpen.622@param type The type of notification requested, not interpreted by IOKit and family defined.623@param port The port to which to send notifications.624@param reference Some families may support passing a reference parameter for the callers use with the notification.625@result A kern_return_t error code. */626627kern_return_t628IOConnectSetNotificationPort(629io_connect_t connect,630uint32_t type,631mach_port_t port,632uintptr_t reference );633634/*! @function IOConnectMapMemory635@abstract Map hardware or shared memory into the caller's task.636@discussion This is a generic method to create a mapping in the callers task. The family will interpret the type parameter to determine what sort of mapping is being requested. Cache modes and placed mappings may be requested by the caller.637@param connect The connect handle created by IOServiceOpen.638@param memoryType What is being requested to be mapped, not interpreted by IOKit and family defined. The family may support physical hardware or shared memory mappings.639@param intoTask The task port for the task in which to create the mapping. This may be different to the task which the opened the connection.640@param atAddress An in/out parameter - if the kIOMapAnywhere option is not set, the caller should pass the address where it requests the mapping be created, otherwise nothing need to set on input. The address of the mapping created is passed back on sucess.641@param ofSize The size of the mapping created is passed back on success.642@result A kern_return_t error code. */643644#if !__LP64__ || defined(IOCONNECT_MAPMEMORY_10_6)645646kern_return_t647IOConnectMapMemory(648io_connect_t connect,649uint32_t memoryType,650task_port_t intoTask,651vm_address_t *atAddress,652vm_size_t *ofSize,653IOOptionBits options );654655#else656657kern_return_t658IOConnectMapMemory(659io_connect_t connect,660uint32_t memoryType,661task_port_t intoTask,662mach_vm_address_t *atAddress,663mach_vm_size_t *ofSize,664IOOptionBits options );665666#endif /* !__LP64__ || defined(IOCONNECT_MAPMEMORY_10_6) */667668669/*! @function IOConnectMapMemory64670@abstract Map hardware or shared memory into the caller's task.671@discussion This is a generic method to create a mapping in the callers task. The family will interpret the type parameter to determine what sort of mapping is being requested. Cache modes and placed mappings may be requested by the caller.672@param connect The connect handle created by IOServiceOpen.673@param memoryType What is being requested to be mapped, not interpreted by IOKit and family defined. The family may support physical hardware or shared memory mappings.674@param intoTask The task port for the task in which to create the mapping. This may be different to the task which the opened the connection.675@param atAddress An in/out parameter - if the kIOMapAnywhere option is not set, the caller should pass the address where it requests the mapping be created, otherwise nothing need to set on input. The address of the mapping created is passed back on sucess.676@param ofSize The size of the mapping created is passed back on success.677@result A kern_return_t error code. */678679kern_return_t IOConnectMapMemory64(680io_connect_t connect,681uint32_t memoryType,682task_port_t intoTask,683mach_vm_address_t *atAddress,684mach_vm_size_t *ofSize,685IOOptionBits options );686687/*! @function IOConnectUnmapMemory688@abstract Remove a mapping made with IOConnectMapMemory.689@discussion This is a generic method to remove a mapping in the callers task.690@param connect The connect handle created by IOServiceOpen.691@param memoryType The memory type originally requested in IOConnectMapMemory.692@param fromTask The task port for the task in which to remove the mapping. This may be different to the task which the opened the connection.693@param atAddress The address of the mapping to be removed.694@result A kern_return_t error code. */695696#if !__LP64__ || defined(IOCONNECT_MAPMEMORY_10_6)697698kern_return_t699IOConnectUnmapMemory(700io_connect_t connect,701uint32_t memoryType,702task_port_t fromTask,703vm_address_t atAddress );704705#else706707kern_return_t708IOConnectUnmapMemory(709io_connect_t connect,710uint32_t memoryType,711task_port_t fromTask,712mach_vm_address_t atAddress );713714715#endif /* !__LP64__ || defined(IOCONNECT_MAPMEMORY_10_6) */716717/*! @function IOConnectUnmapMemory64718@abstract Remove a mapping made with IOConnectMapMemory64.719@discussion This is a generic method to remove a mapping in the callers task.720@param connect The connect handle created by IOServiceOpen.721@param memoryType The memory type originally requested in IOConnectMapMemory.722@param fromTask The task port for the task in which to remove the mapping. This may be different to the task which the opened the connection.723@param atAddress The address of the mapping to be removed.724@result A kern_return_t error code. */725726kern_return_t IOConnectUnmapMemory64(727io_connect_t connect,728uint32_t memoryType,729task_port_t fromTask,730mach_vm_address_t atAddress );731732733/*! @function IOConnectSetCFProperties734@abstract Set CF container based properties on a connection.735@discussion This is a generic method to pass a CF container of properties to the connection. The properties are interpreted by the family and commonly represent configuration settings, but may be interpreted as anything.736@param connect The connect handle created by IOServiceOpen.737@param properties A CF container - commonly a CFDictionary but this is not enforced. The container should consist of objects which are understood by IOKit - these are currently : CFDictionary, CFArray, CFSet, CFString, CFData, CFNumber, CFBoolean, and are passed in the kernel as the corresponding OSDictionary etc. objects.738@result A kern_return_t error code returned by the family. */739740kern_return_t741IOConnectSetCFProperties(742io_connect_t connect,743CFTypeRef properties );744745/*! @function IOConnectSetCFProperty746@abstract Set a CF container based property on a connection.747@discussion This is a generic method to pass a CF property to the connection. The property is interpreted by the family and commonly represent configuration settings, but may be interpreted as anything.748@param connect The connect handle created by IOServiceOpen.749@param propertyName The name of the property as a CFString.750@param property A CF container - should consist of objects which are understood by IOKit - these are currently : CFDictionary, CFArray, CFSet, CFString, CFData, CFNumber, CFBoolean, and are passed in the kernel as the corresponding OSDictionary etc. objects.751@result A kern_return_t error code returned by the object. */752753kern_return_t754IOConnectSetCFProperty(755io_connect_t connect,756CFStringRef propertyName,757CFTypeRef property );758759/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */760761// Combined LP64 & ILP32 Extended IOUserClient::externalMethod762763kern_return_t764IOConnectCallMethod(765mach_port_t connection, // In766uint32_t selector, // In767const uint64_t *input, // In768uint32_t inputCnt, // In769const void *inputStruct, // In770size_t inputStructCnt, // In771uint64_t *output, // Out772uint32_t *outputCnt, // In/Out773void *outputStruct, // Out774size_t *outputStructCnt) // In/Out775AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;776777kern_return_t778IOConnectCallAsyncMethod(779mach_port_t connection, // In780uint32_t selector, // In781mach_port_t wake_port, // In782uint64_t *reference, // In783uint32_t referenceCnt, // In784const uint64_t *input, // In785uint32_t inputCnt, // In786const void *inputStruct, // In787size_t inputStructCnt, // In788uint64_t *output, // Out789uint32_t *outputCnt, // In/Out790void *outputStruct, // Out791size_t *outputStructCnt) // In/Out792AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;793794kern_return_t795IOConnectCallStructMethod(796mach_port_t connection, // In797uint32_t selector, // In798const void *inputStruct, // In799size_t inputStructCnt, // In800void *outputStruct, // Out801size_t *outputStructCnt) // In/Out802AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;803804kern_return_t805IOConnectCallAsyncStructMethod(806mach_port_t connection, // In807uint32_t selector, // In808mach_port_t wake_port, // In809uint64_t *reference, // In810uint32_t referenceCnt, // In811const void *inputStruct, // In812size_t inputStructCnt, // In813void *outputStruct, // Out814size_t *outputStructCnt) // In/Out815AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;816817kern_return_t818IOConnectCallScalarMethod(819mach_port_t connection, // In820uint32_t selector, // In821const uint64_t *input, // In822uint32_t inputCnt, // In823uint64_t *output, // Out824uint32_t *outputCnt) // In/Out825AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;826827kern_return_t828IOConnectCallAsyncScalarMethod(829mach_port_t connection, // In830uint32_t selector, // In831mach_port_t wake_port, // In832uint64_t *reference, // In833uint32_t referenceCnt, // In834const uint64_t *input, // In835uint32_t inputCnt, // In836uint64_t *output, // Out837uint32_t *outputCnt) // In/Out838AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;839840/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */841842kern_return_t843IOConnectTrap0(io_connect_t connect,844uint32_t index );845846kern_return_t847IOConnectTrap1(io_connect_t connect,848uint32_t index,849uintptr_t p1 );850851kern_return_t852IOConnectTrap2(io_connect_t connect,853uint32_t index,854uintptr_t p1,855uintptr_t p2);856857kern_return_t858IOConnectTrap3(io_connect_t connect,859uint32_t index,860uintptr_t p1,861uintptr_t p2,862uintptr_t p3);863864kern_return_t865IOConnectTrap4(io_connect_t connect,866uint32_t index,867uintptr_t p1,868uintptr_t p2,869uintptr_t p3,870uintptr_t p4);871872kern_return_t873IOConnectTrap5(io_connect_t connect,874uint32_t index,875uintptr_t p1,876uintptr_t p2,877uintptr_t p3,878uintptr_t p4,879uintptr_t p5);880881kern_return_t882IOConnectTrap6(io_connect_t connect,883uint32_t index,884uintptr_t p1,885uintptr_t p2,886uintptr_t p3,887uintptr_t p4,888uintptr_t p5,889uintptr_t p6);890891/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */892893/*! @function IOConnectAddClient894@abstract Inform a connection of a second connection.895@discussion This is a generic method to inform a family connection of a second connection, and is rarely used.896@param connect The connect handle created by IOServiceOpen.897@param client Another connect handle created by IOServiceOpen.898@result A kern_return_t error code returned by the family. */899900kern_return_t901IOConnectAddClient(902io_connect_t connect,903io_connect_t client );904905/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */906907/*908* IORegistry accessors909*/910911/*! @function IORegistryGetRootEntry912@abstract Return a handle to the registry root.913@discussion This method provides an accessor to the root of the registry for the machine. The root may be passed to a registry iterator when iterating a plane, and contains properties that describe the available planes, and diagnostic information for IOKit.914@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.915@result A handle to the IORegistryEntry root instance, to be released with IOObjectRelease by the caller, or MACH_PORT_NULL on failure. */916917io_registry_entry_t918IORegistryGetRootEntry(919mach_port_t masterPort );920921/*! @function IORegistryEntryFromPath922@abstract Looks up a registry entry by path.923@discussion This function parses paths to lookup registry entries. The path should begin with '<plane name>:' If there are characters remaining unparsed after an entry has been looked up, this is considered an invalid lookup. Paths are further documented in IORegistryEntry.h924@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.925@param path A C-string path.926@result A handle to the IORegistryEntry witch was found with the path, to be released with IOObjectRelease by the caller, or MACH_PORT_NULL on failure. */927928io_registry_entry_t929IORegistryEntryFromPath(930mach_port_t masterPort,931const io_string_t path );932933934/*! @function IORegistryEntryFromPathCFString935@abstract Looks up a registry entry by path.936@discussion This function parses paths to lookup registry entries. The path should begin with '<plane name>:' If there are characters remaining unparsed after an entry has been looked up, this is considered an invalid lookup. Paths are further documented in IORegistryEntry.h937@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.938@param path A CFString path.939@result A handle to the IORegistryEntry witch was found with the path, to be released with IOObjectRelease by the caller, or MACH_PORT_NULL on failure. */940941io_registry_entry_t942IORegistryEntryCopyFromPath(943mach_port_t masterPort,944CFStringRef path )945#if defined(__MAC_10_11)946__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)947#endif948;949950// options for IORegistryCreateIterator(), IORegistryEntryCreateIterator, IORegistryEntrySearchCFProperty()951enum {952kIORegistryIterateRecursively = 0x00000001,953kIORegistryIterateParents = 0x00000002954};955956/*! @function IORegistryCreateIterator957@abstract Create an iterator rooted at the registry root.958@discussion This method creates an IORegistryIterator in the kernel that is set up with options to iterate children of the registry root entry, and to recurse automatically into entries as they are returned, or only when instructed with calls to IORegistryIteratorEnterEntry. The iterator object keeps track of entries that have been recursed into previously to avoid loops.959@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.960@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.961@param options kIORegistryIterateRecursively may be set to recurse automatically into each entry as it is returned from IOIteratorNext calls on the registry iterator.962@param iterator A created iterator handle, to be released by the caller when it has finished with it.963@result A kern_return_t error code. */964965kern_return_t966IORegistryCreateIterator(967mach_port_t masterPort,968const io_name_t plane,969IOOptionBits options,970io_iterator_t * iterator );971972/*! @function IORegistryEntryCreateIterator973@abstract Create an iterator rooted at a given registry entry.974@discussion This method creates an IORegistryIterator in the kernel that is set up with options to iterate children or parents of a root entry, and to recurse automatically into entries as they are returned, or only when instructed with calls to IORegistryIteratorEnterEntry. The iterator object keeps track of entries that have been recursed into previously to avoid loops.975@param entry The root entry to begin the iteration at.976@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.977@param options kIORegistryIterateRecursively may be set to recurse automatically into each entry as it is returned from IOIteratorNext calls on the registry iterator. kIORegistryIterateParents may be set to iterate the parents of each entry, by default the children are iterated.978@param iterator A created iterator handle, to be released by the caller when it has finished with it.979@result A kern_return_t error code. */980981kern_return_t982IORegistryEntryCreateIterator(983io_registry_entry_t entry,984const io_name_t plane,985IOOptionBits options,986io_iterator_t * iterator );987988/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */989990/*991* IORegistryIterator, subclass of IOIterator992*/993994/*! @function IORegistryIteratorEnterEntry995@abstract Recurse into the current entry in the registry iteration.996@discussion This method makes the current entry, ie. the last entry returned by IOIteratorNext, the root in a new level of recursion.997@result A kern_return_t error code. */998999kern_return_t1000IORegistryIteratorEnterEntry(1001io_iterator_t iterator );10021003/*! @function IORegistryIteratorExitEntry1004@abstract Exits a level of recursion, restoring the current entry.1005@discussion This method undoes an IORegistryIteratorEnterEntry, restoring the current entry. If there are no more levels of recursion to exit false is returned, otherwise true is returned.1006@result kIOReturnSuccess if a level of recursion was undone, kIOReturnNoDevice if no recursive levels are left in the iteration. */10071008kern_return_t1009IORegistryIteratorExitEntry(1010io_iterator_t iterator );10111012/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */10131014/*1015* IORegistryEntry, subclass of IOObject1016*/10171018/*! @function IORegistryEntryGetName1019@abstract Returns a C-string name assigned to a registry entry.1020@discussion Registry entries can be named in a particular plane, or globally. This function returns the entry's global name. The global name defaults to the entry's meta class name if it has not been named.1021@param entry The registry entry handle whose name to look up.1022@param name The caller's buffer to receive the name.1023@result A kern_return_t error code. */10241025kern_return_t1026IORegistryEntryGetName(1027io_registry_entry_t entry,1028io_name_t name );10291030/*! @function IORegistryEntryGetNameInPlane1031@abstract Returns a C-string name assigned to a registry entry, in a specified plane.1032@discussion Registry entries can be named in a particular plane, or globally. This function returns the entry's name in the specified plane or global name if it has not been named in that plane. The global name defaults to the entry's meta class name if it has not been named.1033@param entry The registry entry handle whose name to look up.1034@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1035@param name The caller's buffer to receive the name.1036@result A kern_return_t error code. */10371038kern_return_t1039IORegistryEntryGetNameInPlane(1040io_registry_entry_t entry,1041const io_name_t plane,1042io_name_t name );10431044/*! @function IORegistryEntryGetLocationInPlane1045@abstract Returns a C-string location assigned to a registry entry, in a specified plane.1046@discussion Registry entries can given a location string in a particular plane, or globally. If the entry has had a location set in the specified plane that location string will be returned, otherwise the global location string is returned. If no global location string has been set, an error is returned.1047@param entry The registry entry handle whose name to look up.1048@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1049@param location The caller's buffer to receive the location string.1050@result A kern_return_t error code. */10511052kern_return_t1053IORegistryEntryGetLocationInPlane(1054io_registry_entry_t entry,1055const io_name_t plane,1056io_name_t location );10571058/*! @function IORegistryEntryGetPath1059@abstract Create a path for a registry entry.1060@discussion The path for a registry entry is copied to the caller's buffer. The path describes the entry's attachment in a particular plane, which must be specified. The path begins with the plane name followed by a colon, and then followed by '/' separated path components for each of the entries between the root and the registry entry. An alias may also exist for the entry, and will be returned if available.1061@param entry The registry entry handle whose path to look up.1062@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1063@param path A char buffer allocated by the caller.1064@result IORegistryEntryGetPath will fail if the entry is not attached in the plane, or if the buffer is not large enough to contain the path. */10651066kern_return_t1067IORegistryEntryGetPath(1068io_registry_entry_t entry,1069const io_name_t plane,1070io_string_t path );10711072/*! @function IORegistryEntryCopyPath1073@abstract Create a path for a registry entry.1074@discussion The path for a registry entry is returned as a CFString The path describes the entry's attachment in a particular plane, which must be specified. The path begins with the plane name followed by a colon, and then followed by '/' separated path components for each of the entries between the root and the registry entry. An alias may also exist for the entry, and will be returned if available.1075@param entry The registry entry handle whose path to look up.1076@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1077@result An instance of CFString on success, to be released by the caller. IORegistryEntryCopyPath will fail if the entry is not attached in the plane. */10781079CFStringRef1080IORegistryEntryCopyPath(1081io_registry_entry_t entry,1082const io_name_t plane)1083#if defined(__MAC_10_11)1084__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)1085#endif1086;10871088/*! @function IORegistryEntryGetRegistryEntryID1089@abstract Returns an ID for the registry entry that is global to all tasks.1090@discussion The entry ID returned by IORegistryEntryGetRegistryEntryID can be used to identify a registry entry across all tasks. A registry entry may be looked up by its entryID by creating a matching dictionary with IORegistryEntryIDMatching() to be used with the IOKit matching functions. The ID is valid only until the machine reboots.1091@param entry The registry entry handle whose ID to look up.1092@param entryID The resulting ID.1093@result A kern_return_t error code. */10941095kern_return_t1096IORegistryEntryGetRegistryEntryID(1097io_registry_entry_t entry,1098uint64_t * entryID );10991100/*! @function IORegistryEntryCreateCFProperties1101@abstract Create a CF dictionary representation of a registry entry's property table.1102@discussion This function creates an instantaneous snapshot of a registry entry's property table, creating a CFDictionary analogue in the caller's task. Not every object available in the kernel is represented as a CF container; currently OSDictionary, OSArray, OSSet, OSSymbol, OSString, OSData, OSNumber, OSBoolean are created as their CF counterparts.1103@param entry The registry entry handle whose property table to copy.1104@param properties A CFDictionary is created and returned the caller on success. The caller should release with CFRelease.1105@param allocator The CF allocator to use when creating the CF containers.1106@param options No options are currently defined.1107@result A kern_return_t error code. */11081109kern_return_t1110IORegistryEntryCreateCFProperties(1111io_registry_entry_t entry,1112CFMutableDictionaryRef * properties,1113CFAllocatorRef allocator,1114IOOptionBits options );11151116/*! @function IORegistryEntryCreateCFProperty1117@abstract Create a CF representation of a registry entry's property.1118@discussion This function creates an instantaneous snapshot of a registry entry property, creating a CF container analogue in the caller's task. Not every object available in the kernel is represented as a CF container; currently OSDictionary, OSArray, OSSet, OSSymbol, OSString, OSData, OSNumber, OSBoolean are created as their CF counterparts.1119@param entry The registry entry handle whose property to copy.1120@param key A CFString specifying the property name.1121@param allocator The CF allocator to use when creating the CF container.1122@param options No options are currently defined.1123@result A CF container is created and returned the caller on success. The caller should release with CFRelease. */11241125CFTypeRef1126IORegistryEntryCreateCFProperty(1127io_registry_entry_t entry,1128CFStringRef key,1129CFAllocatorRef allocator,1130IOOptionBits options );11311132/*! @function IORegistryEntrySearchCFProperty1133@abstract Create a CF representation of a registry entry's property.1134@discussion This function creates an instantaneous snapshot of a registry entry property, creating a CF container analogue in the caller's task. Not every object available in the kernel is represented as a CF container; currently OSDictionary, OSArray, OSSet, OSSymbol, OSString, OSData, OSNumber, OSBoolean are created as their CF counterparts.1135This function will search for a property, starting first with specified registry entry's property table, then iterating recusively through either the parent registry entries or the child registry entries of this entry. Once the first occurrence is found, it will lookup and return the value of the property, using the same semantics as IORegistryEntryCreateCFProperty. The iteration keeps track of entries that have been recursed into previously to avoid loops.1136@param entry The registry entry at which to start the search.1137@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1138@param key A CFString specifying the property name.1139@param allocator The CF allocator to use when creating the CF container.1140@param options kIORegistryIterateRecursively may be set to recurse automatically into the registry hierarchy. Without this option, this method degenerates into the standard IORegistryEntryCreateCFProperty() call. kIORegistryIterateParents may be set to iterate the parents of the entry, in place of the children.1141@result A CF container is created and returned the caller on success. The caller should release with CFRelease. */11421143CFTypeRef1144IORegistryEntrySearchCFProperty(1145io_registry_entry_t entry,1146const io_name_t plane,1147CFStringRef key,1148CFAllocatorRef allocator,1149IOOptionBits options ) CF_RETURNS_RETAINED;11501151/* @function IORegistryEntryGetProperty - deprecated,1152use IORegistryEntryCreateCFProperty */11531154kern_return_t1155IORegistryEntryGetProperty(1156io_registry_entry_t entry,1157const io_name_t propertyName,1158io_struct_inband_t buffer,1159uint32_t * size );11601161/*! @function IORegistryEntrySetCFProperties1162@abstract Set CF container based properties in a registry entry.1163@discussion This is a generic method to pass a CF container of properties to an object in the registry. Setting properties in a registry entry is not generally supported, it is more common to support IOConnectSetCFProperties for connection based property setting. The properties are interpreted by the object.1164@param entry The registry entry whose properties to set.1165@param properties A CF container - commonly a CFDictionary but this is not enforced. The container should consist of objects which are understood by IOKit - these are currently : CFDictionary, CFArray, CFSet, CFString, CFData, CFNumber, CFBoolean, and are passed in the kernel as the corresponding OSDictionary etc. objects.1166@result A kern_return_t error code returned by the object. */11671168kern_return_t1169IORegistryEntrySetCFProperties(1170io_registry_entry_t entry,1171CFTypeRef properties );11721173/*! @function IORegistryEntrySetCFProperty1174@abstract Set a CF container based property in a registry entry.1175@discussion This is a generic method to pass a CF container as a property to an object in the registry. Setting properties in a registry entry is not generally supported, it is more common to support IOConnectSetCFProperty for connection based property setting. The property is interpreted by the object.1176@param entry The registry entry whose property to set.1177@param propertyName The name of the property as a CFString.1178@param property A CF container - should consist of objects which are understood by IOKit - these are currently : CFDictionary, CFArray, CFSet, CFString, CFData, CFNumber, CFBoolean, and are passed in the kernel as the corresponding OSDictionary etc. objects.1179@result A kern_return_t error code returned by the object. */11801181kern_return_t1182IORegistryEntrySetCFProperty(1183io_registry_entry_t entry,1184CFStringRef propertyName,1185CFTypeRef property );11861187/*! @function IORegistryEntryGetChildIterator1188@abstract Returns an iterator over an registry entry's child entries in a plane.1189@discussion This method creates an iterator which will return each of a registry entry's child entries in a specified plane.1190@param entry The registry entry whose children to iterate over.1191@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1192@param iterator The created iterator over the children of the entry, on success. The iterator must be released when the iteration is finished.1193@result A kern_return_t error code. */11941195kern_return_t1196IORegistryEntryGetChildIterator(1197io_registry_entry_t entry,1198const io_name_t plane,1199io_iterator_t * iterator );12001201/*! @function IORegistryEntryGetChildEntry1202@abstract Returns the first child of a registry entry in a plane.1203@discussion This function will return the child which first attached to a registry entry in a plane.1204@param entry The registry entry whose child to look up.1205@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1206@param child The first child of the registry entry, on success. The child must be released by the caller.1207@result A kern_return_t error code. */12081209kern_return_t1210IORegistryEntryGetChildEntry(1211io_registry_entry_t entry,1212const io_name_t plane,1213io_registry_entry_t * child );12141215/*! @function IORegistryEntryGetParentIterator1216@abstract Returns an iterator over an registry entry's parent entries in a plane.1217@discussion This method creates an iterator which will return each of a registry entry's parent entries in a specified plane.1218@param entry The registry entry whose parents to iterate over.1219@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1220@param iterator The created iterator over the parents of the entry, on success. The iterator must be released when the iteration is finished.1221@result A kern_return_t error. */12221223kern_return_t1224IORegistryEntryGetParentIterator(1225io_registry_entry_t entry,1226const io_name_t plane,1227io_iterator_t * iterator );12281229/*! @function IORegistryEntryGetParentEntry1230@abstract Returns the first parent of a registry entry in a plane.1231@discussion This function will return the parent to which the registry entry was first attached in a plane.1232@param entry The registry entry whose parent to look up.1233@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1234@param parent The first parent of the registry entry, on success. The parent must be released by the caller.1235@result A kern_return_t error code. */12361237kern_return_t1238IORegistryEntryGetParentEntry(1239io_registry_entry_t entry,1240const io_name_t plane,1241io_registry_entry_t * parent );12421243/*! @function IORegistryEntryInPlane1244@abstract Determines if the registry entry is attached in a plane.1245@discussion This method determines if the entry is attached in a plane to any other entry.1246@param entry The registry entry.1247@param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.1248@result If the entry has a parent in the plane, true is returned, otherwise false is returned. */12491250boolean_t1251IORegistryEntryInPlane(1252io_registry_entry_t entry,1253const io_name_t plane );12541255/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */12561257/*1258* Matching dictionary creation helpers1259*/12601261/*! @function IOServiceMatching1262@abstract Create a matching dictionary that specifies an IOService class match.1263@discussion A very common matching criteria for IOService is based on its class. IOServiceMatching will create a matching dictionary that specifies any IOService of a class, or its subclasses. The class is specified by C-string name.1264@param name The class name, as a const C-string. Class matching is successful on IOService's of this class or any subclass.1265@result The matching dictionary created, is returned on success, or zero on failure. The dictionary is commonly passed to IOServiceGetMatchingServices or IOServiceAddNotification which will consume a reference, otherwise it should be released with CFRelease by the caller. */12661267CFMutableDictionaryRef1268IOServiceMatching(1269const char * name ) CF_RETURNS_RETAINED;12701271/*! @function IOServiceNameMatching1272@abstract Create a matching dictionary that specifies an IOService name match.1273@discussion A common matching criteria for IOService is based on its name. IOServiceNameMatching will create a matching dictionary that specifies an IOService with a given name. Some IOServices created from the device tree will perform name matching on the standard compatible, name, model properties.1274@param name The IOService name, as a const C-string.1275@result The matching dictionary created, is returned on success, or zero on failure. The dictionary is commonly passed to IOServiceGetMatchingServices or IOServiceAddNotification which will consume a reference, otherwise it should be released with CFRelease by the caller. */12761277CFMutableDictionaryRef1278IOServiceNameMatching(1279const char * name ) CF_RETURNS_RETAINED;12801281/*! @function IOBSDNameMatching1282@abstract Create a matching dictionary that specifies an IOService match based on BSD device name.1283@discussion IOServices that represent BSD devices have an associated BSD name. This function creates a matching dictionary that will match IOService's with a given BSD name.1284@param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.1285@param options No options are currently defined.1286@param bsdName The BSD name, as a const char *.1287@result The matching dictionary created, is returned on success, or zero on failure. The dictionary is commonly passed to IOServiceGetMatchingServices or IOServiceAddNotification which will consume a reference, otherwise it should be released with CFRelease by the caller. */12881289CFMutableDictionaryRef1290IOBSDNameMatching(1291mach_port_t masterPort,1292uint32_t options,1293const char * bsdName ) CF_RETURNS_RETAINED;12941295CFMutableDictionaryRef1296IOOpenFirmwarePathMatching(1297mach_port_t masterPort,1298uint32_t options,1299const char * path ) DEPRECATED_ATTRIBUTE;13001301/*! @function IORegistryEntryIDMatching1302@abstract Create a matching dictionary that specifies an IOService match based on a registry entry ID.1303@discussion This function creates a matching dictionary that will match a registered, active IOService found with the given registry entry ID. The entry ID for a registry entry is returned by IORegistryEntryGetRegistryEntryID().1304@param entryID The registry entry ID to be found.1305@result The matching dictionary created, is returned on success, or zero on failure. The dictionary is commonly passed to IOServiceGetMatchingServices or IOServiceAddNotification which will consume a reference, otherwise it should be released with CFRelease by the caller. */13061307CFMutableDictionaryRef1308IORegistryEntryIDMatching(1309uint64_t entryID ) CF_RETURNS_RETAINED;13101311/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */13121313kern_return_t1314IOServiceOFPathToBSDName(mach_port_t masterPort,1315const io_name_t openFirmwarePath,1316io_name_t bsdName) DEPRECATED_ATTRIBUTE;13171318/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */13191320/*! @typedef IOAsyncCallback01321@abstract standard callback function for asynchronous I/O requests with1322no extra arguments beyond a refcon and result code.1323@param refcon The refcon passed into the original I/O request1324@param result The result of the I/O operation1325*/1326typedef void (*IOAsyncCallback0)(void *refcon, IOReturn result);13271328/*! @typedef IOAsyncCallback11329@abstract standard callback function for asynchronous I/O requests with1330one extra argument beyond a refcon and result code.1331This is often a count of the number of bytes transferred1332@param refcon The refcon passed into the original I/O request1333@param result The result of the I/O operation1334@param arg0 Extra argument1335*/1336typedef void (*IOAsyncCallback1)(void *refcon, IOReturn result, void *arg0);13371338/*! @typedef IOAsyncCallback21339@abstract standard callback function for asynchronous I/O requests with1340two extra arguments beyond a refcon and result code.1341@param refcon The refcon passed into the original I/O request1342@param result The result of the I/O operation1343@param arg0 Extra argument1344@param arg1 Extra argument1345*/1346typedef void (*IOAsyncCallback2)(void *refcon, IOReturn result, void *arg0, void *arg1);13471348/*! @typedef IOAsyncCallback1349@abstract standard callback function for asynchronous I/O requests with1350lots of extra arguments beyond a refcon and result code.1351@param refcon The refcon passed into the original I/O request1352@param result The result of the I/O operation1353@param args Array of extra arguments1354@param numArgs Number of extra arguments1355*/1356typedef void (*IOAsyncCallback)(void *refcon, IOReturn result, void **args,1357uint32_t numArgs);135813591360/* Internal use */13611362kern_return_t1363OSGetNotificationFromMessage(1364mach_msg_header_t * msg,1365uint32_t index,1366uint32_t * type,1367uintptr_t * reference,1368void ** content,1369vm_size_t * size );13701371/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */13721373/* Internal use */13741375kern_return_t1376IOCatalogueSendData(1377mach_port_t masterPort,1378uint32_t flag,1379const char *buffer,1380uint32_t size );13811382kern_return_t1383IOCatalogueTerminate(1384mach_port_t masterPort,1385uint32_t flag,1386io_name_t description );13871388kern_return_t1389IOCatalogueGetData(1390mach_port_t masterPort,1391uint32_t flag,1392char **buffer,1393uint32_t *size );13941395kern_return_t1396IOCatalogueModuleLoaded(1397mach_port_t masterPort,1398io_name_t name );13991400/* Use IOCatalogueSendData(), with kIOCatalogResetDrivers, to replace catalogue1401* rather than emptying it. Doing so keeps instance counts down by uniquing1402* existing personalities.1403*/1404kern_return_t1405IOCatalogueReset(1406mach_port_t masterPort,1407uint32_t flag );14081409/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */14101411// obsolete API14121413#if !defined(__LP64__)14141415// for Power Mgt14161417typedef struct IOObject IOObject;14181419// for MacOS.app14201421kern_return_t1422IORegistryDisposeEnumerator(1423io_enumerator_t enumerator ) DEPRECATED_ATTRIBUTE;14241425kern_return_t1426IOMapMemory(1427io_connect_t connect,1428uint32_t memoryType,1429task_port_t intoTask,1430vm_address_t * atAddress,1431vm_size_t * ofSize,1432uint32_t flags ) DEPRECATED_ATTRIBUTE;14331434// for CGS14351436kern_return_t1437IOCompatibiltyNumber(1438mach_port_t connect,1439uint32_t * objectNumber ) DEPRECATED_ATTRIBUTE;14401441// Traditional IOUserClient transport routines1442kern_return_t1443IOConnectMethodScalarIScalarO(1444io_connect_t connect,1445uint32_t index,1446IOItemCount scalarInputCount,1447IOItemCount scalarOutputCount,1448... ) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;14491450kern_return_t1451IOConnectMethodScalarIStructureO(1452io_connect_t connect,1453uint32_t index,1454IOItemCount scalarInputCount,1455IOByteCount * structureSize,1456... ) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;14571458kern_return_t1459IOConnectMethodScalarIStructureI(1460io_connect_t connect,1461uint32_t index,1462IOItemCount scalarInputCount,1463IOByteCount structureSize,1464... ) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;14651466kern_return_t1467IOConnectMethodStructureIStructureO(1468io_connect_t connect,1469uint32_t index,1470IOItemCount structureInputSize,1471IOByteCount * structureOutputSize,1472void * inputStructure,1473void * ouputStructure ) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;14741475// Compatability with earlier Mig interface routines1476#if IOCONNECT_NO_32B_METHODS14771478kern_return_t1479io_connect_map_memory(1480io_connect_t connect,1481uint32_t memoryType,1482task_port_t intoTask,1483vm_address_t *atAddress,1484vm_size_t *ofSize,1485IOOptionBits options) DEPRECATED_ATTRIBUTE;14861487kern_return_t1488io_connect_unmap_memory(1489io_connect_t connect,1490uint32_t memoryType,1491task_port_t fromTask,1492vm_address_t atAddress) DEPRECATED_ATTRIBUTE;14931494kern_return_t1495io_connect_method_scalarI_scalarO(1496mach_port_t connection,1497int selector,1498io_scalar_inband_t input,1499mach_msg_type_number_t inputCnt,1500io_scalar_inband_t output,1501mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;15021503kern_return_t1504io_connect_method_scalarI_structureO(1505mach_port_t connection,1506int selector,1507io_scalar_inband_t input,1508mach_msg_type_number_t inputCnt,1509io_struct_inband_t output,1510mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;15111512kern_return_t1513io_connect_method_scalarI_structureI(1514mach_port_t connection,1515int selector,1516io_scalar_inband_t input,1517mach_msg_type_number_t inputCnt,1518io_struct_inband_t inputStruct,1519mach_msg_type_number_t inputStructCnt) DEPRECATED_ATTRIBUTE;15201521kern_return_t1522io_connect_method_structureI_structureO(1523mach_port_t connection,1524int selector,1525io_struct_inband_t input,1526mach_msg_type_number_t inputCnt,1527io_struct_inband_t output,1528mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;15291530kern_return_t1531io_async_method_scalarI_scalarO(1532mach_port_t connection,1533mach_port_t wake_port,1534io_async_ref_t reference,1535mach_msg_type_number_t referenceCnt,1536int selector,1537io_scalar_inband_t input,1538mach_msg_type_number_t inputCnt,1539io_scalar_inband_t output,1540mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;15411542kern_return_t1543io_async_method_scalarI_structureO(1544mach_port_t connection,1545mach_port_t wake_port,1546io_async_ref_t reference,1547mach_msg_type_number_t referenceCnt,1548int selector,1549io_scalar_inband_t input,1550mach_msg_type_number_t inputCnt,1551io_struct_inband_t output,1552mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;15531554kern_return_t1555io_async_method_scalarI_structureI(1556mach_port_t connection,1557mach_port_t wake_port,1558io_async_ref_t reference,1559mach_msg_type_number_t referenceCnt,1560int selector,1561io_scalar_inband_t input,1562mach_msg_type_number_t inputCnt,1563io_struct_inband_t inputStruct,1564mach_msg_type_number_t inputStructCnt) DEPRECATED_ATTRIBUTE;15651566kern_return_t1567io_async_method_structureI_structureO(1568mach_port_t connection,1569mach_port_t wake_port,1570io_async_ref_t reference,1571mach_msg_type_number_t referenceCnt,1572int selector,1573io_struct_inband_t input,1574mach_msg_type_number_t inputCnt,1575io_struct_inband_t output,1576mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;1577#endif // IOCONNECT_NO_32B_METHODS15781579#endif /* defined(__LP64__) */15801581__END_DECLS15821583#endif /* ! _IOKIT_IOKITLIB_H */158415851586