History log of /openbsd-current/sys/dev/wscons/wsemul_vt100.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.47 02-Aug-2023 miod

Minor changes to reduce differences between vt100 and sun emulations. NFCI


# 1.46 24-Jul-2023 miod

Make sure we do not increase the escape sequence argument count beyond usable
bounds, in case escape sequences end up with too many semicolons.
Without this, the kernel could be made to access random memory after receiving
some specially crafted DCS or CSI terminal escape sequences.

Reported by David Leadbeater (dgl, dgl dot cx)


Revision tags: OPENBSD_7_3_BASE
# 1.45 06-Mar-2023 miod

branches: 1.45.4;
Correctly account the number of bytes processed when outputting UTF-8 encoded
characters.


# 1.44 06-Mar-2023 miod

Replace old'n'wrong UTF-8 logic with a better one borrowed from Citrus;
issue reported by Crystal Kolipe on tech@


# 1.43 26-Feb-2023 miod

Add a few missing bounds checks when processing terminal escape sequences.
Without them, the kernel could be made to crash or reboot after receiving some
specially crafted terminal escape sequences.

Reported by David Leadbeater (dgl, dgl dot cx)


# 1.42 12-Jan-2023 nicm

Disable double width and height escape sequences under SMALL_KERNEL.

ok miod


# 1.41 12-Jan-2023 miod

free(NULL) has been allowed in the kernel since 5.4; remove checks.


# 1.40 09-Jan-2023 nicm

DIAGNOSTIC is redundant with KASSERT, remove it. From Crystal Kolipe.

ok guenther


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.39 25-May-2020 jsg

branches: 1.39.8; 1.39.10;
change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.38 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_6_7_BASE
# 1.37 22-Mar-2020 anton

zap trailing whitespace


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.36 10-Aug-2017 fcambus

Remove some case statements which have been compiled out since 2000.

OK mpi@


# 1.35 11-Apr-2017 dhill

Partially revert previous mallocarray conversions that contain
constants.

The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@

ok deraadt@


# 1.34 09-Apr-2017 dhill

Convert some malloc(9) to mallocarray(9)

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.33 28-Aug-2015 deraadt

fairly simple sizes for free(); ok tedu


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.31 18-Oct-2013 miod

UTF-8 support for wsdisplay emulation modes. Both vt100 and sun emulation
will now recognize xterm-compatible escape sequences ESC % G and ESC % @ to
enter and leave UTF-8 mode, respectively.

Not enabled on SMALL_KERNEL.

Most of this written during c2k7, completed during b2k13.

Note that the value of several international keysyms change, to switch from
ISO Latin-[257] values to the real Unicode values. Be sure to update your
includes and rebuild and install wsconsctl.


# 1.30 18-Oct-2013 miod

Introduce a dedicated private header file to control the optional features
of wscons (which usually get disabled for installation kernels, to save
space), instead of duplicating parts of it to too many places.

No functional change.


Revision tags: OPENBSD_5_4_BASE
# 1.29 16-Jun-2013 miod

Use (N * sizeof(u_int)) instead of (N * sizeof(int)) when malloc'ing u_int *.
Doesn't change anything, but silences a Clang warning; dhill@bitrig


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.28 04-Aug-2011 miod

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.
Noticed by dcoppa@, based on a draft diff by nicm@; ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.27 01-Sep-2010 nicm

After all escape sequence processing, check for being beyond the last
column and and clear VTFL_LASTCHAR if so.

This fixes the case where an escape sequence (originally noticed with
DECSTBM) moves the cursor and doesn't reset the flag - if it was set,
there would be a spurious line feed on the next input.

ok miod


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 05-Sep-2009 miod

Check the return value of all emulops in the emulation code, and abort
tty output as soon as we hit a failure.

Since the `output' of a character may cause several emulops to be called
(e.g. if it causes scrollup or if this is the end of an escape sequence),
all emulation code maintain a so-called `abort state', to be able to properly
recover when the character is tentatively output later, and not reissue
the emulops which did not fail the first time.

With help from mglocker@


# 1.25 05-Sep-2009 miod

Make the output() wsemul_op return the number of characters processed and
check it in wsdisplaystart() to suspend output if not all characters have
been output; they will get reissued at the next tty rstrt_to timeout.


# 1.24 05-Sep-2009 miod

Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 12-Jan-2009 miod

Recognize CAN and SUB control characters, and cancel any current escape
sequence when they appear. Per VT100 manual via naddy@, ok naddy@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 27-Nov-2007 miod

Remove whitespace at EOL, KNF, ansify. Move jump scroll code to a separate
routine. No functional change (har, har)


# 1.21 25-Nov-2007 miod

Ask the emulation code to hide the cursor when leaving emulation mode. This
way we do not get a phantom cursor image when X exits.


# 1.20 11-Sep-2007 gilles

KNF

prompted and "much better" by marco@, ok pyr@


# 1.19 10-Sep-2007 gilles

more MALLOC/FREE -> malloc/free and M_ZERO changes

ok pyr@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.18 14-Feb-2007 jsg

FALLTHRU -> FALLTHROUGH for consistency.
Suggested by miod@


# 1.17 07-Jan-2007 miod

Some dynamically allocated elements are not considered of vital importance
for the vt100 emulation to work well enough for most cases (i.e. alternate
character set tables, non-default tab settings, etc).

However, code did not always check if these elements had been successfully
allocated before trying to use them, or worse, would explicitely panic in
DIAGNOSTIC kernels.

Change this to work in a degraded mode (by ignoring related escape sequences)
instead.


# 1.16 07-Jan-2007 miod

Change allocations to M_NOWAIT in attach methods, and return NULL if they fail.


# 1.15 19-Oct-2006 dim

Fix hopefully the last wscons jump scrolling glitch, which can occur
in case autowrapping is on, and control characters other than BS, CR,
HT are encountered.

Righto! miod@, also verified by Paul Stoeber.


# 1.14 09-Oct-2006 miod

Fix jump scroll glitch, reported by dim@ and Paul Stoeber.


Revision tags: OPENBSD_4_0_BASE
# 1.13 17-Aug-2006 miod

Jump scroll support for vt100 and sun wscons emulations, helps macppc and
zaurus a lot, tested by many; ok deraadt@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 25-Dec-2004 deraadt

correct indent


# 1.11 23-Dec-2004 miod

vt100 wscons crashes restoring cursor if it had never been saved before.

From NetBSD (wsemul_vt100.c 1.24, wsemul_vt100var.h 1.7)


# 1.10 23-Dec-2004 miod

Reliability fix, from NetBSD:
When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.9 02-Apr-2004 deraadt

remove terms 3 & 4 for drochner@NetBSD.org; as seen on netbsd lists


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A UBC_SYNC_B
# 1.8 12-Oct-2002 krw

Remove more '\n's from panic() statements. Both trailing and leading.

Diff generated by Chris Kuethe.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE UBC_BASE
# 1.6 14-Apr-2001 aaron

branches: 1.6.4; 1.6.8;
Remove some static.


# 1.5 07-Mar-2001 aaron

Instead of panic'ing when an ESC is found in kernel output, print a warning
and ignore it; from NetBSD.


# 1.4 20-Feb-2001 deraadt

default to kernel messages blue


# 1.3 10-Feb-2001 mickey

sync w/ netbsd; aaron@ ok


Revision tags: OPENBSD_2_8_BASE
# 1.2 01-Aug-2000 mickey

update wscons, nothing serious, mostly api fixes for us; from netbsd through aaron@


# 1.1 16-May-2000 mickey

