svn commit: r304181 - head/sys/dev/syscons

Bruce Evans bde at FreeBSD.org
Mon Aug 15 19:37:20 UTC 2016


Author: bde
Date: Mon Aug 15 19:37:18 2016
New Revision: 304181
URL: https://svnweb.freebsd.org/changeset/base/304181

Log:
  Restructure the grabbing functions into mere wrappers of new open and
  close functions.  Scattered calls to sc_cnputc() and sc_cngetc() were
  broken by turning the semi-reentrant inline context-switching code in
  these functions into the grabbing functions.  cncheckc() calls for
  panic dumps are the main broken case.  The grabbing functions have
  special behaviour (mainly screen switching in sc_cngrab()) which makes
  them unsuitable as replacements for the inline code.

Modified:
  head/sys/dev/syscons/syscons.c

Modified: head/sys/dev/syscons/syscons.c
==============================================================================
--- head/sys/dev/syscons/syscons.c	Mon Aug 15 19:22:23 2016	(r304180)
+++ head/sys/dev/syscons/syscons.c	Mon Aug 15 19:37:18 2016	(r304181)
@@ -1645,8 +1645,12 @@ sc_cnterm(struct consdev *cp)
     sc_console = NULL;
 }
 
+struct sc_cnstate;		/* not used yet */
+static void sccnclose(sc_softc_t *sc, struct sc_cnstate *sp);
+static void sccnopen(sc_softc_t *sc, struct sc_cnstate *sp, int flags);
+
 static void
-sc_cngrab(struct consdev *cp)
+sccnopen(sc_softc_t *sc, struct sc_cnstate *sp, int flags)
 {
     scr_stat *scp;
     int kbd_mode;
@@ -1662,9 +1666,6 @@ sc_cngrab(struct consdev *cp)
     if (scp->sc->kbd == NULL)
 	return;
 
-    if (scp->sc->grab_level++ > 0)
-	return;
-
     /*
      * Make sure the keyboard is accessible even when the kbd device
      * driver is disabled.
@@ -1678,7 +1679,7 @@ sc_cngrab(struct consdev *cp)
 }
 
 static void
-sc_cnungrab(struct consdev *cp)
+sccnclose(sc_softc_t *sc, struct sc_cnstate *sp)
 {
     scr_stat *scp;
 
@@ -1686,9 +1687,6 @@ sc_cnungrab(struct consdev *cp)
     if (scp->sc->kbd == NULL)
 	return;
 
-    if (--scp->sc->grab_level > 0)
-	return;
-
     /* Restore keyboard mode (for the current, possibly-changed scp). */
     kbdd_poll(scp->sc->kbd, FALSE);
     (void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
@@ -1697,6 +1695,26 @@ sc_cnungrab(struct consdev *cp)
 }
 
 static void
+sc_cngrab(struct consdev *cp)
+{
+    sc_softc_t *sc;
+
+    sc = sc_console->sc;
+    if (sc->grab_level++ == 0)
+	sccnopen(sc, NULL, 0);
+}
+
+static void
+sc_cnungrab(struct consdev *cp)
+{
+    sc_softc_t *sc;
+
+    sc = sc_console->sc;
+    if (--sc->grab_level == 0)
+	sccnclose(sc, NULL);
+}
+
+static void
 sc_cnputc(struct consdev *cd, int c)
 {
     u_char buf[1];


More information about the svn-src-head mailing list