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