xcalwd.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2001-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Excalibur fans watchdog module
*/
#include <sys/platform_module.h>
extern struct mod_ops mod_driverops;
#define MINOR_DEVICE_NAME "xcalwd"
/*
* Define your per instance state data
*/
typedef struct xcalwd_state {
int intvl;
/*
* Pointer to soft states
*/
static void *xcalwd_statep;
/*
* dev_ops
*/
/*
* cb_ops
*/
/*
* timeout handler
*/
static void xcalwd_timeout(void *arg);
/*
* cb_ops
*/
static struct cb_ops xcalwd_cb_ops = {
xcalwd_open, /* open */
xcalwd_close, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
xcalwd_ioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* chpoll */
ddi_prop_op, /* prop_op */
NULL, /* streamtab */
CB_REV, /* rev */
nodev, /* int (*cb_aread)() */
nodev /* int (*cb_awrite)() */
};
/*
* dev_ops
*/
static struct dev_ops xcalwd_dev_ops = {
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
xcalwd_getinfo, /* getinfo */
nulldev, /* identify */
nulldev, /* probe */
xcalwd_attach, /* attach */
xcalwd_detach, /* detach */
nodev, /* devo_reset */
&xcalwd_cb_ops, /* devo_cb_ops */
NULL, /* devo_bus_ops */
NULL /* power */
};
/*
* modldrv
*/
static struct modldrv xcalwd_modldrv = {
&mod_driverops, /* drv_modops */
"Excalibur watchdog timer v%I% ", /* drv_linkinfo */
&xcalwd_dev_ops /* drv_dev_ops */
};
/*
* modlinkage
*/
static struct modlinkage xcalwd_modlinkage = {
};
int
_init(void)
{
int error;
/*
* Initialize the module state structure
*/
sizeof (xcalwd_state_t), 0);
if (error) {
return (error);
}
/*
* Link the driver into the system
*/
if (error) {
return (error);
}
return (0);
}
int
_fini(void)
{
int error;
if (error != 0) {
return (error);
}
/*
* Cleanup resources allocated in _init
*/
return (0);
}
int
{
}
/*ARGSUSED*/
static int
{
int retval;
int instance;
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
else {
}
break;
case DDI_INFO_DEVT2INSTANCE:
break;
default:
break;
}
return (retval);
}
static int
{
int instance;
switch (cmd) {
case DDI_ATTACH:
if (&plat_fan_blast == NULL) {
return (DDI_FAILURE);
}
DDI_SUCCESS) {
"%d state structure", instance);
return (DDI_FAILURE);
}
instance);
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
case DDI_RESUME:
return (DDI_SUCCESS);
default:
break;
}
return (DDI_FAILURE);
}
static int
{
int instance;
switch (cmd) {
case DDI_DETACH:
return (DDI_SUCCESS);
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
break;
}
return (DDI_FAILURE);
}
/*
* Watchdog timeout handler that calls plat_fan_blast to take
* the failsafe action.
*/
static void
xcalwd_timeout(void *arg)
{
if (instance < 0)
return;
return;
return;
}
}
/*ARGSUSED*/
static int
{
int instance;
return (EPERM);
return (EINVAL);
if (instance < 0)
return (ENXIO);
return (ENXIO);
}
return (0);
}
/*ARGSUSED*/
static int
{
int instance;
if (instance < 0)
return (ENXIO);
return (ENXIO);
return (0);
}
/*
* The watchdog is enabled. Cancel the pending timer
* and call plat_fan_blast.
*/
if (tid != 0)
return (0);
}
/*
* These are private ioctls for PICL environmental control plug-in
* to use. The plug-in enables the watchdog before performing
* altering fan speeds. It also periodically issues a keepalive
* to the watchdog to cancel and reinstate the watchdog timer.
* The watchdog timeout handler when executed with the watchdog
* enabled sets fans to full blast by calling plat_fan_blast.
*/
/*ARGSUSED*/
static int
{
int instance;
int intvl;
int o_intvl;
return (EPERM);
if (instance < 0)
return (ENXIO);
return (ENXIO);
switch (cmd) {
case XCALWD_STOPWATCHDOG:
/*
* cancels any pending timer and disables the timer.
*/
tid = 0;
return (0);
}
if (tid != 0)
return (0);
case XCALWD_STARTWATCHDOG:
return (EFAULT);
if (intvl == 0)
return (EINVAL);
return (EFAULT);
return (EINVAL);
}
(void *)instance,
return (0);
case XCALWD_KEEPALIVE:
tid = 0;
if (tid != 0)
(void *)instance,
return (0);
case XCALWD_GETSTATE:
return (EFAULT);
return (0);
default:
return (EINVAL);
}
/*NOTREACHED*/
}