2 * Copyright (c) 1998-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
25 #include <IOKit/IOTypes.h>
26 #include <IOKit/IOMessage.h>
27 #include <IOKit/IOReturn.h>
30 #include <IOKit/pwr_mgt/IOPMDeprecated.h>
36 kIOPMMaxPowerStates
= 10,
37 IOPMMaxPowerStates
= kIOPMMaxPowerStates
40 typedef unsigned long IOPMPowerFlags
;
42 // The following bits are used in the input and output power fields.
43 kIOPMClockNormal
= 0x0004,
44 kIOPMClockRunning
= 0x0008,
45 // Reserved - Used only between root and root parent.
46 kIOPMAuxPowerOn
= 0x0020,
47 // Reserved - kIOPMPagingAvailable used only by now-defunct paging plexus
48 kIOPMPagingAvailable
= 0x0020,
49 kIOPMPassThrough
= 0x0100,
51 // Obsolete - use kIOPMDoze instead of kIOPMSoftSleep
52 kIOPMSoftSleep
= 0x0400,
54 kIOPMRestart
= 0x0080,
56 // The following bits are used in the capabilites field and the power fields
57 kIOPMPowerOn
= 0x0002,
58 kIOPMPreventSystemSleep
= 0x0010,
59 kIOPMPreventIdleSleep
= 0x0040,
61 // The following bits are used in the capabilites field only.
62 // Used between a driver and its policy-maker
63 kIOPMNotAttainable
= 0x0001,
64 // Used internally in a power domain parent
65 kIOPMChildClamp
= 0x0080,
66 // Used internally in a power domain parent
67 kIOPMChildClamp2
= 0x0200,
68 // Marks device as usable in this state
69 kIOPMDeviceUsable
= 0x8000,
70 // Device runs at max performance in this state
71 kIOPMMaxPerformance
= 0x4000,
72 kIOPMContextRetained
= 0x2000,
73 kIOPMConfigRetained
= 0x1000,
74 // Device is capable of system sleep in this state
75 kIOPMSleepCapability
= 0x0004,
76 kIOPMRestartCapability
= 0x0080,
78 // Reserved - Error code. (this is an error return rather than a bit)
79 kIOPMNotPowerManaged
= 0x0800,
80 // Therefore this bit safely overloads it
81 kIOPMStaticPowerValid
= 0x0800,
83 kIOPMCapabilitiesMask
= kIOPMPowerOn
| kIOPMDeviceUsable
|
84 kIOPMMaxPerformance
| kIOPMContextRetained
|
85 kIOPMConfigRetained
| kIOPMSleepCapability
|
86 kIOPMRestartCapability
91 IOPMNotAttainable
= kIOPMNotAttainable
,
92 IOPMPowerOn
= kIOPMPowerOn
,
93 IOPMClockNormal
= kIOPMClockNormal
,
94 IOPMClockRunning
= kIOPMClockRunning
,
95 IOPMAuxPowerOn
= kIOPMAuxPowerOn
,
96 IOPMDeviceUsable
= kIOPMDeviceUsable
,
97 IOPMMaxPerformance
= kIOPMMaxPerformance
,
98 IOPMContextRetained
= kIOPMContextRetained
,
99 IOPMConfigRetained
= kIOPMConfigRetained
,
100 IOPMNotPowerManaged
= kIOPMNotPowerManaged
,
101 IOPMPagingAvailable
= kIOPMPagingAvailable
,
102 IOPMSoftSleep
= kIOPMSoftSleep
107 kIOPMNextHigherState
= 1,
108 kIOPMHighestState
= 2,
109 kIOPMNextLowerState
= 3,
114 IOPMNextHigherState
= kIOPMNextHigherState
,
115 IOPMHighestState
= kIOPMHighestState
,
116 IOPMNextLowerState
= kIOPMNextLowerState
,
117 IOPMLowestState
= kIOPMLowestState
120 // Internal commands used by power managment command queue
122 kIOPMBroadcastAggressiveness
= 1,
126 // Power consumption unknown value
128 kIOPMUnknown
= 0xFFFF
131 /*******************************************************************************
133 * Root Domain property keys of interest
135 ******************************************************************************/
137 /* AppleClamshellState
138 * reflects the state of the clamshell (lid) on a portable.
139 * It has a boolean value.
140 * true == clamshell is closed
141 * false == clamshell is open
142 * not present == no clamshell on this hardware
144 #define kAppleClamshellStateKey "AppleClamshellState"
146 /* AppleClamshellCausesSleep
147 * reflects the clamshell close behavior on a portable.
148 * It has a boolean value.
149 * true == system will sleep when clamshell is closed
150 * false == system will not sleep on clamshell close
151 * (typically external display mode)
152 * not present == no clamshell on this hardware
154 #define kAppleClamshellCausesSleepKey "AppleClamshellCausesSleep"
156 /*******************************************************************************
158 * Root Domain general interest messages
160 ******************************************************************************/
162 /* kIOPMMessageClamshellStateChange
163 * Delivered as a general interest notification on the IOPMrootDomain
164 * IOPMrootDomain sends this message when state of either AppleClamshellState
165 * or AppleClamshellCausesSleep changes. If this clamshell change results in
166 * a sleep, the sleep will initiate soon AFTER delivery of this message.
167 * The state of both variables is encoded in a bitfield argument sent with
168 * the message. Check bits 0 and 1 using kClamshellStateBit & kClamshellSleepBit
171 kClamshellStateBit
= (1 << 0),
172 kClamshellSleepBit
= (1 << 1)
175 #define kIOPMMessageClamshellStateChange \
176 iokit_family_msg(sub_iokit_powermanagement, 0x100)
178 /* kIOPMMessageFeatureChange
179 * Delivered when the set of supported features ("Supported Features" dictionary
180 * under IOPMrootDomain registry) changes in some way. Typically addition or
181 * removal of a supported feature.
182 * RootDomain passes no argument with this message.
184 #define kIOPMMessageFeatureChange \
185 iokit_family_msg(sub_iokit_powermanagement, 0x110)
187 /* kIOPMMessageInflowDisableCancelled
188 * The battery has drained completely to its "Fully Discharged" state.
189 * If a user process has disabled battery inflow for battery
190 * calibration, we forcibly re-enable Inflow at this point.
191 * If inflow HAS been forcibly re-enabled, bit 0
192 * (kInflowForciblyEnabledBit) will be set.
195 kInflowForciblyEnabledBit
= (1 << 0)
198 #define kIOPMMessageInternalBatteryFullyDischarged \
199 iokit_family_msg(sub_iokit_powermanagement, 0x120)
202 /*******************************************************************************
204 * Power commands issued to root domain
206 * These commands are issued from system drivers only:
207 * ApplePMU, AppleSMU, IOGraphics, AppleACPIFamily
209 ******************************************************************************/
211 kIOPMSleepNow
= (1<<0), // put machine to sleep now
212 kIOPMAllowSleep
= (1<<1), // allow idle sleep
213 kIOPMPreventSleep
= (1<<2), // do not allow idle sleep
214 kIOPMPowerButton
= (1<<3), // power button was pressed
215 kIOPMClamshellClosed
= (1<<4), // clamshell was closed
216 kIOPMPowerEmergency
= (1<<5), // battery dangerously low
217 kIOPMDisableClamshell
= (1<<6), // do not sleep on clamshell closure
218 kIOPMEnableClamshell
= (1<<7), // sleep on clamshell closure
219 kIOPMProcessorSpeedChange
= (1<<8), // change the processor speed
220 kIOPMOverTemp
= (1<<9), // system dangerously hot
221 kIOPMClamshellOpened
= (1<<10) // clamshell was opened
224 /*******************************************************************************
226 * Power Management Return Codes
228 ******************************************************************************/
231 // Returned by powerStateWillChange and powerStateDidChange:
232 // Immediate acknowledgement of power state change
234 // Acknowledgement of power state change will come later
235 kIOPMWillAckLater
= 1,
237 // Returned by requestDomainState:
238 // Unrecognized specification parameter
239 kIOPMBadSpecification
= 4,
240 // No power state matches search specification
241 kIOPMNoSuchState
= 5,
243 // Device cannot change its power for some reason
244 kIOPMCannotRaisePower
= 6,
246 // Returned by changeStateTo:
247 // Requested state doesn't exist
248 kIOPMParameterError
= 7,
249 // Device not yet fully hooked into power management
250 kIOPMNotYetInitialized
= 8,
252 // And the old constants; deprecated
253 IOPMNoErr
= kIOPMNoErr
,
254 IOPMAckImplied
= kIOPMAckImplied
,
255 IOPMWillAckLater
= kIOPMWillAckLater
,
256 IOPMBadSpecification
= kIOPMBadSpecification
,
257 IOPMNoSuchState
= kIOPMNoSuchState
,
258 IOPMCannotRaisePower
= kIOPMCannotRaisePower
,
259 IOPMParameterError
= kIOPMParameterError
,
260 IOPMNotYetInitialized
= kIOPMNotYetInitialized
264 // IOPMPowerSource class descriptive strings
265 // Power Source state is published as properties to the IORegistry under these
267 #define kIOPMPSExternalConnectedKey "ExternalConnected"
268 #define kIOPMPSExternalChargeCapableKey "ExternalChargeCapable"
269 #define kIOPMPSBatteryInstalledKey "BatteryInstalled"
270 #define kIOPMPSIsChargingKey "IsCharging"
271 #define kIOPMFullyChargedKey "FullyCharged"
272 #define kIOPMPSAtWarnLevelKey "AtWarnLevel"
273 #define kIOPMPSAtCriticalLevelKey "AtCriticalLevel"
274 #define kIOPMPSCurrentCapacityKey "CurrentCapacity"
275 #define kIOPMPSMaxCapacityKey "MaxCapacity"
276 #define kIOPMPSDesignCapacityKey "DesignCapacity"
277 #define kIOPMPSTimeRemainingKey "TimeRemaining"
278 #define kIOPMPSAmperageKey "Amperage"
279 #define kIOPMPSVoltageKey "Voltage"
280 #define kIOPMPSCycleCountKey "CycleCount"
281 #define kIOPMPSMaxErrKey "MaxErr"
282 #define kIOPMPSAdapterInfoKey "AdapterInfo"
283 #define kIOPMPSLocationKey "Location"
284 #define kIOPMPSErrorConditionKey "ErrorCondition"
285 #define kIOPMPSManufacturerKey "Manufacturer"
286 #define kIOPMPSManufactureDateKey "ManufactureDate"
287 #define kIOPMPSModelKey "Model"
288 #define kIOPMPSSerialKey "Serial"
289 #define kIOPMDeviceNameKey "DeviceName"
290 #define kIOPMPSLegacyBatteryInfoKey "LegacyBatteryInfo"
291 #define kIOPMPSBatteryHealthKey "BatteryHealth"
292 #define kIOPMPSHealthConfidenceKey "HealthConfidence"
294 // Definitions for battery location, in case of multiple batteries.
295 // A location of 0 is unspecified
296 // Location is undefined for single battery systems
298 kIOPMPSLocationLeft
= 1001,
299 kIOPMPSLocationRight
= 1002
302 // Battery quality health types, specified by BatteryHealth and HealthConfidence
303 // properties in an IOPMPowerSource battery kext.
305 kIOPMUndefinedValue
= 0,
311 // Battery's time remaining estimate is invalid this long (seconds) after a wake
312 #define kIOPMPSInvalidWakeSecondsKey "BatteryInvalidWakeSeconds"
314 // Battery must wait this long (seconds) after being completely charged before
315 // the battery is settled.
316 #define kIOPMPSPostChargeWaitSecondsKey "PostChargeWaitSeconds"
318 // Battery must wait this long (seconds) after being completely discharged
319 // before the battery is settled.
320 #define kIOPMPSPostDishargeWaitSecondsKey "PostDischargeWaitSeconds"
324 // PM Settings Controller setting types
325 // Settings types used primarily with:
326 // IOPMrootDomain::registerPMSettingController
327 // The values are identical to the similarly named keys for use in user space
328 // PM settings work. Those keys are defined in IOPMLibPrivate.h.
329 #define kIOPMSettingWakeOnRingKey "Wake On Modem Ring"
330 #define kIOPMSettingRestartOnPowerLossKey "Automatic Restart On Power Loss"
331 #define kIOPMSettingWakeOnACChangeKey "Wake On AC Change"
332 #define kIOPMSettingSleepOnPowerButtonKey "Sleep On Power Button"
333 #define kIOPMSettingWakeOnClamshellKey "Wake On Clamshell Open"
334 #define kIOPMSettingReduceBrightnessKey "ReduceBrightness"
335 #define kIOPMSettingDisplaySleepUsesDimKey "Display Sleep Uses Dim"
336 #define kIOPMSettingTimeZoneOffsetKey "TimeZoneOffsetSeconds"
338 // Setting controlling drivers can register to receive scheduled wake data
339 // Either in "CF seconds" type, or structured calendar data in a formatted
340 // IOPMCalendarStruct defined below.
341 #define kIOPMSettingAutoWakeSecondsKey "wake"
342 #define kIOPMSettingAutoWakeCalendarKey "WakeByCalendarDate"
343 #define kIOPMSettingAutoPowerSecondsKey "poweron"
344 #define kIOPMSettingAutoPowerCalendarKey "PowerByCalendarDate"
346 // Debug seconds auto wake
347 // Used by sleep cycling debug tools
348 #define kIOPMSettingDebugWakeRelativeKey "WakeRelativeToSleep"
349 #define kIOPMSettingDebugPowerRelativeKey "PowerRelativeToShutdown"
351 struct IOPMCalendarStruct
{
359 typedef struct IOPMCalendarStruct IOPMCalendarStruct
;
361 // SetAggressiveness types
363 kPMGeneralAggressiveness
= 0,
365 kPMMinutesToSpinDown
,
367 kPMEthernetWakeOnLANSettings
,
368 kPMSetProcessorSpeed
,
371 kPMLastAggressivenessType
373 #define kMaxType (kPMLastAggressivenessType-1)
375 // SetAggressiveness values for the kPMPowerSource aggressiveness type
377 kIOPMInternalPower
= 1,
381 #define kIOREMSleepEnabledKey "REMSleepEnabled"
383 // Strings for deciphering the dictionary returned from IOPMCopyBatteryInfo
384 #define kIOBatteryInfoKey "IOBatteryInfo"
385 #define kIOBatteryCurrentChargeKey "Current"
386 #define kIOBatteryCapacityKey "Capacity"
387 #define kIOBatteryFlagsKey "Flags"
388 #define kIOBatteryVoltageKey "Voltage"
389 #define kIOBatteryAmperageKey "Amperage"
390 #define kIOBatteryCycleCountKey "Cycle Count"
393 kIOBatteryInstalled
= (1 << 2),
394 kIOBatteryCharge
= (1 << 1),
395 kIOBatteryChargerConnect
= (1 << 0)
399 // Private power management message indicating battery data has changed
400 // Indicates new data resides in the IORegistry
401 #define kIOPMMessageBatteryStatusHasChanged iokit_family_msg(sub_iokit_pmu, 0x100)
403 // Apple private Legacy messages for re-routing AutoWake and AutoPower messages to the PMU
404 // through newer user space IOPMSchedulePowerEvent API
405 #define kIOPMUMessageLegacyAutoWake iokit_family_msg(sub_iokit_pmu, 0x200)
406 #define kIOPMUMessageLegacyAutoPower iokit_family_msg(sub_iokit_pmu, 0x210)
408 // For use with IOPMPowerSource bFlags
409 #define IOPM_POWER_SOURCE_REV 2
411 kIOPMACInstalled
= kIOBatteryChargerConnect
,
412 kIOPMBatteryCharging
= kIOBatteryCharge
,
413 kIOPMBatteryInstalled
= kIOBatteryInstalled
,
414 kIOPMUPSInstalled
= (1<<3),
415 kIOPMBatteryAtWarn
= (1<<4),
416 kIOPMBatteryDepleted
= (1<<5),
417 kIOPMACnoChargeCapability
= (1<<6), // AC adapter cannot charge battery
418 kIOPMRawLowBattery
= (1<<7), // used only by Platform Expert
419 kIOPMForceLowSpeed
= (1<<8), // set by Platfm Expert, chk'd by Pwr Plugin
420 kIOPMClosedClamshell
= (1<<9), // set by PMU - reflects state of the clamshell
421 kIOPMClamshellStateOnWake
= (1<<10) // used only by Platform Expert
425 // **********************************************
426 // Internal power management data structures
427 // **********************************************
429 #if KERNEL && __cplusplus
433 kIOPowerEmergencyLevel
= 1000
438 kIOPMSuperclassPolicy1
441 struct stateChangeNote
{
442 IOPMPowerFlags stateFlags
;
443 unsigned long stateNum
;
446 typedef struct stateChangeNote stateChangeNote
;
448 struct IOPowerStateChangeNotification
{
450 unsigned long returnValue
;
451 unsigned long stateNumber
;
452 IOPMPowerFlags stateFlags
;
454 typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification
;
455 typedef IOPowerStateChangeNotification sleepWakeNote
;
457 extern void IOPMRegisterDevice(const char *, IOService
*);
458 #endif /* KERNEL && __cplusplus */
460 #endif /* ! _IOKIT_IOPM_H */