dcm.c revision 1.11 1 /*
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * from: Utah Hdr: dcm.c 1.26 91/01/21
39 * from: @(#)dcm.c 7.14 (Berkeley) 6/27/91
40 * $Id: dcm.c,v 1.11 1994/02/06 00:44:34 mycroft Exp $
41 */
42
43 /*
44 * TODO:
45 * Timeouts
46 * Test console support.
47 */
48
49 #include "dcm.h"
50 #if NDCM > 0
51 /*
52 * 98642/MUX
53 */
54 #include "sys/param.h"
55 #include "sys/systm.h"
56 #include "sys/ioctl.h"
57 #include "sys/tty.h"
58 #include "sys/proc.h"
59 #include "sys/conf.h"
60 #include "sys/file.h"
61 #include "sys/uio.h"
62 #include "sys/kernel.h"
63 #include "sys/syslog.h"
64 #include "sys/time.h"
65
66 #include "device.h"
67 #include "dcmreg.h"
68 #include "machine/cpu.h"
69 #include "../hp300/isr.h"
70
71 #ifndef DEFAULT_BAUD_RATE
72 #define DEFAULT_BAUD_RATE 9600
73 #endif
74
75 int dcmprobe(), dcmintr(), dcmparam();
76 void dcmstart();
77
78 struct driver dcmdriver = {
79 dcmprobe, "dcm",
80 };
81
82 #define NDCMLINE (NDCM*4)
83
84 struct tty *dcm_tty[NDCMLINE];
85 struct modemreg *dcm_modem[NDCMLINE];
86 char mcndlast[NDCMLINE]; /* XXX last modem status for line */
87 int ndcm = NDCMLINE;
88
89 int dcm_active;
90 int dcmsoftCAR[NDCM];
91 struct dcmdevice *dcm_addr[NDCM];
92 struct isr dcmisr[NDCM];
93
94 struct speedtab dcmspeedtab[] = {
95 0, BR_0,
96 50, BR_50,
97 75, BR_75,
98 110, BR_110,
99 134, BR_134,
100 150, BR_150,
101 300, BR_300,
102 600, BR_600,
103 1200, BR_1200,
104 1800, BR_1800,
105 2400, BR_2400,
106 4800, BR_4800,
107 9600, BR_9600,
108 19200, BR_19200,
109 38400, BR_38400,
110 -1, -1
111 };
112
113 /* u-sec per character based on baudrate (assumes 1 start/8 data/1 stop bit) */
114 #define DCM_USPERCH(s) (10000000 / (s))
115
116 /*
117 * Per board interrupt scheme. 16.7ms is the polling interrupt rate
118 * (16.7ms is about 550 baud, 38.4k is 72 chars in 16.7ms).
119 */
120 #define DIS_TIMER 0
121 #define DIS_PERCHAR 1
122 #define DIS_RESET 2
123
124 int dcmistype = -1; /* -1 == dynamic, 0 == timer, 1 == perchar */
125 int dcminterval = 5; /* interval (secs) between checks */
126 struct dcmischeme {
127 int dis_perchar; /* non-zero if interrupting per char */
128 long dis_time; /* last time examined */
129 int dis_intr; /* recv interrupts during last interval */
130 int dis_char; /* characters read during last interval */
131 } dcmischeme[NDCM];
132
133 /*
134 * Console support
135 */
136 #ifdef DCMCONSOLE
137 int dcmconsole = DCMCONSOLE;
138 #else
139 int dcmconsole = -1;
140 #endif
141 int dcmconsinit;
142 int dcmdefaultrate = DEFAULT_BAUD_RATE;
143 int dcmconbrdbusy = 0;
144 int dcmmajor;
145 extern struct tty *constty;
146
147 #ifdef KGDB
148 /*
149 * Kernel GDB support
150 */
151 #include "machine/remote-sl.h"
152
153 extern dev_t kgdb_dev;
154 extern int kgdb_rate;
155 extern int kgdb_debug_init;
156 #endif
157
158 /* #define IOSTATS */
159
160 #ifdef DEBUG
161 int dcmdebug = 0x0;
162 #define DDB_SIOERR 0x01
163 #define DDB_PARAM 0x02
164 #define DDB_INPUT 0x04
165 #define DDB_OUTPUT 0x08
166 #define DDB_INTR 0x10
167 #define DDB_IOCTL 0x20
168 #define DDB_INTSCHM 0x40
169 #define DDB_MODEM 0x80
170 #define DDB_OPENCLOSE 0x100
171 #endif
172
173 #ifdef IOSTATS
174 #define DCMRBSIZE 94
175 #define DCMXBSIZE 24
176
177 struct dcmstats {
178 long xints; /* # of xmit ints */
179 long xchars; /* # of xmit chars */
180 long xempty; /* times outq is empty in dcmstart */
181 long xrestarts; /* times completed while xmitting */
182 long rints; /* # of recv ints */
183 long rchars; /* # of recv chars */
184 long xsilo[DCMXBSIZE+2]; /* times this many chars xmit on one int */
185 long rsilo[DCMRBSIZE+2]; /* times this many chars read on one int */
186 } dcmstats[NDCM];
187 #endif
188
189 #define UNIT(x) minor(x)
190 #define BOARD(x) (((x) >> 2) & 0x3f)
191 #define PORT(x) ((x) & 3)
192 #define MKUNIT(b,p) (((b) << 2) | (p))
193
194 /*
195 * Conversion from "HP DCE" to almost-normal DCE: on the 638 8-port mux,
196 * the distribution panel uses "HP DCE" conventions. If requested via
197 * the device flags, we swap the inputs to something closer to normal DCE,
198 * allowing a straight-through cable to a DTE or a reversed cable
199 * to a DCE (reversing 2-3, 4-5, 8-20 and leaving 6 unconnected;
200 * this gets "DCD" on pin 20 and "CTS" on 4, but doesn't connect
201 * DSR or make RTS work, though). The following gives the full
202 * details of a cable from this mux panel to a modem:
203 *
204 * HP modem
205 * name pin pin name
206 * HP inputs:
207 * "Rx" 2 3 Tx
208 * CTS 4 5 CTS (only needed for CCTS_OFLOW)
209 * DCD 20 8 DCD
210 * "DSR" 9 6 DSR (unneeded)
211 * RI 22 22 RI (unneeded)
212 *
213 * HP outputs:
214 * "Tx" 3 2 Rx
215 * "DTR" 6 not connected
216 * "RTS" 8 20 DTR
217 * "SR" 23 4 RTS (often not needed)
218 */
219 #define FLAG_STDDCE 0x10 /* map inputs if this bit is set in flags */
220 #define hp2dce_in(ibits) (iconv[(ibits) & 0xf])
221 static char iconv[16] = {
222 0, MI_DM, MI_CTS, MI_CTS|MI_DM,
223 MI_CD, MI_CD|MI_DM, MI_CD|MI_CTS, MI_CD|MI_CTS|MI_DM,
224 MI_RI, MI_RI|MI_DM, MI_RI|MI_CTS, MI_RI|MI_CTS|MI_DM,
225 MI_RI|MI_CD, MI_RI|MI_CD|MI_DM, MI_RI|MI_CD|MI_CTS,
226 MI_RI|MI_CD|MI_CTS|MI_DM
227 };
228
229 dcmprobe(hd)
230 register struct hp_device *hd;
231 {
232 register struct dcmdevice *dcm;
233 register int i;
234 register int timo = 0;
235 int s, brd, isconsole, mbits;
236
237 dcm = (struct dcmdevice *)hd->hp_addr;
238 if ((dcm->dcm_rsid & 0x1f) != DCMID)
239 return (0);
240 brd = hd->hp_unit;
241 isconsole = (brd == BOARD(dcmconsole));
242 /*
243 * XXX selected console device (CONSUNIT) as determined by
244 * dcmcnprobe does not agree with logical numbering imposed
245 * by the config file (i.e. lowest address DCM is not unit
246 * CONSUNIT). Don't recognize this card.
247 */
248 if (isconsole && dcm != dcm_addr[BOARD(dcmconsole)])
249 return (0);
250
251 /*
252 * Empirically derived self-test magic
253 */
254 s = spltty();
255 dcm->dcm_rsid = DCMRS;
256 DELAY(50000); /* 5000 is not long enough */
257 dcm->dcm_rsid = 0;
258 dcm->dcm_ic = IC_IE;
259 dcm->dcm_cr = CR_SELFT;
260 while ((dcm->dcm_ic & IC_IR) == 0)
261 if (++timo == 20000)
262 return (0);
263 DELAY(50000) /* XXX why is this needed ???? */
264 while ((dcm->dcm_iir & IIR_SELFT) == 0)
265 if (++timo == 400000)
266 return (0);
267 DELAY(50000) /* XXX why is this needed ???? */
268 if (dcm->dcm_stcon != ST_OK) {
269 if (!isconsole)
270 printf("dcm%d: self test failed: %x\n",
271 brd, dcm->dcm_stcon);
272 return (0);
273 }
274 dcm->dcm_ic = IC_ID;
275 splx(s);
276
277 hd->hp_ipl = DCMIPL(dcm->dcm_ic);
278 dcm_addr[brd] = dcm;
279 dcm_active |= 1 << brd;
280 dcmsoftCAR[brd] = hd->hp_flags;
281 dcmisr[brd].isr_ipl = hd->hp_ipl;
282 dcmisr[brd].isr_arg = brd;
283 dcmisr[brd].isr_intr = dcmintr;
284 isrlink(&dcmisr[brd]);
285 #ifdef KGDB
286 if (major(kgdb_dev) == dcmmajor && BOARD(kgdb_dev) == brd) {
287 if (dcmconsole == UNIT(kgdb_dev))
288 kgdb_dev = NODEV; /* can't debug over console port */
289 #ifndef KGDB_CHEAT
290 /*
291 * The following could potentially be replaced
292 * by the corresponding code in dcmcnprobe.
293 */
294 else {
295 (void) dcminit(kgdb_dev, kgdb_rate);
296 if (kgdb_debug_init) {
297 printf("dcm%d: ", UNIT(kgdb_dev));
298 kgdb_connect(1);
299 } else
300 printf("dcm%d: kgdb enabled\n", UNIT(kgdb_dev));
301 }
302 /* end could be replaced */
303 #endif
304 }
305 #endif
306 if (dcmistype == DIS_TIMER)
307 dcmsetischeme(brd, DIS_RESET|DIS_TIMER);
308 else
309 dcmsetischeme(brd, DIS_RESET|DIS_PERCHAR);
310
311 /* load pointers to modem control */
312 dcm_modem[MKUNIT(brd, 0)] = &dcm->dcm_modem0;
313 dcm_modem[MKUNIT(brd, 1)] = &dcm->dcm_modem1;
314 dcm_modem[MKUNIT(brd, 2)] = &dcm->dcm_modem2;
315 dcm_modem[MKUNIT(brd, 3)] = &dcm->dcm_modem3;
316 /* set DCD (modem) and CTS (flow control) on all ports */
317 if (dcmsoftCAR[brd] & FLAG_STDDCE)
318 mbits = hp2dce_in(MI_CD|MI_CTS);
319 else
320 mbits = MI_CD|MI_CTS;
321 for (i = 0; i < 4; i++)
322 dcm_modem[MKUNIT(brd, i)]->mdmmsk = mbits;
323
324 dcm->dcm_ic = IC_IE; /* turn all interrupts on */
325 /*
326 * Need to reset baud rate, etc. of next print so reset dcmconsole.
327 * Also make sure console is always "hardwired"
328 */
329 if (isconsole) {
330 dcmconsinit = 0;
331 dcmsoftCAR[brd] |= (1 << PORT(dcmconsole));
332 }
333 return (1);
334 }
335
336 /* ARGSUSED */
337 #ifdef __STDC__
338 dcmopen(dev_t dev, int flag, int mode, struct proc *p)
339 #else
340 dcmopen(dev, flag, mode, p)
341 dev_t dev;
342 int flag, mode;
343 struct proc *p;
344 #endif
345 {
346 register struct tty *tp;
347 register int unit, brd;
348 int error = 0, mbits;
349
350 unit = UNIT(dev);
351 brd = BOARD(unit);
352 if (unit >= NDCMLINE || (dcm_active & (1 << brd)) == 0)
353 return (ENXIO);
354 if(!dcm_tty[unit])
355 tp = dcm_tty[unit] = ttymalloc();
356 else
357 tp = dcm_tty[unit];
358 tp->t_oproc = dcmstart;
359 tp->t_param = dcmparam;
360 tp->t_dev = dev;
361 if ((tp->t_state & TS_ISOPEN) == 0) {
362 tp->t_state |= TS_WOPEN;
363 ttychars(tp);
364 if (tp->t_ispeed == 0) {
365 tp->t_iflag = TTYDEF_IFLAG;
366 tp->t_oflag = TTYDEF_OFLAG;
367 tp->t_cflag = TTYDEF_CFLAG;
368 tp->t_lflag = TTYDEF_LFLAG;
369 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
370 }
371 (void) dcmparam(tp, &tp->t_termios);
372 ttsetwater(tp);
373 } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
374 return (EBUSY);
375 mbits = MO_ON;
376 if (dcmsoftCAR[brd] & FLAG_STDDCE)
377 mbits |= MO_SR; /* pin 23, could be used as RTS */
378 (void) dcmmctl(dev, mbits, DMSET); /* enable port */
379 if ((dcmsoftCAR[brd] & (1 << PORT(unit))) ||
380 (dcmmctl(dev, MO_OFF, DMGET) & MI_CD))
381 tp->t_state |= TS_CARR_ON;
382 #ifdef DEBUG
383 if (dcmdebug & DDB_MODEM)
384 printf("dcm%d: dcmopen port %d softcarr %c\n",
385 brd, unit, (tp->t_state & TS_CARR_ON) ? '1' : '0');
386 #endif
387 (void) spltty();
388 while ((flag&O_NONBLOCK) == 0 && (tp->t_cflag&CLOCAL) == 0 &&
389 (tp->t_state & TS_CARR_ON) == 0) {
390 tp->t_state |= TS_WOPEN;
391 if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
392 ttopen, 0))
393 break;
394 }
395 (void) spl0();
396
397 #ifdef DEBUG
398 if (dcmdebug & DDB_OPENCLOSE)
399 printf("dcmopen: u %x st %x fl %x\n",
400 unit, tp->t_state, tp->t_flags);
401 #endif
402 if (error == 0)
403 error = (*linesw[tp->t_line].l_open)(dev, tp);
404 return (error);
405 }
406
407 /*ARGSUSED*/
408 dcmclose(dev, flag, mode, p)
409 dev_t dev;
410 int flag, mode;
411 struct proc *p;
412 {
413 register struct tty *tp;
414 int unit;
415
416 unit = UNIT(dev);
417 tp = dcm_tty[unit];
418 (*linesw[tp->t_line].l_close)(tp, flag);
419 if (tp->t_cflag&HUPCL || tp->t_state&TS_WOPEN ||
420 (tp->t_state&TS_ISOPEN) == 0)
421 (void) dcmmctl(dev, MO_OFF, DMSET);
422 #ifdef DEBUG
423 if (dcmdebug & DDB_OPENCLOSE)
424 printf("dcmclose: u %x st %x fl %x\n",
425 unit, tp->t_state, tp->t_flags);
426 #endif
427 ttyclose(tp);
428 ttyfree(tp);
429 dcm_tty[unit] = (struct tty *)NULL;
430 return (0);
431 }
432
433 dcmread(dev, uio, flag)
434 dev_t dev;
435 struct uio *uio;
436 {
437 register struct tty *tp;
438
439 tp = dcm_tty[UNIT(dev)];
440 return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
441 }
442
443 dcmwrite(dev, uio, flag)
444 dev_t dev;
445 struct uio *uio;
446 {
447 int unit = UNIT(dev);
448 register struct tty *tp;
449
450 tp = dcm_tty[unit];
451 /*
452 * XXX we disallow virtual consoles if the physical console is
453 * a serial port. This is in case there is a display attached that
454 * is not the console. In that situation we don't need/want the X
455 * server taking over the console.
456 */
457 if (constty && unit == dcmconsole)
458 constty = NULL;
459 return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
460 }
461
462 dcmintr(brd)
463 register int brd;
464 {
465 register struct dcmdevice *dcm = dcm_addr[brd];
466 register struct dcmischeme *dis;
467 register int unit = MKUNIT(brd, 0);
468 register int code, i;
469 int pcnd[4], mcode, mcnd[4];
470
471 /*
472 * Do all guarded register accesses right off to minimize
473 * block out of hardware.
474 */
475 SEM_LOCK(dcm);
476 if ((dcm->dcm_ic & IC_IR) == 0) {
477 SEM_UNLOCK(dcm);
478 return (0);
479 }
480 for (i = 0; i < 4; i++) {
481 pcnd[i] = dcm->dcm_icrtab[i].dcm_data;
482 dcm->dcm_icrtab[i].dcm_data = 0;
483 code = dcm_modem[unit+i]->mdmin;
484 if (dcmsoftCAR[brd] & FLAG_STDDCE)
485 code = hp2dce_in(code);
486 mcnd[i] = code;
487 }
488 code = dcm->dcm_iir & IIR_MASK;
489 dcm->dcm_iir = 0; /* XXX doc claims read clears interrupt?! */
490 mcode = dcm->dcm_modemintr;
491 dcm->dcm_modemintr = 0;
492 SEM_UNLOCK(dcm);
493
494 #ifdef DEBUG
495 if (dcmdebug & DDB_INTR) {
496 printf("dcmintr(%d): iir %x pc %x/%x/%x/%x ",
497 brd, code, pcnd[0], pcnd[1], pcnd[2], pcnd[3]);
498 printf("miir %x mc %x/%x/%x/%x\n",
499 mcode, mcnd[0], mcnd[1], mcnd[2], mcnd[3]);
500 }
501 #endif
502 if (code & IIR_TIMEO)
503 dcmrint(brd, dcm);
504 if (code & IIR_PORT0)
505 dcmpint(unit+0, pcnd[0], dcm);
506 if (code & IIR_PORT1)
507 dcmpint(unit+1, pcnd[1], dcm);
508 if (code & IIR_PORT2)
509 dcmpint(unit+2, pcnd[2], dcm);
510 if (code & IIR_PORT3)
511 dcmpint(unit+3, pcnd[3], dcm);
512 if (code & IIR_MODM) {
513 if (mcode == 0 || mcode & 0x1) /* mcode==0 -> 98642 board */
514 dcmmint(unit+0, mcnd[0], dcm);
515 if (mcode & 0x2)
516 dcmmint(unit+1, mcnd[1], dcm);
517 if (mcode & 0x4)
518 dcmmint(unit+2, mcnd[2], dcm);
519 if (mcode & 0x8)
520 dcmmint(unit+3, mcnd[3], dcm);
521 }
522
523 dis = &dcmischeme[brd];
524 /*
525 * Chalk up a receiver interrupt if the timer running or one of
526 * the ports reports a special character interrupt.
527 */
528 if ((code & IIR_TIMEO) ||
529 ((pcnd[0]|pcnd[1]|pcnd[2]|pcnd[3]) & IT_SPEC))
530 dis->dis_intr++;
531 /*
532 * See if it is time to check/change the interrupt rate.
533 */
534 if (dcmistype < 0 &&
535 (i = time.tv_sec - dis->dis_time) >= dcminterval) {
536 /*
537 * If currently per-character and averaged over 70 interrupts
538 * per-second (66 is threshold of 600 baud) in last interval,
539 * switch to timer mode.
540 *
541 * XXX decay counts ala load average to avoid spikes?
542 */
543 if (dis->dis_perchar && dis->dis_intr > 70 * i)
544 dcmsetischeme(brd, DIS_TIMER);
545 /*
546 * If currently using timer and had more interrupts than
547 * received characters in the last interval, switch back
548 * to per-character. Note that after changing to per-char
549 * we must process any characters already in the queue
550 * since they may have arrived before the bitmap was setup.
551 *
552 * XXX decay counts?
553 */
554 else if (!dis->dis_perchar && dis->dis_intr > dis->dis_char) {
555 dcmsetischeme(brd, DIS_PERCHAR);
556 dcmrint(brd, dcm);
557 }
558 dis->dis_intr = dis->dis_char = 0;
559 dis->dis_time = time.tv_sec;
560 }
561 return (1);
562 }
563
564 /*
565 * Port interrupt. Can be two things:
566 * First, it might be a special character (exception interrupt);
567 * Second, it may be a buffer empty (transmit interrupt);
568 */
569 dcmpint(unit, code, dcm)
570 int unit, code;
571 struct dcmdevice *dcm;
572 {
573 struct tty *tp = dcm_tty[unit];
574
575 if (code & IT_SPEC)
576 dcmreadbuf(unit, dcm, tp);
577 if (code & IT_TX)
578 dcmxint(unit, dcm, tp);
579 }
580
581 dcmrint(brd, dcm)
582 int brd;
583 register struct dcmdevice *dcm;
584 {
585 register int i, unit;
586 register struct tty *tp;
587
588 unit = MKUNIT(brd, 0);
589 tp = dcm_tty[unit];
590 for (i = 0; i < 4; i++, tp++, unit++)
591 dcmreadbuf(unit, dcm, tp);
592 }
593
594 dcmreadbuf(unit, dcm, tp)
595 int unit;
596 register struct dcmdevice *dcm;
597 register struct tty *tp;
598 {
599 int port = PORT(unit);
600 register struct dcmpreg *pp = dcm_preg(dcm, port);
601 register struct dcmrfifo *fifo;
602 register int c, stat;
603 register unsigned head;
604 int nch = 0;
605 #ifdef IOSTATS
606 struct dcmstats *dsp = &dcmstats[BOARD(unit)];
607
608 dsp->rints++;
609 #endif
610 if ((tp->t_state & TS_ISOPEN) == 0) {
611 #ifdef KGDB
612 if ((makedev(dcmmajor, unit) == kgdb_dev) &&
613 (head = pp->r_head & RX_MASK) != (pp->r_tail & RX_MASK) &&
614 dcm->dcm_rfifos[3-port][head>>1].data_char == FRAME_END) {
615 pp->r_head = (head + 2) & RX_MASK;
616 kgdb_connect(0); /* trap into kgdb */
617 return;
618 }
619 #endif /* KGDB */
620 pp->r_head = pp->r_tail & RX_MASK;
621 return;
622 }
623
624 head = pp->r_head & RX_MASK;
625 fifo = &dcm->dcm_rfifos[3-port][head>>1];
626 /*
627 * XXX upper bound on how many chars we will take in one swallow?
628 */
629 while (head != (pp->r_tail & RX_MASK)) {
630 /*
631 * Get character/status and update head pointer as fast
632 * as possible to make room for more characters.
633 */
634 c = fifo->data_char;
635 stat = fifo->data_stat;
636 head = (head + 2) & RX_MASK;
637 pp->r_head = head;
638 fifo = head ? fifo+1 : &dcm->dcm_rfifos[3-port][0];
639 nch++;
640
641 #ifdef DEBUG
642 if (dcmdebug & DDB_INPUT)
643 printf("dcmreadbuf(%d): c%x('%c') s%x f%x h%x t%x\n",
644 unit, c&0xFF, c, stat&0xFF,
645 tp->t_flags, head, pp->r_tail);
646 #endif
647 /*
648 * Check for and handle errors
649 */
650 if (stat & RD_MASK) {
651 #ifdef DEBUG
652 if (dcmdebug & (DDB_INPUT|DDB_SIOERR))
653 printf("dcmreadbuf(%d): err: c%x('%c') s%x\n",
654 unit, stat, c&0xFF, c);
655 #endif
656 if (stat & (RD_BD | RD_FE))
657 c |= TTY_FE;
658 else if (stat & RD_PE)
659 c |= TTY_PE;
660 else if (stat & RD_OVF)
661 log(LOG_WARNING,
662 "dcm%d: silo overflow\n", unit);
663 else if (stat & RD_OE)
664 log(LOG_WARNING,
665 "dcm%d: uart overflow\n", unit);
666 }
667 (*linesw[tp->t_line].l_rint)(c, tp);
668 }
669 dcmischeme[BOARD(unit)].dis_char += nch;
670 #ifdef IOSTATS
671 dsp->rchars += nch;
672 if (nch <= DCMRBSIZE)
673 dsp->rsilo[nch]++;
674 else
675 dsp->rsilo[DCMRBSIZE+1]++;
676 #endif
677 }
678
679 dcmxint(unit, dcm, tp)
680 int unit;
681 struct dcmdevice *dcm;
682 register struct tty *tp;
683 {
684 tp->t_state &= ~TS_BUSY;
685 if (tp->t_state & TS_FLUSH)
686 tp->t_state &= ~TS_FLUSH;
687 (*linesw[tp->t_line].l_start)(tp);
688 }
689
690 dcmmint(unit, mcnd, dcm)
691 register int unit;
692 register struct dcmdevice *dcm;
693 int mcnd;
694 {
695 register struct tty *tp;
696 int delta;
697
698 #ifdef DEBUG
699 if (dcmdebug & DDB_MODEM)
700 printf("dcmmint: port %d mcnd %x mcndlast %x\n",
701 unit, mcnd, mcndlast[unit]);
702 #endif
703 tp = dcm_tty[unit];
704 delta = mcnd ^ mcndlast[unit];
705 mcndlast[unit] = mcnd;
706 if ((delta & MI_CTS) && (tp->t_state & TS_ISOPEN) &&
707 (tp->t_flags & CCTS_OFLOW)) {
708 if (mcnd & MI_CTS) {
709 tp->t_state &= ~TS_TTSTOP;
710 ttstart(tp);
711 } else
712 tp->t_state |= TS_TTSTOP; /* inline dcmstop */
713 }
714 if (delta & MI_CD) {
715 if (mcnd & MI_CD)
716 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
717 else if ((dcmsoftCAR[BOARD(unit)] & (1 << PORT(unit))) == 0 &&
718 (*linesw[tp->t_line].l_modem)(tp, 0) == 0) {
719 dcm_modem[unit]->mdmout = MO_OFF;
720 SEM_LOCK(dcm);
721 dcm->dcm_modemchng |= 1<<(unit & 3);
722 dcm->dcm_cr |= CR_MODM;
723 SEM_UNLOCK(dcm);
724 DELAY(10); /* time to change lines */
725 }
726 }
727 }
728
729 dcmioctl(dev, cmd, data, flag)
730 dev_t dev;
731 caddr_t data;
732 {
733 register struct tty *tp;
734 register int unit = UNIT(dev);
735 register struct dcmdevice *dcm;
736 register int port;
737 int error, s;
738
739 #ifdef DEBUG
740 if (dcmdebug & DDB_IOCTL)
741 printf("dcmioctl: unit %d cmd %x data %x flag %x\n",
742 unit, cmd, *data, flag);
743 #endif
744 tp = dcm_tty[unit];
745 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag);
746 if (error >= 0)
747 return (error);
748 error = ttioctl(tp, cmd, data, flag);
749 if (error >= 0)
750 return (error);
751
752 port = PORT(unit);
753 dcm = dcm_addr[BOARD(unit)];
754 switch (cmd) {
755 case TIOCSBRK:
756 /*
757 * Wait for transmitter buffer to empty
758 */
759 s = spltty();
760 while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
761 DELAY(DCM_USPERCH(tp->t_ospeed));
762 SEM_LOCK(dcm);
763 dcm->dcm_cmdtab[port].dcm_data |= CT_BRK;
764 dcm->dcm_cr |= (1 << port); /* start break */
765 SEM_UNLOCK(dcm);
766 splx(s);
767 break;
768
769 case TIOCCBRK:
770 SEM_LOCK(dcm);
771 dcm->dcm_cmdtab[port].dcm_data |= CT_BRK;
772 dcm->dcm_cr |= (1 << port); /* end break */
773 SEM_UNLOCK(dcm);
774 break;
775
776 case TIOCSDTR:
777 (void) dcmmctl(dev, MO_ON, DMBIS);
778 break;
779
780 case TIOCCDTR:
781 (void) dcmmctl(dev, MO_ON, DMBIC);
782 break;
783
784 case TIOCMSET:
785 (void) dcmmctl(dev, *(int *)data, DMSET);
786 break;
787
788 case TIOCMBIS:
789 (void) dcmmctl(dev, *(int *)data, DMBIS);
790 break;
791
792 case TIOCMBIC:
793 (void) dcmmctl(dev, *(int *)data, DMBIC);
794 break;
795
796 case TIOCMGET:
797 *(int *)data = dcmmctl(dev, 0, DMGET);
798 break;
799
800 default:
801 return (ENOTTY);
802 }
803 return (0);
804 }
805
806 dcmparam(tp, t)
807 register struct tty *tp;
808 register struct termios *t;
809 {
810 register struct dcmdevice *dcm;
811 register int port, mode, cflag = t->c_cflag;
812 int ospeed = ttspeedtab(t->c_ospeed, dcmspeedtab);
813
814 /* check requested parameters */
815 if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
816 return (EINVAL);
817 /* and copy to tty */
818 tp->t_ispeed = t->c_ispeed;
819 tp->t_ospeed = t->c_ospeed;
820 tp->t_cflag = cflag;
821 if (ospeed == 0) {
822 (void) dcmmctl(UNIT(tp->t_dev), MO_OFF, DMSET);
823 return (0);
824 }
825
826 mode = 0;
827 switch (cflag&CSIZE) {
828 case CS5:
829 mode = LC_5BITS; break;
830 case CS6:
831 mode = LC_6BITS; break;
832 case CS7:
833 mode = LC_7BITS; break;
834 case CS8:
835 mode = LC_8BITS; break;
836 }
837 if (cflag&PARENB) {
838 if (cflag&PARODD)
839 mode |= LC_PODD;
840 else
841 mode |= LC_PEVEN;
842 }
843 if (cflag&CSTOPB)
844 mode |= LC_2STOP;
845 else
846 mode |= LC_1STOP;
847 #ifdef DEBUG
848 if (dcmdebug & DDB_PARAM)
849 printf("dcmparam(%d): cflag %x mode %x speed %d uperch %d\n",
850 UNIT(tp->t_dev), cflag, mode, tp->t_ospeed,
851 DCM_USPERCH(tp->t_ospeed));
852 #endif
853
854 port = PORT(tp->t_dev);
855 dcm = dcm_addr[BOARD(tp->t_dev)];
856 /*
857 * Wait for transmitter buffer to empty.
858 */
859 while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
860 DELAY(DCM_USPERCH(tp->t_ospeed));
861 /*
862 * Make changes known to hardware.
863 */
864 dcm->dcm_data[port].dcm_baud = ospeed;
865 dcm->dcm_data[port].dcm_conf = mode;
866 SEM_LOCK(dcm);
867 dcm->dcm_cmdtab[port].dcm_data |= CT_CON;
868 dcm->dcm_cr |= (1 << port);
869 SEM_UNLOCK(dcm);
870 /*
871 * Delay for config change to take place. Weighted by baud.
872 * XXX why do we do this?
873 */
874 DELAY(16 * DCM_USPERCH(tp->t_ospeed));
875 return (0);
876 }
877
878 void
879 dcmstart(tp)
880 register struct tty *tp;
881 {
882 register struct dcmdevice *dcm;
883 register struct dcmpreg *pp;
884 register struct dcmtfifo *fifo;
885 register char *bp;
886 register unsigned tail, next;
887 register int port, nch;
888 unsigned head;
889 char buf[16];
890 int s;
891 #ifdef IOSTATS
892 struct dcmstats *dsp = &dcmstats[BOARD(tp->t_dev)];
893 int tch = 0;
894 #endif
895
896 s = spltty();
897 #ifdef IOSTATS
898 dsp->xints++;
899 #endif
900 #ifdef DEBUG
901 if (dcmdebug & DDB_OUTPUT)
902 printf("dcmstart(%d): state %x flags %x outcc %d\n",
903 UNIT(tp->t_dev), tp->t_state, tp->t_flags,
904 tp->t_outq.c_cc);
905 #endif
906 if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
907 goto out;
908 if (tp->t_outq.c_cc <= tp->t_lowat) {
909 if (tp->t_state&TS_ASLEEP) {
910 tp->t_state &= ~TS_ASLEEP;
911 wakeup((caddr_t)&tp->t_outq);
912 }
913 selwakeup(&tp->t_wsel);
914 }
915 if (tp->t_outq.c_cc == 0) {
916 #ifdef IOSTATS
917 dsp->xempty++;
918 #endif
919 goto out;
920 }
921
922 dcm = dcm_addr[BOARD(tp->t_dev)];
923 port = PORT(tp->t_dev);
924 pp = dcm_preg(dcm, port);
925 tail = pp->t_tail & TX_MASK;
926 next = (tail + 1) & TX_MASK;
927 head = pp->t_head & TX_MASK;
928 if (head == next)
929 goto out;
930 fifo = &dcm->dcm_tfifos[3-port][tail];
931 again:
932 nch = q_to_b(&tp->t_outq, buf, (head - next) & TX_MASK);
933 #ifdef IOSTATS
934 tch += nch;
935 #endif
936 #ifdef DEBUG
937 if (dcmdebug & DDB_OUTPUT)
938 printf("\thead %x tail %x nch %d\n", head, tail, nch);
939 #endif
940 /*
941 * Loop transmitting all the characters we can.
942 */
943 for (bp = buf; --nch >= 0; bp++) {
944 fifo->data_char = *bp;
945 pp->t_tail = next;
946 /*
947 * If this is the first character,
948 * get the hardware moving right now.
949 */
950 if (bp == buf) {
951 tp->t_state |= TS_BUSY;
952 SEM_LOCK(dcm);
953 dcm->dcm_cmdtab[port].dcm_data |= CT_TX;
954 dcm->dcm_cr |= (1 << port);
955 SEM_UNLOCK(dcm);
956 }
957 tail = next;
958 fifo = tail ? fifo+1 : &dcm->dcm_tfifos[3-port][0];
959 next = (next + 1) & TX_MASK;
960 }
961 /*
962 * Head changed while we were loading the buffer,
963 * go back and load some more if we can.
964 */
965 if (tp->t_outq.c_cc && head != (pp->t_head & TX_MASK)) {
966 #ifdef IOSTATS
967 dsp->xrestarts++;
968 #endif
969 head = pp->t_head & TX_MASK;
970 goto again;
971 }
972
973 /*
974 * Kick it one last time in case it finished while we were
975 * loading the last bunch.
976 */
977 if (bp > &buf[1]) {
978 tp->t_state |= TS_BUSY;
979 SEM_LOCK(dcm);
980 dcm->dcm_cmdtab[port].dcm_data |= CT_TX;
981 dcm->dcm_cr |= (1 << port);
982 SEM_UNLOCK(dcm);
983 }
984 #ifdef DEBUG
985 if (dcmdebug & DDB_INTR)
986 printf("dcmstart(%d): head %x tail %x outqcc %d\n",
987 UNIT(tp->t_dev), head, tail, tp->t_outq.c_cc);
988 #endif
989 out:
990 #ifdef IOSTATS
991 dsp->xchars += tch;
992 if (tch <= DCMXBSIZE)
993 dsp->xsilo[tch]++;
994 else
995 dsp->xsilo[DCMXBSIZE+1]++;
996 #endif
997 splx(s);
998 }
999
1000 /*
1001 * Stop output on a line.
1002 */
1003 dcmstop(tp, flag)
1004 register struct tty *tp;
1005 {
1006 int s;
1007
1008 s = spltty();
1009 if (tp->t_state & TS_BUSY) {
1010 /* XXX is there some way to safely stop transmission? */
1011 if ((tp->t_state&TS_TTSTOP) == 0)
1012 tp->t_state |= TS_FLUSH;
1013 }
1014 splx(s);
1015 }
1016
1017 /*
1018 * Modem control
1019 */
1020 dcmmctl(dev, bits, how)
1021 dev_t dev;
1022 int bits, how;
1023 {
1024 register struct dcmdevice *dcm;
1025 int s, unit, brd, hit = 0;
1026
1027 unit = UNIT(dev);
1028 #ifdef DEBUG
1029 if (dcmdebug & DDB_MODEM)
1030 printf("dcmmctl(%d) unit %d bits 0x%x how %x\n",
1031 BOARD(unit), unit, bits, how);
1032 #endif
1033
1034 brd = BOARD(unit);
1035 dcm = dcm_addr[brd];
1036 s = spltty();
1037 switch (how) {
1038
1039 case DMSET:
1040 dcm_modem[unit]->mdmout = bits;
1041 hit++;
1042 break;
1043
1044 case DMBIS:
1045 dcm_modem[unit]->mdmout |= bits;
1046 hit++;
1047 break;
1048
1049 case DMBIC:
1050 dcm_modem[unit]->mdmout &= ~bits;
1051 hit++;
1052 break;
1053
1054 case DMGET:
1055 bits = dcm_modem[unit]->mdmin;
1056 if (dcmsoftCAR[brd] & FLAG_STDDCE)
1057 bits = hp2dce_in(bits);
1058 break;
1059 }
1060 if (hit) {
1061 SEM_LOCK(dcm);
1062 dcm->dcm_modemchng |= 1<<(unit & 3);
1063 dcm->dcm_cr |= CR_MODM;
1064 SEM_UNLOCK(dcm);
1065 DELAY(10); /* delay until done */
1066 (void) splx(s);
1067 }
1068 return (bits);
1069 }
1070
1071 /*
1072 * Set board to either interrupt per-character or at a fixed interval.
1073 */
1074 dcmsetischeme(brd, flags)
1075 int brd, flags;
1076 {
1077 register struct dcmdevice *dcm = dcm_addr[brd];
1078 register struct dcmischeme *dis = &dcmischeme[brd];
1079 register int i;
1080 u_char mask;
1081 int perchar = flags & DIS_PERCHAR;
1082
1083 #ifdef DEBUG
1084 if (dcmdebug & DDB_INTSCHM)
1085 printf("dcmsetischeme(%d, %d): cur %d, ints %d, chars %d\n",
1086 brd, perchar, dis->dis_perchar,
1087 dis->dis_intr, dis->dis_char);
1088 if ((flags & DIS_RESET) == 0 && perchar == dis->dis_perchar) {
1089 printf("dcmsetischeme(%d): redundent request %d\n",
1090 brd, perchar);
1091 return;
1092 }
1093 #endif
1094 /*
1095 * If perchar is non-zero, we enable interrupts on all characters
1096 * otherwise we disable perchar interrupts and use periodic
1097 * polling interrupts.
1098 */
1099 dis->dis_perchar = perchar;
1100 mask = perchar ? 0xf : 0x0;
1101 for (i = 0; i < 256; i++)
1102 dcm->dcm_bmap[i].data_data = mask;
1103 /*
1104 * Don't slow down tandem mode, interrupt on flow control
1105 * chars for any port on the board.
1106 */
1107 if (!perchar) {
1108 register struct tty *tp = dcm_tty[MKUNIT(brd, 0)];
1109 int c;
1110
1111 for (i = 0; i < 4; i++, tp++) {
1112 if ((c = tp->t_cc[VSTART]) != _POSIX_VDISABLE)
1113 dcm->dcm_bmap[c].data_data |= (1 << i);
1114 if ((c = tp->t_cc[VSTOP]) != _POSIX_VDISABLE)
1115 dcm->dcm_bmap[c].data_data |= (1 << i);
1116 }
1117 }
1118 /*
1119 * Board starts with timer disabled so if first call is to
1120 * set perchar mode then we don't want to toggle the timer.
1121 */
1122 if (flags == (DIS_RESET|DIS_PERCHAR))
1123 return;
1124 /*
1125 * Toggle card 16.7ms interrupts (we first make sure that card
1126 * has cleared the bit so it will see the toggle).
1127 */
1128 while (dcm->dcm_cr & CR_TIMER)
1129 ;
1130 SEM_LOCK(dcm);
1131 dcm->dcm_cr |= CR_TIMER;
1132 SEM_UNLOCK(dcm);
1133 }
1134
1135 /*
1136 * Following are all routines needed for DCM to act as console
1137 */
1138 #include <dev/cons.h>
1139
1140 dcmcnprobe(cp)
1141 struct consdev *cp;
1142 {
1143 register struct hp_hw *hw;
1144 int unit;
1145
1146 /* locate the major number */
1147 for (dcmmajor = 0; dcmmajor < nchrdev; dcmmajor++)
1148 if (cdevsw[dcmmajor].d_open == dcmopen)
1149 break;
1150
1151 /*
1152 * Implicitly assigns the lowest select code DCM card found to be
1153 * logical unit 0 (actually CONUNIT). If your config file does
1154 * anything different, you're screwed.
1155 */
1156 for (hw = sc_table; hw->hw_type; hw++)
1157 if (HW_ISDEV(hw, D_COMMDCM) && !badaddr((short *)hw->hw_kva))
1158 break;
1159 if (!HW_ISDEV(hw, D_COMMDCM)) {
1160 cp->cn_pri = CN_DEAD;
1161 return;
1162 }
1163 unit = CONUNIT;
1164 dcm_addr[BOARD(CONUNIT)] = (struct dcmdevice *)hw->hw_kva;
1165
1166 /* initialize required fields */
1167 cp->cn_dev = makedev(dcmmajor, unit);
1168 switch (dcm_addr[BOARD(unit)]->dcm_rsid) {
1169 case DCMID:
1170 cp->cn_pri = CN_NORMAL;
1171 break;
1172 case DCMID|DCMCON:
1173 cp->cn_pri = CN_REMOTE;
1174 break;
1175 default:
1176 cp->cn_pri = CN_DEAD;
1177 return;
1178 }
1179 /*
1180 * If dcmconsole is initialized, raise our priority.
1181 */
1182 if (dcmconsole == UNIT(unit))
1183 cp->cn_pri = CN_REMOTE;
1184 #ifdef KGDB_CHEAT
1185 /*
1186 * This doesn't currently work, at least not with ite consoles;
1187 * the console hasn't been initialized yet.
1188 */
1189 if (major(kgdb_dev) == dcmmajor && BOARD(kgdb_dev) == BOARD(unit)) {
1190 (void) dcminit(kgdb_dev, kgdb_rate);
1191 if (kgdb_debug_init) {
1192 /*
1193 * We assume that console is ready for us...
1194 * this assumes that a dca or ite console
1195 * has been selected already and will init
1196 * on the first putc.
1197 */
1198 printf("dcm%d: ", UNIT(kgdb_dev));
1199 kgdb_connect(1);
1200 }
1201 }
1202 #endif
1203 }
1204
1205 dcmcninit(cp)
1206 struct consdev *cp;
1207 {
1208 dcminit(cp->cn_dev, dcmdefaultrate);
1209 dcmconsinit = 1;
1210 dcmconsole = UNIT(cp->cn_dev);
1211 }
1212
1213 dcminit(dev, rate)
1214 dev_t dev;
1215 int rate;
1216 {
1217 register struct dcmdevice *dcm = dcm_addr[BOARD(dev)];
1218 int s, mode, port;
1219
1220 port = PORT(dev);
1221 mode = LC_8BITS | LC_1STOP;
1222 s = splhigh();
1223 /*
1224 * Wait for transmitter buffer to empty.
1225 */
1226 while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
1227 DELAY(DCM_USPERCH(rate));
1228 /*
1229 * Make changes known to hardware.
1230 */
1231 dcm->dcm_data[port].dcm_baud = ttspeedtab(rate, dcmspeedtab);
1232 dcm->dcm_data[port].dcm_conf = mode;
1233 SEM_LOCK(dcm);
1234 dcm->dcm_cmdtab[port].dcm_data |= CT_CON;
1235 dcm->dcm_cr |= (1 << port);
1236 SEM_UNLOCK(dcm);
1237 /*
1238 * Delay for config change to take place. Weighted by baud.
1239 * XXX why do we do this?
1240 */
1241 DELAY(16 * DCM_USPERCH(rate));
1242 splx(s);
1243 }
1244
1245 dcmcngetc(dev)
1246 dev_t dev;
1247 {
1248 register struct dcmdevice *dcm = dcm_addr[BOARD(dev)];
1249 register struct dcmrfifo *fifo;
1250 register struct dcmpreg *pp;
1251 register unsigned head;
1252 int s, c, stat, port;
1253
1254 port = PORT(dev);
1255 pp = dcm_preg(dcm, port);
1256 s = splhigh();
1257 head = pp->r_head & RX_MASK;
1258 fifo = &dcm->dcm_rfifos[3-port][head>>1];
1259 while (head == (pp->r_tail & RX_MASK))
1260 ;
1261 /*
1262 * If board interrupts are enabled, just let our received char
1263 * interrupt through in case some other port on the board was
1264 * busy. Otherwise we must clear the interrupt.
1265 */
1266 SEM_LOCK(dcm);
1267 if ((dcm->dcm_ic & IC_IE) == 0)
1268 stat = dcm->dcm_iir;
1269 SEM_UNLOCK(dcm);
1270 c = fifo->data_char;
1271 stat = fifo->data_stat;
1272 pp->r_head = (head + 2) & RX_MASK;
1273 splx(s);
1274 return (c);
1275 }
1276
1277 /*
1278 * Console kernel output character routine.
1279 */
1280 dcmcnputc(dev, c)
1281 dev_t dev;
1282 int c;
1283 {
1284 register struct dcmdevice *dcm = dcm_addr[BOARD(dev)];
1285 register struct dcmpreg *pp;
1286 unsigned tail;
1287 int s, port, stat;
1288
1289 port = PORT(dev);
1290 pp = dcm_preg(dcm, port);
1291 s = splhigh();
1292 #ifdef KGDB
1293 if (dev != kgdb_dev)
1294 #endif
1295 if (dcmconsinit == 0) {
1296 (void) dcminit(dev, dcmdefaultrate);
1297 dcmconsinit = 1;
1298 }
1299 tail = pp->t_tail & TX_MASK;
1300 while (tail != (pp->t_head & TX_MASK))
1301 ;
1302 dcm->dcm_tfifos[3-port][tail].data_char = c;
1303 pp->t_tail = tail = (tail + 1) & TX_MASK;
1304 SEM_LOCK(dcm);
1305 dcm->dcm_cmdtab[port].dcm_data |= CT_TX;
1306 dcm->dcm_cr |= (1 << port);
1307 SEM_UNLOCK(dcm);
1308 while (tail != (pp->t_head & TX_MASK))
1309 ;
1310 /*
1311 * If board interrupts are enabled, just let our completion
1312 * interrupt through in case some other port on the board
1313 * was busy. Otherwise we must clear the interrupt.
1314 */
1315 if ((dcm->dcm_ic & IC_IE) == 0) {
1316 SEM_LOCK(dcm);
1317 stat = dcm->dcm_iir;
1318 SEM_UNLOCK(dcm);
1319 }
1320 splx(s);
1321 }
1322 #endif
1323