Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
batclass.h
00001 /* 00002 * batclass.h 00003 * 00004 * Battery class driver interface 00005 * 00006 * This file is part of the w32api package. 00007 * 00008 * Contributors: 00009 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net> 00010 * 00011 * THIS SOFTWARE IS NOT COPYRIGHTED 00012 * 00013 * This source code is offered for use in the public domain. You may 00014 * use, modify or distribute it freely. 00015 * 00016 * This code is distributed in the hope that it will be useful but 00017 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 00018 * DISCLAIMED. This includes but is not limited to warranties of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00020 * 00021 */ 00022 00023 #ifndef __BATCLASS_H 00024 #define __BATCLASS_H 00025 00026 #if __GNUC__ >=3 00027 #pragma GCC system_header 00028 #endif 00029 00030 #ifdef __cplusplus 00031 extern "C" { 00032 #endif 00033 00034 #include "ntddk.h" 00035 00036 #if defined(_BATTERYCLASS_) 00037 #define BCLASSAPI DECLSPEC_EXPORT 00038 #else 00039 #define BCLASSAPI DECLSPEC_IMPORT 00040 #endif 00041 00042 00043 /* Battery device GUIDs */ 00044 00045 DEFINE_GUID(GUID_DEVICE_BATTERY, 00046 0x72631e54L, 0x78A4, 0x11d0, 0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a); 00047 00048 DEFINE_GUID(BATTERY_STATUS_WMI_GUID, 00049 0xfc4670d1, 0xebbf, 0x416e, 0x87, 0xce, 0x37, 0x4a, 0x4e, 0xbc, 0x11, 0x1a); 00050 00051 DEFINE_GUID(BATTERY_RUNTIME_WMI_GUID, 00052 0x535a3767, 0x1ac2, 0x49bc, 0xa0, 0x77, 0x3f, 0x7a, 0x02, 0xe4, 0x0a, 0xec); 00053 00054 DEFINE_GUID(BATTERY_TEMPERATURE_WMI_GUID, 00055 0x1a52a14d, 0xadce, 0x4a44, 0x9a, 0x3e, 0xc8, 0xd8, 0xf1, 0x5f, 0xf2, 0xc2); 00056 00057 DEFINE_GUID(BATTERY_FULL_CHARGED_CAPACITY_WMI_GUID, 00058 0x40b40565, 0x96f7, 0x4435, 0x86, 0x94, 0x97, 0xe0, 0xe4, 0x39, 0x59, 0x05); 00059 00060 DEFINE_GUID(BATTERY_CYCLE_COUNT_WMI_GUID, 00061 0xef98db24, 0x0014, 0x4c25, 0xa5, 0x0b, 0xc7, 0x24, 0xae, 0x5c, 0xd3, 0x71); 00062 00063 DEFINE_GUID(BATTERY_STATIC_DATA_WMI_GUID, 00064 0x05e1e463, 0xe4e2, 0x4ea9, 0x80, 0xcb, 0x9b, 0xd4, 0xb3, 0xca, 0x06, 0x55); 00065 00066 DEFINE_GUID(BATTERY_STATUS_CHANGE_WMI_GUID, 00067 0xcddfa0c3, 0x7c5b, 0x4e43, 0xa0, 0x34, 0x05, 0x9f, 0xa5, 0xb8, 0x43, 0x64); 00068 00069 DEFINE_GUID(BATTERY_TAG_CHANGE_WMI_GUID, 00070 0x5e1f6e19, 0x8786, 0x4d23, 0x94, 0xfc, 0x9e, 0x74, 0x6b, 0xd5, 0xd8, 0x88); 00071 00072 00073 /* BATTERY_INFORMATION.Capabilities constants */ 00074 #define BATTERY_SET_CHARGE_SUPPORTED 0x00000001 00075 #define BATTERY_SET_DISCHARGE_SUPPORTED 0x00000002 00076 #define BATTERY_SET_RESUME_SUPPORTED 0x00000004 00077 #define BATTERY_IS_SHORT_TERM 0x20000000 00078 #define BATTERY_CAPACITY_RELATIVE 0x40000000 00079 #define BATTERY_SYSTEM_BATTERY 0x80000000 00080 00081 typedef struct _BATTERY_INFORMATION { 00082 ULONG Capabilities; 00083 UCHAR Technology; 00084 UCHAR Reserved[3]; 00085 UCHAR Chemistry[4]; 00086 ULONG DesignedCapacity; 00087 ULONG FullChargedCapacity; 00088 ULONG DefaultAlert1; 00089 ULONG DefaultAlert2; 00090 ULONG CriticalBias; 00091 ULONG CycleCount; 00092 } BATTERY_INFORMATION, *PBATTERY_INFORMATION; 00093 00094 typedef struct _BATTERY_MANUFACTURE_DATE { 00095 UCHAR Day; 00096 UCHAR Month; 00097 USHORT Year; 00098 } BATTERY_MANUFACTURE_DATE, *PBATTERY_MANUFACTURE_DATE; 00099 00100 typedef struct _BATTERY_NOTIFY { 00101 ULONG PowerState; 00102 ULONG LowCapacity; 00103 ULONG HighCapacity; 00104 } BATTERY_NOTIFY, *PBATTERY_NOTIFY; 00105 00106 /* BATTERY_STATUS.PowerState flags */ 00107 #define BATTERY_POWER_ON_LINE 0x00000001 00108 #define BATTERY_DISCHARGING 0x00000002 00109 #define BATTERY_CHARGING 0x00000004 00110 #define BATTERY_CRITICAL 0x00000008 00111 00112 /* BATTERY_STATUS.Voltage constant */ 00113 #define BATTERY_UNKNOWN_VOLTAGE 0xFFFFFFFF 00114 00115 /* BATTERY_STATUS.Rate constant */ 00116 #define BATTERY_UNKNOWN_RATE 0x80000000 00117 00118 typedef struct _BATTERY_STATUS { 00119 ULONG PowerState; 00120 ULONG Capacity; 00121 ULONG Voltage; 00122 LONG Rate; 00123 } BATTERY_STATUS, *PBATTERY_STATUS; 00124 00125 /* BATTERY_INFORMATION.Capacity constants */ 00126 #define BATTERY_UNKNOWN_CAPACITY 0xFFFFFFFF 00127 00128 typedef enum _BATTERY_QUERY_INFORMATION_LEVEL { 00129 BatteryInformation = 0, 00130 BatteryGranularityInformation, 00131 BatteryTemperature, 00132 BatteryEstimatedTime, 00133 BatteryDeviceName, 00134 BatteryManufactureDate, 00135 BatteryManufactureName, 00136 BatteryUniqueID, 00137 BatterySerialNumber 00138 } BATTERY_QUERY_INFORMATION_LEVEL; 00139 00140 /* BatteryEstimatedTime constant */ 00141 #define BATTERY_UNKNOWN_TIME 0x80000000 00142 00143 /* NTSTATUS possibly returned by BCLASS_QUERY_STATUS */ 00144 #define BATTERY_TAG_INVALID 0 00145 00146 typedef struct _BATTERY_QUERY_INFORMATION { 00147 ULONG BatteryTag; 00148 BATTERY_QUERY_INFORMATION_LEVEL InformationLevel; 00149 LONG AtRate; 00150 } BATTERY_QUERY_INFORMATION, *PBATTERY_QUERY_INFORMATION; 00151 00152 typedef enum _BATTERY_SET_INFORMATION_LEVEL { 00153 BatteryCriticalBias = 0, 00154 BatteryCharge, 00155 BatteryDischarge 00156 } BATTERY_SET_INFORMATION_LEVEL; 00157 00158 #define MAX_BATTERY_STRING_SIZE 128 00159 00160 typedef struct _BATTERY_SET_INFORMATION { 00161 ULONG BatteryTag; 00162 BATTERY_SET_INFORMATION_LEVEL InformationLevel; 00163 UCHAR Buffer[1]; 00164 } BATTERY_SET_INFORMATION, *PBATTERY_SET_INFORMATION; 00165 00166 typedef struct _BATTERY_WAIT_STATUS { 00167 ULONG BatteryTag; 00168 ULONG Timeout; 00169 ULONG PowerState; 00170 ULONG LowCapacity; 00171 ULONG HighCapacity; 00172 } BATTERY_WAIT_STATUS, *PBATTERY_WAIT_STATUS; 00173 00174 00175 #define IOCTL_BATTERY_QUERY_TAG \ 00176 CTL_CODE(FILE_DEVICE_BATTERY, 0x10, METHOD_BUFFERED, FILE_READ_ACCESS) 00177 00178 #define IOCTL_BATTERY_QUERY_INFORMATION \ 00179 CTL_CODE(FILE_DEVICE_BATTERY, 0x11, METHOD_BUFFERED, FILE_READ_ACCESS) 00180 00181 #define IOCTL_BATTERY_SET_INFORMATION \ 00182 CTL_CODE(FILE_DEVICE_BATTERY, 0x12, METHOD_BUFFERED, FILE_WRITE_ACCESS) 00183 00184 #define IOCTL_BATTERY_QUERY_STATUS \ 00185 CTL_CODE(FILE_DEVICE_BATTERY, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS) 00186 00187 00188 typedef NTSTATUS DDKAPI 00189 (*BCLASS_DISABLE_STATUS_NOTIFY)( 00190 /*IN*/ PVOID Context); 00191 00192 typedef NTSTATUS DDKAPI 00193 (*BCLASS_QUERY_INFORMATION)( 00194 /*IN*/ PVOID Context, 00195 /*IN*/ ULONG BatteryTag, 00196 /*IN*/ BATTERY_QUERY_INFORMATION_LEVEL Level, 00197 /*IN*/ LONG AtRate /*OPTIONAL*/, 00198 /*OUT*/ PVOID Buffer, 00199 /*IN*/ ULONG BufferLength, 00200 /*OUT*/ PULONG ReturnedLength); 00201 00202 typedef NTSTATUS DDKAPI 00203 (*BCLASS_QUERY_STATUS)( 00204 /*IN*/ PVOID Context, 00205 /*IN*/ ULONG BatteryTag, 00206 /*OUT*/ PBATTERY_STATUS BatteryStatus); 00207 00208 typedef NTSTATUS DDKAPI 00209 (*BCLASS_QUERY_TAG)( 00210 /*IN*/ PVOID Context, 00211 /*OUT*/ PULONG BatteryTag); 00212 00213 typedef NTSTATUS DDKAPI 00214 (*BCLASS_SET_INFORMATION)( 00215 /*IN*/ PVOID Context, 00216 /*IN*/ ULONG BatteryTag, 00217 /*IN*/ BATTERY_SET_INFORMATION_LEVEL Level, 00218 /*IN*/ PVOID Buffer /*OPTIONAL*/); 00219 00220 typedef NTSTATUS DDKAPI 00221 (*BCLASS_SET_STATUS_NOTIFY)( 00222 /*IN*/ PVOID Context, 00223 /*IN*/ ULONG BatteryTag, 00224 /*IN*/ PBATTERY_NOTIFY BatteryNotify); 00225 00226 00227 typedef struct _BATTERY_MINIPORT_INFO { 00228 USHORT MajorVersion; 00229 USHORT MinorVersion; 00230 PVOID Context; 00231 BCLASS_QUERY_TAG QueryTag; 00232 BCLASS_QUERY_INFORMATION QueryInformation; 00233 BCLASS_SET_INFORMATION SetInformation; 00234 BCLASS_QUERY_STATUS QueryStatus; 00235 BCLASS_SET_STATUS_NOTIFY SetStatusNotify; 00236 BCLASS_DISABLE_STATUS_NOTIFY DisableStatusNotify; 00237 PDEVICE_OBJECT Pdo; 00238 PUNICODE_STRING DeviceName; 00239 } BATTERY_MINIPORT_INFO, *PBATTERY_MINIPORT_INFO; 00240 00241 /* BATTERY_MINIPORT_INFO.XxxVersion */ 00242 #define BATTERY_CLASS_MAJOR_VERSION 0x0001 00243 #define BATTERY_CLASS_MINOR_VERSION 0x0000 00244 00245 00246 BCLASSAPI 00247 NTSTATUS 00248 DDKAPI 00249 BatteryClassInitializeDevice( 00250 /*IN*/ PBATTERY_MINIPORT_INFO MiniportInfo, 00251 /*IN*/ PVOID *ClassData); 00252 00253 BCLASSAPI 00254 NTSTATUS 00255 DDKAPI 00256 BatteryClassIoctl( 00257 /*IN*/ PVOID ClassData, 00258 /*IN*/ PIRP Irp); 00259 00260 BCLASSAPI 00261 NTSTATUS 00262 DDKAPI 00263 BatteryClassQueryWmiDataBlock( 00264 /*IN*/ PVOID ClassData, 00265 /*IN*/ PDEVICE_OBJECT DeviceObject, 00266 /*IN*/ PIRP Irp, 00267 /*IN*/ ULONG GuidIndex, 00268 /*IN OUT*/ PULONG InstanceLengthArray, 00269 /*IN*/ ULONG OutBufferSize, 00270 /*OUT*/ PUCHAR Buffer); 00271 00272 BCLASSAPI 00273 NTSTATUS 00274 DDKAPI 00275 BatteryClassStatusNotify( 00276 /*IN*/ PVOID ClassData); 00277 00278 BCLASSAPI 00279 NTSTATUS 00280 DDKAPI 00281 BatteryClassSystemControl( 00282 /*IN*/ PVOID ClassData, 00283 /*IN*/ PWMILIB_CONTEXT WmiLibContext, 00284 /*IN*/ PDEVICE_OBJECT DeviceObject, 00285 /*IN*/ PIRP Irp, 00286 /*OUT*/ PSYSCTL_IRP_DISPOSITION Disposition); 00287 00288 BCLASSAPI 00289 NTSTATUS 00290 DDKAPI 00291 BatteryClassUnload( 00292 /*IN*/ PVOID ClassData); 00293 00294 #ifdef __cplusplus 00295 } 00296 #endif 00297 00298 #endif /* __BATCLASS_H */
Generated on Tue Jul 12 2022 19:59:53 by
