2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 #ifndef _IOKIT_ROOTDOMAIN_H
31 #define _IOKIT_ROOTDOMAIN_H
33 #include <IOKit/IOService.h>
34 #include <IOKit/pwr_mgt/IOPM.h>
36 class IOPMPowerStateQueue
;
37 class RootDomainUserClient
;
39 #define kRootDomainSupportedFeatures "Supported Features"
42 kRootDomainSleepNotSupported
= 0x00000000,
43 kRootDomainSleepSupported
= 0x00000001,
44 kFrameBufferDeepSleepSupported
= 0x00000002,
45 kPCICantSleep
= 0x00000004
48 // Constants for use as arguments to the settings callback PMU/SMU defines
49 // with registerPMSettingsController
51 kIOPMAutoWakeSetting
= 1,
52 kIOPMAutoPowerOnSetting
,
53 kIOPMWakeOnRingSetting
,
54 kIOPMAutoRestartOnPowerLossSetting
,
55 kIOPMWakeOnLidSetting
,
56 kIOPMWakeOnACChangeSetting
,
59 typedef int IOPMSystemSettingType
;
63 typedef IOReturn (*IOPMSettingControllerCallback
)(IOPMSystemSettingType arg_type
, int arg_val
, void *info
);
67 IONotifier
* registerSleepWakeInterest(IOServiceInterestHandler
, void *, void * = 0);
68 IONotifier
* registerPrioritySleepWakeInterest(IOServiceInterestHandler handler
, void * self
, void * ref
= 0);
69 IOReturn
acknowledgeSleepWakeNotification(void * );
70 IOReturn
vetoSleepWakeNotification(void * PMrefcon
);
71 IOReturn
rootDomainRestart ( void );
72 IOReturn
rootDomainShutdown ( void );
75 #define IOPM_ROOTDOMAIN_REV 2
77 class IOPMrootDomain
: public IOService
79 OSDeclareDefaultStructors(IOPMrootDomain
)
83 class IOService
* wrangler
; // we tickle the wrangler on button presses, etc
85 static IOPMrootDomain
* construct( void );
86 virtual bool start( IOService
* provider
);
87 virtual IOReturn
setAggressiveness ( unsigned long, unsigned long );
88 virtual IOReturn
youAreRoot ( void );
89 virtual IOReturn
sleepSystem ( void );
90 virtual IOReturn
setProperties ( OSObject
* );
91 IOReturn
shutdownSystem ( void );
92 IOReturn
restartSystem ( void );
93 virtual IOReturn
receivePowerNotification (UInt32 msg
);
94 virtual void setSleepSupported( IOOptionBits flags
);
95 virtual IOOptionBits
getSleepSupported();
96 virtual IOReturn
requestPowerDomainState ( IOPMPowerFlags
, IOPowerConnection
*, unsigned long );
97 virtual void handleSleepTimerExpiration ( void );
98 void stopIgnoringClamshellEventsDuringWakeup ( void );
99 void wakeFromDoze( void );
100 void broadcast_it (unsigned long, unsigned long );
101 void publishFeature( const char *feature
);
102 void unIdleDevice( IOService
*, unsigned long );
103 void announcePowerSourceChange( void );
105 // Override of these methods for logging purposes.
106 virtual IOReturn
changePowerStateTo ( unsigned long ordinal
);
107 virtual IOReturn
changePowerStateToPriv ( unsigned long ordinal
);
109 IOReturn
registerPMSettingController(IOPMSettingControllerCallback
, void *);
113 class IORootParent
* patriarch
; // points to our parent
114 long sleepSlider
; // pref: idle time before idle sleep
115 long longestNonSleepSlider
; // pref: longest of other idle times
116 long extraSleepDelay
; // sleepSlider - longestNonSleepSlider
117 thread_call_t extraSleepTimer
; // used to wait between say display idle and system idle
118 thread_call_t clamshellWakeupIgnore
; // Used to ignore clamshell close events while we're waking from sleep
120 virtual void powerChangeDone ( unsigned long );
121 virtual void command_received ( void *, void * , void * , void *);
122 virtual bool tellChangeDown ( unsigned long stateNum
);
123 virtual bool askChangeDown ( unsigned long stateNum
);
124 virtual void tellChangeUp ( unsigned long );
125 virtual void tellNoChangeDown ( unsigned long );
126 void reportUserInput ( void );
127 static IOReturn
sysPowerDownHandler( void * target
, void * refCon
,
128 UInt32 messageType
, IOService
* service
,
129 void * messageArgument
, vm_size_t argSize
);
131 static IOReturn
displayWranglerNotification( void * target
, void * refCon
,
132 UInt32 messageType
, IOService
* service
,
133 void * messageArgument
, vm_size_t argSize
);
135 static bool displayWranglerPublished( void * target
, void * refCon
,
136 IOService
* newService
);
138 static bool batteryLocationPublished( void * target
, void * refCon
,
139 IOService
* resourceService
);
141 void setQuickSpinDownTimeout ( void );
142 void adjustPowerState( void );
143 void restoreUserSpinDownTimeout ( void );
145 IOLock
*featuresDictLock
; // guards supportedFeatures
146 IOPMPowerStateQueue
*pmPowerStateQueue
;
147 unsigned int user_spindown
; // User's selected disk spindown value
149 unsigned int systemBooting
:1;
150 unsigned int ignoringClamshell
:1;
151 unsigned int allowSleep
:1;
152 unsigned int sleepIsSupported
:1;
153 unsigned int canSleep
:1;
154 unsigned int idleSleepPending
:1;
155 unsigned int sleepASAP
:1;
156 unsigned int desktopMode
:1;
158 unsigned int acAdaptorConnect
:1;
159 unsigned int ignoringClamshellDuringWakeup
:1;
160 unsigned int reservedA
:6;
161 unsigned char reservedB
[3];
163 struct PMSettingCtrl
{
164 IOPMSettingControllerCallback func
;
168 // Private helper to call PM setting controller
169 IOReturn
setPMSetting(int type
, OSNumber
*);
171 struct ExpansionData
{
172 PMSettingCtrl
*_settingController
;
173 thread_call_t diskSyncCalloutEntry
;
174 IONotifier
*_batteryLocationNotifier
;
175 IONotifier
*_displayWranglerNotifier
;
177 ExpansionData
*_reserved
;
178 IOOptionBits platformSleepSupport
;
181 class IORootParent
: public IOService
183 OSDeclareDefaultStructors(IORootParent
)
186 unsigned long mostRecentChange
;
190 bool start ( IOService
* nub
);
191 void shutDownSystem ( void );
192 void restartSystem ( void );
193 void sleepSystem ( void );
194 void dozeSystem ( void );
195 void sleepToDoze ( void );
196 void wakeSystem ( void );
200 #endif /* _IOKIT_ROOTDOMAIN_H */