Sync with trunk (r48545)
[reactos.git] / include / psdk / batclass.h
1 /*
2 * batclass.h
3 *
4 * Battery class driver interface
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 #pragma once
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /* Battery device GUIDs */
30
31 DEFINE_GUID(GUID_DEVICE_BATTERY,
32 0x72631e54L, 0x78A4, 0x11d0, 0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a);
33
34 #if (NTDDI_VERSION >= NTDDI_WINXP)
35 DEFINE_GUID(BATTERY_STATUS_WMI_GUID,
36 0xfc4670d1, 0xebbf, 0x416e, 0x87, 0xce, 0x37, 0x4a, 0x4e, 0xbc, 0x11, 0x1a);
37 DEFINE_GUID(BATTERY_RUNTIME_WMI_GUID,
38 0x535a3767, 0x1ac2, 0x49bc, 0xa0, 0x77, 0x3f, 0x7a, 0x02, 0xe4, 0x0a, 0xec);
39 DEFINE_GUID(BATTERY_TEMPERATURE_WMI_GUID,
40 0x1a52a14d, 0xadce, 0x4a44, 0x9a, 0x3e, 0xc8, 0xd8, 0xf1, 0x5f, 0xf2, 0xc2);
41 DEFINE_GUID(BATTERY_FULL_CHARGED_CAPACITY_WMI_GUID,
42 0x40b40565, 0x96f7, 0x4435, 0x86, 0x94, 0x97, 0xe0, 0xe4, 0x39, 0x59, 0x05);
43 DEFINE_GUID(BATTERY_CYCLE_COUNT_WMI_GUID,
44 0xef98db24, 0x0014, 0x4c25, 0xa5, 0x0b, 0xc7, 0x24, 0xae, 0x5c, 0xd3, 0x71);
45 DEFINE_GUID(BATTERY_STATIC_DATA_WMI_GUID,
46 0x05e1e463, 0xe4e2, 0x4ea9, 0x80, 0xcb, 0x9b, 0xd4, 0xb3, 0xca, 0x06, 0x55);
47 DEFINE_GUID(BATTERY_STATUS_CHANGE_WMI_GUID,
48 0xcddfa0c3, 0x7c5b, 0x4e43, 0xa0, 0x34, 0x05, 0x9f, 0xa5, 0xb8, 0x43, 0x64);
49 DEFINE_GUID(BATTERY_TAG_CHANGE_WMI_GUID,
50 0x5e1f6e19, 0x8786, 0x4d23, 0x94, 0xfc, 0x9e, 0x74, 0x6b, 0xd5, 0xd8, 0x88);
51 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
52
53 #ifndef _BATCLASS_
54 #define _BATCLASS_
55
56 /* BATTERY_INFORMATION.Capabilities constants */
57 #define BATTERY_SET_CHARGE_SUPPORTED 0x00000001
58 #define BATTERY_SET_DISCHARGE_SUPPORTED 0x00000002
59 #define BATTERY_SET_RESUME_SUPPORTED 0x00000004
60 #define BATTERY_IS_SHORT_TERM 0x20000000
61 #define BATTERY_CAPACITY_RELATIVE 0x40000000
62 #define BATTERY_SYSTEM_BATTERY 0x80000000
63
64 /* BATTERY_INFORMATION.Capacity constants */
65 #define BATTERY_UNKNOWN_CAPACITY 0xFFFFFFFF
66
67 /* BatteryEstimatedTime constant */
68 #define BATTERY_UNKNOWN_TIME 0x80000000
69
70 #define MAX_BATTERY_STRING_SIZE 128
71
72 /* BATTERY_STATUS.PowerState flags */
73 #define BATTERY_POWER_ON_LINE 0x00000001
74 #define BATTERY_DISCHARGING 0x00000002
75 #define BATTERY_CHARGING 0x00000004
76 #define BATTERY_CRITICAL 0x00000008
77
78 /* BATTERY_STATUS.Voltage constant */
79 #define BATTERY_UNKNOWN_VOLTAGE 0xFFFFFFFF
80
81 /* BATTERY_STATUS.Rate constant */
82 #define BATTERY_UNKNOWN_RATE 0x80000000
83
84 #define IOCTL_BATTERY_QUERY_TAG \
85 CTL_CODE(FILE_DEVICE_BATTERY, 0x10, METHOD_BUFFERED, FILE_READ_ACCESS)
86 #define IOCTL_BATTERY_QUERY_INFORMATION \
87 CTL_CODE(FILE_DEVICE_BATTERY, 0x11, METHOD_BUFFERED, FILE_READ_ACCESS)
88 #define IOCTL_BATTERY_SET_INFORMATION \
89 CTL_CODE(FILE_DEVICE_BATTERY, 0x12, METHOD_BUFFERED, FILE_WRITE_ACCESS)
90 #define IOCTL_BATTERY_QUERY_STATUS \
91 CTL_CODE(FILE_DEVICE_BATTERY, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS)
92
93 /* NTSTATUS possibly returned by BCLASS_QUERY_STATUS */
94 #define BATTERY_TAG_INVALID 0
95
96 typedef enum _BATTERY_QUERY_INFORMATION_LEVEL {
97 BatteryInformation = 0,
98 BatteryGranularityInformation,
99 BatteryTemperature,
100 BatteryEstimatedTime,
101 BatteryDeviceName,
102 BatteryManufactureDate,
103 BatteryManufactureName,
104 BatteryUniqueID,
105 BatterySerialNumber
106 } BATTERY_QUERY_INFORMATION_LEVEL;
107
108 typedef struct _BATTERY_QUERY_INFORMATION {
109 ULONG BatteryTag;
110 BATTERY_QUERY_INFORMATION_LEVEL InformationLevel;
111 LONG AtRate;
112 } BATTERY_QUERY_INFORMATION, *PBATTERY_QUERY_INFORMATION;
113
114 typedef struct _BATTERY_INFORMATION {
115 ULONG Capabilities;
116 UCHAR Technology;
117 UCHAR Reserved[3];
118 UCHAR Chemistry[4];
119 ULONG DesignedCapacity;
120 ULONG FullChargedCapacity;
121 ULONG DefaultAlert1;
122 ULONG DefaultAlert2;
123 ULONG CriticalBias;
124 ULONG CycleCount;
125 } BATTERY_INFORMATION, *PBATTERY_INFORMATION;
126
127 typedef struct _BATTERY_MANUFACTURE_DATE {
128 UCHAR Day;
129 UCHAR Month;
130 USHORT Year;
131 } BATTERY_MANUFACTURE_DATE, *PBATTERY_MANUFACTURE_DATE;
132
133 typedef enum _BATTERY_SET_INFORMATION_LEVEL {
134 BatteryCriticalBias = 0,
135 BatteryCharge,
136 BatteryDischarge
137 } BATTERY_SET_INFORMATION_LEVEL;
138
139 typedef struct _BATTERY_SET_INFORMATION {
140 ULONG BatteryTag;
141 BATTERY_SET_INFORMATION_LEVEL InformationLevel;
142 UCHAR Buffer[1];
143 } BATTERY_SET_INFORMATION, *PBATTERY_SET_INFORMATION;
144
145 typedef struct _BATTERY_WAIT_STATUS {
146 ULONG BatteryTag;
147 ULONG Timeout;
148 ULONG PowerState;
149 ULONG LowCapacity;
150 ULONG HighCapacity;
151 } BATTERY_WAIT_STATUS, *PBATTERY_WAIT_STATUS;
152
153 typedef struct _BATTERY_STATUS {
154 ULONG PowerState;
155 ULONG Capacity;
156 ULONG Voltage;
157 LONG Rate;
158 } BATTERY_STATUS, *PBATTERY_STATUS;
159
160 #ifndef _WINDOWS_H
161
162 /* BATTERY_MINIPORT_INFO.XxxVersion */
163 #define BATTERY_CLASS_MAJOR_VERSION 0x0001
164 #define BATTERY_CLASS_MINOR_VERSION 0x0000
165
166 typedef NTSTATUS
167 (NTAPI BCLASS_QUERY_TAG_CALLBACK)(
168 IN PVOID Context,
169 OUT PULONG BatteryTag);
170 typedef BCLASS_QUERY_TAG_CALLBACK *PBCLASS_QUERY_TAG_CALLBACK;
171
172 typedef NTSTATUS
173 (NTAPI BCLASS_QUERY_INFORMATION_CALLBACK)(
174 IN PVOID Context,
175 IN ULONG BatteryTag,
176 IN BATTERY_QUERY_INFORMATION_LEVEL Level,
177 IN LONG AtRate,
178 OUT PVOID Buffer,
179 IN ULONG BufferLength,
180 OUT PULONG ReturnedLength);
181 typedef BCLASS_QUERY_INFORMATION_CALLBACK *PBCLASS_QUERY_INFORMATION_CALLBACK;
182
183 typedef NTSTATUS
184 (NTAPI BCLASS_QUERY_STATUS_CALLBACK)(
185 IN PVOID Context,
186 IN ULONG BatteryTag,
187 OUT PBATTERY_STATUS BatteryStatus);
188 typedef BCLASS_QUERY_STATUS_CALLBACK *PBCLASS_QUERY_STATUS_CALLBACK;
189
190 typedef struct _BATTERY_NOTIFY {
191 ULONG PowerState;
192 ULONG LowCapacity;
193 ULONG HighCapacity;
194 } BATTERY_NOTIFY, *PBATTERY_NOTIFY;
195
196 typedef NTSTATUS
197 (NTAPI BCLASS_SET_STATUS_NOTIFY_CALLBACK)(
198 IN PVOID Context,
199 IN ULONG BatteryTag,
200 IN PBATTERY_NOTIFY BatteryNotify);
201 typedef BCLASS_SET_STATUS_NOTIFY_CALLBACK *PBCLASS_SET_STATUS_NOTIFY_CALLBACK;
202
203 typedef NTSTATUS
204 (NTAPI BCLASS_SET_INFORMATION_CALLBACK)(
205 IN PVOID Context,
206 IN ULONG BatteryTag,
207 IN BATTERY_SET_INFORMATION_LEVEL Level,
208 IN PVOID Buffer OPTIONAL);
209 typedef BCLASS_SET_INFORMATION_CALLBACK *PBCLASS_SET_INFORMATION_CALLBACK;
210
211 typedef NTSTATUS
212 (NTAPI BCLASS_DISABLE_STATUS_NOTIFY_CALLBACK)(
213 IN PVOID Context);
214 typedef BCLASS_DISABLE_STATUS_NOTIFY_CALLBACK *PBCLASS_DISABLE_STATUS_NOTIFY_CALLBACK;
215
216 typedef PBCLASS_QUERY_TAG_CALLBACK BCLASS_QUERY_TAG;
217 typedef PBCLASS_QUERY_INFORMATION_CALLBACK BCLASS_QUERY_INFORMATION;
218 typedef PBCLASS_QUERY_STATUS_CALLBACK BCLASS_QUERY_STATUS;
219 typedef PBCLASS_SET_STATUS_NOTIFY_CALLBACK BCLASS_SET_STATUS_NOTIFY;
220 typedef PBCLASS_SET_INFORMATION_CALLBACK BCLASS_SET_INFORMATION;
221 typedef PBCLASS_DISABLE_STATUS_NOTIFY_CALLBACK BCLASS_DISABLE_STATUS_NOTIFY;
222
223 typedef struct _BATTERY_MINIPORT_INFO {
224 USHORT MajorVersion;
225 USHORT MinorVersion;
226 PVOID Context;
227 BCLASS_QUERY_TAG QueryTag;
228 BCLASS_QUERY_INFORMATION QueryInformation;
229 BCLASS_SET_INFORMATION SetInformation;
230 BCLASS_QUERY_STATUS QueryStatus;
231 BCLASS_SET_STATUS_NOTIFY SetStatusNotify;
232 BCLASS_DISABLE_STATUS_NOTIFY DisableStatusNotify;
233 PDEVICE_OBJECT Pdo;
234 PUNICODE_STRING DeviceName;
235 } BATTERY_MINIPORT_INFO, *PBATTERY_MINIPORT_INFO;
236
237 #if (NTDDI_VERSION >= NTDDI_WINXP)
238
239 typedef struct _BATTERY_WMI_STATUS {
240 ULONG Tag;
241 ULONG RemainingCapacity;
242 LONG ChargeRate;
243 LONG DischargeRate;
244 ULONG Voltage;
245 BOOLEAN PowerOnline;
246 BOOLEAN Charging;
247 BOOLEAN Discharging;
248 BOOLEAN Critical;
249 } BATTERY_WMI_STATUS, *PBATTERY_WMI_STATUS;
250
251 typedef struct _BATTERY_WMI_RUNTIME {
252 ULONG Tag;
253 ULONG EstimatedRuntime;
254 } BATTERY_WMI_RUNTIME, *PBATTERY_WMI_RUNTIME;
255
256 typedef struct _BATTERY_WMI_TEMPERATURE {
257 ULONG Tag;
258 ULONG Temperature;
259 } BATTERY_WMI_TEMPERATURE, *PBATTERY_WMI_TEMPERATURE;
260
261 typedef struct _BATTERY_WMI_FULL_CHARGED_CAPACITY {
262 ULONG Tag;
263 ULONG FullChargedCapacity;
264 } BATTERY_WMI_FULL_CHARGED_CAPACITY, *PBATTERY_WMI_FULL_CHARGED_CAPACITY;
265
266 typedef struct _BATTERY_WMI_CYCLE_COUNT {
267 ULONG Tag;
268 ULONG CycleCount;
269 } BATTERY_WMI_CYCLE_COUNT, *PBATTERY_WMI_CYCLE_COUNT;
270
271 typedef struct _BATTERY_WMI_STATIC_DATA {
272 ULONG Tag;
273 WCHAR ManufactureDate[25];
274 BATTERY_REPORTING_SCALE Granularity [4];
275 ULONG Capabilities;
276 UCHAR Technology;
277 ULONG Chemistry;
278 ULONG DesignedCapacity;
279 ULONG DefaultAlert1;
280 ULONG DefaultAlert2;
281 ULONG CriticalBias;
282 WCHAR Strings[1];
283 } BATTERY_WMI_STATIC_DATA, *PBATTERY_WMI_STATIC_DATA;
284
285 typedef struct _BATTERY_WMI_STATUS_CHANGE {
286 ULONG Tag;
287 BOOLEAN PowerOnline;
288 BOOLEAN Charging;
289 BOOLEAN Discharging;
290 BOOLEAN Critical;
291 } BATTERY_WMI_STATUS_CHANGE, *PBATTERY_WMI_STATUS_CHANGE;
292
293 typedef struct _BATTERY_TAG_CHANGE {
294 ULONG Tag;
295 } BATTERY_TAG_CHANGE, *PBATTERY_TAG_CHANGE;
296
297 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
298
299 #if defined(_BATTERYCLASS_)
300 #define BCLASSAPI
301 #else
302 #define BCLASSAPI DECLSPEC_IMPORT
303 #endif
304
305 BCLASSAPI
306 NTSTATUS
307 NTAPI
308 BatteryClassInitializeDevice(
309 IN PBATTERY_MINIPORT_INFO MiniportInfo,
310 IN PVOID *ClassData);
311
312 BCLASSAPI
313 NTSTATUS
314 NTAPI
315 BatteryClassIoctl(
316 IN PVOID ClassData,
317 IN OUT PIRP Irp);
318
319 BCLASSAPI
320 NTSTATUS
321 NTAPI
322 BatteryClassStatusNotify(
323 IN PVOID ClassData);
324
325 #if (NTDDI_VERSION >= NTDDI_WINXP)
326
327 BCLASSAPI
328 NTSTATUS
329 NTAPI
330 BatteryClassQueryWmiDataBlock(
331 IN PVOID ClassData,
332 IN OUT PDEVICE_OBJECT DeviceObject,
333 IN OUT PIRP Irp,
334 IN ULONG GuidIndex,
335 OUT PULONG InstanceLengthArray,
336 IN ULONG OutBufferSize,
337 OUT PUCHAR Buffer OPTIONAL);
338
339 BCLASSAPI
340 NTSTATUS
341 NTAPI
342 BatteryClassSystemControl(
343 IN PVOID ClassData,
344 IN PVOID WmiLibContext, /* PWMILIB_CONTEXT */
345 IN PDEVICE_OBJECT DeviceObject,
346 IN OUT PIRP Irp,
347 OUT PVOID Disposition); /* PSYSCTL_IRP_DISPOSITION */
348
349 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
350
351 BCLASSAPI
352 NTSTATUS
353 NTAPI
354 BatteryClassUnload(
355 IN PVOID ClassData);
356
357 #endif /* _WINDOWS_H */
358
359 #endif /* _BATCLASS_ */
360
361 #ifdef __cplusplus
362 }
363 #endif