ReactOS  0.4.14-dev-50-g13bb5e2
ntpoapi.h
Go to the documentation of this file.
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 {
44 
45 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
46 
47 typedef enum _DEVICE_POWER_STATE {
55 
56 typedef union _POWER_STATE {
60 
61 typedef enum _POWER_STATE_TYPE {
65 
121 
122 typedef enum {
132 
133 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
134 typedef struct {
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 {
152 
153 _Function_class_(PROCESSOR_IDLE_HANDLER)
154 typedef NTSTATUS
155 (FASTCALL *PPROCESSOR_IDLE_HANDLER)(
158 
161  PPROCESSOR_IDLE_HANDLER Handler;
163 
164 typedef VOID
166  IN UCHAR Throttle);
167 
168 typedef NTSTATUS
170  IN UCHAR Throttle);
171 
172 #define MAX_IDLE_HANDLERS 3
173 
174 typedef struct _PROCESSOR_STATE_HANDLER {
181 
192 
193 _Function_class_(ENTER_STATE_SYSTEM_HANDLER)
195 typedef NTSTATUS
196 (NTAPI *PENTER_STATE_SYSTEM_HANDLER)(
198 
199 _Function_class_(ENTER_STATE_HANDLER)
201 typedef NTSTATUS
202 (NTAPI *PENTER_STATE_HANDLER)(
204  _In_opt_ PENTER_STATE_SYSTEM_HANDLER SystemHandler,
207  _In_opt_ LONG volatile *Number);
208 
209 typedef struct _POWER_STATE_HANDLER {
213  PENTER_STATE_HANDLER Handler;
216 
217 _Function_class_(ENTER_STATE_NOTIFY_HANDLER)
219 typedef NTSTATUS
220 (NTAPI *PENTER_STATE_NOTIFY_HANDLER)(
224 
226  PENTER_STATE_NOTIFY_HANDLER Handler;
229 
233 NTSTATUS
234 NTAPI
236  _In_ POWER_INFORMATION_LEVEL InformationLevel,
241 
242 #define PROCESSOR_STATE_TYPE_PERFORMANCE 1
243 #define PROCESSOR_STATE_TYPE_THROTTLE 2
244 
245 typedef struct _PROCESSOR_PERF_LEVEL {
250 
251 typedef struct _PROCESSOR_PERF_STATE {
264 
273 
280 
284 NTSTATUS
285 NTAPI
287  _In_ EXECUTION_STATE esFlags,
289 
291 NTSTATUS
292 NTAPI
294  _In_ LATENCY_TIME latency);
295 
299 NTSTATUS
300 NTAPI
302  _In_ POWER_ACTION SystemAction,
304  _In_ ULONG Flags,
306 
310 NTSTATUS
311 NTAPI
313  _In_ POWER_ACTION SystemAction,
315  _In_ ULONG Flags);
316 
320 NTSTATUS
321 NTAPI
325 
327 NTSTATUS
328 NTAPI
330  _In_ HANDLE Device);
331 
335 BOOLEAN
336 NTAPI
338 
340 NTSTATUS
341 NTAPI
343  _In_ HANDLE Device);
344 
345 #define WINLOGON_LOCK_ON_SLEEP 0x00000001
346 
347 typedef struct {
364 #if (NTDDI_VERSION < NTDDI_WINXP)
365  UCHAR ProcessorThrottleScale;
366  UCHAR spare2[4];
367 #else
370  UCHAR spare2[3];
371 #endif /* (NTDDI_VERSION < NTDDI_WINXP) */
373  UCHAR spare3[8];
376  BATTERY_REPORTING_SCALE BatteryScale[3];
383 
384 typedef struct {
389  BOOLEAN Spare1[4];
397 
406 
407 typedef struct _POWER_ACTION_POLICY {
412 
413 /* POWER_ACTION_POLICY.Flags constants */
414 #define POWER_ACTION_QUERY_ALLOWED 0x00000001
415 #define POWER_ACTION_UI_ALLOWED 0x00000002
416 #define POWER_ACTION_OVERRIDE_APPS 0x00000004
417 #define POWER_ACTION_LIGHTEST_FIRST 0x10000000
418 #define POWER_ACTION_LOCK_CONSOLE 0x20000000
419 #define POWER_ACTION_DISABLE_WAKES 0x40000000
420 #define POWER_ACTION_CRITICAL 0x80000000
421 
422 /* POWER_ACTION_POLICY.EventCode constants */
423 #define POWER_LEVEL_USER_NOTIFY_TEXT 0x00000001
424 #define POWER_LEVEL_USER_NOTIFY_SOUND 0x00000002
425 #define POWER_LEVEL_USER_NOTIFY_EXEC 0x00000004
426 #define POWER_USER_NOTIFY_BUTTON 0x00000008
427 #define POWER_USER_NOTIFY_SHUTDOWN 0x00000010
428 #define POWER_FORCE_TRIGGER_RESET 0x80000000
429 
430 #define DISCHARGE_POLICY_CRITICAL 0
431 #define DISCHARGE_POLICY_LOW 1
432 #define NUM_DISCHARGE_POLICIES 4
433 
434 #define PO_THROTTLE_NONE 0
435 #define PO_THROTTLE_CONSTANT 1
436 #define PO_THROTTLE_DEGRADE 2
437 #define PO_THROTTLE_ADAPTIVE 3
438 #define PO_THROTTLE_MAXIMUM 4
439 
440 #ifdef __cplusplus
441 }
442 #endif
443 
444 #endif /* __NTPOAPI_H */
struct _PROCESSOR_IDLE_HANDLER_INFO * PPROCESSOR_IDLE_HANDLER_INFO
struct _POWER_STATE_HANDLER POWER_STATE_HANDLER
#define _IRQL_requires_same_
Definition: no_sal2.h:652
enum _POWER_STATE_TYPE POWER_STATE_TYPE
#define IN
Definition: typedefs.h:38
enum _POWER_STATE_TYPE * PPOWER_STATE_TYPE
struct _PROCESSOR_IDLE_TIMES * PPROCESSOR_IDLE_TIMES
_POWER_INFORMATION_LEVEL
Definition: ntpoapi.h:66
struct _SYSTEM_BATTERY_STATE SYSTEM_BATTERY_STATE
union _POWER_STATE POWER_STATE
struct _PROCESSOR_POWER_INFORMATION PROCESSOR_POWER_INFORMATION
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
struct _PROCESSOR_PERF_LEVEL PROCESSOR_PERF_LEVEL
_In_ ULONG _In_ ULONG OutputBufferLength
Definition: ntpoapi.h:240
PENTER_STATE_HANDLER Handler
Definition: ntpoapi.h:213
NTSTATUS(FASTCALL * PSET_PROCESSOR_THROTTLE2)(IN UCHAR Throttle)
Definition: ntpoapi.h:169
struct BATTERY_REPORTING_SCALE * PBATTERY_REPORTING_SCALE
struct _POWER_ACTION_POLICY POWER_ACTION_POLICY
struct _PROCESSOR_STATE_HANDLER2 PROCESSOR_STATE_HANDLER2
LONG NTSTATUS
Definition: precomp.h:26
_DEVICE_POWER_STATE
Definition: ntpoapi.h:47
BOOLEAN SystemBatteriesPresent
Definition: ntpoapi.h:374
struct _POWER_STATE_NOTIFY_HANDLER POWER_STATE_NOTIFY_HANDLER
struct _PROCESSOR_STATE_HANDLER * PPROCESSOR_STATE_HANDLER
struct _PROCESSOR_IDLE_TIMES PROCESSOR_IDLE_TIMES
#define NTSYSCALLAPI
Definition: ntbasedef.h:204
struct _SYSTEM_POWER_CAPABILITIES SYSTEM_POWER_CAPABILITIES
struct _PROCESSOR_IDLE_HANDLER_INFO PROCESSOR_IDLE_HANDLER_INFO
PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS]
Definition: ntpoapi.h:267
_In_ SYSTEM_POWER_STATE MinSystemState
Definition: ntpoapi.h:303
POWER_STATE_HANDLER_TYPE Type
Definition: ntpoapi.h:210
#define FASTCALL
Definition: nt_native.h:50
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE
CHAR InputBuffer[80]
Definition: conmgr.c:33
#define _In_opt_
Definition: no_sal2.h:213
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct _PROCESSOR_PERF_LEVEL * PPROCESSOR_PERF_LEVEL
SYSTEM_POWER_STATE SystemState
Definition: ntpoapi.h:57
struct _POWER_ACTION_POLICY * PPOWER_ACTION_POLICY
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG InputBufferLength
Definition: ntpoapi.h:238
_In_ SYSTEM_POWER_STATE _In_ ULONG _In_ BOOLEAN Asynchronous
Definition: ntpoapi.h:303
struct _PROCESSOR_PERF_STATE PROCESSOR_PERF_STATE
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
long LONG
Definition: pedump.c:60
struct SYSTEM_POWER_CAPABILITIES * PSYSTEM_POWER_CAPABILITIES
_SYSTEM_POWER_STATE
Definition: ntpoapi.h:34
unsigned char BOOLEAN
NTSTATUS NTAPI NtInitiatePowerAction(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags, IN BOOLEAN Asynchronous)
Definition: power.c:646
NTSYSCALLAPI NTSTATUS NTAPI NtRequestDeviceWakeup(_In_ HANDLE Device)
POWER_ACTION Action
Definition: ntpoapi.h:408
#define _Out_
Definition: no_sal2.h:323
NTSTATUS NTAPI NtSetSystemPowerState(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags)
Definition: power.c:869
enum _SYSTEM_POWER_STATE * PSYSTEM_POWER_STATE
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
PSET_PROCESSOR_THROTTLE SetThrottle
Definition: ntpoapi.h:177
_Out_ EXECUTION_STATE * PreviousFlags
Definition: ntpoapi.h:288
#define MAX_IDLE_HANDLERS
Definition: ntpoapi.h:172
LATENCY_TIME
Definition: potypes.h:171
enum POWER_ACTION * PPOWER_ACTION
ULONGLONG PerformanceTime
Definition: ntpoapi.h:262
PPROCESSOR_IDLE_HANDLER Handler
Definition: ntpoapi.h:161
SYSTEM_POWER_STATE RtcWake
Definition: ntpoapi.h:379
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
SYSTEM_POWER_STATE SoftLidWake
Definition: ntpoapi.h:378
enum _DEVICE_POWER_STATE * PDEVICE_POWER_STATE
#define __kernel_entry
Definition: specstrings.h:50
struct _SYSTEM_POWER_INFORMATION SYSTEM_POWER_INFORMATION
ULONGLONG EndTime
Definition: ntpoapi.h:149
NTSTATUS NTAPI NtGetDevicePowerState(IN HANDLE Device, IN PDEVICE_POWER_STATE PowerState)
Definition: power.c:787
uint64_t ULONGLONG
Definition: typedefs.h:65
BOOLEAN NTAPI NtIsSystemResumeAutomatic(VOID)
Definition: power.c:796
enum _POWER_INFORMATION_LEVEL POWER_INFORMATION_LEVEL
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
ULONG RemainingCapacity
Definition: ntpoapi.h:391
#define _Inout_
Definition: no_sal2.h:244
enum _POWER_STATE_HANDLER_TYPE POWER_STATE_HANDLER_TYPE
unsigned char UCHAR
Definition: xmlstorage.h:181
ULONGLONG StartTime
Definition: ntpoapi.h:148
BOOLEAN Discharging
Definition: ntpoapi.h:388
struct _POWER_STATE_NOTIFY_HANDLER * PPOWER_STATE_NOTIFY_HANDLER
ULONG EXECUTION_STATE
Definition: potypes.h:169
#define NTSTATUS
Definition: precomp.h:20
POWER_ACTION
Definition: ntpoapi.h:122
#define VOID
Definition: acefi.h:82
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID SystemContext
Definition: ntpoapi.h:204
PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS]
Definition: ntpoapi.h:179
struct _PROCESSOR_STATE_HANDLER PROCESSOR_STATE_HANDLER
NTSYSCALLAPI NTSTATUS NTAPI NtRequestWakeupLatency(_In_ LATENCY_TIME latency)
_In_ ULONG _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer
struct _PROCESSOR_STATE_HANDLER2 * PPROCESSOR_STATE_HANDLER2
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
union _POWER_STATE * PPOWER_STATE
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
#define _In_
Definition: no_sal2.h:204
struct SYSTEM_BATTERY_STATE * PSYSTEM_BATTERY_STATE
unsigned short USHORT
Definition: pedump.c:61
struct _SYSTEM_POWER_INFORMATION * PSYSTEM_POWER_INFORMATION
PENTER_STATE_NOTIFY_HANDLER Handler
Definition: ntpoapi.h:226
_POWER_STATE_HANDLER_TYPE
Definition: ntpoapi.h:182
NTSTATUS NTAPI NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength)
Definition: power.c:660
SYSTEM_POWER_STATE MinDeviceWakeState
Definition: ntpoapi.h:380
_POWER_STATE_TYPE
Definition: ntpoapi.h:61
_In_ PVOID Context
Definition: ntpoapi.h:222
ULONG IdleHandlerReserved[4]
Definition: ntpoapi.h:150
unsigned int ULONG
Definition: retypes.h:1
_Inout_ PPROCESSOR_IDLE_TIMES IdleTimes
Definition: ntpoapi.h:157
struct _POWER_STATE_HANDLER * PPOWER_STATE_HANDLER
struct _PROCESSOR_PERF_STATE * PPROCESSOR_PERF_STATE
PROCESSOR_PERF_LEVEL PerfLevel[1]
Definition: ntpoapi.h:271
_In_opt_ PENTER_STATE_SYSTEM_HANDLER SystemHandler
Definition: ntpoapi.h:204
VOID(FASTCALL * PSET_PROCESSOR_THROTTLE)(IN UCHAR Throttle)
Definition: ntpoapi.h:165
NTSYSCALLAPI NTSTATUS NTAPI NtCancelDeviceWakeupRequest(_In_ HANDLE Device)
_Out_ DEVICE_POWER_STATE * State
Definition: ntpoapi.h:324
SYSTEM_POWER_STATE DefaultLowLatencyWake
Definition: ntpoapi.h:381
PSET_PROCESSOR_THROTTLE2 SetPerfLevel
Definition: ntpoapi.h:268
_In_ PVOID _In_ BOOLEAN Entering
Definition: ntpoapi.h:222
_Function_class_(PROCESSOR_IDLE_HANDLER) typedef NTSTATUS(FASTCALL *PPROCESSOR_IDLE_HANDLER)(_In_ ULONG_PTR Context
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG NumberProcessors
Definition: ntpoapi.h:204
#define APC_LEVEL
Definition: env_spec_w32.h:695
struct _PROCESSOR_POWER_INFORMATION * PPROCESSOR_POWER_INFORMATION
NTSTATUS NTAPI NtSetThreadExecutionState(IN EXECUTION_STATE esFlags, OUT EXECUTION_STATE *PreviousFlags)
Definition: power.c:812
BOOLEAN BatteryPresent
Definition: ntpoapi.h:386
BOOLEAN BatteriesAreShortTerm
Definition: ntpoapi.h:375
SYSTEM_POWER_STATE AcOnLineWake
Definition: ntpoapi.h:377
_In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer
enum _POWER_STATE_HANDLER_TYPE * PPOWER_STATE_HANDLER_TYPE
_IRQL_requires_max_(APC_LEVEL) __kernel_entry NTSYSCALLAPI NTSTATUS NTAPI NtPowerInformation(_In_ POWER_INFORMATION_LEVEL InformationLevel