2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
22 #ifndef _IOKIT_ROOTDOMAIN_H
23 #define _IOKIT_ROOTDOMAIN_H
25 #include <IOKit/IOService.h>
26 #include <IOKit/pwr_mgt/IOPM.h>
28 class RootDomainUserClient
;
31 kRootDomainSleepNotSupported
= 0x00000000,
32 kRootDomainSleepSupported
= 0x00000001,
33 kFrameBufferDeepSleepSupported
= 0x00000002,
34 kPCICantSleep
= 0x00000004
39 IONotifier
* registerSleepWakeInterest(IOServiceInterestHandler
, void *, void * = 0);
40 IONotifier
* registerPrioritySleepWakeInterest(IOServiceInterestHandler handler
, void * self
, void * ref
= 0);
41 IOReturn
acknowledgeSleepWakeNotification(void * );
42 IOReturn
vetoSleepWakeNotification(void * PMrefcon
);
43 IOReturn
rootDomainRestart ( void );
44 IOReturn
rootDomainShutdown ( void );
48 class IOPMrootDomain
: public IOService
50 OSDeclareDefaultStructors(IOPMrootDomain
)
54 class IOService
* wrangler
; // we tickle the wrangler on button presses, etc
56 static IOPMrootDomain
* construct( void );
57 virtual bool start( IOService
* provider
);
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 );
62 IOReturn
shutdownSystem ( void );
63 IOReturn
restartSystem ( void );
64 virtual IOReturn
receivePowerNotification (UInt32 msg
);
65 virtual void setSleepSupported( IOOptionBits flags
);
66 virtual IOOptionBits
getSleepSupported();
67 virtual IOReturn
requestPowerDomainState ( IOPMPowerFlags
, IOPowerConnection
*, unsigned long );
68 virtual void handleSleepTimerExpiration ( void );
69 void wakeFromDoze( void );
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
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 );
85 void reportUserInput ( void );
86 static IOReturn
sysPowerDownHandler( void * target
, void * refCon
,
87 UInt32 messageType
, IOService
* service
,
88 void * messageArgument
, vm_size_t argSize
);
90 static IOReturn
displayWranglerNotification( void * target
, void * refCon
,
91 UInt32 messageType
, IOService
* service
,
92 void * messageArgument
, vm_size_t argSize
);
94 static bool displayWranglerPublished( void * target
, void * refCon
,
95 IOService
* newService
);
97 void setQuickSpinDownTimeout ( void );
98 void adjustPowerState( void );
99 void restoreUserSpinDownTimeout ( void );
101 unsigned int user_spindown
; // User's selected disk spindown value
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
;
113 IOOptionBits platformSleepSupport
;
116 class IORootParent
: public IOService
118 OSDeclareDefaultStructors(IORootParent
)
121 unsigned long mostRecentChange
;
125 bool start ( IOService
* nub
);
126 void shutDownSystem ( void );
127 void restartSystem ( void );
128 void sleepSystem ( void );
129 void dozeSystem ( void );
130 void sleepToDoze ( void );
131 void wakeSystem ( void );
135 #endif /* _IOKIT_ROOTDOMAIN_H */