Pick the hotchar out of the tty structure instead of caching private

copies.

No current line disciplines have a dynamically changing hotchar, and
expecting to receive anything sensible during a change in ldisc is
insane so no locking of the hotchar field is necessary.
This commit is contained in:
Poul-Henning Kamp 2004-06-26 09:20:07 +00:00
parent 57ceda5d84
commit cb9ea5f4cb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=131134
14 changed files with 44 additions and 57 deletions

View File

@ -271,7 +271,6 @@ struct com_s {
u_char last_modem_status; /* last MSR read by intr handler */
u_char prev_modem_status; /* last MSR handled by high level */
u_char hotchar; /* ldisc-specific char to be handled ASAP */
u_char *ibuf; /* start of input buffer */
u_char *ibufend; /* end of input buffer */
u_char *ibufold; /* old input buffer, to be freed */
@ -1111,7 +1110,7 @@ siointr1(vcom)
recv_data = cd_inb(iobase, CD1400_RDSR, cy_align);
#ifndef SOFT_HOTCHAR
if (line_status & CD1400_RDSR_SPECIAL
&& com->hotchar != 0)
&& com->tp->t_hotchar != 0)
swi_sched(sio_fast_ih, 0);
#endif
@ -1139,7 +1138,7 @@ siointr1(vcom)
#endif /* 1 */
++com->bytes_in;
#ifdef SOFT_HOTCHAR
if (com->hotchar != 0 && recv_data == com->hotchar)
if (com->tp->t_hotchar != 0 && recv_data == com->tp->t_hotchar)
swi_sched(sio_fast_ih, 0);
#endif
ioptr = com->iptr;
@ -1187,9 +1186,9 @@ siointr1(vcom)
CD1400_RDSR,
cy_align);
#ifdef SOFT_HOTCHAR
if (com->hotchar != 0
if (com->tp->t_hotchar != 0
&& recv_data
== com->hotchar)
== com->tp->t_hotchar)
swi_sched(sio_fast_ih,
0);
#endif
@ -1204,8 +1203,8 @@ siointr1(vcom)
recv_data = cd_inb(iobase, CD1400_RDSR,
cy_align);
#ifdef SOFT_HOTCHAR
if (com->hotchar != 0
&& recv_data == com->hotchar)
if (com->tp->t_hotchar != 0
&& recv_data == com->tp->t_hotchar)
swi_sched(sio_fast_ih, 0);
#endif
} while (--count != 0);
@ -1229,8 +1228,8 @@ siointr1(vcom)
recv_data = cd_inb(iobase, CD1400_RDSR,
cy_align);
#ifdef SOFT_HOTCHAR
if (com->hotchar != 0
&& recv_data == com->hotchar)
if (com->tp->t_hotchar != 0
&& recv_data == com->tp->t_hotchar)
swi_sched(sio_fast_ih, 0);
#endif
ioptr[0] = recv_data;
@ -2578,12 +2577,12 @@ disc_optim(tp, t, com)
u_char opt;
#endif
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
#ifndef SOFT_HOTCHAR
opt = com->cor[2] & ~CD1400_COR3_SCD34;
if (com->hotchar != 0) {
cd_setreg(com, CD1400_SCHR3, com->hotchar);
cd_setreg(com, CD1400_SCHR4, com->hotchar);
if (com->tp->t_hotchar != 0) {
cd_setreg(com, CD1400_SCHR3, com->tp->t_hotchar);
cd_setreg(com, CD1400_SCHR4, com->tp->t_hotchar);
opt |= CD1400_COR3_SCD34;
}
if (opt != com->cor[2]) {

View File

@ -95,7 +95,6 @@ struct rc_chans {
u_char rc_pendcmd; /* special cmd pending */
u_int rc_dtrwait; /* dtr timeout */
u_int rc_dcdwaits; /* how many waits DCD in open */
u_char rc_hotchar; /* end packed optimize */
struct tty rc_tp; /* tty struct */
u_char *rc_iptr; /* Chars input buffer */
u_char *rc_hiwat; /* hi-water mark */
@ -491,7 +490,7 @@ rc_intr(void *arg)
optr[INPUT_FLAGS_SHIFT] = 0;
optr++;
sc->sc_scheduled_event++;
if (val != 0 && val == rc->rc_hotchar)
if (val != 0 && val == rc->rc_tp.t_hotchar)
swi_sched(sc->sc_swicookie, 0);
}
} else {
@ -522,7 +521,7 @@ rc_intr(void *arg)
|| ((iack & RCSR_PE)
&& (rc->rc_tp.t_iflag & INPCK))))
val = 0;
else if (val != 0 && val == rc->rc_hotchar)
else if (val != 0 && val == rc->rc_tp.t_hotchar)
swi_sched(sc->sc_swicookie, 0);
optr[0] = val;
optr[INPUT_FLAGS_SHIFT] = iack;
@ -935,7 +934,7 @@ rcopen(struct cdev *dev, int flag, int mode, d_thread_t *td)
goto again;
}
error = ttyld_open(tp, dev);
rc->rc_hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if ((tp->t_state & TS_ISOPEN) && CALLOUT(dev))
rc->rc_flags |= RC_ACTOUT;
out:
@ -964,7 +963,7 @@ rcclose(struct cdev *dev, int flag, int mode, d_thread_t *td)
#endif
s = spltty();
ttyld_close(tp, flag);
rc->rc_hotchar = ttyldoptim(tp);
ttyldoptim(tp);
rc_hardclose(rc);
ttyclose(tp);
splx(s);
@ -1154,7 +1153,7 @@ rc_param(struct tty *tp, struct termios *ts)
CCRCMD(sc, rc->rc_chan, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
rc->rc_hotchar = ttyldoptim(tp);
ttyldoptim(tp);
/* modem ctl */
val = cflag & CLOCAL ? 0 : MCOR1_CDzd;
@ -1211,7 +1210,7 @@ rcioctl(struct cdev *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);
rc->rc_hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (error != ENOTTY)
return (error);
s = spltty();

View File

@ -742,7 +742,7 @@ siopen(struct cdev *dev, int flag, int mode, struct thread *td)
}
error = ttyld_open(tp, dev);
pp->sp_hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (tp->t_state & TS_ISOPEN && IS_CALLOUT(mynor))
pp->sp_active_out = TRUE;
@ -1024,7 +1024,7 @@ siioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
}
error = ttyioctl(dev, cmd, data, flag, td);
pp->sp_hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (error != ENOTTY)
goto out;

