ipmivar.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /* $OpenBSD: ipmivar.h,v 1.19 2015/01/07 07:49:18 yasuoka Exp $ */
  2. /*
  3. * Copyright (c) 2005 Jordan Hargrave
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
  16. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
  19. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  21. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  23. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25. * SUCH DAMAGE.
  26. *
  27. */
  28. #ifndef _IPMIVAR_H_
  29. #define _IPMIVAR_H_
  30. #include <sys/timeout.h>
  31. #include <sys/rwlock.h>
  32. #include <sys/sensors.h>
  33. #define IPMI_IF_KCS 1
  34. #define IPMI_IF_SMIC 2
  35. #define IPMI_IF_BT 3
  36. #define IPMI_IF_KCS_NREGS 2
  37. #define IPMI_IF_SMIC_NREGS 3
  38. #define IPMI_IF_BT_NREGS 3
  39. struct ipmi_thread;
  40. struct ipmi_softc;
  41. struct ipmi_bmc_args{
  42. int offset;
  43. u_int8_t mask;
  44. u_int8_t value;
  45. volatile u_int8_t *v;
  46. };
  47. struct ipmi_attach_args {
  48. char *iaa_name;
  49. bus_space_tag_t iaa_iot;
  50. bus_space_tag_t iaa_memt;
  51. int iaa_if_type;
  52. int iaa_if_rev;
  53. int iaa_if_iotype;
  54. int iaa_if_iobase;
  55. int iaa_if_iospacing;
  56. int iaa_if_irq;
  57. int iaa_if_irqlvl;
  58. };
  59. struct ipmi_if {
  60. const char *name;
  61. int nregs;
  62. void *(*buildmsg)(struct ipmi_softc *, int, int, int,
  63. const void *, int *);
  64. int (*sendmsg)(struct ipmi_softc *, int, const u_int8_t *);
  65. int (*recvmsg)(struct ipmi_softc *, int, int *, u_int8_t *);
  66. int (*reset)(struct ipmi_softc *);
  67. int (*probe)(struct ipmi_softc *);
  68. };
  69. struct ipmi_softc {
  70. struct device sc_dev;
  71. struct ipmi_if *sc_if; /* Interface layer */
  72. int sc_if_iospacing; /* Spacing of I/O ports */
  73. int sc_if_rev; /* IPMI Revision */
  74. void *sc_ih; /* Interrupt/IO handles */
  75. bus_space_tag_t sc_iot;
  76. bus_space_handle_t sc_ioh;
  77. int sc_btseq;
  78. int sc_wdog_period;
  79. struct ipmi_thread *sc_thread;
  80. struct timeout sc_timeout;
  81. int sc_max_retries;
  82. int sc_retries;
  83. int sc_wakeup;
  84. struct rwlock sc_lock;
  85. struct ipmi_bmc_args *sc_iowait_args;
  86. struct ipmi_sensor *current_sensor;
  87. struct ksensordev sc_sensordev;
  88. int sc_poll;
  89. };
  90. struct ipmi_thread {
  91. struct ipmi_softc *sc;
  92. volatile int running;
  93. };
  94. #define IPMI_WDOG_MASK 0x03
  95. #define IPMI_WDOG_DISABLED 0x00
  96. #define IPMI_WDOG_REBOOT 0x01
  97. #define IPMI_WDOG_PWROFF 0x02
  98. #define IPMI_WDOG_PWRCYCLE 0x03
  99. #define IPMI_WDOG_PRE_DISABLED 0x00
  100. #define IPMI_WDOG_PRE_SMI 0x01
  101. #define IPMI_WDOG_PRE_NMI 0x02
  102. #define IPMI_WDOG_PRE_INTERRUPT 0x03
  103. #define IPMI_SET_WDOG_TIMER 0
  104. #define IPMI_SET_WDOG_ACTION 1
  105. #define IPMI_SET_WDOG_PRETIMO 2
  106. #define IPMI_SET_WDOG_FLAGS 3
  107. #define IPMI_SET_WDOG_TIMOL 4
  108. #define IPMI_SET_WDOG_TIMOM 5
  109. #define IPMI_SET_WDOG_MAX 6
  110. #define IPMI_GET_WDOG_TIMER IPMI_SET_WDOG_TIMER
  111. #define IPMI_GET_WDOG_ACTION IPMI_SET_WDOG_ACTION
  112. #define IPMI_GET_WDOG_PRETIMO IPMI_SET_WDOG_PRETIMO
  113. #define IPMI_GET_WDOG_FLAGS IPMI_SET_WDOG_FLAGS
  114. #define IPMI_GET_WDOG_TIMOL IPMI_SET_WDOG_TIMOL
  115. #define IPMI_GET_WDOG_TIMOM IPMI_SET_WDOG_TIMOM
  116. #define IPMI_GET_WDOG_PRECDL 6
  117. #define IPMI_GET_WDOG_PRECDM 7
  118. #define IPMI_GET_WDOG_MAX 8
  119. void ipmi_create_thread(void *);
  120. void ipmi_poll_thread(void *);
  121. int kcs_probe(struct ipmi_softc *);
  122. int kcs_reset(struct ipmi_softc *);
  123. int kcs_sendmsg(struct ipmi_softc *, int, const u_int8_t *);
  124. int kcs_recvmsg(struct ipmi_softc *, int, int *len, u_int8_t *);
  125. int bt_probe(struct ipmi_softc *);
  126. int bt_reset(struct ipmi_softc *);
  127. int bt_sendmsg(struct ipmi_softc *, int, const u_int8_t *);
  128. int bt_recvmsg(struct ipmi_softc *, int, int *, u_int8_t *);
  129. int smic_probe(struct ipmi_softc *);
  130. int smic_reset(struct ipmi_softc *);
  131. int smic_sendmsg(struct ipmi_softc *, int, const u_int8_t *);
  132. int smic_recvmsg(struct ipmi_softc *, int, int *, u_int8_t *);
  133. struct dmd_ipmi {
  134. u_int8_t dmd_sig[4]; /* Signature 'IPMI' */
  135. u_int8_t dmd_i2c_address; /* Address of BMC */
  136. u_int8_t dmd_nvram_address; /* Address of NVRAM */
  137. u_int8_t dmd_if_type; /* IPMI Interface Type */
  138. u_int8_t dmd_if_rev; /* IPMI Interface Revision */
  139. } __packed;
  140. #define APP_NETFN 0x06
  141. #define APP_GET_DEVICE_ID 0x01
  142. #define APP_RESET_WATCHDOG 0x22
  143. #define APP_SET_WATCHDOG_TIMER 0x24
  144. #define APP_GET_WATCHDOG_TIMER 0x25
  145. #define TRANSPORT_NETFN 0xC
  146. #define BRIDGE_NETFN 0x2
  147. #define STORAGE_NETFN 0x0A
  148. #define STORAGE_GET_FRU_INV_AREA 0x10
  149. #define STORAGE_READ_FRU_DATA 0x11
  150. #define STORAGE_RESERVE_SDR 0x22
  151. #define STORAGE_GET_SDR 0x23
  152. #define STORAGE_ADD_SDR 0x24
  153. #define STORAGE_ADD_PARTIAL_SDR 0x25
  154. #define STORAGE_DELETE_SDR 0x26
  155. #define STORAGE_RESERVE_SEL 0x42
  156. #define STORAGE_GET_SEL 0x43
  157. #define STORAGE_ADD_SEL 0x44
  158. #define STORAGE_ADD_PARTIAL_SEL 0x45
  159. #define STORAGE_DELETE_SEL 0x46
  160. #define SE_NETFN 0x04
  161. #define SE_GET_SDR_INFO 0x20
  162. #define SE_GET_SDR 0x21
  163. #define SE_RESERVE_SDR 0x22
  164. #define SE_GET_SENSOR_FACTOR 0x23
  165. #define SE_SET_SENSOR_HYSTERESIS 0x24
  166. #define SE_GET_SENSOR_HYSTERESIS 0x25
  167. #define SE_SET_SENSOR_THRESHOLD 0x26
  168. #define SE_GET_SENSOR_THRESHOLD 0x27
  169. #define SE_SET_SENSOR_EVENT_ENABLE 0x28
  170. #define SE_GET_SENSOR_EVENT_ENABLE 0x29
  171. #define SE_REARM_SENSOR_EVENTS 0x2A
  172. #define SE_GET_SENSOR_EVENT_STATUS 0x2B
  173. #define SE_GET_SENSOR_READING 0x2D
  174. #define SE_SET_SENSOR_TYPE 0x2E
  175. #define SE_GET_SENSOR_TYPE 0x2F
  176. struct sdrhdr {
  177. u_int16_t record_id; /* SDR Record ID */
  178. u_int8_t sdr_version; /* SDR Version */
  179. u_int8_t record_type; /* SDR Record Type */
  180. u_int8_t record_length; /* SDR Record Length */
  181. } __packed;
  182. /* SDR: Record Type 1 */
  183. struct sdrtype1 {
  184. struct sdrhdr sdrhdr;
  185. u_int8_t owner_id;
  186. u_int8_t owner_lun;
  187. u_int8_t sensor_num;
  188. u_int8_t entity_id;
  189. u_int8_t entity_instance;
  190. u_int8_t sensor_init;
  191. u_int8_t sensor_caps;
  192. u_int8_t sensor_type;
  193. u_int8_t event_code;
  194. u_int16_t trigger_mask;
  195. u_int16_t reading_mask;
  196. u_int16_t settable_mask;
  197. u_int8_t units1;
  198. u_int8_t units2;
  199. u_int8_t units3;
  200. u_int8_t linear;
  201. u_int8_t m;
  202. u_int8_t m_tolerance;
  203. u_int8_t b;
  204. u_int8_t b_accuracy;
  205. u_int8_t accuracyexp;
  206. u_int8_t rbexp;
  207. u_int8_t analogchars;
  208. u_int8_t nominalreading;
  209. u_int8_t normalmax;
  210. u_int8_t normalmin;
  211. u_int8_t sensormax;
  212. u_int8_t sensormin;
  213. u_int8_t uppernr;
  214. u_int8_t upperc;
  215. u_int8_t uppernc;
  216. u_int8_t lowernr;
  217. u_int8_t lowerc;
  218. u_int8_t lowernc;
  219. u_int8_t physt;
  220. u_int8_t nhyst;
  221. u_int8_t resvd[2];
  222. u_int8_t oem;
  223. u_int8_t typelen;
  224. u_int8_t name[1];
  225. } __packed;
  226. /* SDR: Record Type 2 */
  227. struct sdrtype2 {
  228. struct sdrhdr sdrhdr;
  229. u_int8_t owner_id;
  230. u_int8_t owner_lun;
  231. u_int8_t sensor_num;
  232. u_int8_t entity_id;
  233. u_int8_t entity_instance;
  234. u_int8_t sensor_init;
  235. u_int8_t sensor_caps;
  236. u_int8_t sensor_type;
  237. u_int8_t event_code;
  238. u_int16_t trigger_mask;
  239. u_int16_t reading_mask;
  240. u_int16_t set_mask;
  241. u_int8_t units1;
  242. u_int8_t units2;
  243. u_int8_t units3;
  244. u_int8_t share1;
  245. u_int8_t share2;
  246. u_int8_t physt;
  247. u_int8_t nhyst;
  248. u_int8_t resvd[3];
  249. u_int8_t oem;
  250. u_int8_t typelen;
  251. u_int8_t name[1];
  252. } __packed;
  253. int ipmi_probe(void *);
  254. #endif /* _IPMIVAR_H_ */