diff options
Diffstat (limited to 'sys')
40 files changed, 271 insertions, 634 deletions
diff --git a/sys/alpha/alpha/promcons.c b/sys/alpha/alpha/promcons.c index 7a2d0e46b8f9..3790021985c8 100644 --- a/sys/alpha/alpha/promcons.c +++ b/sys/alpha/alpha/promcons.c @@ -64,8 +64,6 @@ static d_close_t promclose; static d_read_t promread; static d_write_t promwrite; static d_ioctl_t promioctl; -static d_stop_t promstop; -static d_devtotty_t promdevtotty; #define CDEV_MAJOR 97 static struct cdevsw prom_cdevsw = { @@ -74,10 +72,10 @@ static struct cdevsw prom_cdevsw = { /* read */ promread, /* write */ promwrite, /* ioctl */ promioctl, - /* stop */ promstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ promdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "prom", @@ -98,6 +96,7 @@ static struct callout_handle promtimeouthandle void promstart __P((struct tty *)); void promtimeout __P((void *)); int promparam __P((struct tty *, struct termios *)); +void promstop __P((struct tty *, int)); int promopen(dev, flag, mode, p) @@ -116,9 +115,11 @@ promopen(dev, flag, mode, p) s = spltty(); tp = &prom_tty[unit]; + dev->si_tty = tp; tp->t_oproc = promstart; tp->t_param = promparam; + tp->t_stop = promstop; tp->t_dev = dev; if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_CARR_ON; @@ -246,6 +247,7 @@ promstart(tp) void promstop(tp, flag) struct tty *tp; + int flag; { int s; @@ -270,17 +272,6 @@ promtimeout(v) promtimeouthandle = timeout(promtimeout, tp, polltime); } -struct tty * -promdevtotty(dev) - dev_t dev; -{ - - if (minor(dev) != 0) - panic("promtty: bogus"); - - return &prom_tty[0]; -} - DEV_MODULE(prom, CDEV_MAJOR, NOMAJ, prom_cdevsw, 0, 0); #endif /* _PMAP_MAY_USE_PROM_CONSOLE */ diff --git a/sys/alpha/tlsb/zs_tlsb.c b/sys/alpha/tlsb/zs_tlsb.c index 37a94676f676..9e2d7dcc91e0 100644 --- a/sys/alpha/tlsb/zs_tlsb.c +++ b/sys/alpha/tlsb/zs_tlsb.c @@ -67,8 +67,6 @@ static d_close_t zsclose; static d_read_t zsread; static d_write_t zswrite; static d_ioctl_t zsioctl; -static d_stop_t zsstop; -static d_devtotty_t zsdevtotty; #define CDEV_MAJOR 98 static struct cdevsw zs_cdevsw = { @@ -77,10 +75,10 @@ static struct cdevsw zs_cdevsw = { /* read */ zsread, /* write */ zswrite, /* ioctl */ zsioctl, - /* stop */ zsstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ zsdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "zs", @@ -95,6 +93,7 @@ static struct cdevsw zs_cdevsw = { static void zsstart __P((struct tty *)); static int zsparam __P((struct tty *, struct termios *)); +static void zsstop __P((struct tty *tp, int flag)); /* * Helpers for console support. @@ -270,9 +269,11 @@ zsopen(dev_t dev, int flag, int mode, struct proc *p) s = spltty(); tp = &sc->tty; + dev->si_tty = tp; tp->t_oproc = zsstart; tp->t_param = zsparam; + tp->t_stop = zsstop; tp->t_dev = dev; if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_CARR_ON; @@ -381,15 +382,6 @@ zsstop(struct tty *tp, int flag) splx(s); } -static struct tty * -zsdevtotty(dev_t dev) -{ - struct zs_softc* sc = ZS_SOFTC(minor(dev)); - if (!sc) - return (NULL); - return (&sc->tty); -} - DEV_DRIVER_MODULE(zs, zsc, zs_driver, zs_devclass, zs_cdevsw, 0, 0); /* diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 6a33e68c3843..11ea2408146e 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -204,13 +204,12 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) struct vnode *vp; long pgid; struct pgrp *pgrp; - struct tty *tp, *(*d_tty) __P((dev_t)); + struct tty *tp; caddr_t sg; dev_t dev; sg = stackgap_init(); bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(struct flock)); - d_tty = NULL; #ifdef DEBUG printf("Linux-emul(%d): fcntl(%d, %08x, *)\n", @@ -309,8 +308,10 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) dev = vn_todev(vp); if (vp->v_type != VCHR || dev == NODEV) return EINVAL; - d_tty = devsw(dev)->d_devtotty; - if (!d_tty || (!(tp = (*d_tty)(dev)))) + if (!(devsw(dev)->d_flags & D_TTY)) + return EINVAL; + tp = dev->si_tty; + if (!tp) return EINVAL; if (args->cmd == LINUX_F_GETOWN) { p->p_retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID; diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c index 4181c44e2b4e..8f2109c8cfeb 100644 --- a/sys/dev/cy/cy.c +++ b/sys/dev/cy/cy.c @@ -123,7 +123,6 @@ #define p_com_addr p_cy_addr #define sioattach cyattach #define sioclose cyclose -#define siodevtotty cydevtotty #define siodriver cydriver #define siodtrwakeup cydtrwakeup #define sioinput cyinput @@ -136,7 +135,7 @@ #define sioread cyread #define siosettimeout cysettimeout #define siosetwater cysetwater -#define siostop cystop +#define comstop cystop #define siowrite cywrite #define sio_registered cy_registered #define sio_timeout cy_timeout @@ -179,7 +178,7 @@ * * The following com and tty flags correspond closely: * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and - * siostop()) + * comstop()) * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart()) * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) @@ -347,6 +346,7 @@ static int siosetwater __P((struct com_s *com, speed_t speed)); static int comspeed __P((speed_t speed, u_long cy_clock, int *prescaler_io)); static void comstart __P((struct tty *tp)); +static void comstop __P((struct tty *tp, int rw)); static timeout_t comwakeup; static void disc_optim __P((struct tty *tp, struct termios *t, struct com_s *com)); @@ -370,8 +370,6 @@ static d_close_t sioclose; static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; -static d_stop_t siostop; -static d_devtotty_t siodevtotty; #define CDEV_MAJOR 48 static struct cdevsw sio_cdevsw = { @@ -380,10 +378,10 @@ static struct cdevsw sio_cdevsw = { /* read */ sioread, /* write */ siowrite, /* ioctl */ sioioctl, - /* stop */ siostop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ siodevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ driver_name, @@ -674,6 +672,7 @@ sioopen(dev, flag, mode, p) #else tp = com->tp = &sio_tty[unit]; #endif + dev->si_tty = tp; s = spltty(); /* * We jump to this label after all non-interrupted sleeps to pick @@ -721,6 +720,7 @@ open_top: * callout, and to complete a callin open after DCD rises. */ tp->t_oproc = comstart; + tp->t_stop = comstop; tp->t_param = comparam; tp->t_dev = dev; tp->t_termios = mynor & CALLOUT_MASK @@ -853,7 +853,7 @@ sioclose(dev, flag, mode, p) cd_etc(com, CD1400_ETC_STOPBREAK); (*linesw[tp->t_line].l_close)(tp, flag); disc_optim(tp, &tp->t_termios, com); - siostop(tp, FREAD | FWRITE); + comstop(tp, FREAD | FWRITE); comhardclose(com); ttyclose(tp); siosettimeout(); @@ -2414,7 +2414,7 @@ comstart(tp) } static void -siostop(tp, rw) +comstop(tp, rw) struct tty *tp; int rw; { @@ -2454,22 +2454,6 @@ siostop(tp, rw) comstart(tp); } -static struct tty * -siodevtotty(dev) - dev_t dev; -{ - int mynor; - int unit; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NSIO) - return (NULL); - return (&sio_tty[unit]); -} - static int commctl(com, bits, how) struct com_s *com; diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c index 4181c44e2b4e..8f2109c8cfeb 100644 --- a/sys/dev/cy/cy_isa.c +++ b/sys/dev/cy/cy_isa.c @@ -123,7 +123,6 @@ #define p_com_addr p_cy_addr #define sioattach cyattach #define sioclose cyclose -#define siodevtotty cydevtotty #define siodriver cydriver #define siodtrwakeup cydtrwakeup #define sioinput cyinput @@ -136,7 +135,7 @@ #define sioread cyread #define siosettimeout cysettimeout #define siosetwater cysetwater -#define siostop cystop +#define comstop cystop #define siowrite cywrite #define sio_registered cy_registered #define sio_timeout cy_timeout @@ -179,7 +178,7 @@ * * The following com and tty flags correspond closely: * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and - * siostop()) + * comstop()) * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart()) * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) @@ -347,6 +346,7 @@ static int siosetwater __P((struct com_s *com, speed_t speed)); static int comspeed __P((speed_t speed, u_long cy_clock, int *prescaler_io)); static void comstart __P((struct tty *tp)); +static void comstop __P((struct tty *tp, int rw)); static timeout_t comwakeup; static void disc_optim __P((struct tty *tp, struct termios *t, struct com_s *com)); @@ -370,8 +370,6 @@ static d_close_t sioclose; static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; -static d_stop_t siostop; -static d_devtotty_t siodevtotty; #define CDEV_MAJOR 48 static struct cdevsw sio_cdevsw = { @@ -380,10 +378,10 @@ static struct cdevsw sio_cdevsw = { /* read */ sioread, /* write */ siowrite, /* ioctl */ sioioctl, - /* stop */ siostop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ siodevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ driver_name, @@ -674,6 +672,7 @@ sioopen(dev, flag, mode, p) #else tp = com->tp = &sio_tty[unit]; #endif + dev->si_tty = tp; s = spltty(); /* * We jump to this label after all non-interrupted sleeps to pick @@ -721,6 +720,7 @@ open_top: * callout, and to complete a callin open after DCD rises. */ tp->t_oproc = comstart; + tp->t_stop = comstop; tp->t_param = comparam; tp->t_dev = dev; tp->t_termios = mynor & CALLOUT_MASK @@ -853,7 +853,7 @@ sioclose(dev, flag, mode, p) cd_etc(com, CD1400_ETC_STOPBREAK); (*linesw[tp->t_line].l_close)(tp, flag); disc_optim(tp, &tp->t_termios, com); - siostop(tp, FREAD | FWRITE); + comstop(tp, FREAD | FWRITE); comhardclose(com); ttyclose(tp); siosettimeout(); @@ -2414,7 +2414,7 @@ comstart(tp) } static void -siostop(tp, rw) +comstop(tp, rw) struct tty *tp; int rw; { @@ -2454,22 +2454,6 @@ siostop(tp, rw) comstart(tp); } -static struct tty * -siodevtotty(dev) - dev_t dev; -{ - int mynor; - int unit; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NSIO) - return (NULL); - return (&sio_tty[unit]); -} - static int commctl(com, bits, how) struct com_s *com; diff --git a/sys/dev/dgb/dgb.c b/sys/dev/dgb/dgb.c index 60008abe5133..0f24e8c3781a 100644 --- a/sys/dev/dgb/dgb.c +++ b/sys/dev/dgb/dgb.c @@ -188,6 +188,7 @@ static void fepcmd(struct dgb_p *port, unsigned cmd, unsigned op1, unsigned op2, unsigned ncmds, unsigned bytecmd); static void dgbstart __P((struct tty *tp)); +static void dgbstop __P((struct tty *tp, int rw)); static int dgbparam __P((struct tty *tp, struct termios *t)); static void dgbhardclose __P((struct dgb_p *port)); static void dgb_drain_or_flush __P((struct dgb_p *port)); @@ -206,8 +207,6 @@ static d_close_t dgbclose; static d_read_t dgbread; static d_write_t dgbwrite; static d_ioctl_t dgbioctl; -static d_stop_t dgbstop; -static d_devtotty_t dgbdevtotty; #define CDEV_MAJOR 58 static struct cdevsw dgb_cdevsw = { @@ -216,10 +215,10 @@ static struct cdevsw dgb_cdevsw = { /* read */ dgbread, /* write */ dgbwrite, /* ioctl */ dgbioctl, - /* stop */ dgbstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ dgbdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "dgb", @@ -975,6 +974,7 @@ dgbopen(dev, flag, mode, p) return 0; tp=&sc->ttys[pnum]; + dev->si_tty = tp; port=&sc->ports[pnum]; bc=port->brdchan; @@ -1034,6 +1034,7 @@ open_top: */ tp->t_oproc=dgbstart; tp->t_param=dgbparam; + tp->t_stop=dgbstop; tp->t_dev=dev; tp->t_termios= (mynor & CALLOUT_MASK) ? port->it_out : @@ -2184,26 +2185,6 @@ dgbstop(tp, rw) dgbstart(tp); } -struct tty * -dgbdevtotty(dev) - dev_t dev; -{ - int mynor, pnum, unit; - struct dgb_softc *sc; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NDGB) - return (NULL); - pnum = MINOR_TO_PORT(mynor); - sc = &dgb_softc[unit]; - if (pnum >= sc->numports) - return (NULL); - return (&sc->ttys[pnum]); -} - static void fepcmd(port, cmd, op1, op2, ncmds, bytecmd) struct dgb_p *port; diff --git a/sys/dev/dgb/dgm.c b/sys/dev/dgb/dgm.c index 5deb61df9681..ecf6827076cc 100644 --- a/sys/dev/dgb/dgm.c +++ b/sys/dev/dgb/dgm.c @@ -192,6 +192,7 @@ static void fepcmd(struct dgm_p *port, unsigned cmd, unsigned op1, unsigned op2, unsigned ncmds, unsigned bytecmd); static void dgmstart __P((struct tty *tp)); +static void dgmstop __P((struct tty *tp, int rw)); static int dgmparam __P((struct tty *tp, struct termios *t)); static void dgmhardclose __P((struct dgm_p *port)); static void dgm_drain_or_flush __P((struct dgm_p *port)); @@ -210,8 +211,6 @@ static d_close_t dgmclose; static d_read_t dgmread; static d_write_t dgmwrite; static d_ioctl_t dgmioctl; -static d_stop_t dgmstop; -static d_devtotty_t dgmdevtotty; #define CDEV_MAJOR 101 static struct cdevsw dgm_cdevsw = { @@ -220,10 +219,10 @@ static struct cdevsw dgm_cdevsw = { /* read */ dgmread, /* write */ dgmwrite, /* ioctl */ dgmioctl, - /* stop */ dgmstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ dgmdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "dgm", @@ -778,6 +777,7 @@ dgmopen(dev, flag, mode, p) return 0; tp=&sc->ttys[pnum]; + dev->si_tty = tp; port=&sc->ports[pnum]; bc=port->brdchan; @@ -837,6 +837,7 @@ open_top: */ tp->t_oproc=dgmstart; tp->t_param=dgmparam; + tp->t_stop=dgmstop; tp->t_dev=dev; tp->t_termios= (mynor & CALLOUT_MASK) ? port->it_out : @@ -1986,26 +1987,6 @@ dgmstop(tp, rw) dgmstart(tp); } -struct tty * -dgmdevtotty(dev) - dev_t dev; -{ - int mynor, pnum, unit; - struct dgm_softc *sc; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NDGM) - return (NULL); - pnum = MINOR_TO_PORT(mynor); - sc = &dgm_softc[unit]; - if (pnum >= sc->numports) - return (NULL); - return (&sc->ttys[pnum]); -} - static void fepcmd(port, cmd, op1, op2, ncmds, bytecmd) struct dgm_p *port; diff --git a/sys/dev/rc/rc.c b/sys/dev/rc/rc.c index 78dd5f5a12cf..238a05214b9a 100644 --- a/sys/dev/rc/rc.c +++ b/sys/dev/rc/rc.c @@ -23,6 +23,9 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ + * */ /* @@ -87,8 +90,6 @@ static d_close_t rcclose; static d_read_t rcread; static d_write_t rcwrite; static d_ioctl_t rcioctl; -static d_stop_t rcstop; -static d_devtotty_t rcdevtotty; #define CDEV_MAJOR 63 static struct cdevsw rc_cdevsw = { @@ -97,10 +98,10 @@ static struct cdevsw rc_cdevsw = { /* read */ rcread, /* write */ rcwrite, /* ioctl */ rcioctl, - /* stop */ rcstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ rcdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "rc", @@ -182,6 +183,7 @@ static void rc_discard_output __P((struct rc_chans *)); static void rc_hardclose __P((struct rc_chans *)); static int rc_modctl __P((struct rc_chans *, int, int)); static void rc_start __P((struct tty *)); +static void rc_stop __P((struct tty *, int rw)); static int rc_param __P((struct tty *, struct termios *)); static swihand_t rcpoll; static void rc_reinit __P((struct rc_softc *)); @@ -682,7 +684,7 @@ done1: ; } static void -rcstop(tp, rw) +rc_stop(tp, rw) register struct tty *tp; int rw; { @@ -690,7 +692,7 @@ rcstop(tp, rw) u_char *tptr, *eptr; #ifdef RCDEBUG - printf("rc%d/%d: rcstop %s%s\n", rc->rc_rcb->rcb_unit, rc->rc_chan, + printf("rc%d/%d: rc_stop %s%s\n", rc->rc_rcb->rcb_unit, rc->rc_chan, (rw & FWRITE)?"FWRITE ":"", (rw & FREAD)?"FREAD":""); #endif if (rw & FWRITE) @@ -732,6 +734,7 @@ rcopen(dev, flag, mode, p) return ENXIO; rc = &rc_chans[unit]; tp = rc->rc_tp; + dev->si_tty = tp; nec = rc->rc_rcb->rcb_addr; #ifdef RCDEBUG printf("rc%d/%d: rcopen: dev %x\n", rc->rc_rcb->rcb_unit, unit, dev); @@ -771,6 +774,7 @@ again: } else { tp->t_oproc = rc_start; tp->t_param = rc_param; + tp->t_stop = rc_stop; tp->t_dev = dev; if (CALLOUT(dev)) @@ -828,7 +832,7 @@ rcclose(dev, flag, mode, p) s = spltty(); (*linesw[tp->t_line].l_close)(tp, flag); disc_optim(tp, &tp->t_termios, rc); - rcstop(tp, FREAD | FWRITE); + rc_stop(tp, FREAD | FWRITE); rc_hardclose(rc); ttyclose(tp); splx(s); @@ -1407,18 +1411,6 @@ char *comment; } #endif /* RCDEBUG */ -static struct tty * -rcdevtotty(dev) - dev_t dev; -{ - int unit; - - unit = GET_UNIT(dev); - if (unit >= NRC * CD180_NCHAN) - return NULL; - return (&rc_tty[unit]); -} - static void rc_dtrwakeup(chan) void *chan; diff --git a/sys/dev/rp/rp.c b/sys/dev/rp/rp.c index a3a4db2be574..d788b57a5150 100644 --- a/sys/dev/rp/rp.c +++ b/sys/dev/rp/rp.c @@ -797,8 +797,6 @@ static d_close_t rpclose; static d_read_t rpread; static d_write_t rpwrite; static d_ioctl_t rpioctl; -static d_stop_t rpstop; -static d_devtotty_t rpdevtotty; #define CDEV_MAJOR 81 static struct cdevsw rp_cdevsw = { @@ -807,10 +805,10 @@ static struct cdevsw rp_cdevsw = { /* read */ rpread, /* write */ rpwrite, /* ioctl */ rpioctl, - /* stop */ rpstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ rpdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ driver_name, @@ -859,10 +857,9 @@ static struct rp_port *p_rp_table[MAX_RP_PORTS]; * The top-level routines begin here */ -int rpselect __P((dev_t, int, struct proc *)); - static int rpparam __P((struct tty *, struct termios *)); static void rpstart __P((struct tty *)); +static void rpstop __P((struct tty *, int)); static void rphardclose __P((struct rp_port *)); #define rpmap nomap #define rpreset noreset @@ -1310,6 +1307,7 @@ rpopen(dev, flag, mode, p) /* rp->rp_tty = &rp_tty[rp->rp_port]; */ tp = rp->rp_tty; + dev->si_tty = tp; oldspl = spltty(); @@ -1349,6 +1347,7 @@ open_top: tp->t_dev = dev; tp->t_param = rpparam; tp->t_oproc = rpstart; + tp->t_stop = rpstop; tp->t_line = 0; tp->t_termios = IS_CALLOUT(dev) ? rp->it_out : rp->it_in; flags = 0; @@ -2017,29 +2016,3 @@ rpstop(tp, flag) splx(spl); rpstart(tp); } - -int -rpselect(dev, flag, p) - dev_t dev; - int flag; - struct proc *p; -{ - return(0); -} - -struct tty * -rpdevtotty(dev_t dev) -{ - struct rp_port *rp; - int unit, port, mynor, umynor; /* SG */ - - umynor = (((minor(dev) >> 16) -1) * 32); /* SG */ - port = (minor(dev) & 0x1f); /* SG */ - mynor = (port + umynor); /* SG */ - unit = minor_to_unit[mynor]; /* SG */ - - if(IS_CONTROL(dev)) - return(NULL); - rp = rp_addr(unit) + port; - return(rp->rp_tty); -} diff --git a/sys/dev/si/si.c b/sys/dev/si/si.c index bc26654b667f..a1cde6e3d924 100644 --- a/sys/dev/si/si.c +++ b/sys/dev/si/si.c @@ -113,6 +113,7 @@ static int si_modem __P((struct si_port *, enum si_mctl, int)); static void si_write_enable __P((struct si_port *, int)); static int si_Sioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); static void si_start __P((struct tty *)); +static void si_stop __P((struct tty *, int)); static timeout_t si_lstart; static void si_disc_optim __P((struct tty *tp, struct termios *t, struct si_port *pp)); @@ -171,8 +172,6 @@ static d_close_t siclose; static d_read_t siread; static d_write_t siwrite; static d_ioctl_t siioctl; -static d_stop_t sistop; -static d_devtotty_t sidevtotty; #define CDEV_MAJOR 68 static struct cdevsw si_cdevsw = { @@ -181,10 +180,10 @@ static struct cdevsw si_cdevsw = { /* read */ siread, /* write */ siwrite, /* ioctl */ siioctl, - /* stop */ sistop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ sidevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "si", @@ -1162,6 +1161,7 @@ siopen(dev, flag, mode, p) pp = sc->sc_ports + port; tp = pp->sp_tty; /* the "real" tty */ + dev->si_tty = tp; ccbp = pp->sp_ccb; /* Find control block */ DPRINT((pp, DBG_ENTRY|DBG_OPEN, "siopen(%s,%x,%x,%x)\n", devtoname(dev), flag, mode, p)); @@ -1213,6 +1213,7 @@ open_top: */ DPRINT((pp, DBG_OPEN, "first open\n")); tp->t_oproc = si_start; + tp->t_stop = si_stop; tp->t_param = siparam; tp->t_dev = dev; tp->t_termios = mynor & SI_CALLOUT_MASK @@ -1327,7 +1328,7 @@ siclose(dev, flag, mode, p) pp->sp_state &= ~SS_LSTART; } - sistop(tp, FREAD | FWRITE); + si_stop(tp, FREAD | FWRITE); sihardclose(pp); ttyclose(tp); @@ -1458,21 +1459,6 @@ out: } -static struct tty * -sidevtotty(dev_t dev) -{ - struct si_port *pp; - int mynor = minor(dev); - struct si_softc *sc = &si_softc[SI_CARD(mynor)]; - - if (IS_SPECIAL(mynor)) - return(NULL); - if (SI_PORT(mynor) >= sc->sc_nport) - return(NULL); - pp = MINOR2PP(mynor); - return (pp->sp_tty); -} - static int siioctl(dev, cmd, data, flag, p) dev_t dev; @@ -2582,7 +2568,7 @@ si_lstart(void *arg) * Stop output on a line. called at spltty(); */ void -sistop(tp, rw) +si_stop(tp, rw) register struct tty *tp; int rw; { @@ -2592,7 +2578,7 @@ sistop(tp, rw) pp = TP2PP(tp); ccbp = pp->sp_ccb; - DPRINT((TP2PP(tp), DBG_ENTRY|DBG_STOP, "sistop(%x,%x)\n", tp, rw)); + DPRINT((TP2PP(tp), DBG_ENTRY|DBG_STOP, "si_stop(%x,%x)\n", tp, rw)); /* XXX: must check (rw & FWRITE | FREAD) etc flushing... */ if (rw & FWRITE) { diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index 0e9dcad49ee7..28c54db19427 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -307,6 +307,7 @@ static int sioprobe __P((device_t dev)); static void siosettimeout __P((void)); static int siosetwater __P((struct com_s *com, speed_t speed)); static void comstart __P((struct tty *tp)); +static void comstop __P((struct tty *tp, int rw)); static timeout_t comwakeup; static void disc_optim __P((struct tty *tp, struct termios *t, struct com_s *com)); @@ -338,8 +339,6 @@ static d_close_t sioclose; static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; -static d_stop_t siostop; -static d_devtotty_t siodevtotty; #define CDEV_MAJOR 28 static struct cdevsw sio_cdevsw = { @@ -348,10 +347,10 @@ static struct cdevsw sio_cdevsw = { /* read */ sioread, /* write */ siowrite, /* ioctl */ sioioctl, - /* stop */ siostop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ siodevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ driver_name, @@ -1210,6 +1209,7 @@ open_top: */ tp->t_oproc = comstart; tp->t_param = comparam; + tp->t_stop = comstop; tp->t_dev = dev; tp->t_termios = mynor & CALLOUT_MASK ? com->it_out : com->it_in; @@ -1336,7 +1336,7 @@ sioclose(dev, flag, mode, p) s = spltty(); (*linesw[tp->t_line].l_close)(tp, flag); disc_optim(tp, &tp->t_termios, com); - siostop(tp, FREAD | FWRITE); + comstop(tp, FREAD | FWRITE); comhardclose(com); ttyclose(tp); siosettimeout(); @@ -2375,7 +2375,7 @@ comstart(tp) } static void -siostop(tp, rw) +comstop(tp, rw) struct tty *tp; int rw; { @@ -2415,22 +2415,6 @@ siostop(tp, rw) comstart(tp); } -static struct tty * -siodevtotty(dev) - dev_t dev; -{ - int mynor; - int unit; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NSIOTOT) - return (NULL); - return (dev->si_tty); -} - static int commctl(com, bits, how) struct com_s *com; diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 756368655884..e30b29366b1b 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -82,9 +82,9 @@ snpdevtotty (dev) struct cdevsw *cdp; cdp = devsw(dev); - if (cdp == NULL) - return (NULL); - return ((*cdp->d_devtotty)(dev)); + if (cdp && cdp->d_flags & D_TTY) + return (dev->si_tty); + return (NULL); } #define SNP_INPUT_BUF 5 /* This is even too much,the maximal diff --git a/sys/dev/syscons/scvesactl.c b/sys/dev/syscons/scvesactl.c index 21295a44f110..9749cc252b2f 100644 --- a/sys/dev/syscons/scvesactl.c +++ b/sys/dev/syscons/scvesactl.c @@ -59,7 +59,7 @@ vesa_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) struct tty *tp; int mode; - tp = scdevtotty(dev); + tp = dev->si_tty; if (!tp) return ENXIO; scp = SC_STAT(tp->t_dev); diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 3af613468b0c..6ea829f15fe2 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -217,8 +217,8 @@ static struct cdevsw sc_cdevsw = { /* ioctl */ scioctl, /* stop */ nostop, /* reset */ noreset, - /* devtotty */ scdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ scmmap, /* strategy */ nostrategy, /* name */ "sc", @@ -441,13 +441,6 @@ sc_resume_unit(int unit) return 0; } -struct tty -*scdevtotty(dev_t dev) -{ - - return (dev->si_tty); -} - static int scdevtounit(dev_t dev) { @@ -488,6 +481,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) tp = dev->si_tty = ttymalloc(dev->si_tty); tp->t_oproc = (SC_VTY(dev) == SC_MOUSE) ? scmousestart : scstart; tp->t_param = scparam; + tp->t_stop = nostop; tp->t_dev = dev; if (!(tp->t_state & TS_ISOPEN)) { ttychars(tp); diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h index df9fdf3bd0f6..ac38909ea240 100644 --- a/sys/dev/syscons/syscons.h +++ b/sys/dev/syscons/syscons.h @@ -418,7 +418,6 @@ void sc_clear_screen(scr_stat *scp); void sc_set_cursor_image(scr_stat *scp); int sc_clean_up(scr_stat *scp); void sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard); -struct tty *scdevtotty(dev_t dev); #ifndef SC_NO_SYSMOUSE struct tty *sc_get_mouse_tty(void); #endif /* SC_NO_SYSMOUSE */ diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index e8a216319b29..5c003f9955f0 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -46,6 +46,7 @@ #include <sys/fcntl.h> #include <sys/disklabel.h> #include <sys/vmmeter.h> +#include <sys/tty.h> #include <vm/vm.h> #include <vm/vm_prot.h> @@ -167,15 +168,16 @@ spec_open(ap) if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_NODEV)) return (ENXIO); + dsw = devsw(dev); + if ( (dsw == NULL) || (dsw->d_open == NULL)) + return ENXIO; + /* Make this field valid before any I/O in ->d_open */ if (!dev->si_iosize_max) dev->si_iosize_max = DFLTPHYS; switch (vp->v_type) { case VCHR: - dsw = devsw(dev); - if ( (dsw == NULL) || (dsw->d_open == NULL)) - return ENXIO; if (ap->a_cred != FSCRED && (ap->a_mode & FWRITE)) { /* * When running in very secure mode, do not allow @@ -208,9 +210,6 @@ spec_open(ap) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); break; case VBLK: - dsw = devsw(dev); - if ( (dsw == NULL) || (dsw->d_open == NULL)) - return ENXIO; /* * When running in very secure mode, do not allow * opens for writing of any disk block devices. @@ -230,10 +229,26 @@ spec_open(ap) error = (*dsw->d_open)(dev, ap->a_mode, S_IFBLK, p); break; default: - error = 0; + error = ENXIO; break; } + if (error) + return (error); + + if (dsw->d_flags & D_TTY) { + if (!dev->si_tty) { + printf("Warning:%s: no si_tty\n", devtoname(dev)); + } else { + struct tty *tp; + tp = dev->si_tty; + if (!tp->t_stop) { + printf("Warning:%s: no t_stop, using nostop\n", devtoname(dev)); + tp->t_stop = nostop; + } + } + } + if (vn_isdisk(vp)) { if (!dev->si_bsize_phys) dev->si_bsize_phys = DEV_BSIZE; diff --git a/sys/gnu/i386/isa/dgb.c b/sys/gnu/i386/isa/dgb.c index 60008abe5133..0f24e8c3781a 100644 --- a/sys/gnu/i386/isa/dgb.c +++ b/sys/gnu/i386/isa/dgb.c @@ -188,6 +188,7 @@ static void fepcmd(struct dgb_p *port, unsigned cmd, unsigned op1, unsigned op2, unsigned ncmds, unsigned bytecmd); static void dgbstart __P((struct tty *tp)); +static void dgbstop __P((struct tty *tp, int rw)); static int dgbparam __P((struct tty *tp, struct termios *t)); static void dgbhardclose __P((struct dgb_p *port)); static void dgb_drain_or_flush __P((struct dgb_p *port)); @@ -206,8 +207,6 @@ static d_close_t dgbclose; static d_read_t dgbread; static d_write_t dgbwrite; static d_ioctl_t dgbioctl; -static d_stop_t dgbstop; -static d_devtotty_t dgbdevtotty; #define CDEV_MAJOR 58 static struct cdevsw dgb_cdevsw = { @@ -216,10 +215,10 @@ static struct cdevsw dgb_cdevsw = { /* read */ dgbread, /* write */ dgbwrite, /* ioctl */ dgbioctl, - /* stop */ dgbstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ dgbdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "dgb", @@ -975,6 +974,7 @@ dgbopen(dev, flag, mode, p) return 0; tp=&sc->ttys[pnum]; + dev->si_tty = tp; port=&sc->ports[pnum]; bc=port->brdchan; @@ -1034,6 +1034,7 @@ open_top: */ tp->t_oproc=dgbstart; tp->t_param=dgbparam; + tp->t_stop=dgbstop; tp->t_dev=dev; tp->t_termios= (mynor & CALLOUT_MASK) ? port->it_out : @@ -2184,26 +2185,6 @@ dgbstop(tp, rw) dgbstart(tp); } -struct tty * -dgbdevtotty(dev) - dev_t dev; -{ - int mynor, pnum, unit; - struct dgb_softc *sc; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NDGB) - return (NULL); - pnum = MINOR_TO_PORT(mynor); - sc = &dgb_softc[unit]; - if (pnum >= sc->numports) - return (NULL); - return (&sc->ttys[pnum]); -} - static void fepcmd(port, cmd, op1, op2, ncmds, bytecmd) struct dgb_p *port; diff --git a/sys/gnu/i386/isa/dgm.c b/sys/gnu/i386/isa/dgm.c index 5deb61df9681..ecf6827076cc 100644 --- a/sys/gnu/i386/isa/dgm.c +++ b/sys/gnu/i386/isa/dgm.c @@ -192,6 +192,7 @@ static void fepcmd(struct dgm_p *port, unsigned cmd, unsigned op1, unsigned op2, unsigned ncmds, unsigned bytecmd); static void dgmstart __P((struct tty *tp)); +static void dgmstop __P((struct tty *tp, int rw)); static int dgmparam __P((struct tty *tp, struct termios *t)); static void dgmhardclose __P((struct dgm_p *port)); static void dgm_drain_or_flush __P((struct dgm_p *port)); @@ -210,8 +211,6 @@ static d_close_t dgmclose; static d_read_t dgmread; static d_write_t dgmwrite; static d_ioctl_t dgmioctl; -static d_stop_t dgmstop; -static d_devtotty_t dgmdevtotty; #define CDEV_MAJOR 101 static struct cdevsw dgm_cdevsw = { @@ -220,10 +219,10 @@ static struct cdevsw dgm_cdevsw = { /* read */ dgmread, /* write */ dgmwrite, /* ioctl */ dgmioctl, - /* stop */ dgmstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ dgmdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "dgm", @@ -778,6 +777,7 @@ dgmopen(dev, flag, mode, p) return 0; tp=&sc->ttys[pnum]; + dev->si_tty = tp; port=&sc->ports[pnum]; bc=port->brdchan; @@ -837,6 +837,7 @@ open_top: */ tp->t_oproc=dgmstart; tp->t_param=dgmparam; + tp->t_stop=dgmstop; tp->t_dev=dev; tp->t_termios= (mynor & CALLOUT_MASK) ? port->it_out : @@ -1986,26 +1987,6 @@ dgmstop(tp, rw) dgmstart(tp); } -struct tty * -dgmdevtotty(dev) - dev_t dev; -{ - int mynor, pnum, unit; - struct dgm_softc *sc; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NDGM) - return (NULL); - pnum = MINOR_TO_PORT(mynor); - sc = &dgm_softc[unit]; - if (pnum >= sc->numports) - return (NULL); - return (&sc->ttys[pnum]); -} - static void fepcmd(port, cmd, op1, op2, ncmds, bytecmd) struct dgm_p *port; diff --git a/sys/i386/isa/cx.c b/sys/i386/isa/cx.c index da7f2e80317d..0f5f40819d5f 100644 --- a/sys/i386/isa/cx.c +++ b/sys/i386/isa/cx.c @@ -14,6 +14,9 @@ * all derivative works or modified versions. * * Version 1.9, Wed Oct 4 18:58:15 MSK 1995 + * + * $FreeBSD$ + * */ #undef DEBUG @@ -85,8 +88,6 @@ static d_close_t cxclose; static d_read_t cxread; static d_write_t cxwrite; static d_ioctl_t cxioctl; -static d_stop_t cxstop; -static d_devtotty_t cxdevtotty; #define CDEV_MAJOR 42 /* Don't make this static, since if_cx.c uses it. */ @@ -96,10 +97,10 @@ struct cdevsw cx_cdevsw = { /* read */ cxread, /* write */ cxwrite, /* ioctl */ cxioctl, - /* stop */ cxstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ cxdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "cx", @@ -116,6 +117,7 @@ struct tty *cx_tty [NCX*NCHAN]; /* tty data */ #endif static void cxoproc (struct tty *tp); +static void cxstop (struct tty *tp, int flag); static int cxparam (struct tty *tp, struct termios *t); int cxopen (dev_t dev, int flag, int mode, struct proc *p) @@ -149,8 +151,10 @@ int cxopen (dev_t dev, int flag, int mode, struct proc *p) c->ttyp = cx_tty[unit]; #endif c->ttyp->t_oproc = cxoproc; + c->ttyp->t_stop = cxstop; c->ttyp->t_param = cxparam; } + dev->si_tty = c->ttyp; #ifdef __bsdi__ if (! c->ttydev) { MALLOC (c->ttydev, struct ttydevice_tmp*, @@ -743,15 +747,6 @@ cxparam (struct tty *tp, struct termios *t) return (0); } -struct tty *cxdevtotty (dev_t dev) -{ - int unit = UNIT(dev); - - if (unit == UNIT_CTL || unit >= NCX*NCHAN) - return (0); - return (cxchan[unit]->ttyp); -} - /* * Stop output on a line */ diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c index 4181c44e2b4e..8f2109c8cfeb 100644 --- a/sys/i386/isa/cy.c +++ b/sys/i386/isa/cy.c @@ -123,7 +123,6 @@ #define p_com_addr p_cy_addr #define sioattach cyattach #define sioclose cyclose -#define siodevtotty cydevtotty #define siodriver cydriver #define siodtrwakeup cydtrwakeup #define sioinput cyinput @@ -136,7 +135,7 @@ #define sioread cyread #define siosettimeout cysettimeout #define siosetwater cysetwater -#define siostop cystop +#define comstop cystop #define siowrite cywrite #define sio_registered cy_registered #define sio_timeout cy_timeout @@ -179,7 +178,7 @@ * * The following com and tty flags correspond closely: * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and - * siostop()) + * comstop()) * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart()) * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) @@ -347,6 +346,7 @@ static int siosetwater __P((struct com_s *com, speed_t speed)); static int comspeed __P((speed_t speed, u_long cy_clock, int *prescaler_io)); static void comstart __P((struct tty *tp)); +static void comstop __P((struct tty *tp, int rw)); static timeout_t comwakeup; static void disc_optim __P((struct tty *tp, struct termios *t, struct com_s *com)); @@ -370,8 +370,6 @@ static d_close_t sioclose; static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; -static d_stop_t siostop; -static d_devtotty_t siodevtotty; #define CDEV_MAJOR 48 static struct cdevsw sio_cdevsw = { @@ -380,10 +378,10 @@ static struct cdevsw sio_cdevsw = { /* read */ sioread, /* write */ siowrite, /* ioctl */ sioioctl, - /* stop */ siostop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ siodevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ driver_name, @@ -674,6 +672,7 @@ sioopen(dev, flag, mode, p) #else tp = com->tp = &sio_tty[unit]; #endif + dev->si_tty = tp; s = spltty(); /* * We jump to this label after all non-interrupted sleeps to pick @@ -721,6 +720,7 @@ open_top: * callout, and to complete a callin open after DCD rises. */ tp->t_oproc = comstart; + tp->t_stop = comstop; tp->t_param = comparam; tp->t_dev = dev; tp->t_termios = mynor & CALLOUT_MASK @@ -853,7 +853,7 @@ sioclose(dev, flag, mode, p) cd_etc(com, CD1400_ETC_STOPBREAK); (*linesw[tp->t_line].l_close)(tp, flag); disc_optim(tp, &tp->t_termios, com); - siostop(tp, FREAD | FWRITE); + comstop(tp, FREAD | FWRITE); comhardclose(com); ttyclose(tp); siosettimeout(); @@ -2414,7 +2414,7 @@ comstart(tp) } static void -siostop(tp, rw) +comstop(tp, rw) struct tty *tp; int rw; { @@ -2454,22 +2454,6 @@ siostop(tp, rw) comstart(tp); } -static struct tty * -siodevtotty(dev) - dev_t dev; -{ - int mynor; - int unit; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NSIO) - return (NULL); - return (&sio_tty[unit]); -} - static int commctl(com, bits, how) struct com_s *com; diff --git a/sys/i386/isa/istallion.c b/sys/i386/isa/istallion.c index 597f92727808..9ca227598cca 100644 --- a/sys/i386/isa/istallion.c +++ b/sys/i386/isa/istallion.c @@ -528,13 +528,6 @@ STATIC d_close_t stliclose; STATIC d_read_t stliread; STATIC d_write_t stliwrite; STATIC d_ioctl_t stliioctl; -STATIC d_stop_t stlistop; - -#if VFREEBSD >= 220 -STATIC d_devtotty_t stlidevtotty; -#else -struct tty *stlidevtotty(dev_t dev); -#endif /* * Internal function prototypes. @@ -559,6 +552,7 @@ static long stli_mktiocm(unsigned long sigvalue); static void stli_rxprocess(stlibrd_t *brdp, stliport_t *portp); static void stli_flush(stliport_t *portp, int flag); static void stli_start(struct tty *tp); +static void stli_stop(struct tty *tp, int rw); static int stli_param(struct tty *tp, struct termios *tiosp); static void stli_ttyoptim(stliport_t *portp, struct termios *tiosp); static void stli_dtrwakeup(void *arg); @@ -646,10 +640,10 @@ static struct cdevsw stli_cdevsw = { /* read */ stliread, /* write */ stliwrite, /* ioctl */ stliioctl, - /* stop */ stlistop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ stlidevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ stli_drvname, @@ -951,6 +945,7 @@ STATIC int stliopen(dev_t dev, int flag, int mode, struct proc *p) if (portp == (stliport_t *) NULL) return(ENXIO); tp = &portp->tty; + dev->si_tty = tp; callout = minor(dev) & STL_CALLOUTDEV; error = 0; @@ -986,6 +981,7 @@ stliopen_restart: if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_oproc = stli_start; tp->t_param = stli_param; + tp->t_stop = stli_stop; tp->t_dev = dev; tp->t_termios = callout ? portp->initouttios : portp->initintios; @@ -1109,10 +1105,10 @@ STATIC int stliread(dev_t dev, struct uio *uiop, int flag) #if VFREEBSD >= 220 -STATIC void stlistop(struct tty *tp, int rw) +STATIC void stli_stop(struct tty *tp, int rw) { #if DEBUG - printf("stlistop(tp=%x,rw=%x)\n", (int) tp, rw); + printf("stli_stop(tp=%x,rw=%x)\n", (int) tp, rw); #endif stli_flush((stliport_t *) tp, rw); @@ -1134,16 +1130,6 @@ STATIC int stlistop(struct tty *tp, int rw) /*****************************************************************************/ -STATIC struct tty *stlidevtotty(dev_t dev) -{ -#if DEBUG - printf("stlidevtotty(dev=%s)\n", devtoname(dev)); -#endif - return((struct tty *) stli_dev2port(dev)); -} - -/*****************************************************************************/ - STATIC int stliwrite(dev_t dev, struct uio *uiop, int flag) { stliport_t *portp; diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index 4f0bfd64f666..8e5c26d687c4 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -43,6 +43,8 @@ * * @(#)pcvt_drv.c, 3.20, Last Edit-Date: [Mon Apr 19 17:10:09 1999] * + * $FreeBSD$ + * */ /*---------------------------------------------------------------------------* @@ -121,7 +123,6 @@ static d_close_t pcclose; static d_read_t pcread; static d_write_t pcwrite; static d_ioctl_t pcioctl; -static d_devtotty_t pcdevtotty; static d_mmap_t pcmmap; #define CDEV_MAJOR 12 @@ -133,8 +134,8 @@ static struct cdevsw pc_cdevsw = { /* ioctl */ pcioctl, /* stop */ nostop, /* reset */ noreset, - /* devtotty */ pcdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ pcmmap, /* strategy */ nostrategy, /* name */ "vt", @@ -147,15 +148,6 @@ static struct cdevsw pc_cdevsw = { /* bmaj */ -1 }; -#if PCVT_FREEBSD > 205 -struct tty * -pcdevtotty(Dev_t dev) -{ - return get_pccons(dev); -} - -#endif /* PCVT_FREEBSD > 205 */ - #if PCVT_NETBSD > 100 /* NetBSD-current Feb 20 1995 */ int pcprobe(struct device *parent, void *match, void *aux) @@ -470,6 +462,8 @@ pcopen(Dev_t dev, int flag, int mode, struct proc *p) if((tp = get_pccons(dev)) == NULL) return ENXIO; + dev->si_tty = tp; + #if PCVT_EMU_MOUSE if(i == totalscreens) { diff --git a/sys/i386/isa/rc.c b/sys/i386/isa/rc.c index 78dd5f5a12cf..238a05214b9a 100644 --- a/sys/i386/isa/rc.c +++ b/sys/i386/isa/rc.c @@ -23,6 +23,9 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ + * */ /* @@ -87,8 +90,6 @@ static d_close_t rcclose; static d_read_t rcread; static d_write_t rcwrite; static d_ioctl_t rcioctl; -static d_stop_t rcstop; -static d_devtotty_t rcdevtotty; #define CDEV_MAJOR 63 static struct cdevsw rc_cdevsw = { @@ -97,10 +98,10 @@ static struct cdevsw rc_cdevsw = { /* read */ rcread, /* write */ rcwrite, /* ioctl */ rcioctl, - /* stop */ rcstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ rcdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "rc", @@ -182,6 +183,7 @@ static void rc_discard_output __P((struct rc_chans *)); static void rc_hardclose __P((struct rc_chans *)); static int rc_modctl __P((struct rc_chans *, int, int)); static void rc_start __P((struct tty *)); +static void rc_stop __P((struct tty *, int rw)); static int rc_param __P((struct tty *, struct termios *)); static swihand_t rcpoll; static void rc_reinit __P((struct rc_softc *)); @@ -682,7 +684,7 @@ done1: ; } static void -rcstop(tp, rw) +rc_stop(tp, rw) register struct tty *tp; int rw; { @@ -690,7 +692,7 @@ rcstop(tp, rw) u_char *tptr, *eptr; #ifdef RCDEBUG - printf("rc%d/%d: rcstop %s%s\n", rc->rc_rcb->rcb_unit, rc->rc_chan, + printf("rc%d/%d: rc_stop %s%s\n", rc->rc_rcb->rcb_unit, rc->rc_chan, (rw & FWRITE)?"FWRITE ":"", (rw & FREAD)?"FREAD":""); #endif if (rw & FWRITE) @@ -732,6 +734,7 @@ rcopen(dev, flag, mode, p) return ENXIO; rc = &rc_chans[unit]; tp = rc->rc_tp; + dev->si_tty = tp; nec = rc->rc_rcb->rcb_addr; #ifdef RCDEBUG printf("rc%d/%d: rcopen: dev %x\n", rc->rc_rcb->rcb_unit, unit, dev); @@ -771,6 +774,7 @@ again: } else { tp->t_oproc = rc_start; tp->t_param = rc_param; + tp->t_stop = rc_stop; tp->t_dev = dev; if (CALLOUT(dev)) @@ -828,7 +832,7 @@ rcclose(dev, flag, mode, p) s = spltty(); (*linesw[tp->t_line].l_close)(tp, flag); disc_optim(tp, &tp->t_termios, rc); - rcstop(tp, FREAD | FWRITE); + rc_stop(tp, FREAD | FWRITE); rc_hardclose(rc); ttyclose(tp); splx(s); @@ -1407,18 +1411,6 @@ char *comment; } #endif /* RCDEBUG */ -static struct tty * -rcdevtotty(dev) - dev_t dev; -{ - int unit; - - unit = GET_UNIT(dev); - if (unit >= NRC * CD180_NCHAN) - return NULL; - return (&rc_tty[unit]); -} - static void rc_dtrwakeup(chan) void *chan; diff --git a/sys/i386/isa/rp.c b/sys/i386/isa/rp.c index a3a4db2be574..d788b57a5150 100644 --- a/sys/i386/isa/rp.c +++ b/sys/i386/isa/rp.c @@ -797,8 +797,6 @@ static d_close_t rpclose; static d_read_t rpread; static d_write_t rpwrite; static d_ioctl_t rpioctl; -static d_stop_t rpstop; -static d_devtotty_t rpdevtotty; #define CDEV_MAJOR 81 static struct cdevsw rp_cdevsw = { @@ -807,10 +805,10 @@ static struct cdevsw rp_cdevsw = { /* read */ rpread, /* write */ rpwrite, /* ioctl */ rpioctl, - /* stop */ rpstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ rpdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ driver_name, @@ -859,10 +857,9 @@ static struct rp_port *p_rp_table[MAX_RP_PORTS]; * The top-level routines begin here */ -int rpselect __P((dev_t, int, struct proc *)); - static int rpparam __P((struct tty *, struct termios *)); static void rpstart __P((struct tty *)); +static void rpstop __P((struct tty *, int)); static void rphardclose __P((struct rp_port *)); #define rpmap nomap #define rpreset noreset @@ -1310,6 +1307,7 @@ rpopen(dev, flag, mode, p) /* rp->rp_tty = &rp_tty[rp->rp_port]; */ tp = rp->rp_tty; + dev->si_tty = tp; oldspl = spltty(); @@ -1349,6 +1347,7 @@ open_top: tp->t_dev = dev; tp->t_param = rpparam; tp->t_oproc = rpstart; + tp->t_stop = rpstop; tp->t_line = 0; tp->t_termios = IS_CALLOUT(dev) ? rp->it_out : rp->it_in; flags = 0; @@ -2017,29 +2016,3 @@ rpstop(tp, flag) splx(spl); rpstart(tp); } - -int -rpselect(dev, flag, p) - dev_t dev; - int flag; - struct proc *p; -{ - return(0); -} - -struct tty * -rpdevtotty(dev_t dev) -{ - struct rp_port *rp; - int unit, port, mynor, umynor; /* SG */ - - umynor = (((minor(dev) >> 16) -1) * 32); /* SG */ - port = (minor(dev) & 0x1f); /* SG */ - mynor = (port + umynor); /* SG */ - unit = minor_to_unit[mynor]; /* SG */ - - if(IS_CONTROL(dev)) - return(NULL); - rp = rp_addr(unit) + port; - return(rp->rp_tty); -} diff --git a/sys/i386/isa/si.c b/sys/i386/isa/si.c index bc26654b667f..a1cde6e3d924 100644 --- a/sys/i386/isa/si.c +++ b/sys/i386/isa/si.c @@ -113,6 +113,7 @@ static int si_modem __P((struct si_port *, enum si_mctl, int)); static void si_write_enable __P((struct si_port *, int)); static int si_Sioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); static void si_start __P((struct tty *)); +static void si_stop __P((struct tty *, int)); static timeout_t si_lstart; static void si_disc_optim __P((struct tty *tp, struct termios *t, struct si_port *pp)); @@ -171,8 +172,6 @@ static d_close_t siclose; static d_read_t siread; static d_write_t siwrite; static d_ioctl_t siioctl; -static d_stop_t sistop; -static d_devtotty_t sidevtotty; #define CDEV_MAJOR 68 static struct cdevsw si_cdevsw = { @@ -181,10 +180,10 @@ static struct cdevsw si_cdevsw = { /* read */ siread, /* write */ siwrite, /* ioctl */ siioctl, - /* stop */ sistop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ sidevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "si", @@ -1162,6 +1161,7 @@ siopen(dev, flag, mode, p) pp = sc->sc_ports + port; tp = pp->sp_tty; /* the "real" tty */ + dev->si_tty = tp; ccbp = pp->sp_ccb; /* Find control block */ DPRINT((pp, DBG_ENTRY|DBG_OPEN, "siopen(%s,%x,%x,%x)\n", devtoname(dev), flag, mode, p)); @@ -1213,6 +1213,7 @@ open_top: */ DPRINT((pp, DBG_OPEN, "first open\n")); tp->t_oproc = si_start; + tp->t_stop = si_stop; tp->t_param = siparam; tp->t_dev = dev; tp->t_termios = mynor & SI_CALLOUT_MASK @@ -1327,7 +1328,7 @@ siclose(dev, flag, mode, p) pp->sp_state &= ~SS_LSTART; } - sistop(tp, FREAD | FWRITE); + si_stop(tp, FREAD | FWRITE); sihardclose(pp); ttyclose(tp); @@ -1458,21 +1459,6 @@ out: } -static struct tty * -sidevtotty(dev_t dev) -{ - struct si_port *pp; - int mynor = minor(dev); - struct si_softc *sc = &si_softc[SI_CARD(mynor)]; - - if (IS_SPECIAL(mynor)) - return(NULL); - if (SI_PORT(mynor) >= sc->sc_nport) - return(NULL); - pp = MINOR2PP(mynor); - return (pp->sp_tty); -} - static int siioctl(dev, cmd, data, flag, p) dev_t dev; @@ -2582,7 +2568,7 @@ si_lstart(void *arg) * Stop output on a line. called at spltty(); */ void -sistop(tp, rw) +si_stop(tp, rw) register struct tty *tp; int rw; { @@ -2592,7 +2578,7 @@ sistop(tp, rw) pp = TP2PP(tp); ccbp = pp->sp_ccb; - DPRINT((TP2PP(tp), DBG_ENTRY|DBG_STOP, "sistop(%x,%x)\n", tp, rw)); + DPRINT((TP2PP(tp), DBG_ENTRY|DBG_STOP, "si_stop(%x,%x)\n", tp, rw)); /* XXX: must check (rw & FWRITE | FREAD) etc flushing... */ if (rw & FWRITE) { diff --git a/sys/i386/isa/stallion.c b/sys/i386/isa/stallion.c index 628eb19b9dcd..99cef0391202 100644 --- a/sys/i386/isa/stallion.c +++ b/sys/i386/isa/stallion.c @@ -441,13 +441,6 @@ STATIC d_close_t stlclose; STATIC d_read_t stlread; STATIC d_write_t stlwrite; STATIC d_ioctl_t stlioctl; -STATIC d_stop_t stlstop; - -#if VFREEBSD >= 220 -STATIC d_devtotty_t stldevtotty; -#else -struct tty *stldevtotty(dev_t dev); -#endif /* * Internal function prototypes. @@ -458,6 +451,7 @@ static int stl_rawopen(stlport_t *portp); static int stl_rawclose(stlport_t *portp); static int stl_param(struct tty *tp, struct termios *tiosp); static void stl_start(struct tty *tp); +static void stl_stop(struct tty *tp, int); static void stl_ttyoptim(stlport_t *portp, struct termios *tiosp); static void stl_dotimeout(void); static void stl_poll(void *arg); @@ -541,10 +535,10 @@ static struct cdevsw stl_cdevsw = { /* read */ stlread, /* write */ stlwrite, /* ioctl */ stlioctl, - /* stop */ stlstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ stldevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "stl", @@ -783,6 +777,7 @@ STATIC int stlopen(dev_t dev, int flag, int mode, struct proc *p) if (portp == (stlport_t *) NULL) return(ENXIO); tp = &portp->tty; + dev->si_tty = tp; callout = minor(dev) & STL_CALLOUTDEV; error = 0; @@ -806,6 +801,7 @@ stlopen_restart: */ if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_oproc = stl_start; + tp->t_stop = stl_stop; tp->t_param = stl_param; tp->t_dev = dev; tp->t_termios = callout ? portp->initouttios : @@ -926,10 +922,10 @@ STATIC int stlread(dev_t dev, struct uio *uiop, int flag) #if VFREEBSD >= 220 -STATIC void stlstop(struct tty *tp, int rw) +STATIC void stl_stop(struct tty *tp, int rw) { #if DEBUG - printf("stlstop(tp=%x,rw=%x)\n", (int) tp, rw); + printf("stl_stop(tp=%x,rw=%x)\n", (int) tp, rw); #endif stl_flush((stlport_t *) tp, rw); @@ -951,16 +947,6 @@ STATIC int stlstop(struct tty *tp, int rw) /*****************************************************************************/ -STATIC struct tty *stldevtotty(dev_t dev) -{ -#if DEBUG - printf("stldevtotty(dev=%s)\n", devtoname(dev)); -#endif - return((struct tty *) stl_dev2port(dev)); -} - -/*****************************************************************************/ - STATIC int stlwrite(dev_t dev, struct uio *uiop, int flag) { stlport_t *portp; diff --git a/sys/i386/linux/linux_file.c b/sys/i386/linux/linux_file.c index 6a33e68c3843..11ea2408146e 100644 --- a/sys/i386/linux/linux_file.c +++ b/sys/i386/linux/linux_file.c @@ -204,13 +204,12 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) struct vnode *vp; long pgid; struct pgrp *pgrp; - struct tty *tp, *(*d_tty) __P((dev_t)); + struct tty *tp; caddr_t sg; dev_t dev; sg = stackgap_init(); bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(struct flock)); - d_tty = NULL; #ifdef DEBUG printf("Linux-emul(%d): fcntl(%d, %08x, *)\n", @@ -309,8 +308,10 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args) dev = vn_todev(vp); if (vp->v_type != VCHR || dev == NODEV) return EINVAL; - d_tty = devsw(dev)->d_devtotty; - if (!d_tty || (!(tp = (*d_tty)(dev)))) + if (!(devsw(dev)->d_flags & D_TTY)) + return EINVAL; + tp = dev->si_tty; + if (!tp) return EINVAL; if (args->cmd == LINUX_F_GETOWN) { p->p_retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID; diff --git a/sys/isa/sio.c b/sys/isa/sio.c index 0e9dcad49ee7..28c54db19427 100644 --- a/sys/isa/sio.c +++ b/sys/isa/sio.c @@ -307,6 +307,7 @@ static int sioprobe __P((device_t dev)); static void siosettimeout __P((void)); static int siosetwater __P((struct com_s *com, speed_t speed)); static void comstart __P((struct tty *tp)); +static void comstop __P((struct tty *tp, int rw)); static timeout_t comwakeup; static void disc_optim __P((struct tty *tp, struct termios *t, struct com_s *com)); @@ -338,8 +339,6 @@ static d_close_t sioclose; static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; -static d_stop_t siostop; -static d_devtotty_t siodevtotty; #define CDEV_MAJOR 28 static struct cdevsw sio_cdevsw = { @@ -348,10 +347,10 @@ static struct cdevsw sio_cdevsw = { /* read */ sioread, /* write */ siowrite, /* ioctl */ sioioctl, - /* stop */ siostop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ siodevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ driver_name, @@ -1210,6 +1209,7 @@ open_top: */ tp->t_oproc = comstart; tp->t_param = comparam; + tp->t_stop = comstop; tp->t_dev = dev; tp->t_termios = mynor & CALLOUT_MASK ? com->it_out : com->it_in; @@ -1336,7 +1336,7 @@ sioclose(dev, flag, mode, p) s = spltty(); (*linesw[tp->t_line].l_close)(tp, flag); disc_optim(tp, &tp->t_termios, com); - siostop(tp, FREAD | FWRITE); + comstop(tp, FREAD | FWRITE); comhardclose(com); ttyclose(tp); siosettimeout(); @@ -2375,7 +2375,7 @@ comstart(tp) } static void -siostop(tp, rw) +comstop(tp, rw) struct tty *tp; int rw; { @@ -2415,22 +2415,6 @@ siostop(tp, rw) comstart(tp); } -static struct tty * -siodevtotty(dev) - dev_t dev; -{ - int mynor; - int unit; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NSIOTOT) - return (NULL); - return (dev->si_tty); -} - static int commctl(com, bits, how) struct com_s *com; diff --git a/sys/kern/tty.c b/sys/kern/tty.c index ee1b6e76577c..88456be6221c 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -422,12 +422,7 @@ parmrk: if (CCEQ(cc[VSTOP], c)) { if (!ISSET(tp->t_state, TS_TTSTOP)) { SET(tp->t_state, TS_TTSTOP); -#ifdef sun4c /* XXX */ (*tp->t_stop)(tp, 0); -#else - (*devsw(tp->t_dev)->d_stop)(tp, - 0); -#endif return (0); } if (!CCEQ(cc[VSTART], c)) @@ -999,11 +994,7 @@ ttioctl(tp, cmd, data, flag) s = spltty(); if (!ISSET(tp->t_state, TS_TTSTOP)) { SET(tp->t_state, TS_TTSTOP); -#ifdef sun4c /* XXX */ (*tp->t_stop)(tp, 0); -#else - (*devsw(tp->t_dev)->d_stop)(tp, 0); -#endif } splx(s); break; @@ -1062,14 +1053,16 @@ ttioctl(tp, cmd, data, flag) } int -ttypoll(tp, events, p) - struct tty *tp; +ttypoll(dev, events, p) + dev_t dev; int events; struct proc *p; { int s; int revents = 0; + struct tty *tp; + tp = dev->si_tty; if (tp == NULL) /* XXX used to return ENXIO, but that means true! */ return ((events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)) | POLLHUP); @@ -1094,19 +1087,6 @@ ttypoll(tp, events, p) } /* - * This is a wrapper for compatibility with the select vector used by - * cdevsw. It relies on a proper xxxdevtotty routine. - */ -int -ttpoll(dev, events, p) - dev_t dev; - int events; - struct proc *p; -{ - return ttypoll((*devsw(dev)->d_devtotty)(dev), events, p); -} - -/* * Must be called at spltty(). */ static int @@ -1192,11 +1172,7 @@ again: FLUSHQ(&tp->t_outq); CLR(tp->t_state, TS_TTSTOP); } -#ifdef sun4c /* XXX */ (*tp->t_stop)(tp, rw); -#else - (*devsw(tp->t_dev)->d_stop)(tp, rw); -#endif if (rw & FREAD) { FLUSHQ(&tp->t_canq); FLUSHQ(&tp->t_rawq); @@ -1377,11 +1353,7 @@ ttymodem(tp, flag) } else if (!ISSET(tp->t_state, TS_CAR_OFLOW)) { SET(tp->t_state, TS_CAR_OFLOW); SET(tp->t_state, TS_TTSTOP); -#ifdef sun4c /* XXX */ (*tp->t_stop)(tp, 0); -#else - (*devsw(tp->t_dev)->d_stop)(tp, 0); -#endif } } else if (flag == 0) { /* diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c index 4fef6f65cc32..c59864f2ad0a 100644 --- a/sys/kern/tty_cons.c +++ b/sys/kern/tty_cons.c @@ -100,7 +100,6 @@ static u_char cn_phys_is_open; /* nonzero if physical device is open */ static d_close_t *cn_phys_close; /* physical device close function */ static d_open_t *cn_phys_open; /* physical device open function */ struct consdev *cn_tab; /* physical console device info */ -static struct tty *cn_tp; /* physical console tty struct */ static dev_t condev_t; /* represents the device private info */ CONS_DRIVER(cons, NULL, NULL, NULL, NULL, NULL, NULL); @@ -175,7 +174,6 @@ cninit_finish() cdp->d_close = cnclose; cn_phys_open = cdp->d_open; cdp->d_open = cnopen; - cn_tp = (*cdp->d_devtotty)(cn_tab->cn_dev); cn_dev_t = cn_tab->cn_dev; cn_udev_t = dev2udev(cn_dev_t); } @@ -196,7 +194,6 @@ cnuninit(void) cn_phys_close = NULL; cdp->d_open = cn_phys_open; cn_phys_open = NULL; - cn_tp = NULL; cn_dev_t = NODEV; cn_udev_t = NOUDEV; } @@ -281,6 +278,7 @@ cnopen(dev, flag, mode, p) openflag = flag; cn_is_open = 1; } + dev->si_tty = physdev->si_tty; } return (retval); } @@ -292,10 +290,12 @@ cnclose(dev, flag, mode, p) struct proc *p; { dev_t cndev; + struct tty *cn_tp; if (cn_tab == NULL) return (0); cndev = cn_tab->cn_dev; + cn_tp = cndev->si_tty; /* * act appropriatly depending on whether it's /dev/console * or the pysical device (e.g. /dev/sio) that's being closed. diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 2fe2f5ee9a34..9531f7ba53c8 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -58,6 +58,7 @@ MALLOC_DEFINE(M_PTY, "ptys", "pty data structures"); static void ptsstart __P((struct tty *tp)); +static void ptsstop __P((struct tty *tp, int rw)); static void ptcwakeup __P((struct tty *tp, int flag)); static void ptyinit __P((int n)); @@ -66,8 +67,6 @@ static d_close_t ptsclose; static d_read_t ptsread; static d_write_t ptswrite; static d_ioctl_t ptyioctl; -static d_stop_t ptsstop; -static d_devtotty_t ptydevtotty; static d_open_t ptcopen; static d_close_t ptcclose; static d_read_t ptcread; @@ -81,10 +80,10 @@ static struct cdevsw pts_cdevsw = { /* read */ ptsread, /* write */ ptswrite, /* ioctl */ ptyioctl, - /* stop */ ptsstop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ ptydevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "pts", @@ -106,7 +105,7 @@ static struct cdevsw ptc_cdevsw = { /* ioctl */ ptyioctl, /* stop */ nostop, /* reset */ noreset, - /* devtotty */ ptydevtotty, + /* devtotty */ nodevtotty, /* poll */ ptcpoll, /* mmap */ nommap, /* strategy */ nostrategy, @@ -362,6 +361,7 @@ ptcopen(dev, flag, devtype, p) if (tp->t_oproc) return (EIO); tp->t_oproc = ptsstart; + tp->t_stop = ptsstop; (void)(*linesw[tp->t_line].l_modem)(tp, 1); tp->t_lflag &= ~EXTPROC; pti = dev->si_drv1; @@ -647,16 +647,6 @@ block: goto again; } -static struct tty * -ptydevtotty(dev) - dev_t dev; -{ - if (minor(dev) & ~0xff) - return (NULL); - - return dev->si_tty; -} - /*ARGSUSED*/ static int ptyioctl(dev, cmd, data, flag, p) diff --git a/sys/kern/tty_snoop.c b/sys/kern/tty_snoop.c index 756368655884..e30b29366b1b 100644 --- a/sys/kern/tty_snoop.c +++ b/sys/kern/tty_snoop.c @@ -82,9 +82,9 @@ snpdevtotty (dev) struct cdevsw *cdp; cdp = devsw(dev); - if (cdp == NULL) - return (NULL); - return ((*cdp->d_devtotty)(dev)); + if (cdp && cdp->d_flags & D_TTY) + return (dev->si_tty); + return (NULL); } #define SNP_INPUT_BUF 5 /* This is even too much,the maximal diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index e8a216319b29..5c003f9955f0 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -46,6 +46,7 @@ #include <sys/fcntl.h> #include <sys/disklabel.h> #include <sys/vmmeter.h> +#include <sys/tty.h> #include <vm/vm.h> #include <vm/vm_prot.h> @@ -167,15 +168,16 @@ spec_open(ap) if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_NODEV)) return (ENXIO); + dsw = devsw(dev); + if ( (dsw == NULL) || (dsw->d_open == NULL)) + return ENXIO; + /* Make this field valid before any I/O in ->d_open */ if (!dev->si_iosize_max) dev->si_iosize_max = DFLTPHYS; switch (vp->v_type) { case VCHR: - dsw = devsw(dev); - if ( (dsw == NULL) || (dsw->d_open == NULL)) - return ENXIO; if (ap->a_cred != FSCRED && (ap->a_mode & FWRITE)) { /* * When running in very secure mode, do not allow @@ -208,9 +210,6 @@ spec_open(ap) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); break; case VBLK: - dsw = devsw(dev); - if ( (dsw == NULL) || (dsw->d_open == NULL)) - return ENXIO; /* * When running in very secure mode, do not allow * opens for writing of any disk block devices. @@ -230,10 +229,26 @@ spec_open(ap) error = (*dsw->d_open)(dev, ap->a_mode, S_IFBLK, p); break; default: - error = 0; + error = ENXIO; break; } + if (error) + return (error); + + if (dsw->d_flags & D_TTY) { + if (!dev->si_tty) { + printf("Warning:%s: no si_tty\n", devtoname(dev)); + } else { + struct tty *tp; + tp = dev->si_tty; + if (!tp->t_stop) { + printf("Warning:%s: no t_stop, using nostop\n", devtoname(dev)); + tp->t_stop = nostop; + } + } + } + if (vn_isdisk(vp)) { if (!dev->si_bsize_phys) dev->si_bsize_phys = DEV_BSIZE; diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c index 78d427e5d85a..cb181c5b5a7a 100644 --- a/sys/net/ppp_tty.c +++ b/sys/net/ppp_tty.c @@ -896,7 +896,7 @@ pppinput(c, tp) if (c == tp->t_cc[VSTOP] && tp->t_cc[VSTOP] != _POSIX_VDISABLE) { if ((tp->t_state & TS_TTSTOP) == 0) { tp->t_state |= TS_TTSTOP; - (*devsw(tp->t_dev)->d_stop)(tp, 0); + tp->t_stop(tp, 0); } return 0; } diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c index 0aaa6700ef2c..f34b034eaa10 100644 --- a/sys/pc98/cbus/sio.c +++ b/sys/pc98/cbus/sio.c @@ -253,7 +253,7 @@ * * The following com and tty flags correspond closely: * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and - * siostop()) + * comstop()) * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart()) * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) @@ -427,6 +427,7 @@ static int sioprobe __P((device_t dev)); static void siosettimeout __P((void)); static int siosetwater __P((struct com_s *com, speed_t speed)); static void comstart __P((struct tty *tp)); +static void comstop __P((struct tty *tp, int rw)); static timeout_t comwakeup; static void disc_optim __P((struct tty *tp, struct termios *t, struct com_s *com)); @@ -458,8 +459,6 @@ static d_close_t sioclose; static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; -static d_stop_t siostop; -static d_devtotty_t siodevtotty; #define CDEV_MAJOR 28 static struct cdevsw sio_cdevsw = { @@ -468,10 +467,10 @@ static struct cdevsw sio_cdevsw = { /* read */ sioread, /* write */ siowrite, /* ioctl */ sioioctl, - /* stop */ siostop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ siodevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ driver_name, @@ -1946,6 +1945,7 @@ open_top: * callout, and to complete a callin open after DCD rises. */ tp->t_oproc = comstart; + tp->t_stop = comstop; tp->t_param = comparam; tp->t_dev = dev; tp->t_termios = mynor & CALLOUT_MASK @@ -2127,7 +2127,7 @@ sioclose(dev, flag, mode, p) com->modem_checking = 0; #endif disc_optim(tp, &tp->t_termios, com); - siostop(tp, FREAD | FWRITE); + comstop(tp, FREAD | FWRITE); comhardclose(com); ttyclose(tp); siosettimeout(); @@ -3612,7 +3612,7 @@ comstart(tp) } static void -siostop(tp, rw) +comstop(tp, rw) struct tty *tp; int rw; { @@ -3678,22 +3678,6 @@ siostop(tp, rw) comstart(tp); } -static struct tty * -siodevtotty(dev) - dev_t dev; -{ - int mynor; - int unit; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NSIOTOT) - return (NULL); - return (dev->si_tty); -} - static int commctl(com, bits, how) struct com_s *com; diff --git a/sys/pc98/pc98/sio.c b/sys/pc98/pc98/sio.c index 0aaa6700ef2c..f34b034eaa10 100644 --- a/sys/pc98/pc98/sio.c +++ b/sys/pc98/pc98/sio.c @@ -253,7 +253,7 @@ * * The following com and tty flags correspond closely: * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and - * siostop()) + * comstop()) * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart()) * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) @@ -427,6 +427,7 @@ static int sioprobe __P((device_t dev)); static void siosettimeout __P((void)); static int siosetwater __P((struct com_s *com, speed_t speed)); static void comstart __P((struct tty *tp)); +static void comstop __P((struct tty *tp, int rw)); static timeout_t comwakeup; static void disc_optim __P((struct tty *tp, struct termios *t, struct com_s *com)); @@ -458,8 +459,6 @@ static d_close_t sioclose; static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; -static d_stop_t siostop; -static d_devtotty_t siodevtotty; #define CDEV_MAJOR 28 static struct cdevsw sio_cdevsw = { @@ -468,10 +467,10 @@ static struct cdevsw sio_cdevsw = { /* read */ sioread, /* write */ siowrite, /* ioctl */ sioioctl, - /* stop */ siostop, + /* stop */ nostop, /* reset */ noreset, - /* devtotty */ siodevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ driver_name, @@ -1946,6 +1945,7 @@ open_top: * callout, and to complete a callin open after DCD rises. */ tp->t_oproc = comstart; + tp->t_stop = comstop; tp->t_param = comparam; tp->t_dev = dev; tp->t_termios = mynor & CALLOUT_MASK @@ -2127,7 +2127,7 @@ sioclose(dev, flag, mode, p) com->modem_checking = 0; #endif disc_optim(tp, &tp->t_termios, com); - siostop(tp, FREAD | FWRITE); + comstop(tp, FREAD | FWRITE); comhardclose(com); ttyclose(tp); siosettimeout(); @@ -3612,7 +3612,7 @@ comstart(tp) } static void -siostop(tp, rw) +comstop(tp, rw) struct tty *tp; int rw; { @@ -3678,22 +3678,6 @@ siostop(tp, rw) comstart(tp); } -static struct tty * -siodevtotty(dev) - dev_t dev; -{ - int mynor; - int unit; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (NULL); - unit = MINOR_TO_UNIT(mynor); - if ((u_int) unit >= NSIOTOT) - return (NULL); - return (dev->si_tty); -} - static int commctl(com, bits, how) struct com_s *com; diff --git a/sys/pc98/pc98/syscons.c b/sys/pc98/pc98/syscons.c index 30044bd3b5df..f47968917fc0 100644 --- a/sys/pc98/pc98/syscons.c +++ b/sys/pc98/pc98/syscons.c @@ -216,8 +216,8 @@ static struct cdevsw sc_cdevsw = { /* ioctl */ scioctl, /* stop */ nostop, /* reset */ noreset, - /* devtotty */ scdevtotty, - /* poll */ ttpoll, + /* devtotty */ nodevtotty, + /* poll */ ttypoll, /* mmap */ scmmap, /* strategy */ nostrategy, /* name */ "sc", @@ -437,13 +437,6 @@ sc_resume_unit(int unit) return 0; } -struct tty -*scdevtotty(dev_t dev) -{ - - return (dev->si_tty); -} - static int scdevtounit(dev_t dev) { @@ -531,7 +524,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p) int scclose(dev_t dev, int flag, int mode, struct proc *p) { - struct tty *tp = scdevtotty(dev); + struct tty *tp = dev->si_tty; struct scr_stat *scp; int s; @@ -586,7 +579,7 @@ scclose(dev_t dev, int flag, int mode, struct proc *p) int scread(dev_t dev, struct uio *uio, int flag) { - struct tty *tp = scdevtotty(dev); + struct tty *tp = dev->si_tty; sc_touch_scrn_saver(); return((*linesw[tp->t_line].l_read)(tp, uio, flag)); @@ -595,7 +588,7 @@ scread(dev_t dev, struct uio *uio, int flag) int scwrite(dev_t dev, struct uio *uio, int flag) { - struct tty *tp = scdevtotty(dev); + struct tty *tp = dev->si_tty; return((*linesw[tp->t_line].l_write)(tp, uio, flag)); } @@ -689,7 +682,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) scr_stat *scp; int s; - tp = scdevtotty(dev); + tp = dev->si_tty; /* If there is a user_ioctl function call that first */ if (sc_user_ioctl) { diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 16bdb49e9eae..6cdc7287278a 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -169,9 +169,9 @@ struct cdevsw { d_read_t *d_read; d_write_t *d_write; d_ioctl_t *d_ioctl; - d_stop_t *d_stop; + d_stop_t *d_bogostop; d_reset_t *d_bogoreset; /* XXX not used */ - d_devtotty_t *d_devtotty; + d_devtotty_t *d_bogodevtotty; /* XXX not used */ d_poll_t *d_poll; d_mmap_t *d_mmap; d_strategy_t *d_strategy; diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index 16bdb49e9eae..6cdc7287278a 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -169,9 +169,9 @@ struct cdevsw { d_read_t *d_read; d_write_t *d_write; d_ioctl_t *d_ioctl; - d_stop_t *d_stop; + d_stop_t *d_bogostop; d_reset_t *d_bogoreset; /* XXX not used */ - d_devtotty_t *d_devtotty; + d_devtotty_t *d_bogodevtotty; /* XXX not used */ d_poll_t *d_poll; d_mmap_t *d_mmap; d_strategy_t *d_strategy; diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 00fb7a8ad5ca..74754d57c7ad 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -247,8 +247,7 @@ int tputchar __P((int c, struct tty *tp)); int ttioctl __P((struct tty *tp, u_long com, void *data, int flag)); int ttread __P((struct tty *tp, struct uio *uio, int flag)); void ttrstrt __P((void *tp)); -int ttypoll __P((struct tty *tp, int events, struct proc *p)); -int ttpoll __P((dev_t dev, int events, struct proc *p)); +int ttypoll __P((dev_t dev, int events, struct proc *p)); void ttsetwater __P((struct tty *tp)); int ttspeedtab __P((int speed, struct speedtab *table)); int ttstart __P((struct tty *tp)); |