OSDN Git Service

Apply LICENSE to all files as appropriate.
[mingw/mingw-org-wsl.git] / include / ddk / batclass.h
1 /**
2  * @file batclass.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 /*
25  * batclass.h
26  *
27  * Battery class driver interface
28  *
29  * This file is part of the w32api package.
30  *
31  * Contributors:
32  *   Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
33  *
34  * THIS SOFTWARE IS NOT COPYRIGHTED
35  *
36  * This source code is offered for use in the public domain. You may
37  * use, modify or distribute it freely.
38  *
39  * This code is distributed in the hope that it will be useful but
40  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
41  * DISCLAIMED. This includes but is not limited to warranties of
42  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
43  *
44  */
45
46 #ifndef __BATCLASS_H
47 #define __BATCLASS_H
48 #pragma GCC system_header
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 #include "ntddk.h"
55
56 #if defined(_BATTERYCLASS_)
57   #define BCLASSAPI DECLSPEC_EXPORT
58 #else
59   #define BCLASSAPI DECLSPEC_IMPORT
60 #endif
61
62
63 /* Battery device GUIDs */
64
65 DEFINE_GUID(GUID_DEVICE_BATTERY,
66   0x72631e54L, 0x78A4, 0x11d0, 0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a);
67
68 DEFINE_GUID(BATTERY_STATUS_WMI_GUID,
69   0xfc4670d1, 0xebbf, 0x416e, 0x87, 0xce, 0x37, 0x4a, 0x4e, 0xbc, 0x11, 0x1a);
70
71 DEFINE_GUID(BATTERY_RUNTIME_WMI_GUID,
72   0x535a3767, 0x1ac2, 0x49bc, 0xa0, 0x77, 0x3f, 0x7a, 0x02, 0xe4, 0x0a, 0xec);
73
74 DEFINE_GUID(BATTERY_TEMPERATURE_WMI_GUID,
75   0x1a52a14d, 0xadce, 0x4a44, 0x9a, 0x3e, 0xc8, 0xd8, 0xf1, 0x5f, 0xf2, 0xc2);
76
77 DEFINE_GUID(BATTERY_FULL_CHARGED_CAPACITY_WMI_GUID,
78   0x40b40565, 0x96f7, 0x4435, 0x86, 0x94, 0x97, 0xe0, 0xe4, 0x39, 0x59, 0x05);
79
80 DEFINE_GUID(BATTERY_CYCLE_COUNT_WMI_GUID,
81   0xef98db24, 0x0014, 0x4c25, 0xa5, 0x0b, 0xc7, 0x24, 0xae, 0x5c, 0xd3, 0x71);
82
83 DEFINE_GUID(BATTERY_STATIC_DATA_WMI_GUID,
84   0x05e1e463, 0xe4e2, 0x4ea9, 0x80, 0xcb, 0x9b, 0xd4, 0xb3, 0xca, 0x06, 0x55);
85
86 DEFINE_GUID(BATTERY_STATUS_CHANGE_WMI_GUID,
87   0xcddfa0c3, 0x7c5b, 0x4e43, 0xa0, 0x34, 0x05, 0x9f, 0xa5, 0xb8, 0x43, 0x64);
88
89 DEFINE_GUID(BATTERY_TAG_CHANGE_WMI_GUID,
90   0x5e1f6e19, 0x8786, 0x4d23, 0x94, 0xfc, 0x9e, 0x74, 0x6b, 0xd5, 0xd8, 0x88);
91
92
93 /* BATTERY_INFORMATION.Capabilities constants */
94 #define BATTERY_SET_CHARGE_SUPPORTED      0x00000001
95 #define BATTERY_SET_DISCHARGE_SUPPORTED   0x00000002
96 #define BATTERY_SET_RESUME_SUPPORTED      0x00000004
97 #define BATTERY_IS_SHORT_TERM             0x20000000
98 #define BATTERY_CAPACITY_RELATIVE         0x40000000
99 #define BATTERY_SYSTEM_BATTERY            0x80000000
100
101 typedef struct _BATTERY_INFORMATION {
102   ULONG  Capabilities;
103   UCHAR  Technology;
104   UCHAR  Reserved[3];
105   UCHAR  Chemistry[4];
106   ULONG  DesignedCapacity;
107   ULONG  FullChargedCapacity;
108   ULONG  DefaultAlert1;
109   ULONG  DefaultAlert2;
110   ULONG  CriticalBias;
111   ULONG  CycleCount;
112 } BATTERY_INFORMATION, *PBATTERY_INFORMATION;
113
114 typedef struct _BATTERY_MANUFACTURE_DATE {
115   UCHAR  Day;
116   UCHAR  Month;
117   USHORT  Year;
118 } BATTERY_MANUFACTURE_DATE, *PBATTERY_MANUFACTURE_DATE;
119
120 typedef struct _BATTERY_NOTIFY {
121         ULONG  PowerState;
122         ULONG  LowCapacity;
123         ULONG  HighCapacity;
124 } BATTERY_NOTIFY, *PBATTERY_NOTIFY;
125
126 /* BATTERY_STATUS.PowerState flags */
127 #define BATTERY_POWER_ON_LINE             0x00000001
128 #define BATTERY_DISCHARGING               0x00000002
129 #define BATTERY_CHARGING                  0x00000004
130 #define BATTERY_CRITICAL                  0x00000008
131
132 /* BATTERY_STATUS.Voltage constant */
133 #define BATTERY_UNKNOWN_VOLTAGE           0xFFFFFFFF
134
135 /* BATTERY_STATUS.Rate constant */
136 #define BATTERY_UNKNOWN_RATE              0x80000000
137
138 typedef struct _BATTERY_STATUS {
139   ULONG  PowerState;
140   ULONG  Capacity;
141   ULONG  Voltage;
142   LONG  Rate;
143 } BATTERY_STATUS, *PBATTERY_STATUS;
144
145 /* BATTERY_INFORMATION.Capacity constants */
146 #define BATTERY_UNKNOWN_CAPACITY          0xFFFFFFFF
147
148 typedef enum _BATTERY_QUERY_INFORMATION_LEVEL {
149   BatteryInformation = 0,
150   BatteryGranularityInformation,
151   BatteryTemperature,
152   BatteryEstimatedTime,
153   BatteryDeviceName,
154   BatteryManufactureDate,
155   BatteryManufactureName,
156   BatteryUniqueID,
157   BatterySerialNumber
158 } BATTERY_QUERY_INFORMATION_LEVEL;
159
160 /* BatteryEstimatedTime constant */
161 #define BATTERY_UNKNOWN_TIME              0x80000000
162
163 /* NTSTATUS possibly returned by BCLASS_QUERY_STATUS */
164 #define BATTERY_TAG_INVALID 0
165
166 typedef struct _BATTERY_QUERY_INFORMATION {
167   ULONG  BatteryTag;
168   BATTERY_QUERY_INFORMATION_LEVEL  InformationLevel;
169   LONG  AtRate;
170 } BATTERY_QUERY_INFORMATION, *PBATTERY_QUERY_INFORMATION;
171
172 typedef enum _BATTERY_SET_INFORMATION_LEVEL {
173   BatteryCriticalBias = 0,
174   BatteryCharge,
175   BatteryDischarge
176 } BATTERY_SET_INFORMATION_LEVEL;
177
178 #define MAX_BATTERY_STRING_SIZE           128
179
180 typedef struct _BATTERY_SET_INFORMATION {
181         ULONG  BatteryTag;
182         BATTERY_SET_INFORMATION_LEVEL  InformationLevel;
183         UCHAR  Buffer[1];
184 } BATTERY_SET_INFORMATION, *PBATTERY_SET_INFORMATION;
185
186 typedef struct _BATTERY_WAIT_STATUS {
187         ULONG  BatteryTag;
188         ULONG  Timeout;
189         ULONG  PowerState;
190         ULONG  LowCapacity;
191         ULONG  HighCapacity;
192 } BATTERY_WAIT_STATUS, *PBATTERY_WAIT_STATUS;
193
194
195 #define IOCTL_BATTERY_QUERY_TAG \
196   CTL_CODE(FILE_DEVICE_BATTERY, 0x10, METHOD_BUFFERED, FILE_READ_ACCESS)
197
198 #define IOCTL_BATTERY_QUERY_INFORMATION \
199   CTL_CODE(FILE_DEVICE_BATTERY, 0x11, METHOD_BUFFERED, FILE_READ_ACCESS)
200
201 #define IOCTL_BATTERY_SET_INFORMATION \
202   CTL_CODE(FILE_DEVICE_BATTERY, 0x12, METHOD_BUFFERED, FILE_WRITE_ACCESS)
203
204 #define IOCTL_BATTERY_QUERY_STATUS \
205   CTL_CODE(FILE_DEVICE_BATTERY, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS)
206
207
208 typedef NTSTATUS DDKAPI
209 (*BCLASS_DISABLE_STATUS_NOTIFY)(
210   /*IN*/ PVOID  Context);
211
212 typedef NTSTATUS DDKAPI
213 (*BCLASS_QUERY_INFORMATION)(
214   /*IN*/ PVOID  Context,
215   /*IN*/ ULONG  BatteryTag,
216   /*IN*/ BATTERY_QUERY_INFORMATION_LEVEL  Level,
217   /*IN*/ LONG  AtRate  /*OPTIONAL*/,
218   /*OUT*/ PVOID  Buffer,
219   /*IN*/ ULONG  BufferLength,
220   /*OUT*/ PULONG  ReturnedLength);
221
222 typedef NTSTATUS DDKAPI
223 (*BCLASS_QUERY_STATUS)(
224   /*IN*/ PVOID  Context,
225   /*IN*/ ULONG  BatteryTag,
226   /*OUT*/ PBATTERY_STATUS  BatteryStatus);
227
228 typedef NTSTATUS DDKAPI
229 (*BCLASS_QUERY_TAG)(
230   /*IN*/ PVOID  Context,
231   /*OUT*/ PULONG  BatteryTag);
232
233 typedef NTSTATUS DDKAPI
234 (*BCLASS_SET_INFORMATION)(
235   /*IN*/ PVOID  Context,
236   /*IN*/ ULONG  BatteryTag,
237   /*IN*/ BATTERY_SET_INFORMATION_LEVEL  Level,
238   /*IN*/ PVOID  Buffer  /*OPTIONAL*/);
239
240 typedef NTSTATUS DDKAPI
241 (*BCLASS_SET_STATUS_NOTIFY)(
242   /*IN*/ PVOID  Context,
243   /*IN*/ ULONG  BatteryTag,
244   /*IN*/ PBATTERY_NOTIFY  BatteryNotify);
245
246
247 typedef struct _BATTERY_MINIPORT_INFO {
248   USHORT  MajorVersion;
249   USHORT  MinorVersion;
250   PVOID  Context;
251   BCLASS_QUERY_TAG  QueryTag;
252   BCLASS_QUERY_INFORMATION  QueryInformation;
253   BCLASS_SET_INFORMATION  SetInformation;
254   BCLASS_QUERY_STATUS  QueryStatus;
255   BCLASS_SET_STATUS_NOTIFY  SetStatusNotify;
256   BCLASS_DISABLE_STATUS_NOTIFY  DisableStatusNotify;
257   PDEVICE_OBJECT  Pdo;
258   PUNICODE_STRING  DeviceName;
259 } BATTERY_MINIPORT_INFO, *PBATTERY_MINIPORT_INFO;
260
261 /* BATTERY_MINIPORT_INFO.XxxVersion */
262 #define BATTERY_CLASS_MAJOR_VERSION       0x0001
263 #define BATTERY_CLASS_MINOR_VERSION       0x0000
264
265
266 BCLASSAPI
267 NTSTATUS
268 DDKAPI
269 BatteryClassInitializeDevice(
270   /*IN*/ PBATTERY_MINIPORT_INFO  MiniportInfo,
271   /*IN*/ PVOID  *ClassData);
272
273 BCLASSAPI
274 NTSTATUS
275 DDKAPI
276 BatteryClassIoctl(
277   /*IN*/ PVOID  ClassData,
278   /*IN*/ PIRP  Irp);
279
280 BCLASSAPI
281 NTSTATUS
282 DDKAPI
283 BatteryClassQueryWmiDataBlock(
284   /*IN*/ PVOID  ClassData,
285   /*IN*/ PDEVICE_OBJECT  DeviceObject,
286   /*IN*/ PIRP  Irp,
287   /*IN*/ ULONG  GuidIndex,
288   /*IN OUT*/ PULONG  InstanceLengthArray,
289   /*IN*/ ULONG  OutBufferSize,
290   /*OUT*/ PUCHAR  Buffer);
291
292 BCLASSAPI
293 NTSTATUS
294 DDKAPI
295 BatteryClassStatusNotify(
296   /*IN*/ PVOID  ClassData);
297
298 BCLASSAPI
299 NTSTATUS
300 DDKAPI
301 BatteryClassSystemControl(
302   /*IN*/ PVOID  ClassData,
303   /*IN*/ PWMILIB_CONTEXT  WmiLibContext,
304   /*IN*/ PDEVICE_OBJECT  DeviceObject,
305   /*IN*/ PIRP  Irp,
306   /*OUT*/ PSYSCTL_IRP_DISPOSITION  Disposition);
307
308 BCLASSAPI
309 NTSTATUS
310 DDKAPI
311 BatteryClassUnload(
312   /*IN*/ PVOID  ClassData);
313
314 #ifdef __cplusplus
315 }
316 #endif
317
318 #endif /* __BATCLASS_H */