switch ((licr >> 4)& 0x3) { case CL_DMAMODE: teoir = 0x08;
switch (cmr & CL_TXMASK) { case CL_TXDMAINT: { u_char dmabsts; int nbuf, busy, resid; void *pbuffer; dmabsts = sc->cl_reg->cl_dmabsts; log(LOG_WARNING, "cl_txintr: DMAMODE channel %x dmabsts %x\n", channel, dmabsts); nbuf = ((dmabsts & 0x8) >> 3) & 0x1; busy = ((dmabsts & 0x4) >> 2) & 0x1;  do { pbuffer = sc->sc_cl[channel].tx[nbuf]; resid = tp->t_outq.c_cc; cnt = min (CL_BUFSIZE,resid); log(LOG_WARNING, "cl_txintr: resid %x cnt %x pbuf %x\n", resid, cnt, pbuffer); if (cnt != 0) { cnt = q_to_b(&tp->t_outq, pbuffer, cnt); resid -= cnt; if (nbuf == 0) { sc->cl_reg->cl_atbadru = ((u_long) sc->sc_cl[channel].txp[nbuf]) >> 16; sc->cl_reg->cl_atbadrl = ((u_long) sc->sc_cl[channel].txp[nbuf]) & 0xffff; sc->cl_reg->cl_atbcnt = cnt; sc->cl_reg->cl_atbsts = 0x43; } else { sc->cl_reg->cl_btbadru = ((u_long) sc->sc_cl[channel].txp[nbuf]) >> 16; sc->cl_reg->cl_btbadrl = ((u_long) sc->sc_cl[channel].txp[nbuf]) & 0xffff; sc->cl_reg->cl_btbcnt = cnt; sc->cl_reg->cl_btbsts = 0x43; } teoir = 0x08; } else { teoir = 0x08; if (tp->t_state & TS_BUSY) { tp->t_state &= ~(TS_BUSY | TS_FLUSH); if (tp->t_state & TS_ASLEEP) { tp->t_state &= ~TS_ASLEEP; wakeup((caddr_t) &tp->t_outq); } selwakeup(&tp->t_wsel); } sc->cl_reg->cl_ier = sc->cl_reg->cl_ier & ~0x3; } nbuf = ~nbuf & 0x1; busy--; } while (resid != 0 && busy != -1); log(LOG_WARNING, "cl_txintr: done\n"); }
cl_txintr(sc)	struct clsoftc *sc;{	static empty = 0;	u_char tir, licr, teoir;	u_char max;	int channel;	struct tty *tp;	int cnt;	u_char buffer[CL_FIFO_MAX +1];	u_char *tptr;	if(((tir = sc->cl_reg->cl_tir) & 0x40) == 0x0) {		/* only if intr is not shared ??? */		printf ("cl_txintr extra intr\n");		return 0;	}	sc->sc_txintrcnt.ev_count++;	channel	= tir & 0x03;	licr	= sc->cl_reg->cl_licr;		sc->sc_cl[channel].txcnt ++;	tp = sc->sc_cl[channel].tty;	if (tp == NULL || (tp->t_state & TS_ISOPEN) == 0) {		sc->cl_reg->cl_teoir = 0x08;		return 1;	}	switch ((licr >> 4)& 0x3) {	case CL_DMAMODE:		teoir = 0x08;		break;	case CL_INTRMODE:		max = sc->cl_reg->cl_tftc;		cnt = min ((int)max,tp->t_outq.c_cc);		if (cnt != 0) {			cnt = q_to_b(&tp->t_outq, buffer, cnt);			empty = 0;			for (tptr = buffer; tptr < &buffer[cnt]; tptr++) {				sc->cl_reg->cl_tdr = *tptr;			}			teoir = 0x00;		} else {			if (empty > 5 && ((empty % 20000 )== 0)) {			printf("cl_txintr to many empty intr %d channel %d\n",				empty, channel);			}			empty++;			teoir = 0x08;			if (tp->t_state & TS_BUSY) {				tp->t_state &= ~(TS_BUSY | TS_FLUSH);				if (tp->t_state & TS_ASLEEP) {					tp->t_state &= ~TS_ASLEEP;					wakeup((caddr_t) &tp->t_outq);				}				selwakeup(&tp->t_wsel);			}			sc->cl_reg->cl_ier = sc->cl_reg->cl_ier & ~0x3;		}		break;	default:		printf("cl_txintr unknown mode %x\n", ((licr >> 4) & 0x3));		/* we probably will go to hell quickly now */		teoir = 0x08;	}	sc->cl_reg->cl_teoir = teoir;	return 1;}