diff -cPr --exclude-from=Excl.include /mnt/DEV_OS.microSPARC/usr/include/kbd.h /usr/include/kbd.h
*** /mnt/DEV_OS.microSPARC/usr/include/kbd.h
--- /usr/include/kbd.h	Wed Jul 24 09:37:49 1996
***************
*** 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 -cPr --exclude-from=Excl.include /mnt/DEV_OS.microSPARC/usr/include/kbio.h /usr/include/kbio.h
*** /mnt/DEV_OS.microSPARC/usr/include/kbio.h
--- /usr/include/kbio.h	Wed Aug 14 16:29:26 1996
***************
*** 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 -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/Makefile sys/drivers/console/Makefile
*** /mnt/DEV_OS.microSPARC/sys/drivers/console/Makefile	Fri Apr 26 23:27:51 1996
--- sys/drivers/console/Makefile	Fri Aug  2 09:03:05 1996
***************
*** 31,37 ****
  # (keyboard) duart.  The mouse is attached to this port.  It must be
  # defined for the X server to work.
  #
! SPECIAL_CFLAGS = -DMOUSESUPPORT -O
  
  FILES = atcdrvr.xxx gfont.xxx atkey.xxx atbeep.xxx atterm.xxx atutils.xxx 
  HFILES = 
--- 31,37 ----
  # (keyboard) duart.  The mouse is attached to this port.  It must be
  # defined for the X server to work.
  #
! SPECIAL_CFLAGS = -DMOUSESUPPORT -DXSERVERSUPPORT -O
  
  FILES = atcdrvr.xxx gfont.xxx atkey.xxx atbeep.xxx atterm.xxx atutils.xxx 
  HFILES = 
***************
*** 117,122 ****
--- 117,130 ----
  
  # Just Do It.
  FORCE:
+ 
+ atkey.kdb.o : atkey.c
+ 	$(KERN_CC) -c -o atkey.kdb.o $(SPECIAL_CFLAGS) $(KERN_CFLAGS) \
+ 		$(SPECIAL_INCLUDES) $(KERN_INCLUDES)  -DSKDB atkey.c
+ 
+ atkey.nokdb.o : atkey.c
+ 	$(KERN_CC) -c -o atkey.kdb.o $(SPECIAL_CFLAGS) $(KERN_CFLAGS) \
+ 		$(SPECIAL_INCLUDES) $(KERN_INCLUDES)  atkey.c
  
  # Dependencies as of 5/20/1992
  
diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atc.h sys/drivers/console/atc.h
*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atc.h	Fri Apr 26 23:27:51 1996
--- sys/drivers/console/atc.h	Wed Jul 24 11:49:21 1996
***************
*** 191,196 ****
--- 191,202 ----
  #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 -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atcdrvr.c sys/drivers/console/atcdrvr.c
*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atcdrvr.c	Fri Apr 26 23:27:51 1996
--- sys/drivers/console/atcdrvr.c	Wed Aug 14 16:28:23 1996
***************
*** 270,275 ****
--- 270,279 ----
  #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? */
  
***************
*** 537,542 ****
--- 541,550 ----
  	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
***************
*** 586,597 ****
  #ifdef TIOLED
  		case TIOLED:
  #endif
  			h->curled = *arg;
  			if (h->ledstate == -1) {
  				if (timeout(set_kb_lights,h,1) != -1)
  					h->ledstate = 0;
  			}
! 			break;
  		case VT_OPENQRY:
  			if (h->multimode == SCM_ONE) {
  				if (!(h->open & 1)) {
--- 594,630 ----
  #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 OK;
! #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)) {
***************
*** 810,815 ****
--- 843,854 ----
  	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 -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atkey.c sys/drivers/console/atkey.c
*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atkey.c	Fri Apr 26 23:27:51 1996
--- sys/drivers/console/atkey.c	Mon Sep 23 09:19:36 1996
***************
*** 162,167 ****
--- 162,171 ----
  #ifdef	MOUSESUPPORT
  #include "am8530.h"
  #endif	/* MOUSESUPPORT	*/
+ #ifdef	XSERVERSUPPORT
+ #include <kbd.h>
+ #include <kbio.h>
+ #endif
  
  #define	NOTHING_USEFUL	-1
  #define FILL		NOTHING_USEFUL
***************
*** 474,480 ****
  #undef DEBUG
  
  	j = *(volatile unsigned char *)KV_KBD_DATA;
! 
  	/* Do the quick scan mode check first.  If scanning, stuff and exit */
  	screen_num = (h->g - &h->screen[0]);
  	if (h->screen[screen_num].scan_mode) {
--- 478,503 ----
  #undef DEBUG
  
  	j = *(volatile unsigned char *)KV_KBD_DATA;
! #ifdef XSERVERSUPPORT
! 	if (h->kbd_pending == KBD_RESET) {
! 		h->kbd_pending = 0;
! 		h->kbd_id = j;
! 		if (j == KB_SUN4) {
! 			extern int byte_to_keyboard();
! 			timeout(byte_to_keyboard, KBD_CMD_GLAYOUT, 1);
! 		}
! 		goto EOIandExit;
! 	}
! 	if (h->kbd_pending == KBD_LAYOUT) {
! 		h->kbd_pending = 0;
! 		h->kbd_layout = j;
! 		goto EOIandExit;
! 	}
! 	if (j == KBD_RESET || j == KBD_LAYOUT) {
! 		h->kbd_pending = j;
! 		goto EOIandExit;
! 	}
! #endif
  	/* Do the quick scan mode check first.  If scanning, stuff and exit */
  	screen_num = (h->g - &h->screen[0]);
  	if (h->screen[screen_num].scan_mode) {
diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atutils.c sys/drivers/console/atutils.c
*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atutils.c	Fri Apr 26 23:27:51 1996
--- sys/drivers/console/atutils.c	Tue Aug 13 11:54:38 1996
***************
*** 456,462 ****
  }
  
  
! static int byte_to_keyboard(byt)
  unsigned char byt;
  {
  	int i;
--- 456,465 ----
  }
  
  
! #ifndef XSERVERSUPPORT
! static
! #endif
! int byte_to_keyboard(byt)
  unsigned char byt;
  {
  	int i;
***************
*** 495,497 ****
--- 498,544 ----
  			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
