diff options
author | emaste <emaste@FreeBSD.org> | 2014-06-27 17:50:33 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2014-06-27 17:50:33 +0000 |
commit | 2b75e7bbda9839bf493b5afbf7e16c0671f0c5ff (patch) | |
tree | 8d5bf911ab86505463544aa8651ae81db12bcb06 | |
parent | 325c7f4782bf4701164925ba58bd0aacb84b5630 (diff) | |
download | FreeBSD-src-2b75e7bbda9839bf493b5afbf7e16c0671f0c5ff.zip FreeBSD-src-2b75e7bbda9839bf493b5afbf7e16c0671f0c5ff.tar.gz |
Use a common tunable to choose between vt(4)/sc(4)
With this change and previous work from ray@ it will be possible to put
both in GENERIC, and have one enabled by default, but allow the other to
be selected via the loader.
(The previous implementation had separate kern.vt.disable and
hw.syscons.disable tunables, and would panic if both drivers were
compiled in and neither was explicitly disabled.)
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
-rw-r--r-- | share/man/man4/vt.4 | 7 | ||||
-rw-r--r-- | sys/dev/syscons/syscons.c | 9 | ||||
-rw-r--r-- | sys/dev/syscons/sysmouse.c | 3 | ||||
-rw-r--r-- | sys/dev/vt/vt_consolectl.c | 2 | ||||
-rw-r--r-- | sys/dev/vt/vt_core.c | 8 | ||||
-rw-r--r-- | sys/dev/vt/vt_sysmouse.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_cons.c | 43 | ||||
-rw-r--r-- | sys/sys/cons.h | 5 |
8 files changed, 71 insertions, 8 deletions
diff --git a/share/man/man4/vt.4 b/share/man/man4/vt.4 index 809ca07..19d60f0 100644 --- a/share/man/man4/vt.4 +++ b/share/man/man4/vt.4 @@ -43,6 +43,7 @@ In .Xr loader.conf 5 : .Cd hw.vga.textmode=1 +.Cd kern.vty=vt .Sh DESCRIPTION The .Nm @@ -171,6 +172,12 @@ prompt or in Set to 1 to use virtual terminals in text mode instead of graphics mode. Features that require graphics mode, like loadable fonts, will be disabled. +.It Va kern.vty +Set to vt to choose the +.Nm +driver for the system console, if the +.Xr syscons 4 +driver is also compiled in and is the default. .El .Sh FILES .Bl -tag -width /usr/share/syscons/keymaps/* -compact diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 59b16af..6a19523 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -266,6 +266,8 @@ static struct cdevsw consolectl_devsw = { int sc_probe_unit(int unit, int flags) { + if (!vty_enabled(VTY_SC)) + return ENXIO; if (!scvidprobe(unit, flags, FALSE)) { if (bootverbose) printf("%s%d: no video adapter found.\n", SC_DRIVER_NAME, unit); @@ -491,6 +493,9 @@ sc_attach_unit(int unit, int flags) struct cdev *dev; int vc; + if (!vty_enabled(VTY_SC)) + return ENXIO; + flags &= ~SC_KERNEL_CONSOLE; if (sc_console_unit == unit) { @@ -575,6 +580,8 @@ sc_attach_unit(int unit, int flags) static void scmeminit(void *arg) { + if (!vty_enabled(VTY_SC)) + return; if (sc_malloc) return; sc_malloc = TRUE; @@ -1588,7 +1595,7 @@ sc_cnprobe(struct consdev *cp) int unit; int flags; - if (getenv("hw.syscons.disable")) { + if (!vty_enabled(VTY_SC)) { cp->cn_pri = CN_DEAD; return; } diff --git a/sys/dev/syscons/sysmouse.c b/sys/dev/syscons/sysmouse.c index f2163fc..e668497 100644 --- a/sys/dev/syscons/sysmouse.c +++ b/sys/dev/syscons/sysmouse.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/tty.h> #include <sys/ttydefaults.h> #include <sys/kernel.h> +#include <sys/cons.h> #include <sys/consio.h> #include <sys/mouse.h> @@ -165,7 +166,7 @@ static struct ttydevsw smdev_ttydevsw = { static void sm_attach_mouse(void *unused) { - if (getenv("hw.syscons.disable")) + if (!vty_enabled(VTY_SC)) return; sysmouse_tty = tty_alloc(&smdev_ttydevsw, NULL); tty_makedev(sysmouse_tty, NULL, "sysmouse"); diff --git a/sys/dev/vt/vt_consolectl.c b/sys/dev/vt/vt_consolectl.c index be3ef75..32e3ba6 100644 --- a/sys/dev/vt/vt_consolectl.c +++ b/sys/dev/vt/vt_consolectl.c @@ -73,7 +73,7 @@ static void consolectl_drvinit(void *unused) { - if (getenv("kern.vt.disable")) + if (!vty_enabled(VTY_VT)) return; make_dev(&consolectl_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "consolectl"); diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index e0bde1f4..21d530a 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -215,7 +215,7 @@ static void vt_update_static(void *dummy) { - if (getenv("kern.vt.disable")) + if (!vty_enabled(VTY_VT)) return; if (main_vd->vd_driver != NULL) printf("VT: running with driver \"%s\".\n", @@ -959,7 +959,7 @@ vtterm_cnprobe(struct terminal *tm, struct consdev *cp) struct vt_device *vd = vw->vw_device; struct winsize wsz; - if (getenv("kern.vt.disable")) + if (!vty_enabled(VTY_VT)) return; if (vd->vd_flags & VDF_INITIALIZED) @@ -1996,7 +1996,7 @@ vt_upgrade(struct vt_device *vd) struct vt_window *vw; unsigned int i; - if (getenv("kern.vt.disable")) + if (!vty_enabled(VTY_VT)) return; for (i = 0; i < VT_MAXWINDOWS; i++) { @@ -2064,7 +2064,7 @@ vt_allocate(struct vt_driver *drv, void *softc) struct vt_device *vd; struct winsize wsz; - if (getenv("kern.vt.disable")) + if (!vty_enabled(VTY_VT)) return; if (main_vd->vd_driver == NULL) { diff --git a/sys/dev/vt/vt_sysmouse.c b/sys/dev/vt/vt_sysmouse.c index 9186212..21b2400 100644 --- a/sys/dev/vt/vt_sysmouse.c +++ b/sys/dev/vt/vt_sysmouse.c @@ -405,7 +405,7 @@ static void sysmouse_drvinit(void *unused) { - if (getenv("kern.vt.disable")) + if (!vty_enabled(VTY_VT)) return; mtx_init(&sysmouse_lock, "sysmouse", NULL, MTX_DEF); cv_init(&sysmouse_sleep, "sysmrd"); diff --git a/sys/kern/kern_cons.c b/sys/kern/kern_cons.c index ad2ba20..8d23bef 100644 --- a/sys/kern/kern_cons.c +++ b/sys/kern/kern_cons.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ddb.h" +#include "opt_syscons.h" #include <sys/param.h> #include <sys/systm.h> @@ -648,3 +649,45 @@ sysbeep(int pitch __unused, int period __unused) #endif +/* + * Temporary support for sc(4) to vt(4) transition. + */ +static char vty_name[16] = ""; +SYSCTL_STRING(_kern, OID_AUTO, vty, CTLFLAG_RDTUN, vty_name, 0, + "Console vty driver"); + +int +vty_enabled(unsigned vty) +{ + static unsigned vty_selected = 0; + + if (vty_selected == 0) { + TUNABLE_STR_FETCH("kern.vty", vty_name, sizeof(vty_name)); + do { +#if defined(DEV_SC) + if (strcmp(vty_name, "sc") == 0) { + vty_selected = VTY_SC; + break; + } +#endif +#if defined(DEV_VT) + if (strcmp(vty_name, "vt") == 0) { + vty_selected = VTY_VT; + break; + } +#endif +#if defined(DEV_SC) + vty_selected = VTY_SC; +#elif defined(DEV_VT) + vty_selected = VTY_VT; +#endif + } while (0); + + if (vty_selected == VTY_VT) + strcpy(vty_name, "vt"); + else if (vty_selected == VTY_SC) + strcpy(vty_name, "sc"); + } + return ((vty_selected & vty) != 0); +} + diff --git a/sys/sys/cons.h b/sys/sys/cons.h index 8442bf3..485f8c0 100644 --- a/sys/sys/cons.h +++ b/sys/sys/cons.h @@ -133,6 +133,11 @@ int cnunavailable(void); void constty_set(struct tty *tp); void constty_clear(void); +/* sc(4) / vt(4) coexistence shim */ +#define VTY_SC 0x01 +#define VTY_VT 0x02 +int vty_enabled(unsigned int); + #endif /* _KERNEL */ #endif /* !_MACHINE_CONS_H_ */ |