Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Dec 2019 02:30:53 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r355316 - head/sys/dev/syscons
Message-ID:  <201912030230.xB32Ur0l077546@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Tue Dec  3 02:30:52 2019
New Revision: 355316
URL: https://svnweb.freebsd.org/changeset/base/355316

Log:
  syscons.c: clang-format pass to reduce style inconsistencies
  
  This was purely automatically massaged... some parts are still imperfect,
  but this is close enough to make it more readable/easy to work on.
  Unfortunately the vt/syscons/kdb situation slightly complicates changes to
  tty locking, so some work will need to be done to remediate that.

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

Modified: head/sys/dev/syscons/syscons.c
==============================================================================
--- head/sys/dev/syscons/syscons.c	Mon Dec  2 22:44:34 2019	(r355315)
+++ head/sys/dev/syscons/syscons.c	Tue Dec  3 02:30:52 2019	(r355316)
@@ -65,13 +65,13 @@ __FBSDID("$FreeBSD$");
 #include <sys/power.h>
 
 #include <machine/clock.h>
-#if defined(__arm__) || defined(__mips__) || \
-	defined(__powerpc__) || defined(__sparc64__)
+#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) || \
+    defined(__sparc64__)
 #include <machine/sc_machdep.h>
 #else
 #include <machine/pc/display.h>
 #endif
-#if defined( __i386__) || defined(__amd64__)
+#if defined(__i386__) || defined(__amd64__)
 #include <machine/psl.h>
 #include <machine/frame.h>
 #endif
@@ -92,71 +92,74 @@ __FBSDID("$FreeBSD$");
 #define COLD 0
 #define WARM 1
 
-#define DEFAULT_BLANKTIME	(5*60)		/* 5 minutes */
-#define MAX_BLANKTIME		(7*24*60*60)	/* 7 days!? */
+#define DEFAULT_BLANKTIME (5 * 60) /* 5 minutes */
+#define MAX_BLANKTIME (7 * 24 * 60 * 60) /* 7 days!? */
 
-#define KEYCODE_BS		0x0e		/* "<-- Backspace" key, XXX */
+#define KEYCODE_BS 0x0e /* "<-- Backspace" key, XXX */
 
 /* NULL-safe version of "tty_opened()" */
-#define	tty_opened_ns(tp)	((tp) != NULL && tty_opened(tp))
+#define tty_opened_ns(tp) ((tp) != NULL && tty_opened(tp))
 
-static	u_char		sc_kattrtab[MAXCPU];
+static u_char sc_kattrtab[MAXCPU];
 
-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		*sc_kts[MAXCPU];
-static	struct sc_term_sw *sc_ktsw;
-static	scr_stat	main_console;
-static	struct tty 	*main_devs[MAXCONS];
+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 *sc_kts[MAXCPU];
+static struct sc_term_sw *sc_ktsw;
+static scr_stat main_console;
+static struct tty *main_devs[MAXCONS];
 
-static  char        	init_done = COLD;
-static	int		shutdown_in_progress = FALSE;
-static	int		suspend_in_progress = FALSE;
-static	char		sc_malloc = FALSE;
+static char init_done = COLD;
+static int shutdown_in_progress = FALSE;
+static int suspend_in_progress = FALSE;
+static char sc_malloc = FALSE;
 
-static	int		saver_mode = CONS_NO_SAVER; /* LKM/user saver */
-static	int		run_scrn_saver = FALSE;	/* should run the saver? */
-static	int		enable_bell = TRUE; /* enable beeper */
+static int saver_mode = CONS_NO_SAVER; /* LKM/user saver */
+static int run_scrn_saver = FALSE; /* should run the saver? */
+static int enable_bell = TRUE; /* enable beeper */
 
 #ifndef SC_DISABLE_REBOOT
-static  int		enable_reboot = TRUE; /* enable keyboard reboot */
+static int enable_reboot = TRUE; /* enable keyboard reboot */
 #endif
 
 #ifndef SC_DISABLE_KDBKEY
-static  int		enable_kdbkey = TRUE; /* enable keyboard debug */
+static int enable_kdbkey = TRUE; /* enable keyboard debug */
 #endif
 
-static	long        	scrn_blank_time = 0;    /* screen saver timeout value */
+static long scrn_blank_time = 0; /* screen saver timeout value */
 #ifdef DEV_SPLASH
-static	int     	scrn_blanked;		/* # of blanked screen */
-static	int		sticky_splash = FALSE;
+static int scrn_blanked; /* # of blanked screen */
+static int sticky_splash = FALSE;
 
-static	void		none_saver(sc_softc_t *sc, int blank) { }
-static	void		(*current_saver)(sc_softc_t *, int) = none_saver;
+static void
+none_saver(sc_softc_t *sc, int blank)
+{
+}
+static void (*current_saver)(sc_softc_t *, int) = none_saver;
 #endif
 
 #ifdef SC_NO_SUSPEND_VTYSWITCH
-static	int		sc_no_suspend_vtswitch = 1;
+static int sc_no_suspend_vtswitch = 1;
 #else
-static	int		sc_no_suspend_vtswitch = 0;
+static int sc_no_suspend_vtswitch = 0;
 #endif
