+ static IOReturn rootBusyStateChangeHandler( void * target, void * refCon,
+ UInt32 messageType, IOService * service,
+ void * messageArgument, vm_size_t argSize );
+
+ static bool displayWranglerMatchPublished( void * target, void * refCon,
+ IOService * newService,
+ IONotifier * notifier);
+
+ static bool IONVRAMMatchPublished( void * target, void * refCon,
+ IOService * newService,
+ IONotifier * notifier);
+
+ static bool batteryPublished( void * target, void * refCon,
+ IOService * resourceService,
+ IONotifier * notifier);
+
+ void initializeBootSessionUUID( void );
+
+ void fullWakeDelayedWork( void );
+
+ IOService * wrangler;
+ OSDictionary * wranglerIdleSettings;
+
+ IOLock *featuresDictLock; // guards supportedFeatures
+ IOPMPowerStateQueue *pmPowerStateQueue;
+
+ OSArray *allowedPMSettings;
+ OSArray *noPublishPMSettings;
+ PMTraceWorker *pmTracer;
+ PMAssertionsTracker *pmAssertions;
+
+ // Settings controller info
+ IOLock *settingsCtrlLock;
+ OSDictionary *settingsCallbacks;
+ OSDictionary *fPMSettingsDict;
+
+ IONotifier *_batteryPublishNotifier;
+ IONotifier *_displayWranglerNotifier;
+
+ // Statistics
+ const OSSymbol *_statsNameKey;
+ const OSSymbol *_statsPIDKey;
+ const OSSymbol *_statsTimeMSKey;
+ const OSSymbol *_statsResponseTypeKey;
+ const OSSymbol *_statsMessageTypeKey;
+ const OSSymbol *_statsPowerCapsKey;
+ uint32_t sleepCnt;
+ uint32_t darkWakeCnt;
+ uint32_t displayWakeCnt;
+
+ OSString *queuedSleepWakeUUIDString;
+ OSArray *pmStatsAppResponses;
+ OSOrderedSet *noAckApps; // Apps not returning acks to notifications
+ IOBufferMemoryDescriptor *spindumpDesc;
+ thread_call_t stackshotOffloader;
+
+ bool uuidPublished;
+
+ // Pref: idle time before idle sleep
+ unsigned long sleepSlider;
+ unsigned long idleSeconds;
+ uint64_t autoWakeStart;
+ uint64_t autoWakeEnd;
+
+ // Difference between sleepSlider and longestNonSleepSlider
+ unsigned long extraSleepDelay;
+
+ // Used to wait between say display idle and system idle
+ thread_call_t extraSleepTimer;
+ thread_call_t diskSyncCalloutEntry;
+ thread_call_t fullWakeThreadCall;
+
+ // Track system capabilities.
+ uint32_t _desiredCapability;
+ uint32_t _currentCapability;
+ uint32_t _pendingCapability;
+ uint32_t _highestCapability;
+ OSSet * _joinedCapabilityClients;
+ uint32_t _systemStateGeneration;
+
+ // Type of clients that can receive system messages.
+ enum {
+ kSystemMessageClientPowerd = 0x01,
+ kSystemMessageClientLegacyApp = 0x02,
+ kSystemMessageClientKernel = 0x04,
+ kSystemMessageClientAll = 0x07
+ };
+ uint32_t _systemMessageClientMask;
+
+ // Power state and capability change transitions.
+ enum {
+ kSystemTransitionNone = 0,
+ kSystemTransitionSleep = 1,
+ kSystemTransitionWake = 2,
+ kSystemTransitionCapability = 3,
+ kSystemTransitionNewCapClient = 4
+ } _systemTransitionType;
+
+ unsigned int systemBooting :1;
+ unsigned int systemShutdown :1;
+ unsigned int systemDarkWake :1;
+ unsigned int clamshellExists :1;
+ unsigned int clamshellClosed :1;
+ unsigned int clamshellDisabled :1;
+ unsigned int desktopMode :1;
+ unsigned int acAdaptorConnected :1;
+
+ unsigned int clamshellSleepDisabled :1;
+ unsigned int idleSleepTimerPending :1;
+ unsigned int userDisabledAllSleep :1;
+ unsigned int ignoreTellChangeDown :1;
+ unsigned int wranglerAsleep :1;
+ unsigned int wranglerTickled :1;
+ unsigned int ignoreIdleSleepTimer :1;
+ unsigned int graphicsSuppressed :1;
+
+ unsigned int capabilityLoss :1;
+ unsigned int pciCantSleepFlag :1;
+ unsigned int pciCantSleepValid :1;
+ unsigned int logGraphicsClamp :1;
+ unsigned int darkWakeToSleepASAP :1;
+ unsigned int darkWakeMaintenance :1;
+ unsigned int darkWakeSleepService :1;
+ unsigned int darkWakePostTickle :1;
+
+ unsigned int sleepTimerMaintenance :1;
+ unsigned int sleepToStandby :1;
+ unsigned int lowBatteryCondition :1;
+ unsigned int hibernateDisabled :1;
+ unsigned int hibernateRetry :1;
+ unsigned int wranglerTickleLatched :1;
+ unsigned int userIsActive :1;
+ unsigned int userWasActive :1;
+ unsigned int displayIdleForDemandSleep :1;
+
+ uint32_t hibernateMode;
+ AbsoluteTime userActivityTime;
+ AbsoluteTime userActivityTime_prev;
+ uint32_t userActivityCount;
+ uint32_t userActivityAtSleep;
+ uint32_t lastSleepReason;
+ uint32_t fullToDarkReason;
+ uint32_t hibernateAborted;
+
+ enum FullWakeReason {
+ kFullWakeReasonNone = 0,
+ kFullWakeReasonLocalUser = 1,
+ kFullWakeReasonDisplayOn = 2,
+ fFullWakeReasonDisplayOnAndLocalUser = 3
+ };
+ uint32_t fullWakeReason;
+
+ // Info for communicating system state changes to PMCPU
+ int32_t idxPMCPUClamshell;
+ int32_t idxPMCPULimitedPower;
+
+ IOOptionBits platformSleepSupport;
+ uint32_t _debugWakeSeconds;
+ uint32_t _lastDebugWakeSeconds;
+
+ queue_head_t aggressivesQueue;
+ thread_call_t aggressivesThreadCall;
+ OSData * aggressivesData;
+
+ AbsoluteTime userBecameInactiveTime;
+ AbsoluteTime systemWakeTime;
+
+ // PCI top-level PM trace
+ IOService * pciHostBridgeDevice;
+ IOService * pciHostBridgeDriver;
+
+ IONotifier * systemCapabilityNotifier;
+
+ IOPMTimeline *timeline;
+
+ typedef struct {
+ uint32_t pid;
+ uint32_t refcount;
+ } PMNotifySuspendedStruct;
+
+ uint32_t pmSuspendedCapacity;
+ uint32_t pmSuspendedSize;
+ PMNotifySuspendedStruct *pmSuspendedPIDS;
+
+ OSSet * preventIdleSleepList;
+ OSSet * preventSystemSleepList;
+
+ UInt32 _scheduledAlarms;
+ UInt32 _userScheduledAlarm;
+
+#if HIBERNATION
+ clock_sec_t _standbyTimerResetSeconds;
+#endif
+ volatile uint32_t swd_lock; /* Lock to access swd_buffer & and its header */
+ void * swd_buffer; /* Memory allocated for dumping sleep/wake logs */
+ uint8_t swd_flags; /* Flags defined in IOPMPrivate.h */
+
+ IOMemoryMap * swd_logBufMap; /* Memory with sleep/wake logs from previous boot */
+
+
+ int findSuspendedPID(uint32_t pid, uint32_t *outRefCount);
+
+ // IOPMrootDomain internal sleep call
+ IOReturn privateSleepSystem( uint32_t sleepReason );
+ void reportUserInput( void );
+ void setDisableClamShellSleep( bool );
+ bool checkSystemSleepAllowed( IOOptionBits options,
+ uint32_t sleepReason );
+ bool checkSystemSleepEnabled( void );
+ bool checkSystemCanSleep( uint32_t sleepReason );
+ bool checkSystemCanSustainFullWake( void );
+
+ void adjustPowerState( bool sleepASAP = false );
+ void setQuickSpinDownTimeout( void );
+ void restoreUserSpinDownTimeout( void );
+
+ bool shouldSleepOnClamshellClosed(void );
+ void sendClientClamshellNotification( void );
+
+ // Inform PMCPU of changes to state like lid, AC vs. battery
+ void informCPUStateChange( uint32_t type, uint32_t value );
+
+ void dispatchPowerEvent( uint32_t event, void * arg0, uint64_t arg1 );
+ void handlePowerNotification( UInt32 msg );
+
+ IOReturn setPMSetting(const OSSymbol *, OSObject *);
+
+ void startIdleSleepTimer( uint32_t inSeconds );
+ void cancelIdleSleepTimer( void );
+ uint32_t getTimeToIdleSleep( void );
+
+ IOReturn setAggressiveness(
+ unsigned long type,
+ unsigned long value,
+ IOOptionBits options );
+
+ void synchronizeAggressives(
+ queue_head_t * services,
+ const AggressivesRecord * array,
+ int count );
+
+ void broadcastAggressives(
+ const AggressivesRecord * array,
+ int count );
+
+ // getPMTraceMemoryDescriptor should only be called by our friend RootDomainUserClient
+ IOMemoryDescriptor *getPMTraceMemoryDescriptor(void);
+
+ IOReturn setPMAssertionUserLevels(IOPMDriverAssertionType);
+
+ void publishSleepWakeUUID( bool shouldPublish );
+
+ void evaluatePolicy( int stimulus, uint32_t arg = 0 );
+ void requestFullWake( FullWakeReason reason );
+ void willEnterFullWake( void );
+
+ void evaluateAssertions(IOPMDriverAssertionType newAssertions,
+ IOPMDriverAssertionType oldAssertions);
+
+ void deregisterPMSettingObject( PMSettingObject * pmso );
+
+ void sleepWakeDebugMemAlloc( );
+ void sleepWakeDebugDump(IOMemoryMap *logBufMap);
+ IOMemoryMap *sleepWakeDebugRetrieve();
+ errno_t sleepWakeDebugSaveFile(const char *name, char *buf, int len);
+
+#if HIBERNATION
+ bool getSleepOption( const char * key, uint32_t * option );
+ bool evaluateSystemSleepPolicy( IOPMSystemSleepParameters * p,
+ int phase, uint32_t * hibMode );
+ void evaluateSystemSleepPolicyEarly( void );
+ void evaluateSystemSleepPolicyFinal( void );
+#endif /* HIBERNATION */
+
+ bool latchDisplayWranglerTickle( bool latch );
+ void setDisplayPowerOn( uint32_t options );
+#endif /* XNU_KERNEL_PRIVATE */