457212519d08848dbd9df0618cc824025522ca64
[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 #ifndef __BATCLASS_H
24 #define __BATCLASS_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #if defined(_BATTERYCLASS_)
31 #define BCLASSAPI
32 #else
33 #define BCLASSAPI DECLSPEC_IMPORT
34 #endif
35
36
37 /* Battery device GUIDs */
38
39 DEFINE_GUID(GUID_DEVICE_BATTERY,
40 0x72631e54L, 0x78A4, 0x11d0, 0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a);
41
42 DEFINE_GUID(BATTERY_STATUS_WMI_GUID,
43 0xfc4670d1, 0xebbf, 0x416e, 0x87, 0xce, 0x37, 0x4a, 0x4e, 0xbc, 0x11, 0x1a);
44
45 DEFINE_GUID(BATTERY_RUNTIME_WMI_GUID,
46 0x535a3767, 0x1ac2, 0x49bc, 0xa0, 0x77, 0x3f, 0x7a, 0x02, 0xe4, 0x0a, 0xec);
47
48 DEFINE_GUID(BATTERY_TEMPERATURE_WMI_GUID,
49 0x1a52a14d, 0xadce, 0x4a44, 0x9a, 0x3e, 0xc8, 0xd8, 0xf1, 0x5f, 0xf2, 0xc2);
50
51 DEFINE_GUID(BATTERY_FULL_CHARGED_CAPACITY_WMI_GUID,
52 0x40b40565, 0x96f7, 0x4435, 0x86, 0x94, 0x97, 0xe0, 0xe4, 0x39, 0x59, 0x05);
53
54 DEFINE_GUID(BATTERY_CYCLE_COUNT_WMI_GUID,
55 0xef98db24, 0x0014, 0x4c25, 0xa5, 0x0b, 0xc7, 0x24, 0xae, 0x5c, 0xd3, 0x71);
56
57 DEFINE_GUID(BATTERY_STATIC_DATA_WMI_GUID,
58 0x05e1e463, 0xe4e2, 0x4ea9, 0x80, 0xcb, 0x9b, 0xd4, 0xb3, 0xca, 0x06, 0x55);
59
60 DEFINE_GUID(BATTERY_STATUS_CHANGE_WMI_GUID,
61 0xcddfa0c3, 0x7c5b, 0x4e43, 0xa0, 0x34, 0x05, 0x9f, 0xa5, 0xb8, 0x43, 0x64);
62
63 DEFINE_GUID(BATTERY_TAG_CHANGE_WMI_GUID,
64 0x5e1f6e19, 0x8786, 0x4d23, 0x94, 0xfc, 0x9e, 0x74, 0x6b, 0xd5, 0xd8, 0x88);
65
66
67 /* BATTERY_INFORMATION.Capabilities constants */
68 #define BATTERY_SET_CHARGE_SUPPORTED 0x00000001
69 #define BATTERY_SET_DISCHARGE_SUPPORTED 0x00000002
70 #define BATTERY_SET_RESUME_SUPPORTED 0x00000004
71 #define BATTERY_IS_SHORT_TERM 0x20000000
72 #define BATTERY_CAPACITY_RELATIVE 0x40000000
73 #define BATTERY_SYSTEM_BATTERY 0x80000000
74
75 typedef struct _BATTERY_INFORMATION {
76 ULONG Capabilities;
77 UCHAR Technology;
78 UCHAR Reserved[3];
79 UCHAR Chemistry[4];
80 ULONG DesignedCapacity;
81 ULONG FullChargedCapacity;
82 ULONG DefaultAlert1;
83 ULONG DefaultAlert2;
84 ULONG CriticalBias;
85 ULONG CycleCount;
86 } BATTERY_INFORMATION, *PBATTERY_INFORMATION;
87
88 typedef struct _BATTERY_MANUFACTURE_DATE {
89 UCHAR Day;
90 UCHAR Month;
91 USHORT Year;
92 } BATTERY_MANUFACTURE_DATE, *PBATTERY_MANUFACTURE_DATE;
93
94 typedef struct _BATTERY_NOTIFY {
95 ULONG PowerState;
96 ULONG LowCapacity;
97 ULONG HighCapacity;
98 } BATTERY_NOTIFY, *PBATTERY_NOTIFY;
99
100 /* BATTERY_STATUS.PowerState flags */
101 #define BATTERY_POWER_ON_LINE 0x00000001
102 #define BATTERY_DISCHARGING 0x00000002
103 #define BATTERY_CHARGING 0x00000004
104 #define BATTERY_CRITICAL 0x00000008
105
106 /* BATTERY_STATUS.Voltage constant */
107 #define BATTERY_UNKNOWN_VOLTAGE 0xFFFFFFFF
108
109 /* BATTERY_STATUS.Rate constant */
110 #define BATTERY_UNKNOWN_RATE 0x80000000
111
112 typedef struct _BATTERY_STATUS {
113 ULONG PowerState;
114 ULONG Capacity;
115 ULONG Voltage;
116 LONG Rate;
117 } BATTERY_STATUS, *PBATTERY_STATUS;
118
119 /* BATTERY_INFORMATION.Capacity constants */
120 #define BATTERY_UNKNOWN_CAPACITY 0xFFFFFFFF
121
122 typedef enum _BATTERY_QUERY_INFORMATION_LEVEL {
123 BatteryInformation = 0,
124 BatteryGranularityInformation,
125 BatteryTemperature,
126 BatteryEstimatedTime,
127 BatteryDeviceName,
128 BatteryManufactureDate,
129 BatteryManufactureName,
130 BatteryUniqueID,
131 BatterySerialNumber
132 } BATTERY_QUERY_INFORMATION_LEVEL;
133
134 /* BatteryEstimatedTime constant */
135 #define BATTERY_UNKNOWN_TIME 0x80000000
136
137 /* NTSTATUS possibly returned by BCLASS_QUERY_STATUS */
138 #define BATTERY_TAG_INVALID 0
139
140 typedef struct _BATTERY_QUERY_INFORMATION {
141 ULONG BatteryTag;
142 BATTERY_QUERY_INFORMATION_LEVEL InformationLevel;
143 LONG AtRate;
144 } BATTERY_QUERY_INFORMATION, *PBATTERY_QUERY_INFORMATION;
145
146 typedef enum _BATTERY_SET_INFORMATION_LEVEL {
147 BatteryCriticalBias = 0,
148 BatteryCharge,
149 BatteryDischarge
150 } BATTERY_SET_INFORMATION_LEVEL;
151
152 #define MAX_BATTERY_STRING_SIZE 128
153
154 typedef struct _BATTERY_SET_INFORMATION {
155 ULONG BatteryTag;
156 BATTERY_SET_INFORMATION_LEVEL InformationLevel;
157 UCHAR Buffer[1];
158 } BATTERY_SET_INFORMATION, *PBATTERY_SET_INFORMATION;
159
160 typedef struct _BATTERY_WAIT_STATUS {
161 ULONG BatteryTag;
162 ULONG Timeout;
163 ULONG PowerState;
164 ULONG LowCapacity;
165 ULONG HighCapacity;
166 } BATTERY_WAIT_STATUS, *PBATTERY_WAIT_STATUS;
167
168
169 #define IOCTL_BATTERY_QUERY_TAG \
170 CTL_CODE(FILE_DEVICE_BATTERY, 0x10, METHOD_BUFFERED, FILE_READ_ACCESS)
171
172 #define IOCTL_BATTERY_QUERY_INFORMATION \
173 CTL_CODE(FILE_DEVICE_BATTERY, 0x11, METHOD_BUFFERED, FILE_READ_ACCESS)
174
175 #define IOCTL_BATTERY_SET_INFORMATION \
176 CTL_CODE(FILE_DEVICE_BATTERY, 0x12, METHOD_BUFFERED, FILE_WRITE_ACCESS)
177
178 #define IOCTL_BATTERY_QUERY_STATUS \
179 CTL_CODE(FILE_DEVICE_BATTERY, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS)
180
181
182 typedef NTSTATUS
183 (DDKAPI*BCLASS_DISABLE_STATUS_NOTIFY)(
184 IN PVOID Context);
185
186 typedef NTSTATUS
187 (DDKAPI*BCLASS_QUERY_INFORMATION)(
188 IN PVOID Context,
189 IN ULONG BatteryTag,
190 IN BATTERY_QUERY_INFORMATION_LEVEL Level,
191 IN LONG AtRate OPTIONAL,
192 OUT PVOID Buffer,
193 IN ULONG BufferLength,
194 OUT PULONG ReturnedLength);
195
196 typedef NTSTATUS
197 (DDKAPI*BCLASS_QUERY_STATUS)(
198 IN PVOID Context,
199 IN ULONG BatteryTag,
200 OUT PBATTERY_STATUS BatteryStatus);
201
202 typedef NTSTATUS
203 (DDKAPI*BCLASS_QUERY_TAG)(
204 IN PVOID Context,
205 OUT PULONG BatteryTag);
206
207 typedef NTSTATUS
208 (DDKAPI*BCLASS_SET_INFORMATION)(
209 IN PVOID Context,
210 IN ULONG BatteryTag,
211 IN BATTERY_SET_INFORMATION_LEVEL Level,
212 IN PVOID Buffer OPTIONAL);
213
214 typedef NTSTATUS
215 (DDKAPI*BCLASS_SET_STATUS_NOTIFY)(
216 IN PVOID Context,
217 IN ULONG BatteryTag,
218 IN PBATTERY_NOTIFY BatteryNotify);
219
220
221 typedef struct _BATTERY_MINIPORT_INFO {
222 USHORT MajorVersion;
223 USHORT MinorVersion;
224 PVOID Context;
225 BCLASS_QUERY_TAG QueryTag;
226 BCLASS_QUERY_INFORMATION QueryInformation;
227 BCLASS_SET_INFORMATION SetInformation;
228 BCLASS_QUERY_STATUS QueryStatus;
229 BCLASS_SET_STATUS_NOTIFY SetStatusNotify;
230 BCLASS_DISABLE_STATUS_NOTIFY DisableStatusNotify;
231 PDEVICE_OBJECT Pdo;
232 PUNICODE_STRING DeviceName;
233 } BATTERY_MINIPORT_INFO, *PBATTERY_MINIPORT_INFO;
234
235 /* BATTERY_MINIPORT_INFO.XxxVersion */
236 #define BATTERY_CLASS_MAJOR_VERSION 0x0001
237 #define BATTERY_CLASS_MINOR_VERSION 0x0000
238
239
240 BCLASSAPI
241 NTSTATUS
242 DDKAPI
243 BatteryClassInitializeDevice(
244 IN PBATTERY_MINIPORT_INFO MiniportInfo,
245 IN PVOID *ClassData);
246
247 BCLASSAPI
248 NTSTATUS
249 DDKAPI
250 BatteryClassIoctl(
251 IN PVOID ClassData,
252 IN PIRP Irp);
253
254 BCLASSAPI
255 NTSTATUS
256 DDKAPI
257 BatteryClassQueryWmiDataBlock(
258 IN PVOID ClassData,
259 IN PDEVICE_OBJECT DeviceObject,
260 IN PIRP Irp,
261 IN ULONG GuidIndex,
262 IN OUT PULONG InstanceLengthArray,
263 IN ULONG OutBufferSize,
264 OUT PUCHAR Buffer);
265
266 BCLASSAPI
267 NTSTATUS
268 DDKAPI
269 BatteryClassStatusNotify(
270 IN PVOID ClassData);
271
272 BCLASSAPI
273 NTSTATUS
274 DDKAPI
275 BatteryClassSystemControl(
276 IN PVOID ClassData,
277 IN PVOID WmiLibContext, /* PWMILIB_CONTEXT */
278 IN PDEVICE_OBJECT DeviceObject,
279 IN PIRP Irp,
280 OUT PVOID Disposition); /* PSYSCTL_IRP_DISPOSITION */
281
282 BCLASSAPI
283 NTSTATUS
284 DDKAPI
285 BatteryClassUnload(
286 IN PVOID ClassData);
287
288 #ifdef __cplusplus
289 }
290 #endif
291
292 #endif /* __BATCLASS_H */