freebsd-skq/sys/dev/syscons
Bruce Evans d91400bf98 Restore switching to a separate kernel terminal "input" state and extend
it to a separate state for each CPU.

Terminal "input" is user or kernel output.  Its state includes the current
parser state for escape sequences and multi-byte characters, and some
results of previous parsing (mainly attributes), and in teken the cursor
position, but not completed output.  This state must be switched for kernel
output since the kernel can preempt anything, including itself, and this
must not affect the preempted state more than necessary.  Since vty0 is
shared, it is necessary to affect the frame buffer and cursor position and
history, but escape sequences must not be affected and attributes for
further output must not be affected.

This used to work.  The syscons terminal state contained mainly the parser
state for escape sequences and attributes, but not the cursor position,
and was switched.  This was first broken by SMP and/or preemptive kernels.
Then there should really be a separate state for each thread, and one more
for ddb, or locking to prevent preemption.  Serialization of printf() helps.
But it is arcane that full syscons escape sequences mostly work in kernel
printf(), and I have never seen them used except by me to test this fix.
They worked perfectly except for the races, since "input" from the kernel
was not special in any way.

This was broken to use teken.  The general switch was removed, and the
kernel normal attribute was switched specially.  The kernel reverse
attribute (config option SC_CONS_REVERSE_ATTR) became unused, and is
still unusable because teken doesn't support default reverse attributes
(it used to only be used via the ANSI escape sequence to set reverse
video).

The only new difficulty for using teken seems to be that the cursor
position is in the "input" state, so it must be updated in the active
input state for each half of the switch.  Do this to complete the
restoration.

The per-CPU state is mainly to make per-CPU coloring work cleanly, at
a cost of some space.  Each CPU gets its own full set of attribute
(not just the current attribute) maintained in the usual way.  This
also reduces races from unserialized printf()s.  However, this gives
races for serialized printf()s that otherwise have none.  Nothing
prevents the CPU doing the a printf() changing in the middle of an
escape sequence.
2017-03-26 13:03:16 +00:00
..
apm
blank
daemon Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
dragon Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
fade
fire Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
green
logo Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
plasma Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
rain Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
snake
star Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
warp Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
scgfbrndr.c
schistory.c
scmouse.c Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
scterm-teken.c Restore switching to a separate kernel terminal "input" state and extend 2017-03-26 13:03:16 +00:00
scterm.c
scvesactl.c
scvgarndr.c
scvidctl.c Remove pc98 support completely. 2017-01-28 02:22:15 +00:00
scvtb.c
syscons.c Restore switching to a separate kernel terminal "input" state and extend 2017-03-26 13:03:16 +00:00
syscons.h Restore switching to a separate kernel terminal "input" state and extend 2017-03-26 13:03:16 +00:00
sysmouse.c [evdev] Adds evdev support to sysmouse(4) driver 2016-12-10 18:07:16 +00:00