tsalarm.c revision d15360a7f1d6c844288e4ec4c82be4ed51792be2
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
struct tsalarm_softc {
};
/*
* Driver entry points
*/
/* dev_ops and cb_ops entry point function declarations */
static struct cb_ops tsalarm_cb_ops = {
tsalarm_open, /* open */
tsalarm_close, /* close */
nodev, /* strategy() */
nodev, /* print() */
nodev, /* dump() */
nodev, /* read() */
nodev, /* write() */
tsalarm_ioctl, /* ioctl() */
nodev, /* devmap() */
nodev, /* mmap() */
ddi_segmap, /* segmap() */
nochpoll, /* poll() */
ddi_prop_op, /* prop_op() */
NULL, /* cb_str */
};
static struct dev_ops tsalarm_ops = {
0, /* ref count */
tsalarm_getinfo, /* getinfo() */
nulldev, /* identify() */
nulldev, /* probe() */
tsalarm_attach, /* attach() */
tsalarm_detach, /* detach */
nodev, /* reset */
&tsalarm_cb_ops, /* pointer to cb_ops structure */
nulldev /* power() */
};
/*
* Loadable module support.
*/
extern struct mod_ops mod_driverops;
static void *statep;
&mod_driverops, /* Type of module. This is a driver */
"tsalarm control driver v%I%", /* Name of the module */
&tsalarm_ops /* pointer to the dev_ops structure */
};
static struct modlinkage modlinkage = {
&modldrv,
};
int
_init(void)
{
int e;
if (e = ddi_soft_state_init(&statep,
sizeof (struct tsalarm_softc), 1)) {
return (e);
}
if ((e = mod_install(&modlinkage)) != 0) {
}
return (e);
}
int
_fini(void)
{
int e;
if ((e = mod_remove(&modlinkage)) != 0) {
return (e);
}
return (DDI_SUCCESS);
}
int
{
}
/* ARGSUSED */
static int
{
int retval = DDI_SUCCESS;
struct tsalarm_softc *softc;
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
} else {
}
break;
case DDI_INFO_DEVT2INSTANCE:
break;
default:
}
return (retval);
}
static int
{
int inst;
switch (cmd) {
case DDI_ATTACH:
/*
* Allocate a soft state structure for this instance.
*/
goto attach_failed;
/*
* Create minor node. The minor device number, inst, has no
* meaning. The model number above, which will be added to
* the device's softc, is used to direct peculiar behavior.
*/
goto attach_failed;
return (DDI_SUCCESS);
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
/* Free soft state, if allocated. remove minor node if added earlier */
if (softc) {
}
return (DDI_FAILURE);
}
static int
{
int inst;
struct tsalarm_softc *softc;
switch (cmd) {
case DDI_DETACH:
return (DDI_FAILURE);
/*
* Free the soft state and remove minor node added earlier.
*/
return (DDI_SUCCESS);
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/* ARGSUSED */
static int
{
}
/* ARGSUSED */
static int
{
}
/* ARGSUSED */
static int
{
struct tsalarm_softc *softc;
int retval = 0;
int alarm_type, alarm_state = 0;
return (ENXIO);
switch (cmd) {
case LOMIOCALSTATE:
case LOMIOCALSTATE_OLD:
{
sizeof (ts_aldata_t), mode) != 0) {
goto end;
}
if ((alarm_type < ALARM_CRITICAL) ||
(alarm_type > ALARM_USER)) {
goto end;
}
if (retval != 0)
goto end;
goto end;
}
sizeof (ts_aldata_t), mode) != 0) {
goto end;
}
}
break;
case LOMIOCALCTL:
case LOMIOCALCTL_OLD:
{
sizeof (ts_aldata_t), mode) != 0) {
goto end;
}
if ((alarm_type < ALARM_CRITICAL) ||
(alarm_type > ALARM_USER)) {
goto end;
}
if ((alarm_state < ALARM_OFF) ||
(alarm_state > ALARM_ON)) {
goto end;
}
}
break;
default:
break;
}
end:
return (retval);
}