Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/tty.c
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
#define TTYSUP_IFLAG (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|ISTRIP|\ | #define TTYSUP_IFLAG (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|ISTRIP|\ | ||||
INLCR|IGNCR|ICRNL|IXON|IXOFF|IXANY|IMAXBEL) | INLCR|IGNCR|ICRNL|IXON|IXOFF|IXANY|IMAXBEL) | ||||
#define TTYSUP_OFLAG (OPOST|ONLCR|TAB3|ONOEOT|OCRNL|ONOCR|ONLRET) | #define TTYSUP_OFLAG (OPOST|ONLCR|TAB3|ONOEOT|OCRNL|ONOCR|ONLRET) | ||||
#define TTYSUP_LFLAG (ECHOKE|ECHOE|ECHOK|ECHO|ECHONL|ECHOPRT|\ | #define TTYSUP_LFLAG (ECHOKE|ECHOE|ECHOK|ECHO|ECHONL|ECHOPRT|\ | ||||
ECHOCTL|ISIG|ICANON|ALTWERASE|IEXTEN|TOSTOP|\ | ECHOCTL|ISIG|ICANON|ALTWERASE|IEXTEN|TOSTOP|\ | ||||
FLUSHO|NOKERNINFO|NOFLSH) | FLUSHO|NOKERNINFO|NOFLSH) | ||||
#define TTYSUP_CFLAG (CIGNORE|CSIZE|CSTOPB|CREAD|PARENB|PARODD|\ | #define TTYSUP_CFLAG (CIGNORE|CSIZE|CSTOPB|CREAD|PARENB|PARODD|\ | ||||
HUPCL|CLOCAL|CCTS_OFLOW|CRTS_IFLOW|CDTR_IFLOW|\ | HUPCL|CLOCAL|CCTS_OFLOW|CRTS_IFLOW|CDTR_IFLOW|\ | ||||
CDSR_OFLOW|CCAR_OFLOW) | CDSR_OFLOW|CCAR_OFLOW|CNO_RTSDTR) | ||||
#define TTY_CALLOUT(tp,d) (dev2unit(d) & TTYUNIT_CALLOUT) | #define TTY_CALLOUT(tp,d) (dev2unit(d) & TTYUNIT_CALLOUT) | ||||
static int tty_drainwait = 5 * 60; | static int tty_drainwait = 5 * 60; | ||||
SYSCTL_INT(_kern, OID_AUTO, tty_drainwait, CTLFLAG_RWTUN, | SYSCTL_INT(_kern, OID_AUTO, tty_drainwait, CTLFLAG_RWTUN, | ||||
&tty_drainwait, 0, "Default output drain timeout in seconds"); | &tty_drainwait, 0, "Default output drain timeout in seconds"); | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | if (TTY_CALLOUT(tp, dev)) | ||||
tp->t_termios = tp->t_termios_init_out; | tp->t_termios = tp->t_termios_init_out; | ||||
else | else | ||||
tp->t_termios = tp->t_termios_init_in; | tp->t_termios = tp->t_termios_init_in; | ||||
ttydevsw_param(tp, &tp->t_termios); | ttydevsw_param(tp, &tp->t_termios); | ||||
/* Prevent modem control on callout devices and /dev/console. */ | /* Prevent modem control on callout devices and /dev/console. */ | ||||
if (TTY_CALLOUT(tp, dev) || dev == dev_console) | if (TTY_CALLOUT(tp, dev) || dev == dev_console) | ||||
tp->t_termios.c_cflag |= CLOCAL; | tp->t_termios.c_cflag |= CLOCAL; | ||||
if ((tp->t_termios.c_cflag & CNO_RTSDTR) == 0) | |||||
ttydevsw_modem(tp, SER_DTR|SER_RTS, 0); | ttydevsw_modem(tp, SER_DTR|SER_RTS, 0); | ||||
error = ttydevsw_open(tp); | error = ttydevsw_open(tp); | ||||
if (error != 0) | if (error != 0) | ||||
goto done; | goto done; | ||||
ttydisc_open(tp); | ttydisc_open(tp); | ||||
error = tty_watermarks(tp); | error = tty_watermarks(tp); | ||||
if (error != 0) | if (error != 0) | ||||
▲ Show 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | for (cc = 0; cc < NCCS; ++cc) | ||||
if (lock->c_cc[cc]) | if (lock->c_cc[cc]) | ||||
new->c_cc[cc] = old->c_cc[cc]; | new->c_cc[cc] = old->c_cc[cc]; | ||||
if (lock->c_ispeed) | if (lock->c_ispeed) | ||||
new->c_ispeed = old->c_ispeed; | new->c_ispeed = old->c_ispeed; | ||||
if (lock->c_ospeed) | if (lock->c_ospeed) | ||||
new->c_ospeed = old->c_ospeed; | new->c_ospeed = old->c_ospeed; | ||||
} | } | ||||
if (cmd == TIOCSFBAUD) { | |||||
struct termios *lock = TTY_CALLOUT(tp, dev) ? | |||||
&tp->t_termios_lock_out : &tp->t_termios_lock_in; | |||||
/* For lock state devices, just fail */ | |||||
if (lock->c_ispeed || lock->c_ospeed) { | |||||
error = EINVAL; | |||||
goto done; | |||||
} | |||||
error = tty_drain(tp, 0); | |||||
if (error) | |||||
goto done; | |||||
} | |||||
error = tty_ioctl(tp, cmd, data, fflag, td); | error = tty_ioctl(tp, cmd, data, fflag, td); | ||||
done: tty_unlock(tp); | done: tty_unlock(tp); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
ttydev_poll(struct cdev *dev, int events, struct thread *td) | ttydev_poll(struct cdev *dev, int events, struct thread *td) | ||||
▲ Show 20 Lines • Show All 1,257 Lines • ▼ Show 20 Lines | tty_ioctl(struct tty *tp, u_long cmd, void *data, int fflag, struct thread *td) | ||||
tty_lock_assert(tp, MA_OWNED); | tty_lock_assert(tp, MA_OWNED); | ||||
if (tty_gone(tp)) | if (tty_gone(tp)) | ||||
return (ENXIO); | return (ENXIO); | ||||
error = ttydevsw_ioctl(tp, cmd, data, td); | error = ttydevsw_ioctl(tp, cmd, data, td); | ||||
if (error == ENOIOCTL) | if (error == ENOIOCTL) | ||||
error = tty_generic_ioctl(tp, cmd, data, fflag, td); | error = tty_generic_ioctl(tp, cmd, data, fflag, td); | ||||
else { | |||||
if (cmd == TIOCSFBAUD) | |||||
error = tty_watermarks(tp); | |||||
} | |||||
return (error); | return (error); | ||||
} | } | ||||
dev_t | dev_t | ||||
tty_udev(struct tty *tp) | tty_udev(struct tty *tp) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 451 Lines • Show Last 20 Lines |