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