Home | History | Annotate | Download | only in wscons
History log of /src/sys/dev/wscons/wsemul_vt100.c
RevisionDateAuthorComments
 1.52  02-Aug-2023  uwe wsemul_vt100: fix RI to not scroll outside of scroll region

This is the inverse (scroll down) of the problem reported and fixed
for IND (scroll up) in PR kern/11827 back in 2000.

We only have one call site for this, but still move this bit of code
into a separate wsemul_vt100_prevline function to make it symmetric
with wsemul_vt100_nextline. While here, make both take vt100base_data.
 1.51  16-Jul-2023  christos Avoid overflow with too many ';' (David Leadbeater)
Prefix all messages with the method name
 1.50  23-Feb-2023  riastradh wscons(4): Paranoia: Clamp numbers of rows and columns.
 1.49  02-Jan-2022  uwe branches: 1.49.4;
wsemul_vt100.c - make static everything that can be static

Externally, wsdisplay only needs wsemul_vt100_ops. Internally (as
vt100 emulation is split into several files) wsemul_vt100_subr.c needs
wsemul_vt100_reset().
 1.48  07-Jun-2021  christos fix the NetBSD tag.
 1.47  07-Jun-2021  christos PR/56223: David Shao ^[]8;;^G make console unresponsive. From OpenBSD:
In `string' state, accept bell (^G) as an end of sequence in addition to
`ESC \', as supported by xterm; some third-party software such as
ncmpcpp rely upon this.
 1.46  10-Nov-2019  chs branches: 1.46.12;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.45  03-Sep-2018  riastradh branches: 1.45.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.44  21-Jan-2018  martin branches: 1.44.2; 1.44.4;
Try to fix previous to make it compile.
 1.43  21-Jan-2018  christos make check cleaner, and simplify the code.
 1.42  20-Jan-2018  rin Correct wrong assertion code introduced by rev 1.41:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wscons/wsemul_vt100.c#rev1.41

Fix kernel panic reported in PR kern/52935.
 1.41  03-Nov-2017  maya Use __arraycount a bunch
Also, DIAGNOSTIC panic -> KASSERT
 1.40  03-Nov-2017  maya Use c99 initializer for wsemul_ops
 1.39  03-Nov-2017  maya Don't #ifdef DIAGNOSTIC around KASSERTs.

the definition of KASSERT does the same thing
 1.38  19-May-2017  macallan add support for loading fonts in vcons and subsequently resizing screens
- drivers can use this by setting VCONS_LOADFONT and WSSCREEN_RESIZE
- each vcons screen can now have its own font and geometry
- while there, add support for xterm's ESC[18t to report the text buffer's
size

With this tou can:
wsfontload -N foo /usr/share/wscons/fonts/flori.816
wsconsctl -dw font=foo
currently this is limited to drivers that don't use the glyph cache, like genfb
 1.37  24-Aug-2015  pooka to garnish, dust with _KERNEL_OPT
 1.36  19-Oct-2013  mrg branches: 1.36.6;
use __USE() where appropriate.
 1.35  11-Feb-2010  drochner branches: 1.35.10; 1.35.20; 1.35.24;
put back the "vt100base_data" variable which was souce of confusion,
it is really needed, as noted by Geoff Wing
 1.34  10-Feb-2010  skrll Remove accidental commit.
 1.33  10-Feb-2010  skrll Oops. Whitespace in previous.
 1.32  10-Feb-2010  drochner Allow big parts of the vt100 emulation code (what is in
wsemul_vt100_subr.c) to be used by alternative terminal emulators
(which are not in-tree yet but can be loaded as LKMs).
For this, split out that part of the state structure which is used
by the sharable code and include that in the original vt100 state.
This is only a query-replace and sed(1) job for now, it makes sense
to rearrange things a bit so that even more code can be changed --
will do so later.
 1.31  18-Feb-2009  snj branches: 1.31.2;
s/portugese/portuguese/, spotted by Ari Constancio in PR misc/40202.
 1.30  16-Nov-2006  christos branches: 1.30.52; 1.30.62; 1.30.64; 1.30.68; 1.30.70; 1.30.74;
__unused removal on arguments; approved by core.
 1.29  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.28  11-Dec-2005  christos branches: 1.28.20; 1.28.22;
merge ktrace-lwp.
 1.27  27-Feb-2005  perry branches: 1.27.4;
nuke trailing whitespace
 1.26  28-Jul-2004  jmmv branches: 1.26.4; 1.26.6;
Implement support to dynamically change wscons console and kernel colors.

Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").

A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.

Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.

wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.

Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
 1.25  24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.24  19-Apr-2003  christos branches: 1.24.2;
