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.

101 lines
4.7 KiB

  1. /*
  2. * pcy08Jan93: Initial implementation taken from ups.h
  3. * cad26Aug93: Bypass mode convenience
  4. * srt02Feb96: Added UPS_STATE_NO_COMMUNICATION
  5. * djs29Jul96: Added DarkStar states
  6. * tjg03Dec97: Added bit for IM_NOT_INSTALLED
  7. */
  8. #ifndef __SYSSTATE_H
  9. #define __SYSSTATE_H
  10. // The System State is implemented as a bit field as follows.
  11. // Bit 0 - Utility Line Status 0=line good 1=line bad
  12. // Bit 1 - Battery Status 0=battery good 1=battery bad
  13. // Bit 2 - SmartBoost 0=smart boost off 1=smart boost on
  14. // Bit 3 - BatteryCalibration 0=not in progress 1=in progress
  15. // Bit 4 - BatteryReplacement 0=doesnt need replaceing 1=needs replacing
  16. // Bit 5 - Self Test 0=not in progress 1=in progress
  17. // Bit 6 - Line Fail Pending 0=no 1=no
  18. // Bit 7 - Lights Test 0=not in progress 1=in progress
  19. // Bit 8 - Overload 0=no overload 1=overload
  20. // Bit 9 - Abnormal condition 0=no abnormal condition 1=abnormal condition
  21. // Bit 10 - Shutdown in Progress 0=no abnormal condition 1=abnormal condition
  22. // Bit 11 - Bypass, Maint. 0=not on bypass 1=on bypass
  23. // Bit 12 - Bypass, Module Fail. 0=not on bypass 1=on bypass
  24. // Bit 13 - Bypass, Supply Fail. 0=power supply ok 1=ps failed
  25. // Bit 14 - Simulate power Fail 0=no simulation 1=simulated
  26. // Bit 15 - Communications 0=comm ok 1=no comm
  27. // Bit 16 - SmartTrim 0=smart trim off 1=smart trim on
  28. // Bit 17 - Bypass Cont Fail. 0=not on bypass 1=on bypass
  29. // Bit 18 - Redundancy 0=redundnacy ok 1=no redundancy
  30. // Bit 19 - IM 0=IM ok 1=IM failed
  31. // Bit 20 - RIM 0=RIM ok 1=RIM failed
  32. // Bit 21 - IM Installation 0=Installed 1=Not Installed
  33. // System State values
  34. //
  35. #define LINE_STATUS_BIT 0
  36. #define BATTERY_STATUS_BIT 1
  37. #define SMART_BOOST_BIT 2
  38. #define BATTERY_CALIBRATION_BIT 3
  39. #define BATTERY_REPLACEMENT_BIT 4
  40. #define SELF_TEST_BIT 5
  41. #define LINE_FAIL_PENDING_BIT 6
  42. #define LIGHTS_TEST_BIT 7
  43. #define OVERLOAD_BIT 8
  44. #define ABNORMAL_CONDITION_BIT 9
  45. #define SHUTDOWN_IN_PROGRESS_BIT 10
  46. #define BYPASS_MAINT_BIT 11
  47. #define BYPASS_MODULE_FAILED_BIT 12
  48. #define BYPASS_SUPPLY_FAILED_BIT 13
  49. #define SIMULATE_POWER_FAIL_BIT 14
  50. #define COMMUNICATIONS_BIT 15
  51. #define SMART_TRIM_BIT 16
  52. #define BYPASS_CONT_FAILED_BIT 17
  53. #define REDUNDANCY_LOST_BIT 18
  54. #define IM_FAILED_BIT 19
  55. #define RIM_FAILED_BIT 20
  56. #define IM_NOT_INSTALLED_BIT 21
  57. #define UPS_STATE_ON_BATTERY ( 1 << LINE_STATUS_BIT )
  58. #define UPS_STATE_BATTERY_BAD ( 1 << BATTERY_STATUS_BIT )
  59. #define UPS_STATE_ON_BOOST ( 1 << SMART_BOOST_BIT )
  60. #define UPS_STATE_IN_CALIBRATION ( 1 << BATTERY_CALIBRATION_BIT )
  61. #define UPS_STATE_BATTERY_NEEDED ( 1 << BATTERY_REPLACEMENT_BIT )
  62. #define UPS_STATE_IN_SELF_TEST ( 1 << SELF_TEST_BIT )
  63. #define UPS_STATE_LINE_FAIL_PENDING ( 1 << LINE_FAIL_PENDING_BIT )
  64. #define UPS_STATE_IN_LIGHTS_TEST ( 1 << LIGHTS_TEST_BIT )
  65. #define UPS_STATE_OVERLOAD ( 1 << OVERLOAD_BIT )
  66. #define UPS_STATE_ABNORMAL_CONDITION ( 1 << ABNORMAL_CONDITION_BIT )
  67. #define SHUTDOWN_IN_PROGRESS ( 1 << SHUTDOWN_IN_PROGRESS_BIT )
  68. #define UPS_STATE_BYPASS_MAINT ( 1 << BYPASS_MAINT_BIT )
  69. #define UPS_STATE_BYPASS_MODULE_FAILED ( 1 << BYPASS_MODULE_FAILED_BIT )
  70. #define UPS_STATE_BYPASS_SUPPLY_FAILED ( 1 << BYPASS_SUPPLY_FAILED_BIT )
  71. #define UPS_STATE_SIMULATED_POWER_FAIL ( 1 << SIMULATE_POWER_FAIL_BIT )
  72. #define UPS_STATE_NO_COMMUNICATION ( 1 << COMMUNICATIONS_BIT )
  73. // All bit masks greater than bit 15 cannot reliable use bit shifting
  74. // across all platforms.
  75. #define UPS_STATE_ON_TRIM 65536
  76. #define UPS_STATE_BYPASS_CONT_FAILED 131072
  77. #define UPS_STATE_LOST_REDUNDANCY 262144
  78. #define UPS_STATE_IM_FAILED 524288
  79. #define UPS_STATE_RIM_FAILED 1048576
  80. #define UPS_STATE_IM_NOT_INSTALLED 2097152
  81. #define UPS_STATE_ANY_BYPASS_MODE (UPS_STATE_BYPASS_MAINT|\
  82. UPS_STATE_BYPASS_MODULE_FAILED|\
  83. UPS_STATE_BYPASS_SUPPLY_FAILED)
  84. #define UPS_STATE_LOW_BATTERY (UPS_STATE_ON_BATTERY & \
  85. UPS_STATE_BATTERY_BAD)
  86. #define SET_BIT(byte, bitnum) (byte |= ( 1L << bitnum ))
  87. #define CLEAR_BIT(byte, bitnum) (byte &= ~( 1L << bitnum ))
  88. #define IS_STATE(state) (theUpsState & (state) ? 1 : 0)
  89. #endif