Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

439 lines
11 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. batclass.h
  5. Abstract:
  6. Defines battery class driver interfaces.
  7. Author:
  8. Ken Reneris (kenr) 02-Feb-1997
  9. Revision History:
  10. 7-10-98 split this file out of poclass.h (MHills)
  11. --*/
  12. //
  13. // Battery device GUID
  14. //
  15. DEFINE_GUID( GUID_DEVICE_BATTERY, 0x72631e54L, 0x78A4, 0x11d0, 0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a );
  16. DEFINE_GUID (BATTERY_STATUS_WMI_GUID,
  17. 0xfc4670d1, 0xebbf, 0x416e, 0x87, 0xce, 0x37, 0x4a, 0x4e, 0xbc, 0x11, 0x1a);
  18. DEFINE_GUID (BATTERY_RUNTIME_WMI_GUID,
  19. 0x535a3767, 0x1ac2, 0x49bc, 0xa0, 0x77, 0x3f, 0x7a, 0x02, 0xe4, 0x0a, 0xec);
  20. DEFINE_GUID (BATTERY_TEMPERATURE_WMI_GUID,
  21. 0x1a52a14d, 0xadce, 0x4a44, 0x9a, 0x3e, 0xc8, 0xd8, 0xf1, 0x5f, 0xf2, 0xc2);
  22. DEFINE_GUID (BATTERY_FULL_CHARGED_CAPACITY_WMI_GUID,
  23. 0x40b40565, 0x96f7, 0x4435, 0x86, 0x94, 0x97, 0xe0, 0xe4, 0x39, 0x59, 0x05);
  24. DEFINE_GUID (BATTERY_CYCLE_COUNT_WMI_GUID,
  25. 0xef98db24, 0x0014, 0x4c25, 0xa5, 0x0b, 0xc7, 0x24, 0xae, 0x5c, 0xd3, 0x71);
  26. DEFINE_GUID (BATTERY_STATIC_DATA_WMI_GUID,
  27. 0x05e1e463, 0xe4e2, 0x4ea9, 0x80, 0xcb, 0x9b, 0xd4, 0xb3, 0xca, 0x06, 0x55);
  28. DEFINE_GUID (BATTERY_STATUS_CHANGE_WMI_GUID,
  29. 0xcddfa0c3, 0x7c5b, 0x4e43, 0xa0, 0x34, 0x05, 0x9f, 0xa5, 0xb8, 0x43, 0x64);
  30. DEFINE_GUID (BATTERY_TAG_CHANGE_WMI_GUID,
  31. 0x5e1f6e19, 0x8786, 0x4d23, 0x94, 0xfc, 0x9e, 0x74, 0x6b, 0xd5, 0xd8, 0x88);
  32. #ifndef _BATCLASS_
  33. #define _BATCLASS_
  34. //
  35. // Battery driver interface
  36. //
  37. // IOCTL_BATTERY_QUERY_TAG
  38. // IOCTL_BATTERY_QUERY_INFORMATION
  39. // IOCTL_BATTERY_SET_INFORMATION
  40. // IOCTL_BATTERY_QUERY_STATUS
  41. //
  42. //
  43. // IOCTL_BATTERY_QUERY_TAG
  44. //
  45. #define IOCTL_BATTERY_QUERY_TAG \
  46. CTL_CODE(FILE_DEVICE_BATTERY, 0x10, METHOD_BUFFERED, FILE_READ_ACCESS)
  47. #define BATTERY_TAG_INVALID 0
  48. //
  49. // IOCTL_BATTERY_QUERY_INFORMATION
  50. //
  51. #define IOCTL_BATTERY_QUERY_INFORMATION \
  52. CTL_CODE(FILE_DEVICE_BATTERY, 0x11, METHOD_BUFFERED, FILE_READ_ACCESS)
  53. typedef enum {
  54. BatteryInformation,
  55. BatteryGranularityInformation,
  56. BatteryTemperature,
  57. BatteryEstimatedTime,
  58. BatteryDeviceName,
  59. BatteryManufactureDate,
  60. BatteryManufactureName,
  61. BatteryUniqueID,
  62. BatterySerialNumber
  63. } BATTERY_QUERY_INFORMATION_LEVEL;
  64. typedef struct _BATTERY_QUERY_INFORMATION {
  65. ULONG BatteryTag;
  66. BATTERY_QUERY_INFORMATION_LEVEL InformationLevel;
  67. LONG AtRate;
  68. } BATTERY_QUERY_INFORMATION, *PBATTERY_QUERY_INFORMATION;
  69. //
  70. // Format of data returned when
  71. // BATTERY_INFORMATION_LEVEL = BatteryInformation
  72. //
  73. typedef struct _BATTERY_INFORMATION {
  74. ULONG Capabilities;
  75. UCHAR Technology;
  76. UCHAR Reserved[3];
  77. UCHAR Chemistry[4];
  78. ULONG DesignedCapacity;
  79. ULONG FullChargedCapacity;
  80. ULONG DefaultAlert1;
  81. ULONG DefaultAlert2;
  82. ULONG CriticalBias;
  83. ULONG CycleCount;
  84. } BATTERY_INFORMATION, *PBATTERY_INFORMATION;
  85. //
  86. // BATTERY_INFORMATION.Capabilities flags
  87. //
  88. #define BATTERY_SYSTEM_BATTERY 0x80000000
  89. #define BATTERY_CAPACITY_RELATIVE 0x40000000
  90. #define BATTERY_IS_SHORT_TERM 0x20000000
  91. #define BATTERY_SET_CHARGE_SUPPORTED 0x00000001
  92. #define BATTERY_SET_DISCHARGE_SUPPORTED 0x00000002
  93. #define BATTERY_SET_RESUME_SUPPORTED 0x00000004
  94. //
  95. // BATTERY_INFORMATION.XXXCapacity constants
  96. //
  97. #define BATTERY_UNKNOWN_CAPACITY 0xFFFFFFFF
  98. //
  99. // BatteryEstimatedTime constant
  100. //
  101. #define BATTERY_UNKNOWN_TIME 0xFFFFFFFF
  102. //
  103. // Max battery driver BATTERY_QUERY_INFORMATION_LEVEL string storage
  104. // size in bytes.
  105. //
  106. #define MAX_BATTERY_STRING_SIZE 128
  107. //
  108. // Struct for accessing the packed date format in BatteryManufactureDate.
  109. //
  110. typedef struct _BATTERY_MANUFACTURE_DATE
  111. {
  112. UCHAR Day;
  113. UCHAR Month;
  114. USHORT Year;
  115. } BATTERY_MANUFACTURE_DATE, *PBATTERY_MANUFACTURE_DATE;
  116. //
  117. // IOCTL_BATTERY_SET_INFORMATION
  118. //
  119. #define IOCTL_BATTERY_SET_INFORMATION \
  120. CTL_CODE(FILE_DEVICE_BATTERY, 0x12, METHOD_BUFFERED, FILE_WRITE_ACCESS)
  121. typedef enum {
  122. BatteryCriticalBias,
  123. BatteryCharge,
  124. BatteryDischarge
  125. } BATTERY_SET_INFORMATION_LEVEL;
  126. typedef struct _BATTERY_SET_INFORMATION {
  127. ULONG BatteryTag;
  128. BATTERY_SET_INFORMATION_LEVEL InformationLevel;
  129. UCHAR Buffer[1];
  130. } BATTERY_SET_INFORMATION, *PBATTERY_SET_INFORMATION;
  131. //
  132. // IOCTL_BATTERY_QUERY_STATUS
  133. //
  134. #define IOCTL_BATTERY_QUERY_STATUS \
  135. CTL_CODE(FILE_DEVICE_BATTERY, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS)
  136. //
  137. // Structure of input buffer to IOCTL_BATTERY_QUERY_STATUS
  138. //
  139. typedef struct _BATTERY_WAIT_STATUS {
  140. ULONG BatteryTag;
  141. ULONG Timeout;
  142. ULONG PowerState;
  143. ULONG LowCapacity;
  144. ULONG HighCapacity;
  145. } BATTERY_WAIT_STATUS, *PBATTERY_WAIT_STATUS;
  146. //
  147. // Structure of output buffer from IOCTL_BATTERY_QUERY_STATUS
  148. //
  149. typedef struct _BATTERY_STATUS {
  150. ULONG PowerState;
  151. ULONG Capacity;
  152. ULONG Voltage;
  153. LONG Rate;
  154. } BATTERY_STATUS, *PBATTERY_STATUS;
  155. //
  156. // BATTERY_STATUS.PowerState flags
  157. //
  158. #define BATTERY_POWER_ON_LINE 0x00000001
  159. #define BATTERY_DISCHARGING 0x00000002
  160. #define BATTERY_CHARGING 0x00000004
  161. #define BATTERY_CRITICAL 0x00000008
  162. //
  163. // BATTERY_STATUS Constant
  164. // BATTERY_UNKNOWN_CAPACITY defined above for IOCTL_BATTERY_QUERY_INFORMATION
  165. //
  166. #define BATTERY_UNKNOWN_VOLTAGE 0xFFFFFFFF
  167. #define BATTERY_UNKNOWN_RATE 0x80000000
  168. #ifndef _WINDOWS_
  169. //
  170. // Battery Class-Miniport device driver interfaces
  171. //
  172. typedef
  173. NTSTATUS
  174. (*BCLASS_QUERY_TAG)(
  175. IN PVOID Context,
  176. OUT PULONG BatteryTag
  177. );
  178. typedef
  179. NTSTATUS
  180. (*BCLASS_QUERY_INFORMATION)(
  181. IN PVOID Context,
  182. IN ULONG BatteryTag,
  183. IN BATTERY_QUERY_INFORMATION_LEVEL Level,
  184. IN LONG AtRate OPTIONAL,
  185. OUT PVOID Buffer,
  186. IN ULONG BufferLength,
  187. OUT PULONG ReturnedLength
  188. );
  189. typedef
  190. NTSTATUS
  191. (*BCLASS_QUERY_STATUS)(
  192. IN PVOID Context,
  193. IN ULONG BatteryTag,
  194. OUT PBATTERY_STATUS BatteryStatus
  195. );
  196. typedef struct {
  197. ULONG PowerState;
  198. ULONG LowCapacity;
  199. ULONG HighCapacity;
  200. } BATTERY_NOTIFY, *PBATTERY_NOTIFY;
  201. typedef
  202. NTSTATUS
  203. (*BCLASS_SET_STATUS_NOTIFY)(
  204. IN PVOID Context,
  205. IN ULONG BatteryTag,
  206. IN PBATTERY_NOTIFY BatteryNotify
  207. );
  208. typedef
  209. NTSTATUS
  210. (*BCLASS_SET_INFORMATION)(
  211. IN PVOID Context,
  212. IN ULONG BatteryTag,
  213. IN BATTERY_SET_INFORMATION_LEVEL Level,
  214. IN PVOID Buffer OPTIONAL
  215. );
  216. typedef
  217. NTSTATUS
  218. (*BCLASS_DISABLE_STATUS_NOTIFY)(
  219. IN PVOID Context
  220. );
  221. typedef struct {
  222. USHORT MajorVersion;
  223. USHORT MinorVersion;
  224. PVOID Context; // Miniport 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. #define BATTERY_CLASS_MAJOR_VERSION 0x0001
  235. #define BATTERY_CLASS_MINOR_VERSION 0x0000
  236. //
  237. // WMI data block structures
  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. typedef struct _BATTERY_WMI_RUNTIME
  251. {
  252. ULONG Tag;
  253. ULONG EstimatedRuntime;
  254. } BATTERY_WMI_RUNTIME, *PBATTERY_WMI_RUNTIME;
  255. typedef struct _BATTERY_WMI_TEMPERATURE
  256. {
  257. ULONG Tag;
  258. ULONG Temperature;
  259. } BATTERY_WMI_TEMPERATURE, *PBATTERY_WMI_TEMPERATURE;
  260. typedef struct _BATTERY_WMI_FULL_CHARGED_CAPACITY
  261. {
  262. ULONG Tag;
  263. ULONG FullChargedCapacity;
  264. } BATTERY_WMI_FULL_CHARGED_CAPACITY, *PBATTERY_WMI_FULL_CHARGED_CAPACITY;
  265. typedef struct _BATTERY_WMI_CYCLE_COUNT
  266. {
  267. ULONG Tag;
  268. ULONG CycleCount;
  269. } BATTERY_WMI_CYCLE_COUNT, *PBATTERY_WMI_CYCLE_COUNT;
  270. typedef struct _BATTERY_WMI_STATIC_DATA
  271. {
  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. // Four variable length string values are stored with the first USHORT
  284. // value containing the length of the string in bytes.
  285. //
  286. // Device Name
  287. // Manufacture Name
  288. // Serial Number
  289. // UniqueID
  290. //
  291. } BATTERY_WMI_STATIC_DATA, *PBATTERY_WMI_STATIC_DATA;
  292. typedef struct _BATTERY_WMI_STATUS_CHANGE
  293. {
  294. ULONG Tag;
  295. BOOLEAN PowerOnline;
  296. BOOLEAN Charging;
  297. BOOLEAN Discharging;
  298. BOOLEAN Critical;
  299. } BATTERY_WMI_STATUS_CHANGE, *PBATTERY_WMI_STATUS_CHANGE;
  300. typedef struct _BATTERY_TAG_CHANGE
  301. {
  302. ULONG Tag;
  303. } BATTERY_TAG_CHANGE, *PBATTERY_TAG_CHANGE;
  304. //
  305. // Battery class driver functions
  306. //
  307. #if !defined(BATTERYCLASS)
  308. #define BATTERYCLASSAPI DECLSPEC_IMPORT
  309. #else
  310. #define BATTERYCLASSAPI
  311. #endif
  312. NTSTATUS
  313. BATTERYCLASSAPI
  314. BatteryClassInitializeDevice (
  315. IN PBATTERY_MINIPORT_INFO MiniportInfo,
  316. IN PVOID *ClassData
  317. );
  318. NTSTATUS
  319. BATTERYCLASSAPI
  320. BatteryClassUnload (
  321. IN PVOID ClassData
  322. );
  323. NTSTATUS
  324. BATTERYCLASSAPI
  325. BatteryClassIoctl (
  326. IN PVOID ClassData,
  327. IN PIRP Irp
  328. );
  329. NTSTATUS
  330. BATTERYCLASSAPI
  331. BatteryClassSystemControl (
  332. IN PVOID ClassData,
  333. IN PVOID WmiLibContext, //PWMILIB_CONTEXT
  334. IN PDEVICE_OBJECT DeviceObject,
  335. IN PIRP Irp,
  336. OUT PVOID Disposition //PSYSCTL_IRP_DISPOSITION
  337. );
  338. NTSTATUS
  339. BATTERYCLASSAPI
  340. BatteryClassQueryWmiDataBlock(
  341. IN PVOID ClassData,
  342. IN PDEVICE_OBJECT DeviceObject,
  343. IN PIRP Irp,
  344. IN ULONG GuidIndex,
  345. IN OUT PULONG InstanceLengthArray,
  346. IN ULONG OutBufferSize,
  347. OUT PUCHAR Buffer
  348. );
  349. NTSTATUS
  350. BATTERYCLASSAPI
  351. BatteryClassStatusNotify (
  352. IN PVOID ClassData
  353. );
  354. #endif // _WINDOWS_
  355. #endif // _BATCLASS_