source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/ddk/ntpoapi.h@ 1186

Last change on this file since 1186 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 10.8 KB
RevLine 
[1166]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
27extern "C" {
28#endif
29
30#ifndef _PO_DDK_
31#define _PO_DDK_
32
33/* Power States/Levels */
34typedef 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
46typedef enum _DEVICE_POWER_STATE {
47 PowerDeviceUnspecified,
48 PowerDeviceD0,
49 PowerDeviceD1,
50 PowerDeviceD2,
51 PowerDeviceD3,
52 PowerDeviceMaximum
53} DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
54
55typedef union _POWER_STATE {
56 SYSTEM_POWER_STATE SystemState;
57 DEVICE_POWER_STATE DeviceState;
58} POWER_STATE, *PPOWER_STATE;
59
60typedef enum _POWER_STATE_TYPE {
61 SystemPowerState = 0,
62 DevicePowerState
63} POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
64
65typedef 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
121typedef 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_)
133typedef 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
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
147typedef struct _PROCESSOR_IDLE_TIMES {
148 ULONGLONG StartTime;
149 ULONGLONG EndTime;
150 ULONG IdleHandlerReserved[4];
151} PROCESSOR_IDLE_TIMES, *PPROCESSOR_IDLE_TIMES;
152
153typedef BOOLEAN
154(FASTCALL*PPROCESSOR_IDLE_HANDLER)(
155 IN OUT PPROCESSOR_IDLE_TIMES IdleTimes);
156
157typedef struct _PROCESSOR_IDLE_HANDLER_INFO {
158 ULONG HardwareLatency;
159 PPROCESSOR_IDLE_HANDLER Handler;
160} PROCESSOR_IDLE_HANDLER_INFO, *PPROCESSOR_IDLE_HANDLER_INFO;
161
162typedef VOID
163(FASTCALL*PSET_PROCESSOR_THROTTLE)(
164 IN UCHAR Throttle);
165
166typedef NTSTATUS
167(FASTCALL*PSET_PROCESSOR_THROTTLE2)(
168 IN UCHAR Throttle);
169
170#define MAX_IDLE_HANDLERS 3
171
172typedef 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
180typedef 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
191typedef NTSTATUS
192(NTAPI*PENTER_STATE_SYSTEM_HANDLER)(
193 IN PVOID SystemContext);
194
195typedef 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
203typedef 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
211typedef NTSTATUS
212(NTAPI*PENTER_STATE_NOTIFY_HANDLER)(
213 IN POWER_STATE_HANDLER_TYPE State,
214 IN PVOID Context,
215 IN BOOLEAN Entering);
216
217typedef struct _POWER_STATE_NOTIFY_HANDLER {
218 PENTER_STATE_NOTIFY_HANDLER Handler;
219 PVOID Context;
220} POWER_STATE_NOTIFY_HANDLER, *PPOWER_STATE_NOTIFY_HANDLER;
221
222NTSYSCALLAPI
223NTSTATUS
224NTAPI
225NtPowerInformation(
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
235typedef struct _PROCESSOR_PERF_LEVEL {
236 UCHAR PercentFrequency;
237 UCHAR Reserved;
238 USHORT Flags;
239} PROCESSOR_PERF_LEVEL, *PPROCESSOR_PERF_LEVEL;
240
241typedef 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
255typedef 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
264NTSYSCALLAPI
265NTSTATUS
266NTAPI
267NtSetThreadExecutionState(
268 IN EXECUTION_STATE esFlags,
269 OUT EXECUTION_STATE *PreviousFlags);
270
271NTSYSCALLAPI
272NTSTATUS
273NTAPI
274NtRequestWakeupLatency(
275 IN LATENCY_TIME latency);
276
277NTSYSCALLAPI
278NTSTATUS
279NTAPI
280NtInitiatePowerAction(
281 IN POWER_ACTION SystemAction,
282 IN SYSTEM_POWER_STATE MinSystemState,
283 IN ULONG Flags,
284 IN BOOLEAN Asynchronous);
285
286NTSYSCALLAPI
287NTSTATUS
288NTAPI
289NtSetSystemPowerState(
290 IN POWER_ACTION SystemAction,
291 IN SYSTEM_POWER_STATE MinSystemState,
292 IN ULONG Flags);
293
294NTSYSCALLAPI
295NTSTATUS
296NTAPI
297NtGetDevicePowerState(
298 IN HANDLE Device,
299 OUT DEVICE_POWER_STATE *State);
300
301NTSYSCALLAPI
302NTSTATUS
303NTAPI
304NtCancelDeviceWakeupRequest(
305 IN HANDLE Device);
306
307NTSYSCALLAPI
308BOOLEAN
309NTAPI
310NtIsSystemResumeAutomatic(
311 VOID);
312
313NTSYSCALLAPI
314NTSTATUS
315NTAPI
316NtRequestDeviceWakeup(
317 IN HANDLE Device);
318
319#define WINLOGON_LOCK_ON_SLEEP 0x00000001
320
321typedef struct {
322 BOOLEAN PowerButtonPresent;
323 BOOLEAN SleepButtonPresent;
324 BOOLEAN LidPresent;
325 BOOLEAN SystemS1;
326 BOOLEAN SystemS2;
327 BOOLEAN SystemS3;
328 BOOLEAN SystemS4;
329 BOOLEAN SystemS5;
330 BOOLEAN HiberFilePresent;
331 BOOLEAN FullWake;
332 BOOLEAN VideoDimPresent;
333 BOOLEAN ApmPresent;
334 BOOLEAN UpsPresent;
335 BOOLEAN ThermalControl;
336 BOOLEAN ProcessorThrottle;
337 UCHAR ProcessorMinThrottle;
338#if (NTDDI_VERSION < NTDDI_WINXP)
339 UCHAR ProcessorThrottleScale;
340 UCHAR spare2[4];
341#else
342 UCHAR ProcessorMaxThrottle;
343 BOOLEAN FastSystemS4;
344 UCHAR spare2[3];
345#endif /* (NTDDI_VERSION < NTDDI_WINXP) */
346 BOOLEAN DiskSpinDown;
347 UCHAR spare3[8];
348 BOOLEAN SystemBatteriesPresent;
349 BOOLEAN BatteriesAreShortTerm;
350 BATTERY_REPORTING_SCALE BatteryScale[3];
351 SYSTEM_POWER_STATE AcOnLineWake;
352 SYSTEM_POWER_STATE SoftLidWake;
353 SYSTEM_POWER_STATE RtcWake;
354 SYSTEM_POWER_STATE MinDeviceWakeState;
355 SYSTEM_POWER_STATE DefaultLowLatencyWake;
356} SYSTEM_POWER_CAPABILITIES, *PSYSTEM_POWER_CAPABILITIES;
357
358typedef struct {
359 BOOLEAN AcOnLine;
360 BOOLEAN BatteryPresent;
361 BOOLEAN Charging;
362 BOOLEAN Discharging;
363 BOOLEAN Spare1[4];
364 ULONG MaxCapacity;
365 ULONG RemainingCapacity;
366 ULONG Rate;
367 ULONG EstimatedTime;
368 ULONG DefaultAlert1;
369 ULONG DefaultAlert2;
370} SYSTEM_BATTERY_STATE, *PSYSTEM_BATTERY_STATE;
371
372typedef struct _PROCESSOR_POWER_INFORMATION {
373 ULONG Number;
374 ULONG MaxMhz;
375 ULONG CurrentMhz;
376 ULONG MhzLimit;
377 ULONG MaxIdleState;
378 ULONG CurrentIdleState;
379} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
380
381typedef struct _POWER_ACTION_POLICY {
382 POWER_ACTION Action;
383 ULONG Flags;
384 ULONG EventCode;
385} POWER_ACTION_POLICY, *PPOWER_ACTION_POLICY;
386
387/* POWER_ACTION_POLICY.Flags constants */
388#define POWER_ACTION_QUERY_ALLOWED 0x00000001
389#define POWER_ACTION_UI_ALLOWED 0x00000002
390#define POWER_ACTION_OVERRIDE_APPS 0x00000004
391#define POWER_ACTION_LIGHTEST_FIRST 0x10000000
392#define POWER_ACTION_LOCK_CONSOLE 0x20000000
393#define POWER_ACTION_DISABLE_WAKES 0x40000000
394#define POWER_ACTION_CRITICAL 0x80000000
395
396/* POWER_ACTION_POLICY.EventCode constants */
397#define POWER_LEVEL_USER_NOTIFY_TEXT 0x00000001
398#define POWER_LEVEL_USER_NOTIFY_SOUND 0x00000002
399#define POWER_LEVEL_USER_NOTIFY_EXEC 0x00000004
400#define POWER_USER_NOTIFY_BUTTON 0x00000008
401#define POWER_USER_NOTIFY_SHUTDOWN 0x00000010
402#define POWER_FORCE_TRIGGER_RESET 0x80000000
403
404#define DISCHARGE_POLICY_CRITICAL 0
405#define DISCHARGE_POLICY_LOW 1
406#define NUM_DISCHARGE_POLICIES 4
407
408#define PO_THROTTLE_NONE 0
409#define PO_THROTTLE_CONSTANT 1
410#define PO_THROTTLE_DEGRADE 2
411#define PO_THROTTLE_ADAPTIVE 3
412#define PO_THROTTLE_MAXIMUM 4
413
414#ifdef __cplusplus
415}
416#endif
417
418#endif /* __NTPOAPI_H */
419
Note: See TracBrowser for help on using the repository browser.