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