diff options
| author | Poul-Henning Kamp <phk@FreeBSD.org> | 2004-10-18 21:51:27 +0000 |
|---|---|---|
| committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2004-10-18 21:51:27 +0000 |
| commit | 95bc56897714a12b8e95c92dd8e1a70f1154162d (patch) | |
| tree | 20f824d4840c6e3d41b20debf19f65f472d3916d /sys | |
| parent | 2b0448ba0c40d092a45e294f98d8256c6fdb33d7 (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/alpha/alpha/promcons.c | 7 | ||||
| -rw-r--r-- | sys/alpha/tlsb/zs_tlsb.c | 7 | ||||
| -rw-r--r-- | sys/dev/dcons/dcons_os.c | 7 | ||||
| -rw-r--r-- | sys/dev/digi/digi.c | 17 | ||||
| -rw-r--r-- | sys/dev/nmdm/nmdm.c | 8 | ||||
| -rw-r--r-- | sys/dev/ofw/ofw_console.c | 7 | ||||
| -rw-r--r-- | sys/dev/syscons/syscons.c | 40 | ||||
| -rw-r--r-- | sys/dev/syscons/sysmouse.c | 7 | ||||
| -rw-r--r-- | sys/dev/zs/zs.c | 17 | ||||
| -rw-r--r-- | sys/i386/isa/pcvt/pcvt_drv.c | 7 | ||||
| -rw-r--r-- | sys/ia64/ia64/ssc.c | 7 | ||||
| -rw-r--r-- | sys/kern/tty.c | 41 | ||||
| -rw-r--r-- | sys/kern/tty_pty.c | 7 | ||||
| -rw-r--r-- | sys/sys/tty.h | 1 |
14 files changed, 62 insertions, 118 deletions
diff --git a/sys/alpha/alpha/promcons.c b/sys/alpha/alpha/promcons.c index 62ef0e8cfbe2..5caca759d536 100644 --- a/sys/alpha/alpha/promcons.c +++ b/sys/alpha/alpha/promcons.c @@ -107,12 +107,7 @@ promopen(dev, flag, mode, td) tp->t_dev = dev; if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_CARR_ON; - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG|CLOCAL; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + ttyconsmode(tp, 0); ttsetwater(tp); setuptimeout = 1; diff --git a/sys/alpha/tlsb/zs_tlsb.c b/sys/alpha/tlsb/zs_tlsb.c index 84f7e83400df..22093b27069d 100644 --- a/sys/alpha/tlsb/zs_tlsb.c +++ b/sys/alpha/tlsb/zs_tlsb.c @@ -283,12 +283,7 @@ zsopen(struct cdev *dev, int flag, int mode, struct thread *td) tp = dev->si_tty; if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_CARR_ON; - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG|CLOCAL; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + ttyconsolemode(tp, 0); ttsetwater(tp); setuptimeout = 1; } else if ((tp->t_state & TS_XCLUDE) && suser(td)) { diff --git a/sys/dev/dcons/dcons_os.c b/sys/dev/dcons/dcons_os.c index a04d16eda9f2..5a5f0aa10731 100644 --- a/sys/dev/dcons/dcons_os.c +++ b/sys/dev/dcons/dcons_os.c @@ -294,12 +294,7 @@ dcons_open(DEV dev, int flag, int mode, THREAD *td) s = spltty(); if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_CARR_ON; - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG|CLOCAL; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + ttyconsolemode(tp, 0); ttsetwater(tp); } else if ((tp->t_state & TS_XCLUDE) && suser(td)) { splx(s); diff --git a/sys/dev/digi/digi.c b/sys/dev/digi/digi.c index 31e08c98a9dc..5ecc6018689d 100644 --- a/sys/dev/digi/digi.c +++ b/sys/dev/digi/digi.c @@ -85,9 +85,6 @@ static void digi_free_state(struct digi_softc *); fepcmd(port, cmd, (op2 << 8) | op1, ncmds) #define fepcmd_w fepcmd - -static speed_t digidefaultrate = TTYDEF_SPEED; - struct con_bios { struct con_bios *next; u_char *bios; @@ -589,19 +586,7 @@ digi_init(struct digi_softc *sc) bc->edelay = 100; - /* - * We don't use all the flags from <sys/ttydefaults.h> since - * they are only relevant for logins. It's important to have - * echo off initially so that the line doesn't start blathering - * before the echo flag can be turned off. - */ - tp->t_init_in.c_iflag = 0; - tp->t_init_in.c_oflag = 0; - tp->t_init_in.c_cflag = TTYDEF_CFLAG; - tp->t_init_in.c_lflag = 0; - termioschars(&tp->t_init_in); - tp->t_init_in.c_ispeed = tp->t_init_in.c_ospeed = digidefaultrate; - tp->t_init_out = tp->t_init_in; + ttyinitmode(tp, 0, 0); port->send_ring = 1; /* Default action on signal RI */ ttycreate(tp, NULL, 0, MINOR_CALLOUT, "D%r%r", sc->res.unit, i); } diff --git a/sys/dev/nmdm/nmdm.c b/sys/dev/nmdm/nmdm.c index 41a8704305d4..536dce9a4609 100644 --- a/sys/dev/nmdm/nmdm.c +++ b/sys/dev/nmdm/nmdm.c @@ -247,13 +247,7 @@ nmdmopen(struct cdev *dev, int flag, int devtype, struct thread *td) tp2 = sp->other->nm_tty; if ((tp->t_state & TS_ISOPEN) == 0) { - ttychars(tp); /* Set up default chars */ - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_lflag = 0; - tp->t_cflag = TTYDEF_CFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + ttyinitmode(tp, 0, 0); ttsetwater(tp); /* XXX ? */ } else if (tp->t_state & TS_XCLUDE && suser(td)) { return (EBUSY); diff --git a/sys/dev/ofw/ofw_console.c b/sys/dev/ofw/ofw_console.c index 22bed0f28ce9..40ac7dc7ca7b 100644 --- a/sys/dev/ofw/ofw_console.c +++ b/sys/dev/ofw/ofw_console.c @@ -138,12 +138,7 @@ ofw_dev_open(struct cdev *dev, int flag, int mode, struct thread *td) if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_CARR_ON; - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG | CLOCAL; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + ttyconsolemode(tp, 0); ttsetwater(tp); setuptimeout = 1; diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 7cd99daa7b67..f92d2fb16308 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -145,6 +145,7 @@ SYSCTL_INT(_machdep, OID_AUTO, enable_panic_key, CTLFLAG_RW, &enable_panic_key, static int debugger; /* prototypes */ +static struct tty *sc_alloc_tty(struct cdev *dev); static int scvidprobe(int unit, int flags, int cons); static int sckbdprobe(int unit, int flags, int cons); static void scmeminit(void *arg); @@ -288,10 +289,23 @@ static char return names[i].name[(adp->va_flags & V_ADP_COLOR) ? 0 : 1]; } +static struct tty * +sc_alloc_tty(struct cdev *dev) +{ + struct tty *tp; + + tp = dev->si_tty = ttyalloc(); + ttyinitmode(tp, 1, 0); + tp->t_oproc = scstart; + tp->t_param = scparam; + tp->t_stop = nottystop; + tp->t_dev = dev; + return (tp); +} + int sc_attach_unit(int unit, int flags) { - struct tty *tp; sc_softc_t *sc; scr_stat *scp; #ifdef SC_PIXEL_MODE @@ -383,14 +397,9 @@ sc_attach_unit(int unit, int flags) for (vc = 0; vc < sc->vtys; vc++) { if (sc->dev[vc] == NULL) { - dev = make_dev(&sc_cdevsw, vc + unit * MAXCONS, + sc->dev[vc] = make_dev(&sc_cdevsw, vc + unit * MAXCONS, UID_ROOT, GID_WHEEL, 0600, "ttyv%r", vc + unit * MAXCONS); - sc->dev[vc] = dev; - tp = sc->dev[vc]->si_tty = ttyalloc(); - tp->t_oproc = scstart; - tp->t_param = scparam; - tp->t_stop = nottystop; - tp->t_dev = sc->dev[vc]; + sc_alloc_tty(sc->dev[vc]); if (vc == 0 && sc->dev == main_devs) SC_STAT(sc->dev[0]) = &main_console; } @@ -403,12 +412,8 @@ sc_attach_unit(int unit, int flags) dev = make_dev(&sc_cdevsw, SC_CONSOLECTL, UID_ROOT, GID_WHEEL, 0600, "consolectl"); - tp = dev->si_tty = sc_console_tty = ttyalloc(); - ttyconsolemode(tp, 0); - tp->t_oproc = scstart; - tp->t_param = scparam; - tp->t_stop = nottystop; - tp->t_dev = dev; + sc_console_tty = sc_alloc_tty(dev); + ttyconsolemode(sc_console_tty, 0); SC_STAT(dev) = sc_console; return 0; @@ -2581,7 +2586,6 @@ sc_change_cursor_shape(scr_stat *scp, int flags, int base, int height) static void scinit(int unit, int flags) { - struct tty *tp; /* * When syscons is being initialized as the kernel console, malloc() @@ -2692,11 +2696,7 @@ scinit(int unit, int flags) sc->dev = malloc(sizeof(struct cdev *)*sc->vtys, M_DEVBUF, M_WAITOK|M_ZERO); sc->dev[0] = make_dev(&sc_cdevsw, unit * MAXCONS, UID_ROOT, GID_WHEEL, 0600, "ttyv%r", unit * MAXCONS); - tp = sc->dev[0]->si_tty = ttyalloc(); - tp->t_oproc = scstart; - tp->t_param = scparam; - tp->t_stop = nottystop; - tp->t_dev = sc->dev[0]; + sc_alloc_tty(sc->dev[0]); scp = alloc_scp(sc, sc->first_vty); SC_STAT(sc->dev[0]) = scp; } diff --git a/sys/dev/syscons/sysmouse.c b/sys/dev/syscons/sysmouse.c index be4112cf5c4a..4f660e09e878 100644 --- a/sys/dev/syscons/sysmouse.c +++ b/sys/dev/syscons/sysmouse.c @@ -80,12 +80,7 @@ smopen(struct cdev *dev, int flag, int mode, struct thread *td) tp = dev->si_tty; if (!(tp->t_state & TS_ISOPEN)) { - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + ttyinitmode(tp, 0, 0); smparam(tp, &tp->t_termios); ttyld_modem(tp, 1); } else if (tp->t_state & TS_XCLUDE && suser(td)) { diff --git a/sys/dev/zs/zs.c b/sys/dev/zs/zs.c index b79060be2c95..eec675315568 100644 --- a/sys/dev/zs/zs.c +++ b/sys/dev/zs/zs.c @@ -276,12 +276,8 @@ zstty_attach(device_t dev) tp->t_modem = zsttymodem; tp->t_break = zsttybreak; tp->t_stop = zsttystop; - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_lflag = TTYDEF_LFLAG; + ttyinitmode(tp, 0, 0); tp->t_cflag = CREAD | CLOCAL | CS8; - tp->t_ospeed = TTYDEF_SPEED; - tp->t_ispeed = TTYDEF_SPEED; if (zstty_console(dev, mode, sizeof(mode))) { ttychars(tp); @@ -472,19 +468,10 @@ zsttyopen(struct cdev *dev, int flags, int mode, struct thread *td) sc->sc_preg[1] |= ZSWR1_RIE | ZSWR1_SIE; sc->sc_iput = sc->sc_iget = sc->sc_ibuf; - /* - * Initialize the termios status to the defaults. Add in the - * sticky bits from TIOCSFLAGS. - */ - t.c_ispeed = 0; - t.c_ospeed = tp->t_ospeed; - t.c_cflag = TTYDEF_CFLAG; + ttyconsolemode(t, 0); /* Make sure zstty_param() will do something. */ tp->t_ospeed = 0; (void)zstty_param(sc, tp, &t); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_lflag = TTYDEF_LFLAG; ttychars(tp); ttsetwater(tp); diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index 16aa04ccf92c..6eb1ac1b905d 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -297,12 +297,7 @@ pcvt_open(struct cdev *dev, int flag, int mode, struct thread *td) if ((tp->t_state & TS_ISOPEN) == 0) { - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + ttyinitmode(tp, 1, 0); pcvt_param(tp, &tp->t_termios); ttyld_modem(tp, 1); /* fake connection */ winsz = 1; /* set winsize later */ diff --git a/sys/ia64/ia64/ssc.c b/sys/ia64/ia64/ssc.c index a475fb519f5d..6fc3a1b19057 100644 --- a/sys/ia64/ia64/ssc.c +++ b/sys/ia64/ia64/ssc.c @@ -148,12 +148,7 @@ sscopen(struct cdev *dev, int flag, int mode, struct thread *td) tp->t_dev = dev; if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_CARR_ON; - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG|CLOCAL; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + ttyconsolemode(tp, 0); ttsetwater(tp); setuptimeout = 1; diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 020529cff1af..9b4a618c036c 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -2845,11 +2845,7 @@ ttymalloc(struct tty *tp) tp->t_timeout = -1; tp->t_dtr_wait = 3 * hz; - tp->t_init_in.c_iflag = TTYDEF_IFLAG; - tp->t_init_in.c_oflag = TTYDEF_OFLAG; - tp->t_init_in.c_cflag = TTYDEF_CFLAG; - tp->t_init_in.c_lflag = TTYDEF_LFLAG; - tp->t_init_in.c_ispeed = tp->t_init_in.c_ospeed = TTYDEF_SPEED; + ttyinitmode(tp, 0, 0); bcopy(ttydefchars, tp->t_init_in.c_cc, sizeof tp->t_init_in.c_cc); /* Make callout the same as callin */ @@ -3365,23 +3361,44 @@ ttysioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t } /* - * Use more "normal" termios paramters for consoles. + * Initialize a tty to sane modes. */ void -ttyconsolemode(struct tty *tp, int speed) +ttyinitmode(struct tty *tp, int echo, int speed) { + if (speed == 0) + speed = TTYDEF_SPEED; tp->t_init_in.c_iflag = TTYDEF_IFLAG; tp->t_init_in.c_oflag = TTYDEF_OFLAG; - tp->t_init_in.c_cflag = TTYDEF_CFLAG | CLOCAL; - tp->t_init_in.c_lflag = TTYDEF_LFLAG_ECHO; - tp->t_lock_out.c_cflag = tp->t_lock_in.c_cflag = CLOCAL; + tp->t_init_in.c_cflag = TTYDEF_CFLAG; + if (echo) + tp->t_init_in.c_lflag = TTYDEF_LFLAG_ECHO; + else + tp->t_init_in.c_lflag = TTYDEF_LFLAG; + + tp->t_init_in.c_ispeed = tp->t_init_in.c_ospeed = speed; + termioschars(&tp->t_init_in); + tp->t_init_out = tp->t_init_in; + tp->t_termios = tp->t_init_in; +} + +/* + * Use more "normal" termios paramters for consoles. + */ +void +ttyconsolemode(struct tty *tp, int speed) +{ + if (speed == 0) speed = TTYDEF_SPEED; + ttyinitmode(tp, 1, speed); + tp->t_init_in.c_cflag |= CLOCAL; + tp->t_lock_out.c_cflag = tp->t_lock_in.c_cflag = CLOCAL; tp->t_lock_out.c_ispeed = tp->t_lock_out.c_ospeed = - tp->t_lock_in.c_ispeed = tp->t_lock_in.c_ospeed = - tp->t_init_in.c_ispeed = tp->t_init_in.c_ospeed = speed; + tp->t_lock_in.c_ispeed = tp->t_lock_in.c_ospeed = speed; tp->t_init_out = tp->t_init_in; + tp->t_termios = tp->t_init_in; } /* diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 65645815cd86..89d1b36124a2 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -175,12 +175,7 @@ ptsopen(struct cdev *dev, int flag, int devtype, struct thread *td) pt = dev->si_drv1; tp = dev->si_tty; if ((tp->t_state & TS_ISOPEN) == 0) { - ttychars(tp); /* Set up default chars */ - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_lflag = TTYDEF_LFLAG_ECHO; - tp->t_cflag = TTYDEF_CFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + ttyinitmode(tp, 1, 0); } else if (tp->t_state & TS_XCLUDE && suser(td)) return (EBUSY); else if (pt->pt_prison != td->td_ucred->cr_prison) diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 75d183b96d09..d9f104aef81d 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -357,6 +357,7 @@ void ttyflush(struct tty *tp, int rw); void ttyfree(struct tty *tp); void ttygone(struct tty *tp); void ttyinfo(struct tty *tp); +void ttyinitmode(struct tty *tp, int echo, int speed); int ttyinput(int c, struct tty *tp); int ttylclose(struct tty *tp, int flag); void ttyldoptim(struct tty *tp); |