-static	int		sc_susp_scr;
+static int sc_susp_scr;
 
 static SYSCTL_NODE(_hw, OID_AUTO, syscons, CTLFLAG_RD, 0, "syscons");
 static SYSCTL_NODE(_hw_syscons, OID_AUTO, saver, CTLFLAG_RD, 0, "saver");
 SYSCTL_INT(_hw_syscons_saver, OID_AUTO, keybonly, CTLFLAG_RW,
     &sc_saver_keyb_only, 0, "screen saver interrupted by input only");
-SYSCTL_INT(_hw_syscons, OID_AUTO, bell, CTLFLAG_RW, &enable_bell, 
-    0, "enable bell");
+SYSCTL_INT(
+    _hw_syscons, OID_AUTO, bell, CTLFLAG_RW, &enable_bell, 0, "enable bell");
 #ifndef SC_DISABLE_REBOOT
-SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_reboot, CTLFLAG_RW|CTLFLAG_SECURE, &enable_reboot,
-    0, "enable keyboard reboot");
+SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_reboot, CTLFLAG_RW | CTLFLAG_SECURE,
+    &enable_reboot, 0, "enable keyboard reboot");
 #endif
 #ifndef SC_DISABLE_KDBKEY
-SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_debug, CTLFLAG_RW|CTLFLAG_SECURE, &enable_kdbkey,
-    0, "enable keyboard debug");
+SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_debug, CTLFLAG_RW | CTLFLAG_SECURE,
+    &enable_kdbkey, 0, "enable keyboard debug");
 #endif
 SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RWTUN,
     &sc_no_suspend_vtswitch, 0, "Disable VT switch before suspend.");
@@ -164,15 +167,15 @@ SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswit
 #include "font.h"
 #endif
 
-	tsw_ioctl_t	*sc_user_ioctl;
+tsw_ioctl_t *sc_user_ioctl;
 
-static	bios_values_t	bios_value;
+static bios_values_t bios_value;
 
-static	int		enable_panic_key;
+static int enable_panic_key;
 SYSCTL_INT(_machdep, OID_AUTO, enable_panic_key, CTLFLAG_RW, &enable_panic_key,
-	   0, "Enable panic via keypress specified in kbdmap(5)");
+    0, "Enable panic via keypress specified in kbdmap(5)");
 
-#define SC_CONSOLECTL	255
+#define SC_CONSOLECTL 255
 
 #define VTY_WCHAN(sc, vty) (&SC_DEV(sc, vty))
 
@@ -191,8 +194,8 @@ static void scsuspend(void *);
 static void scresume(void *);
 static u_int scgetc(sc_softc_t *sc, u_int flags, struct sc_cnstate *sp);
 static void sc_puts(scr_stat *scp, u_char *buf, int len);
-#define SCGETC_CN	1
-#define SCGETC_NONBLOCK	2
+#define SCGETC_CN 1
+#define SCGETC_NONBLOCK 2
 static void sccnupdate(scr_stat *scp);
 static scr_stat *alloc_scp(sc_softc_t *sc, int vty);
 static void init_scp(sc_softc_t *sc, int vty, scr_stat *scp);
@@ -205,11 +208,12 @@ static int scsplash_callback(int event, void *arg);
 static void scsplash_saver(sc_softc_t *sc, int show);
 static int add_scrn_saver(void (*this_saver)(sc_softc_t *, int));
 static int remove_scrn_saver(void (*this_saver)(sc_softc_t *, int));
-static int set_scrn_saver_mode(scr_stat *scp, int mode, u_char *pal, int border);
+static int set_scrn_saver_mode(
+    scr_stat *scp, int mode, u_char *pal, int border);
 static int restore_scrn_saver_mode(scr_stat *scp, int changemode);
 static void stop_scrn_saver(sc_softc_t *sc, void (*saver)(sc_softc_t *, int));
 static int wait_scrn_saver_stop(sc_softc_t *sc);
-#define scsplash_stick(stick)		(sticky_splash = (stick))
+#define scsplash_stick(stick) (sticky_splash = (stick))
 #else /* !DEV_SPLASH */
 #define scsplash_stick(stick)
 #endif /* DEV_SPLASH */
@@ -231,44 +235,44 @@ static int sc_kattr(void);
 static timeout_t blink_screen;
 static struct tty *sc_alloc_tty(int, int);
 
-static cn_probe_t	sc_cnprobe;
-static cn_init_t	sc_cninit;
-static cn_term_t	sc_cnterm;
-static cn_getc_t	sc_cngetc;
-static cn_putc_t	sc_cnputc;
-static cn_grab_t	sc_cngrab;
-static cn_ungrab_t	sc_cnungrab;
+static cn_probe_t sc_cnprobe;
+static cn_init_t sc_cninit;
+static cn_term_t sc_cnterm;
+static cn_getc_t sc_cngetc;
+static cn_putc_t sc_cnputc;
+static cn_grab_t sc_cngrab;
+static cn_ungrab_t sc_cnungrab;
 
 CONSOLE_DRIVER(sc);
 
