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 #if !(defined(RC_HIDE_N144) || defined(RC_HIDE_N146))
107 kIOPMAOTPower
= 0x00020000,
108 kIOPMAOTCapability
= kIOPMAOTPower
,
109 #endif /* !(defined(RC_HIDE_N144) || defined(RC_HIDE_N146)) */
111 kIOPMPreventIdleSleep
= 0x00000040,
112 kIOPMSleepCapability
= 0x00000004,
113 kIOPMRestartCapability
= 0x00000080,
114 kIOPMSleep
= 0x00000001,
115 kIOPMRestart
= 0x00000080,
116 kIOPMInitialDeviceState
= 0x00000100,
117 kIOPMRootDomainState
= 0x00000200
121 * Private IOPMPowerFlags
124 * Not for use with non-Apple drivers
125 * Their behavior is undefined
128 kIOPMClockNormal
= 0x0004,
129 kIOPMClockRunning
= 0x0008,
130 kIOPMPreventSystemSleep
= 0x0010,
132 kIOPMChildClamp
= 0x0080,
133 kIOPMChildClamp2
= 0x0200,
134 kIOPMNotPowerManaged
= 0x0800
138 * Deprecated IOPMPowerFlags
139 * Their behavior is undefined when used in IOPMPowerState
140 * Capability, InputPowerRequirement, or OutputPowerCharacter fields.
143 kIOPMMaxPerformance
= 0x4000,
144 kIOPMPassThrough
= 0x0100,
145 kIOPMAuxPowerOn
= 0x0020,
146 kIOPMNotAttainable
= 0x0001,
147 kIOPMContextRetained
= 0x2000,
148 kIOPMConfigRetained
= 0x1000,
149 kIOPMStaticPowerValid
= 0x0800,
150 kIOPMSoftSleep
= 0x0400,
151 kIOPMCapabilitiesMask
= kIOPMPowerOn
| kIOPMDeviceUsable
|
152 kIOPMMaxPerformance
| kIOPMContextRetained
|
153 kIOPMConfigRetained
| kIOPMSleepCapability
|
154 kIOPMRestartCapability
158 * Support for old names of IOPMPowerFlag constants
161 IOPMNotAttainable
= kIOPMNotAttainable
,
162 IOPMPowerOn
= kIOPMPowerOn
,
163 IOPMClockNormal
= kIOPMClockNormal
,
164 IOPMClockRunning
= kIOPMClockRunning
,
165 IOPMAuxPowerOn
= kIOPMAuxPowerOn
,
166 IOPMDeviceUsable
= kIOPMDeviceUsable
,
167 IOPMMaxPerformance
= kIOPMMaxPerformance
,
168 IOPMContextRetained
= kIOPMContextRetained
,
169 IOPMConfigRetained
= kIOPMConfigRetained
,
170 IOPMNotPowerManaged
= kIOPMNotPowerManaged
,
171 IOPMSoftSleep
= kIOPMSoftSleep
176 kIOPMNextHigherState
= 1,
177 kIOPMHighestState
= 2,
178 kIOPMNextLowerState
= 3,
183 IOPMNextHigherState
= kIOPMNextHigherState
,
184 IOPMHighestState
= kIOPMHighestState
,
185 IOPMNextLowerState
= kIOPMNextLowerState
,
186 IOPMLowestState
= kIOPMLowestState
189 // Internal commands used by power managment command queue
191 kIOPMBroadcastAggressiveness
= 1,
195 // Power consumption unknown value
197 kIOPMUnknown
= 0xFFFF
200 /*******************************************************************************
202 * Root Domain property keys of interest
204 ******************************************************************************/
206 /* AppleClamshellState
207 * reflects the state of the clamshell (lid) on a portable.
208 * It has a boolean value.
209 * true == clamshell is closed
210 * false == clamshell is open
211 * not present == no clamshell on this hardware
213 #define kAppleClamshellStateKey "AppleClamshellState"
215 /* AppleClamshellCausesSleep
216 * reflects the clamshell close behavior on a portable.
217 * It has a boolean value.
218 * true == system will sleep when clamshell is closed
219 * false == system will not sleep on clamshell close
220 * (typically external display mode)
221 * not present == no clamshell on this hardware
223 #define kAppleClamshellCausesSleepKey "AppleClamshellCausesSleep"
225 /* kIOPMSleepWakeUUIDKey
226 * Key refers to a CFStringRef that will uniquely identify
227 * a sleep/wake cycle for logging & tracking.
228 * The key becomes valid at the beginning of a sleep cycle - before we
229 * initiate any sleep/wake notifications.
230 * The key becomes invalid at the completion of a system wakeup. The
231 * property will not be present in the IOPMrootDomain's registry entry
232 * when it is invalid.
234 * See IOPMrootDomain notification kIOPMMessageSleepWakeUUIDChange
236 #define kIOPMSleepWakeUUIDKey "SleepWakeUUID"
238 /* kIOPMBootSessionUUIDKey
239 * Key refers to a CFStringRef that will uniquely identify
241 * The key becomes valid at boot time and remains valid
242 * till shutdown. The property value will remain same across
243 * sleep/wake/hibernate cycle.
245 #define kIOPMBootSessionUUIDKey "BootSessionUUID"
247 /* kIOPMDeepSleepEnabledKey
248 * Indicates the Deep Sleep enable state.
249 * It has a boolean value.
250 * true == Deep Sleep is enabled
251 * false == Deep Sleep is disabled
252 * not present == Deep Sleep is not supported on this hardware
254 #define kIOPMDeepSleepEnabledKey "Standby Enabled"
256 /* kIOPMDeepSleepDelayKey
257 * Key refers to a CFNumberRef that represents the delay in seconds before
258 * entering Deep Sleep state when on battery power and when remaining
259 * battery capacity is below a particular threshold (e.g., 50%.) The
260 * property is not present if Deep Sleep is unsupported.
262 #define kIOPMDeepSleepDelayKey "Standby Delay"
264 /* kIOPMDeepSleepDelayHighKey
265 * Key refers to a CFNumberRef that represents the delay in seconds before
266 * entering Deep Sleep state. This is used instead of the value specified by
267 * kIOPMDeepSleepDelayKey if the remaining battery capacity is above a
268 * particular threshold (e.g. 50%) or on AC power. The property is not
269 * present if Deep Sleep is unsupported.
271 #define kIOPMDeepSleepDelayHighKey "High Standby Delay"
273 /* kIOPMLowBatteryThresholdKey
274 * Key refers to a CFNumberRef that represents the threshold used to choose
275 * between the normal deep sleep delay and the high deep sleep delay (as a
276 * percentage of total battery capacity remaining.) The property is not
277 * present if Deep Sleep is unsupported.
279 #define kIOPMStandbyBatteryThresholdKey "Standby Battery Threshold"
281 /* kIOPMDestroyFVKeyOnStandbyKey
282 * Specifies if FileVault key can be stored when going to standby mode
283 * It has a boolean value,
284 * true == Destroy FV key when going to standby mode
285 * false == Retain FV key when going to standby mode
286 * not present == Retain FV key when going to standby mode
288 #define kIOPMDestroyFVKeyOnStandbyKey "DestroyFVKeyOnStandby"
290 /*******************************************************************************
292 * Properties that can control power management behavior
294 ******************************************************************************/
296 /* kIOPMResetPowerStateOnWakeKey
297 * If an IOService publishes this key with the value of kOSBooleanTrue,
298 * then PM will disregard the influence from changePowerStateToPriv() or
299 * any activity tickles that occurred before system sleep when resolving
300 * the initial device power state on wake. Influences from power children
301 * and changePowerStateTo() are not eliminated. At the earliest opportunity
302 * upon system wake, PM will query the driver for a new power state to be
303 * installed as the initial changePowerStateToPriv() influence, by calling
304 * initialPowerStateForDomainState() with both kIOPMRootDomainState and
305 * kIOPMPowerOn flags set. The default implementation will always return
306 * the lowest power state. Drivers can override this default behavior to
307 * immediately raise the power state when there are work blocked on the
308 * power change, and cannot afford to wait until the next activity tickle.
309 * This property should be statically added to a driver's plist or set at
310 * runtime before calling PMinit().
312 #define kIOPMResetPowerStateOnWakeKey "IOPMResetPowerStateOnWake"
314 /*******************************************************************************
316 * Driver PM Assertions
318 ******************************************************************************/
320 /* Driver Assertion bitfield description
321 * Driver PM assertions are defined by these bits.
324 /*! kIOPMDriverAssertionCPUBit
325 * When set, PM kernel will prefer to leave the CPU and core hardware
326 * running in "Dark Wake" state, instead of sleeping.
328 kIOPMDriverAssertionCPUBit
= 0x01,
330 /*! kIOPMDriverAssertionPreventSystemIdleSleepBit
331 * When set, the system should not idle sleep. This does not prevent
334 kIOPMDriverAssertionPreventSystemIdleSleepBit
= 0x02,
336 /*! kIOPMDriverAssertionUSBExternalDeviceBit
337 * When set, driver is informing PM that an external USB device is attached.
339 kIOPMDriverAssertionUSBExternalDeviceBit
= 0x04,
341 /*! kIOPMDriverAssertionBluetoothHIDDevicePairedBit
342 * When set, driver is informing PM that a Bluetooth HID device is paired.
344 kIOPMDriverAssertionBluetoothHIDDevicePairedBit
= 0x08,
346 /*! kIOPMDriverAssertionExternalMediaMountedBit
347 * When set, driver is informing PM that an external media is mounted.
349 kIOPMDriverAssertionExternalMediaMountedBit
= 0x10,
351 /*! kIOPMDriverAssertionReservedBit5
352 * Reserved for Thunderbolt.
354 kIOPMDriverAssertionReservedBit5
= 0x20,
356 /*! kIOPMDriverAssertionPreventDisplaySleepBit
357 * When set, the display should remain powered on while the system's awake.
359 kIOPMDriverAssertionPreventDisplaySleepBit
= 0x40,
361 /*! kIOPMDriverAssertionReservedBit7
362 * Reserved for storage family.
364 kIOPMDriverAssertionReservedBit7
= 0x80,
366 /*! kIOPMDriverAssertionMagicPacketWakeEnabledBit
367 * When set, driver is informing PM that magic packet wake is enabled.
369 kIOPMDriverAssertionMagicPacketWakeEnabledBit
= 0x100,
371 /*! kIOPMDriverAssertionNetworkKeepAliveActiveBit
372 * When set, driver is informing PM that it is holding the network
373 * interface up to do TCPKeepAlive
375 kIOPMDriverAssertionNetworkKeepAliveActiveBit
= 0x200
378 /* kIOPMAssertionsDriverKey
379 * This kIOPMrootDomain key refers to a CFNumberRef property, containing
380 * a bitfield describing the aggregate PM assertion levels.
381 * Example: A value of 0 indicates that no driver has asserted anything.
382 * Or, a value of <link>kIOPMDriverAssertionCPUBit</link>
383 * indicates that a driver (or drivers) have asserted a need for CPU and video.
385 #define kIOPMAssertionsDriverKey "DriverPMAssertions"
387 /* kIOPMAssertionsDriverKey
388 * This kIOPMrootDomain key refers to a CFNumberRef property, containing
389 * a bitfield describing the aggregate PM assertion levels.
390 * Example: A value of 0 indicates that no driver has asserted anything.
391 * Or, a value of <link>kIOPMDriverAssertionCPUBit</link>
392 * indicates that a driver (or drivers) have asserted a need for CPU and video.
394 #define kIOPMAssertionsDriverDetailedKey "DriverPMAssertionsDetailed"
396 /*******************************************************************************
398 * Kernel Driver assertion detailed dictionary keys
400 * Keys decode the Array & dictionary data structure under IOPMrootDomain property
401 * kIOPMAssertionsDriverKey.
404 #define kIOPMDriverAssertionIDKey "ID"
405 #define kIOPMDriverAssertionCreatedTimeKey "CreatedTime"
406 #define kIOPMDriverAssertionModifiedTimeKey "ModifiedTime"
407 #define kIOPMDriverAssertionOwnerStringKey "Owner"
408 #define kIOPMDriverAssertionOwnerServiceKey "ServicePtr"
409 #define kIOPMDriverAssertionRegistryEntryIDKey "RegistryEntryID"
410 #define kIOPMDriverAssertionLevelKey "Level"
411 #define kIOPMDriverAssertionAssertedKey "Assertions"
413 /*******************************************************************************
415 * Root Domain general interest messages
417 * Available by registering for interest type 'gIOGeneralInterest'
420 ******************************************************************************/
422 /* kIOPMMessageClamshellStateChange
423 * Delivered as a general interest notification on the IOPMrootDomain
424 * IOPMrootDomain sends this message when state of either AppleClamshellState
425 * or AppleClamshellCausesSleep changes. If this clamshell change results in
426 * a sleep, the sleep will initiate soon AFTER delivery of this message.
427 * The state of both variables is encoded in a bitfield argument sent with
428 * the message. Check bits 0 and 1 using kClamshellStateBit & kClamshellSleepBit
431 kClamshellStateBit
= (1 << 0),
432 kClamshellSleepBit
= (1 << 1)
435 #define kIOPMMessageClamshellStateChange \
436 iokit_family_msg(sub_iokit_powermanagement, 0x100)
438 /* kIOPMMessageFeatureChange
439 * Delivered when the set of supported features ("Supported Features" dictionary
440 * under IOPMrootDomain registry) changes in some way. Typically addition or
441 * removal of a supported feature.
442 * RootDomain passes no argument with this message.
444 #define kIOPMMessageFeatureChange \
445 iokit_family_msg(sub_iokit_powermanagement, 0x110)
447 /* kIOPMMessageInflowDisableCancelled
448 * The battery has drained completely to its "Fully Discharged" state.
449 * If a user process has disabled battery inflow for battery
450 * calibration, we forcibly re-enable Inflow at this point.
451 * If inflow HAS been forcibly re-enabled, bit 0
452 * (kInflowForciblyEnabledBit) will be set.
455 kInflowForciblyEnabledBit
= (1 << 0)
458 /* kIOPMMessageInternalBatteryFullyDischarged
459 * The battery has drained completely to its "Fully Discharged" state.
461 #define kIOPMMessageInternalBatteryFullyDischarged \
462 iokit_family_msg(sub_iokit_powermanagement, 0x120)
464 /* kIOPMMessageSystemPowerEventOccurred
465 * Some major system thermal property has changed, and interested clients may
466 * modify their behavior.
468 #define kIOPMMessageSystemPowerEventOccurred \
469 iokit_family_msg(sub_iokit_powermanagement, 0x130)
471 /* kIOPMMessageSleepWakeUUIDChange
472 * Either a new SleepWakeUUID has been specified at the beginning of a sleep,
473 * or we're removing the existing property upon completion of a wakeup.
475 #define kIOPMMessageSleepWakeUUIDChange \
476 iokit_family_msg(sub_iokit_powermanagement, 0x140)
478 /* kIOPMMessageSleepWakeUUIDSet
479 * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when
480 * a new UUID has been specified.
482 #define kIOPMMessageSleepWakeUUIDSet ((void *)1)
484 /* kIOPMMessageSleepWakeUUIDCleared
485 * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when
486 * the current UUID has been removed.
488 #define kIOPMMessageSleepWakeUUIDCleared ((void *)NULL)
490 /*! kIOPMMessageDriverAssertionsChanged
491 * Sent when kernel PM driver assertions have changed.
493 #define kIOPMMessageDriverAssertionsChanged \
494 iokit_family_msg(sub_iokit_powermanagement, 0x150)
496 /*! kIOPMMessageDarkWakeThermalEmergency
497 * Sent when machine becomes unsustainably warm in DarkWake.
498 * Kernel PM might choose to put the machine back to sleep right after.
500 #define kIOPMMessageDarkWakeThermalEmergency \
501 iokit_family_msg(sub_iokit_powermanagement, 0x160)
503 /*******************************************************************************
505 * Power commands issued to root domain
506 * Use with IOPMrootDomain::receivePowerNotification()
508 * These commands are issued from system drivers only:
509 * ApplePMU, AppleSMU, IOGraphics, AppleACPIFamily
511 * TODO: deprecate kIOPMAllowSleep and kIOPMPreventSleep
512 ******************************************************************************/
514 kIOPMSleepNow
= (1 << 0),// put machine to sleep now
515 kIOPMAllowSleep
= (1 << 1),// allow idle sleep
516 kIOPMPreventSleep
= (1 << 2),// do not allow idle sleep
517 kIOPMPowerButton
= (1 << 3),// power button was pressed
518 kIOPMClamshellClosed
= (1 << 4),// clamshell was closed
519 kIOPMPowerEmergency
= (1 << 5),// battery dangerously low
520 kIOPMDisableClamshell
= (1 << 6),// do not sleep on clamshell closure
521 kIOPMEnableClamshell
= (1 << 7),// sleep on clamshell closure
522 kIOPMProcessorSpeedChange
= (1 << 8),// change the processor speed
523 kIOPMOverTemp
= (1 << 9),// system dangerously hot
524 kIOPMClamshellOpened
= (1 << 10),// clamshell was opened
525 kIOPMDWOverTemp
= (1 << 11),// DarkWake thermal limits exceeded.
526 kIOPMPowerButtonUp
= (1 << 12),// Power button up
527 kIOPMProModeEngaged
= (1 << 13),// Fans entered 'ProMode'
528 kIOPMProModeDisengaged
= (1 << 14) // Fans exited 'ProMode'
532 /*******************************************************************************
534 * Power Management Return Codes
536 ******************************************************************************/
540 // Returned by driver's setPowerState(), powerStateWillChangeTo(),
541 // powerStateDidChangeTo(), or acknowledgeSetPowerState() to
542 // implicitly acknowledge power change upon function return.
546 kIOPMWillAckLater
= 1,
548 // Returned by requestPowerDomainState() to indicate
549 // unrecognized specification parameter.
550 kIOPMBadSpecification
= 4,
552 // Returned by requestPowerDomainState() to indicate
553 // no power state matches search specification.
554 kIOPMNoSuchState
= 5,
557 kIOPMCannotRaisePower
= 6,
560 kIOPMParameterError
= 7,
562 // Returned when power management state is accessed
563 // before driver has called PMinit().
564 kIOPMNotYetInitialized
= 8,
566 // And the old constants; deprecated
567 IOPMNoErr
= kIOPMNoErr
,
568 IOPMAckImplied
= kIOPMAckImplied
,
569 IOPMWillAckLater
= kIOPMWillAckLater
,
570 IOPMBadSpecification
= kIOPMBadSpecification
,
571 IOPMNoSuchState
= kIOPMNoSuchState
,
572 IOPMCannotRaisePower
= kIOPMCannotRaisePower
,
573 IOPMParameterError
= kIOPMParameterError
,
574 IOPMNotYetInitialized
= kIOPMNotYetInitialized
578 // IOPMPowerSource class descriptive strings
579 // Power Source state is published as properties to the IORegistry under these
581 #define kIOPMPSExternalConnectedKey "ExternalConnected"
582 #define kIOPMPSExternalChargeCapableKey "ExternalChargeCapable"
583 #define kIOPMPSBatteryInstalledKey "BatteryInstalled"
584 #define kIOPMPSIsChargingKey "IsCharging"
585 #define kIOPMFullyChargedKey "FullyCharged"
586 #define kIOPMPSAtWarnLevelKey "AtWarnLevel"
587 #define kIOPMPSAtCriticalLevelKey "AtCriticalLevel"
588 #define kIOPMPSCurrentCapacityKey "CurrentCapacity"
589 #define kIOPMPSMaxCapacityKey "MaxCapacity"
590 #define kIOPMPSDesignCapacityKey "DesignCapacity"
591 #define kIOPMPSTimeRemainingKey "TimeRemaining"
592 #define kIOPMPSAmperageKey "Amperage"
593 #define kIOPMPSVoltageKey "Voltage"
594 #define kIOPMPSCycleCountKey "CycleCount"
595 #define kIOPMPSMaxErrKey "MaxErr"
596 #define kIOPMPSAdapterInfoKey "AdapterInfo"
597 #define kIOPMPSLocationKey "Location"
598 #define kIOPMPSErrorConditionKey "ErrorCondition"
599 #define kIOPMPSManufacturerKey "Manufacturer"
600 #define kIOPMPSManufactureDateKey "ManufactureDate"
601 #define kIOPMPSModelKey "Model"
602 #define kIOPMPSSerialKey "Serial"
603 #define kIOPMDeviceNameKey "DeviceName"
604 #define kIOPMPSLegacyBatteryInfoKey "LegacyBatteryInfo"
605 #define kIOPMPSBatteryHealthKey "BatteryHealth"
606 #define kIOPMPSHealthConfidenceKey "HealthConfidence"
607 #define kIOPMPSCapacityEstimatedKey "CapacityEstimated"
608 #define kIOPMPSBatteryChargeStatusKey "ChargeStatus"
609 #define kIOPMPSBatteryTemperatureKey "Temperature"
610 #define kIOPMPSAdapterDetailsKey "AdapterDetails"
611 #define kIOPMPSChargerConfigurationKey "ChargerConfiguration"
613 // kIOPMPSBatteryChargeStatusKey may have one of the following values, or may have
614 // no value. If kIOPMBatteryChargeStatusKey has a NULL value (or no value) associated with it
615 // then charge is proceeding normally. If one of these battery charge status reasons is listed,
616 // then the charge may have been interrupted.
617 #define kIOPMBatteryChargeStatusTooHot "HighTemperature"
618 #define kIOPMBatteryChargeStatusTooCold "LowTemperature"
619 #define kIOPMBatteryChargeStatusTooHotOrCold "HighOrLowTemperature"
620 #define kIOPMBatteryChargeStatusGradient "BatteryTemperatureGradient"
622 // Definitions for battery location, in case of multiple batteries.
623 // A location of 0 is unspecified
624 // Location is undefined for single battery systems
626 kIOPMPSLocationLeft
= 1001,
627 kIOPMPSLocationRight
= 1002
630 // Battery quality health types, specified by BatteryHealth and HealthConfidence
631 // properties in an IOPMPowerSource battery kext.
633 kIOPMUndefinedValue
= 0,
639 // Keys for kIOPMPSAdapterDetailsKey dictionary
640 #define kIOPMPSAdapterDetailsIDKey "AdapterID"
641 #define kIOPMPSAdapterDetailsWattsKey "Watts"
642 #define kIOPMPSAdapterDetailsRevisionKey "AdapterRevision"
643 #define kIOPMPSAdapterDetailsSerialNumberKey "SerialNumber"
644 #define kIOPMPSAdapterDetailsFamilyKey "FamilyCode"
645 #define kIOPMPSAdapterDetailsAmperageKey "Current"
646 #define kIOPMPSAdapterDetailsDescriptionKey "Description"
647 #define kIOPMPSAdapterDetailsPMUConfigurationKey "PMUConfiguration"
648 #define kIOPMPSAdapterDetailsVoltage "Voltage"
649 #define kIOPMPSAdapterDetailsSourceIDKey "Source"
650 #define kIOPMPSAdapterDetailsErrorFlagsKey "ErrorFlags"
651 #define kIOPMPSAdapterDetailsSharedSourceKey "SharedSource"
652 #define kIOPMPSAdapterDetailsCloakedKey "CloakedSource"
654 // values for kIOPSPowerAdapterFamilyKey
656 kIOPSFamilyCodeDisconnected
= 0,
657 kIOPSFamilyCodeUnsupported
= kIOReturnUnsupported
,
658 kIOPSFamilyCodeFirewire
= iokit_family_err(sub_iokit_firewire
, 0),
659 kIOPSFamilyCodeUSBHost
= iokit_family_err(sub_iokit_usb
, 0),
660 kIOPSFamilyCodeUSBHostSuspended
= iokit_family_err(sub_iokit_usb
, 1),
661 kIOPSFamilyCodeUSBDevice
= iokit_family_err(sub_iokit_usb
, 2),
662 kIOPSFamilyCodeUSBAdapter
= iokit_family_err(sub_iokit_usb
, 3),
663 kIOPSFamilyCodeUSBChargingPortDedicated
= iokit_family_err(sub_iokit_usb
, 4),
664 kIOPSFamilyCodeUSBChargingPortDownstream
= iokit_family_err(sub_iokit_usb
, 5),
665 kIOPSFamilyCodeUSBChargingPort
= iokit_family_err(sub_iokit_usb
, 6),
666 kIOPSFamilyCodeUSBUnknown
= iokit_family_err(sub_iokit_usb
, 7),
667 kIOPSFamilyCodeUSBCBrick
= iokit_family_err(sub_iokit_usb
, 8),
668 kIOPSFamilyCodeUSBCTypeC
= iokit_family_err(sub_iokit_usb
, 9),
669 kIOPSFamilyCodeUSBCPD
= iokit_family_err(sub_iokit_usb
, 10),
670 kIOPSFamilyCodeAC
= iokit_family_err(sub_iokit_pmu
, 0),
671 kIOPSFamilyCodeExternal
= iokit_family_err(sub_iokit_pmu
, 1),
672 kIOPSFamilyCodeExternal2
= iokit_family_err(sub_iokit_pmu
, 2),
673 kIOPSFamilyCodeExternal3
= iokit_family_err(sub_iokit_pmu
, 3),
674 kIOPSFamilyCodeExternal4
= iokit_family_err(sub_iokit_pmu
, 4),
675 kIOPSFamilyCodeExternal5
= iokit_family_err(sub_iokit_pmu
, 5),
678 // values for kIOPMPSAdapterDetailsErrorFlagsKey
680 kIOPSAdapterErrorFlagNoErrors
= 0,
681 kIOPSAdapterErrorFlagInsufficientAvailablePower
= (1 << 1),
682 kIOPSAdapterErrorFlagForeignObjectDetected
= (1 << 2),
683 kIOPSAdapterErrorFlagDeviceNeedsToBeRepositioned
= (1 << 3),
686 // Battery's time remaining estimate is invalid this long (seconds) after a wake
687 #define kIOPMPSInvalidWakeSecondsKey "BatteryInvalidWakeSeconds"
689 // Battery must wait this long (seconds) after being completely charged before
690 // the battery is settled.
691 #define kIOPMPSPostChargeWaitSecondsKey "PostChargeWaitSeconds"
693 // Battery must wait this long (seconds) after being completely discharged
694 // before the battery is settled.
695 #define kIOPMPSPostDishargeWaitSecondsKey "PostDischargeWaitSeconds"
698 /* CPU Power Management status keys
699 * Pass as arguments to IOPMrootDomain::systemPowerEventOccurred
700 * Or as arguments to IOPMSystemPowerEventOccurred()
701 * Or to decode the dictionary obtained from IOPMCopyCPUPowerStatus()
702 * These keys reflect restrictions placed on the CPU by the system
703 * to bring the CPU's power consumption within allowable thermal and
708 /* kIOPMGraphicsPowerLimitsKey
709 * The key representing the dictionary of graphics power limits.
710 * The dictionary contains the other kIOPMCPUPower keys & their associated
711 * values (e.g. Speed limit, Processor Count, and Schedule limits).
713 #define kIOPMGraphicsPowerLimitsKey "Graphics_Power_Limits"
715 /* kIOPMGraphicsPowerLimitPerformanceKey
716 * The key representing the percent of overall performance made available
717 * by the graphics chip as a percentage (integer 0 - 100).
719 #define kIOPMGraphicsPowerLimitPerformanceKey "Graphics_Power_Performance"
723 /* kIOPMCPUPowerLimitsKey
724 * The key representing the dictionary of CPU Power Limits.
725 * The dictionary contains the other kIOPMCPUPower keys & their associated
726 * values (e.g. Speed limit, Processor Count, and Schedule limits).
728 #define kIOPMCPUPowerLimitsKey "CPU_Power_Limits"
730 /* kIOPMCPUPowerLimitProcessorSpeedKey defines the speed & voltage limits placed
732 * Represented as a percentage (0-100) of maximum CPU speed.
734 #define kIOPMCPUPowerLimitProcessorSpeedKey "CPU_Speed_Limit"
736 /* kIOPMCPUPowerLimitProcessorCountKey reflects how many, if any, CPUs have been
737 * taken offline. Represented as an integer number of CPUs (0 - Max CPUs).
739 #define kIOPMCPUPowerLimitProcessorCountKey "CPU_Available_CPUs"
741 /* kIOPMCPUPowerLimitSchedulerTimeKey represents the percentage (0-100) of CPU time
742 * available. 100% at normal operation. The OS may limit this time for a percentage
745 #define kIOPMCPUPowerLimitSchedulerTimeKey "CPU_Scheduler_Limit"
748 /* Thermal Level Warning Key
749 * Indicates the thermal constraints placed on the system. This value may
750 * cause clients to action to consume fewer system resources.
751 * The value associated with this warning is defined by the platform.
753 #define kIOPMThermalLevelWarningKey "Thermal_Level_Warning"
755 /* Thermal Warning Level values
756 * kIOPMThermalLevelNormal - under normal operating conditions
757 * kIOPMThermalLevelDanger - thermal pressure may cause system slowdown
758 * kIOPMThermalLevelCritical - thermal conditions may cause imminent shutdown
760 * The platform may define additional thermal levels if necessary.
761 * Platform specific values are defined from 100 and above
764 kIOPMThermalLevelNormal
= 0,
765 kIOPMThermalLevelDanger
= 5,
766 kIOPMThermalLevelCritical
= 10,
768 kIOPMThermalLevelWarning
= 100,
769 kIOPMThermalLevelTrap
= 110,
771 kIOPMThermalLevelUnknown
= 255,
774 #define kIOPMThermalWarningLevelNormal kIOPMThermalLevelNormal
775 #define kIOPMThermalWarningLevelDanger kIOPMThermalLevelWarning
776 #define kIOPMThermalWarningLevelCrisis kIOPMThermalLevelCritical
778 // PM Settings Controller setting types
779 // Settings types used primarily with:
780 // IOPMrootDomain::registerPMSettingController
781 // The values are identical to the similarly named keys for use in user space
782 // PM settings work. Those keys are defined in IOPMLibPrivate.h.
783 #define kIOPMSettingWakeOnRingKey "Wake On Modem Ring"
784 #define kIOPMSettingRestartOnPowerLossKey "Automatic Restart On Power Loss"
785 #define kIOPMSettingWakeOnACChangeKey "Wake On AC Change"
786 #define kIOPMSettingSleepOnPowerButtonKey "Sleep On Power Button"
787 #define kIOPMSettingWakeOnClamshellKey "Wake On Clamshell Open"
788 #define kIOPMSettingReduceBrightnessKey "ReduceBrightness"
789 #define kIOPMSettingDisplaySleepUsesDimKey "Display Sleep Uses Dim"
790 #define kIOPMSettingTimeZoneOffsetKey "TimeZoneOffsetSeconds"
791 #define kIOPMSettingMobileMotionModuleKey "MobileMotionModule"
792 #define kIOPMSettingGraphicsSwitchKey "GPUSwitch"
793 #define kIOPMSettingProModeControl "ProModeControl"
794 #define kIOPMSettingProModeDefer "ProModeDefer"
796 // Setting controlling drivers can register to receive scheduled wake data
797 // Either in "CF seconds" type, or structured calendar data in a formatted
798 // IOPMCalendarStruct defined below.
799 #define kIOPMSettingAutoWakeSecondsKey "wake"
800 #define kIOPMSettingAutoWakeCalendarKey "WakeByCalendarDate"
801 #define kIOPMSettingAutoPowerSecondsKey "poweron"
802 #define kIOPMSettingAutoPowerCalendarKey "PowerByCalendarDate"
804 // Debug seconds auto wake
805 // Used by sleep cycling debug tools
806 #define kIOPMSettingDebugWakeRelativeKey "WakeRelativeToSleep"
807 #define kIOPMSettingDebugPowerRelativeKey "PowerRelativeToShutdown"
809 // Maintenance wake calendar.
810 #define kIOPMSettingMaintenanceWakeCalendarKey "MaintenanceWakeCalendarDate"
813 struct IOPMCalendarStruct
{
822 typedef struct IOPMCalendarStruct IOPMCalendarStruct
;
824 // SetAggressiveness types
826 kPMGeneralAggressiveness
= 0,
828 kPMMinutesToSpinDown
,
830 kPMEthernetWakeOnLANSettings
,
831 kPMSetProcessorSpeed
,
834 kPMLastAggressivenessType
836 #define kMaxType (kPMLastAggressivenessType-1)
838 // SetAggressiveness values for the kPMPowerSource aggressiveness type
840 kIOPMInternalPower
= 1,
844 #define kIOREMSleepEnabledKey "REMSleepEnabled"
846 // Strings for deciphering the dictionary returned from IOPMCopyBatteryInfo
847 #define kIOBatteryInfoKey "IOBatteryInfo"
848 #define kIOBatteryCurrentChargeKey "Current"
849 #define kIOBatteryCapacityKey "Capacity"
850 #define kIOBatteryFlagsKey "Flags"
851 #define kIOBatteryVoltageKey "Voltage"
852 #define kIOBatteryAmperageKey "Amperage"
853 #define kIOBatteryCycleCountKey "Cycle Count"
856 kIOBatteryInstalled
= (1 << 2),
857 kIOBatteryCharge
= (1 << 1),
858 kIOBatteryChargerConnect
= (1 << 0)
861 // Private power management message indicating battery data has changed
862 // Indicates new data resides in the IORegistry
863 #define kIOPMMessageBatteryStatusHasChanged iokit_family_msg(sub_iokit_pmu, 0x100)
865 // Apple private Legacy messages for re-routing AutoWake and AutoPower messages to the PMU
866 // through newer user space IOPMSchedulePowerEvent API
867 #define kIOPMUMessageLegacyAutoWake iokit_family_msg(sub_iokit_pmu, 0x200)
868 #define kIOPMUMessageLegacyAutoPower iokit_family_msg(sub_iokit_pmu, 0x210)
870 // For use with IOPMPowerSource bFlags
871 #define IOPM_POWER_SOURCE_REV 2
873 kIOPMACInstalled
= kIOBatteryChargerConnect
,
874 kIOPMBatteryCharging
= kIOBatteryCharge
,
875 kIOPMBatteryInstalled
= kIOBatteryInstalled
,
876 kIOPMUPSInstalled
= (1 << 3),
877 kIOPMBatteryAtWarn
= (1 << 4),
878 kIOPMBatteryDepleted
= (1 << 5),
879 kIOPMACnoChargeCapability
= (1 << 6), // AC adapter cannot charge battery
880 kIOPMRawLowBattery
= (1 << 7), // used only by Platform Expert
881 kIOPMForceLowSpeed
= (1 << 8), // set by Platfm Expert, chk'd by Pwr Plugin
882 kIOPMClosedClamshell
= (1 << 9), // set by PMU - reflects state of the clamshell
883 kIOPMClamshellStateOnWake
= (1 << 10) // used only by Platform Expert
886 // **********************************************
887 // Internal power management data structures
888 // **********************************************
890 #if KERNEL && __cplusplus
894 kIOPowerEmergencyLevel
= 1000
899 kIOPMSuperclassPolicy1
900 #ifdef KERNEL_PRIVATE
901 , kIOPMActivityTickleTypeAdvisory
= 128
905 struct stateChangeNote
{
906 IOPMPowerFlags stateFlags
;
907 unsigned long stateNum
;
910 typedef struct stateChangeNote stateChangeNote
;
912 #endif /* KERNEL && __cplusplus */
913 struct IOPowerStateChangeNotification
{
915 unsigned long returnValue
;
916 unsigned long stateNumber
;
917 IOPMPowerFlags stateFlags
;
919 typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification
;
920 typedef IOPowerStateChangeNotification sleepWakeNote
;
922 /*! @struct IOPMSystemCapabilityChangeParameters
923 * @abstract A structure describing a system capability change.
924 * @discussion A system capability change is a system level transition from a set
925 * of system capabilities to a new set of system capabilities. Power management
926 * sends a <code>kIOMessageSystemCapabilityChange</code> message and provides
927 * this structure as the message data (by reference) to
928 * <code>gIOPriorityPowerStateInterest</code> clients when system capability
930 * @field notifyRef An identifier for this message notification. Clients with pending
931 * I/O can signal completion by calling <code>allowPowerChange()</code> with this
932 * value as the argument. Clients that are able to process the notification
933 * synchronously should ignore this field.
934 * @field maxWaitForReply A return value to the caller indicating the maximum time in
935 * microseconds to wait for the <code>allowPowerChange()</code> call. The default
936 * value is zero, which indicates the client processing has finished, and power
937 * management should not wait for an <code>allowPowerChange()</code> call.
938 * @field changeFlags Flags will be set to indicate whether the notification precedes
939 * the capability change (<code>kIOPMSystemCapabilityWillChange</code>), or after
940 * the capability change has occurred (<code>kIOPMSystemCapabilityDidChange</code>).
941 * @field __reserved1 Set to zero.
942 * @field fromCapabilities The system capabilities at the start of the transition.
943 * @field toCapabilities The system capabilities at the end of the transition.
944 * @field __reserved2 Set to zero.
946 struct IOPMSystemCapabilityChangeParameters
{
948 uint32_t maxWaitForReply
;
949 uint32_t changeFlags
;
950 uint32_t __reserved1
;
951 uint32_t fromCapabilities
;
952 uint32_t toCapabilities
;
953 uint32_t __reserved2
[4];
956 /*! @enum IOPMSystemCapabilityChangeFlags
957 * @constant kIOPMSystemCapabilityWillChange Indicates the system capability will change.
958 * @constant kIOPMSystemCapabilityDidChange Indicates the system capability has changed.
961 kIOPMSystemCapabilityWillChange
= 0x01,
962 kIOPMSystemCapabilityDidChange
= 0x02
966 kIOPMSystemCapabilityCPU
= 0x01,
967 kIOPMSystemCapabilityGraphics
= 0x02,
968 kIOPMSystemCapabilityAudio
= 0x04,
969 kIOPMSystemCapabilityNetwork
= 0x08
972 #endif /* ! _IOKIT_IOPM_H */