2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 #ifndef _IOKIT_ROOTDOMAIN_H
29 #define _IOKIT_ROOTDOMAIN_H
31 #include <IOKit/IOService.h>
32 #include <IOKit/pwr_mgt/IOPM.h>
33 #include <IOKit/IOBufferMemoryDescriptor.h>
35 #ifdef XNU_KERNEL_PRIVATE
36 struct AggressivesRecord
;
37 struct IOPMMessageFilterContext
;
39 struct IOPMSystemSleepParameters
;
40 class PMSettingObject
;
44 class IOPMPowerStateQueue
;
45 class RootDomainUserClient
;
46 class PMAssertionsTracker
;
50 * Types for PM Assertions
51 * For creating, releasing, and getting PM assertion levels.
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>.
59 typedef uint64_t IOPMDriverAssertionType
;
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.
67 typedef uint64_t IOPMDriverAssertionID
;
68 #define kIOPMUndefinedDriverAssertionID 0
70 /* IOPMDriverAssertionLevel
71 * Possible values for IOPMDriverAssertionLevel are <link>kIOPMDriverAssertionLevelOff</link>
72 * and <link>kIOPMDriverAssertionLevelOn</link>
74 typedef uint32_t IOPMDriverAssertionLevel
;
75 #define kIOPMDriverAssertionLevelOff 0
76 #define kIOPMDriverAssertionLevelOn 255
79 * Flags for get/setSleepSupported()
82 kRootDomainSleepNotSupported
= 0x00000000,
83 kRootDomainSleepSupported
= 0x00000001,
84 kFrameBufferDeepSleepSupported
= 0x00000002,
85 kPCICantSleep
= 0x00000004
89 *IOPMrootDomain registry property keys
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"
99 * Possible sleep reasons found under kRootDomainSleepReasonsKey
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"
111 * String constants for communication with PM CPU
113 #define kIOPMRootDomainLidCloseCString "LidClose"
114 #define kIOPMRootDomainBatPowerCString "BatPower"
117 * Supported Feature bitfields for IOPMrootDomain::publishFeature()
120 kIOPMSupportedOnAC
= (1<<0),
121 kIOPMSupportedOnBatt
= (1<<1),
122 kIOPMSupportedOnUPS
= (1<<2)
125 typedef IOReturn (*IOPMSettingControllerCallback
)
126 (OSObject
*target
, const OSSymbol
*type
,
127 OSObject
*val
, uintptr_t refcon
);
130 IONotifier
* registerSleepWakeInterest(
131 IOServiceInterestHandler
, void *, void * = 0);
133 IONotifier
* registerPrioritySleepWakeInterest(
134 IOServiceInterestHandler handler
,
135 void * self
, void * ref
= 0);
137 IOReturn
acknowledgeSleepWakeNotification(void * );
139 IOReturn
vetoSleepWakeNotification(void * PMrefcon
);
142 #define IOPM_ROOTDOMAIN_REV 2
144 class IOPMrootDomain
: public IOService
146 OSDeclareFinalStructors(IOPMrootDomain
)
149 static IOPMrootDomain
* construct( void );
151 virtual bool start( IOService
* provider
);
152 virtual IOReturn
setAggressiveness( unsigned long, unsigned long );
153 virtual IOReturn
getAggressiveness( unsigned long, unsigned long * );
155 virtual IOReturn
sleepSystem( void );
156 IOReturn
sleepSystemOptions( OSDictionary
*options
);
158 virtual IOReturn
setProperties( OSObject
* );
159 virtual bool serializeProperties( OSSerialize
* s
) const;
160 virtual OSObject
* copyProperty( const char * aKey
) const;
162 /*! @function systemPowerEventOccurred
163 @abstract Other drivers may inform IOPMrootDomain of system PM events
164 @discussion systemPowerEventOccurred is a richer alternative to receivePowerNotification()
165 Only Apple-owned kexts should have reason to call systemPowerEventOccurred.
166 @param event An OSSymbol describing the type of power event.
167 @param value A 32-bit integer value associated with the event.
168 @param shouldUpdate indicates whether the root domain should send a notification
169 to interested parties. Pass false if you're calling systemPowerEventOccurred
170 several times in succession; and pass true only on the last invocatino.
171 @result kIOReturnSuccess on success */
173 IOReturn
systemPowerEventOccurred(
174 const OSSymbol
*event
,
177 IOReturn
systemPowerEventOccurred(
178 const OSSymbol
*event
,
181 virtual IOReturn
receivePowerNotification( UInt32 msg
);
183 virtual void setSleepSupported( IOOptionBits flags
);
185 virtual IOOptionBits
getSleepSupported( void );
187 void wakeFromDoze( void );
189 // KEXT driver announces support of power management feature
191 void publishFeature( const char *feature
);
193 // KEXT driver announces support of power management feature
194 // And specifies power sources with kIOPMSupportedOn{AC/Batt/UPS} bitfield.
195 // Returns a unique uint32_t identifier for later removing support for this
197 // NULL is acceptable for uniqueFeatureID for kexts without plans to unload.
199 void publishFeature( const char *feature
,
200 uint32_t supportedWhere
,
201 uint32_t *uniqueFeatureID
);
203 // KEXT driver announces removal of a previously published power management
204 // feature. Pass 'uniqueFeatureID' returned from publishFeature()
206 IOReturn
removePublishedFeature( uint32_t removeFeatureID
);
208 /*! @function copyPMSetting
209 @abstract Copy the current value for a PM setting. Returns an OSNumber or
210 OSData depending on the setting.
211 @param whichSetting Name of the desired setting.
212 @result OSObject value if valid, NULL otherwise. */
214 OSObject
* copyPMSetting( OSSymbol
*whichSetting
);
216 /*! @function registerPMSettingController
217 @abstract Register for callbacks on changes to certain PM settings.
218 @param settings NULL terminated array of C strings, each string for a PM
219 setting that the caller is interested in and wants to get callbacks for.
220 @param callout C function ptr or member function cast as such.
221 @param target The target of the callback, usually 'this'
222 @param refcon Will be passed to caller in callback; for caller's use.
223 @param handle Caller should keep the OSObject * returned here. If non-NULL,
224 handle will have a retain count of 1 on return. To deregister, pass to
225 unregisterPMSettingController()
226 @result kIOReturnSuccess on success. */
228 IOReturn
registerPMSettingController(
229 const OSSymbol
*settings
[],
230 IOPMSettingControllerCallback callout
,
233 OSObject
**handle
); // out param
235 /*! @function registerPMSettingController
236 @abstract Register for callbacks on changes to certain PM settings.
237 @param settings NULL terminated array of C strings, each string for a PM
238 setting that the caller is interested in and wants to get callbacks for.
239 @param supportedPowerSources bitfield indicating which power sources these
240 settings are supported for (kIOPMSupportedOnAC, etc.)
241 @param callout C function ptr or member function cast as such.
242 @param target The target of the callback, usually 'this'
243 @param refcon Will be passed to caller in callback; for caller's use.
244 @param handle Caller should keep the OSObject * returned here. If non-NULL,
245 handle will have a retain count of 1 on return. To deregister, pass to
246 unregisterPMSettingController()
247 @result kIOReturnSuccess on success. */
249 IOReturn
registerPMSettingController(
250 const OSSymbol
*settings
[],
251 uint32_t supportedPowerSources
,
252 IOPMSettingControllerCallback callout
,
255 OSObject
**handle
); // out param
257 virtual IONotifier
* registerInterest(
258 const OSSymbol
* typeOfInterest
,
259 IOServiceInterestHandler handler
,
260 void * target
, void * ref
= 0 );
262 virtual IOReturn
callPlatformFunction(
263 const OSSymbol
*functionName
,
264 bool waitForFunction
,
265 void *param1
, void *param2
,
266 void *param3
, void *param4
);
268 /*! @function createPMAssertion
269 @abstract Creates an assertion to influence system power behavior.
270 @param whichAssertionBits A bitfield specify the assertion that the caller requests.
271 @param assertionLevel An integer detailing the initial assertion level, kIOPMDriverAssertionLevelOn
272 or kIOPMDriverAssertionLevelOff.
273 @param ownerService A pointer to the caller's IOService class, for tracking.
274 @param ownerDescription A reverse-DNS string describing the caller's identity and reason.
275 @result On success, returns a new assertion of type IOPMDriverAssertionID
277 IOPMDriverAssertionID
createPMAssertion(
278 IOPMDriverAssertionType whichAssertionsBits
,
279 IOPMDriverAssertionLevel assertionLevel
,
280 IOService
*ownerService
,
281 const char *ownerDescription
);
283 /* @function setPMAssertionLevel
284 @abstract Modify the level of a pre-existing assertion.
285 @discussion Change the value of a PM assertion to influence system behavior,
286 without undergoing the work required to create or destroy an assertion. Suggested
287 for clients who will assert and de-assert needs for PM behavior several times over
289 @param assertionID An assertion ID previously returned by <link>createPMAssertion</link>
290 @param assertionLevel The new assertion level.
291 @result kIOReturnSuccess if it worked; kIOReturnNotFound or other IOReturn error on failure.
293 IOReturn
setPMAssertionLevel(IOPMDriverAssertionID assertionID
, IOPMDriverAssertionLevel assertionLevel
);
295 /*! @function getPMAssertionLevel
296 @absract Returns the active level of the specified assertion(s).
297 @discussion Returns <link>kIOPMDriverAssertionLevelOff</link> or
298 <link>kIOPMDriverAssertionLevelOn</link>. If multiple assertions are specified
299 in the bitfield, only returns <link>kIOPMDriverAssertionLevelOn</link>
300 if all assertions are active.
301 @param whichAssertionBits Bits defining the assertion or assertions the caller is interested in
302 the level of. If in doubt, pass <link>kIOPMDriverAssertionCPUBit</link> as the argument.
303 @result Returns <link>kIOPMDriverAssertionLevelOff</link> or
304 <link>kIOPMDriverAssertionLevelOn</link> indicating the specified assertion's levels, if available.
305 If the assertions aren't supported on this machine, or aren't recognized by the OS, the
308 IOPMDriverAssertionLevel
getPMAssertionLevel(IOPMDriverAssertionType whichAssertionBits
);
310 /*! @function releasePMAssertion
311 @abstract Removes an assertion to influence system power behavior.
312 @result On success, returns a new assertion of type IOPMDriverAssertionID *
314 IOReturn
releasePMAssertion(IOPMDriverAssertionID releaseAssertion
);
317 virtual IOReturn
changePowerStateTo( unsigned long ordinal
);
318 virtual IOReturn
changePowerStateToPriv( unsigned long ordinal
);
319 virtual IOReturn
requestPowerDomainState( IOPMPowerFlags
, IOPowerConnection
*, unsigned long );
320 virtual void powerChangeDone( unsigned long );
321 virtual bool tellChangeDown( unsigned long );
322 virtual bool askChangeDown( unsigned long );
323 virtual void tellChangeUp( unsigned long );
324 virtual void tellNoChangeDown( unsigned long );
325 virtual IOReturn
configureReport(IOReportChannelList
*channels
,
326 IOReportConfigureAction action
,
329 virtual IOReturn
updateReport(IOReportChannelList
*channels
,
330 IOReportUpdateAction action
,
334 #ifdef XNU_KERNEL_PRIVATE
335 /* Root Domain internals */
337 void tagPowerPlaneService(
339 IOPMActions
* actions
);
341 void overrideOurPowerChange(
343 IOPMActions
* actions
,
344 IOPMPowerStateIndex
* inOutPowerState
,
345 IOPMPowerChangeFlags
* inOutChangeFlags
,
346 IOPMRequestTag requestTag
);
348 void handleOurPowerChangeStart(
350 IOPMActions
* actions
,
351 IOPMPowerStateIndex powerState
,
352 IOPMPowerChangeFlags
* inOutChangeFlags
,
353 IOPMRequestTag requestTag
);
355 void handleOurPowerChangeDone(
357 IOPMActions
* actions
,
358 IOPMPowerStateIndex powerState
,
359 IOPMPowerChangeFlags changeFlags
,
360 IOPMRequestTag requestTag
);
362 void overridePowerChangeForUIService(
364 IOPMActions
* actions
,
365 IOPMPowerStateIndex
* inOutPowerState
,
366 IOPMPowerChangeFlags
* inOutChangeFlags
);
368 void handleActivityTickleForDisplayWrangler(
370 IOPMActions
* actions
);
372 void handleUpdatePowerClientForDisplayWrangler(
374 IOPMActions
* actions
,
375 const OSSymbol
* powerClient
,
376 IOPMPowerStateIndex oldPowerState
,
377 IOPMPowerStateIndex newPowerState
);
379 bool shouldDelayChildNotification(
380 IOService
* service
);
382 void handlePowerChangeStartForPCIDevice(
384 IOPMActions
* actions
,
385 IOPMPowerStateIndex powerState
,
386 IOPMPowerChangeFlags
* inOutChangeFlags
);
388 void handlePowerChangeDoneForPCIDevice(
390 IOPMActions
* actions
,
391 IOPMPowerStateIndex powerState
,
392 IOPMPowerChangeFlags changeFlags
);
394 void askChangeDownDone(
395 IOPMPowerChangeFlags
* inOutChangeFlags
,
398 void handlePublishSleepWakeUUID(
401 void handleQueueSleepWakeUUID(
404 void handleSuspendPMNotificationClient(
405 uint32_t pid
, bool doSuspend
);
407 void willNotifyPowerChildren( IOPMPowerStateIndex newPowerState
);
409 IOReturn
setMaintenanceWakeCalendar(
410 const IOPMCalendarStruct
* calendar
);
412 IOReturn
getSystemSleepType( uint32_t * sleepType
);
414 // Handle callbacks from IOService::systemWillShutdown()
415 void acknowledgeSystemWillShutdown( IOService
* from
);
417 // Handle platform halt and restart notifications
418 void handlePlatformHaltRestart( UInt32 pe_type
);
420 IOReturn
shutdownSystem( void );
421 IOReturn
restartSystem( void );
422 void handleSleepTimerExpiration( void );
424 bool activitySinceSleep(void);
425 bool abortHibernation(void);
427 IOReturn
joinAggressiveness( IOService
* service
);
428 void handleAggressivesRequests( void );
430 void tracePoint( uint8_t point
);
431 void tracePoint( uint8_t point
, uint8_t data
);
432 void traceDetail( uint32_t data32
);
434 bool systemMessageFilter(
435 void * object
, void * arg1
, void * arg2
, void * arg3
);
437 bool updatePreventIdleSleepList(
438 IOService
* service
, bool addNotRemove
);
439 void updatePreventSystemSleepList(
440 IOService
* service
, bool addNotRemove
);
442 void publishPMSetting(
443 const OSSymbol
* feature
, uint32_t where
, uint32_t * featureID
);
445 /*! @function recordPMEvent
446 @abstract Logs IOService PM event timing.
447 @discussion Should only be called from IOServicePM. Should not be exported.
448 @result kIOReturn on success.
450 IOReturn
recordPMEvent( PMEventDetails
*details
);
451 void recordPMEvent( uint32_t type
, const char *uuid
,
452 uint32_t reason
, uint32_t result
);
453 IOReturn
recordAndReleasePMEvent( PMEventDetails
*details
);
455 void pmStatsRecordEvent(
457 AbsoluteTime timestamp
);
459 void pmStatsRecordApplicationResponse(
460 const OSSymbol
*response
,
467 /*! @function suspendPMNotificationsForPID
468 @abstract kernel process management calls this to disable sleep/wake notifications
469 when a process is suspended.
470 @param pid the process ID
471 @param doSuspend true suspends the notifications; false enables them
473 void suspendPMNotificationsForPID( uint32_t pid
, bool doSuspend
);
475 /*! @function pmNotificationIsSuspended
476 @abstract returns true if PM notifications have been suspended
477 @param pid the process ID
478 @result true if the process has been suspended
480 bool pmNotificationIsSuspended( uint32_t pid
);
483 bool getHibernateSettings(
484 uint32_t * hibernateMode
,
485 uint32_t * hibernateFreeRatio
,
486 uint32_t * hibernateFreeTime
);
488 void sleepWakeDebugTrig(bool restart
);
489 void sleepWakeDebugLog(const char *fmt
,...);
490 void sleepWakeDebugEnableWdog();
491 bool sleepWakeDebugIsWdogEnabled();
492 static void saveTimeoutAppStackShot(void *p0
, void *p1
);
495 friend class PMSettingObject
;
496 friend class RootDomainUserClient
;
497 friend class PMAssertionsTracker
;
499 static IOReturn
sysPowerDownHandler( void * target
, void * refCon
,
500 UInt32 messageType
, IOService
* service
,
501 void * messageArgument
, vm_size_t argSize
);
503 static IOReturn
displayWranglerNotification( void * target
, void * refCon
,
504 UInt32 messageType
, IOService
* service
,
505 void * messageArgument
, vm_size_t argSize
);
507 static IOReturn
rootBusyStateChangeHandler( void * target
, void * refCon
,
508 UInt32 messageType
, IOService
* service
,
509 void * messageArgument
, vm_size_t argSize
);
511 static bool displayWranglerMatchPublished( void * target
, void * refCon
,
512 IOService
* newService
,
513 IONotifier
* notifier
);
515 static bool IONVRAMMatchPublished( void * target
, void * refCon
,
516 IOService
* newService
,
517 IONotifier
* notifier
);
519 static bool batteryPublished( void * target
, void * refCon
,
520 IOService
* resourceService
,
521 IONotifier
* notifier
);
523 void initializeBootSessionUUID( void );
525 void fullWakeDelayedWork( void );
527 IOService
* wrangler
;
528 OSDictionary
* wranglerIdleSettings
;
530 IOLock
*featuresDictLock
; // guards supportedFeatures
531 IOPMPowerStateQueue
*pmPowerStateQueue
;
533 OSArray
*allowedPMSettings
;
534 OSArray
*noPublishPMSettings
;
535 PMTraceWorker
*pmTracer
;
536 PMAssertionsTracker
*pmAssertions
;
538 // Settings controller info
539 IOLock
*settingsCtrlLock
;
540 OSDictionary
*settingsCallbacks
;
541 OSDictionary
*fPMSettingsDict
;
543 IONotifier
*_batteryPublishNotifier
;
544 IONotifier
*_displayWranglerNotifier
;
547 const OSSymbol
*_statsNameKey
;
548 const OSSymbol
*_statsPIDKey
;
549 const OSSymbol
*_statsTimeMSKey
;
550 const OSSymbol
*_statsResponseTypeKey
;
551 const OSSymbol
*_statsMessageTypeKey
;
552 const OSSymbol
*_statsPowerCapsKey
;
554 uint32_t darkWakeCnt
;
555 uint32_t displayWakeCnt
;
557 OSString
*queuedSleepWakeUUIDString
;
558 OSArray
*pmStatsAppResponses
;
559 OSOrderedSet
*noAckApps
; // Apps not returning acks to notifications
560 IOBufferMemoryDescriptor
*spindumpDesc
;
561 thread_call_t stackshotOffloader
;
565 // Pref: idle time before idle sleep
566 unsigned long sleepSlider
;
567 unsigned long idleSeconds
;
568 uint64_t autoWakeStart
;
569 uint64_t autoWakeEnd
;
571 // Difference between sleepSlider and longestNonSleepSlider
572 unsigned long extraSleepDelay
;
574 // Used to wait between say display idle and system idle
575 thread_call_t extraSleepTimer
;
576 thread_call_t diskSyncCalloutEntry
;
577 thread_call_t fullWakeThreadCall
;
579 // Track system capabilities.
580 uint32_t _desiredCapability
;
581 uint32_t _currentCapability
;
582 uint32_t _pendingCapability
;
583 uint32_t _highestCapability
;
584 OSSet
* _joinedCapabilityClients
;
585 uint32_t _systemStateGeneration
;
587 // Type of clients that can receive system messages.
589 kSystemMessageClientPowerd
= 0x01,
590 kSystemMessageClientLegacyApp
= 0x02,
591 kSystemMessageClientKernel
= 0x04,
592 kSystemMessageClientAll
= 0x07
594 uint32_t _systemMessageClientMask
;
596 // Power state and capability change transitions.
598 kSystemTransitionNone
= 0,
599 kSystemTransitionSleep
= 1,
600 kSystemTransitionWake
= 2,
601 kSystemTransitionCapability
= 3,
602 kSystemTransitionNewCapClient
= 4
603 } _systemTransitionType
;
605 unsigned int systemBooting
:1;
606 unsigned int systemShutdown
:1;
607 unsigned int systemDarkWake
:1;
608 unsigned int clamshellExists
:1;
609 unsigned int clamshellClosed
:1;
610 unsigned int clamshellDisabled
:1;
611 unsigned int desktopMode
:1;
612 unsigned int acAdaptorConnected
:1;
614 unsigned int clamshellSleepDisabled
:1;
615 unsigned int idleSleepTimerPending
:1;
616 unsigned int userDisabledAllSleep
:1;
617 unsigned int ignoreTellChangeDown
:1;
618 unsigned int wranglerAsleep
:1;
619 unsigned int wranglerTickled
:1;
620 unsigned int _preventUserActive
:1;
621 unsigned int graphicsSuppressed
:1;
623 unsigned int capabilityLoss
:1;
624 unsigned int pciCantSleepFlag
:1;
625 unsigned int pciCantSleepValid
:1;
626 unsigned int logGraphicsClamp
:1;
627 unsigned int darkWakeToSleepASAP
:1;
628 unsigned int darkWakeMaintenance
:1;
629 unsigned int darkWakeSleepService
:1;
630 unsigned int darkWakePostTickle
:1;
632 unsigned int sleepTimerMaintenance
:1;
633 unsigned int sleepToStandby
:1;
634 unsigned int lowBatteryCondition
:1;
635 unsigned int hibernateDisabled
:1;
636 unsigned int hibernateRetry
:1;
637 unsigned int wranglerTickleLatched
:1;
638 unsigned int userIsActive
:1;
639 unsigned int userWasActive
:1;
640 unsigned int displayIdleForDemandSleep
:1;
642 uint32_t hibernateMode
;
643 AbsoluteTime userActivityTime
;
644 AbsoluteTime userActivityTime_prev
;
645 uint32_t userActivityCount
;
646 uint32_t userActivityAtSleep
;
647 uint32_t lastSleepReason
;
648 uint32_t fullToDarkReason
;
649 uint32_t hibernateAborted
;
651 enum FullWakeReason
{
652 kFullWakeReasonNone
= 0,
653 kFullWakeReasonLocalUser
= 1,
654 kFullWakeReasonDisplayOn
= 2,
655 fFullWakeReasonDisplayOnAndLocalUser
= 3
657 uint32_t fullWakeReason
;
659 // Info for communicating system state changes to PMCPU
660 int32_t idxPMCPUClamshell
;
661 int32_t idxPMCPULimitedPower
;
663 IOOptionBits platformSleepSupport
;
664 uint32_t _debugWakeSeconds
;
665 uint32_t _lastDebugWakeSeconds
;
667 queue_head_t aggressivesQueue
;
668 thread_call_t aggressivesThreadCall
;
669 OSData
* aggressivesData
;
671 AbsoluteTime userBecameInactiveTime
;
672 AbsoluteTime systemWakeTime
;
674 // PCI top-level PM trace
675 IOService
* pciHostBridgeDevice
;
676 IOService
* pciHostBridgeDriver
;
678 IONotifier
* systemCapabilityNotifier
;
680 IOPMTimeline
*timeline
;
685 } PMNotifySuspendedStruct
;
687 uint32_t pmSuspendedCapacity
;
688 uint32_t pmSuspendedSize
;
689 PMNotifySuspendedStruct
*pmSuspendedPIDS
;
691 OSSet
* preventIdleSleepList
;
692 OSSet
* preventSystemSleepList
;
694 UInt32 _scheduledAlarms
;
695 UInt32 _userScheduledAlarm
;
698 clock_sec_t _standbyTimerResetSeconds
;
700 volatile uint32_t swd_lock
; /* Lock to access swd_buffer & and its header */
701 void * swd_buffer
; /* Memory allocated for dumping sleep/wake logs */
702 uint8_t swd_flags
; /* Flags defined in IOPMPrivate.h */
704 IOMemoryMap
* swd_logBufMap
; /* Memory with sleep/wake logs from previous boot */
707 int findSuspendedPID(uint32_t pid
, uint32_t *outRefCount
);
709 // IOPMrootDomain internal sleep call
710 IOReturn
privateSleepSystem( uint32_t sleepReason
);
711 void reportUserInput( void );
712 void setDisableClamShellSleep( bool );
713 bool checkSystemSleepAllowed( IOOptionBits options
,
714 uint32_t sleepReason
);
715 bool checkSystemSleepEnabled( void );
716 bool checkSystemCanSleep( uint32_t sleepReason
);
717 bool checkSystemCanSustainFullWake( void );
719 void adjustPowerState( bool sleepASAP
= false );
720 void setQuickSpinDownTimeout( void );
721 void restoreUserSpinDownTimeout( void );
723 bool shouldSleepOnClamshellClosed(void );
724 void sendClientClamshellNotification( void );
726 // Inform PMCPU of changes to state like lid, AC vs. battery
727 void informCPUStateChange( uint32_t type
, uint32_t value
);
729 void dispatchPowerEvent( uint32_t event
, void * arg0
, uint64_t arg1
);
730 void handlePowerNotification( UInt32 msg
);
732 IOReturn
setPMSetting(const OSSymbol
*, OSObject
*);
734 void startIdleSleepTimer( uint32_t inSeconds
);
735 void cancelIdleSleepTimer( void );
736 uint32_t getTimeToIdleSleep( void );
738 IOReturn
setAggressiveness(
741 IOOptionBits options
);
743 void synchronizeAggressives(
744 queue_head_t
* services
,
745 const AggressivesRecord
* array
,
748 void broadcastAggressives(
749 const AggressivesRecord
* array
,
752 // getPMTraceMemoryDescriptor should only be called by our friend RootDomainUserClient
753 IOMemoryDescriptor
*getPMTraceMemoryDescriptor(void);
755 IOReturn
setPMAssertionUserLevels(IOPMDriverAssertionType
);
757 void publishSleepWakeUUID( bool shouldPublish
);
759 void evaluatePolicy( int stimulus
, uint32_t arg
= 0 );
760 void requestFullWake( FullWakeReason reason
);
761 void willEnterFullWake( void );
763 void evaluateAssertions(IOPMDriverAssertionType newAssertions
,
764 IOPMDriverAssertionType oldAssertions
);
766 void deregisterPMSettingObject( PMSettingObject
* pmso
);
768 void sleepWakeDebugMemAlloc( );
769 void sleepWakeDebugDump(IOMemoryMap
*logBufMap
);
770 IOMemoryMap
*sleepWakeDebugRetrieve();
771 errno_t
sleepWakeDebugSaveFile(const char *name
, char *buf
, int len
);
774 bool getSleepOption( const char * key
, uint32_t * option
);
775 bool evaluateSystemSleepPolicy( IOPMSystemSleepParameters
* p
,
776 int phase
, uint32_t * hibMode
);
777 void evaluateSystemSleepPolicyEarly( void );
778 void evaluateSystemSleepPolicyFinal( void );
779 #endif /* HIBERNATION */
781 bool latchDisplayWranglerTickle( bool latch
);
782 void setDisplayPowerOn( uint32_t options
);
783 void systemDidNotSleep( void );
784 void preventTransitionToUserActive( bool prevent
);
785 #endif /* XNU_KERNEL_PRIVATE */
788 #ifdef XNU_KERNEL_PRIVATE
789 class IORootParent
: public IOService
791 OSDeclareFinalStructors(IORootParent
)
794 static void initialize( void );
795 virtual OSObject
* copyProperty( const char * aKey
) const;
796 bool start( IOService
* nub
);
797 void shutDownSystem( void );
798 void restartSystem( void );
799 void sleepSystem( void );
800 void dozeSystem( void );
801 void sleepToDoze( void );
802 void wakeSystem( void );
804 #endif /* XNU_KERNEL_PRIVATE */
806 #endif /* _IOKIT_ROOTDOMAIN_H */