]>
Commit | Line | Data |
---|---|---|
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 RootDomainUserClient; | |
32 | ||
33 | #define kRootDomainSupportedFeatures "Supported Features" | |
34 | ||
35 | enum { | |
36 | kRootDomainSleepNotSupported = 0x00000000, | |
37 | kRootDomainSleepSupported = 0x00000001, | |
38 | kFrameBufferDeepSleepSupported = 0x00000002, | |
39 | kPCICantSleep = 0x00000004 | |
40 | }; | |
41 | ||
42 | extern "C" | |
43 | { | |
44 | IONotifier * registerSleepWakeInterest(IOServiceInterestHandler, void *, void * = 0); | |
45 | IONotifier * registerPrioritySleepWakeInterest(IOServiceInterestHandler handler, void * self, void * ref = 0); | |
46 | IOReturn acknowledgeSleepWakeNotification(void * ); | |
47 | IOReturn vetoSleepWakeNotification(void * PMrefcon); | |
48 | IOReturn rootDomainRestart ( void ); | |
49 | IOReturn rootDomainShutdown ( void ); | |
50 | } | |
51 | ||
52 | #define IOPM_ROOTDOMAIN_REV 2 | |
53 | ||
54 | class IOPMrootDomain: public IOService | |
55 | { | |
56 | OSDeclareDefaultStructors(IOPMrootDomain) | |
57 | ||
58 | public: | |
59 | ||
60 | class IOService * wrangler; // we tickle the wrangler on button presses, etc | |
61 | ||
62 | static IOPMrootDomain * construct( void ); | |
63 | virtual bool start( IOService * provider ); | |
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 ); | |
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 | ||
81 | // Override of these methods for logging purposes. | |
82 | virtual IOReturn changePowerStateTo ( unsigned long ordinal ); | |
83 | virtual IOReturn changePowerStateToPriv ( unsigned long ordinal ); | |
84 | ||
85 | private: | |
86 | ||
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 | |
92 | thread_call_t clamshellWakeupIgnore; // Used to ignore clamshell close events while we're waking from sleep | |
93 | ||
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 ); | |
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 ); | |
115 | ||
116 | ||
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; | |
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 | ||
133 | thread_call_t diskSyncCalloutEntry; | |
134 | IOOptionBits platformSleepSupport; | |
135 | }; | |
136 | ||
137 | class IORootParent: public IOService | |
138 | { | |
139 | OSDeclareDefaultStructors(IORootParent) | |
140 | ||
141 | private: | |
142 | unsigned long mostRecentChange; | |
143 | ||
144 | public: | |
145 | ||
146 | bool start ( IOService * nub ); | |
147 | void shutDownSystem ( void ); | |
148 | void restartSystem ( void ); | |
149 | void sleepSystem ( void ); | |
150 | void dozeSystem ( void ); | |
151 | void sleepToDoze ( void ); | |
152 | void wakeSystem ( void ); | |
153 | }; | |
154 | ||
155 | ||
156 | #endif /* _IOKIT_ROOTDOMAIN_H */ |