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 /* @constant kIOPMEventTypeIntermediateFlag
34 * @abstract This bit indicates the event is an intermediate event
35 * which must occur within a major system power event.
37 #define kIOPMEventTypeIntermediateFlag 0x10000000
39 /* @enum SystemEventTypes
40 * @abstract Potential system events logged in the system event record.
43 kIOPMEventTypeUndefined
= 0,
45 /* Event types mark driver events
47 kIOPMEventTypeSetPowerStateImmediate
= 1001,
48 kIOPMEventTypeSetPowerStateDelayed
= 1002,
49 kIOPMEventTypePSWillChangeTo
= 1003,
50 kIOPMEventTypePSDidChangeTo
= 1004,
51 kIOPMEventTypeAppResponse
= 1005,
54 /* Start and stop event types bracket major
55 * system power management events.
57 kIOPMEventTypeSleep
= 2001,
58 kIOPMEventTypeSleepDone
= 2002,
59 kIOPMEventTypeWake
= 3001,
60 kIOPMEventTypeWakeDone
= 3002,
61 kIOPMEventTypeDoze
= 4001,
62 kIOPMEventTypeDozeDone
= 4002,
63 kIOPMEventTypeUUIDSet
= 6001,
64 kIOPMEventTypeUUIDClear
= 6002,
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.
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.
74 kIOPMEventTypeAppNotificationsFinished
= 501 | kIOPMEventTypeIntermediateFlag
,
75 kIOPMEventTypeDriverNotificationsFinished
= 502 | kIOPMEventTypeIntermediateFlag
,
76 kIOPMEventTypeCalTimeChange
= 503 | kIOPMEventTypeIntermediateFlag
79 /*****************************************************************************
81 * Private Root Domain general interest messages
83 * Check IOPM.h when adding new messages to avoid conflict.
85 *****************************************************************************/
87 /* kIOPMMessageUserIsActiveChanged
88 * User became active or inactive. Message sent after the kIOPMUserIsActiveKey
89 * property was updated with a new value.
91 #define kIOPMMessageUserIsActiveChanged \
92 iokit_family_msg(sub_iokit_powermanagement, 0x400)
95 * Private IOMessage notifications shared between kernel and userspace PM policy
97 #define kIOPMMessageLastCallBeforeSleep \
98 iokit_family_msg(sub_iokit_powermanagement, 0x410)
100 #define kIOPMMessageIdleSleepPreventers \
101 iokit_family_msg(sub_iokit_powermanagement, 0x420)
103 #define kIOPMMessageSystemSleepPreventers \
104 iokit_family_msg(sub_iokit_powermanagement, 0x430)
106 #define kIOPMMessageLaunchBootSpinDump \
107 iokit_family_msg(sub_iokit_powermanagement, 0x440)
109 #define kIOPMMessageProModeStateChange \
110 iokit_family_msg(sub_iokit_powermanagement, 0x450)
112 /* @enum SystemSleepReasons
113 * @abstract The potential causes for system sleep as logged in the system event record.
116 kIOPMSleepReasonClamshell
= 101,
117 kIOPMSleepReasonPowerButton
= 102,
118 kIOPMSleepReasonSoftware
= 103,
119 kIOPMSleepReasonOSSwitchHibernate
= 104,
120 kIOPMSleepReasonIdle
= 105,
121 kIOPMSleepReasonLowPower
= 106,
122 kIOPMSleepReasonThermalEmergency
= 107,
123 kIOPMSleepReasonMaintenance
= 108,
124 kIOPMSleepReasonSleepServiceExit
= 109,
125 kIOPMSleepReasonDarkWakeThermalEmergency
= 110
129 * Possible C-string sleep reasons found under kRootDomainSleepReasonsKey
131 #define kIOPMClamshellSleepKey "Clamshell Sleep"
132 #define kIOPMPowerButtonSleepKey "Power Button Sleep"
133 #define kIOPMSoftwareSleepKey "Software Sleep"
134 #define kIOPMOSSwitchHibernationKey "OS Switch Sleep"
135 #define kIOPMIdleSleepKey "Idle Sleep"
136 #define kIOPMLowPowerSleepKey "Low Power Sleep"
137 #define kIOPMThermalEmergencySleepKey "Thermal Emergency Sleep"
138 #define kIOPMSleepServiceExitKey "Sleep Service Back to Sleep"
139 #define kIOPMDarkWakeThermalEmergencyKey "Dark Wake Thermal Emergency"
141 /*! kIOPMPSRestrictedModeKey
142 * An IOPMPowerSource property key
143 * Its property has an integer value.
144 * - value = 1 when the device is in a low power state and not fully functional.
145 * - value = 0, or property missing altogether, when the device is
146 * not in a restricted mode power state.
148 #define kIOPMPSRestrictedModeKey "RestrictedMode"
150 #pragma mark Stray Bitfields
151 // Private power commands issued to root domain
152 // bits 0-7 in IOPM.h
155 kIOPMSetValue
= (1<<16),
156 // don't sleep on clamshell closure on a portable with AC connected
157 kIOPMSetDesktopMode
= (1<<17),
158 // set state of AC adaptor connected
159 kIOPMSetACAdaptorConnected
= (1<<18)
162 /*****************************************************************************/
163 /*****************************************************************************/
166 * PM notification types
169 /*! @constant kIOPMSleepServiceScheduleImmediate
171 * Setting type used in calls to IOPMrootDomain::registerPMSettingController
172 * Use this type between powerd and IOKit.framework
175 #define kIOPMSleepServiceScheduleImmediate "SleepServiceImmediate"
177 /*! @constant kIOPMSettingSleepServiceScheduleImmediate
179 * Setting type used in calls to IOPMrootDomain::registerPMSettingController
180 * Use this type between xnu and AppleRTC
182 #define kIOPMSettingSleepServiceWakeCalendarKey "SleepServiceWakeCalendarKey"
184 /*! @constant kIOPMCalendarWakeTypes
186 * These are valid values for IOPM.h:IOPMCalendarStruct->selector
189 kPMCalendarTypeInvalid
= 0,
190 kPMCalendarTypeMaintenance
= 1,
191 kPMCalendarTypeSleepService
= 2
195 /* @constant kIOPMStateConsoleShutdown
196 * @abstract Notification of GUI shutdown state available to kexts.
197 * @discussion This type can be passed as arguments to registerPMSettingController()
198 * to receive callbacks.
200 #define kIOPMStateConsoleShutdown "ConsoleShutdown"
202 /* @enum ShutdownValues
203 * @abstract Potential values shared with key kIOPMStateConsoleShutdown
206 /* @constant kIOPMStateConsoleShutdownNone
207 * @abstract System shutdown (or restart) hasn't started; system is ON.
208 * @discussion Next state: 2
210 kIOPMStateConsoleShutdownNone
= 1,
211 /* @constant kIOPMStateConsoleShutdownPossible
212 * @abstract User has been presented with the option to shutdown or restart. Shutdown may be cancelled.
213 * @discussion Next state may be: 1, 4
215 kIOPMStateConsoleShutdownPossible
= 2,
216 /* @constant kIOPMStateConsoleShutdownUnderway
217 * @abstract Shutdown or restart is proceeding. It may still be cancelled.
218 * @discussion Next state may be: 1, 4. This state is currently unused.
220 kIOPMStateConsoleShutdownUnderway
= 3,
221 /* @constant kIOPMStateConsoleShutdownCertain
222 * @abstract Shutdown is in progress and irrevocable.
223 * @discussion State remains 4 until power is removed from CPU.
225 kIOPMStateConsoleShutdownCertain
= 4,
226 /* @constant kIOPMStateConsoleSULogoutInitiated
227 Indicates that LoginWindow has initiated a software update restart.
228 The next logout will not immediately lead to a shutdown.
230 kIOPMStateConsoleSULogoutInitiated
= 5
233 /* @constant kIOPMSettingSilentRunningKey
234 * @abstract Notification of silent running mode changes to kexts.
235 * @discussion This key can be passed as an argument to registerPMSettingController()
236 * and also identifies the type of PMSetting notification callback.
238 #define kIOPMSettingSilentRunningKey "SilentRunning"
239 #define kIOPMFeatureSilentRunningKey kIOPMSettingSilentRunningKey
241 /* @enum SilentRunningFlags
242 * @abstract The kIOPMSettingSilentRunningKey notification provides an OSNumber
243 * object with a value described by the following flags.
246 kIOPMSilentRunningModeOn
= 0x00000001
249 /*****************************************************************************/
250 /*****************************************************************************/
252 /* PM Statistics - event indices
253 * These are arguments to IOPMrootDomain::pmStatsRecordEvent().
256 kIOPMStatsHibernateImageWrite
= 1,
257 kIOPMStatsHibernateImageRead
,
258 kIOPMStatsDriversNotify
,
259 kIOPMStatsApplicationNotify
,
260 kIOPMStatsLateDriverAcknowledge
,
261 kIOPMStatsLateAppAcknowledge
,
263 // To designate if you're specifying the start or stop end of
264 // each of the above events, do a bitwise OR of the appropriate
265 // Start/Stop flag and pass the result to IOPMrootDomain to record
267 kIOPMStatsEventStartFlag
= (1 << 24),
268 kIOPMStatsEventStopFlag
= (1 << 25)
271 // Keys for IOPMrootDomain registry properties
272 #define kIOPMSleepStatisticsKey "SleepStatistics"
273 #define kIOPMSleepStatisticsAppsKey "AppStatistics"
274 #define kIOPMIdleSleepPreventersKey "IdleSleepPreventers"
275 #define kIOPMSystemSleepPreventersKey "SystemSleepPreventers"
276 #define kIOPMIdleSleepPreventersWithIDKey "IdleSleepPreventersWithID"
277 #define kIOPMSystemSleepPreventersWithIDKey "SystemSleepPreventersWithID"
279 // Application response statistics
280 #define kIOPMStatsNameKey "Name"
281 #define kIOPMStatsPIDKey "Pid"
282 #define kIOPMStatsTimeMSKey "TimeMS"
283 #define kIOPMStatsApplicationResponseTypeKey "ResponseType"
284 #define kIOPMStatsMessageTypeKey "MessageType"
285 #define kIOPMStatsPowerCapabilityKey "PowerCaps"
286 #define kIOPMStatsSystemTransitionKey "TransitionType"
288 // PM Statistics: potential values for the key kIOPMStatsApplicationResponseTypeKey
289 // entry in the application results array.
290 #define kIOPMStatsResponseTimedOut "ResponseTimedOut"
291 #define kIOPMStatsResponseCancel "ResponseCancel"
292 #define kIOPMStatsResponseSlow "ResponseSlow"
293 #define kIOPMStatsResponsePrompt "ResponsePrompt"
294 #define kIOPMStatsDriverPSChangeSlow "DriverPSChangeSlow"
296 struct PMStatsBounds
{
302 struct PMStatsBounds hibWrite
;
303 struct PMStatsBounds hibRead
;
304 // bounds driverNotifySleep;
305 // bounds driverNotifyWake;
306 // bounds appNotifySleep;
307 // bounds appNotifyWake;
308 // OSDictionary *tardyApps;
309 // OSDictionary *tardyDrivers;
312 /*****************************************************************************/
314 /* PM RootDomain tracePoints
316 * In the sleep/wake process, we expect the sleep trace points to proceed
317 * in increasing order. Once sleep begins with code kIOPMTracePointSleepStarted,
318 * we expect sleep to continue in a monotonically increasing order of tracepoints
319 * to kIOPMTracePointSystemLoginwindowPhase. After trace point SystemLoginWindowPhase,
320 * the system will return to kIOPMTracePointSystemUp.
322 * If the trace point decreases (instead of increasing) before reaching kIOPMTracePointSystemUp,
323 * that indicates that the sleep process was cancelled. The cancel reason shall be indicated
324 * in the cancel tracepoint. (TBD)
328 /* When kTracePointSystemUp is the latest tracePoint,
329 * the system is awake. It is not asleep, sleeping, or waking.
331 * Phase begins: At boot, at completion of wake from sleep,
332 * immediately following kIOPMTracePointSystemLoginwindowPhase.
333 * Phase ends: When a sleep attempt is initiated.
335 kIOPMTracePointSystemUp
= 0,
337 /* When kIOPMTracePointSleepStarted is the latest tracePoint,
338 * sleep has been initiated.
340 * Phase begins: At initiation of system sleep (idle or forced).
341 * Phase ends: PM starts to notify applications of system sleep.
343 kIOPMTracePointSleepStarted
= 0x10,
345 /* When kIOPMTracePointSleepApplications is the latest tracePoint,
346 * a system sleep has been initiated and PM waits for responses
347 * from notified applications.
349 * Phase begins: Begin to asynchronously fire kIOMessageSystemWillSleep
350 * notifications, and also kIOMessageCanSystemSleep for the idle sleep case.
351 * Phase ends: When PM has received all application responses.
353 kIOPMTracePointSleepApplications
= 0x11,
355 /* When kIOPMTracePointSleepPriorityClients is the latest tracePoint,
356 * PM is notifying priority clients and in-kernel system capability
357 * clients, and waiting for any asynchronous completions.
359 * Phase begins: Synchronous delivery of kIOMessageSystemWillSleep notifications.
360 * Phase ends: All notified clients have acknowledged.
362 kIOPMTracePointSleepPriorityClients
= 0x12,
364 /* When kIOPMTracePointSleepWillChangeInterests is the latest tracePoint,
365 * PM is calling powerStateWillChangeTo() on interested drivers of root domain.
367 * Phase begins: Dispatch a callout thread to call interested drivers.
368 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
369 * by drivers that indicated asynchronous completion.
371 kIOPMTracePointSleepWillChangeInterests
= 0x13,
373 /* When kIOPMTracePointSleepPowerPlaneDrivers is the latest tracePoint,
374 * PM is directing power plane drivers to power off in leaf-to-root order.
376 * Phase begins: Root domain informs its power children that it will drop to
377 * sleep state. This has a cascade effect and triggers all drivers in
378 * the power plane to transition to a lower power state if necessary.
379 * Phase ends: All power transitions in response to the root domain power
380 * change have completed.
382 kIOPMTracePointSleepPowerPlaneDrivers
= 0x14,
384 /* When kIOPMTracePointSleepDidChangeInterests is the latest tracePoint,
385 * PM is calling powerStateDidChangeTo() on interested drivers of root domain.
387 * Phase begins: Dispatch a callout thread to call interested drivers.
388 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
389 * by drivers that indicated asynchronous completion.
391 kIOPMTracePointSleepDidChangeInterests
= 0x15,
393 /* When kIOPMTracePointSleepCapabilityClients is the latest tracePoint,
394 * PM is notifying system capability clients about system sleep.
396 * Phase begins: Send kIOMessageSystemCapabilityChange notifications to inform
397 * capability clients that system has lost all capabilities.
398 * Phase ends: Finished sending notifications.
400 kIOPMTracePointSleepCapabilityClients
= 0x16,
402 /* When kIOPMTracePointSleepPlatformActions is the latest tracePoint,
403 * PM is calling drivers that have registered a platform sleep action.
405 kIOPMTracePointSleepPlatformActions
= 0x17,
407 /* When kIOPMTracePointSleepCPUs is the latest tracePoint,
408 * PM is shutting down all non-boot processors.
410 * Phase begins: Shutdown all non-boot processors.
411 * Phase ends: Reduced to only the boot processor running.
413 kIOPMTracePointSleepCPUs
= 0x18,
415 /* When kIOPMTracePointSleepPlatformDriver is the latest tracePoint,
416 * PM is executing platform dependent code to prepare for system sleep.
418 kIOPMTracePointSleepPlatformDriver
= 0x19,
420 /* When kIOPMTracePointHibernate is the latest tracePoint,
421 * PM is writing the hibernate image to disk.
423 kIOPMTracePointHibernate
= 0x1a,
425 /* When kIOPMTracePointSystemSleep is the latest tracePoint,
426 * PM has recorded the final trace point before the hardware platform
427 * enters sleep state, or low level wakeup is underway - such as restoring
428 * the hibernate image from disk.
430 * Note: If a system is asleep and then loses power, and it does not have a
431 * hibernate image to restore from (e.g. hibernatemode = 0), then OS X will
432 * interpret this power loss as a failure in kIOPMTracePointSystemSleep.
434 * Phase begins: Before the OS directs the hardware to enter sleep state.
435 * Phase ends: Control returns to the OS on wake, but before recording the first
438 kIOPMTracePointSystemSleep
= 0x1f,
440 /* When kIOPMTracePointWakePlatformDriver is the latest tracePoint,
441 * PM is executing platform dependent code to prepare for system wake.
443 kIOPMTracePointWakePlatformDriver
= 0x21,
445 /* When kIOPMTracePointWakePlatformActions is the latest tracePoint,
446 * PM is calling drivers that have registered a platform wake action.
448 kIOPMTracePointWakePlatformActions
= 0x22,
450 /* When kIOPMTracePointWakeCPUs is the latest tracePoint,
451 * PM is bringing all non-boot processors online.
453 kIOPMTracePointWakeCPUs
= 0x23,
455 /* When kIOPMTracePointWakeWillPowerOnClients is the latest tracePoint,
456 * PM is sending kIOMessageSystemWillPowerOn to both kernel clients and
457 * applications. PM also notifies system capability clients about the
458 * proposed capability change.
460 * Phase begins: Send kIOMessageSystemWillPowerOn and
461 * kIOMessageSystemCapabilityChange notifications.
462 * Phase ends: Finished sending notifications.
464 kIOPMTracePointWakeWillPowerOnClients
= 0x24,
466 /* When kIOPMTracePointWakeWillChangeInterests is the latest tracePoint,
467 * PM is calling powerStateWillChangeTo() on interested drivers of root domain.
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.
473 kIOPMTracePointWakeWillChangeInterests
= 0x25,
475 /* When kIOPMTracePointWakeDidChangeInterests is the latest tracePoint,
476 * PM is calling powerStateDidChangeTo() on interested drivers of root domain.
478 * Phase begins: Dispatch a callout thread to call interested drivers.
479 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
480 * by drivers that indicated asynchronous completion.
482 kIOPMTracePointWakeDidChangeInterests
= 0x26,
484 /* When kIOPMTracePointWakePowerPlaneDrivers is the latest tracePoint,
485 * PM is directing power plane drivers to power up in root-to-leaf order.
487 * Phase begins: Root domain informs its power children that it transitioned
488 * to ON state. This has a cascade effect and triggers all drivers in
489 * the power plane to re-evaluate and potentially change power state.
490 * Phase ends: All power transitions in response to the root domain power
491 * change have completed.
493 kIOPMTracePointWakePowerPlaneDrivers
= 0x27,
495 /* When kIOPMTracePointWakeCapabilityClients is the latest tracePoint,
496 * PM is notifying system capability clients about system wake, and waiting
497 * for any asynchronous completions.
499 * Phase begins: Inform capability clients that system has gained capabilities.
500 * Phase ends: All notified clients have acknowledged.
502 kIOPMTracePointWakeCapabilityClients
= 0x28,
504 /* When kIOPMTracePointWakeApplications is the latest tracePoint,
505 * System CPU is powered, PM has powered on each driver.
507 * Phase begins: Send asynchronous kIOMessageSystemHasPoweredOn notifications.
508 * Phase ends: Finished sending asynchronous notifications.
510 kIOPMTracePointWakeApplications
= 0x29,
512 /* kIOPMTracePointSystemLoginwindowPhase
513 * This phase represents a several minute window after the system has powered on.
514 * Higher levels of system diagnostics are in a heightened state of alert in this phase,
515 * in case any user errors occurred that we could not detect in software.
517 * Phase begins: After IOPMrootDomain sends kIOMessageSystemHasPoweredOn message.
518 * Phase ends: When loginwindow calls IOPMSleepWakeSetUUID(NULL) the system shall
519 * be considered awake and usable. The next phase shall be kIOPMTracePointSystemUp.
521 kIOPMTracePointSystemLoginwindowPhase
= 0x30,
523 /* When kIOPMTracePointDarkWakeEntry is the latest tracePoint,
524 * PM has started a transition from full wake to dark wake.
526 * Phase begins: Start transition to dark wake.
527 * Phase ends: System in dark wake. Before recording kIOPMTracePointSystemUp.
529 kIOPMTracePointDarkWakeEntry
= 0x31,
531 /* When kIOPMTracePointDarkWakeExit is the latest tracePoint,
532 * PM has started a transition from dark wake to full wake.
534 * Phase begins: Start transition to full wake.
535 * Phase ends: System in full wake. Before recording kIOPMTracePointSystemUp.
537 kIOPMTracePointDarkWakeExit
= 0x32
540 /*****************************************************************************/
543 * Component wake progress keys
545 * Certain components have the ability to log their wake progress with
546 * root domain using the keys provided below.
548 * LoginWindow - 4 bits
549 * CoreDisplay - 8 bits
550 * CoreGraphics - 8 bits
552 * These bits are stored with the trace phase that gets logged to
556 // Values that should be passed in to IOPMLogWakeProgress
558 kIOPMLoginWindowProgress
= 1,
559 kIOPMCoreDisplayProgress
= 2,
560 kIOPMCoreGraphicsProgress
= 3
564 kIOPMLoginWindowProgressMask
= 0x0f,
565 kIOPMCoreDisplayProgressMask
= 0xff,
566 kIOPMCoreGraphicsProgressMask
= 0xff
570 * kIOPMLoginWindowProgressKey - identifies PM debug data specific to LoginWindow
571 * for use with IOPMrootDomain. Only 4 bits of data are allotted.
573 #define kIOPMLoginWindowProgressKey "LoginWindowProgress"
576 * kIOPMCoreDisplayProgressKey - identifies PM debug data specific to CoreDisplay
577 * for use with IOPMrootDomain. Only 8 bits of data are allotted.
579 #define kIOPMCoreDisplayProgressKey "CoreDisplayProgress"
582 * kIOPMCoreGraphicsProgressKey - identifies PM debug data specific to CoreGraphics
583 * for use with IOPMrootDomain. Only 8 bits of data are allotted.
585 #define kIOPMCoreGraphicsProgressKey "CoreGraphicsProgress"
587 // For PM internal use only - key to locate sleep failure results within SCDynamicStore.
588 #define kIOPMDynamicStoreSleepFailureKey "SleepFailure"
590 /*****************************************************************************/
592 // For IOPMLibPrivate.h
593 #define kIOPMSleepWakeFailureKey "PMFailurePhase"
594 #define kIOPMSleepWakeFailureCodeKey "PMStatusCode"
595 #define kIOPMSleepWakeFailureLoginKey "LWFailurePhase"
596 #define kIOPMSleepWakeFailureUUIDKey "UUID"
597 #define kIOPMSleepWakeFailureDateKey "Date"
598 #define kIOPMSleepWakeWdogRebootKey "SWWdogTriggeredRestart"
599 #define kIOPMSleepWakeWdogLogsValidKey "SWWdogLogsValid"
601 /*****************************************************************************
603 * Root Domain private property keys
605 *****************************************************************************/
607 /* kIOPMFeatureAutoPowerOffKey
608 * Feature published if Auto Power Off is supported
610 #define kIOPMFeatureAutoPowerOffKey "AutoPowerOff"
612 /* kIOPMAutoPowerOffEnabledKey
613 * Indicates if Auto Power Off is enabled.
614 * It has a boolean value.
615 * true == Auto Power Off is enabled
616 * false == Auto Power Off is disabled
617 * not present == Auto Power Off is not supported on this hardware
619 #define kIOPMAutoPowerOffEnabledKey "AutoPowerOff Enabled"
621 /* kIOPMAutoPowerOffDelayKey
622 * Key refers to a CFNumberRef that represents the delay in seconds before
623 * entering the Auto Power Off state. The property is not present if Auto
624 * Power Off is unsupported.
626 #define kIOPMAutoPowerOffDelayKey "AutoPowerOff Delay"
628 /* kIOPMAutoPowerOffTimerKey
629 * Key refers to a CFNumberRef that indicates the time in seconds until the
630 * expiration of the Auto Power Off delay period. This value should be used
631 * to program a wake alarm before system sleep.
633 #define kIOPMAutoPowerOffTimerKey "AutoPowerOff Timer"
635 /* kIOPMDeepSleepTimerKey
636 * Key refers to a CFNumberRef that indicates the time in seconds until the
637 * expiration of the Standby delay period. This value should be used
638 * to program a wake alarm before system sleep.
640 #define kIOPMDeepSleepTimerKey "Standby Timer"
642 /* kIOPMUserWakeAlarmScheduledKey
643 * Key refers to a boolean value that indicates if an user alarm was scheduled
646 #define kIOPMUserWakeAlarmScheduledKey "UserWakeAlarmScheduled"
648 /* kIOPMDeepIdleSupportedKey
649 * Presence of this key indicates Deep Idle is supported on this platform.
650 * Key will always refer to a value of kOSBooleanTrue.
652 #define kIOPMDeepIdleSupportedKey "IOPMDeepIdleSupported"
654 /* kIOPMUserTriggeredFullWakeKey
655 * Key refers to a boolean value that indicates if the first full wake since
656 * last system sleep was triggered by the local user. This property is set
657 * before the initial full wake transition, and removed after powering down
658 * drivers for system sleep.
660 #define kIOPMUserTriggeredFullWakeKey "IOPMUserTriggeredFullWake"
662 /* kIOPMUserIsActiveKey
663 * Key refers to a boolean value that indicates if the user is active.
665 #define kIOPMUserIsActiveKey "IOPMUserIsActive"
667 /* kIOPMDriverWakeEventsKey
668 * Key refers to a property that should only be examined by powerd.
670 #define kIOPMDriverWakeEventsKey "IOPMDriverWakeEvents"
672 /*****************************************************************************
674 * IOPMDriverWakeEvents dictionary keys
676 *****************************************************************************/
678 #define kIOPMWakeEventTimeKey "Time"
679 #define kIOPMWakeEventFlagsKey "Flags"
680 #define kIOPMWakeEventReasonKey "Reason"
681 #define kIOPMWakeEventDetailsKey "Details"
683 /* kIOPMFeatureProModeKey
684 * Feature published if ProMode is supported
686 #define kIOPMFeatureProModeKey "ProMode"
688 /*****************************************************************************
690 * Wake event flags reported to IOPMrootDomain::claimSystemWakeEvent()
692 *****************************************************************************/
694 #define kIOPMWakeEventSource 0x00000001
696 #if !(defined(RC_HIDE_N144) || defined(RC_HIDE_N146))
697 /*****************************************************************************
701 *****************************************************************************/
703 // signals the device should wake up to user space running
704 #define kIOPMWakeEventAOTExit 0x00000002
706 // will start a 400 ms timer before sleeping
707 #define kIOPMWakeEventAOTPossibleExit 0x00000004
709 // signals the device should wake up to user space running
710 #define kIOPMWakeEventAOTConfirmedPossibleExit 0x00000008
712 // signals the device should go back to AOT
713 #define kIOPMWakeEventAOTRejectedPossibleExit 0x00000010
715 // signals the device should go back to AOT
716 #define kIOPMWakeEventAOTExpiredPossibleExit 0x00000020
718 #define kIOPMWakeEventAOTFlags \
719 (kIOPMWakeEventAOTExit \
720 | kIOPMWakeEventAOTPossibleExit \
721 | kIOPMWakeEventAOTConfirmedPossibleExit \
722 | kIOPMWakeEventAOTRejectedPossibleExit \
723 | kIOPMWakeEventAOTExpiredPossibleExit)
725 #define kIOPMWakeEventAOTPossibleFlags \
726 (kIOPMWakeEventAOTPossibleExit \
727 | kIOPMWakeEventAOTConfirmedPossibleExit \
728 | kIOPMWakeEventAOTRejectedPossibleExit \
729 | kIOPMWakeEventAOTExpiredPossibleExit)
731 #define kIOPMWakeEventAOTPerCycleFlags \
732 (kIOPMWakeEventAOTPossibleExit \
733 | kIOPMWakeEventAOTRejectedPossibleExit \
734 | kIOPMWakeEventAOTExpiredPossibleExit)
736 #define kIOPMWakeEventAOTExitFlags \
737 (kIOPMWakeEventAOTExit \
738 | kIOPMWakeEventAOTConfirmedPossibleExit)
741 kIOPMAOTModeEnable
= 0x00000001,
742 kIOPMAOTModeCycle
= 0x00000002,
743 kIOPMAOTModeAddEventFlags
= 0x00000004,
744 kIOPMAOTModeRespectTimers
= 0x00000008,
745 kIOPMAOTModeDefault
= (kIOPMAOTModeEnable
| kIOPMAOTModeAddEventFlags
| kIOPMAOTModeRespectTimers
)
749 kIOPMAOTMetricsKernelWakeCountMax
= 24
752 struct IOPMAOTMetrics
755 uint32_t possibleCount
;
756 uint32_t confirmedPossibleCount
;
757 uint32_t rejectedPossibleCount
;
758 uint32_t expiredPossibleCount
;
759 uint32_t noTimeSetCount
;
760 uint32_t rtcAlarmsCount
;
761 uint32_t softwareRequestCount
;
764 char kernelWakeReason
[kIOPMAOTMetricsKernelWakeCountMax
][64];
765 // 54:10 secs:ms calendar time
766 uint64_t kernelSleepTime
[kIOPMAOTMetricsKernelWakeCountMax
];
767 uint64_t kernelWakeTime
[kIOPMAOTMetricsKernelWakeCountMax
];
770 #define kIOPMAOTPowerKey "aot-power"
772 #endif /* !(defined(RC_HIDE_N144) || defined(RC_HIDE_N146)) */
774 /*****************************************************************************
776 * System Sleep Policy
778 *****************************************************************************/
780 #define kIOPMSystemSleepPolicySignature 0x54504c53
781 #define kIOPMSystemSleepPolicyVersion 2
784 * @defined kIOPMSystemSleepTypeKey
785 * @abstract Indicates the type of system sleep.
786 * @discussion An OSNumber property of root domain that describes the type
787 * of system sleep. This property is set after notifying priority sleep/wake
788 * clients, but before informing interested drivers and shutting down power
789 * plane drivers. On a hibernate abort or failure, this property will not be
790 * updated and will indicate the failed sleep type.
792 #define kIOPMSystemSleepTypeKey "IOPMSystemSleepType"
794 struct IOPMSystemSleepPolicyVariables
796 uint32_t signature
; // kIOPMSystemSleepPolicySignature
797 uint32_t version
; // kIOPMSystemSleepPolicyVersion
799 uint64_t currentCapability
; // current system capability bits
800 uint64_t highestCapability
; // highest system capability bits
802 uint64_t sleepFactors
; // sleep factor bits
803 uint32_t sleepReason
; // kIOPMSleepReason*
804 uint32_t sleepPhase
; // identify the sleep phase
805 uint32_t hibernateMode
; // current hibernate mode
807 uint32_t standbyDelay
; // standby delay in seconds
808 uint32_t standbyTimer
; // standby timer in seconds
809 uint32_t poweroffDelay
; // auto-poweroff delay in seconds
810 uint32_t scheduledAlarms
; // bitmask of scheduled alarm types
811 uint32_t poweroffTimer
; // auto-poweroff timer in seconds
813 uint32_t reserved
[49]; // pad sizeof 256 bytes
817 kIOPMAlarmBitDebugWake
= 0x01,
818 kIOPMAlarmBitCalendarWake
= 0x02,
819 kIOPMAlarmBitMaintenanceWake
= 0x04,
820 kIOPMAlarmBitSleepServiceWake
= 0x08
824 kIOPMSleepPhase0
= 0,
829 // Sleep Factor Mask / Bits
831 kIOPMSleepFactorSleepTimerWake
= 0x00000001ULL
,
832 kIOPMSleepFactorLidOpen
= 0x00000002ULL
,
833 kIOPMSleepFactorACPower
= 0x00000004ULL
,
834 kIOPMSleepFactorBatteryLow
= 0x00000008ULL
,
835 kIOPMSleepFactorStandbyNoDelay
= 0x00000010ULL
,
836 kIOPMSleepFactorStandbyForced
= 0x00000020ULL
,
837 kIOPMSleepFactorStandbyDisabled
= 0x00000040ULL
,
838 kIOPMSleepFactorUSBExternalDevice
= 0x00000080ULL
,
839 kIOPMSleepFactorBluetoothHIDDevice
= 0x00000100ULL
,
840 kIOPMSleepFactorExternalMediaMounted
= 0x00000200ULL
,
841 kIOPMSleepFactorThunderboltDevice
= 0x00000400ULL
,
842 kIOPMSleepFactorRTCAlarmScheduled
= 0x00000800ULL
,
843 kIOPMSleepFactorMagicPacketWakeEnabled
= 0x00001000ULL
,
844 kIOPMSleepFactorHibernateForced
= 0x00010000ULL
,
845 kIOPMSleepFactorAutoPowerOffDisabled
= 0x00020000ULL
,
846 kIOPMSleepFactorAutoPowerOffForced
= 0x00040000ULL
,
847 kIOPMSleepFactorExternalDisplay
= 0x00080000ULL
,
848 kIOPMSleepFactorNetworkKeepAliveActive
= 0x00100000ULL
,
849 kIOPMSleepFactorLocalUserActivity
= 0x00200000ULL
,
850 kIOPMSleepFactorHibernateFailed
= 0x00400000ULL
,
851 kIOPMSleepFactorThermalWarning
= 0x00800000ULL
,
852 kIOPMSleepFactorDisplayCaptured
= 0x01000000ULL
855 // System Sleep Types
857 kIOPMSleepTypeInvalid
= 0,
858 kIOPMSleepTypeAbortedSleep
= 1,
859 kIOPMSleepTypeNormalSleep
= 2,
860 kIOPMSleepTypeSafeSleep
= 3,
861 kIOPMSleepTypeHibernate
= 4,
862 kIOPMSleepTypeStandby
= 5,
863 kIOPMSleepTypePowerOff
= 6,
864 kIOPMSleepTypeDeepIdle
= 7,
865 kIOPMSleepTypeLast
= 8
868 // System Sleep Flags
870 kIOPMSleepFlagDisableHibernateAbort
= 0x00000001,
871 kIOPMSleepFlagDisableUSBWakeEvents
= 0x00000002,
872 kIOPMSleepFlagDisableBatlowAssertion
= 0x00000004,
873 kIOPMSleepFlagDisableS4WakeSources
= 0x00000008
876 // System Wake Events
878 kIOPMWakeEventLidOpen
= 0x00000001,
879 kIOPMWakeEventLidClose
= 0x00000002,
880 kIOPMWakeEventACAttach
= 0x00000004,
881 kIOPMWakeEventACDetach
= 0x00000008,
882 kIOPMWakeEventCDInsert
= 0x00000010,
883 kIOPMWakeEventCDEject
= 0x00000020,
884 kIOPMWakeEventHPDAttach
= 0x00000040,
885 kIOPMWakeEventHPDDetach
= 0x00000080,
886 kIOPMWakeEventPowerButton
= 0x00000100,
887 kIOPMWakeEventG3PowerOn
= 0x00000200,
888 kIOPMWakeEventUserPME
= 0x00000400,
889 kIOPMWakeEventSleepTimer
= 0x00000800,
890 kIOPMWakeEventBatteryLow
= 0x00001000,
891 kIOPMWakeEventDarkPME
= 0x00002000,
892 kIOPMWakeEventWifi
= 0x00004000,
893 kIOPMWakeEventRTCSystem
= 0x00008000, // Maintenance RTC wake
894 kIOPMWakeEventUSBCPlugin
= 0x00010000, // USB-C Plugin
895 kIOPMWakeEventHID
= 0x00020000,
896 kIOPMWakeEventBluetooth
= 0x00040000,
897 kIOPMWakeEventDFR
= 0x00080000,
898 kIOPMWakeEventSD
= 0x00100000, // SD card
899 kIOPMWakeEventLANWake
= 0x00200000, // Wake on Lan
900 kIOPMWakeEventLANPlugin
= 0x00400000, // Ethernet media sense
901 kIOPMWakeEventThunderbolt
= 0x00800000,
902 kIOPMWakeEventRTCUser
= 0x01000000, // User requested RTC wake
906 * @defined kIOPMSystemSleepParametersKey
907 * @abstract Sleep parameters describing the upcoming sleep
908 * @discussion Root domain updates this OSData property before system sleep
909 * to pass sleep parameters to the platform driver. Some of the parameters
910 * are based on the chosen entry in the system sleep policy table.
912 #define kIOPMSystemSleepParametersKey "IOPMSystemSleepParameters"
913 #define kIOPMSystemSleepParametersVersion 2
915 struct IOPMSystemSleepParameters
921 uint32_t ecWakeEvents
;
922 uint32_t ecWakeTimer
;
923 uint32_t ecPoweroffTimer
;
924 uint32_t reserved2
[10];
925 } __attribute__((packed
));
929 * Sleep Wake debug buffer header
934 uint32_t crc
; /* CRC for spindump & following data.*/
935 uint32_t spindump_offset
; /* Offset at which spindump offset is stored */
936 uint32_t spindump_size
;
937 uint8_t is_osx_watchdog
;
939 /* All members from UUID onwards are saved into log file */
941 char spindump_status
[24]; /* stackshot status*/
942 char PMStatusCode
[32];
947 #define SWD_HDR_SIGNATURE 0xdeb8da2a
949 #define SWD_STACKSHOT_SIZE (40*PAGE_SIZE)
950 #define SWD_COMPRESSED_BUFSIZE (5*PAGE_SIZE)
951 #define SWD_ZLIB_BUFSIZE (10*PAGE_SIZE)
952 #define SWD_STACKSHOT_VAR_PREFIX "sleepwake_diags"
954 #define SWD_SPINDUMP_SIZE (256*1024)
955 #define SWD_INITIAL_SPINDUMP_SIZE ((SWD_SPINDUMP_SIZE/2)-sizeof(swd_hdr))
956 #define SWD_MAX_STACKSHOTS (10)
958 /* Bits in swd_flags */
959 #define SWD_WDOG_ENABLED 0x01
960 #define SWD_BOOT_BY_SW_WDOG 0x02
961 #define SWD_BOOT_BY_OSX_WDOG 0x04
962 #define SWD_VALID_LOGS 0x08
963 #define SWD_LOGS_IN_FILE 0x10
964 #define SWD_LOGS_IN_MEM 0x20
965 #define SWD_PWR_BTN_STACKSHOT 0x30
967 #define SWD_DATA_CRC_ERROR 0x010000
968 #define SWD_BUF_SIZE_ERROR 0x020000
969 #define SWD_HDR_SIZE_ERROR 0x040000
970 #define SWD_FILEOP_ERROR 0x080000
971 #define SWD_HDR_SIGNATURE_ERROR 0x100000
972 #define SWD_INTERNAL_FAILURE 0x200000
975 /* Filenames associated with the stackshots/logs generated by the SWD */
976 #define kOSWatchdogStacksFilename "/var/log/OSXWatchdogStacks.gz"
977 #define kOSWatchdogFailureStringFile "/var/log/OSWatchdogFailureString.txt"
978 #define kSleepWakeStacksFilename "/var/log/SleepWakeStacks.gz"
979 #define kSleepWakeFailureStringFile "/var/log/SleepWakeFailureString.txt"
982 /* RootDomain IOReporting channels */
983 #define kSleepCntChID IOREPORT_MAKEID('S','l','e','e','p','C','n','t')
984 #define kDarkWkCntChID IOREPORT_MAKEID('G','U','I','W','k','C','n','t')
985 #define kUserWkCntChID IOREPORT_MAKEID('D','r','k','W','k','C','n','t')
988 * kAssertDelayChID - Histogram of time elapsed before assertion after wake.
990 #define kAssertDelayBcktCnt 11
991 #define kAssertDelayBcktSize 3
992 #define kAssertDelayChID IOREPORT_MAKEID('r','d','A','s','r','t','D','l')
995 * kSleepDelaysChID - Histogram of time taken to put system to sleep
997 #define kSleepDelaysBcktCnt 13
998 #define kSleepDelaysBcktSize 10
999 #define kSleepDelaysChID IOREPORT_MAKEID('r','d','S','l','p','D','l','y')
1001 /* Sleep Options/settings */
1002 #define kSleepOptionDisplayCapturedModeKey "DisplayCapturedMode"
1005 #if defined(KERNEL) && defined(__cplusplus)
1008 * @defined kIOPMInstallSystemSleepPolicyHandlerKey
1009 * @abstract Name of the platform function to install a sleep policy handler.
1010 * @discussion Pass to IOPMrootDomain::callPlatformFunction(), with a pointer
1011 * to the C-function handler at param1, and an optional target at param2, to
1012 * register a sleep policy handler. Only a single sleep policy handler can
1015 #define kIOPMInstallSystemSleepPolicyHandlerKey \
1016 "IOPMInstallSystemSleepPolicyHandler"
1018 typedef IOReturn (*IOPMSystemSleepPolicyHandler
)(
1020 const IOPMSystemSleepPolicyVariables
* vars
,
1021 IOPMSystemSleepParameters
* params
);
1025 /*****************************************************************************
1027 * Performance Warning
1029 *****************************************************************************/
1031 /* Performance Warning Key
1032 * Key for performance warning event published using IOPMrootDomain::
1033 * systemPowerEventOccurred()
1035 #define kIOPMPerformanceWarningKey "Performance_Warning"
1037 /* Performance warning values */
1039 kIOPMPerformanceNormal
= 0,
1040 kIOPMPerformanceWarning
= 100
1043 #endif /* ! _IOKIT_IOPMPRIVATE_H */