2 * Copyright (c) 1998-2005 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@
31 #include <IOKit/IOTypes.h>
32 #include <IOKit/IOMessage.h>
33 #include <IOKit/IOReturn.h>
36 * @abstract Defines power management constants and keys used by both in-kernel and user space power management.
37 * @discussion IOPM.h defines a range of power management constants used in several in-kernel and user space APIs. Most significantly, the IOPMPowerFlags used to specify the fields of an IOPMPowerState struct are defined here.
39 * Most of the constants defined in IOPM.h are deprecated or for Apple internal use only, and are not elaborated on in headerdoc.
43 kIOPMMaxPowerStates
= 10,
44 IOPMMaxPowerStates
= kIOPMMaxPowerStates
47 /*! @enum IOPMPowerFlags
48 * @abstract Bits are used in defining capabilityFlags, inputPowerRequirements, and outputPowerCharacter in the IOPMPowerState structure.
49 * @discussion These bits may be bitwise-OR'd together in the IOPMPowerState capabilityFlags field, the outputPowerCharacter field, and/or the inputPowerRequirement field.
51 * The comments clearly mark whether each flag should be used in the capabilityFlags field, outputPowerCharacter field, and inputPowerRequirement field, or all three.
53 * The value of capabilityFlags, inputPowerRequirement or outputPowerCharacter may be 0. Most drivers implement their 'OFF' state, used when asleep, by defininf each of the 3 fields as 0.
55 * The bits listed below are only the most common bits used to define a device's power states. Your device's IO family may require that your device specify other input or output power flags to interact properly. Consult family-specific documentation to determine if your IOPower plane parents or children require other power flags; they probably don't.
57 * @constant kIOPMPowerOn Indicates the device is on, requires power, and provides power. Useful as a: Capability, InputPowerRequirement, OutputPowerCharacter
59 * @constant kIOPMDeviceUsable Indicates the device is usable in this state. Useful only as a Capability
61 * @constant kIOPMLowPower
62 * Indicates device is in a low power state. May be bitwis-OR'd together
63 * with kIOPMDeviceUsable flag, to indicate the device is still usable.
65 * A device with a capability of kIOPMLowPower may:
66 * Require either 0 or kIOPMPowerOn from its power parent
67 * Offer either kIOPMLowPower, kIOPMPowerOn, or 0 (no power at all)
68 * to its power plane children.
70 * Useful only as a Capability, although USB drivers should consult USB family documentation for other valid circumstances to use the kIOPMLowPower bit.
72 * @constant kIOPMPreventIdleSleep
73 * In the capability field of a power state, disallows idle system sleep while the device is in that state.
75 * For example, displays and disks set this capability for their ON power state; since the system may not idle sleep while the display (and thus keyboard or mouse) or the disk is active.
77 * Useful only as a Capability.
79 * @constant kIOPMSleepCapability
80 * Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities.
82 * @constant kIOPMRestartCapability
83 * Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities.
85 * @constant kIOPMSleep
86 * Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities.
88 * @constant kIOPMRestart
89 * Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities.
91 * @constant kIOPMInitialDeviceState
92 * Indicates the initial power state for the device. If <code>initialPowerStateForDomainState()</code> returns a power state with this flag set in the capability field, then the initial power change is performed without calling the driver's <code>setPowerState()</code>.
94 * @constant kIOPMRootDomainState
95 * An indication that the power flags represent the state of the root power
96 * domain. This bit must not be set in the IOPMPowerState structure.
97 * Power Management may pass this bit to initialPowerStateForDomainState()
98 * to map from a global system state to the desired device state.
100 typedef unsigned long IOPMPowerFlags
;
102 kIOPMPowerOn
= 0x00000002,
103 kIOPMDeviceUsable
= 0x00008000,
104 kIOPMLowPower
= 0x00010000,
106 kIOPMAOTPower
= 0x00020000,
107 kIOPMAOTCapability
= kIOPMAOTPower
,
109 kIOPMPreventIdleSleep
= 0x00000040,
110 kIOPMSleepCapability
= 0x00000004,
111 kIOPMRestartCapability
= 0x00000080,
112 kIOPMSleep
= 0x00000001,
113 kIOPMRestart
= 0x00000080,
114 kIOPMInitialDeviceState
= 0x00000100,
115 kIOPMRootDomainState
= 0x00000200
119 * Private IOPMPowerFlags
122 * Not for use with non-Apple drivers
123 * Their behavior is undefined
126 kIOPMClockNormal
= 0x0004,
127 kIOPMClockRunning
= 0x0008,
128 kIOPMPreventSystemSleep
= 0x0010,
130 kIOPMChildClamp
= 0x0080,
131 kIOPMChildClamp2
= 0x0200,
132 kIOPMNotPowerManaged
= 0x0800
136 * Deprecated IOPMPowerFlags
137 * Their behavior is undefined when used in IOPMPowerState
138 * Capability, InputPowerRequirement, or OutputPowerCharacter fields.
141 kIOPMMaxPerformance
= 0x4000,
142 kIOPMPassThrough
= 0x0100,
143 kIOPMAuxPowerOn
= 0x0020,
144 kIOPMNotAttainable
= 0x0001,
145 kIOPMContextRetained
= 0x2000,
146 kIOPMConfigRetained
= 0x1000,
147 kIOPMStaticPowerValid
= 0x0800,
148 kIOPMSoftSleep
= 0x0400,
149 kIOPMCapabilitiesMask
= kIOPMPowerOn
| kIOPMDeviceUsable
|
150 kIOPMMaxPerformance
| kIOPMContextRetained
|
151 kIOPMConfigRetained
| kIOPMSleepCapability
|
152 kIOPMRestartCapability
156 * Support for old names of IOPMPowerFlag constants
159 IOPMNotAttainable
= kIOPMNotAttainable
,
160 IOPMPowerOn
= kIOPMPowerOn
,
161 IOPMClockNormal
= kIOPMClockNormal
,
162 IOPMClockRunning
= kIOPMClockRunning
,
163 IOPMAuxPowerOn
= kIOPMAuxPowerOn
,
164 IOPMDeviceUsable
= kIOPMDeviceUsable
,
165 IOPMMaxPerformance
= kIOPMMaxPerformance
,
166 IOPMContextRetained
= kIOPMContextRetained
,
167 IOPMConfigRetained
= kIOPMConfigRetained
,
168 IOPMNotPowerManaged
= kIOPMNotPowerManaged
,
169 IOPMSoftSleep
= kIOPMSoftSleep
174 kIOPMNextHigherState
= 1,
175 kIOPMHighestState
= 2,
176 kIOPMNextLowerState
= 3,
181 IOPMNextHigherState
= kIOPMNextHigherState
,
182 IOPMHighestState
= kIOPMHighestState
,
183 IOPMNextLowerState
= kIOPMNextLowerState
,
184 IOPMLowestState
= kIOPMLowestState
187 // Internal commands used by power managment command queue
189 kIOPMBroadcastAggressiveness
= 1,
193 // Power consumption unknown value
195 kIOPMUnknown
= 0xFFFF
198 /*******************************************************************************
200 * Root Domain property keys of interest
202 ******************************************************************************/
204 /* AppleClamshellState
205 * reflects the state of the clamshell (lid) on a portable.
206 * It has a boolean value.
207 * true == clamshell is closed
208 * false == clamshell is open
209 * not present == no clamshell on this hardware
211 #define kAppleClamshellStateKey "AppleClamshellState"
213 /* AppleClamshellCausesSleep
214 * reflects the clamshell close behavior on a portable.
215 * It has a boolean value.
216 * true == system will sleep when clamshell is closed
217 * false == system will not sleep on clamshell close
218 * (typically external display mode)
219 * not present == no clamshell on this hardware
221 #define kAppleClamshellCausesSleepKey "AppleClamshellCausesSleep"
223 /* kIOPMSleepWakeUUIDKey
224 * Key refers to a CFStringRef that will uniquely identify
225 * a sleep/wake cycle for logging & tracking.
226 * The key becomes valid at the beginning of a sleep cycle - before we
227 * initiate any sleep/wake notifications.
228 * The key becomes invalid at the completion of a system wakeup. The
229 * property will not be present in the IOPMrootDomain's registry entry
230 * when it is invalid.
232 * See IOPMrootDomain notification kIOPMMessageSleepWakeUUIDChange
234 #define kIOPMSleepWakeUUIDKey "SleepWakeUUID"
236 /* kIOPMBootSessionUUIDKey
237 * Key refers to a CFStringRef that will uniquely identify
239 * The key becomes valid at boot time and remains valid
240 * till shutdown. The property value will remain same across
241 * sleep/wake/hibernate cycle.
243 #define kIOPMBootSessionUUIDKey "BootSessionUUID"
245 /* kIOPMDeepSleepEnabledKey
246 * Indicates the Deep Sleep enable state.
247 * It has a boolean value.
248 * true == Deep Sleep is enabled
249 * false == Deep Sleep is disabled
250 * not present == Deep Sleep is not supported on this hardware
252 #define kIOPMDeepSleepEnabledKey "Standby Enabled"
254 /* kIOPMDeepSleepDelayKey
255 * Key refers to a CFNumberRef that represents the delay in seconds before
256 * entering Deep Sleep state when on battery power and when remaining
257 * battery capacity is below a particular threshold (e.g., 50%.) The
258 * property is not present if Deep Sleep is unsupported.
260 #define kIOPMDeepSleepDelayKey "Standby Delay"
262 /* kIOPMDeepSleepDelayHighKey
263 * Key refers to a CFNumberRef that represents the delay in seconds before
264 * entering Deep Sleep state. This is used instead of the value specified by
265 * kIOPMDeepSleepDelayKey if the remaining battery capacity is above a
266 * particular threshold (e.g. 50%) or on AC power. The property is not
267 * present if Deep Sleep is unsupported.
269 #define kIOPMDeepSleepDelayHighKey "High Standby Delay"
271 /* kIOPMLowBatteryThresholdKey
272 * Key refers to a CFNumberRef that represents the threshold used to choose
273 * between the normal deep sleep delay and the high deep sleep delay (as a
274 * percentage of total battery capacity remaining.) The property is not
275 * present if Deep Sleep is unsupported.
277 #define kIOPMStandbyBatteryThresholdKey "Standby Battery Threshold"
279 /* kIOPMDestroyFVKeyOnStandbyKey
280 * Specifies if FileVault key can be stored when going to standby mode
281 * It has a boolean value,
282 * true == Destroy FV key when going to standby mode
283 * false == Retain FV key when going to standby mode
284 * not present == Retain FV key when going to standby mode
286 #define kIOPMDestroyFVKeyOnStandbyKey "DestroyFVKeyOnStandby"
288 /*******************************************************************************
290 * Properties that can control power management behavior
292 ******************************************************************************/
294 /* kIOPMResetPowerStateOnWakeKey
295 * If an IOService publishes this key with the value of kOSBooleanTrue,
296 * then PM will disregard the influence from changePowerStateToPriv() or
297 * any activity tickles that occurred before system sleep when resolving
298 * the initial device power state on wake. Influences from power children
299 * and changePowerStateTo() are not eliminated. At the earliest opportunity
300 * upon system wake, PM will query the driver for a new power state to be
301 * installed as the initial changePowerStateToPriv() influence, by calling
302 * initialPowerStateForDomainState() with both kIOPMRootDomainState and
303 * kIOPMPowerOn flags set. The default implementation will always return
304 * the lowest power state. Drivers can override this default behavior to
305 * immediately raise the power state when there are work blocked on the
306 * power change, and cannot afford to wait until the next activity tickle.
307 * This property should be statically added to a driver's plist or set at
308 * runtime before calling PMinit().
310 #define kIOPMResetPowerStateOnWakeKey "IOPMResetPowerStateOnWake"
312 /*******************************************************************************
314 * Driver PM Assertions
316 ******************************************************************************/
318 /* Driver Assertion bitfield description
319 * Driver PM assertions are defined by these bits.
322 /*! kIOPMDriverAssertionCPUBit
323 * When set, PM kernel will prefer to leave the CPU and core hardware
324 * running in "Dark Wake" state, instead of sleeping.
326 kIOPMDriverAssertionCPUBit
= 0x01,
328 /*! kIOPMDriverAssertionPreventSystemIdleSleepBit
329 * When set, the system should not idle sleep. This does not prevent
332 kIOPMDriverAssertionPreventSystemIdleSleepBit
= 0x02,
334 /*! kIOPMDriverAssertionUSBExternalDeviceBit
335 * When set, driver is informing PM that an external USB device is attached.
337 kIOPMDriverAssertionUSBExternalDeviceBit
= 0x04,
339 /*! kIOPMDriverAssertionBluetoothHIDDevicePairedBit
340 * When set, driver is informing PM that a Bluetooth HID device is paired.
342 kIOPMDriverAssertionBluetoothHIDDevicePairedBit
= 0x08,
344 /*! kIOPMDriverAssertionExternalMediaMountedBit
345 * When set, driver is informing PM that an external media is mounted.
347 kIOPMDriverAssertionExternalMediaMountedBit
= 0x10,
349 /*! kIOPMDriverAssertionReservedBit5
350 * Reserved for Thunderbolt.
352 kIOPMDriverAssertionReservedBit5
= 0x20,
354 /*! kIOPMDriverAssertionPreventDisplaySleepBit
355 * When set, the display should remain powered on while the system's awake.
357 kIOPMDriverAssertionPreventDisplaySleepBit
= 0x40,
359 /*! kIOPMDriverAssertionReservedBit7
360 * Reserved for storage family.
362 kIOPMDriverAssertionReservedBit7
= 0x80,
364 /*! kIOPMDriverAssertionMagicPacketWakeEnabledBit
365 * When set, driver is informing PM that magic packet wake is enabled.
367 kIOPMDriverAssertionMagicPacketWakeEnabledBit
= 0x100,
369 /*! kIOPMDriverAssertionNetworkKeepAliveActiveBit
370 * When set, driver is informing PM that it is holding the network
371 * interface up to do TCPKeepAlive
373 kIOPMDriverAssertionNetworkKeepAliveActiveBit
= 0x200
376 /* kIOPMAssertionsDriverKey
377 * This kIOPMrootDomain key refers to a CFNumberRef property, containing
378 * a bitfield describing the aggregate PM assertion levels.
379 * Example: A value of 0 indicates that no driver has asserted anything.
380 * Or, a value of <link>kIOPMDriverAssertionCPUBit</link>
381 * indicates that a driver (or drivers) have asserted a need for CPU and video.
383 #define kIOPMAssertionsDriverKey "DriverPMAssertions"
385 /* kIOPMAssertionsDriverKey
386 * This kIOPMrootDomain key refers to a CFNumberRef property, containing
387 * a bitfield describing the aggregate PM assertion levels.
388 * Example: A value of 0 indicates that no driver has asserted anything.
389 * Or, a value of <link>kIOPMDriverAssertionCPUBit</link>
390 * indicates that a driver (or drivers) have asserted a need for CPU and video.
392 #define kIOPMAssertionsDriverDetailedKey "DriverPMAssertionsDetailed"
394 /*******************************************************************************
396 * Kernel Driver assertion detailed dictionary keys
398 * Keys decode the Array & dictionary data structure under IOPMrootDomain property
399 * kIOPMAssertionsDriverKey.
402 #define kIOPMDriverAssertionIDKey "ID"
403 #define kIOPMDriverAssertionCreatedTimeKey "CreatedTime"
404 #define kIOPMDriverAssertionModifiedTimeKey "ModifiedTime"
405 #define kIOPMDriverAssertionOwnerStringKey "Owner"
406 #define kIOPMDriverAssertionOwnerServiceKey "ServicePtr"
407 #define kIOPMDriverAssertionRegistryEntryIDKey "RegistryEntryID"
408 #define kIOPMDriverAssertionLevelKey "Level"
409 #define kIOPMDriverAssertionAssertedKey "Assertions"
411 /*******************************************************************************
413 * Root Domain general interest messages
415 * Available by registering for interest type 'gIOGeneralInterest'
418 ******************************************************************************/
420 /* kIOPMMessageClamshellStateChange
421 * Delivered as a general interest notification on the IOPMrootDomain
422 * IOPMrootDomain sends this message when state of either AppleClamshellState
423 * or AppleClamshellCausesSleep changes. If this clamshell change results in
424 * a sleep, the sleep will initiate soon AFTER delivery of this message.
425 * The state of both variables is encoded in a bitfield argument sent with
426 * the message. Check bits 0 and 1 using kClamshellStateBit & kClamshellSleepBit
429 kClamshellStateBit
= (1 << 0),
430 kClamshellSleepBit
= (1 << 1)
433 #define kIOPMMessageClamshellStateChange \
434 iokit_family_msg(sub_iokit_powermanagement, 0x100)
436 /* kIOPMMessageFeatureChange
437 * Delivered when the set of supported features ("Supported Features" dictionary
438 * under IOPMrootDomain registry) changes in some way. Typically addition or
439 * removal of a supported feature.
440 * RootDomain passes no argument with this message.
442 #define kIOPMMessageFeatureChange \
443 iokit_family_msg(sub_iokit_powermanagement, 0x110)
445 /* kIOPMMessageInflowDisableCancelled
446 * The battery has drained completely to its "Fully Discharged" state.
447 * If a user process has disabled battery inflow for battery
448 * calibration, we forcibly re-enable Inflow at this point.
449 * If inflow HAS been forcibly re-enabled, bit 0
450 * (kInflowForciblyEnabledBit) will be set.
453 kInflowForciblyEnabledBit
= (1 << 0)
456 /* kIOPMMessageInternalBatteryFullyDischarged
457 * The battery has drained completely to its "Fully Discharged" state.
459 #define kIOPMMessageInternalBatteryFullyDischarged \
460 iokit_family_msg(sub_iokit_powermanagement, 0x120)
462 /* kIOPMMessageSystemPowerEventOccurred
463 * Some major system thermal property has changed, and interested clients may
464 * modify their behavior.
466 #define kIOPMMessageSystemPowerEventOccurred \
467 iokit_family_msg(sub_iokit_powermanagement, 0x130)
469 /* kIOPMMessageSleepWakeUUIDChange
470 * Either a new SleepWakeUUID has been specified at the beginning of a sleep,
471 * or we're removing the existing property upon completion of a wakeup.
473 #define kIOPMMessageSleepWakeUUIDChange \
474 iokit_family_msg(sub_iokit_powermanagement, 0x140)
476 /* kIOPMMessageSleepWakeUUIDSet
477 * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when
478 * a new UUID has been specified.
480 #define kIOPMMessageSleepWakeUUIDSet ((void *)1)
482 /* kIOPMMessageSleepWakeUUIDCleared
483 * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when
484 * the current UUID has been removed.
486 #define kIOPMMessageSleepWakeUUIDCleared ((void *)NULL)
488 /*! kIOPMMessageDriverAssertionsChanged
489 * Sent when kernel PM driver assertions have changed.
491 #define kIOPMMessageDriverAssertionsChanged \
492 iokit_family_msg(sub_iokit_powermanagement, 0x150)
494 /*! kIOPMMessageDarkWakeThermalEmergency
495 * Sent when machine becomes unsustainably warm in DarkWake.
496 * Kernel PM might choose to put the machine back to sleep right after.
498 #define kIOPMMessageDarkWakeThermalEmergency \
499 iokit_family_msg(sub_iokit_powermanagement, 0x160)
501 /*******************************************************************************
503 * Power commands issued to root domain
504 * Use with IOPMrootDomain::receivePowerNotification()
506 * These commands are issued from system drivers only:
507 * ApplePMU, AppleSMU, IOGraphics, AppleACPIFamily
509 * TODO: deprecate kIOPMAllowSleep and kIOPMPreventSleep
510 ******************************************************************************/
512 kIOPMSleepNow
= (1 << 0),// put machine to sleep now
513 kIOPMAllowSleep
= (1 << 1),// allow idle sleep
514 kIOPMPreventSleep
= (1 << 2),// do not allow idle sleep
515 kIOPMPowerButton
= (1 << 3),// power button was pressed
516 kIOPMClamshellClosed
= (1 << 4),// clamshell was closed
517 kIOPMPowerEmergency
= (1 << 5),// battery dangerously low
518 kIOPMDisableClamshell
= (1 << 6),// do not sleep on clamshell closure
519 kIOPMEnableClamshell
= (1 << 7),// sleep on clamshell closure
520 kIOPMProcessorSpeedChange
= (1 << 8),// change the processor speed
521 kIOPMOverTemp
= (1 << 9),// system dangerously hot
522 kIOPMClamshellOpened
= (1 << 10),// clamshell was opened
523 kIOPMDWOverTemp
= (1 << 11),// DarkWake thermal limits exceeded.
524 kIOPMPowerButtonUp
= (1 << 12),// Power button up
525 kIOPMProModeEngaged
= (1 << 13),// Fans entered 'ProMode'
526 kIOPMProModeDisengaged
= (1 << 14) // Fans exited 'ProMode'
530 /*******************************************************************************
532 * Power Management Return Codes
534 ******************************************************************************/
538 // Returned by driver's setPowerState(), powerStateWillChangeTo(),
539 // powerStateDidChangeTo(), or acknowledgeSetPowerState() to
540 // implicitly acknowledge power change upon function return.
544 kIOPMWillAckLater
= 1,
546 // Returned by requestPowerDomainState() to indicate
547 // unrecognized specification parameter.
548 kIOPMBadSpecification
= 4,
550 // Returned by requestPowerDomainState() to indicate
551 // no power state matches search specification.
552 kIOPMNoSuchState
= 5,
555 kIOPMCannotRaisePower
= 6,
558 kIOPMParameterError
= 7,
560 // Returned when power management state is accessed
561 // before driver has called PMinit().
562 kIOPMNotYetInitialized
= 8,
564 // And the old constants; deprecated
565 IOPMNoErr
= kIOPMNoErr
,
566 IOPMAckImplied
= kIOPMAckImplied
,
567 IOPMWillAckLater
= kIOPMWillAckLater
,
568 IOPMBadSpecification
= kIOPMBadSpecification
,
569 IOPMNoSuchState
= kIOPMNoSuchState
,
570 IOPMCannotRaisePower
= kIOPMCannotRaisePower
,
571 IOPMParameterError
= kIOPMParameterError
,
572 IOPMNotYetInitialized
= kIOPMNotYetInitialized
576 // IOPMPowerSource class descriptive strings
577 // Power Source state is published as properties to the IORegistry under these
579 #define kIOPMPSExternalConnectedKey "ExternalConnected"
580 #define kIOPMPSExternalChargeCapableKey "ExternalChargeCapable"
581 #define kIOPMPSBatteryInstalledKey "BatteryInstalled"
582 #define kIOPMPSIsChargingKey "IsCharging"
583 #define kIOPMFullyChargedKey "FullyCharged"
584 #define kIOPMPSAtWarnLevelKey "AtWarnLevel"
585 #define kIOPMPSAtCriticalLevelKey "AtCriticalLevel"
586 #define kIOPMPSCurrentCapacityKey "CurrentCapacity"
587 #define kIOPMPSMaxCapacityKey "MaxCapacity"
588 #define kIOPMPSDesignCapacityKey "DesignCapacity"
589 #define kIOPMPSTimeRemainingKey "TimeRemaining"
590 #define kIOPMPSAmperageKey "Amperage"
591 #define kIOPMPSVoltageKey "Voltage"
592 #define kIOPMPSCycleCountKey "CycleCount"
593 #define kIOPMPSMaxErrKey "MaxErr"
594 #define kIOPMPSAdapterInfoKey "AdapterInfo"
595 #define kIOPMPSLocationKey "Location"
596 #define kIOPMPSErrorConditionKey "ErrorCondition"
597 #define kIOPMPSManufacturerKey "Manufacturer"
598 #define kIOPMPSManufactureDateKey "ManufactureDate"
599 #define kIOPMPSModelKey "Model"
600 #define kIOPMPSSerialKey "Serial"
601 #define kIOPMDeviceNameKey "DeviceName"
602 #define kIOPMPSLegacyBatteryInfoKey "LegacyBatteryInfo"
603 #define kIOPMPSBatteryHealthKey "BatteryHealth"
604 #define kIOPMPSHealthConfidenceKey "HealthConfidence"
605 #define kIOPMPSCapacityEstimatedKey "CapacityEstimated"
606 #define kIOPMPSBatteryChargeStatusKey "ChargeStatus"
607 #define kIOPMPSBatteryTemperatureKey "Temperature"
608 #define kIOPMPSAdapterDetailsKey "AdapterDetails"
609 #define kIOPMPSChargerConfigurationKey "ChargerConfiguration"
611 // kIOPMPSBatteryChargeStatusKey may have one of the following values, or may have
612 // no value. If kIOPMBatteryChargeStatusKey has a NULL value (or no value) associated with it
613 // then charge is proceeding normally. If one of these battery charge status reasons is listed,
614 // then the charge may have been interrupted.
615 #define kIOPMBatteryChargeStatusTooHot "HighTemperature"
616 #define kIOPMBatteryChargeStatusTooCold "LowTemperature"
617 #define kIOPMBatteryChargeStatusTooHotOrCold "HighOrLowTemperature"
618 #define kIOPMBatteryChargeStatusGradient "BatteryTemperatureGradient"
620 // Definitions for battery location, in case of multiple batteries.
621 // A location of 0 is unspecified
622 // Location is undefined for single battery systems
624 kIOPMPSLocationLeft
= 1001,
625 kIOPMPSLocationRight
= 1002
628 // Battery quality health types, specified by BatteryHealth and HealthConfidence
629 // properties in an IOPMPowerSource battery kext.
631 kIOPMUndefinedValue
= 0,
637 // Keys for kIOPMPSAdapterDetailsKey dictionary
638 #define kIOPMPSAdapterDetailsIDKey "AdapterID"
639 #define kIOPMPSAdapterDetailsWattsKey "Watts"
640 #define kIOPMPSAdapterDetailsRevisionKey "AdapterRevision"
641 #define kIOPMPSAdapterDetailsSerialNumberKey "SerialNumber"
642 #define kIOPMPSAdapterDetailsFamilyKey "FamilyCode"
643 #define kIOPMPSAdapterDetailsAmperageKey "Current"
644 #define kIOPMPSAdapterDetailsDescriptionKey "Description"
645 #define kIOPMPSAdapterDetailsPMUConfigurationKey "PMUConfiguration"
646 #define kIOPMPSAdapterDetailsVoltage "Voltage"
647 #define kIOPMPSAdapterDetailsSourceIDKey "Source"
648 #define kIOPMPSAdapterDetailsErrorFlagsKey "ErrorFlags"
649 #define kIOPMPSAdapterDetailsSharedSourceKey "SharedSource"
650 #define kIOPMPSAdapterDetailsCloakedKey "CloakedSource"
652 // values for kIOPSPowerAdapterFamilyKey
654 kIOPSFamilyCodeDisconnected
= 0,
655 kIOPSFamilyCodeUnsupported
= kIOReturnUnsupported
,
656 kIOPSFamilyCodeFirewire
= iokit_family_err(sub_iokit_firewire
, 0),
657 kIOPSFamilyCodeUSBHost
= iokit_family_err(sub_iokit_usb
, 0),
658 kIOPSFamilyCodeUSBHostSuspended
= iokit_family_err(sub_iokit_usb
, 1),
659 kIOPSFamilyCodeUSBDevice
= iokit_family_err(sub_iokit_usb
, 2),
660 kIOPSFamilyCodeUSBAdapter
= iokit_family_err(sub_iokit_usb
, 3),
661 kIOPSFamilyCodeUSBChargingPortDedicated
= iokit_family_err(sub_iokit_usb
, 4),
662 kIOPSFamilyCodeUSBChargingPortDownstream
= iokit_family_err(sub_iokit_usb
, 5),
663 kIOPSFamilyCodeUSBChargingPort
= iokit_family_err(sub_iokit_usb
, 6),
664 kIOPSFamilyCodeUSBUnknown
= iokit_family_err(sub_iokit_usb
, 7),
665 kIOPSFamilyCodeUSBCBrick
= iokit_family_err(sub_iokit_usb
, 8),
666 kIOPSFamilyCodeUSBCTypeC
= iokit_family_err(sub_iokit_usb
, 9),
667 kIOPSFamilyCodeUSBCPD
= iokit_family_err(sub_iokit_usb
, 10),
668 kIOPSFamilyCodeAC
= iokit_family_err(sub_iokit_pmu
, 0),
669 kIOPSFamilyCodeExternal
= iokit_family_err(sub_iokit_pmu
, 1),
670 kIOPSFamilyCodeExternal2
= iokit_family_err(sub_iokit_pmu
, 2),
671 kIOPSFamilyCodeExternal3
= iokit_family_err(sub_iokit_pmu
, 3),
672 kIOPSFamilyCodeExternal4
= iokit_family_err(sub_iokit_pmu
, 4),
673 kIOPSFamilyCodeExternal5
= iokit_family_err(sub_iokit_pmu
, 5),
674 kIOPSFamilyCodeExternal6
= iokit_family_err(sub_iokit_pmu
, 6),
677 // values for kIOPMPSAdapterDetailsErrorFlagsKey
679 kIOPSAdapterErrorFlagNoErrors
= 0,
680 kIOPSAdapterErrorFlagInsufficientAvailablePower
= (1 << 1),
681 kIOPSAdapterErrorFlagForeignObjectDetected
= (1 << 2),
682 kIOPSAdapterErrorFlagDeviceNeedsToBeRepositioned
= (1 << 3),
685 // Battery's time remaining estimate is invalid this long (seconds) after a wake
686 #define kIOPMPSInvalidWakeSecondsKey "BatteryInvalidWakeSeconds"
688 // Battery must wait this long (seconds) after being completely charged before
689 // the battery is settled.
690 #define kIOPMPSPostChargeWaitSecondsKey "PostChargeWaitSeconds"
692 // Battery must wait this long (seconds) after being completely discharged
693 // before the battery is settled.
694 #define kIOPMPSPostDishargeWaitSecondsKey "PostDischargeWaitSeconds"
697 /* CPU Power Management status keys
698 * Pass as arguments to IOPMrootDomain::systemPowerEventOccurred
699 * Or as arguments to IOPMSystemPowerEventOccurred()
700 * Or to decode the dictionary obtained from IOPMCopyCPUPowerStatus()
701 * These keys reflect restrictions placed on the CPU by the system
702 * to bring the CPU's power consumption within allowable thermal and
707 /* kIOPMGraphicsPowerLimitsKey
708 * The key representing the dictionary of graphics power limits.
709 * The dictionary contains the other kIOPMCPUPower keys & their associated
710 * values (e.g. Speed limit, Processor Count, and Schedule limits).
712 #define kIOPMGraphicsPowerLimitsKey "Graphics_Power_Limits"
714 /* kIOPMGraphicsPowerLimitPerformanceKey
715 * The key representing the percent of overall performance made available
716 * by the graphics chip as a percentage (integer 0 - 100).
718 #define kIOPMGraphicsPowerLimitPerformanceKey "Graphics_Power_Performance"
722 /* kIOPMCPUPowerLimitsKey
723 * The key representing the dictionary of CPU Power Limits.
724 * The dictionary contains the other kIOPMCPUPower keys & their associated
725 * values (e.g. Speed limit, Processor Count, and Schedule limits).
727 #define kIOPMCPUPowerLimitsKey "CPU_Power_Limits"
729 /* kIOPMCPUPowerLimitProcessorSpeedKey defines the speed & voltage limits placed
731 * Represented as a percentage (0-100) of maximum CPU speed.
733 #define kIOPMCPUPowerLimitProcessorSpeedKey "CPU_Speed_Limit"
735 /* kIOPMCPUPowerLimitProcessorCountKey reflects how many, if any, CPUs have been
736 * taken offline. Represented as an integer number of CPUs (0 - Max CPUs).
738 #define kIOPMCPUPowerLimitProcessorCountKey "CPU_Available_CPUs"
740 /* kIOPMCPUPowerLimitSchedulerTimeKey represents the percentage (0-100) of CPU time
741 * available. 100% at normal operation. The OS may limit this time for a percentage
744 #define kIOPMCPUPowerLimitSchedulerTimeKey "CPU_Scheduler_Limit"
747 /* Thermal Level Warning Key
748 * Indicates the thermal constraints placed on the system. This value may
749 * cause clients to action to consume fewer system resources.
750 * The value associated with this warning is defined by the platform.
752 #define kIOPMThermalLevelWarningKey "Thermal_Level_Warning"
754 /* Thermal Warning Level values
755 * kIOPMThermalLevelNormal - under normal operating conditions
756 * kIOPMThermalLevelDanger - thermal pressure may cause system slowdown
757 * kIOPMThermalLevelCritical - thermal conditions may cause imminent shutdown
759 * The platform may define additional thermal levels if necessary.
760 * Platform specific values are defined from 100 and above
763 kIOPMThermalLevelNormal
= 0,
764 kIOPMThermalLevelDanger
= 5,
765 kIOPMThermalLevelCritical
= 10,
767 kIOPMThermalLevelWarning
= 100,
768 kIOPMThermalLevelTrap
= 110,
770 kIOPMThermalLevelUnknown
= 255,
773 #define kIOPMThermalWarningLevelNormal kIOPMThermalLevelNormal
774 #define kIOPMThermalWarningLevelDanger kIOPMThermalLevelWarning
775 #define kIOPMThermalWarningLevelCrisis kIOPMThermalLevelCritical
777 // PM Settings Controller setting types
778 // Settings types used primarily with:
779 // IOPMrootDomain::registerPMSettingController
780 // The values are identical to the similarly named keys for use in user space
781 // PM settings work. Those keys are defined in IOPMLibPrivate.h.
782 #define kIOPMSettingWakeOnRingKey "Wake On Modem Ring"
783 #define kIOPMSettingRestartOnPowerLossKey "Automatic Restart On Power Loss"
784 #define kIOPMSettingWakeOnACChangeKey "Wake On AC Change"
785 #define kIOPMSettingSleepOnPowerButtonKey "Sleep On Power Button"
786 #define kIOPMSettingWakeOnClamshellKey "Wake On Clamshell Open"
787 #define kIOPMSettingReduceBrightnessKey "ReduceBrightness"
788 #define kIOPMSettingDisplaySleepUsesDimKey "Display Sleep Uses Dim"
789 #define kIOPMSettingTimeZoneOffsetKey "TimeZoneOffsetSeconds"
790 #define kIOPMSettingMobileMotionModuleKey "MobileMotionModule"
791 #define kIOPMSettingGraphicsSwitchKey "GPUSwitch"
792 #define kIOPMSettingProModeControl "ProModeControl"
793 #define kIOPMSettingProModeDefer "ProModeDefer"
795 // Setting controlling drivers can register to receive scheduled wake data
796 // Either in "CF seconds" type, or structured calendar data in a formatted
797 // IOPMCalendarStruct defined below.
798 #define kIOPMSettingAutoWakeSecondsKey "wake"
799 #define kIOPMSettingAutoWakeCalendarKey "WakeByCalendarDate"
800 #define kIOPMSettingAutoPowerSecondsKey "poweron"
801 #define kIOPMSettingAutoPowerCalendarKey "PowerByCalendarDate"
803 // Debug seconds auto wake
804 // Used by sleep cycling debug tools
805 #define kIOPMSettingDebugWakeRelativeKey "WakeRelativeToSleep"
806 #define kIOPMSettingDebugPowerRelativeKey "PowerRelativeToShutdown"
808 // Maintenance wake calendar.
809 #define kIOPMSettingMaintenanceWakeCalendarKey "MaintenanceWakeCalendarDate"
812 struct IOPMCalendarStruct
{
821 typedef struct IOPMCalendarStruct IOPMCalendarStruct
;
823 // SetAggressiveness types
825 kPMGeneralAggressiveness
= 0,
827 kPMMinutesToSpinDown
,
829 kPMEthernetWakeOnLANSettings
,
830 kPMSetProcessorSpeed
,
833 kPMLastAggressivenessType
835 #define kMaxType (kPMLastAggressivenessType-1)
837 // SetAggressiveness values for the kPMPowerSource aggressiveness type
839 kIOPMInternalPower
= 1,
843 #define kIOREMSleepEnabledKey "REMSleepEnabled"
845 // Strings for deciphering the dictionary returned from IOPMCopyBatteryInfo
846 #define kIOBatteryInfoKey "IOBatteryInfo"
847 #define kIOBatteryCurrentChargeKey "Current"
848 #define kIOBatteryCapacityKey "Capacity"
849 #define kIOBatteryFlagsKey "Flags"
850 #define kIOBatteryVoltageKey "Voltage"
851 #define kIOBatteryAmperageKey "Amperage"
852 #define kIOBatteryCycleCountKey "Cycle Count"
855 kIOBatteryInstalled
= (1 << 2),
856 kIOBatteryCharge
= (1 << 1),
857 kIOBatteryChargerConnect
= (1 << 0)
860 // Private power management message indicating battery data has changed
861 // Indicates new data resides in the IORegistry
862 #define kIOPMMessageBatteryStatusHasChanged iokit_family_msg(sub_iokit_pmu, 0x100)
864 // Apple private Legacy messages for re-routing AutoWake and AutoPower messages to the PMU
865 // through newer user space IOPMSchedulePowerEvent API
866 #define kIOPMUMessageLegacyAutoWake iokit_family_msg(sub_iokit_pmu, 0x200)
867 #define kIOPMUMessageLegacyAutoPower iokit_family_msg(sub_iokit_pmu, 0x210)
869 // For use with IOPMPowerSource bFlags
870 #define IOPM_POWER_SOURCE_REV 2
872 kIOPMACInstalled
= kIOBatteryChargerConnect
,
873 kIOPMBatteryCharging
= kIOBatteryCharge
,
874 kIOPMBatteryInstalled
= kIOBatteryInstalled
,
875 kIOPMUPSInstalled
= (1 << 3),
876 kIOPMBatteryAtWarn
= (1 << 4),
877 kIOPMBatteryDepleted
= (1 << 5),
878 kIOPMACnoChargeCapability
= (1 << 6), // AC adapter cannot charge battery
879 kIOPMRawLowBattery
= (1 << 7), // used only by Platform Expert
880 kIOPMForceLowSpeed
= (1 << 8), // set by Platfm Expert, chk'd by Pwr Plugin
881 kIOPMClosedClamshell
= (1 << 9), // set by PMU - reflects state of the clamshell
882 kIOPMClamshellStateOnWake
= (1 << 10) // used only by Platform Expert
885 // **********************************************
886 // Internal power management data structures
887 // **********************************************
889 #if KERNEL && __cplusplus
893 kIOPowerEmergencyLevel
= 1000
898 kIOPMSuperclassPolicy1
899 #ifdef KERNEL_PRIVATE
900 , kIOPMActivityTickleTypeAdvisory
= 128
904 struct stateChangeNote
{
905 IOPMPowerFlags stateFlags
;
906 unsigned long stateNum
;
909 typedef struct stateChangeNote stateChangeNote
;
911 #endif /* KERNEL && __cplusplus */
912 struct IOPowerStateChangeNotification
{
914 unsigned long returnValue
;
915 unsigned long stateNumber
;
916 IOPMPowerFlags stateFlags
;
918 typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification
;
919 typedef IOPowerStateChangeNotification sleepWakeNote
;
921 /*! @struct IOPMSystemCapabilityChangeParameters
922 * @abstract A structure describing a system capability change.
923 * @discussion A system capability change is a system level transition from a set
924 * of system capabilities to a new set of system capabilities. Power management
925 * sends a <code>kIOMessageSystemCapabilityChange</code> message and provides
926 * this structure as the message data (by reference) to
927 * <code>gIOPriorityPowerStateInterest</code> clients when system capability
929 * @field notifyRef An identifier for this message notification. Clients with pending
930 * I/O can signal completion by calling <code>allowPowerChange()</code> with this
931 * value as the argument. Clients that are able to process the notification
932 * synchronously should ignore this field.
933 * @field maxWaitForReply A return value to the caller indicating the maximum time in
934 * microseconds to wait for the <code>allowPowerChange()</code> call. The default
935 * value is zero, which indicates the client processing has finished, and power
936 * management should not wait for an <code>allowPowerChange()</code> call.
937 * @field changeFlags Flags will be set to indicate whether the notification precedes
938 * the capability change (<code>kIOPMSystemCapabilityWillChange</code>), or after
939 * the capability change has occurred (<code>kIOPMSystemCapabilityDidChange</code>).
940 * @field __reserved1 Set to zero.
941 * @field fromCapabilities The system capabilities at the start of the transition.
942 * @field toCapabilities The system capabilities at the end of the transition.
943 * @field __reserved2 Set to zero.
945 struct IOPMSystemCapabilityChangeParameters
{
947 uint32_t maxWaitForReply
;
948 uint32_t changeFlags
;
949 uint32_t __reserved1
;
950 uint32_t fromCapabilities
;
951 uint32_t toCapabilities
;
952 uint32_t __reserved2
[4];
955 /*! @enum IOPMSystemCapabilityChangeFlags
956 * @constant kIOPMSystemCapabilityWillChange Indicates the system capability will change.
957 * @constant kIOPMSystemCapabilityDidChange Indicates the system capability has changed.
960 kIOPMSystemCapabilityWillChange
= 0x01,
961 kIOPMSystemCapabilityDidChange
= 0x02
965 kIOPMSystemCapabilityCPU
= 0x01,
966 kIOPMSystemCapabilityGraphics
= 0x02,
967 kIOPMSystemCapabilityAudio
= 0x04,
968 kIOPMSystemCapabilityNetwork
= 0x08
971 #endif /* ! _IOKIT_IOPM_H */