ReactOS 0.4.15-dev-5666-gc548b97
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
27extern "C" {
28#endif
29
30#ifndef _PO_DDK_
31#define _PO_DDK_
32
33/* Power States/Levels */
34typedef enum _SYSTEM_POWER_STATE {
44
45#define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
46
47typedef enum _DEVICE_POWER_STATE {
55
56typedef union _POWER_STATE {
60
61typedef enum _POWER_STATE_TYPE {
65
121
122typedef enum {
132
133#if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_)
134typedef 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
147typedef struct _PROCESSOR_IDLE_TIMES {
152
153_Function_class_(PROCESSOR_IDLE_HANDLER)
154typedef NTSTATUS
155(FASTCALL *PPROCESSOR_IDLE_HANDLER)(
158
161 PPROCESSOR_IDLE_HANDLER Handler;
163
164typedef VOID
166 IN UCHAR Throttle);
167
168typedef NTSTATUS
170 IN UCHAR Throttle);
171
172#define MAX_IDLE_HANDLERS 3
173
181
192
193_Function_class_(ENTER_STATE_SYSTEM_HANDLER)
195typedef NTSTATUS
196(NTAPI *PENTER_STATE_SYSTEM_HANDLER)(
198
199_Function_class_(ENTER_STATE_HANDLER)
201typedef NTSTATUS
202(NTAPI *PENTER_STATE_HANDLER)(
204 _In_opt_ PENTER_STATE_SYSTEM_HANDLER SystemHandler,
207 _In_opt_ LONG volatile *Number);
208
209typedef struct _POWER_STATE_HANDLER {
213 PENTER_STATE_HANDLER Handler;
216
217_Function_class_(ENTER_STATE_NOTIFY_HANDLER)
219typedef NTSTATUS
220(NTAPI *PENTER_STATE_NOTIFY_HANDLER)(
224
226 PENTER_STATE_NOTIFY_HANDLER Handler;
229
234NTAPI
236 _In_ POWER_INFORMATION_LEVEL InformationLevel,
241
242#define PROCESSOR_STATE_TYPE_PERFORMANCE 1
243#define PROCESSOR_STATE_TYPE_THROTTLE 2
244
245typedef struct _PROCESSOR_PERF_LEVEL {
250
251typedef struct _PROCESSOR_PERF_STATE {
264
273
280
285NTAPI
287 _In_ EXECUTION_STATE esFlags,
289
292NTAPI
294 _In_ LATENCY_TIME latency);
295
300NTAPI
302 _In_ POWER_ACTION SystemAction,
306
311NTAPI
313 _In_ POWER_ACTION SystemAction,
316
321NTAPI
325
328NTAPI
331
336NTAPI
338
341NTAPI
344
345#define WINLOGON_LOCK_ON_SLEEP 0x00000001
346
347typedef 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
384typedef struct {
389 BOOLEAN Spare1[4];
397
406
407typedef 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 */
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
LONG NTSTATUS
Definition: precomp.h:26
#define NTSTATUS
Definition: precomp.h:20
#define _IRQL_requires_same_
Definition: driverspecs.h:232
#define _IRQL_requires_max_(irql)
Definition: driverspecs.h:230
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define APC_LEVEL
Definition: env_spec_w32.h:695
unsigned int ULONG
Definition: retypes.h:1
#define _Function_class_(x)
Definition: ms_sal.h:2946
#define _Inout_
Definition: ms_sal.h:378
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_reads_bytes_opt_(size)
Definition: ms_sal.h:322
#define _In_opt_
Definition: ms_sal.h:309
#define _Out_writes_bytes_opt_(size)
Definition: ms_sal.h:351
#define FASTCALL
Definition: nt_native.h:50
#define NTSYSCALLAPI
Definition: ntbasedef.h:204
NTSTATUS NTAPI NtInitiatePowerAction(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags, IN BOOLEAN Asynchronous)
Definition: power.c:766
BOOLEAN NTAPI NtIsSystemResumeAutomatic(VOID)
Definition: power.c:919
NTSTATUS NTAPI NtSetThreadExecutionState(IN EXECUTION_STATE esFlags, OUT EXECUTION_STATE *PreviousFlags)
Definition: power.c:935
NTSTATUS NTAPI NtSetSystemPowerState(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags)
Definition: power.c:992
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:780
NTSTATUS NTAPI NtGetDevicePowerState(IN HANDLE Device, IN PDEVICE_POWER_STATE PowerState)
Definition: power.c:910
_In_ SYSTEM_POWER_STATE MinSystemState
Definition: ntpoapi.h:303
struct _POWER_STATE_NOTIFY_HANDLER * PPOWER_STATE_NOTIFY_HANDLER
#define MAX_IDLE_HANDLERS
Definition: ntpoapi.h:172
_In_ PVOID _In_ BOOLEAN Entering
Definition: ntpoapi.h:223
enum _POWER_STATE_HANDLER_TYPE POWER_STATE_HANDLER_TYPE
struct _PROCESSOR_IDLE_HANDLER_INFO * PPROCESSOR_IDLE_HANDLER_INFO
struct _PROCESSOR_STATE_HANDLER2 PROCESSOR_STATE_HANDLER2
enum POWER_ACTION * PPOWER_ACTION
enum _SYSTEM_POWER_STATE * PSYSTEM_POWER_STATE
_In_ SYSTEM_POWER_STATE _In_ ULONG _In_ BOOLEAN Asynchronous
Definition: ntpoapi.h:305
NTSTATUS(FASTCALL * PSET_PROCESSOR_THROTTLE2)(IN UCHAR Throttle)
Definition: ntpoapi.h:169
_SYSTEM_POWER_STATE
Definition: ntpoapi.h:34
@ PowerSystemMaximum
Definition: ntpoapi.h:42
@ PowerSystemUnspecified
Definition: ntpoapi.h:35
@ PowerSystemSleeping1
Definition: ntpoapi.h:37
@ PowerSystemSleeping2
Definition: ntpoapi.h:38
@ PowerSystemSleeping3
Definition: ntpoapi.h:39
@ PowerSystemShutdown
Definition: ntpoapi.h:41
@ PowerSystemWorking
Definition: ntpoapi.h:36
@ PowerSystemHibernate
Definition: ntpoapi.h:40
struct _PROCESSOR_STATE_HANDLER PROCESSOR_STATE_HANDLER
enum _POWER_STATE_TYPE POWER_STATE_TYPE
struct _PROCESSOR_IDLE_TIMES * PPROCESSOR_IDLE_TIMES
struct _PROCESSOR_PERF_LEVEL * PPROCESSOR_PERF_LEVEL
struct _PROCESSOR_POWER_INFORMATION PROCESSOR_POWER_INFORMATION
NTSYSCALLAPI NTSTATUS NTAPI NtRequestDeviceWakeup(_In_ HANDLE Device)
struct _POWER_STATE_HANDLER * PPOWER_STATE_HANDLER
struct _PROCESSOR_IDLE_TIMES PROCESSOR_IDLE_TIMES
NTSYSCALLAPI NTSTATUS NTAPI NtCancelDeviceWakeupRequest(_In_ HANDLE Device)
struct _PROCESSOR_STATE_HANDLER2 * PPROCESSOR_STATE_HANDLER2
struct _PROCESSOR_STATE_HANDLER * PPROCESSOR_STATE_HANDLER
union _POWER_STATE * PPOWER_STATE
struct SYSTEM_BATTERY_STATE * PSYSTEM_BATTERY_STATE
_POWER_STATE_TYPE
Definition: ntpoapi.h:61
@ DevicePowerState
Definition: ntpoapi.h:63
struct _PROCESSOR_PERF_STATE PROCESSOR_PERF_STATE
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID SystemContext
Definition: ntpoapi.h:205
struct BATTERY_REPORTING_SCALE * PBATTERY_REPORTING_SCALE
struct _PROCESSOR_IDLE_HANDLER_INFO PROCESSOR_IDLE_HANDLER_INFO
struct _POWER_STATE_NOTIFY_HANDLER POWER_STATE_NOTIFY_HANDLER
_Out_ DEVICE_POWER_STATE * State
Definition: ntpoapi.h:324
struct SYSTEM_POWER_CAPABILITIES * PSYSTEM_POWER_CAPABILITIES
union _POWER_STATE POWER_STATE
struct _PROCESSOR_PERF_LEVEL PROCESSOR_PERF_LEVEL
enum _POWER_STATE_HANDLER_TYPE * PPOWER_STATE_HANDLER_TYPE
_Out_ EXECUTION_STATE * PreviousFlags
Definition: ntpoapi.h:288
POWER_ACTION
Definition: ntpoapi.h:122
@ PowerActionShutdownOff
Definition: ntpoapi.h:129
@ PowerActionNone
Definition: ntpoapi.h:123
@ PowerActionHibernate
Definition: ntpoapi.h:126
@ PowerActionShutdown
Definition: ntpoapi.h:127
@ PowerActionShutdownReset
Definition: ntpoapi.h:128
@ PowerActionWarmEject
Definition: ntpoapi.h:130
@ PowerActionReserved
Definition: ntpoapi.h:124
@ PowerActionSleep
Definition: ntpoapi.h:125
_Inout_ PPROCESSOR_IDLE_TIMES IdleTimes
Definition: ntpoapi.h:157
enum _DEVICE_POWER_STATE * PDEVICE_POWER_STATE
enum _POWER_INFORMATION_LEVEL POWER_INFORMATION_LEVEL
struct _SYSTEM_POWER_INFORMATION * PSYSTEM_POWER_INFORMATION
_DEVICE_POWER_STATE
Definition: ntpoapi.h:47
@ PowerDeviceD1
Definition: ntpoapi.h:50
@ PowerDeviceUnspecified
Definition: ntpoapi.h:48
@ PowerDeviceD0
Definition: ntpoapi.h:49
@ PowerDeviceD2
Definition: ntpoapi.h:51
@ PowerDeviceD3
Definition: ntpoapi.h:52
@ PowerDeviceMaximum
Definition: ntpoapi.h:53
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
struct _POWER_STATE_HANDLER POWER_STATE_HANDLER
struct _POWER_ACTION_POLICY * PPOWER_ACTION_POLICY
struct _PROCESSOR_PERF_STATE * PPROCESSOR_PERF_STATE
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE
VOID(FASTCALL * PSET_PROCESSOR_THROTTLE)(IN UCHAR Throttle)
Definition: ntpoapi.h:165
struct _POWER_ACTION_POLICY POWER_ACTION_POLICY
_In_opt_ PENTER_STATE_SYSTEM_HANDLER SystemHandler
Definition: ntpoapi.h:204
struct _SYSTEM_POWER_INFORMATION SYSTEM_POWER_INFORMATION
_In_ PVOID Context
Definition: ntpoapi.h:222
_POWER_INFORMATION_LEVEL
Definition: ntpoapi.h:66
@ ProcessorCap
Definition: ntpoapi.h:101
@ TraceServicePowerMessage
Definition: ntpoapi.h:104
@ SystemWakeSource
Definition: ntpoapi.h:102
@ SessionDisplayState
Definition: ntpoapi.h:109
@ SessionPowerInit
Definition: ntpoapi.h:108
@ ProcessorPowerPolicyDc
Definition: ntpoapi.h:86
@ GroupPark
Definition: ntpoapi.h:115
@ TraceApplicationPowerMessage
Definition: ntpoapi.h:97
@ ProcessorInformationEx
Definition: ntpoapi.h:113
@ SystemPowerStateNotifyHandler
Definition: ntpoapi.h:84
@ SystemPowerStateLogging
Definition: ntpoapi.h:90
@ ProcessorIdleStates
Definition: ntpoapi.h:100
@ LastWakeTime
Definition: ntpoapi.h:81
@ SystemHiberFileInformation
Definition: ntpoapi.h:103
@ SystemBatteryState
Definition: ntpoapi.h:72
@ AdministratorPowerPolicy
Definition: ntpoapi.h:76
@ LastSleepTime
Definition: ntpoapi.h:82
@ ProcessorIdleDomains
Definition: ntpoapi.h:116
@ PowerShutdownNotification
Definition: ntpoapi.h:106
@ SystemReserveHiberFile
Definition: ntpoapi.h:77
@ SystemPowerInformation
Definition: ntpoapi.h:79
@ SystemPowerCapabilities
Definition: ntpoapi.h:71
@ SystemPowerLoggingEntry
Definition: ntpoapi.h:91
@ ProcessorPerfStates
Definition: ntpoapi.h:99
@ PowerRequestAction
Definition: ntpoapi.h:111
@ SystemVideoState
Definition: ntpoapi.h:96
@ ProcessorStateHandler
Definition: ntpoapi.h:74
@ ProcessorPowerPolicyCurrent
Definition: ntpoapi.h:89
@ NotifyUserModeLegacyPowerEvent
Definition: ntpoapi.h:114
@ PowerRequestCreate
Definition: ntpoapi.h:110
@ WakeTimerList
Definition: ntpoapi.h:117
@ NotifyUserPowerSetting
Definition: ntpoapi.h:93
@ SystemExecutionState
Definition: ntpoapi.h:83
@ VerifyProcessorPowerPolicyDc
Definition: ntpoapi.h:88
@ SetPowerSettingValue
Definition: ntpoapi.h:92
@ VerifySystemPolicyDc
Definition: ntpoapi.h:70
@ SystemHiberFileSize
Definition: ntpoapi.h:118
@ ProcessorStateHandler2
Definition: ntpoapi.h:80
@ SystemPowerPolicyAc
Definition: ntpoapi.h:67
@ MonitorCapabilities
Definition: ntpoapi.h:107
@ PowerInformationLevelUnused1
Definition: ntpoapi.h:95
@ ProcessorInformation
Definition: ntpoapi.h:78
@ VerifyProcessorPowerPolicyAc
Definition: ntpoapi.h:87
@ VerifySystemPolicyAc
Definition: ntpoapi.h:69
@ PowerInformationLevelUnused0
Definition: ntpoapi.h:94
@ PowerInformationLevelMaximum
Definition: ntpoapi.h:119
@ ProcessorPowerPolicyAc
Definition: ntpoapi.h:85
@ SystemPowerPolicyDc
Definition: ntpoapi.h:68
@ SystemPowerPolicyCurrent
Definition: ntpoapi.h:75
@ TraceApplicationPowerMessageEnd
Definition: ntpoapi.h:98
@ SystemPowerStateHandler
Definition: ntpoapi.h:73
@ ProcessorLoad
Definition: ntpoapi.h:105
@ GetPowerRequestList
Definition: ntpoapi.h:112
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG NumberProcessors
Definition: ntpoapi.h:206
enum _POWER_STATE_TYPE * PPOWER_STATE_TYPE
_POWER_STATE_HANDLER_TYPE
Definition: ntpoapi.h:182
@ PowerStateMaximum
Definition: ntpoapi.h:190
@ PowerStateSleeping4
Definition: ntpoapi.h:186
@ PowerStateSleeping2
Definition: ntpoapi.h:184
@ PowerStateShutdownReset
Definition: ntpoapi.h:188
@ PowerStateSleeping1
Definition: ntpoapi.h:183
@ PowerStateSleeping4Firmware
Definition: ntpoapi.h:187
@ PowerStateSleeping3
Definition: ntpoapi.h:185
@ PowerStateShutdownOff
Definition: ntpoapi.h:189
NTSYSCALLAPI NTSTATUS NTAPI NtRequestWakeupLatency(_In_ LATENCY_TIME latency)
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
struct _PROCESSOR_POWER_INFORMATION * PPROCESSOR_POWER_INFORMATION
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define __kernel_entry
Definition: specstrings.h:355
ULONG RemainingCapacity
Definition: ntpoapi.h:391
BOOLEAN Discharging
Definition: ntpoapi.h:388
BOOLEAN BatteryPresent
Definition: ntpoapi.h:386
BOOLEAN SystemBatteriesPresent
Definition: ntpoapi.h:374
BOOLEAN BatteriesAreShortTerm
Definition: ntpoapi.h:375
SYSTEM_POWER_STATE AcOnLineWake
Definition: ntpoapi.h:377
SYSTEM_POWER_STATE DefaultLowLatencyWake
Definition: ntpoapi.h:381
SYSTEM_POWER_STATE MinDeviceWakeState
Definition: ntpoapi.h:380
SYSTEM_POWER_STATE SoftLidWake
Definition: ntpoapi.h:378
SYSTEM_POWER_STATE RtcWake
Definition: ntpoapi.h:379
POWER_ACTION Action
Definition: ntpoapi.h:408
POWER_STATE_HANDLER_TYPE Type
Definition: ntpoapi.h:210
PENTER_STATE_HANDLER Handler
Definition: ntpoapi.h:213
PENTER_STATE_NOTIFY_HANDLER Handler
Definition: ntpoapi.h:226
PPROCESSOR_IDLE_HANDLER Handler
Definition: ntpoapi.h:161
ULONGLONG StartTime
Definition: ntpoapi.h:148
ULONGLONG EndTime
Definition: ntpoapi.h:149
ULONG IdleHandlerReserved[4]
Definition: ntpoapi.h:150
ULONGLONG PerformanceTime
Definition: ntpoapi.h:262
PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS]
Definition: ntpoapi.h:267
PSET_PROCESSOR_THROTTLE2 SetPerfLevel
Definition: ntpoapi.h:268
PROCESSOR_PERF_LEVEL PerfLevel[1]
Definition: ntpoapi.h:271
PSET_PROCESSOR_THROTTLE SetThrottle
Definition: ntpoapi.h:177
PROCESSOR_IDLE_HANDLER_INFO IdleHandler[MAX_IDLE_HANDLERS]
Definition: ntpoapi.h:179
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint64_t ULONGLONG
Definition: typedefs.h:67
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
SYSTEM_POWER_STATE SystemState
Definition: ntpoapi.h:57
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
POWER_ACTION
Definition: winnt_old.h:3918
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ SYSTEM_POWER_STATE SystemPowerState
Definition: iotypes.h:7519
LATENCY_TIME
Definition: potypes.h:215
ULONG EXECUTION_STATE
Definition: potypes.h:213
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
unsigned char UCHAR
Definition: xmlstorage.h:181