xref: /titanic_41/usr/src/lib/libipmi/common/ipmi_impl.h (revision b02e9a2d4d2071d770e5aa9ae8f83f2bbe1f2ced)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_IPMI_IMPL_H
27 #define	_IPMI_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <stdlib.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 struct ipmi_sdr_generic_locator;
38 struct ipmi_sdr_fru_locator;
39 
40 typedef struct ipmi_sdr_cache_ent {
41 	uint8_t				isc_type;
42 	struct ipmi_sdr_generic_locator	*isc_generic;
43 	struct ipmi_sdr_fru_locator	*isc_fru;
44 	struct ipmi_sdr_cache_ent	*isc_next;
45 } ipmi_sdr_cache_ent_t;
46 
47 typedef struct ipmi_transport {
48 	void *		(*it_open)(struct ipmi_handle *);
49 	void		(*it_close)(void *);
50 	int 		(*it_send)(void *, struct ipmi_cmd *, struct ipmi_cmd *,
51 			    int *);
52 } ipmi_transport_t;
53 
54 struct ipmi_handle {
55 	ipmi_transport_t	*ih_transport;
56 	void			*ih_tdata;
57 	ipmi_cmd_t		ih_response;
58 	int			ih_errno;
59 	uint16_t		ih_reservation;
60 	int			ih_retries;
61 	ipmi_sdr_cache_ent_t	*ih_sdr_cache;
62 	ipmi_deviceid_t		ih_deviceid;
63 	boolean_t		ih_deviceid_valid;
64 	char			ih_errmsg[1024];
65 	char			ih_errbuf[1024];
66 	ipmi_user_t		*ih_users;
67 };
68 
69 /*
70  * Error handling
71  */
72 extern int ipmi_set_error(ipmi_handle_t *, int, const char *, ...);
73 
74 /*
75  * Memory allocation
76  */
77 extern void *ipmi_alloc(ipmi_handle_t *, size_t);
78 extern void *ipmi_zalloc(ipmi_handle_t *, size_t);
79 extern void ipmi_free(ipmi_handle_t *, void *);
80 extern void *impi_realloc(ipmi_handle_t *, void *, size_t);
81 extern char *ipmi_strdup(ipmi_handle_t *, const char *);
82 
83 /*
84  * Supported transports
85  */
86 extern ipmi_transport_t ipmi_transport_bmc;
87 
88 /*
89  * Miscellaneous routines
90  */
91 extern void ipmi_sdr_clear(ipmi_handle_t *);
92 extern void ipmi_user_clear(ipmi_handle_t *);
93 
94 #ifdef	__cplusplus
95 }
96 #endif
97 
98 #endif	/* _IPMI_IMPL_H */
99