Centralize the line discipline optimization determination in a function
called ttyldoptim(). Use this function from all the relevant drivers. I belive no drivers finger linesw[] directly anymore, paving the way for locking and refcounting.
This commit is contained in:
parent
fe3ec6224a
commit
13e84a71e0
@ -237,7 +237,9 @@ static void cx_error (cx_chan_t *c, int data);
|
||||
static void cx_modem (cx_chan_t *c);
|
||||
static void cx_up (drv_t *d);
|
||||
static void cx_start (drv_t *d);
|
||||
static void disc_optim(struct tty *tp, struct termios *t);
|
||||
#if __FreeBSD_version < 502113
|
||||
static void ttyldoptim(struct tty *tp);
|
||||
#endif
|
||||
#if __FreeBSD_version < 500000
|
||||
static swihand_t cx_softintr;
|
||||
#else
|
||||
@ -1660,7 +1662,7 @@ static int cx_open (dev_t dev, int flag, int mode, struct thread *td)
|
||||
}
|
||||
|
||||
error = ttyld_open (&d->tty, dev);
|
||||
disc_optim (&d->tty, &d->tty.t_termios);
|
||||
ttyldoptim (&d->tty);
|
||||
spl0 ();
|
||||
if (error) {
|
||||
failed: if (! (d->tty.t_state & TS_ISOPEN)) {
|
||||
@ -1701,7 +1703,7 @@ static int cx_close (dev_t dev, int flag, int mode, struct thread *td)
|
||||
}
|
||||
s = splhigh ();
|
||||
ttyld_close(&d->tty, flag);
|
||||
disc_optim (&d->tty, &d->tty.t_termios);
|
||||
ttyldoptim (&d->tty);
|
||||
|
||||
/* Disable receiver.
|
||||
* Transmitter continues sending the queued data. */
|
||||
@ -2129,7 +2131,7 @@ static int cx_ioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct threa
|
||||
if (c->mode == M_ASYNC) {
|
||||
#if __FreeBSD_version >= 502113
|
||||
error = ttyioctl (dev, cmd, data, flag, td);
|
||||
disc_optim (&d->tty, &d->tty.t_termios);
|
||||
ttyldoptim (&d->tty);
|
||||
if (error != ENOTTY) {
|
||||
if (error)
|
||||
CX_DEBUG2 (d, ("ttioctl: 0x%lx, error %d\n", cmd, error));
|
||||
@ -2141,14 +2143,14 @@ static int cx_ioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct threa
|
||||
#else
|
||||
error = (*linesw[d->tty.t_line].l_ioctl) (&d->tty, cmd, data, flag, p);
|
||||
#endif
|
||||
disc_optim (&d->tty, &d->tty.t_termios);
|
||||
ttyldoptim (&d->tty);
|
||||
if (error != ENOIOCTL) {
|
||||
if (error)
|
||||
CX_DEBUG2 (d, ("l_ioctl: 0x%lx, error %d\n", cmd, error));
|
||||
return error;
|
||||
}
|
||||
error = ttioctl (&d->tty, cmd, data, flag);
|
||||
disc_optim (&d->tty, &d->tty.t_termios);
|
||||
ttyldoptim (&d->tty);
|
||||
if (error != ENOIOCTL) {
|
||||
if (error)
|
||||
CX_DEBUG2 (d, ("ttioctl: 0x%lx, error %d\n", cmd, error));
|
||||
@ -2256,16 +2258,20 @@ static void cx_dtrwakeup (void *arg)
|
||||
}
|
||||
|
||||
|
||||
#if __FreeBSD_version < 502113
|
||||
static void
|
||||
disc_optim(tp, t)
|
||||
ttyldoptim(tp)
|
||||
struct tty *tp;
|
||||
struct termios *t;
|
||||
{
|
||||
struct termios *t;
|
||||
|
||||
t = &tp->t_termios;
|
||||
if (CONDITION(t,tp))
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __FreeBSD_version >= 500000
|
||||
void cx_softintr (void *unused)
|
||||
@ -2452,7 +2458,7 @@ static int cx_param (struct tty *tp, struct termios *t)
|
||||
if (! d->chan->dtr)
|
||||
cx_set_dtr (d->chan, 1);
|
||||
|
||||
disc_optim (&d->tty, &d->tty.t_termios);
|
||||
ttyldoptim (&d->tty);
|
||||
cx_set_async_param (d->chan, t->c_ospeed, bits, parity, (t->c_cflag & CSTOPB),
|
||||
!(t->c_cflag & PARENB), (t->c_cflag & CRTSCTS),
|
||||
(t->c_iflag & IXON), (t->c_iflag & IXANY),
|
||||
|
@ -2585,21 +2585,7 @@ disc_optim(tp, t, com)
|
||||
u_char opt;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX can skip a lot more cases if Smarts. Maybe
|
||||
* (IGNCR | ISTRIP | IXON) in c_iflag. But perhaps we
|
||||
* shouldn't skip if (TS_CNTTB | TS_LNCH) is set in t_state.
|
||||
*/
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
|
||||
&& (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
|
||||
&& (!(t->c_iflag & PARMRK)
|
||||
|| (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
|
||||
&& !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
|
||||
&& linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
com->hotchar = linesw[tp->t_line].l_hotchar;
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
#ifndef SOFT_HOTCHAR
|
||||
opt = com->cor[2] & ~CD1400_COR3_SCD34;
|
||||
if (com->hotchar != 0) {
|
||||
|
@ -693,20 +693,6 @@ digimctl(struct digi_p *port, int bits, int how)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
digi_disc_optim(struct tty *tp, struct termios *t, struct digi_p *port)
|
||||
{
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP)) &&
|
||||
(!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK)) &&
|
||||
(!(t->c_iflag & PARMRK) ||
|
||||
(t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK)) &&
|
||||
!(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN)) &&
|
||||
linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
}
|
||||
|
||||
static int
|
||||
digiopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
{
|
||||
@ -853,7 +839,7 @@ digiopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
DLOG(DIGIDB_OPEN, (sc->dev, "port %d: l_open error = %d\n",
|
||||
pnum, error));
|
||||
|
||||
digi_disc_optim(tp, &tp->t_termios, port);
|
||||
ttyldoptim(tp);
|
||||
|
||||
if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
|
||||
port->active_out = TRUE;
|
||||
@ -901,7 +887,7 @@ digiclose(dev_t dev, int flag, int mode, struct thread *td)
|
||||
|
||||
s = spltty();
|
||||
ttyld_close(tp, flag);
|
||||
digi_disc_optim(tp, &tp->t_termios, port);
|
||||
ttyldoptim(tp);
|
||||
digihardclose(port);
|
||||
ttyclose(tp);
|
||||
if (--sc->opencnt == 0)
|
||||
@ -1278,7 +1264,7 @@ digiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
error = ttyioctl(dev, cmd, data, flag, td);
|
||||
if (error == 0 && cmd == TIOCGETA)
|
||||
((struct termios *)data)->c_iflag |= port->c_iflag;
|
||||
digi_disc_optim(tp, &tp->t_termios, port);
|
||||
ttyldoptim(tp);
|
||||
if (error >= 0 && error != ENOTTY)
|
||||
return (error);
|
||||
s = spltty();
|
||||
|
@ -140,7 +140,6 @@ static void rc_reinit(struct rc_softc *);
|
||||
static void printrcflags();
|
||||
#endif
|
||||
static void rc_dtrwakeup(void *);
|
||||
static void disc_optim(struct tty *tp, struct termios *t, struct rc_chans *);
|
||||
static void rc_wait0(struct rc_softc *sc, int chan, int line);
|
||||
|
||||
static d_open_t rcopen;
|
||||
@ -932,7 +931,7 @@ rcopen(dev_t dev, int flag, int mode, d_thread_t *td)
|
||||
goto again;
|
||||
}
|
||||
error = ttyld_open(tp, dev);
|
||||
disc_optim(tp, &tp->t_termios, rc);
|
||||
rc->rc_hotchar = ttyldoptim(tp);
|
||||
if ((tp->t_state & TS_ISOPEN) && CALLOUT(dev))
|
||||
rc->rc_flags |= RC_ACTOUT;
|
||||
out:
|
||||
@ -961,7 +960,7 @@ rcclose(dev_t dev, int flag, int mode, d_thread_t *td)
|
||||
#endif
|
||||
s = spltty();
|
||||
ttyld_close(tp, flag);
|
||||
disc_optim(tp, &tp->t_termios, rc);
|
||||
rc->rc_hotchar = ttyldoptim(tp);
|
||||
rc_hardclose(rc);
|
||||
ttyclose(tp);
|
||||
splx(s);
|
||||
@ -1151,7 +1150,7 @@ rc_param(struct tty *tp, struct termios *ts)
|
||||
|
||||
CCRCMD(sc, rc->rc_chan, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
|
||||
|
||||
disc_optim(tp, ts, rc);
|
||||
rc->rc_hotchar = ttyldoptim(tp);
|
||||
|
||||
/* modem ctl */
|
||||
val = cflag & CLOCAL ? 0 : MCOR1_CDzd;
|
||||
@ -1208,7 +1207,7 @@ rcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, d_thread_t *td)
|
||||
rc = DEV_TO_RC(dev);
|
||||
tp = &rc->rc_tp;
|
||||
error = ttyioctl(dev, cmd, data, flag, td);
|
||||
disc_optim(tp, &tp->t_termios, rc);
|
||||
rc->rc_hotchar = ttyldoptim(tp);
|
||||
if (error != ENOTTY)
|
||||
return (error);
|
||||
s = spltty();
|
||||
@ -1543,22 +1542,6 @@ rc_discard_output(struct rc_chans *rc)
|
||||
ttwwakeup(&rc->rc_tp);
|
||||
}
|
||||
|
||||
static void
|
||||
disc_optim(struct tty *tp, struct termios *t, struct rc_chans *rc)
|
||||
{
|
||||
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
|
||||
&& (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
|
||||
&& (!(t->c_iflag & PARMRK)
|
||||
|| (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
|
||||
&& !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
|
||||
&& linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
rc->rc_hotchar = linesw[tp->t_line].l_hotchar;
|
||||
}
|
||||
|
||||
static void
|
||||
rc_wait0(struct rc_softc *sc, int chan, int line)
|
||||
{
|
||||
|
@ -616,7 +616,6 @@ static int rpparam(struct tty *, struct termios *);
|
||||
static void rpstart(struct tty *);
|
||||
static void rpstop(struct tty *, int);
|
||||
static void rphardclose (struct rp_port *);
|
||||
static void rp_disc_optim (struct tty *tp, struct termios *t);
|
||||
|
||||
static void rp_do_receive(struct rp_port *rp, struct tty *tp,
|
||||
CHANNEL_t *cp, unsigned int ChanStatus)
|
||||
@ -1089,7 +1088,7 @@ rpopen(dev, flag, mode, td)
|
||||
}
|
||||
error = ttyld_open(tp, dev);
|
||||
|
||||
rp_disc_optim(tp, &tp->t_termios);
|
||||
ttyldoptim(tp);
|
||||
if(tp->t_state & TS_ISOPEN && IS_CALLOUT(dev))
|
||||
rp->active_out = TRUE;
|
||||
|
||||
@ -1131,7 +1130,7 @@ rpclose(dev, flag, mode, td)
|
||||
|
||||
oldspl = spltty();
|
||||
ttyld_close(tp, flag);
|
||||
rp_disc_optim(tp, &tp->t_termios);
|
||||
ttyldoptim(tp);
|
||||
rphardclose(rp);
|
||||
|
||||
tp->t_state &= ~TS_BUSY;
|
||||
@ -1321,7 +1320,7 @@ rpioctl(dev, cmd, data, flag, td)
|
||||
t = &tp->t_termios;
|
||||
|
||||
error = ttyioctl(dev, cmd, data, flag, td);
|
||||
rp_disc_optim(tp, &tp->t_termios);
|
||||
ttyldoptim(tp);
|
||||
if(error != ENOTTY)
|
||||
return(error);
|
||||
oldspl = spltty();
|
||||
@ -1543,7 +1542,7 @@ rpparam(tp, t)
|
||||
} else {
|
||||
sDisRTSFlowCtl(cp);
|
||||
}
|
||||
rp_disc_optim(tp, t);
|
||||
ttyldoptim(tp);
|
||||
|
||||
if((cflag & CLOCAL) || (sGetChanStatusLo(cp) & CD_ACT)) {
|
||||
tp->t_state |= TS_CARR_ON;
|
||||
@ -1562,22 +1561,6 @@ rpparam(tp, t)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void
|
||||
rp_disc_optim(tp, t)
|
||||
struct tty *tp;
|
||||
struct termios *t;
|
||||
{
|
||||
if(!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
|
||||
&&(!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
|
||||
&&(!(t->c_iflag & PARMRK)
|
||||
||(t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
|
||||
&& !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
|
||||
&& linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
}
|
||||
|
||||
static void
|
||||
rpstart(tp)
|
||||
struct tty *tp;
|
||||
|
@ -99,7 +99,6 @@ static int si_Sioctl(dev_t, u_long, caddr_t, int, struct thread *);
|
||||
static void si_start(struct tty *);
|
||||
static void si_stop(struct tty *, int);
|
||||
static timeout_t si_lstart;
|
||||
static void si_disc_optim(struct tty *tp, struct termios *t,struct si_port *pp);
|
||||
static void sihardclose(struct si_port *pp);
|
||||
static void sidtrwakeup(void *chan);
|
||||
|
||||
@ -741,7 +740,7 @@ siopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
}
|
||||
|
||||
error = ttyld_open(tp, dev);
|
||||
si_disc_optim(tp, &tp->t_termios, pp);
|
||||
pp->sp_hotchar = ttyldoptim(tp);
|
||||
if (tp->t_state & TS_ISOPEN && IS_CALLOUT(mynor))
|
||||
pp->sp_active_out = TRUE;
|
||||
|
||||
@ -1017,7 +1016,7 @@ siioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
}
|
||||
|
||||
error = ttyioctl(dev, cmd, data, flag, td);
|
||||
si_disc_optim(tp, &tp->t_termios, pp);
|
||||
pp->sp_hotchar = ttyldoptim(tp);
|
||||
if (error != ENOTTY)
|
||||
goto out;
|
||||
|
||||
@ -2075,29 +2074,6 @@ si_command(struct si_port *pp, int cmd, int waitflag)
|
||||
splx(oldspl);
|
||||
}
|
||||
|
||||
static void
|
||||
si_disc_optim(struct tty *tp, struct termios *t, struct si_port *pp)
|
||||
{
|
||||
/*
|
||||
* XXX can skip a lot more cases if Smarts. Maybe
|
||||
* (IGNCR | ISTRIP | IXON) in c_iflag. But perhaps we
|
||||
* shouldn't skip if (TS_CNTTB | TS_LNCH) is set in t_state.
|
||||
*/
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON)) &&
|
||||
(!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK)) &&
|
||||
(!(t->c_iflag & PARMRK) ||
|
||||
(t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK)) &&
|
||||
!(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN)) &&
|
||||
linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
pp->sp_hotchar = linesw[tp->t_line].l_hotchar;
|
||||
DPRINT((pp, DBG_OPTIM, "bypass: %s, hotchar: %x\n",
|
||||
(tp->t_state & TS_CAN_BYPASS_L_RINT) ? "on" : "off",
|
||||
pp->sp_hotchar));
|
||||
}
|
||||
|
||||
|
||||
#ifdef SI_DEBUG
|
||||
|
||||
|
@ -300,8 +300,6 @@ static int siosetwater(struct com_s *com, speed_t speed);
|
||||
static void comstart(struct tty *tp);
|
||||
static void comstop(struct tty *tp, int rw);
|
||||
static timeout_t comwakeup;
|
||||
static void disc_optim(struct tty *tp, struct termios *t,
|
||||
struct com_s *com);
|
||||
|
||||
char sio_driver_name[] = "sio";
|
||||
static struct mtx sio_lock;
|
||||
@ -1352,7 +1350,7 @@ sioopen(dev, flag, mode, td)
|
||||
goto open_top;
|
||||
}
|
||||
error = ttyld_open(tp, dev);
|
||||
disc_optim(tp, &tp->t_termios, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
|
||||
com->active_out = TRUE;
|
||||
siosettimeout();
|
||||
@ -1384,7 +1382,7 @@ sioclose(dev, flag, mode, td)
|
||||
tp = com->tp;
|
||||
s = spltty();
|
||||
ttyld_close(tp, flag);
|
||||
disc_optim(tp, &tp->t_termios, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
comhardclose(com);
|
||||
ttyclose(tp);
|
||||
siosettimeout();
|
||||
@ -2049,7 +2047,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
dt->c_ospeed = tp->t_ospeed;
|
||||
}
|
||||
error = ttyioctl(dev, cmd, data, flag, td);
|
||||
disc_optim(tp, &tp->t_termios, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
if (error != ENOTTY)
|
||||
return (error);
|
||||
s = spltty();
|
||||
@ -2333,7 +2331,7 @@ comparam(tp, t)
|
||||
sio_setreg(com, com_cfcr, com->cfcr_image = cfcr);
|
||||
|
||||
/* XXX shouldn't call functions while intrs are disabled. */
|
||||
disc_optim(tp, t, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
splx(s);
|
||||
@ -2695,24 +2693,6 @@ comwakeup(chan)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
disc_optim(tp, t, com)
|
||||
struct tty *tp;
|
||||
struct termios *t;
|
||||
struct com_s *com;
|
||||
{
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
|
||||
&& (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
|
||||
&& (!(t->c_iflag & PARMRK)
|
||||
|| (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
|
||||
&& !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
|
||||
&& linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
com->hotchar = linesw[tp->t_line].l_hotchar;
|
||||
}
|
||||
|
||||
/*
|
||||
* Following are all routines needed for SIO to act as console
|
||||
*/
|
||||
|
@ -71,7 +71,6 @@ static int sx_modem(struct sx_softc *, struct sx_port *, enum sx_mctl, int);
|
||||
static void sx_write_enable(struct sx_port *, int);
|
||||
static void sx_start(struct tty *);
|
||||
static void sx_stop(struct tty *, int);
|
||||
static void sx_disc_optim(struct tty *tp, struct termios *t,struct sx_port *pp);
|
||||
static void sxhardclose(struct sx_port *pp);
|
||||
static void sxdtrwakeup(void *chan);
|
||||
static void sx_shutdown_chan(struct sx_port *);
|
||||
@ -476,7 +475,7 @@ sxopen(
|
||||
}
|
||||
|
||||
error = ttyld_open(tp, dev);
|
||||
sx_disc_optim(tp, &tp->t_termios, pp);
|
||||
pp->sp_hotchar = ttyldoptim(tp);
|
||||
if (tp->t_state & TS_ISOPEN && DEV_IS_CALLOUT(mynor))
|
||||
pp->sp_active_out = TRUE;
|
||||
|
||||
@ -805,7 +804,7 @@ sxioctl(
|
||||
}
|
||||
|
||||
error = ttyioctl(dev, cmd, data, flag, p);
|
||||
sx_disc_optim(tp, &tp->t_termios, pp);
|
||||
pp->sp_hotchar = ttyldoptim(tp);
|
||||
if (error != ENOTTY)
|
||||
goto out;
|
||||
|
||||
@ -1921,31 +1920,6 @@ sx_stop(
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static void
|
||||
sx_disc_optim(
|
||||
struct tty *tp,
|
||||
struct termios *t,
|
||||
struct sx_port *pp)
|
||||
{
|
||||
/*
|
||||
* If we're in "raw" mode, we can bypass ttyinput().
|
||||
*/
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON)) &&
|
||||
(!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK)) &&
|
||||
(!(t->c_iflag & PARMRK) ||
|
||||
(t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK)) &&
|
||||
!(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN)) &&
|
||||
linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
pp->sp_hotchar = linesw[tp->t_line].l_hotchar;
|
||||
DPRINT((pp, DBG_OPTIM, "sx_disc_optim: bypass %s, hotchar %x\n",
|
||||
(tp->t_state & TS_CAN_BYPASS_L_RINT) ? "yes" : "no",
|
||||
pp->sp_hotchar));
|
||||
}
|
||||
|
||||
|
||||
#ifdef SX_DEBUG
|
||||
|
||||
void
|
||||
|
@ -155,7 +155,6 @@ Static usbd_status ucomstartread(struct ucom_softc *);
|
||||
Static void ucomreadcb(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
Static void ucomwritecb(usbd_xfer_handle, usbd_private_handle, usbd_status);
|
||||
Static void ucomstopread(struct ucom_softc *);
|
||||
static void disc_optim(struct tty *, struct termios *, struct ucom_softc *);
|
||||
|
||||
devclass_t ucom_devclass;
|
||||
|
||||
@ -402,7 +401,7 @@ ucomopen(dev_t dev, int flag, int mode, usb_proc_ptr p)
|
||||
if (error)
|
||||
goto bad;
|
||||
|
||||
disc_optim(tp, &tp->t_termios, sc);
|
||||
sc->hotchar = ttyldoptim(tp);
|
||||
|
||||
DPRINTF(("%s: ucomopen: success\n", USBDEVNAME(sc->sc_dev)));
|
||||
|
||||
@ -462,7 +461,7 @@ ucomclose(dev_t dev, int flag, int mode, usb_proc_ptr p)
|
||||
|
||||
s = spltty();
|
||||
ttyld_close(tp, flag);
|
||||
disc_optim(tp, &tp->t_termios, sc);
|
||||
sc->hotchar = ttyldoptim(tp);
|
||||
ttyclose(tp);
|
||||
splx(s);
|
||||
|
||||
@ -564,7 +563,7 @@ ucomioctl(dev_t dev, u_long cmd, caddr_t data, int flag, usb_proc_ptr p)
|
||||
#endif
|
||||
|
||||
error = ttyioctl(dev, cmd, data, flag, p);
|
||||
disc_optim(tp, &tp->t_termios, sc);
|
||||
sc->hotchar = ttyldoptim(tp);
|
||||
if (error != ENOTTY) {
|
||||
DPRINTF(("ucomioctl: l_ioctl: error = %d\n", error));
|
||||
return (error);
|
||||
@ -824,7 +823,7 @@ ucomparam(struct tty *tp, struct termios *t)
|
||||
(void)ucomctl(sc, UMCR_RTS, DMBIS);
|
||||
}
|
||||
|
||||
disc_optim(tp, t, sc);
|
||||
sc->hotchar = ttyldoptim(tp);
|
||||
|
||||
uerr = ucomstartread(sc);
|
||||
if (uerr != USBD_NORMAL_COMPLETION)
|
||||
@ -1168,21 +1167,3 @@ ucomstopread(struct ucom_softc *sc)
|
||||
|
||||
DPRINTF(("ucomstopread: leave\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
disc_optim(struct tty *tp, struct termios *t, struct ucom_softc *sc)
|
||||
{
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
|
||||
&& (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
|
||||
&& (!(t->c_iflag & PARMRK)
|
||||
|| (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
|
||||
&& !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
|
||||
&& linesw[tp->t_line].l_rint == ttyinput) {
|
||||
DPRINTF(("disc_optim: bypass l_rint\n"));
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
} else {
|
||||
DPRINTF(("disc_optim: can't bypass l_rint\n"));
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
}
|
||||
sc->hotchar = linesw[tp->t_line].l_hotchar;
|
||||
}
|
||||
|
@ -2760,3 +2760,21 @@ ttyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
return (error);
|
||||
return (ENOTTY);
|
||||
}
|
||||
|
||||
int
|
||||
ttyldoptim(struct tty *tp)
|
||||
{
|
||||
struct termios *t;
|
||||
|
||||
t = &tp->t_termios;
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
|
||||
&& (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
|
||||
&& (!(t->c_iflag & PARMRK)
|
||||
|| (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
|
||||
&& !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
|
||||
&& linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
return (linesw[tp->t_line].l_hotchar);
|
||||
}
|
||||
|
@ -386,8 +386,6 @@ static int siosetwater(struct com_s *com, speed_t speed);
|
||||
static void comstart(struct tty *tp);
|
||||
static void comstop(struct tty *tp, int rw);
|
||||
static timeout_t comwakeup;
|
||||
static void disc_optim(struct tty *tp, struct termios *t,
|
||||
struct com_s *com);
|
||||
|
||||
char sio_driver_name[] = "sio";
|
||||
static struct mtx sio_lock;
|
||||
@ -2069,7 +2067,7 @@ sioopen(dev, flag, mode, td)
|
||||
goto open_top;
|
||||
}
|
||||
error = ttyld_open(tp, dev);
|
||||
disc_optim(tp, &tp->t_termios, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
|
||||
com->active_out = TRUE;
|
||||
siosettimeout();
|
||||
@ -2104,7 +2102,7 @@ sioclose(dev, flag, mode, td)
|
||||
#ifdef PC98
|
||||
com->modem_checking = 0;
|
||||
#endif
|
||||
disc_optim(tp, &tp->t_termios, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
comhardclose(com);
|
||||
ttyclose(tp);
|
||||
siosettimeout();
|
||||
@ -3022,7 +3020,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
dt->c_ospeed = tp->t_ospeed;
|
||||
}
|
||||
error = ttyioctl(dev, cmd, data, flag, td);
|
||||
disc_optim(tp, &tp->t_termios, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
if (error != ENOTTY)
|
||||
return (error);
|
||||
s = spltty();
|
||||
@ -3438,7 +3436,7 @@ comparam(tp, t)
|
||||
#endif
|
||||
|
||||
/* XXX shouldn't call functions while intrs are disabled. */
|
||||
disc_optim(tp, t, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
splx(s);
|
||||
@ -3898,24 +3896,6 @@ commint(dev_t dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
disc_optim(tp, t, com)
|
||||
struct tty *tp;
|
||||
struct termios *t;
|
||||
struct com_s *com;
|
||||
{
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
|
||||
&& (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
|
||||
&& (!(t->c_iflag & PARMRK)
|
||||
|| (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
|
||||
&& !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
|
||||
&& linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
com->hotchar = linesw[tp->t_line].l_hotchar;
|
||||
}
|
||||
|
||||
/*
|
||||
* Following are all routines needed for SIO to act as console
|
||||
*/
|
||||
|
@ -386,8 +386,6 @@ static int siosetwater(struct com_s *com, speed_t speed);
|
||||
static void comstart(struct tty *tp);
|
||||
static void comstop(struct tty *tp, int rw);
|
||||
static timeout_t comwakeup;
|
||||
static void disc_optim(struct tty *tp, struct termios *t,
|
||||
struct com_s *com);
|
||||
|
||||
char sio_driver_name[] = "sio";
|
||||
static struct mtx sio_lock;
|
||||
@ -2069,7 +2067,7 @@ sioopen(dev, flag, mode, td)
|
||||
goto open_top;
|
||||
}
|
||||
error = ttyld_open(tp, dev);
|
||||
disc_optim(tp, &tp->t_termios, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
|
||||
com->active_out = TRUE;
|
||||
siosettimeout();
|
||||
@ -2104,7 +2102,7 @@ sioclose(dev, flag, mode, td)
|
||||
#ifdef PC98
|
||||
com->modem_checking = 0;
|
||||
#endif
|
||||
disc_optim(tp, &tp->t_termios, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
comhardclose(com);
|
||||
ttyclose(tp);
|
||||
siosettimeout();
|
||||
@ -3022,7 +3020,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
dt->c_ospeed = tp->t_ospeed;
|
||||
}
|
||||
error = ttyioctl(dev, cmd, data, flag, td);
|
||||
disc_optim(tp, &tp->t_termios, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
if (error != ENOTTY)
|
||||
return (error);
|
||||
s = spltty();
|
||||
@ -3438,7 +3436,7 @@ comparam(tp, t)
|
||||
#endif
|
||||
|
||||
/* XXX shouldn't call functions while intrs are disabled. */
|
||||
disc_optim(tp, t, com);
|
||||
com->hotchar = ttyldoptim(tp);
|
||||
|
||||
mtx_unlock_spin(&sio_lock);
|
||||
splx(s);
|
||||
@ -3898,24 +3896,6 @@ commint(dev_t dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
disc_optim(tp, t, com)
|
||||
struct tty *tp;
|
||||
struct termios *t;
|
||||
struct com_s *com;
|
||||
{
|
||||
if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
|
||||
&& (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
|
||||
&& (!(t->c_iflag & PARMRK)
|
||||
|| (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
|
||||
&& !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
|
||||
&& linesw[tp->t_line].l_rint == ttyinput)
|
||||
tp->t_state |= TS_CAN_BYPASS_L_RINT;
|
||||
else
|
||||
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
|
||||
com->hotchar = linesw[tp->t_line].l_hotchar;
|
||||
}
|
||||
|
||||
/*
|
||||
* Following are all routines needed for SIO to act as console
|
||||
*/
|
||||
|
@ -303,6 +303,7 @@ void ttyfree(struct tty *tp);
|
||||
void ttyinfo(struct tty *tp);
|
||||
int ttyinput(int c, struct tty *tp);
|
||||
int ttylclose(struct tty *tp, int flag);
|
||||
int ttyldoptim(struct tty *tp);
|
||||
struct tty *ttymalloc(struct tty *tp);
|
||||
int ttymodem(struct tty *tp, int flag);
|
||||
int ttyopen(dev_t device, struct tty *tp);
|
||||
|
Loading…
Reference in New Issue
Block a user