[Midnightbsd-cvs] src [10064] trunk/sys/dev/syscons: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun May 27 19:04:23 EDT 2018


Revision: 10064
          http://svnweb.midnightbsd.org/src/?rev=10064
Author:   laffer1
Date:     2018-05-27 19:04:23 -0400 (Sun, 27 May 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/sys/dev/syscons/schistory.c
    trunk/sys/dev/syscons/scmouse.c
    trunk/sys/dev/syscons/scterm-teken.c
    trunk/sys/dev/syscons/scterm.c
    trunk/sys/dev/syscons/scvesactl.c
    trunk/sys/dev/syscons/scvgarndr.c
    trunk/sys/dev/syscons/scvidctl.c
    trunk/sys/dev/syscons/scvtb.c
    trunk/sys/dev/syscons/syscons.c
    trunk/sys/dev/syscons/syscons.h
    trunk/sys/dev/syscons/sysmouse.c

Added Paths:
-----------
    trunk/sys/dev/syscons/plasma/
    trunk/sys/dev/syscons/plasma/fp16.c
    trunk/sys/dev/syscons/plasma/fp16.h
    trunk/sys/dev/syscons/plasma/plasma_saver.c

Added: trunk/sys/dev/syscons/plasma/fp16.c
===================================================================
--- trunk/sys/dev/syscons/plasma/fp16.c	                        (rev 0)
+++ trunk/sys/dev/syscons/plasma/fp16.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -0,0 +1,156 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2015 Dag-Erling Smørgrav
+ * All rights reserved.
+ *
+ * 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: stable/10/sys/dev/syscons/plasma/fp16.c 294783 2016-01-26 08:55:31Z des $
+ */
+
+#ifdef _KERNEL
+#include <sys/libkern.h>
+#else
+#include <stdio.h>
+#include <strings.h>
+#endif
+
+#include "fp16.h"
+
+/*
+ * Compute the quare root of x, using Newton's method with 2^(log2(x)/2)
+ * as the initial estimate.
+ */
+fp16_t
+fp16_sqrt(fp16_t x)
+{
+	fp16_t y, delta;
+	signed int log2x;
+
+	/* special case */
+	if (x == 0)
+		return (0);
+
+	/* shift toward 0 by half the logarithm */
+	log2x = flsl(x) - 1;
+	if (log2x >= 16) {
+		y = x >> (log2x - 16) / 2;
+	} else {
+#if 0
+		y = x << (16 - log2x) / 2;
+#else
+		/* XXX for now, return 0 for anything < 1 */
+		return (0);
+#endif
+	}
+	while (y > 0) {
+		/* delta = y^2 / 2y */
+		delta = fp16_div(fp16_sub(fp16_mul(y, y), x), y * 2);
+		if (delta == 0)
+			break;
+		y = fp16_sub(y, delta);
+	}
+	return (y);
+}
+
+static fp16_t fp16_sin_table[256] = {
+	    0,	  402,	  804,	 1206,	 1608,	 2010,	 2412,	 2814,
+	 3215,	 3617,	 4018,	 4420,	 4821,	 5222,	 5622,	 6023,
+	 6423,	 6823,	 7223,	 7623,	 8022,	 8421,	 8819,	 9218,
+	 9616,	10013,	10410,	10807,	11204,	11600,	11995,	12390,
+	12785,	13179,	13573,	13966,	14359,	14751,	15142,	15533,
+	15923,	16313,	16702,	17091,	17479,	17866,	18253,	18638,
+	19024,	19408,	19792,	20175,	20557,	20938,	21319,	21699,
+	22078,	22456,	22833,	23210,	23586,	23960,	24334,	24707,
+	25079,	25450,	25820,	26189,	26557,	26925,	27291,	27656,
+	28020,	28383,	28745,	29105,	29465,	29824,	30181,	30538,
+	30893,	31247,	31600,	31952,	32302,	32651,	32999,	33346,
+	33692,	34036,	34379,	34721,	35061,	35400,	35738,	36074,
+	36409,	36743,	37075,	37406,	37736,	38064,	38390,	38716,
+	39039,	39362,	39682,	40002,	40319,	40636,	40950,	41263,
+	41575,	41885,	42194,	42501,	42806,	43110,	43412,	43712,
+	44011,	44308,	44603,	44897,	45189,	45480,	45768,	46055,
+	46340,	46624,	46906,	47186,	47464,	47740,	48015,	48288,
+	48558,	48828,	49095,	49360,	49624,	49886,	50146,	50403,
+	50660,	50914,	51166,	51416,	51665,	51911,	52155,	52398,
+	52639,	52877,	53114,	53348,	53581,	53811,	54040,	54266,
+	54491,	54713,	54933,	55152,	55368,	55582,	55794,	56004,
+	56212,	56417,	56621,	56822,	57022,	57219,	57414,	57606,
+	57797,	57986,	58172,	58356,	58538,	58718,	58895,	59070,
+	59243,	59414,	59583,	59749,	59913,	60075,	60235,	60392,
+	60547,	60700,	60850,	60998,	61144,	61288,	61429,	61568,
+	61705,	61839,	61971,	62100,	62228,	62353,	62475,	62596,
+	62714,	62829,	62942,	63053,	63162,	63268,	63371,	63473,
+	63571,	63668,	63762,	63854,	63943,	64030,	64115,	64197,
+	64276,	64353,	64428,	64501,	64571,	64638,	64703,	64766,
+	64826,	64884,	64939,	64992,	65043,	65091,	65136,	65179,
+	65220,	65258,	65294,	65327,	65358,	65386,	65412,	65436,
+	65457,	65475,	65491,	65505,	65516,	65524,	65531,	65534,
+};
+
+/*
+ * Compute the sine of theta.
+ */
+fp16_t
+fp16_sin(fp16_t theta)
+{
+	unsigned int i;
+
+	i = 1024 * (theta % FP16_2PI) / FP16_2PI;
+	switch (i / 256) {
+	case 0:
+		return (fp16_sin_table[i % 256]);
+	case 1:
+		return (fp16_sin_table[255 - i % 256]);
+	case 2:
+		return (-fp16_sin_table[i % 256]);
+	case 3:
+		return (-fp16_sin_table[255 - i % 256]);
+	default:
+		/* inconceivable! */
+		return (0);
+	}
+}
+
+/*
+ * Compute the cosine of theta.
+ */
+fp16_t
+fp16_cos(fp16_t theta)
+{
+	unsigned int i;
+
+	i = 1024 * (theta % FP16_2PI) / FP16_2PI;
+	switch (i / 256) {
+	case 0:
+		return (fp16_sin_table[255 - i % 256]);
+	case 1:
+		return (-fp16_sin_table[i % 256]);
+	case 2:
+		return (-fp16_sin_table[255 - i % 256]);
+	case 3:
+		return (fp16_sin_table[i % 256]);
+	default:
+		/* inconceivable! */
+		return (0);
+	}
+}


Property changes on: trunk/sys/dev/syscons/plasma/fp16.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/syscons/plasma/fp16.h
===================================================================
--- trunk/sys/dev/syscons/plasma/fp16.h	                        (rev 0)
+++ trunk/sys/dev/syscons/plasma/fp16.h	2018-05-27 23:04:23 UTC (rev 10064)
@@ -0,0 +1,86 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2015 Dag-Erling Smørgrav
+ * All rights reserved.
+ *
+ * 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: stable/10/sys/dev/syscons/plasma/fp16.h 294783 2016-01-26 08:55:31Z des $
+ */
+
+#ifndef FP16_H_INCLUDED
+#define FP16_H_INCLUDED
+
+typedef signed long long fp16_t;
+
+#define ItoFP16(n)	((signed long long)(n) << 16)
+#define FP16toI(n)	((signed long long)(n) >> 16)
+
+#ifndef _KERNEL
+#define FP16toF(n)	((n) / 65536.0)
+#endif
+
+/* add a and b */
+static inline fp16_t
+fp16_add(fp16_t a, fp16_t b)
+{
+
+	return (a + b);
+}
+
+/* subtract b from a */
+static inline fp16_t
+fp16_sub(fp16_t a, fp16_t b)
+{
+
+	return (a - b);
+}
+
+/* multiply a by b */
+static inline fp16_t
+fp16_mul(fp16_t a, fp16_t b)
+{
+
+	return (a * b >> 16);
+}
+
+/* divide a by b */
+static inline fp16_t
+fp16_div(fp16_t a, fp16_t b)
+{
+
+	return ((a << 16) / b);
+}
+
+/* square root */
+fp16_t fp16_sqrt(fp16_t);
+
+#define FP16_2PI	 411774
+#define FP16_PI		 205887
+#define FP16_PI_2	 102943
+#define FP16_PI_4	  51471
+
+/* sine and cosine */
+fp16_t fp16_sin(fp16_t);
+fp16_t fp16_cos(fp16_t);
+
+#endif


Property changes on: trunk/sys/dev/syscons/plasma/fp16.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/syscons/plasma/plasma_saver.c
===================================================================
--- trunk/sys/dev/syscons/plasma/plasma_saver.c	                        (rev 0)
+++ trunk/sys/dev/syscons/plasma/plasma_saver.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -0,0 +1,240 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2015 Dag-Erling Smørgrav
+ * All rights reserved.
+ *
+ * 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: stable/10/sys/dev/syscons/plasma/plasma_saver.c 294783 2016-01-26 08:55:31Z des $
+ *
+ * To CJA, in appreciation of Nighthawk brunches past and future.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/syslog.h>
+#include <sys/consio.h>
+#include <sys/fbio.h>
+
+#include <dev/fb/fbreg.h>
+#include <dev/fb/splashreg.h>
+#include <dev/syscons/syscons.h>
+
+#define SAVER_NAME	 "plasma_saver"
+
+#include "fp16.h"
+
+/*
+ * Preferred video modes
+ */
+static int modes[] = {
+	M_VGA_CG640,
+	M_PC98_PEGC640x480,
+	M_PC98_PEGC640x400,
+	M_VGA_CG320,
+	-1
+};
+
+/*
+ * Display parameters
+ */
+static unsigned char *vid;
+static unsigned int banksize, scrmode, scrw, scrh;
+static unsigned int blanked;
+
+/*
+ * List of foci
+ */
+#define FOCI 3
+static struct {
+	int x, y;		/* coordinates */
+	int vx, vy;		/* velocity */
+} plasma_foci[FOCI];
+
+/*
+ * Palette
+ */
+static struct {
+	unsigned char r, g, b;
+} plasma_pal[256];
+
+/*
+ * Draw a new frame
+ */
+static void
+plasma_update(video_adapter_t *adp)
+{
+	unsigned int x, y;	/* coordinates */
+	signed int dx, dy;	/* horizontal / vertical distance */
+	fp16_t sqd, d;		/* square of distance and distance */
+	fp16_t m;		/* magnitude */
+	unsigned int org, off;	/* origin and offset */
+	unsigned int i;		/* loop index */
+
+	/* switch to bank 0 */
+	vidd_set_win_org(adp, 0);
+	/* for each scan line */
+	for (y = org = off = 0; y < scrh; ++y) {
+		/* for each pixel on scan line */
+		for (x = 0; x < scrw; ++x, ++off) {
+			/* for each focus */
+			for (i = m = 0; i < FOCI; ++i) {
+				dx = x - plasma_foci[i].x;
+				dy = y - plasma_foci[i].y;
+				sqd = ItoFP16(dx * dx + dy * dy);
+				d = fp16_sqrt(sqd);
+				/* divide by 4 to stretch out the pattern */
+				m = fp16_sub(m, fp16_cos(d / 4));
+			}
+			/*
+			 * m is now in the range +/- FOCI, but we need a
+			 * value between 0 and 255.  We scale to +/- 127
+			 * and add 127, which moves it into the range [0,
+			 * 254].
+			 */
+			m = fp16_mul(m, ItoFP16(127));
+			m = fp16_div(m, ItoFP16(FOCI));
+			m = fp16_add(m, ItoFP16(127));
+			/* switch banks if necessary */
+			if (off > banksize) {
+				off -= banksize;
+				org += banksize;
+				vidd_set_win_org(adp, org);
+			}
+			/* plot */
+			vid[off] = FP16toI(m);
+		}
+	}
+	/* now move the foci */
+	for (i = 0; i < FOCI; ++i) {
+		plasma_foci[i].x += plasma_foci[i].vx;
+		if (plasma_foci[i].x < 0) {
+			/* bounce against left wall */
+			plasma_foci[i].vx = -plasma_foci[i].vx;
+			plasma_foci[i].x = -plasma_foci[i].x;
+		} else if (plasma_foci[i].x >= scrw) {
+			/* bounce against right wall */
+			plasma_foci[i].vx = -plasma_foci[i].vx;
+			plasma_foci[i].x = scrw - (plasma_foci[i].x - scrw);
+		}
+		plasma_foci[i].y += plasma_foci[i].vy;
+		if (plasma_foci[i].y < 0) {
+			/* bounce against ceiling */
+			plasma_foci[i].vy = -plasma_foci[i].vy;
+			plasma_foci[i].y = -plasma_foci[i].y;
+		} else if (plasma_foci[i].y >= scrh) {
+			/* bounce against floor */
+			plasma_foci[i].vy = -plasma_foci[i].vy;
+			plasma_foci[i].y = scrh - (plasma_foci[i].y - scrh);
+		}
+	}
+}
+
+/*
+ * Start or stop the screensaver
+ */
+static int
+plasma_saver(video_adapter_t *adp, int blank)
+{
+	int pl;
+
+	if (blank) {
+		/* switch to graphics mode */
+		if (blanked <= 0) {
+			pl = splhigh();
+			vidd_set_mode(adp, scrmode);
+			vidd_load_palette(adp, (unsigned char *)plasma_pal);
+			vidd_set_border(adp, 0);
+			blanked++;
+			vid = (unsigned char *)adp->va_window;
+			banksize = adp->va_window_size;
+			splx(pl);
+			vidd_clear(adp);
+		}
+		/* update display */
+		plasma_update(adp);
+	} else {
+		blanked = 0;
+	}
+	return (0);
+}
+
+/*
+ * Initialize on module load
+ */
+static int
+plasma_init(video_adapter_t *adp)
+{
+	video_info_t info;
+	int i;
+
+	/* select video mode */
+	for (i = 0; modes[i] >= 0; ++i)
+		if (vidd_get_info(adp, modes[i], &info) == 0)
+			break;
+	if (modes[i] < 0) {
+		log(LOG_NOTICE, "%s: no supported video modes\n", SAVER_NAME);
+		return (ENODEV);
+	}
+	scrmode = modes[i];
+	scrw = info.vi_width;
+	scrh = info.vi_height;
+
+	/* initialize the palette */
+	for (i = 0; i < 256; ++i)
+		plasma_pal[i].r = plasma_pal[i].g = plasma_pal[i].b = i;
+
+	/* randomize the foci */
+	for (i = 0; i < FOCI; i++) {
+		plasma_foci[i].x = random() % scrw;
+		plasma_foci[i].y = random() % scrh;
+		plasma_foci[i].vx = random() % 5 - 2;
+		plasma_foci[i].vy = random() % 5 - 2;
+	}
+
+	return (0);
+}
+
+/*
+ * Clean up before module unload
+ */
+static int
+plasma_term(video_adapter_t *adp)
+{
+
+	return (0);
+}
+
+/*
+ * Boilerplate
+ */
+static scrn_saver_t plasma_module = {
+	SAVER_NAME,
+	plasma_init,
+	plasma_term,
+	plasma_saver,
+	NULL
+};
+
+SAVER_MODULE(plasma_saver, plasma_module);


Property changes on: trunk/sys/dev/syscons/plasma/plasma_saver.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/dev/syscons/schistory.c
===================================================================
--- trunk/sys/dev/syscons/schistory.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/schistory.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,7 +1,7 @@
-/* $MidnightBSD: src/sys/dev/syscons/schistory.c,v 1.2 2008/12/02 22:43:11 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
- * Copyright (c) 1992-1998 S\xF8ren Schmidt
+ * Copyright (c) 1992-1998 Søren Schmidt
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/schistory.c 239696 2012-08-25 23:59:31Z gonzo $");
 
 #include "opt_syscons.h"
 
@@ -43,7 +43,8 @@
 #include <sys/kernel.h>
 #include <sys/malloc.h>
 
-#if defined(__sparc64__) || defined(__powerpc__)
+#if defined(__arm__) || defined(__mips__) || \
+	defined(__powerpc__) || defined(__sparc64__)
 #include <machine/sc_machdep.h>
 #else
 #include <machine/pc/display.h>

Modified: trunk/sys/dev/syscons/scmouse.c
===================================================================
--- trunk/sys/dev/syscons/scmouse.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/scmouse.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/syscons/scmouse.c,v 1.4 2008/12/02 22:43:11 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/scmouse.c 256381 2013-10-12 15:31:36Z markm $");
 
 #include "opt_syscons.h"
 
@@ -667,7 +667,7 @@
 
 	mouse = (mouse_info_t*)data;
 
-	random_harvest(mouse, sizeof(mouse_info_t), 2, 0, RANDOM_MOUSE);
+	random_harvest(mouse, sizeof(mouse_info_t), 2, RANDOM_MOUSE);
 
 	if (cmd == OLD_CONS_MOUSECTL) {
 	    static u_char swapb[] = { 0, 4, 2, 6, 1, 5, 3, 7 };

Modified: trunk/sys/dev/syscons/scterm-teken.c
===================================================================
--- trunk/sys/dev/syscons/scterm-teken.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/scterm-teken.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -28,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/scterm-teken.c 262861 2014-03-06 18:30:56Z jhb $");
 
 #include "opt_syscons.h"
 #include "opt_teken.h"
@@ -40,7 +41,8 @@
 #include <sys/consio.h>
 #include <sys/kbio.h>
 
-#if defined(__sparc64__) || defined(__powerpc__)
+#if defined(__arm__) || defined(__mips__) || \
+	defined(__powerpc__) || defined(__sparc64__)
 #include <machine/sc_machdep.h>
 #else
 #include <machine/pc/display.h>
@@ -424,10 +426,18 @@
 	{ 0x00b6, 0x14, 0x00 }, { 0x00b7, 0xfa, 0x00 },
 	{ 0x00ba, 0xa7, 0x00 }, { 0x00bb, 0xaf, 0x00 },
 	{ 0x00bc, 0xac, 0x00 }, { 0x00bd, 0xab, 0x00 },
-	{ 0x00bf, 0xa8, 0x00 }, { 0x00c4, 0x8e, 0x01 },
-	{ 0x00c6, 0x92, 0x00 }, { 0x00c7, 0x80, 0x00 },
-	{ 0x00c9, 0x90, 0x00 }, { 0x00d1, 0xa5, 0x00 },
-	{ 0x00d6, 0x99, 0x00 }, { 0x00dc, 0x9a, 0x00 },
+	{ 0x00bf, 0xa8, 0x00 }, { 0x00c0, 0x41, 0x00 },
+	{ 0x00c1, 0x41, 0x00 }, { 0x00c2, 0x41, 0x00 },
+	{ 0x00c4, 0x8e, 0x01 }, { 0x00c6, 0x92, 0x00 }, 
+	{ 0x00c7, 0x80, 0x00 }, { 0x00c8, 0x45, 0x00 },
+	{ 0x00c9, 0x90, 0x00 }, { 0x00ca, 0x45, 0x00 },
+	{ 0x00cb, 0x45, 0x00 }, { 0x00cc, 0x49, 0x00 },
+	{ 0x00cd, 0x49, 0x00 }, { 0x00ce, 0x49, 0x00 },
+	{ 0x00cf, 0x49, 0x00 }, { 0x00d1, 0xa5, 0x00 },
+	{ 0x00d2, 0x4f, 0x00 }, { 0x00d3, 0x4f, 0x00 },
+	{ 0x00d4, 0x4f, 0x00 }, { 0x00d6, 0x99, 0x00 }, 
+	{ 0x00d9, 0x55, 0x00 }, { 0x00da, 0x55, 0x00 },
+	{ 0x00db, 0x55, 0x00 }, { 0x00dc, 0x9a, 0x00 },
 	{ 0x00df, 0xe1, 0x00 }, { 0x00e0, 0x85, 0x00 },
 	{ 0x00e1, 0xa0, 0x00 }, { 0x00e2, 0x83, 0x00 },
 	{ 0x00e4, 0x84, 0x00 }, { 0x00e5, 0x86, 0x00 },
@@ -442,6 +452,7 @@
 	{ 0x00f8, 0xed, 0x00 }, { 0x00f9, 0x97, 0x00 },
 	{ 0x00fa, 0xa3, 0x00 }, { 0x00fb, 0x96, 0x00 },
 	{ 0x00fc, 0x81, 0x00 }, { 0x00ff, 0x98, 0x00 },
+	{ 0x013f, 0x4c, 0x00 }, { 0x0140, 0x6c, 0x00 },
 	{ 0x0192, 0x9f, 0x00 }, { 0x0393, 0xe2, 0x00 },
 	{ 0x0398, 0xe9, 0x00 }, { 0x03a3, 0xe4, 0x00 },
 	{ 0x03a6, 0xe8, 0x00 }, { 0x03a9, 0xea, 0x00 },
@@ -490,7 +501,8 @@
 	{ 0x2584, 0xdc, 0x00 }, { 0x2588, 0xdb, 0x00 },
 	{ 0x258c, 0xdd, 0x00 }, { 0x2590, 0xde, 0x00 },
 	{ 0x2591, 0xb0, 0x02 }, { 0x25a0, 0xfe, 0x00 },
-	{ 0x25ac, 0x16, 0x00 }, { 0x25b2, 0x1e, 0x00 },
+	{ 0x25ac, 0x16, 0x00 }, 
+	{ 0x25ae, 0xdb, 0x00 }, { 0x25b2, 0x1e, 0x00 },
 	{ 0x25ba, 0x10, 0x00 }, { 0x25bc, 0x1f, 0x00 },
 	{ 0x25c4, 0x11, 0x00 }, { 0x25cb, 0x09, 0x00 },
 	{ 0x25d8, 0x08, 0x00 }, { 0x25d9, 0x0a, 0x00 },
@@ -542,7 +554,14 @@
 	vm_offset_t p;
 	int cursor, attr;
 
+	/*
+	 * No support for printing right hand sides for CJK fullwidth
+	 * characters. Simply print a space and assume that the left
+	 * hand side describes the entire character.
+	 */
 	attr = scteken_attr(a) << 8;
+	if (a->ta_format & TF_CJK_RIGHT)
+		c = ' ';
 #ifdef TEKEN_UTF8
 	scteken_get_cp437(&c, &attr);
 #endif /* TEKEN_UTF8 */

Modified: trunk/sys/dev/syscons/scterm.c
===================================================================
--- trunk/sys/dev/syscons/scterm.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/scterm.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/syscons/scterm.c,v 1.2 2008/12/02 22:43:11 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/scterm.c 186681 2009-01-01 13:26:53Z ed $");
 
 #include "opt_syscons.h"
 

Modified: trunk/sys/dev/syscons/scvesactl.c
===================================================================
--- trunk/sys/dev/syscons/scvesactl.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/scvesactl.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/syscons/scvesactl.c,v 1.2 2008/12/02 22:43:11 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/scvesactl.c 197025 2009-09-09 09:50:31Z delphij $");
 
 #include "opt_vga.h"
 

Modified: trunk/sys/dev/syscons/scvgarndr.c
===================================================================
--- trunk/sys/dev/syscons/scvgarndr.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/scvgarndr.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/syscons/scvgarndr.c,v 1.2 2008/12/02 22:43:11 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/scvgarndr.c 251961 2013-06-18 20:19:09Z kib $");
 
 #include "opt_syscons.h"
 #include "opt_vga.h"
@@ -396,6 +396,8 @@
 {
 }
 
+int sc_txtmouse_no_retrace_wait;
+
 #ifndef SC_NO_CUTPASTE
 
 static void
@@ -446,7 +448,9 @@
 #if 1
 	/* wait for vertical retrace to avoid jitter on some videocards */
 	crtc_addr = scp->sc->adp->va_crtc_addr;
-	while (!(inb(crtc_addr + 6) & 0x08)) /* idle */ ;
+	while (!sc_txtmouse_no_retrace_wait &&
+	    !(inb(crtc_addr + 6) & 0x08))
+		/* idle */ ;
 #endif
 	c = scp->sc->mouse_char;
 	vidd_load_font(scp->sc->adp, 0, 32, 8, font_buf, c, 4); 

Modified: trunk/sys/dev/syscons/scvidctl.c
===================================================================
--- trunk/sys/dev/syscons/scvidctl.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/scvidctl.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/syscons/scvidctl.c,v 1.2 2008/12/02 22:43:11 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/scvidctl.c 242529 2012-11-03 22:21:37Z ed $");
 
 #include "opt_compat.h"
 #include "opt_syscons.h"
@@ -138,6 +138,7 @@
 		 int fontsize, int fontwidth)
 {
     video_info_t info;
+    struct winsize wsz;
     u_char *font;
     int prev_ysize;
     int error;
@@ -235,16 +236,9 @@
 
     if (tp == NULL)
 	return 0;
-    DPRINTF(5, ("ws_*size (%d,%d), size (%d,%d)\n",
-	tp->t_winsize.ws_col, tp->t_winsize.ws_row, scp->xsize, scp->ysize));
-    if (tp->t_winsize.ws_col != scp->xsize
-	|| tp->t_winsize.ws_row != scp->ysize) {
-	tp->t_winsize.ws_col = scp->xsize;
-	tp->t_winsize.ws_row = scp->ysize;
-
-	tty_signal_pgrp(tp, SIGWINCH);
-    }
-
+    wsz.ws_col = scp->xsize;
+    wsz.ws_row = scp->ysize;
+    tty_set_winsize(tp, &wsz);
     return 0;
 }
 
