]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/pwr_mgt/RootDomain.h
c817bf40da90dae358d6a5fdf362eb62345f96d1
[apple/xnu.git] / iokit / IOKit / pwr_mgt / RootDomain.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 #ifndef _IOKIT_ROOTDOMAIN_H
29 #define _IOKIT_ROOTDOMAIN_H
30
31 #include <IOKit/IOService.h>
32 #include <IOKit/pwr_mgt/IOPM.h>
33 #include <IOKit/IOBufferMemoryDescriptor.h>
34
35 #ifdef XNU_KERNEL_PRIVATE
36 struct AggressivesRecord;
37 struct IOPMMessageFilterContext;
38 struct IOPMActions;
39 struct IOPMSystemSleepParameters;
40 class PMSettingObject;
41 class IOPMTimeline;
42 class PMEventDetails;
43 class PMTraceWorker;
44 class IOPMPowerStateQueue;
45 class RootDomainUserClient;
46 class PMAssertionsTracker;
47 #endif
48
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 */
59 typedef 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 */
67 typedef 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 */
74 typedef uint32_t IOPMDriverAssertionLevel;
75 #define kIOPMDriverAssertionLevelOff 0
76 #define kIOPMDriverAssertionLevelOn 255
77
78 /*
79 * Flags for get/setSleepSupported()
80 */
81 enum {
82 kRootDomainSleepNotSupported = 0x00000000,
83 kRootDomainSleepSupported = 0x00000001,
84 kFrameBufferDeepSleepSupported = 0x00000002,
85 kPCICantSleep = 0x00000004
86 };
87
88 /*
89 *IOPMrootDomain registry property keys
90 */
91 #define kRootDomainSupportedFeatures "Supported Features"
92 #define kRootDomainSleepReasonKey "Last Sleep Reason"
93 #define kRootDomainSleepOptionsKey "Last Sleep Options"
94 #define kIOPMRootDomainWakeReasonKey "Wake Reason"
95 #define kIOPMRootDomainWakeTypeKey "Wake Type"
96 #define kIOPMRootDomainPowerStatusKey "Power Status"
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"
108 #define kIOPMMaintenanceSleepKey "Maintenance Sleep"
109
110 /*
111 * String constants for communication with PM CPU
112 */
113 #define kIOPMRootDomainLidCloseCString "LidClose"
114 #define kIOPMRootDomainBatPowerCString "BatPower"
115
116 /*
117 * Supported Feature bitfields for IOPMrootDomain::publishFeature()
118 */
119 enum {
120 kIOPMSupportedOnAC = (1<<0),
121 kIOPMSupportedOnBatt = (1<<1),
122 kIOPMSupportedOnUPS = (1<<2)
123 };
124
125 typedef IOReturn (*IOPMSettingControllerCallback)
126 (OSObject *target, const OSSymbol *type,
127 OSObject *val, uintptr_t refcon);
128
129 __BEGIN_DECLS
130 IONotifier * registerSleepWakeInterest(
131 IOServiceInterestHandler, void *, void * = 0);
132
133 IONotifier * registerPrioritySleepWakeInterest(
134 IOServiceInterestHandler handler,
135 void * self, void * ref = 0);
136
137 IOReturn acknowledgeSleepWakeNotification(void * );
138
139 IOReturn vetoSleepWakeNotification(void * PMrefcon);
140 __END_DECLS
141
142 #define IOPM_ROOTDOMAIN_REV 2
143
144 class IOPMrootDomain: public IOService
145 {
146 OSDeclareFinalStructors(IOPMrootDomain)
147
148 public:
149 static IOPMrootDomain * construct( void );
150
151 virtual bool start( IOService * provider );
152 virtual IOReturn setAggressiveness( unsigned long, unsigned long );
153 virtual IOReturn getAggressiveness( unsigned long, unsigned long * );
154
155 virtual IOReturn sleepSystem( void );
156 IOReturn sleepSystemOptions( OSDictionary *options );
157
158 virtual IOReturn setProperties( OSObject * );
159 virtual bool serializeProperties( OSSerialize * s ) const;
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 */
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 );
187
188 // KEXT driver announces support of power management feature
189
190 void publishFeature( const char *feature );
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.
197
198 void publishFeature( const char *feature,
199 uint32_t supportedWhere,
200 uint32_t *uniqueFeatureID);
201
202 // KEXT driver announces removal of a previously published power management
203 // feature. Pass 'uniqueFeatureID' returned from publishFeature()
204
205 IOReturn removePublishedFeature( uint32_t removeFeatureID );
206
207 /*! @function copyPMSetting
208 @abstract Copy the current value for a PM setting. Returns an OSNumber or
209 OSData depending on the setting.
210 @param whichSetting Name of the desired setting.
211 @result OSObject value if valid, NULL otherwise. */
212
213 OSObject * copyPMSetting( OSSymbol *whichSetting );
214
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. */
226
227 IOReturn registerPMSettingController(
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. */
247
248 IOReturn registerPMSettingController(
249 const OSSymbol *settings[],
250 uint32_t supportedPowerSources,
251 IOPMSettingControllerCallback callout,
252 OSObject *target,
253 uintptr_t refcon,
254 OSObject **handle); // out param
255
256 virtual IONotifier * registerInterest(
257 const OSSymbol * typeOfInterest,
258 IOServiceInterestHandler handler,
259 void * target, void * ref = 0 );
260
261 virtual IOReturn callPlatformFunction(
262 const OSSymbol *functionName,
263 bool waitForFunction,
264 void *param1, void *param2,
265 void *param3, void *param4 );
266
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
315 private:
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 */
326 public:
327 void tagPowerPlaneService(
328 IOService * service,
329 IOPMActions * actions );
330
331 void overrideOurPowerChange(
332 IOService * service,
333 IOPMActions * actions,
334 unsigned long * inOutPowerState,
335 uint32_t * inOutChangeFlags );
336
337 void handleOurPowerChangeStart(
338 IOService * service,
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,
372 uint32_t changeFlags );
373
374 void askChangeDownDone(
375 IOPMPowerChangeFlags * inOutChangeFlags,
376 bool * cancel );
377
378 void handlePublishSleepWakeUUID(
379 bool shouldPublish);
380
381 void handleQueueSleepWakeUUID(
382 OSObject *obj);
383
384 void handleSuspendPMNotificationClient(
385 uint32_t pid, bool doSuspend);
386
387 IOReturn setMaintenanceWakeCalendar(
388 const IOPMCalendarStruct * calendar );
389
390 IOReturn getSystemSleepType( uint32_t * sleepType );
391
392 // Handle callbacks from IOService::systemWillShutdown()
393 void acknowledgeSystemWillShutdown( IOService * from );
394
395 // Handle platform halt and restart notifications
396 void handlePlatformHaltRestart( UInt32 pe_type );
397
398 IOReturn shutdownSystem( void );
399 IOReturn restartSystem( void );
400 void handleSleepTimerExpiration( void );
401
402 bool activitySinceSleep(void);
403 bool abortHibernation(void);
404
405 IOReturn joinAggressiveness( IOService * service );
406 void handleAggressivesRequests( void );
407
408 void tracePoint( uint8_t point );
409 void tracePoint( uint8_t point, uint8_t data );
410 void traceDetail( uint32_t data32 );
411
412 bool systemMessageFilter(
413 void * object, void * arg1, void * arg2, void * arg3 );
414
415 void updatePreventIdleSleepList(
416 IOService * service, bool addNotRemove );
417 void updatePreventSystemSleepList(
418 IOService * service, bool addNotRemove );
419
420 void publishPMSetting(
421 const OSSymbol * feature, uint32_t where, uint32_t * featureID );
422
423 /*! @function recordPMEvent
424 @abstract Logs IOService PM event timing.
425 @discussion Should only be called from IOServicePM. Should not be exported.
426 @result kIOReturn on success.
427 */
428 IOReturn recordPMEvent( PMEventDetails *details );
429 IOReturn recordAndReleasePMEvent( PMEventDetails *details );
430 IOReturn recordPMEventGated( PMEventDetails *details );
431 IOReturn recordAndReleasePMEventGated( PMEventDetails *details );
432
433 void pmStatsRecordEvent(
434 int eventIndex,
435 AbsoluteTime timestamp);
436
437 void pmStatsRecordApplicationResponse(
438 const OSSymbol *response,
439 const char *name,
440 int messageType,
441 uint32_t delay_ms,
442 int app_pid);
443
444
445 /*! @function suspendPMNotificationsForPID
446 @abstract kernel process management calls this to disable sleep/wake notifications
447 when a process is suspended.
448 @param pid the process ID
449 @param doSuspend true suspends the notifications; false enables them
450 */
451 void suspendPMNotificationsForPID( uint32_t pid, bool doSuspend);
452
453 /*! @function pmNotificationIsSuspended
454 @abstract returns true if PM notifications have been suspended
455 @param pid the process ID
456 @result true if the process has been suspended
457 */
458 bool pmNotificationIsSuspended( uint32_t pid );
459
460 #if HIBERNATION
461 bool getHibernateSettings(
462 uint32_t * hibernateMode,
463 uint32_t * hibernateFreeRatio,
464 uint32_t * hibernateFreeTime );
465 #endif
466
467 private:
468 friend class PMSettingObject;
469 friend class RootDomainUserClient;
470 friend class PMAssertionsTracker;
471
472 static IOReturn sysPowerDownHandler( void * target, void * refCon,
473 UInt32 messageType, IOService * service,
474 void * messageArgument, vm_size_t argSize );
475
476 static IOReturn displayWranglerNotification( void * target, void * refCon,
477 UInt32 messageType, IOService * service,
478 void * messageArgument, vm_size_t argSize );
479
480 static IOReturn rootBusyStateChangeHandler( void * target, void * refCon,
481 UInt32 messageType, IOService * service,
482 void * messageArgument, vm_size_t argSize );
483
484 static bool displayWranglerMatchPublished( void * target, void * refCon,
485 IOService * newService,
486 IONotifier * notifier);
487
488 static bool batteryPublished( void * target, void * refCon,
489 IOService * resourceService,
490 IONotifier * notifier);
491
492 IOService * wrangler;
493
494 IOLock *featuresDictLock; // guards supportedFeatures
495 IOPMPowerStateQueue *pmPowerStateQueue;
496
497 OSArray *allowedPMSettings;
498 OSArray *noPublishPMSettings;
499 PMTraceWorker *pmTracer;
500 PMAssertionsTracker *pmAssertions;
501
502 // Settings controller info
503 IOLock *settingsCtrlLock;
504 OSDictionary *settingsCallbacks;
505 OSDictionary *fPMSettingsDict;
506
507 IONotifier *_batteryPublishNotifier;
508 IONotifier *_displayWranglerNotifier;
509
510 // Statistics
511 const OSSymbol *_statsNameKey;
512 const OSSymbol *_statsPIDKey;
513 const OSSymbol *_statsTimeMSKey;
514 const OSSymbol *_statsResponseTypeKey;
515 const OSSymbol *_statsMessageTypeKey;
516
517 OSString *queuedSleepWakeUUIDString;
518 OSArray *pmStatsAppResponses;
519
520 bool uuidPublished;
521
522 // Pref: idle time before idle sleep
523 unsigned long sleepSlider;
524 unsigned long idleSeconds;
525 uint64_t autoWakeStart;
526 uint64_t autoWakeEnd;
527
528 // Difference between sleepSlider and longestNonSleepSlider
529 unsigned long extraSleepDelay;
530
531 // Used to wait between say display idle and system idle
532 thread_call_t extraSleepTimer;
533 thread_call_t diskSyncCalloutEntry;
534
535 // IOPMActions parameter encoding
536 enum {
537 kPMActionsFlagIsDisplayWrangler = 0x00000001,
538 kPMActionsFlagIsGraphicsDevice = 0x00000002,
539 kPMActionsFlagIsAudioDevice = 0x00000004,
540 kPMActionsFlagLimitPower = 0x00000008,
541 kPMActionsPCIBitNumberMask = 0x000000ff
542 };
543
544 // Track system capabilities.
545 uint32_t _desiredCapability;
546 uint32_t _currentCapability;
547 uint32_t _pendingCapability;
548 uint32_t _highestCapability;
549 OSSet * _joinedCapabilityClients;
550 uint32_t _systemStateGeneration;
551
552 // Type of clients that can receive system messages.
553 enum {
554 kSystemMessageClientConfigd = 0x01,
555 kSystemMessageClientApp = 0x02,
556 kSystemMessageClientUser = 0x03,
557 kSystemMessageClientKernel = 0x04,
558 kSystemMessageClientAll = 0x07
559 };
560 uint32_t _systemMessageClientMask;
561
562 // Power state and capability change transitions.
563 enum {
564 kSystemTransitionNone = 0,
565 kSystemTransitionSleep = 1,
566 kSystemTransitionWake = 2,
567 kSystemTransitionCapability = 3,
568 kSystemTransitionNewCapClient = 4
569 } _systemTransitionType;
570
571 unsigned int systemBooting :1;
572 unsigned int systemShutdown :1;
573 unsigned int systemDarkWake :1;
574 unsigned int clamshellExists :1;
575 unsigned int clamshellClosed :1;
576 unsigned int clamshellDisabled :1;
577 unsigned int desktopMode :1;
578 unsigned int acAdaptorConnected :1;
579 unsigned int clamshellSleepDisabled :1;
580
581 unsigned int idleSleepTimerPending :1;
582 unsigned int userDisabledAllSleep :1;
583 unsigned int ignoreTellChangeDown :1;
584 unsigned int wranglerAsleep :1;
585 unsigned int wranglerTickled :1;
586 unsigned int wranglerSleepIgnored :1;
587 unsigned int graphicsSuppressed :1;
588 unsigned int darkWakeThermalAlarm :1;
589
590 unsigned int capabilityLoss :1;
591 unsigned int pciCantSleepFlag :1;
592 unsigned int pciCantSleepValid :1;
593 unsigned int logWranglerTickle :1;
594 unsigned int logGraphicsClamp :1;
595 unsigned int darkWakeToSleepASAP :1;
596 unsigned int darkWakeMaintenance :1;
597 unsigned int darkWakeSleepService :1;
598
599 unsigned int darkWakePostTickle :1;
600 unsigned int sleepTimerMaintenance :1;
601 unsigned int lowBatteryCondition :1;
602 unsigned int darkWakeThermalEmergency:1;
603 unsigned int hibernateDisabled :1;
604 unsigned int hibernateNoDefeat :1;
605 unsigned int rejectWranglerTickle :1;
606 unsigned int wranglerTickleLatched :1;
607
608 uint32_t hibernateMode;
609 uint32_t userActivityCount;
610 uint32_t userActivityAtSleep;
611 uint32_t lastSleepReason;
612 uint32_t hibernateAborted;
613
614 // Info for communicating system state changes to PMCPU
615 int32_t idxPMCPUClamshell;
616 int32_t idxPMCPULimitedPower;
617
618 IOOptionBits platformSleepSupport;
619 uint32_t _debugWakeSeconds;
620 uint32_t _lastDebugWakeSeconds;
621
622 queue_head_t aggressivesQueue;
623 thread_call_t aggressivesThreadCall;
624 OSData * aggressivesData;
625
626 AbsoluteTime wranglerSleepTime;
627 AbsoluteTime systemWakeTime;
628
629 // PCI top-level PM trace
630 IOService * pciHostBridgeDevice;
631 IOService * pciHostBridgeDriver;
632
633 IONotifier * systemCapabilityNotifier;
634
635 IOPMTimeline *timeline;
636
637 typedef struct {
638 uint32_t pid;
639 uint32_t refcount;
640 } PMNotifySuspendedStruct;
641
642 uint32_t pmSuspendedCapacity;
643 uint32_t pmSuspendedSize;
644 PMNotifySuspendedStruct *pmSuspendedPIDS;
645
646 OSSet * preventIdleSleepList;
647 OSSet * preventSystemSleepList;
648
649 UInt32 _scheduledAlarms;
650 UInt32 _userScheduledAlarm;
651
652 #if HIBERNATION
653 clock_sec_t _standbyTimerResetSeconds;
654 #endif
655
656 int findSuspendedPID(uint32_t pid, uint32_t *outRefCount);
657
658 // IOPMrootDomain internal sleep call
659 IOReturn privateSleepSystem( uint32_t sleepReason );
660 void reportUserInput( void );
661 void setDisableClamShellSleep( bool );
662 bool checkSystemCanSleep( IOOptionBits options = 0 );
663 bool checkSystemCanSustainFullWake( void );
664
665 void adjustPowerState( bool sleepASAP = false );
666 void setQuickSpinDownTimeout( void );
667 void restoreUserSpinDownTimeout( void );
668
669 bool shouldSleepOnClamshellClosed(void );
670 void sendClientClamshellNotification( void );
671
672 // Inform PMCPU of changes to state like lid, AC vs. battery
673 void informCPUStateChange( uint32_t type, uint32_t value );
674
675 void dispatchPowerEvent( uint32_t event, void * arg0, uint64_t arg1 );
676 void handlePowerNotification( UInt32 msg );
677
678 IOReturn setPMSetting(const OSSymbol *, OSObject *);
679
680 void startIdleSleepTimer( uint32_t inSeconds );
681 void cancelIdleSleepTimer( void );
682
683 IOReturn setAggressiveness(
684 unsigned long type,
685 unsigned long value,
686 IOOptionBits options );
687
688 void synchronizeAggressives(
689 queue_head_t * services,
690 const AggressivesRecord * array,
691 int count );
692
693 void broadcastAggressives(
694 const AggressivesRecord * array,
695 int count );
696
697 // getPMTraceMemoryDescriptor should only be called by our friend RootDomainUserClient
698 IOMemoryDescriptor *getPMTraceMemoryDescriptor(void);
699
700 IOReturn setPMAssertionUserLevels(IOPMDriverAssertionType);
701
702 void publishSleepWakeUUID( bool shouldPublish );
703
704 void evaluatePolicy( int stimulus, uint32_t arg = 0 );
705
706 void evaluateAssertions(IOPMDriverAssertionType newAssertions,
707 IOPMDriverAssertionType oldAssertions);
708
709 void deregisterPMSettingObject( PMSettingObject * pmso );
710
711 #if HIBERNATION
712 bool getSleepOption( const char * key, uint32_t * option );
713 bool evaluateSystemSleepPolicy( IOPMSystemSleepParameters * p,
714 int phase, uint32_t * hibMode );
715 void evaluateSystemSleepPolicyEarly( void );
716 void evaluateSystemSleepPolicyFinal( void );
717 #endif /* HIBERNATION */
718
719 bool latchDisplayWranglerTickle( bool latch );
720 #endif /* XNU_KERNEL_PRIVATE */
721 };
722
723 #ifdef XNU_KERNEL_PRIVATE
724 class IORootParent: public IOService
725 {
726 OSDeclareFinalStructors(IORootParent)
727
728 public:
729 static void initialize( void );
730 virtual OSObject * copyProperty( const char * aKey ) const;
731 bool start( IOService * nub );
732 void shutDownSystem( void );
733 void restartSystem( void );
734 void sleepSystem( void );
735 void dozeSystem( void );
736 void sleepToDoze( void );
737 void wakeSystem( void );
738 };
739 #endif /* XNU_KERNEL_PRIVATE */
740
741 #endif /* _IOKIT_ROOTDOMAIN_H */