01f45935fdd4775079f87e4385e2dae37e09e01b
[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 #define POWER_PERF_SCALE 100
31 #define PERF_LEVEL_TO_PERCENT(x) (((x) * 1000) / (POWER_PERF_SCALE * 10))
32 #define PERCENT_TO_PERF_LEVEL(x) (((x) * POWER_PERF_SCALE * 10) / 1000)
33
34 typedef struct {
35 ULONG Granularity;
36 ULONG Capacity;
37 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
38
39 typedef struct _PROCESSOR_IDLE_TIMES {
40 ULONGLONG StartTime;
41 ULONGLONG EndTime;
42 ULONG IdleHandlerReserved[4];
43 } PROCESSOR_IDLE_TIMES, *PPROCESSOR_IDLE_TIMES;
44
45 typedef BOOLEAN
46 (FASTCALL*PPROCESSOR_IDLE_HANDLER)(
47 IN OUT PPROCESSOR_IDLE_TIMES IdleTimes);
48
49 typedef struct _PROCESSOR_IDLE_HANDLER_INFO {
50 ULONG HardwareLatency;
51 PPROCESSOR_IDLE_HANDLER Handler;
52 } PROCESSOR_IDLE_HANDLER_INFO, *PPROCESSOR_IDLE_HANDLER_INFO;
53
54 typedef VOID
55 (FASTCALL*PSET_PROCESSOR_THROTTLE)(
56 IN UCHAR Throttle);
57
58 typedef NTSTATUS
59 (FASTCALL*PSET_PROCESSOR_THROTTLE2)(
60 IN UCHAR Throttle);
61
62 #define MAX_IDLE_HANDLERS 3
63
64 typedef struct _PROCESSOR_STATE_HANDLER {
65 UCHAR ThrottleScale;
66 BOOLEAN ThrottleOnIdle;
67 PSET_PROCESSOR_THROTTLE SetThrottle;
68 ULONG NumIdleHandlers;
69 PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS];
70 } PROCESSOR_STATE_HANDLER, *PPROCESSOR_STATE_HANDLER;
71
72 typedef enum _POWER_STATE_HANDLER_TYPE {
73 PowerStateSleeping1,
74 PowerStateSleeping2,
75 PowerStateSleeping3,
76 PowerStateSleeping4,
77 PowerStateSleeping4Firmware,
78 PowerStateShutdownReset,
79 PowerStateShutdownOff,
80 PowerStateMaximum
81 } POWER_STATE_HANDLER_TYPE, *PPOWER_STATE_HANDLER_TYPE;
82
83 typedef NTSTATUS
84 (NTAPI*PENTER_STATE_SYSTEM_HANDLER)(
85 IN PVOID SystemContext);
86
87 typedef NTSTATUS
88 (NTAPI*PENTER_STATE_HANDLER)(
89 IN PVOID Context,
90 IN PENTER_STATE_SYSTEM_HANDLER SystemHandler OPTIONAL,
91 IN PVOID SystemContext,
92 IN LONG NumberProcessors,
93 IN LONG volatile *Number);
94
95 typedef struct _POWER_STATE_HANDLER {
96 POWER_STATE_HANDLER_TYPE Type;
97 BOOLEAN RtcWake;
98 UCHAR Spare[3];
99 PENTER_STATE_HANDLER Handler;
100 PVOID Context;
101 } POWER_STATE_HANDLER, *PPOWER_STATE_HANDLER;
102
103 typedef NTSTATUS
104 (NTAPI*PENTER_STATE_NOTIFY_HANDLER)(
105 IN POWER_STATE_HANDLER_TYPE State,
106 IN PVOID Context,
107 IN BOOLEAN Entering);
108
109 typedef struct _POWER_STATE_NOTIFY_HANDLER {
110 PENTER_STATE_NOTIFY_HANDLER Handler;
111 PVOID Context;
112 } POWER_STATE_NOTIFY_HANDLER, *PPOWER_STATE_NOTIFY_HANDLER;
113
114 NTSYSCALLAPI
115 NTSTATUS
116 DDKAPI
117 NtPowerInformation(
118 IN POWER_INFORMATION_LEVEL InformationLevel,
119 IN PVOID InputBuffer OPTIONAL,
120 IN ULONG InputBufferLength,
121 OUT PVOID OutputBuffer OPTIONAL,
122 IN ULONG OutputBufferLength);
123
124 #define PROCESSOR_STATE_TYPE_PERFORMANCE 1
125 #define PROCESSOR_STATE_TYPE_THROTTLE 2
126
127 typedef struct _PROCESSOR_PERF_LEVEL {
128 UCHAR PercentFrequency;
129 UCHAR Reserved;
130 USHORT Flags;
131 } PROCESSOR_PERF_LEVEL, *PPROCESSOR_PERF_LEVEL;
132
133 typedef struct _PROCESSOR_PERF_STATE {
134 UCHAR PercentFrequency;
135 UCHAR MinCapacity;
136 USHORT Power;
137 UCHAR IncreaseLevel;
138 UCHAR DecreaseLevel;
139 USHORT Flags;
140 ULONG IncreaseTime;
141 ULONG DecreaseTime;
142 ULONG IncreaseCount;
143 ULONG DecreaseCount;
144 ULONGLONG PerformanceTime;
145 } PROCESSOR_PERF_STATE, *PPROCESSOR_PERF_STATE;
146
147 typedef struct _PROCESSOR_STATE_HANDLER2 {
148 ULONG NumIdleHandlers;
149 PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS];
150 PSET_PROCESSOR_THROTTLE2 SetPerfLevel;
151 ULONG HardwareLatency;
152 UCHAR NumPerfStates;
153 PROCESSOR_PERF_LEVEL PerfLevel[1];
154 } PROCESSOR_STATE_HANDLER2, *PPROCESSOR_STATE_HANDLER2;
155
156 NTSYSCALLAPI
157 NTSTATUS
158 NTAPI
159 NtSetThreadExecutionState(
160 IN EXECUTION_STATE esFlags,
161 OUT EXECUTION_STATE *PreviousFlags);
162
163 NTSYSCALLAPI
164 NTSTATUS
165 NTAPI
166 NtRequestWakeupLatency(
167 IN LATENCY_TIME latency);
168
169 NTSYSCALLAPI
170 NTSTATUS
171 NTAPI
172 NtInitiatePowerAction(
173 IN POWER_ACTION SystemAction,
174 IN SYSTEM_POWER_STATE MinSystemState,
175 IN ULONG Flags,
176 IN BOOLEAN Asynchronous);
177
178 NTSYSCALLAPI
179 NTSTATUS
180 NTAPI
181 NtSetSystemPowerState(
182 IN POWER_ACTION SystemAction,
183 IN SYSTEM_POWER_STATE MinSystemState,
184 IN ULONG Flags);
185
186 NTSYSCALLAPI
187 NTSTATUS
188 NTAPI
189 NtGetDevicePowerState(
190 IN HANDLE Device,
191 OUT DEVICE_POWER_STATE *State);
192
193 NTSYSCALLAPI
194 NTSTATUS
195 NTAPI
196 NtCancelDeviceWakeupRequest(
197 IN HANDLE Device);
198
199 NTSYSCALLAPI
200 BOOLEAN
201 NTAPI
202 NtIsSystemResumeAutomatic(
203 VOID);
204
205 NTSYSCALLAPI
206 NTSTATUS
207 NTAPI
208 NtRequestDeviceWakeup(
209 IN HANDLE Device);
210
211 #define WINLOGON_LOCK_ON_SLEEP 0x00000001
212
213 typedef struct {
214 BOOLEAN PowerButtonPresent;
215 BOOLEAN SleepButtonPresent;
216 BOOLEAN LidPresent;
217 BOOLEAN SystemS1;
218 BOOLEAN SystemS2;
219 BOOLEAN SystemS3;
220 BOOLEAN SystemS4;
221 BOOLEAN SystemS5;
222 BOOLEAN HiberFilePresent;
223 BOOLEAN FullWake;
224 BOOLEAN VideoDimPresent;
225 BOOLEAN ApmPresent;
226 BOOLEAN UpsPresent;
227 BOOLEAN ThermalControl;
228 BOOLEAN ProcessorThrottle;
229 UCHAR ProcessorMinThrottle;
230 #if (NTDDI_VERSION < NTDDI_WINXP)
231 UCHAR ProcessorThrottleScale;
232 UCHAR spare2[4];
233 #else
234 UCHAR ProcessorMaxThrottle;
235 BOOLEAN FastSystemS4;
236 UCHAR spare2[3];
237 #endif // (NTDDI_VERSION < NTDDI_WINXP)
238 BOOLEAN DiskSpinDown;
239 UCHAR spare3[8];
240 BOOLEAN SystemBatteriesPresent;
241 BOOLEAN BatteriesAreShortTerm;
242 BATTERY_REPORTING_SCALE BatteryScale[3];
243 SYSTEM_POWER_STATE AcOnLineWake;
244 SYSTEM_POWER_STATE SoftLidWake;
245 SYSTEM_POWER_STATE RtcWake;
246 SYSTEM_POWER_STATE MinDeviceWakeState;
247 SYSTEM_POWER_STATE DefaultLowLatencyWake;
248 } SYSTEM_POWER_CAPABILITIES, *PSYSTEM_POWER_CAPABILITIES;
249
250 typedef struct {
251 BOOLEAN AcOnLine;
252 BOOLEAN BatteryPresent;
253 BOOLEAN Charging;
254 BOOLEAN Discharging;
255 BOOLEAN Spare1[4];
256 ULONG MaxCapacity;
257 ULONG RemainingCapacity;
258 ULONG Rate;
259 ULONG EstimatedTime;
260 ULONG DefaultAlert1;
261 ULONG DefaultAlert2;
262 } SYSTEM_BATTERY_STATE, *PSYSTEM_BATTERY_STATE;
263
264 typedef struct _PROCESSOR_POWER_INFORMATION {
265 ULONG Number;
266 ULONG MaxMhz;
267 ULONG CurrentMhz;
268 ULONG MhzLimit;
269 ULONG MaxIdleState;
270 ULONG CurrentIdleState;
271 } PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
272
273 #ifdef __cplusplus
274 }
275 #endif
276
277 #endif /* __NTPOAPI_H */