1*3798Seschrock /*
2*3798Seschrock  * CDDL HEADER START
3*3798Seschrock  *
4*3798Seschrock  * The contents of this file are subject to the terms of the
5*3798Seschrock  * Common Development and Distribution License (the "License").
6*3798Seschrock  * You may not use this file except in compliance with the License.
7*3798Seschrock  *
8*3798Seschrock  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*3798Seschrock  * or http://www.opensolaris.org/os/licensing.
10*3798Seschrock  * See the License for the specific language governing permissions
11*3798Seschrock  * and limitations under the License.
12*3798Seschrock  *
13*3798Seschrock  * When distributing Covered Code, include this CDDL HEADER in each
14*3798Seschrock  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*3798Seschrock  * If applicable, add the following below this CDDL HEADER, with the
16*3798Seschrock  * fields enclosed by brackets "[]" replaced with your own identifying
17*3798Seschrock  * information: Portions Copyright [yyyy] [name of copyright owner]
18*3798Seschrock  *
19*3798Seschrock  * CDDL HEADER END
20*3798Seschrock  */
21*3798Seschrock /*
22*3798Seschrock  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*3798Seschrock  * Use is subject to license terms.
24*3798Seschrock  */
25*3798Seschrock 
26*3798Seschrock #ifndef	_LIBIPMI_H
27*3798Seschrock #define	_LIBIPMI_H
28*3798Seschrock 
29*3798Seschrock #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*3798Seschrock 
31*3798Seschrock #include <sys/bmc_intf.h>
32*3798Seschrock #include <sys/byteorder.h>
33*3798Seschrock 
34*3798Seschrock /*
35*3798Seschrock  * Private interfaces for communicating with attached services over IPMI.  This
36*3798Seschrock  * library is designed for system software communicating with Sun-supported
37*3798Seschrock  * service processors over /dev/bmc.  It is not a generic IPMI library.
38*3798Seschrock  *
39*3798Seschrock  * Documentation references refer to "Intelligent Platform Management Interface
40*3798Seschrock  * Specification Second Generation v2.0", document revision 1.0 with Februrary
41*3798Seschrock  * 15, 2006 Markup from "IPMI v2.0 Addenda, Errata, and Clarifications Revision
42*3798Seschrock  * 3".
43*3798Seschrock  */
44*3798Seschrock 
45*3798Seschrock #ifdef	__cplusplus
46*3798Seschrock extern "C" {
47*3798Seschrock #endif
48*3798Seschrock 
49*3798Seschrock typedef struct ipmi_handle ipmi_handle_t;
50*3798Seschrock 
51*3798Seschrock #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
52*3798Seschrock #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
53*3798Seschrock #endif
54*3798Seschrock 
55*3798Seschrock #pragma pack(1)
56*3798Seschrock 
57*3798Seschrock /*
58*3798Seschrock  * Basic netfn definitions.  See section 5.1.
59*3798Seschrock  */
60*3798Seschrock #define	IPMI_NETFN_APP			BMC_NETFN_APP
61*3798Seschrock #define	IPMI_NETFN_STORAGE		BMC_NETFN_STORAGE
62*3798Seschrock #define	IPMI_NETFN_SE			BMC_NETFN_SE
63*3798Seschrock #define	IPMI_NETFN_OEM			0x2e
64*3798Seschrock 
65*3798Seschrock /*
66*3798Seschrock  * Error definitions
67*3798Seschrock  */
68*3798Seschrock #define	EIPMI_BASE	2000
69*3798Seschrock 
70*3798Seschrock enum {
71*3798Seschrock 	EIPMI_NOMEM = EIPMI_BASE,	/* memory allocation failure */
72*3798Seschrock 	EIPMI_BMC_OPEN_FAILED,		/* failed to open /dev/bmc */
73*3798Seschrock 	EIPMI_BMC_PUTMSG,		/* putmsg() failed */
74*3798Seschrock 	EIPMI_BMC_GETMSG,		/* getmsg() failed */
75*3798Seschrock 	EIPMI_BMC_RESPONSE,		/* response from /dev/bmc failed */
76*3798Seschrock 	EIPMI_INVALID_COMMAND,		/* invalid command */
77*3798Seschrock 	EIPMI_COMMAND_TIMEOUT,		/* command timeout */
78*3798Seschrock 	EIPMI_DATA_LENGTH_EXCEEDED,	/* maximum data length exceeded */
79*3798Seschrock 	EIPMI_SEND_FAILED,		/* failed to send BMC request */
80*3798Seschrock 	EIPMI_UNSPECIFIED,		/* unspecified error */
81*3798Seschrock 	EIPMI_UNKNOWN,			/* unknown error */
82*3798Seschrock 	EIPMI_BAD_RESPONSE,		/* received unexpected response */
83*3798Seschrock 	EIPMI_BAD_RESPONSE_LENGTH,	/* unexpected response length */
84*3798Seschrock 	EIPMI_INVALID_RESERVATION,	/* invalid reservation */
85*3798Seschrock 	EIPMI_NOT_PRESENT,		/* requested entity not present */
86*3798Seschrock 	EIPMI_INVALID_REQUEST,		/* malformed request */
87*3798Seschrock 	EIPMI_BUSY,			/* SP is busy */
88*3798Seschrock 	EIPMI_NOSPACE,			/* SP is out of space */
89*3798Seschrock 	EIPMI_UNAVAILABLE,		/* SP is present but unavailable */
90*3798Seschrock 	EIPMI_ACCESS			/* insufficient privileges */
91*3798Seschrock };
92*3798Seschrock 
93*3798Seschrock /*
94*3798Seschrock  * Basic library functions.
95*3798Seschrock  *
96*3798Seschrock  * The ipmi_handle is the primary interface to the library.  The library itself
97*3798Seschrock  * is not MT-safe, but it is safe within a single handle.  Multithreaded clients
98*3798Seschrock  * should either open multiple handles, or otherwise synchronize access to the
99*3798Seschrock  * same handle.
100*3798Seschrock  *
101*3798Seschrock  * There is a single command response buffer that is stored with the handle, to
102*3798Seschrock  * simplify memory management in the caller.  The memory referenced by a command
103*3798Seschrock  * response is only valid until the next command is issued.  The caller is
104*3798Seschrock  * responsible for making a copy of the response if it is needed.
105*3798Seschrock  */
106*3798Seschrock extern ipmi_handle_t *ipmi_open(int *, char **);
107*3798Seschrock extern void ipmi_close(ipmi_handle_t *);
108*3798Seschrock 
109*3798Seschrock extern int ipmi_errno(ipmi_handle_t *);
110*3798Seschrock extern const char *ipmi_errmsg(ipmi_handle_t *);
111*3798Seschrock 
112*3798Seschrock /*
113*3798Seschrock  * Raw requests.  See section 5.
114*3798Seschrock  */
115*3798Seschrock typedef struct ipmi_cmd {
116*3798Seschrock 	uint8_t		ic_netfn:6;
117*3798Seschrock 	uint8_t		ic_lun:2;
118*3798Seschrock 	uint8_t		ic_cmd;
119*3798Seschrock 	uint16_t	ic_dlen;
120*3798Seschrock 	void		*ic_data;
121*3798Seschrock } ipmi_cmd_t;
122*3798Seschrock 
123*3798Seschrock extern ipmi_cmd_t *ipmi_send(ipmi_handle_t *, ipmi_cmd_t *);
124*3798Seschrock 
125*3798Seschrock /*
126*3798Seschrock  * Retrieve basic information about the IPMI device.  See section 20.1 "Get
127*3798Seschrock  * Device ID Command".
128*3798Seschrock  */
129*3798Seschrock #define	IPMI_CMD_GET_DEVICEID		0x01
130*3798Seschrock 
131*3798Seschrock typedef struct ipmi_deviceid {
132*3798Seschrock 	uint8_t		id_devid;
133*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
134*3798Seschrock 	uint8_t		id_dev_rev:4;
135*3798Seschrock 	uint8_t		__reserved:3;
136*3798Seschrock 	uint8_t		id_dev_sdrs:1;
137*3798Seschrock #else
138*3798Seschrock 	uint8_t		id_dev_sdrs:1;
139*3798Seschrock 	uint8_t		__reserved:3;
140*3798Seschrock 	uint8_t		id_dev_rev:4;
141*3798Seschrock #endif
142*3798Seschrock #if defined(_BIT_FIELD_LTOH)
143*3798Seschrock 	uint8_t		id_firm_major:7;
144*3798Seschrock 	uint8_t		id_dev_available:1;
145*3798Seschrock #else
146*3798Seschrock 	uint8_t		id_dev_available:1;
147*3798Seschrock 	uint8_t		id_firm_major:7;
148*3798Seschrock #endif
149*3798Seschrock 	uint8_t		id_firm_minor;
150*3798Seschrock 	uint8_t		id_ipmi_rev;
151*3798Seschrock 	uint8_t		id_dev_support;
152*3798Seschrock 	uint8_t		id_manufacturer[3];
153*3798Seschrock 	uint16_t	id_product;
154*3798Seschrock } ipmi_deviceid_t;
155*3798Seschrock 
156*3798Seschrock #define	IPMI_OEM_SUN	0x2a
157*3798Seschrock 
158*3798Seschrock ipmi_deviceid_t *ipmi_get_deviceid(ipmi_handle_t *);
159*3798Seschrock 
160*3798Seschrock #define	ipmi_devid_manufacturer(dp)		\
161*3798Seschrock 	((dp)->id_manufacturer[0] |		\
162*3798Seschrock 	((dp)->id_manufacturer[1] << 8) |	\
163*3798Seschrock 	((dp)->id_manufacturer[2] << 16))
164*3798Seschrock 
165*3798Seschrock /*
166*3798Seschrock  * SDR (Sensor Device Record) requests.  A cache of the current SDR repository
167*3798Seschrock  * is kept as part of the IPMI handle and updated when necessary.  Routines to
168*3798Seschrock  * access the raw SDR repository are also provided.
169*3798Seschrock  */
170*3798Seschrock 
171*3798Seschrock /*
172*3798Seschrock  * Reserve repository command.  See section 33.11.
173*3798Seschrock  */
174*3798Seschrock #define	IPMI_CMD_RESERVE_SDR_REPOSITORY	0x22
175*3798Seschrock 
176*3798Seschrock /*
177*3798Seschrock  * Get SDR command.  See section 33.12.  This command accesses the raw SDR
178*3798Seschrock  * repository.  Clients can also use the lookup functions to retrieve a
179*3798Seschrock  * particular SDR record by name.
180*3798Seschrock  *
181*3798Seschrock  * The list of possible types is indicated in the sub-chapters of section 43.
182*3798Seschrock  */
183*3798Seschrock typedef struct ipmi_sdr {
184*3798Seschrock 	uint16_t	is_id;
185*3798Seschrock 	uint8_t		is_version;
186*3798Seschrock 	uint8_t		is_type;
187*3798Seschrock 	uint8_t		is_length;
188*3798Seschrock 	uint8_t		is_record[1];
189*3798Seschrock } ipmi_sdr_t;
190*3798Seschrock #define	IPMI_CMD_GET_SDR		0x23
191*3798Seschrock 
192*3798Seschrock #define	IPMI_SDR_FIRST			0x0000
193*3798Seschrock #define	IPMI_SDR_LAST			0xFFFF
194*3798Seschrock 
195*3798Seschrock extern ipmi_sdr_t *ipmi_sdr_get(ipmi_handle_t *, uint16_t, uint16_t *);
196*3798Seschrock 
197*3798Seschrock /*
198*3798Seschrock  * Generic Device Locator Record.  See section 43.7.
199*3798Seschrock  */
200*3798Seschrock 
201*3798Seschrock #define	IPMI_SDR_TYPE_GENERIC_LOCATOR		0x10
202*3798Seschrock 
203*3798Seschrock typedef struct ipmi_sdr_generic_locator {
204*3798Seschrock 	/* RECORD KEY BYTES */
205*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
206*3798Seschrock 	uint8_t		__reserved1:1;
207*3798Seschrock 	uint8_t		is_gl_accessaddr:7;
208*3798Seschrock 	uint8_t		is_gl_channel_msb:1;
209*3798Seschrock 	uint8_t		is_gl_slaveaddr:7;
210*3798Seschrock 	uint8_t		is_gl_bus:3;
211*3798Seschrock 	uint8_t		is_gl_lun:2;
212*3798Seschrock 	uint8_t		is_gl_channel:3;
213*3798Seschrock #else
214*3798Seschrock 	uint8_t		is_gl_accessaddr:7;
215*3798Seschrock 	uint8_t		__reserved1:1;
216*3798Seschrock 	uint8_t		is_gl_slaveaddr:7;
217*3798Seschrock 	uint8_t		is_gl_channel_msb:1;
218*3798Seschrock 	uint8_t		is_gl_channel:3;
219*3798Seschrock 	uint8_t		is_gl_lun:2;
220*3798Seschrock 	uint8_t		is_gl_bus:3;
221*3798Seschrock #endif
222*3798Seschrock 	/* RECORD BODY BYTES */
223*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
224*3798Seschrock 	uint8_t		is_gl_span:3;
225*3798Seschrock 	uint8_t		__reserved2:5;
226*3798Seschrock #else
227*3798Seschrock 	uint8_t		__reserved2:5;
228*3798Seschrock 	uint8_t		is_gl_span:3;
229*3798Seschrock #endif
230*3798Seschrock 	uint8_t		__reserved3;
231*3798Seschrock 	uint8_t		is_gl_type;
232*3798Seschrock 	uint8_t		is_gl_modifier;
233*3798Seschrock 	uint8_t		is_gl_entity;
234*3798Seschrock 	uint8_t		is_gl_instance;
235*3798Seschrock 	uint8_t		is_gl_oem;
236*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
237*3798Seschrock 	uint8_t		is_gl_idlen:6;
238*3798Seschrock 	uint8_t		is_gl_idtype:2;
239*3798Seschrock #else
240*3798Seschrock 	uint8_t		is_gl_idtype:2;
241*3798Seschrock 	uint8_t		is_gl_idlen:6;
242*3798Seschrock #endif
243*3798Seschrock 	char		is_gl_idstring[1];
244*3798Seschrock } ipmi_sdr_generic_locator_t;
245*3798Seschrock 
246*3798Seschrock /*
247*3798Seschrock  * FRU Device Locator Record.  See section 43.8.
248*3798Seschrock  */
249*3798Seschrock 
250*3798Seschrock #define	IPMI_SDR_TYPE_FRU_LOCATOR		0x11
251*3798Seschrock 
252*3798Seschrock typedef struct ipmi_sdr_fru_locator {
253*3798Seschrock 	/* RECORD KEY BYTES */
254*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
255*3798Seschrock 	uint8_t		__reserved1:1;
256*3798Seschrock 	uint8_t		is_fl_accessaddr:7;
257*3798Seschrock #else
258*3798Seschrock 	uint8_t		is_fl_accessaddr:7;
259*3798Seschrock 	uint8_t		__reserved1:1;
260*3798Seschrock #endif
261*3798Seschrock 	union {
262*3798Seschrock 		struct {
263*3798Seschrock 			uint8_t	_is_fl_devid;
264*3798Seschrock 		} _logical;
265*3798Seschrock 		struct {
266*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
267*3798Seschrock 			uint8_t	__reserved:1;
268*3798Seschrock 			uint8_t	_is_fl_slaveaddr:7;
269*3798Seschrock #else
270*3798Seschrock 			uint8_t	_is_fl_slaveaddr:7;
271*3798Seschrock 			uint8_t	__reserved:1;
272*3798Seschrock #endif
273*3798Seschrock 		} _nonintelligent;
274*3798Seschrock 	} _devid_or_slaveaddr;
275*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
276*3798Seschrock 	uint8_t		is_fl_bus:3;
277*3798Seschrock 	uint8_t		is_fl_lun:2;
278*3798Seschrock 	uint8_t		__reserved2:2;
279*3798Seschrock 	uint8_t		is_fl_logical:1;
280*3798Seschrock 	uint8_t		__reserved3:4;
281*3798Seschrock 	uint8_t		is_fl_channel:4;
282*3798Seschrock #else
283*3798Seschrock 	uint8_t		is_fl_logical:1;
284*3798Seschrock 	uint8_t		__reserved2:2;
285*3798Seschrock 	uint8_t		is_fl_lun:2;
286*3798Seschrock 	uint8_t		is_fl_bus:3;
287*3798Seschrock 	uint8_t		is_fl_channel:4;
288*3798Seschrock 	uint8_t		__reserved3:4;
289*3798Seschrock #endif
290*3798Seschrock 	/* RECORD BODY BYTES */
291*3798Seschrock 	uint8_t		__reserved4;
292*3798Seschrock 	uint8_t		is_fl_type;
293*3798Seschrock 	uint8_t		is_fl_modifier;
294*3798Seschrock 	uint8_t		is_fl_entity;
295*3798Seschrock 	uint8_t		is_fl_instance;
296*3798Seschrock 	uint8_t		is_fl_oem;
297*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
298*3798Seschrock 	uint8_t		is_fl_idlen:6;
299*3798Seschrock 	uint8_t		is_fl_idtype:2;
300*3798Seschrock #else
301*3798Seschrock 	uint8_t		is_fl_idtype:2;
302*3798Seschrock 	uint8_t		is_fl_idlen:6;
303*3798Seschrock #endif
304*3798Seschrock 	char		is_fl_idstring[1];
305*3798Seschrock } ipmi_sdr_fru_locator_t;
306*3798Seschrock 
307*3798Seschrock #define	is_fl_devid	_devid_or_slaveaddr._logical._is_fl_devid
308*3798Seschrock #define	is_fl_slaveaddr	_devid_or_slaveaddr._nonintelligent._is_fl_slaveaddr
309*3798Seschrock 
310*3798Seschrock /*
311*3798Seschrock  * The remaining SDR types do not have an associated structure, yet.
312*3798Seschrock  */
313*3798Seschrock #define	IPMI_SDR_TYPE_FULL_SENSOR		0x01
314*3798Seschrock #define	IPMI_SDR_TYPE_COMPACT_SENSOR		0x02
315*3798Seschrock #define	IPMI_SDR_TYPE_EVENT_ONLY		0x03
316*3798Seschrock #define	IPMI_SDR_TYPE_ENTITY_ASSOCIATION	0x08
317*3798Seschrock #define	IPMI_SDR_TYPE_DEVICE_RELATIVE		0x09
318*3798Seschrock #define	IPMI_SDR_TYPE_MANAGEMENT_DEVICE		0x12
319*3798Seschrock #define	IPMI_SDR_TYPE_MANAGEMENT_CONFIRMATION	0x13
320*3798Seschrock #define	IPMI_SDR_TYPE_BMC_MESSAGE_CHANNEL	0x14
321*3798Seschrock #define	IPMI_SDR_TYPE_OEM			0xC0
322*3798Seschrock 
323*3798Seschrock /*
324*3798Seschrock  * Lookup the given sensor type by name.  These functions automatically read in
325*3798Seschrock  * and cache the complete SDR repository.
326*3798Seschrock  */
327*3798Seschrock extern ipmi_sdr_fru_locator_t *ipmi_sdr_lookup_fru(ipmi_handle_t *,
328*3798Seschrock     const char *);
329*3798Seschrock extern ipmi_sdr_generic_locator_t *ipmi_sdr_lookup_generic(ipmi_handle_t *,
330*3798Seschrock     const char *);
331*3798Seschrock 
332*3798Seschrock /*
333*3798Seschrock  * Get Sensor Reading.  See section 35.14.
334*3798Seschrock  */
335*3798Seschrock 
336*3798Seschrock #define	IPMI_CMD_GET_SENSOR_READING	0x2d
337*3798Seschrock 
338*3798Seschrock typedef struct ipmi_sensor_reading {
339*3798Seschrock 	uint8_t		isr_reading;
340*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
341*3798Seschrock 	uint8_t		__reserved1:5;
342*3798Seschrock 	uint8_t		isr_state_unavailable:1;
343*3798Seschrock 	uint8_t		isr_scanning_disabled:1;
344*3798Seschrock 	uint8_t		isr_event_disabled:1;
345*3798Seschrock #else
346*3798Seschrock 	uint8_t		isr_event_disabled:1;
347*3798Seschrock 	uint8_t		isr_scanning_disabled:1;
348*3798Seschrock 	uint8_t		isr_state_unavailable:1;
349*3798Seschrock 	uint8_t		__reserved1:5;
350*3798Seschrock #endif
351*3798Seschrock 	uint16_t	isr_state;
352*3798Seschrock } ipmi_sensor_reading_t;
353*3798Seschrock 
354*3798Seschrock extern ipmi_sensor_reading_t *ipmi_get_sensor_reading(ipmi_handle_t *, uint8_t);
355*3798Seschrock 
356*3798Seschrock /*
357*3798Seschrock  * Set Sensor Reading.  See section 35.14.
358*3798Seschrock  */
359*3798Seschrock #define	IPMI_CMD_SET_SENSOR_READING	0x30
360*3798Seschrock 
361*3798Seschrock #define	IPMI_SENSOR_OP_CLEAR	0x3	/* clear '0' bits */
362*3798Seschrock #define	IPMI_SENSOR_OP_SET	0x2	/* set '1' bits */
363*3798Seschrock #define	IPMI_SENSOR_OP_EXACT	0x1	/* set bits exactly */
364*3798Seschrock 
365*3798Seschrock typedef struct ipmi_set_sensor_reading {
366*3798Seschrock 	uint8_t		iss_id;
367*3798Seschrock #if defined(_BIT_FIELDS_LTOH)
368*3798Seschrock 	uint8_t		iss_set_reading:1;
369*3798Seschrock 	uint8_t		__reserved:1;
370*3798Seschrock 	uint8_t		iss_deassrt_op:2;
371*3798Seschrock 	uint8_t		iss_assert_op:2;
372*3798Seschrock 	uint8_t		iss_data_bytes:2;
373*3798Seschrock #else
374*3798Seschrock 	uint8_t		iss_data_bytes:2;
375*3798Seschrock 	uint8_t		iss_assert_op:2;
376*3798Seschrock 	uint8_t		iss_deassrt_op:2;
377*3798Seschrock 	uint8_t		__reserved:1;
378*3798Seschrock 	uint8_t		iss_set_reading:1;
379*3798Seschrock #endif
380*3798Seschrock 	uint8_t		iss_sensor_reading;
381*3798Seschrock 	uint16_t	iss_assert_state;	/* optional */
382*3798Seschrock 	uint16_t	iss_deassert_state;	/* optional */
383*3798Seschrock 	uint8_t		iss_event_data1;	/* optional */
384*3798Seschrock 	uint8_t		iss_event_data2;	/* optional */
385*3798Seschrock 	uint8_t		iss_event_data3;	/* optional */
386*3798Seschrock } ipmi_set_sensor_reading_t;
387*3798Seschrock 
388*3798Seschrock extern int ipmi_set_sensor_reading(ipmi_handle_t *,
389*3798Seschrock     ipmi_set_sensor_reading_t *);
390*3798Seschrock 
391*3798Seschrock /*
392*3798Seschrock  * The remaining functions are private to the implementation of the Sun ILOM
393*3798Seschrock  * service processor.  These function first check the manufacturer from the IPMI
394*3798Seschrock  * device ID, and will return EIPMI_NOT_SUPPORTED if attempted for non-Sun
395*3798Seschrock  * devices.
396*3798Seschrock  */
397*3798Seschrock 
398*3798Seschrock /*
399*3798Seschrock  * Sun OEM LED requests.
400*3798Seschrock  */
401*3798Seschrock 
402*3798Seschrock #define	IPMI_CMD_SUNOEM_LED_GET		0x21
403*3798Seschrock #define	IPMI_CMD_SUNOEM_LED_SET		0x22
404*3798Seschrock 
405*3798Seschrock typedef struct ipmi_cmd_sunoem_led_set {
406*3798Seschrock 	uint8_t		ic_sls_devaddr;		/* device slave address */
407*3798Seschrock 	uint8_t		ic_sls_type;		/* led type */
408*3798Seschrock 	uint8_t		ic_sls_ctladdr;		/* controller address */
409*3798Seschrock 	uint8_t		ic_sls_hwinfo;		/* OEM hardware info */
410*3798Seschrock 	uint8_t		ic_sls_mode;		/* LED mode */
411*3798Seschrock 	uint8_t		ic_sls_force;		/* force direct access */
412*3798Seschrock 	uint8_t		ic_sls_role;		/* BMC authorization */
413*3798Seschrock } ipmi_cmd_sunoem_led_set_t;
414*3798Seschrock 
415*3798Seschrock typedef struct ipmi_cmd_sunoem_led_get {
416*3798Seschrock 	uint8_t		ic_slg_devaddr;		/* device slave address */
417*3798Seschrock 	uint8_t		ic_slg_type;		/* led type */
418*3798Seschrock 	uint8_t		ic_slg_ctladdr;		/* controller address */
419*3798Seschrock 	uint8_t		ic_slg_hwinfo;		/* OEM hardware info */
420*3798Seschrock 	uint8_t		ic_slg_force;		/* force direct access */
421*3798Seschrock } ipmi_cmd_sunoem_led_get_t;
422*3798Seschrock 
423*3798Seschrock #define	IPMI_SUNOEM_LED_TYPE_OK2RM	0
424*3798Seschrock #define	IPMI_SUNOEM_LED_TYPE_SERVICE	1
425*3798Seschrock #define	IPMI_SUNOEM_LED_TYPE_ACT	2
426*3798Seschrock #define	IPMI_SUNOEM_LED_TYPE_LOCATE	3
427*3798Seschrock #define	IPMI_SUNOEM_LED_TYPE_ANY	0xFF
428*3798Seschrock 
429*3798Seschrock #define	IPMI_SUNOEM_LED_MODE_OFF	0
430*3798Seschrock #define	IPMI_SUNOEM_LED_MODE_ON		1
431*3798Seschrock #define	IPMI_SUNOEM_LED_MODE_STANDBY	2
432*3798Seschrock #define	IPMI_SUNOEM_LED_MODE_SLOW	3
433*3798Seschrock #define	IPMI_SUNOEM_LED_MODE_FAST	4
434*3798Seschrock 
435*3798Seschrock /*
436*3798Seschrock  * These functions take a SDR record and construct the appropriate form of the
437*3798Seschrock  * above commands.
438*3798Seschrock  */
439*3798Seschrock extern int ipmi_sunoem_led_set(ipmi_handle_t *,
440*3798Seschrock     ipmi_sdr_generic_locator_t *, uint8_t);
441*3798Seschrock extern int ipmi_sunoem_led_get(ipmi_handle_t *,
442*3798Seschrock     ipmi_sdr_generic_locator_t *, uint8_t *);
443*3798Seschrock 
444*3798Seschrock /*
445*3798Seschrock  * Sun OEM uptime.  Note that the underlying command returns the uptime in big
446*3798Seschrock  * endian form.  This wrapper automatically converts to the appropriate native
447*3798Seschrock  * form.
448*3798Seschrock  */
449*3798Seschrock 
450*3798Seschrock #define	IPMI_CMD_SUNOEM_UPTIME		0x08
451*3798Seschrock 
452*3798Seschrock extern int ipmi_sunoem_uptime(ipmi_handle_t *, uint32_t *, uint32_t *);
453*3798Seschrock 
454*3798Seschrock /*
455*3798Seschrock  * Sun OEM FRU update.  The FRU information is managed through a generic
456*3798Seschrock  * identifier, and then a type-specific data portion.  The wrapper function will
457*3798Seschrock  * automatically fill in the data length field according to which type is
458*3798Seschrock  * specified.
459*3798Seschrock  */
460*3798Seschrock 
461*3798Seschrock #define	IPMI_CMD_SUNOEM_FRU_UPDATE	0x16
462*3798Seschrock 
463*3798Seschrock #define	IPMI_SUNOEM_FRU_DIMM	0x00
464*3798Seschrock #define	IPMI_SUNOEM_FRU_CPU	0x01
465*3798Seschrock #define	IPMI_SUNOEM_FRU_BIOS	0x02
466*3798Seschrock #define	IPMI_SUNOEM_FRU_DISK	0x03
467*3798Seschrock 
468*3798Seschrock typedef struct ipmi_sunoem_fru {
469*3798Seschrock 	uint8_t				isf_type;
470*3798Seschrock 	uint8_t				isf_id;
471*3798Seschrock 	uint8_t				isf_datalen;
472*3798Seschrock 	union {
473*3798Seschrock 		struct {
474*3798Seschrock 			uint8_t		isf_data[128];
475*3798Seschrock 		} dimm;
476*3798Seschrock 		struct {
477*3798Seschrock 			uint32_t	isf_thermtrip;
478*3798Seschrock 			uint32_t	isf_eax;
479*3798Seschrock 			char		isf_product[48];
480*3798Seschrock 		} cpu;
481*3798Seschrock 		struct {
482*3798Seschrock 			char		isf_part[16];
483*3798Seschrock 			char		isf_version[16];
484*3798Seschrock 		} bios;
485*3798Seschrock 		struct {
486*3798Seschrock 			char		isf_manufacturer[16];
487*3798Seschrock 			char		isf_model[28];
488*3798Seschrock 			char		isf_serial[20];
489*3798Seschrock 			char		isf_version[8];
490*3798Seschrock 			char		isf_capacity[16];
491*3798Seschrock 		} disk;
492*3798Seschrock 	} isf_data;
493*3798Seschrock } ipmi_sunoem_fru_t;
494*3798Seschrock 
495*3798Seschrock int ipmi_sunoem_update_fru(ipmi_handle_t *, ipmi_sunoem_fru_t *);
496*3798Seschrock 
497*3798Seschrock #pragma pack()
498*3798Seschrock 
499*3798Seschrock #ifdef	__cplusplus
500*3798Seschrock }
501*3798Seschrock #endif
502*3798Seschrock 
503*3798Seschrock #endif	/* _LIBIPMI_H */
504