Sensor.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. * sensor.h
  17. * Sensor functions.
  18. *
  19. * Author: Govind Kothandapani <govindk@ami.com>
  20. *
  21. ******************************************************************/
  22. #ifndef SENSOR_H
  23. #define SENSOR_H
  24. #include "com_IPMI_Sensor.h"
  25. #include "com_IPMI_SDRRecord.h"
  26. #include "SensorMonitor.h"
  27. /**
  28. * @brief Sensor Types
  29. */
  30. #define PROCESSOR 0x07
  31. #define POWER_SUPPLY 0x08
  32. #define MEMORY 0x0c
  33. #define ENTITY_PRESENCE 0x25
  34. #define BATTERY 0x29
  35. /**
  36. * @brief Sensor presence bit
  37. */
  38. #define PROCESSOR_PRESENCE_DETECTED 0x07
  39. #define POWER_SUPPLY_PRESENCE_DETECTED 0x00
  40. #define POWER_SUPPLY_OUT_OF_RANGE_PRESENT 0x05
  41. #define MEMORY_PRESENCE_DETECTED 0x06
  42. #define ENTITY_PRESENCE_ENTITY_PRESENT 0x00
  43. #define BATTERY_PRESENCE_DETECTED 0x02
  44. /**
  45. * @brief Event type codes
  46. */
  47. #define GENERIC_EVENT_TYPE_DEV_PRESENCE 0x08
  48. #define GENERIC_EVENT_TYPE_DEV_AVAILABLE 0x09
  49. #define EVENT_TYPE_SENSOR_SPECIFIC 0x6f
  50. #define EVENT_AND_SCANNING_ENABLE (BIT7|BIT6)
  51. #define READING_UNAVAILABLE (BIT5)
  52. /**
  53. * @brief Sensor Reading for Device
  54. */
  55. #define DEVICE_PRESENT 0x01
  56. #define DEVICE_ENABLED 0x01
  57. /*** External Definitions ***/
  58. #define THRESHOLD_SENSOR_CLASS 0x01
  59. #define GET_SETTABLE_SENSOR_BIT(FLAGS) (FLAGS & 0x80)
  60. #define GET_EVENT_DATA_OP(OP) ( ((OP) >> 6))
  61. #define GET_ASSERT_EVT_OP(OP) ( ((OP) >> 4) & 0x03)
  62. #define GET_DEASSERT_EVT_OP(OP) ( ((OP) >> 2) & 0x03)
  63. #define GET_SETSENSOR_OP(OP) ( (OP) & 0x03)
  64. #define CLEAR_ASSERT_BITS 0x3
  65. #define SET_ASSERT_BITS 0x2
  66. #define WRITE_ASSERT_BITS 0x1
  67. #define CLEAR_DEASSERT_BITS 0x3
  68. #define SET_DEASSERT_BITS 0x2
  69. #define WRITE_DEASSERT_BITS 0x1
  70. #define WRITE_NO_EVTDATA1 0x02
  71. #define WRITE_EVTDATA1 0x01
  72. #define USE_SM_EVTDATA 0x00
  73. #define DCMI_INLET_TEMP_ENTITY_ID 0x40
  74. #define DCMI_CPU_TEMP_ENTITY_ID 0x41
  75. #define DCMI_BASEBOARD_TEMP_ENTITY_ID 0x42
  76. #define IPMI_INLET_TEMP_ENTITY_ID 0x37
  77. #define IPMI_CPU_TEMP_ENTITY_ID 0x03
  78. #define IPMI_BASEBOARD_TEMP_ENTITY_ID 0x07
  79. // Assertion bits for discrete sensor
  80. #define STATE_0_ASSERTED 0x01
  81. #define STATE_1_ASSERTED 0x02
  82. #define STATE_2_ASSERTED 0x04
  83. #define STATE_3_ASSERTED 0x08
  84. #define STATE_4_ASSERTED 0x10
  85. #define STATE_5_ASSERTED 0x20
  86. #define STATE_6_ASSERTED 0x40
  87. #define STATE_7_ASSERTED 0x80
  88. #define STATE_8_ASSERTED 0x01
  89. #define STATE_9_ASSERTED 0x02
  90. #define STATE_10_ASSERTED 0x04
  91. #define STATE_11_ASSERTED 0x08
  92. #define STATE_12_ASSERTED 0x10
  93. #define STATE_13_ASSERTED 0x20
  94. #define STATE_14_ASSERTED 0x40
  95. // FRU State events
  96. #define FRU_NOT_INSTALLED 0x00
  97. #define FRU_INACTIVE 0x01
  98. #define FRU_ACTIVATION_REQUESTED 0x02
  99. #define FRU_ACTIVATION_IN_PROGRESS 0x03
  100. #define FRU_ACTIVE 0x04
  101. #define FRU_DEACTIVATION_REQUESTED 0x05
  102. #define FRU_DEACTIVATION_IN_PROGRESS 0x06
  103. #define FRU_COMMUNICATION_LOST 0x07
  104. // ACPI state events
  105. #define ACPI_S0_WORKING 0x00
  106. #define ACPI_S1_SLEEPING 0x01
  107. #define ACPI_S2_SLEEPING 0x02
  108. #define ACPI_S3_SLEEPING 0x03
  109. #define ACPI_S4_SUSPTODISK 0x04
  110. #define ACPI_S5_SOFTOFF 0x05
  111. #define ACPI_G3_MECHANICAL 0x07
  112. #define ACPI_G1_SLEEPING 0x09
  113. #define ACPI_S5_OVERRIDE 0x0A
  114. #define ACPI_LEGACY_ON 0x0B
  115. #define ACPI_LEGACY_OFF 0x0C
  116. /**
  117. * @brief Initialize Sensor information.
  118. * @return 0 if success, -1 if error
  119. **/
  120. extern int InitSensorInfo (void);
  121. extern int InitSensorDev (void);
  122. /**
  123. * @brief Initialize the scanning bit of each sensor
  124. * @return 0 if success, -1 if error
  125. */
  126. extern int InitSensorScanningBit (void);
  127. /**
  128. * @brief Get sensor's SDR record.
  129. * @param SensorNum - Sensor number.
  130. * @return the sensor's SDR record.
  131. **/
  132. extern SDRRecHdr_T* SR_GetSensorSDR (uint8_t SensorNum);
  133. extern int GetRecordIdsforDCMISensor (uint8_t EntityID,uint8_t SensorType,uint8_t EntityInstance,
  134. uint8_t StartingEntityInstance, uint16_t* pBuf, uint8_t* pTotalValidInstances);
  135. extern int GetDCMITempReading(uint8_t EntityID, uint8_t SensorType,uint8_t EntityInstance,
  136. uint8_t StartingEntityInstance, uint8_t* pBuf, uint8_t* pTotalValidInstances);
  137. /**
  138. * @defgroup sdc Sensor Device Commands
  139. * @ingroup senevt
  140. * IPMI Sensor Device interface command handlers. These commands are
  141. * used for configuring hysterisis and thresholds and reading
  142. * sensor values.
  143. * @{
  144. **/
  145. extern int GetDevSDRInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  146. extern int GetDevSDR ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  147. extern int ReserveDevSDRRepository ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  148. extern int SetSensorType ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  149. extern int GetSensorType ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  150. extern int ReArmSensor ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  151. extern int GetSensorEventStatus ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  152. extern int SetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  153. extern int GetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  154. extern int SetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  155. extern int GetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  156. extern int GetSensorReadingFactors ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  157. extern int SetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  158. extern int GetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  159. extern int GetSensorReading ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  160. extern int SetSensorReading ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  161. int CompareValues(uint8_t isSigned, uint8_t val1, uint8_t val2);
  162. /** @} */
  163. /**
  164. * @brief Get Sensor Hysterisis.
  165. * @param SensorNum - Sensor number.
  166. * @param Res - Response data.
  167. * @return 0 if success, -1 if error.
  168. **/
  169. extern int SR_GetSensorHysterisis (uint8_t SensorNum, GetSensorHysterisisRes_T* Res);
  170. /**
  171. * @brief Get Sensor Threshold.
  172. * @param SensorNum - Sensor number.
  173. * @param Res - Response data.
  174. * @return 0 if success, -1 if error.
  175. **/
  176. extern int SR_GetSensorThreshold (uint8_t SensorNum, GetSensorThresholdRes_T* Res);
  177. /**
  178. * @brief Get Sensor Event Enables.
  179. * @param SensorNum - Sensor number.
  180. * @param Res - Response data.
  181. * @return 0 if success, -1 if error.
  182. **/
  183. extern int SR_GetSensorEventEnable (uint8_t SensorNum, GetSensorEventEnableRes_T* Res);
  184. /**
  185. * @brief Get Sensor Reading.
  186. * @param SensorNum - Sensor number.
  187. * @return the Sensor reading.
  188. **/
  189. extern uint16_t SM_GetSensorReading (uint8_t SensorNum, uint16_t *pSensorReading);
  190. /**
  191. * @brief SR_LoadSDRDefaults.
  192. * @param sr - SDR Record , pSensorInfo - Sensor information.
  193. * @return none.
  194. **/
  195. extern void SR_LoadSDRDefaults (SDRRecHdr_T* sr, SensorInfo_T* pSensorInfo);
  196. /**
  197. * @brief SR_FindSDR.
  198. * @param SensorNum - Finds SDR for this sensor number.
  199. * @return none.
  200. **/
  201. extern SDRRecHdr_T* SR_FindSDR (uint8_t SensorNum);
  202. #endif /* SENSOR_H */