2 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 #ifndef _IOKIT_IOPMPRIVATE_H
29 #define _IOKIT_IOPMPRIVATE_H
31 #include <IOKit/pwr_mgt/IOPM.h>
33 /*****************************************************************************/
35 // Private power commands issued to root domain
39 kIOPMSetValue
= (1<<16),
40 // don't sleep on clamshell closure on a portable with AC connected
41 kIOPMSetDesktopMode
= (1<<17),
42 // set state of AC adaptor connected
43 kIOPMSetACAdaptorConnected
= (1<<18)
46 /*****************************************************************************/
47 /*****************************************************************************/
50 * PM notification types
53 /* @constant kIOPMStateConsoleUserShutdown
54 * @abstract Notification of GUI shutdown state available to kexts.
55 * @discussion This type can be passed as arguments to registerPMSettingController()
56 * to receive callbacks.
58 #define kIOPMStateConsoleShutdown "ConsoleShutdown"
60 /* @enum ShutdownValues
61 * @abstract Potential values shared with key kIOPMStateConsoleUserShutdown
64 /* @constant kIOPMStateConsoleShutdownNone
65 * @abstract System shutdown (or restart) hasn't started; system is ON.
66 * @discussion Next state: 2
68 kIOPMStateConsoleShutdownNone
= 1,
69 /* @constant kIOPMStateConsoleShutdownPossible
70 * @abstract User has been presented with the option to shutdown or restart. Shutdown may be cancelled.
71 * @discussion Next state may be: 1, 4
73 kIOPMStateConsoleShutdownPossible
= 2,
74 /* @constant kIOPMStateConsoleShutdownUnderway
75 * @abstract Shutdown or restart is proceeding. It may still be cancelled.
76 * @discussion Next state may be: 1, 4. This state is currently unused.
78 kIOPMStateConsoleShutdownUnderway
= 3,
79 /* @constant kIOPMStateConsoleShutdownCertain
80 * @abstract Shutdown is in progress and irrevocable.
81 * @discussion State remains 4 until power is removed from CPU.
83 kIOPMStateConsoleShutdownCertain
= 4
86 /*****************************************************************************/
87 /*****************************************************************************/
89 /* PM Statistics - event indices
90 * These are arguments to IOPMrootDomain::pmStatsRecordEvent().
93 kIOPMStatsHibernateImageWrite
= 1,
94 kIOPMStatsHibernateImageRead
,
95 kIOPMStatsDriversNotify
,
96 kIOPMStatsApplicationNotify
,
97 kIOPMStatsLateDriverAcknowledge
,
98 kIOPMStatsLateAppAcknowledge
,
100 // To designate if you're specifying the start or stop end of
101 // each of the above events, do a bitwise OR of the appropriate
102 // Start/Stop flag and pass the result to IOPMrootDomain to record
104 kIOPMStatsEventStartFlag
= (1 << 24),
105 kIOPMStatsEventStopFlag
= (1 << 25)
108 // Keys for IOPMrootDomain registry properties
109 #define kIOPMSleepStatisticsKey "SleepStatistics"
110 #define kIOPMSleepStatisticsAppsKey "AppStatistics"
112 // Application response statistics
113 #define kIOPMStatsNameKey "Name"
114 #define kIOPMStatsPIDKey "Pid"
115 #define kIOPMStatsTimeMSKey "TimeMS"
116 #define kIOPMStatsApplicationResponseTypeKey "ResponseType"
117 #define kIOPMStatsMessageTypeKey "MessageType"
119 // PM Statistics: potential values for the key kIOPMStatsApplicationResponseTypeKey
120 // entry in the application results array.
121 #define kIOPMStatsResponseTimedOut "ResponseTimedOut"
122 #define kIOPMStatsResponseCancel "ResponseCancel"
123 #define kIOPMStatsResponseSlow "ResponseSlow"
131 struct bounds hibWrite
;
132 struct bounds hibRead
;
133 // bounds driverNotifySleep;
134 // bounds driverNotifyWake;
135 // bounds appNotifySleep;
136 // bounds appNotifyWake;
137 // OSDictionary *tardyApps;
138 // OSDictionary *tardyDrivers;
141 /*****************************************************************************/
143 /* PM RootDomain tracePoints
145 * In the sleep/wake process, we expect the sleep trace points to proceed
146 * in increasing order. Once sleep begins with code kIOPMTracePointSleepStarted = 0x11,
147 * we expect sleep to continue in a monotonically increasing order of tracepoints
148 * to kIOPMTracePointSystemLoginwindowPhase = 0x30. After trace point SystemLoginWindowPhase,
149 * the system will return to kIOPMTracePointSystemUp = 0x00.
151 * If the trace point decreases (instead of increasing) before reaching kIOPMTracePointSystemUp,
152 * that indicates that the sleep process was cancelled. The cancel reason shall be indicated
153 * in the cancel tracepoint. (TBD)
157 /* When kTracePointSystemUp is the latest tracePoint,
158 the system is awake. It is not asleep, sleeping, or waking.
160 * Phase begins: At boot, at completion of wake from sleep,
161 immediately following kIOPMTracePointSystemLoginwindowPhase.
162 * Phase ends: When a sleep attempt is initiated.
164 kIOPMTracePointSystemUp
= 0,
166 /* When kIOPMTracePointSleepStarted we have just initiated sleep.
168 Note: The state prior to kIOPMTracePointSleepStarted may be only one of:
169 * kIOPMTracePointSystemUp
170 * kIOPMTracePointSystemLoginwindowPhase or
172 * Phase begins: At initiation of system sleep (idle or forced).
173 * Phase ends: As we start to notify applications of system sleep.
175 kIOPMTracePointSleepStarted
= 0x11,
177 /* When kTracePointSystemSleepAppsPhase is the latest tracePoint,
178 a system sleep has been irrevocably inititated and PM waits
179 for responses from notified applications.
181 * Phase begins: Begin to asynchronously fire kIOMessageSystemWillSleep notifications,
182 * and in the case of an idle sleep kIOMessageCanSystemSleep as well.
183 * Phase ends: When we have received all user & interested kernel acknowledgements.
185 kIOPMTracePointSystemSleepAppsPhase
= 0x12,
188 /* When kIOPMTracePointSystemHibernatePhase is the latest tracePoint,
189 PM is writing the hiernate image to disk.
191 kIOPMTracePointSystemHibernatePhase
= 0x13,
193 /* When kTracePointSystemSleepDriversPhase is the latest tracePoint,
194 PM is iterating the driver tree powering off devices individually.
196 * Phase begins: When IOPMrootDomain has received all of its power acknowledgements and begins
197 * executing IOService::powerDomainWillChangeTo()
198 * Phase ends: When IOPMrootDomain::powerChangeDone begins executing CPU shutoff code.
200 kIOPMTracePointSystemSleepDriversPhase
= 0x14,
202 /* When kTracePointSystemSleepPlatformPhase is the latest tracePoint,
203 all apps and drivers have notified of sleep. Plotfarm is powering
204 off CPU; or system is asleep; or low level wakeup is underway.
206 Note: If a system is asleep and then loses power, and it does not have a hibernate
207 image to restore from (e.g. hibernatemode = 0), then OS X may interpret this power
208 loss as a system crash in the kTracePointSystemSleepPlatformPhase, since the
209 power loss resembles a hang or crash, and the power being removed by the user.
211 * Phase begins: IOPMrootDomain has already shut off drivers, and is now powering off CPU.
212 * Phase ends: Immediately after CPU's are powered back on during wakeup.
214 kIOPMTracePointSystemSleepPlatformPhase
= 0x15,
216 /* When kTracePointSystemWakeDriversPhase is the latest tracePoint,
217 System CPU is powered, PM is notifying drivers of system wake.
219 * Phase begins: CPU's have successfully powered up and OS is executing.
220 * Phase ends: All drivers have handled power events & acknowledged completion.
221 IOPMrootDomain is about to deliver kIOMessageSystemHasPoweredOn.
223 kIOPMTracePointSystemWakeDriversPhase
= 0x21,
225 /* When kTracePointSystemWakeAppsPhase is the latest tracePoint,
226 System CPU is powered, PM has powered on each driver.
228 * Phase begins: IOPMrootDomain::tellChangeUp before sending asynchronous
229 kIOMessageSystemHasPoweredOn notifications
230 * Phase ends: IOPMrootDomain::tellChangeUp after sending asynchronous notifications
232 kIOPMTracePointSystemWakeAppsPhase
= 0x22,
234 /* kIOPMTracePointSystemLoginwindowPhase
235 This phase represents a several minute window after the system has powered on.
236 Higher levels of system diagnostics are in a heightened state of alert in this phase,
237 in case any user errors occurred that we could not detect in software.
239 This several minute window
241 * Phase begins: After IOPMrootDomain sends kIOMessageSystemHasPoweredOn message.
242 * Phase ends: When loginwindow calls IOPMSleepWakeSetUUID(NULL) the system shall
243 be considered awake and usable. The next phase shall be kIOPMTracePointSystemUp.
245 kIOPMTracePointSystemLoginwindowPhase
= 0x30
248 /*****************************************************************************/
251 Ê* kIOPMLoginWindowSecurityDebugKey - identifies PM debug data specific to LoginWindow
252 * for use with IOPMrootDomain.
254 #define kIOPMLoginWindowSecurityDebugKey "LoginWindowSecurity"
256 // For PM internal use only - key to locate sleep failure results within SCDynamicStore.
257 #define kIOPMDynamicStoreSleepFailureKey "SleepFailure"
259 /*****************************************************************************/
261 // For IOPMLibPrivate.h
262 #define kIOPMSleepWakeFailureKey "PMFailurePhase"
263 #define kIOPMSleepWakeFailureCodeKey "PMStatusCode"
264 #define kIOPMSleepWakeFailureLoginKey "LWFailurePhase"
265 #define kIOPMSleepWakeFailureUUIDKey "UUID"
266 #define kIOPMSleepWakeFailureDateKey "Date"
268 #endif /* ! _IOKIT_IOPMPRIVATE_H */