2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #ifndef _IOKIT_ROOTDOMAIN_H
23 #define _IOKIT_ROOTDOMAIN_H
25 #include <IOKit/IOService.h>
26 #include <IOKit/pwr_mgt/IOPM.h>
28 class IOPMPowerStateQueue
;
29 class RootDomainUserClient
;
31 #define kRootDomainSupportedFeatures "Supported Features"
34 kRootDomainSleepNotSupported
= 0x00000000,
35 kRootDomainSleepSupported
= 0x00000001,
36 kFrameBufferDeepSleepSupported
= 0x00000002,
37 kPCICantSleep
= 0x00000004
40 // Constants for use as arguments to registerPMSettingsController
42 kIOPMAutoWakeSetting
= 1,
43 kIOPMAutoPowerOnSetting
,
44 kIOPMWakeOnRingSetting
,
45 kIOPMAutoRestartOnPowerLossSetting
,
46 kIOPMWakeOnLidSetting
,
47 kIOPMWakeOnACChangeSetting
49 typedef int IOPMSystemSettingType
;
53 typedef IOReturn (*IOPMSettingControllerCallback
)(IOPMSystemSettingType arg_type
, int arg_val
, void *info
);
57 IONotifier
* registerSleepWakeInterest(IOServiceInterestHandler
, void *, void * = 0);
58 IONotifier
* registerPrioritySleepWakeInterest(IOServiceInterestHandler handler
, void * self
, void * ref
= 0);
59 IOReturn
acknowledgeSleepWakeNotification(void * );
60 IOReturn
vetoSleepWakeNotification(void * PMrefcon
);
61 IOReturn
rootDomainRestart ( void );
62 IOReturn
rootDomainShutdown ( void );
65 #define IOPM_ROOTDOMAIN_REV 2
67 class IOPMrootDomain
: public IOService
69 OSDeclareDefaultStructors(IOPMrootDomain
)
73 class IOService
* wrangler
; // we tickle the wrangler on button presses, etc
75 static IOPMrootDomain
* construct( void );
76 virtual bool start( IOService
* provider
);
77 virtual IOReturn
setAggressiveness ( unsigned long, unsigned long );
78 virtual IOReturn
youAreRoot ( void );
79 virtual IOReturn
sleepSystem ( void );
80 virtual IOReturn
setProperties ( OSObject
* );
81 IOReturn
shutdownSystem ( void );
82 IOReturn
restartSystem ( void );
83 virtual IOReturn
receivePowerNotification (UInt32 msg
);
84 virtual void setSleepSupported( IOOptionBits flags
);
85 virtual IOOptionBits
getSleepSupported();
86 virtual IOReturn
requestPowerDomainState ( IOPMPowerFlags
, IOPowerConnection
*, unsigned long );
87 virtual void handleSleepTimerExpiration ( void );
88 void stopIgnoringClamshellEventsDuringWakeup ( void );
89 void wakeFromDoze( void );
90 void broadcast_it (unsigned long, unsigned long );
91 void publishFeature( const char *feature
);
92 void unIdleDevice( IOService
*, unsigned long );
93 void announcePowerSourceChange( void );
95 // Override of these methods for logging purposes.
96 virtual IOReturn
changePowerStateTo ( unsigned long ordinal
);
97 virtual IOReturn
changePowerStateToPriv ( unsigned long ordinal
);
99 IOReturn
registerPMSettingController(IOPMSettingControllerCallback
, void *);
100 IOReturn
registerPlatformPowerProfiles(OSArray
*);
104 class IORootParent
* patriarch
; // points to our parent
105 long sleepSlider
; // pref: idle time before idle sleep
106 long longestNonSleepSlider
; // pref: longest of other idle times
107 long extraSleepDelay
; // sleepSlider - longestNonSleepSlider
108 thread_call_t extraSleepTimer
; // used to wait between say display idle and system idle
109 thread_call_t clamshellWakeupIgnore
; // Used to ignore clamshell close events while we're waking from sleep
111 virtual void powerChangeDone ( unsigned long );
112 virtual void command_received ( void *, void * , void * , void *);
113 virtual bool tellChangeDown ( unsigned long stateNum
);
114 virtual bool askChangeDown ( unsigned long stateNum
);
115 virtual void tellChangeUp ( unsigned long );
116 virtual void tellNoChangeDown ( unsigned long );
117 void reportUserInput ( void );
118 static IOReturn
sysPowerDownHandler( void * target
, void * refCon
,
119 UInt32 messageType
, IOService
* service
,
120 void * messageArgument
, vm_size_t argSize
);
122 static IOReturn
displayWranglerNotification( void * target
, void * refCon
,
123 UInt32 messageType
, IOService
* service
,
124 void * messageArgument
, vm_size_t argSize
);
126 static bool displayWranglerPublished( void * target
, void * refCon
,
127 IOService
* newService
);
129 static bool batteryLocationPublished( void * target
, void * refCon
,
130 IOService
* resourceService
);
132 void setQuickSpinDownTimeout ( void );
133 void adjustPowerState( void );
134 void restoreUserSpinDownTimeout ( void );
136 IOPMPowerStateQueue
*pmPowerStateQueue
;
137 unsigned int user_spindown
; // User's selected disk spindown value
139 unsigned int systemBooting
:1;
140 unsigned int ignoringClamshell
:1;
141 unsigned int allowSleep
:1;
142 unsigned int sleepIsSupported
:1;
143 unsigned int canSleep
:1;
144 unsigned int idleSleepPending
:1;
145 unsigned int sleepASAP
:1;
146 unsigned int desktopMode
:1;
148 unsigned int acAdaptorConnect
:1;
149 unsigned int ignoringClamshellDuringWakeup
:1;
150 unsigned int reservedA
:6;
151 unsigned char reservedB
[3];
153 struct PMSettingCtrl
{
154 IOPMSettingControllerCallback func
;
158 // Private helper to call PM setting controller
159 IOReturn
setPMSetting(int type
, OSNumber
*);
161 struct ExpansionData
{
162 PMSettingCtrl
*_settingController
;
163 thread_call_t diskSyncCalloutEntry
;
164 IONotifier
*_batteryLocationNotifier
;
165 IONotifier
*_displayWranglerNotifier
;
167 ExpansionData
*_reserved
;
168 IOOptionBits platformSleepSupport
;
171 class IORootParent
: public IOService
173 OSDeclareDefaultStructors(IORootParent
)
176 unsigned long mostRecentChange
;
180 bool start ( IOService
* nub
);
181 void shutDownSystem ( void );
182 void restartSystem ( void );
183 void sleepSystem ( void );
184 void dozeSystem ( void );
185 void sleepToDoze ( void );
186 void wakeSystem ( void );
190 #endif /* _IOKIT_ROOTDOMAIN_H */