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