]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/pwr_mgt/IOPM.h
f01c84178bb10ae60492d59e7462db15e4630949
[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 or powerStateForDomainState() to map from a global system state to the
99 desired device state.
100 */
101 typedef unsigned long IOPMPowerFlags;
102 enum {
103 kIOPMPowerOn = 0x00000002,
104 kIOPMDeviceUsable = 0x00008000,
105 kIOPMLowPower = 0x00010000,
106 kIOPMPreventIdleSleep = 0x00000040,
107 kIOPMSleepCapability = 0x00000004,
108 kIOPMRestartCapability = 0x00000080,
109 kIOPMSleep = 0x00000001,
110 kIOPMRestart = 0x00000080,
111 kIOPMInitialDeviceState = 0x00000100,
112 kIOPMRootDomainState = 0x00000200
113 };
114
115 /*
116 * Private IOPMPowerFlags
117 *
118 * For Apple use only
119 * Not for use with non-Apple drivers
120 * Their behavior is undefined
121 */
122 enum {
123 kIOPMClockNormal = 0x0004,
124 kIOPMClockRunning = 0x0008,
125 kIOPMPreventSystemSleep = 0x0010,
126 kIOPMDoze = 0x0400,
127 kIOPMChildClamp = 0x0080,
128 kIOPMChildClamp2 = 0x0200,
129 kIOPMNotPowerManaged = 0x0800
130 };
131
132 /*
133 * Deprecated IOPMPowerFlags
134 * Their behavior is undefined when used in IOPMPowerState
135 * Capability, InputPowerRequirement, or OutputPowerCharacter fields.
136 */
137 enum {
138 kIOPMMaxPerformance = 0x4000,
139 kIOPMPassThrough = 0x0100,
140 kIOPMAuxPowerOn = 0x0020,
141 kIOPMNotAttainable = 0x0001,
142 kIOPMContextRetained = 0x2000,
143 kIOPMConfigRetained = 0x1000,
144 kIOPMStaticPowerValid = 0x0800,
145 kIOPMSoftSleep = 0x0400,
146 kIOPMCapabilitiesMask = kIOPMPowerOn | kIOPMDeviceUsable |
147 kIOPMMaxPerformance | kIOPMContextRetained |
148 kIOPMConfigRetained | kIOPMSleepCapability |
149 kIOPMRestartCapability
150 };
151
152 /*
153 * Support for old names of IOPMPowerFlag constants
154 */
155 enum {
156 IOPMNotAttainable = kIOPMNotAttainable,
157 IOPMPowerOn = kIOPMPowerOn,
158 IOPMClockNormal = kIOPMClockNormal,
159 IOPMClockRunning = kIOPMClockRunning,
160 IOPMAuxPowerOn = kIOPMAuxPowerOn,
161 IOPMDeviceUsable = kIOPMDeviceUsable,
162 IOPMMaxPerformance = kIOPMMaxPerformance,
163 IOPMContextRetained = kIOPMContextRetained,
164 IOPMConfigRetained = kIOPMConfigRetained,
165 IOPMNotPowerManaged = kIOPMNotPowerManaged,
166 IOPMSoftSleep = kIOPMSoftSleep
167 };
168
169
170 enum {
171 kIOPMNextHigherState = 1,
172 kIOPMHighestState = 2,
173 kIOPMNextLowerState = 3,
174 kIOPMLowestState = 4
175 };
176
177 enum {
178 IOPMNextHigherState = kIOPMNextHigherState,
179 IOPMHighestState = kIOPMHighestState,
180 IOPMNextLowerState = kIOPMNextLowerState,
181 IOPMLowestState = kIOPMLowestState
182 };
183
184 // Internal commands used by power managment command queue
185 enum {
186 kIOPMBroadcastAggressiveness = 1,
187 kIOPMUnidleDevice
188 };
189
190 // Power consumption unknown value
191 enum {
192 kIOPMUnknown = 0xFFFF
193 };
194
195 /*******************************************************************************
196 *
197 * Root Domain property keys of interest
198 *
199 ******************************************************************************/
200
201 /* AppleClamshellState
202 * reflects the state of the clamshell (lid) on a portable.
203 * It has a boolean value.
204 * true == clamshell is closed
205 * false == clamshell is open
206 * not present == no clamshell on this hardware
207 */
208 #define kAppleClamshellStateKey "AppleClamshellState"
209
210 /* AppleClamshellCausesSleep
211 * reflects the clamshell close behavior on a portable.
212 * It has a boolean value.
213 * true == system will sleep when clamshell is closed
214 * false == system will not sleep on clamshell close
215 * (typically external display mode)
216 * not present == no clamshell on this hardware
217 */
218 #define kAppleClamshellCausesSleepKey "AppleClamshellCausesSleep"
219
220 /* kIOPMSleepWakeUUIDKey
221 * Key refers to a CFStringRef that will uniquely identify
222 * a sleep/wake cycle for logging & tracking.
223 * The key becomes valid at the beginning of a sleep cycle - before we
224 * initiate any sleep/wake notifications.
225 * The key becomes invalid at the completion of a system wakeup. The
226 * property will not be present in the IOPMrootDomain's registry entry
227 * when it is invalid.
228 *
229 * See IOPMrootDomain notification kIOPMMessageSleepWakeUUIDChange
230 */
231 #define kIOPMSleepWakeUUIDKey "SleepWakeUUID"
232
233 /* kIOPMDeepSleepEnabledKey
234 * Indicates the Deep Sleep enable state.
235 * It has a boolean value.
236 * true == Deep Sleep is enabled
237 * false == Deep Sleep is disabled
238 * not present == Deep Sleep is not supported on this hardware
239 */
240 #define kIOPMDeepSleepEnabledKey "Standby Enabled"
241
242 /* kIOPMDeepSleepDelayKey
243 * Key refers to a CFNumberRef that represents the delay in seconds before
244 * entering Deep Sleep state. The property is not present if Deep Sleep is
245 * unsupported.
246 */
247 #define kIOPMDeepSleepDelayKey "Standby Delay"
248
249 /* kIOPMDestroyFVKeyOnStandbyKey
250 * Specifies if FileVault key can be stored when going to standby mode
251 * It has a boolean value,
252 * true == Destroy FV key when going to standby mode
253 * false == Retain FV key when going to standby mode
254 * not present == Retain FV key when going to standby mode
255 */
256 #define kIOPMDestroyFVKeyOnStandbyKey "DestroyFVKeyOnStandby"
257
258 /*******************************************************************************
259 *
260 * Properties that can control power management behavior
261 *
262 ******************************************************************************/
263
264 /* kIOPMResetPowerStateOnWakeKey
265 * If an IOService publishes this key with the value of kOSBooleanTrue,
266 * then PM will disregard the influence from changePowerStateToPriv() or
267 * any activity tickles that occurred before system sleep when resolving
268 * the initial device power state on wake. Influences from power children
269 * and changePowerStateTo() are not eliminated. At the earliest opportunity
270 * upon system wake, PM will query the driver for a new power state to be
271 * installed as the initial changePowerStateToPriv() influence, by calling
272 * initialPowerStateForDomainState() with both kIOPMRootDomainState and
273 * kIOPMPowerOn flags set. The default implementation will always return
274 * the lowest power state. Drivers can override this default behavior to
275 * immediately raise the power state when there are work blocked on the
276 * power change, and cannot afford to wait until the next activity tickle.
277 * This property should be statically added to a driver's plist or set at
278 * runtime before calling PMinit().
279 */
280 #define kIOPMResetPowerStateOnWakeKey "IOPMResetPowerStateOnWake"
281
282 /*******************************************************************************
283 *
284 * Driver PM Assertions
285 *
286 ******************************************************************************/
287
288 /* Driver Assertion bitfield description
289 * Driver PM assertions are defined by these bits.
290 */
291 enum {
292 /*! kIOPMDriverAssertionCPUBit
293 * When set, PM kernel will prefer to leave the CPU and core hardware
294 * running in "Dark Wake" state, instead of sleeping.
295 */
296 kIOPMDriverAssertionCPUBit = 0x01,
297
298 /*! kIOPMDriverAssertionUSBExternalDeviceBit
299 * When set, driver is informing PM that an external USB device is attached.
300 */
301 kIOPMDriverAssertionUSBExternalDeviceBit = 0x04,
302
303 /*! kIOPMDriverAssertionBluetoothHIDDevicePairedBit
304 * When set, driver is informing PM that a Bluetooth HID device is paired.
305 */
306 kIOPMDriverAssertionBluetoothHIDDevicePairedBit = 0x08,
307
308 /*! kIOPMDriverAssertionExternalMediaMountedBit
309 * When set, driver is informing PM that an external media is mounted.
310 */
311 kIOPMDriverAssertionExternalMediaMountedBit = 0x10,
312
313 /*! kIOPMDriverAssertionReservedBit5
314 * Reserved for Thunderbolt.
315 */
316 kIOPMDriverAssertionReservedBit5 = 0x20,
317
318 /*! kIOPMDriverAssertionPreventDisplaySleepBit
319 * When set, the display should remain powered on while the system's awake.
320 */
321 kIOPMDriverAssertionPreventDisplaySleepBit = 0x40,
322
323 /*! kIOPMDriverAssertionReservedBit7
324 * Reserved for storage family.
325 */
326 kIOPMDriverAssertionReservedBit7 = 0x80,
327
328 /*! kIOPMDriverAssertionMagicPacketWakeEnabledBit
329 * When set, driver is informing PM that magic packet wake is enabled.
330 */
331 kIOPMDriverAssertionMagicPacketWakeEnabledBit = 0x100
332 };
333
334 /* kIOPMAssertionsDriverKey
335 * This kIOPMrootDomain key refers to a CFNumberRef property, containing
336 * a bitfield describing the aggregate PM assertion levels.
337 * Example: A value of 0 indicates that no driver has asserted anything.
338 * Or, a value of <link>kIOPMDriverAssertionCPUBit</link>
339 * indicates that a driver (or drivers) have asserted a need for CPU and video.
340 */
341 #define kIOPMAssertionsDriverKey "DriverPMAssertions"
342
343 /* kIOPMAssertionsDriverKey
344 * This kIOPMrootDomain key refers to a CFNumberRef property, containing
345 * a bitfield describing the aggregate PM assertion levels.
346 * Example: A value of 0 indicates that no driver has asserted anything.
347 * Or, a value of <link>kIOPMDriverAssertionCPUBit</link>
348 * indicates that a driver (or drivers) have asserted a need for CPU and video.
349 */
350 #define kIOPMAssertionsDriverDetailedKey "DriverPMAssertionsDetailed"
351
352 /*******************************************************************************
353 *
354 * Kernel Driver assertion detailed dictionary keys
355 *
356 * Keys decode the Array & dictionary data structure under IOPMrootDomain property
357 * kIOPMAssertionsDriverKey.
358 *
359 */
360 #define kIOPMDriverAssertionIDKey "ID"
361 #define kIOPMDriverAssertionCreatedTimeKey "CreatedTime"
362 #define kIOPMDriverAssertionModifiedTimeKey "ModifiedTime"
363 #define kIOPMDriverAssertionOwnerStringKey "Owner"
364 #define kIOPMDriverAssertionOwnerServiceKey "ServicePtr"
365 #define kIOPMDriverAssertionLevelKey "Level"
366 #define kIOPMDriverAssertionAssertedKey "Assertions"
367
368 /*******************************************************************************
369 *
370 * Root Domain general interest messages
371 *
372 * Available by registering for interest type 'gIOGeneralInterest'
373 * on IOPMrootDomain.
374 *
375 ******************************************************************************/
376
377 /* kIOPMMessageClamshellStateChange
378 * Delivered as a general interest notification on the IOPMrootDomain
379 * IOPMrootDomain sends this message when state of either AppleClamshellState
380 * or AppleClamshellCausesSleep changes. If this clamshell change results in
381 * a sleep, the sleep will initiate soon AFTER delivery of this message.
382 * The state of both variables is encoded in a bitfield argument sent with
383 * the message. Check bits 0 and 1 using kClamshellStateBit & kClamshellSleepBit
384 */
385 enum {
386 kClamshellStateBit = (1 << 0),
387 kClamshellSleepBit = (1 << 1)
388 };
389
390 #define kIOPMMessageClamshellStateChange \
391 iokit_family_msg(sub_iokit_powermanagement, 0x100)
392
393 /* kIOPMMessageFeatureChange
394 * Delivered when the set of supported features ("Supported Features" dictionary
395 * under IOPMrootDomain registry) changes in some way. Typically addition or
396 * removal of a supported feature.
397 * RootDomain passes no argument with this message.
398 */
399 #define kIOPMMessageFeatureChange \
400 iokit_family_msg(sub_iokit_powermanagement, 0x110)
401
402 /* kIOPMMessageInflowDisableCancelled
403 * The battery has drained completely to its "Fully Discharged" state.
404 * If a user process has disabled battery inflow for battery
405 * calibration, we forcibly re-enable Inflow at this point.
406 * If inflow HAS been forcibly re-enabled, bit 0
407 * (kInflowForciblyEnabledBit) will be set.
408 */
409 enum {
410 kInflowForciblyEnabledBit = (1 << 0)
411 };
412
413 /* kIOPMMessageInternalBatteryFullyDischarged
414 * The battery has drained completely to its "Fully Discharged" state.
415 */
416 #define kIOPMMessageInternalBatteryFullyDischarged \
417 iokit_family_msg(sub_iokit_powermanagement, 0x120)
418
419 /* kIOPMMessageSystemPowerEventOccurred
420 * Some major system thermal property has changed, and interested clients may
421 * modify their behavior.
422 */
423 #define kIOPMMessageSystemPowerEventOccurred \
424 iokit_family_msg(sub_iokit_powermanagement, 0x130)
425
426 /* kIOPMMessageSleepWakeUUIDChange
427 * Either a new SleepWakeUUID has been specified at the beginning of a sleep,
428 * or we're removing the existing property upon completion of a wakeup.
429 */
430 #define kIOPMMessageSleepWakeUUIDChange \
431 iokit_family_msg(sub_iokit_powermanagement, 0x140)
432
433 /* kIOPMMessageSleepWakeUUIDSet
434 * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when
435 * a new UUID has been specified.
436 */
437 #define kIOPMMessageSleepWakeUUIDSet ((void *)1)
438
439 /* kIOPMMessageSleepWakeUUIDCleared
440 * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when
441 * the current UUID has been removed.
442 */
443 #define kIOPMMessageSleepWakeUUIDCleared ((void *)0)
444
445 /*! kIOPMMessageDriverAssertionsChanged
446 * Sent when kernel PM driver assertions have changed.
447 */
448 #define kIOPMMessageDriverAssertionsChanged \
449 iokit_family_msg(sub_iokit_powermanagement, 0x150)
450
451 /*! kIOPMMessageDarkWakeThermalEmergency
452 * Sent when machine becomes unsustainably warm in DarkWake.
453 * Kernel PM might choose to put the machine back to sleep right after.
454 */
455 #define kIOPMMessageDarkWakeThermalEmergency \
456 iokit_family_msg(sub_iokit_powermanagement, 0x160)
457
458 /*******************************************************************************
459 *
460 * Power commands issued to root domain
461 * Use with IOPMrootDomain::receivePowerNotification()
462 *
463 * These commands are issued from system drivers only:
464 * ApplePMU, AppleSMU, IOGraphics, AppleACPIFamily
465 *
466 * TODO: deprecate kIOPMAllowSleep and kIOPMPreventSleep
467 ******************************************************************************/
468 enum {
469 kIOPMSleepNow = (1<<0), // put machine to sleep now
470 kIOPMAllowSleep = (1<<1), // allow idle sleep
471 kIOPMPreventSleep = (1<<2), // do not allow idle sleep
472 kIOPMPowerButton = (1<<3), // power button was pressed
473 kIOPMClamshellClosed = (1<<4), // clamshell was closed
474 kIOPMPowerEmergency = (1<<5), // battery dangerously low
475 kIOPMDisableClamshell = (1<<6), // do not sleep on clamshell closure
476 kIOPMEnableClamshell = (1<<7), // sleep on clamshell closure
477 kIOPMProcessorSpeedChange = (1<<8), // change the processor speed
478 kIOPMOverTemp = (1<<9), // system dangerously hot
479 kIOPMClamshellOpened = (1<<10), // clamshell was opened
480 kIOPMDWOverTemp = (1<<11) // DarkWake thermal limits exceeded.
481 };
482
483
484 /*******************************************************************************
485 *
486 * Power Management Return Codes
487 *
488 ******************************************************************************/
489 enum {
490 kIOPMNoErr = 0,
491
492 // Returned by driver's setPowerState(), powerStateWillChangeTo(),
493 // powerStateDidChangeTo(), or acknowledgeSetPowerState() to
494 // implicitly acknowledge power change upon function return.
495 kIOPMAckImplied = 0,
496
497 // Deprecated
498 kIOPMWillAckLater = 1,
499
500 // Returned by requestPowerDomainState() to indicate
501 // unrecognized specification parameter.
502 kIOPMBadSpecification = 4,
503
504 // Returned by requestPowerDomainState() to indicate
505 // no power state matches search specification.
506 kIOPMNoSuchState = 5,
507
508 // Deprecated
509 kIOPMCannotRaisePower = 6,
510
511 // Deprecated
512 kIOPMParameterError = 7,
513
514 // Returned when power management state is accessed
515 // before driver has called PMinit().
516 kIOPMNotYetInitialized = 8,
517
518 // And the old constants; deprecated
519 IOPMNoErr = kIOPMNoErr,
520 IOPMAckImplied = kIOPMAckImplied,
521 IOPMWillAckLater = kIOPMWillAckLater,
522 IOPMBadSpecification = kIOPMBadSpecification,
523 IOPMNoSuchState = kIOPMNoSuchState,
524 IOPMCannotRaisePower = kIOPMCannotRaisePower,
525 IOPMParameterError = kIOPMParameterError,
526 IOPMNotYetInitialized = kIOPMNotYetInitialized
527 };
528
529
530 // IOPMPowerSource class descriptive strings
531 // Power Source state is published as properties to the IORegistry under these
532 // keys.
533 #define kIOPMPSExternalConnectedKey "ExternalConnected"
534 #define kIOPMPSExternalChargeCapableKey "ExternalChargeCapable"
535 #define kIOPMPSBatteryInstalledKey "BatteryInstalled"
536 #define kIOPMPSIsChargingKey "IsCharging"
537 #define kIOPMFullyChargedKey "FullyCharged"
538 #define kIOPMPSAtWarnLevelKey "AtWarnLevel"
539 #define kIOPMPSAtCriticalLevelKey "AtCriticalLevel"
540 #define kIOPMPSCurrentCapacityKey "CurrentCapacity"
541 #define kIOPMPSMaxCapacityKey "MaxCapacity"
542 #define kIOPMPSDesignCapacityKey "DesignCapacity"
543 #define kIOPMPSTimeRemainingKey "TimeRemaining"
544 #define kIOPMPSAmperageKey "Amperage"
545 #define kIOPMPSVoltageKey "Voltage"
546 #define kIOPMPSCycleCountKey "CycleCount"
547 #define kIOPMPSMaxErrKey "MaxErr"
548 #define kIOPMPSAdapterInfoKey "AdapterInfo"
549 #define kIOPMPSLocationKey "Location"
550 #define kIOPMPSErrorConditionKey "ErrorCondition"
551 #define kIOPMPSManufacturerKey "Manufacturer"
552 #define kIOPMPSManufactureDateKey "ManufactureDate"
553 #define kIOPMPSModelKey "Model"
554 #define kIOPMPSSerialKey "Serial"
555 #define kIOPMDeviceNameKey "DeviceName"
556 #define kIOPMPSLegacyBatteryInfoKey "LegacyBatteryInfo"
557 #define kIOPMPSBatteryHealthKey "BatteryHealth"
558 #define kIOPMPSHealthConfidenceKey "HealthConfidence"
559 #define kIOPMPSCapacityEstimatedKey "CapacityEstimated"
560 #define kIOPMPSBatteryChargeStatusKey "ChargeStatus"
561 #define kIOPMPSBatteryTemperatureKey "Temperature"
562 #define kIOPMPSAdapterDetailsKey "AdapterDetails"
563 #define kIOPMPSChargerConfigurationKey "ChargerConfiguration"
564
565 // kIOPMPSBatteryChargeStatusKey may have one of the following values, or may have
566 // no value. If kIOPMBatteryChargeStatusKey has a NULL value (or no value) associated with it
567 // then charge is proceeding normally. If one of these battery charge status reasons is listed,
568 // then the charge may have been interrupted.
569 #define kIOPMBatteryChargeStatusTooHot "HighTemperature"
570 #define kIOPMBatteryChargeStatusTooCold "LowTemperature"
571 #define kIOPMBatteryChargeStatusTooHotOrCold "HighOrLowTemperature"
572 #define kIOPMBatteryChargeStatusGradient "BatteryTemperatureGradient"
573
574 // Definitions for battery location, in case of multiple batteries.
575 // A location of 0 is unspecified
576 // Location is undefined for single battery systems
577 enum {
578 kIOPMPSLocationLeft = 1001,
579 kIOPMPSLocationRight = 1002
580 };
581
582 // Battery quality health types, specified by BatteryHealth and HealthConfidence
583 // properties in an IOPMPowerSource battery kext.
584 enum {
585 kIOPMUndefinedValue = 0,
586 kIOPMPoorValue = 1,
587 kIOPMFairValue = 2,
588 kIOPMGoodValue = 3
589 };
590
591 // Keys for kIOPMPSAdapterDetailsKey dictionary
592 #define kIOPMPSAdapterDetailsIDKey "AdapterID"
593 #define kIOPMPSAdapterDetailsWattsKey "Watts"
594 #define kIOPMPSAdapterDetailsRevisionKey "AdapterRevision"
595 #define kIOPMPSAdapterDetailsSerialNumberKey "SerialNumber"
596 #define kIOPMPSAdapterDetailsFamilyKey "FamilyCode"
597 #define kIOPMPSAdapterDetailsAmperageKey "Amperage"
598 #define kIOPMPSAdapterDetailsDescriptionKey "Description"
599 #define kIOPMPSAdapterDetailsPMUConfigurationKey "PMUConfiguration"
600
601 // Battery's time remaining estimate is invalid this long (seconds) after a wake
602 #define kIOPMPSInvalidWakeSecondsKey "BatteryInvalidWakeSeconds"
603
604 // Battery must wait this long (seconds) after being completely charged before
605 // the battery is settled.
606 #define kIOPMPSPostChargeWaitSecondsKey "PostChargeWaitSeconds"
607
608 // Battery must wait this long (seconds) after being completely discharged
609 // before the battery is settled.
610 #define kIOPMPSPostDishargeWaitSecondsKey "PostDischargeWaitSeconds"
611
612
613 /* CPU Power Management status keys
614 * Pass as arguments to IOPMrootDomain::systemPowerEventOccurred
615 * Or as arguments to IOPMSystemPowerEventOccurred()
616 * Or to decode the dictionary obtained from IOPMCopyCPUPowerStatus()
617 * These keys reflect restrictions placed on the CPU by the system
618 * to bring the CPU's power consumption within allowable thermal and
619 * power constraints.
620 */
621
622
623 /* kIOPMGraphicsPowerLimitsKey
624 * The key representing the dictionary of graphics power limits.
625 * The dictionary contains the other kIOPMCPUPower keys & their associated
626 * values (e.g. Speed limit, Processor Count, and Schedule limits).
627 */
628 #define kIOPMGraphicsPowerLimitsKey "Graphics_Power_Limits"
629
630 /* kIOPMGraphicsPowerLimitPerformanceKey
631 * The key representing the percent of overall performance made available
632 * by the graphics chip as a percentage (integer 0 - 100).
633 */
634 #define kIOPMGraphicsPowerLimitPerformanceKey "Graphics_Power_Performance"
635
636
637
638 /* kIOPMCPUPowerLimitsKey
639 * The key representing the dictionary of CPU Power Limits.
640 * The dictionary contains the other kIOPMCPUPower keys & their associated
641 * values (e.g. Speed limit, Processor Count, and Schedule limits).
642 */
643 #define kIOPMCPUPowerLimitsKey "CPU_Power_Limits"
644
645 /* kIOPMCPUPowerLimitProcessorSpeedKey defines the speed & voltage limits placed
646 * on the CPU.
647 * Represented as a percentage (0-100) of maximum CPU speed.
648 */
649 #define kIOPMCPUPowerLimitProcessorSpeedKey "CPU_Speed_Limit"
650
651 /* kIOPMCPUPowerLimitProcessorCountKey reflects how many, if any, CPUs have been
652 * taken offline. Represented as an integer number of CPUs (0 - Max CPUs).
653 */
654 #define kIOPMCPUPowerLimitProcessorCountKey "CPU_Available_CPUs"
655
656 /* kIOPMCPUPowerLimitSchedulerTimeKey represents the percentage (0-100) of CPU time
657 * available. 100% at normal operation. The OS may limit this time for a percentage
658 * less than 100%.
659 */
660 #define kIOPMCPUPowerLimitSchedulerTimeKey "CPU_Scheduler_Limit"
661
662
663 /* Thermal Level Warning Key
664 * Indicates the thermal constraints placed on the system. This value may
665 * cause clients to action to consume fewer system resources.
666 * The value associated with this warning is defined by the platform.
667 */
668 #define kIOPMThermalLevelWarningKey "Thermal_Level_Warning"
669
670 /* Thermal Warning Level values
671 * kIOPMThermalWarningLevelNormal - under normal operating conditions
672 * kIOPMThermalWarningLevelDanger - thermal pressure may cause system slowdown
673 * kIOPMThermalWarningLevelCrisis - thermal conditions may cause imminent shutdown
674 *
675 * The platform may define additional thermal levels if necessary.
676 */
677 enum {
678 kIOPMThermalWarningLevelNormal = 0,
679 kIOPMThermalWarningLevelDanger = 5,
680 kIOPMThermalWarningLevelCrisis = 10
681 };
682
683
684 // PM Settings Controller setting types
685 // Settings types used primarily with:
686 // IOPMrootDomain::registerPMSettingController
687 // The values are identical to the similarly named keys for use in user space
688 // PM settings work. Those keys are defined in IOPMLibPrivate.h.
689 #define kIOPMSettingWakeOnRingKey "Wake On Modem Ring"
690 #define kIOPMSettingRestartOnPowerLossKey "Automatic Restart On Power Loss"
691 #define kIOPMSettingWakeOnACChangeKey "Wake On AC Change"
692 #define kIOPMSettingSleepOnPowerButtonKey "Sleep On Power Button"
693 #define kIOPMSettingWakeOnClamshellKey "Wake On Clamshell Open"
694 #define kIOPMSettingReduceBrightnessKey "ReduceBrightness"
695 #define kIOPMSettingDisplaySleepUsesDimKey "Display Sleep Uses Dim"
696 #define kIOPMSettingTimeZoneOffsetKey "TimeZoneOffsetSeconds"
697 #define kIOPMSettingMobileMotionModuleKey "MobileMotionModule"
698 #define kIOPMSettingGraphicsSwitchKey "GPUSwitch"
699
700 // Setting controlling drivers can register to receive scheduled wake data
701 // Either in "CF seconds" type, or structured calendar data in a formatted
702 // IOPMCalendarStruct defined below.
703 #define kIOPMSettingAutoWakeSecondsKey "wake"
704 #define kIOPMSettingAutoWakeCalendarKey "WakeByCalendarDate"
705 #define kIOPMSettingAutoPowerSecondsKey "poweron"
706 #define kIOPMSettingAutoPowerCalendarKey "PowerByCalendarDate"
707
708 // Debug seconds auto wake
709 // Used by sleep cycling debug tools
710 #define kIOPMSettingDebugWakeRelativeKey "WakeRelativeToSleep"
711 #define kIOPMSettingDebugPowerRelativeKey "PowerRelativeToShutdown"
712
713 // Maintenance wake calendar.
714 #define kIOPMSettingMaintenanceWakeCalendarKey "MaintenanceWakeCalendarDate"
715
716
717 struct IOPMCalendarStruct {
718 UInt32 year;
719 UInt8 month;
720 UInt8 day;
721 UInt8 hour;
722 UInt8 minute;
723 UInt8 second;
724 UInt8 selector;
725 };
726 typedef struct IOPMCalendarStruct IOPMCalendarStruct;
727
728 // SetAggressiveness types
729 enum {
730 kPMGeneralAggressiveness = 0,
731 kPMMinutesToDim,
732 kPMMinutesToSpinDown,
733 kPMMinutesToSleep,
734 kPMEthernetWakeOnLANSettings,
735 kPMSetProcessorSpeed,
736 kPMPowerSource,
737 kPMMotionSensor,
738 kPMLastAggressivenessType
739 };
740 #define kMaxType (kPMLastAggressivenessType-1)
741
742 // SetAggressiveness values for the kPMPowerSource aggressiveness type
743 enum {
744 kIOPMInternalPower = 1,
745 kIOPMExternalPower
746 };
747
748 #define kIOREMSleepEnabledKey "REMSleepEnabled"
749
750 // Strings for deciphering the dictionary returned from IOPMCopyBatteryInfo
751 #define kIOBatteryInfoKey "IOBatteryInfo"
752 #define kIOBatteryCurrentChargeKey "Current"
753 #define kIOBatteryCapacityKey "Capacity"
754 #define kIOBatteryFlagsKey "Flags"
755 #define kIOBatteryVoltageKey "Voltage"
756 #define kIOBatteryAmperageKey "Amperage"
757 #define kIOBatteryCycleCountKey "Cycle Count"
758
759 enum {
760 kIOBatteryInstalled = (1 << 2),
761 kIOBatteryCharge = (1 << 1),
762 kIOBatteryChargerConnect = (1 << 0)
763 };
764
765 // Private power management message indicating battery data has changed
766 // Indicates new data resides in the IORegistry
767 #define kIOPMMessageBatteryStatusHasChanged iokit_family_msg(sub_iokit_pmu, 0x100)
768
769 // Apple private Legacy messages for re-routing AutoWake and AutoPower messages to the PMU
770 // through newer user space IOPMSchedulePowerEvent API
771 #define kIOPMUMessageLegacyAutoWake iokit_family_msg(sub_iokit_pmu, 0x200)
772 #define kIOPMUMessageLegacyAutoPower iokit_family_msg(sub_iokit_pmu, 0x210)
773
774 // For use with IOPMPowerSource bFlags
775 #define IOPM_POWER_SOURCE_REV 2
776 enum {
777 kIOPMACInstalled = kIOBatteryChargerConnect,
778 kIOPMBatteryCharging = kIOBatteryCharge,
779 kIOPMBatteryInstalled = kIOBatteryInstalled,
780 kIOPMUPSInstalled = (1<<3),
781 kIOPMBatteryAtWarn = (1<<4),
782 kIOPMBatteryDepleted = (1<<5),
783 kIOPMACnoChargeCapability = (1<<6), // AC adapter cannot charge battery
784 kIOPMRawLowBattery = (1<<7), // used only by Platform Expert
785 kIOPMForceLowSpeed = (1<<8), // set by Platfm Expert, chk'd by Pwr Plugin
786 kIOPMClosedClamshell = (1<<9), // set by PMU - reflects state of the clamshell
787 kIOPMClamshellStateOnWake = (1<<10) // used only by Platform Expert
788 };
789
790 // **********************************************
791 // Internal power management data structures
792 // **********************************************
793
794 #if KERNEL && __cplusplus
795 class IOService;
796
797 enum {
798 kIOPowerEmergencyLevel = 1000
799 };
800
801 enum {
802 kIOPMSubclassPolicy,
803 kIOPMSuperclassPolicy1
804 #ifdef KERNEL_PRIVATE
805 , kIOPMActivityTickleTypeAdvisory = 128
806 #endif
807 };
808
809 struct stateChangeNote {
810 IOPMPowerFlags stateFlags;
811 unsigned long stateNum;
812 void * powerRef;
813 };
814 typedef struct stateChangeNote stateChangeNote;
815
816 #endif /* KERNEL && __cplusplus */
817 struct IOPowerStateChangeNotification {
818 void * powerRef;
819 unsigned long returnValue;
820 unsigned long stateNumber;
821 IOPMPowerFlags stateFlags;
822 };
823 typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification;
824 typedef IOPowerStateChangeNotification sleepWakeNote;
825
826 /*! @struct IOPMSystemCapabilityChangeParameters
827 @abstract A structure describing a system capability change.
828 @discussion A system capability change is a system level transition from a set
829 of system capabilities to a new set of system capabilities. Power management
830 sends a <code>kIOMessageSystemCapabilityChange</code> message and provides
831 this structure as the message data (by reference) to
832 <code>gIOPriorityPowerStateInterest</code> clients when system capability
833 changes.
834 @field notifyRef An identifier for this message notification. Clients with pending
835 I/O can signal completion by calling <code>allowPowerChange()</code> with this
836 value as the argument. Clients that are able to process the notification
837 synchronously should ignore this field.
838 @field maxWaitForReply A return value to the caller indicating the maximum time in
839 microseconds to wait for the <code>allowPowerChange()</code> call. The default
840 value is zero, which indicates the client processing has finished, and power
841 management should not wait for an <code>allowPowerChange()</code> call.
842 @field changeFlags Flags will be set to indicate whether the notification precedes
843 the capability change (<code>kIOPMSystemCapabilityWillChange</code>), or after
844 the capability change has occurred (<code>kIOPMSystemCapabilityDidChange</code>).
845 @field __reserved1 Set to zero.
846 @field fromCapabilities The system capabilities at the start of the transition.
847 @field toCapabilities The system capabilities at the end of the transition.
848 @field __reserved2 Set to zero.
849 */
850 struct IOPMSystemCapabilityChangeParameters {
851 uint32_t notifyRef;
852 uint32_t maxWaitForReply;
853 uint32_t changeFlags;
854 uint32_t __reserved1;
855 uint32_t fromCapabilities;
856 uint32_t toCapabilities;
857 uint32_t __reserved2[4];
858 };
859
860 /*! @enum IOPMSystemCapabilityChangeFlags
861 @constant kIOPMSystemCapabilityWillChange Indicates the system capability will change.
862 @constant kIOPMSystemCapabilityDidChange Indicates the system capability has changed.
863 */
864 enum {
865 kIOPMSystemCapabilityWillChange = 0x01,
866 kIOPMSystemCapabilityDidChange = 0x02
867 };
868
869 enum {
870 kIOPMSystemCapabilityCPU = 0x01,
871 kIOPMSystemCapabilityGraphics = 0x02,
872 kIOPMSystemCapabilityAudio = 0x04,
873 kIOPMSystemCapabilityNetwork = 0x08
874 };
875
876 #endif /* ! _IOKIT_IOPM_H */