import newer wscons source from netbsd.
art@ said it will make his life easier in alpha
rhands@ said it is not used in powerpc for now
bjc@ said that it would make vax port easier
mickey@ said other platforms can use it, and it's faster


# 1.46 24-Jul-2023 miod

Make sure we do not increase the escape sequence argument count beyond usable
bounds, in case escape sequences end up with too many semicolons.
Without this, the kernel could be made to access random memory after receiving
some specially crafted DCS or CSI terminal escape sequences.

Reported by David Leadbeater (dgl, dgl dot cx)


Revision tags: OPENBSD_7_3_BASE
# 1.45 06-Mar-2023 miod

branches: 1.45.4;
Correctly account the number of bytes processed when outputting UTF-8 encoded
characters.


# 1.44 06-Mar-2023 miod

Replace old'n'wrong UTF-8 logic with a better one borrowed from Citrus;
issue reported by Crystal Kolipe on tech@


# 1.43 26-Feb-2023 miod

Add a few missing bounds checks when processing terminal escape sequences.
Without them, the kernel could be made to crash or reboot after receiving some
specially crafted terminal escape sequences.

Reported by David Leadbeater (dgl, dgl dot cx)


# 1.42 12-Jan-2023 nicm

Disable double width and height escape sequences under SMALL_KERNEL.

ok miod


# 1.41 12-Jan-2023 miod

free(NULL) has been allowed in the kernel since 5.4; remove checks.


# 1.40 09-Jan-2023 nicm

DIAGNOSTIC is redundant with KASSERT, remove it. From Crystal Kolipe.

ok guenther


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.39 25-May-2020 jsg

branches: 1.39.8; 1.39.10;
change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.38 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_6_7_BASE
# 1.37 22-Mar-2020 anton

zap trailing whitespace


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.36 10-Aug-2017 fcambus

Remove some case statements which have been compiled out since 2000.

OK mpi@


# 1.35 11-Apr-2017 dhill

Partially revert previous mallocarray conversions that contain
constants.

The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@

ok deraadt@


# 1.34 09-Apr-2017 dhill

Convert some malloc(9) to mallocarray(9)

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.33 28-Aug-2015 deraadt

fairly simple sizes for free(); ok tedu


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.31 18-Oct-2013 miod

UTF-8 support for wsdisplay emulation modes. Both vt100 and sun emulation
will now recognize xterm-compatible escape sequences ESC % G and ESC % @ to
enter and leave UTF-8 mode, respectively.

Not enabled on SMALL_KERNEL.

Most of this written during c2k7, completed during b2k13.

Note that the value of several international keysyms change, to switch from
ISO Latin-[257] values to the real Unicode values. Be sure to update your
includes and rebuild and install wsconsctl.


# 1.30 18-Oct-2013 miod

Introduce a dedicated private header file to control the optional features
of wscons (which usually get disabled for installation kernels, to save
space), instead of duplicating parts of it to too many places.

No functional change.


Revision tags: OPENBSD_5_4_BASE
# 1.29 16-Jun-2013 miod

Use (N * sizeof(u_int)) instead of (N * sizeof(int)) when malloc'ing u_int *.
Doesn't change anything, but silences a Clang warning; dhill@bitrig


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.28 04-Aug-2011 miod

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.
Noticed by dcoppa@, based on a draft diff by nicm@; ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.27 01-Sep-2010 nicm

After all escape sequence processing, check for being beyond the last
column and and clear VTFL_LASTCHAR if so.

This fixes the case where an escape sequence (originally noticed with
DECSTBM) moves the cursor and doesn't reset the flag - if it was set,
there would be a spurious line feed on the next input.

ok miod


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 05-Sep-2009 miod

Check the return value of all emulops in the emulation code, and abort
tty output as soon as we hit a failure.

Since the `output' of a character may cause several emulops to be called
(e.g. if it causes scrollup or if this is the end of an escape sequence),
all emulation code maintain a so-called `abort state', to be able to properly
recover when the character is tentatively output later, and not reissue
the emulops which did not fail the first time.

With help from mglocker@


# 1.25 05-Sep-2009 miod

Make the output() wsemul_op return the number of characters processed and
check it in wsdisplaystart() to suspend output if not all characters have
been output; they will get reissued at the next tty rstrt_to timeout.


# 1.24 05-Sep-2009 miod

Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 12-Jan-2009 miod

Recognize CAN and SUB control characters, and cancel any current escape
sequence when they appear. Per VT100 manual via naddy@, ok naddy@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 27-Nov-2007 miod

Remove whitespace at EOL, KNF, ansify. Move jump scroll code to a separate
routine. No functional change (har, har)


# 1.21 25-Nov-2007 miod

Ask the emulation code to hide the cursor when leaving emulation mode. This
way we do not get a phantom cursor image when X exits.


# 1.20 11-Sep-2007 gilles

KNF

prompted and "much better" by marco@, ok pyr@


# 1.19 10-Sep-2007 gilles

more MALLOC/FREE -> malloc/free and M_ZERO changes

ok pyr@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.18 14-Feb-2007 jsg

FALLTHRU -> FALLTHROUGH for consistency.
Suggested by miod@


# 1.17 07-Jan-2007 miod

Some dynamically allocated elements are not considered of vital importance
for the vt100 emulation to work well enough for most cases (i.e. alternate
character set tables, non-default tab settings, etc).

However, code did not always check if these elements had been successfully
allocated before trying to use them, or worse, would explicitely panic in
DIAGNOSTIC kernels.

Change this to work in a degraded mode (by ignoring related escape sequences)
instead.


# 1.16 07-Jan-2007 miod

Change allocations to M_NOWAIT in attach methods, and return NULL if they fail.


# 1.15 19-Oct-2006 dim

Fix hopefully the last wscons jump scrolling glitch, which can occur
in case autowrapping is on, and control characters other than BS, CR,
HT are encountered.

Righto! miod@, also verified by Paul Stoeber.


# 1.14 09-Oct-2006 miod

Fix jump scroll glitch, reported by dim@ and Paul Stoeber.


Revision tags: OPENBSD_4_0_BASE
# 1.13 17-Aug-2006 miod

Jump scroll support for vt100 and sun wscons emulations, helps macppc and
zaurus a lot, tested by many; ok deraadt@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 25-Dec-2004 deraadt

correct indent


# 1.11 23-Dec-2004 miod

vt100 wscons crashes restoring cursor if it had never been saved before.

From NetBSD (wsemul_vt100.c 1.24, wsemul_vt100var.h 1.7)


# 1.10 23-Dec-2004 miod

Reliability fix, from NetBSD:
When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.9 02-Apr-2004 deraadt

remove terms 3 & 4 for drochner@NetBSD.org; as seen on netbsd lists


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A UBC_SYNC_B
# 1.8 12-Oct-2002 krw

Remove more '\n's from panic() statements. Both trailing and leading.

Diff generated by Chris Kuethe.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE UBC_BASE
# 1.6 14-Apr-2001 aaron

branches: 1.6.4; 1.6.8;
Remove some static.


# 1.5 07-Mar-2001 aaron

Instead of panic'ing when an ESC is found in kernel output, print a warning
and ignore it; from NetBSD.


# 1.4 20-Feb-2001 deraadt

default to kernel messages blue


# 1.3 10-Feb-2001 mickey

sync w/ netbsd; aaron@ ok


Revision tags: OPENBSD_2_8_BASE
# 1.2 01-Aug-2000 mickey

update wscons, nothing serious, mostly api fixes for us; from netbsd through aaron@


# 1.1 16-May-2000 mickey

import newer wscons source from netbsd.
art@ said it will make his life easier in alpha
rhands@ said it is not used in powerpc for now
bjc@ said that it would make vax port easier
mickey@ said other platforms can use it, and it's faster


