Index: sys/dev/vt/vt.h =================================================================== --- sys/dev/vt/vt.h (revision 267624) +++ sys/dev/vt/vt.h (working copy) @@ -50,6 +50,8 @@ #include "opt_syscons.h" #include "opt_splash.h" +#include + #ifndef VT_MAXWINDOWS #ifdef MAXCONS #define VT_MAXWINDOWS MAXCONS Index: sys/dev/vt/vt_consolectl.c =================================================================== --- sys/dev/vt/vt_consolectl.c (revision 267626) +++ sys/dev/vt/vt_consolectl.c (working copy) @@ -73,7 +73,7 @@ consolectl_drvinit(void *unused) { - if (getenv("kern.vt.disable")) + if (is_vtsubsys_selected("vt") == 0) return; make_dev(&consolectl_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "consolectl"); Index: sys/dev/vt/vt_core.c =================================================================== --- sys/dev/vt/vt_core.c (revision 267626) +++ sys/dev/vt/vt_core.c (working copy) @@ -149,6 +149,8 @@ SET_DECLARE(vt_drv_set, struct vt_driver); +VTSUBSYS_DECLARE(vt, 50); + #define _VTDEFH MAX(100, PIXEL_HEIGHT(VT_FB_DEFAULT_HEIGHT)) #define _VTDEFW MAX(200, PIXEL_WIDTH(VT_FB_DEFAULT_WIDTH)) @@ -215,7 +217,7 @@ vt_update_static(void *dummy) { - if (getenv("kern.vt.disable")) + if (is_vtsubsys_selected("vt") == 0) return; if (main_vd->vd_driver != NULL) printf("VT: running with driver \"%s\".\n", @@ -959,7 +961,7 @@ struct vt_device *vd = vw->vw_device; struct winsize wsz; - if (getenv("kern.vt.disable")) + if (is_vtsubsys_selected("vt") == 0) return; if (vd->vd_flags & VDF_INITIALIZED) @@ -1996,7 +1998,7 @@ struct vt_window *vw; unsigned int i; - if (getenv("kern.vt.disable")) + if (is_vtsubsys_selected("vt") == 0) return; for (i = 0; i < VT_MAXWINDOWS; i++) { @@ -2064,7 +2066,7 @@ struct vt_device *vd; struct winsize wsz; - if (getenv("kern.vt.disable")) + if (is_vtsubsys_selected("vt") == 0) return; if (main_vd->vd_driver == NULL) { Index: sys/dev/vt/vt_sysmouse.c =================================================================== --- sys/dev/vt/vt_sysmouse.c (revision 267626) +++ sys/dev/vt/vt_sysmouse.c (working copy) @@ -405,7 +405,7 @@ sysmouse_drvinit(void *unused) { - if (getenv("kern.vt.disable")) + if (is_vtsubsys_selected("vt") == 0) return; mtx_init(&sysmouse_lock, "sysmouse", NULL, MTX_DEF); cv_init(&sysmouse_sleep, "sysmrd"); Index: sys/dev/vt/vtsubsys_select.h =================================================================== --- sys/dev/vt/vtsubsys_select.h (revision 0) +++ sys/dev/vt/vtsubsys_select.h (working copy) @@ -0,0 +1,95 @@ +/*- + * Copyright (c) 2014 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Oleksandr Rybalko under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _VTSUBSYS_SELECT_H_ +#define _VTSUBSYS_SELECT_H_ +#include +#include +#include +#include + +struct vtsubsys_data { + char *name; + char *envvar; + int priority; +}; + +SET_DECLARE(vtsubsys_set, struct vtsubsys_data); + +static int +is_vtsubsys_selected(char *name) +{ + struct vtsubsys_data **data, *best, *me; + int best_priority, priority; + + /* If subsys $name is only one, return true. */ + if (SET_COUNT(vtsubsys_set) < 2) + return (1); + + best = me = NULL; + best_priority = 0; + SET_FOREACH(data, vtsubsys_set) { + /* Get priority from kenv or set to default. */ + if (getenv_int((*data)->envvar, &priority) == 0) + priority = (*data)->priority; + /* Skip items marked as ...priority=0 (disabled). */ + if (priority == 0) + continue; + + /* Identify item with same name as passed. */ + if (strcmp((*data)->name, name) == 0) + me = *data; + + /* Check if this module is better. */ + if (best == NULL || priority > best_priority) { + best = *data; + best_priority = priority; + } + } + + /* If best is still NULL, then every VT disabled. */ + + if ((me != NULL) && (me == best)) { + return (1); + } + + return (0); +} + +#define VTSUBSYS_DECLARE(_name, _priority) \ + static struct vtsubsys_data _name ## _vtsubsys_data = { \ + .name = #_name, \ + .envvar = "kern." #_name ".priority", \ + .priority = (_priority), \ + }; \ + DATA_SET(vtsubsys_set, _name ## _vtsubsys_data) + +#endif /* _VTSUBSYS_SELECT_H_ */ Property changes on: sys/dev/vt/vtsubsys_select.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sys/dev/syscons/syscons.c =================================================================== --- sys/dev/syscons/syscons.c (revision 267625) +++ sys/dev/syscons/syscons.c (working copy) @@ -169,6 +169,8 @@ SYSCTL_INT(_machdep, OID_AUTO, enable_panic_key, CTLFLAG_RW, &enable_panic_key, 0, "Enable panic via keypress specified in kbdmap(5)"); +VTSUBSYS_DECLARE(syscons, 100); + #define SC_CONSOLECTL 255 #define VTY_WCHAN(sc, vty) (&SC_DEV(sc, vty)) @@ -267,6 +269,10 @@ int sc_probe_unit(int unit, int flags) { + if (is_vtsubsys_selected("syscons") == 0) { + return ENXIO; + } + if (!scvidprobe(unit, flags, FALSE)) { if (bootverbose) printf("%s%d: no video adapter found.\n", SC_DRIVER_NAME, unit); @@ -494,6 +500,10 @@ flags &= ~SC_KERNEL_CONSOLE; + if (is_vtsubsys_selected("syscons") == 0) { + return ENXIO; + } + if (sc_console_unit == unit) { /* * If this unit is being used as the system console, we need to @@ -576,6 +586,9 @@ static void scmeminit(void *arg) { + if (is_vtsubsys_selected("syscons") == 0) { + return; + } if (sc_malloc) return; sc_malloc = TRUE; @@ -1589,7 +1602,7 @@ int unit; int flags; - if (getenv("hw.syscons.disable")) { + if (is_vtsubsys_selected("syscons") == 0) { cp->cn_pri = CN_DEAD; return; } Index: sys/dev/syscons/syscons.h =================================================================== --- sys/dev/syscons/syscons.h (revision 267541) +++ sys/dev/syscons/syscons.h (working copy) @@ -36,6 +36,7 @@ #include #include +#include /* machine-dependent part of the header */ Index: sys/dev/syscons/sysmouse.c =================================================================== --- sys/dev/syscons/sysmouse.c (revision 267625) +++ sys/dev/syscons/sysmouse.c (working copy) @@ -165,7 +165,7 @@ static void sm_attach_mouse(void *unused) { - if (getenv("hw.syscons.disable")) + if (is_vtsubsys_selected("syscons") == 0) return; sysmouse_tty = tty_alloc(&smdev_ttydevsw, NULL); tty_makedev(sysmouse_tty, NULL, "sysmouse");