]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/pwr_mgt/RootDomain.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / RootDomain.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
8ad349bb 4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
1c79356b 5 *
8ad349bb
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
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
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
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.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
1c79356b
A
29 */
30#ifndef _IOKIT_ROOTDOMAIN_H
31#define _IOKIT_ROOTDOMAIN_H
32
33#include <IOKit/IOService.h>
34#include <IOKit/pwr_mgt/IOPM.h>
35
55e303ae 36class IOPMPowerStateQueue;
1c79356b
A
37class RootDomainUserClient;
38
8ad349bb
A
39#define kRootDomainSupportedFeatures "Supported Features"
40
1c79356b
A
41enum {
42 kRootDomainSleepNotSupported = 0x00000000,
43 kRootDomainSleepSupported = 0x00000001,
0b4e3aa0
A
44 kFrameBufferDeepSleepSupported = 0x00000002,
45 kPCICantSleep = 0x00000004
1c79356b
A
46};
47
8ad349bb
A
48// Constants for use as arguments to the settings callback PMU/SMU defines
49// with registerPMSettingsController
e5568f75 50enum {
8ad349bb
A
51 kIOPMAutoWakeSetting = 1,
52 kIOPMAutoPowerOnSetting,
53 kIOPMWakeOnRingSetting,
54 kIOPMAutoRestartOnPowerLossSetting,
55 kIOPMWakeOnLidSetting,
56 kIOPMWakeOnACChangeSetting,
57 kIOPMTimeZoneSetting
e5568f75 58};
8ad349bb 59typedef int IOPMSystemSettingType;
e5568f75 60
e5568f75 61
c0fea474 62
8ad349bb 63typedef IOReturn (*IOPMSettingControllerCallback)(IOPMSystemSettingType arg_type, int arg_val, void *info);
c0fea474 64
8ad349bb
A
65extern "C"
66{
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 );
1c79356b
A
73}
74
d52fe63f 75#define IOPM_ROOTDOMAIN_REV 2
1c79356b
A
76
77class IOPMrootDomain: public IOService
78{
79OSDeclareDefaultStructors(IOPMrootDomain)
80
81public:
82
0b4e3aa0
A
83 class IOService * wrangler; // we tickle the wrangler on button presses, etc
84
85 static IOPMrootDomain * construct( void );
86 virtual bool start( IOService * provider );
1c79356b
A
87 virtual IOReturn setAggressiveness ( unsigned long, unsigned long );
88 virtual IOReturn youAreRoot ( void );
89 virtual IOReturn sleepSystem ( void );
9bccf70c 90 virtual IOReturn setProperties ( OSObject * );
0b4e3aa0
A
91 IOReturn shutdownSystem ( void );
92 IOReturn restartSystem ( void );
1c79356b
A
93 virtual IOReturn receivePowerNotification (UInt32 msg);
94 virtual void setSleepSupported( IOOptionBits flags );
95 virtual IOOptionBits getSleepSupported();
0b4e3aa0
A
96 virtual IOReturn requestPowerDomainState ( IOPMPowerFlags, IOPowerConnection *, unsigned long );
97 virtual void handleSleepTimerExpiration ( void );
d52fe63f 98 void stopIgnoringClamshellEventsDuringWakeup ( void );
0b4e3aa0 99 void wakeFromDoze( void );
9bccf70c 100 void broadcast_it (unsigned long, unsigned long );
d52fe63f 101 void publishFeature( const char *feature );
55e303ae
A
102 void unIdleDevice( IOService *, unsigned long );
103 void announcePowerSourceChange( void );
8ad349bb 104
9bccf70c
A
105 // Override of these methods for logging purposes.
106 virtual IOReturn changePowerStateTo ( unsigned long ordinal );
107 virtual IOReturn changePowerStateToPriv ( unsigned long ordinal );
108
8ad349bb 109 IOReturn registerPMSettingController(IOPMSettingControllerCallback, void *);
e5568f75 110
1c79356b
A
111private:
112
8ad349bb
A
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
d52fe63f 119
1c79356b
A
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 );
0b4e3aa0
A
126 void reportUserInput ( void );
127 static IOReturn sysPowerDownHandler( void * target, void * refCon,
128 UInt32 messageType, IOService * service,
129 void * messageArgument, vm_size_t argSize );
130
131 static IOReturn displayWranglerNotification( void * target, void * refCon,
132 UInt32 messageType, IOService * service,
133 void * messageArgument, vm_size_t argSize );
134
135 static bool displayWranglerPublished( void * target, void * refCon,
136 IOService * newService);
137
8ad349bb 138 static bool batteryLocationPublished( void * target, void * refCon,
483a1d10
A
139 IOService * resourceService );
140
0b4e3aa0 141 void setQuickSpinDownTimeout ( void );
8ad349bb 142 void adjustPowerState( void );
0b4e3aa0 143 void restoreUserSpinDownTimeout ( void );
8ad349bb 144
91447636 145 IOLock *featuresDictLock; // guards supportedFeatures
55e303ae 146 IOPMPowerStateQueue *pmPowerStateQueue;
0b4e3aa0
A
147 unsigned int user_spindown; // User's selected disk spindown value
148
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;
d52fe63f
A
156 unsigned int desktopMode:1;
157
158 unsigned int acAdaptorConnect:1;
159 unsigned int ignoringClamshellDuringWakeup:1;
8ad349bb 160 unsigned int reservedA:6;
d52fe63f 161 unsigned char reservedB[3];
e5568f75 162
8ad349bb
A
163 struct PMSettingCtrl {
164 IOPMSettingControllerCallback func;
165 void *refcon;
166 };
e5568f75 167
8ad349bb
A
168 // Private helper to call PM setting controller
169 IOReturn setPMSetting(int type, OSNumber *);
170
e5568f75 171 struct ExpansionData {
8ad349bb
A
172 PMSettingCtrl *_settingController;
173 thread_call_t diskSyncCalloutEntry;
174 IONotifier *_batteryLocationNotifier;
175 IONotifier *_displayWranglerNotifier;
e5568f75
A
176 };
177 ExpansionData *_reserved;
1c79356b
A
178 IOOptionBits platformSleepSupport;
179};
180
181class IORootParent: public IOService
182{
183OSDeclareDefaultStructors(IORootParent)
0b4e3aa0
A
184
185private:
186 unsigned long mostRecentChange;
1c79356b
A
187
188public:
189
190 bool start ( IOService * nub );
191 void shutDownSystem ( void );
0b4e3aa0 192 void restartSystem ( void );
1c79356b 193 void sleepSystem ( void );
0b4e3aa0
A
194 void dozeSystem ( void );
195 void sleepToDoze ( void );
1c79356b
A
196 void wakeSystem ( void );
197};
198
199
200#endif /* _IOKIT_ROOTDOMAIN_H */