2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
33 #define IOPMMaxPowerStates 10
35 typedef unsigned long IOPMPowerFlags
;
37 // following bits are used in the input and output power fields
38 kIOPMClockNormal
= 0x0004,
39 kIOPMClockRunning
= 0x0008,
40 kIOPMAuxPowerOn
= 0x0020, // used only between root and root parent
41 kIOPMPagingAvailable
= 0x0020, // used only between paging plexus and its children
42 kIOPMPassThrough
= 0x0100,
44 kIOPMSoftSleep
= 0x0400, // old usage, replaced by kIOPMDoze
46 kIOPMRestart
= 0x0080,
47 // following bits are used in the capabilites field and the power fields
48 kIOPMPowerOn
= 0x0002,
49 kIOPMPreventSystemSleep
= 0x0010,
50 kIOPMPreventIdleSleep
= 0x0040,
51 // following bits are used in the capabilites field
52 kIOPMNotAttainable
= 0x0001, // used between a driver and its policy-maker
53 kIOPMChildClamp
= 0x0080, // used internally in a power domain parent
54 kIOPMChildClamp2
= 0x0200, // used internally in a power domain parent
55 kIOPMDeviceUsable
= 0x8000,
56 kIOPMMaxPerformance
= 0x4000,
57 kIOPMContextRetained
= 0x2000,
58 kIOPMConfigRetained
= 0x1000,
59 kIOPMSleepCapability
= 0x0004,
60 kIOPMRestartCapability
= 0x0080,
61 kIOPMNotPowerManaged
= 0x0800, // this is an error return rather than a bit
62 kIOPMStaticPowerValid
= 0x0800, // therefore this bit safely overloads it
64 kIOPMCapabilitiesMask
= kIOPMPowerOn
| kIOPMDeviceUsable
| kIOPMMaxPerformance
|
65 kIOPMContextRetained
| kIOPMConfigRetained
| kIOPMSleepCapability
|
66 kIOPMRestartCapability
71 IOPMNotAttainable
= kIOPMNotAttainable
,
72 IOPMPowerOn
= kIOPMPowerOn
,
73 IOPMClockNormal
= kIOPMClockNormal
,
74 IOPMClockRunning
= kIOPMClockRunning
,
75 IOPMAuxPowerOn
= kIOPMAuxPowerOn
,
76 IOPMDeviceUsable
= kIOPMDeviceUsable
,
77 IOPMMaxPerformance
= kIOPMMaxPerformance
,
78 IOPMContextRetained
= kIOPMContextRetained
,
79 IOPMConfigRetained
= kIOPMConfigRetained
,
80 IOPMNotPowerManaged
= kIOPMNotPowerManaged
,
81 IOPMPagingAvailable
= kIOPMPagingAvailable
,
82 IOPMSoftSleep
= kIOPMSoftSleep
87 kIOPMNextHigherState
= 1,
88 kIOPMHighestState
= 2,
89 kIOPMNextLowerState
= 3,
94 IOPMNextHigherState
= kIOPMNextHigherState
,
95 IOPMHighestState
= kIOPMHighestState
,
96 IOPMNextLowerState
= kIOPMNextLowerState
,
97 IOPMLowestState
= kIOPMLowestState
102 enum { // commands on power managment command queue
103 kIOPMBroadcastAggressiveness
= 1,
107 enum { // special value means "power consumption unknown"
108 kIOPMUnknown
= 0xFFFF
113 kClamshellClosedEventMask
= (1<<0), // User closed lid
114 kDockingBarEventMask
= (1<<1), // OBSOLETE
115 kACPlugEventMask
= (1<<2), // User plugged or unplugged adapter
116 kFrontPanelButtonEventMask
= (1<<3), // User hit the front panel button
117 kBatteryStatusEventMask
= (1<<4) // Battery status has changed
120 // Power commands issued to root domain
122 kIOPMSleepNow
= (1<<0), // put machine to sleep now
123 kIOPMAllowSleep
= (1<<1), // allow idle sleep
124 kIOPMPreventSleep
= (1<<2), // do not allow idle sleep
125 kIOPMPowerButton
= (1<<3), // power button was pressed
126 kIOPMClamshellClosed
= (1<<4), // clamshell was closed
127 kIOPMPowerEmergency
= (1<<5), // battery dangerously low
128 kIOPMDisableClamshell
= (1<<6), // do not sleep on clamshell closure
129 kIOPMEnableClamshell
= (1<<7), // sleep on clamshell closure
130 kIOPMProcessorSpeedChange
= (1<<8), // change the processor speed
131 kIOPMOverTemp
= (1<<9) // system dangerously hot
135 // PUBLIC power management features
136 // NOTE: this is a direct port from classic, some of these bits
137 // are obsolete but are included for completeness
139 kPMHasWakeupTimerMask
= (1<<0), // 1=wake timer is supported
140 kPMHasSharedModemPortMask
= (1<<1), // Not used
141 kPMHasProcessorCyclingMask
= (1<<2), // 1=processor cycling supported
142 kPMMustProcessorCycleMask
= (1<<3), // Not used
143 kPMHasReducedSpeedMask
= (1<<4), // 1=supports reduced processor speed
144 kPMDynamicSpeedChangeMask
= (1<<5), // 1=supports changing processor speed on the fly
145 kPMHasSCSIDiskModeMask
= (1<<6), // 1=supports using machine as SCSI drive
146 kPMCanGetBatteryTimeMask
= (1<<7), // 1=battery time can be calculated
147 kPMCanWakeupOnRingMask
= (1<<8), // 1=machine can wake on modem ring
148 kPMHasDimmingSupportMask
= (1<<9), // 1=has monitor dimming support
149 kPMHasStartupTimerMask
= (1<<10), // 1=can program startup timer
150 kPMHasChargeNotificationMask
= (1<<11), // 1=client can determine charger status/get notifications
151 kPMHasDimSuspendSupportMask
= (1<<12), // 1=can dim diplay to DPMS ('off') state
152 kPMHasWakeOnNetActivityMask
= (1<<13), // 1=supports waking upon receipt of net packet
153 kPMHasWakeOnLidMask
= (1<<14), // 1=can wake upon lid/case opening
154 kPMCanPowerOffPCIBusMask
= (1<<15), // 1=can remove power from PCI bus on sleep
155 kPMHasDeepSleepMask
= (1<<16), // 1=supports deep (hibernation) sleep
156 kPMHasSleepMask
= (1<<17), // 1=machine support low power sleep (ala powerbooks)
157 kPMSupportsServerModeAPIMask
= (1<<18), // 1=supports reboot on AC resume for unexpected power loss
158 kPMHasUPSIntegrationMask
= (1<<19) // 1=supports incorporating UPS devices into power source calcs
161 // PRIVATE power management features
162 // NOTE: this is a direct port from classic, some of these bits
163 // are obsolete but are included for completeness.
165 kPMHasExtdBattInfoMask
= (1<<0), // Not used
166 kPMHasBatteryIDMask
= (1<<1), // Not used
167 kPMCanSwitchPowerMask
= (1<<2), // Not used
168 kPMHasCelsiusCyclingMask
= (1<<3), // Not used
169 kPMHasBatteryPredictionMask
= (1<<4), // Not used
170 kPMHasPowerLevelsMask
= (1<<5), // Not used
171 kPMHasSleepCPUSpeedMask
= (1<<6), // Not used
172 kPMHasBtnIntHandlersMask
= (1<<7), // 1=supports individual button interrupt handlers
173 kPMHasSCSITermPowerMask
= (1<<8), // 1=supports SCSI termination power switch
174 kPMHasADBButtonHandlersMask
= (1<<9), // 1=supports button handlers via ADB
175 kPMHasICTControlMask
= (1<<10), // 1=supports ICT control
176 kPMHasLegacyDesktopSleepMask
= (1<<11), // 1=supports 'doze' style sleep
177 kPMHasDeepIdleMask
= (1<<12), // 1=supports Idle2 in hardware
178 kPMOpenLidPreventsSleepMask
= (1<<13), // 1=open case prevent machine from sleeping
179 kPMClosedLidCausesSleepMask
= (1<<14), // 1=case closed (clamshell closed) causes sleep
180 kPMHasFanControlMask
= (1<<15), // 1=machine has software-programmable fan/thermostat controls
181 kPMHasThermalControlMask
= (1<<16), // 1=machine supports thermal monitoring
182 kPMHasVStepSpeedChangeMask
= (1<<17), // 1=machine supports processor voltage/clock change
183 kPMEnvironEventsPolledMask
= (1<<18) // 1=machine doesn't generate pmu env ints, we must poll instead
186 // DEFAULT public and private features for machines whose device tree
187 // does NOT contain this information (pre-Core99).
189 // For Cuda-based Desktops
191 #define kStdDesktopPMFeatures kPMHasWakeupTimerMask |\
192 kPMHasProcessorCyclingMask |\
193 kPMHasDimmingSupportMask |\
194 kPMHasStartupTimerMask |\
195 kPMSupportsServerModeAPIMask |\
196 kPMHasUPSIntegrationMask
198 #define kStdDesktopPrivPMFeatures kPMHasExtdBattInfoMask |\
199 kPMHasICTControlMask |\
200 kPMHasLegacyDesktopSleepMask
202 #define kStdDesktopNumBatteries 0
204 // For Wallstreet (PowerBook G3 Series 1998)
206 #define kWallstreetPMFeatures kPMHasWakeupTimerMask |\
207 kPMHasProcessorCyclingMask |\
208 kPMHasReducedSpeedMask |\
209 kPMDynamicSpeedChangeMask |\
210 kPMHasSCSIDiskModeMask |\
211 kPMCanGetBatteryTimeMask |\
212 kPMHasDimmingSupportMask |\
213 kPMHasChargeNotificationMask |\
214 kPMHasDimSuspendSupportMask |\
217 #define kWallstreetPrivPMFeatures kPMHasExtdBattInfoMask |\
218 kPMHasBatteryIDMask |\
219 kPMCanSwitchPowerMask |\
220 kPMHasADBButtonHandlersMask |\
221 kPMHasSCSITermPowerMask |\
222 kPMHasICTControlMask |\
223 kPMClosedLidCausesSleepMask |\
224 kPMEnvironEventsPolledMask
226 #define kStdPowerBookPMFeatures kWallstreetPMFeatures
227 #define kStdPowerBookPrivPMFeatures kWallstreetPrivPMFeatures
229 #define kStdPowerBookNumBatteries 2
231 // For 101 (PowerBook G3 Series 1999)
233 #define k101PMFeatures kPMHasWakeupTimerMask |\
234 kPMHasProcessorCyclingMask |\
235 kPMHasReducedSpeedMask |\
236 kPMDynamicSpeedChangeMask |\
237 kPMHasSCSIDiskModeMask |\
238 kPMCanGetBatteryTimeMask |\
239 kPMHasDimmingSupportMask |\
240 kPMHasChargeNotificationMask |\
241 kPMHasDimSuspendSupportMask |\
243 kPMHasUPSIntegrationMask
245 #define k101PrivPMFeatures kPMHasExtdBattInfoMask |\
246 kPMHasBatteryIDMask |\
247 kPMCanSwitchPowerMask |\
248 kPMHasADBButtonHandlersMask |\
249 kPMHasSCSITermPowerMask |\
250 kPMHasICTControlMask |\
251 kPMClosedLidCausesSleepMask |\
252 kPMEnvironEventsPolledMask
254 #define IOPMNoErr 0 // normal return
256 // returned by powerStateWillChange and powerStateDidChange:
257 #define IOPMAckImplied 0 // acknowledgement of power state change is implied
258 #define IOPMWillAckLater 1 // acknowledgement of power state change will come later
260 // returned by requestDomainState
261 #define IOPMBadSpecification 4 // unrecognized specification parameter
262 #define IOPMNoSuchState 5 // no power state matches search specification
264 #define IOPMCannotRaisePower 6 // a device cannot change its power for some reason
266 // returned by changeStateTo
267 #define IOPMParameterError 7 // requested state doesn't exist
268 #define IOPMNotYetInitialized 8 // device not yet fully hooked into power management "graph"
271 // used by Root Domain UserClient
274 kPMGeneralAggressiveness
= 0,
276 kPMMinutesToSpinDown
,
278 kPMEthernetWakeOnLANSettings
,
279 kPMSetProcessorSpeed
,
282 kPMLastAggressivenessType
284 #define kMaxType (kPMLastAggressivenessType-1)
286 // SetAggressiveness values for the kPMPowerSource aggressiveness type
288 kIOPMInternalPower
= 1,
292 #define kAppleClamshellStateKey "AppleClamshellState"
293 #define kIOREMSleepEnabledKey "REMSleepEnabled"
295 // Strings for deciphering the dictionary returned from IOPMCopyBatteryInfo
296 #define kIOBatteryInfoKey "IOBatteryInfo"
297 #define kIOBatteryCurrentChargeKey "Current"
298 #define kIOBatteryCapacityKey "Capacity"
299 #define kIOBatteryFlagsKey "Flags"
300 #define kIOBatteryVoltageKey "Voltage"
301 #define kIOBatteryAmperageKey "Amperage"
304 kIOBatteryInstalled
= (1 << 2),
305 kIOBatteryCharge
= (1 << 1),
306 kIOBatteryChargerConnect
= (1 << 0)
310 // Private power management message indicating battery data has changed
311 // Indicates new data resides in the IORegistry
312 #define kIOPMMessageBatteryStatusHasChanged iokit_family_msg(sub_iokit_pmu, 0x100)
314 // Apple private Legacy messages for re-routing AutoWake and AutoPower messages to the PMU
315 // through newer user space IOPMSchedulePowerEvent API
316 #define kIOPMUMessageLegacyAutoWake iokit_family_msg(sub_iokit_pmu, 0x200)
317 #define kIOPMUMessageLegacyAutoPower iokit_family_msg(sub_iokit_pmu, 0x210)
319 // These flags are deprecated. Use the version with the kIOPM prefix below.
321 kACInstalled
= kIOBatteryChargerConnect
,
322 kBatteryCharging
= kIOBatteryCharge
,
323 kBatteryInstalled
= kIOBatteryInstalled
,
324 kUPSInstalled
= (1<<3),
325 kBatteryAtWarn
= (1<<4),
326 kBatteryDepleted
= (1<<5),
327 kACnoChargeCapability
= (1<<6), // AC adapter cannot charge battery
328 kRawLowBattery
= (1<<7), // used only by Platform Expert
329 kForceLowSpeed
= (1<<8) // set by Platfm Expert, chk'd by Pwr Plugin};
332 // For use with IOPMPowerSource bFlags
333 #define IOPM_POWER_SOURCE_REV 2
335 kIOPMACInstalled
= kIOBatteryChargerConnect
,
336 kIOPMBatteryCharging
= kIOBatteryCharge
,
337 kIOPMBatteryInstalled
= kIOBatteryInstalled
,
338 kIOPMUPSInstalled
= (1<<3),
339 kIOPMBatteryAtWarn
= (1<<4),
340 kIOPMBatteryDepleted
= (1<<5),
341 kIOPMACnoChargeCapability
= (1<<6), // AC adapter cannot charge battery
342 kIOPMRawLowBattery
= (1<<7), // used only by Platform Expert
343 kIOPMForceLowSpeed
= (1<<8), // set by Platfm Expert, chk'd by Pwr Plugin
344 kIOPMClosedClamshell
= (1<<9), // set by PMU - reflects state of the clamshell
345 kIOPMClamshellStateOnWake
= (1<<10) // used only by Platform Expert
349 // **********************************************
350 // Internal power management data structures
351 // **********************************************
353 #if KERNEL && __cplusplus
357 kIOPowerEmergencyLevel
= 1000
362 kIOPMSuperclassPolicy1
365 struct stateChangeNote
{
366 IOPMPowerFlags stateFlags
;
367 unsigned long stateNum
;
370 typedef struct stateChangeNote stateChangeNote
;
372 struct IOPowerStateChangeNotification
{
374 unsigned long returnValue
;
375 unsigned long stateNumber
;
376 IOPMPowerFlags stateFlags
;
378 typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification
;
379 typedef IOPowerStateChangeNotification sleepWakeNote
;
381 extern void IOPMRegisterDevice(const char *, IOService
*);
382 #endif /* KERNEL && __cplusplus */
384 #endif /* ! _IOKIT_IOPM_H */