IOKit.h 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425
  1. /*
  2. * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
  3. *
  4. * @APPLE_LICENSE_HEADER_START@
  5. *
  6. * The contents of this file constitute Original Code as defined in and
  7. * are subject to the Apple Public Source License Version 1.1 (the
  8. * "License"). You may not use this file except in compliance with the
  9. * License. Please obtain a copy of the License at
  10. * http://www.apple.com/publicsource and read it before using this file.
  11. *
  12. * This Original Code and all software distributed under the License are
  13. * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  14. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  15. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  17. * License for the specific language governing rights and limitations
  18. * under the License.
  19. *
  20. * @APPLE_LICENSE_HEADER_END@
  21. */
  22. /*
  23. * HISTORY
  24. *
  25. */
  26. /*
  27. * IOKit user library
  28. */
  29. #ifndef _IOKIT_IOKITLIB_H
  30. #define _IOKIT_IOKITLIB_H
  31. #ifdef KERNEL
  32. #error This file is not for kernel use
  33. #endif
  34. #include <sys/cdefs.h>
  35. #include <sys/types.h>
  36. #include <mach/mach_types.h>
  37. #include <mach/mach_init.h>
  38. #include <CoreFoundation/CFBase.h>
  39. #include <CoreFoundation/CFDictionary.h>
  40. #include <CoreFoundation/CFRunLoop.h>
  41. #include <IOKit/IOTypes.h>
  42. #include <IOKit/IOKitKeys.h>
  43. #include <IOKit/OSMessageNotification.h>
  44. #include <AvailabilityMacros.h>
  45. __BEGIN_DECLS
  46. /*! @header IOKitLib
  47. 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.<br>
  48. 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.
  49. IOKit objects returned by all functions should be released with IOObjectRelease.
  50. */
  51. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  52. typedef struct IONotificationPort * IONotificationPortRef;
  53. /*! @typedef IOServiceMatchingCallback
  54. @abstract Callback function to be notified of IOService publication.
  55. @param refcon The refcon passed when the notification was installed.
  56. @param iterator The notification iterator which now has new objects.
  57. */
  58. typedef void
  59. (*IOServiceMatchingCallback)(
  60. void * refcon,
  61. io_iterator_t iterator );
  62. /*! @typedef IOServiceInterestCallback
  63. @abstract Callback function to be notified of changes in state of an IOService.
  64. @param refcon The refcon passed when the notification was installed.
  65. @param service The IOService whose state has changed.
  66. @param messageType A messageType enum, defined by IOKit/IOMessage.h or by the IOService's family.
  67. @param messageArgument An argument for the message, dependent on the messageType.
  68. */
  69. typedef void
  70. (*IOServiceInterestCallback)(
  71. void * refcon,
  72. io_service_t service,
  73. uint32_t messageType,
  74. void * messageArgument );
  75. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  76. /*! @const kIOMasterPortDefault
  77. @abstract The default mach port used to initiate communication with IOKit.
  78. @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.
  79. */
  80. extern
  81. const mach_port_t kIOMasterPortDefault;
  82. /*! @function IOMasterPort
  83. @abstract Returns the mach port used to initiate communication with IOKit.
  84. @discussion Functions that don't specify an existing object require the IOKit master port to be passed. This function obtains that port.
  85. @param bootstrapPort Pass MACH_PORT_NULL for the default.
  86. @param masterPort The master port is returned.
  87. @result A kern_return_t error code. */
  88. kern_return_t
  89. IOMasterPort( mach_port_t bootstrapPort,
  90. mach_port_t * masterPort );
  91. /*! @function IONotificationPortCreate
  92. @abstract Creates and returns a notification object for receiving IOKit notifications of new devices or state changes.
  93. @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.
  94. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  95. @result A reference to the notification object. */
  96. IONotificationPortRef
  97. IONotificationPortCreate(
  98. mach_port_t masterPort );
  99. /*! @function IONotificationPortDestroy
  100. @abstract Destroys a notification object created with IONotificationPortCreate.
  101. @param notify A reference to the notification object. */
  102. void
  103. IONotificationPortDestroy(
  104. IONotificationPortRef notify );
  105. /*! @function IONotificationPortGetRunLoopSource
  106. @abstract Returns a CFRunLoopSource to be used to listen for notifications.
  107. @discussion A notification object may deliver notifications to a CFRunLoop client by adding the run loop source returned by this function to the run loop.
  108. @param notify The notification object.
  109. @result A CFRunLoopSourceRef for the notification object. */
  110. CFRunLoopSourceRef
  111. IONotificationPortGetRunLoopSource(
  112. IONotificationPortRef notify );
  113. /*! @function IONotificationPortGetMachPort
  114. @abstract Returns a mach_port to be used to listen for notifications.
  115. @discussion A notification object may deliver notifications to a mach messaging client if they listen for messages on the port obtained from this function. Callbacks associated with the notifications may be delivered by calling IODispatchCalloutFromMessage with messages received
  116. @param notify The notification object.
  117. @result A mach_port for the notification object. */
  118. mach_port_t
  119. IONotificationPortGetMachPort(
  120. IONotificationPortRef notify );
  121. /*! @function IODispatchCalloutFromMessage
  122. @abstract Dispatches callback notifications from a mach message.
  123. @discussion A notification object may deliver notifications to a mach messaging client, which should call this function to generate the callbacks associated with the notifications arriving on the port.
  124. @param unused Not used, set to zero.
  125. @param msg A pointer to the message received.
  126. @param reference Pass the IONotificationPortRef for the object. */
  127. void
  128. IODispatchCalloutFromMessage(
  129. void *unused,
  130. mach_msg_header_t *msg,
  131. void *reference );
  132. /*! @function IOCreateReceivePort
  133. @abstract Creates and returns a mach port suitable for receiving IOKit messages of the specified type.
  134. @discussion In the future IOKit may use specialized messages and ports
  135. instead of the standard ports created by mach_port_allocate(). Use this
  136. function instead of mach_port_allocate() to ensure compatibility with future
  137. revisions of IOKit.
  138. @param msgType Type of message to be sent to this port
  139. (kOSNotificationMessageID or kOSAsyncCompleteMessageID)
  140. @param recvPort The created port is returned.
  141. @result A kern_return_t error code. */
  142. kern_return_t
  143. IOCreateReceivePort( uint32_t msgType, mach_port_t * recvPort );
  144. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  145. /*
  146. * IOObject
  147. */
  148. /*! @function IOObjectRelease
  149. @abstract Releases an object handle previously returned by IOKitLib.
  150. @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.
  151. @param object The IOKit object to release.
  152. @result A kern_return_t error code. */
  153. kern_return_t
  154. IOObjectRelease(
  155. io_object_t object );
  156. /*! @function IOObjectRetain
  157. @abstract Retains an object handle previously returned by IOKitLib.
  158. @discussion Gives the caller an additional reference to an existing object handle previously returned by IOKitLib.
  159. @param object The IOKit object to retain.
  160. @result A kern_return_t error code. */
  161. kern_return_t
  162. IOObjectRetain(
  163. io_object_t object );
  164. /*! @function IOObjectGetClass
  165. @abstract Return the class name of an IOKit object.
  166. @discussion This function uses the OSMetaClass system in the kernel to derive the name of the class the object is an instance of.
  167. @param object The IOKit object.
  168. @param className Caller allocated buffer to receive the name string.
  169. @result A kern_return_t error code. */
  170. kern_return_t
  171. IOObjectGetClass(
  172. io_object_t object,
  173. io_name_t className );
  174. /*! @function CFStringRef IOObjectCopyClass
  175. @abstract Return the class name of an IOKit object.
  176. @discussion This function does the same thing as IOObjectGetClass, but returns the result as a CFStringRef.
  177. @param object The IOKit object.
  178. @result The resulting CFStringRef. This should be released by the caller. If a valid object is not passed in, then NULL is returned.*/
  179. CFStringRef
  180. IOObjectCopyClass(io_object_t object)
  181. AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
  182. /*! @function CFStringRef IOObjectCopySuperclassForClass
  183. @abstract Return the superclass name of the given class.
  184. @discussion This function uses the OSMetaClass system in the kernel to derive the name of the superclass of the class.
  185. @param classname The name of the class as a CFString.
  186. @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.*/
  187. CFStringRef
  188. IOObjectCopySuperclassForClass(CFStringRef classname)
  189. AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
  190. /*! @function CFStringRef IOObjectCopyBundleIdentifierForClass
  191. @abstract Return the bundle identifier of the given class.
  192. @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.
  193. @param classname The name of the class as a CFString.
  194. @result The resulting CFStringRef. This should be released by the caller. If a valid class name is not passed in, then NULL is returned.*/
  195. CFStringRef
  196. IOObjectCopyBundleIdentifierForClass(CFStringRef classname)
  197. AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
  198. /*! @function IOObjectConformsTo
  199. @abstract Performs an OSDynamicCast operation on an IOKit object.
  200. @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.
  201. @param object An IOKit object.
  202. @param className The name of the class, as a C-string.
  203. @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. */
  204. boolean_t
  205. IOObjectConformsTo(
  206. io_object_t object,
  207. const io_name_t className );
  208. /*! @function IOObjectIsEqualTo
  209. @abstract Checks two object handles to see if they represent the same kernel object.
  210. @discussion If two object handles are returned by IOKitLib functions, this function will compare them to see if they represent the same kernel object.
  211. @param object An IOKit object.
  212. @param anObject Another IOKit object.
  213. @result If both object handles are valid, and represent the same object in the kernel true is returned, otherwise false. */
  214. boolean_t
  215. IOObjectIsEqualTo(
  216. io_object_t object,
  217. io_object_t anObject );
  218. /*! @function IOObjectGetRetainCount
  219. @abstract Returns kernel retain count of an IOKit object.
  220. @discussion This function may be used in diagnostics to determine the current retain count of the kernel object.
  221. @param object An IOKit object.
  222. @result If the object handle is valid, the kernel objects retain count is returned, otherwise zero is returned. */
  223. uint32_t
  224. IOObjectGetRetainCount(
  225. io_object_t object );
  226. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  227. /*
  228. * IOIterator, subclass of IOObject
  229. */
  230. /*! @function IOIteratorNext
  231. @abstract Returns the next object in an iteration.
  232. @discussion This function returns the next object in an iteration, or zero if no more remain or the iterator is invalid.
  233. @param iterator An IOKit iterator handle.
  234. @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. */
  235. io_object_t
  236. IOIteratorNext(
  237. io_iterator_t iterator );
  238. /*! @function IOIteratorReset
  239. @abstract Resets an iteration back to the beginning.
  240. @discussion If an iterator is invalid, or if the caller wants to start over, IOIteratorReset will set the iteration back to the beginning.
  241. @param iterator An IOKit iterator handle. */
  242. void
  243. IOIteratorReset(
  244. io_iterator_t iterator );
  245. /*! @function IOIteratorIsValid
  246. @abstract Checks an iterator is still valid.
  247. @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.
  248. @param iterator An IOKit iterator handle.
  249. @result True if the iterator handle is valid, otherwise false is returned. */
  250. boolean_t
  251. IOIteratorIsValid(
  252. io_iterator_t iterator );
  253. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  254. /*
  255. * IOService, subclass of IORegistryEntry
  256. */
  257. /*!
  258. @function IOServiceGetMatchingService
  259. @abstract Look up a registered IOService object that matches a matching dictionary.
  260. @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.
  261. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  262. @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, IOOpenFirmwarePathMatching.
  263. @result The first service matched is returned on success. The service must be released by the caller.
  264. */
  265. io_service_t
  266. IOServiceGetMatchingService(
  267. mach_port_t masterPort,
  268. CFDictionaryRef matching );
  269. /*! @function IOServiceGetMatchingServices
  270. @abstract Look up registered IOService objects that match a matching dictionary.
  271. @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.
  272. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  273. @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, IOOpenFirmwarePathMatching.
  274. @param existing An iterator handle is returned on success, and should be released by the caller when the iteration is finished.
  275. @result A kern_return_t error code. */
  276. kern_return_t
  277. IOServiceGetMatchingServices(
  278. mach_port_t masterPort,
  279. CFDictionaryRef matching,
  280. io_iterator_t * existing );
  281. kern_return_t
  282. IOServiceAddNotification(
  283. mach_port_t masterPort,
  284. const io_name_t notificationType,
  285. CFDictionaryRef matching,
  286. mach_port_t wakePort,
  287. uintptr_t reference,
  288. io_iterator_t * notification ) DEPRECATED_ATTRIBUTE;
  289. /*! @function IOServiceAddMatchingNotification
  290. @abstract Look up registered IOService objects that match a matching dictionary, and install a notification request of new IOServices that match.
  291. @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.
  292. @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.
  293. @param notificationType A notification type from IOKitKeys.h
  294. <br> kIOPublishNotification Delivered when an IOService is registered.
  295. <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.
  296. <br> kIOMatchedNotification Delivered when an IOService has had all matching drivers in the kernel probed and started.
  297. <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.
  298. <br> kIOTerminatedNotification Delivered after an IOService has been terminated.
  299. @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, IOOpenFirmwarePathMatching.
  300. @param callback A callback function called when the notification fires.
  301. @param refCon A reference constant for the callbacks use.
  302. @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.
  303. @result A kern_return_t error code. */
  304. kern_return_t
  305. IOServiceAddMatchingNotification(
  306. IONotificationPortRef notifyPort,
  307. const io_name_t notificationType,
  308. CFDictionaryRef matching,
  309. IOServiceMatchingCallback callback,
  310. void * refCon,
  311. io_iterator_t * notification );
  312. /*! @function IOServiceAddInterestNotification
  313. @abstract Register for notification of state changes in an IOService.
  314. @discussion IOService objects deliver notifications of their state changes to their clients via the IOService::message API, and to other interested parties including callers of this function. Message type s are defined IOKit/IOMessage.h.
  315. @param notifyPort A IONotificationPortRef object that controls how messages will be sent when the notification is fired. See IONotificationPortCreate.
  316. @param interestType A notification type from IOKitKeys.h
  317. <br> kIOGeneralInterest General state changes delivered via the IOService::message API.
  318. <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.
  319. @param callback A callback function called when the notification fires, with messageType and messageArgument for the state change.
  320. @param refCon A reference constant for the callbacks use.
  321. @param notification An object handle is returned on success, and should be released by the caller when the notification is to be destroyed.
  322. @result A kern_return_t error code. */
  323. kern_return_t
  324. IOServiceAddInterestNotification(
  325. IONotificationPortRef notifyPort,
  326. io_service_t service,
  327. const io_name_t interestType,
  328. IOServiceInterestCallback callback,
  329. void * refCon,
  330. io_object_t * notification );
  331. /*! @function IOServiceMatchPropertyTable
  332. @abstract Match an IOService objects with matching dictionary.
  333. @discussion This function calls the matching method of an IOService object and returns the boolean result.
  334. @param service The IOService object to match.
  335. @param matching A CF dictionary containing matching information. IOKitLib can construct matching dictionaries for common criteria with helper functions such as IOServiceMatching, IOServiceNameMatching, IOBSDNameMatching, IOOpenFirmwarePathMatching.
  336. @param matches The boolean result is returned.
  337. @result A kern_return_t error code. */
  338. kern_return_t
  339. IOServiceMatchPropertyTable(
  340. io_service_t service,
  341. CFDictionaryRef matching,
  342. boolean_t * matches );
  343. /*! @function IOServiceGetBusyState
  344. @abstract Returns the busyState of an IOService.
  345. @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.
  346. @param service The IOService whose busyState to return.
  347. @param busyState The busyState count is returned.
  348. @result A kern_return_t error code. */
  349. kern_return_t
  350. IOServiceGetBusyState(
  351. io_service_t service,
  352. uint32_t * busyState );
  353. /*! @function IOServiceWaitQuiet
  354. @abstract Wait for an IOService's busyState to be zero.
  355. @discussion Blocks the caller until an IOService is non busy, see IOServiceGetBusyState.
  356. @param service The IOService wait on.
  357. @param waitTime Specifies a maximum time to wait.
  358. @result Returns an error code if mach synchronization primitives fail, kIOReturnTimeout, or kIOReturnSuccess. */
  359. kern_return_t
  360. IOServiceWaitQuiet(
  361. io_service_t service,
  362. mach_timespec_t * waitTime );
  363. /*! @function IOKitGetBusyState
  364. @abstract Returns the busyState of all IOServices.
  365. @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.
  366. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  367. @param busyState The busyState count is returned.
  368. @result A kern_return_t error code. */
  369. kern_return_t
  370. IOKitGetBusyState(
  371. mach_port_t masterPort,
  372. uint32_t * busyState );
  373. /*! @function IOKitWaitQuiet
  374. @abstract Wait for a all IOServices' busyState to be zero.
  375. @discussion Blocks the caller until all IOServices are non busy, see IOKitGetBusyState.
  376. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  377. @param waitTime Specifies a maximum time to wait.
  378. @result Returns an error code if mach synchronization primitives fail, kIOReturnTimeout, or kIOReturnSuccess. */
  379. kern_return_t
  380. IOKitWaitQuiet(
  381. mach_port_t masterPort,
  382. mach_timespec_t * waitTime );
  383. /*! @function IOServiceOpen
  384. @abstract A request to create a connection to an IOService.
  385. @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.
  386. @param service The IOService object to open a connection to, usually obtained via the IOServiceGetMatchingServices or IOServiceAddNotification APIs.
  387. @param owningTask The mach task requesting the connection.
  388. @param type A constant specifying the type of connection to be created, interpreted only by the IOService's family.
  389. @param connect An io_connect_t handle is returned on success, to be used with the IOConnectXXX APIs. It should be destroyed with IOServiceClose().
  390. @result A return code generated by IOService::newUserClient. */
  391. kern_return_t
  392. IOServiceOpen(
  393. io_service_t service,
  394. task_port_t owningTask,
  395. uint32_t type,
  396. io_connect_t * connect );
  397. /*! @function IOServiceRequestProbe
  398. @abstract A request to rescan a bus for device changes.
  399. @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.
  400. @param service The IOService object to request a rescan, usually obtained via the IOServiceGetMatchingServices or IOServiceAddNotification APIs.
  401. @param options An options mask, interpreted only by the IOService's family.
  402. @result A return code generated by IOService::requestProbe. */
  403. kern_return_t
  404. IOServiceRequestProbe(
  405. io_service_t service,
  406. uint32_t options );
  407. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  408. /*
  409. * IOService connection
  410. */
  411. /*! @function IOServiceClose
  412. @abstract Close a connection to an IOService and destroy the connect handle.
  413. @discussion A connection created with the IOServiceOpen should be closed when the connection is no longer to be used with IOServiceClose.
  414. @param connect The connect handle created by IOServiceOpen. It will be destroyed by this function, and should not be released with IOObjectRelease.
  415. @result A kern_return_t error code. */
  416. kern_return_t
  417. IOServiceClose(
  418. io_connect_t connect );
  419. /*! @function IOConnectAddRef
  420. @abstract Adds a reference to the connect handle.
  421. @discussion Adds a reference to the connect handle.
  422. @param connect The connect handle created by IOServiceOpen.
  423. @result A kern_return_t error code. */
  424. kern_return_t
  425. IOConnectAddRef(
  426. io_connect_t connect );
  427. /*! @function IOConnectRelease
  428. @abstract Remove a reference to the connect handle.
  429. @discussion Removes a reference to the connect handle. If the last reference is removed an implicit IOServiceClose is performed.
  430. @param connect The connect handle created by IOServiceOpen.
  431. @result A kern_return_t error code. */
  432. kern_return_t
  433. IOConnectRelease(
  434. io_connect_t connect );
  435. /*! @function IOConnectGetService
  436. @abstract Returns the IOService a connect handle was opened on.
  437. @discussion Finds the service object a connection was opened on.
  438. @param connect The connect handle created by IOServiceOpen.
  439. @param service On succes, the service handle the connection was opened on, which should be released with IOObjectRelease.
  440. @result A kern_return_t error code. */
  441. kern_return_t
  442. IOConnectGetService(
  443. io_connect_t connect,
  444. io_service_t * service );
  445. /*! @function IOConnectSetNotificationPort
  446. @abstract Set a port to receive family specific notifications.
  447. @discussion This is a generic method to pass a mach port send right to be be used by family specific notifications.
  448. @param connect The connect handle created by IOServiceOpen.
  449. @param type The type of notification requested, not interpreted by IOKit and family defined.
  450. @param port The port to which to send notifications.
  451. @param reference Some families may support passing a reference parameter for the callers use with the notification.
  452. @result A kern_return_t error code. */
  453. kern_return_t
  454. IOConnectSetNotificationPort(
  455. io_connect_t connect,
  456. uint32_t type,
  457. mach_port_t port,
  458. uintptr_t reference );
  459. /*! @function IOConnectMapMemory
  460. @abstract Map hardware or shared memory into the caller's task.
  461. @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.
  462. @param connect The connect handle created by IOServiceOpen.
  463. @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.
  464. @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.
  465. @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.
  466. @param ofSize The size of the mapping created is passed back on success.
  467. @result A kern_return_t error code. */
  468. #if !__LP64__
  469. kern_return_t
  470. IOConnectMapMemory(
  471. io_connect_t connect,
  472. uint32_t memoryType,
  473. task_port_t intoTask,
  474. vm_address_t *atAddress,
  475. vm_size_t *ofSize,
  476. IOOptionBits options );
  477. kern_return_t IOConnectMapMemory64
  478. #else
  479. kern_return_t IOConnectMapMemory
  480. #endif
  481. (io_connect_t connect,
  482. uint32_t memoryType,
  483. task_port_t intoTask,
  484. mach_vm_address_t *atAddress,
  485. mach_vm_size_t *ofSize,
  486. IOOptionBits options );
  487. /*! @function IOConnectUnmapMemory
  488. @abstract Remove a mapping made with IOConnectMapMemory.
  489. @discussion This is a generic method to remove a mapping in the callers task.
  490. @param connect The connect handle created by IOServiceOpen.
  491. @param memoryType The memory type originally requested in IOConnectMapMemory.
  492. @param intoTask The task port for the task in which to remove the mapping. This may be different to the task which the opened the connection.
  493. @param atAddress The address of the mapping to be removed.
  494. @result A kern_return_t error code. */
  495. #if !__LP64__
  496. kern_return_t
  497. IOConnectUnmapMemory(
  498. io_connect_t connect,
  499. uint32_t memoryType,
  500. task_port_t fromTask,
  501. vm_address_t atAddress );
  502. kern_return_t IOConnectUnmapMemory64
  503. #else
  504. kern_return_t IOConnectUnmapMemory
  505. #endif
  506. (io_connect_t connect,
  507. uint32_t memoryType,
  508. task_port_t fromTask,
  509. mach_vm_address_t atAddress );
  510. /*! @function IOConnectSetCFProperties
  511. @abstract Set CF container based properties on a connection.
  512. @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.
  513. @param connect The connect handle created by IOServiceOpen.
  514. @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.
  515. @result A kern_return_t error code returned by the family. */
  516. kern_return_t
  517. IOConnectSetCFProperties(
  518. io_connect_t connect,
  519. CFTypeRef properties );
  520. /*! @function IOConnectSetCFProperty
  521. @abstract Set a CF container based property on a connection.
  522. @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.
  523. @param connect The connect handle created by IOServiceOpen.
  524. @param propertyName The name of the property as a CFString.
  525. @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.
  526. @result A kern_return_t error code returned by the object. */
  527. kern_return_t
  528. IOConnectSetCFProperty(
  529. io_connect_t connect,
  530. CFStringRef propertyName,
  531. CFTypeRef property );
  532. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  533. // Combined LP64 & ILP32 Extended IOUserClient::externalMethod
  534. kern_return_t
  535. IOConnectCallMethod(
  536. mach_port_t connection, // In
  537. uint32_t selector, // In
  538. const uint64_t *input, // In
  539. uint32_t inputCnt, // In
  540. const void *inputStruct, // In
  541. size_t inputStructCnt, // In
  542. uint64_t *output, // Out
  543. uint32_t *outputCnt, // In/Out
  544. void *outputStruct, // Out
  545. size_t *outputStructCnt) // In/Out
  546. AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
  547. kern_return_t
  548. IOConnectCallAsyncMethod(
  549. mach_port_t connection, // In
  550. uint32_t selector, // In
  551. mach_port_t wake_port, // In
  552. uint64_t *reference, // In
  553. uint32_t referenceCnt, // In
  554. const uint64_t *input, // In
  555. uint32_t inputCnt, // In
  556. const void *inputStruct, // In
  557. size_t inputStructCnt, // In
  558. uint64_t *output, // Out
  559. uint32_t *outputCnt, // In/Out
  560. void *outputStruct, // Out
  561. size_t *outputStructCnt) // In/Out
  562. AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
  563. kern_return_t
  564. IOConnectCallStructMethod(
  565. mach_port_t connection, // In
  566. uint32_t selector, // In
  567. const void *inputStruct, // In
  568. size_t inputStructCnt, // In
  569. void *outputStruct, // Out
  570. size_t *outputStructCnt) // In/Out
  571. AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
  572. kern_return_t
  573. IOConnectCallAsyncStructMethod(
  574. mach_port_t connection, // In
  575. uint32_t selector, // In
  576. mach_port_t wake_port, // In
  577. uint64_t *reference, // In
  578. uint32_t referenceCnt, // In
  579. const void *inputStruct, // In
  580. size_t inputStructCnt, // In
  581. void *outputStruct, // Out
  582. size_t *outputStructCnt) // In/Out
  583. AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
  584. kern_return_t
  585. IOConnectCallScalarMethod(
  586. mach_port_t connection, // In
  587. uint32_t selector, // In
  588. const uint64_t *input, // In
  589. uint32_t inputCnt, // In
  590. uint64_t *output, // Out
  591. uint32_t *outputCnt) // In/Out
  592. AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
  593. kern_return_t
  594. IOConnectCallAsyncScalarMethod(
  595. mach_port_t connection, // In
  596. uint32_t selector, // In
  597. mach_port_t wake_port, // In
  598. uint64_t *reference, // In
  599. uint32_t referenceCnt, // In
  600. const uint64_t *input, // In
  601. uint32_t inputCnt, // In
  602. uint64_t *output, // Out
  603. uint32_t *outputCnt) // In/Out
  604. AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
  605. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  606. kern_return_t
  607. IOConnectTrap0(io_connect_t connect,
  608. uint32_t index );
  609. kern_return_t
  610. IOConnectTrap1(io_connect_t connect,
  611. uint32_t index,
  612. uintptr_t p1 );
  613. kern_return_t
  614. IOConnectTrap2(io_connect_t connect,
  615. uint32_t index,
  616. uintptr_t p1,
  617. uintptr_t p2);
  618. kern_return_t
  619. IOConnectTrap3(io_connect_t connect,
  620. uint32_t index,
  621. uintptr_t p1,
  622. uintptr_t p2,
  623. uintptr_t p3);
  624. kern_return_t
  625. IOConnectTrap4(io_connect_t connect,
  626. uint32_t index,
  627. uintptr_t p1,
  628. uintptr_t p2,
  629. uintptr_t p3,
  630. uintptr_t p4);
  631. kern_return_t
  632. IOConnectTrap5(io_connect_t connect,
  633. uint32_t index,
  634. uintptr_t p1,
  635. uintptr_t p2,
  636. uintptr_t p3,
  637. uintptr_t p4,
  638. uintptr_t p5);
  639. kern_return_t
  640. IOConnectTrap6(io_connect_t connect,
  641. uint32_t index,
  642. uintptr_t p1,
  643. uintptr_t p2,
  644. uintptr_t p3,
  645. uintptr_t p4,
  646. uintptr_t p5,
  647. uintptr_t p6);
  648. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  649. /*! @function IOConnectAddClient
  650. @abstract Inform a connection of a second connection.
  651. @discussion This is a generic method to inform a family connection of a second connection, and is rarely used.
  652. @param connect The connect handle created by IOServiceOpen.
  653. @param client Another connect handle created by IOServiceOpen.
  654. @result A kern_return_t error code returned by the family. */
  655. kern_return_t
  656. IOConnectAddClient(
  657. io_connect_t connect,
  658. io_connect_t client );
  659. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  660. /*
  661. * IORegistry accessors
  662. */
  663. /*! @function IORegistryGetRootEntry
  664. @abstract Return a handle to the registry root.
  665. @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.
  666. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  667. @result A handle to the IORegistryEntry root instance, to be released with IOObjectRelease by the caller, or MACH_PORT_NULL on failure. */
  668. io_registry_entry_t
  669. IORegistryGetRootEntry(
  670. mach_port_t masterPort );
  671. /*! @function IORegistryEntryFromPath
  672. @abstract Looks up a registry entry by path.
  673. @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.h
  674. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  675. @param path A C-string path.
  676. @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. */
  677. io_registry_entry_t
  678. IORegistryEntryFromPath(
  679. mach_port_t masterPort,
  680. const io_string_t path );
  681. // options for IORegistryCreateIterator(), IORegistryEntryCreateIterator, IORegistryEntrySearchCFProperty()
  682. enum {
  683. kIORegistryIterateRecursively = 0x00000001,
  684. kIORegistryIterateParents = 0x00000002
  685. };
  686. /*! @function IORegistryCreateIterator
  687. @abstract Create an iterator rooted at the registry root.
  688. @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.
  689. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  690. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  691. @param options kIORegistryIterateRecursively may be set to recurse automatically into each entry as it is returned from IOIteratorNext calls on the registry iterator.
  692. @param iterator A created iterator handle, to be released by the caller when it has finished with it.
  693. @result A kern_return_t error code. */
  694. kern_return_t
  695. IORegistryCreateIterator(
  696. mach_port_t masterPort,
  697. const io_name_t plane,
  698. IOOptionBits options,
  699. io_iterator_t * iterator );
  700. /*! @function IORegistryEntryCreateIterator
  701. @abstract Create an iterator rooted at a given registry entry.
  702. @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.
  703. @param entry The root entry to begin the iteration at.
  704. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  705. @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.
  706. @param iterator A created iterator handle, to be released by the caller when it has finished with it.
  707. @result A kern_return_t error code. */
  708. kern_return_t
  709. IORegistryEntryCreateIterator(
  710. io_registry_entry_t entry,
  711. const io_name_t plane,
  712. IOOptionBits options,
  713. io_iterator_t * iterator );
  714. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  715. /*
  716. * IORegistryIterator, subclass of IOIterator
  717. */
  718. /*! @function IORegistryIteratorEnterEntry
  719. @abstract Recurse into the current entry in the registry iteration.
  720. @discussion This method makes the current entry, ie. the last entry returned by IOIteratorNext, the root in a new level of recursion.
  721. @result A kern_return_t error code. */
  722. kern_return_t
  723. IORegistryIteratorEnterEntry(
  724. io_iterator_t iterator );
  725. /*! @function IORegistryIteratorExitEntry
  726. @abstract Exits a level of recursion, restoring the current entry.
  727. @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.
  728. @result kIOReturnSuccess if a level of recursion was undone, kIOReturnNoDevice if no recursive levels are left in the iteration. */
  729. kern_return_t
  730. IORegistryIteratorExitEntry(
  731. io_iterator_t iterator );
  732. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  733. /*
  734. * IORegistryEntry, subclass of IOObject
  735. */
  736. /*! @function IORegistryEntryGetName
  737. @abstract Returns a C-string name assigned to a registry entry.
  738. @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.
  739. @param entry The registry entry handle whose name to look up.
  740. @param name The caller's buffer to receive the name.
  741. @result A kern_return_t error code. */
  742. kern_return_t
  743. IORegistryEntryGetName(
  744. io_registry_entry_t entry,
  745. io_name_t name );
  746. /*! @function IORegistryEntryGetNameInPlane
  747. @abstract Returns a C-string name assigned to a registry entry, in a specified plane.
  748. @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.
  749. @param entry The registry entry handle whose name to look up.
  750. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  751. @param name The caller's buffer to receive the name.
  752. @result A kern_return_t error code. */
  753. kern_return_t
  754. IORegistryEntryGetNameInPlane(
  755. io_registry_entry_t entry,
  756. const io_name_t plane,
  757. io_name_t name );
  758. /*! @function IORegistryEntryGetLocationInPlane
  759. @abstract Returns a C-string location assigned to a registry entry, in a specified plane.
  760. @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.
  761. @param entry The registry entry handle whose name to look up.
  762. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  763. @param location The caller's buffer to receive the location string.
  764. @result A kern_return_t error code. */
  765. kern_return_t
  766. IORegistryEntryGetLocationInPlane(
  767. io_registry_entry_t entry,
  768. const io_name_t plane,
  769. io_name_t location );
  770. /*! @function IORegistryEntryGetPath
  771. @abstract Create a path for a registry entry.
  772. @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.
  773. @param entry The registry entry handle whose path to look up.
  774. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  775. @param path A char buffer allocated by the caller.
  776. @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. */
  777. kern_return_t
  778. IORegistryEntryGetPath(
  779. io_registry_entry_t entry,
  780. const io_name_t plane,
  781. io_string_t path );
  782. /*! @function IORegistryEntryCreateCFProperties
  783. @abstract Create a CF dictionary representation of a registry entry's property table.
  784. @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.
  785. @param entry The registry entry handle whose property table to copy.
  786. @param properties A CFDictionary is created and returned the caller on success. The caller should release with CFRelease.
  787. @param allocator The CF allocator to use when creating the CF containers.
  788. @param options No options are currently defined.
  789. @result A kern_return_t error code. */
  790. kern_return_t
  791. IORegistryEntryCreateCFProperties(
  792. io_registry_entry_t entry,
  793. CFMutableDictionaryRef * properties,
  794. CFAllocatorRef allocator,
  795. IOOptionBits options );
  796. /*! @function IORegistryEntryCreateCFProperty
  797. @abstract Create a CF representation of a registry entry's property.
  798. @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.
  799. @param entry The registry entry handle whose property to copy.
  800. @param key A CFString specifying the property name.
  801. @param allocator The CF allocator to use when creating the CF container.
  802. @param options No options are currently defined.
  803. @result A CF container is created and returned the caller on success. The caller should release with CFRelease. */
  804. CFTypeRef
  805. IORegistryEntryCreateCFProperty(
  806. io_registry_entry_t entry,
  807. CFStringRef key,
  808. CFAllocatorRef allocator,
  809. IOOptionBits options );
  810. /*! @function IORegistryEntrySearchCFProperty
  811. @abstract Create a CF representation of a registry entry's property.
  812. @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.
  813. This 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.
  814. @param entry The registry entry at which to start the search.
  815. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  816. @param key A CFString specifying the property name.
  817. @param allocator The CF allocator to use when creating the CF container.
  818. @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.
  819. @result A CF container is created and returned the caller on success. The caller should release with CFRelease. */
  820. CFTypeRef
  821. IORegistryEntrySearchCFProperty(
  822. io_registry_entry_t entry,
  823. const io_name_t plane,
  824. CFStringRef key,
  825. CFAllocatorRef allocator,
  826. IOOptionBits options );
  827. /* @function IORegistryEntryGetProperty - deprecated,
  828. use IORegistryEntryCreateCFProperty */
  829. kern_return_t
  830. IORegistryEntryGetProperty(
  831. io_registry_entry_t entry,
  832. const io_name_t propertyName,
  833. io_struct_inband_t buffer,
  834. uint32_t * size );
  835. /*! @function IORegistryEntrySetCFProperties
  836. @abstract Set CF container based properties in a registry entry.
  837. @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.
  838. @param entry The registry entry whose properties to set.
  839. @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.
  840. @result A kern_return_t error code returned by the object. */
  841. kern_return_t
  842. IORegistryEntrySetCFProperties(
  843. io_registry_entry_t entry,
  844. CFTypeRef properties );
  845. /*! @function IORegistryEntrySetCFProperty
  846. @abstract Set a CF container based property in a registry entry.
  847. @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.
  848. @param entry The registry entry whose property to set.
  849. @param propertyName The name of the property as a CFString.
  850. @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.
  851. @result A kern_return_t error code returned by the object. */
  852. kern_return_t
  853. IORegistryEntrySetCFProperty(
  854. io_registry_entry_t entry,
  855. CFStringRef propertyName,
  856. CFTypeRef property );
  857. /*! @function IORegistryEntryGetChildIterator
  858. @abstract Returns an iterator over an registry entry's child entries in a plane.
  859. @discussion This method creates an iterator which will return each of a registry entry's child entries in a specified plane.
  860. @param entry The registry entry whose children to iterate over.
  861. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  862. @param iterator The created iterator over the children of the entry, on success. The iterator must be released when the iteration is finished.
  863. @result A kern_return_t error code. */
  864. kern_return_t
  865. IORegistryEntryGetChildIterator(
  866. io_registry_entry_t entry,
  867. const io_name_t plane,
  868. io_iterator_t * iterator );
  869. /*! @function IORegistryEntryGetChildEntry
  870. @abstract Returns the first child of a registry entry in a plane.
  871. @discussion This function will return the child which first attached to a registry entry in a plane.
  872. @param entry The registry entry whose child to look up.
  873. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  874. @param child The first child of the registry entry, on success. The child must be released by the caller.
  875. @result A kern_return_t error code. */
  876. kern_return_t
  877. IORegistryEntryGetChildEntry(
  878. io_registry_entry_t entry,
  879. const io_name_t plane,
  880. io_registry_entry_t * child );
  881. /*! @function IORegistryEntryGetParentIterator
  882. @abstract Returns an iterator over an registry entry's parent entries in a plane.
  883. @discussion This method creates an iterator which will return each of a registry entry's parent entries in a specified plane.
  884. @param entry The registry entry whose parents to iterate over.
  885. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  886. @param iterator The created iterator over the parents of the entry, on success. The iterator must be released when the iteration is finished.
  887. @result A kern_return_t error. */
  888. kern_return_t
  889. IORegistryEntryGetParentIterator(
  890. io_registry_entry_t entry,
  891. const io_name_t plane,
  892. io_iterator_t * iterator );
  893. /*! @function IORegistryEntryGetParentEntry
  894. @abstract Returns the first parent of a registry entry in a plane.
  895. @discussion This function will return the parent to which the registry entry was first attached in a plane.
  896. @param entry The registry entry whose parent to look up.
  897. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  898. @param child The first parent of the registry entry, on success. The parent must be released by the caller.
  899. @result A kern_return_t error code. */
  900. kern_return_t
  901. IORegistryEntryGetParentEntry(
  902. io_registry_entry_t entry,
  903. const io_name_t plane,
  904. io_registry_entry_t * parent );
  905. /*! @function IORegistryEntryInPlane
  906. @abstract Determines if the registry entry is attached in a plane.
  907. @discussion This method determines if the entry is attached in a plane to any other entry.
  908. @param entry The registry entry.
  909. @param plane The name of an existing registry plane. Plane names are defined in IOKitKeys.h, eg. kIOServicePlane.
  910. @result If the entry has a parent in the plane, true is returned, otherwise false is returned. */
  911. boolean_t
  912. IORegistryEntryInPlane(
  913. io_registry_entry_t entry,
  914. const io_name_t plane );
  915. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  916. /*
  917. * Matching dictionary creation helpers
  918. */
  919. /*! @function IOServiceMatching
  920. @abstract Create a matching dictionary that specifies an IOService class match.
  921. @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.
  922. @param name The class name, as a const C-string. Class matching is successful on IOService's of this class or any subclass.
  923. @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. */
  924. CFMutableDictionaryRef
  925. IOServiceMatching(
  926. const char * name );
  927. /*! @function IOServiceNameMatching
  928. @abstract Create a matching dictionary that specifies an IOService name match.
  929. @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 OpenFirmware device tree will perform name matching on the standard OF compatible, name, model properties.
  930. @param name The IOService name, as a const C-string.
  931. @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. */
  932. CFMutableDictionaryRef
  933. IOServiceNameMatching(
  934. const char * name );
  935. /*! @function IOBSDNameMatching
  936. @abstract Create a matching dictionary that specifies an IOService match based on BSD device name.
  937. @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.
  938. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  939. @param options No options are currently defined.
  940. @param bsdName The BSD name, as a const char *.
  941. @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. */
  942. CFMutableDictionaryRef
  943. IOBSDNameMatching(
  944. mach_port_t masterPort,
  945. uint32_t options,
  946. const char * bsdName );
  947. /*! @function IOOpenFirmwarePathMatching
  948. @abstract Create a matching dictionary that specifies an IOService match based on an OpenFirmware device path.
  949. @discussion Certain IOServices (currently, block and ethernet boot devices) may be looked up by a path that specifies their location in the OpenFirmware device tree, represented in the registry by the kIODeviceTreePlane plane. This function creates a matching dictionary that will match IOService's found with a given OpenFirmware device path.
  950. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  951. @param options No options are currently defined.
  952. @param path The OpenFirmware device path, as a const char *.
  953. @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. */
  954. CFMutableDictionaryRef
  955. IOOpenFirmwarePathMatching(
  956. mach_port_t masterPort,
  957. uint32_t options,
  958. const char * path );
  959. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  960. /*! @function IOServiceOFPathToBSDName
  961. @abstract Utility to look up an IOService from its OpenFirmware device path, and return its BSD device name if available.
  962. @discussion Certain IOServices (currently, block and ethernet boot devices) may be looked up by a path that specifies their location in the OpenFirmware device tree, represented in the registry by the kIODeviceTreePlane plane. This function looks up an IOService object with a given OpenFirmware device path, and returns its associated BSD device name.
  963. @param masterPort The master port obtained from IOMasterPort(). Pass kIOMasterPortDefault to look up the default master port.
  964. @param openFirmwarePath The OpenFirmware device path, as a const char *.
  965. @param bsdName The BSD name, as a const char *, is copied to the callers buffer.
  966. @result A kern_return_t error code. */
  967. kern_return_t
  968. IOServiceOFPathToBSDName(mach_port_t masterPort,
  969. const io_name_t openFirmwarePath,
  970. io_name_t bsdName);
  971. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  972. /*! @typedef IOAsyncCallback0
  973. @abstract standard callback function for asynchronous I/O requests with
  974. no extra arguments beyond a refcon and result code.
  975. @param refcon The refcon passed into the original I/O request
  976. @param result The result of the I/O operation
  977. */
  978. typedef void (*IOAsyncCallback0)(void *refcon, IOReturn result);
  979. /*! @typedef IOAsyncCallback1
  980. @abstract standard callback function for asynchronous I/O requests with
  981. one extra argument beyond a refcon and result code.
  982. This is often a count of the number of bytes transferred
  983. @param refcon The refcon passed into the original I/O request
  984. @param result The result of the I/O operation
  985. @param arg0 Extra argument
  986. */
  987. typedef void (*IOAsyncCallback1)(void *refcon, IOReturn result, void *arg0);
  988. /*! @typedef IOAsyncCallback2
  989. @abstract standard callback function for asynchronous I/O requests with
  990. two extra arguments beyond a refcon and result code.
  991. @param refcon The refcon passed into the original I/O request
  992. @param result The result of the I/O operation
  993. @param arg0 Extra argument
  994. @param arg1 Extra argument
  995. */
  996. typedef void (*IOAsyncCallback2)(void *refcon, IOReturn result, void *arg0, void *arg1);
  997. /*! @typedef IOAsyncCallback
  998. @abstract standard callback function for asynchronous I/O requests with
  999. lots of extra arguments beyond a refcon and result code.
  1000. @param refcon The refcon passed into the original I/O request
  1001. @param result The result of the I/O operation
  1002. @param args Array of extra arguments
  1003. @param numArgs Number of extra arguments
  1004. */
  1005. typedef void (*IOAsyncCallback)(void *refcon, IOReturn result, void **args,
  1006. uint32_t numArgs);
  1007. /* Internal use */
  1008. kern_return_t
  1009. OSGetNotificationFromMessage(
  1010. mach_msg_header_t * msg,
  1011. uint32_t index,
  1012. uint32_t * type,
  1013. uintptr_t * reference,
  1014. void ** content,
  1015. vm_size_t * size );
  1016. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1017. /* Internal use */
  1018. kern_return_t
  1019. IOCatalogueSendData(
  1020. mach_port_t masterPort,
  1021. uint32_t flag,
  1022. const char *buffer,
  1023. uint32_t size );
  1024. kern_return_t
  1025. IOCatalogueTerminate(
  1026. mach_port_t masterPort,
  1027. uint32_t flag,
  1028. io_name_t description );
  1029. kern_return_t
  1030. IOCatalogueGetData(
  1031. mach_port_t masterPort,
  1032. uint32_t flag,
  1033. char **buffer,
  1034. uint32_t *size );
  1035. kern_return_t
  1036. IOCatalogueModuleLoaded(
  1037. mach_port_t masterPort,
  1038. io_name_t name );
  1039. kern_return_t
  1040. IOCatalogueReset(
  1041. mach_port_t masterPort,
  1042. uint32_t flag );
  1043. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1044. // obsolete API
  1045. #if !defined(__LP64__)
  1046. // for Power Mgt
  1047. typedef struct IOObject IOObject;
  1048. // for MacOS.app
  1049. kern_return_t
  1050. IORegistryDisposeEnumerator(
  1051. io_enumerator_t enumerator ) DEPRECATED_ATTRIBUTE;
  1052. kern_return_t
  1053. IOMapMemory(
  1054. io_connect_t connect,
  1055. uint32_t memoryType,
  1056. task_port_t intoTask,
  1057. vm_address_t * atAddress,
  1058. vm_size_t * ofSize,
  1059. uint32_t flags ) DEPRECATED_ATTRIBUTE;
  1060. // for CGS
  1061. kern_return_t
  1062. IOCompatibiltyNumber(
  1063. mach_port_t connect,
  1064. uint32_t * objectNumber ) DEPRECATED_ATTRIBUTE;
  1065. // Traditional IOUserClient transport routines
  1066. kern_return_t
  1067. IOConnectMethodScalarIScalarO(
  1068. io_connect_t connect,
  1069. uint32_t index,
  1070. IOItemCount scalarInputCount,
  1071. IOItemCount scalarOutputCount,
  1072. ... ) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;
  1073. kern_return_t
  1074. IOConnectMethodScalarIStructureO(
  1075. io_connect_t connect,
  1076. uint32_t index,
  1077. IOItemCount scalarInputCount,
  1078. IOByteCount * structureSize,
  1079. ... ) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;
  1080. kern_return_t
  1081. IOConnectMethodScalarIStructureI(
  1082. io_connect_t connect,
  1083. uint32_t index,
  1084. IOItemCount scalarInputCount,
  1085. IOByteCount structureSize,
  1086. ... ) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;
  1087. kern_return_t
  1088. IOConnectMethodStructureIStructureO(
  1089. io_connect_t connect,
  1090. uint32_t index,
  1091. IOItemCount structureInputSize,
  1092. IOByteCount * structureOutputSize,
  1093. void * inputStructure,
  1094. void * ouputStructure ) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;
  1095. // Compatability with earlier Mig interface routines
  1096. #if IOCONNECT_NO_32B_METHODS
  1097. kern_return_t
  1098. io_connect_map_memory(
  1099. io_connect_t connect,
  1100. uint32_t memoryType,
  1101. task_port_t intoTask,
  1102. vm_address_t *atAddress,
  1103. vm_size_t *ofSize,
  1104. IOOptionBits options) DEPRECATED_ATTRIBUTE;
  1105. kern_return_t
  1106. io_connect_unmap_memory(
  1107. io_connect_t connect,
  1108. uint32_t memoryType,
  1109. task_port_t fromTask,
  1110. vm_address_t atAddress) DEPRECATED_ATTRIBUTE;
  1111. kern_return_t
  1112. io_connect_method_scalarI_scalarO(
  1113. mach_port_t connection,
  1114. int selector,
  1115. io_scalar_inband_t input,
  1116. mach_msg_type_number_t inputCnt,
  1117. io_scalar_inband_t output,
  1118. mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;
  1119. kern_return_t
  1120. io_connect_method_scalarI_structureO(
  1121. mach_port_t connection,
  1122. int selector,
  1123. io_scalar_inband_t input,
  1124. mach_msg_type_number_t inputCnt,
  1125. io_struct_inband_t output,
  1126. mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;
  1127. kern_return_t
  1128. io_connect_method_scalarI_structureI(
  1129. mach_port_t connection,
  1130. int selector,
  1131. io_scalar_inband_t input,
  1132. mach_msg_type_number_t inputCnt,
  1133. io_struct_inband_t inputStruct,
  1134. mach_msg_type_number_t inputStructCnt) DEPRECATED_ATTRIBUTE;
  1135. kern_return_t
  1136. io_connect_method_structureI_structureO(
  1137. mach_port_t connection,
  1138. int selector,
  1139. io_struct_inband_t input,
  1140. mach_msg_type_number_t inputCnt,
  1141. io_struct_inband_t output,
  1142. mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;
  1143. kern_return_t
  1144. io_async_method_scalarI_scalarO(
  1145. mach_port_t connection,
  1146. mach_port_t wake_port,
  1147. io_async_ref_t reference,
  1148. mach_msg_type_number_t referenceCnt,
  1149. int selector,
  1150. io_scalar_inband_t input,
  1151. mach_msg_type_number_t inputCnt,
  1152. io_scalar_inband_t output,
  1153. mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;
  1154. kern_return_t
  1155. io_async_method_scalarI_structureO(
  1156. mach_port_t connection,
  1157. mach_port_t wake_port,
  1158. io_async_ref_t reference,
  1159. mach_msg_type_number_t referenceCnt,
  1160. int selector,
  1161. io_scalar_inband_t input,
  1162. mach_msg_type_number_t inputCnt,
  1163. io_struct_inband_t output,
  1164. mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;
  1165. kern_return_t
  1166. io_async_method_scalarI_structureI(
  1167. mach_port_t connection,
  1168. mach_port_t wake_port,
  1169. io_async_ref_t reference,
  1170. mach_msg_type_number_t referenceCnt,
  1171. int selector,
  1172. io_scalar_inband_t input,
  1173. mach_msg_type_number_t inputCnt,
  1174. io_struct_inband_t inputStruct,
  1175. mach_msg_type_number_t inputStructCnt) DEPRECATED_ATTRIBUTE;
  1176. kern_return_t
  1177. io_async_method_structureI_structureO(
  1178. mach_port_t connection,
  1179. mach_port_t wake_port,
  1180. io_async_ref_t reference,
  1181. mach_msg_type_number_t referenceCnt,
  1182. int selector,
  1183. io_struct_inband_t input,
  1184. mach_msg_type_number_t inputCnt,
  1185. io_struct_inband_t output,
  1186. mach_msg_type_number_t *outputCnt) DEPRECATED_ATTRIBUTE;
  1187. #endif // IOCONNECT_NO_32B_METHODS
  1188. #endif /* defined(__LP64__) */
  1189. __END_DECLS
  1190. #endif /* ! _IOKIT_IOKITLIB_H */