1 /* 2 * ipmi_types.h 3 * 4 * MontaVista IPMI interface general types. 5 * 6 * Author: MontaVista Software, Inc. 7 * Corey Minyard <minyard@mvista.com> 8 * source@mvista.com 9 * 10 * Copyright 2003,2004,2005 MontaVista Software Inc. 11 * 12 * This software is available to you under a choice of one of two 13 * licenses. You may choose to be licensed under the terms of the GNU 14 * Lesser General Public License (GPL) Version 2 or the modified BSD 15 * license below. The following disclamer applies to both licenses: 16 * 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 23 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * GNU Lesser General Public Licence 29 * 30 * This program is free software; you can redistribute it and/or 31 * modify it under the terms of the GNU Lesser General Public License 32 * as published by the Free Software Foundation; either version 2 of 33 * the License, or (at your option) any later version. 34 * 35 * You should have received a copy of the GNU Lesser General Public 36 * License along with this program; if not, write to the Free 37 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 38 * 39 * Modified BSD Licence 40 * 41 * Redistribution and use in source and binary forms, with or without 42 * modification, are permitted provided that the following conditions 43 * are met: 44 * 45 * 1. Redistributions of source code must retain the above copyright 46 * notice, this list of conditions and the following disclaimer. 47 * 2. Redistributions in binary form must reproduce the above 48 * copyright notice, this list of conditions and the following 49 * disclaimer in the documentation and/or other materials provided 50 * with the distribution. 51 * 3. The name of the author may not be used to endorse or promote 52 * products derived from this software without specific prior 53 * written permission. 54 */ 55 56 #ifndef OPENIPMI_TYPES_H 57 #define OPENIPMI_TYPES_H 58 59 #include <stdint.h> 60 #include <OpenIPMI/ipmi_addr.h> 61 #include <OpenIPMI/deprecator.h> 62 63 #ifdef __cplusplus 64 extern "C" { 65 #endif 66 67 /* 68 * These are the main types the user has to deal with. 69 */ 70 71 /* 72 * This represents IPMI system, called a "domain". A domain is where 73 * a set of entities reside. 74 */ 75 typedef struct ipmi_domain_s ipmi_domain_t; 76 typedef struct ipmi_domain_id_s ipmi_domain_id_t; 77 78 /* 79 * An entity is a physical device that can be monitored or controlled. 80 */ 81 typedef struct ipmi_entity_s ipmi_entity_t; 82 typedef struct ipmi_entity_id_s ipmi_entity_id_t; 83 84 /* 85 * A fru is something that an entity contains that holds information 86 * about the entity in a defined format. 87 */ 88 typedef struct ipmi_fru_s ipmi_fru_t; 89 90 /* 91 * A sensor is something connected to an entity that can monitor or control 92 * the entity. 93 */ 94 typedef struct ipmi_sensor_s ipmi_sensor_t; 95 typedef struct ipmi_sensor_id_s ipmi_sensor_id_t; 96 97 /* 98 * A control is an output device, such as a light, relay, or display. 99 */ 100 typedef struct ipmi_control_s ipmi_control_t; 101 typedef struct ipmi_control_id_s ipmi_control_id_t; 102 103 /* Used to represent a time difference, in nanoseconds. */ 104 typedef int64_t ipmi_timeout_t; 105 106 #define IPMI_INVALID_TIME INT64_MIN 107 /* Used to represent an absolute time, in nanoseconds since 00:00 Jan 108 1, 1970 */ 109 typedef int64_t ipmi_time_t; 110 111 /* This type holds the arguments for an IPMI connection. */ 112 typedef struct ipmi_args_s ipmi_args_t; 113 114 #ifndef __LINUX_IPMI_H /* Don't include this is we are including the kernel */ 115 116 #define IPMI_MAX_MSG_LENGTH 256 117 118 /* A raw IPMI message without any addressing. This covers both 119 commands and responses. The completion code is always the first 120 byte of data in the response (as the spec shows the messages laid 121 out). */ 122 typedef struct ipmi_msg 123 { 124 unsigned char netfn; 125 unsigned char cmd; 126 unsigned short data_len; 127 unsigned char *data; 128 } ipmi_msg_t; 129 130 #else 131 132 /* Generate a type for the kernel version of this. */ 133 typedef struct ipmi_msg ipmi_msg_t; 134 135 #endif 136 137 /* A structure used to hold messages that can be put into a linked 138 list. */ 139 typedef struct ipmi_msg_item_s 140 { 141 ipmi_addr_t addr; 142 unsigned int addr_len; 143 ipmi_msg_t msg; 144 unsigned char data[IPMI_MAX_MSG_LENGTH]; 145 struct ipmi_msg_item_s *next; 146 void *data1; 147 void *data2; 148 void *data3; 149 void *data4; 150 } ipmi_msgi_t; 151 152 /* Return values for function that take the previous item. */ 153 /* Use this if you are not keeping the message structure for later user. */ 154 #define IPMI_MSG_ITEM_NOT_USED 0 155 /* If you keep the message data in a callback, return this so the caller 156 knows to not free the data itself. You must free it later. */ 157 #define IPMI_MSG_ITEM_USED 1 158 159 /* Pay no attention to the contents of these structures... */ 160 struct ipmi_domain_id_s 161 { 162 ipmi_domain_t *domain; 163 }; 164 #define IPMI_DOMAIN_ID_INVALID { NULL } 165 166 struct ipmi_entity_id_s 167 { 168 ipmi_domain_id_t domain_id; 169 unsigned int entity_id : 8; 170 unsigned int entity_instance : 8; 171 unsigned int channel : 4; 172 unsigned int address : 8; 173 long seq; 174 }; 175 #define IPMI_ENTITY_ID_INVALID { IPMI_DOMAIN_ID_INVALID, 0, 0, 0, 0, 0 } 176 177 /* This structure is kind of a cheap hack. It's internal and 178 definately *NOT* for use by the user. It can represent two 179 different types of addresses. An IPMI will have a normal channel 180 number (usually 0 or 1) and the IPMB address will be in "mc_num". 181 A direct connection to a system interface (KCS, LAN, etc.) is 182 represented as IPMI_BMC_CHANNEL in the channel number and the 183 interface number in mc_num. Multiple interface numbers are used 184 because you can have more than one connection to a domain; the 185 first connection will be mc_num 0, the second will be mc_num 1, 186 etc. */ 187 typedef struct ipmi_mcid_s 188 { 189 ipmi_domain_id_t domain_id; 190 unsigned char mc_num; 191 unsigned char channel; 192 long seq; 193 } ipmi_mcid_t; 194 #define IPMI_MCID_INVALID { IPMI_DOMAIN_ID_INVALID, 0, 0, 0 } 195 196 typedef struct ipmi_mc_s ipmi_mc_t; 197 198 struct ipmi_sensor_id_s 199 { 200 ipmi_mcid_t mcid; 201 unsigned int lun : 3; 202 unsigned int sensor_num : 8; 203 }; 204 #define IPMI_SENSOR_ID_INVALID { IPMI_MCID_INVALID, 0, 0 } 205 206 struct ipmi_control_id_s 207 { 208 ipmi_mcid_t mcid; 209 unsigned int lun : 3; 210 unsigned int control_num : 8; 211 }; 212 #define IPMI_CONTROL_ID_INVALID { IPMI_MCID_INVALID, 0, 0 } 213 214 /* The event structure is no longer public. */ 215 typedef struct ipmi_event_s ipmi_event_t; 216 217 /* This represents a low-level connection. */ 218 typedef struct ipmi_con_s ipmi_con_t; 219 220 /* 221 * Channel information for a connection. 222 */ 223 typedef struct ipmi_chan_info_s 224 { 225 unsigned int medium : 7; 226 unsigned int xmit_support : 1; 227 unsigned int recv_lun : 3; 228 unsigned int protocol : 5; 229 unsigned int session_support : 2; 230 unsigned int vendor_id : 24; 231 unsigned int aux_info : 16; 232 } ipmi_chan_info_t; 233 234 #define MAX_IPMI_USED_CHANNELS 14 235 236 #ifdef __cplusplus 237 } 238 #endif 239 240 #endif /* OPENIPMI_TYPES_H */ 241