]>
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; | |
28 | ||
29 | #define IOPMNotAttainable 0x0001 | |
30 | #define IOPMPowerOn 0x0002 | |
31 | #define IOPMClockNormal 0x0004 | |
32 | #define IOPMClockRunning 0x0008 | |
33 | #define IOPMWakeupEnabled 0x0010 | |
34 | #define IOPMAuxPowerOn 0x0020 | |
35 | // following "capabilites" exist for the convenience | |
36 | // of the "interested drivers" | |
37 | #define IOPMDeviceUsable 0x8000 | |
38 | #define IOPMMaxPerformance 0x4000 | |
39 | #define IOPMContextRetained 0x2000 | |
40 | #define IOPMConfigRetained 0x1000 | |
41 | #define IOPMNotPowerManaged 0x0800 | |
42 | #define IOPMSoftSleep 0x0400 | |
43 | ||
44 | #define IOPMNextHigherState 1 | |
45 | #define IOPMHighestState 2 | |
46 | #define IOPMNextLowerState 3 | |
47 | #define IOPMLowestState 4 | |
48 | ||
49 | ||
50 | enum { // commands on power managment command queue | |
51 | kPMbroadcastAggressiveness = 1, | |
52 | kPMunIdleDevice, | |
53 | kPMsleepDemand, | |
54 | kPMwakeSignal, | |
55 | kPMallowSleep, | |
56 | kPMcancelSleep | |
57 | }; | |
58 | ||
59 | // Power events | |
60 | enum { | |
61 | kClamshellClosedEventMask = (1<<0), // User closed lid | |
62 | kDockingBarEventMask = (1<<1), // OBSOLETE | |
63 | kACPlugEventMask = (1<<2), // User plugged or unplugged adapter | |
64 | kFrontPanelButtonEventMask = (1<<3), // User hit the front panel button | |
65 | kBatteryStatusEventMask = (1<<4) // Battery status has changed | |
66 | }; | |
67 | ||
68 | // Power commands issued to root domain | |
69 | enum { | |
70 | kIOPMSleepNow = (1<<0), // put machine to sleep now | |
71 | kIOPMAllowSleep = (1<<1), // allow idle sleep | |
72 | kIOPMPreventSleep = (1<<2), // do not allow idle sleep | |
73 | kIOPMPowerButton = (1<<3), // power button was pressed | |
74 | kIOPMClamshellClosed = (1<<4), // clamshell was closed | |
75 | kIOPMPowerEmergency = (1<<5), // battery dangerously low | |
76 | kIOPMIgnoreClamshell = (1<<6) // take no action on clamshell closure | |
77 | }; | |
78 | // Return codes | |
79 | ||
80 | // PUBLIC power management features | |
81 | // NOTE: this is a direct port from classic, some of these bits | |
82 | // are obsolete but are included for completeness | |
83 | enum { | |
84 | kPMHasWakeupTimerMask = (1<<0), // 1=wake timer is supported | |
85 | kPMHasSharedModemPortMask = (1<<1), // Not used | |
86 | kPMHasProcessorCyclingMask = (1<<2), // 1=processor cycling supported | |
87 | kPMMustProcessorCycleMask = (1<<3), // Not used | |
88 | kPMHasReducedSpeedMask = (1<<4), // 1=supports reduced processor speed | |
89 | kPMDynamicSpeedChangeMask = (1<<5), // 1=supports changing processor speed on the fly | |
90 | kPMHasSCSIDiskModeMask = (1<<6), // 1=supports using machine as SCSI drive | |
91 | kPMCanGetBatteryTimeMask = (1<<7), // 1=battery time can be calculated | |
92 | kPMCanWakeupOnRingMask = (1<<8), // 1=machine can wake on modem ring | |
93 | kPMHasDimmingSupportMask = (1<<9), // 1=has monitor dimming support | |
94 | kPMHasStartupTimerMask = (1<<10), // 1=can program startup timer | |
95 | kPMHasChargeNotificationMask = (1<<11), // 1=client can determine charger status/get notifications | |
96 | kPMHasDimSuspendSupportMask = (1<<12), // 1=can dim diplay to DPMS ('off') state | |
97 | kPMHasWakeOnNetActivityMask = (1<<13), // 1=supports waking upon receipt of net packet | |
98 | kPMHasWakeOnLidMask = (1<<14), // 1=can wake upon lid/case opening | |
99 | kPMCanPowerOffPCIBusMask = (1<<15), // 1=can remove power from PCI bus on sleep | |
100 | kPMHasDeepSleepMask = (1<<16), // 1=supports deep (hibernation) sleep | |
101 | kPMHasSleepMask = (1<<17), // 1=machine support low power sleep (ala powerbooks) | |
102 | kPMSupportsServerModeAPIMask = (1<<18), // 1=supports reboot on AC resume for unexpected power loss | |
103 | kPMHasUPSIntegrationMask = (1<<19) // 1=supports incorporating UPS devices into power source calcs | |
104 | }; | |
105 | ||
106 | // PRIVATE power management features | |
107 | // NOTE: this is a direct port from classic, some of these bits | |
108 | // are obsolete but are included for completeness. | |
109 | enum { | |
110 | kPMHasExtdBattInfoMask = (1<<0), // Not used | |
111 | kPMHasBatteryIDMask = (1<<1), // Not used | |
112 | kPMCanSwitchPowerMask = (1<<2), // Not used | |
113 | kPMHasCelsiusCyclingMask = (1<<3), // Not used | |
114 | kPMHasBatteryPredictionMask = (1<<4), // Not used | |
115 | kPMHasPowerLevelsMask = (1<<5), // Not used | |
116 | kPMHasSleepCPUSpeedMask = (1<<6), // Not used | |
117 | kPMHasBtnIntHandlersMask = (1<<7), // 1=supports individual button interrupt handlers | |
118 | kPMHasSCSITermPowerMask = (1<<8), // 1=supports SCSI termination power switch | |
119 | kPMHasADBButtonHandlersMask = (1<<9), // 1=supports button handlers via ADB | |
120 | kPMHasICTControlMask = (1<<10), // 1=supports ICT control | |
121 | kPMHasLegacyDesktopSleepMask = (1<<11), // 1=supports 'doze' style sleep | |
122 | kPMHasDeepIdleMask = (1<<12), // 1=supports Idle2 in hardware | |
123 | kPMOpenLidPreventsSleepMask = (1<<13), // 1=open case prevent machine from sleeping | |
124 | kPMClosedLidCausesSleepMask = (1<<14), // 1=case closed (clamshell closed) causes sleep | |
125 | kPMHasFanControlMask = (1<<15), // 1=machine has software-programmable fan/thermostat controls | |
126 | kPMHasThermalControlMask = (1<<16), // 1=machine supports thermal monitoring | |
127 | kPMHasVStepSpeedChangeMask = (1<<17), // 1=machine supports processor voltage/clock change | |
128 | kPMEnvironEventsPolledMask = (1<<18) // 1=machine doesn't generate pmu env ints, we must poll instead | |
129 | }; | |
130 | ||
131 | // DEFAULT public and private features for machines whose device tree | |
132 | // does NOT contain this information (pre-Core99). | |
133 | ||
134 | // For Cuda-based Desktops | |
135 | ||
136 | #define kStdDesktopPMFeatures kPMHasWakeupTimerMask |\ | |
137 | kPMHasProcessorCyclingMask |\ | |
138 | kPMHasDimmingSupportMask |\ | |
139 | kPMHasStartupTimerMask |\ | |
140 | kPMSupportsServerModeAPIMask |\ | |
141 | kPMHasUPSIntegrationMask | |
142 | ||
143 | #define kStdDesktopPrivPMFeatures kPMHasExtdBattInfoMask |\ | |
144 | kPMHasICTControlMask |\ | |
145 | kPMHasLegacyDesktopSleepMask | |
146 | ||
147 | #define kStdDesktopNumBatteries 0 | |
148 | ||
149 | // For Wallstreet (PowerBook G3 Series 1998) | |
150 | ||
151 | #define kWallstreetPMFeatures kPMHasWakeupTimerMask |\ | |
152 | kPMHasProcessorCyclingMask |\ | |
153 | kPMHasReducedSpeedMask |\ | |
154 | kPMDynamicSpeedChangeMask |\ | |
155 | kPMHasSCSIDiskModeMask |\ | |
156 | kPMCanGetBatteryTimeMask |\ | |
157 | kPMHasDimmingSupportMask |\ | |
158 | kPMHasChargeNotificationMask |\ | |
159 | kPMHasDimSuspendSupportMask |\ | |
160 | kPMHasSleepMask | |
161 | ||
162 | #define kWallstreetPrivPMFeatures kPMHasExtdBattInfoMask |\ | |
163 | kPMHasBatteryIDMask |\ | |
164 | kPMCanSwitchPowerMask |\ | |
165 | kPMHasADBButtonHandlersMask |\ | |
166 | kPMHasSCSITermPowerMask |\ | |
167 | kPMHasICTControlMask |\ | |
168 | kPMClosedLidCausesSleepMask |\ | |
169 | kPMEnvironEventsPolledMask | |
170 | ||
171 | #define kStdPowerBookPMFeatures kWallstreetPMFeatures | |
172 | #define kStdPowerBookPrivPMFeatures kWallstreetPrivPMFeatures | |
173 | ||
174 | #define kStdPowerBookNumBatteries 2 | |
175 | ||
176 | // For 101 (PowerBook G3 Series 1999) | |
177 | ||
178 | #define k101PMFeatures kPMHasWakeupTimerMask |\ | |
179 | kPMHasProcessorCyclingMask |\ | |
180 | kPMHasReducedSpeedMask |\ | |
181 | kPMDynamicSpeedChangeMask |\ | |
182 | kPMHasSCSIDiskModeMask |\ | |
183 | kPMCanGetBatteryTimeMask |\ | |
184 | kPMHasDimmingSupportMask |\ | |
185 | kPMHasChargeNotificationMask |\ | |
186 | kPMHasDimSuspendSupportMask |\ | |
187 | kPMHasSleepMask |\ | |
188 | kPMHasUPSIntegrationMask | |
189 | ||
190 | #define k101PrivPMFeatures kPMHasExtdBattInfoMask |\ | |
191 | kPMHasBatteryIDMask |\ | |
192 | kPMCanSwitchPowerMask |\ | |
193 | kPMHasADBButtonHandlersMask |\ | |
194 | kPMHasSCSITermPowerMask |\ | |
195 | kPMHasICTControlMask |\ | |
196 | kPMClosedLidCausesSleepMask |\ | |
197 | kPMEnvironEventsPolledMask | |
198 | ||
199 | #define IOPMNoErr 0 // normal return | |
200 | ||
201 | // returned by powerStateWillChange and powerStateDidChange: | |
202 | #define IOPMAckImplied 0 // acknowledgement of power state change is implied | |
203 | #define IOPMWillAckLater 1 // acknowledgement of power state change will come later | |
204 | ||
205 | // returned by requestDomainState | |
206 | #define IOPMBadSpecification 4 // unrecognized specification parameter | |
207 | #define IOPMNoSuchState 5 // no power state matches search specification | |
208 | ||
209 | #define IOPMCannotRaisePower 6 // a device cannot change its power for some reason | |
210 | ||
211 | // returned by changeStateTo | |
212 | #define IOPMParameterError 7 // requested state doesn't exist | |
213 | #define IOPMNotYetInitialized 8 // device not yet fully hooked into power management "graph" | |
214 | ||
215 | ||
216 | // used by Root Domain UserClient | |
217 | ||
218 | enum { | |
219 | kPMGeneralAggressiveness = 0, | |
220 | kPMMinutesToDim, | |
221 | kPMMinutesToSpinDown, | |
222 | kPMMinutesToSleep | |
223 | }; | |
224 | #define kMaxType kPMMinutesToSleep | |
225 | ||
226 | ||
227 | #define kIOBatteryInfoKey "IOBatteryInfo" | |
228 | #define kIOBatteryCurrentChargeKey "Current" | |
229 | #define kIOBatteryCapacityKey "Capacity" | |
230 | #define kIOBatteryFlagsKey "Flags" | |
231 | #define kIOBatteryVoltageKey "Voltage" | |
232 | #define kIOBatteryAmperageKey "Amperage" | |
233 | enum { | |
234 | kIOBatteryInstalled = (1 << 2), | |
235 | kIOBatteryCharge = (1 << 1), | |
236 | kIOBatteryChargerConnect = (1 << 0) | |
237 | }; | |
238 | ||
239 | ||
240 | #if KERNEL && __cplusplus | |
241 | class IOService; | |
242 | ||
243 | enum { | |
244 | kIOPowerEmergencyLevel = 1000 | |
245 | }; | |
246 | ||
247 | enum { | |
248 | kIOPMSubclassPolicy, | |
249 | kIOPMSuperclassPolicy1 | |
250 | }; | |
251 | ||
252 | struct stateChangeNote{ | |
253 | IOPMPowerFlags stateFlags; | |
254 | unsigned long stateNum; | |
255 | void * powerRef; | |
256 | }; | |
257 | typedef struct stateChangeNote stateChangeNote; | |
258 | ||
259 | struct sleepWakeNote{ | |
260 | void * powerRef; | |
261 | unsigned long returnValue; | |
262 | }; | |
263 | typedef struct sleepWakeNote sleepWakeNote; | |
264 | ||
265 | extern void IOPMRegisterDevice(const char *, IOService *); | |
266 | #endif /* KERNEL && __cplusplus */ | |
267 | ||
268 | #endif /* ! _IOKIT_IOPM_H */ | |
269 |