kernel - Fix serious issue w/ smp_invltlb(), plus other issues.
[dragonfly.git] / sys / platform / pc32 / include / mouse.h
1 /*-
2  * Copyright (c) 1992, 1993 Erik Forsberg.
3  * Copyright (c) 1996, 1997 Kazutaka YOKOTA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
13  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
15  * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
18  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
19  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22  *
23  * $FreeBSD: src/sys/i386/include/mouse.h,v 1.15.2.2 2002/04/15 00:52:08 will Exp $
24  * $DragonFly: src/sys/platform/pc32/include/mouse.h,v 1.2 2003/06/17 04:28:35 dillon Exp $
25  */
26
27 #ifndef _MACHINE_MOUSE_H_
28 #define _MACHINE_MOUSE_H_
29
30 #include <sys/types.h>
31 #include <sys/ioccom.h>
32
33 /* ioctls */
34 #define MOUSE_GETSTATUS         _IOR('M', 0, mousestatus_t)
35 #define MOUSE_GETHWINFO         _IOR('M', 1, mousehw_t)
36 #define MOUSE_GETMODE           _IOR('M', 2, mousemode_t)
37 #define MOUSE_SETMODE           _IOW('M', 3, mousemode_t)
38 #define MOUSE_GETLEVEL          _IOR('M', 4, int)
39 #define MOUSE_SETLEVEL          _IOW('M', 5, int)
40 #define MOUSE_GETVARS           _IOR('M', 6, mousevar_t)
41 #define MOUSE_SETVARS           _IOW('M', 7, mousevar_t)
42 #define MOUSE_READSTATE         _IOWR('M', 8, mousedata_t)
43 #define MOUSE_READDATA          _IOWR('M', 9, mousedata_t)
44
45 #if notyet
46 #define MOUSE_SETRESOLUTION     _IOW('M', 10, int)
47 #define MOUSE_SETSCALING        _IOW('M', 11, int)
48 #define MOUSE_SETRATE           _IOW('M', 12, int)
49 #define MOUSE_GETHWID           _IOR('M', 13, int)
50 #endif
51
52 /* mouse status block */
53 typedef struct mousestatus {
54     int     flags;              /* state change flags */
55     int     button;             /* button status */
56     int     obutton;            /* previous button status */
57     int     dx;                 /* x movement */
58     int     dy;                 /* y movement */
59     int     dz;                 /* z movement */
60 } mousestatus_t;
61
62 /* button */
63 #define MOUSE_BUTTON1DOWN       0x0001  /* left */
64 #define MOUSE_BUTTON2DOWN       0x0002  /* middle */
65 #define MOUSE_BUTTON3DOWN       0x0004  /* right */
66 #define MOUSE_BUTTON4DOWN       0x0008
67 #define MOUSE_BUTTON5DOWN       0x0010
68 #define MOUSE_BUTTON6DOWN       0x0020
69 #define MOUSE_BUTTON7DOWN       0x0040
70 #define MOUSE_BUTTON8DOWN       0x0080
71 #define MOUSE_MAXBUTTON         31
72 #define MOUSE_STDBUTTONS        0x0007          /* buttons 1-3 */
73 #define MOUSE_EXTBUTTONS        0x7ffffff8      /* the others (28 of them!) */
74 #define MOUSE_BUTTONS           (MOUSE_STDBUTTONS | MOUSE_EXTBUTTONS)
75
76 /* flags */
77 #define MOUSE_STDBUTTONSCHANGED MOUSE_STDBUTTONS
78 #define MOUSE_EXTBUTTONSCHANGED MOUSE_EXTBUTTONS
79 #define MOUSE_BUTTONSCHANGED    MOUSE_BUTTONS
80 #define MOUSE_POSCHANGED        0x80000000
81
82 typedef struct mousehw {
83         int buttons;            /* -1 if unknown */
84         int iftype;             /* MOUSE_IF_XXX */
85         int type;               /* mouse/track ball/pad... */
86         int model;              /* I/F dependent model ID: MOUSE_MODEL_XXX */
87         int hwid;               /* I/F dependent hardware ID
88                                  * for the PS/2 mouse, it will be PSM_XXX_ID 
89                                  */
90 } mousehw_t;
91
92 /* iftype */
93 #define MOUSE_IF_UNKNOWN        (-1)
94 #define MOUSE_IF_SERIAL         0
95 #define MOUSE_IF_BUS            1
96 #define MOUSE_IF_INPORT         2
97 #define MOUSE_IF_PS2            3
98 #define MOUSE_IF_SYSMOUSE       4
99 #define MOUSE_IF_USB            5
100
101 /* type */
102 #define MOUSE_UNKNOWN           (-1)    /* should be treated as a mouse */
103 #define MOUSE_MOUSE             0
104 #define MOUSE_TRACKBALL         1
105 #define MOUSE_STICK             2
106 #define MOUSE_PAD               3
107
108 /* model */
109 #define MOUSE_MODEL_UNKNOWN             (-1)
110 #define MOUSE_MODEL_GENERIC             0
111 #define MOUSE_MODEL_GLIDEPOINT          1
112 #define MOUSE_MODEL_NETSCROLL           2
113 #define MOUSE_MODEL_NET                 3
114 #define MOUSE_MODEL_INTELLI             4
115 #define MOUSE_MODEL_THINK               5
116 #define MOUSE_MODEL_EASYSCROLL          6
117 #define MOUSE_MODEL_MOUSEMANPLUS        7
118 #define MOUSE_MODEL_KIDSPAD             8
119 #define MOUSE_MODEL_VERSAPAD            9
120 #define MOUSE_MODEL_EXPLORER            10
121 #define MOUSE_MODEL_4D                  11
122 #define MOUSE_MODEL_4DPLUS              12
123
124 typedef struct mousemode {
125         int protocol;           /* MOUSE_PROTO_XXX */
126         int rate;               /* report rate (per sec), -1 if unknown */
127         int resolution;         /* MOUSE_RES_XXX, -1 if unknown */
128         int accelfactor;        /* accelation factor (must be 1 or greater) */
129         int level;              /* driver operation level */
130         int packetsize;         /* the length of the data packet */
131         unsigned char syncmask[2]; /* sync. data bits in the header byte */
132 } mousemode_t;
133
134 /* protocol */
135 /*
136  * Serial protocols:
137  *   Microsoft, MouseSystems, Logitech, MM series, MouseMan, Hitachi Tablet,
138  *   GlidePoint, IntelliMouse, Thinking Mouse, MouseRemote, Kidspad,
139  *   VersaPad
140  * Bus mouse protocols:
141  *   bus, InPort
142  * PS/2 mouse protocol:
143  *   PS/2
144  */
145 #define MOUSE_PROTO_UNKNOWN     (-1)
146 #define MOUSE_PROTO_MS          0       /* Microsoft Serial, 3 bytes */
147 #define MOUSE_PROTO_MSC         1       /* Mouse Systems, 5 bytes */
148 #define MOUSE_PROTO_LOGI        2       /* Logitech, 3 bytes */
149 #define MOUSE_PROTO_MM          3       /* MM series, 3 bytes */
150 #define MOUSE_PROTO_LOGIMOUSEMAN 4      /* Logitech MouseMan 3/4 bytes */
151 #define MOUSE_PROTO_BUS         5       /* MS/Logitech bus mouse */
152 #define MOUSE_PROTO_INPORT      6       /* MS/ATI InPort mouse */
153 #define MOUSE_PROTO_PS2         7       /* PS/2 mouse, 3 bytes */
154 #define MOUSE_PROTO_HITTAB      8       /* Hitachi Tablet 3 bytes */
155 #define MOUSE_PROTO_GLIDEPOINT  9       /* ALPS GlidePoint, 3/4 bytes */
156 #define MOUSE_PROTO_INTELLI     10      /* MS IntelliMouse, 4 bytes */
157 #define MOUSE_PROTO_THINK       11      /* Kensignton Thinking Mouse, 3/4 bytes */
158 #define MOUSE_PROTO_SYSMOUSE    12      /* /dev/sysmouse */
159 #define MOUSE_PROTO_X10MOUSEREM 13      /* X10 MouseRemote, 3 bytes */
160 #define MOUSE_PROTO_KIDSPAD     14      /* Genius Kidspad */
161 #define MOUSE_PROTO_VERSAPAD    15      /* Interlink VersaPad, 6 bytes */
162 #define MOUSE_PROTO_JOGDIAL     16      /* Vaio's JogDial */
163
164 #define MOUSE_RES_UNKNOWN       (-1)
165 #define MOUSE_RES_DEFAULT       0
166 #define MOUSE_RES_LOW           (-2)
167 #define MOUSE_RES_MEDIUMLOW     (-3)
168 #define MOUSE_RES_MEDIUMHIGH    (-4)
169 #define MOUSE_RES_HIGH          (-5)
170
171 typedef struct mousedata {
172         int len;                /* # of data in the buffer */
173         int buf[16];            /* data buffer */
174 } mousedata_t;
175
176 #if (defined(MOUSE_GETVARS))
177
178 typedef struct mousevar {
179         int var[16];
180 } mousevar_t;
181
182 /* magic numbers in var[0] */
183 #define MOUSE_VARS_PS2_SIG      0x00325350      /* 'PS2' */
184 #define MOUSE_VARS_BUS_SIG      0x00535542      /* 'BUS' */
185 #define MOUSE_VARS_INPORT_SIG   0x00504e49      /* 'INP' */
186
187 #endif /* MOUSE_GETVARS */
188
189 /* Microsoft Serial mouse data packet */
190 #define MOUSE_MSS_PACKETSIZE    3
191 #define MOUSE_MSS_SYNCMASK      0x40
192 #define MOUSE_MSS_SYNC          0x40
193 #define MOUSE_MSS_BUTTONS       0x30
194 #define MOUSE_MSS_BUTTON1DOWN   0x20    /* left */
195 #define MOUSE_MSS_BUTTON2DOWN   0x00    /* no middle button */
196 #define MOUSE_MSS_BUTTON3DOWN   0x10    /* right */
197
198 /* Logitech MouseMan data packet (M+ protocol) */
199 #define MOUSE_LMAN_BUTTON2DOWN  0x20    /* middle button, the 4th byte */
200
201 /* ALPS GlidePoint extention (variant of M+ protocol) */
202 #define MOUSE_ALPS_BUTTON2DOWN  0x20    /* middle button, the 4th byte */
203 #define MOUSE_ALPS_TAP          0x10    /* `tapping' action, the 4th byte */
204
205 /* Kinsington Thinking Mouse extention (variant of M+ protocol) */
206 #define MOUSE_THINK_BUTTON2DOWN 0x20    /* lower-left button, the 4th byte */
207 #define MOUSE_THINK_BUTTON4DOWN 0x10    /* lower-right button, the 4th byte */
208
209 /* MS IntelliMouse (variant of MS Serial) */
210 #define MOUSE_INTELLI_PACKETSIZE 4
211 #define MOUSE_INTELLI_BUTTON2DOWN 0x10  /* middle button in the 4th byte */
212
213 /* Mouse Systems Corp. mouse data packet */
214 #define MOUSE_MSC_PACKETSIZE    5
215 #define MOUSE_MSC_SYNCMASK      0xf8
216 #define MOUSE_MSC_SYNC          0x80
217 #define MOUSE_MSC_BUTTONS       0x07
218 #define MOUSE_MSC_BUTTON1UP     0x04    /* left */
219 #define MOUSE_MSC_BUTTON2UP     0x02    /* middle */
220 #define MOUSE_MSC_BUTTON3UP     0x01    /* right */
221 #define MOUSE_MSC_MAXBUTTON     3
222
223 /* MM series mouse data packet */
224 #define MOUSE_MM_PACKETSIZE     3
225 #define MOUSE_MM_SYNCMASK       0xe0
226 #define MOUSE_MM_SYNC           0x80
227 #define MOUSE_MM_BUTTONS        0x07
228 #define MOUSE_MM_BUTTON1DOWN    0x04    /* left */
229 #define MOUSE_MM_BUTTON2DOWN    0x02    /* middle */
230 #define MOUSE_MM_BUTTON3DOWN    0x01    /* right */
231 #define MOUSE_MM_XPOSITIVE      0x10
232 #define MOUSE_MM_YPOSITIVE      0x08
233
234 /* PS/2 mouse data packet */
235 #define MOUSE_PS2_PACKETSIZE    3
236 #define MOUSE_PS2_SYNCMASK      0xc8
237 #define MOUSE_PS2_SYNC          0x08
238 #define MOUSE_PS2_BUTTONS       0x07    /* 0x03 for 2 button mouse */
239 #define MOUSE_PS2_BUTTON1DOWN   0x01    /* left */
240 #define MOUSE_PS2_BUTTON2DOWN   0x04    /* middle */
241 #define MOUSE_PS2_BUTTON3DOWN   0x02    /* right */
242 #define MOUSE_PS2_TAP           MOUSE_PS2_SYNC /* GlidePoint (PS/2) `tapping'
243                                                 * Yes! this is the same bit 
244                                                 * as SYNC!
245                                                 */
246
247 #define MOUSE_PS2_XNEG          0x10
248 #define MOUSE_PS2_YNEG          0x20
249 #define MOUSE_PS2_XOVERFLOW     0x40
250 #define MOUSE_PS2_YOVERFLOW     0x80
251
252 /* Logitech MouseMan+ (PS/2) data packet (PS/2++ protocol) */
253 #define MOUSE_PS2PLUS_SYNCMASK  0x48
254 #define MOUSE_PS2PLUS_SYNC      0x48
255 #define MOUSE_PS2PLUS_ZNEG      0x08    /* sign bit */
256 #define MOUSE_PS2PLUS_BUTTON4DOWN 0x10  /* 4th button on MouseMan+ */
257 #define MOUSE_PS2PLUS_BUTTON5DOWN 0x20
258
259 /* IBM ScrollPoint (PS/2) also uses PS/2++ protocol */
260 #define MOUSE_SPOINT_ZNEG       0x80    /* sign bits */
261 #define MOUSE_SPOINT_WNEG       0x08
262
263 /* MS IntelliMouse (PS/2) data packet */
264 #define MOUSE_PS2INTELLI_PACKETSIZE 4
265 /* some compatible mice have additional buttons */
266 #define MOUSE_PS2INTELLI_BUTTON4DOWN 0x40
267 #define MOUSE_PS2INTELLI_BUTTON5DOWN 0x80
268
269 /* MS IntelliMouse Explorer (PS/2) data packet (variation of IntelliMouse) */
270 #define MOUSE_EXPLORER_ZNEG     0x08    /* sign bit */
271 /* IntelliMouse Explorer has additional button data in the fourth byte */
272 #define MOUSE_EXPLORER_BUTTON4DOWN 0x10
273 #define MOUSE_EXPLORER_BUTTON5DOWN 0x20
274
275 /* Interlink VersaPad (serial I/F) data packet */
276 #define MOUSE_VERSA_PACKETSIZE  6
277 #define MOUSE_VERSA_IN_USE      0x04
278 #define MOUSE_VERSA_SYNCMASK    0xc3
279 #define MOUSE_VERSA_SYNC        0xc0
280 #define MOUSE_VERSA_BUTTONS     0x30
281 #define MOUSE_VERSA_BUTTON1DOWN 0x20    /* left */
282 #define MOUSE_VERSA_BUTTON2DOWN 0x00    /* middle */
283 #define MOUSE_VERSA_BUTTON3DOWN 0x10    /* right */
284 #define MOUSE_VERSA_TAP         0x08
285
286 /* Interlink VersaPad (PS/2 I/F) data packet */
287 #define MOUSE_PS2VERSA_PACKETSIZE       6
288 #define MOUSE_PS2VERSA_IN_USE           0x10
289 #define MOUSE_PS2VERSA_SYNCMASK         0xe8
290 #define MOUSE_PS2VERSA_SYNC             0xc8
291 #define MOUSE_PS2VERSA_BUTTONS          0x05
292 #define MOUSE_PS2VERSA_BUTTON1DOWN      0x04    /* left */
293 #define MOUSE_PS2VERSA_BUTTON2DOWN      0x00    /* middle */
294 #define MOUSE_PS2VERSA_BUTTON3DOWN      0x01    /* right */
295 #define MOUSE_PS2VERSA_TAP              0x02
296
297 /* A4 Tech 4D Mouse (PS/2) data packet */
298 #define MOUSE_4D_PACKETSIZE             3       
299 #define MOUSE_4D_WHEELBITS              0xf0
300
301 /* A4 Tech 4D+ Mouse (PS/2) data packet */
302 #define MOUSE_4DPLUS_PACKETSIZE         3       
303 #define MOUSE_4DPLUS_ZNEG               0x04    /* sign bit */
304 #define MOUSE_4DPLUS_BUTTON4DOWN        0x08
305
306 /* sysmouse extended data packet */
307 /*
308  * /dev/sysmouse sends data in two formats, depending on the protocol
309  * level.  At the level 0, format is exactly the same as MousSystems'
310  * five byte packet.  At the level 1, the first five bytes are the same
311  * as at the level 0.  There are additional three bytes which shows
312  * `dz' and the states of additional buttons.  `dz' is expressed as the
313  * sum of the byte 5 and 6 which contain signed seven bit values.
314  * The states of the button 4 though 10 are in the bit 0 though 6 in 
315  * the byte 7 respectively: 1 indicates the button is up.
316  */
317 #define MOUSE_SYS_PACKETSIZE    8
318 #define MOUSE_SYS_SYNCMASK      0xf8
319 #define MOUSE_SYS_SYNC          0x80
320 #define MOUSE_SYS_BUTTON1UP     0x04    /* left, 1st byte */
321 #define MOUSE_SYS_BUTTON2UP     0x02    /* middle, 1st byte */
322 #define MOUSE_SYS_BUTTON3UP     0x01    /* right, 1st byte */
323 #define MOUSE_SYS_BUTTON4UP     0x0001  /* 7th byte */
324 #define MOUSE_SYS_BUTTON5UP     0x0002
325 #define MOUSE_SYS_BUTTON6UP     0x0004
326 #define MOUSE_SYS_BUTTON7UP     0x0008
327 #define MOUSE_SYS_BUTTON8UP     0x0010
328 #define MOUSE_SYS_BUTTON9UP     0x0020
329 #define MOUSE_SYS_BUTTON10UP    0x0040
330 #define MOUSE_SYS_MAXBUTTON     10
331 #define MOUSE_SYS_STDBUTTONS    0x07
332 #define MOUSE_SYS_EXTBUTTONS    0x7f    /* the others */
333
334 /* Mouse remote socket */
335 #define _PATH_MOUSEREMOTE       "/var/run/MouseRemote"
336
337 #endif /* _MACHINE_MOUSE_H_ */