# 1.45 06-Mar-2023 miod

Correctly account the number of bytes processed when outputting UTF-8 encoded
characters.


# 1.44 06-Mar-2023 miod

Replace old'n'wrong UTF-8 logic with a better one borrowed from Citrus;
issue reported by Crystal Kolipe on tech@


# 1.43 26-Feb-2023 miod

Add a few missing bounds checks when processing terminal escape sequences.
Without them, the kernel could be made to crash or reboot after receiving some
specially crafted terminal escape sequences.

Reported by David Leadbeater (dgl, dgl dot cx)


# 1.42 12-Jan-2023 nicm

Disable double width and height escape sequences under SMALL_KERNEL.

ok miod


# 1.41 12-Jan-2023 miod

free(NULL) has been allowed in the kernel since 5.4; remove checks.


# 1.40 09-Jan-2023 nicm

DIAGNOSTIC is redundant with KASSERT, remove it. From Crystal Kolipe.

ok guenther


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.39 25-May-2020 jsg

branches: 1.39.8; 1.39.10;
change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.38 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_6_7_BASE
# 1.37 22-Mar-2020 anton

zap trailing whitespace


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.36 10-Aug-2017 fcambus

Remove some case statements which have been compiled out since 2000.

OK mpi@


# 1.35 11-Apr-2017 dhill

Partially revert previous mallocarray conversions that contain
constants.

The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@

ok deraadt@


# 1.34 09-Apr-2017 dhill

Convert some malloc(9) to mallocarray(9)

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.33 28-Aug-2015 deraadt

fairly simple sizes for free(); ok tedu


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.31 18-Oct-2013 miod

UTF-8 support for wsdisplay emulation modes. Both vt100 and sun emulation
will now recognize xterm-compatible escape sequences ESC % G and ESC % @ to
enter and leave UTF-8 mode, respectively.

Not enabled on SMALL_KERNEL.

Most of this written during c2k7, completed during b2k13.

Note that the value of several international keysyms change, to switch from
ISO Latin-[257] values to the real Unicode values. Be sure to update your
includes and rebuild and install wsconsctl.


# 1.30 18-Oct-2013 miod

Introduce a dedicated private header file to control the optional features
of wscons (which usually get disabled for installation kernels, to save
space), instead of duplicating parts of it to too many places.

No functional change.


Revision tags: OPENBSD_5_4_BASE
# 1.29 16-Jun-2013 miod

Use (N * sizeof(u_int)) instead of (N * sizeof(int)) when malloc'ing u_int *.
Doesn't change anything, but silences a Clang warning; dhill@bitrig


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.28 04-Aug-2011 miod

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.
Noticed by dcoppa@, based on a draft diff by nicm@; ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.27 01-Sep-2010 nicm

After all escape sequence processing, check for being beyond the last
column and and clear VTFL_LASTCHAR if so.

This fixes the case where an escape sequence (originally noticed with
DECSTBM) moves the cursor and doesn't reset the flag - if it was set,
there would be a spurious line feed on the next input.

ok miod


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 05-Sep-2009 miod

Check the return value of all emulops in the emulation code, and abort
tty output as soon as we hit a failure.

Since the `output' of a character may cause several emulops to be called
(e.g. if it causes scrollup or if this is the end of an escape sequence),
all emulation code maintain a so-called `abort state', to be able to properly
recover when the character is tentatively output later, and not reissue
the emulops which did not fail the first time.

With help from mglocker@


# 1.25 05-Sep-2009 miod

Make the output() wsemul_op return the number of characters processed and
check it in wsdisplaystart() to suspend output if not all characters have
been output; they will get reissued at the next tty rstrt_to timeout.


# 1.24 05-Sep-2009 miod

Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 12-Jan-2009 miod

Recognize CAN and SUB control characters, and cancel any current escape
sequence when they appear. Per VT100 manual via naddy@, ok naddy@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 27-Nov-2007 miod

Remove whitespace at EOL, KNF, ansify. Move jump scroll code to a separate
routine. No functional change (har, har)


# 1.21 25-Nov-2007 miod

Ask the emulation code to hide the cursor when leaving emulation mode. This
way we do not get a phantom cursor image when X exits.


# 1.20 11-Sep-2007 gilles

KNF

prompted and "much better" by marco@, ok pyr@


# 1.19 10-Sep-2007 gilles

more MALLOC/FREE -> malloc/free and M_ZERO changes

ok pyr@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.18 14-Feb-2007 jsg

FALLTHRU -> FALLTHROUGH for consistency.
Suggested by miod@


# 1.17 07-Jan-2007 miod

Some dynamically allocated elements are not considered of vital importance
for the vt100 emulation to work well enough for most cases (i.e. alternate
character set tables, non-default tab settings, etc).

However, code did not always check if these elements had been successfully
allocated before trying to use them, or worse, would explicitely panic in
DIAGNOSTIC kernels.

Change this to work in a degraded mode (by ignoring related escape sequences)
instead.


# 1.16 07-Jan-2007 miod

Change allocations to M_NOWAIT in attach methods, and return NULL if they fail.


# 1.15 19-Oct-2006 dim

Fix hopefully the last wscons jump scrolling glitch, which can occur
in case autowrapping is on, and control characters other than BS, CR,
HT are encountered.

Righto! miod@, also verified by Paul Stoeber.


# 1.14 09-Oct-2006 miod

Fix jump scroll glitch, reported by dim@ and Paul Stoeber.


Revision tags: OPENBSD_4_0_BASE
# 1.13 17-Aug-2006 miod

Jump scroll support for vt100 and sun wscons emulations, helps macppc and
zaurus a lot, tested by many; ok deraadt@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 25-Dec-2004 deraadt

correct indent


# 1.11 23-Dec-2004 miod

vt100 wscons crashes restoring cursor if it had never been saved before.

From NetBSD (wsemul_vt100.c 1.24, wsemul_vt100var.h 1.7)


# 1.10 23-Dec-2004 miod

Reliability fix, from NetBSD:
When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.9 02-Apr-2004 deraadt

remove terms 3 & 4 for drochner@NetBSD.org; as seen on netbsd lists


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A UBC_SYNC_B
# 1.8 12-Oct-2002 krw

Remove more '\n's from panic() statements. Both trailing and leading.

Diff generated by Chris Kuethe.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE UBC_BASE
# 1.6 14-Apr-2001 aaron

branches: 1.6.4; 1.6.8;
Remove some static.


# 1.5 07-Mar-2001 aaron

Instead of panic'ing when an ESC is found in kernel output, print a warning
and ignore it; from NetBSD.


# 1.4 20-Feb-2001 deraadt

default to kernel messages blue


# 1.3 10-Feb-2001 mickey

sync w/ netbsd; aaron@ ok


Revision tags: OPENBSD_2_8_BASE
# 1.2 01-Aug-2000 mickey

update wscons, nothing serious, mostly api fixes for us; from netbsd through aaron@


# 1.1 16-May-2000 mickey

import newer wscons source from netbsd.
art@ said it will make his life easier in alpha
rhands@ said it is not used in powerpc for now
bjc@ said that it would make vax port easier
mickey@ said other platforms can use it, and it's faster


# 1.43 26-Feb-2023 miod

Add a few missing bounds checks when processing terminal escape sequences.
Without them, the kernel could be made to crash or reboot after receiving some
specially crafted terminal escape sequences.

Reported by David Leadbeater (dgl, dgl dot cx)


# 1.42 12-Jan-2023 nicm

Disable double width and height escape sequences under SMALL_KERNEL.

