]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
d7e50217 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
d7e50217 A |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
d7e50217 A |
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. | |
1c79356b A |
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 RootDomainUserClient; | |
32 | ||
d52fe63f A |
33 | #define kRootDomainSupportedFeatures "Supported Features" |
34 | ||
1c79356b A |
35 | enum { |
36 | kRootDomainSleepNotSupported = 0x00000000, | |
37 | kRootDomainSleepSupported = 0x00000001, | |
0b4e3aa0 A |
38 | kFrameBufferDeepSleepSupported = 0x00000002, |
39 | kPCICantSleep = 0x00000004 | |
1c79356b A |
40 | }; |
41 | ||
42 | extern "C" | |
43 | { | |
44 | IONotifier * registerSleepWakeInterest(IOServiceInterestHandler, void *, void * = 0); | |
0b4e3aa0 | 45 | IONotifier * registerPrioritySleepWakeInterest(IOServiceInterestHandler handler, void * self, void * ref = 0); |
1c79356b | 46 | IOReturn acknowledgeSleepWakeNotification(void * ); |
0b4e3aa0 A |
47 | IOReturn vetoSleepWakeNotification(void * PMrefcon); |
48 | IOReturn rootDomainRestart ( void ); | |
49 | IOReturn rootDomainShutdown ( void ); | |
1c79356b A |
50 | } |
51 | ||
d52fe63f | 52 | #define IOPM_ROOTDOMAIN_REV 2 |
1c79356b A |
53 | |
54 | class IOPMrootDomain: public IOService | |
55 | { | |
56 | OSDeclareDefaultStructors(IOPMrootDomain) | |
57 | ||
58 | public: | |
59 | ||
0b4e3aa0 A |
60 | class IOService * wrangler; // we tickle the wrangler on button presses, etc |
61 | ||
62 | static IOPMrootDomain * construct( void ); | |
63 | virtual bool start( IOService * provider ); | |
1c79356b A |
64 | virtual IOReturn newUserClient ( task_t, void *, UInt32, IOUserClient ** ); |
65 | virtual IOReturn setAggressiveness ( unsigned long, unsigned long ); | |
66 | virtual IOReturn youAreRoot ( void ); | |
67 | virtual IOReturn sleepSystem ( void ); | |
9bccf70c | 68 | virtual IOReturn setProperties ( OSObject * ); |
0b4e3aa0 A |
69 | IOReturn shutdownSystem ( void ); |
70 | IOReturn restartSystem ( void ); | |
1c79356b A |
71 | virtual IOReturn receivePowerNotification (UInt32 msg); |
72 | virtual void setSleepSupported( IOOptionBits flags ); | |
73 | virtual IOOptionBits getSleepSupported(); | |
0b4e3aa0 A |
74 | virtual IOReturn requestPowerDomainState ( IOPMPowerFlags, IOPowerConnection *, unsigned long ); |
75 | virtual void handleSleepTimerExpiration ( void ); | |
d52fe63f | 76 | void stopIgnoringClamshellEventsDuringWakeup ( void ); |
0b4e3aa0 | 77 | void wakeFromDoze( void ); |
9bccf70c | 78 | void broadcast_it (unsigned long, unsigned long ); |
d52fe63f | 79 | void publishFeature( const char *feature ); |
1c79356b | 80 | |
9bccf70c A |
81 | // Override of these methods for logging purposes. |
82 | virtual IOReturn changePowerStateTo ( unsigned long ordinal ); | |
83 | virtual IOReturn changePowerStateToPriv ( unsigned long ordinal ); | |
84 | ||
1c79356b A |
85 | private: |
86 | ||
0b4e3aa0 A |
87 | class IORootParent * patriarch; // points to our parent |
88 | long sleepSlider; // pref: idle time before idle sleep | |
89 | long longestNonSleepSlider; // pref: longest of other idle times | |
90 | long extraSleepDelay; // sleepSlider - longestNonSleepSlider | |
91 | thread_call_t extraSleepTimer; // used to wait between say display idle and system idle | |
d52fe63f A |
92 | thread_call_t clamshellWakeupIgnore; // Used to ignore clamshell close events while we're waking from sleep |
93 | ||
1c79356b A |
94 | virtual void powerChangeDone ( unsigned long ); |
95 | virtual void command_received ( void *, void * , void * , void *); | |
96 | virtual bool tellChangeDown ( unsigned long stateNum); | |
97 | virtual bool askChangeDown ( unsigned long stateNum); | |
98 | virtual void tellChangeUp ( unsigned long ); | |
99 | virtual void tellNoChangeDown ( unsigned long ); | |
0b4e3aa0 A |
100 | void reportUserInput ( void ); |
101 | static IOReturn sysPowerDownHandler( void * target, void * refCon, | |
102 | UInt32 messageType, IOService * service, | |
103 | void * messageArgument, vm_size_t argSize ); | |
104 | ||
105 | static IOReturn displayWranglerNotification( void * target, void * refCon, | |
106 | UInt32 messageType, IOService * service, | |
107 | void * messageArgument, vm_size_t argSize ); | |
108 | ||
109 | static bool displayWranglerPublished( void * target, void * refCon, | |
110 | IOService * newService); | |
111 | ||
112 | void setQuickSpinDownTimeout ( void ); | |
113 | void adjustPowerState( void ); | |
114 | void restoreUserSpinDownTimeout ( void ); | |
1c79356b | 115 | |
d52fe63f | 116 | |
0b4e3aa0 A |
117 | unsigned int user_spindown; // User's selected disk spindown value |
118 | ||
119 | unsigned int systemBooting:1; | |
120 | unsigned int ignoringClamshell:1; | |
121 | unsigned int allowSleep:1; | |
122 | unsigned int sleepIsSupported:1; | |
123 | unsigned int canSleep:1; | |
124 | unsigned int idleSleepPending:1; | |
125 | unsigned int sleepASAP:1; | |
d52fe63f A |
126 | unsigned int desktopMode:1; |
127 | ||
128 | unsigned int acAdaptorConnect:1; | |
129 | unsigned int ignoringClamshellDuringWakeup:1; | |
130 | unsigned int reservedA:6; | |
131 | unsigned char reservedB[3]; | |
132 | ||
0b4e3aa0 | 133 | thread_call_t diskSyncCalloutEntry; |
1c79356b A |
134 | IOOptionBits platformSleepSupport; |
135 | }; | |
136 | ||
137 | class IORootParent: public IOService | |
138 | { | |
139 | OSDeclareDefaultStructors(IORootParent) | |
0b4e3aa0 A |
140 | |
141 | private: | |
142 | unsigned long mostRecentChange; | |
1c79356b A |
143 | |
144 | public: | |
145 | ||
146 | bool start ( IOService * nub ); | |
147 | void shutDownSystem ( void ); | |
0b4e3aa0 | 148 | void restartSystem ( void ); |
1c79356b | 149 | void sleepSystem ( void ); |
0b4e3aa0 A |
150 | void dozeSystem ( void ); |
151 | void sleepToDoze ( void ); | |
1c79356b A |
152 | void wakeSystem ( void ); |
153 | }; | |
154 | ||
155 | ||
156 | #endif /* _IOKIT_ROOTDOMAIN_H */ |