Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jun 2014 17:50:33 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r267965 - in head: share/man/man4 sys/dev/syscons sys/dev/vt sys/kern sys/sys
Message-ID:  <201406271750.s5RHoXe7013363@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Fri Jun 27 17:50:33 2014
New Revision: 267965
URL: http://svnweb.freebsd.org/changeset/base/267965

Log:
  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

Modified:
  head/share/man/man4/vt.4
  head/sys/dev/syscons/syscons.c
  head/sys/dev/syscons/sysmouse.c
  head/sys/dev/vt/vt_consolectl.c
  head/sys/dev/vt/vt_core.c
  head/sys/dev/vt/vt_sysmouse.c
  head/sys/kern/kern_cons.c
  head/sys/sys/cons.h

Modified: head/share/man/man4/vt.4
==============================================================================
--- head/share/man/man4/vt.4	Fri Jun 27 17:22:18 2014	(r267964)
+++ head/share/man/man4/vt.4	Fri Jun 27 17:50:33 2014	(r267965)
@@ -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

Modified: head/sys/dev/syscons/syscons.c
==============================================================================
--- head/sys/dev/syscons/syscons.c	Fri Jun 27 17:22:18 2014	(r267964)
+++ head/sys/dev/syscons/syscons.c	Fri Jun 27 17:50:33 2014	(r267965)
@@ -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;
     }

Modified: head/sys/dev/syscons/sysmouse.c
==============================================================================
--- head/sys/dev/syscons/sysmouse.c	Fri Jun 27 17:22:18 2014	(r267964)
+++ head/sys/dev/syscons/sysmouse.c	Fri Jun 27 17:50:33 2014	(r267965)
@@ -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");

Modified: head/sys/dev/vt/vt_consolectl.c
==============================================================================
--- head/sys/dev/vt/vt_consolectl.c	Fri Jun 27 17:22:18 2014	(r267964)
+++ head/sys/dev/vt/vt_consolectl.c	Fri Jun 27 17:50:33 2014	(r267965)
@@ -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");

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Fri Jun 27 17:22:18 2014	(r267964)
+++ head/sys/dev/vt/vt_core.c	Fri Jun 27 17:50:33 2014	(r267965)
@@ -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, stru
 	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 
 	struct vt_device *vd;
 	struct winsize wsz;
 
-	if (getenv("kern.vt.disable"))
+	if (!vty_enabled(VTY_VT))
 		return;
 
 	if (main_vd->vd_driver == NULL) {

Modified: head/sys/dev/vt/vt_sysmouse.c
==============================================================================
--- head/sys/dev/vt/vt_sysmouse.c	Fri Jun 27 17:22:18 2014	(r267964)
+++ head/sys/dev/vt/vt_sysmouse.c	Fri Jun 27 17:50:33 2014	(r267965)
@@ -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");

Modified: head/sys/kern/kern_cons.c
==============================================================================
--- head/sys/kern/kern_cons.c	Fri Jun 27 17:22:18 2014	(r267964)
+++ head/sys/kern/kern_cons.c	Fri Jun 27 17:50:33 2014	(r267965)
@@ -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 _
 
 #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);
+}
+

Modified: head/sys/sys/cons.h
==============================================================================
--- head/sys/sys/cons.h	Fri Jun 27 17:22:18 2014	(r267964)
+++ head/sys/sys/cons.h	Fri Jun 27 17:50:33 2014	(r267965)
@@ -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_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406271750.s5RHoXe7013363>