View File

@ -334,7 +334,6 @@ struct si_port {
int sp_dtr_wait; /* DTR holddown in hz */
int sp_delta_overflows;
u_int sp_wopeners; /* # procs waiting DCD */
u_char sp_hotchar; /* ldisc specific ASAP char */
/* Initial state. */
struct termios sp_iin;
struct termios sp_iout;

View File

@ -216,7 +216,6 @@ struct com_s {
u_char last_modem_status; /* last MSR read by intr handler */
u_char prev_modem_status; /* last MSR handled by high level */
u_char hotchar; /* ldisc-specific char to be handled ASAP */
u_char *ibuf; /* start of input buffer */
u_char *ibufend; /* end of input buffer */
u_char *ibufold; /* old input buffer, to be freed */
@ -1383,7 +1382,7 @@ sioopen(dev, flag, mode, td)
goto open_top;
}
error = ttyld_open(tp, dev);
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
com->active_out = TRUE;
siosettimeout();
@ -1424,7 +1423,7 @@ sioclose(dev, flag, mode, td)
tp = com->tp;
s = spltty();
ttyld_close(tp, flag);
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
comhardclose(com);
ttyclose(tp);
siosettimeout();
@ -1876,7 +1875,7 @@ siointr1(com)
recv_data = 0;
}
++com->bytes_in;
if (com->hotchar != 0 && recv_data == com->hotchar)
if (com->tp->t_hotchar != 0 && recv_data == com->tp->t_hotchar)
swi_sched(sio_fast_ih, 0);
ioptr = com->iptr;
if (ioptr >= com->ibufend)
@ -2107,7 +2106,7 @@ sioioctl(dev, cmd, data, flag, td)
dt->c_ospeed = tp->t_ospeed;
}
error = ttyioctl(dev, cmd, data, flag, td);
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (error != ENOTTY)
return (error);
s = spltty();
@ -2375,7 +2374,7 @@ comparam(tp, t)
sio_setreg(com, com_cfcr, com->cfcr_image = cfcr);
/* XXX shouldn't call functions while intrs are disabled. */
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
mtx_unlock_spin(&sio_lock);
splx(s);

