libipmi.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. #ifndef LIBIPMI_H
  2. #define LIBIPMI_H
  3. #define u8 unsigned char
  4. #define u16 unsigned short int
  5. #define s32 long int
  6. /*! Return value that indicates a specified sensor is disabled, and cannot be read */
  7. #define IPMI_SENSOR_DISABLED ( -3 )
  8. /* IPMI threshold state definitions for monitoring */
  9. #define THRESH_UNINITIALIZED ( (u16)0x00 ) /*!< Threshold state on first run */
  10. #define THRESH_NORMAL ( (u16)0x01 ) /*!< Sensor is normal (unused in IPMI ) */
  11. #define THRESH_UP_NONCRIT ( (u16)0x02 ) /*!< IPMI Upper Non-Critical Threshold */
  12. #define THRESH_UP_CRITICAL ( (u16)0x04 ) /*!< IPMI Upper Critical Threshold */
  13. #define THRESH_LOW_NONCRIT ( (u16)0x08 ) /*!< IPMI Lower Non-Critical Threshold */
  14. #define THRESH_LOW_CRITICAL ( (u16)0x10 ) /*!< IPMI Lower Critical Threshold */
  15. #define THRESH_ACCESS_FAILED ( (u16)0x20 ) /*!< Access failed sensor state */
  16. #define THRESH_UP_NON_RECOV ( (u16)0x40 ) /*!< IPMI Upper Non-Recoverable Threshold */
  17. #define THRESH_LOW_NON_RECOV ( (u16)0x80 ) /*!< IPMI Lower Non-Recoverable Threshold */
  18. /* Macros for converting netfn/lun combos */
  19. #define NETFN( netfnlun ) ( ( netfnlun & (u8)0xFC ) >> 2 )
  20. #define NETLUN( netfnlun ) ( ( netfnlun & (u8)0x03 ) )
  21. #define NETFNLUN( netfn,lun ) ( ( netfn << 2 ) | ( lun ) )
  22. /* Macros for converting seq/lun combos */
  23. #define SEQ( seqlun ) ( ( seqlun & (u8)0xFC ) >> 2 )
  24. #define SLUN( seqlun ) ( ( seqlun & (u8)0x03 ) )
  25. #define SEQLUN( seq, lun ) ( ( seq << 2 ) | ( lun ) )
  26. /***** IPMI Constant Definitions *****/
  27. /* Completion Codes */
  28. #define IPMI_SUCCESS ( (u8)0x00 )
  29. /* Sensor Data Record types */
  30. #define SDR_FULL ( (u8)0x01 ) /**< SDR RecordType for Full Sensor Record */
  31. #define SDR_COMPACT ( (u8)0x02 ) /**< SDR RecordType for Compact Sensor Record */
  32. /* Raw sensor reading numeric format codes */
  33. #define SDR_READING_UNSIGNED ( (u8)0 )
  34. #define SDR_READING_1SCOMP ( (u8)1 )
  35. #define SDR_READING_2SCOMP ( (u8)2 )
  36. #define SDR_READING_NONANALOG ( (u8)3 )
  37. /* Max size of an SDR of type SDR_FULL. SDR_COMPACT records are smaller. */
  38. #define SDR_MAX_SIZE ( 64 )
  39. /* Chassis control codes */
  40. #define CHASSIS_POWER_DOWN ( (u8)0x00 )
  41. #define CHASSIS_POWER_UP ( (u8)0x01 )
  42. #define CHASSIS_POWER_CYCLE ( (u8)0x02 )
  43. #define CHASSIS_HARD_RESET ( (u8)0x03 )
  44. #define CHASSIS_PULSE_DUMP ( (u8)0x04 )
  45. #define CHASSIS_ACPI_POWER_DOWN ( (u8)0x05 )
  46. /* Sensor Type Codes */
  47. #define IPMI_SENSOR_TEMPERATURE ( (u8)0x01 )
  48. #define IPMI_SENSOR_VOLTAGE ( (u8)0x02 )
  49. #define IPMI_SENSOR_CURRENT ( (u8)0x03 )
  50. #define IPMI_SENSOR_FAN ( (u8)0x04 )
  51. #define IPMI_SENSOR_POWER_SUPPLY ( (u8)0x08 )
  52. #define IPMI_SENSOR_POWER_UNIT ( (u8)0x09 )
  53. #define IPMI_SENSOR_COOLING_DEVICE ( (u8)0x0A )
  54. #define IPMI_SENSOR_MEMORY ( (u8)0x0C )
  55. /* Sensor Unit Type Codes from the IPMI spec */
  56. #define IPMI_UNIT_UNSPECIFIED 0
  57. #define IPMI_UNIT_DEGREES_C 1
  58. #define IPMI_UNIT_DEGREES_F 2
  59. #define IPMI_UNIT_DEGREES_K 3
  60. #define IPMI_UNIT_VOLTS 4
  61. #define IPMI_UNIT_AMPS 5
  62. #define IPMI_UNIT_WATTS 6
  63. #define IPMI_UNIT_JOULES 7
  64. #define IPMI_UNIT_COULOMBS 8
  65. #define IPMI_UNIT_VA 9
  66. #define IPMI_UNIT_NITS 10
  67. #define IPMI_UNIT_LUMEN 11
  68. #define IPMI_UNIT_LUX 12
  69. #define IPMI_UNIT_CANDELA 13
  70. #define IPMI_UNIT_KPA 14
  71. #define IPMI_UNIT_PSI 15
  72. #define IPMI_UNIT_NEWTON 16
  73. #define IPMI_UNIT_CFM 17
  74. #define IPMI_UNIT_RPM 18
  75. #define IPMI_UNIT_HZ 19
  76. #define IPMI_UNIT_MICROSECOND 20
  77. #define IPMI_UNIT_MILLISECOND 21
  78. #define IPMI_UNIT_SECOND 22
  79. #define IPMI_UNIT_MINUTE 23
  80. #define IPMI_UNIT_HOUR 24
  81. #define IPMI_UNIT_DAY 25
  82. #define IPMI_UNIT_WEEK 26
  83. #define IPMI_UNIT_MIL 27
  84. #define IPMI_UNIT_INCHES 28
  85. #define IPMI_UNIT_FEET 29
  86. #define IPMI_UNIT_CUIN 30
  87. #define IPMI_UNIT_CUFEET 31
  88. #define IPMI_UNIT_MM 32
  89. #define IPMI_UNIT_CM 33
  90. #define IPMI_UNIT_M 34
  91. #define IPMI_UNIT_CUCM 35
  92. #define IPMI_UNIT_CUM 36
  93. #define IPMI_UNIT_LITERS 37
  94. #define IPMI_UNIT_FLUIDOUNCE 38
  95. #define IPMI_UNIT_RADIANS 39
  96. #define IPMI_UNIT_STERADIANS 40
  97. #define IPMI_UNIT_REVOLUTIONS 41
  98. #define IPMI_UNIT_CYCLES 42
  99. #define IPMI_UNIT_GRAVITIES 43
  100. #define IPMI_UNIT_OUNCE 44
  101. #define IPMI_UNIT_POUND 45
  102. #define IPMI_UNIT_FTLB 46
  103. #define IPMI_UNIT_OZIN 47
  104. #define IPMI_UNIT_GAUSS 48
  105. #define IPMI_UNIT_GILBERTS 49
  106. #define IPMI_UNIT_HENRY 50
  107. #define IPMI_UNIT_MILLIHENRY 51
  108. #define IPMI_UNIT_FARAD 52
  109. #define IPMI_UNIT_MICROFARAD 53
  110. #define IPMI_UNIT_OHMS 54
  111. #define IPMI_UNIT_SIEMENS 55
  112. #define IPMI_UNIT_MOLE 56
  113. #define IPMI_UNIT_BECQUEREL 57
  114. #define IPMI_UNIT_PPM 58
  115. #define IPMI_UNIT_RESERVED 59
  116. #define IPMI_UNIT_DECIBELS 60
  117. #define IPMI_UNIT_DBA 61
  118. #define IPMI_UNIT_DBC 62
  119. #define IPMI_UNIT_GRAY 63
  120. #define IPMI_UNIT_SIEVERT 64
  121. #define IPMI_UNIT_COLORTEMPDK 65
  122. #define IPMI_UNIT_BIT 66
  123. #define IPMI_UNIT_KILOBIT 67
  124. #define IPMI_UNIT_MEGABIT 68
  125. #define IPMI_UNIT_GIGABIT 69
  126. #define IPMI_UNIT_BYTE 70
  127. #define IPMI_UNIT_KILOBYTE 71
  128. #define IPMI_UNIT_MEGABYTE 72
  129. #define IPMI_UNIT_GIGABYTE 73
  130. #define IPMI_UNIT_WORD 74
  131. #define IPMI_UNIT_DWORD 75
  132. #define IPMI_UNIT_QWORD 76
  133. #define IPMI_UNIT_LINE 77
  134. #define IPMI_UNIT_HIT 78
  135. #define IPMI_UNIT_MISS 79
  136. #define IPMI_UNIT_RETRY 80
  137. #define IPMI_UNIT_RESET 81
  138. #define IPMI_UNIT_OVERRUNFLOW 82
  139. #define IPMI_UNIT_UNDERRUN 83
  140. #define IPMI_UNIT_COLLISION 84
  141. #define IPMI_UNIT_PACKETS 85
  142. #define IPMI_UNIT_MESSAGES 86
  143. #define IPMI_UNIT_CHARACTERS 87
  144. #define IPMI_UNIT_ERROR 88
  145. #define IPMI_UNIT_CORRERROR 89
  146. #define IPMI_UNIT_UNCORRERROR 90
  147. /** \name IPMI Functions */
  148. /** \{ */
  149. /** \brief Send the IPMI Get Sensor Reading command and get the response
  150. *
  151. * Send the GetSensorReading command to the specified slave with \a sensor as
  152. * the sensor number, and get the response.
  153. *
  154. * \param slave The slave address of the IPMI device (8-bit format)
  155. * \param sensor The sensor number on the IPMI device
  156. * \param reading The address of a u8 that will be filled with the sensor
  157. * reading. Note that this is a raw sensor value which must be converted
  158. * by use of the \ref ipmi_convert_reading function.
  159. * \param response The address of a \ref GetSensorReadingResponseStruct
  160. * if you want the entire sensor response, not just the sensor reading.
  161. * Pass \c NULL if you just want the sensor reading.
  162. *
  163. * \retval "IPMI response code" Success
  164. * \retval HHM_FAILURE The sensor reading could not be retrieved.
  165. *
  166. * \note For almost all sensors, the IPMI response code should be 0x00.
  167. * Some devices might return other completion codes to convey OEM specific
  168. * information, or just to be contrary. If the behaviour of a particular
  169. * device is not well known with respect to completion codes, assume that if
  170. * a completion code other than 0x00 is returned, the value in \a reading
  171. * is invalid.
  172. */
  173. /*@external@*/extern int
  174. ipmi_get_sensor_reading( u8 slave, u8 sensor, /*@out@*/u8 *reading,
  175. /*@null@*//*@out@*/GetSensorReadingResponseStruct *response )
  176. /*@globals fileSystem@*/
  177. /*@modifies *reading,fileSystem,response@*/;
  178. /** \brief Get a reservation to access the SDR repository
  179. *
  180. * This is required for certain IPMI commands, such as GetSDR when doing
  181. * partial reads and from non-zero offsets, as well as other commands.
  182. * See the IPMI spec for details.
  183. *
  184. * \param slave The slave address of the IPMI device (8-bit format)
  185. * \param response A pointer to an \ref IPMBReserveSDRRepositoryStruct that
  186. * this function fills in
  187. *
  188. * \retval "IPMI Completion Code" Success
  189. * \retval HHM_FAILURE Failure, errno set
  190. *
  191. * \note For almost all sensors, the IPMI response code should be 0x00.
  192. * Some devices might return other completion codes to convey OEM specific
  193. * information, or just to be contrary. If the behaviour of a particular
  194. * device is not well known with respect to completion codes, assume that if
  195. * a completion code other than 0x00 is returned, the value in \a reading
  196. * is invalid.
  197. */
  198. /*@external@*/extern int
  199. ipmi_reserve_sdr_repository( u8 slave, /*@out@*/IPMBReserveSDRRepositoryStruct *response )
  200. /*@globals fileSystem@*/
  201. /*@modifies *response,fileSystem@*/;
  202. /** \brief Get a reservation to access the SEL
  203. *
  204. * Get a reservation to access the SEL. This is required for
  205. * certain IPMI commands See the IPMI spec for details.
  206. *
  207. * \param slave The slave address of the IPMI device (8-bit format)
  208. * \param response An \ref ReserveSELResponseStruct that this
  209. * function fills in.
  210. *
  211. * \retval "IPMI Completion Code" Success
  212. * \retval HHM_FAILURE Failure, errno set
  213. *
  214. * \note For almost all sensors, the IPMI response code should be 0x00.
  215. * Some devices might return other completion codes to convey OEM specific
  216. * information, or just to be contrary. If the behaviour of a particular
  217. * device is not well known with respect to completion codes, assume that if
  218. * a completion code other than 0x00 is returned, the value in \a reading
  219. * is invalid.
  220. */
  221. /*@external@*/extern int
  222. ipmi_reserve_sel_repository( u8 slave, /*@out@*/ReserveSELResponseStruct *response ) //jimbo notice!
  223. /*@globals fileSystem@*/
  224. /*@modifies *response,fileSystem@*/;
  225. /** \brief Read an SDR entry or part of an SDR entry from an IPMI device
  226. *
  227. * Read an SDR entry from the SDR repository. Usually only BMCs have SDR
  228. * repositories. SDR entries have useful info such as sensor numbers,
  229. * sensor types, and data conversion equations, and can be used to determine
  230. * the type of sensors available, and how to monitor them.
  231. * This is probably not the function you are looking for. This function is
  232. * a raw interface to the GetSDR function, suitable for performing partial
  233. * reads and testing. If you just want to read the entire SDR entry, use
  234. * \ref ipmi_get_sdr_full which is much easier to use.
  235. *
  236. * \param slave The slave address of the IPMI device (8-bit format)
  237. * \param reservation_id An SDR reservation ID obtained from the
  238. * \ref ipmi_reserve_sdr_repository command, or zero if not doing a partial
  239. * read and \a offset_into_record is zero.
  240. * \param record_id The SDR record ID to read
  241. * \param bytes_to_read The number of bytes to read from the record. Pass
  242. * 0xFF to read the entire record. Be aware, however, that most BMCs do not
  243. * support sending a response large enough to contain the entire record.
  244. * \param offset_into_record The starting point for the SDR read operation in
  245. * the record. If this is not 0, you need to call
  246. * \ref ipmi_reserve_sdr_repository before this function.
  247. * \param record_data A buffer that will be filled in with the entire GetSDR
  248. * response (cast this buffer to an \ref IPMBGetSDRResponseStruct after
  249. * calling). The length of the SDR entry is variable, so the data buffer
  250. * should be ~255 bytes long to be safe.
  251. *
  252. * \retval "Length of the SDR read" Success. The IPMI completion code is
  253. * contained within the \ref IPMBGetSDRResponseStruct returned in
  254. * \a record_data
  255. * \retval HHM_FAILURE Failure, errno set
  256. *
  257. * \note For almost all sensors, the IPMI response code should be 0x00.
  258. * Some devices might return other completion codes to convey OEM specific
  259. * information, or just to be contrary. If the behaviour of a particular
  260. * device is not well known with respect to completion codes, assume that if
  261. * a completion code other than 0x00 is returned, the value in \a reading
  262. * is invalid.
  263. */
  264. /*@external@*/extern int
  265. ipmi_get_sdr( u8 slave, u16 reservation_id, u16 record_id,
  266. u8 offset_into_record, u8 bytes_to_read, /*@out@*/u8 *record_data )
  267. /*@globals fileSystem@*/
  268. /*@modifies *record_data,fileSystem@*/;
  269. /** \brief Read an entire SDR entry from an IPMI device
  270. *
  271. * Like \ref ipmi_get_sdr, but this command always reads the entire SDR entry,
  272. * even if it needs to break the operation down into a series of partial
  273. * reads. Like \ref ipmi_get_sdr, \a record_data should be able to accomodate
  274. * 255 bytes.
  275. *
  276. * \param slave The slave address of the IPMI device (8-bit format)
  277. * \param record_id The SDR record to read
  278. * \param record_data A buffer the function fills in that will contain the
  279. * \ref IPMBGetSDRResponseStruct and the entire SDR entry specified in
  280. * \a record_id
  281. *
  282. * \retval "Length of the SDR read" Success. The completion code is contained
  283. * within the \ref IPMBGetSDRResponseStruct returned in \a record_data
  284. * \retval HHM_FAILURE Failure, errno set
  285. *
  286. * \note For almost all sensors, the IPMI response code should be 0x00.
  287. * Some devices might return other completion codes to convey OEM specific
  288. * information, or just to be contrary. If the behaviour of a particular
  289. * device is not well known with respect to completion codes, assume that if
  290. * a completion code other than 0x00 is returned, the value in \a reading
  291. * is invalid.
  292. */
  293. /*@external@*/extern int
  294. ipmi_get_sdr_full( u8 slave, u16 record_id, /*@out@*/u8 *record_data )
  295. /*@globals fileSystem@*/
  296. /*@modifies *record_data,fileSystem@*/;
  297. /** \brief Get an SEL entry from an IPMI device
  298. *
  299. * Read an SEL entry from the SEL. Usually only BMCs have an SEL. This is
  300. * probably not the function you are looking for. This function is a raw
  301. * interface to the GetSEL function, suitable for performing partial reads
  302. * and testing. If you just want to read the entire SEL entry, use
  303. * \ref ipmi_get_sel_full, which is much easier to use.
  304. *
  305. * \param slave The slave address of the IPMI device (8-bit format)
  306. * \param reservation_id An SEL reservation ID obtained from the
  307. * \ref ipmi_reserve_sel_repository command, or zero if not doing a partial
  308. * read and \a offset_into_record is zero.
  309. * \param record_id The SEL record ID to read.
  310. * \param offset_into_record The offset into the specified record to read
  311. * from. Zero for the beginning of the record.
  312. * \param bytes_to_read The number of bytes to read from the record. Pass
  313. * 0xFF to read the entire record. Be aware, however, that most BMCs do
  314. * not support sending a response large enough to contain the entire record
  315. * \param response A \ref GetSELEntryResponseStruct that will be filled in
  316. * with the entire GetSEL response.
  317. *
  318. * \retval "IPMI Completion Code" Success
  319. * \retval HHM_FAILURE Failure, errno set
  320. *
  321. * \note For almost all sensors, the IPMI response code should be 0x00.
  322. * Some devices might return other completion codes to convey OEM specific
  323. * information, or just to be contrary. If the behaviour of a particular
  324. * device is not well known with respect to completion codes, assume that if
  325. * a completion code other than 0x00 is returned, the value in \a reading
  326. * is invalid.
  327. */
  328. ///*@external@*/extern int
  329. //ipmi_get_sel_entry( u8 slave, u16 reservation_id, u16 record_id,
  330. // u8 offset_into_record, u8 bytes_to_read,
  331. // /*@out@*/GetSELEntryResponseStruct *response )
  332. /*@globals fileSystem@*/
  333. /*@modifies *response,fileSystem@*/;
  334. /** \brief Get an entire SEL entry from an IPMI device
  335. *
  336. * Like \ref ipmi_get_sel_entry, but this command always reads the entire SEL
  337. * entry, even if it needs to break the operation down into a series of
  338. * partial reads
  339. *
  340. * \param slave The slave address of the IPMI device (8-bit format)
  341. * \param record_id The SEL entry to read
  342. * \param response A \ref GetSELEntryResponseStruct pointer which will
  343. * be filled in by this function.
  344. *
  345. * \retval "IPMI Completion Code" Success
  346. * \retval HHM_FAILURE Failure, errno set
  347. */
  348. ///*@external@*/extern int
  349. //ipmi_get_sel_full( u8 slave, u16 record_id, /*@out@*/GetSELEntryResponseStruct *response )
  350. ///*@globals fileSystem@*/
  351. ///*@modifies *response,fileSystem@*/;
  352. /** \brief Send the IPMI Get Device ID command and get the response
  353. *
  354. * Send the get device ID IPMI command to a slave address on the I2C bus, and
  355. * receive the response.
  356. *
  357. * \param slave Slave address of the IPMI device (8-bit format)
  358. * \param response The above slave's complete response to the get device
  359. * ID command.
  360. *
  361. * \retval "IPMI Completion Code" Succes
  362. * \retval HHM_FAILURE Failure, errno set
  363. *
  364. * \note For almost all sensors, the IPMI response code should be 0x00.
  365. * Some devices might return other completion codes to convey OEM specific
  366. * information, or just to be contrary. If the behaviour of a particular
  367. * device is not well known with respect to completion codes, assume that if
  368. * a completion code other than 0x00 is returned, the value in \a reading
  369. * is invalid.
  370. */
  371. ///*@external@*/extern int
  372. //ipmi_get_device_id( u8 slave, /*@out@*/IPMBGetDeviceIDResponseStruct *response )
  373. ///*@globals fileSystem@*/
  374. ///*@modifies *response,fileSystem@*/;
  375. /** \brief Send the IPMI Chassis Power Down command
  376. *
  377. * \param slave Slave address of the IPMI device (8-bit format)
  378. *
  379. * \retval "IPMI Completion Code" Success
  380. * \retval HHM_FAILURE Failure, errno set
  381. *
  382. * \note For almost all sensors, the IPMI response code should be 0x00.
  383. * Some devices might return other completion codes to convey OEM specific
  384. * information, or just to be contrary. If the behaviour of a particular
  385. * device is not well known with respect to completion codes, assume that if
  386. * a completion code other than 0x00 is returned, the value in \a reading
  387. * is invalid.
  388. */
  389. /*@external@*/extern int
  390. ipmi_chassis_power_down( u8 slave )
  391. /*@globals fileSystem@*//*@modifies fileSystem@*/;
  392. /** \brief Send the IPMI Chassis Power Up command
  393. *
  394. * \param slave Slave address of the IPMI device (8-bit format)
  395. *
  396. * \retval "IPMI Completion Code" Success
  397. * \retval HHM_FAILURE Failure, errno set
  398. *
  399. * \note For almost all sensors, the IPMI response code should be 0x00.
  400. * Some devices might return other completion codes to convey OEM specific
  401. * information, or just to be contrary. If the behaviour of a particular
  402. * device is not well known with respect to completion codes, assume that if
  403. * a completion code other than 0x00 is returned, the value in \a reading
  404. * is invalid.
  405. */
  406. /*@external@*/extern int
  407. ipmi_chassis_power_up( u8 slave )
  408. /*@globals fileSystem@*//*@modifies fileSystem@*/;
  409. /** \brief Send the IPMI Chassis Power Cycle command
  410. *
  411. * \param slave Slave address of the IPMI device (8-bit format)
  412. *
  413. * \retval "IPMI Completion Code" Success
  414. * \retval HHM_FAILURE Failure, errno set
  415. *
  416. * \note For almost all sensors, the IPMI response code should be 0x00.
  417. * Some devices might return other completion codes to convey OEM specific
  418. * information, or just to be contrary. If the behaviour of a particular
  419. * device is not well known with respect to completion codes, assume that if
  420. * a completion code other than 0x00 is returned, the value in \a reading
  421. * is invalid.
  422. */
  423. /*@external@*/extern int
  424. ipmi_chassis_power_cycle( u8 slave )
  425. /*@globals fileSystem@*//*@modifies fileSystem@*/;
  426. /** \brief Send the IPMI Chassis Hard Reset command
  427. *
  428. * \param slave Slave address of the IPMI device (8-bit format)
  429. *
  430. * \retval "IPMI Completion Code" Success
  431. * \retval HHM_FAILURE Failure, errno set
  432. *
  433. * \note For almost all sensors, the IPMI response code should be 0x00.
  434. * Some devices might return other completion codes to convey OEM specific
  435. * information, or just to be contrary. If the behaviour of a particular
  436. * device is not well known with respect to completion codes, assume that if
  437. * a completion code other than 0x00 is returned, the value in \a reading
  438. * is invalid.
  439. */
  440. /*@external@*/extern int
  441. ipmi_chassis_hard_reset( u8 slave )
  442. /*@globals fileSystem@*//*@modifies fileSystem@*/;
  443. /** \brief Send the IPMI Chassis ACPI Power Down command
  444. *
  445. * \param slave Slave address of the IPMI device (8-bit format)
  446. *
  447. * \retval "IPMI Completion Code" Success
  448. * \retval HHM_FAILURE Failure, errno set
  449. *
  450. * \note For almost all sensors, the IPMI response code should be 0x00.
  451. * Some devices might return other completion codes to convey OEM specific
  452. * information, or just to be contrary. If the behaviour of a particular
  453. * device is not well known with respect to completion codes, assume that if
  454. * a completion code other than 0x00 is returned, the value in \a reading
  455. * is invalid.
  456. */
  457. /*@external@*/extern int
  458. ipmi_chassis_acpi_power_down( u8 slave )
  459. /*@globals fileSystem@*//*@modifies fileSystem@*/;
  460. /** \brief Send an arbitrary IPMI command, and get the response
  461. *
  462. * Send any IPMI command your heart desires to any I2C/LUN combo and receive
  463. * the response. See the IPMI spec for further info.
  464. *
  465. * \param slave Slave address of the IPMI device (8-bit format)
  466. * \param netFn The net function of the command to send
  467. * \param targetLUN The LUN of the IPMI device
  468. * \param command A buffer containing the command number, and any extra data
  469. * which is needed for the command.
  470. * \param cmd_len The length of the command buffer
  471. * \param response_buffer The buffer which will be filled with the response
  472. * to your ipmi command.
  473. * \param response_len The size of the buffer to which
  474. * \a response_buffer points
  475. *
  476. * \retval "Length of the IPMI response" Success
  477. * \retval HHM_FAILURE Failure, errno set
  478. */
  479. /*@external@*/extern int
  480. ipmi_generic_command( u8 slave, u8 netFn, u8 targetLUN, u8 *command,
  481. size_t cmd_len, /*@out@*/u8 *response_buffer,
  482. size_t response_len )
  483. /*@globals fileSystem@*/
  484. /*@modifies *response_buffer,fileSystem@*/;
  485. /** \brief Convert a raw sensor reading to its final reading using an SDR
  486. *
  487. * Use the standard IPMI method and SDR data to convert a raw sensor reading
  488. * into its converted value. See the IPMI spec for further info on this
  489. * conversion.
  490. *
  491. * \param sdr_buffer A pointer to a complete SDR entry which contains reading
  492. * conversion data. IE, it is a Full SDR entry.
  493. * \param raw_reading The raw sensor reading you want to convert
  494. * \param converted_reading Pointer to an s32 that will be assigned the
  495. * converted reading on success.
  496. *
  497. * \retval 0 Success, or sensor out of IPMI sensor min/max reading range, with
  498. * 0 in \a converted_reading
  499. * \retval HHM_FAILURE Not enough information to perform the conversion
  500. */
  501. /*@external@*/extern int
  502. ipmi_convert_reading( u8 *sdr_buffer, u8 raw_reading, /*@out@*/float *converted_reading )
  503. /*@modifies *converted_reading@*/;
  504. /** \brief Use an SDR entry to read the corresponding sensor
  505. *
  506. * Use a (usually saved) SDR entry to read the current value of
  507. * a sensor. The reading is performed as specified by the SDR
  508. * entry passed in \a sdr_buffer. The reading obtained is the
  509. * final, converted sensor reading
  510. *
  511. * \param sdr_buffer Pointer to a complete SDR buffer that contains
  512. * information on accessing a sensor.
  513. * \param raw_reading The raw sensor reading fresh from the BMC.
  514. * \param reading The converted sensor reading read and converted
  515. * as specified by the SDR entry.
  516. * \param discrete Pointer to a u8 used as a boolean, indicates if
  517. * the sensor read is a discrete sensor instead of an analog sensor
  518. *
  519. * \retval HHM_FAILURE Failure
  520. * \retval IPMI_SENSOR_DISABLED Reading is invalid, this sensor is disabled
  521. * \retval 0 Success
  522. */
  523. /*@external@*/extern int
  524. hhm_access_sdr_sensors( u8 *sdr_buffer, /*@out@*/u8 *raw_reading,
  525. /*@out@*/float *reading, /*@out@*/u8 *discrete )
  526. /*@globals fileSystem@*/
  527. /*@modifies *raw_reading,*reading,fileSystem,discrete@*/;
  528. /** \} */
  529. /** \brief Extract a descriptive string from an SDR entry
  530. *
  531. * Read the text description field from the provided SDR, convert it
  532. * to a nice standard ascii string, and copy it into \a description.
  533. *
  534. * \param sdr_buffer Pointer to a buffer containing an SDR
  535. * \param description Pointer to a buffer that will be filled with the
  536. * description of this SDR. \a Description should have 17 bytes of storage,
  537. * to account for the 16 possible bytes of description defined by IPMI, and
  538. * the \c NULL terminator.
  539. *
  540. * \retval 0 Success
  541. * \retval HHM_FAILURE Failure, errno set
  542. */
  543. /*@external@*/extern int
  544. extract_sdr_id( u8 *sdr_buffer, /*@out@*/char *description )
  545. /*@modifies *description@*/;
  546. /** \brief Convert an IPMI (or AMI OEM) unit type code to a descriptive string
  547. *
  548. * Convert an IPMI or AMI OEM unit type code into a string suitable for
  549. * display. This function could (for example), convert the unit type 0x01 to
  550. * the string "degrees C".
  551. *
  552. * \param unit_type_code An IPMI (or AMI OEM) unit type code
  553. * \param unit_type_string A char buffer that will contain the unit string
  554. * on completion.
  555. * \param unit_string_len The length of the unit string. Expect around 20
  556. * chars at most, but there is no internal limit to any particular size.
  557. *
  558. * \retval 0 Success
  559. * \retval HHM_FAILURE Failure, errno set, "Unrecognized" is set in
  560. * \a unit_type_string.
  561. */
  562. /*@external@*/extern int
  563. sdk_unit_to_string( u8 unit_type_code, /*@out@*/char *unit_type_string,
  564. size_t unit_string_len )
  565. /*@modifies unit_type_string@*/;
  566. /** \brief Generate a string corresponding to a discrete reading code
  567. *
  568. * Convert a discrete state (supplied in \a reading) into a string using the
  569. * \a reading_type_code and the IPMI table of discrete states.
  570. *
  571. * \param reading The sensor reading (discrete state)
  572. * \param reading_type_code The reading type code from the SDR
  573. * \param sensor_type The sensor type code from the SDR
  574. * \param discrete_string Pointer to a buffer we will fill with text
  575. * describing the discrete state
  576. * \param string_size The amount of storage at \a discrete_string
  577. *
  578. * \retval 0 Success
  579. * \retval HHM_FAILURE Failure, errno set
  580. */
  581. /*@external@*/extern int
  582. ipmi_discrete_reading_string( s32 reading, u8 reading_type_code,
  583. u8 sensor_type,
  584. /*@out@*/char *discrete_string,
  585. size_t string_size )
  586. /*@modifies discrete_string@*/;
  587. /** \brief Get the threshold state of a sensor based on its SDR
  588. *
  589. * Determine the state of a given sensor based on threshold information
  590. * from its SDR. This state is a bitfield with individual bits indicating
  591. * which thresholds have been passed. A bit is set to 1 when the threshold
  592. * it represents has been passed. This function also handles threshold
  593. * hysteresis values correctly.
  594. *
  595. * \param sensor_reading A raw, unconverted sensor reading
  596. * \param sdr_buffer A pointer to a buffer containing an SDR
  597. * \param last_state The previous state of the sensor, obtained from a prior
  598. * call to this function. Pass \ref THRESH_UNINITIALIZED if there is no
  599. * \a last_state because this is the first call to \ref get_sdr_sensor_state
  600. * for this sensor.
  601. * \param current_state Variable that will be filled with the current state
  602. * of the sensor, based on information passed in \a sensor_reading and
  603. * \a sdr_buffer. See \ref THRESH_UP_NONCRIT for an example of a state
  604. * bitfield.
  605. *
  606. * \retval 0 Success
  607. * \retval HHM_FAILURE Failure, errno set
  608. */
  609. /*@external@*/extern int
  610. get_sdr_sensor_state( u8 sensor_reading, u8 *sdr_buffer, u16 last_state,
  611. /*@out@*/u16 *current_state )
  612. /*@modifies *current_state@*/;
  613. #endif