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