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 /* @enum SystemSleepReasons
110 * @abstract The potential causes for system sleep as logged in the system event record.
113 kIOPMSleepReasonClamshell
= 101,
114 kIOPMSleepReasonPowerButton
= 102,
115 kIOPMSleepReasonSoftware
= 103,
116 kIOPMSleepReasonOSSwitchHibernate
= 104,
117 kIOPMSleepReasonIdle
= 105,
118 kIOPMSleepReasonLowPower
= 106,
119 kIOPMSleepReasonThermalEmergency
= 107,
120 kIOPMSleepReasonMaintenance
= 108,
121 kIOPMSleepReasonSleepServiceExit
= 109,
122 kIOPMSleepReasonDarkWakeThermalEmergency
= 110
126 * Possible C-string sleep reasons found under kRootDomainSleepReasonsKey
128 #define kIOPMClamshellSleepKey "Clamshell Sleep"
129 #define kIOPMPowerButtonSleepKey "Power Button Sleep"
130 #define kIOPMSoftwareSleepKey "Software Sleep"
131 #define kIOPMOSSwitchHibernationKey "OS Switch Sleep"
132 #define kIOPMIdleSleepKey "Idle Sleep"
133 #define kIOPMLowPowerSleepKey "Low Power Sleep"
134 #define kIOPMThermalEmergencySleepKey "Thermal Emergency Sleep"
135 #define kIOPMSleepServiceExitKey "Sleep Service Back to Sleep"
136 #define kIOPMDarkWakeThermalEmergencyKey "Dark Wake Thermal Emergency"
138 /*! kIOPMPSRestrictedModeKey
139 * An IOPMPowerSource property key
140 * Its property has an integer value.
141 * - value = 1 when the device is in a low power state and not fully functional.
142 * - value = 0, or property missing altogether, when the device is
143 * not in a restricted mode power state.
145 #define kIOPMPSRestrictedModeKey "RestrictedMode"
147 #pragma mark Stray Bitfields
148 // Private power commands issued to root domain
149 // bits 0-7 in IOPM.h
152 kIOPMSetValue
= (1<<16),
153 // don't sleep on clamshell closure on a portable with AC connected
154 kIOPMSetDesktopMode
= (1<<17),
155 // set state of AC adaptor connected
156 kIOPMSetACAdaptorConnected
= (1<<18)
159 /*****************************************************************************/
160 /*****************************************************************************/
163 * PM notification types
166 /*! @constant kIOPMSleepServiceScheduleImmediate
168 * Setting type used in calls to IOPMrootDomain::registerPMSettingController
169 * Use this type between powerd and IOKit.framework
172 #define kIOPMSleepServiceScheduleImmediate "SleepServiceImmediate"
174 /*! @constant kIOPMSettingSleepServiceScheduleImmediate
176 * Setting type used in calls to IOPMrootDomain::registerPMSettingController
177 * Use this type between xnu and AppleRTC
179 #define kIOPMSettingSleepServiceWakeCalendarKey "SleepServiceWakeCalendarKey"
181 /*! @constant kIOPMCalendarWakeTypes
183 * These are valid values for IOPM.h:IOPMCalendarStruct->selector
186 kPMCalendarTypeInvalid
= 0,
187 kPMCalendarTypeMaintenance
= 1,
188 kPMCalendarTypeSleepService
= 2
192 /* @constant kIOPMStateConsoleShutdown
193 * @abstract Notification of GUI shutdown state available to kexts.
194 * @discussion This type can be passed as arguments to registerPMSettingController()
195 * to receive callbacks.
197 #define kIOPMStateConsoleShutdown "ConsoleShutdown"
199 /* @enum ShutdownValues
200 * @abstract Potential values shared with key kIOPMStateConsoleShutdown
203 /* @constant kIOPMStateConsoleShutdownNone
204 * @abstract System shutdown (or restart) hasn't started; system is ON.
205 * @discussion Next state: 2
207 kIOPMStateConsoleShutdownNone
= 1,
208 /* @constant kIOPMStateConsoleShutdownPossible
209 * @abstract User has been presented with the option to shutdown or restart. Shutdown may be cancelled.
210 * @discussion Next state may be: 1, 4
212 kIOPMStateConsoleShutdownPossible
= 2,
213 /* @constant kIOPMStateConsoleShutdownUnderway
214 * @abstract Shutdown or restart is proceeding. It may still be cancelled.
215 * @discussion Next state may be: 1, 4. This state is currently unused.
217 kIOPMStateConsoleShutdownUnderway
= 3,
218 /* @constant kIOPMStateConsoleShutdownCertain
219 * @abstract Shutdown is in progress and irrevocable.
220 * @discussion State remains 4 until power is removed from CPU.
222 kIOPMStateConsoleShutdownCertain
= 4,
223 /* @constant kIOPMStateConsoleSULogoutInitiated
224 Indicates that LoginWindow has initiated a software update restart.
225 The next logout will not immediately lead to a shutdown.
227 kIOPMStateConsoleSULogoutInitiated
= 5
230 /* @constant kIOPMSettingSilentRunningKey
231 * @abstract Notification of silent running mode changes to kexts.
232 * @discussion This key can be passed as an argument to registerPMSettingController()
233 * and also identifies the type of PMSetting notification callback.
235 #define kIOPMSettingSilentRunningKey "SilentRunning"
236 #define kIOPMFeatureSilentRunningKey kIOPMSettingSilentRunningKey
238 /* @enum SilentRunningFlags
239 * @abstract The kIOPMSettingSilentRunningKey notification provides an OSNumber
240 * object with a value described by the following flags.
243 kIOPMSilentRunningModeOn
= 0x00000001
246 /*****************************************************************************/
247 /*****************************************************************************/
249 /* PM Statistics - event indices
250 * These are arguments to IOPMrootDomain::pmStatsRecordEvent().
253 kIOPMStatsHibernateImageWrite
= 1,
254 kIOPMStatsHibernateImageRead
,
255 kIOPMStatsDriversNotify
,
256 kIOPMStatsApplicationNotify
,
257 kIOPMStatsLateDriverAcknowledge
,
258 kIOPMStatsLateAppAcknowledge
,
260 // To designate if you're specifying the start or stop end of
261 // each of the above events, do a bitwise OR of the appropriate
262 // Start/Stop flag and pass the result to IOPMrootDomain to record
264 kIOPMStatsEventStartFlag
= (1 << 24),
265 kIOPMStatsEventStopFlag
= (1 << 25)
268 // Keys for IOPMrootDomain registry properties
269 #define kIOPMSleepStatisticsKey "SleepStatistics"
270 #define kIOPMSleepStatisticsAppsKey "AppStatistics"
271 #define kIOPMIdleSleepPreventersKey "IdleSleepPreventers"
272 #define kIOPMSystemSleepPreventersKey "SystemSleepPreventers"
273 #define kIOPMIdleSleepPreventersWithIDKey "IdleSleepPreventersWithID"
274 #define kIOPMSystemSleepPreventersWithIDKey "SystemSleepPreventersWithID"
276 // Application response statistics
277 #define kIOPMStatsNameKey "Name"
278 #define kIOPMStatsPIDKey "Pid"
279 #define kIOPMStatsTimeMSKey "TimeMS"
280 #define kIOPMStatsApplicationResponseTypeKey "ResponseType"
281 #define kIOPMStatsMessageTypeKey "MessageType"
282 #define kIOPMStatsPowerCapabilityKey "PowerCaps"
283 #define kIOPMStatsSystemTransitionKey "TransitionType"
285 // PM Statistics: potential values for the key kIOPMStatsApplicationResponseTypeKey
286 // entry in the application results array.
287 #define kIOPMStatsResponseTimedOut "ResponseTimedOut"
288 #define kIOPMStatsResponseCancel "ResponseCancel"
289 #define kIOPMStatsResponseSlow "ResponseSlow"
290 #define kIOPMStatsResponsePrompt "ResponsePrompt"
291 #define kIOPMStatsDriverPSChangeSlow "DriverPSChangeSlow"
293 struct PMStatsBounds
{
299 struct PMStatsBounds hibWrite
;
300 struct PMStatsBounds hibRead
;
301 // bounds driverNotifySleep;
302 // bounds driverNotifyWake;
303 // bounds appNotifySleep;
304 // bounds appNotifyWake;
305 // OSDictionary *tardyApps;
306 // OSDictionary *tardyDrivers;
309 /*****************************************************************************/
311 /* PM RootDomain tracePoints
313 * In the sleep/wake process, we expect the sleep trace points to proceed
314 * in increasing order. Once sleep begins with code kIOPMTracePointSleepStarted,
315 * we expect sleep to continue in a monotonically increasing order of tracepoints
316 * to kIOPMTracePointSystemLoginwindowPhase. After trace point SystemLoginWindowPhase,
317 * the system will return to kIOPMTracePointSystemUp.
319 * If the trace point decreases (instead of increasing) before reaching kIOPMTracePointSystemUp,
320 * that indicates that the sleep process was cancelled. The cancel reason shall be indicated
321 * in the cancel tracepoint. (TBD)
325 /* When kTracePointSystemUp is the latest tracePoint,
326 * the system is awake. It is not asleep, sleeping, or waking.
328 * Phase begins: At boot, at completion of wake from sleep,
329 * immediately following kIOPMTracePointSystemLoginwindowPhase.
330 * Phase ends: When a sleep attempt is initiated.
332 kIOPMTracePointSystemUp
= 0,
334 /* When kIOPMTracePointSleepStarted is the latest tracePoint,
335 * sleep has been initiated.
337 * Phase begins: At initiation of system sleep (idle or forced).
338 * Phase ends: PM starts to notify applications of system sleep.
340 kIOPMTracePointSleepStarted
= 0x10,
342 /* When kIOPMTracePointSleepApplications is the latest tracePoint,
343 * a system sleep has been initiated and PM waits for responses
344 * from notified applications.
346 * Phase begins: Begin to asynchronously fire kIOMessageSystemWillSleep
347 * notifications, and also kIOMessageCanSystemSleep for the idle sleep case.
348 * Phase ends: When PM has received all application responses.
350 kIOPMTracePointSleepApplications
= 0x11,
352 /* When kIOPMTracePointSleepPriorityClients is the latest tracePoint,
353 * PM is notifying priority clients and in-kernel system capability
354 * clients, and waiting for any asynchronous completions.
356 * Phase begins: Synchronous delivery of kIOMessageSystemWillSleep notifications.
357 * Phase ends: All notified clients have acknowledged.
359 kIOPMTracePointSleepPriorityClients
= 0x12,
361 /* When kIOPMTracePointSleepWillChangeInterests is the latest tracePoint,
362 * PM is calling powerStateWillChangeTo() on interested drivers of root domain.
364 * Phase begins: Dispatch a callout thread to call interested drivers.
365 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
366 * by drivers that indicated asynchronous completion.
368 kIOPMTracePointSleepWillChangeInterests
= 0x13,
370 /* When kIOPMTracePointSleepPowerPlaneDrivers is the latest tracePoint,
371 * PM is directing power plane drivers to power off in leaf-to-root order.
373 * Phase begins: Root domain informs its power children that it will drop to
374 * sleep state. This has a cascade effect and triggers all drivers in
375 * the power plane to transition to a lower power state if necessary.
376 * Phase ends: All power transitions in response to the root domain power
377 * change have completed.
379 kIOPMTracePointSleepPowerPlaneDrivers
= 0x14,
381 /* When kIOPMTracePointSleepDidChangeInterests is the latest tracePoint,
382 * PM is calling powerStateDidChangeTo() on interested drivers of root domain.
384 * Phase begins: Dispatch a callout thread to call interested drivers.
385 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
386 * by drivers that indicated asynchronous completion.
388 kIOPMTracePointSleepDidChangeInterests
= 0x15,
390 /* When kIOPMTracePointSleepCapabilityClients is the latest tracePoint,
391 * PM is notifying system capability clients about system sleep.
393 * Phase begins: Send kIOMessageSystemCapabilityChange notifications to inform
394 * capability clients that system has lost all capabilities.
395 * Phase ends: Finished sending notifications.
397 kIOPMTracePointSleepCapabilityClients
= 0x16,
399 /* When kIOPMTracePointSleepPlatformActions is the latest tracePoint,
400 * PM is calling drivers that have registered a platform sleep action.
402 kIOPMTracePointSleepPlatformActions
= 0x17,
404 /* When kIOPMTracePointSleepCPUs is the latest tracePoint,
405 * PM is shutting down all non-boot processors.
407 * Phase begins: Shutdown all non-boot processors.
408 * Phase ends: Reduced to only the boot processor running.
410 kIOPMTracePointSleepCPUs
= 0x18,
412 /* When kIOPMTracePointSleepPlatformDriver is the latest tracePoint,
413 * PM is executing platform dependent code to prepare for system sleep.
415 kIOPMTracePointSleepPlatformDriver
= 0x19,
417 /* When kIOPMTracePointHibernate is the latest tracePoint,
418 * PM is writing the hibernate image to disk.
420 kIOPMTracePointHibernate
= 0x1a,
422 /* When kIOPMTracePointSystemSleep is the latest tracePoint,
423 * PM has recorded the final trace point before the hardware platform
424 * enters sleep state, or low level wakeup is underway - such as restoring
425 * the hibernate image from disk.
427 * Note: If a system is asleep and then loses power, and it does not have a
428 * hibernate image to restore from (e.g. hibernatemode = 0), then OS X will
429 * interpret this power loss as a failure in kIOPMTracePointSystemSleep.
431 * Phase begins: Before the OS directs the hardware to enter sleep state.
432 * Phase ends: Control returns to the OS on wake, but before recording the first
435 kIOPMTracePointSystemSleep
= 0x1f,
437 /* When kIOPMTracePointWakePlatformDriver is the latest tracePoint,
438 * PM is executing platform dependent code to prepare for system wake.
440 kIOPMTracePointWakePlatformDriver
= 0x21,
442 /* When kIOPMTracePointWakePlatformActions is the latest tracePoint,
443 * PM is calling drivers that have registered a platform wake action.
445 kIOPMTracePointWakePlatformActions
= 0x22,
447 /* When kIOPMTracePointWakeCPUs is the latest tracePoint,
448 * PM is bringing all non-boot processors online.
450 kIOPMTracePointWakeCPUs
= 0x23,
452 /* When kIOPMTracePointWakeWillPowerOnClients is the latest tracePoint,
453 * PM is sending kIOMessageSystemWillPowerOn to both kernel clients and
454 * applications. PM also notifies system capability clients about the
455 * proposed capability change.
457 * Phase begins: Send kIOMessageSystemWillPowerOn and
458 * kIOMessageSystemCapabilityChange notifications.
459 * Phase ends: Finished sending notifications.
461 kIOPMTracePointWakeWillPowerOnClients
= 0x24,
463 /* When kIOPMTracePointWakeWillChangeInterests is the latest tracePoint,
464 * PM is calling powerStateWillChangeTo() on interested drivers of root domain.
466 * Phase begins: Dispatch a callout thread to call interested drivers.
467 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
468 * by drivers that indicated asynchronous completion.
470 kIOPMTracePointWakeWillChangeInterests
= 0x25,
472 /* When kIOPMTracePointWakeDidChangeInterests is the latest tracePoint,
473 * PM is calling powerStateDidChangeTo() on interested drivers of root domain.
475 * Phase begins: Dispatch a callout thread to call interested drivers.
476 * Phase ends: Callout thread work done, and acknowledgePowerChange() called
477 * by drivers that indicated asynchronous completion.
479 kIOPMTracePointWakeDidChangeInterests
= 0x26,
481 /* When kIOPMTracePointWakePowerPlaneDrivers is the latest tracePoint,
482 * PM is directing power plane drivers to power up in root-to-leaf order.
484 * Phase begins: Root domain informs its power children that it transitioned
485 * to ON state. This has a cascade effect and triggers all drivers in
486 * the power plane to re-evaluate and potentially change power state.
487 * Phase ends: All power transitions in response to the root domain power
488 * change have completed.
490 kIOPMTracePointWakePowerPlaneDrivers
= 0x27,
492 /* When kIOPMTracePointWakeCapabilityClients is the latest tracePoint,
493 * PM is notifying system capability clients about system wake, and waiting
494 * for any asynchronous completions.
496 * Phase begins: Inform capability clients that system has gained capabilities.
497 * Phase ends: All notified clients have acknowledged.
499 kIOPMTracePointWakeCapabilityClients
= 0x28,
501 /* When kIOPMTracePointWakeApplications is the latest tracePoint,
502 * System CPU is powered, PM has powered on each driver.
504 * Phase begins: Send asynchronous kIOMessageSystemHasPoweredOn notifications.
505 * Phase ends: Finished sending asynchronous notifications.
507 kIOPMTracePointWakeApplications
= 0x29,
509 /* kIOPMTracePointSystemLoginwindowPhase
510 * This phase represents a several minute window after the system has powered on.
511 * Higher levels of system diagnostics are in a heightened state of alert in this phase,
512 * in case any user errors occurred that we could not detect in software.
514 * Phase begins: After IOPMrootDomain sends kIOMessageSystemHasPoweredOn message.
515 * Phase ends: When loginwindow calls IOPMSleepWakeSetUUID(NULL) the system shall
516 * be considered awake and usable. The next phase shall be kIOPMTracePointSystemUp.
518 kIOPMTracePointSystemLoginwindowPhase
= 0x30,
520 /* When kIOPMTracePointDarkWakeEntry is the latest tracePoint,
521 * PM has started a transition from full wake to dark wake.
523 * Phase begins: Start transition to dark wake.
524 * Phase ends: System in dark wake. Before recording kIOPMTracePointSystemUp.
526 kIOPMTracePointDarkWakeEntry
= 0x31,
528 /* When kIOPMTracePointDarkWakeExit is the latest tracePoint,
529 * PM has started a transition from dark wake to full wake.
531 * Phase begins: Start transition to full wake.
532 * Phase ends: System in full wake. Before recording kIOPMTracePointSystemUp.
534 kIOPMTracePointDarkWakeExit
= 0x32
537 /*****************************************************************************/
540 * Component wake progress keys
542 * Certain components have the ability to log their wake progress with
543 * root domain using the keys provided below.
545 * LoginWindow - 4 bits
546 * CoreDisplay - 8 bits
547 * CoreGraphics - 8 bits
549 * These bits are stored with the trace phase that gets logged to
553 // Values that should be passed in to IOPMLogWakeProgress
555 kIOPMLoginWindowProgress
= 1,
556 kIOPMCoreDisplayProgress
= 2,
557 kIOPMCoreGraphicsProgress
= 3
561 kIOPMLoginWindowProgressMask
= 0x0f,
562 kIOPMCoreDisplayProgressMask
= 0xff,
563 kIOPMCoreGraphicsProgressMask
= 0xff
567 * kIOPMLoginWindowProgressKey - identifies PM debug data specific to LoginWindow
568 * for use with IOPMrootDomain. Only 4 bits of data are allotted.
570 #define kIOPMLoginWindowProgressKey "LoginWindowProgress"
573 * kIOPMCoreDisplayProgressKey - identifies PM debug data specific to CoreDisplay
574 * for use with IOPMrootDomain. Only 8 bits of data are allotted.
576 #define kIOPMCoreDisplayProgressKey "CoreDisplayProgress"
579 * kIOPMCoreGraphicsProgressKey - identifies PM debug data specific to CoreGraphics
580 * for use with IOPMrootDomain. Only 8 bits of data are allotted.
582 #define kIOPMCoreGraphicsProgressKey "CoreGraphicsProgress"
584 // For PM internal use only - key to locate sleep failure results within SCDynamicStore.
585 #define kIOPMDynamicStoreSleepFailureKey "SleepFailure"
587 /*****************************************************************************/
589 // For IOPMLibPrivate.h
590 #define kIOPMSleepWakeFailureKey "PMFailurePhase"
591 #define kIOPMSleepWakeFailureCodeKey "PMStatusCode"
592 #define kIOPMSleepWakeFailureLoginKey "LWFailurePhase"
593 #define kIOPMSleepWakeFailureUUIDKey "UUID"
594 #define kIOPMSleepWakeFailureDateKey "Date"
595 #define kIOPMSleepWakeWdogRebootKey "SWWdogTriggeredRestart"
596 #define kIOPMSleepWakeWdogLogsValidKey "SWWdogLogsValid"
598 /*****************************************************************************
600 * Root Domain private property keys
602 *****************************************************************************/
604 /* kIOPMFeatureAutoPowerOffKey
605 * Feature published if Auto Power Off is supported
607 #define kIOPMFeatureAutoPowerOffKey "AutoPowerOff"
609 /* kIOPMAutoPowerOffEnabledKey
610 * Indicates if Auto Power Off is enabled.
611 * It has a boolean value.
612 * true == Auto Power Off is enabled
613 * false == Auto Power Off is disabled
614 * not present == Auto Power Off is not supported on this hardware
616 #define kIOPMAutoPowerOffEnabledKey "AutoPowerOff Enabled"
618 /* kIOPMAutoPowerOffDelayKey
619 * Key refers to a CFNumberRef that represents the delay in seconds before
620 * entering the Auto Power Off state. The property is not present if Auto
621 * Power Off is unsupported.
623 #define kIOPMAutoPowerOffDelayKey "AutoPowerOff Delay"
625 /* kIOPMAutoPowerOffTimerKey
626 * Key refers to a CFNumberRef that indicates the time in seconds until the
627 * expiration of the Auto Power Off delay period. This value should be used
628 * to program a wake alarm before system sleep.
630 #define kIOPMAutoPowerOffTimerKey "AutoPowerOff Timer"
632 /* kIOPMDeepSleepTimerKey
633 * Key refers to a CFNumberRef that indicates the time in seconds until the
634 * expiration of the Standby delay period. This value should be used
635 * to program a wake alarm before system sleep.
637 #define kIOPMDeepSleepTimerKey "Standby Timer"
639 /* kIOPMUserWakeAlarmScheduledKey
640 * Key refers to a boolean value that indicates if an user alarm was scheduled
643 #define kIOPMUserWakeAlarmScheduledKey "UserWakeAlarmScheduled"
645 /* kIOPMDeepIdleSupportedKey
646 * Presence of this key indicates Deep Idle is supported on this platform.
647 * Key will always refer to a value of kOSBooleanTrue.
649 #define kIOPMDeepIdleSupportedKey "IOPMDeepIdleSupported"
651 /* kIOPMUserTriggeredFullWakeKey
652 * Key refers to a boolean value that indicates if the first full wake since
653 * last system sleep was triggered by the local user. This property is set
654 * before the initial full wake transition, and removed after powering down
655 * drivers for system sleep.
657 #define kIOPMUserTriggeredFullWakeKey "IOPMUserTriggeredFullWake"
659 /* kIOPMUserIsActiveKey
660 * Key refers to a boolean value that indicates if the user is active.
662 #define kIOPMUserIsActiveKey "IOPMUserIsActive"
664 /* kIOPMDriverWakeEventsKey
665 * Key refers to a property that should only be examined by powerd.
667 #define kIOPMDriverWakeEventsKey "IOPMDriverWakeEvents"
669 /*****************************************************************************
671 * IOPMDriverWakeEvents dictionary keys
673 *****************************************************************************/
675 #define kIOPMWakeEventTimeKey "Time"
676 #define kIOPMWakeEventFlagsKey "Flags"
677 #define kIOPMWakeEventReasonKey "Reason"
678 #define kIOPMWakeEventDetailsKey "Details"
680 /*****************************************************************************
682 * Wake event flags reported to IOPMrootDomain::claimSystemWakeEvent()
684 *****************************************************************************/
686 #define kIOPMWakeEventSource 0x00000001
688 #if !(defined(RC_HIDE_N144) || defined(RC_HIDE_N146))
689 /*****************************************************************************
693 *****************************************************************************/
695 // signals the device should wake up to user space running
696 #define kIOPMWakeEventAOTExit 0x00000002
698 // will start a 400 ms timer before sleeping
699 #define kIOPMWakeEventAOTPossibleExit 0x00000004
701 // signals the device should wake up to user space running
702 #define kIOPMWakeEventAOTConfirmedPossibleExit 0x00000008
704 // signals the device should go back to AOT
705 #define kIOPMWakeEventAOTRejectedPossibleExit 0x00000010
707 // signals the device should go back to AOT
708 #define kIOPMWakeEventAOTExpiredPossibleExit 0x00000020
710 #define kIOPMWakeEventAOTFlags \
711 (kIOPMWakeEventAOTExit \
712 | kIOPMWakeEventAOTPossibleExit \
713 | kIOPMWakeEventAOTConfirmedPossibleExit \
714 | kIOPMWakeEventAOTRejectedPossibleExit \
715 | kIOPMWakeEventAOTExpiredPossibleExit)
717 #define kIOPMWakeEventAOTPossibleFlags \
718 (kIOPMWakeEventAOTPossibleExit \
719 | kIOPMWakeEventAOTConfirmedPossibleExit \
720 | kIOPMWakeEventAOTRejectedPossibleExit \
721 | kIOPMWakeEventAOTExpiredPossibleExit)
723 #define kIOPMWakeEventAOTPerCycleFlags \
724 (kIOPMWakeEventAOTPossibleExit \
725 | kIOPMWakeEventAOTRejectedPossibleExit \
726 | kIOPMWakeEventAOTExpiredPossibleExit)
728 #define kIOPMWakeEventAOTExitFlags \
729 (kIOPMWakeEventAOTExit \
730 | kIOPMWakeEventAOTConfirmedPossibleExit)
733 kIOPMAOTModeEnable
= 0x00000001,
734 kIOPMAOTModeCycle
= 0x00000002,
735 kIOPMAOTModeAddEventFlags
= 0x00000004,
736 kIOPMAOTModeRespectTimers
= 0x00000008,
737 kIOPMAOTModeDefault
= (kIOPMAOTModeEnable
| kIOPMAOTModeAddEventFlags
| kIOPMAOTModeRespectTimers
)
741 kIOPMAOTMetricsKernelWakeCountMax
= 24
744 struct IOPMAOTMetrics
747 uint32_t possibleCount
;
748 uint32_t confirmedPossibleCount
;
749 uint32_t rejectedPossibleCount
;
750 uint32_t expiredPossibleCount
;
751 uint32_t noTimeSetCount
;
752 uint32_t rtcAlarmsCount
;
753 uint32_t softwareRequestCount
;
756 char kernelWakeReason
[kIOPMAOTMetricsKernelWakeCountMax
][64];
757 // 54:10 secs:ms calendar time
758 uint64_t kernelSleepTime
[kIOPMAOTMetricsKernelWakeCountMax
];
759 uint64_t kernelWakeTime
[kIOPMAOTMetricsKernelWakeCountMax
];
762 #define kIOPMAOTPowerKey "aot-power"
764 #endif /* !(defined(RC_HIDE_N144) || defined(RC_HIDE_N146)) */
766 /*****************************************************************************
768 * System Sleep Policy
770 *****************************************************************************/
772 #define kIOPMSystemSleepPolicySignature 0x54504c53
773 #define kIOPMSystemSleepPolicyVersion 2
776 * @defined kIOPMSystemSleepTypeKey
777 * @abstract Indicates the type of system sleep.
778 * @discussion An OSNumber property of root domain that describes the type
779 * of system sleep. This property is set after notifying priority sleep/wake
780 * clients, but before informing interested drivers and shutting down power
781 * plane drivers. On a hibernate abort or failure, this property will not be
782 * updated and will indicate the failed sleep type.
784 #define kIOPMSystemSleepTypeKey "IOPMSystemSleepType"
786 struct IOPMSystemSleepPolicyVariables
788 uint32_t signature
; // kIOPMSystemSleepPolicySignature
789 uint32_t version
; // kIOPMSystemSleepPolicyVersion
791 uint64_t currentCapability
; // current system capability bits
792 uint64_t highestCapability
; // highest system capability bits
794 uint64_t sleepFactors
; // sleep factor bits
795 uint32_t sleepReason
; // kIOPMSleepReason*
796 uint32_t sleepPhase
; // identify the sleep phase
797 uint32_t hibernateMode
; // current hibernate mode
799 uint32_t standbyDelay
; // standby delay in seconds
800 uint32_t standbyTimer
; // standby timer in seconds
801 uint32_t poweroffDelay
; // auto-poweroff delay in seconds
802 uint32_t scheduledAlarms
; // bitmask of scheduled alarm types
803 uint32_t poweroffTimer
; // auto-poweroff timer in seconds
805 uint32_t reserved
[49]; // pad sizeof 256 bytes
809 kIOPMAlarmBitDebugWake
= 0x01,
810 kIOPMAlarmBitCalendarWake
= 0x02,
811 kIOPMAlarmBitMaintenanceWake
= 0x04,
812 kIOPMAlarmBitSleepServiceWake
= 0x08
816 kIOPMSleepPhase0
= 0,
821 // Sleep Factor Mask / Bits
823 kIOPMSleepFactorSleepTimerWake
= 0x00000001ULL
,
824 kIOPMSleepFactorLidOpen
= 0x00000002ULL
,
825 kIOPMSleepFactorACPower
= 0x00000004ULL
,
826 kIOPMSleepFactorBatteryLow
= 0x00000008ULL
,
827 kIOPMSleepFactorStandbyNoDelay
= 0x00000010ULL
,
828 kIOPMSleepFactorStandbyForced
= 0x00000020ULL
,
829 kIOPMSleepFactorStandbyDisabled
= 0x00000040ULL
,
830 kIOPMSleepFactorUSBExternalDevice
= 0x00000080ULL
,
831 kIOPMSleepFactorBluetoothHIDDevice
= 0x00000100ULL
,
832 kIOPMSleepFactorExternalMediaMounted
= 0x00000200ULL
,
833 kIOPMSleepFactorThunderboltDevice
= 0x00000400ULL
,
834 kIOPMSleepFactorRTCAlarmScheduled
= 0x00000800ULL
,
835 kIOPMSleepFactorMagicPacketWakeEnabled
= 0x00001000ULL
,
836 kIOPMSleepFactorHibernateForced
= 0x00010000ULL
,
837 kIOPMSleepFactorAutoPowerOffDisabled
= 0x00020000ULL
,
838 kIOPMSleepFactorAutoPowerOffForced
= 0x00040000ULL
,
839 kIOPMSleepFactorExternalDisplay
= 0x00080000ULL
,
840 kIOPMSleepFactorNetworkKeepAliveActive
= 0x00100000ULL
,
841 kIOPMSleepFactorLocalUserActivity
= 0x00200000ULL
,
842 kIOPMSleepFactorHibernateFailed
= 0x00400000ULL
,
843 kIOPMSleepFactorThermalWarning
= 0x00800000ULL
,
844 kIOPMSleepFactorDisplayCaptured
= 0x01000000ULL
847 // System Sleep Types
849 kIOPMSleepTypeInvalid
= 0,
850 kIOPMSleepTypeAbortedSleep
= 1,
851 kIOPMSleepTypeNormalSleep
= 2,
852 kIOPMSleepTypeSafeSleep
= 3,
853 kIOPMSleepTypeHibernate
= 4,
854 kIOPMSleepTypeStandby
= 5,
855 kIOPMSleepTypePowerOff
= 6,
856 kIOPMSleepTypeDeepIdle
= 7,
857 kIOPMSleepTypeLast
= 8
860 // System Sleep Flags
862 kIOPMSleepFlagDisableHibernateAbort
= 0x00000001,
863 kIOPMSleepFlagDisableUSBWakeEvents
= 0x00000002,
864 kIOPMSleepFlagDisableBatlowAssertion
= 0x00000004,
865 kIOPMSleepFlagDisableS4WakeSources
= 0x00000008
868 // System Wake Events
870 kIOPMWakeEventLidOpen
= 0x00000001,
871 kIOPMWakeEventLidClose
= 0x00000002,
872 kIOPMWakeEventACAttach
= 0x00000004,
873 kIOPMWakeEventACDetach
= 0x00000008,
874 kIOPMWakeEventCDInsert
= 0x00000010,
875 kIOPMWakeEventCDEject
= 0x00000020,
876 kIOPMWakeEventHPDAttach
= 0x00000040,
877 kIOPMWakeEventHPDDetach
= 0x00000080,
878 kIOPMWakeEventPowerButton
= 0x00000100,
879 kIOPMWakeEventG3PowerOn
= 0x00000200,
880 kIOPMWakeEventUserPME
= 0x00000400,
881 kIOPMWakeEventSleepTimer
= 0x00000800,
882 kIOPMWakeEventBatteryLow
= 0x00001000,
883 kIOPMWakeEventDarkPME
= 0x00002000,
884 kIOPMWakeEventWifi
= 0x00004000,
885 kIOPMWakeEventRTCSystem
= 0x00008000, // Maintenance RTC wake
886 kIOPMWakeEventUSBCPlugin
= 0x00010000, // USB-C Plugin
887 kIOPMWakeEventHID
= 0x00020000,
888 kIOPMWakeEventBluetooth
= 0x00040000,
889 kIOPMWakeEventDFR
= 0x00080000,
890 kIOPMWakeEventSD
= 0x00100000, // SD card
891 kIOPMWakeEventLANWake
= 0x00200000, // Wake on Lan
892 kIOPMWakeEventLANPlugin
= 0x00400000, // Ethernet media sense
893 kIOPMWakeEventThunderbolt
= 0x00800000,
894 kIOPMWakeEventRTCUser
= 0x01000000, // User requested RTC wake
898 * @defined kIOPMSystemSleepParametersKey
899 * @abstract Sleep parameters describing the upcoming sleep
900 * @discussion Root domain updates this OSData property before system sleep
901 * to pass sleep parameters to the platform driver. Some of the parameters
902 * are based on the chosen entry in the system sleep policy table.
904 #define kIOPMSystemSleepParametersKey "IOPMSystemSleepParameters"
905 #define kIOPMSystemSleepParametersVersion 2
907 struct IOPMSystemSleepParameters
913 uint32_t ecWakeEvents
;
914 uint32_t ecWakeTimer
;
915 uint32_t ecPoweroffTimer
;
916 uint32_t reserved2
[10];
917 } __attribute__((packed
));
921 * Sleep Wake debug buffer header
926 uint32_t crc
; /* CRC for spindump & following data.*/
927 uint32_t spindump_offset
; /* Offset at which spindump offset is stored */
928 uint32_t spindump_size
;
929 uint8_t is_osx_watchdog
;
931 /* All members from UUID onwards are saved into log file */
933 char spindump_status
[24]; /* stackshot status*/
934 char PMStatusCode
[32];
939 #define SWD_HDR_SIGNATURE 0xdeb8da2a
941 #define SWD_STACKSHOT_SIZE (40*PAGE_SIZE)
942 #define SWD_COMPRESSED_BUFSIZE (5*PAGE_SIZE)
943 #define SWD_ZLIB_BUFSIZE (10*PAGE_SIZE)
944 #define SWD_STACKSHOT_VAR_PREFIX "sleepwake_diags"
946 #define SWD_SPINDUMP_SIZE (256*1024)
947 #define SWD_INITIAL_SPINDUMP_SIZE ((SWD_SPINDUMP_SIZE/2)-sizeof(swd_hdr))
948 #define SWD_MAX_STACKSHOTS (10)
950 /* Bits in swd_flags */
951 #define SWD_WDOG_ENABLED 0x01
952 #define SWD_BOOT_BY_SW_WDOG 0x02
953 #define SWD_BOOT_BY_OSX_WDOG 0x04
954 #define SWD_VALID_LOGS 0x08
955 #define SWD_LOGS_IN_FILE 0x10
956 #define SWD_LOGS_IN_MEM 0x20
957 #define SWD_PWR_BTN_STACKSHOT 0x30
959 #define SWD_DATA_CRC_ERROR 0x010000
960 #define SWD_BUF_SIZE_ERROR 0x020000
961 #define SWD_HDR_SIZE_ERROR 0x040000
962 #define SWD_FILEOP_ERROR 0x080000
963 #define SWD_HDR_SIGNATURE_ERROR 0x100000
964 #define SWD_INTERNAL_FAILURE 0x200000
967 /* Filenames associated with the stackshots/logs generated by the SWD */
968 #define kOSWatchdogStacksFilename "/var/log/OSXWatchdogStacks.gz"
969 #define kOSWatchdogFailureStringFile "/var/log/OSWatchdogFailureString.txt"
970 #define kSleepWakeStacksFilename "/var/log/SleepWakeStacks.gz"
971 #define kSleepWakeFailureStringFile "/var/log/SleepWakeFailureString.txt"
974 /* RootDomain IOReporting channels */
975 #define kSleepCntChID IOREPORT_MAKEID('S','l','e','e','p','C','n','t')
976 #define kDarkWkCntChID IOREPORT_MAKEID('G','U','I','W','k','C','n','t')
977 #define kUserWkCntChID IOREPORT_MAKEID('D','r','k','W','k','C','n','t')
980 * kAssertDelayChID - Histogram of time elapsed before assertion after wake.
982 #define kAssertDelayBcktCnt 11
983 #define kAssertDelayBcktSize 3
984 #define kAssertDelayChID IOREPORT_MAKEID('r','d','A','s','r','t','D','l')
987 * kSleepDelaysChID - Histogram of time taken to put system to sleep
989 #define kSleepDelaysBcktCnt 13
990 #define kSleepDelaysBcktSize 10
991 #define kSleepDelaysChID IOREPORT_MAKEID('r','d','S','l','p','D','l','y')
993 /* Sleep Options/settings */
994 #define kSleepOptionDisplayCapturedModeKey "DisplayCapturedMode"
997 #if defined(KERNEL) && defined(__cplusplus)
1000 * @defined kIOPMInstallSystemSleepPolicyHandlerKey
1001 * @abstract Name of the platform function to install a sleep policy handler.
1002 * @discussion Pass to IOPMrootDomain::callPlatformFunction(), with a pointer
1003 * to the C-function handler at param1, and an optional target at param2, to
1004 * register a sleep policy handler. Only a single sleep policy handler can
1007 #define kIOPMInstallSystemSleepPolicyHandlerKey \
1008 "IOPMInstallSystemSleepPolicyHandler"
1010 typedef IOReturn (*IOPMSystemSleepPolicyHandler
)(
1012 const IOPMSystemSleepPolicyVariables
* vars
,
1013 IOPMSystemSleepParameters
* params
);
1017 /*****************************************************************************
1019 * Performance Warning
1021 *****************************************************************************/
1023 /* Performance Warning Key
1024 * Key for performance warning event published using IOPMrootDomain::
1025 * systemPowerEventOccurred()
1027 #define kIOPMPerformanceWarningKey "Performance_Warning"
1029 /* Performance warning values */
1031 kIOPMPerformanceNormal
= 0,
1032 kIOPMPerformanceWarning
= 100
1035 #endif /* ! _IOKIT_IOPMPRIVATE_H */