]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/pwr_mgt/RootDomain.h
xnu-1699.26.8.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / RootDomain.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28#ifndef _IOKIT_ROOTDOMAIN_H
29#define _IOKIT_ROOTDOMAIN_H
30
31#include <IOKit/IOService.h>
32#include <IOKit/pwr_mgt/IOPM.h>
b0d623f7 33#include "IOKit/pwr_mgt/IOPMPrivate.h"
6d2010ae 34#include <IOKit/IOBufferMemoryDescriptor.h>
b0d623f7
A
35
36#ifdef XNU_KERNEL_PRIVATE
b0d623f7 37struct AggressivesRecord;
6d2010ae
A
38struct IOPMMessageFilterContext;
39struct IOPMActions;
40class PMSettingObject;
41class IOPMTimeline;
42class PMEventDetails;
43class PMTraceWorker;
55e303ae 44class IOPMPowerStateQueue;
1c79356b 45class RootDomainUserClient;
6d2010ae
A
46class PMAssertionsTracker;
47#endif
1c79356b 48
0b4c1975
A
49/*!
50 * Types for PM Assertions
51 * For creating, releasing, and getting PM assertion levels.
52 */
53
54/*! IOPMDriverAssertionType
55 * A bitfield describing a set of assertions. May be used to specify which assertions
56 * to set with <link>IOPMrootDomain::createPMAssertion</link>; or to query which
57 * assertions are set with <link>IOPMrootDomain::releasePMAssertion</link>.
58 */
59typedef uint64_t IOPMDriverAssertionType;
60
61/* IOPMDriverAssertionID
62 * Drivers may create PM assertions to request system behavior (keep the system awake,
63 * or keep the display awake). When a driver creates an assertion via
64 * <link>IOPMrootDomain::createPMAssertion</link>, PM returns a handle to
65 * the assertion of type IOPMDriverAssertionID.
66 */
67typedef uint64_t IOPMDriverAssertionID;
68#define kIOPMUndefinedDriverAssertionID 0
69
70/* IOPMDriverAssertionLevel
71 * Possible values for IOPMDriverAssertionLevel are <link>kIOPMDriverAssertionLevelOff</link>
72 * and <link>kIOPMDriverAssertionLevelOn</link>
73 */
74typedef uint32_t IOPMDriverAssertionLevel;
75#define kIOPMDriverAssertionLevelOff 0
76#define kIOPMDriverAssertionLevelOn 255
77
b0d623f7
A
78/*
79 * Flags for get/setSleepSupported()
80 */
1c79356b
A
81enum {
82 kRootDomainSleepNotSupported = 0x00000000,
83 kRootDomainSleepSupported = 0x00000001,
0b4e3aa0 84 kFrameBufferDeepSleepSupported = 0x00000002,
b0d623f7 85 kPCICantSleep = 0x00000004
1c79356b
A
86};
87
2d21ac55
A
88/*
89 *IOPMrootDomain registry property keys
90 */
91#define kRootDomainSupportedFeatures "Supported Features"
92#define kRootDomainSleepReasonKey "Last Sleep Reason"
93#define kRootDomainSleepOptionsKey "Last Sleep Options"
b0d623f7
A
94#define kIOPMRootDomainWakeReasonKey "Wake Reason"
95#define kIOPMRootDomainWakeTypeKey "Wake Type"
4a3eedf9 96#define kIOPMRootDomainPowerStatusKey "Power Status"
2d21ac55
A
97
98/*
99 * Possible sleep reasons found under kRootDomainSleepReasonsKey
100 */
101#define kIOPMClamshellSleepKey "Clamshell Sleep"
102#define kIOPMPowerButtonSleepKey "Power Button Sleep"
103#define kIOPMSoftwareSleepKey "Software Sleep"
104#define kIOPMOSSwitchHibernationKey "OS Switch Sleep"
105#define kIOPMIdleSleepKey "Idle Sleep"
106#define kIOPMLowPowerSleepKey "Low Power Sleep"
107#define kIOPMThermalEmergencySleepKey "Thermal Emergency Sleep"
b0d623f7 108#define kIOPMMaintenanceSleepKey "Maintenance Sleep"
2d21ac55
A
109
110/*
111 * String constants for communication with PM CPU
112 */
113#define kIOPMRootDomainLidCloseCString "LidClose"
114#define kIOPMRootDomainBatPowerCString "BatPower"
0c530ab8 115
b0d623f7
A
116/*
117 * Supported Feature bitfields for IOPMrootDomain::publishFeature()
118 */
e5568f75 119enum {
b0d623f7
A
120 kIOPMSupportedOnAC = (1<<0),
121 kIOPMSupportedOnBatt = (1<<1),
122 kIOPMSupportedOnUPS = (1<<2)
e5568f75 123};
4452a7af 124
b0d623f7
A
125typedef IOReturn (*IOPMSettingControllerCallback)
126 (OSObject *target, const OSSymbol *type,
0c530ab8 127 OSObject *val, uintptr_t refcon);
4452a7af 128
b0d623f7
A
129__BEGIN_DECLS
130IONotifier * registerSleepWakeInterest(
131 IOServiceInterestHandler, void *, void * = 0);
0c530ab8 132
b0d623f7
A
133IONotifier * registerPrioritySleepWakeInterest(
134 IOServiceInterestHandler handler,
135 void * self, void * ref = 0);
0c530ab8 136
b0d623f7 137IOReturn acknowledgeSleepWakeNotification(void * );
0c530ab8 138
b0d623f7
A
139IOReturn vetoSleepWakeNotification(void * PMrefcon);
140__END_DECLS
1c79356b 141
d52fe63f 142#define IOPM_ROOTDOMAIN_REV 2
1c79356b
A
143
144class IOPMrootDomain: public IOService
145{
b0d623f7 146 OSDeclareFinalStructors(IOPMrootDomain)
0b4e3aa0 147
b0d623f7 148public:
0b4e3aa0 149 static IOPMrootDomain * construct( void );
2d21ac55 150
b0d623f7
A
151 virtual bool start( IOService * provider );
152 virtual IOReturn setAggressiveness( unsigned long, unsigned long );
153 virtual IOReturn getAggressiveness( unsigned long, unsigned long * );
2d21ac55 154
b0d623f7
A
155 virtual IOReturn sleepSystem( void );
156 IOReturn sleepSystemOptions( OSDictionary *options );
157
158 virtual IOReturn setProperties( OSObject * );
0b4c1975 159 virtual bool serializeProperties( OSSerialize * s ) const;
4a3eedf9
A
160
161/*! @function systemPowerEventOccurred
162 @abstract Other drivers may inform IOPMrootDomain of system PM events
163 @discussion systemPowerEventOccurred is a richer alternative to receivePowerNotification()
164 Only Apple-owned kexts should have reason to call systemPowerEventOccurred.
165 @param event An OSSymbol describing the type of power event.
166 @param value A 32-bit integer value associated with the event.
167 @param shouldUpdate indicates whether the root domain should send a notification
168 to interested parties. Pass false if you're calling systemPowerEventOccurred
169 several times in succession; and pass true only on the last invocatino.
170 @result kIOReturnSuccess on success */
b0d623f7
A
171
172 IOReturn systemPowerEventOccurred(
173 const OSSymbol *event,
174 uint32_t intValue );
175
176 IOReturn systemPowerEventOccurred(
177 const OSSymbol *event,
178 OSObject *value );
179
180 virtual IOReturn receivePowerNotification( UInt32 msg );
181
182 virtual void setSleepSupported( IOOptionBits flags );
183
184 virtual IOOptionBits getSleepSupported( void );
185
186 void wakeFromDoze( void );
0c530ab8
A
187
188 // KEXT driver announces support of power management feature
b0d623f7
A
189
190 void publishFeature( const char *feature );
0c530ab8
A
191
192 // KEXT driver announces support of power management feature
193 // And specifies power sources with kIOPMSupportedOn{AC/Batt/UPS} bitfield.
194 // Returns a unique uint32_t identifier for later removing support for this
195 // feature.
196 // NULL is acceptable for uniqueFeatureID for kexts without plans to unload.
b0d623f7
A
197
198 void publishFeature( const char *feature,
199 uint32_t supportedWhere,
200 uint32_t *uniqueFeatureID);
0c530ab8
A
201
202 // KEXT driver announces removal of a previously published power management
203 // feature. Pass 'uniqueFeatureID' returned from publishFeature()
0c530ab8 204
b0d623f7 205 IOReturn removePublishedFeature( uint32_t removeFeatureID );
9bccf70c 206
0c530ab8 207/*! @function copyPMSetting
b0d623f7 208 @abstract Copy the current value for a PM setting. Returns an OSNumber or
0c530ab8 209 OSData depending on the setting.
b0d623f7
A
210 @param whichSetting Name of the desired setting.
211 @result OSObject value if valid, NULL otherwise. */
212
213 OSObject * copyPMSetting( OSSymbol *whichSetting );
214
0c530ab8
A
215/*! @function registerPMSettingController
216 @abstract Register for callbacks on changes to certain PM settings.
217 @param settings NULL terminated array of C strings, each string for a PM
218 setting that the caller is interested in and wants to get callbacks for.
219 @param callout C function ptr or member function cast as such.
220 @param target The target of the callback, usually 'this'
221 @param refcon Will be passed to caller in callback; for caller's use.
222 @param handle Caller should keep the OSObject * returned here. If non-NULL,
223 handle will have a retain count of 1 on return. To deregister, pass to
224 unregisterPMSettingController()
225 @result kIOReturnSuccess on success. */
b0d623f7
A
226
227 IOReturn registerPMSettingController(
0c530ab8
A
228 const OSSymbol *settings[],
229 IOPMSettingControllerCallback callout,
230 OSObject *target,
231 uintptr_t refcon,
232 OSObject **handle); // out param
233
234/*! @function registerPMSettingController
235 @abstract Register for callbacks on changes to certain PM settings.
236 @param settings NULL terminated array of C strings, each string for a PM
237 setting that the caller is interested in and wants to get callbacks for.
238 @param supportedPowerSources bitfield indicating which power sources these
239 settings are supported for (kIOPMSupportedOnAC, etc.)
240 @param callout C function ptr or member function cast as such.
241 @param target The target of the callback, usually 'this'
242 @param refcon Will be passed to caller in callback; for caller's use.
243 @param handle Caller should keep the OSObject * returned here. If non-NULL,
244 handle will have a retain count of 1 on return. To deregister, pass to
245 unregisterPMSettingController()
246 @result kIOReturnSuccess on success. */
b0d623f7
A
247
248 IOReturn registerPMSettingController(
0c530ab8
A
249 const OSSymbol *settings[],
250 uint32_t supportedPowerSources,
251 IOPMSettingControllerCallback callout,
252 OSObject *target,
253 uintptr_t refcon,
254 OSObject **handle); // out param
e5568f75 255
b0d623f7
A
256 virtual IONotifier * registerInterest(
257 const OSSymbol * typeOfInterest,
258 IOServiceInterestHandler handler,
259 void * target, void * ref = 0 );
b0d623f7
A
260
261 virtual IOReturn callPlatformFunction(
262 const OSSymbol *functionName,
263 bool waitForFunction,
264 void *param1, void *param2,
265 void *param3, void *param4 );
266
0b4c1975
A
267/*! @function createPMAssertion
268 @abstract Creates an assertion to influence system power behavior.
269 @param whichAssertionBits A bitfield specify the assertion that the caller requests.
270 @param assertionLevel An integer detailing the initial assertion level, kIOPMDriverAssertionLevelOn
271 or kIOPMDriverAssertionLevelOff.
272 @param ownerService A pointer to the caller's IOService class, for tracking.
273 @param ownerDescription A reverse-DNS string describing the caller's identity and reason.
274 @result On success, returns a new assertion of type IOPMDriverAssertionID
275*/
276 IOPMDriverAssertionID createPMAssertion(
277 IOPMDriverAssertionType whichAssertionsBits,
278 IOPMDriverAssertionLevel assertionLevel,
279 IOService *ownerService,
280 const char *ownerDescription);
281
282/* @function setPMAssertionLevel
283 @abstract Modify the level of a pre-existing assertion.
284 @discussion Change the value of a PM assertion to influence system behavior,
285 without undergoing the work required to create or destroy an assertion. Suggested
286 for clients who will assert and de-assert needs for PM behavior several times over
287 their lifespan.
288 @param assertionID An assertion ID previously returned by <link>createPMAssertion</link>
289 @param assertionLevel The new assertion level.
290 @result kIOReturnSuccess if it worked; kIOReturnNotFound or other IOReturn error on failure.
291*/
292 IOReturn setPMAssertionLevel(IOPMDriverAssertionID assertionID, IOPMDriverAssertionLevel assertionLevel);
293
294/*! @function getPMAssertionLevel
295 @absract Returns the active level of the specified assertion(s).
296 @discussion Returns <link>kIOPMDriverAssertionLevelOff</link> or
297 <link>kIOPMDriverAssertionLevelOn</link>. If multiple assertions are specified
298 in the bitfield, only returns <link>kIOPMDriverAssertionLevelOn</link>
299 if all assertions are active.
300 @param whichAssertionBits Bits defining the assertion or assertions the caller is interested in
301 the level of. If in doubt, pass <link>kIOPMDriverAssertionCPUBit</link> as the argument.
302 @result Returns <link>kIOPMDriverAssertionLevelOff</link> or
303 <link>kIOPMDriverAssertionLevelOn</link> indicating the specified assertion's levels, if available.
304 If the assertions aren't supported on this machine, or aren't recognized by the OS, the
305 result is undefined.
306*/
307 IOPMDriverAssertionLevel getPMAssertionLevel(IOPMDriverAssertionType whichAssertionBits);
308
309/*! @function releasePMAssertion
310 @abstract Removes an assertion to influence system power behavior.
311 @result On success, returns a new assertion of type IOPMDriverAssertionID *
312*/
313 IOReturn releasePMAssertion(IOPMDriverAssertionID releaseAssertion);
314
b0d623f7
A
315private:
316 virtual IOReturn changePowerStateTo( unsigned long ordinal );
317 virtual IOReturn changePowerStateToPriv( unsigned long ordinal );
318 virtual IOReturn requestPowerDomainState( IOPMPowerFlags, IOPowerConnection *, unsigned long );
319 virtual void powerChangeDone( unsigned long );
320 virtual bool tellChangeDown( unsigned long );
321 virtual bool askChangeDown( unsigned long );
322 virtual void tellChangeUp( unsigned long );
323 virtual void tellNoChangeDown( unsigned long );
324#ifdef XNU_KERNEL_PRIVATE
325 /* Root Domain internals */
326public:
6d2010ae
A
327 void tagPowerPlaneService(
328 IOService * service,
329 IOPMActions * actions );
b0d623f7 330
6d2010ae
A
331 void overrideOurPowerChange(
332 IOService * service,
333 IOPMActions * actions,
334 unsigned long * inOutPowerState,
335 uint32_t * inOutChangeFlags );
0b4c1975 336
6d2010ae 337 void handleOurPowerChangeStart(
b0d623f7 338 IOService * service,
6d2010ae
A
339 IOPMActions * actions,
340 uint32_t powerState,
341 uint32_t * inOutChangeFlags );
342
343 void handleOurPowerChangeDone(
344 IOService * service,
345 IOPMActions * actions,
346 uint32_t powerState,
347 uint32_t changeFlags );
348
349 void overridePowerChangeForUIService(
350 IOService * service,
351 IOPMActions * actions,
352 unsigned long * inOutPowerState,
353 uint32_t * inOutChangeFlags );
354
355 void handleActivityTickleForDisplayWrangler(
356 IOService * service,
357 IOPMActions * actions );
358
359 bool shouldDelayChildNotification(
360 IOService * service );
361
362 void handlePowerChangeStartForPCIDevice(
363 IOService * service,
364 IOPMActions * actions,
365 uint32_t powerState,
366 uint32_t * inOutChangeFlags );
367
368 void handlePowerChangeDoneForPCIDevice(
369 IOService * service,
370 IOPMActions * actions,
371 uint32_t powerState,
b0d623f7
A
372 uint32_t changeFlags );
373
6d2010ae
A
374 void askChangeDownDone(
375 IOPMPowerChangeFlags * inOutChangeFlags,
376 bool * cancel );
377
378 void handlePublishSleepWakeUUID(
379 bool shouldPublish);
380
381 void handleQueueSleepWakeUUID(
382 OSObject *obj);
383
7ddcb079 384 IOReturn setMaintenanceWakeCalendar(const IOPMCalendarStruct * calendar );
b0d623f7
A
385
386 // Handle callbacks from IOService::systemWillShutdown()
6d2010ae 387 void acknowledgeSystemWillShutdown( IOService * from );
2d21ac55 388
b0d623f7 389 // Handle platform halt and restart notifications
6d2010ae
A
390 void handlePlatformHaltRestart( UInt32 pe_type );
391
392 IOReturn shutdownSystem( void );
393 IOReturn restartSystem( void );
394 void handleSleepTimerExpiration( void );
2d21ac55 395
0b4c1975
A
396 bool activitySinceSleep(void);
397 bool abortHibernation(void);
b0d623f7
A
398
399 IOReturn joinAggressiveness( IOService * service );
400 void handleAggressivesRequests( void );
401
402 void tracePoint( uint8_t point );
6d2010ae
A
403 void tracePoint( uint8_t point, uint8_t data );
404 void traceDetail( uint32_t data32 );
405
406 bool systemMessageFilter(
407 void * object, void * arg1, void * arg2, void * arg3 );
408
7ddcb079
A
409 void publishPMSetting(
410 const OSSymbol * feature, uint32_t where, uint32_t * featureID );
411
6d2010ae
A
412/*! @function recordPMEvent
413 @abstract Logs IOService PM event timing.
414 @discussion Should only be called from IOServicePM. Should not be exported.
415 @result kIOReturn on success.
416*/
417 IOReturn recordPMEvent( PMEventDetails *details );
418 IOReturn recordAndReleasePMEvent( PMEventDetails *details );
419 IOReturn recordPMEventGated( PMEventDetails *details );
420 IOReturn recordAndReleasePMEventGated( PMEventDetails *details );
421
422 void pmStatsRecordEvent(
423 int eventIndex,
424 AbsoluteTime timestamp);
425
426 void pmStatsRecordApplicationResponse(
427 const OSSymbol *response,
428 const char *name,
429 int messageType,
430 uint32_t delay_ms,
431 int app_pid);
432
433#if HIBERNATION
434 bool getHibernateSettings(
435 uint32_t * hibernateMode,
436 uint32_t * hibernateFreeRatio,
437 uint32_t * hibernateFreeTime );
438#endif
b0d623f7 439
1c79356b 440private:
b0d623f7 441 friend class PMSettingObject;
0b4c1975 442 friend class RootDomainUserClient;
6d2010ae
A
443 friend class PMAssertionsTracker;
444
445 static IOReturn sysPowerDownHandler( void * target, void * refCon,
446 UInt32 messageType, IOService * service,
447 void * messageArgument, vm_size_t argSize );
448
449 static IOReturn displayWranglerNotification( void * target, void * refCon,
450 UInt32 messageType, IOService * service,
451 void * messageArgument, vm_size_t argSize );
452
453 static IOReturn rootBusyStateChangeHandler( void * target, void * refCon,
454 UInt32 messageType, IOService * service,
455 void * messageArgument, vm_size_t argSize );
456
457 static bool displayWranglerMatchPublished( void * target, void * refCon,
458 IOService * newService,
459 IONotifier * notifier);
460
461 static bool batteryPublished( void * target, void * refCon,
462 IOService * resourceService,
463 IONotifier * notifier);
1c79356b 464
b0d623f7 465 IOService * wrangler;
6d2010ae 466 IOService * wranglerConnection;
0c530ab8 467
b0d623f7
A
468 IOLock *featuresDictLock; // guards supportedFeatures
469 IOPMPowerStateQueue *pmPowerStateQueue;
470
471 OSArray *allowedPMSettings;
7ddcb079 472 OSArray *noPublishPMSettings;
b0d623f7 473 PMTraceWorker *pmTracer;
0b4c1975 474 PMAssertionsTracker *pmAssertions;
0c530ab8 475
b0d623f7 476 // Settings controller info
6d2010ae 477 IOLock *settingsCtrlLock;
b0d623f7
A
478 OSDictionary *settingsCallbacks;
479 OSDictionary *fPMSettingsDict;
480
481 IONotifier *_batteryPublishNotifier;
482 IONotifier *_displayWranglerNotifier;
483
484 // Statistics
6d2010ae
A
485 const OSSymbol *_statsNameKey;
486 const OSSymbol *_statsPIDKey;
487 const OSSymbol *_statsTimeMSKey;
488 const OSSymbol *_statsResponseTypeKey;
489 const OSSymbol *_statsMessageTypeKey;
b0d623f7
A
490
491 OSString *queuedSleepWakeUUIDString;
b0d623f7
A
492 OSArray *pmStatsAppResponses;
493
6d2010ae 494 bool uuidPublished;
b0d623f7
A
495 PMStatsStruct pmStats;
496
497 // Pref: idle time before idle sleep
498 unsigned long sleepSlider;
499 unsigned long idleSeconds;
500 uint64_t autoWakeStart;
501 uint64_t autoWakeEnd;
0c530ab8
A
502
503 // Difference between sleepSlider and longestNonSleepSlider
b0d623f7 504 unsigned long extraSleepDelay;
0c530ab8
A
505
506 // Used to wait between say display idle and system idle
6d2010ae 507 thread_call_t extraSleepTimer;
b0d623f7
A
508 thread_call_t diskSyncCalloutEntry;
509
6d2010ae
A
510 // IOPMActions parameter encoding
511 enum {
512 kPMActionsFlagIsDisplayWrangler = 0x00000001,
513 kPMActionsFlagIsGraphicsDevice = 0x00000002,
514 kPMActionsFlagIsAudioDevice = 0x00000004,
515 kPMActionsFlagLimitPower = 0x00000008,
516 kPMActionsPCIBitNumberMask = 0x000000ff
517 };
518
519 // Track system capabilities.
520 uint32_t _desiredCapability;
521 uint32_t _currentCapability;
522 uint32_t _pendingCapability;
523 uint32_t _highestCapability;
524 OSSet * _joinedCapabilityClients;
525 uint32_t _systemStateGeneration;
526
527 // Type of clients that can receive system messages.
528 enum {
529 kSystemMessageClientConfigd = 0x01,
530 kSystemMessageClientApp = 0x02,
531 kSystemMessageClientUser = 0x03,
532 kSystemMessageClientKernel = 0x04,
533 kSystemMessageClientAll = 0x07
534 };
535 uint32_t _systemMessageClientMask;
536
537 // Power state and capability change transitions.
538 enum {
539 kSystemTransitionNone = 0,
540 kSystemTransitionSleep = 1,
541 kSystemTransitionWake = 2,
542 kSystemTransitionCapability = 3,
543 kSystemTransitionNewCapClient = 4
544 } _systemTransitionType;
b0d623f7
A
545
546 unsigned int systemBooting :1;
547 unsigned int systemShutdown :1;
6d2010ae 548 unsigned int systemDarkWake :1;
b0d623f7 549 unsigned int clamshellExists :1;
6d2010ae
A
550 unsigned int clamshellClosed :1;
551 unsigned int clamshellDisabled :1;
b0d623f7 552 unsigned int desktopMode :1;
6d2010ae 553 unsigned int acAdaptorConnected :1;
b0d623f7 554
b0d623f7
A
555 unsigned int idleSleepTimerPending :1;
556 unsigned int userDisabledAllSleep :1;
6d2010ae
A
557 unsigned int childPreventSystemSleep :1;
558 unsigned int ignoreTellChangeDown :1;
b0d623f7 559 unsigned int wranglerAsleep :1;
6d2010ae
A
560 unsigned int wranglerTickled :1;
561 unsigned int wranglerSleepIgnored :1;
562 unsigned int graphicsSuppressed :1;
563
564 unsigned int capabilityLoss :1;
565 unsigned int pciCantSleepFlag :1;
566 unsigned int pciCantSleepValid :1;
567 unsigned int logWranglerTickle :1;
568 unsigned int logGraphicsClamp :1;
569 unsigned int darkWakeToSleepASAP :1;
570 unsigned int darkWakeMaintenance :1;
7ddcb079 571 unsigned int darkWakeSleepService :1;
6d2010ae 572 unsigned int darkWakePostTickle :1;
b0d623f7 573
0b4c1975
A
574 unsigned int sleepTimerMaintenance :1;
575 unsigned int lowBatteryCondition :1;
576 unsigned int hibernateDisabled :1;
577 unsigned int hibernateNoDefeat :1;
578 unsigned int hibernateAborted :1;
6d2010ae 579 unsigned int rejectWranglerTickle :1;
0b4c1975
A
580
581 uint32_t hibernateMode;
582 uint32_t userActivityCount;
583 uint32_t userActivityAtSleep;
584 uint32_t lastSleepReason;
585
b0d623f7
A
586 // Info for communicating system state changes to PMCPU
587 int32_t idxPMCPUClamshell;
588 int32_t idxPMCPULimitedPower;
589
590 IOOptionBits platformSleepSupport;
6d2010ae 591 uint32_t _debugWakeSeconds;
7ddcb079 592 uint32_t _lastDebugWakeSeconds;
b0d623f7
A
593
594 queue_head_t aggressivesQueue;
595 thread_call_t aggressivesThreadCall;
596 OSData * aggressivesData;
597
598 AbsoluteTime wranglerSleepTime;
6d2010ae
A
599 AbsoluteTime systemWakeTime;
600
b0d623f7
A
601 // PCI top-level PM trace
602 IOService * pciHostBridgeDevice;
6d2010ae 603 IOService * pciHostBridgeDriver;
b0d623f7 604
6d2010ae 605 IONotifier * systemCapabilityNotifier;
2d21ac55 606
6d2010ae 607 IOPMTimeline *timeline;
0b4e3aa0 608
7ddcb079
A
609 IOPMSystemSleepPolicyHandler _sleepPolicyHandler;
610 void * _sleepPolicyTarget;
611 IOPMSystemSleepPolicyVariables *_sleepPolicyVars;
612
6d2010ae
A
613 // IOPMrootDomain internal sleep call
614 IOReturn privateSleepSystem( uint32_t sleepReason );
615 void reportUserInput( void );
616 bool checkSystemCanSleep( IOOptionBits options = 0 );
0b4e3aa0 617
6d2010ae
A
618 void adjustPowerState( bool sleepASAP = false );
619 void setQuickSpinDownTimeout( void );
620 void restoreUserSpinDownTimeout( void );
0b4e3aa0 621
6d2010ae
A
622 bool shouldSleepOnClamshellClosed(void );
623 void sendClientClamshellNotification( void );
483a1d10 624
2d21ac55 625 // Inform PMCPU of changes to state like lid, AC vs. battery
6d2010ae 626 void informCPUStateChange( uint32_t type, uint32_t value );
b0d623f7 627
6d2010ae
A
628 void dispatchPowerEvent( uint32_t event, void * arg0, uint64_t arg1 );
629 void handlePowerNotification( UInt32 msg );
b0d623f7 630
6d2010ae 631 IOReturn setPMSetting(const OSSymbol *, OSObject *);
0c530ab8 632
6d2010ae
A
633 void startIdleSleepTimer( uint32_t inSeconds );
634 void cancelIdleSleepTimer( void );
b0d623f7
A
635
636 IOReturn setAggressiveness(
637 unsigned long type,
638 unsigned long value,
639 IOOptionBits options );
640
641 void synchronizeAggressives(
642 queue_head_t * services,
643 const AggressivesRecord * array,
644 int count );
645
646 void broadcastAggressives(
647 const AggressivesRecord * array,
648 int count );
649
6d2010ae
A
650 // getPMTraceMemoryDescriptor should only be called by our friend RootDomainUserClient
651 IOMemoryDescriptor *getPMTraceMemoryDescriptor(void);
2d21ac55 652
0b4c1975 653 IOReturn setPMAssertionUserLevels(IOPMDriverAssertionType);
6d2010ae 654
0b4c1975
A
655 void publishSleepWakeUUID( bool shouldPublish );
656
6d2010ae
A
657 void evaluatePolicy( int stimulus, uint32_t arg = 0 );
658
7ddcb079
A
659 void evaluateAssertions(IOPMDriverAssertionType newAssertions,
660 IOPMDriverAssertionType oldAssertions);
661
6d2010ae
A
662 void deregisterPMSettingObject( PMSettingObject * pmso );
663
0b4c1975
A
664#if HIBERNATION
665 bool getSleepOption( const char * key, uint32_t * option );
7ddcb079 666 bool evaluateSystemSleepPolicy( IOPMSystemSleepParameters * p, int phase );
0b4c1975
A
667 void evaluateSystemSleepPolicyEarly( void );
668 void evaluateSystemSleepPolicyFinal( void );
669#endif /* HIBERNATION */
b0d623f7 670#endif /* XNU_KERNEL_PRIVATE */
1c79356b
A
671};
672
b0d623f7 673#ifdef XNU_KERNEL_PRIVATE
1c79356b
A
674class IORootParent: public IOService
675{
b0d623f7 676 OSDeclareFinalStructors(IORootParent)
0b4e3aa0 677
b0d623f7 678public:
6d2010ae
A
679 static void initialize( void );
680 virtual OSObject * copyProperty( const char * aKey ) const;
b0d623f7
A
681 bool start( IOService * nub );
682 void shutDownSystem( void );
683 void restartSystem( void );
684 void sleepSystem( void );
685 void dozeSystem( void );
686 void sleepToDoze( void );
687 void wakeSystem( void );
1c79356b 688};
b0d623f7 689#endif /* XNU_KERNEL_PRIVATE */
1c79356b 690
b0d623f7 691#endif /* _IOKIT_ROOTDOMAIN_H */