From owner-svn-src-all@freebsd.org Mon Aug 15 19:37:20 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0B75DBBB21A; Mon, 15 Aug 2016 19:37:20 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA1AF114C; Mon, 15 Aug 2016 19:37:19 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7FJbIln003512; Mon, 15 Aug 2016 19:37:18 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7FJbINn003511; Mon, 15 Aug 2016 19:37:18 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201608151937.u7FJbINn003511@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Mon, 15 Aug 2016 19:37:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r304181 - head/sys/dev/syscons X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Aug 2016 19:37:20 -0000 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];