| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: siotty.c,v 1.33 2011/11/26 04:40:50 tsutsui Exp $ */ | | 1 | /* $NetBSD: siotty.c,v 1.33.4.1 2014/01/12 12:21:16 bouyer Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Tohru Nishimura. | | 8 | * by Tohru Nishimura. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -21,225 +21,368 @@ | | | @@ -21,225 +21,368 @@ |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | | 32 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ |
33 | | | 33 | |
34 | __KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.33 2011/11/26 04:40:50 tsutsui Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.33.4.1 2014/01/12 12:21:16 bouyer Exp $"); |
35 | | | 35 | |
36 | #include "opt_ddb.h" | | 36 | #include "opt_ddb.h" |
37 | | | 37 | |
38 | #include <sys/param.h> | | 38 | #include <sys/param.h> |
39 | #include <sys/systm.h> | | 39 | #include <sys/systm.h> |
40 | #include <sys/device.h> | | 40 | #include <sys/device.h> |
41 | #include <sys/conf.h> | | 41 | #include <sys/conf.h> |
42 | #include <sys/ioctl.h> | | 42 | #include <sys/ioctl.h> |
43 | #include <sys/proc.h> | | 43 | #include <sys/proc.h> |
44 | #include <sys/tty.h> | | 44 | #include <sys/tty.h> |
45 | #include <sys/uio.h> | | 45 | #include <sys/uio.h> |
46 | #include <sys/callout.h> | | 46 | #include <sys/callout.h> |
47 | #include <sys/fcntl.h> | | 47 | #include <sys/fcntl.h> |
48 | #include <dev/cons.h> | | 48 | #include <dev/cons.h> |
49 | #include <sys/kauth.h> | | 49 | #include <sys/kauth.h> |
| | | 50 | #include <sys/kmem.h> |
50 | | | 51 | |
51 | #include <machine/cpu.h> | | 52 | #include <machine/cpu.h> |
52 | | | 53 | |
53 | #include <luna68k/dev/sioreg.h> | | 54 | #include <luna68k/dev/sioreg.h> |
54 | #include <luna68k/dev/siovar.h> | | 55 | #include <luna68k/dev/siovar.h> |
55 | | | 56 | |
56 | #include "ioconf.h" | | 57 | #include "ioconf.h" |
57 | | | 58 | |
58 | #define TIOCM_BREAK 01000 /* non standard use */ | | 59 | #define TIOCM_BREAK 01000 /* non standard use */ |
59 | | | 60 | |
60 | static const uint8_t ch0_regs[6] = { | | 61 | static const uint8_t ch0_regs[6] = { |
61 | WR0_RSTINT, /* reset E/S interrupt */ | | 62 | WR0_RSTINT, /* reset E/S interrupt */ |
62 | WR1_RXALLS | WR1_TXENBL, /* Rx per char, Tx */ | | 63 | WR1_RXALLS | WR1_TXENBL, /* Rx per char, Tx */ |
63 | 0, /* */ | | 64 | 0, /* */ |
64 | WR3_RX8BIT | WR3_RXENBL, /* Rx */ | | 65 | WR3_RX8BIT | WR3_RXENBL, /* Rx */ |
65 | WR4_BAUD96 | WR4_STOP1, /* Tx/Rx */ | | 66 | WR4_BAUD96 | WR4_STOP1, /* Tx/Rx */ |
66 | WR5_TX8BIT | WR5_TXENBL | WR5_DTR | WR5_RTS, /* Tx */ | | 67 | WR5_TX8BIT | WR5_TXENBL | WR5_DTR | WR5_RTS, /* Tx */ |
67 | }; | | 68 | }; |
68 | | | 69 | |
69 | static const struct speedtab siospeedtab[] = { | | 70 | static const struct speedtab siospeedtab[] = { |
70 | { 2400, WR4_BAUD24, }, | | 71 | { 2400, WR4_BAUD24, }, |
71 | { 4800, WR4_BAUD48, }, | | 72 | { 4800, WR4_BAUD48, }, |
72 | { 9600, WR4_BAUD96, }, | | 73 | { 9600, WR4_BAUD96, }, |
73 | { -1, 0, }, | | 74 | { -1, 0, }, |
74 | }; | | 75 | }; |
75 | | | 76 | |
76 | struct siotty_softc { | | 77 | struct siotty_softc { |
77 | device_t sc_dev; | | 78 | device_t sc_dev; |
78 | struct tty *sc_tty; | | 79 | struct tty *sc_tty; |
79 | struct sioreg *sc_ctl; | | 80 | struct sioreg *sc_ctl; |
80 | u_int sc_flags; | | 81 | u_int sc_flags; |
81 | uint8_t sc_wr[6]; | | 82 | uint8_t sc_wr[6]; |
| | | 83 | void *sc_si; /* software interrupt handler */ |
| | | 84 | u_int sc_hwflags; |
| | | 85 | #define SIOTTY_HW_CONSOLE 0x0001 |
| | | 86 | |
| | | 87 | uint8_t *sc_rbuf; |
| | | 88 | uint8_t *sc_rbufend; |
| | | 89 | uint8_t * volatile sc_rbget; |
| | | 90 | uint8_t * volatile sc_rbput; |
| | | 91 | volatile u_int sc_rbavail; |
| | | 92 | |
| | | 93 | uint8_t *sc_tba; |
| | | 94 | u_int sc_tbc; |
| | | 95 | |
| | | 96 | bool sc_rx_ready; |
| | | 97 | bool sc_tx_busy; |
| | | 98 | bool sc_tx_done; |
82 | }; | | 99 | }; |
83 | | | 100 | |
| | | 101 | #define SIOTTY_RING_SIZE 2048 |
| | | 102 | u_int siotty_rbuf_size = SIOTTY_RING_SIZE; |
| | | 103 | |
| | | 104 | static struct cnm_state siotty_cnm_state; |
| | | 105 | |
84 | #include "siotty.h" | | 106 | #include "siotty.h" |
85 | static void siostart(struct tty *); | | 107 | static void siostart(struct tty *); |
86 | static int sioparam(struct tty *, struct termios *); | | 108 | static int sioparam(struct tty *, struct termios *); |
87 | static void siottyintr(int); | | 109 | static void siottyintr(int); |
| | | 110 | static void siottysoft(void *); |
| | | 111 | static void siotty_rxsoft(struct siotty_softc *, struct tty *); |
| | | 112 | static void siotty_txsoft(struct siotty_softc *, struct tty *); |
88 | static int siomctl(struct siotty_softc *, int, int); | | 113 | static int siomctl(struct siotty_softc *, int, int); |
89 | | | 114 | |
90 | static int siotty_match(device_t, cfdata_t, void *); | | 115 | static int siotty_match(device_t, cfdata_t, void *); |
91 | static void siotty_attach(device_t, device_t, void *); | | 116 | static void siotty_attach(device_t, device_t, void *); |
92 | | | 117 | |
93 | CFATTACH_DECL_NEW(siotty, sizeof(struct siotty_softc), | | 118 | CFATTACH_DECL_NEW(siotty, sizeof(struct siotty_softc), |
94 | siotty_match, siotty_attach, NULL, NULL); | | 119 | siotty_match, siotty_attach, NULL, NULL); |
95 | | | 120 | |
96 | dev_type_open(sioopen); | | 121 | dev_type_open(sioopen); |
97 | dev_type_close(sioclose); | | 122 | dev_type_close(sioclose); |
98 | dev_type_read(sioread); | | 123 | dev_type_read(sioread); |
99 | dev_type_write(siowrite); | | 124 | dev_type_write(siowrite); |
100 | dev_type_ioctl(sioioctl); | | 125 | dev_type_ioctl(sioioctl); |
101 | dev_type_stop(siostop); | | 126 | dev_type_stop(siostop); |
102 | dev_type_tty(siotty); | | 127 | dev_type_tty(siotty); |
103 | dev_type_poll(siopoll); | | 128 | dev_type_poll(siopoll); |
104 | | | 129 | |
105 | const struct cdevsw siotty_cdevsw = { | | 130 | const struct cdevsw siotty_cdevsw = { |
106 | sioopen, sioclose, sioread, siowrite, sioioctl, | | 131 | sioopen, sioclose, sioread, siowrite, sioioctl, |
107 | siostop, siotty, siopoll, nommap, ttykqfilter, D_TTY | | 132 | siostop, siotty, siopoll, nommap, ttykqfilter, D_TTY |
108 | }; | | 133 | }; |
109 | | | 134 | |
110 | static int | | 135 | static int |
111 | siotty_match(device_t parent, cfdata_t cf, void *aux) | | 136 | siotty_match(device_t parent, cfdata_t cf, void *aux) |
112 | { | | 137 | { |
113 | struct sio_attach_args *args = aux; | | 138 | struct sio_attach_args *args = aux; |
114 | | | 139 | |
115 | if (args->channel != 0) /* XXX allow tty on Ch.B XXX */ | | 140 | if (args->channel != 0) /* XXX allow tty on Ch.B XXX */ |
116 | return 0; | | 141 | return 0; |
117 | return 1; | | 142 | return 1; |
118 | } | | 143 | } |
119 | | | 144 | |
120 | static void | | 145 | static void |
121 | siotty_attach(struct device *parent, struct device *self, void *aux) | | 146 | siotty_attach(device_t parent, device_t self, void *aux) |
122 | { | | 147 | { |
123 | struct sio_softc *scp = device_private(parent); | | 148 | struct sio_softc *scp = device_private(parent); |
124 | struct siotty_softc *sc = device_private(self); | | 149 | struct siotty_softc *sc = device_private(self); |
125 | struct sio_attach_args *args = aux; | | 150 | struct sio_attach_args *args = aux; |
| | | 151 | struct tty *tp; |
126 | | | 152 | |
127 | sc->sc_dev = self; | | 153 | sc->sc_dev = self; |
128 | sc->sc_ctl = (struct sioreg *)scp->scp_ctl + args->channel; | | 154 | sc->sc_ctl = (struct sioreg *)scp->scp_ctl + args->channel; |
129 | memcpy(sc->sc_wr, ch0_regs, sizeof(ch0_regs)); | | 155 | memcpy(sc->sc_wr, ch0_regs, sizeof(ch0_regs)); |
130 | scp->scp_intr[args->channel] = siottyintr; | | 156 | scp->scp_intr[args->channel] = siottyintr; |
| | | 157 | if (args->hwflags == 1) |
| | | 158 | sc->sc_hwflags |= SIOTTY_HW_CONSOLE; |
131 | | | 159 | |
132 | if (args->hwflags == 1) { | | 160 | if ((sc->sc_hwflags & SIOTTY_HW_CONSOLE) != 0) { |
133 | aprint_normal(" (console)"); | | 161 | aprint_normal(" (console)"); |
134 | sc->sc_flags = TIOCFLAG_SOFTCAR; | | 162 | sc->sc_flags = TIOCFLAG_SOFTCAR; |
135 | } else { | | 163 | } else { |
136 | setsioreg(sc->sc_ctl, WR0, WR0_CHANRST); | | 164 | setsioreg(sc->sc_ctl, WR0, WR0_CHANRST); |
137 | setsioreg(sc->sc_ctl, WR2A, WR2_VEC86 | WR2_INTR_1); | | 165 | setsioreg(sc->sc_ctl, WR2A, WR2_VEC86 | WR2_INTR_1); |
138 | setsioreg(sc->sc_ctl, WR2B, 0); | | 166 | setsioreg(sc->sc_ctl, WR2B, 0); |
139 | setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]); | | 167 | setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]); |
140 | setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]); | | 168 | setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]); |
141 | setsioreg(sc->sc_ctl, WR3, sc->sc_wr[WR3]); | | 169 | setsioreg(sc->sc_ctl, WR3, sc->sc_wr[WR3]); |
142 | setsioreg(sc->sc_ctl, WR5, sc->sc_wr[WR5]); | | 170 | setsioreg(sc->sc_ctl, WR5, sc->sc_wr[WR5]); |
143 | setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]); | | 171 | setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]); |
144 | } | | 172 | } |
145 | setsioreg(sc->sc_ctl, WR1, sc->sc_wr[WR1]); /* now interrupt driven */ | | 173 | setsioreg(sc->sc_ctl, WR1, sc->sc_wr[WR1]); /* now interrupt driven */ |
146 | | | 174 | |
147 | aprint_normal("\n"); | | 175 | aprint_normal("\n"); |
| | | 176 | |
| | | 177 | sc->sc_rbuf = kmem_alloc(siotty_rbuf_size * 2, KM_NOSLEEP); |
| | | 178 | if (sc->sc_rbuf == NULL) { |
| | | 179 | aprint_error_dev(self, "unable to allocate ring buffer\n"); |
| | | 180 | return; |
| | | 181 | } |
| | | 182 | sc->sc_rbufend = sc->sc_rbuf + (siotty_rbuf_size * 2); |
| | | 183 | sc->sc_rbput = sc->sc_rbget = sc->sc_rbuf; |
| | | 184 | sc->sc_rbavail = siotty_rbuf_size; |
| | | 185 | |
| | | 186 | tp = tty_alloc(); |
| | | 187 | tp->t_oproc = siostart; |
| | | 188 | tp->t_param = sioparam; |
| | | 189 | tp->t_hwiflow = NULL /* XXX siohwiflow XXX */; |
| | | 190 | if ((sc->sc_hwflags & SIOTTY_HW_CONSOLE) != 0) |
| | | 191 | tp->t_dev = cn_tab->cn_dev; |
| | | 192 | sc->sc_tty = tp; |
| | | 193 | |
| | | 194 | tty_attach(tp); |
| | | 195 | |
| | | 196 | sc->sc_si = softint_establish(SOFTINT_SERIAL, siottysoft, sc); |
148 | } | | 197 | } |
149 | | | 198 | |
150 | /*-------------------- low level routine --------------------*/ | | 199 | /*-------------------- low level routine --------------------*/ |
151 | | | 200 | |
152 | static void | | 201 | static void |
153 | siottyintr(int chan) | | 202 | siottyintr(int chan) |
154 | { | | 203 | { |
155 | struct siotty_softc *sc; | | 204 | struct siotty_softc *sc; |
156 | struct sioreg *sio; | | 205 | struct sioreg *sio; |
157 | struct tty *tp; | | 206 | uint8_t *put, *end; |
158 | unsigned int code; | | 207 | uint8_t c; |
159 | int rr; | | 208 | uint16_t rr; |
| | | 209 | int cc; |
160 | | | 210 | |
161 | sc = device_lookup_private(&siotty_cd, chan); | | 211 | sc = device_lookup_private(&siotty_cd, chan); |
162 | if (sc == NULL) | | 212 | if (sc == NULL) |
163 | return; | | 213 | return; |
164 | | | 214 | |
165 | tp = sc->sc_tty; | | 215 | end = sc->sc_rbufend; |
| | | 216 | put = sc->sc_rbput; |
| | | 217 | cc = sc->sc_rbavail; |
| | | 218 | |
166 | sio = sc->sc_ctl; | | 219 | sio = sc->sc_ctl; |
167 | rr = getsiocsr(sio); | | 220 | rr = getsiocsr(sio); |
| | | 221 | if ((rr & RR_BREAK) != 0) { |
| | | 222 | sio->sio_cmd = WR0_RSTINT; |
| | | 223 | cn_check_magic(sc->sc_tty->t_dev, CNC_BREAK, siotty_cnm_state); |
| | | 224 | } |
168 | if (rr & RR_RXRDY) { | | 225 | if (rr & RR_RXRDY) { |
169 | do { | | 226 | do { |
170 | code = sio->sio_data; | | 227 | if (cc > 0) { |
171 | if (rr & (RR_FRAMING | RR_OVERRUN | RR_PARITY)) { | | 228 | c = sio->sio_data; |
172 | sio->sio_cmd = WR0_ERRRST; | | 229 | cn_check_magic(sc->sc_tty->t_dev, c, |
173 | if (sio->sio_stat & RR_FRAMING) | | 230 | siotty_cnm_state); |
174 | code |= TTY_FE; | | 231 | put[0] = c; |
175 | else if (sio->sio_stat & RR_PARITY) | | 232 | put[1] = rr & 0xff; |
176 | code |= TTY_PE; | | 233 | put += 2; |
177 | } | | 234 | if (put >= end) |
178 | if (tp == NULL || (tp->t_state & TS_ISOPEN) == 0) | | 235 | put = sc->sc_rbuf; |
179 | continue; | | 236 | cc--; |
180 | #if 0 && defined(DDB) /* ?!?! fails to resume ?!?! */ | | | |
181 | if ((rr & RR_BREAK) && tp->t_dev == cn_tab->cn_dev) { | | | |
182 | cpu_Debugger(); | | | |
183 | return; | | | |
184 | } | | 237 | } |
185 | #endif | | 238 | if ((rr & (RR_FRAMING | RR_OVERRUN | RR_PARITY)) != 0) |
186 | (*tp->t_linesw->l_rint)(code, tp); | | 239 | sio->sio_cmd = WR0_ERRRST; |
| | | 240 | |
| | | 241 | sc->sc_rbput = put; |
| | | 242 | sc->sc_rbavail = cc; |
| | | 243 | sc->sc_rx_ready = true; |
187 | } while ((rr = getsiocsr(sio)) & RR_RXRDY); | | 244 | } while ((rr = getsiocsr(sio)) & RR_RXRDY); |
188 | } | | 245 | } |
189 | if (rr & RR_TXRDY) { | | 246 | if (rr & RR_TXRDY) { |
190 | sio->sio_cmd = WR0_RSTPEND; | | 247 | sio->sio_cmd = WR0_RSTPEND; |
191 | if (tp != NULL) { | | 248 | if (sc->sc_tbc > 0) { |
192 | tp->t_state &= ~(TS_BUSY|TS_FLUSH); | | 249 | sio->sio_data = *sc->sc_tba; |
193 | (*tp->t_linesw->l_start)(tp); | | 250 | sc->sc_tba++; |
| | | 251 | sc->sc_tbc--; |
| | | 252 | } else { |
| | | 253 | if (sc->sc_tx_busy) { |
| | | 254 | sc->sc_tx_busy = false; |
| | | 255 | sc->sc_tx_done = true; |
| | | 256 | } |
194 | } | | 257 | } |
195 | } | | 258 | } |
| | | 259 | softint_schedule(sc->sc_si); |
| | | 260 | } |
| | | 261 | |
| | | 262 | static void |
| | | 263 | siottysoft(void *arg) |
| | | 264 | { |
| | | 265 | struct siotty_softc *sc; |
| | | 266 | struct tty *tp; |
| | | 267 | |
| | | 268 | sc = arg; |
| | | 269 | tp = sc->sc_tty; |
| | | 270 | |
| | | 271 | if (sc->sc_rx_ready) { |
| | | 272 | sc->sc_rx_ready = false; |
| | | 273 | siotty_rxsoft(sc, tp); |
| | | 274 | } |
| | | 275 | if (sc->sc_tx_done) { |
| | | 276 | sc->sc_tx_done = false; |
| | | 277 | siotty_txsoft(sc, tp); |
| | | 278 | } |
| | | 279 | } |
| | | 280 | |
| | | 281 | static void |
| | | 282 | siotty_rxsoft(struct siotty_softc *sc, struct tty *tp) |
| | | 283 | { |
| | | 284 | uint8_t *get, *end; |
| | | 285 | u_int cc, scc; |
| | | 286 | unsigned int code; |
| | | 287 | uint8_t stat; |
| | | 288 | int s; |
| | | 289 | |
| | | 290 | end = sc->sc_rbufend; |
| | | 291 | get = sc->sc_rbget; |
| | | 292 | scc = cc = siotty_rbuf_size - sc->sc_rbavail; |
| | | 293 | |
| | | 294 | if (cc == siotty_rbuf_size) { |
| | | 295 | printf("%s: rx buffer overflow\n", device_xname(sc->sc_dev)); |
| | | 296 | } |
| | | 297 | |
| | | 298 | while (cc > 0) { |
| | | 299 | code = get[0]; |
| | | 300 | stat = get[1]; |
| | | 301 | if ((stat & RR_FRAMING) != 0) |
| | | 302 | code |= TTY_FE; |
| | | 303 | else if ((stat & RR_PARITY) != 0) |
| | | 304 | code |= TTY_PE; |
| | | 305 | |
| | | 306 | (*tp->t_linesw->l_rint)(code, tp); |
| | | 307 | get += 2; |
| | | 308 | if (get >= end) |
| | | 309 | get = sc->sc_rbuf; |
| | | 310 | cc--; |
| | | 311 | } |
| | | 312 | |
| | | 313 | if (cc != scc) { |
| | | 314 | s = splserial(); |
| | | 315 | sc->sc_rbget = get; |
| | | 316 | sc->sc_rbavail += scc - cc; |
| | | 317 | splx(s); |
| | | 318 | } |
| | | 319 | } |
| | | 320 | |
| | | 321 | static void |
| | | 322 | siotty_txsoft(struct siotty_softc *sc, struct tty *tp) |
| | | 323 | { |
| | | 324 | |
| | | 325 | tp->t_state &= ~TS_BUSY; |
| | | 326 | if ((tp->t_state & TS_FLUSH) != 0) |
| | | 327 | tp->t_state &= ~TS_FLUSH; |
| | | 328 | else |
| | | 329 | ndflush(&tp->t_outq, (int)(sc->sc_tba - tp->t_outq.c_cf)); |
| | | 330 | (*tp->t_linesw->l_start)(tp); |
196 | } | | 331 | } |
197 | | | 332 | |
198 | static void | | 333 | static void |
199 | siostart(struct tty *tp) | | 334 | siostart(struct tty *tp) |
200 | { | | 335 | { |
201 | struct siotty_softc *sc; | | 336 | struct siotty_softc *sc; |
202 | int s, c; | | 337 | int s; |
203 | | | 338 | uint8_t *tba; |
| | | 339 | int tbc; |
| | | 340 | |
204 | sc = device_lookup_private(&siotty_cd, minor(tp->t_dev)); | | 341 | sc = device_lookup_private(&siotty_cd, minor(tp->t_dev)); |
205 | s = splserial(); | | 342 | s = splserial(); |
206 | if (tp->t_state & (TS_BUSY|TS_TIMEOUT|TS_TTSTOP)) | | 343 | if (tp->t_state & (TS_BUSY|TS_TIMEOUT|TS_TTSTOP)) |
207 | goto out; | | 344 | goto out; |
208 | if (!ttypull(tp)) | | 345 | if (!ttypull(tp)) |
209 | goto out; | | 346 | goto out; |
210 | tp->t_state |= TS_BUSY; | | 347 | tp->t_state |= TS_BUSY; |
211 | while (getsiocsr(sc->sc_ctl) & RR_TXRDY) { | | 348 | |
212 | if ((c = getc(&tp->t_outq)) == -1) | | 349 | tba = tp->t_outq.c_cf; |
213 | break; | | 350 | tbc = ndqb(&tp->t_outq, 0); |
214 | sc->sc_ctl->sio_data = c; | | 351 | |
215 | } | | 352 | sc->sc_tba = tba; |
| | | 353 | sc->sc_tbc = tbc; |
| | | 354 | sc->sc_tx_busy = true; |
| | | 355 | |
| | | 356 | sc->sc_ctl->sio_data = *sc->sc_tba; |
| | | 357 | sc->sc_tba++; |
| | | 358 | sc->sc_tbc--; |
216 | out: | | 359 | out: |
217 | splx(s); | | 360 | splx(s); |
218 | } | | 361 | } |
219 | | | 362 | |
220 | void | | 363 | void |
221 | siostop(struct tty *tp, int flag) | | 364 | siostop(struct tty *tp, int flag) |
222 | { | | 365 | { |
223 | int s; | | 366 | int s; |
224 | | | 367 | |
225 | s = splserial(); | | 368 | s = splserial(); |
226 | if (TS_BUSY == (tp->t_state & (TS_BUSY|TS_TTSTOP))) { | | 369 | if (TS_BUSY == (tp->t_state & (TS_BUSY|TS_TTSTOP))) { |
227 | /* | | 370 | /* |
228 | * Device is transmitting; must stop it. | | 371 | * Device is transmitting; must stop it. |
229 | */ | | 372 | */ |
230 | tp->t_state |= TS_FLUSH; | | 373 | tp->t_state |= TS_FLUSH; |
231 | } | | 374 | } |
232 | splx(s); | | 375 | splx(s); |
233 | } | | 376 | } |
234 | | | 377 | |
235 | static int | | 378 | static int |
236 | sioparam(struct tty *tp, struct termios *t) | | 379 | sioparam(struct tty *tp, struct termios *t) |
237 | { | | 380 | { |
238 | struct siotty_softc *sc; | | 381 | struct siotty_softc *sc; |
239 | int wr4, s; | | 382 | int wr4, s; |
240 | | | 383 | |
241 | sc = device_lookup_private(&siotty_cd, minor(tp->t_dev)); | | 384 | sc = device_lookup_private(&siotty_cd, minor(tp->t_dev)); |
242 | if (t->c_ispeed && t->c_ispeed != t->c_ospeed) | | 385 | if (t->c_ispeed && t->c_ispeed != t->c_ospeed) |
243 | return EINVAL; | | 386 | return EINVAL; |
244 | wr4 = ttspeedtab(t->c_ospeed, siospeedtab); | | 387 | wr4 = ttspeedtab(t->c_ospeed, siospeedtab); |
245 | if (wr4 < 0) | | 388 | if (wr4 < 0) |
| @@ -269,42 +412,44 @@ sioparam(struct tty *tp, struct termios | | | @@ -269,42 +412,44 @@ sioparam(struct tty *tp, struct termios |
269 | switch (tp->t_cflag & CSIZE) { | | 412 | switch (tp->t_cflag & CSIZE) { |
270 | case CS7: | | 413 | case CS7: |
271 | sc->sc_wr[WR3] |= WR3_RX7BIT; sc->sc_wr[WR5] |= WR5_TX7BIT; | | 414 | sc->sc_wr[WR3] |= WR3_RX7BIT; sc->sc_wr[WR5] |= WR5_TX7BIT; |
272 | break; | | 415 | break; |
273 | case CS8: | | 416 | case CS8: |
274 | sc->sc_wr[WR3] |= WR3_RX8BIT; sc->sc_wr[WR5] |= WR5_TX8BIT; | | 417 | sc->sc_wr[WR3] |= WR3_RX8BIT; sc->sc_wr[WR5] |= WR5_TX8BIT; |
275 | break; | | 418 | break; |
276 | } | | 419 | } |
277 | if (tp->t_cflag & PARENB) { | | 420 | if (tp->t_cflag & PARENB) { |
278 | wr4 |= WR4_PARENAB; | | 421 | wr4 |= WR4_PARENAB; |
279 | if ((tp->t_cflag & PARODD) == 0) | | 422 | if ((tp->t_cflag & PARODD) == 0) |
280 | wr4 |= WR4_EPARITY; | | 423 | wr4 |= WR4_EPARITY; |
281 | } | | 424 | } |
282 | wr4 |= (tp->t_cflag & CSTOPB) ? WR4_STOP2 : WR4_STOP1; | | 425 | wr4 |= (tp->t_cflag & CSTOPB) ? WR4_STOP2 : WR4_STOP1; |
283 | sc->sc_wr[WR4] = wr4; | | 426 | sc->sc_wr[WR4] = wr4; |
284 | | | 427 | |
285 | s = splserial(); | | 428 | s = splserial(); |
286 | setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]); | | 429 | setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]); |
287 | setsioreg(sc->sc_ctl, WR3, sc->sc_wr[WR3]); | | 430 | setsioreg(sc->sc_ctl, WR3, sc->sc_wr[WR3]); |
288 | setsioreg(sc->sc_ctl, WR5, sc->sc_wr[WR5]); | | 431 | setsioreg(sc->sc_ctl, WR5, sc->sc_wr[WR5]); |
289 | splx(s); | | 432 | splx(s); |
290 | | | 433 | |
291 | return 0; | | 434 | return 0; |
292 | } | | 435 | } |
293 | | | 436 | |
294 | static int | | 437 | static int |
295 | siomctl(struct siotty_softc *sc, int control, int op) | | 438 | siomctl(struct siotty_softc *sc, int control, int op) |
296 | { | | 439 | { |
297 | int val, s, wr5, rr; | | 440 | int val, s; |
| | | 441 | uint8_t wr5; |
| | | 442 | uint16_t rr; |
298 | | | 443 | |
299 | val = 0; | | 444 | val = 0; |
300 | if (control & TIOCM_BREAK) | | 445 | if (control & TIOCM_BREAK) |
301 | val |= WR5_BREAK; | | 446 | val |= WR5_BREAK; |
302 | if (control & TIOCM_DTR) | | 447 | if (control & TIOCM_DTR) |
303 | val |= WR5_DTR; | | 448 | val |= WR5_DTR; |
304 | if (control & TIOCM_RTS) | | 449 | if (control & TIOCM_RTS) |
305 | val |= WR5_RTS; | | 450 | val |= WR5_RTS; |
306 | s = splserial(); | | 451 | s = splserial(); |
307 | wr5 = sc->sc_wr[WR5]; | | 452 | wr5 = sc->sc_wr[WR5]; |
308 | switch (op) { | | 453 | switch (op) { |
309 | case DMSET: | | 454 | case DMSET: |
310 | wr5 &= ~(WR5_BREAK|WR5_DTR|WR5_RTS); | | 455 | wr5 &= ~(WR5_BREAK|WR5_DTR|WR5_RTS); |
| @@ -321,138 +466,139 @@ siomctl(struct siotty_softc *sc, int con | | | @@ -321,138 +466,139 @@ siomctl(struct siotty_softc *sc, int con |
321 | if (wr5 & WR5_DTR) | | 466 | if (wr5 & WR5_DTR) |
322 | val |= TIOCM_DTR; | | 467 | val |= TIOCM_DTR; |
323 | if (wr5 & WR5_RTS) | | 468 | if (wr5 & WR5_RTS) |
324 | val |= TIOCM_RTS; | | 469 | val |= TIOCM_RTS; |
325 | if (rr & RR_CTS) | | 470 | if (rr & RR_CTS) |
326 | val |= TIOCM_CTS; | | 471 | val |= TIOCM_CTS; |
327 | if (rr & RR_DCD) | | 472 | if (rr & RR_DCD) |
328 | val |= TIOCM_CD; | | 473 | val |= TIOCM_CD; |
329 | goto done; | | 474 | goto done; |
330 | } | | 475 | } |
331 | sc->sc_wr[WR5] = wr5; | | 476 | sc->sc_wr[WR5] = wr5; |
332 | setsioreg(sc->sc_ctl, WR5, wr5); | | 477 | setsioreg(sc->sc_ctl, WR5, wr5); |
333 | val = 0; | | 478 | val = 0; |
334 | done: | | 479 | done: |
335 | splx(s); | | 480 | splx(s); |
336 | return val; | | 481 | return val; |
337 | } | | 482 | } |
338 | | | 483 | |
339 | /*-------------------- cdevsw[] interface --------------------*/ | | 484 | /*-------------------- cdevsw[] interface --------------------*/ |
340 | | | 485 | |
341 | int | | 486 | int |
342 | sioopen(dev_t dev, int flag, int mode, struct lwp *l) | | 487 | sioopen(dev_t dev, int flag, int mode, struct lwp *l) |
343 | { | | 488 | { |
344 | struct siotty_softc *sc; | | 489 | struct siotty_softc *sc; |
345 | struct tty *tp; | | 490 | struct tty *tp; |
346 | int error; | | 491 | int error; |
| | | 492 | int s; |
347 | | | 493 | |
348 | sc = device_lookup_private(&siotty_cd, minor(dev)); | | 494 | sc = device_lookup_private(&siotty_cd, minor(dev)); |
349 | if (sc == NULL) | | 495 | if (sc == NULL) |
350 | return ENXIO; | | 496 | return ENXIO; |
351 | if ((tp = sc->sc_tty) == NULL) { | | | |
352 | tp = sc->sc_tty = tty_alloc(); | | | |
353 | tty_attach(tp); | | | |
354 | } | | | |
355 | | | 497 | |
356 | tp->t_oproc = siostart; | | 498 | tp = sc->sc_tty; |
357 | tp->t_param = sioparam; | | | |
358 | tp->t_hwiflow = NULL /* XXX siohwiflow XXX */; | | | |
359 | tp->t_dev = dev; | | | |
360 | | | 499 | |
361 | if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) | | 500 | if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) |
362 | return EBUSY; | | 501 | return EBUSY; |
363 | | | 502 | |
364 | if ((tp->t_state & TS_ISOPEN) == 0 && tp->t_wopen == 0) { | | 503 | if ((tp->t_state & TS_ISOPEN) == 0 && tp->t_wopen == 0) { |
365 | struct termios t; | | 504 | struct termios t; |
366 | | | 505 | |
| | | 506 | tp->t_dev = dev; |
367 | t.c_ispeed = t.c_ospeed = TTYDEF_SPEED; | | 507 | t.c_ispeed = t.c_ospeed = TTYDEF_SPEED; |
368 | t.c_cflag = TTYDEF_CFLAG; | | 508 | t.c_cflag = TTYDEF_CFLAG; |
369 | tp->t_ospeed = 0; /* force register update */ | | 509 | tp->t_ospeed = 0; /* force register update */ |
370 | (void)sioparam(tp, &t); | | 510 | (void)sioparam(tp, &t); |
371 | tp->t_iflag = TTYDEF_IFLAG; | | 511 | tp->t_iflag = TTYDEF_IFLAG; |
372 | tp->t_oflag = TTYDEF_OFLAG; | | 512 | tp->t_oflag = TTYDEF_OFLAG; |
373 | tp->t_lflag = TTYDEF_LFLAG; | | 513 | tp->t_lflag = TTYDEF_LFLAG; |
374 | ttychars(tp); | | 514 | ttychars(tp); |
375 | ttsetwater(tp); | | 515 | ttsetwater(tp); |
376 | /* raise RTS and DTR here; but, DTR lead is not wired */ | | 516 | /* raise RTS and DTR here; but, DTR lead is not wired */ |
377 | /* then check DCD condition; but, DCD lead is not wired */ | | 517 | /* then check DCD condition; but, DCD lead is not wired */ |
378 | tp->t_state |= TS_CARR_ON; /* assume detected all the time */ | | | |
379 | #if 0 | | 518 | #if 0 |
380 | if ((sc->sc_flags & TIOCFLAG_SOFTCAR) | | 519 | if ((sc->sc_flags & TIOCFLAG_SOFTCAR) |
381 | || (tp->t_cflag & MDMBUF) | | 520 | || (tp->t_cflag & MDMBUF) |
382 | || (getsiocsr(sc->sc_ctl) & RR_DCD)) | | 521 | || (getsiocsr(sc->sc_ctl) & RR_DCD)) |
383 | tp->t_state |= TS_CARR_ON; | | 522 | tp->t_state |= TS_CARR_ON; |
384 | else | | 523 | else |
385 | tp->t_state &= ~TS_CARR_ON; | | 524 | tp->t_state &= ~TS_CARR_ON; |
| | | 525 | #else |
| | | 526 | tp->t_state |= TS_CARR_ON; /* assume detected all the time */ |
386 | #endif | | 527 | #endif |
| | | 528 | |
| | | 529 | s = splserial(); |
| | | 530 | sc->sc_rbput = sc->sc_rbget = sc->sc_rbuf; |
| | | 531 | sc->sc_rbavail = siotty_rbuf_size; |
| | | 532 | splx(s); |
387 | } | | 533 | } |
388 | | | 534 | |
389 | error = ttyopen(tp, 0, (flag & O_NONBLOCK)); | | 535 | error = ttyopen(tp, 0, (flag & O_NONBLOCK)); |
390 | if (error > 0) | | 536 | if (error > 0) |
391 | return error; | | 537 | return error; |
392 | return (*tp->t_linesw->l_open)(dev, tp); | | 538 | return (*tp->t_linesw->l_open)(dev, tp); |
393 | } | | 539 | } |
394 | | | 540 | |
395 | int | | 541 | int |
396 | sioclose(dev_t dev, int flag, int mode, struct lwp *l) | | 542 | sioclose(dev_t dev, int flag, int mode, struct lwp *l) |
397 | { | | 543 | { |
398 | struct siotty_softc *sc = device_lookup_private(&siotty_cd,minor(dev)); | | 544 | struct siotty_softc *sc = device_lookup_private(&siotty_cd,minor(dev)); |
399 | struct tty *tp = sc->sc_tty; | | 545 | struct tty *tp = sc->sc_tty; |
400 | int s; | | 546 | int s; |
401 | | | 547 | |
402 | (*tp->t_linesw->l_close)(tp, flag); | | 548 | (*tp->t_linesw->l_close)(tp, flag); |
403 | | | 549 | |
404 | s = splserial(); | | 550 | s = splserial(); |
405 | siomctl(sc, TIOCM_BREAK, DMBIC); | | 551 | siomctl(sc, TIOCM_BREAK, DMBIC); |
406 | #if 0 /* because unable to feed DTR signal */ | | 552 | #if 0 /* because unable to feed DTR signal */ |
407 | if ((tp->t_cflag & HUPCL) | | 553 | if ((tp->t_cflag & HUPCL) |
408 | || tp->t_wopen || (tp->t_state & TS_ISOPEN) == 0) { | | 554 | || tp->t_wopen || (tp->t_state & TS_ISOPEN) == 0) { |
409 | siomctl(sc, TIOCM_DTR, DMBIC); | | 555 | siomctl(sc, TIOCM_DTR, DMBIC); |
410 | /* Yield CPU time to others for 1 second, then ... */ | | 556 | /* Yield CPU time to others for 1 second, then ... */ |
411 | siomctl(sc, TIOCM_DTR, DMBIS); | | 557 | siomctl(sc, TIOCM_DTR, DMBIS); |
412 | } | | 558 | } |
413 | #endif | | 559 | #endif |
414 | splx(s); | | 560 | splx(s); |
415 | return ttyclose(tp); | | 561 | return ttyclose(tp); |
416 | } | | 562 | } |
417 | | | 563 | |
418 | int | | 564 | int |
419 | sioread(dev_t dev, struct uio *uio, int flag) | | 565 | sioread(dev_t dev, struct uio *uio, int flag) |
420 | { | | 566 | { |
421 | struct siotty_softc *sc; | | 567 | struct siotty_softc *sc; |
422 | struct tty *tp; | | 568 | struct tty *tp; |
423 | | | 569 | |
424 | sc = device_lookup_private(&siotty_cd, minor(dev)); | | 570 | sc = device_lookup_private(&siotty_cd, minor(dev)); |
425 | tp = sc->sc_tty; | | 571 | tp = sc->sc_tty; |
426 | return (*tp->t_linesw->l_read)(tp, uio, flag); | | 572 | return (*tp->t_linesw->l_read)(tp, uio, flag); |
427 | } | | 573 | } |
428 | | | 574 | |
429 | int | | 575 | int |
430 | siowrite(dev_t dev, struct uio *uio, int flag) | | 576 | siowrite(dev_t dev, struct uio *uio, int flag) |
431 | { | | 577 | { |
432 | struct siotty_softc *sc; | | 578 | struct siotty_softc *sc; |
433 | struct tty *tp; | | 579 | struct tty *tp; |
434 | | | 580 | |
435 | sc = device_lookup_private(&siotty_cd, minor(dev)); | | 581 | sc = device_lookup_private(&siotty_cd, minor(dev)); |
436 | tp = sc->sc_tty; | | 582 | tp = sc->sc_tty; |
437 | return (*tp->t_linesw->l_write)(tp, uio, flag); | | 583 | return (*tp->t_linesw->l_write)(tp, uio, flag); |
438 | } | | 584 | } |
439 | | | 585 | |
440 | int | | 586 | int |
441 | siopoll(dev_t dev, int events, struct lwp *l) | | 587 | siopoll(dev_t dev, int events, struct lwp *l) |
442 | { | | 588 | { |
443 | struct siotty_softc *sc; | | 589 | struct siotty_softc *sc; |
444 | struct tty *tp; | | 590 | struct tty *tp; |
445 | | | 591 | |
446 | sc = device_lookup_private(&siotty_cd, minor(dev)); | | 592 | sc = device_lookup_private(&siotty_cd, minor(dev)); |
447 | tp = sc->sc_tty; | | 593 | tp = sc->sc_tty; |
448 | return ((*tp->t_linesw->l_poll)(tp, events, l)); | | 594 | return ((*tp->t_linesw->l_poll)(tp, events, l)); |
449 | } | | 595 | } |
450 | | | 596 | |
451 | int | | 597 | int |
452 | sioioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) | | 598 | sioioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) |
453 | { | | 599 | { |
454 | struct siotty_softc *sc; | | 600 | struct siotty_softc *sc; |
455 | struct tty *tp; | | 601 | struct tty *tp; |
456 | int error; | | 602 | int error; |
457 | | | 603 | |
458 | sc = device_lookup_private(&siotty_cd, minor(dev)); | | 604 | sc = device_lookup_private(&siotty_cd, minor(dev)); |
| @@ -498,43 +644,43 @@ sioioctl(dev_t dev, u_long cmd, void *da | | | @@ -498,43 +644,43 @@ sioioctl(dev_t dev, u_long cmd, void *da |
498 | *(int *)data = sc->sc_flags; | | 644 | *(int *)data = sc->sc_flags; |
499 | break; | | 645 | break; |
500 | default: | | 646 | default: |
501 | return EPASSTHROUGH; | | 647 | return EPASSTHROUGH; |
502 | } | | 648 | } |
503 | return 0; | | 649 | return 0; |
504 | } | | 650 | } |
505 | | | 651 | |
506 | /* ARSGUSED */ | | 652 | /* ARSGUSED */ |
507 | struct tty * | | 653 | struct tty * |
508 | siotty(dev_t dev) | | 654 | siotty(dev_t dev) |
509 | { | | 655 | { |
510 | struct siotty_softc *sc; | | 656 | struct siotty_softc *sc; |
511 | | | 657 | |
512 | sc = device_lookup_private(&siotty_cd, minor(dev)); | | 658 | sc = device_lookup_private(&siotty_cd, minor(dev)); |
513 | return sc->sc_tty; | | 659 | return sc->sc_tty; |
514 | } | | 660 | } |
515 | | | 661 | |
516 | /*-------------------- miscelleneous routine --------------------*/ | | 662 | /*-------------------- miscelleneous routine --------------------*/ |
517 | | | 663 | |
518 | /* EXPORT */ void | | 664 | /* EXPORT */ void |
519 | setsioreg(struct sioreg *sio, int regno, int val) | | 665 | setsioreg(struct sioreg *sio, int regno, int val) |
520 | { | | 666 | { |
521 | | | 667 | |
522 | if (regno != 0) | | 668 | if (regno != 0) |
523 | sio->sio_cmd = regno; /* DELAY(); */ | | 669 | sio->sio_cmd = regno; /* DELAY(); */ |
524 | sio->sio_cmd = val; /* DELAY(); */ | | 670 | sio->sio_cmd = val; /* DELAY(); */ |
525 | } | | 671 | } |
526 | | | 672 | |
527 | /* EXPORT */ int | | 673 | /* EXPORT */ uint16_t |
528 | getsiocsr(struct sioreg *sio) | | 674 | getsiocsr(struct sioreg *sio) |
529 | { | | 675 | { |
530 | int val; | | 676 | int val; |
531 | | | 677 | |
532 | val = sio->sio_stat << 8; /* DELAY(); */ | | 678 | val = sio->sio_stat << 8; /* DELAY(); */ |
533 | sio->sio_cmd = 1; /* DELAY(); */ | | 679 | sio->sio_cmd = 1; /* DELAY(); */ |
534 | val |= sio->sio_stat; /* DELAY(); */ | | 680 | val |= sio->sio_stat; /* DELAY(); */ |
535 | return val; | | 681 | return val; |
536 | } | | 682 | } |
537 | | | 683 | |
538 | /*--------------------- console interface ----------------------*/ | | 684 | /*--------------------- console interface ----------------------*/ |
539 | | | 685 | |
540 | void syscnattach(int); | | 686 | void syscnattach(int); |
| @@ -557,26 +703,28 @@ struct consdev syscons = { | | | @@ -557,26 +703,28 @@ struct consdev syscons = { |
557 | /* EXPORT */ void | | 703 | /* EXPORT */ void |
558 | syscnattach(int channel) | | 704 | syscnattach(int channel) |
559 | { | | 705 | { |
560 | /* | | 706 | /* |
561 | * Channel A is immediately initialized with 9600N1 right after cold | | 707 | * Channel A is immediately initialized with 9600N1 right after cold |
562 | * boot/reset/poweron. ROM monitor emits one line message on CH.A. | | 708 | * boot/reset/poweron. ROM monitor emits one line message on CH.A. |
563 | */ | | 709 | */ |
564 | struct sioreg *sio; | | 710 | struct sioreg *sio; |
565 | sio = (struct sioreg *)0x51000000 + channel; | | 711 | sio = (struct sioreg *)0x51000000 + channel; |
566 | | | 712 | |
567 | syscons.cn_dev = makedev(cdevsw_lookup_major(&siotty_cdevsw), | | 713 | syscons.cn_dev = makedev(cdevsw_lookup_major(&siotty_cdevsw), |
568 | channel); | | 714 | channel); |
569 | cn_tab = &syscons; | | 715 | cn_tab = &syscons; |
| | | 716 | cn_init_magic(&siotty_cnm_state); |
| | | 717 | cn_set_magic("\047\001"); |
570 | | | 718 | |
571 | setsioreg(sio, WR0, WR0_CHANRST); | | 719 | setsioreg(sio, WR0, WR0_CHANRST); |
572 | setsioreg(sio, WR2A, WR2_VEC86 | WR2_INTR_1); | | 720 | setsioreg(sio, WR2A, WR2_VEC86 | WR2_INTR_1); |
573 | setsioreg(sio, WR2B, 0); | | 721 | setsioreg(sio, WR2B, 0); |
574 | setsioreg(sio, WR0, ch0_regs[WR0]); | | 722 | setsioreg(sio, WR0, ch0_regs[WR0]); |
575 | setsioreg(sio, WR4, ch0_regs[WR4]); | | 723 | setsioreg(sio, WR4, ch0_regs[WR4]); |
576 | setsioreg(sio, WR3, ch0_regs[WR3]); | | 724 | setsioreg(sio, WR3, ch0_regs[WR3]); |
577 | setsioreg(sio, WR5, ch0_regs[WR5]); | | 725 | setsioreg(sio, WR5, ch0_regs[WR5]); |
578 | setsioreg(sio, WR0, ch0_regs[WR0]); | | 726 | setsioreg(sio, WR0, ch0_regs[WR0]); |
579 | } | | 727 | } |
580 | | | 728 | |
581 | /* EXPORT */ int | | 729 | /* EXPORT */ int |
582 | syscngetc(dev_t dev) | | 730 | syscngetc(dev_t dev) |