Commit Graph

22 Commits

Author SHA1 Message Date
Jean-Sébastien Pédron
547e74a8be teken, vt(4): New callbacks to lock the terminal once
... to process input, instead of inside each smaller operations such as
appending a character or moving the cursor forward.

In other words, before we were doing (oversimplified):

  teken_input()
    <for each input character>
      vtterm_putchar()
        VTBUF_LOCK()
        VTBUF_UNLOCK()
      vtterm_cursor_position()
        VTBUF_LOCK()
        VTBUF_UNLOCK()

Now, we are doing:

  vtterm_pre_input()
    VTBUF_LOCK()
  teken_input()
    <for each input character>
      vtterm_putchar()
      vtterm_cursor_position()
  vtterm_post_input()
    VTBUF_UNLOCK()

The situation was even worse when the vtterm_copy() and vtterm_fill()
callbacks were involved.

The new callbacks are:
  * struct terminal_class->tc_pre_input()
  * struct terminal_class->tc_post_input()

They are called in teken_input(), surrounding the while() loop.

The goal is to improve input processing speed of vt(4). As a benchmark,
here is the time taken to write a text file of 360 000 lines (26 MiB) on
`ttyv0`:

  * vt(4), unmodified:      1500 ms
  * vt(4), with this patch: 1200 ms
  * syscons(4):              700 ms

This is on a Haswell laptop with a GENERIC-NODEBUG kernel.

At the same time, the locking is changed in the vt_flush() function
which is responsible to draw the text on screen. So instead of
(indirectly) using VTBUF_LOCK() just to read and reset the dirty area
of the internal buffer, the lock is held for about the entire function,
including the drawing part.

The change is mostly visible while content is scrolling fast: before,
lines could appear garbled while scrolling because the internal buffer
was accessed without locks (once the scrolling was finished, the output
was correct). Now, the scrolling appears correct.

In the end, the locking model is closer to what syscons(4) does.

Differential Revision:	https://reviews.freebsd.org/D15302
2018-05-16 09:01:02 +00:00
Ed Maste
e1734edf76 Implement "vidcontrol -h <history_size>" for vt(4)
PR:		210415
Submitted by:	Siva Mahadevan
Reviewed by:	ray (earlier)
MFC after:	1 month
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D11814
2017-12-05 22:19:59 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Ravi Pokala
07a4559495 Un-break vt(4) for {powerpc,powerpc64,sparc64} LINT kernel builds
The {powerpc,powerpc64,sparc64} LINT kernel builds fail with this error:

    sys/dev/vt/vt_buf.c:198: warning: 'vtbuf_htw' defined but not used

Move vtbuf_htw() inside the '#if SC_NO_CUTPASTE' block where it belongs, and
put it in the proper order.

This fixes the immedate issue w/ vt(4), but all three then fail on different
issues.

Reviewed by:	emaste
2017-02-15 17:33:03 +00:00
Aleksandr Rybalko
c0e295def7 o Reset mouse selection when new lines reach selection lines.
o Fix how selection handled on display.

Submitted by:	hselasky
Reviewed by:	hselasky, emaste(previous version)
Todo:		track mouse select direction.
2017-02-10 13:28:30 +00:00
Jean-Sébastien Pédron
da49f6bcc3 vt(4): Adjust the cursor position after changing the window size
A new terminal_set_cursor() is added: it wraps the existing
teken_set_cursor() function.

In vtbuf_grow(), the cursor position is adjusted at the end of the
function. In vt_change_font(), we call terminal_set_cursor() just after
terminal_set_winsize_blank(), while the terminal is mute.

This fixes a bug where, after loading a kernel video driver which
increases the terminal window size, the cursor remains at its old
position, in other words, in the middle of the display content.

PR:		194421
MFC after:	1 week
2014-11-01 17:05:15 +00:00
Bjoern A. Zeeb
a10068fdf5 Make gcc happy by initialising the variable only set in a couple of
case statements without a default.

MFC after:	2 days
X-MFC with:	r271871
2014-09-20 08:18:48 +00:00
Jean-Sébastien Pédron
1454439c13 vt(4): Rewrite history scrolling
It's now possible to scroll up the 500 hard-coded lines of history, not
just a fraction of them. For instance, one can reach the top of the boot
process.

Sometimes, when scrolling or when changing the screen size (by changing
the font or loading a KMS driver for instance), one could see the
history cycling (old content appeared below latest lines). This is
fixed.

Now, when the resolution changes are more lines can be shown, the
displayed area is adjusted so that, if the screen was filled with
content before, it's filled with content after as well: more history
is visible, instead of having blank lines below the previously visible
content.

MFC after:	3 days
2014-09-19 12:20:43 +00:00
Jean-Sébastien Pédron
c3a05e5422 vt(4): Remove vt_buf->vb_dirtymask
This structure and the associated functions were unused since the
implementation of vd_bitblt_text_t callbacks.

