version 1.128.4.4, 2001/10/13 17:42:52 |
version 1.129, 2001/11/12 15:25:27 |
|
|
* @(#)tty.c 8.13 (Berkeley) 1/9/95 |
* @(#)tty.c 8.13 (Berkeley) 1/9/95 |
*/ |
*/ |
|
|
|
#include <sys/cdefs.h> |
|
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
#include "opt_uconsole.h" |
#include "opt_uconsole.h" |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
Line 68 static void ttyecho(int, struct tty *); |
|
Line 71 static void ttyecho(int, struct tty *); |
|
static void ttyrubo(struct tty *, int); |
static void ttyrubo(struct tty *, int); |
static int proc_compare(struct proc *, struct proc *); |
static int proc_compare(struct proc *, struct proc *); |
|
|
static int ttnread __P((struct tty *)); |
|
static void ttyblock __P((struct tty *)); |
|
static void ttyecho __P((int, struct tty *)); |
|
static void ttyrubo __P((struct tty *, int)); |
|
static int proc_compare __P((struct proc *, struct proc *)); |
|
|
|
#include <sys/conf.h> |
|
extern int comopen(struct vnode *, int oflags, int devtype, struct proc *p); |
|
|
|
/* Symbolic sleep message strings. */ |
/* Symbolic sleep message strings. */ |
const char ttclos[] = "ttycls"; |
const char ttclos[] = "ttycls"; |
const char ttopen[] = "ttyopn"; |
const char ttopen[] = "ttyopn"; |
Line 230 ttyopen(struct tty *tp, int dialout, int |
|
Line 224 ttyopen(struct tty *tp, int dialout, int |
|
return (0); |
return (0); |
} |
} |
|
|
|
|
/* |
/* |
* Initial open of tty, or (re)entry to standard tty line discipline. |
* Initial open of tty, or (re)entry to standard tty line discipline. |
*/ |
*/ |
int |
int |
ttylopen(struct vnode *devvp, struct tty *tp) |
ttylopen(dev_t device, struct tty *tp) |
{ |
{ |
int s; |
int s; |
|
|
s = spltty(); |
s = spltty(); |
tp->t_dev = vdev_rdev(devvp); |
tp->t_dev = device; |
if (!ISSET(tp->t_state, TS_ISOPEN)) { |
if (!ISSET(tp->t_state, TS_ISOPEN)) { |
SET(tp->t_state, TS_ISOPEN); |
SET(tp->t_state, TS_ISOPEN); |
memset(&tp->t_winsize, 0, sizeof(tp->t_winsize)); |
memset(&tp->t_winsize, 0, sizeof(tp->t_winsize)); |
Line 260 ttylopen(struct vnode *devvp, struct tty |
|
Line 253 ttylopen(struct vnode *devvp, struct tty |
|
int |
int |
ttyclose(struct tty *tp) |
ttyclose(struct tty *tp) |
{ |
{ |
if (constty == tp) { |
extern struct tty *constty; /* Temporary virtual console. */ |
|
|
|
if (constty == tp) |
constty = NULL; |
constty = NULL; |
vrele(consvp); |
|
consvp = NULL; |
|
} |
|
|
|
ttyflush(tp, FREAD | FWRITE); |
ttyflush(tp, FREAD | FWRITE); |
|
|
Line 729 ttyoutput(int c, struct tty *tp) |
|
Line 721 ttyoutput(int c, struct tty *tp) |
|
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
ttioctl(struct tty *tp, struct vnode *devvp, u_long cmd, caddr_t data, |
ttioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p) |
int flag, struct proc *p) |
|
{ |
{ |
extern struct tty *constty; /* Temporary virtual console. */ |
extern struct tty *constty; /* Temporary virtual console. */ |
extern int nlinesw; |
extern int nlinesw; |
Line 816 ttioctl(struct tty *tp, struct vnode *de |
|
Line 807 ttioctl(struct tty *tp, struct vnode *de |
|
return (error); |
return (error); |
#endif |
#endif |
constty = tp; |
constty = tp; |
vref(devvp); |
} else if (tp == constty) |
consvp = devvp; |
|
} else if (tp == constty) { |
|
constty = NULL; |
constty = NULL; |
consvp = NULL; |
|
vrele(devvp); |
|
} |
|
break; |
break; |
case TIOCDRAIN: /* wait till output drained */ |
case TIOCDRAIN: /* wait till output drained */ |
if ((error = ttywait(tp)) != 0) |
if ((error = ttywait(tp)) != 0) |
Line 956 ttioctl(struct tty *tp, struct vnode *de |
|
Line 942 ttioctl(struct tty *tp, struct vnode *de |
|
device = tp->t_dev; |
device = tp->t_dev; |
s = spltty(); |
s = spltty(); |
(*tp->t_linesw->l_close)(tp, flag); |
(*tp->t_linesw->l_close)(tp, flag); |
error = (*lp->l_open)(devvp, tp); |
error = (*lp->l_open)(device, tp); |
if (error) { |
if (error) { |
(void)(*tp->t_linesw->l_open)(devvp, tp); |
(void)(*tp->t_linesw->l_open)(device, tp); |
splx(s); |
splx(s); |
return (error); |
return (error); |
} |
} |
Line 1027 ttioctl(struct tty *tp, struct vnode *de |
|
Line 1013 ttioctl(struct tty *tp, struct vnode *de |
|
break; |
break; |
default: |
default: |
#ifdef COMPAT_OLDTTY |
#ifdef COMPAT_OLDTTY |
return (ttcompat(tp, devvp, cmd, data, flag, p)); |
return (ttcompat(tp, cmd, data, flag, p)); |
#else |
#else |
return (-1); |
return (-1); |
#endif |
#endif |
Line 1222 ttstart(struct tty *tp) |
|
Line 1208 ttstart(struct tty *tp) |
|
int |
int |
ttylclose(struct tty *tp, int flag) |
ttylclose(struct tty *tp, int flag) |
{ |
{ |
|
|
if (flag & FNONBLOCK) |
if (flag & FNONBLOCK) |
ttyflush(tp, FREAD | FWRITE); |
ttyflush(tp, FREAD | FWRITE); |
else |
else |