]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/pwr_mgt/RootDomain.h
9a514bdbca7a86f731b2a87048b6b6ae82b0b4a0
[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 // Handle callbacks from IOService::systemWillShutdown()
391 void acknowledgeSystemWillShutdown( IOService * from );
392
393 // Handle platform halt and restart notifications
394 void handlePlatformHaltRestart( UInt32 pe_type );
395
396 IOReturn shutdownSystem( void );
397 IOReturn restartSystem( void );
398 void handleSleepTimerExpiration( void );
399
400 bool activitySinceSleep(void);
401 bool abortHibernation(void);
402
403 IOReturn joinAggressiveness( IOService * service );
404 void handleAggressivesRequests( void );
405
406 void tracePoint( uint8_t point );
407 void tracePoint( uint8_t point, uint8_t data );
408 void traceDetail( uint32_t data32 );
409
410 bool systemMessageFilter(
411 void * object, void * arg1, void * arg2, void * arg3 );
412
413 void updatePreventIdleSleepList(
414 IOService * service, bool addNotRemove );
415 void updatePreventSystemSleepList(
416 IOService * service, bool addNotRemove );
417
418 void publishPMSetting(
419 const OSSymbol * feature, uint32_t where, uint32_t * featureID );
420
421 /*! @function recordPMEvent
422 @abstract Logs IOService PM event timing.
423 @discussion Should only be called from IOServicePM. Should not be exported.
424 @result kIOReturn on success.
425 */
426 IOReturn recordPMEvent( PMEventDetails *details );
427 IOReturn recordAndReleasePMEvent( PMEventDetails *details );
428 IOReturn recordPMEventGated( PMEventDetails *details );
429 IOReturn recordAndReleasePMEventGated( PMEventDetails *details );
430
431 void pmStatsRecordEvent(
432 int eventIndex,
433 AbsoluteTime timestamp);
434
435 void pmStatsRecordApplicationResponse(
436 const OSSymbol *response,
437 const char *name,
438 int messageType,
439 uint32_t delay_ms,
440 int app_pid);
441
442
443 /*! @function suspendPMNotificationsForPID
444 @abstract kernel process management calls this to disable sleep/wake notifications
445 when a process is suspended.
446 @param pid the process ID
447 @param doSuspend true suspends the notifications; false enables them
448 */
449 void suspendPMNotificationsForPID( uint32_t pid, bool doSuspend);
450
451 /*! @function pmNotificationIsSuspended
452 @abstract returns true if PM notifications have been suspended
453 @param pid the process ID
454 @result true if the process has been suspended
455 */
456 bool pmNotificationIsSuspended( uint32_t pid );
457
458
459 #if HIBERNATION
460 bool getHibernateSettings(
461 uint32_t * hibernateMode,
462 uint32_t * hibernateFreeRatio,
463 uint32_t * hibernateFreeTime );
464 #endif
465
466 private:
467 friend class PMSettingObject;
468 friend class RootDomainUserClient;
469 friend class PMAssertionsTracker;
470
471 static IOReturn sysPowerDownHandler( void * target, void * refCon,
472 UInt32 messageType, IOService * service,
473 void * messageArgument, vm_size_t argSize );
474
475 static IOReturn displayWranglerNotification( void * target, void * refCon,
476 UInt32 messageType, IOService * service,
477 void * messageArgument, vm_size_t argSize );
478
479 static IOReturn rootBusyStateChangeHandler( void * target, void * refCon,
480 UInt32 messageType, IOService * service,
481 void * messageArgument, vm_size_t argSize );
482
483 static bool displayWranglerMatchPublished( void * target, void * refCon,
484 IOService * newService,
485 IONotifier * notifier);
486
487 static bool batteryPublished( void * target, void * refCon,
488 IOService * resourceService,
489 IONotifier * notifier);
490
491 IOService * wrangler;
492
493 IOLock *featuresDictLock; // guards supportedFeatures
494 IOPMPowerStateQueue *pmPowerStateQueue;
495
496 OSArray *allowedPMSettings;
497 OSArray *noPublishPMSettings;
498 PMTraceWorker *pmTracer;
499 PMAssertionsTracker *pmAssertions;
500
501 // Settings controller info
502 IOLock *settingsCtrlLock;
503 OSDictionary *settingsCallbacks;
504 OSDictionary *fPMSettingsDict;
505
506 IONotifier *_batteryPublishNotifier;
507 IONotifier *_displayWranglerNotifier;
508
509 // Statistics
510 const OSSymbol *_statsNameKey;
511 const OSSymbol *_statsPIDKey;
512 const OSSymbol *_statsTimeMSKey;
513 const OSSymbol *_statsResponseTypeKey;
514 const OSSymbol *_statsMessageTypeKey;
515
516 OSString *queuedSleepWakeUUIDString;
517 OSArray *pmStatsAppResponses;
518
519 bool uuidPublished;
520
521 // Pref: idle time before idle sleep
522 unsigned long sleepSlider;
523 unsigned long idleSeconds;
524 uint64_t autoWakeStart;
525 uint64_t autoWakeEnd;
526
527 // Difference between sleepSlider and longestNonSleepSlider
528 unsigned long extraSleepDelay;
529
530 // Used to wait between say display idle and system idle
531 thread_call_t extraSleepTimer;
532 thread_call_t diskSyncCalloutEntry;
533
534 // IOPMActions parameter encoding
535 enum {
536 kPMActionsFlagIsDisplayWrangler = 0x00000001,
537 kPMActionsFlagIsGraphicsDevice = 0x00000002,
538 kPMActionsFlagIsAudioDevice = 0x00000004,
539 kPMActionsFlagLimitPower = 0x00000008,
540 kPMActionsPCIBitNumberMask = 0x000000ff
541 };
542
543 // Track system capabilities.
544 uint32_t _desiredCapability;
545 uint32_t _currentCapability;
546 uint32_t _pendingCapability;
547 uint32_t _highestCapability;
548 OSSet * _joinedCapabilityClients;
549 uint32_t _systemStateGeneration;
550
551 // Type of clients that can receive system messages.
552 enum {
553 kSystemMessageClientConfigd = 0x01,
554 kSystemMessageClientApp = 0x02,
555 kSystemMessageClientUser = 0x03,
556 kSystemMessageClientKernel = 0x04,
557 kSystemMessageClientAll = 0x07
558 };
559 uint32_t _systemMessageClientMask;
560
561 // Power state and capability change transitions.
562 enum {
563 kSystemTransitionNone = 0,
564 kSystemTransitionSleep = 1,
565 kSystemTransitionWake = 2,
566 kSystemTransitionCapability = 3,
567 kSystemTransitionNewCapClient = 4
568 } _systemTransitionType;
569
570 unsigned int systemBooting :1;
571 unsigned int systemShutdown :1;
572 unsigned int systemDarkWake :1;
573 unsigned int clamshellExists :1;
574 unsigned int clamshellClosed :1;
575 unsigned int clamshellDisabled :1;
576 unsigned int desktopMode :1;
577 unsigned int acAdaptorConnected :1;
578
579 unsigned int idleSleepTimerPending :1;
580 unsigned int userDisabledAllSleep :1;
581 unsigned int ignoreTellChangeDown :1;
582 unsigned int wranglerAsleep :1;
583 unsigned int wranglerTickled :1;
584 unsigned int wranglerSleepIgnored :1;
585 unsigned int graphicsSuppressed :1;
586 unsigned int darkWakeThermalAlarm :1;
587
588 unsigned int capabilityLoss :1;
589 unsigned int pciCantSleepFlag :1;
590 unsigned int pciCantSleepValid :1;
591 unsigned int logWranglerTickle :1;
592 unsigned int logGraphicsClamp :1;
593 unsigned int darkWakeToSleepASAP :1;
594 unsigned int darkWakeMaintenance :1;
595 unsigned int darkWakeSleepService :1;
596
597 unsigned int darkWakePostTickle :1;
598 unsigned int sleepTimerMaintenance :1;
599 unsigned int lowBatteryCondition :1;
600 unsigned int darkWakeThermalEmergency:1;
601 unsigned int hibernateDisabled :1;
602 unsigned int hibernateNoDefeat :1;
603 unsigned int rejectWranglerTickle :1;
604 unsigned int wranglerTickleLatched :1;
605
606 uint32_t hibernateMode;
607 uint32_t userActivityCount;
608 uint32_t userActivityAtSleep;
609 uint32_t lastSleepReason;
610 uint32_t hibernateAborted;
611
612 // Info for communicating system state changes to PMCPU
613 int32_t idxPMCPUClamshell;
614 int32_t idxPMCPULimitedPower;
615
616 IOOptionBits platformSleepSupport;
617 uint32_t _debugWakeSeconds;
618 uint32_t _lastDebugWakeSeconds;
619
620 queue_head_t aggressivesQueue;
621 thread_call_t aggressivesThreadCall;
622 OSData * aggressivesData;
623
624 AbsoluteTime wranglerSleepTime;
625 AbsoluteTime systemWakeTime;
626
627 // PCI top-level PM trace
628 IOService * pciHostBridgeDevice;
629 IOService * pciHostBridgeDriver;
630
631 IONotifier * systemCapabilityNotifier;
632
633 IOPMTimeline *timeline;
634
635 typedef struct {
636 uint32_t pid;
637 uint32_t refcount;
638 } PMNotifySuspendedStruct;
639
640 uint32_t pmSuspendedCapacity;
641 uint32_t pmSuspendedSize;
642 PMNotifySuspendedStruct *pmSuspendedPIDS;
643
644 OSSet * preventIdleSleepList;
645 OSSet * preventSystemSleepList;
646
647 #if HIBERNATION
648 clock_sec_t _standbyTimerResetSeconds;
649 #endif
650
651 int findSuspendedPID(uint32_t pid, uint32_t *outRefCount);
652
653 // IOPMrootDomain internal sleep call
654 IOReturn privateSleepSystem( uint32_t sleepReason );
655 void reportUserInput( void );
656 bool checkSystemCanSleep( IOOptionBits options = 0 );
657 bool checkSystemCanSustainFullWake( void );
658
659 void adjustPowerState( bool sleepASAP = false );
660 void setQuickSpinDownTimeout( void );
661 void restoreUserSpinDownTimeout( void );
662
663 bool shouldSleepOnClamshellClosed(void );
664 void sendClientClamshellNotification( void );
665
666 // Inform PMCPU of changes to state like lid, AC vs. battery
667 void informCPUStateChange( uint32_t type, uint32_t value );
668
669 void dispatchPowerEvent( uint32_t event, void * arg0, uint64_t arg1 );
670 void handlePowerNotification( UInt32 msg );
671
672 IOReturn setPMSetting(const OSSymbol *, OSObject *);
673
674 void startIdleSleepTimer( uint32_t inSeconds );
675 void cancelIdleSleepTimer( void );
676
677 IOReturn setAggressiveness(
678 unsigned long type,
679 unsigned long value,
680 IOOptionBits options );
681
682 void synchronizeAggressives(
683 queue_head_t * services,
684 const AggressivesRecord * array,
685 int count );
686
687 void broadcastAggressives(
688 const AggressivesRecord * array,
689 int count );
690
691 // getPMTraceMemoryDescriptor should only be called by our friend RootDomainUserClient
692 IOMemoryDescriptor *getPMTraceMemoryDescriptor(void);
693
694 IOReturn setPMAssertionUserLevels(IOPMDriverAssertionType);
695
696 void publishSleepWakeUUID( bool shouldPublish );
697
698 void evaluatePolicy( int stimulus, uint32_t arg = 0 );
699
700 void evaluateAssertions(IOPMDriverAssertionType newAssertions,
701 IOPMDriverAssertionType oldAssertions);
702
703 void deregisterPMSettingObject( PMSettingObject * pmso );
704
705 #if HIBERNATION
706 bool getSleepOption( const char * key, uint32_t * option );
707 bool evaluateSystemSleepPolicy( IOPMSystemSleepParameters * p, int sleepPhase );
708 void evaluateSystemSleepPolicyEarly( void );
709 void evaluateSystemSleepPolicyFinal( void );
710 #endif /* HIBERNATION */
711
712 bool latchDisplayWranglerTickle( bool latch );
713 #endif /* XNU_KERNEL_PRIVATE */
714 };
715
716 #ifdef XNU_KERNEL_PRIVATE
717 class IORootParent: public IOService
718 {
719 OSDeclareFinalStructors(IORootParent)
720
721 public:
722 static void initialize( void );
723 virtual OSObject * copyProperty( const char * aKey ) const;
724 bool start( IOService * nub );
725 void shutDownSystem( void );
726 void restartSystem( void );
727 void sleepSystem( void );
728 void dozeSystem( void );
729 void sleepToDoze( void );
730 void wakeSystem( void );
731 };
732 #endif /* XNU_KERNEL_PRIVATE */
733
734 #endif /* _IOKIT_ROOTDOMAIN_H */