ok miod


# 1.41 12-Jan-2023 miod

free(NULL) has been allowed in the kernel since 5.4; remove checks.


# 1.40 09-Jan-2023 nicm

DIAGNOSTIC is redundant with KASSERT, remove it. From Crystal Kolipe.

ok guenther


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.39 25-May-2020 jsg

branches: 1.39.8; 1.39.10;
change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.38 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_6_7_BASE
# 1.37 22-Mar-2020 anton

zap trailing whitespace


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.36 10-Aug-2017 fcambus

Remove some case statements which have been compiled out since 2000.

OK mpi@


# 1.35 11-Apr-2017 dhill

Partially revert previous mallocarray conversions that contain
constants.

The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@

ok deraadt@


# 1.34 09-Apr-2017 dhill

Convert some malloc(9) to mallocarray(9)

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.33 28-Aug-2015 deraadt

fairly simple sizes for free(); ok tedu


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.31 18-Oct-2013 miod

UTF-8 support for wsdisplay emulation modes. Both vt100 and sun emulation
will now recognize xterm-compatible escape sequences ESC % G and ESC % @ to
enter and leave UTF-8 mode, respectively.

Not enabled on SMALL_KERNEL.

Most of this written during c2k7, completed during b2k13.

Note that the value of several international keysyms change, to switch from
ISO Latin-[257] values to the real Unicode values. Be sure to update your
includes and rebuild and install wsconsctl.


# 1.30 18-Oct-2013 miod

Introduce a dedicated private header file to control the optional features
of wscons (which usually get disabled for installation kernels, to save
space), instead of duplicating parts of it to too many places.

No functional change.


Revision tags: OPENBSD_5_4_BASE
# 1.29 16-Jun-2013 miod

Use (N * sizeof(u_int)) instead of (N * sizeof(int)) when malloc'ing u_int *.
Doesn't change anything, but silences a Clang warning; dhill@bitrig


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.28 04-Aug-2011 miod

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.
Noticed by dcoppa@, based on a draft diff by nicm@; ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.27 01-Sep-2010 nicm

After all escape sequence processing, check for being beyond the last
column and and clear VTFL_LASTCHAR if so.

This fixes the case where an escape sequence (originally noticed with
DECSTBM) moves the cursor and doesn't reset the flag - if it was set,
there would be a spurious line feed on the next input.

ok miod


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 05-Sep-2009 miod

Check the return value of all emulops in the emulation code, and abort
tty output as soon as we hit a failure.

Since the `output' of a character may cause several emulops to be called
(e.g. if it causes scrollup or if this is the end of an escape sequence),
all emulation code maintain a so-called `abort state', to be able to properly
recover when the character is tentatively output later, and not reissue
the emulops which did not fail the first time.

With help from mglocker@


# 1.25 05-Sep-2009 miod

Make the output() wsemul_op return the number of characters processed and
check it in wsdisplaystart() to suspend output if not all characters have
been output; they will get reissued at the next tty rstrt_to timeout.


# 1.24 05-Sep-2009 miod

Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 12-Jan-2009 miod

Recognize CAN and SUB control characters, and cancel any current escape
sequence when they appear. Per VT100 manual via naddy@, ok naddy@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 27-Nov-2007 miod

Remove whitespace at EOL, KNF, ansify. Move jump scroll code to a separate
routine. No functional change (har, har)


# 1.21 25-Nov-2007 miod

Ask the emulation code to hide the cursor when leaving emulation mode. This
way we do not get a phantom cursor image when X exits.


# 1.20 11-Sep-2007 gilles

KNF

prompted and "much better" by marco@, ok pyr@


# 1.19 10-Sep-2007 gilles

more MALLOC/FREE -> malloc/free and M_ZERO changes

ok pyr@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.18 14-Feb-2007 jsg

FALLTHRU -> FALLTHROUGH for consistency.
Suggested by miod@


# 1.17 07-Jan-2007 miod

Some dynamically allocated elements are not considered of vital importance
for the vt100 emulation to work well enough for most cases (i.e. alternate
character set tables, non-default tab settings, etc).

However, code did not always check if these elements had been successfully
allocated before trying to use them, or worse, would explicitely panic in
DIAGNOSTIC kernels.

Change this to work in a degraded mode (by ignoring related escape sequences)
instead.


# 1.16 07-Jan-2007 miod

Change allocations to M_NOWAIT in attach methods, and return NULL if they fail.


# 1.15 19-Oct-2006 dim

Fix hopefully the last wscons jump scrolling glitch, which can occur
in case autowrapping is on, and control characters other than BS, CR,
HT are encountered.

Righto! miod@, also verified by Paul Stoeber.


# 1.14 09-Oct-2006 miod

Fix jump scroll glitch, reported by dim@ and Paul Stoeber.


Revision tags: OPENBSD_4_0_BASE
# 1.13 17-Aug-2006 miod

Jump scroll support for vt100 and sun wscons emulations, helps macppc and
zaurus a lot, tested by many; ok deraadt@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 25-Dec-2004 deraadt

correct indent


# 1.11 23-Dec-2004 miod

vt100 wscons crashes restoring cursor if it had never been saved before.

From NetBSD (wsemul_vt100.c 1.24, wsemul_vt100var.h 1.7)


# 1.10 23-Dec-2004 miod

Reliability fix, from NetBSD:
When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.9 02-Apr-2004 deraadt

remove terms 3 & 4 for drochner@NetBSD.org; as seen on netbsd lists


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A UBC_SYNC_B
# 1.8 12-Oct-2002 krw

Remove more '\n's from panic() statements. Both trailing and leading.

Diff generated by Chris Kuethe.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE UBC_BASE
# 1.6 14-Apr-2001 aaron

branches: 1.6.4; 1.6.8;
Remove some static.


# 1.5 07-Mar-2001 aaron

Instead of panic'ing when an ESC is found in kernel output, print a warning
and ignore it; from NetBSD.


# 1.4 20-Feb-2001 deraadt

default to kernel messages blue


# 1.3 10-Feb-2001 mickey

sync w/ netbsd; aaron@ ok


Revision tags: OPENBSD_2_8_BASE
# 1.2 01-Aug-2000 mickey

update wscons, nothing serious, mostly api fixes for us; from netbsd through aaron@


# 1.1 16-May-2000 mickey

import newer wscons source from netbsd.
art@ said it will make his life easier in alpha
rhands@ said it is not used in powerpc for now
bjc@ said that it would make vax port easier
mickey@ said other platforms can use it, and it's faster


# 1.42 12-Jan-2023 nicm

Disable double width and height escape sequences under SMALL_KERNEL.

ok miod


# 1.41 12-Jan-2023 miod

free(NULL) has been allowed in the kernel since 5.4; remove checks.


# 1.40 09-Jan-2023 nicm

DIAGNOSTIC is redundant with KASSERT, remove it. From Crystal Kolipe.

ok guenther


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.39 25-May-2020 jsg

change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.38 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_6_7_BASE
# 1.37 22-Mar-2020 anton

zap trailing whitespace


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.36 10-Aug-2017 fcambus

Remove some case statements which have been compiled out since 2000.

OK mpi@


# 1.35 11-Apr-2017 dhill

Partially revert previous mallocarray conversions that contain
constants.

The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@

ok deraadt@


# 1.34 09-Apr-2017 dhill

Convert some malloc(9) to mallocarray(9)

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.33 28-Aug-2015 deraadt

fairly simple sizes for free(); ok tedu


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.31 18-Oct-2013 miod