-static	tsw_open_t	sctty_open;
-static	tsw_close_t	sctty_close;
-static	tsw_outwakeup_t	sctty_outwakeup;
-static	tsw_ioctl_t	sctty_ioctl;
-static	tsw_mmap_t	sctty_mmap;
+static tsw_open_t sctty_open;
+static tsw_close_t sctty_close;
+static tsw_outwakeup_t sctty_outwakeup;
+static tsw_ioctl_t sctty_ioctl;
+static tsw_mmap_t sctty_mmap;
 
 static struct ttydevsw sc_ttydevsw = {
-	.tsw_open	= sctty_open,
-	.tsw_close	= sctty_close,
-	.tsw_outwakeup	= sctty_outwakeup,
-	.tsw_ioctl	= sctty_ioctl,
-	.tsw_mmap	= sctty_mmap,
+	.tsw_open = sctty_open,
+	.tsw_close = sctty_close,
+	.tsw_outwakeup = sctty_outwakeup,
+	.tsw_ioctl = sctty_ioctl,
+	.tsw_mmap = sctty_mmap,
 };
 
-static d_ioctl_t	consolectl_ioctl;
-static d_close_t	consolectl_close;
+static d_ioctl_t consolectl_ioctl;
+static d_close_t consolectl_close;
 
 static struct cdevsw consolectl_devsw = {
-	.d_version	= D_VERSION,
-	.d_flags	= D_NEEDGIANT | D_TRACKCLOSE,
-	.d_ioctl	= consolectl_ioctl,
-	.d_close	= consolectl_close,
-	.d_name		= "consolectl",
+	.d_version = D_VERSION,
+	.d_flags = D_NEEDGIANT | D_TRACKCLOSE,
+	.d_ioctl = consolectl_ioctl,
+	.d_close = consolectl_close,
+	.d_name = "consolectl",
 };
 
 /* ec -- emergency console. */
 
-static	u_int	ec_scroffset;
+static u_int ec_scroffset;
 
 static void
 ec_putc(int c)
@@ -309,15 +313,18 @@ ec_putc(int c)
 	do {
 		ind = ec_scroffset;
 		column = ind % xsize;
-		width = (c == '\b' ? -1 : c == '\t' ? (column + 8) & ~7 :
-		    c == '\r' ? -column : c == '\n' ? xsize - column : 1);
+		width = (c == '\b' ?
+			-1 :
+			c == '\t' ?
+			(column + 8) & ~7 :
+			c == '\r' ? -column : c == '\n' ? xsize - column : 1);
 		if (width == 0 || (width < 0 && ind < -width))
 			return;
 	} while (atomic_cmpset_rel_int(&ec_scroffset, ind, ind + width) == 0);
 	if (c == '\b' || c == '\r')
 		return;
 	if (c == '\n')
-		ind += xsize;	/* XXX clearing from new pos is not atomic */
+		ind += xsize; /* XXX clearing from new pos is not atomic */
 
 	attr = sc_kattr();
 	if (c == '\t' || c == '\n')
@@ -330,88 +337,89 @@ ec_putc(int c)
 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);
-	return ENXIO;
-    }
+	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);
+		return ENXIO;
+	}
 
-    /* syscons will be attached even when there is no keyboard */
-    sckbdprobe(unit, flags, FALSE);
+	/* syscons will be attached even when there is no keyboard */
+	sckbdprobe(unit, flags, FALSE);
 
-    return 0;
+	return 0;
 }
 
-/* probe video adapters, return TRUE if found */ 
+/* probe video adapters, return TRUE if found */
 static int
 scvidprobe(int unit, int flags, int cons)
 {
-    /*
-     * Access the video adapter driver through the back door!
-     * Video adapter drivers need to be configured before syscons.
-     * However, when syscons is being probed as the low-level console,
-     * they have not been initialized yet.  We force them to initialize
-     * themselves here. XXX
-     */
-    vid_configure(cons ? VIO_PROBE_ONLY : 0);
+	/*
+	 * Access the video adapter driver through the back door!
+	 * Video adapter drivers need to be configured before syscons.
+	 * However, when syscons is being probed as the low-level console,
+	 * they have not been initialized yet.  We force them to initialize
+	 * themselves here. XXX
+	 */
+	vid_configure(cons ? VIO_PROBE_ONLY : 0);
 
-    return (vid_find_adapter("*", unit) >= 0);
+	return (vid_find_adapter("*", unit) >= 0);
 }
 
 /* probe the keyboard, return TRUE if found */
 static int
 sckbdprobe(int unit, int flags, int cons)
 {
-    /* access the keyboard driver through the backdoor! */
-    kbd_configure(cons ? KB_CONF_PROBE_ONLY : 0);
+	/* access the keyboard driver through the backdoor! */
+	kbd_configure(cons ? KB_CONF_PROBE_ONLY : 0);
 
-    return (kbd_find_keyboard("*", unit) >= 0);
+	return (kbd_find_keyboard("*", unit) >= 0);
 }
 
