sys/sparc/dev/zs.c
/*
 * Open a zs serial port.  This interface may not be used to open
 * the keyboard and mouse ports. (XXX)
 */
Open a zs serial port.  This interface may not be used to open
the keyboard and mouse ports. (XXX)
Open a zs serial port . This interface may not be used to open the keyboard and mouse ports . ( XXX )
int
zsopen(dev_t dev, int flags, int mode, struct proc *p)
{
	register struct tty *tp;
	register struct zs_chanstate *cs;
	struct zsinfo *zi;
	int unit = minor(dev), zs = unit >> 1, error, s;
	if (zs >= zscd.cd_ndevs || (zi = zscd.cd_devs[zs]) == NULL ||
	    unit == ZS_KBD || unit == ZS_MOUSE)
		return (ENXIO);
	cs = &zi->zi_cs[unit & 1];
	if (cs->cs_consio)
		return (ENXIO);		
	tp = cs->cs_ttyp;
	s = spltty();
	if ((tp->t_state & TS_ISOPEN) == 0) {
		ttychars(tp);
		if (tp->t_ispeed == 0) {
			tp->t_iflag = TTYDEF_IFLAG;
			tp->t_oflag = TTYDEF_OFLAG;
			tp->t_cflag = TTYDEF_CFLAG;
			tp->t_lflag = TTYDEF_LFLAG;
			tp->t_ispeed = tp->t_ospeed = cs->cs_speed;
		}
		(void) zsparam(tp, &tp->t_termios);
		ttsetwater(tp);
	} else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
		splx(s);
		return (EBUSY);
	}
	error = 0;
	for (;;) {
		zs_modem(cs, 1);
		if (cs->cs_softcar)
			tp->t_state |= TS_CARR_ON;
		if (flags & O_NONBLOCK || tp->t_cflag & CLOCAL ||
		    tp->t_state & TS_CARR_ON)
			break;
		tp->t_state |= TS_WOPEN;
		if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
		    ttopen, 0))
			break;
	}
	splx(s);
	if (error == 0)
		error = linesw[tp->t_line].l_open(dev, tp);
	if (error)
		zs_modem(cs, 0);
	return (error);
}
int zsopen ( dev_t dev , int flags , int mode , struct proc * p ) { register struct tty * tp ; register struct zs_chanstate * cs ; struct zsinfo * zi ; int unit = minor ( dev ) , zs = unit >> 1 , error , s ; if ( zs >= zscd . cd_ndevs || ( zi = zscd . cd_devs [ zs ] ) == NULL || unit == ZS_KBD || unit == ZS_MOUSE ) return ( ENXIO ) ; cs = & zi -> zi_cs [ unit & 1 ] ; if ( cs -> cs_consio ) return ( ENXIO ) ; tp = cs -> cs_ttyp ; s = spltty ( ) ; if ( ( tp -> t_state & TS_ISOPEN ) == 0 ) { ttychars ( tp ) ; if ( tp -> t_ispeed == 0 ) { tp -> t_iflag = TTYDEF_IFLAG ; tp -> t_oflag = TTYDEF_OFLAG ; tp -> t_cflag = TTYDEF_CFLAG ; tp -> t_lflag = TTYDEF_LFLAG ; tp -> t_ispeed = tp -> t_ospeed = cs -> cs_speed ; } ( void ) zsparam ( tp , & tp -> t_termios ) ; ttsetwater ( tp ) ; } else if ( tp -> t_state & TS_XCLUDE && p -> p_ucred -> cr_uid != 0 ) { splx ( s ) ; return ( EBUSY ) ; } error = 0 ; for ( ; ; ) { zs_modem ( cs , 1 ) ; if ( cs -> cs_softcar ) tp -> t_state |= TS_CARR_ON ; if ( flags & O_NONBLOCK || tp -> t_cflag & CLOCAL || tp -> t_state & TS_CARR_ON ) break ; tp -> t_state |= TS_WOPEN ; if ( error = ttysleep ( tp , ( caddr_t ) & tp -> t_rawq , TTIPRI | PCATCH , ttopen , 0 ) ) break ; } splx ( s ) ; if ( error == 0 ) error = linesw [ tp -> t_line ] . l_open ( dev , tp ) ; if ( error ) zs_modem ( cs , 0 ) ; return ( error ) ; }
Open a zs serial port.
Open a zs serial port .
/* ??? */ /* loop, turning on the device, until carrier present */