From owner-svn-src-all@freebsd.org Fri Aug 25 02:37:33 2017 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 832B3DED6B2; Fri, 25 Aug 2017 02:37:33 +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 547936F3AB; Fri, 25 Aug 2017 02:37:33 +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 v7P2bWNq019310; Fri, 25 Aug 2017 02:37:32 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7P2bWHs019309; Fri, 25 Aug 2017 02:37:32 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201708250237.v7P2bWHs019309@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Fri, 25 Aug 2017 02:37:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322869 - head/sys/dev/syscons X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/sys/dev/syscons X-SVN-Commit-Revision: 322869 X-SVN-Commit-Repository: base 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.23 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: Fri, 25 Aug 2017 02:37:33 -0000 Author: bde Date: Fri Aug 25 02:37:32 2017 New Revision: 322869 URL: https://svnweb.freebsd.org/changeset/base/322869 Log: Fix missing switching of the terminal emulator when switching the terminal state for kernel console output. r56043 in 2000 added many complications to support dynamic selection of the terminal emulator using modules and the ioctl CONS_SETTERM. This was never completed. There are still no modules, but it is easy to restore the scterm and dumb emulators at compile time. Then boot-time configuration for the preferred one doesn't work right, but CONS_SETTERM almost works after fixing this bug. CONS_SETTERM only switches the emulator for the user state, leaving the kernel state(s) still using the boot-time emulator. The fix is especially important when switching from sc to scteken, since the scteken state has pointers in it. Rename kernel_console_ts to sc_kts. Modified: head/sys/dev/syscons/syscons.c Modified: head/sys/dev/syscons/syscons.c ============================================================================== --- head/sys/dev/syscons/syscons.c Fri Aug 25 00:28:56 2017 (r322868) +++ head/sys/dev/syscons/syscons.c Fri Aug 25 02:37:32 2017 (r322869) @@ -98,7 +98,8 @@ static int sc_console_unit = -1; static int sc_saver_keyb_only = 1; static scr_stat *sc_console; static struct consdev *sc_consptr; -static void *kernel_console_ts[MAXCPU]; +static void *sc_kts[MAXCPU]; +static struct sc_term_sw *sc_ktsw; static scr_stat main_console; static struct tty *main_devs[MAXCONS]; @@ -564,6 +565,7 @@ sc_attach_unit(int unit, int flags) scinit(unit, flags); if (sc_console->tsw->te_size > 0) { + sc_ktsw = sc_console->tsw; /* assert(sc_console->ts != NULL); */ oldts = sc_console->ts; for (i = 0; i <= mp_maxid; i++) { @@ -573,7 +575,7 @@ sc_attach_unit(int unit, int flags) sc_console->ts = ts; (*sc_console->tsw->te_default_attr)(sc_console, sc_kattrtab[i], SC_KERNEL_CONS_REV_ATTR); - kernel_console_ts[i] = ts; + sc_kts[i] = ts; } sc_console->ts = oldts; (*sc_console->tsw->te_default_attr)(sc_console, SC_NORM_ATTR, @@ -1728,11 +1730,14 @@ sc_cnterm(struct consdev *cp) sccnupdate(sc_console); #endif - for (i = 0; i <= mp_maxid; i++) { - ts = kernel_console_ts[i]; - kernel_console_ts[i] = NULL; - (*sc_console->tsw->te_term)(sc_console, &ts); - free(ts, M_DEVBUF); + if (sc_ktsw != NULL) { + for (i = 0; i <= mp_maxid; i++) { + ts = sc_kts[i]; + sc_kts[i] = NULL; + (*sc_ktsw->te_term)(sc_console, &ts); + free(ts, M_DEVBUF); + } + sc_ktsw = NULL; } scterm(sc_console_unit, SC_KERNEL_CONSOLE); sc_console_unit = -1; @@ -1992,13 +1997,16 @@ sc_cnputc(struct consdev *cd, int c) sizeof(sc_cnputc_log)) continue; /* Console output has a per-CPU "input" state. Switch for it. */ + oldtsw = scp->tsw; oldts = scp->ts; - ts = kernel_console_ts[PCPU_GET(cpuid)]; + ts = sc_kts[PCPU_GET(cpuid)]; if (ts != NULL) { + scp->tsw = sc_ktsw; scp->ts = ts; (*scp->tsw->te_sync)(scp); } sc_puts(scp, buf, 1); + scp->tsw = oldtsw; scp->ts = oldts; (*scp->tsw->te_sync)(scp); }