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