PR/17738: Matthias Drochner, PR/21230: Onno van der Linden: vt100 wscons
crashes restoring cursor. Fixed by adding a flag as suggested.
 1.23  11-Feb-2003  drochner stylistic change: put variable declarations to the top of a function
 1.22  05-Jan-2003  sommerfeld Fix build glitch.
 1.21  05-Jan-2003  sommerfeld When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.
Should fix kern/11827
 1.20  27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.19  09-Jul-2002  junyoung switch/case KNF.
 1.18  04-Jul-2002  junyoung alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.17  12-Jan-2002  tsutsui branches: 1.17.8; 1.17.10;
Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.16  13-Nov-2001  lukem add/cleanup RCSIDs
 1.15  13-Oct-2001  augustss ANSIfy.
 1.14  21-Feb-2001  jdolecek branches: 1.14.2; 1.14.4;
don't panic if there is ESC in kernel output, just print a warning and
ignore the ESC; also remove the #ifdef DIAGNOSTIC
 1.13  28-Apr-2000  mycroft branches: 1.13.4;
Add a concept of the `background attribute'. This is the same as the
current attribute, but has all non-color flags turned off. Use this when
doing erasure, as this allows us to optimize repainting in curses.

XXX The way the default attribute is handled is totally bogus and needs to
be fixed.
 1.12  03-Nov-1999  mycroft Only update the cursor state if it's enabled.
 1.11  10-Mar-1999  drochner branches: 1.11.8; 1.11.10; 1.11.12;
don't erase the characters moved over on a <TAB>, a real VT100 doesn't
do this - thanks Bill Sommerfeld (PR kern/7124)
 1.10  17-Jan-1999  drochner define a "clear screen" command to the emulator and complete the
emulation's "reset" implementations as far as useful
 1.9  13-Jan-1999  drochner export functions to reset the emulator and the character mappings
 1.8  10-Jan-1999  augustss Change from bcopy/bzero to memxxx. From PR 6778 by
Erik Bertelsen <erik@q610.ebe.uni-c.dk>.
 1.7  12-Aug-1998  drochner Separate special character handling from normal output so that they
are obeyed even during an escape sequence.
This is how the original VT100 behaves.
 1.6  29-Jun-1998  drochner don't set a tabstop in column 1
 1.5  29-Jun-1998  drochner fix gcc unused variable warning
From Matthias Scheler <tron@lyssa.owl.de>.
 1.4  26-Jun-1998  drochner Fix initialization in console case: use the paramerters which were passed
in the cninit() call - the new ones are not useful.
 1.3  26-Jun-1998  drochner Improvements to the VT100 emulation:
-display DEC special graphics and DEC technical characters as far as
possible
-implement the font switching controls (need documentation!)
-behave well if double-width characters are requested
-simplify the state machine: store CSI command modifiers in variables
instead of dedicating own states to each of them
 1.2  20-Jun-1998  drochner Change the calling interface for text output (to the graphics driver)
to take a single character at a time, where the character is an "int" now.
The old interface (took a string) was never called with more than 1
char to print, and the "int" allows us to handle charsets cleanly.
 1.1  20-Jun-1998  drochner First cut on a VT100 emulation.
It should be able to parse escape sequences up to VT300, but not everything
is implemented. Most notably, there is no font handling - all displayable
characters are handed to the graphics driver. To solve this, a serious
interface change to the graphics driver is needed (Unicode?).
 1.11.12.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.10.1  15-Nov-1999  fvdl Sync with -current
 1.11.8.2  12-Mar-2001  bouyer Sync with HEAD.
 1.11.8.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.4.1  27-May-2003  msaitoh Pullup rev. 1.24 via patch (requested by drochner in ticket #43)
vt100 wscons crashes restoring cursor. Fixed by adding a flag as suggested.
Fixes PR#17738, PR#21230
 1.14.4.4  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.14.4.3  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.14.4.2  11-Feb-2002  jdolecek Sync w/ -current.
 1.14.4.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.6  07-Jan-2003  thorpej Sync with HEAD.
 1.14.2.5  18-Oct-2002  nathanw Catch up to -current.
 1.14.2.4  01-Aug-2002  nathanw Catch up to -current.
 1.14.2.3  28-Feb-2002  nathanw Catch up to -current.
 1.14.2.2  14-Nov-2001  nathanw Catch up to -current.
 1.14.2.1  22-Oct-2001  nathanw Catch up to -current.
 1.17.10.1  16-Jun-2003  grant Apply patch (requested by drochner in ticket #1277):

fix crash due to wrong argument in the (almost useless)
DECRQUPSS escape sequence

PR/17738: Matthias Drochner, PR/21230: Onno van der Linden: vt100 wscons
crashes restoring cursor. Fixed by adding a flag as suggested.
 1.17.8.1  15-Jul-2002  gehenna catch up with -current.
 1.24.2.4  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.24.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.24.2.1  03-Aug-2004  skrll Sync with HEAD
 1.26.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.26.4.1  29-Apr-2005  kent sync with -current
 1.27.4.1  30-Dec-2006  yamt sync with head.
 1.28.22.2  10-Dec-2006  yamt sync with head.
 1.28.22.1  22-Oct-2006  yamt sync with head
 1.28.20.1  18-Nov-2006  ad Sync with head.
 1.30.74.1  21-Mar-2012  jdc Pull up revisions (requested by bouyer in ticket #1727):
src/sys/dev/wscons/wsemul_vt100.c 1.31
src/sys/dev/wscons/wsemul_vt100_chars.c 1.12
src/sys/dev/wscons/wsksymdef.h 1.62

s/portugese/portuguese/, spotted by Ari Constancio in PR misc/40202.
 1.30.70.1  21-Mar-2012  jdc Pull up revisions (requested by bouyer in ticket #1727):
src/sys/dev/wscons/wsemul_vt100.c 1.31
src/sys/dev/wscons/wsemul_vt100_chars.c 1.12
src/sys/dev/wscons/wsksymdef.h 1.62

s/portugese/portuguese/, spotted by Ari Constancio in PR misc/40202.
 1.30.68.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.30.64.1  21-Mar-2012  jdc Pull up revisions (requested by bouyer in ticket #1727):
src/sys/dev/wscons/wsemul_vt100.c 1.31
src/sys/dev/wscons/wsemul_vt100_chars.c 1.12
src/sys/dev/wscons/wsksymdef.h 1.62

s/portugese/portuguese/, spotted by Ari Constancio in PR misc/40202.
 1.30.62.1  03-Mar-2009  skrll Sync with HEAD.
 1.30.52.2  11-Mar-2010  yamt sync with head
 1.30.52.1  04-May-2009  yamt sync with head.
 1.31.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.35.24.1  18-May-2014  rmind sync with head
 1.35.20.2  03-Dec-2017  jdolecek update from HEAD
 1.35.20.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.10.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.36.6.2  28-Aug-2017  skrll Sync with HEAD
 1.36.6.1  22-Sep-2015  skrll Sync with HEAD
 1.44.4.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.44.4.1  10-Jun-2019  christos Sync with HEAD
 1.44.2.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.45.4.1  29-Nov-2023  martin Pull up following revision(s) (requested by gutteridge in ticket #1772):

sys/dev/wscons/wsemul_vt100.c: revision 1.47
sys/dev/wscons/wsemul_vt100.c: revision 1.48

PR/56223: David Shao ^[]8;;^G make console unresponsive. From OpenBSD:

In `string' state, accept bell (^G) as an end of sequence in addition to
`ESC \', as supported by xterm; some third-party software such as
ncmpcpp rely upon this.

fix the NetBSD tag.
 1.46.12.1  17-Jun-2021  thorpej Sync w/ HEAD.
 1.49.4.1  30-Jul-2023  martin Pull up following revision(s) (requested by uwe in ticket #257):
sys/dev/wscons/wsemul_vt100_subr.c: revision 1.25
sys/dev/wscons/wsemul_vt100_subr.c: revision 1.26
sys/dev/wscons/wsemul_vt100_subr.c: revision 1.27
sys/dev/wscons/wsemul_vt100_subr.c: revision 1.28
sys/dev/wscons/wsemul_vt100_subr.c: revision 1.29
sys/dev/wscons/wsemul_vt100.c: revision 1.50
sys/dev/wscons/wsemul_vt100.c: revision 1.51
sys/dev/wscons/wsemul_vt100_subr.c: revision 1.30
sys/dev/wscons/wsemul_vt100_subr.c: revision 1.31

Fix off by one (Crystal Kolipe in tech-kern@)

Add rin, indn, vpa, hpa, and cbt terminfo capabilities (Crystal Kolipe)

wscons(4): Ignore nonsense tab stops in vt100 emulation.

wscons(4): Paranoia: Clamp numbers of rows and columns.

wsemul_vt100_subr: don't assert unsigned ncols >= 0

wsemul_vt100_subr: spell edp->tabs assertion with NULL

Avoid overflow with too many ';' (David Leadbeater)

Prefix all messages with the method name

wsemul_vt100_subr: complete the refactoring from 2010
In 1.20 refactoring, functions in this file were changed to accept a
pointer to the new base class instead of the full emuldata:
-wsemul_vt100_foo(struct wsemul_vt100_emuldata *edp, ...)
+wsemul_vt100_foo(struct vt100base_data *edp, ...)
but the argument name was not changed. While this saved on the diff
churn back then, it created a rather unfortunate situation where the
same emulation state variables are referred to differently in this
file and other vt100 emulation files. Complete that old change by
renaming the base class arguments to match the variable name used for
it in other files.

Same object code is generated.

RSS XML Feed