summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/sunLynx/patch.Console
blob: 58a2d80f3e50c44b87009ce01dc53a82a2c1e1b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
diff -crP /cdrom/usr/include/kbd.h /usr/include/kbd.h
*** /cdrom/usr/include/kbd.h	Wed Dec 31 16:00:00 1969
--- /usr/include/kbd.h	Sun May 11 23:22:45 1997
***************
*** 0 ****
--- 1,90 ----
+ /*	$NetBSD: kbd.h,v 1.4 1995/07/06 05:36:29 pk Exp $ */
+ 
+ /*
+  * Copyright (c) 1992, 1993
+  *	The Regents of the University of California.  All rights reserved.
+  *
+  * This software was developed by the Computer Systems Engineering group
+  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+  * contributed to Berkeley.
+  *
+  * All advertising materials mentioning features or use of this software
+  * must display the following acknowledgement:
+  *	This product includes software developed by the University of
+  *	California, Lawrence Berkeley Laboratory.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 3. All advertising materials mentioning features or use of this software
+  *    must display the following acknowledgement:
+  *	This product includes software developed by the University of
+  *	California, Berkeley and its contributors.
+  * 4. Neither the name of the University nor the names of its contributors
+  *    may be used to endorse or promote products derived from this software
+  *    without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  *
+  *	@(#)kbd.h	8.1 (Berkeley) 6/11/93
+  */
+ 
+ /*
+  * Keyboard `registers'.  (This should be called kbd_reg.h but we need to
+  * be compatible.)
+  */
+ 
+ /*
+  * Control codes sent from type 2, 3, and 4 keyboards.
+  *
+  * Note that KBD_RESET is followed by a keyboard ID, while KBD_IDLE is not.
+  * KBD_IDLE does not take the place of any `up' transitions (it merely occurs
+  * after them).
+  */
+ #define	KBD_RESET	0xff		/* keyboard `reset' response */
+ #define	KBD_IDLE	0x7f		/* keyboard `all keys are up' code */
+ #define	KBD_LAYOUT	0xfe		/* keyboard `get layout' response */
+ 
+ /* Keyboard IDs */
+ #define	KB_SUN2		2		/* type 2 keyboard */
+ #define	KB_SUN3		3		/* type 3 keyboard */
+ #define	KB_SUN4		4		/* type 4 keyboard */
+ 
+ /* Key codes are in 0x00..0x7e; KBD_UP is set if the key goes up */
+ #define	KBD_KEYMASK	0x7f		/* keyboard key mask */
+ #define	KBD_UP		0x80		/* keyboard `up' transition */
+ 
+ /* Keyboard codes needed to recognize the L1-A sequence */
+ #define	KBD_L1		1		/* keyboard code for `L1' key */
+ #define	KBD_A		77		/* keyboard code for `A' key */
+ 
+ /* Control codes sent to the various keyboards */
+ #define	KBD_CMD_RESET	1		/* reset keyboard */
+ #define	KBD_CMD_BELL	2		/* turn bell on */
+ #define	KBD_CMD_NOBELL	3		/* turn bell off */
+ #define	KBD_CMD_CLICK	10		/* turn keyclick on */
+ #define	KBD_CMD_NOCLICK	11		/* turn keyclick off */
+ #define KBD_CMD_SETLED	14		/* set LED state (type 4 kbd) */
+ #define KBD_CMD_GLAYOUT	15		/* get DIP switch (type 4 kbd) */
+ 
+ #define	LED_NUM_LOCK	0x1
+ #if !defined(Lynx) || !defined(LED_COMPOSE)
+ #define	LED_COMPOSE	0x2
+ #endif
+ #define	LED_SCROLL_LOCK	0x4
+ #define	LED_CAPS_LOCK	0x8
diff -crP /cdrom/usr/include/kbio.h /usr/include/kbio.h
*** /cdrom/usr/include/kbio.h	Wed Dec 31 16:00:00 1969
--- /usr/include/kbio.h	Sun May 11 23:22:46 1997
***************
*** 0 ****
--- 1,115 ----
+ /*	$NetBSD: kbio.h,v 1.4 1995/05/10 16:07:27 pk Exp $ */
+ 
+ /*
+  * Copyright (c) 1992, 1993
+  *	The Regents of the University of California.  All rights reserved.
+  *
+  * This software was developed by the Computer Systems Engineering group
+  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+  * contributed to Berkeley.
+  *
+  * All advertising materials mentioning features or use of this software
+  * must display the following acknowledgement:
+  *	This product includes software developed by the University of
+  *	California, Lawrence Berkeley Laboratory.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 3. All advertising materials mentioning features or use of this software
+  *    must display the following acknowledgement:
+  *	This product includes software developed by the University of
+  *	California, Berkeley and its contributors.
+  * 4. Neither the name of the University nor the names of its contributors
+  *    may be used to endorse or promote products derived from this software
+  *    without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  *
+  *	@(#)kbio.h	8.1 (Berkeley) 6/11/93
+  */
+ 
+ /*
+  * The following is a minimal emulation of Sun's `kio' structures
+  * and related operations necessary to make X11 happy (i.e., make it
+  * compile, and make old X11 binaries run).
+  */
+ 
+ /*
+  * The kiockey structure apparently gets and/or sets keyboard mappings.
+  * It seems to be kind of useless, but X11 uses it (according to the
+  * comments) to figure out when a Sun 386i has a type-4 keyboard but
+  * claims to have a type-3 keyboard.  We need just enough to cause the
+  * appropriate ioctl to return the appropriate magic value.
+  *
+  * KIOCGETKEY fills in kio_entry from kio_station.  Not sure what tablemask
+  * is for; X sets it before the call, so it is not an output, but we do not
+  * care anyway.  KIOCSDIRECT is supposed to tell the kernel whether to send
+  * keys to the console or to X; we just send them to X whenever the keyboard
+  * is open at all.  (XXX may need to change this later)
+  *
+  * Keyboard commands and types are defined in kbd.h as they are actually
+  * real hardware commands and type numbers.
+  */
+ struct okiockey { /* Out-dated key translation structure */
+ 	int	kio_tablemask;	/* whatever */
+ 	u_char	kio_station;	/* key number */
+ 	u_char	kio_entry;	/* HOLE if not present */
+ 	char	kio_text[10];	/* the silly escape sequences (unsupported) */
+ };
+ 
+ struct kiockey {
+ 	int	kio_tablemask;	/* whatever */
+ 	u_char	kio_station;	/* key number */
+ 	u_short	kio_entry;	/* HOLE if not present */
+ 	char	kio_text[10];	/* the silly escape sequences (unsupported) */
+ };
+ 
+ /*
+  * Values for kio_tablemask. These determine which table to read/modify
+  * in KIOC[SG]KEY ioctls. Currently, we only have "non-shift" and "shift"
+  * tables.
+  */
+ #define KIOC_NOMASK	0x0
+ #define KIOC_CAPSMASK	0x1
+ #define KIOC_SHIFTMASK	0xe
+ #define KIOC_CTRLMASK	0x30
+ #define KIOC_ALTGMASK	0x200
+ #define KIOC_NUMLMASK	0x800
+ 
+ #define	HOLE	0x302		/* value for kio_entry to say `really type 3' */
+ 
+ #define	KIOCTRANS	_IOW('k', 0, int)	/* set translation mode */
+ 			/* (we only accept TR_UNTRANS_EVENT) */
+ #define	KIOCGETKEY	_IOWR('k', 2, struct okiockey) /* fill in kio_entry */
+ #define	KIOCGTRANS	_IOR('k', 5, int)	/* get translation mode */
+ #define	KIOCCMD		_IOW('k', 8, int)	/* X uses this to ring bell */
+ #define	KIOCTYPE	_IOR('k', 9, int)	/* get keyboard type */
+ #define	KIOCSDIRECT	_IOW('k', 10, int)	/* keys to console? */
+ #define KIOCSKEY	_IOW('k', 12, struct kiockey) /* set xlat mode */
+ #ifndef Lynx
+ #define KIOCGKEY	_IOWR('k', 13, struct kiockey) /* get xlat mode */
+ #endif
+ #define	KIOCLAYOUT	_IOR('k', 20, int)	/* get keyboard layout */
+ #define	KIOCSLED	_IOW('k', 14, char)	/* set LED state */
+ #define	KIOCGLED	_IOR('k', 15, char)	/* get LED state */
+ 
+ #define	TR_NONE			0	/* X compat, unsupported */
+ #define	TR_ASCII		1	/* X compat, unsupported */
+ #define	TR_EVENT		2	/* X compat, unsupported */
+ #define	TR_UNTRANS_EVENT	3
diff -crP /cdrom/sys/drivers/console/Makefile /sys/drivers/console/Makefile
*** /cdrom/sys/drivers/console/Makefile	Sun Feb  9 04:43:06 1997
--- /sys/drivers/console/Makefile	Sun May 11 23:24:04 1997
***************
*** 24,30 ****
  
  LIBRARY= drivers
  
