4 * Battery class driver interface
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
36 #if defined(_BATTERYCLASS_)
37 #define BCLASSAPI DECLSPEC_EXPORT
39 #define BCLASSAPI DECLSPEC_IMPORT
43 /* Battery device GUIDs */
45 DEFINE_GUID(GUID_DEVICE_BATTERY
,
46 0x72631e54L
, 0x78A4, 0x11d0, 0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a);
48 DEFINE_GUID(BATTERY_STATUS_WMI_GUID
,
49 0xfc4670d1, 0xebbf, 0x416e, 0x87, 0xce, 0x37, 0x4a, 0x4e, 0xbc, 0x11, 0x1a);
51 DEFINE_GUID(BATTERY_RUNTIME_WMI_GUID
,
52 0x535a3767, 0x1ac2, 0x49bc, 0xa0, 0x77, 0x3f, 0x7a, 0x02, 0xe4, 0x0a, 0xec);
54 DEFINE_GUID(BATTERY_TEMPERATURE_WMI_GUID
,
55 0x1a52a14d, 0xadce, 0x4a44, 0x9a, 0x3e, 0xc8, 0xd8, 0xf1, 0x5f, 0xf2, 0xc2);
57 DEFINE_GUID(BATTERY_FULL_CHARGED_CAPACITY_WMI_GUID
,
58 0x40b40565, 0x96f7, 0x4435, 0x86, 0x94, 0x97, 0xe0, 0xe4, 0x39, 0x59, 0x05);
60 DEFINE_GUID(BATTERY_CYCLE_COUNT_WMI_GUID
,
61 0xef98db24, 0x0014, 0x4c25, 0xa5, 0x0b, 0xc7, 0x24, 0xae, 0x5c, 0xd3, 0x71);
63 DEFINE_GUID(BATTERY_STATIC_DATA_WMI_GUID
,
64 0x05e1e463, 0xe4e2, 0x4ea9, 0x80, 0xcb, 0x9b, 0xd4, 0xb3, 0xca, 0x06, 0x55);
66 DEFINE_GUID(BATTERY_STATUS_CHANGE_WMI_GUID
,
67 0xcddfa0c3, 0x7c5b, 0x4e43, 0xa0, 0x34, 0x05, 0x9f, 0xa5, 0xb8, 0x43, 0x64);
69 DEFINE_GUID(BATTERY_TAG_CHANGE_WMI_GUID
,
70 0x5e1f6e19, 0x8786, 0x4d23, 0x94, 0xfc, 0x9e, 0x74, 0x6b, 0xd5, 0xd8, 0x88);
73 /* BATTERY_INFORMATION.Capabilities constants */
74 #define BATTERY_SET_CHARGE_SUPPORTED 0x00000001
75 #define BATTERY_SET_DISCHARGE_SUPPORTED 0x00000002
76 #define BATTERY_SET_RESUME_SUPPORTED 0x00000004
77 #define BATTERY_IS_SHORT_TERM 0x20000000
78 #define BATTERY_CAPACITY_RELATIVE 0x40000000
79 #define BATTERY_SYSTEM_BATTERY 0x80000000
81 typedef struct _BATTERY_INFORMATION
{
86 ULONG DesignedCapacity
;
87 ULONG FullChargedCapacity
;
92 } BATTERY_INFORMATION
, *PBATTERY_INFORMATION
;
94 typedef struct _BATTERY_MANUFACTURE_DATE
{
98 } BATTERY_MANUFACTURE_DATE
, *PBATTERY_MANUFACTURE_DATE
;
100 typedef struct _BATTERY_NOTIFY
{
104 } BATTERY_NOTIFY
, *PBATTERY_NOTIFY
;
106 /* BATTERY_STATUS.PowerState flags */
107 #define BATTERY_POWER_ON_LINE 0x00000001
108 #define BATTERY_DISCHARGING 0x00000002
109 #define BATTERY_CHARGING 0x00000004
110 #define BATTERY_CRITICAL 0x00000008
112 /* BATTERY_STATUS.Voltage constant */
113 #define BATTERY_UNKNOWN_VOLTAGE 0xFFFFFFFF
115 /* BATTERY_STATUS.Rate constant */
116 #define BATTERY_UNKNOWN_RATE 0x80000000
118 typedef struct _BATTERY_STATUS
{
123 } BATTERY_STATUS
, *PBATTERY_STATUS
;
125 /* BATTERY_INFORMATION.Capacity constants */
126 #define BATTERY_UNKNOWN_CAPACITY 0xFFFFFFFF
128 typedef enum _BATTERY_QUERY_INFORMATION_LEVEL
{
129 BatteryInformation
= 0,
130 BatteryGranularityInformation
,
132 BatteryEstimatedTime
,
134 BatteryManufactureDate
,
135 BatteryManufactureName
,
138 } BATTERY_QUERY_INFORMATION_LEVEL
;
140 /* BatteryEstimatedTime constant */
141 #define BATTERY_UNKNOWN_TIME 0x80000000
143 /* NTSTATUS possibly returned by BCLASS_QUERY_STATUS */
144 #define BATTERY_TAG_INVALID 0
146 typedef struct _BATTERY_QUERY_INFORMATION
{
148 BATTERY_QUERY_INFORMATION_LEVEL InformationLevel
;
150 } BATTERY_QUERY_INFORMATION
, *PBATTERY_QUERY_INFORMATION
;
152 typedef enum _BATTERY_SET_INFORMATION_LEVEL
{
153 BatteryCriticalBias
= 0,
156 } BATTERY_SET_INFORMATION_LEVEL
;
158 #define MAX_BATTERY_STRING_SIZE 128
160 typedef struct _BATTERY_SET_INFORMATION
{
162 BATTERY_SET_INFORMATION_LEVEL InformationLevel
;
164 } BATTERY_SET_INFORMATION
, *PBATTERY_SET_INFORMATION
;
166 typedef struct _BATTERY_WAIT_STATUS
{
172 } BATTERY_WAIT_STATUS
, *PBATTERY_WAIT_STATUS
;
175 #define IOCTL_BATTERY_QUERY_TAG \
176 CTL_CODE(FILE_DEVICE_BATTERY, 0x10, METHOD_BUFFERED, FILE_READ_ACCESS)
178 #define IOCTL_BATTERY_QUERY_INFORMATION \
179 CTL_CODE(FILE_DEVICE_BATTERY, 0x11, METHOD_BUFFERED, FILE_READ_ACCESS)
181 #define IOCTL_BATTERY_SET_INFORMATION \
182 CTL_CODE(FILE_DEVICE_BATTERY, 0x12, METHOD_BUFFERED, FILE_WRITE_ACCESS)
184 #define IOCTL_BATTERY_QUERY_STATUS \
185 CTL_CODE(FILE_DEVICE_BATTERY, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS)
188 typedef NTSTATUS DDKAPI
189 (*BCLASS_DISABLE_STATUS_NOTIFY
)(
190 /*IN*/ PVOID Context
);
192 typedef NTSTATUS DDKAPI
193 (*BCLASS_QUERY_INFORMATION
)(
194 /*IN*/ PVOID Context
,
195 /*IN*/ ULONG BatteryTag
,
196 /*IN*/ BATTERY_QUERY_INFORMATION_LEVEL Level
,
197 /*IN*/ LONG AtRate
/*OPTIONAL*/,
198 /*OUT*/ PVOID Buffer
,
199 /*IN*/ ULONG BufferLength
,
200 /*OUT*/ PULONG ReturnedLength
);
202 typedef NTSTATUS DDKAPI
203 (*BCLASS_QUERY_STATUS
)(
204 /*IN*/ PVOID Context
,
205 /*IN*/ ULONG BatteryTag
,
206 /*OUT*/ PBATTERY_STATUS BatteryStatus
);
208 typedef NTSTATUS DDKAPI
210 /*IN*/ PVOID Context
,
211 /*OUT*/ PULONG BatteryTag
);
213 typedef NTSTATUS DDKAPI
214 (*BCLASS_SET_INFORMATION
)(
215 /*IN*/ PVOID Context
,
216 /*IN*/ ULONG BatteryTag
,
217 /*IN*/ BATTERY_SET_INFORMATION_LEVEL Level
,
218 /*IN*/ PVOID Buffer
/*OPTIONAL*/);
220 typedef NTSTATUS DDKAPI
221 (*BCLASS_SET_STATUS_NOTIFY
)(
222 /*IN*/ PVOID Context
,
223 /*IN*/ ULONG BatteryTag
,
224 /*IN*/ PBATTERY_NOTIFY BatteryNotify
);
227 typedef struct _BATTERY_MINIPORT_INFO
{
231 BCLASS_QUERY_TAG QueryTag
;
232 BCLASS_QUERY_INFORMATION QueryInformation
;
233 BCLASS_SET_INFORMATION SetInformation
;
234 BCLASS_QUERY_STATUS QueryStatus
;
235 BCLASS_SET_STATUS_NOTIFY SetStatusNotify
;
236 BCLASS_DISABLE_STATUS_NOTIFY DisableStatusNotify
;
238 PUNICODE_STRING DeviceName
;
239 } BATTERY_MINIPORT_INFO
, *PBATTERY_MINIPORT_INFO
;
241 /* BATTERY_MINIPORT_INFO.XxxVersion */
242 #define BATTERY_CLASS_MAJOR_VERSION 0x0001
243 #define BATTERY_CLASS_MINOR_VERSION 0x0000
249 BatteryClassInitializeDevice(
250 /*IN*/ PBATTERY_MINIPORT_INFO MiniportInfo
,
251 /*IN*/ PVOID
*ClassData
);
257 /*IN*/ PVOID ClassData
,
263 BatteryClassQueryWmiDataBlock(
264 /*IN*/ PVOID ClassData
,
265 /*IN*/ PDEVICE_OBJECT DeviceObject
,
267 /*IN*/ ULONG GuidIndex
,
268 /*IN OUT*/ PULONG InstanceLengthArray
,
269 /*IN*/ ULONG OutBufferSize
,
270 /*OUT*/ PUCHAR Buffer
);
275 BatteryClassStatusNotify(
276 /*IN*/ PVOID ClassData
);
281 BatteryClassSystemControl(
282 /*IN*/ PVOID ClassData
,
283 /*IN*/ PWMILIB_CONTEXT WmiLibContext
,
284 /*IN*/ PDEVICE_OBJECT DeviceObject
,
286 /*OUT*/ PSYSCTL_IRP_DISPOSITION Disposition
);
292 /*IN*/ PVOID ClassData
);
298 #endif /* __BATCLASS_H */