2
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
8
* Redistribution of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
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.
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.
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.
32
* You acknowledge that this software is not designed or intended for use
33
* in the design, construction, operation or maintenance of any nuclear
40
#include <sys/ioctl.h>
44
#include <sys/types.h>
45
#include <sys/stropts.h>
47
#include <ipmitool/ipmi.h>
48
#include <ipmitool/ipmi_intf.h>
50
#include <sys/lipmi/lipmi_intf.h>
52
#define IPMI_LIPMI_DEV "/dev/lipmi"
56
static int ipmi_lipmi_open(struct ipmi_intf * intf)
58
intf->fd = open(IPMI_LIPMI_DEV, O_RDWR);
60
perror("Could not open lipmi device");
67
static void ipmi_lipmi_close(struct ipmi_intf * intf)
69
if (intf && intf->fd >= 0)
75
static struct ipmi_rs * ipmi_lipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
78
static struct lipmi_reqrsp reqrsp;
79
static struct ipmi_rs rsp;
80
static int curr_seq = 0;
85
if (!intf->opened && intf->open && intf->open(intf) < 0)
88
memset(&reqrsp, 0, sizeof(reqrsp));
89
reqrsp.req.fn = req->msg.netfn;
91
reqrsp.req.cmd = req->msg.cmd;
92
reqrsp.req.datalength = req->msg.data_len;
93
memcpy(reqrsp.req.data, req->msg.data, req->msg.data_len);
94
reqrsp.rsp.datalength = RECV_MAX_PAYLOAD_SIZE;
96
istr.ic_cmd = IOCTL_IPMI_KCS_ACTION;
98
istr.ic_dp = (char *)&reqrsp;
99
istr.ic_len = sizeof(struct lipmi_reqrsp);
102
printf("LIPMI req.fn : %x\n", reqrsp.req.fn);
103
printf("LIPMI req.lun : %x\n", reqrsp.req.lun);
104
printf("LIPMI req.cmd : %x\n", reqrsp.req.cmd);
105
printf("LIPMI req.datalength : %d\n", reqrsp.req.datalength);
108
if (ioctl(intf->fd, I_STR, &istr) < 0) {
109
perror("LIPMI IOCTL: I_STR");
113
memset(&rsp, 0, sizeof(struct ipmi_rs));
114
rsp.ccode = reqrsp.rsp.ccode;
115
rsp.data_len = reqrsp.rsp.datalength;
117
if (!rsp.ccode && rsp.data_len)
118
memcpy(rsp.data, reqrsp.rsp.data, rsp.data_len);
123
struct ipmi_intf ipmi_lipmi_intf = {
125
desc: "Solaris x86 LIPMI Interface",
126
open: ipmi_lipmi_open,
127
close: ipmi_lipmi_close,
128
sendrecv: ipmi_lipmi_send_cmd,
129
target_addr: IPMI_BMC_SLAVE_ADDR,