xref: /openbmc/ipmitool/src/plugins/open/open.h (revision c18ec02f)
1 /*
2  * Copyright (c) 2003 Sun Microsystems, Inc.  All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistribution of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistribution in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * Neither the name of Sun Microsystems, Inc. or the names of
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * This software is provided "AS IS," without a warranty of any kind.
20  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21  * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22  * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
23  * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
24  * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
25  * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.  IN NO EVENT WILL
26  * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
27  * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
28  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
29  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
30  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31  */
32 
33 #ifndef IPMI_OPENIPMI_H
34 #define IPMI_OPENIPMI_H
35 
36 #define IPMI_MAX_ADDR_SIZE		0x20
37 #define IPMI_BMC_CHANNEL		0xf
38 #define IPMI_NUM_CHANNELS		0x10
39 
40 #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE	0x0c
41 #define IPMI_IPMB_ADDR_TYPE		0x01
42 #define IPMI_IPMB_BROADCAST_ADDR_TYPE	0x41
43 
44 #define IPMI_RESPONSE_RECV_TYPE		1
45 #define IPMI_ASYNC_EVENT_RECV_TYPE	2
46 #define IPMI_CMD_RECV_TYPE		3
47 
48 struct ipmi_addr {
49 	int addr_type;
50 	short channel;
51 	char data[IPMI_MAX_ADDR_SIZE];
52 };
53 
54 struct ipmi_msg {
55 	unsigned char netfn;
56         unsigned char cmd;
57         unsigned short data_len;
58         unsigned char *data;
59 };
60 
61 struct ipmi_req {
62 	unsigned char *addr;
63 	unsigned int addr_len;
64 	long msgid;
65 	struct ipmi_msg msg;
66 };
67 
68 struct ipmi_recv {
69 	int recv_type;
70 	unsigned char *addr;
71 	unsigned int addr_len;
72 	long msgid;
73 	struct ipmi_msg msg;
74 };
75 
76 struct ipmi_cmdspec {
77 	unsigned char netfn;
78 	unsigned char cmd;
79 };
80 
81 struct ipmi_system_interface_addr {
82 	int addr_type;
83 	short channel;
84 	unsigned char lun;
85 };
86 
87 struct ipmi_ipmb_addr {
88 	int addr_type;
89 	short channel;
90 	unsigned char slave_addr;
91 	unsigned char lun;
92 };
93 
94 #define IPMI_IOC_MAGIC			'i'
95 #define IPMICTL_RECEIVE_MSG_TRUNC	_IOWR(IPMI_IOC_MAGIC, 11, struct ipmi_recv)
96 #define IPMICTL_RECEIVE_MSG		_IOWR(IPMI_IOC_MAGIC, 12, struct ipmi_recv)
97 #define IPMICTL_SEND_COMMAND		_IOR(IPMI_IOC_MAGIC, 13, struct ipmi_req)
98 #define IPMICTL_REGISTER_FOR_CMD	_IOR(IPMI_IOC_MAGIC, 14, struct ipmi_cmdspec)
99 #define IPMICTL_UNREGISTER_FOR_CMD	_IOR(IPMI_IOC_MAGIC, 15, struct ipmi_cmdspec)
100 #define IPMICTL_SET_GETS_EVENTS_CMD	_IOR(IPMI_IOC_MAGIC, 16, int)
101 #define IPMICTL_SET_MY_ADDRESS_CMD	_IOR(IPMI_IOC_MAGIC, 17, unsigned int)
102 #define IPMICTL_GET_MY_ADDRESS_CMD	_IOR(IPMI_IOC_MAGIC, 18, unsigned int)
103 #define IPMICTL_SET_MY_LUN_CMD		_IOR(IPMI_IOC_MAGIC, 19, unsigned int)
104 #define IPMICTL_GET_MY_LUN_CMD		_IOR(IPMI_IOC_MAGIC, 20, unsigned int)
105 
106 #endif /*IPMI_OPENIPMI_H*/
107