xref: /netbsd-src/sys/dev/sun/msvar.h (revision 3b01aba77a7a698587faaae455bbfe740923c1f5)
1 /*	$NetBSD: msvar.h,v 1.2 2000/09/21 23:40:47 eeh Exp $	*/
2 
3 /*
4  * Copyright (c) 1992, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This software was developed by the Computer Systems Engineering group
8  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9  * contributed to Berkeley.
10  *
11  * All advertising materials mentioning features or use of this software
12  * must display the following acknowledgement:
13  *	This product includes software developed by the University of
14  *	California, Lawrence Berkeley Laboratory.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions
18  * are met:
19  * 1. Redistributions of source code must retain the above copyright
20  *    notice, this list of conditions and the following disclaimer.
21  * 2. Redistributions in binary form must reproduce the above copyright
22  *    notice, this list of conditions and the following disclaimer in the
23  *    documentation and/or other materials provided with the distribution.
24  * 3. All advertising materials mentioning features or use of this software
25  *    must display the following acknowledgement:
26  *	This product includes software developed by the University of
27  *	California, Berkeley and its contributors.
28  * 4. Neither the name of the University nor the names of its contributors
29  *    may be used to endorse or promote products derived from this software
30  *    without specific prior written permission.
31  *
32  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42  * SUCH DAMAGE.
43  *
44  *	@(#)ms.c	8.1 (Berkeley) 6/11/93
45  */
46 
47 /*
48  * How many input characters we can buffer.
49  * The port-specific var.h may override this.
50  * Note: must be a power of two!
51  */
52 #define	MS_RX_RING_SIZE	256
53 #define MS_RX_RING_MASK (MS_RX_RING_SIZE-1)
54 /*
55  * Output buffer.  Only need a few chars.
56  */
57 #define	MS_TX_RING_SIZE	16
58 #define MS_TX_RING_MASK (MS_TX_RING_SIZE-1)
59 /*
60  * Keyboard serial line speed is fixed at 1200 bps; mouse serial line
61  * speed defaults to 1200 bps.
62  */
63 #ifdef	SUN_MS_BPS
64 #define	MS_BPS	SUN_MS_BPS
65 #else
66 #define MS_BPS 	1200
67 #endif
68 
69 /*
70  * Mouse state.  A Mouse Systems mouse is a fairly simple device,
71  * producing five-byte blobs of the form:
72  *
73  *	b dx dy dx dy
74  *
75  * where b is the button state, encoded as 0x80|(~buttons)---there are
76  * three buttons (4=left, 2=middle, 1=right)---and dx,dy are X and Y
77  * delta values, none of which have are in [0x80..0x87].  (This lets
78  * us sync up with the mouse after an error.)
79  */
80 struct ms_softc {
81 	struct	device ms_dev;		/* required first: base device */
82 	struct	zs_chanstate *ms_cs;
83 
84 	/*
85 	 * The deviopen and deviclose routines are provided
86 	 * by the lower level driver and used as a back door
87 	 * when opening and closing the internal device.
88 	 */
89 	int	(*ms_deviopen)	__P((struct device *, int));
90 	int	(*ms_deviclose)	__P((struct device *, int));
91 
92 	/* Flags to communicate with ms_softintr() */
93 	volatile int ms_intr_flags;
94 #define	INTR_RX_OVERRUN 1
95 #define INTR_TX_EMPTY   2
96 #define INTR_ST_CHECK   4
97 
98 	/*
99 	 * The receive ring buffer.
100 	 */
101 	u_int	ms_rbget;	/* ring buffer `get' index */
102 	volatile u_int	ms_rbput;	/* ring buffer `put' index */
103 	u_short	ms_rbuf[MS_RX_RING_SIZE]; /* rr1, data pairs */
104 
105 	/*
106 	 * State of input translator
107 	 */
108 	short	ms_byteno;		/* input byte number, for decode */
109 	char	ms_mb;			/* mouse button state */
110 	char	ms_ub;			/* user button state */
111 	int	ms_dx;			/* delta-x */
112 	int	ms_dy;			/* delta-y */
113 
114 	/*
115 	 * State of upper interface.
116 	 */
117 	volatile int ms_ready;		/* event queue is ready */
118 	struct	evvar ms_events;	/* event queue state */
119 };
120 
121 /* front-end call back for mouse input */
122 void ms_input __P((struct ms_softc *, int c));
123