2 * Copyright (c) 2002-2020 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 #define kIOPMMessageRequestUserActive \
113 iokit_family_msg(sub_iokit_powermanagement, 0x460)
115 #define kIOPMMessageRequestSystemShutdown \
116 iokit_family_msg(sub_iokit_powermanagement, 0x470)
118 /* @enum SystemSleepReasons
119 * @abstract The potential causes for system sleep as logged in the system event record.
122 kIOPMSleepReasonClamshell
= 101,
123 kIOPMSleepReasonPowerButton
= 102,
124 kIOPMSleepReasonSoftware
= 103,
125 kIOPMSleepReasonOSSwitchHibernate
= 104,
126 kIOPMSleepReasonIdle
= 105,
127 kIOPMSleepReasonLowPower
= 106,
128 kIOPMSleepReasonThermalEmergency
= 107,
129 kIOPMSleepReasonMaintenance
= 108,
130 kIOPMSleepReasonSleepServiceExit
= 109,
131 kIOPMSleepReasonDarkWakeThermalEmergency
= 110,
132 kIOPMSleepReasonNotificationWakeExit
= 111
136 * Possible C-string sleep reasons found under kRootDomainSleepReasonsKey
138 #define kIOPMClamshellSleepKey "Clamshell Sleep"
139 #define kIOPMPowerButtonSleepKey "Power Button Sleep"
140 #define kIOPMSoftwareSleepKey "Software Sleep"
141 #define kIOPMOSSwitchHibernationKey "OS Switch Sleep"
142 #define kIOPMIdleSleepKey "Idle Sleep"
143 #define kIOPMLowPowerSleepKey "Low Power Sleep"
144 #define kIOPMThermalEmergencySleepKey "Thermal Emergency Sleep"
145 #define kIOPMSleepServiceExitKey "Sleep Service Back to Sleep"
146 #define kIOPMDarkWakeThermalEmergencyKey "Dark Wake Thermal Emergency"
147 #define kIOPMNotificationWakeExitKey "Notification Wake Back to Sleep"
149 /*! kIOPMPSRestrictedModeKey
150 * An IOPMPowerSource property key
151 * Its property has an integer value.
152 * - value = 1 when the device is in a low power state and not fully functional.
153 * - value = 0, or property missing altogether, when the device is
154 * not in a restricted mode power state.
156 #define kIOPMPSRestrictedModeKey "RestrictedMode"
158 // Private keys for kIOPMPSAdapterDetailsKey dictionary
159 #define kIOPMPSAdapterDetailsIsWirelessKey "IsWireless"
161 #pragma mark Stray Bitfields
162 // Private power commands issued to root domain
163 // bits 0-7 in IOPM.h
166 kIOPMSetValue
= (1<<16),
167 // don't sleep on clamshell closure on a portable with AC connected
168 kIOPMSetDesktopMode
= (1<<17),
169 // set state of AC adaptor connected
170 kIOPMSetACAdaptorConnected
= (1<<18)
173 /*****************************************************************************/
174 /*****************************************************************************/
177 * PM notification types
180 /*! @constant kIOPMSleepServiceScheduleImmediate
182 * Setting type used in calls to IOPMrootDomain::registerPMSettingController
183 * Use this type between powerd and IOKit.framework
186 #define kIOPMSleepServiceScheduleImmediate "SleepServiceImmediate"
188 /*! @constant kIOPMSettingSleepServiceScheduleImmediate
190 * Setting type used in calls to IOPMrootDomain::registerPMSettingController
191 * Use this type between xnu and AppleRTC
193 #define kIOPMSettingSleepServiceWakeCalendarKey "SleepServiceWakeCalendarKey"
195 /*! @constant kIOPMCalendarWakeTypes
197 * These are valid values for IOPM.h:IOPMCalendarStruct->selector
200 kPMCalendarTypeInvalid
= 0,
201 kPMCalendarTypeMaintenance
= 1,
202 kPMCalendarTypeSleepService
= 2
206 /* @constant kIOPMStateConsoleShutdown
207 * @abstract Notification of GUI shutdown state available to kexts.
208 * @discussion This type can be passed as arguments to registerPMSettingController()
209 * to receive callbacks.
211 #define kIOPMStateConsoleShutdown "ConsoleShutdown"
213 /* @enum ShutdownValues
214 * @abstract Potential values shared with key kIOPMStateConsoleShutdown
217 /* @constant kIOPMStateConsoleShutdownNone
218 * @abstract System shutdown (or restart) hasn't started; system is ON.
219 * @discussion Next state: 2
221 kIOPMStateConsoleShutdownNone
= 1,
222 /* @constant kIOPMStateConsoleShutdownPossible
223 * @abstract User has been presented with the option to shutdown or restart. Shutdown may be cancelled.
224 * @discussion Next state may be: 1, 4
226 kIOPMStateConsoleShutdownPossible
= 2,
227 /* @constant kIOPMStateConsoleShutdownUnderway
228 * @abstract Shutdown or restart is proceeding. It may still be cancelled.
229 * @discussion Next state may be: 1, 4. This state is currently unused.
231 kIOPMStateConsoleShutdownUnderway
= 3,
232 /* @constant kIOPMStateConsoleShutdownCertain
233 * @abstract Shutdown is in progress and irrevocable.
234 * @discussion State remains 4 until power is removed from CPU.
236 kIOPMStateConsoleShutdownCertain
= 4,
237 /* @constant kIOPMStateConsoleSULogoutInitiated
238 Indicates that LoginWindow has initiated a software update restart.
239 The next logout will not immediately lead to a shutdown.
241 kIOPMStateConsoleSULogoutInitiated
= 5
244 /* @constant kIOPMSettingSilentRunningKey
245 * @abstract Notification of silent running mode changes to kexts.
246 * @discussion This key can be passed as an argument to registerPMSettingController()
247 * and also identifies the type of PMSetting notification callback.
249 #define kIOPMSettingSilentRunningKey "SilentRunning"
250 #define kIOPMFeatureSilentRunningKey kIOPMSettingSilentRunningKey
252 /* @enum SilentRunningFlags
253 * @abstract The kIOPMSettingSilentRunningKey notification provides an OSNumber
254 * object with a value described by the following flags.
257 kIOPMSilentRunningModeOn
= 0x00000001
260 /* @constant kIOPMSettingLowLatencyAudioModeKey
261 * @abstract Notification about low latency activity in the system available to kexts.
262 * @discussion This type can be passed as arguments to registerPMSettingController()
263 * to receive callbacks.
265 #define kIOPMSettingLowLatencyAudioModeKey "LowLatencyAudioMode"
267 /*****************************************************************************/
268 /*****************************************************************************/
270 /* PM Statistics - event indices
271 * These are arguments to IOPMrootDomain::pmStatsRecordEvent().
274 kIOPMStatsHibernateImageWrite
= 1,
275 kIOPMStatsHibernateImageRead
,
276 kIOPMStatsDriversNotify
,
277 kIOPMStatsApplicationNotify
,
278 kIOPMStatsLateDriverAcknowledge
,
279 kIOPMStatsLateAppAcknowledge
,
281 // To designate if you're specifying the start or stop end of
282 // each of the above events, do a bitwise OR of the appropriate
283 // Start/Stop flag and pass the result to IOPMrootDomain to record
285 kIOPMStatsEventStartFlag
= (1 << 24),
286 kIOPMStatsEventStopFlag
= (1 << 25)
289 // Keys for IOPMrootDomain registry properties
290 #define kIOPMSleepStatisticsKey "SleepStatistics"
291 #define kIOPMSleepStatisticsAppsKey "AppStatistics"
292 #define kIOPMIdleSleepPreventersKey "IdleSleepPreventers"
293 #define kIOPMSystemSleepPreventersKey "SystemSleepPreventers"
294 #define kIOPMIdleSleepPreventersWithIDKey "IdleSleepPreventersWithID"
295 #define kIOPMSystemSleepPreventersWithIDKey "SystemSleepPreventersWithID"
297 // Application response statistics
298 #define kIOPMStatsNameKey "Name"
299 #define kIOPMStatsPIDKey "Pid"
300 #define kIOPMStatsTimeMSKey "TimeMS"
301 #define kIOPMStatsApplicationResponseTypeKey "ResponseType"
302 #define kIOPMStatsMessageTypeKey "MessageType"
303 #define kIOPMStatsPowerCapabilityKey "PowerCaps"
304 #define kIOPMStatsSystemTransitionKey "TransitionType"
306 // PM Statistics: potential values for the key kIOPMStatsApplicationResponseTypeKey
307 // entry in the application results array.
308 #define kIOPMStatsResponseTimedOut "ResponseTimedOut"
309 #define kIOPMStatsResponseCancel "ResponseCancel"
310 #define kIOPMStatsResponseSlow "ResponseSlow"
311 #define kIOPMStatsResponsePrompt "ResponsePrompt"
312 #define kIOPMStatsDriverPSChangeSlow "DriverPSChangeSlow"
314 struct PMStatsBounds
{
320 struct PMStatsBounds hibWrite
;
321 struct PMStatsBounds hibRead
;
322 // bounds driverNotifySleep;
323 // bounds driverNotifyWake;
324 // bounds appNotifySleep;
325 // bounds appNotifyWake;
326 // OSDictionary *tardyApps;
327 // OSDictionary *tardyDrivers;
330 /*****************************************************************************/
332 /* PM RootDomain tracePoints
334 * In the sleep/wake process, we expect the sleep trace points to proceed
335 * in increasing order. Once sleep begins with code kIOPMTracePointSleepStarted,
336 * we expect sleep to continue in a monotonically increasing order of tracepoints
337 * to kIOPMTracePointSystemLoginwindowPhase. After trace point SystemLoginWindowPhase,
338 * the system will return to kIOPMTracePointSystemUp.
340 * If the trace point decreases (instead of increasing) before reaching kIOPMTracePointSystemUp,
341 * that indicates that the sleep process was cancelled. The cancel reason shall be indicated
342 * in the cancel tracepoint. (TBD)
346 /* When kTracePointSystemUp is the latest tracePoint,
347 * the system is awake. It is not asleep, sleeping, or waking.
349 * Phase begins: At boot, at completion of wake from sleep,
350 * immediately following kIOPMTracePointSystemLoginwindowPhase.
351 * Phase ends: When a sleep attempt is initiated.
353 kIOPMTracePointSystemUp
= 0,
355 /* When kIOPMTracePointSleepStarted is the latest tracePoint,
356 * sleep has been initiated.
358 * Phase begins: At initiation of system sleep (idle or forced).
359 * Phase ends: PM starts to notify applications of system sleep.
361 kIOPMTracePointSleepStarted
= 0x10,
363 /* When kIOPMTracePointSleepApplications is the latest tracePoint,
364 * a system sleep has been initiated and PM waits for responses
365 * from notified applications.
367 * Phase begins: Begin to asynchronously fire kIOMessageSystemWillSleep
368 * notifications, and also kIOMessageCanSystemSleep for the idle sleep case.
369 * Phase ends: When PM has received all application responses.
371 kIOPMTracePointSleepApplications
= 0x11,
373 /* When kIOPMTracePointSleepPriorityClients is the latest tracePoint,
374 * PM is notifying priority clients and in-kernel system capability
375 * clients, and waiting for any asynchronous completions.
377 * Phase begins: Synchronous delivery of kIOMessageSystemWillSleep notifications.
378 * Phase ends: All notified clients have acknowledged.
380 kIOPMTracePointSleepPriorityClients
= 0x12,
382 /* When kIOPMTracePointSleepWillChangeInterests is the latest tracePoint,
383 * PM is calling powerStateWillChangeTo() on interested drivers of root domain.
385 * Phase begins: Dispatch a callout thread to call interested drivers.
386 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
387 * by drivers that indicated asynchronous completion.
389 kIOPMTracePointSleepWillChangeInterests
= 0x13,
391 /* When kIOPMTracePointSleepPowerPlaneDrivers is the latest tracePoint,
392 * PM is directing power plane drivers to power off in leaf-to-root order.
394 * Phase begins: Root domain informs its power children that it will drop to
395 * sleep state. This has a cascade effect and triggers all drivers in
396 * the power plane to transition to a lower power state if necessary.
397 * Phase ends: All power transitions in response to the root domain power
398 * change have completed.
400 kIOPMTracePointSleepPowerPlaneDrivers
= 0x14,
402 /* When kIOPMTracePointSleepDidChangeInterests is the latest tracePoint,
403 * PM is calling powerStateDidChangeTo() on interested drivers of root domain.
405 * Phase begins: Dispatch a callout thread to call interested drivers.
406 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
407 * by drivers that indicated asynchronous completion.
409 kIOPMTracePointSleepDidChangeInterests
= 0x15,
411 /* When kIOPMTracePointSleepCapabilityClients is the latest tracePoint,
412 * PM is notifying system capability clients about system sleep.
414 * Phase begins: Send kIOMessageSystemCapabilityChange notifications to inform
415 * capability clients that system has lost all capabilities.
416 * Phase ends: Finished sending notifications.
418 kIOPMTracePointSleepCapabilityClients
= 0x16,
420 /* When kIOPMTracePointSleepPlatformActions is the latest tracePoint,
421 * PM is calling drivers that have registered a platform sleep action.
423 kIOPMTracePointSleepPlatformActions
= 0x17,
425 /* When kIOPMTracePointSleepCPUs is the latest tracePoint,
426 * PM is shutting down all non-boot processors.
428 * Phase begins: Shutdown all non-boot processors.
429 * Phase ends: Reduced to only the boot processor running.
431 kIOPMTracePointSleepCPUs
= 0x18,
433 /* When kIOPMTracePointSleepPlatformDriver is the latest tracePoint,
434 * PM is executing platform dependent code to prepare for system sleep.
436 kIOPMTracePointSleepPlatformDriver
= 0x19,
438 /* When kIOPMTracePointHibernate is the latest tracePoint,
439 * PM is writing the hibernate image to disk.
441 kIOPMTracePointHibernate
= 0x1a,
443 /* When kIOPMTracePointSystemSleep is the latest tracePoint,
444 * PM has recorded the final trace point before the hardware platform
445 * enters sleep state, or low level wakeup is underway - such as restoring
446 * the hibernate image from disk.
448 * Note: If a system is asleep and then loses power, and it does not have a
449 * hibernate image to restore from (e.g. hibernatemode = 0), then OS X will
450 * interpret this power loss as a failure in kIOPMTracePointSystemSleep.
452 * Phase begins: Before the OS directs the hardware to enter sleep state.
453 * Phase ends: Control returns to the OS on wake, but before recording the first
456 kIOPMTracePointSystemSleep
= 0x1f,
458 /* When kIOPMTracePointWakePlatformDriver is the latest tracePoint,
459 * PM is executing platform dependent code to prepare for system wake.
461 kIOPMTracePointWakePlatformDriver
= 0x21,
463 /* When kIOPMTracePointWakePlatformActions is the latest tracePoint,
464 * PM is calling drivers that have registered a platform wake action.
466 kIOPMTracePointWakePlatformActions
= 0x22,
468 /* When kIOPMTracePointWakeCPUs is the latest tracePoint,
469 * PM is bringing all non-boot processors online.
471 kIOPMTracePointWakeCPUs
= 0x23,
473 /* When kIOPMTracePointWakeWillPowerOnClients is the latest tracePoint,
474 * PM is sending kIOMessageSystemWillPowerOn to both kernel clients and
475 * applications. PM also notifies system capability clients about the
476 * proposed capability change.
478 * Phase begins: Send kIOMessageSystemWillPowerOn and
479 * kIOMessageSystemCapabilityChange notifications.
480 * Phase ends: Finished sending notifications.
482 kIOPMTracePointWakeWillPowerOnClients
= 0x24,
484 /* When kIOPMTracePointWakeWillChangeInterests is the latest tracePoint,
485 * PM is calling powerStateWillChangeTo() on interested drivers of root domain.
487 * Phase begins: Dispatch a callout thread to call interested drivers.
488 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
489 * by drivers that indicated asynchronous completion.
491 kIOPMTracePointWakeWillChangeInterests
= 0x25,
493 /* When kIOPMTracePointWakeDidChangeInterests is the latest tracePoint,
494 * PM is calling powerStateDidChangeTo() on interested drivers of root domain.
496 * Phase begins: Dispatch a callout thread to call interested drivers.
497 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
498 * by drivers that indicated asynchronous completion.
500 kIOPMTracePointWakeDidChangeInterests
= 0x26,
502 /* When kIOPMTracePointWakePowerPlaneDrivers is the latest tracePoint,
503 * PM is directing power plane drivers to power up in root-to-leaf order.
505 * Phase begins: Root domain informs its power children that it transitioned
506 * to ON state. This has a cascade effect and triggers all drivers in
507 * the power plane to re-evaluate and potentially change power state.
508 * Phase ends: All power transitions in response to the root domain power
509 * change have completed.
511 kIOPMTracePointWakePowerPlaneDrivers
= 0x27,
513 /* When kIOPMTracePointWakeCapabilityClients is the latest tracePoint,
514 * PM is notifying system capability clients about system wake, and waiting
515 * for any asynchronous completions.
517 * Phase begins: Inform capability clients that system has gained capabilities.
518 * Phase ends: All notified clients have acknowledged.
520 kIOPMTracePointWakeCapabilityClients
= 0x28,
522 /* When kIOPMTracePointWakeApplications is the latest tracePoint,
523 * System CPU is powered, PM has powered on each driver.
525 * Phase begins: Send asynchronous kIOMessageSystemHasPoweredOn notifications.
526 * Phase ends: Finished sending asynchronous notifications.
528 kIOPMTracePointWakeApplications
= 0x29,
530 /* kIOPMTracePointSystemLoginwindowPhase
531 * This phase represents a several minute window after the system has powered on.
532 * Higher levels of system diagnostics are in a heightened state of alert in this phase,
533 * in case any user errors occurred that we could not detect in software.
535 * Phase begins: After IOPMrootDomain sends kIOMessageSystemHasPoweredOn message.
536 * Phase ends: When loginwindow calls IOPMSleepWakeSetUUID(NULL) the system shall
537 * be considered awake and usable. The next phase shall be kIOPMTracePointSystemUp.
539 kIOPMTracePointSystemLoginwindowPhase
= 0x30,
541 /* When kIOPMTracePointDarkWakeEntry is the latest tracePoint,
542 * PM has started a transition from full wake to dark wake.
544 * Phase begins: Start transition to dark wake.
545 * Phase ends: System in dark wake. Before recording kIOPMTracePointSystemUp.
547 kIOPMTracePointDarkWakeEntry
= 0x31,
549 /* When kIOPMTracePointDarkWakeExit is the latest tracePoint,
550 * PM has started a transition from dark wake to full wake.
552 * Phase begins: Start transition to full wake.
553 * Phase ends: System in full wake. Before recording kIOPMTracePointSystemUp.
555 kIOPMTracePointDarkWakeExit
= 0x32
558 /*****************************************************************************/
561 * Component wake progress keys
563 * Certain components have the ability to log their wake progress with
564 * root domain using the keys provided below.
566 * LoginWindow - 4 bits
567 * CoreDisplay - 8 bits
568 * CoreGraphics - 8 bits
570 * These bits are stored with the trace phase that gets logged to
574 // Values that should be passed in to IOPMLogWakeProgress
576 kIOPMLoginWindowProgress
= 1,
577 kIOPMCoreDisplayProgress
= 2,
578 kIOPMCoreGraphicsProgress
= 3
582 kIOPMLoginWindowProgressMask
= 0x0f,
583 kIOPMCoreDisplayProgressMask
= 0xff,
584 kIOPMCoreGraphicsProgressMask
= 0xff
588 * kIOPMLoginWindowProgressKey - identifies PM debug data specific to LoginWindow
589 * for use with IOPMrootDomain. Only 4 bits of data are allotted.
591 #define kIOPMLoginWindowProgressKey "LoginWindowProgress"
594 * kIOPMCoreDisplayProgressKey - identifies PM debug data specific to CoreDisplay
595 * for use with IOPMrootDomain. Only 8 bits of data are allotted.
597 #define kIOPMCoreDisplayProgressKey "CoreDisplayProgress"
600 * kIOPMCoreGraphicsProgressKey - identifies PM debug data specific to CoreGraphics
601 * for use with IOPMrootDomain. Only 8 bits of data are allotted.
603 #define kIOPMCoreGraphicsProgressKey "CoreGraphicsProgress"
605 // For PM internal use only - key to locate sleep failure results within SCDynamicStore.
606 #define kIOPMDynamicStoreSleepFailureKey "SleepFailure"
608 /*****************************************************************************/
610 // For IOPMLibPrivate.h
611 #define kIOPMSleepWakeFailureKey "PMFailurePhase"
612 #define kIOPMSleepWakeFailureCodeKey "PMStatusCode"
613 #define kIOPMSleepWakeFailureLoginKey "LWFailurePhase"
614 #define kIOPMSleepWakeFailureUUIDKey "UUID"
615 #define kIOPMSleepWakeFailureDateKey "Date"
616 #define kIOPMSleepWakeWdogRebootKey "SWWdogTriggeredRestart"
617 #define kIOPMSleepWakeWdogLogsValidKey "SWWdogLogsValid"
619 /*****************************************************************************
621 * Root Domain private property keys
623 *****************************************************************************/
625 /* kIOPMFeatureAutoPowerOffKey
626 * Feature published if Auto Power Off is supported
628 #define kIOPMFeatureAutoPowerOffKey "AutoPowerOff"
630 /* kIOPMAutoPowerOffEnabledKey
631 * Indicates if Auto Power Off is enabled.
632 * It has a boolean value.
633 * true == Auto Power Off is enabled
634 * false == Auto Power Off is disabled
635 * not present == Auto Power Off is not supported on this hardware
637 #define kIOPMAutoPowerOffEnabledKey "AutoPowerOff Enabled"
639 /* kIOPMAutoPowerOffDelayKey
640 * Key refers to a CFNumberRef that represents the delay in seconds before
641 * entering the Auto Power Off state. The property is not present if Auto
642 * Power Off is unsupported.
644 #define kIOPMAutoPowerOffDelayKey "AutoPowerOff Delay"
646 /* kIOPMAutoPowerOffTimerKey
647 * Key refers to a CFNumberRef that indicates the time in seconds until the
648 * expiration of the Auto Power Off delay period. This value should be used
649 * to program a wake alarm before system sleep.
651 #define kIOPMAutoPowerOffTimerKey "AutoPowerOff Timer"
653 /* kIOPMDeepSleepTimerKey
654 * Key refers to a CFNumberRef that indicates the time in seconds until the
655 * expiration of the Standby delay period. This value should be used
656 * to program a wake alarm before system sleep.
658 #define kIOPMDeepSleepTimerKey "Standby Timer"
660 /* kIOPMUserWakeAlarmScheduledKey
661 * Key refers to a boolean value that indicates if an user alarm was scheduled
664 #define kIOPMUserWakeAlarmScheduledKey "UserWakeAlarmScheduled"
666 /* kIOPMDeepIdleSupportedKey
667 * Presence of this key indicates Deep Idle is supported on this platform.
668 * Key will always refer to a value of kOSBooleanTrue.
670 #define kIOPMDeepIdleSupportedKey "IOPMDeepIdleSupported"
672 /* kIOPMUserTriggeredFullWakeKey
673 * Key refers to a boolean value that indicates if the first full wake since
674 * last system sleep was triggered by the local user. This property is set
675 * before the initial full wake transition, and removed after powering down
676 * drivers for system sleep.
678 #define kIOPMUserTriggeredFullWakeKey "IOPMUserTriggeredFullWake"
680 /* kIOPMUserIsActiveKey
681 * Key refers to a boolean value that indicates if the user is active.
683 #define kIOPMUserIsActiveKey "IOPMUserIsActive"
685 /* kIOPMDriverWakeEventsKey
686 * Key refers to a property that should only be examined by powerd.
688 #define kIOPMDriverWakeEventsKey "IOPMDriverWakeEvents"
690 /*****************************************************************************
692 * IOPMDriverWakeEvents dictionary keys
694 *****************************************************************************/
696 #define kIOPMWakeEventTimeKey "Time"
697 #define kIOPMWakeEventFlagsKey "Flags"
698 #define kIOPMWakeEventReasonKey "Reason"
699 #define kIOPMWakeEventDetailsKey "Details"
701 /* kIOPMFeatureProModeKey
702 * Feature published if ProMode is supported
704 #define kIOPMFeatureProModeKey "ProMode"
706 /*****************************************************************************
708 * Wake event flags reported to IOPMrootDomain::claimSystemWakeEvent()
710 *****************************************************************************/
712 #define kIOPMWakeEventSource 0x00000001
714 /*****************************************************************************
718 *****************************************************************************/
720 // signals the device should wake up to user space running
721 #define kIOPMWakeEventAOTExit 0x00000002
723 // will start a 400 ms timer before sleeping
724 #define kIOPMWakeEventAOTPossibleExit 0x00000004
726 // signals the device should wake up to user space running
727 #define kIOPMWakeEventAOTConfirmedPossibleExit 0x00000008
729 // signals the device should go back to AOT
730 #define kIOPMWakeEventAOTRejectedPossibleExit 0x00000010
732 // signals the device should go back to AOT
733 #define kIOPMWakeEventAOTExpiredPossibleExit 0x00000020
735 #define kIOPMWakeEventAOTFlags \
736 (kIOPMWakeEventAOTExit \
737 | kIOPMWakeEventAOTPossibleExit \
738 | kIOPMWakeEventAOTConfirmedPossibleExit \
739 | kIOPMWakeEventAOTRejectedPossibleExit \
740 | kIOPMWakeEventAOTExpiredPossibleExit)
742 #define kIOPMWakeEventAOTPossibleFlags \
743 (kIOPMWakeEventAOTPossibleExit \
744 | kIOPMWakeEventAOTConfirmedPossibleExit \
745 | kIOPMWakeEventAOTRejectedPossibleExit \
746 | kIOPMWakeEventAOTExpiredPossibleExit)
748 #define kIOPMWakeEventAOTPerCycleFlags \
749 (kIOPMWakeEventAOTPossibleExit \
750 | kIOPMWakeEventAOTRejectedPossibleExit \
751 | kIOPMWakeEventAOTExpiredPossibleExit)
753 #define kIOPMWakeEventAOTExitFlags \
754 (kIOPMWakeEventAOTExit \
755 | kIOPMWakeEventAOTConfirmedPossibleExit)
758 kIOPMAOTModeMask
= 0x000000ff,
759 kIOPMAOTModeEnable
= 0x00000001,
760 kIOPMAOTModeCycle
= 0x00000002,
761 kIOPMAOTModeAddEventFlags
= 0x00000004,
762 kIOPMAOTModeRespectTimers
= 0x00000008,
763 kIOPMAOTModeDefault
= (kIOPMAOTModeEnable
| kIOPMAOTModeAddEventFlags
| kIOPMAOTModeRespectTimers
)
767 kIOPMAOTMetricsKernelWakeCountMax
= 24
770 struct IOPMAOTMetrics
773 uint32_t possibleCount
;
774 uint32_t confirmedPossibleCount
;
775 uint32_t rejectedPossibleCount
;
776 uint32_t expiredPossibleCount
;
777 uint32_t noTimeSetCount
;
778 uint32_t rtcAlarmsCount
;
779 uint32_t softwareRequestCount
;
782 char kernelWakeReason
[kIOPMAOTMetricsKernelWakeCountMax
][64];
783 // 54:10 secs:ms calendar time
784 uint64_t kernelSleepTime
[kIOPMAOTMetricsKernelWakeCountMax
];
785 uint64_t kernelWakeTime
[kIOPMAOTMetricsKernelWakeCountMax
];
788 #define kIOPMAOTPowerKey "aot-power"
790 /*****************************************************************************
794 *****************************************************************************/
796 /* An OSNumber property set on a power managed driver that the root domain
797 * will use as the driver's max power state while system is in dark wake.
798 * This property should be set prior to the driver joining the PM tree.
800 #define kIOPMDarkWakeMaxPowerStateKey "IOPMDarkWakeMaxPowerState"
802 /*****************************************************************************
804 * System Sleep Policy
806 *****************************************************************************/
808 #define kIOPMSystemSleepPolicySignature 0x54504c53
809 #define kIOPMSystemSleepPolicyVersion 2
812 * @defined kIOPMSystemSleepTypeKey
813 * @abstract Indicates the type of system sleep.
814 * @discussion An OSNumber property of root domain that describes the type
815 * of system sleep. This property is set after notifying priority sleep/wake
816 * clients, but before informing interested drivers and shutting down power
817 * plane drivers. On a hibernate abort or failure, this property will not be
818 * updated and will indicate the failed sleep type.
820 #define kIOPMSystemSleepTypeKey "IOPMSystemSleepType"
822 struct IOPMSystemSleepPolicyVariables
824 uint32_t signature
; // kIOPMSystemSleepPolicySignature
825 uint32_t version
; // kIOPMSystemSleepPolicyVersion
827 uint64_t currentCapability
; // current system capability bits
828 uint64_t highestCapability
; // highest system capability bits
830 uint64_t sleepFactors
; // sleep factor bits
831 uint32_t sleepReason
; // kIOPMSleepReason*
832 uint32_t sleepPhase
; // identify the sleep phase
833 uint32_t hibernateMode
; // current hibernate mode
835 uint32_t standbyDelay
; // standby delay in seconds
836 uint32_t standbyTimer
; // standby timer in seconds
837 uint32_t poweroffDelay
; // auto-poweroff delay in seconds
838 uint32_t scheduledAlarms
; // bitmask of scheduled alarm types
839 uint32_t poweroffTimer
; // auto-poweroff timer in seconds
841 uint32_t reserved
[49]; // pad sizeof 256 bytes
845 kIOPMAlarmBitDebugWake
= 0x01,
846 kIOPMAlarmBitCalendarWake
= 0x02,
847 kIOPMAlarmBitMaintenanceWake
= 0x04,
848 kIOPMAlarmBitSleepServiceWake
= 0x08
852 kIOPMSleepPhase0
= 0,
857 // Sleep Factor Mask / Bits
859 kIOPMSleepFactorSleepTimerWake
= 0x00000001ULL
,
860 kIOPMSleepFactorLidOpen
= 0x00000002ULL
,
861 kIOPMSleepFactorACPower
= 0x00000004ULL
,
862 kIOPMSleepFactorBatteryLow
= 0x00000008ULL
,
863 kIOPMSleepFactorStandbyNoDelay
= 0x00000010ULL
,
864 kIOPMSleepFactorStandbyForced
= 0x00000020ULL
,
865 kIOPMSleepFactorStandbyDisabled
= 0x00000040ULL
,
866 kIOPMSleepFactorUSBExternalDevice
= 0x00000080ULL
,
867 kIOPMSleepFactorBluetoothHIDDevice
= 0x00000100ULL
,
868 kIOPMSleepFactorExternalMediaMounted
= 0x00000200ULL
,
869 kIOPMSleepFactorThunderboltDevice
= 0x00000400ULL
,
870 kIOPMSleepFactorRTCAlarmScheduled
= 0x00000800ULL
,
871 kIOPMSleepFactorMagicPacketWakeEnabled
= 0x00001000ULL
,
872 kIOPMSleepFactorHibernateForced
= 0x00010000ULL
,
873 kIOPMSleepFactorAutoPowerOffDisabled
= 0x00020000ULL
,
874 kIOPMSleepFactorAutoPowerOffForced
= 0x00040000ULL
,
875 kIOPMSleepFactorExternalDisplay
= 0x00080000ULL
,
876 kIOPMSleepFactorNetworkKeepAliveActive
= 0x00100000ULL
,
877 kIOPMSleepFactorLocalUserActivity
= 0x00200000ULL
,
878 kIOPMSleepFactorHibernateFailed
= 0x00400000ULL
,
879 kIOPMSleepFactorThermalWarning
= 0x00800000ULL
,
880 kIOPMSleepFactorDisplayCaptured
= 0x01000000ULL
883 // System Sleep Types
885 kIOPMSleepTypeInvalid
= 0,
886 kIOPMSleepTypeAbortedSleep
= 1,
887 kIOPMSleepTypeNormalSleep
= 2,
888 kIOPMSleepTypeSafeSleep
= 3,
889 kIOPMSleepTypeHibernate
= 4,
890 kIOPMSleepTypeStandby
= 5,
891 kIOPMSleepTypePowerOff
= 6,
892 kIOPMSleepTypeDeepIdle
= 7,
893 kIOPMSleepTypeLast
= 8
896 // System Sleep Flags
898 kIOPMSleepFlagDisableHibernateAbort
= 0x00000001,
899 kIOPMSleepFlagDisableUSBWakeEvents
= 0x00000002,
900 kIOPMSleepFlagDisableBatlowAssertion
= 0x00000004,
901 kIOPMSleepFlagDisableS4WakeSources
= 0x00000008
904 // System Wake Events
906 kIOPMWakeEventLidOpen
= 0x00000001,
907 kIOPMWakeEventLidClose
= 0x00000002,
908 kIOPMWakeEventACAttach
= 0x00000004,
909 kIOPMWakeEventACDetach
= 0x00000008,
910 kIOPMWakeEventCDInsert
= 0x00000010,
911 kIOPMWakeEventCDEject
= 0x00000020,
912 kIOPMWakeEventHPDAttach
= 0x00000040,
913 kIOPMWakeEventHPDDetach
= 0x00000080,
914 kIOPMWakeEventPowerButton
= 0x00000100,
915 kIOPMWakeEventG3PowerOn
= 0x00000200,
916 kIOPMWakeEventUserPME
= 0x00000400,
917 kIOPMWakeEventSleepTimer
= 0x00000800,
918 kIOPMWakeEventBatteryLow
= 0x00001000,
919 kIOPMWakeEventDarkPME
= 0x00002000,
920 kIOPMWakeEventWifi
= 0x00004000,
921 kIOPMWakeEventRTCSystem
= 0x00008000, // Maintenance RTC wake
922 kIOPMWakeEventUSBCPlugin
= 0x00010000, // USB-C Plugin
923 kIOPMWakeEventHID
= 0x00020000,
924 kIOPMWakeEventBluetooth
= 0x00040000,
925 kIOPMWakeEventDFR
= 0x00080000,
926 kIOPMWakeEventSD
= 0x00100000, // SD card
927 kIOPMWakeEventLANWake
= 0x00200000, // Wake on Lan
928 kIOPMWakeEventLANPlugin
= 0x00400000, // Ethernet media sense
929 kIOPMWakeEventThunderbolt
= 0x00800000,
930 kIOPMWakeEventRTCUser
= 0x01000000, // User requested RTC wake
934 * @defined kIOPMSystemSleepParametersKey
935 * @abstract Sleep parameters describing the upcoming sleep
936 * @discussion Root domain updates this OSData property before system sleep
937 * to pass sleep parameters to the platform driver. Some of the parameters
938 * are based on the chosen entry in the system sleep policy table.
940 #define kIOPMSystemSleepParametersKey "IOPMSystemSleepParameters"
941 #define kIOPMSystemSleepParametersVersion 2
943 struct IOPMSystemSleepParameters
949 uint32_t ecWakeEvents
;
950 uint32_t ecWakeTimer
;
951 uint32_t ecPoweroffTimer
;
952 uint32_t reserved2
[10];
953 } __attribute__((packed
));
957 * Sleep Wake debug buffer header
962 uint32_t crc
; /* CRC for spindump & following data.*/
963 uint32_t spindump_offset
; /* Offset at which spindump offset is stored */
964 uint32_t spindump_size
;
965 uint8_t is_osx_watchdog
;
967 /* All members from UUID onwards are saved into log file */
969 char spindump_status
[24]; /* stackshot status*/
970 char PMStatusCode
[32];
975 #define SWD_HDR_SIGNATURE 0xdeb8da2a
977 #define SWD_STACKSHOT_SIZE (40*PAGE_SIZE)
978 #define SWD_COMPRESSED_BUFSIZE (5*PAGE_SIZE)
979 #define SWD_ZLIB_BUFSIZE (10*PAGE_SIZE)
980 #define SWD_STACKSHOT_VAR_PREFIX "sleepwake_diags"
982 #define SWD_SPINDUMP_SIZE (256*1024)
983 #define SWD_INITIAL_SPINDUMP_SIZE ((SWD_SPINDUMP_SIZE/2)-sizeof(swd_hdr))
984 #define SWD_MAX_STACKSHOTS (10)
986 /* Bits in swd_flags */
987 #define SWD_WDOG_ENABLED 0x01
988 #define SWD_BOOT_BY_SW_WDOG 0x02
989 #define SWD_BOOT_BY_OSX_WDOG 0x04
990 #define SWD_VALID_LOGS 0x08
991 #define SWD_LOGS_IN_FILE 0x10
992 #define SWD_LOGS_IN_MEM 0x20
993 #define SWD_PWR_BTN_STACKSHOT 0x30
995 #define SWD_DATA_CRC_ERROR 0x010000
996 #define SWD_BUF_SIZE_ERROR 0x020000
997 #define SWD_HDR_SIZE_ERROR 0x040000
998 #define SWD_FILEOP_ERROR 0x080000
999 #define SWD_HDR_SIGNATURE_ERROR 0x100000
1000 #define SWD_INTERNAL_FAILURE 0x200000
1003 /* Filenames associated with the stackshots/logs generated by the SWD */
1004 #define kOSWatchdogStacksFilename "/var/log/OSXWatchdogStacks.gz"
1005 #define kOSWatchdogFailureStringFile "/var/log/OSWatchdogFailureString.txt"
1006 #define kSleepWakeStacksFilename "/var/log/SleepWakeStacks.gz"
1007 #define kSleepWakeFailureStringFile "/var/log/SleepWakeFailureString.txt"
1010 /* RootDomain IOReporting channels */
1011 #define kSleepCntChID IOREPORT_MAKEID('S','l','e','e','p','C','n','t')
1012 #define kDarkWkCntChID IOREPORT_MAKEID('G','U','I','W','k','C','n','t')
1013 #define kUserWkCntChID IOREPORT_MAKEID('D','r','k','W','k','C','n','t')
1016 * kAssertDelayChID - Histogram of time elapsed before assertion after wake.
1018 #define kAssertDelayBcktCnt 11
1019 #define kAssertDelayBcktSize 3
1020 #define kAssertDelayChID IOREPORT_MAKEID('r','d','A','s','r','t','D','l')
1023 * kSleepDelaysChID - Histogram of time taken to put system to sleep
1025 #define kSleepDelaysBcktCnt 13
1026 #define kSleepDelaysBcktSize 10
1027 #define kSleepDelaysChID IOREPORT_MAKEID('r','d','S','l','p','D','l','y')
1029 /* Sleep Options/settings */
1030 #define kSleepOptionDisplayCapturedModeKey "DisplayCapturedMode"
1033 #if defined(KERNEL) && defined(__cplusplus)
1036 * @defined kIOPMInstallSystemSleepPolicyHandlerKey
1037 * @abstract Name of the platform function to install a sleep policy handler.
1038 * @discussion Pass to IOPMrootDomain::callPlatformFunction(), with a pointer
1039 * to the C-function handler at param1, and an optional target at param2, to
1040 * register a sleep policy handler. Only a single sleep policy handler can
1043 #define kIOPMInstallSystemSleepPolicyHandlerKey \
1044 "IOPMInstallSystemSleepPolicyHandler"
1046 typedef IOReturn (*IOPMSystemSleepPolicyHandler
)(
1048 const IOPMSystemSleepPolicyVariables
* vars
,
1049 IOPMSystemSleepParameters
* params
);
1053 /*****************************************************************************
1055 * Performance Warning
1057 *****************************************************************************/
1059 /* Performance Warning Key
1060 * Key for performance warning event published using IOPMrootDomain::
1061 * systemPowerEventOccurred()
1063 #define kIOPMPerformanceWarningKey "Performance_Warning"
1065 /* Performance warning values */
1067 kIOPMPerformanceNormal
= 0,
1068 kIOPMPerformanceWarning
= 100
1071 #endif /* ! _IOKIT_IOPMPRIVATE_H */