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.

123 lines
4.3 KiB

  1. #ifndef _CBATTERY_H
  2. #define _CBATTERY_H
  3. /*
  4. * title: cbattery.h
  5. *
  6. * purpose: header for wdm kernel battery object
  7. *
  8. */
  9. // HID USAGE PAGE NUMBERS
  10. #define POWER_PAGE 0x84
  11. #define BATTERY_PAGE 0x85
  12. // HID USAGE NUMBERS (Power Page)
  13. #define PRESENT_STATUS_ID 0x02
  14. #define UPS_ID 0x04
  15. #define POWER_SUMMARY_ID 0x24
  16. #define VOLTAGE_ID 0x30
  17. #define CURRENT_ID 0x31
  18. #define CONFIG_VOLTAGE_ID 0x40
  19. #define CONFIG_CURRENT_ID 0x41
  20. #define DELAY_BEFORE_SHUTDOWN_ID 0x57
  21. #define SHUTDOWN_IMMINENT_ID 0x69
  22. #define MANUFACTURER_ID 0xfd
  23. #define PRODUCT_ID 0xfe
  24. #define SERIAL_NUMBER_ID 0xff
  25. // HID USAGE NUMBERS (Battery Page)
  26. #define REMAINING_CAPACITY_LIMIT_ID 0x29
  27. #define CAPACITY_MODE_ID 0x2c
  28. #define BELOW_REMAINING_CAPACITY_ID 0x42
  29. #define CHARGING_ID 0x44
  30. #define DISCHARGING_ID 0x45
  31. #define REMAINING_CAPACITY_ID 0x66
  32. #define FULL_CHARGED_CAPACITY_ID 0x67
  33. #define RUNTIME_TO_EMPTY_ID 0x68
  34. #define DESIGN_CAPACITY_ID 0x83
  35. #define MANUFACTURE_DATE_ID 0x85
  36. #define ICHEMISTRY_ID 0x89
  37. #define WARNING_CAPACITY_LIMIT_ID 0x8c
  38. #define GRANULARITY1_ID 0x8d
  39. #define GRANULARITY2_ID 0x8e
  40. #define OEM_INFO_ID 0x8f
  41. #define AC_PRESENT_ID 0xd0
  42. typedef enum {
  43. PRESENT_STATUS_INDEX, // 0
  44. UPS_INDEX, // 1
  45. POWER_SUMMARY_INDEX, // 2
  46. VOLTAGE_INDEX, // 3
  47. CURRENT_INDEX, // 4
  48. CONFIG_VOLTAGE_INDEX, // 5
  49. CONFIG_CURRENT_INDEX, // 6
  50. DELAY_BEFORE_SHUTDOWN_INDEX, // 7
  51. SHUTDOWN_IMMINENT_INDEX, // 8
  52. MANUFACTURER_INDEX, // 9
  53. PRODUCT_INDEX, // a
  54. SERIAL_NUMBER_INDEX, // b
  55. REMAINING_CAPACITY_LIMIT_INDEX, // c
  56. CAPACITY_MODE_INDEX, // d
  57. BELOW_REMAINING_CAPACITY_INDEX, // e
  58. CHARGING_INDEX, // f
  59. DISCHARGING_INDEX, // 10
  60. REMAINING_CAPACITY_INDEX, // 11
  61. FULL_CHARGED_CAPACITY_INDEX, // 12
  62. RUNTIME_TO_EMPTY_INDEX, // 13
  63. DESIGN_CAPACITY_INDEX, // 14
  64. MANUFACTURE_DATE_INDEX, // 15
  65. CHEMISTRY_INDEX, // 16
  66. WARNING_CAPACITY_LIMIT_INDEX, // 17
  67. GRANULARITY1_INDEX, // 18
  68. GRANULARITY2_INDEX, // 19
  69. OEM_INFO_INDEX, // 1a
  70. AC_PRESENT_INDEX, // 1b
  71. MAX_USAGE_INDEXS // 1c
  72. } USAGE_INDEX;
  73. typedef struct {
  74. USAGE Page;
  75. USAGE UsageID;
  76. } USAGE_ENTRY;
  77. extern USAGE_ENTRY UsageArray[];
  78. class CBattery
  79. {
  80. public: // accessors
  81. CBattery(CHidDevice *);
  82. ~CBattery();
  83. NTSTATUS RefreshStatus();
  84. bool InitValues(); // initialize static values from device
  85. bool GetSetValue(USAGE_INDEX, PULONG, bool);
  86. CUString * GetCUString(USAGE_INDEX);
  87. ULONG GetUnit(USAGE_INDEX);
  88. SHORT GetExponent(USAGE_INDEX);
  89. CUsage * GetUsage(USAGE_INDEX);
  90. public: // members
  91. PVOID m_pBatteryClass; // Battery Class handle
  92. CHidDevice * m_pCHidDevice; // the hid device for this battery
  93. BOOLEAN m_bIsCacheValid; // Is cached battery info currently valid?
  94. //
  95. // Battery
  96. //
  97. BOOLEAN m_bRelative; // indicates capacity in percent or absolute values
  98. ULONGLONG m_RefreshTime;
  99. BATTERY_STATUS m_BatteryStatus;
  100. BATTERY_INFORMATION m_BatteryInfo;
  101. PBATTERY_NOTIFY m_pBatteryNotify;
  102. USHORT m_Tag;
  103. CUString * m_pSerialNumber;
  104. CUString * m_pOEMInformation;
  105. CUString * m_pProduct;
  106. CUString * m_pManufacturer;
  107. BATTERY_MANUFACTURE_DATE m_ManufactureDate;
  108. };
  109. #endif // cbattery.h