From 0567d4ef5fa68876b3d70414d79e61c5cad5db3e Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 26 Jun 2004 09:20:07 +0000 Subject: [PATCH] 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. --- sys/dev/cy/cy.c | 25 ++++++++++++------------- sys/dev/rc/rc.c | 13 ++++++------- sys/dev/si/si.c | 4 ++-- sys/dev/si/si.h | 1 - sys/dev/sio/sio.c | 11 +++++------ sys/dev/sx/sx.c | 4 ++-- sys/dev/sx/sx.h | 1 - sys/dev/usb/ucom.c | 13 ++++--------- sys/dev/usb/ucomvar.h | 1 - sys/kern/tty.c | 3 +-- sys/net/ppp_tty.c | 1 + sys/pc98/cbus/sio.c | 11 +++++------ sys/pc98/pc98/sio.c | 11 +++++------ sys/sys/tty.h | 2 +- 14 files changed, 44 insertions(+), 57 deletions(-) diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c index 53caa3edb66..3a1d26ed3dc 100644 --- a/sys/dev/cy/cy.c +++ b/sys/dev/cy/cy.c @@ -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]) { diff --git a/sys/dev/rc/rc.c b/sys/dev/rc/rc.c index de80e92a01e..18bb09e8616 100644 --- a/sys/dev/rc/rc.c +++ b/sys/dev/rc/rc.c @@ -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(); diff --git a/sys/dev/si/si.c b/sys/dev/si/si.c index ad7d426054a..ffe26cb37ad 100644 --- a/sys/dev/si/si.c +++ b/sys/dev/si/si.c @@ -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; diff --git a/sys/dev/si/si.h b/sys/dev/si/si.h index a0c1ebdb111..3222e2e204d 100644 --- a/sys/dev/si/si.h +++ b/sys/dev/si/si.h @@ -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; diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index 83b62ff1caa..1dbf3c811f6 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -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); diff --git a/sys/dev/sx/sx.c b/sys/dev/sx/sx.c index 8a523fa378b..e7f5d82904c 100644 --- a/sys/dev/sx/sx.c +++ b/sys/dev/sx/sx.c @@ -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; diff --git a/sys/dev/sx/sx.h b/sys/dev/sx/sx.h index 5d142a7c434..3d4c9710461 100644 --- a/sys/dev/sx/sx.h +++ b/sys/dev/sx/sx.h @@ -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. */ diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index 82245b79089..2d28cf7c487 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -66,11 +66,6 @@ __FBSDID("$FreeBSD$"); * POSSIBILITY OF SUCH DAMAGE. */ -/* - * TODO: - * 1. How do I handle hotchar? - */ - #include #include #include @@ -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) diff --git a/sys/dev/usb/ucomvar.h b/sys/dev/usb/ucomvar.h index 63146b9721e..818c3245a83 100644 --- a/sys/dev/usb/ucomvar.h +++ b/sys/dev/usb/ucomvar.h @@ -163,7 +163,6 @@ struct ucom_softc { int sc_state; int sc_poll; - u_char hotchar; u_char sc_lsr; u_char sc_msr; diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 5520b8288a8..90d90cf333a 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -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); } diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c index 05ffb169ab6..a76234dd9af 100644 --- a/sys/net/ppp_tty.c +++ b/sys/net/ppp_tty.c @@ -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); /* diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c index bdc1c6a377a..5895396164d 100644 --- a/sys/pc98/cbus/sio.c +++ b/sys/pc98/cbus/sio.c @@ -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); diff --git a/sys/pc98/pc98/sio.c b/sys/pc98/pc98/sio.c index bdc1c6a377a..5895396164d 100644 --- a/sys/pc98/pc98/sio.c +++ b/sys/pc98/pc98/sio.c @@ -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); diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 853b5f3f5fb..fea9bcd8b46 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -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); -- 2.45.2