+ IOReturn setMaintenanceWakeCalendar(
+ const IOPMCalendarStruct * calendar );
+
+ IOReturn getSystemSleepType(uint32_t * sleepType, uint32_t * standbyTimer);
+
+// Handle callbacks from IOService::systemWillShutdown()
+ void acknowledgeSystemWillShutdown( IOService * from );
+
+// Handle platform halt and restart notifications
+ void handlePlatformHaltRestart( UInt32 pe_type );
+
+ IOReturn shutdownSystem( void );
+ IOReturn restartSystem( void );
+ void handleSleepTimerExpiration( void );
+
+ bool activitySinceSleep(void);
+ bool abortHibernation(void);
+ void updateConsoleUsers(void);
+
+ IOReturn joinAggressiveness( IOService * service );
+ void handleAggressivesRequests( void );
+
+ void kdebugTrace(uint32_t event, uint64_t regId,
+ uintptr_t param1, uintptr_t param2, uintptr_t param3 = 0);
+ void tracePoint(uint8_t point);
+ void traceDetail(uint32_t msgType, uint32_t msgIndex, uint32_t delay);
+ void traceDetail(OSObject *notifier, bool start);
+ void traceAckDelay(OSObject *notifier, uint32_t response, uint32_t delay_ms);
+
+ void startSpinDump(uint32_t spindumpKind);
+
+ bool systemMessageFilter(
+ void * object, void * arg1, void * arg2, void * arg3 );
+
+ bool updatePreventIdleSleepList(
+ IOService * service, bool addNotRemove );
+ void updatePreventSystemSleepList(
+ IOService * service, bool addNotRemove );
+
+ bool updatePreventIdleSleepListInternal(
+ IOService * service, bool addNotRemove, unsigned int oldCount);
+ unsigned int idleSleepPreventersCount();
+
+ void publishPMSetting(
+ const OSSymbol * feature, uint32_t where, uint32_t * featureID );
+
+ void pmStatsRecordEvent(
+ int eventIndex,
+ AbsoluteTime timestamp);
+
+ void pmStatsRecordApplicationResponse(
+ const OSSymbol *response,
+ const char *name,
+ int messageType,
+ uint32_t delay_ms,
+ uint64_t id,
+ OSObject *object,
+ IOPMPowerStateIndex ps = 0);
+
+ void copyWakeReasonString( char * outBuf, size_t bufSize );
+
+#if HIBERNATION
+ bool getHibernateSettings(
+ uint32_t * hibernateMode,
+ uint32_t * hibernateFreeRatio,
+ uint32_t * hibernateFreeTime );
+ bool mustHibernate( void );
+#endif
+ void takeStackshot(bool restart);
+ void sleepWakeDebugTrig(bool restart);
+ void sleepWakeDebugEnableWdog();
+ bool sleepWakeDebugIsWdogEnabled();
+ void sleepWakeDebugSaveSpinDumpFile();
+ bool checkShutdownTimeout();
+ void panicWithShutdownLog(uint32_t timeoutInMs) __abortlike;
+ uint32_t getWatchdogTimeout();
+ void deleteStackshot();
+
+private:
+ friend class PMSettingObject;
+ friend class RootDomainUserClient;
+ friend class PMAssertionsTracker;
+
+ static IOReturn sysPowerDownHandler( void * target, void * refCon,
+ UInt32 messageType, IOService * service,
+ void * messageArgument, vm_size_t argSize );
+
+ static IOReturn displayWranglerNotification( void * target, void * refCon,
+ UInt32 messageType, IOService * service,
+ void * messageArgument, vm_size_t argSize );
+
+ 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 batteryPublished( void * target, void * refCon,
+ IOService * resourceService,
+ IONotifier * notifier);
+
+ void initializeBootSessionUUID( void );
+
+ void fullWakeDelayedWork( void );
+
+ IOService * wrangler;
+ OSDictionary * wranglerIdleSettings;
+
+ IOLock *featuresDictLock;// guards supportedFeatures
+ IOLock *wakeEventLock;
+ 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;
+ IOLock *pmStatsLock;// guards pmStatsAppResponses
+
+ void *sleepDelaysReport; // report to track time taken to go to sleep
+ uint32_t sleepDelaysClientCnt;// Number of interested clients in sleepDelaysReport
+ uint64_t ts_sleepStart;
+ uint64_t wake2DarkwakeDelay; // Time taken to change from full wake -> Dark wake
+
+
+ void *assertOnWakeReport;// report to track time spent without any assertions held after wake
+ uint32_t assertOnWakeClientCnt;// Number of clients interested in assertOnWakeReport
+ clock_sec_t assertOnWakeSecs; // Num of secs after wake for first assertion
+
+ bool uuidPublished;
+
+// Pref: idle time before idle sleep
+ bool idleSleepEnabled;
+ 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 powerButtonDown;
+ thread_call_t powerButtonUp;
+ thread_call_t diskSyncCalloutEntry;
+ thread_call_t fullWakeThreadCall;
+ thread_call_t updateConsoleUsersEntry;
+
+// 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 _preventUserActive :1;
+ unsigned int graphicsSuppressed :1;
+ unsigned int isRTCAlarmWake :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;
+ unsigned int darkWakeHibernateError :1;
+ unsigned int thermalWarningState:1;
+ unsigned int toldPowerdCapWillChange :1;
+ unsigned int displayPowerOnRequested:1;
+
+ uint8_t tasksSuspended;
+ uint8_t tasksSuspendState;
+ uint32_t hibernateMode;
+ AbsoluteTime userActivityTime;
+ AbsoluteTime userActivityTime_prev;
+ uint32_t userActivityCount;
+ uint32_t userActivityAtSleep;
+ uint32_t lastSleepReason;
+ uint32_t fullToDarkReason;
+ uint32_t hibernateAborted;
+ uint8_t standbyNixed;
+ uint8_t resetTimers;
+
+ 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;
+
+// PCI top-level PM trace
+ IOService * pciHostBridgeDevice;
+ IOService * pciHostBridgeDriver;
+
+ IONotifier * systemCapabilityNotifier;
+
+ 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;
+ clock_sec_t _scheduledAlarmUTC;
+
+#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 */
+ uint32_t swd_flags;/* Flags defined in IOPMPrivate.h */
+ void * swd_compressed_buffer;
+ void * swd_spindump_buffer;
+ thread_t notifierThread;
+ OSObject *notifierObject;
+
+ IOBufferMemoryDescriptor *swd_memDesc;
+
+// Wake Event Reporting
+ OSArray * _systemWakeEventsArray;
+ bool _acceptSystemWakeEvents;
+
+ // AOT --
+ IOPMCalendarStruct _aotWakeTimeCalendar;
+ IOTimerEventSource * _aotTimerES;
+ clock_sec_t _aotWakeTimeUTC;
+ uint64_t _aotTestTime;
+ uint64_t _aotTestInterval;
+ uint32_t _aotPendingFlags;
+public:
+ IOPMAOTMetrics * _aotMetrics;
+ uint8_t _aotMode;