-static char
-*adapter_name(video_adapter_t *adp)
+static char *
+adapter_name(video_adapter_t *adp)
 {
-    static struct {
-	int type;
-	char *name[2];
-    } names[] = {
-	{ KD_MONO,	{ "MDA",	"MDA" } },
-	{ KD_HERCULES,	{ "Hercules",	"Hercules" } },
-	{ KD_CGA,	{ "CGA",	"CGA" } },
-	{ KD_EGA,	{ "EGA",	"EGA (mono)" } },
-	{ KD_VGA,	{ "VGA",	"VGA (mono)" } },
-	{ KD_TGA,	{ "TGA",	"TGA" } },
-	{ -1,		{ "Unknown",	"Unknown" } },
-    };
-    int i;
+	static struct {
+		int type;
+		char *name[2];
+	} names[] = {
+		{ KD_MONO, { "MDA", "MDA" } },
+		{ KD_HERCULES, { "Hercules", "Hercules" } },
+		{ KD_CGA, { "CGA", "CGA" } },
+		{ KD_EGA, { "EGA", "EGA (mono)" } },
+		{ KD_VGA, { "VGA", "VGA (mono)" } },
+		{ KD_TGA, { "TGA", "TGA" } },
+		{ -1, { "Unknown", "Unknown" } },
+	};
+	int i;
 
-    for (i = 0; names[i].type != -1; ++i)
-	if (names[i].type == adp->va_type)
-	    break;
-    return names[i].name[(adp->va_flags & V_ADP_COLOR) ? 0 : 1];
+	for (i = 0; names[i].type != -1; ++i)
+		if (names[i].type == adp->va_type)
+			break;
+	return names[i].name[(adp->va_flags & V_ADP_COLOR) ? 0 : 1];
 }
 
 static void
 sctty_outwakeup(struct tty *tp)
 {
-    size_t len;
-    u_char buf[PCBURST];
-    scr_stat *scp = sc_get_stat(tp);
+	size_t len;
+	u_char buf[PCBURST];
+	scr_stat *scp = sc_get_stat(tp);
 
-    if (scp->status & SLKED ||
-	(scp == scp->sc->cur_scp && scp->sc->blink_in_progress))
-	return;
+	if (scp->status & SLKED ||
+	    (scp == scp->sc->cur_scp && scp->sc->blink_in_progress))
+		return;
 
-    for (;;) {
-	len = ttydisc_getc(tp, buf, sizeof buf);
-	if (len == 0)
-	    break;
-	SC_VIDEO_LOCK(scp->sc);
-	sc_puts(scp, buf, len);
-	SC_VIDEO_UNLOCK(scp->sc);
-    }
+	for (;;) {
+		len = ttydisc_getc(tp, buf, sizeof buf);
+		if (len == 0)
+			break;
+		SC_VIDEO_LOCK(scp->sc);
+		sc_puts(scp, buf, len);
+		SC_VIDEO_UNLOCK(scp->sc);
+	}
 }
 
 static struct tty *
@@ -553,144 +561,145 @@ sc_set_vesa_mode(scr_stat *scp, sc_softc_t *sc, int un
 int
 sc_attach_unit(int unit, int flags)
 {
-    sc_softc_t *sc;
-    scr_stat *scp;
-    struct cdev *dev;
-    void *oldts, *ts;
-    int i, vc;
+	sc_softc_t *sc;
+	scr_stat *scp;
+	struct cdev *dev;
+	void *oldts, *ts;
+	int i, vc;
 
-    if (!vty_enabled(VTY_SC))
-        return ENXIO;
+	if (!vty_enabled(VTY_SC))
+		return ENXIO;
 
-    flags &= ~SC_KERNEL_CONSOLE;
+	flags &= ~SC_KERNEL_CONSOLE;
 
-    if (sc_console_unit == unit) {
-	/*
-	 * If this unit is being used as the system console, we need to
-	 * adjust some variables and buffers before and after scinit().
-	 */
-	/* assert(sc_console != NULL) */
-	flags |= SC_KERNEL_CONSOLE;
-	scmeminit(NULL);
+	if (sc_console_unit == unit) {
+		/*
+		 * If this unit is being used as the system console, we need to
+		 * adjust some variables and buffers before and after scinit().
+		 */
+		/* assert(sc_console != NULL) */
+		flags |= SC_KERNEL_CONSOLE;
+		scmeminit(NULL);
 
-	scinit(unit, 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++) {
-		ts = malloc(sc_console->tsw->te_size, M_DEVBUF,
-			    M_WAITOK | M_ZERO);
-		(*sc_console->tsw->te_init)(sc_console, &ts, SC_TE_COLD_INIT);
-		sc_console->ts = ts;
-		(*sc_console->tsw->te_default_attr)(sc_console, sc_kattrtab[i],
-						    SC_KERNEL_CONS_REV_ATTR);
-		sc_kts[i] = ts;
-	    }
-	    sc_console->ts = oldts;
-    	    (*sc_console->tsw->te_default_attr)(sc_console, SC_NORM_ATTR,
-						SC_NORM_REV_ATTR);
+		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++) {
+				ts = malloc(sc_console->tsw->te_size, M_DEVBUF,
+				    M_WAITOK | M_ZERO);
+				(*sc_console->tsw->te_init)(
+				    sc_console, &ts, SC_TE_COLD_INIT);
+				sc_console->ts = ts;
+				(*sc_console->tsw->te_default_attr)(sc_console,
+				    sc_kattrtab[i], SC_KERNEL_CONS_REV_ATTR);
+				sc_kts[i] = ts;
+			}
+			sc_console->ts = oldts;
+			(*sc_console->tsw->te_default_attr)(
+			    sc_console, SC_NORM_ATTR, SC_NORM_REV_ATTR);
+		}
+	} else {
+		scinit(unit, flags);
 	}
-    } else {
-	scinit(unit, flags);
-    }
 
