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