]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/pwr_mgt/RootDomain.h
xnu-517.7.21.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
A
99 IOReturn registerPMSettingController(IOPMSettingControllerCallback, void *);
100
1c79356b
A
101private:
102
0b4e3aa0
A
103 class IORootParent * patriarch; // points to our parent
104 long sleepSlider; // pref: idle time before idle sleep
105 long longestNonSleepSlider; // pref: longest of other idle times
106 long extraSleepDelay; // sleepSlider - longestNonSleepSlider
107 thread_call_t extraSleepTimer; // used to wait between say display idle and system idle
d52fe63f
A
108 thread_call_t clamshellWakeupIgnore; // Used to ignore clamshell close events while we're waking from sleep
109
1c79356b
A
110 virtual void powerChangeDone ( unsigned long );
111 virtual void command_received ( void *, void * , void * , void *);
112 virtual bool tellChangeDown ( unsigned long stateNum);
113 virtual bool askChangeDown ( unsigned long stateNum);
114 virtual void tellChangeUp ( unsigned long );
115 virtual void tellNoChangeDown ( unsigned long );
0b4e3aa0
A
116 void reportUserInput ( void );
117 static IOReturn sysPowerDownHandler( void * target, void * refCon,
118 UInt32 messageType, IOService * service,
119 void * messageArgument, vm_size_t argSize );
120
121 static IOReturn displayWranglerNotification( void * target, void * refCon,
122 UInt32 messageType, IOService * service,
123 void * messageArgument, vm_size_t argSize );
124
125 static bool displayWranglerPublished( void * target, void * refCon,
126 IOService * newService);
127
483a1d10
A
128 static bool batteryLocationPublished( void * target, void * refCon,
129 IOService * resourceService );
130
0b4e3aa0
A
131 void setQuickSpinDownTimeout ( void );
132 void adjustPowerState( void );
133 void restoreUserSpinDownTimeout ( void );
1c79356b 134
55e303ae 135 IOPMPowerStateQueue *pmPowerStateQueue;
0b4e3aa0
A
136 unsigned int user_spindown; // User's selected disk spindown value
137
138 unsigned int systemBooting:1;
139 unsigned int ignoringClamshell:1;
140 unsigned int allowSleep:1;
141 unsigned int sleepIsSupported:1;
142 unsigned int canSleep:1;
143 unsigned int idleSleepPending:1;
144 unsigned int sleepASAP:1;
d52fe63f
A
145 unsigned int desktopMode:1;
146
147 unsigned int acAdaptorConnect:1;
148 unsigned int ignoringClamshellDuringWakeup:1;
149 unsigned int reservedA:6;
150 unsigned char reservedB[3];
e5568f75
A
151
152 struct PMSettingCtrl {
153 IOPMSettingControllerCallback func;
154 void *refcon;
155 };
156
157 // Private helper to call PM setting controller
158 IOReturn setPMSetting(int type, OSNumber *);
483a1d10 159
e5568f75 160 struct ExpansionData {
483a1d10
A
161 PMSettingCtrl *_settingController;
162 thread_call_t diskSyncCalloutEntry;
163 IONotifier *_batteryLocationNotifier;
164 IONotifier *_displayWranglerNotifier;
e5568f75
A
165 };
166 ExpansionData *_reserved;
1c79356b
A
167 IOOptionBits platformSleepSupport;
168};
169
170class IORootParent: public IOService
171{
172OSDeclareDefaultStructors(IORootParent)
0b4e3aa0
A
173
174private:
175 unsigned long mostRecentChange;
1c79356b
A
176
177public:
178
179 bool start ( IOService * nub );
180 void shutDownSystem ( void );
0b4e3aa0 181 void restartSystem ( void );
1c79356b 182 void sleepSystem ( void );
0b4e3aa0
A
183 void dozeSystem ( void );
184 void sleepToDoze ( void );
1c79356b
A
185 void wakeSystem ( void );
186};
187
188
189#endif /* _IOKIT_ROOTDOMAIN_H */