ipmivar.h revision 1.1 1 /* $NetBSD: ipmivar.h,v 1.1 2006/10/01 18:37:55 bouyer Exp $ */
2
3 /*
4 * Copyright (c) 2005 Jordan Hargrave
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 */
29
30 #include <dev/sysmon/sysmonvar.h>
31
32 #ifndef _IPMIVAR_H_
33 #define _IPMIVAR_H_
34
35 #define IPMI_IF_KCS 1
36 #define IPMI_IF_SMIC 2
37 #define IPMI_IF_BT 3
38
39 #define IPMI_IF_KCS_NREGS 2
40 #define IPMI_IF_SMIC_NREGS 3
41 #define IPMI_IF_BT_NREGS 3
42
43 struct ipmi_thread;
44 struct ipmi_softc;
45
46 struct ipmi_bmc_args{
47 int offset;
48 u_int8_t mask;
49 u_int8_t value;
50 volatile u_int8_t *v;
51 };
52
53 struct ipmi_attach_args {
54 bus_space_tag_t iaa_iot;
55 bus_space_tag_t iaa_memt;
56
57 int iaa_if_type;
58 int iaa_if_rev;
59 int iaa_if_iotype;
60 int iaa_if_iobase;
61 int iaa_if_iospacing;
62 int iaa_if_irq;
63 int iaa_if_irqlvl;
64 };
65
66 struct ipmi_if {
67 const char *name;
68 int nregs;
69 void *(*buildmsg)(struct ipmi_softc *, int, int, int,
70 const void *, int *);
71 int (*sendmsg)(struct ipmi_softc *, int, const u_int8_t *);
72 int (*recvmsg)(struct ipmi_softc *, int, int *, u_int8_t *);
73 int (*reset)(struct ipmi_softc *);
74 int (*probe)(struct ipmi_softc *);
75 };
76
77 struct ipmi_softc {
78 struct device sc_dev;
79
80 struct ipmi_if *sc_if; /* Interface layer */
81 int sc_if_iospacing; /* Spacing of I/O ports */
82 int sc_if_rev; /* IPMI Revision */
83
84 void *sc_ih; /* Interrupt/IO handles */
85 bus_space_tag_t sc_iot;
86 bus_space_handle_t sc_ioh;
87
88 int sc_btseq;
89
90 struct proc *sc_kthread;
91
92 struct callout sc_callout;
93 int sc_max_retries;
94 int sc_retries;
95 int sc_wakeup;
96
97 struct lock sc_lock;
98
99 struct ipmi_bmc_args *sc_iowait_args;
100
101 struct ipmi_sensor *current_sensor;
102 volatile int sc_thread_running;
103 struct sysmon_wdog sc_wdog;
104 struct sysmon_envsys sc_envsys;
105 #define sc_ranges sc_envsys.sme_ranges
106 #define sc_sensor_info sc_envsys.sme_sensor_info
107 #define sc_sensor_data sc_envsys.sme_sensor_data
108 int sc_nsensors; /* total number of sensors */
109 int sc_nsensors_typ[ENVSYS_NSENSORS]; /* number per type */
110 };
111
112 struct ipmi_thread {
113 struct ipmi_softc *sc;
114 volatile int running;
115 };
116
117 #define IPMI_WDOG_USE_NLOG 0x80
118 #define IPMI_WDOG_USE_NSTOP 0x40
119 #define IPMI_WDOG_USE_USE_MASK 0x07
120 #define IPMI_WDOG_USE_USE_FRB2 0x01
121 #define IPMI_WDOG_USE_USE_POST 0x02
122 #define IPMI_WDOG_USE_USE_OSLOAD 0x03
123 #define IPMI_WDOG_USE_USE_OS 0x04
124 #define IPMI_WDOG_USE_USE_EOM 0x05
125
126 #define IPMI_WDOG_ACT_MASK 0x07
127 #define IPMI_WDOG_ACT_DISABLED 0x00
128 #define IPMI_WDOG_ACT_RESET 0x01
129 #define IPMI_WDOG_ACT_PWROFF 0x02
130 #define IPMI_WDOG_ACT_PWRCYCLE 0x03
131
132 #define IPMI_WDOG_ACT_PRE_MASK 0x70
133 #define IPMI_WDOG_ACT_PRE_DISABLED 0x00
134 #define IPMI_WDOG_ACT_PRE_SMI 0x10
135 #define IPMI_WDOG_ACT_PRE_NMI 0x20
136 #define IPMI_WDOG_ACT_PRE_INTERRUPT 0x30
137
138 struct ipmi_set_watchdog {
139 u_int8_t wdog_use;
140 u_int8_t wdog_action;
141 u_int8_t wdog_pretimeout;
142 u_int8_t wdog_flags;
143 u_int16_t wdog_timeout;
144 } __packed;
145
146 struct ipmi_get_watchdog {
147 u_int8_t wdog_use;
148 u_int8_t wdog_action;
149 u_int8_t wdog_pretimeout;
150 u_int8_t wdog_flags;
151 u_int16_t wdog_timeout;
152 u_int16_t wdog_countdown;
153 } __packed;
154
155 void ipmi_create_thread(void *);
156 void ipmi_poll_thread(void *);
157
158 int kcs_probe(struct ipmi_softc *);
159 int kcs_reset(struct ipmi_softc *);
160 int kcs_sendmsg(struct ipmi_softc *, int, const u_int8_t *);
161 int kcs_recvmsg(struct ipmi_softc *, int, int *len, u_int8_t *);
162
163 int bt_probe(struct ipmi_softc *);
164 int bt_reset(struct ipmi_softc *);
165 int bt_sendmsg(struct ipmi_softc *, int, const u_int8_t *);
166 int bt_recvmsg(struct ipmi_softc *, int, int *, u_int8_t *);
167
168 int smic_probe(struct ipmi_softc *);
169 int smic_reset(struct ipmi_softc *);
170 int smic_sendmsg(struct ipmi_softc *, int, const u_int8_t *);
171 int smic_recvmsg(struct ipmi_softc *, int, int *, u_int8_t *);
172
173 struct dmd_ipmi {
174 u_int8_t dmd_sig[4]; /* Signature 'IPMI' */
175 u_int8_t dmd_i2c_address; /* Address of BMC */
176 u_int8_t dmd_nvram_address; /* Address of NVRAM */
177 u_int8_t dmd_if_type; /* IPMI Interface Type */
178 u_int8_t dmd_if_rev; /* IPMI Interface Revision */
179 } __packed;
180
181
182 #define APP_NETFN 0x06
183 #define APP_GET_DEVICE_ID 0x01
184 #define APP_RESET_WATCHDOG 0x22
185 #define APP_SET_WATCHDOG_TIMER 0x24
186 #define APP_GET_WATCHDOG_TIMER 0x25
187
188 #define TRANSPORT_NETFN 0xC
189 #define BRIDGE_NETFN 0x2
190
191 #define STORAGE_NETFN 0x0A
192 #define STORAGE_GET_FRU_INV_AREA 0x10
193 #define STORAGE_READ_FRU_DATA 0x11
194 #define STORAGE_RESERVE_SDR 0x22
195 #define STORAGE_GET_SDR 0x23
196 #define STORAGE_ADD_SDR 0x24
197 #define STORAGE_ADD_PARTIAL_SDR 0x25
198 #define STORAGE_DELETE_SDR 0x26
199 #define STORAGE_RESERVE_SEL 0x42
200 #define STORAGE_GET_SEL 0x43
201 #define STORAGE_ADD_SEL 0x44
202 #define STORAGE_ADD_PARTIAL_SEL 0x45
203 #define STORAGE_DELETE_SEL 0x46
204
205 #define SE_NETFN 0x04
206 #define SE_GET_SDR_INFO 0x20
207 #define SE_GET_SDR 0x21
208 #define SE_RESERVE_SDR 0x22
209 #define SE_GET_SENSOR_FACTOR 0x23
210 #define SE_SET_SENSOR_HYSTERESIS 0x24
211 #define SE_GET_SENSOR_HYSTERESIS 0x25
212 #define SE_SET_SENSOR_THRESHOLD 0x26
213 #define SE_GET_SENSOR_THRESHOLD 0x27
214 #define SE_SET_SENSOR_EVENT_ENABLE 0x28
215 #define SE_GET_SENSOR_EVENT_ENABLE 0x29
216 #define SE_REARM_SENSOR_EVENTS 0x2A
217 #define SE_GET_SENSOR_EVENT_STATUS 0x2B
218 #define SE_GET_SENSOR_READING 0x2D
219 #define SE_SET_SENSOR_TYPE 0x2E
220 #define SE_GET_SENSOR_TYPE 0x2F
221
222 struct sdrhdr {
223 u_int16_t record_id; /* SDR Record ID */
224 u_int8_t sdr_version; /* SDR Version */
225 u_int8_t record_type; /* SDR Record Type */
226 u_int8_t record_length; /* SDR Record Length */
227 } __packed;
228
229 /* SDR: Record Type 1 */
230 struct sdrtype1 {
231 struct sdrhdr sdrhdr;
232
233 u_int8_t owner_id;
234 u_int8_t owner_lun;
235 u_int8_t sensor_num;
236
237 u_int8_t entity_id;
238 u_int8_t entity_instance;
239 u_int8_t sensor_init;
240 u_int8_t sensor_caps;
241 u_int8_t sensor_type;
242 u_int8_t event_code;
243 u_int16_t trigger_mask;
244 u_int16_t reading_mask;
245 u_int16_t settable_mask;
246 u_int8_t units1;
247 u_int8_t units2;
248 u_int8_t units3;
249 u_int8_t linear;
250 u_int8_t m;
251 u_int8_t m_tolerance;
252 u_int8_t b;
253 u_int8_t b_accuracy;
254 u_int8_t accuracyexp;
255 u_int8_t rbexp;
256 u_int8_t analogchars;
257 u_int8_t nominalreading;
258 u_int8_t normalmax;
259 u_int8_t normalmin;
260 u_int8_t sensormax;
261 u_int8_t sensormin;
262 u_int8_t uppernr;
263 u_int8_t upperc;
264 u_int8_t uppernc;
265 u_int8_t lowernr;
266 u_int8_t lowerc;
267 u_int8_t lowernc;
268 u_int8_t physt;
269 u_int8_t nhyst;
270 u_int8_t resvd[2];
271 u_int8_t oem;
272 u_int8_t typelen;
273 u_int8_t name[1];
274 } __packed;
275
276 /* SDR: Record Type 2 */
277 struct sdrtype2 {
278 struct sdrhdr sdrhdr;
279
280 u_int8_t owner_id;
281 u_int8_t owner_lun;
282 u_int8_t sensor_num;
283
284 u_int8_t entity_id;
285 u_int8_t entity_instance;
286 u_int8_t sensor_init;
287 u_int8_t sensor_caps;
288 u_int8_t sensor_type;
289 u_int8_t event_code;
290 u_int16_t trigger_mask;
291 u_int16_t reading_mask;
292 u_int16_t set_mask;
293 u_int8_t units1;
294 u_int8_t units2;
295 u_int8_t units3;
296 u_int8_t share1;
297 u_int8_t share2;
298 u_int8_t physt;
299 u_int8_t nhyst;
300 u_int8_t resvd[3];
301 u_int8_t oem;
302 u_int8_t typelen;
303 u_int8_t name[1];
304 } __packed;
305
306 int ipmi_probe(struct ipmi_attach_args *);
307
308 #endif /* _IPMIVAR_H_ */
309