vuidmice.c revision 664d603cda9e909161e63d9ac5ff4724dd2a4852
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* VUIDMICE module: put mouse events into vuid format
*/
#include <sys/vuid_event.h>
#include <sys/vuidmice.h>
#include <sys/vuid_wheel.h>
const int, const int, const cred_t *const);
static int vuidmice_rsrv(queue_t *const);
static int vuidmice_handle_wheel_resolution_ioctl(queue_t *const,
mblk_t *, int);
static int vuidmice_service_wheel_info(mblk_t *);
void VUID_CLOSE(queue_t *const);
static kmutex_t vuidmice_lock;
static struct module_info vuidmice_iinfo = {
0,
0,
1000,
100
};
static struct qinit vuidmice_rinit = {
NULL,
};
static struct module_info vuidmice_oinfo = {
0,
0,
1000,
100
};
static struct qinit vuidmice_winit = {
NULL,
NULL,
NULL,
NULL,
};
struct streamtab vuidmice_info = {
NULL,
};
/*
* This is the loadable module wrapper.
*/
/*
* D_MTQPAIR effectively makes the module single threaded.
* There can be only one thread active in the module at any time.
* It may be a read or write thread.
*/
};
static struct modlstrmod modlstrmod = {
"mouse events to vuid events",
&fsw
};
/*
* Module linkage information for the kernel.
*/
static struct modlinkage modlinkage = {
};
static int module_open = 0; /* allow only one open of this module */
int
_init(void)
{
register int rc;
}
return (rc);
}
int
_fini(void)
{
register int rc;
return (rc);
}
int
{
}
/* ARGSUSED1 */
static int
{
return (0); /* reopen */
/* Allow only 1 open of this module */
if (module_open) {
return (EBUSY);
}
module_open++;
/*
* Both the read and write queues share the same state structures.
*/
/* initialize state */
#ifdef VUID_OPEN
module_open--;
return (ENXIO);
}
#endif
return (0);
}
/* ARGSUSED1 */
static int
{
#ifdef VUID_CLOSE
VUID_CLOSE(qp);
#endif
module_open--;
return (0);
}
/*
* Put procedure for input from driver end of stream (read queue).
*/
static int
{
/*
* Handle all the related high priority messages here, hence
* should spend the least amount of time here.
*/
}
return (0);
}
static int
{
if (!canputnext(qp))
case M_DATA:
else
break;
default:
"vuidmice_rsrv: bad message type (0x%x)\n",
break;
}
}
return (0);
}
/*
* Put procedure for write from user end of stream (write queue).
*/
static int
{
int error = 0;
/*
* Handle all the related high priority messages here, hence
* should spend the least amount of time here.
*/
case M_FLUSH:
return (0);
case M_IOCTL: {
case VUIDSFORMAT:
/*
* VUIDSFORMAT is known to the stream head and thus
* is guaranteed to be an I_STR ioctl.
*/
return (0);
} else {
int format_type;
if (error != 0) {
return (0);
}
}
/* return buffer to pool ASAP */
}
return (0);
case VUIDGFORMAT:
/* return buffer to pool ASAP */
}
/*
* VUIDGFORMAT is known to the stream head and thus
* is guaranteed to be an I_STR ioctl.
*/
return (0);
}
return (0);
}
return (0);
case VUID_NATIVE:
case VUIDSADDR:
case VUIDGADDR:
return (0);
case MSIOBUTTONS:
/* return buffer to pool ASAP */
}
/*
* MSIOBUTTONS is known to streamio.c and this
* is assume to be non-I_STR & non-TRANSPARENT ioctl
*/
return (0);
}
return (0);
}
return (0);
}
return (0);
/*
* New IOCTL support. Since it's explicitly mentioned
* that you can't add more ioctls to stream head's
* hard coded list, we have to do the transparent
* ioctl processing which is not very exciting.
*/
case VUIDGWHEELCOUNT:
case VUIDGWHEELINFO:
case VUIDGWHEELSTATE:
case VUIDSWHEELSTATE:
case MSIOSRESOLUTION:
if (!error) {
return (0);
} else {
return (0);
}
default:
return (0);
}
} /* End of case M_IOCTL */
case M_IOCDATA:
return (0);
default:
return (0);
}
/*NOTREACHED*/
}
void
{
int strikes = 1;
/*
* Give this event 3 chances to allocate blocks,
* otherwise discard this mouse event. 3 Strikes and you're out.
*/
if (++strikes > 3)
return;
drv_usecwait(10);
}
else
}
/*
* vuidmice_miocdata
* M_IOCDATA processing for IOCTL's: VUIDGWHEELCOUNT, VUIDGWHEELINFO,
* VUIDGWHEELSTATE, VUIDSWHEELSTATE & MSIOSRESOLUTION.
*/
static void
{
int err = 0;
goto err;
}
case VUIDGWHEELCOUNT:
}
break;
case VUIDGWHEELINFO:
case VUIDGWHEELSTATE:
break;
}
} else {
}
if (err) {
break;
}
size = sizeof (wheel_state);
} else {
size = sizeof (wheel_info);
}
}
}
break;
case VUIDSWHEELSTATE:
case MSIOSRESOLUTION:
break;
}
}
if (err) {
break;
}
}
break;
default:
break;
}
err:
if (err) {
}
if (copyresp->cp_private) {
}
}
}
/*
* vuidmice_handle_wheel_resolution_ioctl
* Handle wheel mouse and MSIOSRESOLUTION ioctls.
*
* Here we also support non-transparent way of these ioctls
* just like usb mouse driver does, so the consms module is
* very simple to deal with these ioctls.
*/
static int
{
int err = 0;
return (EINVAL);
switch (cmd) {
case VUIDGWHEELCOUNT:
size = sizeof (int);
return (EAGAIN);
return (err);
case VUIDGWHEELINFO:
size = sizeof (wheel_info);
break;
case VUIDSWHEELSTATE:
case VUIDGWHEELSTATE:
size = sizeof (wheel_state);
break;
case MSIOSRESOLUTION:
size = sizeof (Ms_screen_resolution);
break;
}
return (EAGAIN);
return (err);
} else {
switch (cmd) {
case VUIDGWHEELCOUNT:
}
break;
}
break;
case VUIDGWHEELINFO:
break;
}
break;
case VUIDSWHEELSTATE:
case VUIDGWHEELSTATE:
break;
}
break;
case MSIOSRESOLUTION:
/*
* Now we just make Xserver and
* the virtual mouse happy. Of course,
* the screen resolution value may
* be used later for absolute PS/2 mouse.
*/
err = 0;
break;
}
if (!err) {
}
return (err);
}
}
static int
{
wheel_info *wi;
int err = 0;
return (err);
}
return (err);
}
return (err);
}
static int
{
return (err);
}
return (err);
}
switch (cmd) {
case VUIDGWHEELSTATE:
ws->stateflags =
break;
case VUIDSWHEELSTATE:
break;
default:
return (err);
}
return (err);
}