UTF-8 support for wsdisplay emulation modes. Both vt100 and sun emulation
will now recognize xterm-compatible escape sequences ESC % G and ESC % @ to
enter and leave UTF-8 mode, respectively.

Not enabled on SMALL_KERNEL.

Most of this written during c2k7, completed during b2k13.

Note that the value of several international keysyms change, to switch from
ISO Latin-[257] values to the real Unicode values. Be sure to update your
includes and rebuild and install wsconsctl.


# 1.30 18-Oct-2013 miod

Introduce a dedicated private header file to control the optional features
of wscons (which usually get disabled for installation kernels, to save
space), instead of duplicating parts of it to too many places.

No functional change.


Revision tags: OPENBSD_5_4_BASE
# 1.29 16-Jun-2013 miod

Use (N * sizeof(u_int)) instead of (N * sizeof(int)) when malloc'ing u_int *.
Doesn't change anything, but silences a Clang warning; dhill@bitrig


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.28 04-Aug-2011 miod

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.
Noticed by dcoppa@, based on a draft diff by nicm@; ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.27 01-Sep-2010 nicm

After all escape sequence processing, check for being beyond the last
column and and clear VTFL_LASTCHAR if so.

This fixes the case where an escape sequence (originally noticed with
DECSTBM) moves the cursor and doesn't reset the flag - if it was set,
there would be a spurious line feed on the next input.

ok miod


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 05-Sep-2009 miod

Check the return value of all emulops in the emulation code, and abort
tty output as soon as we hit a failure.

Since the `output' of a character may cause several emulops to be called
(e.g. if it causes scrollup or if this is the end of an escape sequence),
all emulation code maintain a so-called `abort state', to be able to properly
recover when the character is tentatively output later, and not reissue
the emulops which did not fail the first time.

With help from mglocker@


# 1.25 05-Sep-2009 miod

Make the output() wsemul_op return the number of characters processed and
check it in wsdisplaystart() to suspend output if not all characters have
been output; they will get reissued at the next tty rstrt_to timeout.


# 1.24 05-Sep-2009 miod

Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 12-Jan-2009 miod

Recognize CAN and SUB control characters, and cancel any current escape
sequence when they appear. Per VT100 manual via naddy@, ok naddy@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 27-Nov-2007 miod

Remove whitespace at EOL, KNF, ansify. Move jump scroll code to a separate
routine. No functional change (har, har)


# 1.21 25-Nov-2007 miod

Ask the emulation code to hide the cursor when leaving emulation mode. This
way we do not get a phantom cursor image when X exits.


# 1.20 11-Sep-2007 gilles

KNF

prompted and "much better" by marco@, ok pyr@


# 1.19 10-Sep-2007 gilles

more MALLOC/FREE -> malloc/free and M_ZERO changes

ok pyr@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.18 14-Feb-2007 jsg

FALLTHRU -> FALLTHROUGH for consistency.
Suggested by miod@


# 1.17 07-Jan-2007 miod

Some dynamically allocated elements are not considered of vital importance
for the vt100 emulation to work well enough for most cases (i.e. alternate
character set tables, non-default tab settings, etc).

However, code did not always check if these elements had been successfully
allocated before trying to use them, or worse, would explicitely panic in
DIAGNOSTIC kernels.

Change this to work in a degraded mode (by ignoring related escape sequences)
instead.


# 1.16 07-Jan-2007 miod

Change allocations to M_NOWAIT in attach methods, and return NULL if they fail.


# 1.15 19-Oct-2006 dim

Fix hopefully the last wscons jump scrolling glitch, which can occur
in case autowrapping is on, and control characters other than BS, CR,
HT are encountered.

Righto! miod@, also verified by Paul Stoeber.


# 1.14 09-Oct-2006 miod

Fix jump scroll glitch, reported by dim@ and Paul Stoeber.


Revision tags: OPENBSD_4_0_BASE
# 1.13 17-Aug-2006 miod

Jump scroll support for vt100 and sun wscons emulations, helps macppc and
zaurus a lot, tested by many; ok deraadt@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 25-Dec-2004 deraadt

correct indent


# 1.11 23-Dec-2004 miod

vt100 wscons crashes restoring cursor if it had never been saved before.

From NetBSD (wsemul_vt100.c 1.24, wsemul_vt100var.h 1.7)


# 1.10 23-Dec-2004 miod

Reliability fix, from NetBSD:
When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.9 02-Apr-2004 deraadt

remove terms 3 & 4 for drochner@NetBSD.org; as seen on netbsd lists


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A UBC_SYNC_B
# 1.8 12-Oct-2002 krw

Remove more '\n's from panic() statements. Both trailing and leading.

Diff generated by Chris Kuethe.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE UBC_BASE
# 1.6 14-Apr-2001 aaron

branches: 1.6.4; 1.6.8;
Remove some static.


# 1.5 07-Mar-2001 aaron

Instead of panic'ing when an ESC is found in kernel output, print a warning
and ignore it; from NetBSD.


# 1.4 20-Feb-2001 deraadt

default to kernel messages blue


# 1.3 10-Feb-2001 mickey

sync w/ netbsd; aaron@ ok


Revision tags: OPENBSD_2_8_BASE
# 1.2 01-Aug-2000 mickey

update wscons, nothing serious, mostly api fixes for us; from netbsd through aaron@


# 1.1 16-May-2000 mickey

import newer wscons source from netbsd.
art@ said it will make his life easier in alpha
rhands@ said it is not used in powerpc for now
bjc@ said that it would make vax port easier
mickey@ said other platforms can use it, and it's faster


# 1.40 09-Jan-2023 nicm

DIAGNOSTIC is redundant with KASSERT, remove it. From Crystal Kolipe.

ok guenther


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.39 25-May-2020 jsg

change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.38 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_6_7_BASE
# 1.37 22-Mar-2020 anton

zap trailing whitespace


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.36 10-Aug-2017 fcambus

Remove some case statements which have been compiled out since 2000.

OK mpi@


# 1.35 11-Apr-2017 dhill

Partially revert previous mallocarray conversions that contain
constants.

The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@

ok deraadt@


# 1.34 09-Apr-2017 dhill

Convert some malloc(9) to mallocarray(9)

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.33 28-Aug-2015 deraadt

fairly simple sizes for free(); ok tedu


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.31 18-Oct-2013 miod

UTF-8 support for wsdisplay emulation modes. Both vt100 and sun emulation
will now recognize xterm-compatible escape sequences ESC % G and ESC % @ to
enter and leave UTF-8 mode, respectively.

Not enabled on SMALL_KERNEL.

Most of this written during c2k7, completed during b2k13.

Note that the value of several international keysyms change, to switch from
ISO Latin-[257] values to the real Unicode values. Be sure to update your
includes and rebuild and install wsconsctl.


# 1.30 18-Oct-2013 miod

Introduce a dedicated private header file to control the optional features
of wscons (which usually get disabled for installation kernels, to save
space), instead of duplicating parts of it to too many places.

No functional change.


Revision tags: OPENBSD_5_4_BASE
# 1.29 16-Jun-2013 miod

Use (N * sizeof(u_int)) instead of (N * sizeof(int)) when malloc'ing u_int *.
Doesn't change anything, but silences a Clang warning; dhill@bitrig


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.28 04-Aug-2011 miod

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.
Noticed by dcoppa@, based on a draft diff by nicm@; ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.27 01-Sep-2010 nicm

After all escape sequence processing, check for being beyond the last
column and and clear VTFL_LASTCHAR if so.

This fixes the case where an escape sequence (originally noticed with
DECSTBM) moves the cursor and doesn't reset the flag - if it was set,
there would be a spurious line feed on the next input.

