4 * APIs for power management.
6 * This file is part of the w32api package.
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
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.
27 #pragma GCC system_header
37 #define POWER_PERF_SCALE 100
38 #define PERF_LEVEL_TO_PERCENT(x) (((x) * 1000) / (POWER_PERF_SCALE * 10))
39 #define PERCENT_TO_PERF_LEVEL(x) (((x) * POWER_PERF_SCALE * 10) / 1000)
41 typedef struct _PROCESSOR_IDLE_TIMES
{
44 ULONG IdleHandlerReserved
[4];
45 } PROCESSOR_IDLE_TIMES
, *PPROCESSOR_IDLE_TIMES
;
47 typedef BOOLEAN DDKFASTAPI
48 (*PPROCESSOR_IDLE_HANDLER
)(
49 /*IN OUT*/ PPROCESSOR_IDLE_TIMES IdleTimes
);
51 typedef struct _PROCESSOR_IDLE_HANDLER_INFO
{
52 ULONG HardwareLatency
;
53 PPROCESSOR_IDLE_HANDLER Handler
;
54 } PROCESSOR_IDLE_HANDLER_INFO
, *PPROCESSOR_IDLE_HANDLER_INFO
;
56 typedef VOID DDKFASTAPI
57 (*PSET_PROCESSOR_THROTTLE
)(
58 /*IN*/ UCHAR Throttle
);
60 typedef NTSTATUS DDKFASTAPI
61 (*PSET_PROCESSOR_THROTTLE2
)(
62 /*IN*/ UCHAR Throttle
);
64 #define MAX_IDLE_HANDLERS 3
66 typedef struct _PROCESSOR_STATE_HANDLER
{
68 BOOLEAN ThrottleOnIdle
;
69 PSET_PROCESSOR_THROTTLE SetThrottle
;
70 ULONG NumIdleHandlers
;
71 PROCESSOR_IDLE_HANDLER_INFO IdleHandler
[MAX_IDLE_HANDLERS
];
72 } PROCESSOR_STATE_HANDLER
, *PPROCESSOR_STATE_HANDLER
;
74 typedef enum _POWER_STATE_HANDLER_TYPE
{
79 PowerStateSleeping4Firmware
,
80 PowerStateShutdownReset
,
81 PowerStateShutdownOff
,
83 } POWER_STATE_HANDLER_TYPE
, *PPOWER_STATE_HANDLER_TYPE
;
85 typedef NTSTATUS DDKAPI
86 (*PENTER_STATE_SYSTEM_HANDLER
)(
87 /*IN*/ PVOID SystemContext
);
89 typedef NTSTATUS DDKAPI
90 (*PENTER_STATE_HANDLER
)(
92 /*IN*/ PENTER_STATE_SYSTEM_HANDLER SystemHandler
/*OPTIONAL*/,
93 /*IN*/ PVOID SystemContext
,
94 /*IN*/ LONG NumberProcessors
,
95 /*IN*/ VOLATILE PLONG Number
);
97 typedef struct _POWER_STATE_HANDLER
{
98 POWER_STATE_HANDLER_TYPE Type
;
101 PENTER_STATE_HANDLER Handler
;
103 } POWER_STATE_HANDLER
, *PPOWER_STATE_HANDLER
;
105 typedef NTSTATUS STDCALL
106 (*PENTER_STATE_NOTIFY_HANDLER
)(
107 /*IN*/ POWER_STATE_HANDLER_TYPE State
,
108 /*IN*/ PVOID Context
,
109 /*IN*/ BOOLEAN Entering
);
111 typedef struct _POWER_STATE_NOTIFY_HANDLER
{
112 PENTER_STATE_NOTIFY_HANDLER Handler
;
114 } POWER_STATE_NOTIFY_HANDLER
, *PPOWER_STATE_NOTIFY_HANDLER
;
120 /*IN*/ POWER_INFORMATION_LEVEL InformationLevel
,
121 /*IN*/ PVOID InputBuffer
/*OPTIONAL*/,
122 /*IN*/ ULONG InputBufferLength
,
123 /*OUT*/ PVOID OutputBuffer
/*OPTIONAL*/,
124 /*IN*/ ULONG OutputBufferLength
);
126 #define PROCESSOR_STATE_TYPE_PERFORMANCE 1
127 #define PROCESSOR_STATE_TYPE_THROTTLE 2
129 typedef struct _PROCESSOR_PERF_LEVEL
{
130 UCHAR PercentFrequency
;
133 } PROCESSOR_PERF_LEVEL
, *PPROCESSOR_PERF_LEVEL
;
135 typedef struct _PROCESSOR_PERF_STATE
{
136 UCHAR PercentFrequency
;
146 ULONGLONG PerformanceTime
;
147 } PROCESSOR_PERF_STATE
, *PPROCESSOR_PERF_STATE
;
149 typedef struct _PROCESSOR_STATE_HANDLER2
{
150 ULONG NumIdleHandlers
;
151 PROCESSOR_IDLE_HANDLER_INFO IdleHandler
[MAX_IDLE_HANDLERS
];
152 PSET_PROCESSOR_THROTTLE2 SetPerfLevel
;
153 ULONG HardwareLatency
;
155 PROCESSOR_PERF_LEVEL PerfLevel
[1];
156 } PROCESSOR_STATE_HANDLER2
, *PPROCESSOR_STATE_HANDLER2
;
162 NtSetThreadExecutionState(
163 /*IN*/ EXECUTION_STATE esFlags
,
164 /*OUT*/ EXECUTION_STATE
*PreviousFlags
);
169 NtRequestWakeupLatency(
170 /*IN*/ LATENCY_TIME latency
);
175 NtInitiatePowerAction(
176 /*IN*/ POWER_ACTION SystemAction
,
177 /*IN*/ SYSTEM_POWER_STATE MinSystemState
,
179 /*IN*/ BOOLEAN Asynchronous
);
184 NtSetSystemPowerState(
185 /*IN*/ POWER_ACTION SystemAction
,
186 /*IN*/ SYSTEM_POWER_STATE MinSystemState
,
192 NtGetDevicePowerState(
193 /*IN*/ HANDLE Device
,
194 /*OUT*/ DEVICE_POWER_STATE
*State
);
199 NtCancelDeviceWakeupRequest(
200 /*IN*/ HANDLE Device
);
205 NtIsSystemResumeAutomatic(
211 NtRequestDeviceWakeup(
212 /*IN*/ HANDLE Device
);
214 #define WINLOGON_LOCK_ON_SLEEP 0x00000001
216 typedef struct _PROCESSOR_POWER_INFORMATION
{
222 ULONG CurrentIdleState
;
223 } PROCESSOR_POWER_INFORMATION
, *PPROCESSOR_POWER_INFORMATION
;
229 #endif /* __NTPOAPI_H */