#ifndef _IOKIT_ROOTDOMAIN_H
#define _IOKIT_ROOTDOMAIN_H
#include <IOKit/IOService.h>
#include <IOKit/pwr_mgt/IOPM.h>
class IOPMWorkArbiter;
class IOPMPowerStateQueue;
class RootDomainUserClient;
enum {
kRootDomainSleepNotSupported = 0x00000000,
kRootDomainSleepSupported = 0x00000001,
kFrameBufferDeepSleepSupported = 0x00000002,
kPCICantSleep = 0x00000004
};
#define kRootDomainSupportedFeatures "Supported Features"
enum {
kIOPMSupportedOnAC = 1<<0,
kIOPMSupportedOnBatt = 1<<1,
kIOPMSupportedOnUPS = 1<<2
};
typedef IOReturn (*IOPMSettingControllerCallback) \
(OSObject *target, const OSSymbol *type, \
OSObject *val, uintptr_t refcon);
extern "C"
{
IONotifier * registerSleepWakeInterest(
IOServiceInterestHandler, void *, void * = 0);
IONotifier * registerPrioritySleepWakeInterest(
IOServiceInterestHandler handler,
void * self, void * ref = 0);
IOReturn acknowledgeSleepWakeNotification(void * );
IOReturn vetoSleepWakeNotification(void * PMrefcon);
IOReturn rootDomainRestart ( void );
IOReturn rootDomainShutdown ( void );
}
#define IOPM_ROOTDOMAIN_REV 2
class IOPMrootDomain: public IOService
{
OSDeclareDefaultStructors(IOPMrootDomain)
public:
class IOService * wrangler;
IOPMWorkArbiter * getPMArbiter(void);
static IOPMrootDomain * construct( void );
virtual bool start( IOService * provider );
virtual IOReturn setAggressiveness ( unsigned long, unsigned long );
virtual IOReturn youAreRoot ( void );
virtual IOReturn sleepSystem ( void );
virtual IOReturn setProperties ( OSObject * );
IOReturn shutdownSystem ( void );
IOReturn restartSystem ( void );
virtual IOReturn receivePowerNotification (UInt32 msg);
virtual void setSleepSupported( IOOptionBits flags );
virtual IOOptionBits getSleepSupported();
virtual IOReturn requestPowerDomainState ( IOPMPowerFlags, IOPowerConnection *, unsigned long );
virtual void handleSleepTimerExpiration ( void );
void stopIgnoringClamshellEventsDuringWakeup ( void );
void wakeFromDoze( void );
void broadcast_it (unsigned long, unsigned long );
void publishFeature( const char *feature );
void publishFeature( const char *feature,
uint32_t supportedWhere,
uint32_t *uniqueFeatureID);
IOReturn removePublishedFeature( uint32_t removeFeatureID );
void unIdleDevice( IOService *, unsigned long );
void announcePowerSourceChange( void );
virtual IOReturn changePowerStateTo ( unsigned long ordinal );
virtual IOReturn changePowerStateToPriv ( unsigned long ordinal );
OSObject *copyPMSetting(OSSymbol *whichSetting);
IOReturn registerPMSettingController(
const OSSymbol *settings[],
IOPMSettingControllerCallback callout,
OSObject *target,
uintptr_t refcon,
OSObject **handle);
IOReturn registerPMSettingController(
const OSSymbol *settings[],
uint32_t supportedPowerSources,
IOPMSettingControllerCallback callout,
OSObject *target,
uintptr_t refcon,
OSObject **handle);
private:
class IORootParent * patriarch;
long sleepSlider;
long longestNonSleepSlider;
long extraSleepDelay;
thread_call_t extraSleepTimer;
thread_call_t clamshellWakeupIgnore;
virtual void powerChangeDone ( unsigned long );
virtual void command_received ( void *, void * , void * , void *);
virtual bool tellChangeDown ( unsigned long stateNum);
virtual bool askChangeDown ( unsigned long stateNum);
virtual void tellChangeUp ( unsigned long );
virtual void tellNoChangeDown ( unsigned long );
void reportUserInput ( void );
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 bool displayWranglerPublished( void * target, void * refCon,
IOService * newService);
static bool batteryPublished( void * target, void * refCon,
IOService * resourceService );
void adjustPowerState ( void );
void setQuickSpinDownTimeout ( void );
void restoreUserSpinDownTimeout ( void );
bool shouldSleepOnClamshellClosed (void );
void sendClientClamshellNotification ( void );
IOLock *featuresDictLock; IOPMPowerStateQueue *pmPowerStateQueue;
IOWorkLoop *arbiterWorkLoop;
IOPMWorkArbiter *pmArbiter;
unsigned int user_spindown;
unsigned int systemBooting:1;
unsigned int ignoringClamshell:1;
unsigned int allowSleep:1;
unsigned int sleepIsSupported:1;
unsigned int canSleep:1;
unsigned int idleSleepPending:1;
unsigned int sleepASAP:1;
unsigned int desktopMode:1;
unsigned int acAdaptorConnect:1;
unsigned int ignoringClamshellDuringWakeup:1;
unsigned int clamshellIsClosed:1;
unsigned int clamshellExists:1;
unsigned int reservedA:4;
unsigned char reservedB[3];
OSArray *allowedPMSettings;
IORecursiveLock *settingsCtrlLock;
OSDictionary *settingsCallbacks;
OSDictionary *fPMSettingsDict;
IOReturn setPMSetting(const OSSymbol *, OSObject *);
thread_call_t diskSyncCalloutEntry;
IONotifier *_batteryPublishNotifier;
IONotifier *_displayWranglerNotifier;
struct ExpansionData {
};
ExpansionData *_reserved;
IOOptionBits platformSleepSupport;
friend class PMSettingObject;
};
class IORootParent: public IOService
{
OSDeclareDefaultStructors(IORootParent)
private:
unsigned long mostRecentChange;
public:
virtual IOReturn changePowerStateToPriv ( unsigned long ordinal );
bool start ( IOService * nub );
void shutDownSystem ( void );
void restartSystem ( void );
void sleepSystem ( void );
void dozeSystem ( void );
void sleepToDoze ( void );
void wakeSystem ( void );
};
#endif