]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/pwr_mgt/IOPMPrivate.h
xnu-3789.1.32.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / IOPMPrivate.h
CommitLineData
d52fe63f
A
1/*
2 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
d52fe63f 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
d52fe63f
A
27 */
28#ifndef _IOKIT_IOPMPRIVATE_H
29#define _IOKIT_IOPMPRIVATE_H
30
31#include <IOKit/pwr_mgt/IOPM.h>
32
6d2010ae
A
33/* @constant kIOPMEventTypeIntermediateFlag
34 * @abstract This bit indicates the event is an intermediate event
35 * which must occur within a major system power event.
36 */
37#define kIOPMEventTypeIntermediateFlag 0x10000000
38
39/* @enum SystemEventTypes
40 * @abstract Potential system events logged in the system event record.
41 */
42enum {
39236c6e 43 kIOPMEventTypeUndefined = 0,
6d2010ae 44
fe8ab488 45 /* Event types mark driver events
6d2010ae
A
46 */
47 kIOPMEventTypeSetPowerStateImmediate = 1001,
48 kIOPMEventTypeSetPowerStateDelayed = 1002,
49 kIOPMEventTypePSWillChangeTo = 1003,
50 kIOPMEventTypePSDidChangeTo = 1004,
51 kIOPMEventTypeAppResponse = 1005,
52
53
54 /* Start and stop event types bracket major
55 * system power management events.
56 */
39236c6e
A
57 kIOPMEventTypeSleep = 2001,
58 kIOPMEventTypeSleepDone = 2002,
59 kIOPMEventTypeWake = 3001,
60 kIOPMEventTypeWakeDone = 3002,
61 kIOPMEventTypeDoze = 4001,
62 kIOPMEventTypeDozeDone = 4002,
39236c6e
A
63 kIOPMEventTypeUUIDSet = 6001,
64 kIOPMEventTypeUUIDClear = 6002,
6d2010ae
A
65
66 /* Intermediate events that may only occur within the bounds
67 * of a major system event (between the event's initiation and its "done event".)
68 * e.g. chronologically kIOPMEventTypeSleep may be followed by one or more
69 * intermediate events, which then must be followed by kIOPMEventTypeSleepDone.
70 *
71 * The intermediate events below will always occur in a Sleep or Wake event, and may
72 * or may not occur for any of the other events.
73 */
74 kIOPMEventTypeAppNotificationsFinished = 501 | kIOPMEventTypeIntermediateFlag,
75 kIOPMEventTypeDriverNotificationsFinished = 502 | kIOPMEventTypeIntermediateFlag,
76 kIOPMEventTypeCalTimeChange = 503 | kIOPMEventTypeIntermediateFlag
77};
78
39236c6e
A
79/*****************************************************************************
80 *
81 * Private Root Domain general interest messages
82 *
83 * Check IOPM.h when adding new messages to avoid conflict.
84 *
85 *****************************************************************************/
86
fe8ab488 87/* kIOPMMessageUserIsActiveChanged
39236c6e
A
88 * User became active or inactive. Message sent after the kIOPMUserIsActiveKey
89 * property was updated with a new value.
fe8ab488 90 */
39236c6e
A
91#define kIOPMMessageUserIsActiveChanged \
92 iokit_family_msg(sub_iokit_powermanagement, 0x400)
6d2010ae 93
39236c6e
A
94/*
95 * Private IOMessage notifications shared between kernel and userspace PM policy
96 */
97#define kIOPMMessageLastCallBeforeSleep \
98 iokit_family_msg(sub_iokit_powermanagement, 0x410)
99
3e170ce0
A
100#define kIOPMMessageIdleSleepPreventers \
101 iokit_family_msg(sub_iokit_powermanagement, 0x420)
102
103#define kIOPMMessageSystemSleepPreventers \
104 iokit_family_msg(sub_iokit_powermanagement, 0x430)
105
39236c6e 106/* @enum SystemSleepReasons
6d2010ae
A
107 * @abstract The potential causes for system sleep as logged in the system event record.
108 */
109enum {
110 kIOPMSleepReasonClamshell = 101,
111 kIOPMSleepReasonPowerButton = 102,
112 kIOPMSleepReasonSoftware = 103,
113 kIOPMSleepReasonOSSwitchHibernate = 104,
114 kIOPMSleepReasonIdle = 105,
115 kIOPMSleepReasonLowPower = 106,
116 kIOPMSleepReasonThermalEmergency = 107,
7ddcb079 117 kIOPMSleepReasonMaintenance = 108,
316670eb
A
118 kIOPMSleepReasonSleepServiceExit = 109,
119 kIOPMSleepReasonDarkWakeThermalEmergency = 110
6d2010ae
A
120};
121
122/*
123 * Possible C-string sleep reasons found under kRootDomainSleepReasonsKey
124 */
125#define kIOPMClamshellSleepKey "Clamshell Sleep"
126#define kIOPMPowerButtonSleepKey "Power Button Sleep"
127#define kIOPMSoftwareSleepKey "Software Sleep"
128#define kIOPMOSSwitchHibernationKey "OS Switch Sleep"
129#define kIOPMIdleSleepKey "Idle Sleep"
130#define kIOPMLowPowerSleepKey "Low Power Sleep"
131#define kIOPMThermalEmergencySleepKey "Thermal Emergency Sleep"
7ddcb079 132#define kIOPMSleepServiceExitKey "Sleep Service Back to Sleep"
316670eb 133#define kIOPMDarkWakeThermalEmergencyKey "Dark Wake Thermal Emergency"
6d2010ae 134
fe8ab488
A
135/*! kIOPMPSRestrictedModeKey
136 * An IOPMPowerSource property key
137 * Its property has an integer value.
138 * - value = 1 when the device is in a low power state and not fully functional.
139 * - value = 0, or property missing altogether, when the device is
140 * not in a restricted mode power state.
141*/
142#define kIOPMPSRestrictedModeKey "RestrictedMode"
6d2010ae
A
143
144#pragma mark Stray Bitfields
d52fe63f
A
145// Private power commands issued to root domain
146// bits 0-7 in IOPM.h
147
148enum {
b0d623f7 149 kIOPMSetValue = (1<<16),
d52fe63f 150 // don't sleep on clamshell closure on a portable with AC connected
b0d623f7 151 kIOPMSetDesktopMode = (1<<17),
d52fe63f 152 // set state of AC adaptor connected
b0d623f7 153 kIOPMSetACAdaptorConnected = (1<<18)
d52fe63f
A
154};
155
b0d623f7
A
156/*****************************************************************************/
157/*****************************************************************************/
158
593a1d5f
A
159/*
160 * PM notification types
161 */
162
7ddcb079
A
163/*! @constant kIOPMSleepServiceScheduleImmediate
164 *
165 * Setting type used in calls to IOPMrootDomain::registerPMSettingController
166 * Use this type between powerd and IOKit.framework
167 *
168 */
169#define kIOPMSleepServiceScheduleImmediate "SleepServiceImmediate"
170
171/*! @constant kIOPMSettingSleepServiceScheduleImmediate
172 *
173 * Setting type used in calls to IOPMrootDomain::registerPMSettingController
174 * Use this type between xnu and AppleRTC
175 */
176#define kIOPMSettingSleepServiceWakeCalendarKey "SleepServiceWakeCalendarKey"
177
fe8ab488 178/*! @constant kIOPMCalendarWakeTypes
7ddcb079
A
179 *
180 * These are valid values for IOPM.h:IOPMCalendarStruct->selector
181 */
182enum {
183 kPMCalendarTypeMaintenance = 1,
184 kPMCalendarTypeSleepService = 2
185};
186
187
188/* @constant kIOPMStateConsoleShutdown
593a1d5f
A
189 * @abstract Notification of GUI shutdown state available to kexts.
190 * @discussion This type can be passed as arguments to registerPMSettingController()
191 * to receive callbacks.
192 */
193#define kIOPMStateConsoleShutdown "ConsoleShutdown"
194
195/* @enum ShutdownValues
7ddcb079 196 * @abstract Potential values shared with key kIOPMStateConsoleShutdown
593a1d5f
A
197 */
198enum {
199/* @constant kIOPMStateConsoleShutdownNone
200 * @abstract System shutdown (or restart) hasn't started; system is ON.
201 * @discussion Next state: 2
202 */
203 kIOPMStateConsoleShutdownNone = 1,
204/* @constant kIOPMStateConsoleShutdownPossible
205 * @abstract User has been presented with the option to shutdown or restart. Shutdown may be cancelled.
206 * @discussion Next state may be: 1, 4
207 */
208 kIOPMStateConsoleShutdownPossible = 2,
209/* @constant kIOPMStateConsoleShutdownUnderway
210 * @abstract Shutdown or restart is proceeding. It may still be cancelled.
211 * @discussion Next state may be: 1, 4. This state is currently unused.
212 */
213 kIOPMStateConsoleShutdownUnderway = 3,
214/* @constant kIOPMStateConsoleShutdownCertain
215 * @abstract Shutdown is in progress and irrevocable.
216 * @discussion State remains 4 until power is removed from CPU.
217 */
fe8ab488
A
218 kIOPMStateConsoleShutdownCertain = 4,
219/* @constant kIOPMStateConsoleSULogoutInitiated
220 Indicates that LoginWindow has initiated a software update restart.
221 The next logout will not immediately lead to a shutdown.
222 */
223 kIOPMStateConsoleSULogoutInitiated = 5
593a1d5f
A
224};
225
7ddcb079
A
226/* @constant kIOPMSettingSilentRunningKey
227 * @abstract Notification of silent running mode changes to kexts.
228 * @discussion This key can be passed as an argument to registerPMSettingController()
229 * and also identifies the type of PMSetting notification callback.
230 */
231#define kIOPMSettingSilentRunningKey "SilentRunning"
232#define kIOPMFeatureSilentRunningKey kIOPMSettingSilentRunningKey
233
234/* @enum SilentRunningFlags
235 * @abstract The kIOPMSettingSilentRunningKey notification provides an OSNumber
236 * object with a value described by the following flags.
237 */
238enum {
239 kIOPMSilentRunningModeOn = 0x00000001
240};
241
b0d623f7
A
242/*****************************************************************************/
243/*****************************************************************************/
244
fe8ab488 245/* PM Statistics - event indices
b0d623f7
A
246 * These are arguments to IOPMrootDomain::pmStatsRecordEvent().
247 */
248enum {
249 kIOPMStatsHibernateImageWrite = 1,
250 kIOPMStatsHibernateImageRead,
251 kIOPMStatsDriversNotify,
252 kIOPMStatsApplicationNotify,
253 kIOPMStatsLateDriverAcknowledge,
254 kIOPMStatsLateAppAcknowledge,
fe8ab488
A
255
256 // To designate if you're specifying the start or stop end of
b0d623f7
A
257 // each of the above events, do a bitwise OR of the appropriate
258 // Start/Stop flag and pass the result to IOPMrootDomain to record
259 // the event.
260 kIOPMStatsEventStartFlag = (1 << 24),
261 kIOPMStatsEventStopFlag = (1 << 25)
262};
263
264// Keys for IOPMrootDomain registry properties
265#define kIOPMSleepStatisticsKey "SleepStatistics"
266#define kIOPMSleepStatisticsAppsKey "AppStatistics"
3e170ce0
A
267#define kIOPMIdleSleepPreventersKey "IdleSleepPreventers"
268#define kIOPMSystemSleepPreventersKey "SystemSleepPreventers"
b0d623f7
A
269
270// Application response statistics
271#define kIOPMStatsNameKey "Name"
272#define kIOPMStatsPIDKey "Pid"
273#define kIOPMStatsTimeMSKey "TimeMS"
274#define kIOPMStatsApplicationResponseTypeKey "ResponseType"
275#define kIOPMStatsMessageTypeKey "MessageType"
39236c6e 276#define kIOPMStatsPowerCapabilityKey "PowerCaps"
fe8ab488
A
277#define kIOPMStatsSystemTransitionKey "TransitionType"
278
b0d623f7
A
279// PM Statistics: potential values for the key kIOPMStatsApplicationResponseTypeKey
280// entry in the application results array.
281#define kIOPMStatsResponseTimedOut "ResponseTimedOut"
282#define kIOPMStatsResponseCancel "ResponseCancel"
283#define kIOPMStatsResponseSlow "ResponseSlow"
fe8ab488
A
284#define kIOPMStatsResponsePrompt "ResponsePrompt"
285#define kIOPMStatsDriverPSChangeSlow "DriverPSChangeSlow"
b0d623f7 286
7ddcb079
A
287struct PMStatsBounds{
288 uint64_t start;
289 uint64_t stop;
290};
b0d623f7 291typedef struct {
fe8ab488 292
7ddcb079
A
293 struct PMStatsBounds hibWrite;
294 struct PMStatsBounds hibRead;
b0d623f7
A
295// bounds driverNotifySleep;
296// bounds driverNotifyWake;
297// bounds appNotifySleep;
fe8ab488
A
298// bounds appNotifyWake;
299// OSDictionary *tardyApps;
b0d623f7
A
300// OSDictionary *tardyDrivers;
301} PMStatsStruct;
302
303/*****************************************************************************/
304
305/* PM RootDomain tracePoints
306 *
307 * In the sleep/wake process, we expect the sleep trace points to proceed
6d2010ae 308 * in increasing order. Once sleep begins with code kIOPMTracePointSleepStarted,
b0d623f7 309 * we expect sleep to continue in a monotonically increasing order of tracepoints
6d2010ae
A
310 * to kIOPMTracePointSystemLoginwindowPhase. After trace point SystemLoginWindowPhase,
311 * the system will return to kIOPMTracePointSystemUp.
b0d623f7
A
312 *
313 * If the trace point decreases (instead of increasing) before reaching kIOPMTracePointSystemUp,
314 * that indicates that the sleep process was cancelled. The cancel reason shall be indicated
315 * in the cancel tracepoint. (TBD)
316 */
317
318enum {
319/* When kTracePointSystemUp is the latest tracePoint,
6d2010ae
A
320 * the system is awake. It is not asleep, sleeping, or waking.
321 *
322 * Phase begins: At boot, at completion of wake from sleep,
323 * immediately following kIOPMTracePointSystemLoginwindowPhase.
324 * Phase ends: When a sleep attempt is initiated.
b0d623f7
A
325 */
326 kIOPMTracePointSystemUp = 0,
327
6d2010ae
A
328/* When kIOPMTracePointSleepStarted is the latest tracePoint,
329 * sleep has been initiated.
330 *
331 * Phase begins: At initiation of system sleep (idle or forced).
332 * Phase ends: PM starts to notify applications of system sleep.
333 */
334 kIOPMTracePointSleepStarted = 0x10,
b0d623f7 335
6d2010ae
A
336/* When kIOPMTracePointSleepApplications is the latest tracePoint,
337 * a system sleep has been initiated and PM waits for responses
338 * from notified applications.
339 *
340 * Phase begins: Begin to asynchronously fire kIOMessageSystemWillSleep
341 * notifications, and also kIOMessageCanSystemSleep for the idle sleep case.
342 * Phase ends: When PM has received all application responses.
343 */
344 kIOPMTracePointSleepApplications = 0x11,
b0d623f7 345
6d2010ae
A
346/* When kIOPMTracePointSleepPriorityClients is the latest tracePoint,
347 * PM is notifying priority clients and in-kernel system capability
348 * clients, and waiting for any asynchronous completions.
349 *
350 * Phase begins: Synchronous delivery of kIOMessageSystemWillSleep notifications.
351 * Phase ends: All notified clients have acknowledged.
352 */
353 kIOPMTracePointSleepPriorityClients = 0x12,
fe8ab488 354
6d2010ae
A
355/* When kIOPMTracePointSleepWillChangeInterests is the latest tracePoint,
356 * PM is calling powerStateWillChangeTo() on interested drivers of root domain.
357 *
358 * Phase begins: Dispatch a callout thread to call interested drivers.
359 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
360 * by drivers that indicated asynchronous completion.
b0d623f7 361 */
6d2010ae 362 kIOPMTracePointSleepWillChangeInterests = 0x13,
b0d623f7 363
6d2010ae
A
364/* When kIOPMTracePointSleepPowerPlaneDrivers is the latest tracePoint,
365 * PM is directing power plane drivers to power off in leaf-to-root order.
366 *
367 * Phase begins: Root domain informs its power children that it will drop to
368 * sleep state. This has a cascade effect and triggers all drivers in
369 * the power plane to transition to a lower power state if necessary.
370 * Phase ends: All power transitions in response to the root domain power
371 * change have completed.
372 */
373 kIOPMTracePointSleepPowerPlaneDrivers = 0x14,
fe8ab488 374
6d2010ae
A
375/* When kIOPMTracePointSleepDidChangeInterests is the latest tracePoint,
376 * PM is calling powerStateDidChangeTo() on interested drivers of root domain.
377 *
378 * Phase begins: Dispatch a callout thread to call interested drivers.
379 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
380 * by drivers that indicated asynchronous completion.
381 */
382 kIOPMTracePointSleepDidChangeInterests = 0x15,
b0d623f7 383
6d2010ae
A
384/* When kIOPMTracePointSleepCapabilityClients is the latest tracePoint,
385 * PM is notifying system capability clients about system sleep.
386 *
387 * Phase begins: Send kIOMessageSystemCapabilityChange notifications to inform
388 * capability clients that system has lost all capabilities.
389 * Phase ends: Finished sending notifications.
b0d623f7 390 */
6d2010ae 391 kIOPMTracePointSleepCapabilityClients = 0x16,
b0d623f7 392
6d2010ae
A
393/* When kIOPMTracePointSleepPlatformActions is the latest tracePoint,
394 * PM is calling drivers that have registered a platform sleep action.
395 */
396 kIOPMTracePointSleepPlatformActions = 0x17,
b0d623f7 397
6d2010ae
A
398/* When kIOPMTracePointSleepCPUs is the latest tracePoint,
399 * PM is shutting down all non-boot processors.
400 *
401 * Phase begins: Shutdown all non-boot processors.
402 * Phase ends: Reduced to only the boot processor running.
b0d623f7 403 */
6d2010ae 404 kIOPMTracePointSleepCPUs = 0x18,
b0d623f7 405
6d2010ae
A
406/* When kIOPMTracePointSleepPlatformDriver is the latest tracePoint,
407 * PM is executing platform dependent code to prepare for system sleep.
408 */
409 kIOPMTracePointSleepPlatformDriver = 0x19,
b0d623f7 410
6d2010ae
A
411/* When kIOPMTracePointHibernate is the latest tracePoint,
412 * PM is writing the hibernate image to disk.
b0d623f7 413 */
6d2010ae 414 kIOPMTracePointHibernate = 0x1a,
b0d623f7 415
6d2010ae
A
416/* When kIOPMTracePointSystemSleep is the latest tracePoint,
417 * PM has recorded the final trace point before the hardware platform
418 * enters sleep state, or low level wakeup is underway - such as restoring
419 * the hibernate image from disk.
420 *
421 * Note: If a system is asleep and then loses power, and it does not have a
422 * hibernate image to restore from (e.g. hibernatemode = 0), then OS X will
423 * interpret this power loss as a failure in kIOPMTracePointSystemSleep.
424 *
425 * Phase begins: Before the OS directs the hardware to enter sleep state.
426 * Phase ends: Control returns to the OS on wake, but before recording the first
427 * wake trace point.
428 */
429 kIOPMTracePointSystemSleep = 0x1f,
b0d623f7 430
6d2010ae
A
431/* When kIOPMTracePointWakePlatformDriver is the latest tracePoint,
432 * PM is executing platform dependent code to prepare for system wake.
433 */
434 kIOPMTracePointWakePlatformDriver = 0x21,
435
436/* When kIOPMTracePointWakePlatformActions is the latest tracePoint,
437 * PM is calling drivers that have registered a platform wake action.
438 */
439 kIOPMTracePointWakePlatformActions = 0x22,
b0d623f7 440
6d2010ae
A
441/* When kIOPMTracePointWakeCPUs is the latest tracePoint,
442 * PM is bringing all non-boot processors online.
443 */
444 kIOPMTracePointWakeCPUs = 0x23,
445
446/* When kIOPMTracePointWakeWillPowerOnClients is the latest tracePoint,
447 * PM is sending kIOMessageSystemWillPowerOn to both kernel clients and
448 * applications. PM also notifies system capability clients about the
449 * proposed capability change.
450 *
451 * Phase begins: Send kIOMessageSystemWillPowerOn and
452 * kIOMessageSystemCapabilityChange notifications.
453 * Phase ends: Finished sending notifications.
b0d623f7 454 */
6d2010ae 455 kIOPMTracePointWakeWillPowerOnClients = 0x24,
b0d623f7 456
6d2010ae
A
457/* When kIOPMTracePointWakeWillChangeInterests is the latest tracePoint,
458 * PM is calling powerStateWillChangeTo() on interested drivers of root domain.
459 *
460 * Phase begins: Dispatch a callout thread to call interested drivers.
461 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
462 * by drivers that indicated asynchronous completion.
463 */
464 kIOPMTracePointWakeWillChangeInterests = 0x25,
465
466/* When kIOPMTracePointWakeDidChangeInterests is the latest tracePoint,
467 * PM is calling powerStateDidChangeTo() on interested drivers of root domain.
468 *
469 * Phase begins: Dispatch a callout thread to call interested drivers.
470 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
471 * by drivers that indicated asynchronous completion.
472 */
473 kIOPMTracePointWakeDidChangeInterests = 0x26,
b0d623f7 474
6d2010ae
A
475/* When kIOPMTracePointWakePowerPlaneDrivers is the latest tracePoint,
476 * PM is directing power plane drivers to power up in root-to-leaf order.
477 *
478 * Phase begins: Root domain informs its power children that it transitioned
479 * to ON state. This has a cascade effect and triggers all drivers in
480 * the power plane to re-evaluate and potentially change power state.
481 * Phase ends: All power transitions in response to the root domain power
482 * change have completed.
b0d623f7 483 */
6d2010ae 484 kIOPMTracePointWakePowerPlaneDrivers = 0x27,
b0d623f7 485
6d2010ae
A
486/* When kIOPMTracePointWakeCapabilityClients is the latest tracePoint,
487 * PM is notifying system capability clients about system wake, and waiting
488 * for any asynchronous completions.
489 *
490 * Phase begins: Inform capability clients that system has gained capabilities.
491 * Phase ends: All notified clients have acknowledged.
492 */
493 kIOPMTracePointWakeCapabilityClients = 0x28,
b0d623f7 494
6d2010ae
A
495/* When kIOPMTracePointWakeApplications is the latest tracePoint,
496 * System CPU is powered, PM has powered on each driver.
497 *
498 * Phase begins: Send asynchronous kIOMessageSystemHasPoweredOn notifications.
499 * Phase ends: Finished sending asynchronous notifications.
b0d623f7 500 */
6d2010ae 501 kIOPMTracePointWakeApplications = 0x29,
b0d623f7
A
502
503/* kIOPMTracePointSystemLoginwindowPhase
6d2010ae
A
504 * This phase represents a several minute window after the system has powered on.
505 * Higher levels of system diagnostics are in a heightened state of alert in this phase,
506 * in case any user errors occurred that we could not detect in software.
507 *
508 * Phase begins: After IOPMrootDomain sends kIOMessageSystemHasPoweredOn message.
fe8ab488 509 * Phase ends: When loginwindow calls IOPMSleepWakeSetUUID(NULL) the system shall
6d2010ae
A
510 * be considered awake and usable. The next phase shall be kIOPMTracePointSystemUp.
511 */
512 kIOPMTracePointSystemLoginwindowPhase = 0x30,
b0d623f7 513
6d2010ae
A
514/* When kIOPMTracePointDarkWakeEntry is the latest tracePoint,
515 * PM has started a transition from full wake to dark wake.
516 *
517 * Phase begins: Start transition to dark wake.
518 * Phase ends: System in dark wake. Before recording kIOPMTracePointSystemUp.
519 */
520 kIOPMTracePointDarkWakeEntry = 0x31,
521
522/* When kIOPMTracePointDarkWakeExit is the latest tracePoint,
523 * PM has started a transition from dark wake to full wake.
524 *
525 * Phase begins: Start transition to full wake.
526 * Phase ends: System in full wake. Before recording kIOPMTracePointSystemUp.
b0d623f7 527 */
6d2010ae 528 kIOPMTracePointDarkWakeExit = 0x32
b0d623f7
A
529};
530
531/*****************************************************************************/
532
533/*
39037602
A
534 * Component wake progress keys
535 *
536 * Certain components have the ability to log their wake progress with
537 * root domain using the keys provided below.
538 *
539 * LoginWindow - 4 bits
540 * CoreDisplay - 8 bits
541 * CoreGraphics - 8 bits
542 *
543 * These bits are stored with the trace phase that gets logged to
544 * the RTC register.
545 */
546
547// Values that should be passed in to IOPMLogWakeProgress
548enum {
549 kIOPMLoginWindowProgress = 1,
550 kIOPMCoreDisplayProgress = 2,
551 kIOPMCoreGraphicsProgress = 3
552};
553
554enum {
555 kIOPMLoginWindowProgressMask = 0x0f,
556 kIOPMCoreDisplayProgressMask = 0xff,
557 kIOPMCoreGraphicsProgressMask = 0xff
558};
559
560/*
561 * kIOPMLoginWindowProgressKey - identifies PM debug data specific to LoginWindow
562 * for use with IOPMrootDomain. Only 4 bits of data are allotted.
563 */
564#define kIOPMLoginWindowProgressKey "LoginWindowProgress"
565
566/*
567 * kIOPMCoreDisplayProgressKey - identifies PM debug data specific to CoreDisplay
568 * for use with IOPMrootDomain. Only 8 bits of data are allotted.
569 */
570#define kIOPMCoreDisplayProgressKey "CoreDisplayProgress"
571
572/*
573 * kIOPMCoreGraphicsProgressKey - identifies PM debug data specific to CoreGraphics
574 * for use with IOPMrootDomain. Only 8 bits of data are allotted.
575 */
576#define kIOPMCoreGraphicsProgressKey "CoreGraphicsProgress"
b0d623f7
A
577
578// For PM internal use only - key to locate sleep failure results within SCDynamicStore.
579#define kIOPMDynamicStoreSleepFailureKey "SleepFailure"
580
581/*****************************************************************************/
582
583// For IOPMLibPrivate.h
584#define kIOPMSleepWakeFailureKey "PMFailurePhase"
585#define kIOPMSleepWakeFailureCodeKey "PMStatusCode"
586#define kIOPMSleepWakeFailureLoginKey "LWFailurePhase"
587#define kIOPMSleepWakeFailureUUIDKey "UUID"
588#define kIOPMSleepWakeFailureDateKey "Date"
39236c6e
A
589#define kIOPMSleepWakeWdogRebootKey "SWWdogTriggeredRestart"
590#define kIOPMSleepWakeWdogLogsValidKey "SWWdogLogsValid"
b0d623f7 591
99c3a104
A
592/*****************************************************************************
593 *
594 * Root Domain private property keys
595 *
596 *****************************************************************************/
597
db609669
A
598/* kIOPMFeatureAutoPowerOffKey
599 * Feature published if Auto Power Off is supported
600 */
601#define kIOPMFeatureAutoPowerOffKey "AutoPowerOff"
602
99c3a104
A
603/* kIOPMAutoPowerOffEnabledKey
604 * Indicates if Auto Power Off is enabled.
605 * It has a boolean value.
606 * true == Auto Power Off is enabled
607 * false == Auto Power Off is disabled
608 * not present == Auto Power Off is not supported on this hardware
0b4c1975 609 */
99c3a104 610#define kIOPMAutoPowerOffEnabledKey "AutoPowerOff Enabled"
0b4c1975 611
99c3a104
A
612/* kIOPMAutoPowerOffDelayKey
613 * Key refers to a CFNumberRef that represents the delay in seconds before
614 * entering the Auto Power Off state. The property is not present if Auto
615 * Power Off is unsupported.
616 */
617#define kIOPMAutoPowerOffDelayKey "AutoPowerOff Delay"
0b4c1975 618
db609669
A
619/* kIOPMAutoPowerOffTimerKey
620 * Key refers to a CFNumberRef that indicates the time in seconds until the
621 * expiration of the Auto Power Off delay period. This value should be used
622 * to program a wake alarm before system sleep.
623 */
624#define kIOPMAutoPowerOffTimerKey "AutoPowerOff Timer"
625
626/* kIOPMUserWakeAlarmScheduledKey
627 * Key refers to a boolean value that indicates if an user alarm was scheduled
628 * or pending.
629 */
630#define kIOPMUserWakeAlarmScheduledKey "UserWakeAlarmScheduled"
631
bd504ef0
A
632/* kIOPMDeepIdleSupportedKey
633 * Presence of this key indicates Deep Idle is supported on this platform.
634 * Key will always refer to a value of kOSBooleanTrue.
635 */
636#define kIOPMDeepIdleSupportedKey "IOPMDeepIdleSupported"
637
39236c6e
A
638/* kIOPMUserTriggeredFullWakeKey
639 * Key refers to a boolean value that indicates if the first full wake since
640 * last system sleep was triggered by the local user. This property is set
641 * before the initial full wake transition, and removed after powering down
642 * drivers for system sleep.
643 */
644#define kIOPMUserTriggeredFullWakeKey "IOPMUserTriggeredFullWake"
645
646/* kIOPMUserIsActiveKey
647 * Key refers to a boolean value that indicates if the user is active.
648 */
649#define kIOPMUserIsActiveKey "IOPMUserIsActive"
650
fe8ab488
A
651/* kIOPMDriverWakeEventsKey
652 * Key refers to a property that should only be examined by powerd.
653 */
654#define kIOPMDriverWakeEventsKey "IOPMDriverWakeEvents"
655
656/*****************************************************************************
657 *
658 * IOPMDriverWakeEvents dictionary keys
659 *
660 *****************************************************************************/
661
662#define kIOPMWakeEventTimeKey "Time"
663#define kIOPMWakeEventFlagsKey "Flags"
664#define kIOPMWakeEventReasonKey "Reason"
665#define kIOPMWakeEventDetailsKey "Details"
666
667/*****************************************************************************
668 *
669 * Wake event flags reported to IOPMrootDomain::claimSystemWakeEvent()
670 *
671 *****************************************************************************/
672
673#define kIOPMWakeEventSource 0x00000001
674
99c3a104
A
675/*****************************************************************************
676 *
677 * System Sleep Policy
678 *
679 *****************************************************************************/
7ddcb079 680
99c3a104
A
681#define kIOPMSystemSleepPolicySignature 0x54504c53
682#define kIOPMSystemSleepPolicyVersion 2
683
684/*!
685 * @defined kIOPMSystemSleepTypeKey
686 * @abstract Indicates the type of system sleep.
687 * @discussion An OSNumber property of root domain that describes the type
688 * of system sleep. This property is set after notifying priority sleep/wake
689 * clients, but before informing interested drivers and shutting down power
fe8ab488
A
690 * plane drivers. On a hibernate abort or failure, this property will not be
691 * updated and will indicate the failed sleep type.
99c3a104
A
692 */
693#define kIOPMSystemSleepTypeKey "IOPMSystemSleepType"
694
695struct IOPMSystemSleepPolicyVariables
0b4c1975 696{
99c3a104
A
697 uint32_t signature; // kIOPMSystemSleepPolicySignature
698 uint32_t version; // kIOPMSystemSleepPolicyVersion
699
700 uint64_t currentCapability; // current system capability bits
701 uint64_t highestCapability; // highest system capability bits
702
703 uint64_t sleepFactors; // sleep factor bits
704 uint32_t sleepReason; // kIOPMSleepReason*
705 uint32_t sleepPhase; // identify the sleep phase
706 uint32_t hibernateMode; // current hibernate mode
707
708 uint32_t standbyDelay; // standby delay in seconds
709 uint32_t poweroffDelay; // auto-poweroff delay in seconds
710 uint32_t scheduledAlarms; // bitmask of scheduled alarm types
db609669 711 uint32_t poweroffTimer; // auto-poweroff timer in seconds
99c3a104 712
db609669 713 uint32_t reserved[49]; // pad sizeof 256 bytes
99c3a104
A
714};
715
716enum {
717 kIOPMAlarmBitDebugWake = 0x01,
718 kIOPMAlarmBitCalendarWake = 0x02,
719 kIOPMAlarmBitMaintenanceWake = 0x04,
720 kIOPMAlarmBitSleepServiceWake = 0x08
0b4c1975 721};
d52fe63f 722
0b4c1975 723enum {
db609669
A
724 kIOPMSleepPhase0 = 0,
725 kIOPMSleepPhase1,
99c3a104 726 kIOPMSleepPhase2
0b4c1975
A
727};
728
99c3a104
A
729// Sleep Factor Mask / Bits
730enum {
731 kIOPMSleepFactorSleepTimerWake = 0x00000001ULL,
732 kIOPMSleepFactorLidOpen = 0x00000002ULL,
733 kIOPMSleepFactorACPower = 0x00000004ULL,
734 kIOPMSleepFactorBatteryLow = 0x00000008ULL,
735 kIOPMSleepFactorStandbyNoDelay = 0x00000010ULL,
736 kIOPMSleepFactorStandbyForced = 0x00000020ULL,
737 kIOPMSleepFactorStandbyDisabled = 0x00000040ULL,
738 kIOPMSleepFactorUSBExternalDevice = 0x00000080ULL,
739 kIOPMSleepFactorBluetoothHIDDevice = 0x00000100ULL,
740 kIOPMSleepFactorExternalMediaMounted = 0x00000200ULL,
741 kIOPMSleepFactorThunderboltDevice = 0x00000400ULL,
742 kIOPMSleepFactorRTCAlarmScheduled = 0x00000800ULL,
743 kIOPMSleepFactorMagicPacketWakeEnabled = 0x00001000ULL,
744 kIOPMSleepFactorHibernateForced = 0x00010000ULL,
745 kIOPMSleepFactorAutoPowerOffDisabled = 0x00020000ULL,
746 kIOPMSleepFactorAutoPowerOffForced = 0x00040000ULL,
39236c6e
A
747 kIOPMSleepFactorExternalDisplay = 0x00080000ULL,
748 kIOPMSleepFactorNetworkKeepAliveActive = 0x00100000ULL,
fe8ab488 749 kIOPMSleepFactorLocalUserActivity = 0x00200000ULL,
a1c7dba1
A
750 kIOPMSleepFactorHibernateFailed = 0x00400000ULL,
751 kIOPMSleepFactorThermalWarning = 0x00800000ULL,
752 kIOPMSleepFactorDisplayCaptured = 0x01000000ULL
99c3a104
A
753};
754
755// System Sleep Types
756enum {
757 kIOPMSleepTypeInvalid = 0,
758 kIOPMSleepTypeAbortedSleep = 1,
759 kIOPMSleepTypeNormalSleep = 2,
760 kIOPMSleepTypeSafeSleep = 3,
761 kIOPMSleepTypeHibernate = 4,
762 kIOPMSleepTypeStandby = 5,
763 kIOPMSleepTypePowerOff = 6,
bd504ef0
A
764 kIOPMSleepTypeDeepIdle = 7,
765 kIOPMSleepTypeLast = 8
99c3a104
A
766};
767
768// System Sleep Flags
769enum {
770 kIOPMSleepFlagDisableHibernateAbort = 0x00000001,
771 kIOPMSleepFlagDisableUSBWakeEvents = 0x00000002,
39236c6e
A
772 kIOPMSleepFlagDisableBatlowAssertion = 0x00000004,
773 kIOPMSleepFlagDisableS4WakeSources = 0x00000008
99c3a104
A
774};
775
776// System Wake Events
777enum {
778 kIOPMWakeEventLidOpen = 0x00000001,
779 kIOPMWakeEventLidClose = 0x00000002,
780 kIOPMWakeEventACAttach = 0x00000004,
781 kIOPMWakeEventACDetach = 0x00000008,
782 kIOPMWakeEventCDInsert = 0x00000010,
783 kIOPMWakeEventCDEject = 0x00000020,
784 kIOPMWakeEventHPDAttach = 0x00000040,
785 kIOPMWakeEventHPDDetach = 0x00000080,
786 kIOPMWakeEventPowerButton = 0x00000100,
787 kIOPMWakeEventG3PowerOn = 0x00000200,
788 kIOPMWakeEventUserPME = 0x00000400,
789 kIOPMWakeEventSleepTimer = 0x00000800,
790 kIOPMWakeEventBatteryLow = 0x00001000,
791 kIOPMWakeEventDarkPME = 0x00002000
792};
793
794/*!
795 * @defined kIOPMSystemSleepParametersKey
796 * @abstract Sleep parameters describing the upcoming sleep
797 * @discussion Root domain updates this OSData property before system sleep
798 * to pass sleep parameters to the platform driver. Some of the parameters
799 * are based on the chosen entry in the system sleep policy table.
800 */
801#define kIOPMSystemSleepParametersKey "IOPMSystemSleepParameters"
802#define kIOPMSystemSleepParametersVersion 2
803
804struct IOPMSystemSleepParameters
805{
806 uint16_t version;
807 uint16_t reserved1;
808 uint32_t sleepType;
809 uint32_t sleepFlags;
810 uint32_t ecWakeEvents;
811 uint32_t ecWakeTimer;
812 uint32_t ecPoweroffTimer;
813 uint32_t reserved2[10];
814} __attribute__((packed));
815
39236c6e
A
816
817/*
818 * Sleep Wake debug buffer header
819 */
820typedef struct {
fe8ab488 821 uint32_t signature;
39236c6e 822 uint32_t alloc_size;
fe8ab488 823 uint32_t crc; /* CRC for spindump & following data.*/
39236c6e
A
824 uint32_t spindump_offset; /* Offset at which spindump offset is stored */
825 uint32_t spindump_size;
fe8ab488 826 uint8_t is_osx_watchdog;
39236c6e
A
827
828 /* All members from UUID onwards are saved into log file */
fe8ab488 829 char UUID[44];
39037602 830 char spindump_status[24]; /* stackshot status*/
fe8ab488
A
831 char PMStatusCode[32];
832 char reason[32];
833} swd_hdr;
39236c6e 834
fe8ab488
A
835
836#define SWD_HDR_SIGNATURE 0xdeb8da2a
fe8ab488
A
837
838#define SWD_BUF_SIZE (40*PAGE_SIZE)
839#define SWD_INITIAL_STACK_SIZE ((SWD_BUF_SIZE/2)-sizeof(swd_hdr))
39236c6e 840
3e170ce0
A
841#define SWD_SPINDUMP_SIZE (256*1024)
842#define SWD_INITIAL_SPINDUMP_SIZE ((SWD_SPINDUMP_SIZE/2)-sizeof(swd_hdr))
843
39236c6e 844/* Bits in swd_flags */
fe8ab488
A
845#define SWD_WDOG_ENABLED 0x01
846#define SWD_BOOT_BY_SW_WDOG 0x02
847#define SWD_BOOT_BY_OSX_WDOG 0x04
848#define SWD_VALID_LOGS 0x08
849#define SWD_LOGS_IN_FILE 0x10
850#define SWD_LOGS_IN_MEM 0x20
851
39037602
A
852#define SWD_DATA_CRC_ERROR 0x010000
853#define SWD_BUF_SIZE_ERROR 0x020000
854#define SWD_HDR_SIZE_ERROR 0x040000
855#define SWD_FILEOP_ERROR 0x080000
856#define SWD_HDR_SIGNATURE_ERROR 0x100000
857#define SWD_INTERNAL_FAILURE 0x200000
858
859
fe8ab488 860/* Filenames associated with the stackshots/logs generated by the SWD */
3e170ce0 861#define kSleepWakeStackBinFilename "/var/log/SleepWakeStacks.bin"
fe8ab488
A
862#define kSleepWakeStackFilename "/var/log/SleepWakeStacks.dump"
863#define kSleepWakeLogFilename "/var/log/SleepWakeLog.dump"
864#define kAppleOSXWatchdogStackFilename "/var/log/AppleOSXWatchdogStacks.dump"
865#define kAppleOSXWatchdogLogFilename "/var/log/AppleOSXWatchdogLog.dump"
866
867inline char const* getDumpStackFilename(swd_hdr *hdr)
868{
869 if (hdr && hdr->is_osx_watchdog)
870 return kAppleOSXWatchdogStackFilename;
871 return kSleepWakeStackFilename;
872}
39236c6e 873
fe8ab488
A
874inline char const* getDumpLogFilename(swd_hdr *hdr)
875{
876 if (hdr && hdr->is_osx_watchdog)
877 return kAppleOSXWatchdogLogFilename;
878 return kSleepWakeLogFilename;
879}
39236c6e
A
880
881/* RootDomain IOReporting channels */
882#define kSleepCntChID IOREPORT_MAKEID('S','l','e','e','p','C','n','t')
883#define kDarkWkCntChID IOREPORT_MAKEID('G','U','I','W','k','C','n','t')
884#define kUserWkCntChID IOREPORT_MAKEID('D','r','k','W','k','C','n','t')
885
3e170ce0
A
886/*
887 * kAssertDelayChID - Histogram of time elapsed before assertion after wake.
888 */
889#define kAssertDelayBcktCnt 11
890#define kAssertDelayBcktSize 3
891#define kAssertDelayChID IOREPORT_MAKEID('r','d','A','s','r','t','D','l')
892
893/*
894 * kSleepDelaysChID - Histogram of time taken to put system to sleep
895 */
896#define kSleepDelaysBcktCnt 13
897#define kSleepDelaysBcktSize 10
898#define kSleepDelaysChID IOREPORT_MAKEID('r','d','S','l','p','D','l','y')
39236c6e 899
a1c7dba1
A
900/* Sleep Options/settings */
901#define kSleepOptionDisplayCapturedModeKey "DisplayCapturedMode"
902
39236c6e 903
99c3a104
A
904#if defined(KERNEL) && defined(__cplusplus)
905
906/*!
907 * @defined kIOPMInstallSystemSleepPolicyHandlerKey
908 * @abstract Name of the platform function to install a sleep policy handler.
909 * @discussion Pass to IOPMrootDomain::callPlatformFunction(), with a pointer
910 * to the C-function handler at param1, and an optional target at param2, to
911 * register a sleep policy handler. Only a single sleep policy handler can
912 * be installed.
913 */
fe8ab488 914#define kIOPMInstallSystemSleepPolicyHandlerKey \
99c3a104
A
915 "IOPMInstallSystemSleepPolicyHandler"
916
917typedef IOReturn (*IOPMSystemSleepPolicyHandler)(
918 void * target,
919 const IOPMSystemSleepPolicyVariables * vars,
920 IOPMSystemSleepParameters * params );
921
922#endif /* KERNEL */
923
a1c7dba1
A
924/*****************************************************************************
925 *
926 * Performance Warning
927 *
928 *****************************************************************************/
929
930/* Performance Warning Key
931 * Key for performance warning event published using IOPMrootDomain::
932 * systemPowerEventOccurred()
933 */
934#define kIOPMPerformanceWarningKey "Performance_Warning"
935
936/* Performance warning values */
937enum {
938 kIOPMPerformanceNormal = 0,
939 kIOPMPerformanceWarning = 100
940};
941
0b4c1975 942#endif /* ! _IOKIT_IOPMPRIVATE_H */