]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/pwr_mgt/IOPM.h
xnu-6153.41.3.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / IOPM.h
1 /*
2 * Copyright (c) 1998-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 #ifndef _IOKIT_IOPM_H
29 #define _IOKIT_IOPM_H
30
31 #include <IOKit/IOTypes.h>
32 #include <IOKit/IOMessage.h>
33 #include <IOKit/IOReturn.h>
34
35 /*! @header IOPM.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.
38 *
39 * Most of the constants defined in IOPM.h are deprecated or for Apple internal use only, and are not elaborated on in headerdoc.
40 */
41
42 enum {
43 kIOPMMaxPowerStates = 10,
44 IOPMMaxPowerStates = kIOPMMaxPowerStates
45 };
46
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.
50 *
51 * The comments clearly mark whether each flag should be used in the capabilityFlags field, outputPowerCharacter field, and inputPowerRequirement field, or all three.
52 *
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.
54 *
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.
56 *
57 * @constant kIOPMPowerOn Indicates the device is on, requires power, and provides power. Useful as a: Capability, InputPowerRequirement, OutputPowerCharacter
58 *
59 * @constant kIOPMDeviceUsable Indicates the device is usable in this state. Useful only as a Capability
60 *
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.
64 *
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.
69 *
70 * Useful only as a Capability, although USB drivers should consult USB family documentation for other valid circumstances to use the kIOPMLowPower bit.
71 *
72 * @constant kIOPMPreventIdleSleep
73 * In the capability field of a power state, disallows idle system sleep while the device is in that state.
74 *
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.
76 *
77 * Useful only as a Capability.
78 *
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.
81 *
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.
84 *
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.
87 *
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.
90 *
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>.
93 *
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.
99 */
100 typedef unsigned long IOPMPowerFlags;
101 enum {
102 kIOPMPowerOn = 0x00000002,
103 kIOPMDeviceUsable = 0x00008000,
104 kIOPMLowPower = 0x00010000,
105 #if PRIVATE
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)) */
110 #endif /* PRIVATE */
111 kIOPMPreventIdleSleep = 0x00000040,
112 kIOPMSleepCapability = 0x00000004,
113 kIOPMRestartCapability = 0x00000080,
114 kIOPMSleep = 0x00000001,
115 kIOPMRestart = 0x00000080,
116 kIOPMInitialDeviceState = 0x00000100,
117 kIOPMRootDomainState = 0x00000200
118 };
119
120 /*
121 * Private IOPMPowerFlags
122 *
123 * For Apple use only
124 * Not for use with non-Apple drivers
125 * Their behavior is undefined
126 */
127 enum {
128 kIOPMClockNormal = 0x0004,
129 kIOPMClockRunning = 0x0008,
130 kIOPMPreventSystemSleep = 0x0010,
131 kIOPMDoze = 0x0400,
132 kIOPMChildClamp = 0x0080,
133 kIOPMChildClamp2 = 0x0200,
134 kIOPMNotPowerManaged = 0x0800
135 };
136
137 /*
138 * Deprecated IOPMPowerFlags
139 * Their behavior is undefined when used in IOPMPowerState
140 * Capability, InputPowerRequirement, or OutputPowerCharacter fields.
141 */
142 enum {
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
155 };
156
157 /*
158 * Support for old names of IOPMPowerFlag constants
159 */
160 enum {
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
172 };
173
174
175 enum {
176 kIOPMNextHigherState = 1,
177 kIOPMHighestState = 2,
178 kIOPMNextLowerState = 3,
179 kIOPMLowestState = 4
180 };
181
182 enum {
183 IOPMNextHigherState = kIOPMNextHigherState,
184 IOPMHighestState = kIOPMHighestState,
185 IOPMNextLowerState = kIOPMNextLowerState,
186 IOPMLowestState = kIOPMLowestState
187 };
188
189 // Internal commands used by power managment command queue
190 enum {
191 kIOPMBroadcastAggressiveness = 1,
192 kIOPMUnidleDevice
193 };
194
195 // Power consumption unknown value
196 enum {
197 kIOPMUnknown = 0xFFFF
198 };
199
200 /*******************************************************************************
201 *
202 * Root Domain property keys of interest
203 *
204 ******************************************************************************/
205
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
212 */
213 #define kAppleClamshellStateKey "AppleClamshellState"
214
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
222 */
223 #define kAppleClamshellCausesSleepKey "AppleClamshellCausesSleep"
224
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.
233 *
234 * See IOPMrootDomain notification kIOPMMessageSleepWakeUUIDChange
235 */
236 #define kIOPMSleepWakeUUIDKey "SleepWakeUUID"
237
238 /* kIOPMBootSessionUUIDKey
239 * Key refers to a CFStringRef that will uniquely identify
240 * a boot cycle.
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.
244 */
245 #define kIOPMBootSessionUUIDKey "BootSessionUUID"
246
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
253 */
254 #define kIOPMDeepSleepEnabledKey "Standby Enabled"
255
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.
261 */
262 #define kIOPMDeepSleepDelayKey "Standby Delay"
263
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.
270 */
271 #define kIOPMDeepSleepDelayHighKey "High Standby Delay"
272
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.
278 */
279 #define kIOPMStandbyBatteryThresholdKey "Standby Battery Threshold"
280
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
287 */
288 #define kIOPMDestroyFVKeyOnStandbyKey "DestroyFVKeyOnStandby"
289
290 /*******************************************************************************
291 *
292 * Properties that can control power management behavior
293 *
294 ******************************************************************************/
295
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().
311 */
312 #define kIOPMResetPowerStateOnWakeKey "IOPMResetPowerStateOnWake"
313
314 /*******************************************************************************
315 *
316 * Driver PM Assertions
317 *
318 ******************************************************************************/
319
320 /* Driver Assertion bitfield description
321 * Driver PM assertions are defined by these bits.
322 */
323 enum {
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.
327 */
328 kIOPMDriverAssertionCPUBit = 0x01,
329
330 /*! kIOPMDriverAssertionPreventSystemIdleSleepBit
331 * When set, the system should not idle sleep. This does not prevent
332 * demand sleep.
333 */
334 kIOPMDriverAssertionPreventSystemIdleSleepBit = 0x02,
335
336 /*! kIOPMDriverAssertionUSBExternalDeviceBit
337 * When set, driver is informing PM that an external USB device is attached.
338 */
339 kIOPMDriverAssertionUSBExternalDeviceBit = 0x04,
340
341 /*! kIOPMDriverAssertionBluetoothHIDDevicePairedBit
342 * When set, driver is informing PM that a Bluetooth HID device is paired.
343 */
344 kIOPMDriverAssertionBluetoothHIDDevicePairedBit = 0x08,
345
346 /*! kIOPMDriverAssertionExternalMediaMountedBit
347 * When set, driver is informing PM that an external media is mounted.
348 */
349 kIOPMDriverAssertionExternalMediaMountedBit = 0x10,
350
351 /*! kIOPMDriverAssertionReservedBit5
352 * Reserved for Thunderbolt.
353 */
354 kIOPMDriverAssertionReservedBit5 = 0x20,
355
356 /*! kIOPMDriverAssertionPreventDisplaySleepBit
357 * When set, the display should remain powered on while the system's awake.
358 */
359 kIOPMDriverAssertionPreventDisplaySleepBit = 0x40,
360
361 /*! kIOPMDriverAssertionReservedBit7
362 * Reserved for storage family.
363 */
364 kIOPMDriverAssertionReservedBit7 = 0x80,
365
366 /*! kIOPMDriverAssertionMagicPacketWakeEnabledBit
367 * When set, driver is informing PM that magic packet wake is enabled.
368 */
369 kIOPMDriverAssertionMagicPacketWakeEnabledBit = 0x100,
370
371 /*! kIOPMDriverAssertionNetworkKeepAliveActiveBit
372 * When set, driver is informing PM that it is holding the network
373 * interface up to do TCPKeepAlive
374 */
375 kIOPMDriverAssertionNetworkKeepAliveActiveBit = 0x200
376 };
377
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.
384 */
385 #define kIOPMAssertionsDriverKey "DriverPMAssertions"
386
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.
393 */
394 #define kIOPMAssertionsDriverDetailedKey "DriverPMAssertionsDetailed"
395
396 /*******************************************************************************
397 *
398 * Kernel Driver assertion detailed dictionary keys
399 *
400 * Keys decode the Array & dictionary data structure under IOPMrootDomain property
401 * kIOPMAssertionsDriverKey.
402 *
403 */
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"
412
413 /*******************************************************************************
414 *
415 * Root Domain general interest messages
416 *
417 * Available by registering for interest type 'gIOGeneralInterest'
418 * on IOPMrootDomain.
419 *
420 ******************************************************************************/
421
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
429 */
430 enum {
431 kClamshellStateBit = (1 << 0),
432 kClamshellSleepBit = (1 << 1)
433 };
434
435 #define kIOPMMessageClamshellStateChange \
436 iokit_family_msg(sub_iokit_powermanagement, 0x100)
437
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.
443 */
444 #define kIOPMMessageFeatureChange \
445 iokit_family_msg(sub_iokit_powermanagement, 0x110)
446
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.
453 */
454 enum {
455 kInflowForciblyEnabledBit = (1 << 0)
456 };
457
458 /* kIOPMMessageInternalBatteryFullyDischarged
459 * The battery has drained completely to its "Fully Discharged" state.
460 */
461 #define kIOPMMessageInternalBatteryFullyDischarged \
462 iokit_family_msg(sub_iokit_powermanagement, 0x120)
463
464 /* kIOPMMessageSystemPowerEventOccurred
465 * Some major system thermal property has changed, and interested clients may
466 * modify their behavior.
467 */
468 #define kIOPMMessageSystemPowerEventOccurred \
469 iokit_family_msg(sub_iokit_powermanagement, 0x130)
470
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.
474 */
475 #define kIOPMMessageSleepWakeUUIDChange \
476 iokit_family_msg(sub_iokit_powermanagement, 0x140)
477
478 /* kIOPMMessageSleepWakeUUIDSet
479 * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when
480 * a new UUID has been specified.
481 */
482 #define kIOPMMessageSleepWakeUUIDSet ((void *)1)
483
484 /* kIOPMMessageSleepWakeUUIDCleared
485 * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when
486 * the current UUID has been removed.
487 */
488 #define kIOPMMessageSleepWakeUUIDCleared ((void *)NULL)
489
490 /*! kIOPMMessageDriverAssertionsChanged
491 * Sent when kernel PM driver assertions have changed.
492 */
493 #define kIOPMMessageDriverAssertionsChanged \
494 iokit_family_msg(sub_iokit_powermanagement, 0x150)
495
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.
499 */
500 #define kIOPMMessageDarkWakeThermalEmergency \
501 iokit_family_msg(sub_iokit_powermanagement, 0x160)
502
503 /*******************************************************************************
504 *
505 * Power commands issued to root domain
506 * Use with IOPMrootDomain::receivePowerNotification()
507 *
508 * These commands are issued from system drivers only:
509 * ApplePMU, AppleSMU, IOGraphics, AppleACPIFamily
510 *
511 * TODO: deprecate kIOPMAllowSleep and kIOPMPreventSleep
512 ******************************************************************************/
513 enum {
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'
529 };
530
531
532 /*******************************************************************************
533 *
534 * Power Management Return Codes
535 *
536 ******************************************************************************/
537 enum {
538 kIOPMNoErr = 0,
539
540 // Returned by driver's setPowerState(), powerStateWillChangeTo(),
541 // powerStateDidChangeTo(), or acknowledgeSetPowerState() to
542 // implicitly acknowledge power change upon function return.
543 kIOPMAckImplied = 0,
544
545 // Deprecated
546 kIOPMWillAckLater = 1,
547
548 // Returned by requestPowerDomainState() to indicate
549 // unrecognized specification parameter.
550 kIOPMBadSpecification = 4,
551
552 // Returned by requestPowerDomainState() to indicate
553 // no power state matches search specification.
554 kIOPMNoSuchState = 5,
555
556 // Deprecated
557 kIOPMCannotRaisePower = 6,
558
559 // Deprecated
560 kIOPMParameterError = 7,
561
562 // Returned when power management state is accessed
563 // before driver has called PMinit().
564 kIOPMNotYetInitialized = 8,
565
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
575 };
576
577
578 // IOPMPowerSource class descriptive strings
579 // Power Source state is published as properties to the IORegistry under these
580 // keys.
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"
612
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"
621
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
625 enum {
626 kIOPMPSLocationLeft = 1001,
627 kIOPMPSLocationRight = 1002
628 };
629
630 // Battery quality health types, specified by BatteryHealth and HealthConfidence
631 // properties in an IOPMPowerSource battery kext.
632 enum {
633 kIOPMUndefinedValue = 0,
634 kIOPMPoorValue = 1,
635 kIOPMFairValue = 2,
636 kIOPMGoodValue = 3
637 };
638
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"
653
654 // values for kIOPSPowerAdapterFamilyKey
655 enum {
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),
676 };
677
678 // values for kIOPMPSAdapterDetailsErrorFlagsKey
679 enum {
680 kIOPSAdapterErrorFlagNoErrors = 0,
681 kIOPSAdapterErrorFlagInsufficientAvailablePower = (1 << 1),
682 kIOPSAdapterErrorFlagForeignObjectDetected = (1 << 2),
683 kIOPSAdapterErrorFlagDeviceNeedsToBeRepositioned = (1 << 3),
684 };
685
686 // Battery's time remaining estimate is invalid this long (seconds) after a wake
687 #define kIOPMPSInvalidWakeSecondsKey "BatteryInvalidWakeSeconds"
688
689 // Battery must wait this long (seconds) after being completely charged before
690 // the battery is settled.
691 #define kIOPMPSPostChargeWaitSecondsKey "PostChargeWaitSeconds"
692
693 // Battery must wait this long (seconds) after being completely discharged
694 // before the battery is settled.
695 #define kIOPMPSPostDishargeWaitSecondsKey "PostDischargeWaitSeconds"
696
697
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
704 * power constraints.
705 */
706
707
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).
712 */
713 #define kIOPMGraphicsPowerLimitsKey "Graphics_Power_Limits"
714
715 /* kIOPMGraphicsPowerLimitPerformanceKey
716 * The key representing the percent of overall performance made available
717 * by the graphics chip as a percentage (integer 0 - 100).
718 */
719 #define kIOPMGraphicsPowerLimitPerformanceKey "Graphics_Power_Performance"
720
721
722
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).
727 */
728 #define kIOPMCPUPowerLimitsKey "CPU_Power_Limits"
729
730 /* kIOPMCPUPowerLimitProcessorSpeedKey defines the speed & voltage limits placed
731 * on the CPU.
732 * Represented as a percentage (0-100) of maximum CPU speed.
733 */
734 #define kIOPMCPUPowerLimitProcessorSpeedKey "CPU_Speed_Limit"
735
736 /* kIOPMCPUPowerLimitProcessorCountKey reflects how many, if any, CPUs have been
737 * taken offline. Represented as an integer number of CPUs (0 - Max CPUs).
738 */
739 #define kIOPMCPUPowerLimitProcessorCountKey "CPU_Available_CPUs"
740
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
743 * less than 100%.
744 */
745 #define kIOPMCPUPowerLimitSchedulerTimeKey "CPU_Scheduler_Limit"
746
747
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.
752 */
753 #define kIOPMThermalLevelWarningKey "Thermal_Level_Warning"
754
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
759 *
760 * The platform may define additional thermal levels if necessary.
761 * Platform specific values are defined from 100 and above
762 */
763 enum {
764 kIOPMThermalLevelNormal = 0,
765 kIOPMThermalLevelDanger = 5,
766 kIOPMThermalLevelCritical = 10,
767
768 kIOPMThermalLevelWarning = 100,
769 kIOPMThermalLevelTrap = 110,
770
771 kIOPMThermalLevelUnknown = 255,
772 };
773
774 #define kIOPMThermalWarningLevelNormal kIOPMThermalLevelNormal
775 #define kIOPMThermalWarningLevelDanger kIOPMThermalLevelWarning
776 #define kIOPMThermalWarningLevelCrisis kIOPMThermalLevelCritical
777
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"
795
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"
803
804 // Debug seconds auto wake
805 // Used by sleep cycling debug tools
806 #define kIOPMSettingDebugWakeRelativeKey "WakeRelativeToSleep"
807 #define kIOPMSettingDebugPowerRelativeKey "PowerRelativeToShutdown"
808
809 // Maintenance wake calendar.
810 #define kIOPMSettingMaintenanceWakeCalendarKey "MaintenanceWakeCalendarDate"
811
812
813 struct IOPMCalendarStruct {
814 UInt32 year;
815 UInt8 month;
816 UInt8 day;
817 UInt8 hour;
818 UInt8 minute;
819 UInt8 second;
820 UInt8 selector;
821 };
822 typedef struct IOPMCalendarStruct IOPMCalendarStruct;
823
824 // SetAggressiveness types
825 enum {
826 kPMGeneralAggressiveness = 0,
827 kPMMinutesToDim,
828 kPMMinutesToSpinDown,
829 kPMMinutesToSleep,
830 kPMEthernetWakeOnLANSettings,
831 kPMSetProcessorSpeed,
832 kPMPowerSource,
833 kPMMotionSensor,
834 kPMLastAggressivenessType
835 };
836 #define kMaxType (kPMLastAggressivenessType-1)
837
838 // SetAggressiveness values for the kPMPowerSource aggressiveness type
839 enum {
840 kIOPMInternalPower = 1,
841 kIOPMExternalPower
842 };
843
844 #define kIOREMSleepEnabledKey "REMSleepEnabled"
845
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"
854
855 enum {
856 kIOBatteryInstalled = (1 << 2),
857 kIOBatteryCharge = (1 << 1),
858 kIOBatteryChargerConnect = (1 << 0)
859 };
860
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)
864
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)
869
870 // For use with IOPMPowerSource bFlags
871 #define IOPM_POWER_SOURCE_REV 2
872 enum {
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
884 };
885
886 // **********************************************
887 // Internal power management data structures
888 // **********************************************
889
890 #if KERNEL && __cplusplus
891 class IOService;
892
893 enum {
894 kIOPowerEmergencyLevel = 1000
895 };
896
897 enum {
898 kIOPMSubclassPolicy,
899 kIOPMSuperclassPolicy1
900 #ifdef KERNEL_PRIVATE
901 , kIOPMActivityTickleTypeAdvisory = 128
902 #endif
903 };
904
905 struct stateChangeNote {
906 IOPMPowerFlags stateFlags;
907 unsigned long stateNum;
908 void * powerRef;
909 };
910 typedef struct stateChangeNote stateChangeNote;
911
912 #endif /* KERNEL && __cplusplus */
913 struct IOPowerStateChangeNotification {
914 void * powerRef;
915 unsigned long returnValue;
916 unsigned long stateNumber;
917 IOPMPowerFlags stateFlags;
918 };
919 typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification;
920 typedef IOPowerStateChangeNotification sleepWakeNote;
921
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
929 * changes.
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.
945 */
946 struct IOPMSystemCapabilityChangeParameters {
947 uint32_t notifyRef;
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];
954 };
955
956 /*! @enum IOPMSystemCapabilityChangeFlags
957 * @constant kIOPMSystemCapabilityWillChange Indicates the system capability will change.
958 * @constant kIOPMSystemCapabilityDidChange Indicates the system capability has changed.
959 */
960 enum {
961 kIOPMSystemCapabilityWillChange = 0x01,
962 kIOPMSystemCapabilityDidChange = 0x02
963 };
964
965 enum {
966 kIOPMSystemCapabilityCPU = 0x01,
967 kIOPMSystemCapabilityGraphics = 0x02,
968 kIOPMSystemCapabilityAudio = 0x04,
969 kIOPMSystemCapabilityNetwork = 0x08
970 };
971
972 #endif /* ! _IOKIT_IOPM_H */