/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
*/
/*
* The ipmi driver is an openipmi compatible IPMI driver based on the FreeBSD
* driver.
*
* The current implementation has several limitations:
* 1) It only does discovery through the SMBIOS. The FreeBSD driver has
* several additional ways to discover the IPMI device (acpi, bus checking,
* etc.). This support could be ported if necessary.
* 2) The driver currently only supports the IPMI KCS_MODE mode (reported
* through the SMBIOS as SMBIOS SMB_IPMI_T_KCS). Support for the other modes
* (BT_MODE, SMIC_MODE, SSIF_MODE) could be ported if necessary.
* 3) The driver does not currently set up an IPMI watchdog. This also could
* be ported if necessary.
*/
#include <sys/smbios_impl.h>
#include "ipmivars.h"
/*
* Use the SMBIOS info to determine if the system has an IPMI.
*/
static int
get_smbios_ipmi_info(void)
{
return (DDI_FAILURE);
(long long unsigned int)(ipmi.smbip_addr));
/*
* Some systems have a bios that will report an IPMI device even when
* it is not installed. In this case we see 0x0 as the base address.
* If we see this address, assume the device is not really present.
*/
return (DDI_FAILURE);
}
switch (ipmi.smbip_type) {
case SMB_IPMI_T_KCS:
case SMB_IPMI_T_SMIC:
1 : 0;
break;
case SMB_IPMI_T_SSIF:
"using BMC I2C slave address instead");
} else {
}
break;
default:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static ipmi_device_t *
{
ipmi_device_t *p;
return (p);
}
}
return (NULL);
}
/*
* Each open returns a new pseudo device.
*/
/*ARGSUSED*/
static int
{
if (ipmi_attached == B_FALSE)
return (ENXIO);
if (ipmi_found == B_FALSE)
return (ENODEV);
/* exclusive opens are not supported */
return (ENOTSUP);
return (ENODEV);
/* Initialize the per file descriptor data. */
return (0);
}
/*ARGSUSED*/
static int
{
return (ENODEV);
/* remove any pending requests */
}
}
/* remove any requests in queue of stuff completed */
}
return (0);
}
/*ARGSUSED*/
static int
{
int orig_cmd = 0;
return (EPERM);
return (ENODEV);
model = get_udatamodel();
if (model == DATAMODEL_NATIVE) {
switch (cmd) {
case IPMICTL_SEND_COMMAND:
return (EFAULT);
break;
case IPMICTL_RECEIVE_MSG:
return (EFAULT);
break;
}
} else {
/* Convert 32-bit structures to native. */
switch (cmd) {
case IPMICTL_SEND_COMMAND_32:
return (EFAULT);
break;
case IPMICTL_RECEIVE_MSG_32:
return (EFAULT);
break;
}
}
switch (cmd) {
case IPMICTL_SEND_COMMAND:
/* Check that we didn't get a ridiculous length */
return (EINVAL);
/* This struct is the same for 32/64 */
return (EFAULT);
}
dev->ipmi_requests++;
if (error)
return (error);
break;
case IPMICTL_RECEIVE_MSG:
/* This struct is the same for 32/64 */
return (EFAULT);
return (EAGAIN);
}
if (error) {
ir_link);
dev->ipmi_requests--;
return (error);
}
return (EMSGSIZE);
}
dev->ipmi_requests--;
if (orig_cmd == IPMICTL_RECEIVE_MSG_TRUNC_32 ||
/* Update changed fields in 32-bit structure. */
} else {
}
/* This struct is the same for 32/64 */
if (error == 0)
if (error == 0)
if (error == 0)
len - 1);
if (error)
return (EFAULT);
break;
sizeof (dev->ipmi_address))) {
return (EFAULT);
}
break;
sizeof (dev->ipmi_address))) {
return (EFAULT);
}
break;
case IPMICTL_SET_MY_LUN_CMD:
return (EFAULT);
}
break;
case IPMICTL_GET_MY_LUN_CMD:
return (EFAULT);
}
break;
break;
case IPMICTL_REGISTER_FOR_CMD:
return (EINVAL);
default:
return (EINVAL);
}
return (0);
}
static int
pollhead_t **phpp)
{
short revent = 0;
return (ENODEV);
if (dev->ipmi_requests == 0)
}
if (revent == 0) {
/* nothing has occurred */
if (!anyyet)
}
return (0);
}
/*ARGSUSED*/
static int
{
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
return (DDI_SUCCESS);
case DDI_INFO_DEVT2INSTANCE:
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
static void
{
/* poke the taskq so that it can terminate */
sc->ipmi_detaching = 0;
}
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
/* this driver only supports one device instance */
if (ddi_get_instance(dip) != 0) {
"!not attaching to non-zero device instance %d",
return (DDI_FAILURE);
}
if (get_smbios_ipmi_info() == DDI_FAILURE)
return (DDI_FAILURE);
/*
* Support for the other types (SMIC, SSIF) should be added here.
*/
switch (sc->ipmi_io_type) {
case SMB_IPMI_T_KCS:
if (ipmi_kcs_attach(sc) != 0)
return (DDI_FAILURE);
break;
default:
return (DDI_FAILURE);
}
ipmi_found = B_TRUE;
0) == DDI_FAILURE) {
return (DDI_FAILURE);
}
/* Create ID space for open devs. ID 0 is reserved. */
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
if (cmd != DDI_DETACH)
return (DDI_FAILURE);
if (ipmi_found == B_FALSE)
return (DDI_SUCCESS);
if (!list_is_empty(&dev_list)) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
NULL, /* streamtab */
nodev, /* awread */
nodev /* awrite */
};
0, /* reference count */
nulldev, /* identify */
nulldev, /* probe */
nodev, /* reset */
NULL, /* bus ops */
NULL, /* power */
};
};
};
int
_init(void)
{
return (mod_install(&ml));
}
int
_fini(void)
{
return (mod_remove(&ml));
}
int
{
}