]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOService.h
xnu-792.22.5.tar.gz
[apple/xnu.git] / iokit / IOKit / IOService.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * Copyright (c) 1998,1999 Apple Computer, Inc. All rights reserved.
30 *
31 * HISTORY
32 *
33 */
34
35
36 #ifndef _IOKIT_IOSERVICE_H
37 #define _IOKIT_IOSERVICE_H
38
39 #include <IOKit/IORegistryEntry.h>
40 #include <IOKit/IOReturn.h>
41 #include <IOKit/IODeviceMemory.h>
42 #include <IOKit/IONotifier.h>
43 #include <IOKit/IOLocks.h>
44
45 #include <IOKit/IOKitDebug.h>
46 #include <IOKit/IOInterrupts.h>
47
48 class IOPMinformee;
49 class IOPowerConnection;
50
51 #include <IOKit/pwr_mgt/IOPMpowerState.h>
52 #include <IOKit/IOServicePM.h>
53
54 extern "C" {
55 #include <kern/thread_call.h>
56 }
57
58 enum {
59 kIODefaultProbeScore = 0
60 };
61
62 // masks for getState()
63 enum {
64 kIOServiceInactiveState = 0x00000001,
65 kIOServiceRegisteredState = 0x00000002,
66 kIOServiceMatchedState = 0x00000004,
67 kIOServiceFirstPublishState = 0x00000008,
68 kIOServiceFirstMatchState = 0x00000010
69 };
70
71 enum {
72 // options for registerService()
73 kIOServiceExclusive = 0x00000001,
74
75 // options for terminate()
76 kIOServiceRequired = 0x00000001,
77 kIOServiceTerminate = 0x00000004,
78
79 // options for registerService() & terminate()
80 kIOServiceSynchronous = 0x00000002,
81 // options for registerService()
82 kIOServiceAsynchronous = 0x00000008
83 };
84
85 // options for open()
86 enum {
87 kIOServiceSeize = 0x00000001,
88 kIOServiceFamilyOpenOptions = 0xffff0000
89 };
90
91 // options for close()
92 enum {
93 kIOServiceFamilyCloseOptions = 0xffff0000
94 };
95
96 typedef void * IONotificationRef;
97
98 extern const IORegistryPlane * gIOServicePlane;
99 extern const IORegistryPlane * gIOPowerPlane;
100
101 extern const OSSymbol * gIOResourcesKey;
102 extern const OSSymbol * gIOResourceMatchKey;
103 extern const OSSymbol * gIOProviderClassKey;
104 extern const OSSymbol * gIONameMatchKey;
105 extern const OSSymbol * gIONameMatchedKey;
106 extern const OSSymbol * gIOPropertyMatchKey;
107 extern const OSSymbol * gIOLocationMatchKey;
108 extern const OSSymbol * gIOParentMatchKey;
109 extern const OSSymbol * gIOPathMatchKey;
110 extern const OSSymbol * gIOMatchCategoryKey;
111 extern const OSSymbol * gIODefaultMatchCategoryKey;
112 extern const OSSymbol * gIOMatchedServiceCountKey;
113
114 extern const OSSymbol * gIOUserClientClassKey;
115 extern const OSSymbol * gIOKitDebugKey;
116 extern const OSSymbol * gIOServiceKey;
117
118 extern const OSSymbol * gIOCommandPoolSizeKey;
119
120 extern const OSSymbol * gIOPublishNotification;
121 extern const OSSymbol * gIOFirstPublishNotification;
122 extern const OSSymbol * gIOMatchedNotification;
123 extern const OSSymbol * gIOFirstMatchNotification;
124 extern const OSSymbol * gIOTerminatedNotification;
125
126 extern const OSSymbol * gIOGeneralInterest;
127 extern const OSSymbol * gIOBusyInterest;
128 extern const OSSymbol * gIOOpenInterest;
129 extern const OSSymbol * gIOAppPowerStateInterest;
130 extern const OSSymbol * gIOPriorityPowerStateInterest;
131
132 extern const OSSymbol * gIODeviceMemoryKey;
133 extern const OSSymbol * gIOInterruptControllersKey;
134 extern const OSSymbol * gIOInterruptSpecifiersKey;
135
136 extern SInt32 IOServiceOrdering( const OSMetaClassBase * inObj1, const OSMetaClassBase * inObj2, void * ref );
137
138 typedef void (*IOInterruptAction)( OSObject * target, void * refCon,
139 IOService * nub, int source );
140
141 /*! @typedef IOServiceNotificationHandler
142 @param target Reference supplied when the notification was registered.
143 @param refCon Reference constant supplied when the notification was registered.
144 @param newService The IOService object the notification is delivering. It is retained for the duration of the handler's invocation and doesn't need to be released by the handler. */
145
146 typedef bool (*IOServiceNotificationHandler)( void * target, void * refCon,
147 IOService * newService );
148
149 /*! @typedef IOServiceInterestHandler
150 @param target Reference supplied when the notification was registered.
151 @param refCon Reference constant supplied when the notification was registered.
152 @param messageType Type of the message - IOKit defined in IOKit/IOMessage.h or family specific.
153 @param provider The IOService object who is delivering the notification. It is retained for the duration of the handler's invocation and doesn't need to be released by the handler.
154 @param messageArgument An argument for message, dependent on its type.
155 @param argSize Non zero if the argument represents a struct of that size, used when delivering messages outside the kernel. */
156
157 typedef IOReturn (*IOServiceInterestHandler)( void * target, void * refCon,
158 UInt32 messageType, IOService * provider,
159 void * messageArgument, vm_size_t argSize );
160
161 typedef void (*IOServiceApplierFunction)(IOService * service, void * context);
162 typedef void (*OSObjectApplierFunction)(OSObject * object, void * context);
163
164 class IOUserClient;
165 class IOPlatformExpert;
166
167 /*! @class IOService : public IORegistryEntry
168 @abstract The base class for most families, devices and drivers.
169 @discussion The IOService base class defines APIs used to publish services, instantiate other services based on the existance of a providing service (ie. driver stacking), destroy a service and its dependent stack, notify interested parties of service state changes, and general utility functions useful across all families.
170
171 Types of service are specified with a matching dictionary that describes properties of the service. For example, a matching dictionary might describe any IOUSBDevice (or subclass), an IOUSBDevice with a certain class code, or a IOPCIDevice with a set of OpenFirmware matching names or device & vendor IDs. Since the matching dictionary is interpreted by the family which created the service, as well as generically by IOService, the list of properties considered for matching depends on the familiy.
172
173 Matching dictionaries are associated with IOService classes by the catalogue, as driver property tables, and also supplied by clients of the notification APIs.
174
175 IOService provides matching based on c++ class (via OSMetaClass dynamic casting), registry entry name, a registry path to the service (which includes OpenFirmware paths), a name assigned by BSD, or by its location (its point of attachment).
176
177 <br><br>Driver Instantiation by IOService<br><br>
178
179 Drivers are subclasses of IOService, and their availability is managed through the catalogue. They are instantiated based on the publication of an IOService they use (for example, an IOPCIDevice or IOUSBDevice), or when they are added to the catalogue and the IOService(s) they use are already available.
180
181 When an IOService (the "provider") is published with the registerService() method, the matching and probing process begins, which is always single threaded per provider. A list of matching dictionaries from the catalog and installed publish notification requests, that successfully match the IOService, is constructed, with ordering supplied by kIOProbeScoreKey ("IOProbeScore") property in the dictionary, or supplied with the notification.
182
183 Each entry in the list is then processed in order - for notifications, the notification is delivered, for driver property tables a lot more happens.
184
185 The driver class is instantiated and init() called with its property table. The new driver instance is then attached to the provider, and has its probe() method called with the provider as an argument. The default probe method does nothing but return success, but a driver may implement this method to interrogate the provider to make sure it can work with it. It may also modify its probe score at this time. After probe, the driver is detached and the next in the list is considered (ie. attached, probed, and detached).
186
187 When the probing phase is complete, the list consists of successfully probed drivers, in order of their probe score (after adjustment during the probe() call). The list is then divided into categories based on the kIOMatchCategoryKey property ("IOMatchCategory"); drivers without a match category are all considered in one default category. Match categories allow multiple clients of a provider to be attached and started, though the provider may also enforce open/close semantics to gain active access to it.
188
189 For each category, the highest scoring driver in that category is attached to the provider, and its start() method called. If start() is successful, the rest of the drivers in the same match category are discarded, otherwise the next highest scoring driver is started, and so one.
190
191 The driver should only consider itself in action when the start method is called, meaning it has been selected for use on the provider, and consuming that particular match category. It should also be prepared to be allocated, probed and freed even if the probe was sucessful.
192
193 After the drivers have all synchronously been started, the installed "matched" notifications that match the registered IOService are delivered.
194
195 <br><br>Properties used by IOService<br><br>
196
197 kIOClassKey, extern const OSSymbol * gIOClassKey, "IOClass"
198 <br>
199 Class of the driver to instantiate on matching providers.
200 <br>
201 <br>
202 kIOProviderClassKey, extern const OSSymbol * gIOProviderClassKey, "IOProviderClass"
203 <br>
204 Class of the provider(s) to be considered for matching, checked with OSDynamicCast so subclasses will also match.
205 <br>
206 <br>
207 kIOProbeScoreKey, extern const OSSymbol * gIOProbeScoreKey, "IOProbeScore"
208 <br>
209 The probe score initially used to order multiple matching drivers.
210 <br>
211 <br>
212 kIOMatchCategoryKey, extern const OSSymbol * gIOMatchCategoryKey, "IOMatchCategory"
213 <br>
214 A string defining the driver category for matching purposes. All drivers with no IOMatchCategory property are considered to be in the same default category. Only one driver in a category can be started on each provider.
215 <br>
216 <br>
217 kIONameMatchKey, extern const OSSymbol * gIONameMatchKey, "IONameMatch"
218 <br>
219 A string or collection of strings that match the provider's name. The comparison is implemented with the IORegistryEntry::compareNames method, which supports a single string, or any collection (OSArray, OSSet, OSDictionary etc.) of strings. IOService objects with OpenFirmware device tree properties (eg. IOPCIDevice) will also be matched based on that standard's "compatible", "name", "device_type" properties. The matching name will be left in the driver's property table in the kIONameMatchedKey property.
220 <br>
221 Examples
222 <br>
223 &ltkey&gtIONameMatch&lt/key&gt <br>
224 &ltstring&gtpci106b,7&ltstring&gt
225 <br>
226 For a list of possible matching names, a serialized array of strings should used, eg.
227 <br>
228 &ltkey&gtIONameMatch&lt/key&gt <br>
229 &ltarray&gt <br>
230 &ltstring&gtAPPL,happy16&lt/string&gt <br>
231 &ltstring&gtpci106b,7&lt/string&gt <br>
232 &lt/array&gt
233 <br>
234 <br>
235 kIONameMatchedKey, extern const OSSymbol * gIONameMatchedKey, "IONameMatched"
236 <br>
237 The name successfully matched name from the kIONameMatchKey property will be left in the driver's property table as the kIONameMatchedKey property.
238 <br>
239 <br>
240 kIOPropertyMatchKey, extern const OSSymbol * gIOPropertyMatchKey, "IOPropertyMatch"
241 <br>
242 A dictionary of properties that each must exist in the matching IOService and compare sucessfully with the isEqualTo method.
243 &ltkey&gtIOPropertyMatch&lt/key&gt <br>
244 &ltdictionary&gt <br>
245 &ltkey&gtname&lt/key&gt <br>
246 &ltstring&gtAPPL,meek8&lt/string&gt <br>
247 &lt/dictionary&gt
248 <br>
249 <br>
250 kIOUserClientClassKey, extern const OSSymbol * gIOUserClientClassKey, "IOUserClientClass"
251 <br>
252 The class name that the service will attempt to allocate when a user client connection is requested. First the device nub is queried, then the nub's provider is queried by default.
253 <br>
254 <br>
255 kIOKitDebugKey, extern const OSSymbol * gIOKitDebugKey, "IOKitDebug"
256 <br>
257 Set some debug flags for logging the driver loading process. Flags are defined in IOKit/IOKitDebug.h, but 65535 works well.
258
259 */
260
261 class IOService : public IORegistryEntry
262 {
263 OSDeclareDefaultStructors(IOService)
264
265 protected:
266 /*! @struct ExpansionData
267 @discussion This structure will be used to expand the capablilties of this class in the future.
268 */
269 struct ExpansionData { };
270
271 /*! @var reserved
272 Reserved for future use. (Internal use only) */
273 ExpansionData * reserved;
274
275 private:
276 IOService * __provider;
277 SInt32 __providerGeneration;
278 IOService * __owner;
279 IOOptionBits __state[2];
280 IOOptionBits __reserved[4];
281
282 // pointer to private instance variables for power management
283 IOPMpriv * priv;
284
285 protected:
286 // TRUE once PMinit has been called
287 bool initialized;
288
289 public:
290 // pointer to protected instance variables for power management
291 IOPMprot * pm_vars;
292
293 public:
294 /* methods available in Mac OS X 10.1 or later */
295 /*! @function requestTerminate
296 @abstract Passes a termination up the stack.
297 @discussion When an IOService is made inactive the default behaviour is to also make any of its clients that have it as their only provider also inactive, in this way recursing the termination up the driver stack. This method allows an IOService object to override this behaviour. Returning true from this method when passed a just terminated provider will cause the client to also be terminated.
298 @param provider The terminated provider of this object.
299 @param options Options originally passed to terminate, plus kIOServiceRecursing.
300 @result true if this object should be terminated now that its provider as been. */
301
302 virtual bool requestTerminate( IOService * provider, IOOptionBits options );
303
304 /*! @function willTerminate
305 @abstract Passes a termination up the stack.
306 @discussion Notification that a provider has been terminated, sent before recursing up the stack, in root-to-leaf order.
307 @param provider The terminated provider of this object.
308 @param options Options originally passed to terminate.
309 @result true return true. */
310
311 virtual bool willTerminate( IOService * provider, IOOptionBits options );
312
313 /*! @function didTerminate
314 @abstract Passes a termination up the stack.
315 @discussion Notification that a provider has been terminated, sent after recursing up the stack, in leaf-to-root order.
316 @param provider The terminated provider of this object.
317 @param options Options originally passed to terminate.
318 @param defer If there is pending I/O that requires this object to persist, and the provider is not opened by this object set defer to true and call the IOService::didTerminate() implementation when the I/O completes. Otherwise, leave defer set to its default value of false.
319 @result true return true. */
320
321 virtual bool didTerminate( IOService * provider, IOOptionBits options, bool * defer );
322
323 /* method available in Mac OS X 10.4 or later */
324 /*! @function nextIdleTimeout
325 @abstract Allows subclasses to customize idle power management behavior.
326 @discussion Returns the next time that the device should idle into its next lower power state. Subclasses may override for custom idle behavior.
327 @param currentTime The current time
328 @param lastActivity The time of last activity on this device
329 @param powerState The device's current power state.
330 @result Returns the next time the device should idle off (in seconds, relative to the current time). */
331
332 virtual SInt32 nextIdleTimeout(AbsoluteTime currentTime,
333 AbsoluteTime lastActivity, unsigned int powerState);
334
335 private:
336 OSMetaClassDeclareReservedUsed(IOService, 0);
337 OSMetaClassDeclareReservedUsed(IOService, 1);
338 OSMetaClassDeclareReservedUsed(IOService, 2);
339 OSMetaClassDeclareReservedUsed(IOService, 3);
340
341 OSMetaClassDeclareReservedUnused(IOService, 4);
342 OSMetaClassDeclareReservedUnused(IOService, 5);
343 OSMetaClassDeclareReservedUnused(IOService, 6);
344 OSMetaClassDeclareReservedUnused(IOService, 7);
345 OSMetaClassDeclareReservedUnused(IOService, 8);
346 OSMetaClassDeclareReservedUnused(IOService, 9);
347 OSMetaClassDeclareReservedUnused(IOService, 10);
348 OSMetaClassDeclareReservedUnused(IOService, 11);
349 OSMetaClassDeclareReservedUnused(IOService, 12);
350 OSMetaClassDeclareReservedUnused(IOService, 13);
351 OSMetaClassDeclareReservedUnused(IOService, 14);
352 OSMetaClassDeclareReservedUnused(IOService, 15);
353 OSMetaClassDeclareReservedUnused(IOService, 16);
354 OSMetaClassDeclareReservedUnused(IOService, 17);
355 OSMetaClassDeclareReservedUnused(IOService, 18);
356 OSMetaClassDeclareReservedUnused(IOService, 19);
357 OSMetaClassDeclareReservedUnused(IOService, 20);
358 OSMetaClassDeclareReservedUnused(IOService, 21);
359 OSMetaClassDeclareReservedUnused(IOService, 22);
360 OSMetaClassDeclareReservedUnused(IOService, 23);
361 OSMetaClassDeclareReservedUnused(IOService, 24);
362 OSMetaClassDeclareReservedUnused(IOService, 25);
363 OSMetaClassDeclareReservedUnused(IOService, 26);
364 OSMetaClassDeclareReservedUnused(IOService, 27);
365 OSMetaClassDeclareReservedUnused(IOService, 28);
366 OSMetaClassDeclareReservedUnused(IOService, 29);
367 OSMetaClassDeclareReservedUnused(IOService, 30);
368 OSMetaClassDeclareReservedUnused(IOService, 31);
369 OSMetaClassDeclareReservedUnused(IOService, 32);
370 OSMetaClassDeclareReservedUnused(IOService, 33);
371 OSMetaClassDeclareReservedUnused(IOService, 34);
372 OSMetaClassDeclareReservedUnused(IOService, 35);
373 OSMetaClassDeclareReservedUnused(IOService, 36);
374 OSMetaClassDeclareReservedUnused(IOService, 37);
375 OSMetaClassDeclareReservedUnused(IOService, 38);
376 OSMetaClassDeclareReservedUnused(IOService, 39);
377 OSMetaClassDeclareReservedUnused(IOService, 40);
378 OSMetaClassDeclareReservedUnused(IOService, 41);
379 OSMetaClassDeclareReservedUnused(IOService, 42);
380 OSMetaClassDeclareReservedUnused(IOService, 43);
381 OSMetaClassDeclareReservedUnused(IOService, 44);
382 OSMetaClassDeclareReservedUnused(IOService, 45);
383 OSMetaClassDeclareReservedUnused(IOService, 46);
384 OSMetaClassDeclareReservedUnused(IOService, 47);
385
386 #ifdef __ppc__
387 OSMetaClassDeclareReservedUnused(IOService, 48);
388 OSMetaClassDeclareReservedUnused(IOService, 49);
389 OSMetaClassDeclareReservedUnused(IOService, 50);
390 OSMetaClassDeclareReservedUnused(IOService, 51);
391 OSMetaClassDeclareReservedUnused(IOService, 52);
392 OSMetaClassDeclareReservedUnused(IOService, 53);
393 OSMetaClassDeclareReservedUnused(IOService, 54);
394 OSMetaClassDeclareReservedUnused(IOService, 55);
395 OSMetaClassDeclareReservedUnused(IOService, 56);
396 OSMetaClassDeclareReservedUnused(IOService, 57);
397 OSMetaClassDeclareReservedUnused(IOService, 58);
398 OSMetaClassDeclareReservedUnused(IOService, 59);
399 OSMetaClassDeclareReservedUnused(IOService, 60);
400 OSMetaClassDeclareReservedUnused(IOService, 61);
401 OSMetaClassDeclareReservedUnused(IOService, 62);
402 OSMetaClassDeclareReservedUnused(IOService, 63);
403 #endif
404
405 public:
406 /*! @function getState
407 @abstract Accessor for IOService state bits, not normally needed or used outside IOService.
408 @result State bits for the IOService, eg. kIOServiceInactiveState, kIOServiceRegisteredState. */
409
410 virtual IOOptionBits getState( void ) const;
411
412 /*! @function isInactive
413 @abstract Check the IOService has been terminated, and is in the process of being destroyed.
414 @discussion When an IOService is successfully terminated, it is immediately made inactive, which blocks further attach()es, matching or notifications occuring on the object. It remains inactive until the last client closes, and is then finalized and destroyed.
415 @result Returns true if the IOService has been terminated. */
416
417 bool isInactive( void ) const;
418
419 /* Stack creation */
420
421 /*! @function registerService
422 @abstract Start the registration process for a newly discovered IOService.
423 @discussion This function allows an IOService subclass to be published and made available to possible clients, by starting the registration process and delivering notifications to registered clients. The object should be completely setup and ready to field requests from clients before registerService is called.
424 @param options The default zero options mask is recommended & should be used in most cases. The registration process is usually asynchronous, with possible driver probing & notification occurring some time later. kIOServiceSynchronous may be passed to carry out the matching and notification process for currently registered clients before returning to the caller. */
425
426 virtual void registerService( IOOptionBits options = 0 );
427
428 /*! @function probe
429 @abstract During an IOService instantiation probe a matched service to see if it can be used.
430 @discussion The registration process for an IOService (the provider) includes instantiating possible driver clients. The probe method is called in the client instance to check the matched service can be used before the driver is considered to be started. Since matching screens many possible providers, in many cases the probe method can be left unimplemented by IOService subclasses. The client is already attached to the provider when probe is called.
431 @param provider The registered IOService which matches a driver personality's matching dictionary.
432 @param score Pointer to the current driver's probe score, which is used to order multiple matching drivers in the same match category. It defaults to the value of the IOProbeScore property in the drivers property table, or kIODefaultProbeScore if none is specified. The probe method may alter the score to affect start order.
433 @result Returns an IOService instance or zero when the probe is unsuccessful. In almost all cases the value of this is returned on success. If another IOService object is returned, the probed instance is detached and freed, and the returned instance is used in its stead for start. */
434
435 virtual IOService * probe( IOService * provider,
436 SInt32 * score );
437
438 /*! @function start
439 @abstract During an IOService instantiation, the start method is called when the IOService has been selected to run on the provider.
440 @discussion The registration process for an IOService (the provider) includes instantiating possible driver clients. The start method is called in the client instance when it has been selected (by its probe score and match category) to be the winning client. The client is already attached to the provider when start is called.
441 @result Return true if the start was successful, false otherwise (which will cause the instance to be detached and usually freed). */
442
443 virtual bool start( IOService * provider );
444
445 /*! @function stop
446 @abstract During an IOService termination, the stop method is called in its clients before they are detached & it is destroyed.
447 @discussion The termination process for an IOService (the provider) will call stop in each of its clients, after they have closed the provider if they had it open, or immediately on termination. */
448
449 virtual void stop( IOService * provider );
450
451 /* Open / Close */
452
453 /*! @function open
454 @abstract Request active access to a provider.
455 @discussion IOService provides generic open and close semantics to track clients of a provider that have established an active datapath. The use of open & close, and rules regarding ownership are family defined, and defined by the handleOpen / handleClose methods in the provider. Some families will limit access to a provider based on its open state.
456 @param forClient Designates the client of the provider requesting the open.
457 @param options Options for the open. The provider family may implement options for open; IOService defines only kIOServiceSeize to request the device be withdrawn from its current owner.
458 @result Return true if the open was successful, false otherwise. */
459
460 virtual bool open( IOService * forClient,
461 IOOptionBits options = 0,
462 void * arg = 0 );
463
464 /*! @function close
465 @abstract Release active access to a provider.
466 @discussion IOService provides generic open and close semantics to track clients of a provider that have established an active datapath. The use of open & close, and rules regarding ownership are family defined, and defined by the handleOpen / handleClose methods in the provider.
467 @param forClient Designates the client of the provider requesting the close.
468 @param options Options available for the close. The provider family may implement options for close; IOService defines none.
469 @param arg Family specific arguments, ignored by IOService. */
470
471 virtual void close( IOService * forClient,
472 IOOptionBits options = 0 );
473
474 /*! @function isOpen
475 @abstract Determine whether a specific, or any, client has an IOService open.
476 @discussion Returns the open state of an IOService with respect to the specified client, or when it is open by any client.
477 @param forClient If non-zero, isOpen returns the open state for that client. If zero is passed, isOpen returns the open state for all clients.
478 @result Returns true if the specific, or any, client has the IOService open. */
479
480 virtual bool isOpen( const IOService * forClient = 0 ) const;
481
482 /*! @function handleOpen
483 @abstract Overrideable method to control the open / close behaviour of an IOService.
484 @discussion IOService calls this method in its subclasses in response to the open method, so the subclass may implement the request. The default implementation provides single owner access to an IOService via open. The object is locked via lockForArbitration before handleOpen is called.
485 @param forClient Designates the client of the provider requesting the open.
486 @param options Options for the open, may be interpreted by the implementor of handleOpen.
487 @result Return true if the open was successful, false otherwise. */
488
489 virtual bool handleOpen( IOService * forClient,
490 IOOptionBits options,
491 void * arg );
492
493 /*! @function handleClose
494 @abstract Overrideable method to control the open / close behaviour of an IOService.
495 @discussion IOService calls this method in its subclasses in response to the close method, so the subclass may implement the request. The default implementation provides single owner access to an IOService via open. The object is locked via lockForArbitration before handleClose is called.
496 @param forClient Designates the client of the provider requesting the close.
497 @param options Options for the close, may be interpreted by the implementor of handleOpen. */
498
499 virtual void handleClose( IOService * forClient,
500 IOOptionBits options );
501
502 /*! @function handleIsOpen
503 @abstract Overrideable method to control the open / close behaviour of an IOService.
504 @discussion IOService calls this method in its subclasses in response to the open method, so the subclass may implement the request. The default implementation provides single owner access to an IOService via open. The object is locked via lockForArbitration before handleIsOpen is called.
505 @param forClient If non-zero, isOpen returns the open state for that client. If zero is passed, isOpen returns the open state for all clients.
506 @result Returns true if the specific, or any, client has the IOService open. */
507
508 virtual bool handleIsOpen( const IOService * forClient ) const;
509
510 /* Stacking change */
511
512 /*! @function terminate
513 @abstract Make an IOService inactive and begin its destruction.
514 @discussion Registering an IOService informs possible clients of its existance and instantiates drivers that may be used with it; terminate involves the opposite process of informing clients that an IOService is no longer able to be used and will be destroyed. By default, if any client has the service open, terminate fails. If the kIOServiceRequired flag is passed however, terminate will be sucessful though further progress in the destruction of the IOService will not proceed until the last client has closed it. The service will be made inactive immediately upon successful termination, and all its clients will be notified via their message method with a message of type kIOMessageServiceIsTerminated. Both these actions take place on the callers thread. After the IOService is made inactive, further matching or attach calls will fail on it. Each client has its stop method called upon their close of an inactive IOService, or on its termination if they do not have it open. After stop, detach is called in each client. When all clients have been detached, the finalize method is called in the inactive service. The terminate process is inherently asynchronous since it will be deferred until all clients have chosen to close.
515 @param options In most cases no options are needed. kIOServiceSynchronous may be passed to cause terminate to not return until the service is finalized. */
516
517 virtual bool terminate( IOOptionBits options = 0 );
518
519 /*! @function finalize
520 @abstract The last stage in an IOService destruction.
521 @discussion The finalize method is called in an inactive (ie. terminated) IOService after the last client has detached. IOService's implementation will call stop, close, and detach on each provider. When finalize returns, the object's retain count will have no references generated by IOService's registration process.
522 @param options The options passed to the terminate method of the IOService are passed on to finalize.
523 @result Returns true. */
524
525 virtual bool finalize( IOOptionBits options );
526
527 /*! @function free
528 @discussion Free data structures that were allocated when power management was initialized on this service. */
529
530 virtual void free( void );
531
532 /*! @function lockForArbitration
533 @abstract Locks an IOService against changes in state or ownership.
534 @discussion The registration, termination and open / close functions of IOService use lockForArbtration to single thread access to an IOService. lockForArbitration will grant recursive access to the same thread.
535 @param isSuccessRequired If a request for access to an IOService should be denied if it is terminated, isSuccessRequired should passed as false, otherwise pass true. */
536
537 virtual bool lockForArbitration( bool isSuccessRequired = true );
538
539 /*! @function unlockForArbitration
540 @abstract Unlocks an IOService after a successful lockForArbitration.
541 @discussion A thread granted exclusive access to an IOService should release it with unlockForArbitration. */
542
543 virtual void unlockForArbitration( void );
544
545 /*! @function terminateClient
546 @abstract Passes a termination up the stack.
547 @discussion When an IOService is made inactive the default behaviour is to also make any of its clients that have it as their only provider also inactive, in this way recursing the termination up the driver stack. This method allows a terminated IOService to override this behaviour. Note the client may also override this behaviour by overriding its terminate method.
548 @param client The client of the of the terminated provider.
549 @param options Options originally passed to terminate, plus kIOServiceRecursing.
550 @result result of the terminate request on the client. */
551
552 virtual bool terminateClient( IOService * client, IOOptionBits options );
553
554 /* Busy state indicates discovery, matching or termination is in progress */
555
556 /*! @function getBusyState
557 @abstract Returns the busyState of an IOService.
558 @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.
559 @result The busyState. */
560
561 virtual UInt32 getBusyState( void );
562
563 /*! @function adjustBusy
564 @abstract Adjusts the busyState of an IOService.
565 @discussion Applies a delta to an IOService's busyState. A change in the busyState to or from zero will change the IOService's provider's busyState by one (in the same direction).
566 @param delta The delta to be applied to the IOService busy state. */
567
568 virtual void adjustBusy( SInt32 delta );
569
570 /*! @function waitQuiet
571 @abstract Wait for an IOService's busyState to be zero.
572 @discussion Blocks the caller until an IOService is non busy.
573 @param timeout Specifies a maximum time to wait.
574 @result Returns an error code if mach synchronization primitives fail, kIOReturnTimeout, or kIOReturnSuccess. */
575
576 virtual IOReturn waitQuiet( mach_timespec_t * timeout = 0 );
577
578 /* Matching */
579
580 /*! @function matchPropertyTable
581 @abstract Allows a registered IOService to implement family specific matching.
582 @discussion All matching on an IOService will call this method to allow a family writer to implement matching in addition to the generic methods provided by IOService. The implementer should examine the matching dictionary passed to see if it contains properties the family understands for matching, and use them to match with the IOService if so. Note that since matching is also carried out by other parts of IOKit, the matching dictionary may contain properties the family does not understand - these should not be considered matching failures.
583 @param table The dictionary of properties to be matched against.
584 @param score Pointer to the current driver's probe score, which is used to order multiple matching drivers in the same match category. It defaults to the value of the IOProbeScore property in the drivers property table, or kIODefaultProbeScore if none is specified.
585 @result Returns false if the family considers the matching dictionary does not match in properties it understands, true otherwise. */
586
587 virtual bool matchPropertyTable( OSDictionary * table,
588 SInt32 * score );
589
590 virtual bool matchPropertyTable( OSDictionary * table );
591
592 /*! @function matchLocation
593 @abstract Allows a registered IOService to direct location matching.
594 @discussion By default, a location matching property will be applied to an IOService's provider. This method allows that behaviour to be overridden by families.
595 @param client The IOService at which matching is taking place.
596 @result Returns the IOService instance to be used for location matching. */
597
598 virtual IOService * matchLocation( IOService * client );
599
600 /* Resource service */
601
602 /*! @function publishResource
603 @abstract Use the resource service to publish a property.
604 @discussion The resource service uses IOService's matching and notification to allow objects to be published and found by any IOKit client by a global name. publishResource makes an object available to anyone waiting for it or looking for it in the future.
605 @param key An OSSymbol key that globally identifies the object.
606 @param The object to be published. */
607
608 static void publishResource( const OSSymbol * key, OSObject * value = 0 );
609
610 /*! @function publishResource
611 @abstract Use the resource service to publish a property.
612 @discussion The resource service uses IOService's matching and notification to allow objects to be published and found by any IOKit client by a global name. publishResource makes an object available to anyone waiting for it or looking for it in the future.
613 @param key A C-string key that globally identifies the object.
614 @param The object to be published. */
615
616 static void publishResource( const char * key, OSObject * value = 0 );
617 virtual bool addNeededResource( const char * key );
618
619 /* Notifications */
620
621 /*! @function addNotification
622 @abstract Add a persistant notification handler to be notified of IOService events.
623 @discussion IOService will deliver notifications of changes in state of an IOService to registered clients. The type of notification is specified by a symbol, for example gIOMatchedNotification or gIOTerminatedNotification, and notifications will only include IOService's that match the supplied matching dictionary. Notifications are ordered by a priority set with addNotification. When the notification is installed, its handler will be called with each of any currently existing IOService's that are in the correct state (eg. registered) and match the supplied matching dictionary, avoiding races between finding preexisting and new IOService events. The notification request is identified by an instance of an IONotifier object, through which it can be enabled, disabled or removed. addNotification will consume a retain count on the matching dictionary when the notification is removed.
624 @param type An OSSymbol identifying the type of notification and IOService state:
625 <br> gIOPublishNotification Delivered when an IOService is registered.
626 <br> gIOFirstPublishNotification Delivered when an IOService is registered, but only once per IOService instance. Some IOService's may be reregistered when their state is changed.
627 <br> gIOMatchedNotification Delivered when an IOService has been matched with all client drivers, and they have been probed and started.
628 <br> gIOFirstMatchNotification Delivered when an IOService has been matched with all client drivers, but only once per IOService instance. Some IOService's may be reregistered when their state is changed.
629 <br> gIOTerminatedNotification Delivered after an IOService has been terminated, during its finalize stage.
630 @param matching A matching dictionary to restrict notifications to only matching IOServices. The dictionary will be released when the notification is removed - consuming the passed in reference.
631 @param handler A C-function callback to deliver notifications.
632 @param target An instance reference for the callbacks use.
633 @param ref A reference constant for the callbacks use
634 @param priority A constant ordering all notifications of a each type.
635 @result Returns an instance of an IONotifier object that can be used to control or destroy the notification request. */
636
637 static IONotifier * addNotification(
638 const OSSymbol * type, OSDictionary * matching,
639 IOServiceNotificationHandler handler,
640 void * target, void * ref = 0,
641 SInt32 priority = 0 );
642
643 /*! @function waitForService
644 @abstract Wait for a matching to service to be published.
645 @discussion Provides a method of waiting for an IOService matching the supplied matching dictionary to be registered and fully matched.
646 @param matching The matching dictionary describing the desired IOService. waitForService will consume one reference of the matching dictionary.
647 @param timeout The maximum time to wait.
648 @result A published IOService matching the supplied dictionary. */
649
650 static IOService * waitForService( OSDictionary * matching,
651 mach_timespec_t * timeout = 0);
652
653 /*! @function getMatchingServices
654 @abstract Finds the set of current published IOServices matching a matching dictionary.
655 @discussion Provides a method of finding the current set of published IOServices matching the supplied matching dictionary.
656 @param matching The matching dictionary describing the desired IOServices.
657 @result An instance of an iterator over a set of IOServices. To be released by the caller. */
658
659 static OSIterator * getMatchingServices( OSDictionary * matching );
660
661 /*! @function installNotification
662 @abstract Add a persistant notification handler to be notified of IOService events.
663 @discussion A lower level interface to addNotification that will install a handler and return the current set of IOServices that are in the specified state and match the matching dictionary.
664 @param type See addNotification.
665 @param matching See addNotification.
666 @param handler See addNotification.
667 @param self See addNotification.
668 @param ref See addNotification.
669 @param priority See addNotification.
670 @param existing Returns an iterator over the set of IOServices that are currently in the specified state and match the matching dictionary.
671 @result See addNotification. */
672
673 static IONotifier * installNotification(
674 const OSSymbol * type, OSDictionary * matching,
675 IOServiceNotificationHandler handler,
676 void * target, void * ref,
677 SInt32 priority, OSIterator ** existing );
678
679 /* Helpers to make matching dictionaries for simple cases,
680 * they add keys to an existing dictionary, or create one. */
681
682 /*! @function serviceMatching
683 @abstract Create a matching dictionary, or add matching properties to an existing dictionary, that specify an IOService class match.
684 @discussion A very common matching criteria for IOService is based on its class. serviceMatching will create a matching dictionary that specifies any IOService of a class, or its subclasses. The class is specified by name, and an existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
685 @param className The class name, as a const C-string. Class matching is successful on IOService's of this class or any subclass.
686 @param table If zero, serviceMatching will create a matching dictionary and return a reference to it, otherwise the matching properties are added to the specified dictionary.
687 @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
688
689 static OSDictionary * serviceMatching( const char * className,
690 OSDictionary * table = 0 );
691
692 /*! @function serviceMatching
693 @abstract Create a matching dictionary, or add matching properties to an existing dictionary, that specify an IOService class match.
694 @discussion A very common matching criteria for IOService is based on its class. serviceMatching will create a matching dictionary that specifies any IOService of a class, or its subclasses. The class is specified by name, and an existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
695 @param className The class name, as an OSString (which includes OSSymbol). Class matching is successful on IOService's of this class or any subclass.
696 @param table If zero, serviceMatching will create a matching dictionary and return a reference to it, otherwise the matching properties are added to the specified dictionary.
697 @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
698
699 static OSDictionary * serviceMatching( const OSString * className,
700 OSDictionary * table = 0 );
701
702 /*! @function nameMatching
703 @abstract Create a matching dictionary, or add matching properties to an existing dictionary, that specify an IOService name match.
704 @discussion A very common matching criteria for IOService is based on its name. nameMatching will create a matching dictionary that specifies any IOService which respond sucessfully to the IORegistryEntry method compareName. An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
705 @param name The service's name, as a const C-string. Name matching is successful on IOService's which respond sucessfully to the IORegistryEntry method compareName.
706 @param table If zero, nameMatching will create a matching dictionary and return a reference to it, otherwise the matching properties are added to the specified dictionary.
707 @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
708
709 static OSDictionary * nameMatching( const char * name,
710 OSDictionary * table = 0 );
711
712 /*! @function nameMatching
713 @abstract Create a matching dictionary, or add matching properties to an existing dictionary, that specify an IOService name match.
714 @discussion A very common matching criteria for IOService is based on its name. nameMatching will create a matching dictionary that specifies any IOService which respond sucessfully to the IORegistryEntry method compareName. An existing dictionary may be passed in, in which case the matching properties will be added to that dictionary rather than creating a new one.
715 @param name The service's name, as an OSString (which includes OSSymbol). Name matching is successful on IOService's which respond sucessfully to the IORegistryEntry method compareName.
716 @param table If zero, nameMatching will create a matching dictionary and return a reference to it, otherwise the matching properties are added to the specified dictionary.
717 @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
718
719 static OSDictionary * nameMatching( const OSString* name,
720 OSDictionary * table = 0 );
721
722 /*! @function resourceMatching
723 @abstract Create a matching dictionary, or add matching properties to an existing dictionary, that specify a resource service match.
724 @discussion IOService maintains a resource service IOResources that allows objects to be published and found globally in IOKit based on a name, using the standard IOService matching and notification calls.
725 @param name The resource name, as a const C-string. Resource matching is successful when an object by that name has been published with the publishResource method.
726 @param table If zero, resourceMatching will create a matching dictionary and return a reference to it, otherwise the matching properties are added to the specified dictionary.
727 @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
728
729 static OSDictionary * resourceMatching( const char * name,
730 OSDictionary * table = 0 );
731
732 /*! @function resourceMatching
733 @abstract Create a matching dictionary, or add matching properties to an existing dictionary, that specify a resource service match.
734 @discussion IOService maintains a resource service IOResources that allows objects to be published and found globally in IOKit based on a name, using the standard IOService matching and notification calls.
735 @param name The resource name, as an OSString (which includes OSSymbol). Resource matching is successful when an object by that name has been published with the publishResource method.
736 @param table If zero, resourceMatching will create a matching dictionary and return a reference to it, otherwise the matching properties are added to the specified dictionary.
737 @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
738
739 static OSDictionary * resourceMatching( const OSString * name,
740 OSDictionary * table = 0 );
741
742 /*! @function addLocation
743 @abstract Add a location matching property to an existing dictionary.
744 @discussion This function creates matching properties that specify the location of a IOService, as an embedded matching dictionary. This matching will be successful on an IOService which attached to an IOService which matches this location matching dictionary.
745 @param table The matching properties are added to the specified dictionary, which must be non-zero.
746 @result The location matching dictionary created is returned on success, or zero on failure. */
747
748 static OSDictionary * addLocation( OSDictionary * table );
749
750 /* Helpers for matching dictionaries. */
751
752 /*! @function compareProperty
753 @abstract Utility to compare a property in a matching dictionary with an IOService's property table.
754 @discussion This is a helper function to aid in implementing matchPropertyTable. If the property specified by key exists in the matching dictionary, it is compared with a property of the same name in the IOService's property table. The comparison is performed with the isEqualTo method. If the property does not exist in the matching table, success is returned. If the property exists in the matching dictionary but not the IOService property table, failure is returned.
755 @param matching The matching dictionary, which must be non-zero.
756 @param key The dictionary key specifying the property to be compared, as a C-string.
757 @result If the property does not exist in the matching table, true is returned. If the property exists in the matching dictionary but not the IOService property table, failure is returned. Otherwise the result of calling the property from the matching dictionary's isEqualTo method with the IOService property as an argument is returned. */
758
759 virtual bool compareProperty( OSDictionary * matching,
760 const char * key );
761 /*! @function compareProperty
762 @abstract Utility to compare a property in a matching dictionary with an IOService's property table.
763 @discussion This is a helper function to aid in implementing matchPropertyTable. If the property specified by key exists in the matching dictionary, it is compared with a property of the same name in the IOService's property table. The comparison is performed with the isEqualTo method. If the property does not exist in the matching table, success is returned. If the property exists in the matching dictionary but not the IOService property table, failure is returned.
764 @param matching The matching dictionary, which must be non-zero.
765 @param key The dictionary key specifying the property to be compared, as an OSString (which includes OSSymbol).
766 @result If the property does not exist in the matching table, true is returned. If the property exists in the matching dictionary but not the IOService property table, failure is returned. Otherwise the result of calling the property from the matching dictionary's isEqualTo method with the IOService property as an argument is returned. */
767
768 virtual bool compareProperty( OSDictionary * matching,
769 const OSString * key );
770
771 /*! @function compareProperties
772 @abstract Utility to compare a set of properties in a matching dictionary with an IOService's property table.
773 @discussion This is a helper function to aid in implementing matchPropertyTable. A collection of dictionary keys specifies properties in a matching dictionary to be compared, with compareProperty, with an IOService property table, if compareProperty returns true for each key, success is return else failure.
774 @param matching The matching dictionary, which must be non-zero.
775 @param keys A collection (eg. OSSet, OSArray, OSDictionary) which should contain OSStrings (or OSSymbols) that specify the property keys to be compared.
776 @result if compareProperty returns true for each key in the collection, success is return else failure. */
777
778 virtual bool compareProperties( OSDictionary * matching,
779 OSCollection * keys );
780
781 /* Client / provider accessors */
782
783 /*! @function attach
784 @abstract Attaches an IOService client to a provider in the registry.
785 @discussion This function called in an IOService client enters the client into the registry as a child of the provider in the service plane. The provider must be active or the attach will fail. Multiple attach calls to the same provider are no-ops and return success. A client may be attached to multiple providers. Entering an object into the registry will retain both the client and provider until they are detached.
786 @param provider The IOService object which will serve as this objects provider.
787 @result false if the provider is inactive or on a resource failure, otherwise true. */
788
789 virtual bool attach( IOService * provider );
790
791 /*! @function detach
792 @abstract Detaches an IOService client from a provider in the registry.
793 @discussion This function called in an IOService client removes the client as a child of the provider in the service plane of the registry. If the provider is not a parent of the client this is a no-op, otherwise the registry will release both the client and provider.
794 @param provider The IOService object to detach from. */
795
796 virtual void detach( IOService * provider );
797
798 /*! @function getProvider
799 @abstract Returns an IOService's primary provider.
800 @discussion This function called in an IOService client will return the provider to which it was first attached. Since the majority of IOService objects have only one provider, this is a useful simplification and also supports caching of the provider when the registry is unchanged.
801 @result Returns the first provider of the client, or zero if the IOService is not attached into the registry. The provider is retained while the client is attached, and should not be released by the caller. */
802
803 virtual IOService * getProvider( void ) const;
804
805 /*! @function getWorkLoop
806 @abstract Returns the current work loop or provider->getWorkLoop().
807 @discussion This function returns a valid work loop that a client can use to add an IOCommandGate to. The intention is that an IOService client has data that needs to be protected but doesn't want to pay the cost of an entire dedicated thread. This data has to be accessed from a providers call out context as well. So to achieve both of these goals the client creates an IOCommandGate to lock access to his data but he registers it with the providers work loop, i.e. the work loop which will make the completion call outs. In one fell swoop we avoid a potentially nasty deadlock 'cause a work loop's gate is recursive.
808 @result Always returns a work loop, either the current work loop or it walks up the $link getProvider() chain calling getWorkLoop. Eventually it will reach a valid work loop based driver or the root of the io tree where it will return a system wide work loop. Returns 0 if it fails to find (or create) */
809
810 virtual IOWorkLoop * getWorkLoop() const;
811
812 /*! @function getProviderIterator
813 @abstract Returns an iterator over an IOService's providers.
814 @discussion For those few IOService objects that obtain service from multiple providers, this method supplies an iterator over a client's providers.
815 @result Returns an iterator over the providers of the client, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */
816
817 virtual OSIterator * getProviderIterator( void ) const;
818
819 /*! @function getOpenProviderIterator
820 @abstract Returns an iterator over an client's providers that are currently opened by the client.
821 @discussion For those few IOService objects that obtain service from multiple providers, this method supplies an iterator over a client's providers, locking each in turn with lockForArbitration and returning those that have been opened by the client.
822 @result Returns an iterator over the providers the client has open, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, and the current entry in the iteration is locked with lockForArbitration, protecting it from state changes. */
823
824 virtual OSIterator * getOpenProviderIterator( void ) const;
825
826 /*! @function getClient
827 @abstract Returns an IOService's primary client.
828 @discussion This function called in an IOService provider will return the first client to attach to it. For IOService objects which have only only one client, this may be a useful simplification.
829 @result Returns the first client of the provider, or zero if the IOService is not attached into the registry. The client is retained while it is attached, and should not be released by the caller. */
830
831 virtual IOService * getClient( void ) const;
832
833 /*! @function getClientIterator
834 @abstract Returns an iterator over an IOService's clients.
835 @discussion For IOService objects that may have multiple clients, this method supplies an iterator over a provider's clients.
836 @result Returns an iterator over the clients of the provider, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, though they may no longer be attached during the iteration. */
837
838 virtual OSIterator * getClientIterator( void ) const;
839
840 /*! @function getOpenClientIterator
841 @abstract Returns an iterator over an provider's clients that currently have opened the provider.
842 @discussion For IOService objects that may have multiple clients, this method supplies an iterator over a provider's clients, locking each in turn with lockForArbitration and returning those that have opened the provider.
843 @result Returns an iterator over the clients which the provider open, or zero if there is a resource failure. The iterator must be released when the iteration is finished. All objects returned by the iteration are retained while the iterator is valid, and the current entry in the iteration is locked with lockForArbitration, protecting it from state changes. */
844
845 virtual OSIterator * getOpenClientIterator( void ) const;
846
847 /*! @function callPlatformFunction
848 @abstract Calls the platform function with the given name.
849 @discussion The platform expert or other drivers may implement various functions to control hardware features. callPlatformFunction allows any IOService object to access these functions. Normally callPlatformFunction will be called on a service's provider. The provider will service the request or pass it to it's provider. The systems IOPlatformExpert subclass will catch functions it knows about and redirect them into other parts of the IOService plane. If the IOPlatformExpert subclass can not execute the function, the base class will be called. The IOPlatformExpert base class will attempt to find a service to execute the function by looking up the function name in a IOResources name space. A service may publish a service using publishResource(functionName, this). If no service can be found to execute the function an error will be returned.
850 @param functionName name of the function to be called. When functionName is a c-string, callPlatformFunction will convert the c-string to a OSSymbol and call other OSSymbol version of callPlatformFunction. This process can block and should not be used from an interrupt context.
851 @param waitForFunction if true callPlatformFunction will not return until the function has been called.
852 @result Return an IOReturn code, kIOReturnSuccess if the function was successfully executed, kIOReturnUnsupported if a service to execute the function could not be found. Other return codes may be returned by the function.*/
853
854 virtual IOReturn callPlatformFunction( const OSSymbol * functionName,
855 bool waitForFunction,
856 void *param1, void *param2,
857 void *param3, void *param4 );
858
859 virtual IOReturn callPlatformFunction( const char * functionName,
860 bool waitForFunction,
861 void *param1, void *param2,
862 void *param3, void *param4 );
863
864
865 /* Some accessors */
866
867 /*! @function getPlatform
868 @abstract Returns a pointer to the platform expert instance for the machine.
869 @discussion This method provides an accessor to the platform expert instance for the machine.
870 @result A pointer to the IOPlatformExport instance. It should not be released by the caller. */
871
872 static IOPlatformExpert * getPlatform( void );
873
874 /*! @function getPMRootDomain
875 @abstract Returns a pointer to the power management root domain instance for the machine.
876 @discussion This method provides an accessor to the power management root domain instance for the machine.
877 @result A pointer to the power management root domain instance. It should not be released by the caller. */
878
879 static class IOPMrootDomain * getPMRootDomain( void );
880
881 /*! @function getServiceRoot
882 @abstract Returns a pointer to the root of the service plane.
883 @discussion This method provides an accessor to the root of the service plane for the machine.
884 @result A pointer to the IOService instance at the root of the service plane. It should not be released by the caller. */
885
886 static IOService * getServiceRoot( void );
887
888 /*! @function getResourceService
889 @abstract Returns a pointer to the IOResources service.
890 @discussion IOService maintains a resource service IOResources that allows objects to be published and found globally in IOKit based on a name, using the standard IOService matching and notification calls.
891 @result A pointer to the IOResources instance. It should not be released by the caller. */
892
893 static IOService * getResourceService( void );
894
895 /* Allocate resources for a matched service */
896
897 /*! @function getResources
898 @abstract Allocate any needed resources for a published IOService before clients attach.
899 @discussion This method is called during the registration process for an IOService object if there are success driver matches, before any clients attach. It allows for lazy allocation of resources to an IOService when a matching driver is found.
900 @result Return an IOReturn code, kIOReturnSuccess is necessary for the IOService to be successfully used, otherwise the registration process for the object is halted. */
901
902 virtual IOReturn getResources( void );
903
904 /* Device memory accessors */
905
906 /*! @function getDeviceMemoryCount
907 @abstract Returns a count of the physical memory ranges available for a device.
908 @discussion This method will return the count of physical memory ranges, each represented by an IODeviceMemory instance, that have been allocated for a memory mapped device.
909 @result An integer count of the number of ranges available. */
910
911 virtual IOItemCount getDeviceMemoryCount( void );
912
913 /*! @function getDeviceMemoryWithIndex
914 @abstract Returns an instance of IODeviceMemory representing one of a device's memory mapped ranges.
915 @discussion This method will return a pointer to an instance of IODeviceMemory for the physical memory range at the given index for a memory mapped device.
916 @param index An index into the array of ranges assigned to the device.
917 @result A pointer to an instance of IODeviceMemory, or zero if the index is beyond the count available. The IODeviceMemory is retained by the provider, so is valid while attached, or while any mappings to it exist. It should not be released by the caller. See also mapDeviceMemory() which will create a device memory mapping. */
918
919 virtual IODeviceMemory * getDeviceMemoryWithIndex( unsigned int index );
920
921 /*! @function mapDeviceMemoryWithIndex
922 @abstract Maps a physical range of a device.
923 @discussion This method will create a mapping for the IODeviceMemory at the given index, with IODeviceMemory::map(options). The mapping is represented by the returned instance of IOMemoryMap, which should not be released until the mapping is no longer required.
924 @param index An index into the array of ranges assigned to the device.
925 @result An instance of IOMemoryMap, or zero if the index is beyond the count available. The mapping should be released only when access to it is no longer required. */
926
927 virtual IOMemoryMap * mapDeviceMemoryWithIndex( unsigned int index,
928 IOOptionBits options = 0 );
929
930 /*! @function getDeviceMemory
931 @abstract Returns the array of IODeviceMemory objects representing a device's memory mapped ranges.
932 @discussion This method will return an array of IODeviceMemory objects representing the physical memory ranges allocated to a memory mapped device.
933 @result An OSArray of IODeviceMemory objects, or zero if none are available. The array is retained by the provider, so is valid while attached. */
934
935 virtual OSArray * getDeviceMemory( void );
936
937 /*! @function setDeviceMemory
938 @abstract Sets the array of IODeviceMemory objects representing a device's memory mapped ranges.
939 @discussion This method will set an array of IODeviceMemory objects representing the physical memory ranges allocated to a memory mapped device.
940 @param array An OSArray of IODeviceMemory objects, or zero if none are available. The array will be retained by the object. */
941
942 virtual void setDeviceMemory( OSArray * array );
943
944 /* Interrupt accessors */
945
946 /*! @function registerInterrupt
947 @abstract Register a C-function interrupt handler for a device supplying interrupts.
948 @discussion This method will install a C-function interrupt handler to be called at primary interrupt time for a device's interrupt. Only one handler may be installed per interrupt source. IOInterruptEventSource provides an IOWorkLoop based abstraction for interrupt delivery that may be more appropriate for work loop based drivers.
949 @param source The index of the interrupt source in the device.
950 @param target An object instance to be passed to the interrupt handler.
951 @param handler The C-function to be to be called at primary interrupt time when the interrupt occurs. The handler should process the interrupt by clearing the interrupt, or by disabling the source.
952 @param refCon A reference constant for the handler's use.
953 @result An IOReturn code.<br>kIOReturnNoInterrupt is returned if the source is not valid.<br>kIOReturnNoResources is returned if the interrupt already has an installed handler. */
954
955 virtual IOReturn registerInterrupt(int source, OSObject *target,
956 IOInterruptAction handler,
957 void *refCon = 0);
958
959 /*! @function unregisterInterrupt
960 @abstract Remove a C-function interrupt handler for a device supplying hardware interrupts.
961 @discussion This method will remove a C-function interrupt handler previously installed with registerInterrupt.
962 @param source The index of the interrupt source in the device.
963 @result An IOReturn code.<br>kIOReturnNoInterrupt is returned if the source is not valid. */
964
965 virtual IOReturn unregisterInterrupt(int source);
966
967 /*! @function getInterruptType
968 @abstract Return the type of interrupt used for a device supplying hardware interrupts.
969 @discussion This method will return the type of interrupt used by the device.
970 @param source The index of the interrupt source in the device.
971 @param interruptType The interrupt type for the interrupt source will be stored here by getInterruptType.<br> kIOInterruptTypeEdge will be returned for edge trigggered sources.<br> kIOInterruptTypeLevel will be returned for level trigggered sources.
972 @result An IOReturn code.<br>kIOReturnNoInterrupt is returned if the source is not valid. */
973
974 virtual IOReturn getInterruptType(int source, int *interruptType);
975
976 /*! @function enableInterrupt
977 @abstract Enable a device interrupt.
978 @discussion Enable a device interrupt. It is the callers responsiblity to keep track of the enable state of the interrupt source.
979 @param source The index of the interrupt source in the device.
980 @result An IOReturn code.<br>kIOReturnNoInterrupt is returned if the source is not valid. */
981
982 virtual IOReturn enableInterrupt(int source);
983
984 /*! @function disableInterrupt
985 @abstract Disable a device interrupt.
986 @discussion Synchronously disable a device interrupt. If the interrupt routine is running, the call will block until the routine completes. It is the callers responsiblity to keep track of the enable state of the interrupt source.
987 @param source The index of the interrupt source in the device.
988 @result An IOReturn code.<br>kIOReturnNoInterrupt is returned if the source is not valid. */
989
990 virtual IOReturn disableInterrupt(int source);
991
992 /*! @function causeInterrupt
993 @abstract Cause a device interrupt to occur.
994 @discussion Emulate a hardware interrupt, to be called from task level.
995 @param source The index of the interrupt source in the device.
996 @result An IOReturn code.<br>kIOReturnNoInterrupt is returned if the source is not valid. */
997
998 virtual IOReturn causeInterrupt(int source);
999
1000 /*! @function requestProbe
1001 @abstract An external request that hardware be re-scanned for devices.
1002 @discussion For bus families that do not usually detect device addition or removal, this method represents an external request (eg. from a utility application) to rescan and publish or remove found devices.
1003 @param options Family defined options, not interpreted by IOService.
1004 @result An IOReturn code. */
1005
1006 virtual IOReturn requestProbe( IOOptionBits options );
1007
1008 /* Generic API for non-data-path upstream calls */
1009
1010 /*! @function message
1011 @abstract Receive a generic message delivered from an attached provider.
1012 @discussion A provider may deliver messages via the message method to its clients informing them of state changes, for example kIOMessageServiceIsTerminated or kIOMessageServiceIsSuspended. Certain messages are defined by IOKit in IOMessage.h while others may family dependent. This method is implemented in the client to receive messages.
1013 @param type A type defined in IOMessage.h or defined by the provider family.
1014 @param provider The provider from which the message originates.
1015 @param argument An argument defined by the provider family, not used by IOService.
1016 @result An IOReturn code defined by the message type. */
1017
1018 virtual IOReturn message( UInt32 type, IOService * provider,
1019 void * argument = 0 );
1020
1021 /*! @function messageClient
1022 @abstract Send a generic message to an attached client.
1023 @discussion A provider may deliver messages via the message method to its clients informing them of state changes, for example kIOMessageServiceIsTerminated or kIOMessageServiceIsSuspended. Certain messages are defined by IOKit in IOMessage.h while others may family dependent. This method may be called in the provider to send a message to the specified client, which may be useful for overrides.
1024 @param type A type defined in IOMessage.h or defined by the provider family.
1025 @param client A client of the IOService to send the message.
1026 @param argument An argument defined by the provider family, not used by IOService.
1027 @result The return code from the client message call. */
1028
1029 virtual IOReturn messageClient( UInt32 messageType, OSObject * client,
1030 void * messageArgument = 0, vm_size_t argSize = 0 );
1031
1032 /*! @function messageClients
1033 @abstract Send a generic message to all attached clients.
1034 @discussion A provider may deliver messages via the message method to its clients informing them of state changes, for example kIOMessageServiceIsTerminated or kIOMessageServiceIsSuspended. Certain messages are defined by IOKit in IOMessage.h while others may family dependent. This method may be called in the provider to send a message to all the attached clients, via the messageClient method.
1035 @param type A type defined in IOMessage.h or defined by the provider family.
1036 @param argument An argument defined by the provider family, not used by IOService.
1037 @result Any non-kIOReturnSuccess return codes returned by the clients, or kIOReturnSuccess if all return kIOReturnSuccess. */
1038
1039 virtual IOReturn messageClients( UInt32 type,
1040 void * argument = 0, vm_size_t argSize = 0 );
1041
1042 virtual IONotifier * registerInterest( const OSSymbol * typeOfInterest,
1043 IOServiceInterestHandler handler,
1044 void * target, void * ref = 0 );
1045
1046 virtual void applyToProviders( IOServiceApplierFunction applier,
1047 void * context );
1048
1049 virtual void applyToClients( IOServiceApplierFunction applier,
1050 void * context );
1051
1052 virtual void applyToInterested( const OSSymbol * typeOfInterest,
1053 OSObjectApplierFunction applier,
1054 void * context );
1055
1056 virtual IOReturn acknowledgeNotification( IONotificationRef notification,
1057 IOOptionBits response );
1058
1059 /* User client create */
1060
1061 /*! @function newUserClient
1062 @abstract A request to create a connection for a non kernel client.
1063 @discussion A non kernel client may request a connection be opened via the IOServiceOpen() library function, which will call this method in an IOService. The rules & capabilities of user level clients are family dependent, and use the functions of the IOUserClient class for support. IOService's implementation returns kIOReturnUnsupported, so any family supporting user clients must implement this method.
1064 @param owningTask The mach task requesting the connection.
1065 @param securityID A token representing the access level for the task.
1066 @param type A constant specifying the type of connection to be created, specified by the caller of IOServiceOpen and interpreted only by the family.
1067 @param handler An instance of an IOUserClient object to represent the connection, which will be released when the connection is closed, or zero if the connection was not opened.
1068 @param properties A dictionary of additional properties for the connection.
1069 @result A return code to be passed back to the caller of IOServiceOpen. */
1070
1071 virtual IOReturn newUserClient( task_t owningTask, void * securityID,
1072 UInt32 type, OSDictionary * properties,
1073 IOUserClient ** handler );
1074
1075 virtual IOReturn newUserClient( task_t owningTask, void * securityID,
1076 UInt32 type, IOUserClient ** handler );
1077
1078 /* Return code utilities */
1079
1080 /*! @function stringFromReturn
1081 @abstract A utility to supply a programmer friendly string from an IOReturn code.
1082 @discussion Strings are available for the standard return codes in IOReturn.h in IOService, while subclasses may implement this method to interpret family dependent return codes.
1083 @param rtn The IOReturn code.
1084 @result A pointer to a constant string, or zero if the return code is unknown. */
1085
1086 virtual const char * stringFromReturn( IOReturn rtn );
1087
1088 /*! @function errnoFromReturn
1089 @abstract A utility to translate an IOReturn code to a BSD errno.
1090 @discussion BSD defines its own return codes for its functions in sys/errno.h, and IOKit families may need to supply compliant results in BSD shims. Results are available for the standard return codes in IOReturn.h in IOService, while subclasses may implement this method to interpret family dependent return codes.
1091 @param rtn The IOReturn code.
1092 @result The BSD errno or EIO if unknown. */
1093
1094 virtual int errnoFromReturn( IOReturn rtn );
1095
1096 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1097 /* * * * * * * * * * * * Internals * * * * * * * * * * * */
1098 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1099
1100 public:
1101 int _numInterruptSources;
1102 IOInterruptSource *_interruptSources;
1103
1104 static void initialize( void );
1105
1106 virtual bool serializeProperties( OSSerialize * s ) const;
1107
1108 static void setPlatform( IOPlatformExpert * platform);
1109 static void setPMRootDomain( class IOPMrootDomain * rootDomain );
1110
1111 static IOReturn catalogNewDrivers( OSOrderedSet * newTables );
1112 static IOReturn waitMatchIdle( UInt32 ms );
1113
1114 static IOService * resources( void );
1115 virtual bool checkResources( void );
1116 virtual bool checkResource( OSObject * matching );
1117
1118 virtual void probeCandidates( OSOrderedSet * matches );
1119 virtual bool startCandidate( IOService * candidate );
1120 virtual IOService * getClientWithCategory( const OSSymbol * category );
1121
1122 virtual bool passiveMatch( OSDictionary * matching, bool changesOK = false);
1123
1124 virtual void startMatching( IOOptionBits options = 0 );
1125 virtual void doServiceMatch( IOOptionBits options );
1126 virtual void doServiceTerminate( IOOptionBits options );
1127
1128 static OSObject * getExistingServices( OSDictionary * matching,
1129 IOOptionBits inState, IOOptionBits options = 0 );
1130
1131 static IONotifier * setNotification(
1132 const OSSymbol * type, OSDictionary * matching,
1133 IOServiceNotificationHandler handler,
1134 void * target, void * ref,
1135 SInt32 priority = 0 );
1136
1137 static IONotifier * doInstallNotification(
1138 const OSSymbol * type, OSDictionary * matching,
1139 IOServiceNotificationHandler handler,
1140 void * target, void * ref,
1141 SInt32 priority, OSIterator ** existing );
1142
1143 static bool syncNotificationHandler( void * target, void * ref,
1144 IOService * newService );
1145
1146 virtual void deliverNotification( const OSSymbol * type,
1147 IOOptionBits orNewState, IOOptionBits andNewState );
1148
1149 bool invokeNotifer( class _IOServiceNotifier * notify );
1150
1151 virtual void unregisterAllInterest( void );
1152
1153 virtual IOReturn waitForState( UInt32 mask, UInt32 value,
1154 mach_timespec_t * timeout = 0 );
1155
1156 UInt32 _adjustBusy( SInt32 delta );
1157
1158 bool terminatePhase1( IOOptionBits options = 0 );
1159 void scheduleTerminatePhase2( IOOptionBits options = 0 );
1160 void scheduleStop( IOService * provider );
1161 void scheduleFinalize( void );
1162 static void terminateThread( void * arg );
1163 static void terminateWorker( IOOptionBits options );
1164 static void actionWillTerminate( IOService * victim, IOOptionBits options,
1165 OSArray * doPhase2List );
1166 static void actionDidTerminate( IOService * victim, IOOptionBits options );
1167 static void actionFinalize( IOService * victim, IOOptionBits options );
1168 static void actionStop( IOService * client, IOService * provider );
1169
1170 virtual IOReturn resolveInterrupt(IOService *nub, int source);
1171 virtual IOReturn lookupInterrupt(int source, bool resolve, IOInterruptController **interruptController);
1172
1173 // SPI to control CPU low power modes
1174 void setCPUSnoopDelay(UInt32 ns);
1175 UInt32 getCPUSnoopDelay();
1176 void requireMaxBusStall(UInt32 ns);
1177
1178 void PMfree( void );
1179
1180 /* power management */
1181
1182 /*! @function PMinit
1183 A power managment policy-maker for a device calls itself here to initialize its power management.
1184 PMinit allocates and initializes the power management instance variables, and it should be called before any
1185 access to those variables or the power management methods. */
1186 virtual void PMinit (void );
1187
1188 /*! @function PMstop
1189 A power managment policy-maker for a device calls itself here when it resigns its responsibilities as
1190 policy-maker. This typically happens when it is handing off the responsibility to another policy-maker,
1191 or when the device is removed from the system. The power managment variables don't exist after
1192 this call, and the power managment methods in the caller shouldn't be accessed. */
1193 virtual void PMstop ( void );
1194
1195 /*! @function joinPMtree
1196 A policy-maker calls its nub here when initializing, to be attached into
1197 the power management hierarchy. The default function is to call the
1198 platform expert, which knows how to do it. This method is overridden
1199 by a nub subclass which may either know how to do it, or may need
1200 to take other action.
1201
1202 This may be the only "power management" method used in a nub, meaning
1203 it may be called even if the nub is not initialized for power management.
1204
1205 Before the nub returns from this method, the caller will probably be called
1206 at "setPowerParent" and "setAggressiveness" and possibly at "addPowerChild" as it is
1207 added to me hierarchy. */
1208 virtual void joinPMtree ( IOService * driver );
1209
1210 /*! @function registerPowerDriver
1211 A driver calls a policy-maker here to volunteer to control power to the device.
1212 If the policy-maker accepts the volunteer, it adds the volunteer to its list of
1213 interested drivers, and it will call the volunteer at appropriate times to switch
1214 the power state of the device.
1215 @param controllingDriver
1216 This points to the calling driver.
1217 @param powerStates
1218 This is an array of power states which the driver can deal with. If this array
1219 is no less rich than one supplied by an earlier volunteer, then the policy-maker
1220 uses the calling driver as its power-controlling driver.
1221 @param numberOfStates
1222 The number of power states in the array. Power states are defined in
1223 pwr_mgt/IOPMpowerState.h.
1224 @result
1225 IOPMNoErr is returned. There are various error conditions possible which prevent
1226 the policy-maker from accepting the new power state array. These conditions
1227 are logged in the power managment event log, but not returned to the caller. */
1228 virtual IOReturn registerPowerDriver ( IOService* controllingDriver, IOPMPowerState* powerStates, unsigned long numberOfStates );
1229
1230 /*! @function registerInterestedDriver
1231 Some IOService calls a policy-maker here to register interest in the changing
1232 power state of its device.
1233 @param theDriver
1234 The policy-maker adds this pointer to the calling IOService to its list of
1235 interested drivers. It informs drivers on this list pre- and post-power change.
1236 @result
1237 The policy-maker returns flags describing the capability of the device in its
1238 current power state. The policy-maker does not interpret these flags or
1239 understand them; they come from the power state array, and are understood
1240 only by interested drivers and perhaps the power-controlling driver. If the
1241 current power state is not yet defined, zero is returned. This is the case when
1242 the policy-maker is not yet in the power domain hierarchy or when it doesn't
1243 have a power-controlling driver yet. */
1244 virtual IOPMPowerFlags registerInterestedDriver ( IOService* theDriver );
1245
1246 /*! @function deRegisterInterestedDriver
1247 An IOService which has previously registered with a policy-maker as an interested
1248 driver calls the policy-maker here to withdraw its interest. The policy-maker removes
1249 it from its list of interested drivers.
1250 @result
1251 These bits describe the capability of the device in its current power state. They are
1252 not understood by the policy-maker; they come from the capabilityFlags field of the
1253 current power state in the power state array. */
1254 virtual IOReturn deRegisterInterestedDriver ( IOService * theDriver );
1255
1256 /*! @function acknowledgePowerChange
1257 When a device is changing power state, its policy-maker informs interested
1258 parties before and after the change. Interested parties are those which
1259 have registered as interested drivers and also children of the policy-maker
1260 in the case that it is a power domain.
1261 When an object is so informed, it can return an indication that it is prepared
1262 for the change, or it can return an indication that it needs some time to
1263 prepare. In this case it will call this method in the policy-maker when it has
1264 prepared.
1265 @param theDriver
1266 This points to the calling driver. The policy-maker uses it to know if all
1267 interested parties have acknowledged the power state change.
1268 @result
1269 IOPMNoErr is returned. */
1270 virtual IOReturn acknowledgePowerChange ( IOService * whichDriver );
1271
1272 /*! @function acknowledgeSetPowerState
1273 When a policy-maker instructs its controlling driver to switch the state of
1274 the device, the driver can return an indication that the change is complete,
1275 or it can return an indication that it needs some time to make the change.
1276 In this case it will call this method in the policy-maker when it has made the
1277 power state change.
1278 @result
1279 IOPMNoErr is returned. */
1280 virtual IOReturn acknowledgeSetPowerState ( void );
1281
1282 /*! @function powerDomainWillChangeTo
1283 When a power domain changes state, it notifies its children, which
1284 are policy-makers, by calling them at this method. It calls here
1285 before it makes the change, and a called policy-maker can return
1286 IOPMAckImplied to indicate that it is prepared for the change,
1287 or it can return a non-zero number to indicate that it is not prepared
1288 but will prepare and then call the parent at acknowledgePowerChange.
1289
1290 To prepare for a lowering of the power domain, the policy-maker
1291 informs all its interested parties of any resulting change in its device,
1292 and when they have all acknowledged, it calls its controlling driver
1293 to switch the device to an appropriate power state for the imminent
1294 domain state. If any interested driver or the controlling driver does
1295 not acknowledge immediately, then the policy-maker also will not.
1296
1297 To prepare for a raising of the power domain, the policy-maker
1298 informs all its interested parties of any resulting change in its device.
1299 If any do not acknowledge immediately, then the policy-maker also will not.
1300 @param newPowerStateFlags
1301 These flags describe the character of power in the imminent domain state.
1302 They are not understood by the policy-maker. It asks the controlling
1303 driver to translate them into a state number within the power state array.
1304 (The policy-maker for the domain also doesn't understand the bits; they
1305 come from a outputPowerCharacter field of the power state array for
1306 the power domain.)
1307 @param whichParent
1308 This pointer identifies the calling parent. */
1309 IOReturn powerDomainWillChangeTo ( IOPMPowerFlags newPowerStateFlags, IOPowerConnection * whichParent );
1310
1311 /*! @function powerDomainDidChangeTo
1312 When a power domain changes state, it notifies its children, which
1313 are policy-makers, by calling them at this method. It calls here
1314 after the changed power of the power domain has settled at the
1315 new level. A called policy-maker can return
1316 IOPMAckImplied to indicate that it is prepared for the change,
1317 or it can return a non-zero number to indicate that it is not prepared
1318 but will prepare and then call the parent at acknowledgePowerChange.
1319
1320 To prepare for a lowered power domain, the policy-maker
1321 informs all its interested parties of the new power state of its device.
1322 If any do not acknowledge immediately, then the policy-maker also will not.
1323
1324 To prepare for a raised power domain, the policy-maker calls its controlling
1325 driver to switch the device to the appropriate power state for the new
1326 domain state. When that is accomplished, the policy-maker informs
1327 all its interested parties of the new power state. If any interested driver
1328 or the controlling driver does not acknowledge immediately, then the
1329 policy-maker also will not.
1330
1331 @param newPowerStateFlags
1332 These flags describe the character of power in the new domain state.
1333 They are not understood by the policy-maker. It asks the controlling
1334 driver to translate them into a state number within the power state array.
1335 (The policy-maker for the domain also doesn't understand the bits; they
1336 come from a outputPowerCharacter field of the power state array for
1337 the power domain.)
1338 @param whichParent
1339 This pointer identifies the calling parent. */
1340 IOReturn powerDomainDidChangeTo ( IOPMPowerFlags newPowerStateFlags, IOPowerConnection * whichParent );
1341
1342 /*! @function requestPowerDomainState
1343 The child of a power domain calls it parent here to request power of a certain
1344 character. It does this after lowering power in its own device which allows
1345 it to tolerate lower power in the domain, and it does this if it needs more
1346 power for its device than is currently available in the domain.
1347 @param desiredState
1348 These flags describe the power required for some state of the caller's device.
1349 They are not understood by either the child or the parent. They come from
1350 the power state array of the child (in the inputPowerRequirement field), and
1351 the parent compares them to bits in the outputPowerCharacter fields of its
1352 power state array.
1353 @param whichChild
1354 This points to the caller, so the power domain can know which child is requesting.
1355 @param specificationFlags
1356 This value modifies the parent's choice of power state.
1357 If the parameter is IOPMNextHigherState, the parent will choose the lowest state
1358 which matches desiredState and which is higher than the current state.
1359 If the parameter is IOPMHighestState , the parent will choose the highest state
1360 which matches desiredState.
1361 If the parameter is IOPMNextLowerState, the parent will choose the highest state
1362 which matches desiredState and which is lower than the current state.
1363 If the parameter is IOPMLowestState, the parent will choose the lowest state
1364 which matches desiredState.
1365 A state matches desiredState if all the bits set in desiredState are also set in the
1366 outputPowerCharacter field of that state in the parent's power state array.
1367 @result
1368 The power domain parent returns IOPMBadSpecification if specificationFlags
1369 not wellformed. It returns IOPMNoSuchState if no state in its array satisfies
1370 the callers specification. It returns IOPMNotYetInitialized if it has not power
1371 state array yet to compare with. Otherwise it returns IOPMNoErr. In the last
1372 case it will initiate its change to the new state if it has a parent in the hierarchy
1373 (or is the root power domain.) */
1374 virtual IOReturn requestPowerDomainState ( IOPMPowerFlags desiredState, IOPowerConnection * whichChild, unsigned long specificationFlags );
1375
1376 /*! @function makeUsable
1377 Some client of a device is asking that it become usable. Although
1378 this has not come from the policy-maker for the device, treat it exactly
1379 as if it had. In this way, subsequent requests for lower power from
1380 the policy-maker will pre-empt this request.
1381 We treat this as policy-maker request to switch to the highest power state.
1382 @result
1383 The return code reflects the state of the policy-maker's internal queue of power
1384 changes and can be ignored by the caller. */
1385 virtual IOReturn makeUsable ( void );
1386
1387 /*! @function temporaryPowerClampOn
1388 A power domain calls this method to hold itself in the highest power state until it
1389 has children, and at that point the domain state is controlled by the childrens'
1390 requirements.
1391 @result
1392 The return code reflects the state of the policy-maker's internal queue of power
1393 changes and can be ignored by the caller. */
1394 virtual IOReturn temporaryPowerClampOn ( void );
1395
1396 /*! @function changePowerStateTo
1397 The power-controlling driver calls the policy-maker here when it wants the device
1398 switched to a different power state. This is mildly ironic in that it is the controlling
1399 driver which does the switching, but it must do it this way so that the policy-maker
1400 can make sure the power domain is correct and to notify interested parties
1401 pre-change. When appropriate, the policy-maker will call the controlling driver and
1402 have it switch the device to the requested state in the usual way.
1403 This request by the controlling driver is sticky in that the policy-maker will not
1404 switch the device lower than this request, so if the driver needs power raised for
1405 some reason and then gets it and does what it needs, it should then rescind the
1406 request by requesting state zero. This will allow the policy-maker to control the
1407 device as usual.
1408 @param ordinal
1409 This is the number, in the power state array, of the desired power state.
1410 @result
1411 The return code reflects the state of the policy-maker's internal queue of power
1412 changes and can be ignored by the caller. */
1413 virtual IOReturn changePowerStateTo ( unsigned long ordinal );
1414
1415 /*! @function currentCapability
1416 Some object calls a policy-maker here to find out the current capability of a device.
1417 The policy-maker returns a copy of the capabilityFlags field for the current power
1418 state in the power state array. */
1419 virtual IOPMPowerFlags currentCapability ( void );
1420
1421 /*! @function currentPowerConsumption
1422 Some object calls a policy-maker here to find out the current power consumption of a device.
1423 The policy-maker returns a copy of the staticPower field for the current power state in the
1424 power state array. */
1425 virtual unsigned long currentPowerConsumption ( void );
1426
1427 /*! @function activityTickle
1428 A principal function of a policy-maker is deciding when the device is idle and can be
1429 powered down. To do this it needs to know when the device is being used. In some
1430 cases it is in the data path to the device so it knows when it is being used. In others
1431 it is not and must be told. The activityTickle method is provided for objects in the
1432 system to tell a policy-maker that its device is being used.
1433
1434 If the policy-maker is managing the idleness determination totally on its own, the
1435 paramter should be kIOPMSubclassPolicy, and the policy-maker should intercept
1436 the activityTickle call, because the superclass will do nothing with it.
1437
1438 The IOService superclass can manage idleness determination, too, with the simple
1439 mechanism of an idle timer and this activityTickle call. To start this up, the policy-
1440 maker calls its superclass at setIdleTimerPeriod. This starts a timer for the time
1441 interval specified in the call. When the timer expires, the superclass checks to see
1442 if there has been any activity since the last timer expiration. (It checks to see if
1443 activityTickle has been called). If there has been activity, it restarts the timer, and
1444 this process continues. When the timer expires, and there has been no device
1445 activity, the superclass lowers the device power state to the next lower state.
1446 This can continue until the device is in state zero.
1447
1448 After the device has been powered down by at least one power state,
1449 a call to activityTickle will cause the device to be switched to a higher state
1450 required for the activity.
1451
1452 activityTickle in the IOService superclass is meant to be called by sub-classed
1453 policy-makers, because only they understand the paramters. They may implement
1454 an activityTickle for their clients and then call this activityTickle in the superclass.
1455 @param type
1456 activityTickle with parameter kIOPMSubclassPolicy is not handled in IOService
1457 and should be intercepted by the subclass policy-maker.
1458 activityTickle with parameter kIOPMSuperclassPolicy1 causes an activity flag to be set,
1459 and the device state checked. If the device has been powered down, it is powered up again.
1460 @param stateNumber
1461 When the type parameter is kIOPMSuperclassPolicy1, the stateNumber contains
1462 the desired power state ordinal for the activity. If the device is in a lower state,
1463 the superclass will switch it to this state. This is for devices which can handle
1464 some accesses in lower power states than others; the device is powered up only
1465 as far as it needs to be for the activity.
1466 @result
1467 When the type parameter is kIOPMSuperclassPolicy1, the superclass returns true
1468 if the device is currently in the state specified by stateNumber. If it is in a lower
1469 state and must be brought up, it returns false. In this case the superclass will
1470 cause the device to be brought up. */
1471 virtual bool activityTickle ( unsigned long type, unsigned long stateNumber=0 );
1472
1473 /*! @function setAggressiveness
1474 The parent of a policy-maker calls it here while broadcasting an aggressiveness factor
1475 around the power management hierarchy.
1476
1477 A policy-maker may want to intercept this call if it needs to do something with the
1478 new factor, like change its idle timeout, for example. A policy-maker which does
1479 intercept should call setAggressiveness in its superclass, though.
1480 @param type
1481 There are several aggressiveness factors which can be broadcast. One is a general
1482 aggressiveness factor, and the others are specific to parts of the system, like the
1483 hard drive or the display. A policy-maker takes action only on a factor that applies
1484 to its policy. These factor types (e.g. kPMSetGeneralAggressiveness) are defined
1485 in pwr_mgt/IOPM.h.
1486 @param newLevel
1487 This is the aggressiveness factor's new value.
1488 @result
1489 setAggressiveness returns IOPMNoErr. */
1490 virtual IOReturn setAggressiveness ( unsigned long, unsigned long newLevel );
1491
1492 /*! @function getAggressiveness
1493 Return the current aggressiveness value for the given type.
1494 */
1495 virtual IOReturn getAggressiveness ( unsigned long, unsigned long * );
1496
1497 /*! @function systemWake
1498 The parent of a policy-maker calls it here while broadcasting a system wake event.
1499
1500 A policy-maker must intercept this call if its device can wake the system from sleep.
1501 It should check to see if its device did in fact wake the system, and if so, treat the
1502 waking action as activity: it should request power from its parent to keep the system
1503 up until it idles again.
1504
1505 A policy-maker which does intercept should call systemWake in its superclass.
1506 @result
1507 systemWake returns IOPMNoErr. */
1508 virtual IOReturn systemWake ( void );
1509
1510 /*! @function temperatureCriticalForZone
1511 A policy-maker calls its parent power domain to alert it to critical temperature in
1512 some thermal zone.
1513 @param whichZone
1514 This is a pointer to the IOService policy-maker for the thermal zone which has
1515 reported critical temperature.
1516 @result
1517 temperatureCriticalForZone returns IOPMNoErr. */
1518 virtual IOReturn temperatureCriticalForZone ( IOService * whichZone );
1519
1520 /*! @function youAreRoot
1521 The Platform Expert instantiates the root power domain IOService and
1522 calls it here to inform it that it is the root power domain.
1523 (The only difference between the root domain and any other power domain
1524 is that the root has no parent and therefore never calls it. */
1525 virtual IOReturn youAreRoot ( void );
1526
1527 /*! @function setPowerParent
1528 The Platform Expert or some other IOService calls a policy-maker here to
1529 inform it who its parent is in the power management hierarchy. This is
1530 part of the process of attaching a policy-maker into the hierarchy.
1531 @param theParent
1532 This is a pointer to the parent IOService power domain.
1533 @param stateKnown
1534 This is true if the parent knows its power state. (It would not if it doesn't yet
1535 have a parent or a controlling driver)
1536 @param currentState
1537 If the stateKnown parameter is true, these flags describe the character of
1538 power in the power domain. If the policy-maker has a controlling driver,
1539 the policy-maker asks the driver, given this power domain state,
1540 what state it would be in, and then it tells the driver to assume that state. */
1541 virtual IOReturn setPowerParent ( IOPowerConnection * theParent, bool stateKnown, IOPMPowerFlags currentState );
1542
1543 /*! @function addPowerChild
1544 The Platform Expert or some other IOService calls a power domain policy-maker
1545 here to introduce it to a child of it, a member of the domain.
1546 @param theChild
1547 This is a pointer to the child IOService, which is another power domain policy-maker
1548 or a device policy-maker. */
1549 virtual IOReturn addPowerChild ( IOService * theChild );
1550
1551 /*! @function removePowerChild
1552 A power domain policy-maker is called here to tell it that one of its enclosed members
1553 is disappearing. This happens when a device policy-maker hands off its responsibility
1554 to another policy-maker or when its device disappears. */
1555 virtual IOReturn removePowerChild ( IOPowerConnection * theChild );
1556
1557 /* @function command_received
1558 */
1559 virtual void command_received ( void *, void * , void * , void *);
1560
1561 /* @function start_PM_idle_timer
1562 */
1563 virtual void start_PM_idle_timer ( void );
1564
1565 /* @function PM_idle_timer_expiration
1566 */
1567 virtual void PM_idle_timer_expiration ( void );
1568
1569 /* @function PM_Clamp_Timer_Expired
1570 */
1571 virtual void PM_Clamp_Timer_Expired (void);
1572
1573 /*! @function setIdleTimerPeriod
1574 A policy-maker which uses the type 1 idleness determination provided by IOService
1575 calls its superclass here to set or change the idle timer period.
1576
1577 See activityTickle for a description of this idleness determination.
1578 @param period
1579 This is the desired idle timer period in seconds.
1580 @result
1581 The normal return is IOPMNoErr, but it is possible to return kIOReturnError if there
1582 was difficulty creating the timer event or the command queue, for example (which is
1583 done only on the first call.) */
1584 virtual IOReturn setIdleTimerPeriod ( unsigned long );
1585
1586 /*! @function getPMworkloop
1587 */
1588 virtual IOWorkLoop *getPMworkloop ( void );
1589
1590 /* @function ack_timer_ticked
1591 */
1592 void ack_timer_ticked ( void );
1593
1594 /* @function settleTimerExpired
1595 */
1596 void settleTimerExpired ( void );
1597
1598 IOReturn serializedAllowPowerChange2 ( unsigned long );
1599 IOReturn serializedCancelPowerChange2 ( unsigned long );
1600
1601 // implemented by power-controlling driver...
1602
1603 /*! @function setPowerState
1604 A policy-maker (usually its superclass) calls its controlling driver here to change
1605 the power state of its device.
1606 @param powerStateOrdinal
1607 This is the number in the power state array of the state the driver is being
1608 instructed to switch to.
1609 @param whatDevice
1610 This is a pointer to the policy-maker. It is useful when a single power-controlling
1611 driver controls multiple devices and needs to know for which device it is being
1612 called.
1613 @result
1614 The driver returns IOPMAckImplied if it has complied with the request when it
1615 returns. If it has started the process of changing power state but not finished
1616 it, it should return a number of microseconds which is an upper limit of the time
1617 it will need to finish. Then, when it has completed the power switch, it should
1618 call acknowledgeSetPowerState in the policy-maker. */
1619 virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService* whatDevice );
1620
1621 /*! @function clampPowerOn
1622 This method sets the device to the highest power state and ensures it stays there
1623 until a timer of duration length expires.
1624 */
1625 virtual void clampPowerOn (unsigned long duration);
1626
1627 /*! @function maxCapabilityForDomainState
1628 A policy-maker (usually its superclass) calls its controlling driver here to find out
1629 the highest power state possible for a given power domain state. This happens
1630 when the power domain is changing state and the policy-maker wants to find
1631 out what states the device is capable of in the new domain state.
1632 @param domainState
1633 These flags describe the character of domain power in some domain power state.
1634 The flags are not understood by the calling policy-maker; they were passed to it
1635 by its power domain parent. They come from the outputPowerCharacter field
1636 of a state in the power domain's power state array.
1637
1638 This method is implemented in a simple way in IOService. It scans the power state
1639 array looking for the highest state whose inputPowerRequirement field exactly
1640 matches the parameter. If more intelligent determination is required, the
1641 power-controlling driver should implement the method and override the superclass.
1642 @result
1643 A state number is returned. */
1644 virtual unsigned long maxCapabilityForDomainState ( IOPMPowerFlags domainState );
1645
1646 /*! @function initialPowerStateForDomainState
1647 A policy-maker (usually its superclass) calls its controlling driver here to find out
1648 which power state the device is in, given the current power domain state. This
1649 happens once, when the policy-maker is initializing, and the controlling driver
1650 can use this to know what state the device is in initially.
1651 @param domainState
1652 These flags describe the character of domain power in the current state of the
1653 power domain. The flags are not understood by the calling policy-maker; they
1654 were passed to it by its power domain parent. They come from the
1655 outputPowerCharacter field of the current power state in the power domain's
1656 power state array.
1657
1658 This method is implemented in a simple way in IOService. It scans the power state
1659 array looking for the highest state whose inputPowerRequirement field exactly
1660 matches the parameter. If more intelligent determination is required, the
1661 power-controlling driver should implement the method and override the superclass.
1662 @result
1663 A state number is returned. */
1664 virtual unsigned long initialPowerStateForDomainState ( IOPMPowerFlags );
1665
1666 /*! @function powerStateForDomainState
1667 A policy-maker (usually its superclass) calls its controlling driver here to find out
1668 what power state the device would be in for a given power domain state. This
1669 happens when the power domain is changing state and the policy-maker wants
1670 to find out the effect of the change.
1671 @param domainState
1672 These flags describe the character of domain power in some domain power state.
1673 The flags are not understood by the calling policy-maker; they were passed to it
1674 by its power domain parent. They come from the outputPowerCharacter field
1675 of a state in the power domain's power state array.
1676
1677 This method is implemented in a simple way in IOService. It scans the power state
1678 array looking for the highest state whose inputPowerRequirement field exactly
1679 matches the parameter. If more intelligent determination is required, the
1680 power-controlling driver should implement the method and override the superclass.
1681 @result
1682 A state number is returned. */
1683 virtual unsigned long powerStateForDomainState ( IOPMPowerFlags domainState );
1684
1685 /*! @function powerStateWillChangeTo
1686 A policy-maker informs interested parties that its device is about to change to
1687 a different power state. Interested parties are those that have registered for
1688 this notification via registerInterestedDriver and also the power-controlling
1689 driver which is registered as an interested driver automatically when it registers
1690 as the controlling driver.
1691 @param capabilities
1692 These flags describe the capability of the device in the new power state. They
1693 are not understood by the policy-maker; they come from the capabilityFlags field
1694 of the new state in the power state array.
1695 @param stateNumber
1696 This is the number of the state in the state array that the device is switching to.
1697 @param whatDevice
1698 This points to the policy-maker, and it is used by a driver which is receiving power
1699 state change notifications for multiple devices.
1700 @result
1701 The driver returns IOPMAckImplied if it has prepared for the power change when it
1702 returns. If it has started preparing but not finished, it should return a number of
1703 microseconds which is an upper limit of the time it will need to finish preparing.
1704 Then, when it has completed its preparations, it should call acknowledgePowerChange
1705 in the policy-maker. */
1706 virtual IOReturn powerStateWillChangeTo ( IOPMPowerFlags, unsigned long, IOService* );
1707
1708 /*! @function powerStateDidChangeTo
1709 A policy-maker informs interested parties that its device has changed to
1710 a different power state. Interested parties are those that have registered for
1711 this notification via registerInterestedDriver and also the power-controlling
1712 driver which is registered as an interested driver automatically when it registers
1713 as the controlling driver.
1714 @param capabilities
1715 These flags describe the capability of the device in the new power state. They
1716 are not understood by the policy-maker; they come from the capabilityFlags field
1717 of the new state in the power state array.
1718 @param stateNumber
1719 This is the number of the state in the state array that the device has switched to.
1720 @param whatDevice
1721 This points to the policy-maker, and it is used by a driver which is receiving power
1722 state change notifications for multiple devices.
1723 @result
1724 The driver returns IOPMAckImplied if it has prepared for the power change when it
1725 returns. If it has started preparing but not finished, it should return a number of
1726 microseconds which is an upper limit of the time it will need to finish preparing.
1727 Then, when it has completed its preparations, it should call acknowledgePowerChange
1728 in the policy-maker. */
1729 virtual IOReturn powerStateDidChangeTo ( IOPMPowerFlags, unsigned long, IOService* );
1730
1731 /*! @function didYouWakeSystem
1732 A policy-maker calls its power driver here to ask if its device is the one
1733 which just woke the system from sleep.
1734 @result
1735 The driver returns true if it did wake the system and false if it didn't. */
1736 virtual bool didYouWakeSystem ( void );
1737
1738 /*! @function newTemperature
1739 A thermal-zone driver calls its policy-maker here to tell it that the temperature in
1740 the zone has changed. The thermal-zone policy-maker uses this information to
1741 manage its thermal zone.
1742 @param currentTemp
1743 This is the new temperature in the thermal zone.
1744 @param whichZone
1745 This is a pointer to the controlling driver.
1746 */
1747 virtual IOReturn newTemperature ( long currentTemp, IOService * whichZone );
1748
1749 virtual bool askChangeDown ( unsigned long );
1750 virtual bool tellChangeDown ( unsigned long );
1751 bool tellChangeDown1 ( unsigned long );
1752 bool tellChangeDown2 ( unsigned long );
1753 virtual void tellNoChangeDown ( unsigned long );
1754 virtual void tellChangeUp ( unsigned long );
1755 virtual IOReturn allowPowerChange ( unsigned long refcon );
1756 virtual IOReturn cancelPowerChange ( unsigned long refcon );
1757
1758 // ...implemented by power-controlling driver
1759
1760 protected:
1761 /*! @function changePowerStateToPriv
1762 A policy-maker calls its superclass here to change the power state of the device.
1763 The superclass takes care of making sure the power domain state is appropriate
1764 and informing interested parties. It calls the controlling driver to make the change.
1765 @param ordinal
1766 This is the number, in the power state array, of the desired power state.
1767 @result
1768 The return code reflects the state of the policy-maker's internal queue of power
1769 changes and can be ignored by the caller.
1770 */
1771 IOReturn changePowerStateToPriv ( unsigned long ordinal );
1772
1773 /*! @function powerOverrideOnPriv
1774 A policy-maker normally keeps its device at the highest state required by itself,
1775 its power-controlling driver, and its children (when the power domain state
1776 allows). There may be times, however, when a policy-maker needs the power
1777 state lower than its driver or its children desire, and when this is the case, it
1778 calls powerOverrideOnPriv in its superclass to enable this override. When the override
1779 is on, the superclass keeps the device in the state desired by the policy-maker
1780 (requested via changePowerStateToPriv), regardless of the children's or driver's desire.
1781 Turning on the override will initiate a power change if the policy-maker's desired
1782 power state is different from the maximum of the controlling driver's desire and
1783 the children's desires.
1784 @result
1785 The return code reflects the state of the policy-maker's internal queue of power
1786 changes and can be ignored by the caller. */
1787 IOReturn powerOverrideOnPriv ( void );
1788
1789 /*! @function powerOverrideOffPriv
1790 When a policy-maker has enabled the override, it can disable it again by calling
1791 this method in its superclass. This will allow the superclass to keep the device
1792 at the highest state required by itself, its power-controlling driver, and its
1793 children (when the power domain state allows). Turning off the override
1794 will initiate a power change if the policy-maker's desired power state is different
1795 from the maximum of the controlling driver's desire and the children's desires.
1796 @result
1797 The return code reflects the state of the policy-maker's internal queue of power
1798 changes and can be ignored by the caller. */
1799 IOReturn powerOverrideOffPriv ( void );
1800
1801 /*! @function powerChangeDone
1802 A policy-maker calls itself here when a power change is completely done, when
1803 all interested parties have acknowledged the powerStateDidChangeTo call.
1804 The implementation here is null; the method is meant to be overridden by
1805 subclassed policy-makers, and that is how one finds out that a power change
1806 it initiated is complete
1807 @param stateNumber
1808 This is the number of the state in the state array that the device has switched from. */
1809 virtual void powerChangeDone ( unsigned long );
1810
1811 bool tellClientsWithResponse ( int messageType );
1812 void tellClients ( int messageType );
1813
1814 private:
1815
1816 IOReturn enqueuePowerChange ( unsigned long, unsigned long, unsigned long, IOPowerConnection *, unsigned long );
1817 void setParentInfo ( IOPMPowerFlags, IOPowerConnection * );
1818 IOReturn notifyAll ( bool is_prechange );
1819 bool notifyChild ( IOPowerConnection * nextObject, bool is_prechange );
1820 bool inform ( IOPMinformee * nextObject, bool is_prechange );
1821
1822 // Power Management state machine
1823 // power change initiated by driver
1824 void OurChangeTellClientsPowerDown ( void );
1825 void OurChangeTellPriorityClientsPowerDown ( void );
1826 void OurChangeNotifyInterestedDriversWillChange ( void );
1827 void OurChangeSetPowerState ( void );
1828 void OurChangeWaitForPowerSettle ( void );
1829 void OurChangeNotifyInterestedDriversDidChange ( void );
1830 void OurChangeFinish ( void );
1831
1832 // downward power change initiated by a power parent
1833 IOReturn ParentDownTellPriorityClientsPowerDown_Immediate ( void );
1834 IOReturn ParentDownNotifyInterestedDriversWillChange_Immediate ( void );
1835 void ParentDownTellPriorityClientsPowerDown_Delayed ( void );
1836 void ParentDownNotifyInterestedDriversWillChange_Delayed ( void );
1837 IOReturn ParentDownSetPowerState_Immediate ( void );
1838 IOReturn ParentDownWaitForPowerSettleAndNotifyDidChange_Immediate ( void );
1839 void ParentDownNotifyDidChangeAndAcknowledgeChange_Delayed ( void );
1840 void ParentDownSetPowerState_Delayed ( void );
1841 void ParentDownWaitForPowerSettle_Delayed ( void );
1842 void ParentDownAcknowledgeChange_Delayed ( void );
1843
1844 // upward power change initiated by a power parent
1845 void ParentUpSetPowerState_Delayed ( void );
1846 IOReturn ParentUpSetPowerState_Immediate ( void );
1847 IOReturn ParentUpWaitForSettleTime_Immediate ( void );
1848 IOReturn ParentUpNotifyInterestedDriversDidChange_Immediate ( void );
1849 void ParentUpWaitForSettleTime_Delayed ( void );
1850 void ParentUpNotifyInterestedDriversDidChange_Delayed ( void );
1851 void ParentUpAcknowledgePowerChange_Delayed ( void );
1852
1853 void all_done ( void );
1854 void all_acked ( void );
1855 void driver_acked ( void );
1856 void start_ack_timer ( void );
1857 void stop_ack_timer ( void );
1858
1859 unsigned long compute_settle_time ( void );
1860 IOReturn startSettleTimer ( unsigned long delay );
1861 IOReturn changeState ( void );
1862 IOReturn add_child_to_active_change ( IOPowerConnection * );
1863 IOReturn add_driver_to_active_change ( IOPMinformee * );
1864 IOReturn instruct_driver ( unsigned long newState );
1865 bool acquire_lock ( void );
1866 IOReturn start_parent_change ( unsigned long queue_head );
1867 void start_our_change ( unsigned long queue_head );
1868 IOReturn ask_parent ( unsigned long requestedState );
1869 bool checkForDone ( void );
1870 bool responseValid ( unsigned long x );
1871 IOReturn allowCancelCommon ( void );
1872 void computeDesiredState ( void );
1873 void rebuildChildClampBits ( void );
1874 IOReturn temporaryMakeUsable ( void );
1875 };
1876
1877 #endif /* ! _IOKIT_IOSERVICE_H */