@@ -255,6 +249,7 @@
     return ENODEV;
 #else
     video_info_t info;
+    struct winsize wsz;
     int error;
     int s;
 
@@ -301,14 +296,9 @@
 
     if (tp == NULL)
 	return 0;
-    if (tp->t_winsize.ws_xpixel != scp->xpixel
-	|| tp->t_winsize.ws_ypixel != scp->ypixel) {
-	tp->t_winsize.ws_xpixel = scp->xpixel;
-	tp->t_winsize.ws_ypixel = scp->ypixel;
-
-	tty_signal_pgrp(tp, SIGWINCH);
-    }
-
+    wsz.ws_col = scp->xsize;
+    wsz.ws_row = scp->ysize;
+    tty_set_winsize(tp, &wsz);
     return 0;
 #endif /* SC_NO_MODE_CHANGE */
 }
@@ -321,7 +311,7 @@
     return ENODEV;
 #else
     video_info_t info;
-    ksiginfo_t ksi;
+    struct winsize wsz;
     u_char *font;
     int prev_ysize;
     int error;
@@ -426,20 +416,9 @@
 
     if (tp == NULL)
 	return 0;
-    if (tp->t_winsize.ws_col != scp->xsize
-	|| tp->t_winsize.ws_row != scp->ysize) {
-	tp->t_winsize.ws_col = scp->xsize;
-	tp->t_winsize.ws_row = scp->ysize;
-	if (tp->t_pgrp != NULL) {
-	    ksiginfo_init(&ksi);
-	    ksi.ksi_signo = SIGWINCH;
-	    ksi.ksi_code = SI_KERNEL;
-	    PGRP_LOCK(tp->t_pgrp);
-	    pgsignal(tp->t_pgrp, SIGWINCH, 1, &ksi);
-	    PGRP_UNLOCK(tp->t_pgrp);
-	}
-    }
-
+    wsz.ws_col = scp->xsize;
+    wsz.ws_row = scp->ysize;
+    tty_set_winsize(tp, &wsz);
     return 0;
 #endif /* SC_PIXEL_MODE */
 }