View File

@ -477,7 +477,7 @@ sxopen(
}
error = ttyld_open(tp, dev);
pp->sp_hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (tp->t_state & TS_ISOPEN && DEV_IS_CALLOUT(mynor))
pp->sp_active_out = TRUE;
@ -812,7 +812,7 @@ sxioctl(
}
error = ttyioctl(dev, cmd, data, flag, p);
pp->sp_hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (error != ENOTTY)
goto out;

View File

@ -42,7 +42,6 @@ struct sx_port {
int sp_dtr_wait; /* DTR holddown in hz */
int sp_delta_overflows;
u_int sp_wopeners; /* Processes waiting for DCD. */
u_char sp_hotchar; /* ldisc specific ASAP char */
struct termios sp_iin; /* Initial state. */
struct termios sp_iout;
struct termios sp_lin; /* Lock state. */

View File

@ -66,11 +66,6 @@ __FBSDID("$FreeBSD$");
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* TODO:
* 1. How do I handle hotchar?
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -401,7 +396,7 @@ ucomopen(struct cdev *dev, int flag, int mode, usb_proc_ptr p)
if (error)
goto bad;
sc->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
DPRINTF(("%s: ucomopen: success\n", USBDEVNAME(sc->sc_dev)));
@ -461,7 +456,7 @@ ucomclose(struct cdev *dev, int flag, int mode, usb_proc_ptr p)
s = spltty();
ttyld_close(tp, flag);
sc->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
ttyclose(tp);
splx(s);
@ -563,7 +558,7 @@ ucomioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, usb_proc_ptr p)
#endif
error = ttyioctl(dev, cmd, data, flag, p);
sc->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (error != ENOTTY) {
DPRINTF(("ucomioctl: l_ioctl: error = %d\n", error));
return (error);
@ -823,7 +818,7 @@ ucomparam(struct tty *tp, struct termios *t)
(void)ucomctl(sc, UMCR_RTS, DMBIS);
}
sc->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
uerr = ucomstartread(sc);
if (uerr != USBD_NORMAL_COMPLETION)

View File

@ -163,7 +163,6 @@ struct ucom_softc {
int sc_state;
int sc_poll;
u_char hotchar;
u_char sc_lsr;
u_char sc_msr;

View File

@ -2899,7 +2899,7 @@ ttyioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
return (ENOTTY);
}
int
void
ttyldoptim(struct tty *tp)
{
struct termios *t;
@ -2914,7 +2914,6 @@ ttyldoptim(struct tty *tp)
tp->t_state |= TS_CAN_BYPASS_L_RINT;
else
tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
return (tp->t_hotchar);
}

View File

