1 /* 2 * Copyright (c) 2006 IronPort Systems Inc. <ambrisko@ironport.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: src/sys/sys/ipmi.h,v 1.2 2006/09/22 22:11:29 jhb Exp $ 27 */ 28 29 /* 30 * Copyright 2012 Joyent, Inc. All rights reserved. 31 */ 32 33 #ifndef _SYS_IPMI_H_ 34 #define _SYS_IPMI_H_ 35 36 #include <sys/types.h> 37 #include <sys/ioccom.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 #define IPMI_MAX_ADDR_SIZE 0x20 44 #define IPMI_MAX_RX 1024 45 #define IPMI_BMC_SLAVE_ADDR 0x20 /* Default slave address */ 46 #define IPMI_BMC_CHANNEL 0x0f /* BMC channel */ 47 48 #define IPMI_BMC_SMS_LUN 0x02 49 50 #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c 51 #define IPMI_IPMB_ADDR_TYPE 0x01 52 #define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41 53 54 #define IPMI_IOC_MAGIC 'i' 55 #define IPMICTL_RECEIVE_MSG_TRUNC \ 56 _IOWR(IPMI_IOC_MAGIC, 11, struct ipmi_recv) 57 #define IPMICTL_RECEIVE_MSG \ 58 _IOWR(IPMI_IOC_MAGIC, 12, struct ipmi_recv) 59 #define IPMICTL_SEND_COMMAND \ 60 _IOW(IPMI_IOC_MAGIC, 13, struct ipmi_req) 61 #define IPMICTL_REGISTER_FOR_CMD \ 62 _IOW(IPMI_IOC_MAGIC, 14, struct ipmi_cmdspec) 63 #define IPMICTL_UNREGISTER_FOR_CMD \ 64 _IOW(IPMI_IOC_MAGIC, 15, struct ipmi_cmdspec) 65 #define IPMICTL_SET_GETS_EVENTS_CMD _IOW(IPMI_IOC_MAGIC, 16, int) 66 #define IPMICTL_SET_MY_ADDRESS_CMD _IOW(IPMI_IOC_MAGIC, 17, unsigned int) 67 #define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int) 68 #define IPMICTL_SET_MY_LUN_CMD _IOW(IPMI_IOC_MAGIC, 19, unsigned int) 69 #define IPMICTL_GET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 20, unsigned int) 70 71 #define IPMI_RESPONSE_RECV_TYPE 1 72 #define IPMI_ASYNC_EVENT_RECV_TYPE 2 73 #define IPMI_CMD_RECV_TYPE 3 74 75 #define IPMI_APP_REQUEST 0x06 76 #define IPMI_GET_DEVICE_ID 0x01 77 #define IPMI_CLEAR_FLAGS 0x30 78 #define IPMI_GET_MSG_FLAGS 0x31 79 #define IPMI_MSG_AVAILABLE 0x01 80 #define IPMI_MSG_BUFFER_FULL 0x02 81 #define IPMI_WDT_PRE_TIMEOUT 0x08 82 #define IPMI_GET_MSG 0x33 83 #define IPMI_SEND_MSG 0x34 84 #define IPMI_GET_CHANNEL_INFO 0x42 85 #define IPMI_RESET_WDOG 0x22 86 #define IPMI_SET_WDOG 0x24 87 #define IPMI_GET_WDOG 0x25 88 89 #define IPMI_SET_WD_TIMER_SMS_OS 0x04 90 #define IPMI_SET_WD_TIMER_DONT_STOP 0x40 91 #define IPMI_SET_WD_ACTION_RESET 0x01 92 93 struct ipmi_msg { 94 unsigned char netfn; 95 unsigned char cmd; 96 unsigned short data_len; 97 unsigned char *data; 98 }; 99 100 struct ipmi_req { 101 unsigned char *addr; 102 unsigned int addr_len; 103 long msgid; 104 struct ipmi_msg msg; 105 }; 106 107 struct ipmi_recv { 108 int recv_type; 109 unsigned char *addr; 110 unsigned int addr_len; 111 long msgid; 112 struct ipmi_msg msg; 113 }; 114 115 struct ipmi_cmdspec { 116 unsigned char netfn; 117 unsigned char cmd; 118 }; 119 120 struct ipmi_addr { 121 int addr_type; 122 short channel; 123 unsigned char data[IPMI_MAX_ADDR_SIZE]; 124 }; 125 126 struct ipmi_system_interface_addr { 127 int addr_type; 128 short channel; 129 unsigned char lun; 130 }; 131 132 struct ipmi_ipmb_addr { 133 int addr_type; 134 short channel; 135 unsigned char slave_addr; 136 unsigned char lun; 137 }; 138 139 #ifdef _KERNEL 140 141 #define IPMICTL_RECEIVE_MSG_TRUNC_32 \ 142 _IOWR(IPMI_IOC_MAGIC, 11, struct ipmi_recv32) 143 #define IPMICTL_RECEIVE_MSG_32 \ 144 _IOWR(IPMI_IOC_MAGIC, 12, struct ipmi_recv32) 145 #define IPMICTL_SEND_COMMAND_32 \ 146 _IOW(IPMI_IOC_MAGIC, 13, struct ipmi_req32) 147 148 struct ipmi_msg32 { 149 unsigned char netfn; 150 unsigned char cmd; 151 unsigned short data_len; 152 uint32_t data; 153 }; 154 155 struct ipmi_req32 { 156 uint32_t addr; 157 unsigned int addr_len; 158 int32_t msgid; 159 struct ipmi_msg32 msg; 160 }; 161 162 struct ipmi_recv32 { 163 int recv_type; 164 uint32_t addr; 165 unsigned int addr_len; 166 int32_t msgid; 167 struct ipmi_msg32 msg; 168 }; 169 170 #endif /* _KERNEL */ 171 172 #ifdef __cplusplus 173 } 174 #endif 175 176 #endif /* _SYS_IPMI_H_ */ 177