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