diff options
author | ed <ed@FreeBSD.org> | 2008-08-20 08:31:58 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-08-20 08:31:58 +0000 |
commit | cc3116a9380fe32a751b584f3d8083698ccfba15 (patch) | |
tree | bd0c08a66997254385160ce71ea32029b99f99f9 /sys/ia64 | |
parent | b49301b5cd9ff43a7af0bd9054d9d1a328c0d212 (diff) | |
download | FreeBSD-src-cc3116a9380fe32a751b584f3d8083698ccfba15.zip FreeBSD-src-cc3116a9380fe32a751b584f3d8083698ccfba15.tar.gz |
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
Diffstat (limited to 'sys/ia64')
-rw-r--r-- | sys/ia64/conf/GENERIC | 2 | ||||
-rw-r--r-- | sys/ia64/conf/SKI | 2 | ||||
-rw-r--r-- | sys/ia64/ia64/ssc.c | 138 |
3 files changed, 41 insertions, 101 deletions
diff --git a/sys/ia64/conf/GENERIC b/sys/ia64/conf/GENERIC index ae94a22..793190d 100644 --- a/sys/ia64/conf/GENERIC +++ b/sys/ia64/conf/GENERIC @@ -151,7 +151,7 @@ device faith # IPv6-to-IPv4 relaying (translation) device gif # IPv6 and IPv4 tunneling device loop # Network loopback device md # Memory "disks" -device pty # Pseudo-ttys (telnet etc) +device pty # BSD-style compatibility pseudo ttys device puc # Multi I/O cards and multi-channel UARTs device random # Entropy device device tun # Packet tunnel. diff --git a/sys/ia64/conf/SKI b/sys/ia64/conf/SKI index 377ee93..001c710 100644 --- a/sys/ia64/conf/SKI +++ b/sys/ia64/conf/SKI @@ -53,7 +53,7 @@ device pci # PCI bus support device ether # Ethernet support device loop # Network loopback device md # Memory "disks" -device pty # Pseudo-ttys (telnet etc) +device pty # BSD-style compatibility pseudo ttys device random # Entropy device device tun # Packet tunnel. diff --git a/sys/ia64/ia64/ssc.c b/sys/ia64/ia64/ssc.c index 274cc0d..04144c5 100644 --- a/sys/ia64/ia64/ssc.c +++ b/sys/ia64/ia64/ssc.c @@ -54,26 +54,22 @@ #define SSC_POLL_HZ 50 -static d_open_t ssc_open; -static d_close_t ssc_close; - -static struct cdevsw ssc_cdevsw = { - .d_version = D_VERSION, - .d_open = ssc_open, - .d_close = ssc_close, - .d_name = "ssc", - .d_flags = D_TTY | D_NEEDGIANT, +static tsw_open_t ssc_open; +static tsw_outwakeup_t ssc_outwakeup; +static tsw_close_t ssc_close; + +static struct ttydevsw ssc_class = { + .tsw_flags = TF_NOPREFIX, + .tsw_open = ssc_open, + .tsw_outwakeup = ssc_outwakeup, + .tsw_close = ssc_close, }; -static struct tty *ssc_tp = NULL; static int polltime; static struct callout_handle ssc_timeouthandle = CALLOUT_HANDLE_INITIALIZER(&ssc_timeouthandle); -static void ssc_start(struct tty *); static void ssc_timeout(void *); -static int ssc_param(struct tty *, struct termios *); -static void ssc_stop(struct tty *, int); static u_int64_t ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which) @@ -90,7 +86,8 @@ ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which) static void ssc_cnprobe(struct consdev *cp) { - sprintf(cp->cn_name, "ssccons"); + + strcpy(cp->cn_name, "ssccons"); cp->cn_pri = CN_INTERNAL; } @@ -107,8 +104,10 @@ ssc_cnterm(struct consdev *cp) static void ssc_cnattach(void *arg) { - make_dev(&ssc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "ssccons"); - ssc_tp = ttyalloc(); + struct tty *tp; + + tp = tty_alloc(&ssc_class, NULL, NULL); + tty_makedev(tp, NULL, "ssccons"); } SYSINIT(ssc_cnattach, SI_SUB_DRIVERS, SI_ORDER_ANY, ssc_cnattach, 0); @@ -130,100 +129,39 @@ ssc_cngetc(struct consdev *cp) } static int -ssc_open(struct cdev *dev, int flag, int mode, struct thread *td) +ssc_open(struct tty *tp) { - struct tty *tp; - int s; - int error = 0, setuptimeout = 0; - - tp = dev->si_tty = ssc_tp; - - s = spltty(); - tp->t_oproc = ssc_start; - tp->t_param = ssc_param; - tp->t_stop = ssc_stop; - tp->t_dev = dev; - if ((tp->t_state & TS_ISOPEN) == 0) { - tp->t_state |= TS_CARR_ON; - ttyconsolemode(tp, 0); - - setuptimeout = 1; - } else if ((tp->t_state & TS_XCLUDE) && - priv_check(td, PRIV_TTY_EXCLUSIVE)) { - splx(s); - return EBUSY; - } - - splx(s); - error = ttyld_open(tp, dev); + polltime = hz / SSC_POLL_HZ; + if (polltime < 1) + polltime = 1; + ssc_timeouthandle = timeout(ssc_timeout, tp, polltime); - if (error == 0 && setuptimeout) { - polltime = hz / SSC_POLL_HZ; - if (polltime < 1) - polltime = 1; - ssc_timeouthandle = timeout(ssc_timeout, tp, polltime); - } - return error; + return (0); } -static int -ssc_close(struct cdev *dev, int flag, int mode, struct thread *td) +static void +ssc_close(struct tty *tp) { - int unit = minor(dev); - struct tty *tp = ssc_tp; - - if (unit != 0) - return ENXIO; untimeout(ssc_timeout, tp, ssc_timeouthandle); - ttyld_close(tp, flag); - tty_close(tp); - return 0; -} - -static int -ssc_param(struct tty *tp, struct termios *t) -{ - - return 0; } static void -ssc_start(struct tty *tp) +ssc_outwakeup(struct tty *tp) { - int s; + char buf[128]; + size_t len, c; - s = spltty(); + for (;;) { + len = ttydisc_getc(tp, buf, sizeof buf); + if (len == 0) + break; - if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) { - ttwwakeup(tp); - splx(s); - return; + c = 0; + while (len-- > 0) + ssc_cnputc(NULL, buf[c++]); } - - tp->t_state |= TS_BUSY; - while (tp->t_outq.c_cc != 0) - ssc_cnputc(NULL, getc(&tp->t_outq)); - tp->t_state &= ~TS_BUSY; - - ttwwakeup(tp); - splx(s); -} - -/* - * Stop output on a line. - */ -static void -ssc_stop(struct tty *tp, int flag) -{ - int s; - - s = spltty(); - if (tp->t_state & TS_BUSY) - if ((tp->t_state & TS_TTSTOP) == 0) - tp->t_state |= TS_FLUSH; - splx(s); } static void @@ -232,10 +170,12 @@ ssc_timeout(void *v) struct tty *tp = v; int c; - while ((c = ssc_cngetc(NULL)) != -1) { - if (tp->t_state & TS_ISOPEN) - ttyld_rint(tp, c); - } + tty_lock(tp); + while ((c = ssc_cngetc(NULL)) != -1) + ttydisc_rint(tp, c, 0); + ttydisc_rint_done(tp); + tty_unlock(tp); + ssc_timeouthandle = timeout(ssc_timeout, tp, polltime); } |