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