ok miod


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 05-Sep-2009 miod

Check the return value of all emulops in the emulation code, and abort
tty output as soon as we hit a failure.

Since the `output' of a character may cause several emulops to be called
(e.g. if it causes scrollup or if this is the end of an escape sequence),
all emulation code maintain a so-called `abort state', to be able to properly
recover when the character is tentatively output later, and not reissue
the emulops which did not fail the first time.

With help from mglocker@


# 1.25 05-Sep-2009 miod

Make the output() wsemul_op return the number of characters processed and
check it in wsdisplaystart() to suspend output if not all characters have
been output; they will get reissued at the next tty rstrt_to timeout.


# 1.24 05-Sep-2009 miod

Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 12-Jan-2009 miod

Recognize CAN and SUB control characters, and cancel any current escape
sequence when they appear. Per VT100 manual via naddy@, ok naddy@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 27-Nov-2007 miod

Remove whitespace at EOL, KNF, ansify. Move jump scroll code to a separate
routine. No functional change (har, har)


# 1.21 25-Nov-2007 miod

Ask the emulation code to hide the cursor when leaving emulation mode. This
way we do not get a phantom cursor image when X exits.


# 1.20 11-Sep-2007 gilles

KNF

prompted and "much better" by marco@, ok pyr@


# 1.19 10-Sep-2007 gilles

more MALLOC/FREE -> malloc/free and M_ZERO changes

ok pyr@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.18 14-Feb-2007 jsg

FALLTHRU -> FALLTHROUGH for consistency.
Suggested by miod@


# 1.17 07-Jan-2007 miod

Some dynamically allocated elements are not considered of vital importance
for the vt100 emulation to work well enough for most cases (i.e. alternate
character set tables, non-default tab settings, etc).

However, code did not always check if these elements had been successfully
allocated before trying to use them, or worse, would explicitely panic in
DIAGNOSTIC kernels.

Change this to work in a degraded mode (by ignoring related escape sequences)
instead.


# 1.16 07-Jan-2007 miod

Change allocations to M_NOWAIT in attach methods, and return NULL if they fail.


# 1.15 19-Oct-2006 dim

Fix hopefully the last wscons jump scrolling glitch, which can occur
in case autowrapping is on, and control characters other than BS, CR,
HT are encountered.

Righto! miod@, also verified by Paul Stoeber.


# 1.14 09-Oct-2006 miod

Fix jump scroll glitch, reported by dim@ and Paul Stoeber.


Revision tags: OPENBSD_4_0_BASE
# 1.13 17-Aug-2006 miod

Jump scroll support for vt100 and sun wscons emulations, helps macppc and
zaurus a lot, tested by many; ok deraadt@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 25-Dec-2004 deraadt

correct indent


# 1.11 23-Dec-2004 miod

vt100 wscons crashes restoring cursor if it had never been saved before.

From NetBSD (wsemul_vt100.c 1.24, wsemul_vt100var.h 1.7)


# 1.10 23-Dec-2004 miod

Reliability fix, from NetBSD:
When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.9 02-Apr-2004 deraadt

remove terms 3 & 4 for drochner@NetBSD.org; as seen on netbsd lists


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A UBC_SYNC_B
# 1.8 12-Oct-2002 krw

Remove more '\n's from panic() statements. Both trailing and leading.

Diff generated by Chris Kuethe.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE UBC_BASE
# 1.6 14-Apr-2001 aaron

branches: 1.6.4; 1.6.8;
Remove some static.


# 1.5 07-Mar-2001 aaron

Instead of panic'ing when an ESC is found in kernel output, print a warning
and ignore it; from NetBSD.


# 1.4 20-Feb-2001 deraadt

default to kernel messages blue


# 1.3 10-Feb-2001 mickey

sync w/ netbsd; aaron@ ok


Revision tags: OPENBSD_2_8_BASE
# 1.2 01-Aug-2000 mickey

update wscons, nothing serious, mostly api fixes for us; from netbsd through aaron@


# 1.1 16-May-2000 mickey

import newer wscons source from netbsd.
art@ said it will make his life easier in alpha
rhands@ said it is not used in powerpc for now
bjc@ said that it would make vax port easier
mickey@ said other platforms can use it, and it's faster


# 1.39 25-May-2020 jsg

change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.38 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_6_7_BASE
# 1.37 22-Mar-2020 anton

zap trailing whitespace


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.36 10-Aug-2017 fcambus

Remove some case statements which have been compiled out since 2000.

OK mpi@


# 1.35 11-Apr-2017 dhill

Partially revert previous mallocarray conversions that contain
constants.

The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@

ok deraadt@


# 1.34 09-Apr-2017 dhill

Convert some malloc(9) to mallocarray(9)

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.33 28-Aug-2015 deraadt

fairly simple sizes for free(); ok tedu


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.31 18-Oct-2013 miod

UTF-8 support for wsdisplay emulation modes. Both vt100 and sun emulation
will now recognize xterm-compatible escape sequences ESC % G and ESC % @ to
enter and leave UTF-8 mode, respectively.

Not enabled on SMALL_KERNEL.

Most of this written during c2k7, completed during b2k13.

Note that the value of several international keysyms change, to switch from
ISO Latin-[257] values to the real Unicode values. Be sure to update your
includes and rebuild and install wsconsctl.


# 1.30 18-Oct-2013 miod

Introduce a dedicated private header file to control the optional features
of wscons (which usually get disabled for installation kernels, to save
space), instead of duplicating parts of it to too many places.

No functional change.


Revision tags: OPENBSD_5_4_BASE
# 1.29 16-Jun-2013 miod

Use (N * sizeof(u_int)) instead of (N * sizeof(int)) when malloc'ing u_int *.
Doesn't change anything, but silences a Clang warning; dhill@bitrig


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.28 04-Aug-2011 miod

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.
Noticed by dcoppa@, based on a draft diff by nicm@; ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.27 01-Sep-2010 nicm

After all escape sequence processing, check for being beyond the last
column and and clear VTFL_LASTCHAR if so.

This fixes the case where an escape sequence (originally noticed with
DECSTBM) moves the cursor and doesn't reset the flag - if it was set,
there would be a spurious line feed on the next input.

ok miod


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 05-Sep-2009 miod

Check the return value of all emulops in the emulation code, and abort
tty output as soon as we hit a failure.

Since the `output' of a character may cause several emulops to be called
(e.g. if it causes scrollup or if this is the end of an escape sequence),
all emulation code maintain a so-called `abort state', to be able to properly
recover when the character is tentatively output later, and not reissue
the emulops which did not fail the first time.

With help from mglocker@


# 1.25 05-Sep-2009 miod

Make the output() wsemul_op return the number of characters processed and
check it in wsdisplaystart() to suspend output if not all characters have
been output; they will get reissued at the next tty rstrt_to timeout.


# 1.24 05-Sep-2009 miod

Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 12-Jan-2009 miod

Recognize CAN and SUB control characters, and cancel any current escape
sequence when they appear. Per VT100 manual via naddy@, ok naddy@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 27-Nov-2007 miod

Remove whitespace at EOL, KNF, ansify. Move jump scroll code to a separate
routine. No functional change (har, har)


# 1.21 25-Nov-2007 miod

Ask the emulation code to hide the cursor when leaving emulation mode. This
way we do not get a phantom cursor image when X exits.


# 1.20 11-Sep-2007 gilles

KNF

prompted and "much better" by marco@, ok pyr@


# 1.19 10-Sep-2007 gilles

more MALLOC/FREE -> malloc/free and M_ZERO changes

ok pyr@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.18 14-Feb-2007 jsg

