xref: /titanic_52/usr/src/lib/libipmi/common/libipmi.h (revision 2f172c55ef76964744bc62b4500ece87f3089b4d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LIBIPMI_H
27 #define	_LIBIPMI_H
28 
29 #include <sys/bmc_intf.h>
30 #include <sys/byteorder.h>
31 #include <sys/sysmacros.h>
32 
33 /*
34  * Private interfaces for communicating with attached services over IPMI.  This
35  * library is designed for system software communicating with Sun-supported
36  * service processors over /dev/bmc.  It is not a generic IPMI library.
37  *
38  * Documentation references refer to "Intelligent Platform Management Interface
39  * Specification Second Generation v2.0", document revision 1.0 with Februrary
40  * 15, 2006 Markup from "IPMI v2.0 Addenda, Errata, and Clarifications Revision
41  * 3".
42  */
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 typedef struct ipmi_handle ipmi_handle_t;
49 
50 #pragma pack(1)
51 
52 /*
53  * Basic netfn definitions.  See section 5.1.
54  */
55 #define	IPMI_NETFN_APP			BMC_NETFN_APP
56 #define	IPMI_NETFN_STORAGE		BMC_NETFN_STORAGE
57 #define	IPMI_NETFN_SE			BMC_NETFN_SE
58 #define	IPMI_NETFN_TRANSPORT		0x0C
59 #define	IPMI_NETFN_OEM			0x2e
60 
61 /*
62  * Error definitions
63  */
64 #define	EIPMI_BASE	2000
65 
66 typedef enum {
67 	EIPMI_NOMEM = EIPMI_BASE,	/* memory allocation failure */
68 	EIPMI_BMC_OPEN_FAILED,		/* failed to open /dev/bmc */
69 	EIPMI_BMC_PUTMSG,		/* failed to send message to /dev/bmc */
70 	EIPMI_BMC_GETMSG,	/* failed to read response from /dev/bmc */
71 	EIPMI_BMC_RESPONSE,		/* response from /dev/bmc failed */
72 	EIPMI_INVALID_COMMAND,		/* invalid command */
73 	EIPMI_COMMAND_TIMEOUT,		/* command timeout */
74 	EIPMI_DATA_LENGTH_EXCEEDED,	/* maximum data length exceeded */
75 	EIPMI_SEND_FAILED,		/* failed to send BMC request */
76 	EIPMI_UNSPECIFIED,		/* unspecified BMC error */
77 	EIPMI_UNKNOWN,			/* unknown error */
78 	EIPMI_BAD_RESPONSE,		/* received unexpected response */
79 	EIPMI_BAD_RESPONSE_LENGTH,	/* unexpected response length */
80 	EIPMI_INVALID_RESERVATION,	/* invalid or cancelled reservation */
81 	EIPMI_NOT_PRESENT,		/* requested entity not present */
82 	EIPMI_INVALID_REQUEST,		/* malformed request data */
83 	EIPMI_BUSY,			/* service processor is busy */
84 	EIPMI_NOSPACE,			/* service processor is out of space */
85 	EIPMI_UNAVAILABLE,		/* service processor is unavailable */
86 	EIPMI_ACCESS,			/* insufficient privileges */
87 	EIPMI_BADPARAM,			/* parameter is not supported */
88 	EIPMI_READONLY,			/* attempt to write read-only param */
89 	EIPMI_WRITEONLY			/* attempt to read write-only param */
90 } ipmi_errno_t;
91 
92 /*
93  * Basic library functions.
94  *
95  * The ipmi_handle is the primary interface to the library.  The library itself
96  * is not MT-safe, but it is safe within a single handle.  Multithreaded clients
97  * should either open multiple handles, or otherwise synchronize access to the
98  * same handle.
99  *
100  * There is a single command response buffer that is stored with the handle, to
101  * simplify memory management in the caller.  The memory referenced by a command
102  * response is only valid until the next command is issued.  The caller is
103  * responsible for making a copy of the response if it is needed.
104  */
105 extern ipmi_handle_t *ipmi_open(int *, char **);
106 extern void ipmi_close(ipmi_handle_t *);
107 
108 extern int ipmi_errno(ipmi_handle_t *);
109 extern const char *ipmi_errmsg(ipmi_handle_t *);
110 
111 /*
112  * Raw requests.  See section 5.
113  */
114 typedef struct ipmi_cmd {
115 	uint8_t		ic_netfn:6;
116 	uint8_t		ic_lun:2;
117 	uint8_t		ic_cmd;
118 	uint16_t	ic_dlen;
119 	void		*ic_data;
120 } ipmi_cmd_t;
121 
122 extern ipmi_cmd_t *ipmi_send(ipmi_handle_t *, ipmi_cmd_t *);
123 
124 /*
125  * Retrieve basic information about the IPMI device.  See section 20.1 "Get
126  * Device ID Command".
127  */
128 #define	IPMI_CMD_GET_DEVICEID		0x01
129 
130 typedef struct ipmi_deviceid {
131 	uint8_t		id_devid;
132 	DECL_BITFIELD3(
133 	    id_dev_rev		:4,
134 	    __reserved		:3,
135 	    id_dev_sdrs		:1);
136 	DECL_BITFIELD2(
137 	    id_firm_major	:7,
138 	    id_dev_available	:1);
139 	uint8_t		id_firm_minor;
140 	uint8_t		id_ipmi_rev;
141 	uint8_t		id_dev_support;
142 	uint8_t		id_manufacturer[3];
143 	uint16_t	id_product;
144 } ipmi_deviceid_t;
145 
146 #define	IPMI_OEM_SUN		0x2a
147 #define	IPMI_PROD_SUN_ILOM	0x4701
148 
149 ipmi_deviceid_t *ipmi_get_deviceid(ipmi_handle_t *);
150 
151 #define	ipmi_devid_manufacturer(dp)		\
152 	((dp)->id_manufacturer[0] |		\
153 	((dp)->id_manufacturer[1] << 8) |	\
154 	((dp)->id_manufacturer[2] << 16))
155 
156 const char *ipmi_firmware_version(ipmi_handle_t *);
157 
158 /*
159  * Get Channel Info.  See section 22.24.
160  */
161 typedef struct ipmi_channel_info {
162 	DECL_BITFIELD2(
163 	    ici_number		:4,
164 	    __reserved1		:4);
165 	DECL_BITFIELD2(
166 	    ici_medium		:7,
167 	    __reserved2		:1);
168 	DECL_BITFIELD2(
169 	    ici_protocol	:5,
170 	    __reserved3		:3);
171 	DECL_BITFIELD3(
172 	    ici_session_count	:6,
173 	    ici_single_session	:1,
174 	    ici_multi_Session	:1);
175 	uint8_t		ici_vendor[3];
176 	uint8_t		ici_auxinfo[2];
177 } ipmi_channel_info_t;
178 
179 #define	IPMI_CMD_GET_CHANNEL_INFO	0x42
180 
181 /*
182  * Channel Numbers.  See section 6.3.
183  */
184 #define	IPMI_CHANNEL_PRIMARY		0x0
185 #define	IPMI_CHANNEL_MIN		0x1
186 #define	IPMI_CHANNEL_MAX		0xB
187 #define	IPMI_CHANNEL_CURRENT		0xE
188 #define	IPMI_CHANNEL_SYSTEM		0xF
189 
190 extern ipmi_channel_info_t *ipmi_get_channel_info(ipmi_handle_t *, int);
191 
192 /*
193  * Channel Protocol Types.  See section 6.4.
194  */
195 #define	IPMI_PROTOCOL_IPMB		0x1
196 #define	IPMI_PROTOCOL_ICMB		0x2
197 #define	IPMI_PROTOCOL_SMBUS		0x4
198 #define	IPMI_PROTOCOL_KCS		0x5
199 #define	IPMI_PROTOCOL_SMIC		0x6
200 #define	IPMI_PROTOCOL_BT10		0x7
201 #define	IPMI_PROTOCOL_BT15		0x8
202 #define	IPMI_PROTOCOL_TMODE		0x9
203 #define	IPMI_PROTOCOL_OEM1		0xC
204 #define	IPMI_PROTOCOL_OEM2		0xD
205 #define	IPMI_PROTOCOL_OEM3		0xE
206 #define	IPMI_PROTOCOL_OEM4		0xF
207 
208 /*
209  * Channel Medium Types.  See section 6.5.
210  */
211 #define	IPMI_MEDIUM_IPMB		0x1
212 #define	IPMI_MEDIUM_ICMB10		0x2
213 #define	IPMI_MEDIUM_ICMB09		0x3
214 #define	IPMI_MEDIUM_8023LAN		0x4
215 #define	IPMI_MEDIUM_RS232		0x5
216 #define	IPMI_MEDIUM_OTHERLAN		0x6
217 #define	IPMI_MEDIUM_PCISMBUS		0x7
218 #define	IPMI_MEDIUM_SMBUS10		0x8
219 #define	IPMI_MEDIUM_SMBUS20		0x9
220 #define	IPMI_MEDIUM_USB1		0xA
221 #define	IPMI_MEDIUM_USB2		0xB
222 #define	IPMI_MEDIUM_SYSTEM		0xC
223 
224 /*
225  * LAN Configuration.  See section 23.  While the underlying mechanism is
226  * implemented via a sequence of get/set parameter commands, we assume that
227  * consumers prefer to get and set information in chunks, and therefore expose
228  * the configuration as a structure, with some of the less useful fields
229  * removed.  When making changes, the consumer specifies which fields to apply
230  * along with the structure the library takes care of the rest of the work.
231  *
232  * This can be expanded in the future as needed.
233  */
234 
235 typedef struct ipmi_lan_config {
236 	boolean_t	ilc_set_in_progress;
237 	uint32_t	ilc_ipaddr;
238 	uint8_t		ilc_ipaddr_source;
239 	uint8_t		ilc_macaddr[6];
240 	uint32_t	ilc_subnet;
241 	uint32_t	ilc_gateway_addr;
242 } ipmi_lan_config_t;
243 
244 #define	IPMI_LAN_SRC_UNSPECIFIED	0x0
245 #define	IPMI_LAN_SRC_STATIC		0x1
246 #define	IPMI_LAN_SRC_DHCP		0x2
247 #define	IPMI_LAN_SRC_BIOS		0x3
248 #define	IPMI_LAN_SRC_OTHER		0x4
249 
250 #define	IPMI_LAN_SET_IPADDR		0x01
251 #define	IPMI_LAN_SET_IPADDR_SOURCE	0x02
252 #define	IPMI_LAN_SET_MACADDR		0x04
253 #define	IPMI_LAN_SET_SUBNET		0x08
254 #define	IPMI_LAN_SET_GATEWAY_ADDR	0x10
255 
256 #define	IPMI_CMD_SET_LAN_CONFIG		0x01
257 #define	IPMI_CMD_GET_LAN_CONFIG		0x02
258 
259 extern int ipmi_lan_get_config(ipmi_handle_t *, int,
260     ipmi_lan_config_t *);
261 extern int ipmi_lan_set_config(ipmi_handle_t *, int, ipmi_lan_config_t *, int);
262 
263 /*
264  * SEL (System Event Log) commands.  Currently the library only provides
265  * commands for reading the SEL.
266  */
267 
268 /*
269  * 31.2 Get SEL Info Command
270  */
271 #define	IPMI_CMD_GET_SEL_INFO		0x40
272 
273 typedef struct ipmi_sel_info {
274 	uint8_t		isel_version;
275 	uint16_t	isel_entries;
276 	uint16_t	isel_free;
277 	uint32_t	isel_add_ts;
278 	uint32_t	isel_erase_ts;
279 	DECL_BITFIELD6(
280 	    isel_supp_allocation	:1,
281 	    isel_supp_reserve		:1,
282 	    isel_supp_partial		:1,
283 	    isel_supp_delete		:1,
284 	    __reserved			:3,
285 	    isel_overflow		:1);
286 } ipmi_sel_info_t;
287 
288 extern ipmi_sel_info_t *ipmi_sel_get_info(ipmi_handle_t *);
289 extern boolean_t ipmi_sdr_changed(ipmi_handle_t *);
290 extern int ipmi_sdr_refresh(ipmi_handle_t *);
291 
292 /*
293  * 32.1 SEL Event Records
294  */
295 typedef struct ipmi_sel_event {
296 	uint16_t	isel_ev_next;
297 	uint16_t	isel_ev_recid;
298 	uint8_t		isel_ev_rectype;
299 	uint32_t	isel_ev_ts;
300 	DECL_BITFIELD2(
301 	    isel_ev_software	:1,
302 	    isel_ev_addr_or_id	:7);
303 	DECL_BITFIELD3(
304 	    isel_ev_lun		:2,
305 	    __reserved		:2,
306 	    isel_ev_channel	:4);
307 	uint8_t		isel_ev_rev;
308 	uint8_t		isel_ev_sensor_type;
309 	uint8_t		isel_ev_sensor_number;
310 	DECL_BITFIELD2(
311 	    isel_ev_type	:7,
312 	    isel_ev_dir		:1);
313 	uint8_t		isel_ev_data[3];
314 } ipmi_sel_event_t;
315 
316 #define	IPMI_EV_REV15		0x04
317 #define	IPMI_EV_REV1		0x03
318 
319 #define	IPMI_SEL_SYSTEM		0x02
320 #define	IPMI_SEL_OEMTS_LO	0xC0
321 #define	IPMI_SEL_OEMTS_HI	0xDF
322 #define	IPMI_SEL_OEM_LO		0xE0
323 #define	IPMI_SEL_OEM_HI		0xFF
324 
325 #define	IPMI_EV_ASSERT		0x0
326 #define	IPMI_EV_DEASSERT	0x1
327 
328 /*
329  * 32.2 OEM SEL Record (with timestamp)
330  */
331 typedef struct ipmi_sel_oem_ts {
332 	uint16_t	isel_oem_next;
333 	uint16_t	isel_oem_id;
334 	uint8_t		isel_oem_type;
335 	uint32_t	isel_oem_ts;
336 	uint8_t		isel_oem_devid[3];
337 	uint8_t		isel_oem_data[6];
338 } ipmi_sel_oem_ts_t;
339 
340 /*
341  * 32.3 OEM SEL Record (no timestamp)
342  */
343 typedef struct ipmi_sel_oem {
344 	uint16_t	isel_oem_next;
345 	uint16_t	isel_oem_id;
346 	uint8_t		isel_oem_type;
347 	uint8_t		isel_oem_data[13];
348 } ipmi_sel_oem_t;
349 
350 /*
351  * 29.3 Platform Event Message Command.
352  */
353 typedef struct ipmi_platform_event_message {
354 	uint8_t		ipem_generator;
355 	uint8_t		ipem_rev;
356 	uint8_t		ipem_sensor_type;
357 	uint8_t		ipem_sensor_num;
358 	DECL_BITFIELD2(
359 	    ipem_event_type	:7,
360 	    ipem_event_dir	:1);
361 	uint8_t		ipem_event_data[3];
362 } ipmi_platform_event_message_t;
363 
364 #define	IPMI_CMD_PLATFORM_EVENT_MESSAGE	0x02
365 
366 extern int ipmi_event_platform_message(ipmi_handle_t *,
367     ipmi_platform_event_message_t *);
368 
369 /*
370  * 29.7 Event Data Field Formats.  Consumers can cast the data field of the
371  * event record to the appropriate type depending on the sensor class.
372  */
373 
374 typedef struct ipmi_event_threshold {
375 	DECL_BITFIELD3(
376 	    iev_offset		:4,
377 	    iev_desc_byte3	:2,
378 	    iev_desc_byte2	:2);
379 	uint8_t		iev_reading;
380 	uint8_t		iev_threshold;
381 } ipmi_event_threshold_t;
382 
383 #define	IPMI_EV_DESC_UNSPECIFIED	0x00
384 #define	IPMI_EV_DESC_TRIGGER		0x01
385 #define	IPMI_EV_DESC_OEM		0x02
386 #define	IPMI_EV_DESC_SPECIFIC		0x03
387 
388 typedef struct ipmi_event_discrete {
389 	DECL_BITFIELD3(
390 	    iev_offset		:4,
391 	    iev_desc_byte3	:2,
392 	    iev_desc_byte2	:2);
393 	DECL_BITFIELD2(
394 	    iev_offset_type	:4,
395 	    iev_offset_severity	:4);
396 	uint8_t		iev_oem_code;
397 } ipmi_event_discrete_t;
398 
399 #define	IPMI_EV_DESC_PREVSTATE		0x01
400 #define	IPMI_EV_DESC_SPECIFIC		0x03
401 
402 typedef struct ipmi_event_oem {
403 	DECL_BITFIELD3(
404 	    iev_offset		:4,
405 	    iev_desc_byte3	:2,
406 	    iev_desc_byte2	:2);
407 	DECL_BITFIELD2(
408 	    iev_offset_type	:4,
409 	    iev_offset_severity	:4);
410 	uint8_t		iev_oem_code;
411 } ipmi_event_oem_t;
412 
413 /*
414  * Get SEL Entry Command.  See section 31.5.  We don't support partial reads, so
415  * this interface is quite a bit simpler than in the spec.  We default to
416  * returning event records, though the consumer should check the type field and
417  * cast it to the appropriate type if it is no IPMI_SEL_SYSTEM.
418  */
419 #define	IPMI_CMD_GET_SEL_ENTRY		0x43
420 
421 extern ipmi_sel_event_t *ipmi_sel_get_entry(ipmi_handle_t *, uint16_t);
422 
423 #define	IPMI_SEL_FIRST_ENTRY		0x0000
424 #define	IPMI_SEL_LAST_ENTRY		0xFFFF
425 
426 /*
427  * SEL time management.  See sections 31.10 and 31.11.
428  */
429 #define	IPMI_CMD_GET_SEL_TIME		0x48
430 #define	IPMI_CMD_SET_SEL_TIME		0x49
431 #define	IPMI_CMD_GET_SEL_UTC_OFFSET	0x5C
432 #define	IPMI_CMD_SET_SEL_UTC_OFFSET	0x5D
433 
434 extern int ipmi_sel_get_time(ipmi_handle_t *, uint32_t *);
435 extern int ipmi_sel_set_time(ipmi_handle_t *, uint32_t);
436 extern int ipmi_sel_get_utc_offset(ipmi_handle_t *, int *);
437 extern int ipmi_sel_set_utc_offset(ipmi_handle_t *, int);
438 
439 /*
440  * SDR (Sensor Device Record) requests.  A cache of the current SDR repository
441  * is kept as part of the IPMI handle and updated when necessary.  This does the
442  * work of processing the SDR names and providing an easy way to lookup
443  * individual records and iterate over all records.
444  */
445 
446 /*
447  * Get SDR Repository Info Command.  See section 33.9.
448  */
449 #define	IPMI_CMD_GET_SDR_INFO		0x20
450 
451 typedef struct ipmi_sdr_info {
452 	uint8_t		isi_version;
453 	uint16_t	isi_record_count;
454 	uint16_t	isi_free_space;
455 	uint32_t	isi_add_ts;
456 	uint32_t	isi_erase_ts;
457 	DECL_BITFIELD7(
458 	    isi_supp_allocation		:1,
459 	    isi_supp_reserve		:1,
460 	    isi_supp_partial		:1,
461 	    isi_supp_delete		:1,
462 	    __reserved			:1,
463 	    isi_modal			:2,
464 	    isi_overflow		:1);
465 } ipmi_sdr_info_t;
466 
467 extern ipmi_sdr_info_t *ipmi_sdr_get_info(ipmi_handle_t *);
468 
469 /*
470  * Reserve repository command.  See section 33.11.
471  */
472 #define	IPMI_CMD_RESERVE_SDR_REPOSITORY	0x22
473 
474 /*
475  * Get SDR command.  See section 33.12.  This command accesses the raw SDR
476  * repository.  Clients can also use the lookup functions to retrieve a
477  * particular SDR record by name.
478  *
479  * The list of possible types is indicated in the sub-chapters of section 43.
480  */
481 typedef struct ipmi_sdr {
482 	uint16_t	is_id;
483 	uint8_t		is_version;
484 	uint8_t		is_type;
485 	uint8_t		is_length;
486 	uint8_t		is_record[1];
487 } ipmi_sdr_t;
488 #define	IPMI_CMD_GET_SDR		0x23
489 
490 #define	IPMI_SDR_FIRST			0x0000
491 #define	IPMI_SDR_LAST			0xFFFF
492 
493 extern ipmi_sdr_t *ipmi_sdr_get(ipmi_handle_t *, uint16_t, uint16_t *);
494 
495 /*
496  * Full Sensor Record.  See 43.1
497  */
498 #define	IPMI_SDR_TYPE_FULL_SENSOR		0x01
499 
500 typedef struct ipmi_sdr_full_sensor {
501 	/* RECORD KEY BYTES */
502 	uint8_t		is_fs_owner;
503 	DECL_BITFIELD3(
504 	    is_fs_sensor_lun			:2,
505 	    __reserved1				:2,
506 	    is_fs_channel			:4);
507 	uint8_t		is_fs_number;
508 	/* RECORD BODY BYTES */
509 	uint8_t		is_fs_entity_id;
510 	DECL_BITFIELD2(
511 	    is_fs_entity_instance		:7,
512 	    is_fs_entity_logical		:1);
513 	DECL_BITFIELD8(
514 	    is_fs_sensor_scanning_enabled	:1,
515 	    is_fs_event_generation_enabled	:1,
516 	    is_fs_init_sensor_type		:1,
517 	    is_fs_init_hysteresis		:1,
518 	    is_fs_init_thresholds		:1,
519 	    is_fs_init_events			:1,
520 	    is_fs_init_scanning			:1,
521 	    is_fs_settable			:1);
522 	DECL_BITFIELD5(
523 	    is_fs_event_support			:2,
524 	    is_fs_threshold_support		:2,
525 	    is_fs_hysteresis_support		:2,
526 	    is_fs_rearm_support			:1,
527 	    is_fs_ignore			:1);
528 	uint8_t		is_fs_type;
529 	uint8_t		is_fs_reading_type;
530 	uint16_t	is_fs_assert_mask;
531 	uint16_t	is_fs_deassert_mask;
532 	uint16_t	is_fs_reading_mask;
533 	DECL_BITFIELD4(
534 	    is_fs_units_isprcnt			:1,
535 	    is_fs_mod_unit			:2,
536 	    is_fs_rate_unit			:3,
537 	    is_fs_analog_fmt			:2);
538 	uint8_t		is_fs_unit2;
539 	uint8_t		is_fs_unit3;
540 	/* Linearization */
541 	DECL_BITFIELD2(
542 	    is_fs_sensor_linear_type		:7,
543 	    __reserved2				:1);
544 	/* M, Tolerance */
545 	uint16_t	is_fs_mtol;
546 	/* B, Accuracy, R exp, B exp */
547 	uint32_t	is_fs_bacc;
548 	DECL_BITFIELD4(
549 	    is_fs_nominal_reading_spec		:1,
550 	    is_fs_normal_max_spec		:1,
551 	    is_fs_normal_min_spec		:1,
552 	    __reserved3				:5);
553 	uint8_t	is_fs_nominal_reading;
554 	uint8_t	is_fs_normal_maximum;
555 	uint8_t	is_fs_normal_minimum;
556 	uint8_t	is_fs_max;
557 	uint8_t	is_fs_min;
558 	uint8_t is_fs_upper_nonrecov;
559 	uint8_t	is_fs_upper_critical;
560 	uint8_t	is_fs_upper_noncrit;
561 	uint8_t	is_fs_lower_nonrecov;
562 	uint8_t	is_fs_lower_critical;
563 	uint8_t	is_fs_lower_noncrit;
564 	uint8_t		is_fs_hysteresis_positive;
565 	uint8_t		is_fs_hysteresis_negative;
566 	uint16_t	__reserved4;
567 	uint8_t		is_fs_oem;
568 	DECL_BITFIELD3(
569 	    is_fs_idlen				:5,
570 	    __reserved5				:1,
571 	    is_fs_idtype			:2);
572 	char		is_fs_idstring[1];
573 } ipmi_sdr_full_sensor_t;
574 
575 #define	IPMI_SDR_TYPE_COMPACT_SENSOR		0x02
576 
577 /*
578  * Compact Sensor Record.  See section 43.2
579  */
580 typedef struct ipmi_sdr_compact_sensor {
581 	/* RECORD KEY BYTES */
582 	uint8_t		is_cs_owner;
583 	DECL_BITFIELD3(
584 	    is_cs_sensor_lun			:2,
585 	    is_cs_fru_lun			:2,
586 	    is_cs_channel			:4);
587 	uint8_t		is_cs_number;
588 	/* RECORD BODY BYTES */
589 	uint8_t		is_cs_entity_id;
590 	DECL_BITFIELD2(
591 	    is_cs_entity_instance		:7,
592 	    is_cs_entity_logical		:1);
593 	DECL_BITFIELD8(
594 	    is_cs_sensor_scanning_enabled	:1,
595 	    is_cs_event_generation_enabled	:1,
596 	    is_cs_init_sensor_type		:1,
597 	    is_cs_init_hysteresis		:1,
598 	    __reserved1				:1,
599 	    is_cs_init_events			:1,
600 	    is_cs_init_scanning			:1,
601 	    is_cs_settable			:1);
602 	DECL_BITFIELD5(
603 	    is_cs_event_support			:2,
604 	    is_cs_threshold_support		:2,
605 	    is_cs_hysteresis_support		:2,
606 	    is_cs_rearm_support			:1,
607 	    is_cs_ignore			:1);
608 	uint8_t		is_cs_type;
609 	uint8_t		is_cs_reading_type;
610 	uint16_t	is_cs_assert_mask;
611 	uint16_t	is_cs_deassert_mask;
612 	uint16_t	is_cs_reading_mask;
613 	DECL_BITFIELD4(
614 	    is_cs_units_isprcnt			:1,
615 	    is_cs_mod_unit			:2,
616 	    is_cs_rate_unit			:3,
617 	    __reserved2				:2);
618 	uint8_t		is_cs_unit2;
619 	uint8_t		is_cs_unit3;
620 	DECL_BITFIELD3(
621 	    is_cs_share_count			:4,
622 	    is_cs_modifier_type			:2,
623 	    is_cs_direction			:2);
624 	DECL_BITFIELD2(
625 	    is_cs_modifier_offset		:7,
626 	    is_cs_sharing			:1);
627 	uint8_t		is_cs_hysteresis_positive;
628 	uint8_t		is_cs_hysteresis_negative;
629 	uint16_t	__reserved3;
630 	uint8_t		__reserved4;
631 	uint8_t		is_cs_oem;
632 	DECL_BITFIELD3(
633 	    is_cs_idlen				:5,
634 	    __reserved5				:1,
635 	    is_cs_idtype			:2);
636 	char		is_cs_idstring[1];
637 } ipmi_sdr_compact_sensor_t;
638 
639 /*
640  * Threshold sensor masks for is_cs_assert_mask and is_cs_deassert_mask.
641  */
642 #define	IPMI_SENSOR_RETURN_NONRECOV	0x4000
643 #define	IPMI_SENSOR_RETURN_CRIT		0x2000
644 #define	IPMI_SENSOR_RETURN_NONCRIT	0x1000
645 
646 #define	IPMI_SENSOR_MASK_UPPER_NONRECOV_HI	0x0800
647 #define	IPMI_SENSOR_MASK_UPPER_NONRECOV_LO	0x0400
648 #define	IPMI_SENSOR_MASK_UPPER_CRIT_HI		0x0200
649 #define	IPMI_SENSOR_MASK_UPPER_CRIT_LO		0x0100
650 #define	IPMI_SENSOR_MASK_UPPER_NONCRIT_HI	0x0080
651 #define	IPMI_SENSOR_MASK_UPPER_NONCRIT_LO	0x0040
652 #define	IPMI_SENSOR_MASK_LOWER_NONRECOV_HI	0x0020
653 #define	IPMI_SENSOR_MASK_LOWER_NONRECOV_LO	0x0010
654 #define	IPMI_SENSOR_MASK_LOWER_CRIT_HI		0x0008
655 #define	IPMI_SENSOR_MASK_LOWER_CRIT_LO		0x0004
656 #define	IPMI_SENSOR_MASK_LOWER_NONCRIT_HI	0x0002
657 #define	IPMI_SENSOR_MASK_LOWER_NONCRIT_LO	0x0001
658 
659 /*
660  * Threshold sensor masks for is_cs_reading_mask.
661  */
662 #define	IPMI_SENSOR_SETTABLE_UPPER_NONRECOV	0x2000
663 #define	IPMI_SENSOR_SETTABLE_UPPER_CRIT		0x1000
664 #define	IPMI_SENSOR_SETTABLE_UPPER_NONCRIT	0x0800
665 #define	IPMI_SENSOR_SETTABLE_LOWER_NONRECOV	0x0400
666 #define	IPMI_SENSOR_SETTABLE_LOWER_CRIT		0x0200
667 #define	IPMI_SENSOR_SETTABLE_LOWER_NONCRIT	0x0100
668 #define	IPMI_SENSOR_READABLE_UPPER_NONRECOV	0x0020
669 #define	IPMI_SENSOR_READABLE_UPPER_CRIT		0x0010
670 #define	IPMI_SENSOR_READABLE_UPPER_NONCRIT	0x0008
671 #define	IPMI_SENSOR_READABLE_LOWER_NONRECOV	0x0004
672 #define	IPMI_SENSOR_READABLE_LOWER_CRIT		0x0002
673 #define	IPMI_SENSOR_READABLE_LOWER_NONCRIT	0x0001
674 
675 /*
676  * Values for is_cs_reading_type.  See table 42-2.
677  */
678 #define	IPMI_RT_THRESHOLD			0x01
679 #define	IPMI_RT_USAGE				0x02
680 #define	IPMI_RT_STATE				0x03
681 #define	IPMI_RT_PREDFAIL			0x04
682 #define	IPMI_RT_LIMIT				0x05
683 #define	IPMI_RT_PERFORMANCE			0x06
684 #define	IPMI_RT_SEVERITY			0x07
685 #define	IPMI_RT_PRESENT				0x08
686 #define	IPMI_RT_ENABLED				0x09
687 #define	IPMI_RT_AVAILABILITY			0x0A
688 #define	IPMI_RT_REDUNDANCY			0x0B
689 #define	IPMI_RT_ACPI				0x0C
690 #define	IPMI_RT_SPECIFIC			0x6F
691 
692 /*
693  * Bitmasks based on above reading types.  See table 42-2
694  */
695 #define	IPMI_SR_THRESHOLD_LOWER_NONCRIT_LOW	0x0001
696 #define	IPMI_SR_THRESHOLD_LOWER_NONCRIT_HIGH	0x0002
697 #define	IPMI_SR_THRESHOLD_LOWER_CRIT_LOW	0x0004
698 #define	IPMI_SR_THRESHOLD_LOWER_CRIT_HIGH	0x0008
699 #define	IPMI_SR_THRESHOLD_LOWER_NONRECOV_LOW	0x0010
700 #define	IPMI_SR_THRESHOLD_LOWER_NONRECOV_HIGH	0x0020
701 #define	IPMI_SR_THRESHOLD_UPPER_NONCRIT_LOW	0x0040
702 #define	IPMI_SR_THRESHOLD_UPPER_NONCRIT_HIGH	0x0080
703 #define	IPMI_SR_THRESHOLD_UPPER_CRIT_LOW	0x0100
704 #define	IPMI_SR_THRESHOLD_UPPER_CRIT_HIGH	0x0200
705 #define	IPMI_SR_THRESHOLD_UPPER_NONRECOV_LOW	0x0400
706 #define	IPMI_SR_THRESHOLD_UPPER_NONRECOV_HIGH	0x0800
707 
708 #define	IPMI_SR_USAGE_IDLE			0x0001
709 #define	IPMI_SR_USAGE_ACTIVE			0x0002
710 #define	IPMI_SR_USAGE_BUSY			0x0004
711 
712 #define	IPMI_SR_STATE_DEASSERT			0x0001
713 #define	IPMI_SR_STATE_ASSERT			0x0002
714 
715 #define	IPMI_SR_PREDFAIL_DEASSERT		0x0001
716 #define	IPMI_SR_PREDFAIL_ASSERT			0x0002
717 
718 #define	IPMI_SR_LIMIT_NOTEXCEEDED		0x0001
719 #define	IPMI_SR_LIMIT_EXCEEDED			0x0002
720 
721 #define	IPMI_SR_PERFORMANCE_MET			0x0001
722 #define	IPMI_SR_PERFORMANCE_LAGS		0x0002
723 
724 #define	IPMI_SR_SEVERITY_TO_OK			0x0001
725 #define	IPMI_SR_SEVERITY_OK_TO_NONCRIT		0x0002
726 #define	IPMI_SR_SEVERITY_LESS_TO_CRIT		0x0004
727 #define	IPMI_SR_SEVERITY_LESS_TO_NONRECOV	0x0008
728 #define	IPMI_SR_SEVERITY_MORE_TO_NONCRIT	0x0010
729 #define	IPMI_SR_SEVERITY_NONRECOV_TO_CRIT	0x0020
730 #define	IPMI_SR_SEVERITY_TO_NONRECOV		0x0040
731 #define	IPMI_SR_SEVERITY_MONITOR		0x0080
732 #define	IPMI_SR_SEVERITY_INFO			0x0100
733 
734 #define	IPMI_SR_PRESENT_DEASSERT		0x0001
735 #define	IPMI_SR_PRESENT_ASSERT			0x0002
736 
737 #define	IPMI_SR_ENABLED_DEASSERT		0x0001
738 #define	IPMI_SR_ENABLED_ASSERT			0x0002
739 
740 #define	IPMI_SR_AVAILABILITY_RUNNING		0x0001
741 #define	IPMI_SR_AVAILABILITY_INTEST		0x0002
742 #define	IPMI_SR_AVAILABILITY_POWEROFF		0x0004
743 #define	IPMI_SR_AVAILABILITY_ONLINE		0x0008
744 #define	IPMI_SR_AVAILABILITY_OFFLINE		0x0010
745 #define	IPMI_SR_AVAILABILITY_OFFDUTY		0x0020
746 #define	IPMI_SR_AVAILABILITY_DEGRADED		0x0040
747 #define	IPMI_SR_AVAILABILITY_POWERSAVE		0x0080
748 #define	IPMI_SR_AVAILABILITY_INSTALLERR		0x0100
749 
750 #define	IPMI_SR_REDUNDANCY_FULL			0x0001
751 #define	IPMI_SR_REDUNDANCY_LOST			0x0002
752 #define	IPMI_SR_REDUNDANCY_DEGRADED		0x0004
753 #define	IPMI_SR_REDUNDANCY_NONE_MINIMAL		0x0008
754 #define	IPMI_SR_REDUNDANCY_NONE_REGAINED	0x0010
755 #define	IPMI_SR_REDUNDANCY_NONE_INSUFFFICIENT	0x0020
756 #define	IPMI_SR_REDUNDANCY_DEG_FROM_FULL	0x0040
757 #define	IPMI_SR_REDUNDANCY_DEG_FROM_NON		0x0080
758 
759 #define	IPMI_SR_ACPI_DO				0x0001
760 #define	IPMI_SR_ACPI_D1				0x0002
761 #define	IPMI_SR_ACPI_D2				0x0004
762 #define	IPMI_SR_ACPI_D3				0x0008
763 
764 /*
765  * Bitmasks for sensor-specific reading type (0x6F).  See section 42.2.
766  */
767 #define	IPMI_ST_RESERVED			0x00
768 #define	IPMI_ST_TEMP				0x01
769 #define	IPMI_ST_VOLTAGE				0x02
770 #define	IPMI_ST_CURRENT				0x03
771 #define	IPMI_ST_FAN				0x04
772 #define	IPMI_ST_PHYSICAL			0x05
773 
774 #define	IPMI_EV_PHYSICAL_GENERAL		0x0001
775 #define	IPMI_EV_PHYSICAL_BAY			0x0002
776 #define	IPMI_EV_PHYSICAL_CARD			0x0004
777 #define	IPMI_EV_PHYSICAL_PROCESSOR		0x0008
778 #define	IPMI_EV_PHYSICAL_LAN			0x0010
779 #define	IPMI_EV_PHYSICAL_DOCK			0x0020
780 #define	IPMI_EV_PHYSICAL_FAN			0x0040
781 
782 #define	IPMI_ST_PLATFORM			0x06
783 
784 #define	IPMI_EV_PLATFORM_SECURE			0x0001
785 #define	IPMI_EV_PLATFORM_USER_PASS		0x0002
786 #define	IPMI_EV_PLATFORM_SETUP_PASS		0x0004
787 #define	IPMI_EV_PLATFORM_NETWORK_PASS		0x0008
788 #define	IPMI_EV_PLATFORM_OTHER_PASS		0x0010
789 #define	IPMI_EV_PLATFORM_OUT_OF_BAND		0x0020
790 
791 #define	IPMI_ST_PROCESSOR			0x07
792 
793 #define	IPMI_EV_PROCESSOR_IERR			0x0001
794 #define	IPMI_EV_PROCESSOR_THERMAL		0x0002
795 #define	IPMI_EV_PROCESSOR_FRB1			0x0004
796 #define	IPMI_EV_PROCESSOR_FRB2			0x0008
797 #define	IPMI_EV_PROCESSOR_FRB3			0x0010
798 #define	IPMI_EV_PROCESSOR_CONFIG		0x0020
799 #define	IPMI_EV_PROCESSOR_SMBIOS		0x0040
800 #define	IPMI_EV_PROCESSOR_PRESENT		0x0080
801 #define	IPMI_EV_PROCESSOR_DISABLED		0x0100
802 #define	IPMI_EV_PROCESSOR_TERMINATOR		0x0200
803 #define	IPMI_EV_PROCESSOR_THROTTLED		0x0400
804 
805 #define	IPMI_ST_POWER_SUPPLY			0x08
806 
807 #define	IPMI_EV_POWER_SUPPLY_PRESENT		0x0001
808 #define	IPMI_EV_POWER_SUPPLY_FAILURE		0x0002
809 #define	IPMI_EV_POWER_SUPPLY_PREDFAIL		0x0004
810 #define	IPMI_EV_POWER_SUPPLY_INPUT_LOST		0x0008
811 #define	IPMI_EV_POWER_SUPPLY_INPUT_RANGE	0x0010
812 #define	IPMI_EV_POWER_SUPPLY_INPUT_RANGE_PRES	0x0020
813 #define	IPMI_EV_POWER_SUPPLY_CONFIG_ERR		0x0040
814 
815 #define	IPMI_ST_POWER_UNIT			0x09
816 
817 #define	IPMI_EV_POWER_UNIT_OFF			0x0001
818 #define	IPMI_EV_POWER_UNIT_CYCLE		0x0002
819 #define	IPMI_EV_POWER_UNIT_240_DOWN		0x0004
820 #define	IPMI_EV_POWER_UNIT_INTERLOCK_DOWN	0x0008
821 #define	IPMI_EV_POWER_UNIT_AC_LOST		0x0010
822 #define	IPMI_EV_POWER_UNIT_SOFT_FAILURE		0x0020
823 #define	IPMI_EV_POWER_UNIT_FAIL			0x0040
824 #define	IPMI_EV_POWER_UNIT_PREDFAIL		0x0080
825 
826 #define	IPMI_ST_COOLING				0x0A
827 #define	IPMI_ST_OTHER				0x0B
828 #define	IPMI_ST_MEMORY				0x0C
829 
830 #define	IPMI_EV_MEMORY_CE			0x0001
831 #define	IPMI_EV_MEMORY_UE			0x0002
832 #define	IPMI_EV_MEMORY_PARITY			0x0004
833 #define	IPMI_EV_MEMORY_SCRUB_FAIL		0x0008
834 #define	IPMI_EV_MEMORY_DISABLED			0x0010
835 #define	IPMI_EV_MEMORY_CE_LOG_LIMIT		0x0020
836 #define	IPMI_EV_MEMORY_PRESENT			0x0040
837 #define	IPMI_EV_MEMORY_CONFIG_ERR		0x0080
838 #define	IPMI_EV_MEMORY_SPARE			0x0100
839 #define	IPMI_EV_MEMORY_THROTTLED		0x0200
840 #define	IPMI_EV_MEMORY_OVERTEMP			0x0400
841 
842 #define	IPMI_ST_BAY				0x0D
843 
844 #define	IPMI_EV_BAY_PRESENT			0x0001
845 #define	IPMI_EV_BAY_FAULT			0x0002
846 #define	IPMI_EV_BAY_PREDFAIL			0x0004
847 #define	IPMI_EV_BAY_SPARE			0x0008
848 #define	IPMI_EV_BAY_CHECK			0x0010
849 #define	IPMI_EV_BAY_CRITICAL			0x0020
850 #define	IPMI_EV_BAY_FAILED			0x0040
851 #define	IPMI_EV_BAY_REBUILDING			0x0080
852 #define	IPMI_EV_BAY_ABORTED			0x0100
853 
854 #define	IPMI_ST_POST_RESIZE			0x0E
855 #define	IPMI_ST_FIRMWARE			0x0F
856 
857 #define	IPMI_EV_FIRMWARE_ERROR			0x0001
858 #define	IPMI_EV_FIRMWARE_HANG			0x0002
859 #define	IPMI_EV_FIRMWARE_PROGRESS		0x0004
860 
861 #define	IPMI_ST_EVENT_LOG			0x10
862 
863 #define	IPMI_EV_EVENT_LOG_CE			0x0001
864 #define	IPMI_EV_EVENT_LOG_TYPE			0x0002
865 #define	IPMI_EV_EVENT_LOG_RESET			0x0004
866 #define	IPMI_EV_EVENT_LOG_ALL			0x0008
867 #define	IPMI_EV_EVENT_LOG_FULL			0x0010
868 #define	IPMI_EV_EVENT_LOG_ALMOST_FULL		0x0020
869 
870 #define	IPMI_ST_WATCHDOG1			0x11
871 
872 #define	IPMI_EV_WATCHDOG_BIOS_RESET		0x0001
873 #define	IPMI_EV_WATCHDOG_OS_RESET		0x0002
874 #define	IPMI_EV_WATCHDOG_OS_SHUTDOWN		0x0004
875 #define	IPMI_EV_WATCHDOG_OS_PWR_DOWN		0x0008
876 #define	IPMI_EV_WATCHDOG_OS_PWR_CYCLE		0x0010
877 #define	IPMI_EV_WATCHDOG_OS_NMI_DIAG		0x0020
878 #define	IPMI_EV_WATCHDOG_EXPIRED		0x0040
879 #define	IPMI_EV_WATCHDOG_PRE_TIMEOUT_INT	0x0080
880 
881 #define	IPMI_ST_SYSTEM				0x12
882 
883 #define	IPMI_EV_STSTEM_RECONF			0x0001
884 #define	IPMI_EV_STSTEM_BOOT			0x0002
885 #define	IPMI_EV_STSTEM_UNKNOWN_HW_FAILURE	0x0004
886 #define	IPMI_EV_STSTEM_AUX_LOG_UPDATED		0x0008
887 #define	IPMI_EV_STSTEM_PEF_ACTION		0x0010
888 #define	IPMI_EV_SYSTEM_TIMETAMP_CLOCKSYNC	0x0020
889 
890 #define	IPMI_ST_CRITICAL			0x13
891 
892 #define	IPMI_EV_CRITICAL_EXT_NMI		0x0001
893 #define	IPMI_EV_CRITICAL_BUS_TIMOEOUT		0x0002
894 #define	IPMI_EV_CRITICAL_IO_NMI			0x0004
895 #define	IPMI_EV_CRITICAL_SW_NMI			0x0008
896 #define	IPMI_EV_CRITICAL_PCI_PERR		0x0010
897 #define	IPMI_EV_CRITICAL_PCI_SERR		0x0020
898 #define	IPMI_EV_CRITICAL_EISA_FAILSAFE		0x0040
899 #define	IPMI_EV_CRITICAL_BUS_CE			0x0080
900 #define	IPMI_EV_CRITICAL_BUS_UE			0x0100
901 #define	IPMI_EV_CRITICAL_FATAL_NMI		0x0200
902 #define	IPMI_EV_CRITICAL_BUS_FATAL_ERR		0x0400
903 #define	IPMI_EV_CRITICAL_BUS_DEGRADED		0x0800
904 
905 #define	IPMI_ST_BUTTON				0x14
906 
907 #define	IPMI_EV_BUTTON_PWR			0x0001
908 #define	IPMI_EV_BUTTON_SLEEP			0x0002
909 #define	IPMI_EV_BUTTON_RESET			0x0004
910 #define	IPMI_EV_BUTTON_FRU_LATCH		0x0008
911 #define	IPMI_EV_BUTTON_FRU_SERVICE		0x0010
912 
913 #define	IPMI_ST_MODULE				0x15
914 #define	IPMI_ST_MICROCONTROLLER			0x16
915 #define	IPMI_ST_CARD				0x17
916 #define	IPMI_ST_CHASSIS				0x18
917 
918 #define	IPMI_ST_CHIPSET				0x19
919 
920 #define	IPMI_EV_CHIPSET_PWR_CTL_FAIL		0x0001
921 
922 #define	IPMI_ST_FRU				0x1A
923 #define	IPMI_ST_CABLE				0x1B
924 
925 #define	IPMI_EV_CABLE_CONNECTED			0x0001
926 #define	IPMI_EV_CABLE_CONFIG_ERR		0x0002
927 
928 #define	IPMI_ST_TERMINATOR			0x1C
929 
930 #define	IPMI_ST_BOOT				0x1D
931 
932 #define	IPMI_EV_BOOT_BIOS_PWR_UP		0x0001
933 #define	IPMI_EV_BOOT_BIOS_HARD_RESET		0x0002
934 #define	IPMI_EV_BOOT_BIOS_WARM_RESET		0x0004
935 #define	IPMI_EV_BOOT_PXE_BOOT			0x0008
936 #define	IPMI_EV_BOOT_DIAG_BOOT			0x0010
937 #define	IPMI_EV_BOOT_OS_HARD_RESET		0x0020
938 #define	IPMI_EV_BOOT_OS_WARM_RESET		0x0040
939 #define	IPMI_EV_BOOT_SYS_RESTART		0x0080
940 
941 #define	IPMI_ST_BOOT_ERROR			0x1E
942 
943 #define	IPMI_EV_BOOT_ERROR_NOMEDIA		0x0001
944 #define	IPMI_EV_BOOT_ERROR_NON_BOOTABLE_DISK	0x0002
945 #define	IPMI_EV_BOOT_ERROR_NO_PXE_SERVER	0x0004
946 #define	IPMI_EV_BOOT_ERROR_INV_BOOT_SECT	0x0008
947 #define	IPMI_EV_BOOT_ERROR_USR_SELECT_TIMEOUT	0x0010
948 
949 #define	IPMI_ST_BOOT_OS				0x1F
950 
951 #define	IPMI_EV_BOOT_OS_A_DRV_BOOT_COMPLETE	0x0001
952 #define	IPMI_EV_BOOT_OS_C_DRV_BOOT_COMPLETE	0x0002
953 #define	IPMI_EV_BOOT_OS_PXE_BOOT_COMPLETE	0x0004
954 #define	IPMI_EV_BOOT_OS_DIAG_BOOT_COMPLETE	0x0008
955 #define	IPMI_EV_BOOT_OS_CDROM_BOOT_COMPLETE	0x0010
956 #define	IPMI_EV_BOOT_OS_ROM_BOOT_COMPLETE	0x0020
957 #define	IPMI_EV_BOOT_OS_UNSPEC_BOOT_COMPLETE	0x0040
958 
959 #define	IPMI_ST_OS_SHUTDOWN			0x20
960 
961 #define	IPMI_EV_OS_SHUTDOWN_LOADING		0x0001
962 #define	IPMI_EV_OS_SHUTDOWN_CRASH		0x0002
963 #define	IPMI_EV_OS_STOP_GRACEFUL		0x0004
964 #define	IPMI_EV_OS_SHUTDOWN_GRACEFUL		0x0008
965 #define	IPMI_EV_OS_SHUTDOWN_PEF			0x0010
966 #define	IPMI_EV_OS_SHUTDOWN_BMC			0x0020
967 
968 #define	IPMI_ST_SLOT				0x21
969 
970 #define	IPMI_EV_SLOT_FAULT_ASSERTED		0x0001
971 #define	IPMI_EV_SLOT_IDENTIFY_ASSERTED		0x0002
972 #define	IPMI_EV_SLOT_CONNECTED			0x0004
973 #define	IPMI_EV_SLOT_INSTALL_READY		0x0008
974 #define	IPMI_EV_SLOT_REMOVE_READY		0x0010
975 #define	IPMI_EV_SLOT_PWR_OFF			0x0020
976 #define	IPMI_EV_SLOT_REMOVED			0x0040
977 #define	IPMI_EV_SLOT_INTERLOCK_ASSERTED		0x0080
978 #define	IPMI_EV_SLOT_DISABLED			0x0100
979 #define	IPMI_EV_SLOT_SPARE_DEVICE		0x0200
980 
981 #define	IPMI_ST_ACPI				0x22
982 
983 #define	IPMI_EV_ACPI_PSTATE_S0_G0		0x0001
984 #define	IPMI_EV_ACPI_PSTATE_S1			0x0002
985 #define	IPMI_EV_ACPI_PSTATE_S2			0x0004
986 #define	IPMI_EV_ACPI_PSTATE_S3			0x0008
987 #define	IPMI_EV_ACPI_PSTATE_S4			0x0010
988 #define	IPMI_EV_ACPI_PSTATE_S5_G2_SOFT_OFF	0x0020
989 #define	IPMI_EV_ACPI_PSTATE_S4_S5_SOFT_OFF	0x0040
990 #define	IPMI_EV_ACPI_PSATTE_G3_MECH_OFF		0x0080
991 #define	IPMI_EV_ACPI_PSTATE_S1_S2_S3_SLEEP	0x0100
992 #define	IPMI_EV_ACPI_PSTATE_G1_SLEEP		0x0200
993 #define	IPMI_EV_ACPI_PSTATE_S5_OVERRIDE		0x0400
994 #define	IPMI_EV_ACPI_PSTATE_LEGACY_ON		0x0800
995 #define	IPMI_EV_ACPI_PSTATE_LEGACY_OFF		0x1000
996 #define	IPMI_EV_ACPI_PSTATE_UNKNOWN		0x2000
997 
998 #define	IPMI_ST_WATCHDOG2			0x23
999 
1000 #define	IPMI_EV_WATCHDOG2_EXPIRED		0x0001
1001 #define	IPMI_EV_WATCHDOG2_HARD_RESET		0x0002
1002 #define	IPMI_EV_WATCHDOG2_PWR_DOWN		0x0004
1003 #define	IPMI_EV_WATCHDOG2_PWR_CYCLE		0x0008
1004 #define	IPMI_EV_WATCHDOG2_RESERVED1		0x0010
1005 #define	IPMI_EV_WATCHDOG2_RESERVED2		0x0020
1006 #define	IPMI_EV_WATCHDOG2_RESERVED3		0x0040
1007 #define	IPMI_EV_WATCHDOG2_RESERVED4		0x0080
1008 #define	IPMI_EV_WATCHDOG2_TIMEOUT_INT		0x0100
1009 
1010 #define	IPMI_ST_ALERT				0x24
1011 
1012 #define	IPMI_EV_ALERT_PLAT_PAGE			0x0001
1013 #define	IPMI_EV_ALERT_PLAT_LAN_ALERT		0x0002
1014 #define	IPMI_EV_ALERT_PLAT_EVT_TRAP		0x0004
1015 #define	IPMI_EV_ALERT_PLAT_SNMP_TRAP		0x0008
1016 
1017 #define	IPMI_ST_PRESENCE			0x25
1018 
1019 #define	IPMI_EV_PRESENCE_PRESENT		0x0001
1020 #define	IPMI_EV_PRESENCE_ABSENT			0x0002
1021 #define	IPMI_EV_PRESENCE_DISABLED		0x0004
1022 
1023 #define	IPMI_ST_ASIC				0x26
1024 
1025 #define	IPMI_ST_LAN				0x27
1026 
1027 #define	IPMI_EV_LAN_HEARTBEAT_LOST		0x0001
1028 #define	IPMI_EV_LAN_HEARTBEAT			0x0002
1029 
1030 #define	IPMI_ST_HEALTH				0x28
1031 
1032 #define	IPMI_EV_HEALTH_SENSOR_ACC_DEGRADED	0x0001
1033 #define	IPMI_EV_HEALTH_CNTLR_ACC_DEGRADED	0x0002
1034 #define	IPMI_EV_HEALTH_CNTLR_OFFLINE		0x0004
1035 #define	IPMI_EV_HEALTH_CNTLR_UNAVAIL		0x0008
1036 #define	IPMI_EV_HEALTH_SENSOR_FAILURE		0x0010
1037 #define	IPMI_EV_HEALTH_FRU_FAILURE		0x0020
1038 
1039 #define	IPMI_ST_BATTERY				0x29
1040 
1041 #define	IPMI_EV_BATTERY_LOW			0x0001
1042 #define	IPMI_EV_BATTERY_FAILED			0x0002
1043 #define	IPMI_EV_BATTERY_PRESENCE		0x0004
1044 
1045 #define	IPMI_ST_AUDIT				0x2A
1046 
1047 #define	IPMI_EV_AUDIT_SESSION_ACTIVATED		0x0001
1048 #define	IPMI_EV_AUDIT_SESSION_DEACTIVATED	0x0002
1049 
1050 #define	IPMI_ST_VERSION				0x2B
1051 
1052 #define	IPMI_EV_VERSION_HW_CHANGE		0x0001
1053 #define	IPMI_EV_VERSION_SW_CHANGE		0x0002
1054 #define	IPMI_EV_VERSION_HW_INCOMPATIBLE		0x0004
1055 #define	IPMI_EV_VERSION_SW_INCOMPATIBLE		0x0008
1056 #define	IPMI_EV_VERSION_HW_INVAL		0x0010
1057 #define	IPMI_EV_VERSION_SW_INVAL		0x0020
1058 #define	IPMI_EV_VERSION_HW_CHANGE_SUCCESS	0x0040
1059 #define	IPMI_EV_VERSION_SW_CHANGE_SUCCESS	0x0080
1060 
1061 #define	IPMI_ST_FRU_STATE			0x2C
1062 
1063 #define	IPMI_EV_FRU_STATE_NOT_INSTALLED		0x0001
1064 #define	IPMI_EV_FRU_STATE_INACTIVE		0x0002
1065 #define	IPMI_EV_FRU_STATE_ACT_REQ		0x0004
1066 #define	IPMI_EV_FRU_STATE_ACT_INPROGRESS	0x0008
1067 #define	IPMI_EV_FRU_STATE_ACTIVE		0x0010
1068 #define	IPMI_EV_FRU_STATE_DEACT_REQ		0x0020
1069 #define	IPMI_EV_FRU_STATE_DEACT_INPROGRESS	0x0040
1070 #define	IPMI_EV_FRU_STATE_COMM_LOST		0x0080
1071 
1072 /*
1073  * Constants for unit type codes.  See Table 43-15.
1074  */
1075 #define	IPMI_UNITS_UNSPECIFIED			0x00
1076 #define	IPMI_UNITS_DEGREES_C			0x01
1077 #define	IPMI_UNITS_DEGREES_F			0x02
1078 #define	IPMI_UNITS_DEGREES_K			0x03
1079 #define	IPMI_UNITS_VOLTS			0x04
1080 #define	IPMI_UNITS_AMPS				0x05
1081 #define	IPMI_UNITS_WATTS			0x06
1082 #define	IPMI_UNITS_JOULES			0x07
1083 #define	IPMI_UNITS_COULOMBS			0x08
1084 #define	IPMI_UNITS_VA				0x09
1085 #define	IPMI_UNITS_NITS				0x0A
1086 #define	IPMI_UNITS_LUMEN			0x0B
1087 #define	IPMI_UNITS_LUX				0x0C
1088 #define	IPMI_UNITS_CANDELA			0x0D
1089 #define	IPMI_UNITS_KPA				0x0E
1090 #define	IPMI_UNITS_PSI				0x0F
1091 
1092 #define	IPMI_UNITS_NEWTON			0x10
1093 #define	IPMI_UNITS_CFM				0x11
1094 #define	IPMI_UNITS_RPM				0x12
1095 #define	IPMI_UNITS_HZ				0x13
1096 #define	IPMI_UNITS_MICROSEC			0x14
1097 #define	IPMI_UNITS_MILLISEC			0x15
1098 #define	IPMI_UNITS_SECS				0x16
1099 #define	IPMI_UNITS_MIN				0x17
1100 #define	IPMI_UNITS_HOUR				0x18
1101 #define	IPMI_UNITS_DAY				0x19
1102 #define	IPMI_UNITS_WEEK				0x1A
1103 #define	IPMI_UNITS_MIL				0x1B
1104 #define	IPMI_UNITS_INCHES			0x1C
1105 #define	IPMI_UNITS_FEET				0x1D
1106 #define	IPMI_UNITS_CUB_INCH			0x1E
1107 #define	IPMI_UNITS_CUB_FEET			0x1F
1108 
1109 #define	IPMI_UNITS_MM				0x20
1110 #define	IPMI_UNITS_CM				0x21
1111 #define	IPMI_UNITS_METERS			0x22
1112 #define	IPMI_UNITS_CUB_CM			0x23
1113 #define	IPMI_UNITS_CUB_METER			0x24
1114 #define	IPMI_UNITS_LITERS			0x25
1115 #define	IPMI_UNITS_FLUID_OUNCE			0x26
1116 #define	IPMI_UNITS_RADIANS			0x27
1117 #define	IPMI_UNITS_STERADIANS			0x28
1118 #define	IPMI_UNITS_REVOLUTIONS			0x29
1119 #define	IPMI_UNITS_CYCLES			0x2A
1120 #define	IPMI_UNITS_GRAVITIES			0x2B
1121 #define	IPMI_UNITS_OUNCE			0x2C
1122 #define	IPMI_UNITS_POUND			0x2D
1123 #define	IPMI_UNITS_FOOT_POUND			0x2E
1124 #define	IPMI_UNITS_OZ_INCH			0x2F
1125 
1126 #define	IPMI_UNITS_GAUSS			0x30
1127 #define	IPMI_UNITS_GILBERTS			0x31
1128 #define	IPMI_UNITS_HENRY			0x32
1129 #define	IPMI_UNITS_MILHENRY			0x33
1130 #define	IPMI_UNITS_FARAD			0x34
1131 #define	IPMI_UNITS_MICROFARAD			0x35
1132 #define	IPMI_UNITS_OHMS				0x36
1133 #define	IPMI_UNITS_SIEMENS			0x37
1134 #define	IPMI_UNITS_MOLE				0x38
1135 #define	IPMI_UNITS_BECQUEREL			0x39
1136 #define	IPMI_UNITS_PPM				0x3A
1137 /* 0x3B is reserved */
1138 #define	IPMI_UNITS_DECIBELS			0x3C
1139 #define	IPMI_UNITS_DBA				0x3D
1140 #define	IPMI_UNITS_DBC				0x3E
1141 #define	IPMI_UNITS_GRAY				0x3F
1142 
1143 #define	IPMI_UNITS_SIEVERT			0x40
1144 #define	IPMI_UNITS_COLOR_TEMP_K			0x41
1145 #define	IPMI_UNITS_BIT				0x42
1146 #define	IPMI_UNITS_KILOBIT			0x43
1147 #define	IPMI_UNITS_MEGABIT			0x44
1148 #define	IPMI_UNITS_GIGABIT			0x45
1149 #define	IPMI_UNITS_BYTE				0x46
1150 #define	IPMI_UNITS_KILOBYTE			0x47
1151 #define	IPMI_UNITS_MEGABYTE			0x48
1152 #define	IPMI_UNITS_GIGABYTE			0x49
1153 #define	IPMI_UNITS_WORD				0x4A
1154 #define	IPMI_UNITS_DWORD			0x4B
1155 #define	IPMI_UNITS_QWORD			0x4C
1156 #define	IPMI_UNITS_MEMLINE			0x4D
1157 #define	IPMI_UNITS_HIT				0x4E
1158 #define	IPMI_UNITS_MISS				0x4F
1159 
1160 #define	IPMI_UNITS_RETRY			0x50
1161 #define	IPMI_UNITS_RESET			0x51
1162 #define	IPMI_UNITS_OVERFLOW			0x52
1163 #define	IPMI_UNITS_UNDERRUN			0x53
1164 #define	IPMI_UNITS_COLLISION			0x54
1165 #define	IPMI_UNITS_PACKETS			0x55
1166 #define	IPMI_UNITS_MESSAGES			0x56
1167 #define	IPMI_UNITS_CHARACTERS			0x57
1168 #define	IPMI_UNITS_ERROR			0x58
1169 #define	IPMI_UNITS_CE				0x59
1170 #define	IPMI_UNITS_UE				0x5A
1171 #define	IPMI_UNITS_FATAL_ERROR			0x5B
1172 #define	IPMI_UNITS_GRAMS			0x5C
1173 
1174 /*
1175  * Event-Only Record.  See section 43.3.
1176  */
1177 
1178 #define	IPMI_SDR_TYPE_EVENT_ONLY		0x03
1179 
1180 typedef struct ipmi_sdr_event_only {
1181 	/* RECORD KEY BYTES */
1182 	uint8_t		is_eo_owner;
1183 	DECL_BITFIELD3(
1184 	    is_eo_sensor_lun			:2,
1185 	    is_eo_fru_lun			:2,
1186 	    is_eo_channel			:4);
1187 	uint8_t		is_eo_number;
1188 	/* RECORD BODY BYTES */
1189 	uint8_t		is_eo_entity_id;
1190 	DECL_BITFIELD2(
1191 	    is_eo_entity_instance		:7,
1192 	    is_eo_entity_logical		:1);
1193 	uint8_t		is_eo_sensor_type;
1194 	uint8_t		is_eo_reading_type;
1195 	DECL_BITFIELD3(
1196 	    is_eo_share_count			:4,
1197 	    is_eo_modifier_type			:2,
1198 	    is_eo_direction			:2);
1199 	DECL_BITFIELD2(
1200 	    is_eo_modifier_offset		:7,
1201 	    is_eo_sharing			:1);
1202 	uint8_t		__reserved;
1203 	uint8_t		is_eo_oem;
1204 	DECL_BITFIELD3(
1205 	    is_eo_idlen				:5,
1206 	    __reserved1				:1,
1207 	    is_eo_idtype			:2);
1208 	char		is_eo_idstring[1];
1209 } ipmi_sdr_event_only_t;
1210 
1211 /*
1212  * Entity Association Record.  See section 43.4.
1213  */
1214 
1215 #define	IPMI_SDR_TYPE_ENTITY_ASSOCIATION	0x08
1216 
1217 typedef struct ipmi_sdr_entity_association {
1218 	/* RECORD KEY BYTES */
1219 	uint8_t		is_ea_entity_id;
1220 	uint8_t		is_ea_entity_instance;
1221 	DECL_BITFIELD4(
1222 	    __reserved		:5,
1223 	    is_ea_presence	:1,
1224 	    is_ea_record_link	:1,
1225 	    is_ea_range		:1);
1226 	/* RECORD BODY BYTES */
1227 	struct {
1228 		uint8_t		is_ea_sub_id;
1229 		uint8_t		is_ea_sub_instance;
1230 	} is_ea_sub[4];
1231 } ipmi_sdr_entity_association_t;
1232 
1233 /*
1234  * Device-relative Entity Association Record.  See section 43.5.
1235  */
1236 
1237 #define	IPMI_SDR_TYPE_DEVICE_RELATIVE		0x09
1238 
1239 typedef struct ipmi_sdr_device_relative {
1240 	/* RECORD KEY BYTES */
1241 	uint8_t		is_dr_entity_id;
1242 	uint8_t		is_dr_entity_instance;
1243 	DECL_BITFIELD2(
1244 	    __reserved1			:1,
1245 	    is_dr_slaveaddr		:7);
1246 	DECL_BITFIELD2(
1247 	    __reserved2			:4,
1248 	    is_dr_channel		:4);
1249 	DECL_BITFIELD4(
1250 	    __reserved			:5,
1251 	    is_dr_presence		:1,
1252 	    is_dr_record_link		:1,
1253 	    is_dr_range			:1);
1254 	/* RECORD BODY BYTES */
1255 	struct {
1256 		DECL_BITFIELD2(
1257 		    __reserved3		:1,
1258 		    is_dr_sub_slaveaddr	:7);
1259 		DECL_BITFIELD2(
1260 		    __reserved4		:4,
1261 		    is_dr_sub_channel	:4);
1262 		uint8_t		is_ea_sub_id;
1263 		uint8_t		is_ea_sub_instance;
1264 	} is_ea_sub[4];
1265 } ipmi_sdr_device_relative_t;
1266 
1267 /*
1268  * Generic Device Locator Record.  See section 43.7.
1269  */
1270 
1271 #define	IPMI_SDR_TYPE_GENERIC_LOCATOR		0x10
1272 
1273 typedef struct ipmi_sdr_generic_locator {
1274 	/* RECORD KEY BYTES */
1275 	DECL_BITFIELD2(
1276 	    __reserved1		:1,
1277 	    is_gl_accessaddr	:7);
1278 	DECL_BITFIELD2(
1279 	    is_gl_channel_msb	:1,
1280 	    is_gl_slaveaddr	:7);
1281 	DECL_BITFIELD3(
1282 	    is_gl_bus		:3,
1283 	    is_gl_lun		:2,
1284 	    is_gl_channel	:3);
1285 	/* RECORD BODY BYTES */
1286 	DECL_BITFIELD2(
1287 	    is_gl_span		:3,
1288 	    __reserved2		:5);
1289 	uint8_t		__reserved3;
1290 	uint8_t		is_gl_type;
1291 	uint8_t		is_gl_modifier;
1292 	uint8_t		is_gl_entity;
1293 	uint8_t		is_gl_instance;
1294 	uint8_t		is_gl_oem;
1295 	DECL_BITFIELD3(
1296 	    is_gl_idlen		:5,
1297 	    __reserved4		:1,
1298 	    is_gl_idtype	:2);
1299 	char		is_gl_idstring[1];
1300 } ipmi_sdr_generic_locator_t;
1301 
1302 /*
1303  * FRU Device Locator Record.  See section 43.8.
1304  */
1305 
1306 #define	IPMI_SDR_TYPE_FRU_LOCATOR		0x11
1307 
1308 typedef struct ipmi_sdr_fru_locator {
1309 	/* RECORD KEY BYTES */
1310 	DECL_BITFIELD2(
1311 	    __reserved1		:1,
1312 	    is_fl_accessaddr	:7);
1313 	union {
1314 		struct {
1315 			uint8_t	_is_fl_devid;
1316 		} _logical;
1317 		struct {
1318 			DECL_BITFIELD2(
1319 			    __reserved		:1,
1320 			    _is_fl_slaveaddr	:7);
1321 		} _nonintelligent;
1322 	} _devid_or_slaveaddr;
1323 	DECL_BITFIELD4(
1324 	    is_fl_bus		:3,
1325 	    is_fl_lun		:2,
1326 	    __reserved2		:2,
1327 	    is_fl_logical	:1);
1328 	DECL_BITFIELD2(
1329 	    __reserved3		:4,
1330 	    is_fl_channel	:4);
1331 	/* RECORD BODY BYTES */
1332 	uint8_t		__reserved4;
1333 	uint8_t		is_fl_type;
1334 	uint8_t		is_fl_modifier;
1335 	uint8_t		is_fl_entity;
1336 	uint8_t		is_fl_instance;
1337 	uint8_t		is_fl_oem;
1338 	DECL_BITFIELD3(
1339 	    is_fl_idlen		:5,
1340 	    __reserved5		:1,
1341 	    is_fl_idtype	:2);
1342 	char		is_fl_idstring[1];
1343 } ipmi_sdr_fru_locator_t;
1344 
1345 #define	is_fl_devid	_devid_or_slaveaddr._logical._is_fl_devid
1346 #define	is_fl_slaveaddr	_devid_or_slaveaddr._nonintelligent._is_fl_slaveaddr
1347 
1348 /*
1349  * Management Controller Device Locator Record.  See section 43.9
1350  */
1351 
1352 #define	IPMI_SDR_TYPE_MANAGEMENT_LOCATOR	0x12
1353 
1354 typedef struct ipmi_sdr_management_locator {
1355 	/* RECORD KEY BYTES */
1356 	DECL_BITFIELD2(
1357 	    __reserved1			:1,
1358 	    is_ml_devaddr		:7);
1359 	DECL_BITFIELD2(
1360 	    is_ml_channel		:4,
1361 	    __reserved2			:4);
1362 	/* RECORD BODY BYTES */
1363 	DECL_BITFIELD7(
1364 	    is_ml_init_message		:2,
1365 	    is_ml_init_log		:1,
1366 	    is_ml_init_controller_log	:1,
1367 	    __reserved3			:1,
1368 	    is_ml_static		:1,
1369 	    is_ml_acpi_device		:1,
1370 	    is_ml_acpi_system		:1);
1371 	DECL_BITFIELD8(
1372 	    is_ml_supp_sensor		:1,
1373 	    is_ml_supp_sdr		:1,
1374 	    is_ml_supp_sel		:1,
1375 	    is_ml_supp_fru		:1,
1376 	    is_ml_supp_event_receiver	:1,
1377 	    is_ml_supp_event_generator	:1,
1378 	    is_ml_supp_bridge		:1,
1379 	    is_ml_supp_chassis		:1);
1380 	uint8_t		__reserved4;
1381 	uint16_t	__reserved5;
1382 	uint8_t		is_ml_entity_id;
1383 	uint8_t		is_ml_entity_instance;
1384 	uint8_t		is_ml_oem;
1385 	DECL_BITFIELD3(
1386 	    is_ml_idlen		:5,
1387 	    __reserved6		:1,
1388 	    is_ml_idtype	:2);
1389 	char		is_ml_idstring[1];
1390 } ipmi_sdr_management_locator_t;
1391 
1392 #define	IPMI_MESSAGE_INIT_ENABLE		0x0
1393 #define	IPMI_MESSAGE_INIT_DISABLE		0x1
1394 #define	IPMI_MESSAGE_INIT_NONE			0x2
1395 
1396 /*
1397  *  Management Controller Confirmation Record.  See section 43.10
1398  */
1399 
1400 #define	IPMI_SDR_TYPE_MANAGEMENT_CONFIRMATION	0x13
1401 
1402 typedef struct ipmi_sdr_management_confirmation {
1403 	/* RECORD KEY BYTES */
1404 	DECL_BITFIELD2(
1405 	    __reserved1		:1,
1406 	    is_mc_slaveaddr	:7);
1407 	uint8_t		is_mc_deviceid;
1408 	DECL_BITFIELD2(
1409 	    is_mc_dev_revision	:4,
1410 	    is_mc_channel	:4);
1411 	/* RECORD BODY BYTES */
1412 	DECL_BITFIELD2(
1413 	    is_mc_major_rev	:7,
1414 	    __reserved2		:1);
1415 	uint8_t		is_mc_minor_rev;
1416 	uint8_t		is_mc_impi_ver;
1417 	uint8_t		is_mc_manufacturer[3];
1418 	uint16_t	is_mc_product;
1419 	uint8_t		is_mc_guid[16];
1420 } ipmi_sdr_management_confirmation_t;
1421 
1422 /*
1423  * BMC Message Channel Info Record.  See esction 43.11.
1424  */
1425 
1426 #define	IPMI_SDR_TYPE_BMC_MESSAGE_CHANNEL	0x14
1427 
1428 typedef struct ipmi_sdr_bmc_channel {
1429 	/* RECORD BODY BYTES */
1430 	struct {
1431 		DECL_BITFIELD3(
1432 		    is_bc_protocol	:4,
1433 		    is_bc_receive_lun	:3,
1434 		    is_bc_transmit	:1);
1435 	} is_bc_channel[8];
1436 	uint8_t		is_bc_interrupt_type;
1437 	uint8_t		is_bc_buffer_type;
1438 	uint8_t		__reserved;
1439 } ipmi_sdr_bmc_channel_t;
1440 
1441 /*
1442  * OEM Record.  See ction 43.12.
1443  */
1444 
1445 #define	IPMI_SDR_TYPE_OEM			0xC0
1446 
1447 typedef struct ipmi_sdr_oem {
1448 	uint8_t		is_oem_manufacturer[3];
1449 	uint8_t		is_oem_data[1];
1450 } ipmi_sdr_oem_t;
1451 
1452 /*
1453  * Iterate over the SDR repository.  This function does the work of parsing the
1454  * name when available, and keeping the repository in a consistent state.
1455  */
1456 extern int ipmi_sdr_iter(ipmi_handle_t *,
1457     int (*)(ipmi_handle_t *, const char *, ipmi_sdr_t *, void *), void *);
1458 
1459 /*
1460  * Lookup the given sensor type by name.  These functions automatically read in
1461  * and cache the complete SDR repository.
1462  */
1463 extern ipmi_sdr_t *ipmi_sdr_lookup(ipmi_handle_t *, const char *);
1464 extern ipmi_sdr_fru_locator_t *ipmi_sdr_lookup_fru(ipmi_handle_t *,
1465     const char *);
1466 extern ipmi_sdr_generic_locator_t *ipmi_sdr_lookup_generic(ipmi_handle_t *,
1467     const char *);
1468 extern ipmi_sdr_compact_sensor_t *ipmi_sdr_lookup_compact_sensor(
1469     ipmi_handle_t *, const char *);
1470 extern ipmi_sdr_full_sensor_t *ipmi_sdr_lookup_full_sensor(
1471     ipmi_handle_t *, const char *);
1472 
1473 /*
1474  * Entity ID codes.  See table 43.13.
1475  */
1476 #define	IPMI_ET_UNSPECIFIED		0x00
1477 #define	IPMI_ET_OTHER			0x01
1478 #define	IPMI_ET_UNKNOWN			0x02
1479 #define	IPMI_ET_PROCESSOR		0x03
1480 #define	IPMI_ET_DISK			0x04
1481 #define	IPMI_ET_PERIPHERAL		0x05
1482 #define	IPMI_ET_MANAGEMENT_MODULE	0x06
1483 #define	IPMI_ET_MOTHERBOARD		0x07
1484 #define	IPMI_ET_MEMORY_MODULE		0x08
1485 #define	IPMI_ET_PROCESSOR_MODULE	0x09
1486 #define	IPMI_ET_PSU			0x0A
1487 #define	IPMI_ET_CARD			0x0B
1488 #define	IPMI_ET_FRONT_PANEL		0x0C
1489 #define	IPMI_ET_BACK_PANEL		0x0D
1490 #define	IPMI_ET_POWER_BOARD		0x0E
1491 #define	IPMI_ET_BACKPLANE		0x0F
1492 #define	IPMI_ET_EXPANSION_BOARD		0x10
1493 #define	IPMI_ET_OTHER_BOARD		0x11
1494 #define	IPMI_ET_PROCESSOR_BOARD		0x12
1495 #define	IPMI_ET_POWER_DOMAIN		0x13
1496 #define	IPMI_ET_POWER_CONVERTER		0x14
1497 #define	IPMI_ET_POWER_MANAGEMENT	0x15
1498 #define	IPMI_ET_BACK_CHASSIS		0x16
1499 #define	IPMI_ET_SYSTEM_CHASSIS		0x17
1500 #define	IPMI_ET_SUB_CHASSIS		0x18
1501 #define	IPMI_ET_OTHER_CHASSIS		0x19
1502 #define	IPMI_ET_DISK_BAY		0x1A
1503 #define	IPMI_ET_PERIPHERAL_BAY		0x1B
1504 #define	IPMI_ET_DEVICE_BAY		0x1C
1505 #define	IPMI_ET_FAN			0x1D
1506 #define	IPMI_ET_COOLING_DOMAIN		0x1E
1507 #define	IPMI_ET_CABLE			0x1F
1508 #define	IPMI_ET_MEMORY_DEVICE		0x20
1509 #define	IPMI_ET_MANAGEMENT_SOFTWARE	0x21
1510 #define	IPMI_ET_SYSTEM_FIRMWARE		0x22
1511 #define	IPMI_ET_OS			0x23
1512 #define	IPMI_ET_SYSTEM_BUS		0x24
1513 #define	IPMI_ET_GROUP			0x25
1514 #define	IPMI_ET_REMOTE			0x26
1515 #define	IPMI_ET_ENVIRONMENT		0x27
1516 #define	IPMI_ET_BATTERY			0x28
1517 #define	IPMI_ET_BLADE			0x29
1518 #define	IPMI_ET_SWITCH			0x2A
1519 #define	IPMI_ET_PROCMEM_MODULE		0x2B
1520 #define	IPMI_ET_IO_MODULE		0x2C
1521 #define	IPMI_ET_PROCIO_MODULE		0x2D
1522 #define	IPMI_ET_CONTROLLER_FIRMWARE	0x2E
1523 #define	IPMI_ET_CHANNEL			0x2F
1524 #define	IPMI_ET_PCI			0x30
1525 #define	IPMI_ET_PCIE			0x31
1526 #define	IPMI_ET_SCSI			0x32
1527 #define	IPMI_ET_SATA_SAS		0x33
1528 #define	IPMI_ET_FSB			0x34
1529 #define	IPMI_ET_RTC			0x35
1530 
1531 /*
1532  * Get Sensor Reading.  See section 35.14.
1533  */
1534 
1535 #define	IPMI_CMD_GET_SENSOR_READING	0x2d
1536 
1537 typedef struct ipmi_sensor_reading {
1538 	uint8_t		isr_reading;
1539 	DECL_BITFIELD4(
1540 	    __reserved1			:5,
1541 	    isr_state_unavailable	:1,
1542 	    isr_scanning_enabled	:1,
1543 	    isr_event_enabled		:1);
1544 	uint16_t	isr_state;
1545 } ipmi_sensor_reading_t;
1546 
1547 #define	IPMI_SENSOR_THRESHOLD_LOWER_NONCRIT		0x0001
1548 #define	IPMI_SENSOR_THRESHOLD_LOWER_CRIT		0x0002
1549 #define	IPMI_SENSOR_THRESHOLD_LOWER_NONRECOV		0x0004
1550 #define	IPMI_SENSOR_THRESHOLD_UPPER_NONCRIT		0x0008
1551 #define	IPMI_SENSOR_THRESHOLD_UPPER_CRIT		0x0010
1552 #define	IPMI_SENSOR_THRESHOLD_UPPER_NONRECOV		0x0020
1553 
1554 extern ipmi_sensor_reading_t *ipmi_get_sensor_reading(ipmi_handle_t *, uint8_t);
1555 extern int ipmi_sdr_conv_reading(ipmi_sdr_full_sensor_t *, uint8_t,
1556     double *);
1557 /*
1558  * Set Sensor Reading.  See section 35.14.
1559  */
1560 #define	IPMI_CMD_SET_SENSOR_READING	0x30
1561 
1562 #define	IPMI_SENSOR_OP_CLEAR	0x3	/* clear '0' bits */
1563 #define	IPMI_SENSOR_OP_SET	0x2	/* set '1' bits */
1564 #define	IPMI_SENSOR_OP_EXACT	0x1	/* set bits exactly */
1565 
1566 typedef struct ipmi_set_sensor_reading {
1567 	uint8_t		iss_id;
1568 	DECL_BITFIELD5(
1569 	    iss_set_reading		:1,
1570 	    __reserved			:1,
1571 	    iss_deassrt_op		:2,
1572 	    iss_assert_op		:2,
1573 	    iss_data_bytes		:2);
1574 	uint8_t		iss_sensor_reading;
1575 	uint16_t	iss_assert_state;	/* optional */
1576 	uint16_t	iss_deassert_state;	/* optional */
1577 	uint8_t		iss_event_data1;	/* optional */
1578 	uint8_t		iss_event_data2;	/* optional */
1579 	uint8_t		iss_event_data3;	/* optional */
1580 } ipmi_set_sensor_reading_t;
1581 
1582 extern int ipmi_set_sensor_reading(ipmi_handle_t *,
1583     ipmi_set_sensor_reading_t *);
1584 
1585 /*
1586  * These IPMI message id/opcodes are documented in Appendix G in the IPMI spec.
1587  *
1588  * Payloads for these two commands are described in Sections 34.1 and 34.2 of
1589  * the spec, respectively.
1590  */
1591 #define	IPMI_CMD_GET_FRU_INV_AREA	0x10
1592 #define	IPMI_CMD_READ_FRU_DATA		0x11
1593 
1594 /*
1595  * Structs to hold the FRU Common Header and the FRU Product Info Area, as
1596  * described in the IPMI Platform Management FRU Information Storage
1597  * Definition (v1.1).
1598  */
1599 typedef struct ipmi_fru_hdr
1600 {
1601 	uint8_t		ifh_format;
1602 	uint8_t		ifh_int_use_off;
1603 	uint8_t		ifh_chassis_info_off;
1604 	uint8_t		ifh_board_info_off;
1605 	uint8_t		ifh_product_info_off;
1606 	uint8_t		ifh_multi_rec_off;
1607 	uint8_t		ifh_pad;
1608 	uint8_t		ifh_chksum;
1609 } ipmi_fru_hdr_t;
1610 
1611 /*
1612  * Because only 6 bits are used to specify the length of each field in the FRU
1613  * product and board info areas, the biggest string we would ever need to hold
1614  * would be 63 chars plus a NULL.
1615  */
1616 #define	FRU_INFO_MAXLEN	64
1617 
1618 typedef struct ipmi_fru_brd_info
1619 {
1620 	char	ifbi_manuf_date[3];
1621 	char	ifbi_manuf_name[FRU_INFO_MAXLEN];
1622 	char	ifbi_board_name[FRU_INFO_MAXLEN];
1623 	char	ifbi_product_serial[FRU_INFO_MAXLEN];
1624 	char	ifbi_part_number[FRU_INFO_MAXLEN];
1625 } ipmi_fru_brd_info_t;
1626 
1627 typedef struct ipmi_fru_prod_info
1628 {
1629 	char	ifpi_manuf_name[FRU_INFO_MAXLEN];
1630 	char	ifpi_product_name[FRU_INFO_MAXLEN];
1631 	char	ifpi_part_number[FRU_INFO_MAXLEN];
1632 	char	ifpi_product_version[FRU_INFO_MAXLEN];
1633 	char	ifpi_product_serial[FRU_INFO_MAXLEN];
1634 	char	ifpi_asset_tag[FRU_INFO_MAXLEN];
1635 } ipmi_fru_prod_info_t;
1636 
1637 extern int ipmi_fru_read(ipmi_handle_t *, ipmi_sdr_fru_locator_t *, char **);
1638 extern int ipmi_fru_parse_board(ipmi_handle_t *, char *, ipmi_fru_brd_info_t *);
1639 extern int ipmi_fru_parse_product(ipmi_handle_t *, char *,
1640     ipmi_fru_prod_info_t *);
1641 
1642 /*
1643  * Routines to convert from entity and sensors defines into text strings.
1644  */
1645 void ipmi_entity_name(uint8_t, char *, size_t);
1646 void ipmi_sensor_type_name(uint8_t, char *, size_t);
1647 void ipmi_sensor_units_name(uint8_t, char *, size_t);
1648 void ipmi_sensor_reading_name(uint8_t, uint8_t, char *, size_t);
1649 
1650 /*
1651  * Entity management.  IPMI has a notion of 'entities', but these are not
1652  * directly accessible from any commands.  Instead, their existence is inferred
1653  * from examining the SDR repository.  Since this is rather unwieldy, and
1654  * iterating over entities is a common operation, libipmi provides an entity
1655  * abstraction that hides the implementation details.  This handles entity
1656  * groupings as well as SDR associations.
1657  */
1658 typedef struct ipmi_entity {
1659 	uint8_t		ie_type;
1660 	uint8_t		ie_instance;
1661 	uint8_t		ie_children;
1662 	boolean_t	ie_logical;
1663 } ipmi_entity_t;
1664 
1665 extern int ipmi_entity_iter(ipmi_handle_t *, int (*)(ipmi_handle_t *,
1666     ipmi_entity_t *, void *), void *);
1667 extern int ipmi_entity_iter_sdr(ipmi_handle_t *, ipmi_entity_t *,
1668     int (*)(ipmi_handle_t *, ipmi_entity_t *, const char *, ipmi_sdr_t *,
1669     void *), void *);
1670 extern int ipmi_entity_iter_children(ipmi_handle_t *, ipmi_entity_t *,
1671     int (*)(ipmi_handle_t *, ipmi_entity_t *, void *), void *);
1672 extern ipmi_entity_t *ipmi_entity_lookup(ipmi_handle_t *, uint8_t,
1673     uint8_t);
1674 extern ipmi_entity_t *ipmi_entity_lookup_sdr(ipmi_handle_t *, const char *);
1675 extern ipmi_entity_t *ipmi_entity_parent(ipmi_handle_t *, ipmi_entity_t *);
1676 extern int ipmi_entity_present(ipmi_handle_t *, ipmi_entity_t *, boolean_t *);
1677 extern int ipmi_entity_present_sdr(ipmi_handle_t *, ipmi_sdr_t *, boolean_t *);
1678 
1679 /*
1680  * User management.  The raw functions are private to libipmi, and only the
1681  * higher level abstraction (ipmi_user_t) is exported to consumers of the
1682  * library.
1683  */
1684 
1685 #define	IPMI_USER_PRIV_CALLBACK		0x1
1686 #define	IPMI_USER_PRIV_USER		0x2
1687 #define	IPMI_USER_PRIV_OPERATOR		0x3
1688 #define	IPMI_USER_PRIV_ADMIN		0x4
1689 #define	IPMI_USER_PRIV_OEM		0x5
1690 #define	IPMI_USER_PRIV_NONE		0xf
1691 
1692 typedef struct ipmi_user {
1693 	uint8_t		iu_uid;
1694 	char		*iu_name;
1695 	boolean_t	iu_enabled;
1696 	boolean_t	iu_ipmi_msg_enable;
1697 	boolean_t	iu_link_auth_enable;
1698 	uint8_t		iu_priv;
1699 } ipmi_user_t;
1700 
1701 extern int ipmi_user_iter(ipmi_handle_t *,
1702     int (*)(ipmi_user_t *, void *), void *);
1703 extern ipmi_user_t *ipmi_user_lookup_name(ipmi_handle_t *, const char *);
1704 extern ipmi_user_t *ipmi_user_lookup_id(ipmi_handle_t *, uint8_t);
1705 extern int ipmi_user_set_password(ipmi_handle_t *, uint8_t, const char *);
1706 
1707 /*
1708  * The remaining functions are private to the implementation of the Sun ILOM
1709  * service processor.  These function first check the manufacturer from the IPMI
1710  * device ID, and will return EIPMI_NOT_SUPPORTED if attempted for non-Sun
1711  * devices.
1712  */
1713 
1714 /*
1715  * Sun OEM LED requests.
1716  */
1717 
1718 #define	IPMI_SUNOEM_LED_MODE_OFF	0
1719 #define	IPMI_SUNOEM_LED_MODE_ON		1
1720 #define	IPMI_SUNOEM_LED_MODE_STANDBY	2
1721 #define	IPMI_SUNOEM_LED_MODE_SLOW	3
1722 #define	IPMI_SUNOEM_LED_MODE_FAST	4
1723 
1724 /*
1725  * These functions take a SDR record and construct the appropriate form of the
1726  * above commands.
1727  */
1728 extern int ipmi_sunoem_led_set(ipmi_handle_t *,
1729     ipmi_sdr_generic_locator_t *, uint8_t);
1730 extern int ipmi_sunoem_led_get(ipmi_handle_t *,
1731     ipmi_sdr_generic_locator_t *, uint8_t *);
1732 
1733 /*
1734  * Sun OEM uptime.  Note that the underlying command returns the uptime in big
1735  * endian form.  This wrapper automatically converts to the appropriate native
1736  * form.
1737  */
1738 
1739 #define	IPMI_CMD_SUNOEM_UPTIME		0x08
1740 
1741 extern int ipmi_sunoem_uptime(ipmi_handle_t *, uint32_t *, uint32_t *);
1742 
1743 /*
1744  * Sun OEM FRU update.  The FRU information is managed through a generic
1745  * identifier, and then a type-specific data portion.  The wrapper function will
1746  * automatically fill in the data length field according to which type is
1747  * specified.
1748  */
1749 
1750 #define	IPMI_CMD_SUNOEM_FRU_UPDATE	0x16
1751 
1752 #define	IPMI_SUNOEM_FRU_DIMM	0x00
1753 #define	IPMI_SUNOEM_FRU_CPU	0x01
1754 #define	IPMI_SUNOEM_FRU_BIOS	0x02
1755 #define	IPMI_SUNOEM_FRU_DISK	0x03
1756 
1757 typedef struct ipmi_sunoem_fru {
1758 	uint8_t				isf_type;
1759 	uint8_t				isf_id;
1760 	uint8_t				isf_datalen;
1761 	union {
1762 		struct {
1763 			uint8_t		isf_data[128];
1764 		} dimm;
1765 		struct {
1766 			uint32_t	isf_thermtrip;
1767 			uint32_t	isf_eax;
1768 			char		isf_product[48];
1769 		} cpu;
1770 		struct {
1771 			char		isf_part[16];
1772 			char		isf_version[16];
1773 		} bios;
1774 		struct {
1775 			char		isf_manufacturer[16];
1776 			char		isf_model[28];
1777 			char		isf_serial[20];
1778 			char		isf_version[8];
1779 			char		isf_capacity[16];
1780 		} disk;
1781 	} isf_data;
1782 } ipmi_sunoem_fru_t;
1783 
1784 int ipmi_sunoem_update_fru(ipmi_handle_t *, ipmi_sunoem_fru_t *);
1785 
1786 #pragma pack()
1787 
1788 #ifdef	__cplusplus
1789 }
1790 #endif
1791 
1792 #endif	/* _LIBIPMI_H */
1793