[DDK]
[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
45 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
46
47 typedef enum _DEVICE_POWER_STATE {
48 PowerDeviceUnspecified,
49 PowerDeviceD0,
50 PowerDeviceD1,
51 PowerDeviceD2,
52 PowerDeviceD3,
53 PowerDeviceMaximum
54 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
55
56 typedef union _POWER_STATE {
57 SYSTEM_POWER_STATE SystemState;
58 DEVICE_POWER_STATE DeviceState;
59 } POWER_STATE, *PPOWER_STATE;
60
61 typedef enum _POWER_STATE_TYPE {
62 SystemPowerState = 0,
63 DevicePowerState
64 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
65
66 typedef enum _POWER_INFORMATION_LEVEL {
67 SystemPowerPolicyAc,
68 SystemPowerPolicyDc,
69 VerifySystemPolicyAc,
70 VerifySystemPolicyDc,
71 SystemPowerCapabilities,
72 SystemBatteryState,
73 SystemPowerStateHandler,
74 ProcessorStateHandler,
75 SystemPowerPolicyCurrent,
76 AdministratorPowerPolicy,
77 SystemReserveHiberFile,
78 ProcessorInformation,
79 SystemPowerInformation,
80 ProcessorStateHandler2,
81 LastWakeTime,
82 LastSleepTime,
83 SystemExecutionState,
84 SystemPowerStateNotifyHandler,
85 ProcessorPowerPolicyAc,
86 ProcessorPowerPolicyDc,
87 VerifyProcessorPowerPolicyAc,
88 VerifyProcessorPowerPolicyDc,
89 ProcessorPowerPolicyCurrent,
90 SystemPowerStateLogging,
91 SystemPowerLoggingEntry,
92 SetPowerSettingValue,
93 NotifyUserPowerSetting,
94 PowerInformationLevelUnused0,
95 PowerInformationLevelUnused1,
96 SystemVideoState,
97 TraceApplicationPowerMessage,
98 TraceApplicationPowerMessageEnd,
99 ProcessorPerfStates,
100 ProcessorIdleStates,
101 ProcessorCap,
102 SystemWakeSource,
103 SystemHiberFileInformation,
104 TraceServicePowerMessage,
105 ProcessorLoad,
106 PowerShutdownNotification,
107 MonitorCapabilities,
108 SessionPowerInit,
109 SessionDisplayState,
110 PowerRequestCreate,
111 PowerRequestAction,
112 GetPowerRequestList,
113 ProcessorInformationEx,
114 NotifyUserModeLegacyPowerEvent,
115 GroupPark,
116 ProcessorIdleDomains,
117 WakeTimerList,
118 SystemHiberFileSize,
119 PowerInformationLevelMaximum
120 } POWER_INFORMATION_LEVEL;
121
122 typedef enum {
123 PowerActionNone,
124 PowerActionReserved,
125 PowerActionSleep,
126 PowerActionHibernate,
127 PowerActionShutdown,
128 PowerActionShutdownReset,
129 PowerActionShutdownOff,
130 PowerActionWarmEject
131 } POWER_ACTION, *PPOWER_ACTION;
132
133 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
134 typedef struct {
135 ULONG Granularity;
136 ULONG Capacity;
137 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
138 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */
139
140
141 #endif /* _PO_DDK_ */
142
143 #define POWER_PERF_SCALE 100
144 #define PERF_LEVEL_TO_PERCENT(x) (((x) * 1000) / (POWER_PERF_SCALE * 10))
145 #define PERCENT_TO_PERF_LEVEL(x) (((x) * POWER_PERF_SCALE * 10) / 1000)
146
147 typedef struct _PROCESSOR_IDLE_TIMES {
148 ULONGLONG StartTime;
149 ULONGLONG EndTime;
150 ULONG IdleHandlerReserved[4];
151 } PROCESSOR_IDLE_TIMES, *PPROCESSOR_IDLE_TIMES;
152
153 typedef BOOLEAN
154 (FASTCALL*PPROCESSOR_IDLE_HANDLER)(
155 IN OUT PPROCESSOR_IDLE_TIMES IdleTimes);
156
157 typedef struct _PROCESSOR_IDLE_HANDLER_INFO {
158 ULONG HardwareLatency;
159 PPROCESSOR_IDLE_HANDLER Handler;
160 } PROCESSOR_IDLE_HANDLER_INFO, *PPROCESSOR_IDLE_HANDLER_INFO;
161
162 typedef VOID
163 (FASTCALL*PSET_PROCESSOR_THROTTLE)(
164 IN UCHAR Throttle);
165
166 typedef NTSTATUS
167 (FASTCALL*PSET_PROCESSOR_THROTTLE2)(
168 IN UCHAR Throttle);
169
170 #define MAX_IDLE_HANDLERS 3
171
172 typedef struct _PROCESSOR_STATE_HANDLER {
173 UCHAR ThrottleScale;
174 BOOLEAN ThrottleOnIdle;
175 PSET_PROCESSOR_THROTTLE SetThrottle;
176 ULONG NumIdleHandlers;
177 PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS];
178 } PROCESSOR_STATE_HANDLER, *PPROCESSOR_STATE_HANDLER;
179
180 typedef enum _POWER_STATE_HANDLER_TYPE {
181 PowerStateSleeping1,
182 PowerStateSleeping2,
183 PowerStateSleeping3,
184 PowerStateSleeping4,
185 PowerStateSleeping4Firmware,
186 PowerStateShutdownReset,
187 PowerStateShutdownOff,
188 PowerStateMaximum
189 } POWER_STATE_HANDLER_TYPE, *PPOWER_STATE_HANDLER_TYPE;
190
191 typedef NTSTATUS
192 (NTAPI*PENTER_STATE_SYSTEM_HANDLER)(
193 IN PVOID SystemContext);
194
195 typedef NTSTATUS
196 (NTAPI*PENTER_STATE_HANDLER)(
197 IN PVOID Context,
198 IN PENTER_STATE_SYSTEM_HANDLER SystemHandler OPTIONAL,
199 IN PVOID SystemContext,
200 IN LONG NumberProcessors,
201 IN LONG volatile *Number);
202
203 typedef struct _POWER_STATE_HANDLER {
204 POWER_STATE_HANDLER_TYPE Type;
205 BOOLEAN RtcWake;
206 UCHAR Spare[3];
207 PENTER_STATE_HANDLER Handler;
208 PVOID Context;
209 } POWER_STATE_HANDLER, *PPOWER_STATE_HANDLER;
210
211 typedef NTSTATUS
212 (NTAPI*PENTER_STATE_NOTIFY_HANDLER)(
213 IN POWER_STATE_HANDLER_TYPE State,
214 IN PVOID Context,
215 IN BOOLEAN Entering);
216
217 typedef struct _POWER_STATE_NOTIFY_HANDLER {
218 PENTER_STATE_NOTIFY_HANDLER Handler;
219 PVOID Context;
220 } POWER_STATE_NOTIFY_HANDLER, *PPOWER_STATE_NOTIFY_HANDLER;
221
222 NTSYSCALLAPI
223 NTSTATUS
224 NTAPI
225 NtPowerInformation(
226 IN POWER_INFORMATION_LEVEL InformationLevel,
227 IN PVOID InputBuffer OPTIONAL,
228 IN ULONG InputBufferLength,
229 OUT PVOID OutputBuffer OPTIONAL,
230 IN ULONG OutputBufferLength);
231
232 #define PROCESSOR_STATE_TYPE_PERFORMANCE 1
233 #define PROCESSOR_STATE_TYPE_THROTTLE 2
234
235 typedef struct _PROCESSOR_PERF_LEVEL {
236 UCHAR PercentFrequency;
237 UCHAR Reserved;
238 USHORT Flags;
239 } PROCESSOR_PERF_LEVEL, *PPROCESSOR_PERF_LEVEL;
240
241 typedef struct _PROCESSOR_PERF_STATE {
242 UCHAR PercentFrequency;
243 UCHAR MinCapacity;
244 USHORT Power;
245 UCHAR IncreaseLevel;
246 UCHAR DecreaseLevel;
247 USHORT Flags;
248 ULONG IncreaseTime;
249 ULONG DecreaseTime;
250 ULONG IncreaseCount;
251 ULONG DecreaseCount;
252 ULONGLONG PerformanceTime;
253 } PROCESSOR_PERF_STATE, *PPROCESSOR_PERF_STATE;
254
255 typedef struct _PROCESSOR_STATE_HANDLER2 {
256 ULONG NumIdleHandlers;
257 PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS];
258 PSET_PROCESSOR_THROTTLE2 SetPerfLevel;
259 ULONG HardwareLatency;
260 UCHAR NumPerfStates;
261 PROCESSOR_PERF_LEVEL PerfLevel[1];
262 } PROCESSOR_STATE_HANDLER2, *PPROCESSOR_STATE_HANDLER2;
263
264 NTSYSCALLAPI
265 NTSTATUS
266 NTAPI
267 NtSetThreadExecutionState(
268 IN EXECUTION_STATE esFlags,
269 OUT EXECUTION_STATE *PreviousFlags);
270
271 NTSYSCALLAPI
272 NTSTATUS
273 NTAPI
274 NtRequestWakeupLatency(
275 IN LATENCY_TIME latency);
276
277 NTSYSCALLAPI
278 NTSTATUS
279 NTAPI
280 NtInitiatePowerAction(
281 IN POWER_ACTION SystemAction,
282 IN SYSTEM_POWER_STATE MinSystemState,
283 IN ULONG Flags,
284 IN BOOLEAN Asynchronous);
285
286 NTSYSCALLAPI
287 NTSTATUS
288 NTAPI
289 NtSetSystemPowerState(
290 IN POWER_ACTION SystemAction,
291 IN SYSTEM_POWER_STATE MinSystemState,
292 IN ULONG Flags);
293
294 NTSYSCALLAPI
295 NTSTATUS
296 NTAPI
297 NtGetDevicePowerState(
298 IN HANDLE Device,
299 OUT DEVICE_POWER_STATE *State);
300
301 NTSYSCALLAPI
302 NTSTATUS
303 NTAPI
304 NtCancelDeviceWakeupRequest(
305 IN HANDLE Device);
306
307 NTSYSCALLAPI
308 BOOLEAN
309 NTAPI
310 NtIsSystemResumeAutomatic(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 */