1 /* $NetBSD: ipmi.h,v 1.2 2024/12/04 15:25:30 riastradh Exp $ */ 2 3 /*- 4 * Copyright (c) 2019 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Michael van Elst 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _SYS_IPMI_H_ 33 #define _SYS_IPMI_H_ 34 35 #include <sys/ioccom.h> 36 37 #define IPMI_MAX_ADDR_SIZE 0x20 38 #define IPMI_MAX_RX 1024 39 #define IPMI_BMC_SLAVE_ADDR 0x20 40 #define IPMI_BMC_CHANNEL 0x0f 41 #define IPMI_BMC_SMS_LUN 0x02 42 43 #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c 44 #define IPMI_IPMB_ADDR_TYPE 0x01 45 #define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41 46 47 struct ipmi_msg { 48 unsigned char netfn; 49 unsigned char cmd; 50 unsigned short data_len; 51 unsigned char *data; 52 }; 53 54 struct ipmi_req { 55 unsigned char *addr; 56 unsigned int addr_len; 57 long msgid; 58 struct ipmi_msg msg; 59 }; 60 61 struct ipmi_recv { 62 int recv_type; 63 #define IPMI_RESPONSE_RECV_TYPE 1 64 #define IPMI_ASYNC_EVENT_RECV_TYPE 2 65 #define IPMI_CMD_RECV_TYPE 3 66 unsigned char *addr; 67 unsigned int addr_len; 68 long msgid; 69 struct ipmi_msg msg; 70 }; 71 72 struct ipmi_cmdspec { 73 unsigned char netfn; 74 unsigned char cmd; 75 }; 76 77 struct ipmi_addr { 78 int addr_type; 79 short channel; 80 unsigned char data[IPMI_MAX_ADDR_SIZE]; 81 }; 82 83 struct ipmi_system_interface_addr { 84 int addr_type; 85 short channel; 86 unsigned char lun; 87 }; 88 89 struct ipmi_ipmb_addr { 90 int addr_type; 91 short channel; 92 unsigned char slave_addr; 93 unsigned char lun; 94 }; 95 96 #define IPMICTL_RECEIVE_MSG_TRUNC _IOWR('i', 11, struct ipmi_recv) 97 #define IPMICTL_RECEIVE_MSG _IOWR('i', 12, struct ipmi_recv) 98 #define IPMICTL_SEND_COMMAND _IOW('i', 13, struct ipmi_req) 99 #define IPMICTL_REGISTER_FOR_CMD _IOW('i', 14, struct ipmi_cmdspec) 100 #define IPMICTL_UNREGISTER_FOR_CMD _IOW('i', 15, struct ipmi_cmdspec) 101 #define IPMICTL_SET_GETS_EVENTS_CMD _IOW('i', 16, int) 102 #define IPMICTL_SET_MY_ADDRESS_CMD _IOW('i', 17, unsigned int) 103 #define IPMICTL_GET_MY_ADDRESS_CMD _IOR('i', 18, unsigned int) 104 #define IPMICTL_SET_MY_LUN_CMD _IOW('i', 19, unsigned int) 105 #define IPMICTL_GET_MY_LUN_CMD _IOR('i', 20, unsigned int) 106 107 #endif /* !_SYS_IPMI_H_ */ 108