]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/pwr_mgt/RootDomain.h
xnu-517.12.7.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 *
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 28class IOPMPowerStateQueue;
1c79356b
A
29class RootDomainUserClient;
30
d52fe63f
A
31#define kRootDomainSupportedFeatures "Supported Features"
32
1c79356b
A
33enum {
34 kRootDomainSleepNotSupported = 0x00000000,
35 kRootDomainSleepSupported = 0x00000001,
0b4e3aa0
A
36 kFrameBufferDeepSleepSupported = 0x00000002,
37 kPCICantSleep = 0x00000004
1c79356b
A
38};
39
e5568f75
A
40// Constants for use as arguments to registerPMSettingsController
41enum {
42 kIOPMAutoWakeSetting = 1,
43 kIOPMAutoPowerOnSetting,
44 kIOPMWakeOnRingSetting,
45 kIOPMAutoRestartOnPowerLossSetting,
46 kIOPMWakeOnLidSetting,
47 kIOPMWakeOnACChangeSetting
48};
49typedef int IOPMSystemSettingType;
50
51
52
53typedef IOReturn (*IOPMSettingControllerCallback)(IOPMSystemSettingType arg_type, int arg_val, void *info);
54
1c79356b
A
55extern "C"
56{
57 IONotifier * registerSleepWakeInterest(IOServiceInterestHandler, void *, void * = 0);
0b4e3aa0 58 IONotifier * registerPrioritySleepWakeInterest(IOServiceInterestHandler handler, void * self, void * ref = 0);
1c79356b 59 IOReturn acknowledgeSleepWakeNotification(void * );
0b4e3aa0
A
60 IOReturn vetoSleepWakeNotification(void * PMrefcon);
61 IOReturn rootDomainRestart ( void );
62 IOReturn rootDomainShutdown ( void );
1c79356b
A
63}
64
d52fe63f 65#define IOPM_ROOTDOMAIN_REV 2
1c79356b
A
66
67class IOPMrootDomain: public IOService
68{
69OSDeclareDefaultStructors(IOPMrootDomain)
70
71public:
72
0b4e3aa0
A
73 class IOService * wrangler; // we tickle the wrangler on button presses, etc
74
75 static IOPMrootDomain * construct( void );
76 virtual bool start( IOService * provider );
1c79356b
A
77 virtual IOReturn setAggressiveness ( unsigned long, unsigned long );
78 virtual IOReturn youAreRoot ( void );
79 virtual IOReturn sleepSystem ( void );
9bccf70c 80 virtual IOReturn setProperties ( OSObject * );
0b4e3aa0
A
81 IOReturn shutdownSystem ( void );
82 IOReturn restartSystem ( void );
1c79356b
A
83 virtual IOReturn receivePowerNotification (UInt32 msg);
84 virtual void setSleepSupported( IOOptionBits flags );
85 virtual IOOptionBits getSleepSupported();
0b4e3aa0
A
86 virtual IOReturn requestPowerDomainState ( IOPMPowerFlags, IOPowerConnection *, unsigned long );
87 virtual void handleSleepTimerExpiration ( void );
d52fe63f 88 void stopIgnoringClamshellEventsDuringWakeup ( void );
0b4e3aa0 89 void wakeFromDoze( void );
9bccf70c 90 void broadcast_it (unsigned long, unsigned long );
d52fe63f 91 void publishFeature( const char *feature );
55e303ae
A
92 void unIdleDevice( IOService *, unsigned long );
93 void announcePowerSourceChange( void );
e5568f75 94
9bccf70c
A
95 // Override of these methods for logging purposes.
96 virtual IOReturn changePowerStateTo ( unsigned long ordinal );
97 virtual IOReturn changePowerStateToPriv ( unsigned long ordinal );
98
e5568f75 99 IOReturn registerPMSettingController(IOPMSettingControllerCallback, void *);
ccc36f2f 100 IOReturn registerPlatformPowerProfiles(OSArray *);
e5568f75 101
1c79356b
A
102private:
103
0b4e3aa0
A
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
d52fe63f
A
109 thread_call_t clamshellWakeupIgnore; // Used to ignore clamshell close events while we're waking from sleep
110
1c79356b
A
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 );
0b4e3aa0
A
117 void reportUserInput ( void );
118 static IOReturn sysPowerDownHandler( void * target, void * refCon,
119 UInt32 messageType, IOService * service,
120 void * messageArgument, vm_size_t argSize );
121
122 static IOReturn displayWranglerNotification( void * target, void * refCon,
123 UInt32 messageType, IOService * service,
124 void * messageArgument, vm_size_t argSize );
125
126 static bool displayWranglerPublished( void * target, void * refCon,
127 IOService * newService);
128
483a1d10
A
129 static bool batteryLocationPublished( void * target, void * refCon,
130 IOService * resourceService );
131
0b4e3aa0
A
132 void setQuickSpinDownTimeout ( void );
133 void adjustPowerState( void );
134 void restoreUserSpinDownTimeout ( void );
1c79356b 135
55e303ae 136 IOPMPowerStateQueue *pmPowerStateQueue;
0b4e3aa0
A
137 unsigned int user_spindown; // User's selected disk spindown value
138
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;
d52fe63f
A
146 unsigned int desktopMode:1;
147
148 unsigned int acAdaptorConnect:1;
149 unsigned int ignoringClamshellDuringWakeup:1;
150 unsigned int reservedA:6;
151 unsigned char reservedB[3];
e5568f75
A
152
153 struct PMSettingCtrl {
154 IOPMSettingControllerCallback func;
155 void *refcon;
156 };
157
158 // Private helper to call PM setting controller
159 IOReturn setPMSetting(int type, OSNumber *);
483a1d10 160
e5568f75 161 struct ExpansionData {
483a1d10
A
162 PMSettingCtrl *_settingController;
163 thread_call_t diskSyncCalloutEntry;
164 IONotifier *_batteryLocationNotifier;
165 IONotifier *_displayWranglerNotifier;
e5568f75
A
166 };
167 ExpansionData *_reserved;
1c79356b
A
168 IOOptionBits platformSleepSupport;
169};
170
171class IORootParent: public IOService
172{
173OSDeclareDefaultStructors(IORootParent)
0b4e3aa0
A
174
175private:
176 unsigned long mostRecentChange;
1c79356b
A
177
178public:
179
180 bool start ( IOService * nub );
181 void shutDownSystem ( void );
0b4e3aa0 182 void restartSystem ( void );
1c79356b 183 void sleepSystem ( void );
0b4e3aa0
A
184 void dozeSystem ( void );
185 void sleepToDoze ( void );
1c79356b
A
186 void wakeSystem ( void );
187};
188
189
190#endif /* _IOKIT_ROOTDOMAIN_H */