dl.c revision 1.26 1 1.26 jdolecek /* $NetBSD: dl.c,v 1.26 2002/10/23 09:13:36 jdolecek Exp $ */
2 1.2 thorpej
3 1.2 thorpej /*-
4 1.2 thorpej * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
5 1.2 thorpej * All rights reserved.
6 1.2 thorpej *
7 1.2 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.2 thorpej * by Jason R. Thorpe.
9 1.2 thorpej *
10 1.2 thorpej * Redistribution and use in source and binary forms, with or without
11 1.2 thorpej * modification, are permitted provided that the following conditions
12 1.2 thorpej * are met:
13 1.2 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.2 thorpej * notice, this list of conditions and the following disclaimer.
15 1.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.2 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.2 thorpej * documentation and/or other materials provided with the distribution.
18 1.2 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.2 thorpej * must display the following acknowledgement:
20 1.2 thorpej * This product includes software developed by the NetBSD
21 1.2 thorpej * Foundation, Inc. and its contributors.
22 1.2 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.2 thorpej * contributors may be used to endorse or promote products derived
24 1.2 thorpej * from this software without specific prior written permission.
25 1.2 thorpej *
26 1.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.2 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.2 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.2 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
37 1.2 thorpej */
38 1.2 thorpej
39 1.1 ragge /*
40 1.1 ragge * Copyright (c) 1997 Ben Harris. All rights reserved.
41 1.1 ragge * Copyright (c) 1996 Ken C. Wellsch. All rights reserved.
42 1.1 ragge * Copyright (c) 1982, 1986, 1990, 1992, 1993
43 1.1 ragge * The Regents of the University of California. All rights reserved.
44 1.1 ragge *
45 1.1 ragge * This code is derived from software contributed to Berkeley by
46 1.1 ragge * Ralph Campbell and Rick Macklem.
47 1.1 ragge *
48 1.1 ragge * Redistribution and use in source and binary forms, with or without
49 1.1 ragge * modification, are permitted provided that the following conditions
50 1.1 ragge * are met:
51 1.1 ragge * 1. Redistributions of source code must retain the above copyright
52 1.1 ragge * notice, this list of conditions and the following disclaimer.
53 1.1 ragge * 2. Redistributions in binary form must reproduce the above copyright
54 1.1 ragge * notice, this list of conditions and the following disclaimer in the
55 1.1 ragge * documentation and/or other materials provided with the distribution.
56 1.1 ragge * 3. All advertising materials mentioning features or use of this software
57 1.1 ragge * must display the following acknowledgement:
58 1.1 ragge * This product includes software developed by the University of
59 1.1 ragge * California, Berkeley and its contributors.
60 1.1 ragge * 4. Neither the name of the University nor the names of its contributors
61 1.1 ragge * may be used to endorse or promote products derived from this software
62 1.1 ragge * without specific prior written permission.
63 1.1 ragge *
64 1.1 ragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
65 1.1 ragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
66 1.1 ragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
67 1.1 ragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
68 1.1 ragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
69 1.1 ragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
70 1.1 ragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
71 1.1 ragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
72 1.1 ragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
73 1.1 ragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
74 1.1 ragge * SUCH DAMAGE.
75 1.1 ragge */
76 1.1 ragge
77 1.1 ragge /*
78 1.1 ragge * dl.c -- Device driver for the DL11 and DLV11 serial cards.
79 1.1 ragge *
80 1.1 ragge * OS-interface code derived from the dz and dca (hp300) drivers.
81 1.1 ragge */
82 1.19 lukem
83 1.19 lukem #include <sys/cdefs.h>
84 1.26 jdolecek __KERNEL_RCSID(0, "$NetBSD: dl.c,v 1.26 2002/10/23 09:13:36 jdolecek Exp $");
85 1.1 ragge
86 1.1 ragge #include <sys/param.h>
87 1.1 ragge #include <sys/systm.h>
88 1.1 ragge #include <sys/ioctl.h>
89 1.1 ragge #include <sys/tty.h>
90 1.1 ragge #include <sys/proc.h>
91 1.1 ragge #include <sys/buf.h>
92 1.1 ragge #include <sys/conf.h>
93 1.1 ragge #include <sys/file.h>
94 1.1 ragge #include <sys/uio.h>
95 1.1 ragge #include <sys/kernel.h>
96 1.1 ragge #include <sys/syslog.h>
97 1.1 ragge #include <sys/device.h>
98 1.1 ragge
99 1.7 ragge #include <machine/bus.h>
100 1.1 ragge
101 1.10 ragge #include <dev/qbus/ubavar.h>
102 1.1 ragge
103 1.10 ragge #include <dev/qbus/dlreg.h>
104 1.1 ragge
105 1.7 ragge #include "ioconf.h"
106 1.1 ragge
107 1.1 ragge struct dl_softc {
108 1.1 ragge struct device sc_dev;
109 1.13 matt struct evcnt sc_rintrcnt;
110 1.13 matt struct evcnt sc_tintrcnt;
111 1.7 ragge bus_space_tag_t sc_iot;
112 1.7 ragge bus_space_handle_t sc_ioh;
113 1.7 ragge struct tty *sc_tty;
114 1.1 ragge };
115 1.1 ragge
116 1.13 matt static int dl_match (struct device *, struct cfdata *, void *);
117 1.13 matt static void dl_attach (struct device *, struct device *, void *);
118 1.13 matt static void dlrint (void *);
119 1.13 matt static void dlxint (void *);
120 1.13 matt static void dlstart (struct tty *);
121 1.13 matt static int dlparam (struct tty *, struct termios *);
122 1.13 matt static void dlbrk (struct dl_softc *, int);
123 1.1 ragge
124 1.24 thorpej CFATTACH_DECL(dl, sizeof(struct dl_softc),
125 1.25 thorpej dl_match, dl_attach, NULL, NULL);
126 1.21 gehenna
127 1.21 gehenna dev_type_open(dlopen);
128 1.21 gehenna dev_type_close(dlclose);
129 1.21 gehenna dev_type_read(dlread);
130 1.21 gehenna dev_type_write(dlwrite);
131 1.21 gehenna dev_type_ioctl(dlioctl);
132 1.21 gehenna dev_type_stop(dlstop);
133 1.21 gehenna dev_type_tty(dltty);
134 1.21 gehenna dev_type_poll(dlpoll);
135 1.21 gehenna
136 1.21 gehenna const struct cdevsw dl_cdevsw = {
137 1.21 gehenna dlopen, dlclose, dlread, dlwrite, dlioctl,
138 1.26 jdolecek dlstop, dltty, dlpoll, nommap, ttykqfilter, D_TTY
139 1.1 ragge };
140 1.3 thorpej
141 1.7 ragge #define DL_READ_WORD(reg) \
142 1.7 ragge bus_space_read_2(sc->sc_iot, sc->sc_ioh, reg)
143 1.7 ragge #define DL_WRITE_WORD(reg, val) \
144 1.7 ragge bus_space_write_2(sc->sc_iot, sc->sc_ioh, reg, val)
145 1.7 ragge #define DL_WRITE_BYTE(reg, val) \
146 1.7 ragge bus_space_write_1(sc->sc_iot, sc->sc_ioh, reg, val)
147 1.1 ragge
148 1.1 ragge /* Autoconfig handles: setup the controller to interrupt, */
149 1.1 ragge /* then complete the housecleaning for full operation */
150 1.1 ragge
151 1.1 ragge static int
152 1.14 matt dl_match (struct device *parent, struct cfdata *cf, void *aux)
153 1.1 ragge {
154 1.1 ragge struct uba_attach_args *ua = aux;
155 1.1 ragge
156 1.1 ragge #ifdef DL_DEBUG
157 1.7 ragge printf("Probing for dl at %lo ... ", (long)ua->ua_iaddr);
158 1.1 ragge #endif
159 1.1 ragge
160 1.7 ragge bus_space_write_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR, DL_XCSR_TXIE);
161 1.7 ragge if (bus_space_read_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR) !=
162 1.7 ragge (DL_XCSR_TXIE | DL_XCSR_TX_READY)) {
163 1.1 ragge #ifdef DL_DEBUG
164 1.7 ragge printf("failed (step 1; XCSR = %.4b)\n",
165 1.7 ragge bus_space_read_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR),
166 1.7 ragge DL_XCSR_BITS);
167 1.1 ragge #endif
168 1.1 ragge return 0;
169 1.1 ragge }
170 1.1 ragge
171 1.1 ragge /*
172 1.1 ragge * We have to force an interrupt so the uba driver can work
173 1.1 ragge * out where we are. Unfortunately, the only way to make a
174 1.1 ragge * DL11 interrupt is to get it to send or receive a
175 1.1 ragge * character. We'll send a NUL and hope it doesn't hurt
176 1.1 ragge * anything.
177 1.1 ragge */
178 1.1 ragge
179 1.7 ragge bus_space_write_1(ua->ua_iot, ua->ua_ioh, DL_UBA_XBUFL, '\0');
180 1.1 ragge #if 0 /* This test seems to fail 2/3 of the time :-( */
181 1.1 ragge if (dladdr->dl_xcsr != (DL_XCSR_TXIE)) {
182 1.1 ragge #ifdef DL_DEBUG
183 1.1 ragge printf("failed (step 2; XCSR = %.4b)\n", dladdr->dl_xcsr,
184 1.1 ragge DL_XCSR_BITS);
185 1.1 ragge #endif
186 1.1 ragge return 0;
187 1.1 ragge }
188 1.1 ragge #endif
189 1.1 ragge DELAY(100000); /* delay 1/10 s for character to transmit */
190 1.7 ragge if (bus_space_read_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR) !=
191 1.7 ragge (DL_XCSR_TXIE | DL_XCSR_TX_READY)) {
192 1.1 ragge #ifdef DL_DEBUG
193 1.7 ragge printf("failed (step 3; XCSR = %.4b)\n",
194 1.7 ragge bus_space_read_2(ua->ua_iot, ua->ua_ioh, DL_UBA_XCSR),
195 1.7 ragge DL_XCSR_BITS);
196 1.1 ragge #endif
197 1.1 ragge return 0;
198 1.1 ragge }
199 1.1 ragge
200 1.1 ragge
201 1.1 ragge /* What else do I need to do? */
202 1.1 ragge
203 1.1 ragge return 1;
204 1.1 ragge
205 1.1 ragge }
206 1.1 ragge
207 1.1 ragge static void
208 1.14 matt dl_attach (struct device *parent, struct device *self, void *aux)
209 1.1 ragge {
210 1.1 ragge struct dl_softc *sc = (void *)self;
211 1.12 augustss struct uba_attach_args *ua = aux;
212 1.1 ragge
213 1.7 ragge sc->sc_iot = ua->ua_iot;
214 1.7 ragge sc->sc_ioh = ua->ua_ioh;
215 1.1 ragge
216 1.1 ragge /* Tidy up the device */
217 1.1 ragge
218 1.7 ragge DL_WRITE_WORD(DL_UBA_RCSR, DL_RCSR_RXIE);
219 1.7 ragge DL_WRITE_WORD(DL_UBA_XCSR, DL_XCSR_TXIE);
220 1.1 ragge
221 1.1 ragge /* Initialize our softc structure. Should be done in open? */
222 1.1 ragge
223 1.1 ragge sc->sc_tty = ttymalloc();
224 1.1 ragge tty_attach(sc->sc_tty);
225 1.1 ragge
226 1.11 matt /* Now register the TX & RX interrupt handlers */
227 1.13 matt uba_intr_establish(ua->ua_icookie, ua->ua_cvec,
228 1.13 matt dlxint, sc, &sc->sc_tintrcnt);
229 1.13 matt uba_intr_establish(ua->ua_icookie, ua->ua_cvec - 4,
230 1.13 matt dlrint, sc, &sc->sc_rintrcnt);
231 1.14 matt evcnt_attach_dynamic(&sc->sc_rintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt,
232 1.14 matt sc->sc_dev.dv_xname, "rintr");
233 1.14 matt evcnt_attach_dynamic(&sc->sc_tintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt,
234 1.14 matt sc->sc_dev.dv_xname, "tintr");
235 1.1 ragge
236 1.1 ragge printf("\n");
237 1.1 ragge }
238 1.1 ragge
239 1.1 ragge /* Receiver Interrupt Handler */
240 1.1 ragge
241 1.1 ragge static void
242 1.14 matt dlrint(void *arg)
243 1.1 ragge {
244 1.14 matt struct dl_softc *sc = arg;
245 1.1 ragge
246 1.7 ragge if (DL_READ_WORD(DL_UBA_RCSR) & DL_RCSR_RX_DONE) {
247 1.14 matt struct tty *tp = sc->sc_tty;
248 1.14 matt unsigned c;
249 1.14 matt int cc;
250 1.14 matt
251 1.7 ragge c = DL_READ_WORD(DL_UBA_RBUF);
252 1.1 ragge cc = c & 0xFF;
253 1.1 ragge
254 1.1 ragge if (!(tp->t_state & TS_ISOPEN)) {
255 1.1 ragge wakeup((caddr_t)&tp->t_rawq);
256 1.1 ragge return;
257 1.1 ragge }
258 1.1 ragge
259 1.14 matt if (c & DL_RBUF_OVERRUN_ERR) {
260 1.1 ragge /*
261 1.1 ragge * XXX: This should really be logged somwhere
262 1.1 ragge * else where we can afford the time.
263 1.1 ragge */
264 1.1 ragge log(LOG_WARNING, "%s: rx overrun\n",
265 1.1 ragge sc->sc_dev.dv_xname);
266 1.14 matt }
267 1.1 ragge if (c & DL_RBUF_FRAMING_ERR)
268 1.1 ragge cc |= TTY_FE;
269 1.1 ragge if (c & DL_RBUF_PARITY_ERR)
270 1.1 ragge cc |= TTY_PE;
271 1.1 ragge
272 1.15 eeh (*tp->t_linesw->l_rint)(cc, tp);
273 1.14 matt #if defined(DIAGNOSTIC)
274 1.14 matt } else {
275 1.1 ragge log(LOG_WARNING, "%s: stray rx interrupt\n",
276 1.1 ragge sc->sc_dev.dv_xname);
277 1.14 matt #endif
278 1.14 matt }
279 1.1 ragge }
280 1.1 ragge
281 1.1 ragge /* Transmitter Interrupt Handler */
282 1.1 ragge
283 1.1 ragge static void
284 1.14 matt dlxint(void *arg)
285 1.1 ragge {
286 1.11 matt struct dl_softc *sc = arg;
287 1.14 matt struct tty *tp = sc->sc_tty;
288 1.14 matt
289 1.1 ragge tp->t_state &= ~(TS_BUSY | TS_FLUSH);
290 1.16 enami (*tp->t_linesw->l_start)(tp);
291 1.1 ragge
292 1.1 ragge return;
293 1.1 ragge }
294 1.1 ragge
295 1.1 ragge int
296 1.14 matt dlopen(dev_t dev, int flag, int mode, struct proc *p)
297 1.1 ragge {
298 1.12 augustss struct tty *tp;
299 1.14 matt struct dl_softc *sc;
300 1.12 augustss int unit;
301 1.1 ragge
302 1.7 ragge unit = minor(dev);
303 1.1 ragge
304 1.1 ragge if (unit >= dl_cd.cd_ndevs || dl_cd.cd_devs[unit] == NULL)
305 1.1 ragge return ENXIO;
306 1.1 ragge sc = dl_cd.cd_devs[unit];
307 1.1 ragge
308 1.1 ragge tp = sc->sc_tty;
309 1.1 ragge if (tp == NULL)
310 1.1 ragge return ENODEV;
311 1.1 ragge tp->t_oproc = dlstart;
312 1.1 ragge tp->t_param = dlparam;
313 1.1 ragge tp->t_dev = dev;
314 1.1 ragge
315 1.1 ragge if (!(tp->t_state & TS_ISOPEN)) {
316 1.1 ragge ttychars(tp);
317 1.1 ragge tp->t_iflag = TTYDEF_IFLAG;
318 1.1 ragge tp->t_oflag = TTYDEF_OFLAG;
319 1.1 ragge /* No modem control, so set CLOCAL. */
320 1.1 ragge tp->t_cflag = TTYDEF_CFLAG | CLOCAL;
321 1.1 ragge tp->t_lflag = TTYDEF_LFLAG;
322 1.1 ragge tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
323 1.1 ragge
324 1.1 ragge dlparam(tp, &tp->t_termios);
325 1.1 ragge ttsetwater(tp);
326 1.1 ragge
327 1.1 ragge } else if ((tp->t_state & TS_XCLUDE) && p->p_ucred->cr_uid != 0)
328 1.1 ragge return EBUSY;
329 1.1 ragge
330 1.15 eeh return ((*tp->t_linesw->l_open)(dev, tp));
331 1.1 ragge }
332 1.1 ragge
333 1.1 ragge /*ARGSUSED*/
334 1.1 ragge int
335 1.14 matt dlclose(dev_t dev, int flag, int mode, struct proc *p)
336 1.1 ragge {
337 1.14 matt struct dl_softc *sc = dl_cd.cd_devs[minor(dev)];
338 1.14 matt struct tty *tp = sc->sc_tty;
339 1.1 ragge
340 1.15 eeh (*tp->t_linesw->l_close)(tp, flag);
341 1.1 ragge
342 1.1 ragge /* Make sure a BREAK state is not left enabled. */
343 1.1 ragge dlbrk(sc, 0);
344 1.1 ragge
345 1.1 ragge return (ttyclose(tp));
346 1.1 ragge }
347 1.1 ragge
348 1.1 ragge int
349 1.14 matt dlread(dev_t dev, struct uio *uio, int flag)
350 1.1 ragge {
351 1.14 matt struct dl_softc *sc = dl_cd.cd_devs[minor(dev)];
352 1.14 matt struct tty *tp = sc->sc_tty;
353 1.1 ragge
354 1.15 eeh return ((*tp->t_linesw->l_read)(tp, uio, flag));
355 1.1 ragge }
356 1.1 ragge
357 1.1 ragge int
358 1.14 matt dlwrite(dev_t dev, struct uio *uio, int flag)
359 1.1 ragge {
360 1.14 matt struct dl_softc *sc = dl_cd.cd_devs[minor(dev)];
361 1.14 matt struct tty *tp = sc->sc_tty;
362 1.1 ragge
363 1.15 eeh return ((*tp->t_linesw->l_write)(tp, uio, flag));
364 1.17 scw }
365 1.17 scw
366 1.17 scw int
367 1.18 ragge dlpoll(dev_t dev, int events, struct proc *p)
368 1.17 scw {
369 1.17 scw struct dl_softc *sc = dl_cd.cd_devs[minor(dev)];
370 1.17 scw struct tty *tp = sc->sc_tty;
371 1.17 scw
372 1.17 scw return ((*tp->t_linesw->l_poll)(tp, events, p));
373 1.1 ragge }
374 1.1 ragge
375 1.1 ragge int
376 1.14 matt dlioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, struct proc *p)
377 1.1 ragge {
378 1.14 matt struct dl_softc *sc = dl_cd.cd_devs[minor(dev)];
379 1.14 matt struct tty *tp = sc->sc_tty;
380 1.1 ragge int error;
381 1.1 ragge
382 1.1 ragge
383 1.15 eeh error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, p);
384 1.20 atatat if (error != EPASSTHROUGH)
385 1.1 ragge return (error);
386 1.20 atatat
387 1.1 ragge error = ttioctl(tp, cmd, data, flag, p);
388 1.20 atatat if (error != EPASSTHROUGH)
389 1.1 ragge return (error);
390 1.1 ragge
391 1.1 ragge switch (cmd) {
392 1.1 ragge
393 1.1 ragge case TIOCSBRK:
394 1.1 ragge dlbrk(sc, 1);
395 1.1 ragge break;
396 1.1 ragge
397 1.1 ragge case TIOCCBRK:
398 1.1 ragge dlbrk(sc, 0);
399 1.1 ragge break;
400 1.1 ragge
401 1.1 ragge case TIOCMGET:
402 1.1 ragge /* No modem control, assume they're all low. */
403 1.1 ragge *(int *)data = 0;
404 1.1 ragge break;
405 1.1 ragge
406 1.1 ragge default:
407 1.20 atatat return (EPASSTHROUGH);
408 1.1 ragge }
409 1.1 ragge return (0);
410 1.1 ragge }
411 1.1 ragge
412 1.1 ragge struct tty *
413 1.14 matt dltty(dev_t dev)
414 1.1 ragge {
415 1.14 matt struct dl_softc *sc = dl_cd.cd_devs[minor(dev)];
416 1.14 matt
417 1.1 ragge return sc->sc_tty;
418 1.1 ragge }
419 1.1 ragge
420 1.1 ragge void
421 1.14 matt dlstop(struct tty *tp, int flag)
422 1.1 ragge {
423 1.14 matt int s = spltty();
424 1.1 ragge
425 1.14 matt if ((tp->t_state & (TS_BUSY|TS_TTSTOP)) == TS_BUSY)
426 1.14 matt tp->t_state |= TS_FLUSH;
427 1.1 ragge splx(s);
428 1.1 ragge }
429 1.1 ragge
430 1.1 ragge static void
431 1.14 matt dlstart(struct tty *tp)
432 1.1 ragge {
433 1.14 matt struct dl_softc *sc = dl_cd.cd_devs[minor(tp->t_dev)];
434 1.14 matt int s = spltty();
435 1.1 ragge
436 1.1 ragge if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
437 1.1 ragge goto out;
438 1.1 ragge if (tp->t_outq.c_cc <= tp->t_lowat) {
439 1.1 ragge if (tp->t_state & TS_ASLEEP) {
440 1.1 ragge tp->t_state &= ~TS_ASLEEP;
441 1.1 ragge wakeup((caddr_t)&tp->t_outq);
442 1.1 ragge }
443 1.1 ragge selwakeup(&tp->t_wsel);
444 1.1 ragge }
445 1.1 ragge if (tp->t_outq.c_cc == 0)
446 1.1 ragge goto out;
447 1.1 ragge
448 1.1 ragge
449 1.7 ragge if (DL_READ_WORD(DL_UBA_XCSR) & DL_XCSR_TX_READY) {
450 1.1 ragge tp->t_state |= TS_BUSY;
451 1.7 ragge DL_WRITE_BYTE(DL_UBA_XBUFL, getc(&tp->t_outq));
452 1.1 ragge }
453 1.1 ragge out:
454 1.1 ragge splx(s);
455 1.1 ragge return;
456 1.1 ragge }
457 1.1 ragge
458 1.1 ragge /*ARGSUSED*/
459 1.1 ragge static int
460 1.14 matt dlparam(struct tty *tp, struct termios *t)
461 1.1 ragge {
462 1.1 ragge /*
463 1.1 ragge * All this kind of stuff (speed, character format, whatever)
464 1.1 ragge * is set by jumpers on the card. Changing it is thus rather
465 1.1 ragge * tricky for a mere device driver.
466 1.1 ragge */
467 1.1 ragge return 0;
468 1.1 ragge }
469 1.1 ragge
470 1.1 ragge static void
471 1.14 matt dlbrk(struct dl_softc *sc, int state)
472 1.1 ragge {
473 1.7 ragge int s = spltty();
474 1.7 ragge
475 1.7 ragge if (state) {
476 1.7 ragge DL_WRITE_WORD(DL_UBA_XCSR, DL_READ_WORD(DL_UBA_XCSR) |
477 1.7 ragge DL_XCSR_TX_BREAK);
478 1.7 ragge } else {
479 1.7 ragge DL_WRITE_WORD(DL_UBA_XCSR, DL_READ_WORD(DL_UBA_XCSR) &
480 1.7 ragge ~DL_XCSR_TX_BREAK);
481 1.7 ragge }
482 1.1 ragge splx(s);
483 1.1 ragge }
484