! SPECIAL_CFLAGS=-DMOUSESUPPORT
  
  include	../../OBJ_RULES
  
--- 24,30 ----
  
  LIBRARY= drivers
  
! SPECIAL_CFLAGS=-DMOUSESUPPORT -DXSERVERSUPPORT
  
  include	../../OBJ_RULES
  
diff -crP /cdrom/sys/drivers/console/atc.h /sys/drivers/console/atc.h
*** /cdrom/sys/drivers/console/atc.h	Sun Feb  9 04:43:06 1997
--- /sys/drivers/console/atc.h	Sun May 11 23:22:46 1997
***************
*** 108,113 ****
--- 108,119 ----
  #ifdef	MOUSESUPPORT
  	struct ttystatics mousechannel;
  #endif	/* MOUSESUPPORT	*/
+ #ifdef XSERVERSUPPORT
+ 	int kbd_pending;
+ 	int kbd_id;			/* keyboard type	*/
+ 	int kbd_layout;			/* layout on type 4	*/
+ 	int kbd_click;			/* kbd click on?	*/
+ #endif
  };
  
  struct kbd_registers_type {
diff -crP /cdrom/sys/drivers/console/atcdrvr.c /sys/drivers/console/atcdrvr.c
*** /cdrom/sys/drivers/console/atcdrvr.c	Sun Feb  9 04:43:06 1997
--- /sys/drivers/console/atcdrvr.c	Sun May 11 23:25:15 1997
***************
*** 38,43 ****
--- 38,47 ----
  #ifdef	MOUSESUPPORT
  #include "am8530.h"
  #endif	/* MOUSESUPPORT	*/
+ #ifdef	XSERVERSUPPORT
+ #include <kbd.h>
+ #include <kbio.h>
+ #endif
  
  char *screen_address;		/* is this supposed to be in the driver info? */
  
***************
*** 305,310 ****
--- 309,318 ----
  	int m;
  	int ps;
  	extern int set_kb_lights();
+ #ifdef XSERVERSUPPORT
+ 	extern int kbd_docmd();
+ 	int err;
+ #endif
  	
  if (!atc_flag){ pseterr(EIO); return(SYSERR);}
  #ifdef	MOUSESUPPORT
***************
*** 354,365 ****
--- 362,398 ----
  #ifdef TIOLED
  		case TIOLED:
  #endif
+ #ifdef XSERVERSUPPORT
+ 		case KIOCSLED:
+ #endif
  			h->curled = *arg;
  			if (h->ledstate == -1) {
  				if (timeout(set_kb_lights,h,1) != -1)
  					h->ledstate = 0;
  			}
  			return 0;
+ #ifdef XSERVERSUPPORT
+ 		case KIOCTYPE:
+ 			if (wbounds(arg) < sizeof(int)) {
+ 				pseterr(EFAULT);
+ 				return SYSERR;
+ 			}
+ 			*(int *)arg = h->kbd_id;
+ 			return OK;
+ 		case KIOCLAYOUT:
+ 			if (wbounds(arg) < sizeof(int)) {
+ 				pseterr(EFAULT);
+ 				return SYSERR;
+ 			}
+ 			*(int *)arg = h->kbd_layout;
+ 			return OK;
+ 		case KIOCCMD:
+ 			if (err = kbd_docmd(h, *(int *)arg)) {
+ 				pseterr(err);
+ 				return SYSERR;
+ 			}
+ 			return OK;
+ #endif
  		case VT_OPENQRY:
  			if (h->multimode == SCM_ONE) {
  				if (!(h->open & 1)) {
***************
*** 578,583 ****
--- 611,622 ----
  	h->open = 0;
  	h->break_code = 0;
  	h->info = info;
+ #ifdef	XSERVERSUPPORT
+ 	h->kbd_pending = 0;
+ 	h->kbd_id = KB_SUN4;		/* query KBD later....	*/
+ 	h->kbd_layout = 0;		/* US_ASCII		*/
+ 	h->kbd_click = 0;		/* silent movie		*/
+ #endif
  #ifdef	MOUSESUPPORT
  	tmgr_install(&h->mousechannel, &info->sg, 0, mouse_xmit_ena, h);
  #endif	/* MOUSESUPPORT	*/
diff -crP /cdrom/sys/drivers/console/atkey.c /sys/drivers/console/atkey.c
*** /cdrom/sys/drivers/console/atkey.c	Sun Feb  9 04:43:07 1997
--- /sys/drivers/console/atkey.c	Sun May 11 23:22:46 1997
***************
*** 26,31 ****
--- 26,35 ----
  #ifdef	MOUSESUPPORT
  #include "am8530.h"
  #endif	/* MOUSESUPPORT	*/
+ #ifdef	XSERVERSUPPORT
+ #include <kbd.h>
+ #include <kbio.h>
+ #endif
  
  #define	NOTHING_USEFUL	-1
  #define FILL		NOTHING_USEFUL
diff -crP /cdrom/sys/drivers/console/atutils.c /sys/drivers/console/atutils.c
*** /cdrom/sys/drivers/console/atutils.c	Sun Feb  9 04:43:07 1997
--- /sys/drivers/console/atutils.c	Sun May 11 23:22:46 1997
***************
*** 361,367 ****
  }
  
  
! static int byte_to_keyboard(byt)
  unsigned char byt;
  {
  	int i;
--- 361,370 ----
  }
  
  
! #ifndef XSERVERSUPPORT
! static
! #endif
! int byte_to_keyboard(byt)
  unsigned char byt;
  {
  	int i;
***************
*** 400,402 ****
--- 403,449 ----
  			break;
  	}
  }
+ 
+ #ifdef XSERVERSUPPORT
+ #include <kbd.h>
+ #include <kbio.h>
+ 
+  /*
+  * Execute a keyboard command; return 0 on success.
+  */
+ kbd_docmd(h, cmd)
+ register struct kdhglobals *h;
+ int cmd;
+ {
+ 	switch (cmd) {
+ 
+ 	case KBD_CMD_BELL:
+ 	case KBD_CMD_NOBELL:
+ 		/* Supported by type 2, 3, and 4 keyboards */
+ 		break;
+ 
+ 	case KBD_CMD_CLICK:
+ 		/* Unsupported by type 2 keyboards */
+ 		if (h->kbd_id != KB_SUN2) {
+ 			h->kbd_click = 1;
+ 			break;
+ 		}
+ 		return (EINVAL);
+ 
+ 	case KBD_CMD_NOCLICK:
+ 		/* Unsupported by type 2 keyboards */
+ 		if (h->kbd_id != KB_SUN2) {
+ 			h->kbd_click = 0;
+ 			break;
+ 		}
+ 		return (EINVAL);
+ 
+ 	default:
+ 		return (EINVAL);	/* ENOTTY? EOPNOTSUPP? */
+ 	}
+ 
+ 	if (timeout(byte_to_keyboard, cmd, 1) < 0)
+ 		return (ENOSPC);	/* ERESTART? */
+ 	return (0);
+ }
+ #endif