SensorMonitor.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /****************************************************************
  2. ****************************************************************
  3. ** **
  4. ** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. ** **
  6. ** All Rights Reserved. **
  7. ** **
  8. ** 6145-F, Northbelt Parkway, Norcross, **
  9. ** **
  10. ** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. ** **
  12. ****************************************************************
  13. ****************************************************************/
  14. /*****************************************************************
  15. *
  16. * SensorMonitor.h
  17. * Sensor Monitor
  18. *
  19. * Author: Rama Rao Bisa <ramab@ami.com>
  20. *
  21. *****************************************************************/
  22. #ifndef SENSOR_MONITOR_H
  23. #define SENSOR_MONITOR_H
  24. #include "com_IPMI_SDRRecord.h"
  25. /*** Soft Processor Control functions ***/
  26. #define READ_CTRL_FN 0x01
  27. #define LWR_NON_CRITICAL_GOING_LOW_CTRL_FN 0x02
  28. #define LWR_CRITICAL_GOING_LOW_CTRL_FN 0x03
  29. #define LWR_NON_RECOVERABLE_GOING_LOW_CTRL_FN 0x04
  30. #define UPPER_NON_CRITICAL_GOING_HIGH_CTRL_FN 0x05
  31. #define UPPER_CRITICAL_GOING_HIGH_CTRL_FN 0x06
  32. #define UPPER_NON_RECOVERABLE_GOING_HIGH_CTRL_FN 0x07
  33. #define LWR_NON_CRITICAL_GOING_HIGH_CTRL_FN 0x82
  34. #define LWR_CRITICAL_GOING_HIGH_CTRL_FN 0x83
  35. #define LWR_NON_RECOVERABLE_GOING_HIGH_CTRL_FN 0x84
  36. #define UPPER_NON_CRITICAL_GOING_LOW_CTRL_FN 0x85
  37. #define UPPER_CRITICAL_GOING_LOW_CTRL_FN 0x86
  38. #define UPPER_NON_RECOVERABLE_GOING_LOW_CTRL_FN 0x87
  39. #define GET_NORMAL_VALUE 0xFE
  40. #define INIT_CTRL_FN 0xFF
  41. /*** Sensor Event definitions ***/
  42. #define SENSOR_STATUS_NORMAL 0x00
  43. #define SENSOR_STATUS_WARNING_HIGH 0x01
  44. #define SENSOR_STATUS_WARNING_LOW 0x02
  45. #define SENSOR_STATUS_CRITICAL_HIGH 0x03
  46. #define SENSOR_STATUS_CRITICAL_LOW 0x04
  47. #define SENSOR_STATUS_NONRECOVERABLE_HIGH 0x05
  48. #define SENSOR_STATUS_NONRECOVERABLE_LOW 0x06
  49. #define SENSOR_STATUS_FATAL 0x08
  50. #define MAX_SENSORS_ALLOWED 20
  51. #ifdef SKIPPER
  52. #define MAX_SENSORS 0x13
  53. #define MAX_FANS 0x08
  54. #define MAX_VOLTS 0x08
  55. #define MAX_TEMPS 0x01
  56. #else
  57. #define MAX_SENSORS 0x11
  58. #define MAX_FANS 0x07
  59. #define MAX_VOLTS 0x08
  60. #define MAX_TEMPS 0x00
  61. #endif
  62. //#define MAX_SENSOR_NUMBERS (64) //RAM limit
  63. /*---------------------------------------------------
  64. * Parameters passed to the sensor monitor handler Q.
  65. *---------------------------------------------------*/
  66. #define PARAM_REARM_ALL_SENSORS 0x01
  67. #define PARAM_REARM_SENSOR 0x02
  68. #define PARAM_HANDLE_IRQ 0x03
  69. #define PARAM_SENSOR_SCAN 0x04
  70. //typedef int (*pPDK_MonitorHook_T) (void* pSensorInfo,uint8_t *pReadFlags,int BMCInst);
  71. //typedef int (*pPDK_SensorInitHook_T) (void *pSensorInfo,int BMCInst);
  72. //typedef int (*pPDK_MonitorExtHook_T) (void *pSensorInfo, uint8_t* pReadFlags,int BMCInst);
  73. //typedef int (*pPDK_PreEventLogHook_T) (void *pSensorInfo, uint8_t* pEventData, uint8_t* pReadFlags,int BMCInst);
  74. ///* Hook Type supported */
  75. //typedef enum
  76. //{
  77. // HT_INIT_SENSOR,
  78. // HT_PRE_MONITOR,
  79. // HT_POST_MONITOR
  80. //} HookType_e;
  81. //
  82. //#define MAX_PRE_MONITOR_HOOKS 3
  83. //#define MAX_POST_MONITOR_HOOKS 3
  84. //#define MAX_POST_MONITOR_EXT_HOOKS 3
  85. //#define MAX_INIT_SENSOR_HOOKS 3
  86. //#define MAX_PRE_EVENT_LOG_HOOKS 3
  87. /* Sensor Monitor Event Flags */
  88. #define SET_SM_INIT_DONE(FLAGS) (FLAGS = FLAGS & 0xFE)
  89. #define SET_SM_REINIT(FLAGS) (FLAGS = FLAGS | 0x01)
  90. #define SET_SM_UNABLE_TO_READ(FLAGS) (FLAGS = FLAGS | 0x20)
  91. #define SET_SM_CLEAR_UNABLE_TO_READ(FLAGS) (FLAGS = FLAGS & 0xDF)
  92. #define SET_SM_ENABLE_SCAN(FLAGS) (FLAGS = FLAGS | 0x40)
  93. #define SET_SM_DISABLE_SCAN(FLAGS) (FLAGS = FLAGS & 0xBF)
  94. #define SET_SM_ENABLE_EVT(FLAGS) (FLAGS = FLAGS | 0x80)
  95. #define SET_SM_DISABLE_EVT(FLAGS) (FLAGS = FLAGS & 0x7F)
  96. #pragma pack (1)
  97. //typedef struct
  98. //{
  99. // uint8_t MonitorInterval;
  100. //// uint8_t MonitorState ;
  101. //// uint16_t NormalValue;
  102. // uint8_t PowerOnDelay; //Delay after chassis power on in seconds. 0 - don't delay
  103. // uint8_t SysResetDelay ; // Delay after chassis reset in seconds. 0 - don't delay
  104. //} SensorProperties_T;
  105. //typedef struct
  106. //{
  107. // uint8_t SensorNum; /* Sensor Numbner */
  108. // uint8_t HookType; /* Type of the hook */
  109. // pPDK_MonitorHook_T pHook; /* Hook */
  110. //} PDKSensorHook_T;
  111. /**
  112. * @struct SensorInfo_T
  113. * @brief Sensor Information.
  114. **/
  115. typedef struct
  116. {
  117. // uint8_t IsSensorPresent; //nessary
  118. uint8_t SensorNumber;
  119. uint8_t SensorReading;
  120. uint16_t SettableThreshMask;
  121. uint16_t Err;
  122. uint16_t PreviousState;
  123. uint16_t RecordID;
  124. uint8_t SensorTypeCode;
  125. uint8_t EventTypeCode;
  126. uint8_t SensorInit; //SDR sensor initialization
  127. // These values are copied from the SDR.
  128. uint8_t Units1;
  129. uint8_t Units2;
  130. uint8_t Units3;
  131. // Caution !!! Order of these members has to maintained
  132. // Some of the command implementation needs the order to be maintained
  133. // the following set are used in Get Sensor Reading Factors command
  134. uint8_t M_LSB;
  135. uint8_t M_MSB_Tolerance;
  136. uint8_t B_LSB;
  137. uint8_t B_MSB_Accuracy;
  138. uint8_t Accuracy_MSB_Exp;
  139. uint8_t RExp_BExp;
  140. uint16_t sensor_send_packed[12]; //nessary??
  141. // the following set are used in Get/Set Sensor Threshold commands
  142. uint8_t LowerNonCritical;
  143. uint8_t LowerCritical;
  144. uint8_t LowerNonRecoverable;
  145. uint8_t UpperNonCritical;
  146. uint8_t UpperCritical;
  147. uint8_t UpperNonRecoverable;
  148. // the following set are used in Get/Set Sensor Hysteresis commands
  149. uint8_t PosHysteresis;
  150. uint8_t NegHysteresis;
  151. // the following set are used in Get/Set Event Enables commands
  152. uint8_t EventFlags;
  153. /* Event Flags description */
  154. /* Bit 0 - Initialization Done */
  155. /* Bit 1 - Update in Progress */
  156. /* Bit 2 - reserved */
  157. /* Bit 3 - reserved */
  158. /* Bit 4 - reserved */
  159. /* Bit 5 - Unable to read */
  160. /* Bit 6 - Sensor Scanning disabled */
  161. /* Bit 7 - Event Message Disabled */
  162. uint8_t AssertionEventEnablesByte1;
  163. uint8_t AssertionEventEnablesByte2;
  164. uint8_t DeassertionEventEnablesByte1;
  165. uint8_t DeassertionEventEnablesByte2;
  166. uint8_t EventLevel;
  167. uint8_t HealthLevel; // Added to provide correct Health state
  168. uint8_t AssertionEventOccuredByte1;
  169. uint8_t AssertionEventOccuredByte2;
  170. uint8_t DeassertionEventOccuredByte1;
  171. uint8_t DeassertionEventOccuredByte2;
  172. uint8_t SensorMonitorInterval; // added to effect different sensor monitor intervals.
  173. uint8_t SensorState; //wether monitor on standby
  174. uint8_t SensorReadType;
  175. uint8_t PowerOnDelay; //Delay after chassis power on in seconds. 0 - don't delay
  176. uint8_t SysResetDelay ; // Delay after chassis reset in seconds. 0 - don't delay
  177. /* Settable Sensor Fields */
  178. uint8_t Operation;
  179. uint8_t EvtData1;
  180. uint8_t EvtData2;
  181. uint8_t EvtData3;
  182. uint8_t ComparisonStatus;
  183. uint8_t SensorCaps; // JM 062306 - Added to support manual re-arm sensors
  184. uint8_t AssertionHistoryByte1; // JM 062306 - Added to support manual re-arm sensors
  185. uint8_t AssertionHistoryByte2; // JM 062306 - Added to support manual re-arm sensors
  186. uint8_t DeassertionHistoryByte1; // JM 062306 - Added to support manual re-arm sensors
  187. uint8_t DeassertionHistoryByte2; // JM 062306 - Added to support manual re-arm sensors
  188. /* Sensor Monitor Internal Flags
  189. * This flags overrides any IPMI SDR settings.
  190. *
  191. *
  192. * */
  193. // uint8_t InternalFlags;
  194. /* Bit 0 - Enable/Disable scanning - overrides SDR scanning bit */
  195. /* Bit 1 - reserved */
  196. /* Bit 2 - reserved */
  197. /* Bit 3 - reserved */
  198. /* Bit 4 - reserved */
  199. /* Bit 5 - reserved */
  200. /* Bit 6 - reserved */
  201. /* Bit 7 - reserved */
  202. uint8_t OEMField;
  203. // pPDK_MonitorHook_T pPreMonitor;
  204. // pPDK_MonitorHook_T pPostMonitor;
  205. // pPDK_SensorInitHook_T pInitSensor [MAX_INIT_SENSOR_HOOKS];
  206. // uint8_t InitSensorHookCnt;
  207. // pPDK_MonitorExtHook_T pPostMontiorExt [MAX_POST_MONITOR_EXT_HOOKS];
  208. // uint8_t PostMonitorExtHookCnt;
  209. // pPDK_PreEventLogHook_T pPreEventLog [MAX_PRE_EVENT_LOG_HOOKS];
  210. // uint8_t PreEventLogHookCnt;
  211. /* The offset for the sensor is added for OPMA Support */
  212. uint8_t SenReadingOffset;
  213. uint8_t SensorOwnerLun;
  214. uint8_t IsDCMITempsensor;
  215. uint8_t EntityID;
  216. uint8_t EntiryInstance;
  217. SDRRecHdr_T* SDRRec;
  218. } SensorInfo_T;
  219. /**
  220. * @struct SensorSharedMem_T
  221. * @brief Shared memory for Sensor Information.
  222. **/
  223. typedef struct
  224. {
  225. SensorInfo_T SensorInfo [MAX_SENSOR_NUMBERS + 1]; /* Holds all sensor informations */
  226. uint32_t SensorTick;
  227. uint8_t GlobalSensorScanningEnable;
  228. } SensorSharedMem_T;
  229. #pragma pack ()
  230. ///*---------------------------------------
  231. // * InitInternalSensors
  232. // *---------------------------------------*/
  233. //extern int InitInternalSensors (SensorInfo_T *pSensorInfo);
  234. ///**
  235. // * @var g_SensorValues
  236. // * @brief Global array that holds current sensor values.
  237. //**/
  238. //extern uint8_t g_SensorValues [];
  239. ///*
  240. // * @fn InitPowerOnTick
  241. // * @brief Initialize the power on tick counter,
  242. // * should be invoked when ever power on occurs.
  243. // */
  244. //extern void InitPowerOnTick ();
  245. ///*
  246. // * @fn InitSysResetTick
  247. // * @brief Initialize the System Reset tick counter,
  248. // * should be invoked when ever power reset occurs.
  249. // */
  250. //extern void InitSysResetTick ();
  251. ///**
  252. // * @brief Initialize Sensor monitoring.
  253. // * @return 0 if success, -1 if error.
  254. //**/
  255. //extern int InitSensorMonitor (void);
  256. /**
  257. * @brief Sensor monitoring task.
  258. **/
  259. extern void *SensorMonitorTask (void*);
  260. ///**
  261. // * @brief Returns the current sensor reading
  262. //**/
  263. //extern uint16_t SM_GetSensorReading (uint8_t SenNum, uint16_t *pSensorReading);
  264. SensorInfo_T* getSensorInfo(uint8_t sensorNum);
  265. int SensorAverage(uint8_t SensorNum, uint8_t* pSensorReading);
  266. int get_sensor_reading (uint8_t sensor_num, uint8_t *preading);
  267. #endif /* SENSOR_MONITOR_H */