MFC after:	3 days
2014-09-19 11:02:44 +00:00
Aleksandr Rybalko
44f751a21e Fix stray char on paste.
Tested by:	dumbbell and me
MFC after:	1 week
2014-09-12 14:17:09 +00:00
Aleksandr Rybalko
13c6f8a053 spelling fixes
Submitted by:	"Sam Fourman Jr." <sfourman@gmail.com>
MFC after:	1 week
2014-09-10 11:27:33 +00:00
Jean-Sébastien Pédron
b7fe496196 vt(4): Change vb_history_size from "int" to "unsigned int"
CID:		1230002, 1230003
MFC after:	1 week
2014-08-29 08:16:31 +00:00
Jean-Sébastien Pédron
cb81897a72 vt(4): When creating a window buffer, fill it entirely
... not just the visible part.

This fixes a bug where, when switching from eg. vt_vga to vt_fb (ie. the
resolution goes up), the originally hidden, uninitialized area of the
buffer is displayed on the screen. This leads to a missing text cursor
when it's over an unitialized area.

This was also visible when selecting text: the uninitialized area was
not highlighted.

Internally, this area was zeroed: characters were all 0x00000000,
meaning the foreground and background color was black. Now, everything
is filled with a space with a gray foreground color, like the visible
area.

While here, remove the check for the mute flag and always use
TERMINAL_NORM_ATTR as the character attribute (ie. gray foreground,
black background).

MFC after:	1 week
2014-08-26 17:48:05 +00:00
Jean-Sébastien Pédron
82276bbb00 vt(4): Use the actual size of the mouse when marking its position as dirty
This fixes a bug where part of the cursor was not erased.

MFC after:	1 week
2014-08-22 17:09:31 +00:00
Jean-Sébastien Pédron
c6e1a98786 vt(4): Constify vt_buf argument of vtbuf_iscursor()
MFC after:	1 week
2014-08-21 18:26:32 +00:00
Jean-Sébastien Pédron
00c33067e1 vt(4): Add vtbuf_dirty*_locked() to lock vtbuf once, not twice
In several functions, vtbuf_putchar() in particular, the lock on vtbuf
is acquired twice:
    1. once by the said functions;
    2. once in vtbuf_dirty().

Now, vtbuf_dirty_locked() and vtbuf_dirty_cell_locked() allow to
acquire that lock only once.

This improves the input speed of vt(4). To measure the gain, a
50,000-lines file was displayed on the console using cat(1). The time
taken by cat(1) is reported below:
    o  On amd64, with vt_vga:
        - before: 1.0"
	- after:  0.5"
    o  On sparc64, with creator_vt:
        - before: 13.6"
	- after:  10.5"

MFC after:	1 week
2014-08-10 15:02:51 +00:00
Marius Strobl
7344ee184b In order to get vt(4) a bit closer to the feature set provided by sc(4),
implement options TERMINAL_{KERN,NORM}_ATTR. These are aliased to
SC_{KERNEL_CONS,NORM}_ATTR and like these latter, allow to change the
default colors of normal and kernel text respectively.
Note on the naming: Although affecting the output of vt(4), technically
kern/subr_terminal.c is primarily concerned with changing default colors
so it would be inconsistent to term these options VT_{KERN,NORM}_ATTR.
Actually, if the architecture and abstraction of terminal+teken+vt would
be perfect, dev/vt/* wouldn't be touched by this commit at all.

Reviewed by:	emaste
MFC after:	3 days
Sponsored by:	Bally Wulff Games & Entertainment GmbH
2014-06-27 19:57:57 +00:00
Ed Maste
7cd5ec40cf Update size in vt_grow if we don't have to reallocate
vt_grow may be called with a new size that's larger than previous but
does not require reallocation - for example, when the number of columns
is the same and new number of rows is less than the history size.
Prior to this change we would fail to update vb_scr_size, and then hit
a KASSERT when trying to write to the newly visible rows.

Sponsored by:	The FreeBSD Foundation
2014-05-29 21:10:33 +00:00
Ed Maste
ba23b43576 Correct KASSERT strings
Rows refer to height and cols to width.
2014-05-29 20:26:01 +00:00
Aleksandr Rybalko
8a25d54521 Fix scrollback.
Sponsored by:	The FreeBSD Foundation
2014-05-08 13:46:36 +00:00
Aleksandr Rybalko
0f49db6e47 Respect SC_NO_CUTPASTE option. It disable mouse cursor and cut/paste support
for vt(9). Note: /dev/sysmouse not affected.

Sponsored by:	The FreeBSD Foundation
2013-12-09 15:01:34 +00:00
Aleksandr Rybalko
27cf7d04ef Merge VT(9) project (a.k.a. newcons).
Reviewed by:	nwhitehorn
MFC_to_10_after:	re approval

Sponsored by:	The FreeBSD Foundation
2013-12-05 22:38:53 +00:00