Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Mar 2017 11:31:06 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315065 - head/sys/dev/syscons
Message-ID:  <201703111131.v2BBV6BM012427@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Sat Mar 11 11:31:06 2017
New Revision: 315065
URL: https://svnweb.freebsd.org/changeset/base/315065

Log:
  Add a scteken_set_cursor() (sc to teken) method and use it to fix
  some cases of initialization and resetting of the teken cursor position.
  (This bad name is consistent with others, but it is too easy to confuse
  with scteken_cursor() which goes in the opposite direction.)
  
  The following cases were broken:
  - for booting without a syscons console, the teken and sc positions for
    ttyv0 were (0, 0), but are supposed to be somewhere in the middle of
    the screen (after carefully preserved BIOS and loader messages) (at
    least if there is no mode switch that loses the messages).
  - after mode switches, the screen is cleared and the cursor is supposed to
    be moved to (0, 0), but it was only moved there for sc.
  
  The following case was hacked to work:
  - for booting with a syscons console, it was arranged that scteken_init()
    for the console could see a nonzero cursor position and adjust, although
    this broke the sc seeing it in the non-console case above.

Modified:
  head/sys/dev/syscons/scterm-teken.c
  head/sys/dev/syscons/syscons.c
  head/sys/dev/syscons/syscons.h

Modified: head/sys/dev/syscons/scterm-teken.c
==============================================================================
--- head/sys/dev/syscons/scterm-teken.c	Sat Mar 11 09:22:53 2017	(r315064)
+++ head/sys/dev/syscons/scterm-teken.c	Sat Mar 11 11:31:06 2017	(r315065)
@@ -62,6 +62,7 @@ static sc_term_default_attr_t	scteken_de
 static sc_term_clear_t		scteken_clear;
 static sc_term_input_t		scteken_input;
 static sc_term_fkeystr_t	scteken_fkeystr;
+static sc_term_set_cursor_t	scteken_set_cursor;
 static void			scteken_nop(void);
 
 typedef struct {
@@ -88,6 +89,7 @@ static sc_term_sw_t sc_term_scteken = {
 	(sc_term_notify_t *)scteken_nop,
 	scteken_input,
 	scteken_fkeystr,
+	scteken_set_cursor,
 };
 
 SCTERM_MODULE(scteken, sc_term_scteken);
@@ -140,13 +142,6 @@ scteken_init(scr_stat *scp, void **softc
 		tp.tp_row = scp->ysize;
 		tp.tp_col = scp->xsize;
 		teken_set_winsize(&ts->ts_teken, &tp);
-
-		if (scp->cursor_pos < scp->ysize * scp->xsize) {
-			/* Valid old cursor position. */
-			tp.tp_row = scp->cursor_pos / scp->xsize;
-			tp.tp_col = scp->cursor_pos % scp->xsize;
-			teken_set_cursor(&ts->ts_teken, &tp);
-		}
 		break;
 	}
 
@@ -234,6 +229,7 @@ scteken_clear(scr_stat *scp)
 {
 
 	sc_move_cursor(scp, 0, 0);
+	scteken_set_cursor(scp, 0, 0);
 	sc_vtb_clear(&scp->vtb, scp->sc->scr_map[0x20], SC_NORM_ATTR << 8);
 	mark_all(scp);
 }
@@ -296,6 +292,17 @@ scteken_fkeystr(scr_stat *scp, int c)
 }
 
 static void
+scteken_set_cursor(scr_stat *scp, int col, int row)
+{
+	teken_stat *ts = scp->ts;
+	teken_pos_t tp;
+
+	tp.tp_col = col;
+	tp.tp_row = row;
+	teken_set_cursor(&ts->ts_teken, &tp);
+}
+
+static void
 scteken_nop(void)
 {
 

Modified: head/sys/dev/syscons/syscons.c
==============================================================================
--- head/sys/dev/syscons/syscons.c	Sat Mar 11 09:22:53 2017	(r315064)
+++ head/sys/dev/syscons/syscons.c	Sat Mar 11 11:31:06 2017	(r315065)
@@ -3140,16 +3140,6 @@ scinit(int unit, int flags)
 	    init_scp(sc, sc->first_vty, scp);
 	    sc_vtb_init(&scp->vtb, VTB_MEMORY, scp->xsize, scp->ysize,
 			(void *)sc_buffer, FALSE);
-
-	    /* move cursors to the initial positions */
-	    if (col >= scp->xsize)
-		col = 0;
-	    if (row >= scp->ysize)
-		row = scp->ysize - 1;
-	    scp->xpos = col;
-	    scp->ypos = row;
-	    scp->cursor_pos = scp->cursor_oldpos = row*scp->xsize + col;
-
 	    if (sc_init_emulator(scp, SC_DFLT_TERM))
 		sc_init_emulator(scp, "*");
 	    (*scp->tsw->te_default_attr)(scp, SC_NORM_ATTR, SC_NORM_REV_ATTR);
@@ -3171,6 +3161,17 @@ scinit(int unit, int flags)
 	    sc_vtb_copy(&scp->scr, 0, &scp->vtb, 0, scp->xsize*scp->ysize);
 #endif
 
+	/* Sync h/w cursor position to s/w (sc and teken). */
+	if (col >= scp->xsize)
+	    col = 0;
+	if (row >= scp->ysize)
+	    row = scp->ysize - 1;
+	scp->xpos = col;
+	scp->ypos = row;
+	scp->cursor_pos = scp->cursor_oldpos = row*scp->xsize + col;
+	(*scp->tsw->te_set_cursor)(scp, col, row);
+
+	/* Sync BIOS cursor shape to s/w (sc only). */
 	if (bios_value.cursor_end < scp->font_size)
 	    sc->dflt_curs_attr.base = scp->font_size - 
 					  bios_value.cursor_end - 1;

Modified: head/sys/dev/syscons/syscons.h
==============================================================================
--- head/sys/dev/syscons/syscons.h	Sat Mar 11 09:22:53 2017	(r315064)
+++ head/sys/dev/syscons/syscons.h	Sat Mar 11 11:31:06 2017	(r315065)
@@ -394,6 +394,7 @@ typedef void	sc_term_notify_t(scr_stat *
 #define SC_TE_NOTIFY_VTSWITCH_OUT	1
 typedef int	sc_term_input_t(scr_stat *scp, int c, struct tty *tp);
 typedef const char *sc_term_fkeystr_t(scr_stat *scp, int c);
+typedef void sc_term_set_cursor_t(scr_stat *scp, int col, int row);
 
 typedef struct sc_term_sw {
 	LIST_ENTRY(sc_term_sw)	link;
@@ -412,6 +413,7 @@ typedef struct sc_term_sw {
 	sc_term_notify_t	*te_notify;
 	sc_term_input_t		*te_input;
 	sc_term_fkeystr_t	*te_fkeystr;
+	sc_term_set_cursor_t	*te_set_cursor;
 } sc_term_sw_t;
 
 #define SCTERM_MODULE(name, sw)					\



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