ospeed = sabtty_speed(t->c_ospeed); if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed)) return (EINVAL);  s = spltty();   sabtty_mdmctrl(sc, TIOCM_DTR, (t->c_ospeed == 0) ? DMBIC : DMBIS);  dafo = SAB_READ(sc, SAB_DAFO);  cflag = t->c_cflag; if (sc->sc_flags & (SABTTYF_CONS_IN | SABTTYF_CONS_OUT)) { cflag |= CLOCAL; cflag &= ~HUPCL; }  if (cflag & CSTOPB) dafo |= SAB_DAFO_STOP; else dafo &= ~SAB_DAFO_STOP;  dafo &= ~SAB_DAFO_CHL_CSIZE; switch (cflag & CSIZE) { case CS5: dafo |= SAB_DAFO_CHL_CS5; break; case CS6: dafo |= SAB_DAFO_CHL_CS6; break; case CS7: dafo |= SAB_DAFO_CHL_CS7; break; default: dafo |= SAB_DAFO_CHL_CS8; break; }  dafo &= ~SAB_DAFO_PARMASK; if (cflag & PARENB) { if (cflag & PARODD) dafo |= SAB_DAFO_PAR_ODD; else dafo |= SAB_DAFO_PAR_EVEN; } else dafo |= SAB_DAFO_PAR_NONE;  if (ospeed != 0) { SAB_WRITE(sc, SAB_BGR, ospeed & 0xff); r = SAB_READ(sc, SAB_CCR2); r &= ~(SAB_CCR2_BR9 | SAB_CCR2_BR8); r |= (ospeed >> 2) & (SAB_CCR2_BR9 | SAB_CCR2_BR8); SAB_WRITE(sc, SAB_CCR2, r); }  r = SAB_READ(sc, SAB_MODE); r |= SAB_MODE_RAC; if (cflag & CRTSCTS) { r &= ~(SAB_MODE_RTS | SAB_MODE_FCTS); r |= SAB_MODE_FRTS; sc->sc_imr1 &= ~SAB_IMR1_CSC; } else { r |= SAB_MODE_RTS | SAB_MODE_FCTS; r &= ~SAB_MODE_FRTS; sc->sc_imr1 |= SAB_IMR1_CSC; } SAB_WRITE(sc, SAB_MODE, r); SAB_WRITE(sc, SAB_IMR1, sc->sc_imr1);  tp->t_cflag = cflag;  splx(s); return (0);
return (sabttyparam(sc, tp, t));
sabtty_param(tp, t)	struct tty *tp;	struct termios *t;{	struct sab_softc *bc = sab_cd.cd_devs[SAB_CARD(tp->t_dev)];	struct sabtty_softc *sc = bc->sc_child[SAB_PORT(tp->t_dev)];	int s, ospeed;	tcflag_t cflag;	u_int8_t dafo, r;	ospeed = sabtty_speed(t->c_ospeed);	if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))		return (EINVAL);	s = spltty();	/* hang up line if ospeed is zero, otherwise raise dtr */	sabtty_mdmctrl(sc, TIOCM_DTR,	    (t->c_ospeed == 0) ? DMBIC : DMBIS);	dafo = SAB_READ(sc, SAB_DAFO);	cflag = t->c_cflag;	if (sc->sc_flags & (SABTTYF_CONS_IN | SABTTYF_CONS_OUT)) {		cflag |= CLOCAL;		cflag &= ~HUPCL;	}	if (cflag & CSTOPB)		dafo |= SAB_DAFO_STOP;	else		dafo &= ~SAB_DAFO_STOP;	dafo &= ~SAB_DAFO_CHL_CSIZE;	switch (cflag & CSIZE) {	case CS5:		dafo |= SAB_DAFO_CHL_CS5;		break;	case CS6:		dafo |= SAB_DAFO_CHL_CS6;		break;	case CS7:		dafo |= SAB_DAFO_CHL_CS7;		break;	default:		dafo |= SAB_DAFO_CHL_CS8;		break;	}	dafo &= ~SAB_DAFO_PARMASK;	if (cflag & PARENB) {		if (cflag & PARODD)			dafo |= SAB_DAFO_PAR_ODD;		else			dafo |= SAB_DAFO_PAR_EVEN;	} else		dafo |= SAB_DAFO_PAR_NONE;	if (ospeed != 0) {		SAB_WRITE(sc, SAB_BGR, ospeed & 0xff);		r = SAB_READ(sc, SAB_CCR2);		r &= ~(SAB_CCR2_BR9 | SAB_CCR2_BR8);		r |= (ospeed >> 2) & (SAB_CCR2_BR9 | SAB_CCR2_BR8);		SAB_WRITE(sc, SAB_CCR2, r);	}	r = SAB_READ(sc, SAB_MODE);	r |= SAB_MODE_RAC;	if (cflag & CRTSCTS) {		r &= ~(SAB_MODE_RTS | SAB_MODE_FCTS);		r |= SAB_MODE_FRTS;		sc->sc_imr1 &= ~SAB_IMR1_CSC;	} else {		r |= SAB_MODE_RTS | SAB_MODE_FCTS;		r &= ~SAB_MODE_FRTS;		sc->sc_imr1 |= SAB_IMR1_CSC;	}	SAB_WRITE(sc, SAB_MODE, r);	SAB_WRITE(sc, SAB_IMR1, sc->sc_imr1);	tp->t_cflag = cflag;	splx(s);	return (0);}