[HEADERS]
[reactos.git] / reactos / include / ddk / ntpoapi.h
1 /*
2 * ntpoapi.h
3 *
4 * APIs for power management.
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22
23 #ifndef __NTPOAPI_H
24 #define __NTPOAPI_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #ifndef _PO_DDK_
31 #define _PO_DDK_
32
33 /* Power States/Levels */
34 typedef enum _SYSTEM_POWER_STATE {
35 PowerSystemUnspecified,
36 PowerSystemWorking,
37 PowerSystemSleeping1,
38 PowerSystemSleeping2,
39 PowerSystemSleeping3,
40 PowerSystemHibernate,
41 PowerSystemShutdown,
42 PowerSystemMaximum
43 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
44 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
45
46 typedef enum _DEVICE_POWER_STATE {
47 PowerDeviceUnspecified,
48 PowerDeviceD0,
49 PowerDeviceD1,
50 PowerDeviceD2,
51 PowerDeviceD3,
52 PowerDeviceMaximum
53 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
54
55 typedef union _POWER_STATE {
56 SYSTEM_POWER_STATE SystemState;
57 DEVICE_POWER_STATE DeviceState;
58 } POWER_STATE, *PPOWER_STATE;
59
60 typedef enum _POWER_STATE_TYPE {
61 SystemPowerState = 0,
62 DevicePowerState
63 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
64
65 typedef enum _POWER_INFORMATION_LEVEL {
66 SystemPowerPolicyAc,
67 SystemPowerPolicyDc,
68 VerifySystemPolicyAc,
69 VerifySystemPolicyDc,
70 SystemPowerCapabilities,
71 SystemBatteryState,
72 SystemPowerStateHandler,
73 ProcessorStateHandler,
74 SystemPowerPolicyCurrent,
75 AdministratorPowerPolicy,
76 SystemReserveHiberFile,
77 ProcessorInformation,
78 SystemPowerInformation,
79 ProcessorStateHandler2,
80 LastWakeTime,
81 LastSleepTime,
82 SystemExecutionState,
83 SystemPowerStateNotifyHandler,
84 ProcessorPowerPolicyAc,
85 ProcessorPowerPolicyDc,
86 VerifyProcessorPowerPolicyAc,
87 VerifyProcessorPowerPolicyDc,
88 ProcessorPowerPolicyCurrent,
89 SystemPowerStateLogging,
90 SystemPowerLoggingEntry,
91 SetPowerSettingValue,
92 NotifyUserPowerSetting,
93 PowerInformationLevelUnused0,
94 PowerInformationLevelUnused1,
95 SystemVideoState,
96 TraceApplicationPowerMessage,
97 TraceApplicationPowerMessageEnd,
98 ProcessorPerfStates,
99 ProcessorIdleStates,
100 ProcessorCap,
101 SystemWakeSource,
102 SystemHiberFileInformation,
103 TraceServicePowerMessage,
104 ProcessorLoad,
105 PowerShutdownNotification,
106 MonitorCapabilities,
107 SessionPowerInit,
108 SessionDisplayState,
109 PowerRequestCreate,
110 PowerRequestAction,
111 GetPowerRequestList,
112 ProcessorInformationEx,
113 NotifyUserModeLegacyPowerEvent,
114 GroupPark,
115 ProcessorIdleDomains,
116 WakeTimerList,
117 SystemHiberFileSize,
118 PowerInformationLevelMaximum
119 } POWER_INFORMATION_LEVEL;
120
121 typedef enum {
122 PowerActionNone,
123 PowerActionReserved,
124 PowerActionSleep,
125 PowerActionHibernate,
126 PowerActionShutdown,
127 PowerActionShutdownReset,
128 PowerActionShutdownOff,
129 PowerActionWarmEject
130 } POWER_ACTION, *PPOWER_ACTION;
131
132 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
133 typedef struct {
134 ULONG Granularity;
135 ULONG Capacity;
136 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
137 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
138
139
140 #endif /* _PO_DDK_ */
141
142 #define POWER_PERF_SCALE 100
143 #define PERF_LEVEL_TO_PERCENT(x) (((x) * 1000) / (POWER_PERF_SCALE * 10))
144 #define PERCENT_TO_PERF_LEVEL(x) (((x) * POWER_PERF_SCALE * 10) / 1000)
145
146 typedef struct _PROCESSOR_IDLE_TIMES {
147 ULONGLONG StartTime;
148 ULONGLONG EndTime;
149 ULONG IdleHandlerReserved[4];
150 } PROCESSOR_IDLE_TIMES, *PPROCESSOR_IDLE_TIMES;
151
152 typedef BOOLEAN
153 (FASTCALL*PPROCESSOR_IDLE_HANDLER)(
154 IN OUT PPROCESSOR_IDLE_TIMES IdleTimes);
155
156 typedef struct _PROCESSOR_IDLE_HANDLER_INFO {
157 ULONG HardwareLatency;
158 PPROCESSOR_IDLE_HANDLER Handler;
159 } PROCESSOR_IDLE_HANDLER_INFO, *PPROCESSOR_IDLE_HANDLER_INFO;
160
161 typedef VOID
162 (FASTCALL*PSET_PROCESSOR_THROTTLE)(
163 IN UCHAR Throttle);
164
165 typedef NTSTATUS
166 (FASTCALL*PSET_PROCESSOR_THROTTLE2)(
167 IN UCHAR Throttle);
168
169 #define MAX_IDLE_HANDLERS 3
170
171 typedef struct _PROCESSOR_STATE_HANDLER {
172 UCHAR ThrottleScale;
173 BOOLEAN ThrottleOnIdle;
174 PSET_PROCESSOR_THROTTLE SetThrottle;
175 ULONG NumIdleHandlers;
176 PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS];
177 } PROCESSOR_STATE_HANDLER, *PPROCESSOR_STATE_HANDLER;
178
179 typedef enum _POWER_STATE_HANDLER_TYPE {
180 PowerStateSleeping1,
181 PowerStateSleeping2,
182 PowerStateSleeping3,
183 PowerStateSleeping4,
184 PowerStateSleeping4Firmware,
185 PowerStateShutdownReset,
186 PowerStateShutdownOff,
187 PowerStateMaximum
188 } POWER_STATE_HANDLER_TYPE, *PPOWER_STATE_HANDLER_TYPE;
189
190 typedef NTSTATUS
191 (NTAPI*PENTER_STATE_SYSTEM_HANDLER)(
192 IN PVOID SystemContext);
193
194 typedef NTSTATUS
195 (NTAPI*PENTER_STATE_HANDLER)(
196 IN PVOID Context,
197 IN PENTER_STATE_SYSTEM_HANDLER SystemHandler OPTIONAL,
198 IN PVOID SystemContext,
199 IN LONG NumberProcessors,
200 IN LONG volatile *Number);
201
202 typedef struct _POWER_STATE_HANDLER {
203 POWER_STATE_HANDLER_TYPE Type;
204 BOOLEAN RtcWake;
205 UCHAR Spare[3];
206 PENTER_STATE_HANDLER Handler;
207 PVOID Context;
208 } POWER_STATE_HANDLER, *PPOWER_STATE_HANDLER;
209
210 typedef NTSTATUS
211 (NTAPI*PENTER_STATE_NOTIFY_HANDLER)(
212 IN POWER_STATE_HANDLER_TYPE State,
213 IN PVOID Context,
214 IN BOOLEAN Entering);
215
216 typedef struct _POWER_STATE_NOTIFY_HANDLER {
217 PENTER_STATE_NOTIFY_HANDLER Handler;
218 PVOID Context;
219 } POWER_STATE_NOTIFY_HANDLER, *PPOWER_STATE_NOTIFY_HANDLER;
220
221 NTSYSCALLAPI
222 NTSTATUS
223 DDKAPI
224 NtPowerInformation(
225 IN POWER_INFORMATION_LEVEL InformationLevel,
226 IN PVOID InputBuffer OPTIONAL,
227 IN ULONG InputBufferLength,
228 OUT PVOID OutputBuffer OPTIONAL,
229 IN ULONG OutputBufferLength);
230
231 #define PROCESSOR_STATE_TYPE_PERFORMANCE 1
232 #define PROCESSOR_STATE_TYPE_THROTTLE 2
233
234 typedef struct _PROCESSOR_PERF_LEVEL {
235 UCHAR PercentFrequency;
236 UCHAR Reserved;
237 USHORT Flags;
238 } PROCESSOR_PERF_LEVEL, *PPROCESSOR_PERF_LEVEL;
239
240 typedef struct _PROCESSOR_PERF_STATE {
241 UCHAR PercentFrequency;
242 UCHAR MinCapacity;
243 USHORT Power;
244 UCHAR IncreaseLevel;
245 UCHAR DecreaseLevel;
246 USHORT Flags;
247 ULONG IncreaseTime;
248 ULONG DecreaseTime;
249 ULONG IncreaseCount;
250 ULONG DecreaseCount;
251 ULONGLONG PerformanceTime;
252 } PROCESSOR_PERF_STATE, *PPROCESSOR_PERF_STATE;
253
254 typedef struct _PROCESSOR_STATE_HANDLER2 {
255 ULONG NumIdleHandlers;
256 PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS];
257 PSET_PROCESSOR_THROTTLE2 SetPerfLevel;
258 ULONG HardwareLatency;
259 UCHAR NumPerfStates;
260 PROCESSOR_PERF_LEVEL PerfLevel[1];
261 } PROCESSOR_STATE_HANDLER2, *PPROCESSOR_STATE_HANDLER2;
262
263 NTSYSCALLAPI
264 NTSTATUS
265 NTAPI
266 NtSetThreadExecutionState(
267 IN EXECUTION_STATE esFlags,
268 OUT EXECUTION_STATE *PreviousFlags);
269
270 NTSYSCALLAPI
271 NTSTATUS
272 NTAPI
273 NtRequestWakeupLatency(
274 IN LATENCY_TIME latency);
275
276 NTSYSCALLAPI
277 NTSTATUS
278 NTAPI
279 NtInitiatePowerAction(
280 IN POWER_ACTION SystemAction,
281 IN SYSTEM_POWER_STATE MinSystemState,
282 IN ULONG Flags,
283 IN BOOLEAN Asynchronous);
284
285 NTSYSCALLAPI
286 NTSTATUS
287 NTAPI
288 NtSetSystemPowerState(
289 IN POWER_ACTION SystemAction,
290 IN SYSTEM_POWER_STATE MinSystemState,
291 IN ULONG Flags);
292
293 NTSYSCALLAPI
294 NTSTATUS
295 NTAPI
296 NtGetDevicePowerState(
297 IN HANDLE Device,
298 OUT DEVICE_POWER_STATE *State);
299
300 NTSYSCALLAPI
301 NTSTATUS
302 NTAPI
303 NtCancelDeviceWakeupRequest(
304 IN HANDLE Device);
305
306 NTSYSCALLAPI
307 BOOLEAN
308 NTAPI
309 NtIsSystemResumeAutomatic(
310 VOID);
311
312 NTSYSCALLAPI
313 NTSTATUS
314 NTAPI
315 NtRequestDeviceWakeup(
316 IN HANDLE Device);
317
318 #define WINLOGON_LOCK_ON_SLEEP 0x00000001
319
320 typedef struct {
321 BOOLEAN PowerButtonPresent;
322 BOOLEAN SleepButtonPresent;
323 BOOLEAN LidPresent;
324 BOOLEAN SystemS1;
325 BOOLEAN SystemS2;
326 BOOLEAN SystemS3;
327 BOOLEAN SystemS4;
328 BOOLEAN SystemS5;
329 BOOLEAN HiberFilePresent;
330 BOOLEAN FullWake;
331 BOOLEAN VideoDimPresent;
332 BOOLEAN ApmPresent;
333 BOOLEAN UpsPresent;
334 BOOLEAN ThermalControl;
335 BOOLEAN ProcessorThrottle;
336 UCHAR ProcessorMinThrottle;
337 #if (NTDDI_VERSION < NTDDI_WINXP)
338 UCHAR ProcessorThrottleScale;
339 UCHAR spare2[4];
340 #else
341 UCHAR ProcessorMaxThrottle;
342 BOOLEAN FastSystemS4;
343 UCHAR spare2[3];
344 #endif // (NTDDI_VERSION < NTDDI_WINXP)
345 BOOLEAN DiskSpinDown;
346 UCHAR spare3[8];
347 BOOLEAN SystemBatteriesPresent;
348 BOOLEAN BatteriesAreShortTerm;
349 BATTERY_REPORTING_SCALE BatteryScale[3];
350 SYSTEM_POWER_STATE AcOnLineWake;
351 SYSTEM_POWER_STATE SoftLidWake;
352 SYSTEM_POWER_STATE RtcWake;
353 SYSTEM_POWER_STATE MinDeviceWakeState;
354 SYSTEM_POWER_STATE DefaultLowLatencyWake;
355 } SYSTEM_POWER_CAPABILITIES, *PSYSTEM_POWER_CAPABILITIES;
356
357 typedef struct {
358 BOOLEAN AcOnLine;
359 BOOLEAN BatteryPresent;
360 BOOLEAN Charging;
361 BOOLEAN Discharging;
362 BOOLEAN Spare1[4];
363 ULONG MaxCapacity;
364 ULONG RemainingCapacity;
365 ULONG Rate;
366 ULONG EstimatedTime;
367 ULONG DefaultAlert1;
368 ULONG DefaultAlert2;
369 } SYSTEM_BATTERY_STATE, *PSYSTEM_BATTERY_STATE;
370
371 typedef struct _PROCESSOR_POWER_INFORMATION {
372 ULONG Number;
373 ULONG MaxMhz;
374 ULONG CurrentMhz;
375 ULONG MhzLimit;
376 ULONG MaxIdleState;
377 ULONG CurrentIdleState;
378 } PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
379
380 typedef struct _POWER_ACTION_POLICY {
381 POWER_ACTION Action;
382 ULONG Flags;
383 ULONG EventCode;
384 } POWER_ACTION_POLICY, *PPOWER_ACTION_POLICY;
385
386 /* POWER_ACTION_POLICY.Flags constants */
387 #define POWER_ACTION_QUERY_ALLOWED 0x00000001
388 #define POWER_ACTION_UI_ALLOWED 0x00000002
389 #define POWER_ACTION_OVERRIDE_APPS 0x00000004
390 #define POWER_ACTION_LIGHTEST_FIRST 0x10000000
391 #define POWER_ACTION_LOCK_CONSOLE 0x20000000
392 #define POWER_ACTION_DISABLE_WAKES 0x40000000
393 #define POWER_ACTION_CRITICAL 0x80000000
394
395 /* POWER_ACTION_POLICY.EventCode constants */
396 #define POWER_LEVEL_USER_NOTIFY_TEXT 0x00000001
397 #define POWER_LEVEL_USER_NOTIFY_SOUND 0x00000002
398 #define POWER_LEVEL_USER_NOTIFY_EXEC 0x00000004
399 #define POWER_USER_NOTIFY_BUTTON 0x00000008
400 #define POWER_USER_NOTIFY_SHUTDOWN 0x00000010
401 #define POWER_FORCE_TRIGGER_RESET 0x80000000
402
403 #define DISCHARGE_POLICY_CRITICAL 0
404 #define DISCHARGE_POLICY_LOW 1
405 #define NUM_DISCHARGE_POLICIES 4
406
407 #define PO_THROTTLE_NONE 0
408 #define PO_THROTTLE_CONSTANT 1
409 #define PO_THROTTLE_DEGRADE 2
410 #define PO_THROTTLE_ADAPTIVE 3
411 #define PO_THROTTLE_MAXIMUM 4
412
413 #ifdef __cplusplus
414 }
415 #endif
416
417 #endif /* __NTPOAPI_H */