/*
- * Copyright (c) 1998-2019 Apple Inc. All rights reserved.
+ * Copyright (c) 1998-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#ifndef _IOKIT_ROOTDOMAIN_H
#define _IOKIT_ROOTDOMAIN_H
+#include <libkern/c++/OSPtr.h>
#include <IOKit/IOService.h>
#include <IOKit/pwr_mgt/IOPM.h>
#include <IOKit/IOBufferMemoryDescriptor.h>
virtual IOReturn setProperties( OSObject * ) APPLE_KEXT_OVERRIDE;
virtual bool serializeProperties( OSSerialize * s ) const APPLE_KEXT_OVERRIDE;
- virtual OSObject * copyProperty( const char * aKey ) const APPLE_KEXT_OVERRIDE;
+ virtual OSPtr<OSObject> copyProperty( const char * aKey ) const APPLE_KEXT_OVERRIDE;
/*! @function systemPowerEventOccurred
* @abstract Other drivers may inform IOPMrootDomain of system PM events
* Please pass an OSString defining the event.
*/
#endif
- void claimSystemWakeEvent( IOService *device,
- IOOptionBits flags,
- const char *reason,
- OSObject *details = NULL );
+ void claimSystemWakeEvent(
+ IOService *device,
+ IOOptionBits flags,
+ const char *reason,
+ OSObject *details = NULL );
+
+ void claimSystemBootEvent(
+ IOService *device,
+ IOOptionBits flags,
+ const char *reason,
+ OSObject *details = NULL );
+
+ void claimSystemShutdownEvent(
+ IOService *device,
+ IOOptionBits flags,
+ const char *reason,
+ OSObject *details = NULL );
virtual IOReturn receivePowerNotification( UInt32 msg );
void wakeFromDoze( void );
+ void requestUserActive(IOService *driver, const char *reason);
+
// KEXT driver announces support of power management feature
void publishFeature( const char *feature );
* @param whichSetting Name of the desired setting.
* @result OSObject value if valid, NULL otherwise. */
- OSObject * copyPMSetting( OSSymbol *whichSetting );
+ OSPtr<OSObject> copyPMSetting( OSSymbol *whichSetting );
/*! @function registerPMSettingController
* @abstract Register for callbacks on changes to certain PM settings.
uintptr_t refcon,
OSObject **handle); // out param
- virtual IONotifier * registerInterest(
+ virtual OSPtr<IONotifier> registerInterest(
const OSSymbol * typeOfInterest,
IOServiceInterestHandler handler,
void * target, void * ref = NULL ) APPLE_KEXT_OVERRIDE;
/* Root Domain internals */
public:
void tagPowerPlaneService(
- IOService * service,
- IOPMActions * actions );
+ IOService * service,
+ IOPMActions * actions,
+ IOPMPowerStateIndex maxPowerState );
void overrideOurPowerChange(
IOService * service,
IOPMActions * actions,
+ const IOPMRequest * request,
IOPMPowerStateIndex * inOutPowerState,
- IOPMPowerChangeFlags * inOutChangeFlags,
- IOPMRequestTag requestTag );
+ IOPMPowerChangeFlags * inOutChangeFlags );
void handleOurPowerChangeStart(
IOService * service,
IOPMActions * actions,
+ const IOPMRequest * request,
IOPMPowerStateIndex powerState,
- IOPMPowerChangeFlags * inOutChangeFlags,
- IOPMRequestTag requestTag );
+ IOPMPowerChangeFlags * inOutChangeFlags );
void handleOurPowerChangeDone(
IOService * service,
IOPMActions * actions,
+ const IOPMRequest * request,
IOPMPowerStateIndex powerState,
- IOPMPowerChangeFlags changeFlags,
- IOPMRequestTag requestTag );
+ IOPMPowerChangeFlags changeFlags );
- void overridePowerChangeForUIService(
+ void overridePowerChangeForService(
IOService * service,
IOPMActions * actions,
+ const IOPMRequest * request,
IOPMPowerStateIndex * inOutPowerState,
IOPMPowerChangeFlags * inOutChangeFlags );
void handlePowerChangeStartForPCIDevice(
IOService * service,
IOPMActions * actions,
+ const IOPMRequest * request,
IOPMPowerStateIndex powerState,
IOPMPowerChangeFlags * inOutChangeFlags );
void handlePowerChangeDoneForPCIDevice(
IOService * service,
IOPMActions * actions,
+ const IOPMRequest * request,
IOPMPowerStateIndex powerState,
IOPMPowerChangeFlags changeFlags );
void handleQueueSleepWakeUUID(
OSObject *obj);
- void handleDisplayPowerOn();
+ void willTellSystemCapabilityDidChange(void);
+
+ void handleSetDisplayPowerOn(bool powerOn);
void willNotifyPowerChildren( IOPMPowerStateIndex newPowerState );
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 traceNotification(OSObject *notifier, bool start, uint64_t ts = 0, uint32_t msgIndex = UINT_MAX);
+ void traceNotificationAck(OSObject *notifier, uint32_t delay_ms);
+ void traceNotificationResponse(OSObject *object, uint32_t delay_ms, uint32_t ack_time_us);
+ void traceFilteredNotification(OSObject *notifier);
+ const char * getNotificationClientName(OSObject *notifier);
void startSpinDump(uint32_t spindumpKind);
uint32_t delay_ms,
uint64_t id,
OSObject *object,
- IOPMPowerStateIndex ps = 0);
+ IOPMPowerStateIndex ps = 0,
+ bool async = false);
void copyWakeReasonString( char * outBuf, size_t bufSize );
+ void copyShutdownReasonString( char * outBuf, size_t bufSize );
+ void lowLatencyAudioNotify(uint64_t time, boolean_t state);
#if HIBERNATION
bool getHibernateSettings(
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;
+ OSPtr<IOService> wrangler;
+ OSPtr<OSDictionary> wranglerIdleSettings;
IOLock *featuresDictLock;// guards supportedFeatures
IOLock *wakeEventLock;
IOPMPowerStateQueue *pmPowerStateQueue;
- OSArray *allowedPMSettings;
- OSArray *noPublishPMSettings;
- PMTraceWorker *pmTracer;
+ OSPtr<OSArray> allowedPMSettings;
+ OSPtr<OSArray> noPublishPMSettings;
+ OSPtr<PMTraceWorker> pmTracer;
PMAssertionsTracker *pmAssertions;
// Settings controller info
IOLock *settingsCtrlLock;
- OSDictionary *settingsCallbacks;
- OSDictionary *fPMSettingsDict;
-
- IONotifier *_batteryPublishNotifier;
- IONotifier *_displayWranglerNotifier;
+ OSPtr<OSDictionary> settingsCallbacks;
+ OSPtr<OSDictionary> fPMSettingsDict;
// Statistics
- const OSSymbol *_statsNameKey;
- const OSSymbol *_statsPIDKey;
- const OSSymbol *_statsTimeMSKey;
- const OSSymbol *_statsResponseTypeKey;
- const OSSymbol *_statsMessageTypeKey;
- const OSSymbol *_statsPowerCapsKey;
+ OSPtr<const OSSymbol> _statsNameKey;
+ OSPtr<const OSSymbol> _statsPIDKey;
+ OSPtr<const OSSymbol> _statsTimeMSKey;
+ OSPtr<const OSSymbol> _statsResponseTypeKey;
+ OSPtr<const OSSymbol> _statsMessageTypeKey;
+ OSPtr<const OSSymbol> _statsPowerCapsKey;
uint32_t sleepCnt;
uint32_t darkWakeCnt;
uint32_t displayWakeCnt;
- OSString *queuedSleepWakeUUIDString;
- OSArray *pmStatsAppResponses;
+ OSPtr<OSString> queuedSleepWakeUUIDString;
+ OSPtr<OSArray> pmStatsAppResponses;
IOLock *pmStatsLock;// guards pmStatsAppResponses
void *sleepDelaysReport; // report to track time taken to go to sleep
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
// Pref: idle time before idle sleep
bool idleSleepEnabled;
- unsigned long sleepSlider;
- unsigned long idleSeconds;
- uint64_t autoWakeStart;
- uint64_t autoWakeEnd;
+ uint32_t sleepSlider;
+ uint32_t idleSeconds;
// Difference between sleepSlider and longestNonSleepSlider
- unsigned long extraSleepDelay;
+ uint32_t extraSleepDelay;
// Used to wait between say display idle and system idle
thread_call_t extraSleepTimer;
uint32_t _currentCapability;
uint32_t _pendingCapability;
uint32_t _highestCapability;
- OSSet * _joinedCapabilityClients;
+ OSPtr<OSSet> _joinedCapabilityClients;
uint32_t _systemStateGeneration;
// Type of clients that can receive system messages.
unsigned int desktopMode :1;
unsigned int acAdaptorConnected :1;
- unsigned int clamshellSleepDisabled :1;
+ unsigned int clamshellIgnoreClose :1;
unsigned int idleSleepTimerPending :1;
unsigned int userDisabledAllSleep :1;
unsigned int ignoreTellChangeDown :1;
unsigned int wranglerAsleep :1;
- unsigned int wranglerTickled :1;
+ unsigned int darkWakeExit :1;
unsigned int _preventUserActive :1;
- unsigned int graphicsSuppressed :1;
- unsigned int isRTCAlarmWake :1;
+ unsigned int darkWakePowerClamped :1;
unsigned int capabilityLoss :1;
unsigned int pciCantSleepFlag :1;
unsigned int pciCantSleepValid :1;
- unsigned int logGraphicsClamp :1;
+ unsigned int darkWakeLogClamp :1;
unsigned int darkWakeToSleepASAP :1;
unsigned int darkWakeMaintenance :1;
unsigned int darkWakeSleepService :1;
unsigned int lowBatteryCondition :1;
unsigned int hibernateDisabled :1;
unsigned int hibernateRetry :1;
- unsigned int wranglerTickleLatched :1;
+ unsigned int wranglerTickled :1;
unsigned int userIsActive :1;
unsigned int userWasActive :1;
unsigned int displayIdleForDemandSleep :1;
unsigned int darkWakeHibernateError :1;
- unsigned int thermalWarningState:1;
+ unsigned int thermalWarningState :1;
unsigned int toldPowerdCapWillChange :1;
- unsigned int displayPowerOnRequested:1;
+ unsigned int displayPowerOnRequested :1;
+ unsigned int isRTCAlarmWake :1;
+ unsigned int wranglerPowerOff :1;
+ unsigned int thermalEmergencyState :1;
uint8_t tasksSuspended;
uint8_t tasksSuspendState;
};
uint32_t fullWakeReason;
+ enum {
+ kClamshellSleepDisableInternal = 0x01,
+ kClamshellSleepDisablePowerd = 0x02
+ };
+ uint32_t clamshellSleepDisableMask;
+
// 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;
+ OSPtr<OSData> aggressivesData;
AbsoluteTime userBecameInactiveTime;
// PCI top-level PM trace
- IOService * pciHostBridgeDevice;
- IOService * pciHostBridgeDriver;
+ OSPtr<IOService> pciHostBridgeDevice;
+ OSPtr<IOService> pciHostBridgeDriver;
- IONotifier * systemCapabilityNotifier;
+ OSPtr<IONotifier> systemCapabilityNotifier;
typedef struct {
uint32_t pid;
uint32_t pmSuspendedSize;
PMNotifySuspendedStruct *pmSuspendedPIDS;
- OSSet * preventIdleSleepList;
- OSSet * preventSystemSleepList;
+ OSPtr<OSSet> preventIdleSleepList;
+ OSPtr<OSSet> preventSystemSleepList;
- UInt32 _scheduledAlarms;
- UInt32 _userScheduledAlarm;
- clock_sec_t _scheduledAlarmUTC;
+ OSPtr<const OSSymbol> _nextScheduledAlarmType;
+ clock_sec_t _nextScheduledAlarmUTC;
+ clock_sec_t _calendarWakeAlarmUTC;
+ UInt32 _scheduledAlarmMask;
+ UInt32 _userScheduledAlarmMask;
#if HIBERNATION
clock_sec_t _standbyTimerResetSeconds;
void * swd_compressed_buffer;
void * swd_spindump_buffer;
thread_t notifierThread;
- OSObject *notifierObject;
+ OSPtr<OSObject> notifierObject;
- IOBufferMemoryDescriptor *swd_memDesc;
+ OSPtr<IOBufferMemoryDescriptor> swd_spindump_memDesc;
+ OSPtr<IOBufferMemoryDescriptor> swd_memDesc;
// Wake Event Reporting
- OSArray * _systemWakeEventsArray;
- bool _acceptSystemWakeEvents;
+ OSPtr<OSArray> _systemWakeEventsArray;
+ bool _acceptSystemWakeEvents;
// AOT --
IOPMCalendarStruct _aotWakeTimeCalendar;
- IOTimerEventSource * _aotTimerES;
+ OSPtr<IOTimerEventSource> _aotTimerES;
clock_sec_t _aotWakeTimeUTC;
uint64_t _aotTestTime;
uint64_t _aotTestInterval;
// IOPMrootDomain internal sleep call
IOReturn privateSleepSystem( uint32_t sleepReason );
void reportUserInput( void );
+ void updateUserActivity( void );
void setDisableClamShellSleep( bool );
+ void setClamShellSleepDisable(bool disable, uint32_t bitmask);
bool checkSystemSleepAllowed( IOOptionBits options,
uint32_t sleepReason );
bool checkSystemSleepEnabled( void );
void sleepWakeDebugSpinDumpMemAlloc();
errno_t sleepWakeDebugSaveFile(const char *name, char *buf, int len);
+ IOReturn changePowerStateWithOverrideTo( IOPMPowerStateIndex ordinal, IOPMRequestTag tag );
+ IOReturn changePowerStateWithTagToPriv( IOPMPowerStateIndex ordinal, IOPMRequestTag tag );
+ IOReturn changePowerStateWithTagTo( IOPMPowerStateIndex ordinal, IOPMRequestTag tag );
#if HIBERNATION
bool getSleepOption( const char * key, uint32_t * option );
bool latchDisplayWranglerTickle( bool latch );
void setDisplayPowerOn( uint32_t options );
- void acceptSystemWakeEvents( bool accept );
+ void acceptSystemWakeEvents( uint32_t control );
void systemDidNotSleep( void );
void preventTransitionToUserActive( bool prevent );
void setThermalState(OSObject *value);
void copySleepPreventersList(OSArray **idleSleepList, OSArray **systemSleepList);
void copySleepPreventersListWithID(OSArray **idleSleepList, OSArray **systemSleepList);
+ void recordRTCAlarm(const OSSymbol *type, OSObject *object);
+
+ // Used to inform interested clients about low latency audio activity in the system
+ OSPtr<OSDictionary> lowLatencyAudioNotifierDict;
+ OSPtr<OSNumber> lowLatencyAudioNotifyStateVal;
+ OSPtr<OSNumber> lowLatencyAudioNotifyTimestampVal;
+ OSPtr<const OSSymbol> lowLatencyAudioNotifyStateSym;
+ OSPtr<const OSSymbol> lowLatencyAudioNotifyTimestampSym;
#endif /* XNU_KERNEL_PRIVATE */
};
public:
static void initialize( void );
- virtual OSObject * copyProperty( const char * aKey ) const APPLE_KEXT_OVERRIDE;
+ virtual OSPtr<OSObject> copyProperty( const char * aKey ) const APPLE_KEXT_OVERRIDE;
bool start( IOService * nub ) APPLE_KEXT_OVERRIDE;
void shutDownSystem( void );
void restartSystem( void );