sc->sc_flags &= ~SABTTYF_STOP; sc->sc_flags |= SABTTYF_DONE; needsoft = 1;
sabtty_intr(sc, needsoftp)	struct sabtty_softc *sc;	int *needsoftp;{	u_int8_t isr0, isr1;	int i, len = 0, needsoft = 0, r = 0, clearfifo = 0;	isr0 = SAB_READ(sc, SAB_ISR0);	isr1 = SAB_READ(sc, SAB_ISR1);	if (isr0 || isr1)		r = 1;	if (isr0 & SAB_ISR0_RPF) {		len = 32;		clearfifo = 1;	}	if (isr0 & SAB_ISR0_TCD) {		len = (32 - 1) & SAB_READ(sc, SAB_RBCL);		clearfifo = 1;	}	if (isr0 & SAB_ISR0_TIME) {		sabtty_cec_wait(sc);		SAB_WRITE(sc, SAB_CMDR, SAB_CMDR_RFRD);	}	if (isr0 & SAB_ISR0_RFO) {		sc->sc_flags |= SABTTYF_RINGOVERFLOW;		clearfifo = 1;	}	if (len != 0) {		u_int8_t *ptr;		ptr = sc->sc_rput;		for (i = 0; i < len; i++) {			*ptr++ = SAB_READ(sc, SAB_RFIFO);			if (ptr == sc->sc_rend)				ptr = sc->sc_rbuf;			if (ptr == sc->sc_rget) {				if (ptr == sc->sc_rbuf)					ptr = sc->sc_rend;				ptr--;				sc->sc_flags |= SABTTYF_RINGOVERFLOW;			}		}		sc->sc_rput = ptr;		needsoft = 1;	}	if (clearfifo) {		sabtty_cec_wait(sc);		SAB_WRITE(sc, SAB_CMDR, SAB_CMDR_RMC);	}	if (isr0 & SAB_ISR0_CDSC) {		sc->sc_flags |= SABTTYF_CDCHG;		needsoft = 1;	}	if (isr1 & SAB_ISR1_BRK)		sabtty_abort(sc);	if (isr1 & SAB_ISR1_XPR) {		r = 1;		if ((sc->sc_flags & SABTTYF_STOP) == 0) {			len = 32;			if (sc->sc_txc < 32)				len = sc->sc_txc;			for (i = 0; i < len; i++) {				SAB_WRITE(sc, SAB_XFIFO + i, *sc->sc_txp);				sc->sc_txp++;				sc->sc_txc--;			}			if (i != 0) {				sabtty_cec_wait(sc);				SAB_WRITE(sc, SAB_CMDR, SAB_CMDR_XF);			}		}		if ((sc->sc_txc == 0) || (sc->sc_flags & SABTTYF_STOP)) {			sc->sc_imr1 |= SAB_IMR1_XPR;			SAB_WRITE(sc, SAB_IMR1, sc->sc_imr1);			sc->sc_flags &= ~SABTTYF_STOP;			sc->sc_flags |= SABTTYF_DONE;			needsoft = 1;		}	}	if (needsoft)		*needsoftp = needsoft;	return (r);}