]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/pwr_mgt/RootDomain.h
bd7270585bfa8b9a05fb0695581a9cf0ce525037
[apple/xnu.git] / iokit / IOKit / pwr_mgt / RootDomain.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 #ifndef _IOKIT_ROOTDOMAIN_H
26 #define _IOKIT_ROOTDOMAIN_H
27
28 #include <IOKit/IOService.h>
29 #include <IOKit/pwr_mgt/IOPM.h>
30
31 class IOPMPowerStateQueue;
32 class RootDomainUserClient;
33
34 #define kRootDomainSupportedFeatures "Supported Features"
35
36 enum {
37 kRootDomainSleepNotSupported = 0x00000000,
38 kRootDomainSleepSupported = 0x00000001,
39 kFrameBufferDeepSleepSupported = 0x00000002,
40 kPCICantSleep = 0x00000004
41 };
42
43 extern "C"
44 {
45 IONotifier * registerSleepWakeInterest(IOServiceInterestHandler, void *, void * = 0);
46 IONotifier * registerPrioritySleepWakeInterest(IOServiceInterestHandler handler, void * self, void * ref = 0);
47 IOReturn acknowledgeSleepWakeNotification(void * );
48 IOReturn vetoSleepWakeNotification(void * PMrefcon);
49 IOReturn rootDomainRestart ( void );
50 IOReturn rootDomainShutdown ( void );
51 }
52
53 #define IOPM_ROOTDOMAIN_REV 2
54
55 class IOPMrootDomain: public IOService
56 {
57 OSDeclareDefaultStructors(IOPMrootDomain)
58
59 public:
60
61 class IOService * wrangler; // we tickle the wrangler on button presses, etc
62
63 static IOPMrootDomain * construct( void );
64 virtual bool start( IOService * provider );
65 virtual IOReturn setAggressiveness ( unsigned long, unsigned long );
66 virtual IOReturn youAreRoot ( void );
67 virtual IOReturn sleepSystem ( void );
68 virtual IOReturn setProperties ( OSObject * );
69 IOReturn shutdownSystem ( void );
70 IOReturn restartSystem ( void );
71 virtual IOReturn receivePowerNotification (UInt32 msg);
72 virtual void setSleepSupported( IOOptionBits flags );
73 virtual IOOptionBits getSleepSupported();
74 virtual IOReturn requestPowerDomainState ( IOPMPowerFlags, IOPowerConnection *, unsigned long );
75 virtual void handleSleepTimerExpiration ( void );
76 void stopIgnoringClamshellEventsDuringWakeup ( void );
77 void wakeFromDoze( void );
78 void broadcast_it (unsigned long, unsigned long );
79 void publishFeature( const char *feature );
80 void unIdleDevice( IOService *, unsigned long );
81 void announcePowerSourceChange( void );
82
83 // Override of these methods for logging purposes.
84 virtual IOReturn changePowerStateTo ( unsigned long ordinal );
85 virtual IOReturn changePowerStateToPriv ( unsigned long ordinal );
86
87 private:
88
89 class IORootParent * patriarch; // points to our parent
90 long sleepSlider; // pref: idle time before idle sleep
91 long longestNonSleepSlider; // pref: longest of other idle times
92 long extraSleepDelay; // sleepSlider - longestNonSleepSlider
93 thread_call_t extraSleepTimer; // used to wait between say display idle and system idle
94 thread_call_t clamshellWakeupIgnore; // Used to ignore clamshell close events while we're waking from sleep
95
96 virtual void powerChangeDone ( unsigned long );
97 virtual void command_received ( void *, void * , void * , void *);
98 virtual bool tellChangeDown ( unsigned long stateNum);
99 virtual bool askChangeDown ( unsigned long stateNum);
100 virtual void tellChangeUp ( unsigned long );
101 virtual void tellNoChangeDown ( unsigned long );
102 void reportUserInput ( void );
103 static IOReturn sysPowerDownHandler( void * target, void * refCon,
104 UInt32 messageType, IOService * service,
105 void * messageArgument, vm_size_t argSize );
106
107 static IOReturn displayWranglerNotification( void * target, void * refCon,
108 UInt32 messageType, IOService * service,
109 void * messageArgument, vm_size_t argSize );
110
111 static bool displayWranglerPublished( void * target, void * refCon,
112 IOService * newService);
113
114 void setQuickSpinDownTimeout ( void );
115 void adjustPowerState( void );
116 void restoreUserSpinDownTimeout ( void );
117
118 IOPMPowerStateQueue *pmPowerStateQueue;
119 unsigned int user_spindown; // User's selected disk spindown value
120
121 unsigned int systemBooting:1;
122 unsigned int ignoringClamshell:1;
123 unsigned int allowSleep:1;
124 unsigned int sleepIsSupported:1;
125 unsigned int canSleep:1;
126 unsigned int idleSleepPending:1;
127 unsigned int sleepASAP:1;
128 unsigned int desktopMode:1;
129
130 unsigned int acAdaptorConnect:1;
131 unsigned int ignoringClamshellDuringWakeup:1;
132 unsigned int reservedA:6;
133 unsigned char reservedB[3];
134
135 thread_call_t diskSyncCalloutEntry;
136 IOOptionBits platformSleepSupport;
137 };
138
139 class IORootParent: public IOService
140 {
141 OSDeclareDefaultStructors(IORootParent)
142
143 private:
144 unsigned long mostRecentChange;
145
146 public:
147
148 bool start ( IOService * nub );
149 void shutDownSystem ( void );
150 void restartSystem ( void );
151 void sleepSystem ( void );
152 void dozeSystem ( void );
153 void sleepToDoze ( void );
154 void wakeSystem ( void );
155 };
156
157
158 #endif /* _IOKIT_ROOTDOMAIN_H */