Modified: trunk/sys/dev/syscons/scvtb.c
===================================================================
--- trunk/sys/dev/syscons/scvtb.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/scvtb.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/syscons/scvtb.c,v 1.2 2008/12/02 22:43:11 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/scvtb.c 146476 2005-05-21 20:28:15Z marius $");
 
 #include "opt_syscons.h"
 

Modified: trunk/sys/dev/syscons/syscons.c
===================================================================
--- trunk/sys/dev/syscons/syscons.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/syscons.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,6 +1,6 @@
 /* $MidnightBSD$ */
 /*-
- * Copyright (c) 1992-1998 S\xF8ren Schmidt
+ * Copyright (c) 1992-1998 Søren Schmidt
  * All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/syscons.c 282750 2015-05-11 08:16:33Z avg $");
 
 #include "opt_compat.h"
 #include "opt_syscons.h"
@@ -63,7 +63,8 @@
 #include <sys/power.h>
 
 #include <machine/clock.h>
-#if defined(__sparc64__) || defined(__powerpc__)
+#if defined(__arm__) || defined(__mips__) || \
+	defined(__powerpc__) || defined(__sparc64__)
 #include <machine/sc_machdep.h>
 #else
 #include <machine/pc/display.h>
@@ -87,6 +88,9 @@
 
 #define KEYCODE_BS		0x0e		/* "<-- Backspace" key, XXX */
 
