diff options
author | ed <ed@FreeBSD.org> | 2008-08-24 19:50:57 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-08-24 19:50:57 +0000 |
commit | 149600a3ddad2aafd0fa943d7511dd1e48d0e4b9 (patch) | |
tree | d15d9d203484c610ec6fdbd7fb910480a5fdd58c /sys/dev/syscons/syscons.c | |
parent | 5890c8d4b72728d4a9cbbee6ac4043ec602d455d (diff) | |
download | FreeBSD-src-149600a3ddad2aafd0fa943d7511dd1e48d0e4b9.zip FreeBSD-src-149600a3ddad2aafd0fa943d7511dd1e48d0e4b9.tar.gz |
Make syscons(4) use ttyv0 instead of consolectl as its primary window.
When I was hacking on uart(4) to make it work with the MPSAFE TTY layer,
I noticed there was a difference between the way syscons and uart work
with respect to consoles:
- The uart(4) driver sets cn_name to the corresponding ttyu%r node,
which means init(8) (which opens /dev/console) will have its output
redirected to /dev/ttyu%r. After /etc/rc is done, it can spawn a getty
on that device node as well.
- Syscons used a little different approach. Apart from the /dev/ttyv%r
nodes, it creates a /dev/consolectl node. This device node is used by
moused and others to deliver their data, but for some reason it also
acts as a TTY, which shares its stat structure with ttyv0. This device
node is used as a console (run conscontrol).
There are a couple advantages of this approach:
- Because we use two different TTY's to represent the 0th syscons
window, we allocate two sets of TTY buffers. Even if you don't use
/dev/consolectl after the system has booted (systems that don't run
moused), it seems the buffers are still allocated.
- We have to apply an evil hack to redirect input to /dev/consolectl.
Because each window (stat) is associated not associated with one TTY,
syscons solves this by redirecting all input to closed TTY's to
consolectl.
This means that opening /dev/ttyv0 while in single user mode will
probably cause strange things to happen with respect to keyboard input
redirection.
The first patch that I discussed with philip@ turned consolectl into a
symlink to ttyv0, but this was not a good idea, because in theory we
would want consolectl to be a simple device node, which contains all the
`privileged' ioctl()'s. Apart from that, it didn't work, because each
time /dev/ttyv0 got revoked, moused also lost its descriptor to deliver
input, which meant you had to plug out/in your mouse to make it work
again. This version just leaves the consolectl device the way it is. It
can still be used to write output to ttyv0, but it can no longer receive
any input.
In my opinion this patch is not a complete solution, but it's already a
step in the good direction. It would allow us to turn consolectl into a
special (non-TTY) device node in the far future. It shaves off 15 KB of
wasted TTY buffer space.
Discussed with: philip
Diffstat (limited to 'sys/dev/syscons/syscons.c')
-rw-r--r-- | sys/dev/syscons/syscons.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index ed5e459..3c83adb 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -103,7 +103,6 @@ static default_attr kernel_default = { static int sc_console_unit = -1; static int sc_saver_keyb_only = 1; static scr_stat *sc_console; -static struct tty *sc_console_tty; static struct consdev *sc_consptr; static void *kernel_console_ts; static scr_stat main_console; @@ -362,6 +361,7 @@ sc_attach_unit(int unit, int flags) video_info_t info; #endif int vc; + struct tty *tp; flags &= ~SC_KERNEL_CONSOLE; @@ -457,8 +457,8 @@ sc_attach_unit(int unit, int flags) */ } - sc_console_tty = sc_alloc_tty(0, "consolectl"); - SC_STAT(sc_console_tty) = sc_console; + tp = sc_alloc_tty(0, "consolectl"); + SC_STAT(tp) = sc_console; return 0; } @@ -639,13 +639,8 @@ sckbdevent(keyboard_t *thiskbd, int event, void *arg) while ((c = scgetc(sc, SCGETC_NONBLOCK)) != NOKEY) { cur_tty = SC_DEV(sc, sc->cur_scp->index); - if (!tty_opened(cur_tty)) { - cur_tty = sc_console_tty; - if (cur_tty == NULL) - continue; - if (!tty_opened(cur_tty)) - continue; - } + if (!tty_opened(cur_tty)) + continue; if ((*sc->cur_scp->tsw->te_input)(sc->cur_scp, c, cur_tty)) continue; @@ -1473,7 +1468,7 @@ sc_cnprobe(struct consdev *cp) return; /* initialize required fields */ - sprintf(cp->cn_name, "consolectl"); + strcpy(cp->cn_name, "ttyv0"); } static void |