]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/pwr_mgt/RootDomain.h
xnu-201.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / RootDomain.h
CommitLineData
1c79356b
A
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
28class RootDomainUserClient;
29
30enum {
31 kRootDomainSleepNotSupported = 0x00000000,
32 kRootDomainSleepSupported = 0x00000001,
0b4e3aa0
A
33 kFrameBufferDeepSleepSupported = 0x00000002,
34 kPCICantSleep = 0x00000004
1c79356b
A
35};
36
37extern "C"
38{
39 IONotifier * registerSleepWakeInterest(IOServiceInterestHandler, void *, void * = 0);
0b4e3aa0 40 IONotifier * registerPrioritySleepWakeInterest(IOServiceInterestHandler handler, void * self, void * ref = 0);
1c79356b 41 IOReturn acknowledgeSleepWakeNotification(void * );
0b4e3aa0
A
42 IOReturn vetoSleepWakeNotification(void * PMrefcon);
43 IOReturn rootDomainRestart ( void );
44 IOReturn rootDomainShutdown ( void );
1c79356b
A
45}
46
47
48class IOPMrootDomain: public IOService
49{
50OSDeclareDefaultStructors(IOPMrootDomain)
51
52public:
53
0b4e3aa0
A
54 class IOService * wrangler; // we tickle the wrangler on button presses, etc
55
56 static IOPMrootDomain * construct( void );
57 virtual bool start( IOService * provider );
1c79356b
A
58 virtual IOReturn newUserClient ( task_t, void *, UInt32, IOUserClient ** );
59 virtual IOReturn setAggressiveness ( unsigned long, unsigned long );
60 virtual IOReturn youAreRoot ( void );
61 virtual IOReturn sleepSystem ( void );
0b4e3aa0
A
62 IOReturn shutdownSystem ( void );
63 IOReturn restartSystem ( void );
1c79356b
A
64 virtual IOReturn receivePowerNotification (UInt32 msg);
65 virtual void setSleepSupported( IOOptionBits flags );
66 virtual IOOptionBits getSleepSupported();
0b4e3aa0
A
67 virtual IOReturn requestPowerDomainState ( IOPMPowerFlags, IOPowerConnection *, unsigned long );
68 virtual void handleSleepTimerExpiration ( void );
69 void wakeFromDoze( void );
1c79356b
A
70
71private:
72
0b4e3aa0
A
73 class IORootParent * patriarch; // points to our parent
74 long sleepSlider; // pref: idle time before idle sleep
75 long longestNonSleepSlider; // pref: longest of other idle times
76 long extraSleepDelay; // sleepSlider - longestNonSleepSlider
77 thread_call_t extraSleepTimer; // used to wait between say display idle and system idle
1c79356b
A
78
79 virtual void powerChangeDone ( unsigned long );
80 virtual void command_received ( void *, void * , void * , void *);
81 virtual bool tellChangeDown ( unsigned long stateNum);
82 virtual bool askChangeDown ( unsigned long stateNum);
83 virtual void tellChangeUp ( unsigned long );
84 virtual void tellNoChangeDown ( unsigned long );
0b4e3aa0
A
85 void reportUserInput ( void );
86 static IOReturn sysPowerDownHandler( void * target, void * refCon,
87 UInt32 messageType, IOService * service,
88 void * messageArgument, vm_size_t argSize );
89
90 static IOReturn displayWranglerNotification( void * target, void * refCon,
91 UInt32 messageType, IOService * service,
92 void * messageArgument, vm_size_t argSize );
93
94 static bool displayWranglerPublished( void * target, void * refCon,
95 IOService * newService);
96
97 void setQuickSpinDownTimeout ( void );
98 void adjustPowerState( void );
99 void restoreUserSpinDownTimeout ( void );
1c79356b 100
0b4e3aa0
A
101 unsigned int user_spindown; // User's selected disk spindown value
102
103 unsigned int systemBooting:1;
104 unsigned int ignoringClamshell:1;
105 unsigned int allowSleep:1;
106 unsigned int sleepIsSupported:1;
107 unsigned int canSleep:1;
108 unsigned int idleSleepPending:1;
109 unsigned int sleepASAP:1;
110 unsigned int reservedA:1;
111 unsigned int reservedB[2];
112 thread_call_t diskSyncCalloutEntry;
1c79356b
A
113 IOOptionBits platformSleepSupport;
114};
115
116class IORootParent: public IOService
117{
118OSDeclareDefaultStructors(IORootParent)
0b4e3aa0
A
119
120private:
121 unsigned long mostRecentChange;
1c79356b
A
122
123public:
124
125 bool start ( IOService * nub );
126 void shutDownSystem ( void );
0b4e3aa0 127 void restartSystem ( void );
1c79356b 128 void sleepSystem ( void );
0b4e3aa0
A
129 void dozeSystem ( void );
130 void sleepToDoze ( void );
1c79356b
A
131 void wakeSystem ( void );
132};
133
134
135#endif /* _IOKIT_ROOTDOMAIN_H */