FALLTHRU -> FALLTHROUGH for consistency.
Suggested by miod@


# 1.17 07-Jan-2007 miod

Some dynamically allocated elements are not considered of vital importance
for the vt100 emulation to work well enough for most cases (i.e. alternate
character set tables, non-default tab settings, etc).

However, code did not always check if these elements had been successfully
allocated before trying to use them, or worse, would explicitely panic in
DIAGNOSTIC kernels.

Change this to work in a degraded mode (by ignoring related escape sequences)
instead.


# 1.16 07-Jan-2007 miod

Change allocations to M_NOWAIT in attach methods, and return NULL if they fail.


# 1.15 19-Oct-2006 dim

Fix hopefully the last wscons jump scrolling glitch, which can occur
in case autowrapping is on, and control characters other than BS, CR,
HT are encountered.

Righto! miod@, also verified by Paul Stoeber.


# 1.14 09-Oct-2006 miod

Fix jump scroll glitch, reported by dim@ and Paul Stoeber.


Revision tags: OPENBSD_4_0_BASE
# 1.13 17-Aug-2006 miod

Jump scroll support for vt100 and sun wscons emulations, helps macppc and
zaurus a lot, tested by many; ok deraadt@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 25-Dec-2004 deraadt

correct indent


# 1.11 23-Dec-2004 miod

vt100 wscons crashes restoring cursor if it had never been saved before.

From NetBSD (wsemul_vt100.c 1.24, wsemul_vt100var.h 1.7)


# 1.10 23-Dec-2004 miod

Reliability fix, from NetBSD:
When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.9 02-Apr-2004 deraadt

remove terms 3 & 4 for drochner@NetBSD.org; as seen on netbsd lists


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A UBC_SYNC_B
# 1.8 12-Oct-2002 krw

Remove more '\n's from panic() statements. Both trailing and leading.

Diff generated by Chris Kuethe.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE UBC_BASE
# 1.6 14-Apr-2001 aaron

branches: 1.6.4; 1.6.8;
Remove some static.


# 1.5 07-Mar-2001 aaron

Instead of panic'ing when an ESC is found in kernel output, print a warning
and ignore it; from NetBSD.


# 1.4 20-Feb-2001 deraadt

default to kernel messages blue


# 1.3 10-Feb-2001 mickey

sync w/ netbsd; aaron@ ok


Revision tags: OPENBSD_2_8_BASE
# 1.2 01-Aug-2000 mickey

update wscons, nothing serious, mostly api fixes for us; from netbsd through aaron@


# 1.1 16-May-2000 mickey

import newer wscons source from netbsd.
art@ said it will make his life easier in alpha
rhands@ said it is not used in powerpc for now
bjc@ said that it would make vax port easier
mickey@ said other platforms can use it, and it's faster


# 1.37 22-Mar-2020 anton

zap trailing whitespace


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.36 10-Aug-2017 fcambus

Remove some case statements which have been compiled out since 2000.

OK mpi@


# 1.35 11-Apr-2017 dhill

Partially revert previous mallocarray conversions that contain
constants.

The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@

ok deraadt@


# 1.34 09-Apr-2017 dhill

Convert some malloc(9) to mallocarray(9)

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.33 28-Aug-2015 deraadt

fairly simple sizes for free(); ok tedu


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.31 18-Oct-2013 miod

UTF-8 support for wsdisplay emulation modes. Both vt100 and sun emulation
will now recognize xterm-compatible escape sequences ESC % G and ESC % @ to
enter and leave UTF-8 mode, respectively.

Not enabled on SMALL_KERNEL.

Most of this written during c2k7, completed during b2k13.

Note that the value of several international keysyms change, to switch from
ISO Latin-[257] values to the real Unicode values. Be sure to update your
includes and rebuild and install wsconsctl.


# 1.30 18-Oct-2013 miod

Introduce a dedicated private header file to control the optional features
of wscons (which usually get disabled for installation kernels, to save
space), instead of duplicating parts of it to too many places.

No functional change.


Revision tags: OPENBSD_5_4_BASE
# 1.29 16-Jun-2013 miod

Use (N * sizeof(u_int)) instead of (N * sizeof(int)) when malloc'ing u_int *.
Doesn't change anything, but silences a Clang warning; dhill@bitrig


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.28 04-Aug-2011 miod

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.
Noticed by dcoppa@, based on a draft diff by nicm@; ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.27 01-Sep-2010 nicm

After all escape sequence processing, check for being beyond the last
column and and clear VTFL_LASTCHAR if so.

This fixes the case where an escape sequence (originally noticed with
DECSTBM) moves the cursor and doesn't reset the flag - if it was set,
there would be a spurious line feed on the next input.

ok miod


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 05-Sep-2009 miod

Check the return value of all emulops in the emulation code, and abort
tty output as soon as we hit a failure.

Since the `output' of a character may cause several emulops to be called
(e.g. if it causes scrollup or if this is the end of an escape sequence),
all emulation code maintain a so-called `abort state', to be able to properly
recover when the character is tentatively output later, and not reissue
the emulops which did not fail the first time.

With help from mglocker@


# 1.25 05-Sep-2009 miod

Make the output() wsemul_op return the number of characters processed and
check it in wsdisplaystart() to suspend output if not all characters have
been output; they will get reissued at the next tty rstrt_to timeout.


# 1.24 05-Sep-2009 miod

Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 12-Jan-2009 miod

Recognize CAN and SUB control characters, and cancel any current escape
sequence when they appear. Per VT100 manual via naddy@, ok naddy@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 27-Nov-2007 miod

Remove whitespace at EOL, KNF, ansify. Move jump scroll code to a separate
routine. No functional change (har, har)


# 1.21 25-Nov-2007 miod

Ask the emulation code to hide the cursor when leaving emulation mode. This
way we do not get a phantom cursor image when X exits.


# 1.20 11-Sep-2007 gilles

KNF

prompted and "much better" by marco@, ok pyr@


# 1.19 10-Sep-2007 gilles

more MALLOC/FREE -> malloc/free and M_ZERO changes

ok pyr@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.18 14-Feb-2007 jsg

FALLTHRU -> FALLTHROUGH for consistency.
Suggested by miod@


# 1.17 07-Jan-2007 miod

Some dynamically allocated elements are not considered of vital importance
for the vt100 emulation to work well enough for most cases (i.e. alternate
character set tables, non-default tab settings, etc).

However, code did not always check if these elements had been successfully
allocated before trying to use them, or worse, would explicitely panic in
DIAGNOSTIC kernels.

Change this to work in a degraded mode (by ignoring related escape sequences)
instead.


# 1.16 07-Jan-2007 miod

Change allocations to M_NOWAIT in attach methods, and return NULL if they fail.


# 1.15 19-Oct-2006 dim

Fix hopefully the last wscons jump scrolling glitch, which can occur
in case autowrapping is on, and control characters other than BS, CR,
HT are encountered.

Righto! miod@, also verified by Paul Stoeber.


# 1.14 09-Oct-2006 miod

Fix jump scroll glitch, reported by dim@ and Paul Stoeber.


Revision tags: OPENBSD_4_0_BASE
# 1.13 17-Aug-2006 miod

Jump scroll support for vt100 and sun wscons emulations, helps macppc and
zaurus a lot, tested by many; ok deraadt@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 25-Dec-2004 deraadt

correct indent


# 1.11 23-Dec-2004 miod

vt100 wscons crashes restoring cursor if it had never been saved before.

From NetBSD (wsemul_vt100.c 1.24, wsemul_vt100var.h 1.7)


# 1.10 23-Dec-2004 miod

