]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/pwr_mgt/RootDomain.h
4e89c16fcd6b8e27ca83c80a1fef4ee89173a9fd
[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 * 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 IOReturn shutdownSystem ( void );
66 IOReturn restartSystem ( void );
67 virtual IOReturn receivePowerNotification (UInt32 msg);
68 virtual void setSleepSupported( IOOptionBits flags );
69 virtual IOOptionBits getSleepSupported();
70 virtual IOReturn requestPowerDomainState ( IOPMPowerFlags, IOPowerConnection *, unsigned long );
71 virtual void handleSleepTimerExpiration ( void );
72 void stopIgnoringClamshellEventsDuringWakeup ( void );
73 void wakeFromDoze( void );
74 void publishFeature( const char *feature );
75
76 private:
77
78 class IORootParent * patriarch; // points to our parent
79 long sleepSlider; // pref: idle time before idle sleep
80 long longestNonSleepSlider; // pref: longest of other idle times
81 long extraSleepDelay; // sleepSlider - longestNonSleepSlider
82 thread_call_t extraSleepTimer; // used to wait between say display idle and system idle
83 thread_call_t clamshellWakeupIgnore; // Used to ignore clamshell close events while we're waking from sleep
84
85 virtual void powerChangeDone ( unsigned long );
86 virtual void command_received ( void *, void * , void * , void *);
87 virtual bool tellChangeDown ( unsigned long stateNum);
88 virtual bool askChangeDown ( unsigned long stateNum);
89 virtual void tellChangeUp ( unsigned long );
90 virtual void tellNoChangeDown ( unsigned long );
91 void reportUserInput ( void );
92 static IOReturn sysPowerDownHandler( void * target, void * refCon,
93 UInt32 messageType, IOService * service,
94 void * messageArgument, vm_size_t argSize );
95
96 static IOReturn displayWranglerNotification( void * target, void * refCon,
97 UInt32 messageType, IOService * service,
98 void * messageArgument, vm_size_t argSize );
99
100 static bool displayWranglerPublished( void * target, void * refCon,
101 IOService * newService);
102
103 void setQuickSpinDownTimeout ( void );
104 void adjustPowerState( void );
105 void restoreUserSpinDownTimeout ( void );
106
107
108 unsigned int user_spindown; // User's selected disk spindown value
109
110 unsigned int systemBooting:1;
111 unsigned int ignoringClamshell:1;
112 unsigned int allowSleep:1;
113 unsigned int sleepIsSupported:1;
114 unsigned int canSleep:1;
115 unsigned int idleSleepPending:1;
116 unsigned int sleepASAP:1;
117 unsigned int desktopMode:1;
118
119 unsigned int acAdaptorConnect:1;
120 unsigned int ignoringClamshellDuringWakeup:1;
121 unsigned int reservedA:6;
122 unsigned char reservedB[3];
123
124 thread_call_t diskSyncCalloutEntry;
125 IOOptionBits platformSleepSupport;
126 };
127
128 class IORootParent: public IOService
129 {
130 OSDeclareDefaultStructors(IORootParent)
131
132 private:
133 unsigned long mostRecentChange;
134
135 public:
136
137 bool start ( IOService * nub );
138 void shutDownSystem ( void );
139 void restartSystem ( void );
140 void sleepSystem ( void );
141 void dozeSystem ( void );
142 void sleepToDoze ( void );
143 void wakeSystem ( void );
144 };
145
146
147 #endif /* _IOKIT_ROOTDOMAIN_H */