1/*	$NetBSD: ipmi.h,v 1.1 2019/05/18 08:38:00 mlelstv 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#define	IPMI_MAX_ADDR_SIZE		0x20
 36#define IPMI_MAX_RX			1024
 37#define	IPMI_BMC_SLAVE_ADDR		0x20
 38#define	IPMI_BMC_CHANNEL		0x0f
 39#define	IPMI_BMC_SMS_LUN		0x02
 40
 41#define IPMI_SYSTEM_INTERFACE_ADDR_TYPE	0x0c
 42#define IPMI_IPMB_ADDR_TYPE		0x01
 43#define IPMI_IPMB_BROADCAST_ADDR_TYPE	0x41
 44
 45struct ipmi_msg {
 46	unsigned char	netfn;
 47	unsigned char	cmd;
 48	unsigned short	data_len;
 49	unsigned char	*data;
 50};
 51
 52struct ipmi_req {
 53	unsigned char	*addr;
 54	unsigned int	addr_len;
 55	long		msgid;
 56	struct ipmi_msg msg;
 57};
 58
 59struct ipmi_recv {
 60	int		recv_type;
 61#define IPMI_RESPONSE_RECV_TYPE		1
 62#define IPMI_ASYNC_EVENT_RECV_TYPE	2
 63#define IPMI_CMD_RECV_TYPE		3
 64	unsigned char	*addr;
 65	unsigned int	addr_len;
 66	long		msgid;
 67	struct ipmi_msg msg;
 68};
 69
 70struct ipmi_cmdspec {
 71	unsigned char	netfn;
 72	unsigned char	cmd;
 73};
 74
 75struct ipmi_addr {
 76	int		addr_type;
 77	short		channel;
 78	unsigned char	data[IPMI_MAX_ADDR_SIZE];
 79};
 80
 81struct ipmi_system_interface_addr {
 82	int		addr_type;
 83	short		channel;
 84	unsigned char	lun;
 85};
 86
 87struct ipmi_ipmb_addr {
 88	int		addr_type;
 89	short		channel;
 90	unsigned char	slave_addr;
 91	unsigned char	lun;
 92};
 93
 94#define IPMICTL_RECEIVE_MSG_TRUNC       _IOWR('i', 11, struct ipmi_recv)
 95#define IPMICTL_RECEIVE_MSG             _IOWR('i', 12, struct ipmi_recv)
 96#define IPMICTL_SEND_COMMAND            _IOW('i', 13, struct ipmi_req)
 97#define IPMICTL_REGISTER_FOR_CMD        _IOW('i', 14, struct ipmi_cmdspec)
 98#define IPMICTL_UNREGISTER_FOR_CMD      _IOW('i', 15, struct ipmi_cmdspec)
 99#define IPMICTL_SET_GETS_EVENTS_CMD     _IOW('i', 16, int)
100#define IPMICTL_SET_MY_ADDRESS_CMD      _IOW('i', 17, unsigned int)
101#define IPMICTL_GET_MY_ADDRESS_CMD      _IOR('i', 18, unsigned int)
102#define IPMICTL_SET_MY_LUN_CMD          _IOW('i', 19, unsigned int) 
103#define IPMICTL_GET_MY_LUN_CMD          _IOR('i', 20, unsigned int)
104
105#endif /* !_SYS_IPMI_H_ */