Home | History | Annotate | Line # | Download | only in sun
kbdsunvar.h revision 1.2
      1  1.2  uwe /*	$NetBSD: kbdsunvar.h,v 1.2 2002/10/21 15:36:35 uwe Exp $ */
      2  1.2  uwe 
      3  1.2  uwe /*
      4  1.2  uwe  * Copyright (c) 1992, 1993
      5  1.2  uwe  *	The Regents of the University of California.  All rights reserved.
      6  1.2  uwe  *
      7  1.2  uwe  * This software was developed by the Computer Systems Engineering group
      8  1.2  uwe  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9  1.2  uwe  * contributed to Berkeley.
     10  1.2  uwe  *
     11  1.2  uwe  * All advertising materials mentioning features or use of this software
     12  1.2  uwe  * must display the following acknowledgement:
     13  1.2  uwe  *	This product includes software developed by the University of
     14  1.2  uwe  *	California, Lawrence Berkeley Laboratory.
     15  1.2  uwe  *
     16  1.2  uwe  * Redistribution and use in source and binary forms, with or without
     17  1.2  uwe  * modification, are permitted provided that the following conditions
     18  1.2  uwe  * are met:
     19  1.2  uwe  * 1. Redistributions of source code must retain the above copyright
     20  1.2  uwe  *    notice, this list of conditions and the following disclaimer.
     21  1.2  uwe  * 2. Redistributions in binary form must reproduce the above copyright
     22  1.2  uwe  *    notice, this list of conditions and the following disclaimer in the
     23  1.2  uwe  *    documentation and/or other materials provided with the distribution.
     24  1.2  uwe  * 3. All advertising materials mentioning features or use of this software
     25  1.2  uwe  *    must display the following acknowledgement:
     26  1.2  uwe  *	This product includes software developed by the University of
     27  1.2  uwe  *	California, Berkeley and its contributors.
     28  1.2  uwe  * 4. Neither the name of the University nor the names of its contributors
     29  1.2  uwe  *    may be used to endorse or promote products derived from this software
     30  1.2  uwe  *    without specific prior written permission.
     31  1.2  uwe  *
     32  1.2  uwe  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     33  1.2  uwe  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     34  1.2  uwe  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     35  1.2  uwe  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     36  1.2  uwe  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     37  1.2  uwe  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     38  1.2  uwe  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     39  1.2  uwe  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     40  1.2  uwe  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     41  1.2  uwe  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     42  1.2  uwe  * SUCH DAMAGE.
     43  1.2  uwe  *
     44  1.2  uwe  *	@(#)kbd.c	8.2 (Berkeley) 10/30/93
     45  1.2  uwe  */
     46  1.2  uwe 
     47  1.1  uwe /*
     48  1.1  uwe  * Keyboard driver - middle layer for sun keyboard off a serial line.
     49  1.2  uwe  * This code is used by kbd_zs and sunkbd (line discipline) drivers.
     50  1.1  uwe  */
     51  1.1  uwe 
     52  1.2  uwe 
     53  1.1  uwe /*
     54  1.1  uwe  * How many input characters we can buffer.
     55  1.1  uwe  * The port-specific var.h may override this.
     56  1.1  uwe  * Note: must be a power of two!
     57  1.1  uwe  */
     58  1.1  uwe #define	KBD_RX_RING_SIZE	256
     59  1.1  uwe #define KBD_RX_RING_MASK	(KBD_RX_RING_SIZE - 1)
     60  1.1  uwe 
     61  1.1  uwe /*
     62  1.1  uwe  * Output buffer.  Only need a few chars.
     63  1.1  uwe  */
     64  1.1  uwe #define	KBD_TX_RING_SIZE	16
     65  1.1  uwe #define KBD_TX_RING_MASK	(KBD_TX_RING_SIZE - 1)
     66  1.2  uwe 
     67  1.1  uwe /*
     68  1.1  uwe  * Keyboard serial line speed defaults to 1200 bps.
     69  1.1  uwe  */
     70  1.1  uwe #define KBD_DEFAULT_BPS		1200
     71  1.2  uwe 
     72  1.1  uwe #define KBD_RESET_TIMO		1000 /* mS. */
     73  1.1  uwe 
     74  1.1  uwe 
     75  1.1  uwe struct kbd_sun_softc {
     76  1.1  uwe 	/* upper layer (also inherits struct device) */
     77  1.1  uwe 	struct kbd_softc k_kbd;
     78  1.1  uwe 
     79  1.1  uwe 	union {
     80  1.1  uwe 		void *ku_priv;
     81  1.1  uwe 		struct zs_chanstate *ku_cs;
     82  1.1  uwe 	} k_u;
     83  1.1  uwe #define k_priv	k_u.ku_priv
     84  1.1  uwe #define	k_cs	k_u.ku_cs
     85  1.1  uwe 
     86  1.1  uwe 	/*
     87  1.1  uwe 	 * The deviopen and deviclose routines are provided by the
     88  1.1  uwe 	 * underlying lower level driver and used as a back door when
     89  1.1  uwe 	 * opening and closing the internal device.
     90  1.1  uwe 	 */
     91  1.1  uwe 	int (*k_deviopen)(struct device *, int);
     92  1.1  uwe 	int (*k_deviclose)(struct device *, int);
     93  1.1  uwe 
     94  1.1  uwe 	/*
     95  1.1  uwe 	 * Callback provided by the lower layer (actual device driver).
     96  1.1  uwe 	 * Middle layer uses it to send commands to sun keyboard.
     97  1.1  uwe 	 */
     98  1.1  uwe 	void (*k_write_data)(struct kbd_sun_softc *, int);
     99  1.1  uwe 
    100  1.1  uwe 	/* Was initialized once. */
    101  1.1  uwe 	int k_isopen;
    102  1.1  uwe 
    103  1.1  uwe 	/*
    104  1.1  uwe 	 * Magic sequence stuff (Stop-A, aka L1-A).
    105  1.1  uwe 	 * XXX: convert to cnmagic(9).
    106  1.1  uwe 	 */
    107  1.1  uwe 	char k_magic1_down;
    108  1.1  uwe 	u_char k_magic1;	/* L1 */
    109  1.1  uwe 	u_char k_magic2;	/* A */
    110  1.1  uwe 
    111  1.1  uwe 	/* Expecting ID or layout byte from keyboard */
    112  1.1  uwe 	int k_expect;
    113  1.1  uwe #define	KBD_EXPECT_IDCODE	1
    114  1.1  uwe #define	KBD_EXPECT_LAYOUT	2
    115  1.1  uwe 
    116  1.1  uwe 	/* Flags to communicate with kbd_softint() */
    117  1.1  uwe 	volatile int k_intr_flags;
    118  1.1  uwe #define	INTR_RX_OVERRUN 1
    119  1.1  uwe #define INTR_TX_EMPTY   2
    120  1.1  uwe #define INTR_ST_CHECK   4
    121  1.1  uwe 
    122  1.1  uwe 	/* Transmit state */
    123  1.1  uwe 	volatile int k_txflags;
    124  1.1  uwe #define	K_TXBUSY 1
    125  1.1  uwe #define K_TXWANT 2
    126  1.1  uwe 
    127  1.1  uwe 	/*
    128  1.1  uwe 	 * The transmit ring buffer.
    129  1.1  uwe 	 */
    130  1.1  uwe 	volatile u_int k_tbget;	/* transmit buffer `get' index */
    131  1.1  uwe 	volatile u_int k_tbput;	/* transmit buffer `put' index */
    132  1.1  uwe 	u_char k_tbuf[KBD_TX_RING_SIZE]; /* data */
    133  1.1  uwe 
    134  1.1  uwe 	/*
    135  1.1  uwe 	 * The receive ring buffer.
    136  1.1  uwe 	 */
    137  1.1  uwe 	u_int k_rbget;		/* ring buffer `get' index */
    138  1.1  uwe 	volatile u_int k_rbput; /* ring buffer `put' index */
    139  1.1  uwe 	u_short	k_rbuf[KBD_RX_RING_SIZE]; /* rr1, data pairs */
    140  1.1  uwe };
    141  1.1  uwe 
    142  1.1  uwe /* Middle layer methods exported to the upper layer. */
    143  1.2  uwe extern const struct kbd_ops kbd_ops_sun;
    144  1.1  uwe 
    145  1.2  uwe /* Methods for the lower layer to call. */
    146  1.1  uwe extern void	kbd_sun_input(struct kbd_sun_softc *k, int);
    147  1.1  uwe extern void	kbd_sun_output(struct kbd_sun_softc *k, int c);
    148  1.1  uwe extern void	kbd_sun_start_tx(struct kbd_sun_softc *k);
    149