@ -212,6 +212,7 @@ pppopen(dev, tp)
sc->sc_if.if_baudrate = tp->t_ospeed;
tp->t_sc = (caddr_t) sc;
tp->t_hotchar = PPP_FLAG;
ttyflush(tp, FREAD | FWRITE);
/*

View File

@ -278,7 +278,6 @@ struct com_s {
u_char last_modem_status; /* last MSR read by intr handler */
u_char prev_modem_status; /* last MSR handled by high level */
u_char hotchar; /* ldisc-specific char to be handled ASAP */
u_char *ibuf; /* start of input buffer */
u_char *ibufend; /* end of input buffer */
u_char *ibufold; /* old input buffer, to be freed */
@ -2103,7 +2102,7 @@ sioopen(dev, flag, mode, td)
goto open_top;
}
error = ttyld_open(tp, dev);
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
com->active_out = TRUE;
siosettimeout();
@ -2147,7 +2146,7 @@ sioclose(dev, flag, mode, td)
#ifdef PC98
com->modem_checking = 0;
#endif
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
comhardclose(com);
ttyclose(tp);
siosettimeout();
@ -2755,7 +2754,7 @@ status_read:;
recv_data = 0;
}
++com->bytes_in;
if (com->hotchar != 0 && recv_data == com->hotchar)
if (com->tp->t_hotchar != 0 && recv_data == com->tp->t_hotchar)
swi_sched(sio_fast_ih, 0);
ioptr = com->iptr;
if (ioptr >= com->ibufend)
@ -3082,7 +3081,7 @@ sioioctl(dev, cmd, data, flag, td)
dt->c_ospeed = tp->t_ospeed;
}
error = ttyioctl(dev, cmd, data, flag, td);
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (error != ENOTTY)
return (error);
s = spltty();
@ -3426,7 +3425,7 @@ comparam(tp, t)
#endif
/* XXX shouldn't call functions while intrs are disabled. */
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
mtx_unlock_spin(&sio_lock);
splx(s);

View File

@ -278,7 +278,6 @@ struct com_s {
u_char last_modem_status; /* last MSR read by intr handler */
u_char prev_modem_status; /* last MSR handled by high level */
u_char hotchar; /* ldisc-specific char to be handled ASAP */
u_char *ibuf; /* start of input buffer */
u_char *ibufend; /* end of input buffer */
u_char *ibufold; /* old input buffer, to be freed */
@ -2103,7 +2102,7 @@ sioopen(dev, flag, mode, td)
goto open_top;
}
error = ttyld_open(tp, dev);
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
com->active_out = TRUE;
siosettimeout();
@ -2147,7 +2146,7 @@ sioclose(dev, flag, mode, td)
#ifdef PC98
com->modem_checking = 0;
#endif
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
comhardclose(com);
ttyclose(tp);
siosettimeout();
@ -2755,7 +2754,7 @@ status_read:;
recv_data = 0;
}
++com->bytes_in;
if (com->hotchar != 0 && recv_data == com->hotchar)
if (com->tp->t_hotchar != 0 && recv_data == com->tp->t_hotchar)
swi_sched(sio_fast_ih, 0);
ioptr = com->iptr;
if (ioptr >= com->ibufend)
@ -3082,7 +3081,7 @@ sioioctl(dev, cmd, data, flag, td)
dt->c_ospeed = tp->t_ospeed;
}
error = ttyioctl(dev, cmd, data, flag, td);
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
if (error != ENOTTY)
return (error);
s = spltty();
@ -3426,7 +3425,7 @@ comparam(tp, t)
#endif
/* XXX shouldn't call functions while intrs are disabled. */
com->hotchar = ttyldoptim(tp);
ttyldoptim(tp);
mtx_unlock_spin(&sio_lock);
splx(s);

View File

@ -304,7 +304,7 @@ void ttyflush(struct tty *tp, int rw);
void ttyinfo(struct tty *tp);
int ttyinput(int c, struct tty *tp);
int ttylclose(struct tty *tp, int flag);
int ttyldoptim(struct tty *tp);
void ttyldoptim(struct tty *tp);
struct tty *ttymalloc(struct tty *tp);
int ttymodem(struct tty *tp, int flag);
int ttyopen(struct cdev *device, struct tty *tp);