Reliability fix, from NetBSD:
When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.9 02-Apr-2004 deraadt

remove terms 3 & 4 for drochner@NetBSD.org; as seen on netbsd lists


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A UBC_SYNC_B
# 1.8 12-Oct-2002 krw

Remove more '\n's from panic() statements. Both trailing and leading.

Diff generated by Chris Kuethe.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE UBC_BASE
# 1.6 14-Apr-2001 aaron

branches: 1.6.4; 1.6.8;
Remove some static.


# 1.5 07-Mar-2001 aaron

Instead of panic'ing when an ESC is found in kernel output, print a warning
and ignore it; from NetBSD.


# 1.4 20-Feb-2001 deraadt

default to kernel messages blue


# 1.3 10-Feb-2001 mickey

sync w/ netbsd; aaron@ ok


Revision tags: OPENBSD_2_8_BASE
# 1.2 01-Aug-2000 mickey

update wscons, nothing serious, mostly api fixes for us; from netbsd through aaron@


# 1.1 16-May-2000 mickey

import newer wscons source from netbsd.
art@ said it will make his life easier in alpha
rhands@ said it is not used in powerpc for now
bjc@ said that it would make vax port easier
mickey@ said other platforms can use it, and it's faster


Revision tags: OPENBSD_6_2_BASE
# 1.36 10-Aug-2017 fcambus

Remove some case statements which have been compiled out since 2000.

OK mpi@


# 1.35 11-Apr-2017 dhill

Partially revert previous mallocarray conversions that contain
constants.

The consensus is that if both operands are constant, we don't need
mallocarray. Reminded by tedu@

ok deraadt@


# 1.34 09-Apr-2017 dhill

Convert some malloc(9) to mallocarray(9)

ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.33 28-Aug-2015 deraadt

fairly simple sizes for free(); ok tedu


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.32 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.31 18-Oct-2013 miod

UTF-8 support for wsdisplay emulation modes. Both vt100 and sun emulation
will now recognize xterm-compatible escape sequences ESC % G and ESC % @ to
enter and leave UTF-8 mode, respectively.

Not enabled on SMALL_KERNEL.

Most of this written during c2k7, completed during b2k13.

Note that the value of several international keysyms change, to switch from
ISO Latin-[257] values to the real Unicode values. Be sure to update your
includes and rebuild and install wsconsctl.


# 1.30 18-Oct-2013 miod

Introduce a dedicated private header file to control the optional features
of wscons (which usually get disabled for installation kernels, to save
space), instead of duplicating parts of it to too many places.

No functional change.


Revision tags: OPENBSD_5_4_BASE
# 1.29 16-Jun-2013 miod

Use (N * sizeof(u_int)) instead of (N * sizeof(int)) when malloc'ing u_int *.
Doesn't change anything, but silences a Clang warning; dhill@bitrig


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.28 04-Aug-2011 miod

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.
Noticed by dcoppa@, based on a draft diff by nicm@; ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.27 01-Sep-2010 nicm

After all escape sequence processing, check for being beyond the last
column and and clear VTFL_LASTCHAR if so.

This fixes the case where an escape sequence (originally noticed with
DECSTBM) moves the cursor and doesn't reset the flag - if it was set,
there would be a spurious line feed on the next input.

ok miod


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.26 05-Sep-2009 miod

Check the return value of all emulops in the emulation code, and abort
tty output as soon as we hit a failure.

Since the `output' of a character may cause several emulops to be called
(e.g. if it causes scrollup or if this is the end of an escape sequence),
all emulation code maintain a so-called `abort state', to be able to properly
recover when the character is tentatively output later, and not reissue
the emulops which did not fail the first time.

With help from mglocker@


# 1.25 05-Sep-2009 miod

Make the output() wsemul_op return the number of characters processed and
check it in wsdisplaystart() to suspend output if not all characters have
been output; they will get reissued at the next tty rstrt_to timeout.


# 1.24 05-Sep-2009 miod

Rework internal interfaces in the wsdisplay emulation code to prepare for
upcoming changes. No functional change.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 12-Jan-2009 miod

Recognize CAN and SUB control characters, and cancel any current escape
sequence when they appear. Per VT100 manual via naddy@, ok naddy@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.22 27-Nov-2007 miod

Remove whitespace at EOL, KNF, ansify. Move jump scroll code to a separate
routine. No functional change (har, har)


# 1.21 25-Nov-2007 miod

Ask the emulation code to hide the cursor when leaving emulation mode. This
way we do not get a phantom cursor image when X exits.


# 1.20 11-Sep-2007 gilles

KNF

prompted and "much better" by marco@, ok pyr@


# 1.19 10-Sep-2007 gilles

more MALLOC/FREE -> malloc/free and M_ZERO changes

ok pyr@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.18 14-Feb-2007 jsg

FALLTHRU -> FALLTHROUGH for consistency.
Suggested by miod@


# 1.17 07-Jan-2007 miod

Some dynamically allocated elements are not considered of vital importance
for the vt100 emulation to work well enough for most cases (i.e. alternate
character set tables, non-default tab settings, etc).

However, code did not always check if these elements had been successfully
allocated before trying to use them, or worse, would explicitely panic in
DIAGNOSTIC kernels.

Change this to work in a degraded mode (by ignoring related escape sequences)
instead.


# 1.16 07-Jan-2007 miod

Change allocations to M_NOWAIT in attach methods, and return NULL if they fail.


# 1.15 19-Oct-2006 dim

Fix hopefully the last wscons jump scrolling glitch, which can occur
in case autowrapping is on, and control characters other than BS, CR,
HT are encountered.

Righto! miod@, also verified by Paul Stoeber.


# 1.14 09-Oct-2006 miod

Fix jump scroll glitch, reported by dim@ and Paul Stoeber.


Revision tags: OPENBSD_4_0_BASE
# 1.13 17-Aug-2006 miod

Jump scroll support for vt100 and sun wscons emulations, helps macppc and
zaurus a lot, tested by many; ok deraadt@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.12 25-Dec-2004 deraadt

correct indent


# 1.11 23-Dec-2004 miod

vt100 wscons crashes restoring cursor if it had never been saved before.

From NetBSD (wsemul_vt100.c 1.24, wsemul_vt100var.h 1.7)


# 1.10 23-Dec-2004 miod

Reliability fix, from NetBSD:
When moving the cursor down, only scroll up if cursor is exactly at
bottom of scroll region; don't scroll if below scroll region.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.9 02-Apr-2004 deraadt

remove terms 3 & 4 for drochner@NetBSD.org; as seen on netbsd lists


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE UBC_SYNC_A UBC_SYNC_B
# 1.8 12-Oct-2002 krw

Remove more '\n's from panic() statements. Both trailing and leading.

Diff generated by Chris Kuethe.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.7 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE UBC_BASE
# 1.6 14-Apr-2001 aaron

branches: 1.6.4; 1.6.8;
Remove some static.


# 1.5 07-Mar-2001 aaron

Instead of panic'ing when an ESC is found in kernel output, print a warning
and ignore it; from NetBSD.


# 1.4 20-Feb-2001 deraadt

default to kernel messages blue


# 1.3 10-Feb-2001 mickey

sync w/ netbsd; aaron@ ok


Revision tags: OPENBSD_2_8_BASE
# 1.2 01-Aug-2000 mickey

update wscons, nothing serious, mostly api fixes for us; from netbsd through aaron@


# 1.1 16-May-2000 mickey

import newer wscons source from netbsd.
art@ said it will make his life easier in alpha
rhands@ said it is not used in powerpc for now
bjc@ said that it would make vax port easier
mickey@ said other platforms can use it, and it's faster