1 /* $NetBSD: kbdsunvar.h,v 1.6 2008/03/29 19:15:36 tsutsui Exp $ */
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
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.
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.
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * @(#)kbd.c 8.2 (Berkeley) 10/30/93
44 * Keyboard driver - middle layer for sun keyboard off a serial line.
45 * This code is used by kbd_zs and sunkbd (line discipline) drivers.
50 * How many input characters we can buffer.
51 * The port-specific var.h may override this.
52 * Note: must be a power of two!
54 #define KBD_RX_RING_SIZE 256
55 #define KBD_RX_RING_MASK (KBD_RX_RING_SIZE - 1)
58 * Output buffer. Only need a few chars.
60 #define KBD_TX_RING_SIZE 16
61 #define KBD_TX_RING_MASK (KBD_TX_RING_SIZE - 1)
64 * Keyboard serial line speed defaults to 1200 bps.
66 #define KBD_DEFAULT_BPS 1200
68 #define KBD_RESET_TIMO 1000 /* mS. */
71 struct kbd_sun_softc
{
72 /* upper layer (also inherits device_t) */
73 struct kbd_softc k_kbd
;
77 struct zs_chanstate
*ku_cs
;
79 #define k_priv k_u.ku_priv
80 #define k_cs k_u.ku_cs
83 * The deviopen and deviclose routines are provided by the
84 * underlying lower level driver and used as a back door when
85 * opening and closing the internal device.
87 int (*k_deviopen
)(device_t
, int);
88 int (*k_deviclose
)(device_t
, int);
91 * Callback provided by the lower layer (actual device driver).
92 * Middle layer uses it to send commands to sun keyboard.
94 void (*k_write_data
)(struct kbd_sun_softc
*, int);
96 /* Was initialized once. */
100 * Magic sequence stuff (Stop-A, aka L1-A).
101 * XXX: convert to cnmagic(9).
104 u_char k_magic1
; /* L1 */
105 u_char k_magic2
; /* A */
107 /* Expecting ID or layout byte from keyboard */
109 #define KBD_EXPECT_IDCODE 1
110 #define KBD_EXPECT_LAYOUT 2
112 /* Flags to communicate with kbd_softint() */
113 volatile int k_intr_flags
;
114 #define INTR_RX_OVERRUN 1
115 #define INTR_TX_EMPTY 2
116 #define INTR_ST_CHECK 4
119 volatile int k_txflags
;
124 * The transmit ring buffer.
126 volatile u_int k_tbget
; /* transmit buffer `get' index */
127 volatile u_int k_tbput
; /* transmit buffer `put' index */
128 u_char k_tbuf
[KBD_TX_RING_SIZE
]; /* data */
131 * The receive ring buffer.
133 u_int k_rbget
; /* ring buffer `get' index */
134 volatile u_int k_rbput
; /* ring buffer `put' index */
135 u_short k_rbuf
[KBD_RX_RING_SIZE
]; /* rr1, data pairs */
138 /* Middle layer methods exported to the upper layer. */
139 extern const struct kbd_ops kbd_ops_sun
;
141 /* Methods for the lower layer to call. */
142 extern int kbd_sun_input(struct kbd_sun_softc
*k
, int);
143 extern void kbd_sun_output(struct kbd_sun_softc
*k
, int c
);
144 extern void kbd_sun_start_tx(struct kbd_sun_softc
*k
);