ser.c revision 1.5 1 1.1 mw /*
2 1.1 mw * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
3 1.1 mw * All rights reserved.
4 1.1 mw *
5 1.1 mw * Redistribution and use in source and binary forms, with or without
6 1.1 mw * modification, are permitted provided that the following conditions
7 1.1 mw * are met:
8 1.1 mw * 1. Redistributions of source code must retain the above copyright
9 1.1 mw * notice, this list of conditions and the following disclaimer.
10 1.1 mw * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 mw * notice, this list of conditions and the following disclaimer in the
12 1.1 mw * documentation and/or other materials provided with the distribution.
13 1.1 mw * 3. All advertising materials mentioning features or use of this software
14 1.1 mw * must display the following acknowledgement:
15 1.1 mw * This product includes software developed by the University of
16 1.1 mw * California, Berkeley and its contributors.
17 1.1 mw * 4. Neither the name of the University nor the names of its contributors
18 1.1 mw * may be used to endorse or promote products derived from this software
19 1.1 mw * without specific prior written permission.
20 1.1 mw *
21 1.1 mw * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 mw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 mw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 mw * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 mw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 mw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 mw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 mw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 mw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 mw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 mw * SUCH DAMAGE.
32 1.1 mw *
33 1.4 mw * @(#)ser.c 7.12 (Berkeley) 6/27/91
34 1.1 mw */
35 1.1 mw
36 1.1 mw #include "ser.h"
37 1.1 mw
38 1.1 mw #if NSER > 0
39 1.1 mw #include "sys/param.h"
40 1.1 mw #include "sys/systm.h"
41 1.1 mw #include "sys/ioctl.h"
42 1.1 mw #include "sys/tty.h"
43 1.1 mw #include "sys/proc.h"
44 1.1 mw #include "sys/conf.h"
45 1.1 mw #include "sys/file.h"
46 1.1 mw #include "sys/malloc.h"
47 1.1 mw #include "sys/uio.h"
48 1.1 mw #include "sys/kernel.h"
49 1.1 mw #include "sys/syslog.h"
50 1.1 mw
51 1.1 mw #include "device.h"
52 1.1 mw #include "serreg.h"
53 1.1 mw #include "machine/cpu.h"
54 1.1 mw
55 1.1 mw #include "../amiga/custom.h"
56 1.1 mw #include "../amiga/cia.h"
57 1.5 mw #include "../amiga/cc.h"
58 1.1 mw
59 1.1 mw int serprobe();
60 1.1 mw struct driver serdriver = {
61 1.1 mw serprobe, "ser",
62 1.1 mw };
63 1.1 mw
64 1.1 mw int serstart(), serparam(), serintr();
65 1.3 mw extern int ttrstrt();
66 1.1 mw int ser_active;
67 1.1 mw int ser_hasfifo;
68 1.1 mw int nser = NSER;
69 1.1 mw #ifdef SERCONSOLE
70 1.1 mw int serconsole = SERCONSOLE;
71 1.1 mw #else
72 1.1 mw int serconsole = -1;
73 1.1 mw #endif
74 1.1 mw int serconsinit;
75 1.1 mw int serdefaultrate = TTYDEF_SPEED;
76 1.1 mw int sermajor;
77 1.1 mw struct serdevice *ser_addr[NSER];
78 1.5 mw struct vbl_node ser_vbl_node[NSER];
79 1.1 mw struct tty ser_cons;
80 1.3 mw struct tty *ser_tty[NSER];
81 1.1 mw
82 1.1 mw struct speedtab serspeedtab[] = {
83 1.1 mw 0, 0,
84 1.1 mw 50, SERBRD(50),
85 1.1 mw 75, SERBRD(75),
86 1.1 mw 110, SERBRD(110),
87 1.1 mw 134, SERBRD(134),
88 1.1 mw 150, SERBRD(150),
89 1.1 mw 200, SERBRD(200),
90 1.1 mw 300, SERBRD(300),
91 1.1 mw 600, SERBRD(600),
92 1.1 mw 1200, SERBRD(1200),
93 1.1 mw 1800, SERBRD(1800),
94 1.1 mw 2400, SERBRD(2400),
95 1.1 mw 4800, SERBRD(4800),
96 1.1 mw 9600, SERBRD(9600),
97 1.1 mw 19200, SERBRD(19200),
98 1.1 mw 38400, SERBRD(38400),
99 1.1 mw -1, -1
100 1.1 mw };
101 1.1 mw
102 1.1 mw
103 1.1 mw /* since this UART is not particularly bright (nice put), we'll have to do
104 1.1 mw parity stuff on our own. this table contains the 8th bit in 7bit character
105 1.1 mw mode, for even parity. If you want odd parity, flip the bit. (for
106 1.1 mw generation of the table, see genpar.c) */
107 1.1 mw
108 1.1 mw u_char even_parity[] = {
109 1.1 mw 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
110 1.1 mw 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
111 1.1 mw 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
112 1.1 mw 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
113 1.1 mw 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
114 1.1 mw 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
115 1.1 mw 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
116 1.1 mw 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
117 1.1 mw };
118 1.1 mw
119 1.1 mw
120 1.1 mw /* since we don't get interrupts for changes on the modem control line,
121 1.1 mw well have to fake them by comparing current settings to the settings
122 1.1 mw we remembered on last invocation. */
123 1.1 mw u_char last_ciab_pra;
124 1.1 mw
125 1.1 mw extern struct tty *constty;
126 1.1 mw #ifdef KGDB
127 1.1 mw #include "machine/remote-sl.h"
128 1.1 mw
129 1.1 mw extern dev_t kgdb_dev;
130 1.1 mw extern int kgdb_rate;
131 1.1 mw extern int kgdb_debug_init;
132 1.1 mw #endif
133 1.1 mw
134 1.1 mw #ifdef DEBUG
135 1.1 mw long fifoin[17];
136 1.1 mw long fifoout[17];
137 1.1 mw long serintrcount[16];
138 1.1 mw long sermintcount[16];
139 1.1 mw #endif
140 1.1 mw
141 1.5 mw void sermint (register int unit);
142 1.5 mw
143 1.5 mw int
144 1.1 mw serprobe(ad)
145 1.5 mw register struct amiga_device *ad;
146 1.1 mw {
147 1.5 mw register struct serdevice *ser;
148 1.5 mw register int unit;
149 1.5 mw unsigned short ir = custom.intenar;
150 1.5 mw
151 1.5 mw ser = (struct serdevice *) ad->amiga_addr;
152 1.5 mw unit = ad->amiga_unit;
153 1.5 mw if (unit == serconsole)
154 1.5 mw DELAY(100000);
155 1.5 mw
156 1.5 mw ad->amiga_ipl = 2;
157 1.5 mw ser_addr[unit] = ser;
158 1.5 mw ser_active |= 1 << unit;
159 1.5 mw ser_vbl_node[unit].function = sermint;
160 1.5 mw add_vbl_function (&ser_vbl_node[unit], SER_VBL_PRIORITY, (void *)unit);
161 1.1 mw #ifdef KGDB
162 1.5 mw if (kgdb_dev == makedev(sermajor, unit)) {
163 1.5 mw if (serconsole == unit)
164 1.5 mw kgdb_dev = NODEV; /* can't debug over console port */
165 1.5 mw else {
166 1.5 mw (void) serinit(unit, kgdb_rate);
167 1.5 mw serconsinit = 1; /* don't re-init in serputc */
168 1.5 mw if (kgdb_debug_init) {
169 1.1 mw /*
170 1.5 mw * Print prefix of device name,
171 1.5 mw * let kgdb_connect print the rest.
172 1.1 mw */
173 1.5 mw printf("ser%d: ", unit);
174 1.5 mw kgdb_connect(1);
175 1.5 mw } else
176 1.5 mw printf("ser%d: kgdb enabled\n", unit);
177 1.5 mw }
178 1.5 mw }
179 1.5 mw #endif
180 1.5 mw /*
181 1.5 mw * Need to reset baud rate, etc. of next print so reset serconsinit.
182 1.5 mw */
183 1.5 mw if (unit == serconsole)
184 1.5 mw serconsinit = 0;
185 1.5 mw
186 1.5 mw return (1);
187 1.1 mw }
188 1.1 mw
189 1.1 mw /* ARGSUSED */
190 1.5 mw int
191 1.1 mw #ifdef __STDC__
192 1.1 mw seropen(dev_t dev, int flag, int mode, struct proc *p)
193 1.1 mw #else
194 1.1 mw seropen(dev, flag, mode, p)
195 1.5 mw dev_t dev;
196 1.5 mw int flag, mode;
197 1.5 mw struct proc *p;
198 1.1 mw #endif
199 1.1 mw {
200 1.5 mw register struct tty *tp;
201 1.5 mw register int unit;
202 1.5 mw int error = 0;
203 1.5 mw int s;
204 1.5 mw
205 1.5 mw unit = SERUNIT(dev);
206 1.1 mw
207 1.5 mw if (unit >= NSER || (ser_active & (1 << unit)) == 0)
208 1.5 mw return (ENXIO);
209 1.5 mw if(!ser_tty[unit])
210 1.5 mw {
211 1.5 mw tp = ser_tty[unit] = ttymalloc();
212 1.5 mw /* default values are not optimal for this device, increase
213 1.5 mw buffers */
214 1.5 mw clfree(&tp->t_rawq);
215 1.5 mw clfree(&tp->t_canq);
216 1.5 mw clfree(&tp->t_outq);
217 1.5 mw clalloc(&tp->t_rawq, 8192, 1);
218 1.5 mw clalloc(&tp->t_canq, 8192, 1);
219 1.5 mw clalloc(&tp->t_outq, 8192, 0);
220 1.5 mw }
221 1.5 mw else
222 1.5 mw tp = ser_tty[unit];
223 1.1 mw
224 1.5 mw tp->t_oproc = serstart;
225 1.5 mw tp->t_param = serparam;
226 1.5 mw tp->t_dev = dev;
227 1.5 mw
228 1.5 mw if ((tp->t_state & TS_ISOPEN) == 0)
229 1.5 mw {
230 1.5 mw tp->t_state |= TS_WOPEN;
231 1.5 mw ttychars(tp);
232 1.5 mw if (tp->t_ispeed == 0)
233 1.5 mw {
234 1.5 mw tp->t_iflag = TTYDEF_IFLAG | IXOFF; /* XXXXX */
235 1.5 mw tp->t_oflag = TTYDEF_OFLAG;
236 1.1 mw #if 0
237 1.5 mw tp->t_cflag = TTYDEF_CFLAG;
238 1.1 mw #else
239 1.5 mw tp->t_cflag = (CREAD | CS8 | CLOCAL); /* XXXXX */
240 1.1 mw #endif
241 1.5 mw tp->t_lflag = TTYDEF_LFLAG;
242 1.5 mw tp->t_ispeed = tp->t_ospeed = serdefaultrate;
243 1.1 mw }
244 1.5 mw serparam(tp, &tp->t_termios);
245 1.5 mw ttsetwater(tp);
246 1.5 mw }
247 1.5 mw else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
248 1.5 mw return (EBUSY);
249 1.5 mw
250 1.5 mw (void) sermctl (dev, TIOCM_DTR | TIOCM_RTS, DMSET);
251 1.5 mw
252 1.5 mw if (DIALOUT(dev) || (sermctl (dev, 0, DMGET) & TIOCM_CD))
253 1.5 mw tp->t_state |= TS_CARR_ON;
254 1.5 mw
255 1.5 mw s = spltty();
256 1.5 mw while ((flag & O_NONBLOCK) == 0
257 1.5 mw && (tp->t_cflag & CLOCAL) == 0
258 1.5 mw && (tp->t_state & TS_CARR_ON) == 0)
259 1.5 mw {
260 1.5 mw tp->t_state |= TS_WOPEN;
261 1.5 mw if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
262 1.5 mw ttopen, 0))
263 1.5 mw break;
264 1.5 mw }
265 1.5 mw splx (s);
266 1.5 mw if (error == 0)
267 1.5 mw {
268 1.5 mw /* reset the tty pointer, as there could have been a dialout
269 1.5 mw use of the tty with a dialin open waiting. */
270 1.5 mw tp->t_dev = dev;
271 1.5 mw error = (*linesw[tp->t_line].l_open)(dev, tp);
272 1.5 mw }
273 1.5 mw return (error);
274 1.1 mw }
275 1.1 mw
276 1.1 mw /*ARGSUSED*/
277 1.5 mw int
278 1.1 mw serclose(dev, flag, mode, p)
279 1.5 mw dev_t dev;
280 1.5 mw int flag, mode;
281 1.5 mw struct proc *p;
282 1.5 mw {
283 1.5 mw register struct tty *tp;
284 1.5 mw register struct serdevice *ser;
285 1.5 mw register int unit;
286 1.5 mw
287 1.5 mw unit = SERUNIT(dev);
288 1.5 mw
289 1.5 mw ser = ser_addr[unit];
290 1.5 mw tp = ser_tty[unit];
291 1.5 mw (*linesw[tp->t_line].l_close)(tp, flag);
292 1.5 mw custom.adkcon = ADKCONF_UARTBRK; /* clear break */
293 1.1 mw #ifdef KGDB
294 1.5 mw /* do not disable interrupts if debugging */
295 1.5 mw if (dev != kgdb_dev)
296 1.1 mw #endif
297 1.5 mw custom.intena = INTF_RBF|INTF_TBE; /* clear interrupt enable */
298 1.5 mw custom.intreq = INTF_RBF|INTF_TBE; /* and interrupt request */
299 1.1 mw #if 0
300 1.5 mw /* if the device is closed, it's close, no matter whether we deal with modem
301 1.5 mw control signals nor not. */
302 1.5 mw if (tp->t_cflag&HUPCL || tp->t_state&TS_WOPEN ||
303 1.5 mw (tp->t_state&TS_ISOPEN) == 0)
304 1.1 mw #endif
305 1.5 mw (void) sermctl(dev, 0, DMSET);
306 1.5 mw ttyclose(tp);
307 1.1 mw #if 0
308 1.5 mw if (tp != &ser_cons)
309 1.5 mw {
310 1.5 mw remove_vbl_function (&ser_vbl_node[unit]);
311 1.5 mw ttyfree (tp);
312 1.5 mw ser_tty[unit] = (struct tty *)NULL;
313 1.5 mw }
314 1.3 mw #endif
315 1.5 mw return (0);
316 1.1 mw }
317 1.1 mw
318 1.5 mw int
319 1.1 mw serread(dev, uio, flag)
320 1.5 mw dev_t dev;
321 1.5 mw struct uio *uio;
322 1.1 mw {
323 1.5 mw register struct tty *tp = ser_tty[SERUNIT(dev)];
324 1.5 mw int error;
325 1.3 mw
326 1.5 mw if (! tp)
327 1.5 mw return ENXIO;
328 1.1 mw
329 1.5 mw error = (*linesw[tp->t_line].l_read)(tp, uio, flag);
330 1.5 mw
331 1.5 mw return error;
332 1.1 mw }
333 1.1 mw
334 1.5 mw int
335 1.1 mw serwrite(dev, uio, flag)
336 1.5 mw dev_t dev;
337 1.5 mw struct uio *uio;
338 1.1 mw {
339 1.5 mw int unit = SERUNIT(dev);
340 1.5 mw register struct tty *tp = ser_tty[unit];
341 1.1 mw
342 1.5 mw if (! tp)
343 1.5 mw return ENXIO;
344 1.3 mw
345 1.5 mw /*
346 1.5 mw * (XXX) We disallow virtual consoles if the physical console is
347 1.5 mw * a serial port. This is in case there is a display attached that
348 1.5 mw * is not the console. In that situation we don't need/want the X
349 1.5 mw * server taking over the console.
350 1.5 mw */
351 1.5 mw if (constty && unit == serconsole)
352 1.5 mw constty = NULL;
353 1.5 mw return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
354 1.1 mw }
355 1.3 mw
356 1.3 mw
357 1.3 mw /* don't do any processing of data here, so we store the raw code
358 1.5 mw obtained from the uart register. In theory, 110kBaud gives you
359 1.3 mw 11kcps, so 16k buffer should be more than enough, interrupt
360 1.3 mw latency of 1s should never happen, or something is seriously
361 1.3 mw wrong.. */
362 1.5 mw #define SERIBUF_SIZE 16384
363 1.3 mw static u_short serbuf[SERIBUF_SIZE];
364 1.3 mw static u_short *sbrpt = serbuf;
365 1.3 mw static u_short *sbwpt = serbuf;
366 1.3 mw
367 1.3 mw
368 1.3 mw /* this is a replacement for the lack of a hardware fifo. 32k should be
369 1.3 mw enough (there's only one unit anyway, so this is not going to
370 1.3 mw accumulate). */
371 1.3 mw void
372 1.3 mw ser_fastint ()
373 1.3 mw {
374 1.3 mw /* we're at RBE-level, which is higher than VBL-level which is used
375 1.3 mw to periodically transmit contents of this buffer up one layer,
376 1.3 mw so no spl-raising is necessary. */
377 1.3 mw
378 1.3 mw register u_short ints, code;
379 1.3 mw
380 1.3 mw ints = custom.intreqr & INTF_RBF;
381 1.3 mw if (! ints)
382 1.3 mw return;
383 1.3 mw
384 1.3 mw /* clear interrupt */
385 1.3 mw custom.intreq = ints;
386 1.3 mw /* this register contains both data and status bits! */
387 1.3 mw code = custom.serdatr;
388 1.3 mw
389 1.3 mw /* should really not happen, but you never know.. buffer
390 1.3 mw overflow. */
391 1.3 mw if (sbwpt + 1 == sbrpt
392 1.3 mw || (sbwpt == serbuf + SERIBUF_SIZE - 1 && sbrpt == serbuf))
393 1.3 mw {
394 1.3 mw log (LOG_WARNING, "ser_fastint: buffer overflow!");
395 1.3 mw return;
396 1.3 mw }
397 1.3 mw
398 1.3 mw *sbwpt++ = code;
399 1.3 mw if (sbwpt == serbuf + SERIBUF_SIZE)
400 1.3 mw sbwpt = serbuf;
401 1.3 mw }
402 1.3 mw
403 1.3 mw
404 1.3 mw int
405 1.5 mw serintr (unit)
406 1.5 mw register int unit;
407 1.1 mw {
408 1.5 mw register struct serdevice *ser;
409 1.5 mw int s1, s2;
410 1.1 mw
411 1.5 mw ser = ser_addr[unit];
412 1.1 mw
413 1.5 mw /* make sure we're not interrupted by another
414 1.5 mw vbl, but allow level5 ints */
415 1.5 mw s1 = spltty();
416 1.1 mw
417 1.5 mw /* ok, pass along any acumulated information .. */
418 1.5 mw while (sbrpt != sbwpt)
419 1.5 mw {
420 1.5 mw /* no collision with ser_fastint() */
421 1.5 mw sereint (unit, *sbrpt, ser);
422 1.5 mw /* lock against ser_fastint() */
423 1.5 mw s2 = spl5();
424 1.5 mw {
425 1.5 mw sbrpt++;
426 1.5 mw if (sbrpt == serbuf + SERIBUF_SIZE)
427 1.5 mw sbrpt = serbuf;
428 1.5 mw }
429 1.5 mw splx (s2);
430 1.5 mw }
431 1.5 mw
432 1.5 mw splx (s1);
433 1.1 mw
434 1.3 mw #if 0
435 1.3 mw /* add the code below if you really need it */
436 1.1 mw {
437 1.1 mw /*
438 1.1 mw * Process a received byte. Inline for speed...
439 1.1 mw */
440 1.1 mw #ifdef KGDB
441 1.1 mw #define RCVBYTE() \
442 1.1 mw ch = code & 0xff; \
443 1.1 mw if ((tp->t_state & TS_ISOPEN) == 0) { \
444 1.1 mw if (ch == FRAME_END && \
445 1.1 mw kgdb_dev == makedev(sermajor, unit)) \
446 1.1 mw kgdb_connect(0); /* trap into kgdb */ \
447 1.1 mw }
448 1.1 mw #else
449 1.1 mw #define RCVBYTE()
450 1.1 mw #endif
451 1.1 mw RCVBYTE();
452 1.1 mw /* sereint does the receive-processing */
453 1.1 mw sereint (unit, code, ser);
454 1.1 mw }
455 1.3 mw #endif
456 1.1 mw }
457 1.1 mw
458 1.5 mw int
459 1.1 mw sereint(unit, stat, ser)
460 1.5 mw register int unit, stat;
461 1.5 mw register struct serdevice *ser;
462 1.1 mw {
463 1.5 mw register struct tty *tp;
464 1.5 mw register int c;
465 1.5 mw register u_char ch;
466 1.1 mw
467 1.5 mw tp = ser_tty[unit];
468 1.5 mw if ((tp->t_state & TS_ISOPEN) == 0)
469 1.5 mw {
470 1.1 mw #ifdef KGDB
471 1.5 mw /* we don't care about parity errors */
472 1.5 mw if (kgdb_dev == makedev(sermajor, unit) && c == FRAME_END)
473 1.5 mw kgdb_connect(0); /* trap into kgdb */
474 1.1 mw #endif
475 1.5 mw return;
476 1.5 mw }
477 1.1 mw
478 1.5 mw ch = stat & 0xff;
479 1.5 mw c = ch;
480 1.5 mw /* all databits 0 including stop indicate break condition */
481 1.5 mw if (!(stat & 0x1ff))
482 1.5 mw c |= TTY_FE;
483 1.5 mw
484 1.5 mw /* if parity checking enabled, check parity */
485 1.5 mw else if ((tp->t_cflag & PARENB) &&
486 1.5 mw (((ch >> 7) + even_parity[ch & 0x7f] + !!(tp->t_cflag & PARODD)) & 1))
487 1.5 mw c |= TTY_PE;
488 1.5 mw
489 1.5 mw if (stat & SERDATRF_OVRUN)
490 1.5 mw log(LOG_WARNING, "ser%d: silo overflow\n", unit);
491 1.5 mw
492 1.5 mw (*linesw[tp->t_line].l_rint)(c, tp);
493 1.1 mw }
494 1.1 mw
495 1.3 mw /* this interrupt is periodically invoked in the vertical blank
496 1.3 mw interrupt. It's used to keep track of the modem control lines
497 1.3 mw and (new with the fast_int code) to move accumulated data
498 1.3 mw up into the tty layer. */
499 1.3 mw void
500 1.5 mw sermint (register int unit)
501 1.1 mw {
502 1.5 mw register struct tty *tp;
503 1.5 mw register u_char stat, last, istat;
504 1.5 mw register struct serdevice *ser;
505 1.5 mw
506 1.5 mw tp = ser_tty[unit];
507 1.5 mw if (!tp)
508 1.5 mw return;
509 1.3 mw
510 1.5 mw if ((tp->t_state & (TS_ISOPEN|TS_WOPEN)) == 0)
511 1.5 mw {
512 1.5 mw sbrpt = sbwpt = serbuf;
513 1.5 mw return;
514 1.5 mw }
515 1.5 mw
516 1.5 mw /* first empty buffer */
517 1.5 mw serintr (unit);
518 1.5 mw
519 1.5 mw stat = ciab.pra;
520 1.5 mw last = last_ciab_pra;
521 1.5 mw last_ciab_pra = stat;
522 1.1 mw
523 1.5 mw /* check whether any interesting signal changed state */
524 1.5 mw istat = stat ^ last;
525 1.1 mw
526 1.5 mw if ((istat & CIAB_PRA_CD) && DIALIN(tp->t_dev))
527 1.5 mw {
528 1.5 mw if (ISDCD (stat))
529 1.5 mw (*linesw[tp->t_line].l_modem)(tp, 1);
530 1.5 mw else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0)
531 1.5 mw {
532 1.5 mw CLRDTR (stat);
533 1.5 mw CLRRTS (stat);
534 1.5 mw ciab.pra = stat;
535 1.5 mw last_ciab_pra = stat;
536 1.5 mw }
537 1.5 mw }
538 1.5 mw if ((istat & CIAB_PRA_CTS) && (tp->t_state & TS_ISOPEN) &&
539 1.5 mw (tp->t_cflag & CRTSCTS))
540 1.5 mw {
541 1.5 mw #if 0
542 1.5 mw /* the line is up and we want to do rts/cts flow control */
543 1.5 mw if (ISCTS (stat))
544 1.5 mw {
545 1.5 mw tp->t_state &=~ TS_TTSTOP;
546 1.5 mw ttstart(tp);
547 1.5 mw /* cause tbe-int if we were stuck there */
548 1.5 mw custom.intreq = INTF_SETCLR | INTF_TBE;
549 1.5 mw }
550 1.5 mw else
551 1.5 mw tp->t_state |= TS_TTSTOP;
552 1.5 mw #else
553 1.5 mw /* do this on hardware level, not with tty driver */
554 1.5 mw if (ISCTS (stat))
555 1.5 mw {
556 1.5 mw tp->t_state &= ~TS_TTSTOP;
557 1.5 mw /* cause TBE interrupt */
558 1.5 mw custom.intreq = INTF_SETCLR | INTF_TBE;
559 1.5 mw }
560 1.5 mw #endif
561 1.5 mw }
562 1.1 mw }
563 1.1 mw
564 1.5 mw int
565 1.1 mw serioctl(dev, cmd, data, flag)
566 1.5 mw dev_t dev;
567 1.5 mw caddr_t data;
568 1.1 mw {
569 1.5 mw register struct tty *tp;
570 1.5 mw register int unit = SERUNIT(dev);
571 1.5 mw register struct serdevice *ser;
572 1.5 mw register int error;
573 1.5 mw
574 1.5 mw tp = ser_tty[unit];
575 1.5 mw if (! tp)
576 1.5 mw return ENXIO;
577 1.5 mw
578 1.5 mw error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag);
579 1.5 mw if (error >= 0)
580 1.5 mw return (error);
581 1.5 mw
582 1.5 mw error = ttioctl(tp, cmd, data, flag);
583 1.5 mw if (error >= 0)
584 1.5 mw return (error);
585 1.5 mw
586 1.5 mw ser = ser_addr[unit];
587 1.5 mw switch (cmd)
588 1.5 mw {
589 1.5 mw case TIOCSBRK:
590 1.5 mw custom.adkcon = ADKCONF_SETCLR | ADKCONF_UARTBRK;
591 1.5 mw break;
592 1.5 mw
593 1.5 mw case TIOCCBRK:
594 1.5 mw custom.adkcon = ADKCONF_UARTBRK;
595 1.5 mw break;
596 1.5 mw
597 1.5 mw case TIOCSDTR:
598 1.5 mw (void) sermctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIS);
599 1.5 mw break;
600 1.5 mw
601 1.5 mw case TIOCCDTR:
602 1.5 mw (void) sermctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIC);
603 1.5 mw break;
604 1.5 mw
605 1.5 mw case TIOCMSET:
606 1.5 mw (void) sermctl(dev, *(int *)data, DMSET);
607 1.5 mw break;
608 1.5 mw
609 1.5 mw case TIOCMBIS:
610 1.5 mw (void) sermctl(dev, *(int *)data, DMBIS);
611 1.5 mw break;
612 1.5 mw
613 1.5 mw case TIOCMBIC:
614 1.5 mw (void) sermctl(dev, *(int *)data, DMBIC);
615 1.5 mw break;
616 1.5 mw
617 1.5 mw case TIOCMGET:
618 1.5 mw *(int *)data = sermctl(dev, 0, DMGET);
619 1.5 mw break;
620 1.5 mw
621 1.5 mw default:
622 1.5 mw return (ENOTTY);
623 1.5 mw }
624 1.1 mw
625 1.5 mw return (0);
626 1.1 mw }
627 1.1 mw
628 1.5 mw int
629 1.1 mw serparam(tp, t)
630 1.5 mw register struct tty *tp;
631 1.5 mw register struct termios *t;
632 1.1 mw {
633 1.5 mw register struct serdevice *ser;
634 1.5 mw register int cfcr, cflag = t->c_cflag;
635 1.5 mw int unit = SERUNIT(tp->t_dev);
636 1.5 mw int ospeed = ttspeedtab(t->c_ospeed, serspeedtab);
637 1.5 mw
638 1.5 mw /* check requested parameters */
639 1.5 mw if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
640 1.5 mw return (EINVAL);
641 1.5 mw
642 1.5 mw /* and copy to tty */
643 1.5 mw tp->t_ispeed = t->c_ispeed;
644 1.5 mw tp->t_ospeed = t->c_ospeed;
645 1.5 mw tp->t_cflag = cflag;
646 1.5 mw
647 1.5 mw custom.intena = INTF_SETCLR | INTF_RBF | INTF_TBE;
648 1.5 mw last_ciab_pra = ciab.pra;
649 1.5 mw
650 1.5 mw if (ospeed == 0)
651 1.5 mw {
652 1.5 mw (void) sermctl(tp->t_dev, 0, DMSET); /* hang up line */
653 1.5 mw return (0);
654 1.5 mw }
655 1.5 mw else
656 1.5 mw {
657 1.5 mw /* make sure any previous hangup is undone, ie.
658 1.5 mw reenable DTR. */
659 1.5 mw (void) sermctl (tp->t_dev, TIOCM_DTR | TIOCM_RTS, DMSET);
660 1.5 mw }
661 1.5 mw /* set the baud rate */
662 1.5 mw custom.serper = (0<<15) | ospeed; /* select 8 bit mode (instead of 9 bit) */
663 1.5 mw
664 1.5 mw return (0);
665 1.1 mw }
666 1.3 mw
667 1.3 mw
668 1.3 mw static void
669 1.3 mw ser_putchar (tp, c)
670 1.3 mw struct tty *tp;
671 1.3 mw unsigned short c;
672 1.3 mw {
673 1.3 mw /* handle truncation of character if necessary */
674 1.3 mw if ((tp->t_cflag & CSIZE) == CS7)
675 1.3 mw c &= 0x7f;
676 1.3 mw
677 1.3 mw /* handle parity if necessary (forces CS7) */
678 1.3 mw if (tp->t_cflag & PARENB)
679 1.3 mw {
680 1.5 mw c &= 0x7f;
681 1.5 mw if (even_parity[c])
682 1.3 mw c |= 0x80;
683 1.3 mw if (tp->t_cflag & PARODD)
684 1.3 mw c ^= 0x80;
685 1.3 mw }
686 1.3 mw
687 1.3 mw /* add stop bit(s) */
688 1.3 mw if (tp->t_cflag & CSTOPB)
689 1.3 mw c |= 0x300;
690 1.3 mw else
691 1.3 mw c |= 0x100;
692 1.3 mw
693 1.3 mw custom.serdat = c;
694 1.3 mw }
695 1.3 mw
696 1.3 mw
697 1.5 mw #define SEROBUF_SIZE 32
698 1.3 mw static u_char ser_outbuf[SEROBUF_SIZE];
699 1.3 mw static u_char *sob_ptr=ser_outbuf, *sob_end=ser_outbuf;
700 1.3 mw void
701 1.3 mw ser_outintr ()
702 1.3 mw {
703 1.3 mw struct tty *tp = ser_tty[0]; /* hmmmmm */
704 1.3 mw unsigned short c;
705 1.5 mw int s = spltty ();
706 1.3 mw
707 1.3 mw if (! tp)
708 1.5 mw goto out;
709 1.3 mw
710 1.3 mw if (! (custom.intreqr & INTF_TBE))
711 1.5 mw goto out;
712 1.3 mw
713 1.3 mw /* clear interrupt */
714 1.3 mw custom.intreq = INTF_TBE;
715 1.3 mw
716 1.3 mw if (sob_ptr == sob_end)
717 1.3 mw {
718 1.5 mw tp->t_state &= ~(TS_BUSY|TS_FLUSH);
719 1.5 mw if (tp->t_line)
720 1.5 mw (*linesw[tp->t_line].l_start)(tp);
721 1.5 mw else
722 1.5 mw serstart (tp);
723 1.5 mw
724 1.5 mw goto out;
725 1.3 mw }
726 1.3 mw
727 1.5 mw /* do hardware flow control here. if the CTS line goes down, don't
728 1.5 mw transmit anything. That way, we'll be restarted by the periodic
729 1.5 mw interrupt when CTS comes back up. */
730 1.5 mw if (ISCTS (ciab.pra))
731 1.5 mw ser_putchar (tp, *sob_ptr++);
732 1.5 mw out:
733 1.5 mw splx (s);
734 1.3 mw }
735 1.1 mw
736 1.5 mw int
737 1.1 mw serstart(tp)
738 1.5 mw register struct tty *tp;
739 1.1 mw {
740 1.5 mw register int cc, s;
741 1.5 mw int unit;
742 1.5 mw register struct serdevice *ser;
743 1.5 mw int hiwat = 0;
744 1.5 mw
745 1.5 mw if (! (tp->t_state & TS_ISOPEN))
746 1.5 mw return;
747 1.5 mw
748 1.5 mw unit = SERUNIT(tp->t_dev);
749 1.5 mw ser = ser_addr[unit];
750 1.5 mw
751 1.5 mw s = spltty();
752 1.5 mw if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP))
753 1.5 mw goto out;
754 1.5 mw
755 1.5 mw cc = tp->t_outq.c_cc;
756 1.5 mw if (cc <= tp->t_lowat)
757 1.5 mw {
758 1.5 mw if (tp->t_state & TS_ASLEEP)
759 1.5 mw {
760 1.5 mw tp->t_state &= ~TS_ASLEEP;
761 1.5 mw wakeup(&tp->t_outq);
762 1.3 mw }
763 1.5 mw selwakeup(&tp->t_wsel);
764 1.5 mw }
765 1.5 mw
766 1.5 mw if (! cc || (tp->t_state & TS_BUSY))
767 1.5 mw goto out;
768 1.5 mw
769 1.5 mw /* we only do bulk transfers if using CTSRTS flow control,
770 1.5 mw not for (probably sloooow) ixon/ixoff devices. */
771 1.5 mw if (! (tp->t_cflag & CRTSCTS))
772 1.5 mw cc = 1;
773 1.5 mw
774 1.5 mw /*
775 1.5 mw * Limit the amount of output we do in one burst
776 1.5 mw * to prevent hogging the CPU.
777 1.5 mw */
778 1.5 mw if (cc > SEROBUF_SIZE)
779 1.5 mw {
780 1.5 mw hiwat++;
781 1.5 mw cc = SEROBUF_SIZE;
782 1.5 mw }
783 1.5 mw cc = q_to_b (&tp->t_outq, ser_outbuf, cc);
784 1.5 mw if (cc > 0)
785 1.5 mw {
786 1.5 mw tp->t_state |= TS_BUSY;
787 1.5 mw
788 1.5 mw sob_ptr = ser_outbuf;
789 1.5 mw sob_end = ser_outbuf + cc;
790 1.5 mw /* get first character out, then have tbe-interrupts blow out
791 1.5 mw further characters, until buffer is empty, and TS_BUSY
792 1.5 mw gets cleared. */
793 1.5 mw ser_putchar (tp, *sob_ptr++);
794 1.5 mw }
795 1.1 mw
796 1.5 mw out:
797 1.5 mw splx(s);
798 1.1 mw }
799 1.1 mw
800 1.1 mw /*
801 1.1 mw * Stop output on a line.
802 1.1 mw */
803 1.1 mw /*ARGSUSED*/
804 1.5 mw int
805 1.1 mw serstop(tp, flag)
806 1.5 mw register struct tty *tp;
807 1.1 mw {
808 1.5 mw register int s;
809 1.1 mw
810 1.5 mw s = spltty();
811 1.5 mw if (tp->t_state & TS_BUSY)
812 1.5 mw {
813 1.5 mw if ((tp->t_state & TS_TTSTOP) == 0)
814 1.5 mw tp->t_state |= TS_FLUSH;
815 1.5 mw }
816 1.5 mw splx(s);
817 1.1 mw }
818 1.1 mw
819 1.5 mw int
820 1.1 mw sermctl(dev, bits, how)
821 1.5 mw dev_t dev;
822 1.5 mw int bits, how;
823 1.1 mw {
824 1.5 mw register struct serdevice *ser;
825 1.5 mw register int unit;
826 1.5 mw u_char ub;
827 1.5 mw int s;
828 1.1 mw
829 1.5 mw unit = SERUNIT(dev);
830 1.5 mw ser = ser_addr[unit];
831 1.1 mw
832 1.5 mw /* convert TIOCM* mask into CIA mask (which is really low-active!!) */
833 1.5 mw if (how != DMGET)
834 1.5 mw {
835 1.5 mw ub = 0;
836 1.5 mw if (bits & TIOCM_DTR) ub |= CIAB_PRA_DTR;
837 1.5 mw if (bits & TIOCM_RTS) ub |= CIAB_PRA_RTS;
838 1.5 mw if (bits & TIOCM_CTS) ub |= CIAB_PRA_CTS;
839 1.5 mw if (bits & TIOCM_CD) ub |= CIAB_PRA_CD;
840 1.5 mw if (bits & TIOCM_RI) ub |= CIAB_PRA_SEL; /* collision with /dev/par ! */
841 1.5 mw if (bits & TIOCM_DSR) ub |= CIAB_PRA_DSR;
842 1.5 mw }
843 1.1 mw
844 1.1 mw
845 1.5 mw s = spltty();
846 1.5 mw switch (how)
847 1.5 mw {
848 1.5 mw case DMSET:
849 1.5 mw /* invert and set */
850 1.5 mw ciab.pra = ~ub;
851 1.5 mw break;
852 1.5 mw
853 1.5 mw case DMBIC:
854 1.5 mw ciab.pra |= ub;
855 1.5 mw ub = ~ciab.pra;
856 1.5 mw break;
857 1.5 mw
858 1.5 mw case DMBIS:
859 1.5 mw ciab.pra &= ~ub;
860 1.5 mw ub = ~ciab.pra;
861 1.5 mw break;
862 1.5 mw
863 1.5 mw case DMGET:
864 1.5 mw ub = ~ciab.pra;
865 1.5 mw break;
866 1.5 mw }
867 1.5 mw (void) splx(s);
868 1.5 mw
869 1.5 mw bits = 0;
870 1.5 mw if (ub & CIAB_PRA_DTR) bits |= TIOCM_DTR;
871 1.5 mw if (ub & CIAB_PRA_RTS) bits |= TIOCM_RTS;
872 1.5 mw if (ub & CIAB_PRA_CTS) bits |= TIOCM_CTS;
873 1.5 mw if (ub & CIAB_PRA_CD) bits |= TIOCM_CD;
874 1.5 mw if (ub & CIAB_PRA_SEL) bits |= TIOCM_RI;
875 1.5 mw if (ub & CIAB_PRA_DSR) bits |= TIOCM_DSR;
876 1.5 mw
877 1.5 mw return bits;
878 1.1 mw }
879 1.1 mw
880 1.1 mw /*
881 1.1 mw * Following are all routines needed for SER to act as console
882 1.1 mw */
883 1.1 mw #include "../amiga/cons.h"
884 1.1 mw
885 1.1 mw sercnprobe(cp)
886 1.1 mw struct consdev *cp;
887 1.1 mw {
888 1.5 mw int unit = CONUNIT;
889 1.5 mw /* locate the major number */
890 1.5 mw for (sermajor = 0; sermajor < nchrdev; sermajor++)
891 1.5 mw if (cdevsw[sermajor].d_open == seropen)
892 1.5 mw break;
893 1.1 mw
894 1.5 mw /* XXX: ick */
895 1.5 mw unit = CONUNIT;
896 1.1 mw
897 1.5 mw /* initialize required fields */
898 1.5 mw cp->cn_dev = makedev(sermajor, unit);
899 1.3 mw #if 0
900 1.5 mw /* on ser it really doesn't matter whether we're later
901 1.5 mw using the tty interface or single-character io thru
902 1.5 mw cnputc, so don't reach out to later on remember that
903 1.5 mw our console is here (see ite.c) */
904 1.5 mw cp->cn_tp = ser_tty[unit];
905 1.5 mw #endif
906 1.5 mw cp->cn_pri = CN_NORMAL;
907 1.5 mw
908 1.5 mw /*
909 1.5 mw * If serconsole is initialized, raise our priority.
910 1.5 mw */
911 1.5 mw if (serconsole == unit)
912 1.5 mw cp->cn_pri = CN_REMOTE;
913 1.1 mw #ifdef KGDB
914 1.5 mw if (major(kgdb_dev) == 1) /* XXX */
915 1.5 mw kgdb_dev = makedev(sermajor, minor(kgdb_dev));
916 1.1 mw #endif
917 1.1 mw }
918 1.1 mw
919 1.1 mw sercninit(cp)
920 1.1 mw struct consdev *cp;
921 1.1 mw {
922 1.5 mw int unit = SERUNIT(cp->cn_dev);
923 1.1 mw
924 1.5 mw serinit(unit, serdefaultrate);
925 1.5 mw serconsole = unit;
926 1.5 mw serconsinit = 1;
927 1.1 mw }
928 1.1 mw
929 1.1 mw serinit(unit, rate)
930 1.1 mw int unit, rate;
931 1.1 mw {
932 1.5 mw int s;
933 1.1 mw
934 1.1 mw #ifdef lint
935 1.5 mw stat = unit; if (stat) return;
936 1.1 mw #endif
937 1.5 mw s = splhigh();
938 1.5 mw /* might want to fiddle with the CIA later ??? */
939 1.5 mw custom.serper = ttspeedtab(rate, serspeedtab);
940 1.5 mw splx(s);
941 1.1 mw }
942 1.1 mw
943 1.1 mw sercngetc(dev)
944 1.1 mw {
945 1.5 mw u_short stat;
946 1.5 mw int c, s;
947 1.1 mw
948 1.1 mw #ifdef lint
949 1.5 mw stat = dev; if (stat) return (0);
950 1.1 mw #endif
951 1.5 mw s = splhigh();
952 1.5 mw while (!((stat = custom.serdatr & 0xffff) & SERDATRF_RBF))
953 1.5 mw ;
954 1.5 mw c = stat & 0xff;
955 1.5 mw /* clear interrupt */
956 1.5 mw custom.intreq = INTF_RBF;
957 1.5 mw splx(s);
958 1.5 mw return (c);
959 1.1 mw }
960 1.1 mw
961 1.1 mw /*
962 1.1 mw * Console kernel output character routine.
963 1.1 mw */
964 1.1 mw sercnputc(dev, c)
965 1.5 mw dev_t dev;
966 1.5 mw register int c;
967 1.1 mw {
968 1.5 mw register int timo;
969 1.5 mw short stat;
970 1.5 mw int s = splhigh();
971 1.1 mw
972 1.1 mw #ifdef lint
973 1.5 mw stat = dev; if (stat) return;
974 1.1 mw #endif
975 1.5 mw if (serconsinit == 0)
976 1.5 mw {
977 1.5 mw (void) serinit(SERUNIT(dev), serdefaultrate);
978 1.5 mw serconsinit = 1;
979 1.5 mw }
980 1.5 mw
981 1.5 mw /* wait for any pending transmission to finish */
982 1.5 mw timo = 50000;
983 1.5 mw while (! (custom.serdatr & SERDATRF_TBE) && --timo)
984 1.5 mw ;
985 1.5 mw
986 1.5 mw custom.serdat = (c&0xff) | 0x100;
987 1.5 mw /* wait for this transmission to complete */
988 1.5 mw timo = 1500000;
989 1.5 mw while (! (custom.serdatr & SERDATRF_TBE) && --timo)
990 1.5 mw ;
991 1.5 mw
992 1.5 mw /* wait for the device (my vt100..) to process the data, since
993 1.5 mw we don't do flow-control with cnputc */
994 1.5 mw for (timo = 0; timo < 30000; timo++) ;
995 1.5 mw
996 1.5 mw /* clear any interrupts generated by this transmission */
997 1.5 mw custom.intreq = INTF_TBE;
998 1.5 mw splx(s);
999 1.1 mw }
1000 1.1 mw
1001 1.1 mw
1002 1.1 mw serspit(c)
1003 1.5 mw int c;
1004 1.1 mw {
1005 1.5 mw register struct Custom *cu asm("a2") = CUSTOMbase;
1006 1.5 mw register int timo asm("d2");
1007 1.5 mw extern int cold;
1008 1.5 mw int s;
1009 1.5 mw
1010 1.5 mw if (c == 10)
1011 1.5 mw serspit (13);
1012 1.5 mw
1013 1.5 mw s = splhigh();
1014 1.5 mw
1015 1.5 mw /* wait for any pending transmission to finish */
1016 1.5 mw timo = 500000;
1017 1.5 mw while (! (cu->serdatr & (SERDATRF_TBE|SERDATRF_TSRE)) && --timo)
1018 1.5 mw ;
1019 1.5 mw cu->serdat = (c&0xff) | 0x100;
1020 1.5 mw /* wait for this transmission to complete */
1021 1.5 mw timo = 15000000;
1022 1.5 mw while (! (cu->serdatr & SERDATRF_TBE) && --timo)
1023 1.5 mw ;
1024 1.5 mw /* clear any interrupts generated by this transmission */
1025 1.5 mw cu->intreq = INTF_TBE;
1026 1.5 mw
1027 1.5 mw for (timo = 0; timo < 30000; timo++) ;
1028 1.5 mw
1029 1.5 mw splx (s);
1030 1.1 mw }
1031 1.1 mw
1032 1.3 mw serspits(cp)
1033 1.3 mw char *cp;
1034 1.3 mw {
1035 1.3 mw while (*cp)
1036 1.3 mw serspit(*cp++);
1037 1.3 mw }
1038 1.3 mw
1039 1.1 mw int
1040 1.1 mw serselect(dev, rw, p)
1041 1.5 mw dev_t dev;
1042 1.5 mw int rw;
1043 1.5 mw struct proc *p;
1044 1.5 mw {
1045 1.5 mw register struct tty *tp = ser_tty[SERUNIT(dev)];
1046 1.5 mw int nread;
1047 1.5 mw int s = spltty();
1048 1.5 mw struct proc *selp;
1049 1.5 mw
1050 1.5 mw switch (rw)
1051 1.5 mw {
1052 1.5 mw case FREAD:
1053 1.5 mw nread = ttnread(tp);
1054 1.5 mw if (nread > 0 || ((tp->t_cflag&CLOCAL) == 0
1055 1.5 mw && (tp->t_state&TS_CARR_ON) == 0))
1056 1.5 mw goto win;
1057 1.5 mw selrecord(p, &tp->t_rsel);
1058 1.5 mw break;
1059 1.5 mw
1060 1.5 mw case FWRITE:
1061 1.5 mw if (tp->t_outq.c_cc <= tp->t_lowat)
1062 1.5 mw goto win;
1063 1.5 mw selrecord(p, &tp->t_wsel);
1064 1.5 mw break;
1065 1.5 mw }
1066 1.5 mw splx(s);
1067 1.5 mw return (0);
1068 1.5 mw
1069 1.5 mw win:
1070 1.5 mw splx(s);
1071 1.5 mw return (1);
1072 1.1 mw }
1073 1.1 mw
1074 1.1 mw #endif
1075