-    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;
+	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;
 
 #ifdef SC_PIXEL_MODE
-    if ((sc->config & SC_VESAMODE) != 0)
-	sc_set_vesa_mode(scp, sc, unit);
+	if ((sc->config & SC_VESAMODE) != 0)
+		sc_set_vesa_mode(scp, sc, unit);
 #endif /* SC_PIXEL_MODE */
 
-    /* initialize cursor */
-    if (!ISGRAPHSC(scp))
-    	update_cursor_image(scp);
+	/* initialize cursor */
+	if (!ISGRAPHSC(scp))
+		update_cursor_image(scp);
 
-    /* get screen update going */
-    scrn_timer(sc);
+	/* get screen update going */
+	scrn_timer(sc);
 
-    /* set up the keyboard */
-    (void)kbdd_ioctl(sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
-    update_kbd_state(scp, scp->status, LOCK_MASK);
+	/* set up the keyboard */
+	(void)kbdd_ioctl(sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
+	update_kbd_state(scp, scp->status, LOCK_MASK);
 
-    printf("%s%d: %s <%d virtual consoles, flags=0x%x>\n",
-	   SC_DRIVER_NAME, unit, adapter_name(sc->adp), sc->vtys, sc->config);
-    if (bootverbose) {
-	printf("%s%d:", SC_DRIVER_NAME, unit);
-    	if (sc->adapter >= 0)
-	    printf(" fb%d", sc->adapter);
-	if (sc->keyboard >= 0)
-	    printf(", kbd%d", sc->keyboard);
-	if (scp->tsw)
-	    printf(", terminal emulator: %s (%s)",
-		   scp->tsw->te_name, scp->tsw->te_desc);
-	printf("\n");
-    }
+	printf("%s%d: %s <%d virtual consoles, flags=0x%x>\n", SC_DRIVER_NAME,
+	    unit, adapter_name(sc->adp), sc->vtys, sc->config);
+	if (bootverbose) {
+		printf("%s%d:", SC_DRIVER_NAME, unit);
+		if (sc->adapter >= 0)
+			printf(" fb%d", sc->adapter);
+		if (sc->keyboard >= 0)
+			printf(", kbd%d", sc->keyboard);
+		if (scp->tsw)
+			printf(", terminal emulator: %s (%s)",
+			    scp->tsw->te_name, scp->tsw->te_desc);
+		printf("\n");
+	}
 
-    /* Register suspend/resume/shutdown callbacks for the kernel console. */
-    if (sc_console_unit == unit) {
-	EVENTHANDLER_REGISTER(power_suspend_early, scsuspend, NULL,
-			      EVENTHANDLER_PRI_ANY);
-	EVENTHANDLER_REGISTER(power_resume, scresume, NULL,
-			      EVENTHANDLER_PRI_ANY);
-	EVENTHANDLER_REGISTER(shutdown_pre_sync, scshutdown, NULL,
-			      SHUTDOWN_PRI_DEFAULT);
-    }
+	/* Register suspend/resume/shutdown callbacks for the kernel console. */
+	if (sc_console_unit == unit) {
+		EVENTHANDLER_REGISTER(
+		    power_suspend_early, scsuspend, NULL, EVENTHANDLER_PRI_ANY);
+		EVENTHANDLER_REGISTER(
+		    power_resume, scresume, NULL, EVENTHANDLER_PRI_ANY);
+		EVENTHANDLER_REGISTER(
+		    shutdown_pre_sync, scshutdown, NULL, SHUTDOWN_PRI_DEFAULT);
+	}
 
-    for (vc = 0; vc < sc->vtys; vc++) {
-	if (sc->dev[vc] == NULL) {
-		sc->dev[vc] = sc_alloc_tty(vc, vc + unit * MAXCONS);
-		if (vc == 0 && sc->dev == main_devs)
-			SC_STAT(sc->dev[0]) = &main_console;
+	for (vc = 0; vc < sc->vtys; vc++) {
+		if (sc->dev[vc] == NULL) {
+			sc->dev[vc] = sc_alloc_tty(vc, vc + unit * MAXCONS);
+			if (vc == 0 && sc->dev == main_devs)
+				SC_STAT(sc->dev[0]) = &main_console;
+		}
+		/*
+		 * The first vty already has struct tty and scr_stat initialized
+		 * in scinit().  The other vtys will have these structs when
+		 * first opened.
+		 */
 	}
-	/*
-	 * The first vty already has struct tty and scr_stat initialized
-	 * in scinit().  The other vtys will have these structs when
-	 * first opened.
-	 */
-    }
 
-    dev = make_dev(&consolectl_devsw, 0, UID_ROOT, GID_WHEEL, 0600,
-        "consolectl");
-    dev->si_drv1 = sc->dev[0];
+	dev = make_dev(
+	    &consolectl_devsw, 0, UID_ROOT, GID_WHEEL, 0600, "consolectl");
+	dev->si_drv1 = sc->dev[0];
 
-    return 0;
+	return 0;
 }
 
 static void
 scmeminit(void *arg)
 {
-    if (!vty_enabled(VTY_SC))
-        return;
-    if (sc_malloc)
-	return;
-    sc_malloc = TRUE;
+	if (!vty_enabled(VTY_SC))
+		return;
+	if (sc_malloc)
+		return;
+	sc_malloc = TRUE;
 
-    /*
-     * As soon as malloc() becomes functional, we had better allocate
-     * various buffers for the kernel console.
-     */
+	/*
+	 * As soon as malloc() becomes functional, we had better allocate
+	 * various buffers for the kernel console.
+	 */
 
-    if (sc_console_unit < 0)	/* sc_console == NULL */
-	return;
+	if (sc_console_unit < 0) /* sc_console == NULL */
+		return;
 
-    /* copy the temporary buffer to the final buffer */
-    sc_alloc_scr_buffer(sc_console, FALSE, FALSE);
+	/* copy the temporary buffer to the final buffer */
+	sc_alloc_scr_buffer(sc_console, FALSE, FALSE);
 
 #ifndef SC_NO_CUTPASTE
-    sc_alloc_cut_buffer(sc_console, FALSE);
+	sc_alloc_cut_buffer(sc_console, FALSE);
 #endif
 
 #ifndef SC_NO_HISTORY
-    /* initialize history buffer & pointers */
-    sc_alloc_history_buffer(sc_console, 0, 0, FALSE);
+	/* initialize history buffer & pointers */
+	sc_alloc_history_buffer(sc_console, 0, 0, FALSE);
 #endif
 }
 
@@ -700,101 +709,104 @@ SYSINIT(sc_mem, SI_SUB_KMEM, SI_ORDER_ANY, scmeminit, 
 static int
 scdevtounit(struct tty *tp)
 {
-    int vty = SC_VTY(tp);
+	int vty = SC_VTY(tp);
 
-    if (vty == SC_CONSOLECTL)
-	return ((sc_console != NULL) ? sc_console->sc->unit : -1);
-    else if ((vty < 0) || (vty >= MAXCONS*sc_max_unit()))
-	return -1;
-    else
-	return vty/MAXCONS;
+	if (vty == SC_CONSOLECTL)
+		return ((sc_console != NULL) ? sc_console->sc->unit : -1);
+	else if ((vty < 0) || (vty >= MAXCONS * sc_max_unit()))
+		return -1;
+	else
+		return vty / MAXCONS;
 }
 
 static int
 sctty_open(struct tty *tp)
 {
-    int unit = scdevtounit(tp);
-    sc_softc_t *sc;
-    scr_stat *scp;
+	int unit = scdevtounit(tp);
+	sc_softc_t *sc;
+	scr_stat *scp;
 #ifndef __sparc64__
-    keyarg_t key;
+	keyarg_t key;
 #endif
 
-    DPRINTF(5, ("scopen: dev:%s, unit:%d, vty:%d\n",
-		devtoname(tp->t_dev), unit, SC_VTY(tp)));
+	DPRINTF(5,
+	    ("scopen: dev:%s, unit:%d, vty:%d\n", devtoname(tp->t_dev), unit,
+		SC_VTY(tp)));
 
-    sc = sc_get_softc(unit, (sc_console_unit == unit) ? SC_KERNEL_CONSOLE : 0);
-    if (sc == NULL)
-	return ENXIO;
+	sc = sc_get_softc(
+	    unit, (sc_console_unit == unit) ? SC_KERNEL_CONSOLE : 0);
+	if (sc == NULL)
+		return ENXIO;
 
-    if (!tty_opened(tp)) {
-        /* Use the current setting of the <-- key as default VERASE. */  
-        /* If the Delete key is preferable, an stty is necessary     */
+	if (!tty_opened(tp)) {
+		/* Use the current setting of the <-- key as default VERASE. */
+		/* If the Delete key is preferable, an stty is necessary     */
 #ifndef __sparc64__
-	if (sc->kbd != NULL) {
-	    key.keynum = KEYCODE_BS;
-	    (void)kbdd_ioctl(sc->kbd, GIO_KEYMAPENT, (caddr_t)&key);
-            tp->t_termios.c_cc[VERASE] = key.key.map[0];
-	}
+		if (sc->kbd != NULL) {
+			key.keynum = KEYCODE_BS;
+			(void)kbdd_ioctl(sc->kbd, GIO_KEYMAPENT, (caddr_t)&key);
+			tp->t_termios.c_cc[VERASE] = key.key.map[0];
+		}
 #endif
-    }
+	}
 
-    scp = sc_get_stat(tp);
-    if (scp == NULL) {
-	scp = SC_STAT(tp) = alloc_scp(sc, SC_VTY(tp));
-	if (ISGRAPHSC(scp))
-	    sc_set_pixel_mode(scp, NULL, 0, 0, 16, 8);
-    }
-    if (!tp->t_winsize.ws_col && !tp->t_winsize.ws_row) {
-	tp->t_winsize.ws_col = scp->xsize;
-	tp->t_winsize.ws_row = scp->ysize;
-    }
+	scp = sc_get_stat(tp);
+	if (scp == NULL) {
+		scp = SC_STAT(tp) = alloc_scp(sc, SC_VTY(tp));
+		if (ISGRAPHSC(scp))
+			sc_set_pixel_mode(scp, NULL, 0, 0, 16, 8);
+	}
+	if (!tp->t_winsize.ws_col && !tp->t_winsize.ws_row) {
+		tp->t_winsize.ws_col = scp->xsize;
+		tp->t_winsize.ws_row = scp->ysize;
+	}
 
-    return (0);
+	return (0);
 }
 
 static void
 sctty_close(struct tty *tp)
 {
-    scr_stat *scp;
-    int s;
+	scr_stat *scp;
+	int s;
 
-    if (SC_VTY(tp) != SC_CONSOLECTL) {
-	scp = sc_get_stat(tp);
-	/* were we in the middle of the VT switching process? */
-	DPRINTF(5, ("sc%d: scclose(), ", scp->sc->unit));
-	s = spltty();
-	if ((scp == scp->sc->cur_scp) && (scp->sc->unit == sc_console_unit))
-	    cnavailable(sc_consptr, TRUE);
-	if (finish_vt_rel(scp, TRUE, &s) == 0)	/* force release */
-	    DPRINTF(5, ("reset WAIT_REL, "));
-	if (finish_vt_acq(scp) == 0)		/* force acknowledge */
-	    DPRINTF(5, ("reset WAIT_ACQ, "));
+	if (SC_VTY(tp) != SC_CONSOLECTL) {
+		scp = sc_get_stat(tp);
+		/* were we in the middle of the VT switching process? */
+		DPRINTF(5, ("sc%d: scclose(), ", scp->sc->unit));
+		s = spltty();
+		if ((scp == scp->sc->cur_scp) &&
+		    (scp->sc->unit == sc_console_unit))
+			cnavailable(sc_consptr, TRUE);
+		if (finish_vt_rel(scp, TRUE, &s) == 0) /* force release */
+			DPRINTF(5, ("reset WAIT_REL, "));
+		if (finish_vt_acq(scp) == 0) /* force acknowledge */
+			DPRINTF(5, ("reset WAIT_ACQ, "));
 #ifdef not_yet_done
-	if (scp == &main_console) {
-	    scp->pid = 0;
-	    scp->proc = NULL;
-	    scp->smode.mode = VT_AUTO;
-	}
-	else {
-	    sc_vtb_destroy(&scp->vtb);
+		if (scp == &main_console) {
+			scp->pid = 0;
+			scp->proc = NULL;
+			scp->smode.mode = VT_AUTO;
+		} else {
+			sc_vtb_destroy(&scp->vtb);
 #ifndef __sparc64__
-	    sc_vtb_destroy(&scp->scr);
+			sc_vtb_destroy(&scp->scr);
 #endif
-	    sc_free_history_buffer(scp, scp->ysize);
-	    SC_STAT(tp) = NULL;
-	    free(scp, M_DEVBUF);
-	}
+			sc_free_history_buffer(scp, scp->ysize);
+			SC_STAT(tp) = NULL;
+			free(scp, M_DEVBUF);
+		}
 #else
-	scp->pid = 0;
-	scp->proc = NULL;
-	scp->smode.mode = VT_AUTO;
+		scp->pid = 0;
+		scp->proc = NULL;
+		scp->smode.mode = VT_AUTO;
 #endif
-	scp->kbd_mode = K_XLATE;
-	if (scp == scp->sc->cur_scp)
-	    (void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
-	DPRINTF(5, ("done.\n"));
-    }
+		scp->kbd_mode = K_XLATE;
+		if (scp == scp->sc->cur_scp)
+			(void)kbdd_ioctl(
+			    scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
+		DPRINTF(5, ("done.\n"));
+	}
 }
 
 #if 0 /* XXX mpsafetty: fix screensaver. What about outwakeup? */
@@ -810,867 +822,886 @@ scread(struct cdev *dev, struct uio *uio, int flag)
 static int
 sckbdevent(keyboard_t *thiskbd, int event, void *arg)
 {
-    sc_softc_t *sc;
-    struct tty *cur_tty;
-    int c, error = 0; 
-    size_t len;
-    const u_char *cp;
+	sc_softc_t *sc;
+	struct tty *cur_tty;
+	int c, error = 0;
+	size_t len;
+	const u_char *cp;
 
-    sc = (sc_softc_t *)arg;
-    /* assert(thiskbd == sc->kbd) */
+	sc = (sc_softc_t *)arg;
+	/* assert(thiskbd == sc->kbd) */
 
-    mtx_lock(&Giant);
+	mtx_lock(&Giant);
 
-    switch (event) {
-    case KBDIO_KEYINPUT:
-	break;
-    case KBDIO_UNLOADING:
-	sc->kbd = NULL;
-	sc->keyboard = -1;
-	kbd_release(thiskbd, (void *)&sc->keyboard);
-	goto done;
-    default:
-	error = EINVAL;
-	goto done;
-    }
+	switch (event) {
+	case KBDIO_KEYINPUT:
+		break;
+	case KBDIO_UNLOADING:
+		sc->kbd = NULL;
+		sc->keyboard = -1;
+		kbd_release(thiskbd, (void *)&sc->keyboard);
+		goto done;
+	default:
+		error = EINVAL;
+		goto done;
+	}
 
-    /* 
-     * Loop while there is still input to get from the keyboard.
-     * I don't think this is nessesary, and it doesn't fix
-     * the Xaccel-2.1 keyboard hang, but it can't hurt.		XXX
-     */
-    while ((c = scgetc(sc, SCGETC_NONBLOCK, NULL)) != NOKEY) {
+	/*
+	 * Loop while there is still input to get from the keyboard.
+	 * I don't think this is nessesary, and it doesn't fix
+	 * the Xaccel-2.1 keyboard hang, but it can't hurt.		XXX
+	 */
+	while ((c = scgetc(sc, SCGETC_NONBLOCK, NULL)) != NOKEY) {
 
-	cur_tty = SC_DEV(sc, sc->cur_scp->index);
-	if (!tty_opened_ns(cur_tty))
-	    continue;
+		cur_tty = SC_DEV(sc, sc->cur_scp->index);
+		if (!tty_opened_ns(cur_tty))
+			continue;
 
-	if ((*sc->cur_scp->tsw->te_input)(sc->cur_scp, c, cur_tty))
-	    continue;
+		if ((*sc->cur_scp->tsw->te_input)(sc->cur_scp, c, cur_tty))
+			continue;
 
-	switch (KEYFLAGS(c)) {
-	case 0x0000: /* normal key */
-	    ttydisc_rint(cur_tty, KEYCHAR(c), 0);
-	    break;
-	case FKEY:  /* function key, return string */
-	    cp = (*sc->cur_scp->tsw->te_fkeystr)(sc->cur_scp, c);
-	    if (cp != NULL) {
-	    	ttydisc_rint_simple(cur_tty, cp, strlen(cp));
-		break;
-	    }
-	    cp = kbdd_get_fkeystr(thiskbd, KEYCHAR(c), &len);
-	    if (cp != NULL)
-	    	ttydisc_rint_simple(cur_tty, cp, len);
-	    break;
-	case MKEY:  /* meta is active, prepend ESC */
-	    ttydisc_rint(cur_tty, 0x1b, 0);
-	    ttydisc_rint(cur_tty, KEYCHAR(c), 0);
-	    break;
-	case BKEY:  /* backtab fixed sequence (esc [ Z) */
-	    ttydisc_rint_simple(cur_tty, "\x1B[Z", 3);
-	    break;
+		switch (KEYFLAGS(c)) {
+		case 0x0000: /* normal key */
+			ttydisc_rint(cur_tty, KEYCHAR(c), 0);
+			break;
+		case FKEY: /* function key, return string */
+			cp = (*sc->cur_scp->tsw->te_fkeystr)(sc->cur_scp, c);
+			if (cp != NULL) {
+				ttydisc_rint_simple(cur_tty, cp, strlen(cp));
+				break;
+			}
+			cp = kbdd_get_fkeystr(thiskbd, KEYCHAR(c), &len);
+			if (cp != NULL)
+				ttydisc_rint_simple(cur_tty, cp, len);
+			break;
+		case MKEY: /* meta is active, prepend ESC */
+			ttydisc_rint(cur_tty, 0x1b, 0);
+			ttydisc_rint(cur_tty, KEYCHAR(c), 0);
+			break;
+		case BKEY: /* backtab fixed sequence (esc [ Z) */
+			ttydisc_rint_simple(cur_tty, "\x1B[Z", 3);
+			break;
+		}
+
+		ttydisc_rint_done(cur_tty);
 	}
 
-	ttydisc_rint_done(cur_tty);
-    }
+	sc->cur_scp->status |= MOUSE_HIDDEN;
 
-    sc->cur_scp->status |= MOUSE_HIDDEN;
-
 done:
-    mtx_unlock(&Giant);
-    return (error);
+	mtx_unlock(&Giant);
+	return (error);
 }
 
 static int
 sctty_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
 {
-    int error;
-    int i;
-    struct cursor_attr *cap;
-    sc_softc_t *sc;
-    scr_stat *scp;
-    int s;
+	int error;
+	int i;
+	struct cursor_attr *cap;
+	sc_softc_t *sc;
+	scr_stat *scp;
+	int s;
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
-    int ival;
+	int ival;
 #endif
 
-    /* If there is a user_ioctl function call that first */
-    if (sc_user_ioctl) {
-	error = (*sc_user_ioctl)(tp, cmd, data, td);
+	/* If there is a user_ioctl function call that first */
+	if (sc_user_ioctl) {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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