/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2011 Bayard G. Bell. All rights reserved.
*/
/*
* MT STREAMS Virtual Console Redirection Device Driver
*/
/*
* Routine to to register/unregister our queue for console output and pass
* redirected data to the console. The cvc driver will do a putnext using
* our queue, so we will not see the redirected console data.
*/
extern int cvc_register(queue_t *);
extern int cvc_unregister(queue_t *);
static int cvcr_suspend = 0;
1314, /* mi_idnum Bad luck number +1 ;-) */
"cvcredir", /* mi_idname */
0, /* mi_minpsz */
INFPSZ, /* mi_maxpsz */
2048, /* mi_hiwat */
2048 /* mi_lowat */
};
NULL, /* qi_putp */
NULL, /* qi_srvp */
cvcr_open, /* qi_qopen */
cvcr_close, /* qi_qclose */
NULL, /* qi_qadmin */
&minfo, /* qi_minfo */
NULL /* qi_mstat */
};
cvcr_wput, /* qi_putp */
NULL, /* qi_srvp */
cvcr_open, /* qi_qopen */
cvcr_close, /* qi_qclose */
NULL, /* qi_qadmin */
&minfo, /* qi_minfo */
NULL /* qi_mstat */
};
&cvcr_rinit, /* st_rdinit */
&cvcr_winit, /* st_wrinit */
NULL, /* st_muxrinit */
NULL /* st_muxwrinit */
};
&mod_driverops, /* Type of module. This one is a pseudo driver */
"CVC redirect driver 'cvcredir'",
&cvcrops, /* driver ops */
};
&modldrv,
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
int
{
}
static int
{
#ifdef lint
#endif
if (cmd == DDI_RESUME) {
cvcr_suspend = 0;
} else {
return (-1);
}
}
return (DDI_SUCCESS);
}
static int
{
if (cmd == DDI_SUSPEND) {
cvcr_suspend = 1;
} else {
if (cmd != DDI_DETACH) {
return (DDI_FAILURE);
}
}
return (DDI_SUCCESS);
}
/* ARGSUSED */
static int
{
register int error;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
error = DDI_FAILURE;
} else {
error = DDI_SUCCESS;
}
break;
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
error = DDI_SUCCESS;
break;
default:
error = DDI_FAILURE;
}
return (error);
}
/* ARGSUSED */
static int
{
/*
* call into the cvc driver to register our queue. cvc will use
* our queue to send console output data upstream (our stream)to
* cvcd which has us open and is reading console data.
*/
(void *)q);
}
return (0);
}
/* ARGSUSED */
static int
{
/*
* call into the cvc driver to un-register our queue. cvc will
* no longer use our queue to send console output data upstream.
*/
(void) cvc_unregister(RD(q));
return (0);
}
static int
{
/*
* Handle BREAK key for debugger and TIOCSWINSZ.
*/
cvcr_ioctl(q, mp);
return (0);
}
/*
* Call into the cvc driver to put console input data on
* its upstream queue to be picked up by the console driver.
*/
return (0);
}
static void
{
int error;
case CVC_BREAK:
break;
case CVC_DISCONNECT:
case TIOCSWINSZ:
/*
* Generate a SIGHUP or SIGWINCH to the console. Note in this
* case cvc_redir does not free up mp, so we can reuse it for
*/
if (error != 0)
else
break;
default:
break;
}
}