+/* NULL-safe version of "tty_opened()" */
+#define	tty_opened_ns(tp)	((tp) != NULL && tty_opened(tp))
+
 typedef struct default_attr {
 	int		std_color;		/* normal hardware color */
 	int		rev_color;		/* reverse hardware color */
@@ -219,6 +223,7 @@
 static void exchange_scr(sc_softc_t *sc);
 static void update_cursor_image(scr_stat *scp);
 static void change_cursor_shape(scr_stat *scp, int flags, int base, int height);
+static void update_font(scr_stat *);
 static int save_kbd_state(scr_stat *scp);
 static int update_kbd_state(scr_stat *scp, int state, int mask);
 static int update_kbd_leds(scr_stat *scp, int which);
@@ -263,6 +268,8 @@
 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);
@@ -488,6 +495,9 @@
     struct cdev *dev;
     int vc;
 
+    if (!vty_enabled(VTY_SC))
+        return ENXIO;
+
     flags &= ~SC_KERNEL_CONSOLE;
 
     if (sc_console_unit == unit) {
@@ -503,6 +513,8 @@
 
     sc = sc_get_softc(unit, flags & SC_KERNEL_CONSOLE);
     sc->config = flags;
+    callout_init(&sc->ctimeout, 0);
+    callout_init(&sc->cblink, 0);
     scp = sc_get_stat(sc->dev[0]);
     if (sc_console == NULL)	/* sc_console_unit < 0 */
 	sc_console = scp;
@@ -539,7 +551,7 @@
 
     /* Register suspend/resume/shutdown callbacks for the kernel console. */
     if (sc_console_unit == unit) {
-	EVENTHANDLER_REGISTER(power_suspend, scsuspend, NULL,
+	EVENTHANDLER_REGISTER(power_suspend_early, scsuspend, NULL,
 			      EVENTHANDLER_PRI_ANY);
 	EVENTHANDLER_REGISTER(power_resume, scresume, NULL,
 			      EVENTHANDLER_PRI_ANY);
@@ -570,6 +582,8 @@
 static void
 scmeminit(void *arg)
 {
+    if (!vty_enabled(VTY_SC))
+        return;
     if (sc_malloc)
 	return;
     sc_malloc = TRUE;
@@ -743,7 +757,7 @@
     while ((c = scgetc(sc, SCGETC_NONBLOCK)) != NOKEY) {
 
 	cur_tty = SC_DEV(sc, sc->cur_scp->index);
-	if (!tty_opened(cur_tty))
+	if (!tty_opened_ns(cur_tty))
 	    continue;
 
 	if ((*sc->cur_scp->tsw->te_input)(sc->cur_scp, c, cur_tty))
@@ -1137,7 +1151,7 @@
     case VT_OPENQRY:    	/* return free virtual console */
 	for (i = sc->first_vty; i < sc->first_vty + sc->vtys; i++) {
 	    tp = SC_DEV(sc, i);
-	    if (!tty_opened(tp)) {
+	    if (!tty_opened_ns(tp)) {
 		*(int *)data = i + 1;
 		return 0;
 	    }
@@ -1583,6 +1597,11 @@
     int unit;
     int flags;
 
+    if (!vty_enabled(VTY_SC)) {
+	cp->cn_pri = CN_DEAD;
+	return;
+    }
+
     cp->cn_pri = sc_get_cons_priority(&unit, &flags);
 
     /* a video card is always required */
@@ -1714,6 +1733,7 @@
 	 * spinlock.
 	 */
 	tp = SC_DEV(scp->sc, scp->index);
+	/* XXX "tp" can be NULL */
 	tty_lock(tp);
 	if (tty_opened(tp))
 	    sctty_outwakeup(tp);
@@ -1827,13 +1847,11 @@
 scrn_timer(void *arg)
 {
 #ifndef PC98
-    static int kbd_interval = 0;
+    static time_t kbd_time_stamp = 0;
 #endif
-    struct timeval tv;
     sc_softc_t *sc;
     scr_stat *scp;
-    int again;
-    int s;
+    int again, rate;
 
     again = (arg != NULL);
     if (arg != NULL)
@@ -1843,18 +1861,18 @@
     else
 	return;
 
+    /* find the vty to update */
+    scp = sc->cur_scp;
+
     /* don't do anything when we are performing some I/O operations */
-    if (suspend_in_progress || sc->font_loading_in_progress) {
-	if (again)
-	    timeout(scrn_timer, sc, hz / 10);
-	return;
-    }
-    s = spltty();
+    if (suspend_in_progress || sc->font_loading_in_progress)
+	goto done;
 
 #ifndef PC98
     if ((sc->kbd == NULL) && (sc->config & SC_AUTODETECT_KBD)) {
 	/* try to allocate a keyboard automatically */
-	if (++kbd_interval >= 25) {
+	if (kbd_time_stamp != time_uptime) {
+	    kbd_time_stamp = time_uptime;
 	    sc->keyboard = sc_allocate_keyboard(sc, -1);
 	    if (sc->keyboard >= 0) {
 		sc->kbd = kbd_get_keyboard(sc->keyboard);
@@ -1863,25 +1881,20 @@
 		update_kbd_state(sc->cur_scp, sc->cur_scp->status,
 				 LOCK_MASK);
 	    }
-	    kbd_interval = 0;
 	}
     }
 #endif /* PC98 */
 
-    /* find the vty to update */
-    scp = sc->cur_scp;
-
     /* should we stop the screen saver? */
-    getmicrouptime(&tv);
     if (debugger > 0 || panicstr || shutdown_in_progress)
 	sc_touch_scrn_saver();
     if (run_scrn_saver) {
-	if (tv.tv_sec > sc->scrn_time_stamp + scrn_blank_time)
+	if (time_uptime > sc->scrn_time_stamp + scrn_blank_time)
 	    sc->flags |= SC_SCRN_IDLE;
 	else
 	    sc->flags &= ~SC_SCRN_IDLE;
     } else {
-	sc->scrn_time_stamp = tv.tv_sec;
+	sc->scrn_time_stamp = time_uptime;
 	sc->flags &= ~SC_SCRN_IDLE;
 	if (scrn_blank_time > 0)
 	    run_scrn_saver = TRUE;
@@ -1894,12 +1907,8 @@
 
     /* should we just return ? */
     if (sc->blink_in_progress || sc->switch_in_progress
-	|| sc->write_in_progress) {
-	if (again)
-	    timeout(scrn_timer, sc, hz / 10);
-	splx(s);
-	return;
-    }
+	|| sc->write_in_progress)
+	goto done;
 
     /* Update the screen */
     scp = sc->cur_scp;		/* cur_scp may have changed... */
@@ -1913,9 +1922,19 @@
 	    (*current_saver)(sc, TRUE);
 #endif
 
-    if (again)
-	timeout(scrn_timer, sc, hz / 25);
-    splx(s);
+done:
+    if (again) {
+	/*
+	 * Use reduced "refresh" rate if we are in graphics and that is not a
+	 * graphical screen saver.  In such case we just have nothing to do.
+	 */
+	if (ISGRAPHSC(scp) && !(sc->flags & SC_SCRN_BLANKED))
+	    rate = 2;
+	else
+	    rate = 30;
+	callout_reset_sbt(&sc->ctimeout, SBT_1S / rate, 0,
+	    scrn_timer, sc, C_PREL(1));
+    }
 }
 
 static int
@@ -2434,7 +2453,7 @@
      */
     tp = SC_DEV(sc, cur_scp->index);
     if ((cur_scp->index != next_scr)
-	&& tty_opened(tp)
+	&& tty_opened_ns(tp)
 	&& (cur_scp->smode.mode == VT_AUTO)
 	&& ISGRAPHSC(cur_scp)) {
 	splx(s);
@@ -2451,7 +2470,7 @@
      */
     if ((sc_console == NULL) || (next_scr != sc_console->index)) {
 	tp = SC_DEV(sc, next_scr);
-	if (!tty_opened(tp)) {
+	if (!tty_opened_ns(tp)) {
 	    splx(s);
 	    sc_bell(cur_scp, bios_value.bell_pitch, BELL_DURATION);
 	    DPRINTF(5, ("error 2, requested vty isn't open!\n"));
@@ -3137,7 +3156,7 @@
 
 	suspend_in_progress = FALSE;
 	if (sc_susp_scr < 0) {
-		mark_all(sc_console->sc->cur_scp);
+		update_font(sc_console->sc->cur_scp);
 		return;
 	}
 	sc_switch_scr(sc_console->sc, sc_susp_scr);
@@ -3394,7 +3413,7 @@
 	sc_touch_scrn_saver();
 
     if (!(flags & SCGETC_CN))
-	random_harvest(&c, sizeof(c), 1, 0, RANDOM_KEYBOARD);
+	random_harvest(&c, sizeof(c), 1, RANDOM_KEYBOARD);
 
     if (scp->kbd_mode != K_XLATE)
 	return KEYCHAR(c);
@@ -3490,7 +3509,7 @@
 			    sc_draw_cursor_image(scp);
 			}
 			tp = SC_DEV(sc, scp->index);
-			if (!kdb_active && tty_opened(tp))
+			if (!kdb_active && tty_opened_ns(tp))
 			    sctty_outwakeup(tp);
 #endif
 		    }
@@ -3585,7 +3604,7 @@
 			sc->first_vty + i != this_scr; 
 			i = (i + 1)%sc->vtys) {
 		    struct tty *tp = SC_DEV(sc, sc->first_vty + i);
-		    if (tty_opened(tp)) {
+		    if (tty_opened_ns(tp)) {
 			sc_switch_scr(scp->sc, sc->first_vty + i);
 			break;
 		    }
@@ -3598,7 +3617,7 @@
 			sc->first_vty + i != this_scr;
 			i = (i + sc->vtys - 1)%sc->vtys) {
 		    struct tty *tp = SC_DEV(sc, sc->first_vty + i);
-		    if (tty_opened(tp)) {
+		    if (tty_opened_ns(tp)) {
 			sc_switch_scr(scp->sc, sc->first_vty + i);
 			break;
 		    }
@@ -3642,6 +3661,37 @@
     return vidd_mmap(scp->sc->adp, offset, paddr, nprot, memattr);
 }
 
+static void
+update_font(scr_stat *scp)
+{
+#ifndef SC_NO_FONT_LOADING
+    /* load appropriate font */
+    if (!(scp->status & GRAPHICS_MODE)) {
+	if (!(scp->status & PIXEL_MODE) && ISFONTAVAIL(scp->sc->adp->va_flags)) {
+	    if (scp->font_size < 14) {
+		if (scp->sc->fonts_loaded & FONT_8)
+		    sc_load_font(scp, 0, 8, 8, scp->sc->font_8, 0, 256);
+	    } else if (scp->font_size >= 16) {
+		if (scp->sc->fonts_loaded & FONT_16)
+		    sc_load_font(scp, 0, 16, 8, scp->sc->font_16, 0, 256);
+	    } else {
+		if (scp->sc->fonts_loaded & FONT_14)
+		    sc_load_font(scp, 0, 14, 8, scp->sc->font_14, 0, 256);
+	    }
+	    /*
+	     * FONT KLUDGE:
+	     * This is an interim kludge to display correct font.
+	     * Always use the font page #0 on the video plane 2.
+	     * Somehow we cannot show the font in other font pages on
+	     * some video cards... XXX
+	     */ 
+	    sc_show_font(scp, 0);
+	}
+	mark_all(scp);
+    }
+#endif /* !SC_NO_FONT_LOADING */
+}
+
 static int
 save_kbd_state(scr_stat *scp)
 {
@@ -3714,32 +3764,7 @@
 		(void *)scp->sc->adp->va_window, FALSE);
 #endif
 
-#ifndef SC_NO_FONT_LOADING
-    /* load appropriate font */
-    if (!(scp->status & GRAPHICS_MODE)) {
-	if (!(scp->status & PIXEL_MODE) && ISFONTAVAIL(scp->sc->adp->va_flags)) {
-	    if (scp->font_size < 14) {
-		if (scp->sc->fonts_loaded & FONT_8)
-		    sc_load_font(scp, 0, 8, 8, scp->sc->font_8, 0, 256);
-	    } else if (scp->font_size >= 16) {
-		if (scp->sc->fonts_loaded & FONT_16)
-		    sc_load_font(scp, 0, 16, 8, scp->sc->font_16, 0, 256);
-	    } else {
-		if (scp->sc->fonts_loaded & FONT_14)
-		    sc_load_font(scp, 0, 14, 8, scp->sc->font_14, 0, 256);
-	    }
-	    /*
-	     * FONT KLUDGE:
-	     * This is an interim kludge to display correct font.
-	     * Always use the font page #0 on the video plane 2.
-	     * Somehow we cannot show the font in other font pages on
-	     * some video cards... XXX
-	     */ 
-	    sc_show_font(scp, 0);
-	}
-	mark_all(scp);
-    }
-#endif /* !SC_NO_FONT_LOADING */
+    update_font(scp);
 
     sc_set_border(scp, scp->border);
     sc_set_cursor_image(scp);
@@ -3794,7 +3819,7 @@
     u_char *rmap;
 
     tp = SC_DEV(scp->sc, scp->sc->cur_scp->index);
-    if (!tty_opened(tp))
+    if (!tty_opened_ns(tp))
 	return;
     rmap = scp->sc->scr_rmap;
     for (; count > 0; --count)
@@ -3808,7 +3833,7 @@
     struct tty *tp;
 
     tp = SC_DEV(scp->sc, scp->sc->cur_scp->index);
-    if (!tty_opened(tp))
+    if (!tty_opened_ns(tp))
 	return;
     ttydisc_rint_simple(tp, p, count);
     if (wakeup) {
@@ -3850,7 +3875,7 @@
 	scp->sc->blink_in_progress = 0;
     	mark_all(scp);
 	tp = SC_DEV(scp->sc, scp->index);
-	if (tty_opened(tp))
+	if (tty_opened_ns(tp))
 	    sctty_outwakeup(tp);
 	if (scp->sc->delayed_next_scr)
 	    sc_switch_scr(scp->sc, scp->sc->delayed_next_scr - 1);
@@ -3859,7 +3884,8 @@
 	(*scp->rndr->draw)(scp, 0, scp->xsize*scp->ysize, 
 			   scp->sc->blink_in_progress & 1);
 	scp->sc->blink_in_progress--;
-	timeout(blink_screen, scp, hz / 10);
+	callout_reset_sbt(&scp->sc->cblink, SBT_1S / 15, 0,
+	    blink_screen, scp, C_PREL(0));
     }
 }
 

Modified: trunk/sys/dev/syscons/syscons.h
===================================================================
--- trunk/sys/dev/syscons/syscons.h	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/syscons.h	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,6 +1,6 @@
-/* $MidnightBSD: src/sys/dev/syscons/syscons.h,v 1.6 2012/03/24 01:11:05 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
- * Copyright (c) 1995-1998 S\xF8ren Schmidt
+ * Copyright (c) 1995-1998 Søren Schmidt
  * All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
@@ -29,7 +29,7 @@
  * (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$
+ * $FreeBSD: stable/10/sys/dev/syscons/syscons.h 262674 2014-03-02 01:46:44Z jmmv $
  */
 
 #ifndef _DEV_SYSCONS_SYSCONS_H_
@@ -146,9 +146,9 @@
 /*
    The following #defines are hard-coded for a maximum text
    resolution corresponding to a maximum framebuffer
-   resolution of 1600x1200 with an 8x8 font...
+   resolution of 1920x1200 with an 8x8 font...
 */
-#define	COL		200
+#define	COL		240
 #define	ROW		150
 
 #define PCBURST		128
@@ -270,6 +270,8 @@
 #ifdef KDB
 	int		sc_altbrk;
 #endif
+	struct callout	ctimeout;
+	struct callout	cblink;
 } sc_softc_t;
 
 /* virtual screen */

Modified: trunk/sys/dev/syscons/sysmouse.c
===================================================================
--- trunk/sys/dev/syscons/sysmouse.c	2018-05-27 23:01:30 UTC (rev 10063)
+++ trunk/sys/dev/syscons/sysmouse.c	2018-05-27 23:04:23 UTC (rev 10064)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/syscons/sysmouse.c,v 1.3 2009/08/30 06:02:33 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/syscons/sysmouse.c 268366 2014-07-07 14:16:05Z ray $");
 
 #include "opt_syscons.h"
 
@@ -38,6 +38,7 @@
 #include <sys/tty.h>
 #include <sys/ttydefaults.h>
 #include <sys/kernel.h>
+#include <sys/cons.h>
 #include <sys/consio.h>
 #include <sys/mouse.h>
 
@@ -166,6 +167,8 @@
 static void
 sm_attach_mouse(void *unused)
 {
+	if (!vty_enabled(VTY_SC))
+		return;
 	sysmouse_tty = tty_alloc(&smdev_ttydevsw, NULL);
 	tty_makedev(sysmouse_tty, NULL, "sysmouse");
 }



More information about the Midnightbsd-cvs mailing list