]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
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. | |
11 | * | |
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 | |
18 | * under the License. | |
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 A |
120 | kIOPMDisableClamshell = (1<<6), // do not sleep on clamshell closure |
121 | kIOPMEnableClamshell = (1<<7) // sleep on clamshell closure | |
1c79356b A |
122 | }; |
123 | // Return codes | |
124 | ||
125 | // PUBLIC power management features | |
126 | // NOTE: this is a direct port from classic, some of these bits | |
127 | // are obsolete but are included for completeness | |
128 | enum { | |
129 | kPMHasWakeupTimerMask = (1<<0), // 1=wake timer is supported | |
130 | kPMHasSharedModemPortMask = (1<<1), // Not used | |
131 | kPMHasProcessorCyclingMask = (1<<2), // 1=processor cycling supported | |
132 | kPMMustProcessorCycleMask = (1<<3), // Not used | |
133 | kPMHasReducedSpeedMask = (1<<4), // 1=supports reduced processor speed | |
134 | kPMDynamicSpeedChangeMask = (1<<5), // 1=supports changing processor speed on the fly | |
135 | kPMHasSCSIDiskModeMask = (1<<6), // 1=supports using machine as SCSI drive | |
136 | kPMCanGetBatteryTimeMask = (1<<7), // 1=battery time can be calculated | |
137 | kPMCanWakeupOnRingMask = (1<<8), // 1=machine can wake on modem ring | |
138 | kPMHasDimmingSupportMask = (1<<9), // 1=has monitor dimming support | |
139 | kPMHasStartupTimerMask = (1<<10), // 1=can program startup timer | |
140 | kPMHasChargeNotificationMask = (1<<11), // 1=client can determine charger status/get notifications | |
141 | kPMHasDimSuspendSupportMask = (1<<12), // 1=can dim diplay to DPMS ('off') state | |
142 | kPMHasWakeOnNetActivityMask = (1<<13), // 1=supports waking upon receipt of net packet | |
143 | kPMHasWakeOnLidMask = (1<<14), // 1=can wake upon lid/case opening | |
144 | kPMCanPowerOffPCIBusMask = (1<<15), // 1=can remove power from PCI bus on sleep | |
145 | kPMHasDeepSleepMask = (1<<16), // 1=supports deep (hibernation) sleep | |
146 | kPMHasSleepMask = (1<<17), // 1=machine support low power sleep (ala powerbooks) | |
147 | kPMSupportsServerModeAPIMask = (1<<18), // 1=supports reboot on AC resume for unexpected power loss | |
148 | kPMHasUPSIntegrationMask = (1<<19) // 1=supports incorporating UPS devices into power source calcs | |
149 | }; | |
150 | ||
151 | // PRIVATE power management features | |
152 | // NOTE: this is a direct port from classic, some of these bits | |
153 | // are obsolete but are included for completeness. | |
154 | enum { | |
155 | kPMHasExtdBattInfoMask = (1<<0), // Not used | |
156 | kPMHasBatteryIDMask = (1<<1), // Not used | |
157 | kPMCanSwitchPowerMask = (1<<2), // Not used | |
158 | kPMHasCelsiusCyclingMask = (1<<3), // Not used | |
159 | kPMHasBatteryPredictionMask = (1<<4), // Not used | |
160 | kPMHasPowerLevelsMask = (1<<5), // Not used | |
161 | kPMHasSleepCPUSpeedMask = (1<<6), // Not used | |
162 | kPMHasBtnIntHandlersMask = (1<<7), // 1=supports individual button interrupt handlers | |
163 | kPMHasSCSITermPowerMask = (1<<8), // 1=supports SCSI termination power switch | |
164 | kPMHasADBButtonHandlersMask = (1<<9), // 1=supports button handlers via ADB | |
165 | kPMHasICTControlMask = (1<<10), // 1=supports ICT control | |
166 | kPMHasLegacyDesktopSleepMask = (1<<11), // 1=supports 'doze' style sleep | |
167 | kPMHasDeepIdleMask = (1<<12), // 1=supports Idle2 in hardware | |
168 | kPMOpenLidPreventsSleepMask = (1<<13), // 1=open case prevent machine from sleeping | |
169 | kPMClosedLidCausesSleepMask = (1<<14), // 1=case closed (clamshell closed) causes sleep | |
170 | kPMHasFanControlMask = (1<<15), // 1=machine has software-programmable fan/thermostat controls | |
171 | kPMHasThermalControlMask = (1<<16), // 1=machine supports thermal monitoring | |
172 | kPMHasVStepSpeedChangeMask = (1<<17), // 1=machine supports processor voltage/clock change | |
173 | kPMEnvironEventsPolledMask = (1<<18) // 1=machine doesn't generate pmu env ints, we must poll instead | |
174 | }; | |
175 | ||
176 | // DEFAULT public and private features for machines whose device tree | |
177 | // does NOT contain this information (pre-Core99). | |
178 | ||
179 | // For Cuda-based Desktops | |
180 | ||
181 | #define kStdDesktopPMFeatures kPMHasWakeupTimerMask |\ | |
182 | kPMHasProcessorCyclingMask |\ | |
183 | kPMHasDimmingSupportMask |\ | |
184 | kPMHasStartupTimerMask |\ | |
185 | kPMSupportsServerModeAPIMask |\ | |
186 | kPMHasUPSIntegrationMask | |
187 | ||
188 | #define kStdDesktopPrivPMFeatures kPMHasExtdBattInfoMask |\ | |
189 | kPMHasICTControlMask |\ | |
190 | kPMHasLegacyDesktopSleepMask | |
191 | ||
192 | #define kStdDesktopNumBatteries 0 | |
193 | ||
194 | // For Wallstreet (PowerBook G3 Series 1998) | |
195 | ||
196 | #define kWallstreetPMFeatures kPMHasWakeupTimerMask |\ | |
197 | kPMHasProcessorCyclingMask |\ | |
198 | kPMHasReducedSpeedMask |\ | |
199 | kPMDynamicSpeedChangeMask |\ | |
200 | kPMHasSCSIDiskModeMask |\ | |
201 | kPMCanGetBatteryTimeMask |\ | |
202 | kPMHasDimmingSupportMask |\ | |
203 | kPMHasChargeNotificationMask |\ | |
204 | kPMHasDimSuspendSupportMask |\ | |
205 | kPMHasSleepMask | |
206 | ||
207 | #define kWallstreetPrivPMFeatures kPMHasExtdBattInfoMask |\ | |
208 | kPMHasBatteryIDMask |\ | |
209 | kPMCanSwitchPowerMask |\ | |
210 | kPMHasADBButtonHandlersMask |\ | |
211 | kPMHasSCSITermPowerMask |\ | |
212 | kPMHasICTControlMask |\ | |
213 | kPMClosedLidCausesSleepMask |\ | |
214 | kPMEnvironEventsPolledMask | |
215 | ||
216 | #define kStdPowerBookPMFeatures kWallstreetPMFeatures | |
217 | #define kStdPowerBookPrivPMFeatures kWallstreetPrivPMFeatures | |
218 | ||
219 | #define kStdPowerBookNumBatteries 2 | |
220 | ||
221 | // For 101 (PowerBook G3 Series 1999) | |
222 | ||
223 | #define k101PMFeatures kPMHasWakeupTimerMask |\ | |
224 | kPMHasProcessorCyclingMask |\ | |
225 | kPMHasReducedSpeedMask |\ | |
226 | kPMDynamicSpeedChangeMask |\ | |
227 | kPMHasSCSIDiskModeMask |\ | |
228 | kPMCanGetBatteryTimeMask |\ | |
229 | kPMHasDimmingSupportMask |\ | |
230 | kPMHasChargeNotificationMask |\ | |
231 | kPMHasDimSuspendSupportMask |\ | |
232 | kPMHasSleepMask |\ | |
233 | kPMHasUPSIntegrationMask | |
234 | ||
235 | #define k101PrivPMFeatures kPMHasExtdBattInfoMask |\ | |
236 | kPMHasBatteryIDMask |\ | |
237 | kPMCanSwitchPowerMask |\ | |
238 | kPMHasADBButtonHandlersMask |\ | |
239 | kPMHasSCSITermPowerMask |\ | |
240 | kPMHasICTControlMask |\ | |
241 | kPMClosedLidCausesSleepMask |\ | |
242 | kPMEnvironEventsPolledMask | |
243 | ||
244 | #define IOPMNoErr 0 // normal return | |
245 | ||
246 | // returned by powerStateWillChange and powerStateDidChange: | |
247 | #define IOPMAckImplied 0 // acknowledgement of power state change is implied | |
248 | #define IOPMWillAckLater 1 // acknowledgement of power state change will come later | |
249 | ||
250 | // returned by requestDomainState | |
251 | #define IOPMBadSpecification 4 // unrecognized specification parameter | |
252 | #define IOPMNoSuchState 5 // no power state matches search specification | |
253 | ||
254 | #define IOPMCannotRaisePower 6 // a device cannot change its power for some reason | |
255 | ||
256 | // returned by changeStateTo | |
257 | #define IOPMParameterError 7 // requested state doesn't exist | |
258 | #define IOPMNotYetInitialized 8 // device not yet fully hooked into power management "graph" | |
259 | ||
260 | ||
261 | // used by Root Domain UserClient | |
262 | ||
263 | enum { | |
264 | kPMGeneralAggressiveness = 0, | |
265 | kPMMinutesToDim, | |
266 | kPMMinutesToSpinDown, | |
0b4e3aa0 A |
267 | kPMMinutesToSleep, |
268 | kPMEthernetWakeOnLANSettings, | |
1c79356b | 269 | }; |
0b4e3aa0 | 270 | #define kMaxType kPMEthernetWakeOnLANSettings |
1c79356b A |
271 | |
272 | ||
273 | #define kIOBatteryInfoKey "IOBatteryInfo" | |
274 | #define kIOBatteryCurrentChargeKey "Current" | |
275 | #define kIOBatteryCapacityKey "Capacity" | |
276 | #define kIOBatteryFlagsKey "Flags" | |
277 | #define kIOBatteryVoltageKey "Voltage" | |
278 | #define kIOBatteryAmperageKey "Amperage" | |
279 | enum { | |
280 | kIOBatteryInstalled = (1 << 2), | |
281 | kIOBatteryCharge = (1 << 1), | |
282 | kIOBatteryChargerConnect = (1 << 0) | |
283 | }; | |
284 | ||
285 | ||
286 | #if KERNEL && __cplusplus | |
287 | class IOService; | |
288 | ||
289 | enum { | |
290 | kIOPowerEmergencyLevel = 1000 | |
291 | }; | |
292 | ||
293 | enum { | |
294 | kIOPMSubclassPolicy, | |
295 | kIOPMSuperclassPolicy1 | |
296 | }; | |
297 | ||
298 | struct stateChangeNote{ | |
299 | IOPMPowerFlags stateFlags; | |
300 | unsigned long stateNum; | |
301 | void * powerRef; | |
302 | }; | |
303 | typedef struct stateChangeNote stateChangeNote; | |
304 | ||
0b4e3aa0 | 305 | struct IOPowerStateChangeNotification { |
1c79356b A |
306 | void * powerRef; |
307 | unsigned long returnValue; | |
0b4e3aa0 A |
308 | unsigned long stateNumber; |
309 | IOPMPowerFlags stateFlags; | |
1c79356b | 310 | }; |
0b4e3aa0 A |
311 | typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification; |
312 | typedef IOPowerStateChangeNotification sleepWakeNote; | |
1c79356b A |
313 | |
314 | extern void IOPMRegisterDevice(const char *, IOService *); | |
315 | #endif /* KERNEL && __cplusplus */ | |
316 | ||
317 | #endif /* ! _IOKIT_IOPM_H */ | |
318 |