ipmi.c revision e1c99a74dc27ba07cba2cd8181f462ea9a5b0dba
/*
* Copyright (c) 2006 IronPort Systems Inc. <ambrisko@ironport.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright 2012, Joyent, Inc. All rights reserved.
* Copyright 2013, Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/smbios_impl.h>
#include "ipmivars.h"
static kcondvar_t slplock;
/*
* Request management.
*/
/* Allocate a new request with request and reply buffers. */
struct ipmi_request *
{
struct ipmi_request *req;
KM_SLEEP);
if (requestlen) {
}
if (replylen) {
}
return (req);
}
/* Free a request no longer in use. */
void
{
}
/* Store a processed request on the appropriate completion queue. */
/*ARGSUSED*/
void
{
struct ipmi_device *dev;
/*
* Anonymous requests (from inside the driver) always have a
* waiter that we awaken.
*/
} else {
}
}
/*
* Enqueue an internal driver request and wait until it is completed.
*/
static int
int timo)
{
int error;
if (error == 0) {
/* Wait for result - see ipmi_complete_request */
if (timo == 0)
else
ddi_get_lbolt() + timo);
if (error == -1)
error = EWOULDBLOCK;
else
}
return (error);
}
/*
* Helper routine for polled system interfaces that use
* ipmi_polled_enqueue_request() to queue requests. This request
* waits until there is a pending request and then returns the first
* request. If the driver is shutting down, it returns NULL.
*/
struct ipmi_request *
{
struct ipmi_request *req;
if (sc->ipmi_detaching)
return (NULL);
return (req);
}
int
{
return (0);
}
void
{
}
{
struct ipmi_request *req;
int error, i;
/* Initialize interface-independent state. */
/* Initialize interface-dependent state. */
if (error) {
return (B_FALSE);
}
/* Send a GET_DEVICE_ID request. */
IPMI_GET_DEVICE_ID, 0, 15);
if (error == EWOULDBLOCK) {
return (B_FALSE);
} else if (error) {
return (B_FALSE);
} else if (req->ir_compcode != 0) {
"Bad completion code for GET_DEVICE_ID: %d",
req->ir_compcode);
return (B_FALSE);
req->ir_replylen);
return (B_FALSE);
}
"version %d.%d",
IPMI_CLEAR_FLAGS, 1, 0);
return (B_FALSE);
}
/* Magic numbers */
}
}
for (i = 0; i < 8; i++) {
IPMI_GET_CHANNEL_INFO, 1, 0);
break;
}
if (req->ir_compcode != 0) {
break;
}
}
/* probe for watchdog */
IPMI_GET_WDOG, 0, 0);
return (B_FALSE);
}
/*
* Here is where we could register a watchdog event handler.
* See ipmi_wd_event() in the FreeBSD code.
*/
}
return (B_TRUE);
}