Home | History | Annotate | only in /src/sys/dev/wscons
History log of /src/sys/dev/wscons
RevisionDateAuthorComments
 1.4 11-Apr-2001  jdolecek Put back all header files defining ioctls
 1.3 20-Oct-2000  simonb branches: 1.3.2;
Only install wsconsio.h, wsdisplay_usl_io.h, wsksymdef.h and wsksymvar.h
into /usr/include/dev/wscons.
 1.2 06-Jan-1999  drochner branches: 1.2.8; 1.2.18;
don't install wskbdmap_mfii.h to userland
 1.1 12-Jun-1998  cgd Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install. (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.) The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change. Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
 1.2.18.1 20-Oct-2000  tv Pullup 1.3 [simonb]:
Only install wsconsio.h, wsdisplay_usl_io.h, wsksymdef.h and wsksymvar.h
into /usr/include/dev/wscons.
 1.2.8.2 21-Apr-2001  bouyer Sync with HEAD
 1.2.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.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3 20-Jun-1998  drochner add some more ASCII definitions, move NP->FF for consistency
 1.2 15-Jun-1998  drochner #define NUL 0 -- isn't that great?
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.56 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.55 18-Dec-2017  jmcneill branches: 1.55.2; 1.55.4;
Add WSDISPLAY_MULTICONS option which allows wsdisplay to cooperate with
the console device being overridden. This allows for simultaneous console
output on fb and debug uart.
 1.54 30-Aug-2017  jmcneill Add a keymap for converting Linux event codes to wscons keysyms.
 1.53 18-Jun-2017  pgoyette wsbellmux.c doesn't need a needs-flag
 1.52 12-Jun-2017  pgoyette Nothing needs the NWSBELL flag, so don't bother creating it
 1.51 11-Jun-2017  nat New device wsbell - allows for a console beep for non pckbds (usb etc).
Works for platforms without pcppi - can work with spkr at audio and spkr
at pcppi.

To use add the following to your kernel config:
wsbell* at spkr? console?

Ok pgoyette@.
 1.50 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.49 17-Oct-2014  uebayasi branches: 1.49.2;
Give up making wscons modular for now.

My intent is to make "no" handle dependency right so that you can simplely do:

no wsdisplay*
 1.48 10-Oct-2014  uebayasi Normalize wscons devices (except leaving one strange definition).
 1.47 04-Oct-2012  macallan defflag GLYPHCACHE_DEBUG
 1.46 16-Feb-2012  macallan branches: 1.46.2;
generic support for caching glyphs in video memory
for speeding up anti-aliased fonts on slow CPUs
 1.45 29-Jun-2011  macallan branches: 1.45.2; 1.45.6;
dumping ground for generic driver convenience functions
So far it contains only a generic WSDISPLAYIO_GET_EDID implementation that
relies on EDID data being passed to drivers as a device property.
 1.44 25-May-2011  macallan remove VCONS_DRAW_ASYNC
it was always experimental, VCONS_DRAW_INTR is much simpler and Just Works.
 1.43 08-Feb-2011  jmcneill add support for command buffering in vcons. still a WIP, same limitations
as async drawing (no ddb, needs interrupts). you can try it with options
VCONS_DRAW_INTR. as with async, there are still occasional glitches.
 1.42 25-Jan-2011  macallan Add support for asynchronous drawing in vcons.
This is not finished but good enough for others to play with, enable with
options VCONS_DRAW_ASYNC
With this all drawing operations will be posted to a ring buffer instead
of being run directly, and run by a kernel thread. This avoids having to wait
for drawing operations to finish with the kernel lock held ( to a degree at
least ) and scrolling a (slow) framebuffer console should not disrupt other
operations anymore.
Problems:
- we need to switch back to synchronous operations when panicing or entering
ddb, also re-enable async drawing when leaving ddb
- there are still occasional glitches
tested on an SS20 with cg14 and cg6 for dumb and accelerated cases
 1.41 20-Aug-2009  macallan branches: 1.41.4; 1.41.6; 1.41.8;
add vcons_replay_msgbuf() for use by wsdisplay drivers to replay the message
buffer when attaching so older log messages will show up in the scrollback
buffer
Idea from gimpy
 1.40 06-Aug-2007  macallan branches: 1.40.26; 1.40.34;
add scrollback support
 1.39 09-Oct-2006  peter branches: 1.39.8; 1.39.18; 1.39.22;
Remove (the default) #define XXXDEBUG and add the options to the relevant
files.xxx file.
 1.38 15-Apr-2006  jmmv branches: 1.38.8; 1.38.10;
Remove the getwschar and putwschar accessops from wsdisplay drivers as
requested by uwe@. These were wrong because they were receiving an
emulcookie yet they were accessops (thus having to receive an accesscookie).
Instead, just handle the WSDISPLAYIO_{GET,PUT}WSCHAR ioctls from the
driver's ioctl accessop.

As this reduces the amount of code needed to handle these operations to
two small functions in each driver, remove the WSDISPLAY_CHARFUNCS kernel
option.

Reviewed by, at least, uwe@ and macallan@. No objections in tech-kern@.
 1.37 23-Feb-2006  macallan branches: 1.37.2; 1.37.4; 1.37.6;
Add support for virtual consoles to igsfb.
Works fine on a Krups, needs testing on other ports.
 1.36 12-Feb-2006  macallan framework for generic virtual consoles
 1.35 11-Dec-2005  christos branches: 1.35.2; 1.35.4; 1.35.6;
merge ktrace-lwp.
 1.34 04-May-2005  augustss branches: 1.34.2;
Make auto repeat of events a compile time option, and have it off by default.
Turn on by WSKBD_EVENT_AUTOREPEAT.
 1.33 29-Jul-2004  jmmv Implement border color customization in wscons(4), only available for vga(4)
at the moment.

This includes the addition of two new wsdisplay ioctls, WSDISPLAY_{G,S}BORDER,
one to get the actual color and one to set it, respectively. Possible colors
match those defined by ANSI (and listed in wsdisplayvar.h).

It also adds two accessops to the underlying graphics device, getborder and
setborder, which mach their ioctl counterparts.

Two kernel options are added: WSDISPLAY_CUSTOM_BORDER, which enables the
ioctls described above (to customize the border color from userland after
boot), and WSDISPLAY_BORDER_COLOR, which sets the color at boot time.
The former is enabled by default on the GENERIC kernel, but not on INSTALL
(among others). The later is always commented out, leaving the usual black
border as a default.

wsconsctl is modified to allow accessing this value easily. For example,
'wsconsctl -d -w border=blue'.
 1.32 28-Jul-2004  jmmv Forgot to define WSDISPLAY_CUSTOM_OUTPUT here.
 1.31 28-Jul-2004  jmmv 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.30 28-May-2004  christos PR/19925: David Ferlier: Add scrolling support to wscons.
 1.29 28-May-2004  tsarna Refactor tpcalib and hpc* ports to make tpcalib MI, as discussed on tech-kern.
 1.28 02-Apr-2003  drochner branches: 1.28.2; 1.28.4;
allow to customize how highlighting and underlining text is substituted
if the display doesn't provide this
submitted by xs@kittenz.org per PR kern/18004
 1.27 02-Jul-2002  itojun wsdisplay needs wsevent.c. PR 17456
 1.26 26-Jun-2002  christos PR/17402: Add wsmoused support by providing get/set char and events.
 1.25 28-Nov-2001  lukem branches: 1.25.8; 1.25.10;
- convert usage of "defopt" to "defflag" where the relevant option does
not support a value (e.g., it's to be used as "options FOO" instead of
"options FOO=xxx"). options that take a value were converted to
defparam recently.
- minor whitespace & formatting cleanups
 1.24 20-Nov-2001  lukem - replace "defopt" with "defparam" for options which must take a value,
as config(8) will warn for value-less defparam options
- minor whitespace/formatting cleanup
- consolidate opt_tcp_recvspace.h and opt_tcp_sendspace.h into opt_tcp_space.h
 1.23 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.22 05-Oct-2001  eeh branches: 1.22.2;
Stop wscons from conflicting with rcons.
 1.21 24-Feb-2001  lukem branches: 1.21.2; 1.21.4; 1.21.6;
whitespace police
 1.20 15-Sep-2000  drochner add definitions for ISO-7 (greek) support
 1.19 12-Dec-1999  scottr defopt RCONS_4BPP.
 1.18 30-Jul-1999  augustss branches: 1.18.2; 1.18.8;
Eliminate the need for needs-count for wsmux. This should make
wsdisplays work properly again.
 1.17 30-Jul-1999  thorpej GRR! Kludge around the extremely annoying wsmux configuration lossage
by removing the "| wsdisplay" from the wsmux.c file declaration. This
will cause any kernel which includes wsdisplay but not wsmux explicitly
to fail to link, but at least those of us with multiple wsdisplays on
a single machine can build kernels again.
 1.16 29-Jul-1999  augustss Add the wsmux pseudo device.
 1.15 15-May-1999  drochner Get rid of the timeout-driven wscons_glue stuff which caused a lot of
headaches.
Now console keyboard and display are connected at autoconfiguration time,
when the last of them is found. Other keyboards / displays remain
unconnected until a new ioctl (WSDISPLAYIO_SETKEYBOARD) is called.
 1.14 14-May-1999  drochner Sort out the inclusion of wscons source files: the files are only
compiled if the corresponding devices are configured.
(Files calling wscons functions have to check whether these are present.)
 1.13 01-Apr-1999  drochner branches: 1.13.4;
defopt WSCONS_SUPPORT_PCVTFONTS
 1.12 27-Mar-1999  dbj defopt RCONS_2BPP and RCONS_16BPP
add support for 16bpp framebuffers as found on color nexten.
 1.11 22-Mar-1999  sommerfe defopt WSDISPLAY_DEFAULTSCREENS
 1.10 29-Jan-1999  drochner make the timeout for process/vt synchronization "config" settable and
ddb/gdb patchable
 1.9 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.8 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.7 15-Jun-1998  drochner prepare for VT100 emulation
 1.6 11-Jun-1998  drochner add options for new compatibility stuff, add wsdisplay_compat_usl.c
 1.5 14-May-1998  drochner Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.4 17-Apr-1998  thorpej defopt the WSEMUL options.
 1.3 15-Apr-1998  drochner some attributes are now global
 1.2 07-Apr-1998  hannken Initial import of MI keyboard translation for dev/wscons.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.13.4.2 02-Aug-1999  thorpej Update from trunk.
 1.13.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.18.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.18.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.18.2.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.21.6.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.21.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.21.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.21.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.21.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.21.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.21.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.22.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.25.10.1 03-Jul-2002  lukem Pull up revision 1.27 (requested by itojun in ticket #425):
wsdisplay needs wsevent.c. PR 17456
 1.25.8.1 15-Jul-2002  gehenna catch up with -current.
 1.28.4.1 07-Jun-2004  tron Pull up revision 1.30 (requested by recht in ticket #451):
PR/19925: David Ferlier: Add scrolling support to wscons.
 1.28.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.28.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.28.2.1 03-Aug-2004  skrll Sync with HEAD
 1.34.2.3 03-Sep-2007  yamt sync with head.
 1.34.2.2 30-Dec-2006  yamt sync with head.
 1.34.2.1 21-Jun-2006  yamt sync with head.
 1.35.6.1 22-Apr-2006  simonb Sync with head.
 1.35.4.1 09-Sep-2006  rpaulo sync with head
 1.35.2.2 01-Mar-2006  yamt sync with head.
 1.35.2.1 18-Feb-2006  yamt sync with head.
 1.37.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.37.4.1 19-Apr-2006  elad sync with head.
 1.37.2.1 24-May-2006  yamt sync with head.
 1.38.10.1 22-Oct-2006  yamt sync with head
 1.38.8.1 18-Nov-2006  ad Sync with head.
 1.39.22.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.39.18.1 15-Aug-2007  skrll Sync with HEAD.
 1.39.8.1 20-Aug-2007  ad Sync with HEAD.
 1.40.34.2 06-Aug-2007  macallan add scrollback support
 1.40.34.1 06-Aug-2007  macallan file files.wscons was added on branch matt-mips64 on 2007-08-06 03:11:33 +0000
 1.40.26.1 16-Sep-2009  yamt sync with head
 1.41.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.41.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.41.4.2 31-May-2011  rmind sync with head
 1.41.4.1 05-Mar-2011  rmind sync with head
 1.45.6.1 18-Feb-2012  mrg merge to -current.
 1.45.2.2 30-Oct-2012  yamt sync with head
 1.45.2.1 17-Apr-2012  yamt sync with head
 1.46.2.2 03-Dec-2017  jdolecek update from HEAD
 1.46.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.49.2.1 28-Aug-2017  skrll Sync with HEAD
 1.55.4.1 10-Jun-2019  christos Sync with HEAD
 1.55.2.1 24-Mar-2018  pgoyette Move the compat_50-specific code out of wscons/wsevent.c into its own
source file, which is now part of the compat_50 module.
 1.2 31-Aug-2017  jmcneill branches: 1.2.2;
Instead of a Linux keymap, convert Linux event codes to USB scan codes and
use the ukbd keymaps instead.
 1.1 30-Aug-2017  jmcneill Add a keymap for converting Linux event codes to wscons keysyms.
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 31-Aug-2017  jdolecek file linux_keymap.c was added on branch tls-maxphys on 2017-12-03 11:37:37 +0000
 1.2 31-Aug-2017  jmcneill branches: 1.2.2;
Instead of a Linux keymap, convert Linux event codes to USB scan codes and
use the ukbd keymaps instead.
 1.1 30-Aug-2017  jmcneill Add a keymap for converting Linux event codes to wscons keysyms.
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 31-Aug-2017  jdolecek file linux_keymap.h was added on branch tls-maxphys on 2017-12-03 11:37:37 +0000
 1.7 10-Mar-2018  khorben Fix spello in a comment
 1.6 14-Mar-2014  khorben branches: 1.6.28;
Fixed wrong cast and invalid array access in the calibration framework, as
documented in PR kern/45872. The AA() macro accessed sample coordinates as
long integers, whereas they are really stored as signed integers.

Fixes calibration on my Wetab device.
 1.5 14-Sep-2013  martin Comment out a variable only used in #if 0 code
 1.4 09-Oct-2006  peter branches: 1.4.64; 1.4.88; 1.4.94; 1.4.98; 1.4.104;
s/REGENTS/AUTHOR/
 1.3 11-Dec-2005  christos branches: 1.3.20; 1.3.22;
merge ktrace-lwp.
 1.2 01-Jun-2005  uwe branches: 1.2.2;
Constify. Drivers pass const default calibration data to
WSMOUSEIO_SCALIBCOORDS using __UNCONST, so make sure we don't try to
modify it.
 1.1 28-May-2004  tsarna branches: 1.1.2;
Refactor tpcalib and hpc* ports to make tpcalib MI, as discussed on tech-kern.
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 28-May-2004  skrll file mra.c was added on branch ktrace-lwp on 2004-08-03 10:52:10 +0000
 1.2.2.1 30-Dec-2006  yamt sync with head.
 1.3.22.1 22-Oct-2006  yamt sync with head
 1.3.20.1 18-Nov-2006  ad Sync with head.
 1.4.104.1 18-May-2014  rmind sync with head
 1.4.98.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.94.1 11-Apr-2014  msaitoh Pull up following revision(s) (requested by khorben in ticket #1037):
sys/dev/wscons/mra.c 1.6

Fixed wrong cast and invalid array access in the calibration framework,
as documented in PR kern/45872. The AA() macro accessed sample
coordinates as long integers, whereas they are really stored as signed
integers.
 1.4.88.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.4.64.1 16-Apr-2014  msaitoh Pull up following revision(s) (requested by khorben in ticket #1900):
sys/dev/wscons/mra.c rev. 1.6

Fixed wrong cast and invalid array access in the calibration framework,
as documented in PR kern/45872. The AA() macro accessed sample
coordinates as long integers, whereas they are really stored as signed
integers.
 1.6.28.1 15-Mar-2018  pgoyette Synch with HEAD
 1.13 09-Jul-2019  ryoon Do not overflow int64_t on HP Spectre x360 13-inch ae019TU

The machine has pen touch panel with (18344, 10544) -> (3840, 2160)
conversion.
 1.12 06-Apr-2017  macallan branches: 1.12.14;
don't forget to store bounds rectangle in raw mode
 1.11 04-Mar-2007  christos branches: 1.11.86; 1.11.106; 1.11.110; 1.11.114;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.10 16-Nov-2006  christos branches: 1.10.4;
__unused removal on arguments; approved by core.
 1.9 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.8 09-Oct-2006  peter s/REGENTS/AUTHOR/
 1.7 09-Oct-2006  peter Remove (the default) #define XXXDEBUG and add the options to the relevant
files.xxx file.
 1.6 11-Dec-2005  christos branches: 1.6.20; 1.6.22;
merge ktrace-lwp.
 1.5 01-Jun-2005  uwe branches: 1.5.2;
Constify. Drivers pass const default calibration data to
WSMOUSEIO_SCALIBCOORDS using __UNCONST, so make sure we don't try to
modify it.
 1.4 31-May-2005  uwe Fix misleading indentation.
 1.3 27-Feb-2005  perry nuke trailing whitespace
 1.2 12-Jun-2004  tsarna branches: 1.2.2; 1.2.6; 1.2.8;
Add calibration support to uep driver.
Untested, still need a userland utility to calibrate with.
 1.1 28-May-2004  tsarna Refactor tpcalib and hpc* ports to make tpcalib MI, as discussed on tech-kern.
 1.2.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.6.1 29-Apr-2005  kent sync with -current
 1.2.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.5 18-Dec-2004  skrll Sync with HEAD.
 1.2.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.2 03-Aug-2004  skrll Sync with HEAD
 1.2.2.1 12-Jun-2004  skrll file tpcalib.c was added on branch ktrace-lwp on 2004-08-03 10:52:10 +0000
 1.5.2.3 03-Sep-2007  yamt sync with head.
 1.5.2.2 30-Dec-2006  yamt sync with head.
 1.5.2.1 21-Jun-2006  yamt sync with head.
 1.6.22.2 10-Dec-2006  yamt sync with head.
 1.6.22.1 22-Oct-2006  yamt sync with head
 1.6.20.1 18-Nov-2006  ad Sync with head.
 1.10.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.11.114.1 21-Apr-2017  bouyer Sync with HEAD
 1.11.110.1 26-Apr-2017  pgoyette Sync with HEAD
 1.11.106.1 28-Aug-2017  skrll Sync with HEAD
 1.11.86.1 03-Dec-2017  jdolecek update from HEAD
 1.12.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 09-Oct-2006  peter branches: 1.3.4;
s/REGENTS/AUTHOR/
 1.2 11-Dec-2005  christos branches: 1.2.20; 1.2.22;
merge ktrace-lwp.
 1.1 28-May-2004  tsarna branches: 1.1.2; 1.1.14;
Refactor tpcalib and hpc* ports to make tpcalib MI, as discussed on tech-kern.
 1.1.14.3 03-Sep-2007  yamt sync with head.
 1.1.14.2 30-Dec-2006  yamt sync with head.
 1.1.14.1 21-Jun-2006  yamt sync with head.
 1.1.2.5 18-Dec-2004  skrll Sync with HEAD.
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 28-May-2004  skrll file tpcalibvar.h was added on branch ktrace-lwp on 2004-08-03 10:52:10 +0000
 1.2.22.1 22-Oct-2006  yamt sync with head
 1.2.20.1 18-Nov-2006  ad Sync with head.
 1.3.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.4 25-Feb-2010  drochner retire our private definitions for the scan1/3/5/7/9 DEC graphics
symbols, use the unicode definitions instead (which apparently didn't
exist when I wrote that)
 1.3 02-Dec-2001  ross branches: 1.3.118; 1.3.140;
Revert previous; the _e003U definition is used elsewhere.
 1.2 01-Dec-2001  bjh21 On a VT100, the "scanline 5" character is also used for box drawing, so
represent it as U+2500 (BOX DRAWINGS LIGHT HORIZONTAL). This makes NetHack
DECgraphics mode work properly on a wscons console using an IBM-encoded font.
 1.1 20-Feb-1999  drochner branches: 1.1.20; 1.1.22;
complete the font tables for the DEC special fonts; assign some codes
from the private Unicode area (0xe000 ff.) to stuff I didn't find in
the Unicode database
 1.1.22.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.20.1 08-Jan-2002  nathanw Catch up to -current.
 1.3.140.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.118.1 11-Mar-2010  yamt sync with head
 1.1 10-Feb-2010  drochner branches: 1.1.2; 1.1.6;
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.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 10-Feb-2010  uebayasi file vt100_base.h was added on branch uebayasi-xip on 2010-04-30 14:43:54 +0000
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 10-Feb-2010  yamt file vt100_base.h was added on branch yamt-nfs-mp on 2010-03-11 15:04:09 +0000
 1.14 31-Mar-2022  pgoyette For device modules that provide both auto-config and /dev/xxx
interfaces, make sure that initialization and destruction
follow the proper sequence. This is triggered by the recent
changes to the devsw stuff; per riastradh@ the required call
sequence is:

devsw_attach()
config_init_component() or config_cf*_attach()
...
config_fini_component() or config_cf*_detach()
devsw_detach()

While here, add a few missing calls to some of the detach
routines.

Testing of these changes has been limited to:
1. compile without build break
2. no related test failures from atf
3. modload/modunload work as well as
before.

No functional device testing done, since I don't have any
of these devices. Let me know of any damage I might cause
here!

XXX Some of the modules affected by this commit are already
XXX broken; see kern/56772. This commit does not break
any additional modules (as far as I know).
 1.13 27-Dec-2020  tsutsui Explicitly include generated ioconf.h for struct cfdrivers.
 1.12 22-Jun-2019  isaki branches: 1.12.10;
Add missing SETBELL() for WSKBDIO_COMPLEXBELL.
wskbd_bell_data structure has value fields and operation bitmask field.
"xset b * * 0" doesn't touch period field (and doesn't initialized it)
and doesn't set DOPERIOD flag (this means that period field should not
be used). SETBELL() handles this situation appropliately.
This happened during copying wsbell.c from wskbd.c.
Fix PR xsrc/54245.
 1.11 18-Apr-2019  isaki Fix the bell period.
 1.10 18-Apr-2019  isaki White space and indent fix.
 1.9 03-Nov-2017  maya branches: 1.9.2; 1.9.6;
Remove redundant includes of malloc.h
 1.8 13-Jun-2017  nat branches: 1.8.4;
Implement missing ioctls for the default bell.
 1.7 13-Jun-2017  nat Change sc_dying from u_char to bool.
 1.6 13-Jun-2017  nat Remove dying ftom vb_args and use sc_dying instead.
 1.5 13-Jun-2017  nat Move duplicate definition of SETBELL macro into wsbelldata.h.
 1.4 12-Jun-2017  pgoyette Revert previous - it's no longer needed since data structure sizes no
longer depend on which wscons child devices exist
 1.3 12-Jun-2017  pgoyette For now, #include wsdisplay.h to get the definition of NWSDISPLAY

The symbol is currently used to conditionally include members of a
data structure, so without this include there could be different
structure definitions, with different sizes, and data corruption is
likely.

XXX For cleaner modularization, all of the needs-flag entries in
XXX wscons should be removed.
 1.2 11-Jun-2017  pgoyette Add module infrastructure for wsbell(4)
 1.1 11-Jun-2017  nat New device wsbell - allows for a console beep for non pckbds (usb etc).
Works for platforms without pcppi - can work with spkr at audio and spkr
at pcppi.

To use add the following to your kernel config:
wsbell* at spkr? console?

Ok pgoyette@.
 1.8.4.2 28-Aug-2017  skrll Sync with HEAD
 1.8.4.1 13-Jun-2017  skrll file wsbell.c was added on branch nick-nhusb on 2017-08-28 17:52:31 +0000
 1.9.6.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9.6.1 10-Jun-2019  christos Sync with HEAD
 1.9.2.2 03-Dec-2017  jdolecek update from HEAD
 1.9.2.1 03-Nov-2017  jdolecek file wsbell.c was added on branch tls-maxphys on 2017-12-03 11:37:37 +0000
 1.12.10.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.2 13-Jun-2017  nat branches: 1.2.4; 1.2.6;
Move duplicate definition of SETBELL macro into wsbelldata.h.
 1.1 11-Jun-2017  nat Seperate the definitions for the console beep. This code will be shared
with a new device.

Ok pgoyette@.
 1.2.6.2 03-Dec-2017  jdolecek update from HEAD
 1.2.6.1 13-Jun-2017  jdolecek file wsbelldata.h was added on branch tls-maxphys on 2017-12-03 11:37:37 +0000
 1.2.4.2 28-Aug-2017  skrll Sync with HEAD
 1.2.4.1 13-Jun-2017  skrll file wsbelldata.h was added on branch nick-nhusb on 2017-08-28 17:52:31 +0000
 1.1 11-Jun-2017  nat branches: 1.1.4; 1.1.6;
New device wsbell - allows for a console beep for non pckbds (usb etc).
Works for platforms without pcppi - can work with spkr at audio and spkr
at pcppi.

To use add the following to your kernel config:
wsbell* at spkr? console?

Ok pgoyette@.
 1.1.6.2 03-Dec-2017  jdolecek update from HEAD
 1.1.6.1 11-Jun-2017  jdolecek file wsbellmux.c was added on branch tls-maxphys on 2017-12-03 11:37:37 +0000
 1.1.4.2 28-Aug-2017  skrll Sync with HEAD
 1.1.4.1 11-Jun-2017  skrll file wsbellmux.c was added on branch nick-nhusb on 2017-08-28 17:52:31 +0000
 1.1 11-Jun-2017  nat branches: 1.1.4; 1.1.6;
New device wsbell - allows for a console beep for non pckbds (usb etc).
Works for platforms without pcppi - can work with spkr at audio and spkr
at pcppi.

To use add the following to your kernel config:
wsbell* at spkr? console?

Ok pgoyette@.
 1.1.6.2 03-Dec-2017  jdolecek update from HEAD
 1.1.6.1 11-Jun-2017  jdolecek file wsbellmuxvar.h was added on branch tls-maxphys on 2017-12-03 11:37:37 +0000
 1.1.4.2 28-Aug-2017  skrll Sync with HEAD
 1.1.4.1 11-Jun-2017  skrll file wsbellmuxvar.h was added on branch nick-nhusb on 2017-08-28 17:52:31 +0000
 1.3 13-Jun-2017  nat branches: 1.3.4; 1.3.6;
Change sc_dying from u_char to bool.
 1.2 13-Jun-2017  nat Remove dying ftom vb_args and use sc_dying instead.
 1.1 11-Jun-2017  nat New device wsbell - allows for a console beep for non pckbds (usb etc).
Works for platforms without pcppi - can work with spkr at audio and spkr
at pcppi.

To use add the following to your kernel config:
wsbell* at spkr? console?

Ok pgoyette@.
 1.3.6.2 03-Dec-2017  jdolecek update from HEAD
 1.3.6.1 13-Jun-2017  jdolecek file wsbellvar.h was added on branch tls-maxphys on 2017-12-03 11:37:37 +0000
 1.3.4.2 28-Aug-2017  skrll Sync with HEAD
 1.3.4.1 13-Jun-2017  skrll file wsbellvar.h was added on branch nick-nhusb on 2017-08-28 17:52:31 +0000
 1.19 19-Oct-2007  dogcow If you're going to use device_t, may as well include sys/device.h; unb0rks
the build for sparc{,64}.
 1.18 18-Oct-2007  joerg Use aprint API for output and convert to device_t/softc separation.
 1.17 09-Oct-2006  peter branches: 1.17.8; 1.17.22; 1.17.24; 1.17.28;
KNF: No variable names in the prototype.
 1.16 10-Nov-2001  augustss branches: 1.16.32; 1.16.62; 1.16.64;
Make wsdisplay_set_console_kbd() a little less twisted.
 1.15 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.14 13-Oct-2001  augustss branches: 1.14.2;
ANSIfy.
 1.13 01-Oct-2000  takemura branches: 1.13.2; 1.13.4;
- Add ioctl commands to wsdisplay which set/get some LCD status,
backlight, brightness and contrast.
- Add 9 command key symbols which make wskbd to call wsdisplay's
iocontrol.
- Add special key map variant KB_MACHDEP. This variant does not
have any real keymap but it's just a placeholder for machine dependent
maps which will be overwrite by machine dependent keyboard driver.
 1.12 06-Mar-2000  thorpej Add cnbell() support.
 1.11 01-Dec-1999  augustss Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.
 1.10 29-Jul-1999  augustss branches: 1.10.2; 1.10.8;
Add the wsmux pseudo device.
 1.9 15-May-1999  drochner Get rid of the timeout-driven wscons_glue stuff which caused a lot of
headaches.
Now console keyboard and display are connected at autoconfiguration time,
when the last of them is found. Other keyboards / displays remain
unconnected until a new ioctl (WSDISPLAYIO_SETKEYBOARD) is called.
 1.8 18-Jan-1999  drochner branches: 1.8.4;
remove wsdisplay_has_emulator(), this is not meaningful with virtual screens,
and it did not work with external (serial) consoles what can cause that
a display has no screen and thus no "focus"
 1.7 17-Jan-1999  drochner extend the interface for reset-like commands from the keyboard
 1.6 14-Jan-1999  drochner -actually reset the terminal emulator on close()
-add a callback to reset the terminal emulator by keyboard command
 1.5 02-Aug-1998  drochner Split the wskbd_attach arguments into console and autoconfiguration parts
(again); put some constant data into shared structures. This makes it
more look like the mouse part, and it helps USB integration.
Implement wskbd_enable() to enable/disable the keyboard.
 1.4 23-Jul-1998  drochner Switch keyboard to "event mode" on open.
Nuke wskbd_set_translation(). It doesn't fit into the "screen" model.
 1.3 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.2 11-Jun-1998  drochner add "sleeping ok" argument to wsdisplay_switch()
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.8.4.2 02-Aug-1999  thorpej Update from trunk.
 1.8.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.10.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.10.2.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 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.13.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.14.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.16.64.1 22-Oct-2006  yamt sync with head
 1.16.62.1 18-Nov-2006  ad Sync with head.
 1.16.32.2 27-Oct-2007  yamt sync with head.
 1.16.32.1 30-Dec-2006  yamt sync with head.
 1.17.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.17.24.1 06-Nov-2007  matt sync with HEAD
 1.17.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.17.8.1 23-Oct-2007  ad Sync with head.
 1.6 15-May-1999  drochner Get rid of the timeout-driven wscons_glue stuff which caused a lot of
headaches.
Now console keyboard and display are connected at autoconfiguration time,
when the last of them is found. Other keyboards / displays remain
unconnected until a new ioctl (WSDISPLAYIO_SETKEYBOARD) is called.
 1.5 18-Jan-1999  drochner branches: 1.5.4;
remove wsdisplay_has_emulator(), this is not meaningful with virtual screens,
and it did not work with external (serial) consoles what can cause that
a display has no screen and thus no "focus"
 1.4 25-Jul-1998  augustss Insert lots of ``#if NWSMOUSE > 0'' and ``#if NWSDISPLAY > 0'' to make it
possible to have a wsmouse and/or wskbd without having a wsdisplay.
 1.3 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.2 23-May-1998  thorpej Make it possible to build a kernel with a wscons display device but not
a wscons keyboard device.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.5.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11 06-Jul-2022  andvar fix various typos in comments.
 1.10 09-Oct-2006  peter KNF: No variable names in the prototype.
 1.9 11-Dec-2005  christos branches: 1.9.20; 1.9.22;
merge ktrace-lwp.
 1.8 07-Aug-2003  agc branches: 1.8.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.7 04-Jul-2002  junyoung branches: 1.7.6;
alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.6 13-Oct-2001  augustss branches: 1.6.10;
ANSIfy.
 1.5 12-Feb-1999  drochner branches: 1.5.20; 1.5.22;
change the "mapchar" interface to return a "quality" or "match level"
arguments which allows to find approximations for characters which are
not present in a font
 1.4 26-Jun-1998  drochner add dummy character mapping function
 1.3 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.2 14-May-1998  drochner Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.5.22.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.22.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.20.2 01-Aug-2002  nathanw Catch up to -current.
 1.5.20.1 22-Oct-2001  nathanw Catch up to -current.
 1.6.10.1 15-Jul-2002  gehenna catch up with -current.
 1.7.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.6.1 03-Aug-2004  skrll Sync with HEAD
 1.8.16.1 30-Dec-2006  yamt sync with head.
 1.9.22.1 22-Oct-2006  yamt sync with head
 1.9.20.1 18-Nov-2006  ad Sync with head.
 1.4 13-Jan-2007  cube Complete initializers so those files compile.
 1.3 11-Dec-2005  christos branches: 1.3.20;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 22-Mar-1998  drochner branches: 1.1.48;
Initial import of cgd's new wscons code.
 1.1.48.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.48.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.48.1 03-Aug-2004  skrll Sync with HEAD
 1.2.16.1 26-Feb-2007  yamt sync with head.
 1.3.20.1 01-Feb-2007  ad Sync with head.
 1.8 03-Sep-2018  riastradh 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.7 25-Oct-2013  martin branches: 1.7.28; 1.7.30;
Consistently ifdef a variable and all uses
 1.6 11-Dec-2005  christos branches: 1.6.110; 1.6.120; 1.6.126;
merge ktrace-lwp.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 13-Nov-2001  lukem branches: 1.4.16;
add/cleanup RCSIDs
 1.3 13-Oct-2001  augustss ANSIfy.
 1.2 14-May-1998  drochner branches: 1.2.26; 1.2.28;
Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.2.28.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.26.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.26.1 22-Oct-2001  nathanw Catch up to -current.
 1.4.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.16.1 03-Aug-2004  skrll Sync with HEAD
 1.6.126.1 18-May-2014  rmind sync with head
 1.6.120.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.110.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.7.30.1 10-Jun-2019  christos Sync with HEAD
 1.7.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.11 11-Dec-2005  christos merge ktrace-lwp.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.9 04-Jul-2002  junyoung branches: 1.9.6;
alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.8 13-Nov-2001  lukem branches: 1.8.8;
add/cleanup RCSIDs
 1.7 13-Oct-2001  augustss ANSIfy.
 1.6 30-Mar-2000  augustss branches: 1.6.6; 1.6.8;
Remove register declarations.
 1.5 12-Feb-1999  drochner branches: 1.5.8;
change the "mapchar" interface to return a "quality" or "match level"
arguments which allows to find approximations for characters which are
not present in a font
 1.4 26-Jun-1998  drochner add dummy character mapping function
 1.3 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.2 14-May-1998  drochner Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.5.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.6.8.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.6.3 01-Aug-2002  nathanw Catch up to -current.
 1.6.6.2 14-Nov-2001  nathanw Catch up to -current.
 1.6.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.8.8.1 15-Jul-2002  gehenna catch up with -current.
 1.9.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.6.1 03-Aug-2004  skrll Sync with HEAD
 1.130 26-Jul-2025  martin PR 58681: add a port of the OpenBSD viogpu(4) driver written by
Joshua Stein <jcs@openbsd.org>.
Port by George Matsumura with help from Jiaxun Yang.
 1.129 20-Oct-2024  mlelstv Add WSDISPLAYIO_GFONT ioctl to query the installed font name.
 1.128 20-Oct-2024  mlelstv Add type for videocore6 display.
 1.127 20-Jan-2024  jmcneill branches: 1.127.2;
wscons: Add HOLLYWOOD display and YUY2 pixel format types
 1.126 28-Sep-2021  nia branches: 1.126.4;
wsmouse: add support for "precision scrolling" events and (GET|SET)PARAMS

WSCONS_EVENT_HSCROLL and WSCONS_EVENT_VSCROLL are two new wscons event
types that allow scrolling with a higher precision ("smoothness") than an
emulated scroll wheel, and are useful for touch input drivers.

WSMOUSEIO_GETPARAMS and WSMOUSEIO_SETPARAMS are two new ioctls that allow
the speed and direction of precision scrolling to be configured.

both features were originally implemented in OpenBSD.
 1.125 24-Apr-2021  macallan add an ioctl() to get a list of fonts currently available via wsfont
 1.124 29-Oct-2020  nia wscons(4): WSKBD_TYPE_PC_AT is automatically translated to
WSKBD_TYPE_PC_XT in modern kernels
 1.123 24-May-2019  nonaka Added drivers for Hyper-V Synthetic Keyboard and Video device.
 1.122 17-Mar-2019  tnn allocate wsdisplay type 66 for ssdfb(4)
 1.121 31-Aug-2017  jmcneill branches: 1.121.4;
Instead of a Linux keymap, convert Linux event codes to USB scan codes and
use the ukbd keymaps instead.
 1.120 26-Aug-2017  jmcneill add WSKBD_TYPE_TCAKP for Texas Instruments TCA8418
 1.119 11-Jun-2017  nat New device wsbell - allows for a console beep for non pckbds (usb etc).
Works for platforms without pcppi - can work with spkr at audio and spkr
at pcppi.

To use add the following to your kernel config:
wsbell* at spkr? console?

Ok pgoyette@.
 1.118 03-Jun-2017  jmcneill branches: 1.118.2;
Add type for ARM PrimeCell PL11x
 1.117 24-Mar-2017  macallan add fbinfo flag for wildcat split framebuffer workaround
 1.116 10-Jan-2017  christos branches: 1.116.2;
Needed <sys/time.h> that it got in the past by side-effect loading
of <sys/stat.h> from <fcntl.h>. Go figure.
 1.115 10-Jun-2016  macallan branches: 1.115.2;
add WSDISPLAY_TYPE_PLATINUM, for platinumfb
 1.114 19-Jul-2015  mlelstv use optimized refresh with VCONS_DRAW_INTR even when in polling mode.
 1.113 18-May-2015  jmcneill add WSDISPLAY_TYPE_TEGRA
 1.112 20-Mar-2015  jmcneill add WSDISPLAY_TYPE_MESON
 1.111 06-Jan-2015  christos add MGX
 1.110 06-Jan-2015  christos tab police
 1.109 09-Nov-2014  jmcneill branches: 1.109.2;
add WSDISPLAY_TYPE_ALLWINNER
 1.108 29-Apr-2013  kiyohara branches: 1.108.2; 1.108.10;
Add WS{DISPLAY,KBD}_TYPE_* for epoc32.
 1.107 31-Jan-2013  macallan add ioctl(WSDISPLAYIO_GET_FBINFO)
 1.106 21-Jan-2013  macallan add WSDISPLAY_TYPE_OMAP3
 1.105 08-Jan-2013  jmcneill add WSDISPLAY_TYPE_VC4 and WSDISPLAYIO_BUS_SOC
 1.104 17-Apr-2012  bsh branches: 1.104.2;
Support i.MX51's LCD framebuffer on Netwalker.
from Kenichi Hashimoto.
 1.103 24-Jan-2012  macallan branches: 1.103.2;
ass WSDISPLAY_TYPE_VALKYRIE
 1.102 30-Dec-2011  reinoud Add the Usermode vnc framebuffer and (vnc) remote keyboard types.
 1.101 15-Dec-2011  phx Amiga wscons/Xorg support, first phase.
Implemented wscons for CV64 and CV64/3D. Other graphics cards drivers are
prepared for it, but will not be attempted before Xorg is not running.
The wscons support is disabled by default. A GENERIC kernel should behave
like always. Use WSCONS to try out a kernel with wscons support.
Done by rkujawa@ and phx@.
 1.100 21-Jul-2011  tsutsui branches: 1.100.2; 1.100.6;
Add and return WSKBD_TYPE_LUNA and WSDISPLAY_TYPE_LUNA on WS*_GTYPE ioctls.

XXX: should we still sync <sys/dev/wsconsio.h> and src/sbin/wsconsctl/util.c?
 1.99 29-Jun-2011  macallan make the EDID buffer pointer void *
 1.98 29-Jun-2011  macallan make sizes unsigned
 1.97 29-Jun-2011  macallan add two new ioctl()s:
WSDISPLAYIO_GET_EDID to retrieve EDID data from display drivers
WSDISPLAYIO_SET_POLLING to control polling with VCONS_DRAW_INTR
 1.96 08-Jun-2011  drochner add support for the interesting parts of ISO-2 and KOI8-R fonts
to the vga(4) driver
 1.95 06-Feb-2011  tsutsui branches: 1.95.2;
Switch NetBSD/hp300 to wscons with rasops. Simply ported from OpenBSD/hp300.

- Only A1416 Kathmandu (topcat) framebuffer on 425t is tested, but
all other variants (TigerShark, Hyperion, DaVinci, GatorBox, Renaissance)
should also work if they are working on OpenBSD/hp300.
- sti(4) and SGC bus support are not pulled because I don't have 425e
and I can't confirm that 362 and 382 actually have SGC bus.
(I'll commit a DIO based dumb driver for 362 and 382 framebuffers later)
- Xorg server with wsfb driver will also be integrated soon
once after keycode with NoSymbol problem is addressed.
(We have to re-think what code should be used on WSDISPLAY_COMPAT_RAWKBD)
- MI HIL keyboard and mouse drivers are working fine though
cngetc via hilkbd has some problem (still we can input commands).
- No old HP-UX like HIL ioctl compatibility (we removed COMPAT_HPUX anyway).
grfinfo(8) and hilinfo(8) will be removed shortly.

Demonstrated on NetBSD booth at Open Source Conference 2011 Kagawa.
 1.94 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.93 02-Oct-2010  macallan branches: 1.93.2; 1.93.4;
clarify how backlight control ioctl()s are supposed to work
TODO: adapt r128fb and radeonfb
 1.92 31-Dec-2009  macallan branches: 1.92.2; 1.92.4;
add WSDISPLAY_TYPE_XVR1000
 1.91 15-Nov-2009  tsutsui Reserve WSDISPLAY_TYPE for DisplayLink DL-1x0/DL-1x5 USB LCDs and
USB-VGA adaptors (which may require a new ioctl for DUMBFB ops). From
FUKAUMI Naoki.
 1.90 08-Feb-2009  uwe G/c duplicate definition of WSCONS_EVENT_ASCII.
 1.89 13-Jan-2009  christos branches: 1.89.2;
provide wscons_event compatibility with 5.0.
 1.88 27-Aug-2007  macallan branches: 1.88.22; 1.88.26; 1.88.34;
add type for Fujitsu AG-10e
 1.87 26-Jul-2007  nonaka branches: 1.87.4; 1.87.6;
add WSDISPLAY_TYPE_PXALCD for PXA2x0 LCD controller.
 1.86 26-Jul-2007  macallan add WSDISPLAY_TYPE_CRIME for the SGI O2's graphics hardware
 1.85 11-Apr-2007  macallan branches: 1.85.4;
add WSDISPLAY_TYPE_GENFB
 1.84 19-Jan-2007  macallan branches: 1.84.2; 1.84.6; 1.84.8;
add #defines for ADB and pseudo mice
 1.83 26-Dec-2006  rumble Add type for sgimips/light(4).
 1.82 17-Dec-2006  peter Add WSKBD_TYPE_ZAURUS (Sharp Zaurus keyboard).
 1.81 02-Dec-2006  freza Welcome to evbppc/virtex -- port to Xilinx Virtex series FPGA's with embedded
ibm405d5 core.

OK by Simon Burge
 1.80 19-Jun-2006  gdamore branches: 1.80.4; 1.80.6;
Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.
 1.79 18-Feb-2006  jmcneill branches: 1.79.2; 1.79.8; 1.79.10;
Bunch of changes to wscons in preparation for splash screen support:
* Add WSDISPLAY_TYPE_VESA for vesafb. While here, fix a typo in a comment.
* Add WSDISPLAYIO_SSPLASH and WSDISPLAYIO_SPROGRESS ioctls. The former
toggles the splash screen on and off, and the latter updates the progress
animation.
* Prevent more than one hw driver from claiming to be the console.
* In vcons, keep two pointers to the screen's vcons_data. This lets us
override the original (ie with null emulops during boot), and restore
them later on.
 1.78 05-Feb-2006  jmmv Add support to automatically repeat mouse button events in wsmouse(4) and
change wsconsctl(4) so that this is configurable.

This is specially useful for mice that provide page up/down buttons instead
of a real wheel and that do not send events repeatedly from the hardware.
(E.g.: Logitech Marble Mouse.)

No objections in tech-kern@.
 1.77 29-Dec-2005  tsutsui branches: 1.77.2; 1.77.4; 1.77.6;
Add WSKBD_TYPE_EWS4800 for EWS4800 machines.
 1.76 23-Nov-2005  augustss Some devices provide more than three (X, Y, and Z) "directions". So add
a W "coordinate" that can be used for these.
This changes the type of wsmouse_input(). To avoid changing a lot of drivers
a compatibilty #define is provided. Maybe changing all drivers would have
been better?
 1.75 28-Aug-2005  tsutsui branches: 1.75.6;
TAB/space cosmetics.
 1.74 28-Apr-2005  martin branches: 1.74.2;
Make it possible for a console driver to deliver raw ASCII characters
to wskbd. This is for special cases only, and may even be considered a
hack, but it is cheap and very local.
 1.73 27-Feb-2005  perry branches: 1.73.2;
nuke trailing whitespace
 1.72 04-Feb-2005  joff Support wsdisplay(4) attachments of hd44780 LCD controllers
 1.71 31-Jan-2005  joff Add new wskbd type MATRIXKP
 1.70 26-Aug-2004  jkunz branches: 1.70.4; 1.70.6;
Import STI wscons(4) driver from OpenBSD and add new driver for PS/2
keyboard / mouse pots of LASI.
 1.69 29-Jul-2004  jmmv Implement border color customization in wscons(4), only available for vga(4)
at the moment.

This includes the addition of two new wsdisplay ioctls, WSDISPLAY_{G,S}BORDER,
one to get the actual color and one to set it, respectively. Possible colors
match those defined by ANSI (and listed in wsdisplayvar.h).

It also adds two accessops to the underlying graphics device, getborder and
setborder, which mach their ioctl counterparts.

Two kernel options are added: WSDISPLAY_CUSTOM_BORDER, which enables the
ioctls described above (to customize the border color from userland after
boot), and WSDISPLAY_BORDER_COLOR, which sets the color at boot time.
The former is enabled by default on the GENERIC kernel, but not on INSTALL
(among others). The later is always commented out, leaving the usual black
border as a default.

wsconsctl is modified to allow accessing this value easily. For example,
'wsconsctl -d -w border=blue'.
 1.68 28-Jul-2004  jmmv 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.67 20-Jul-2004  heas Add WSDISPLAYIO_[GS]MODE type _DUMBFB - mapped fb (no registers)
Add WSDISPLAYIO_LINEBYTES ioctl - # bytes/row

Used by ffb driver and XFree wsfb driver module - From OpenBSD
 1.66 07-Jul-2004  sekiya Add SGI types for mouse and keyboard.
 1.65 07-Jun-2004  christos make the scroll lines ioctl struct take u_int's again. The wsconsctl
command does not deal with shorts well.
 1.64 01-Jun-2004  christos White space changes only;
1. put value defines under the fields that they refer too, all the time
not just in some of the ioctls.
2. use #define<tab>value consistently.
 1.63 01-Jun-2004  christos Re-group scrolling ioctl's and provide new numbers for them! (thanks to
John Heasley for catching that).
 1.62 28-May-2004  christos PR/19925: David Ferlier: Add scrolling support to wscons.
 1.61 19-Mar-2004  petrov branches: 1.61.2;
Add sun display types.
 1.60 18-Mar-2004  sekiya Add console type for SGI GR2 family.
 1.59 24-Jan-2004  sekiya Add display type for SGI Newport.
 1.58 03-Jun-2003  petrov branches: 1.58.2;
Add sun keyboards and display.
 1.57 10-Feb-2003  jdolecek undo constification of 'data' for wsdisplay font - unfortunately we need
to be able to adjust the font to display adapter needs very soon (in consinit()),
so it's not possible to do font copy
 1.56 09-Feb-2003  jdolecek make 'name' and 'data' of struct wsdisplay_font const, mark data arrays
in font sources const
 1.55 31-Jan-2003  thomas Define Atari wskeyboard type.
 1.54 03-Jan-2003  takemura Added new ioctl command, WSMOUSEIO_GETID to tell touch panel identifier
for tpctl(8).
 1.53 10-Dec-2002  itohy Add WSKBD_TYPE_MAPLE and WSMOUSE_TYPE_MAPLE for Dreamcast Maple bus devices.
 1.52 25-Sep-2002  reinoud Fix some small unclear documentation and cleanup a bit...
 1.51 26-Jun-2002  christos PR/17402: Add wsmoused support by providing get/set char and events.
 1.50 07-Apr-2002  hannken branches: 1.50.2;
Rename WSDISPLAYIO_USEFONT to WSDISPLAYIO_SFONT.

Approved by Matthias Drochner <drochner@netbsd.org>.
 1.49 24-Feb-2002  ad Add WSMOUSE_TYPE_MAXINE.
 1.48 13-Jan-2002  jandberg added amiga display/mouse/keyboard defines
 1.47 04-Dec-2001  gmcgarry Simply entries added in previous.
 1.46 02-Dec-2001  gmcgarry Add identifiers for HP devices.
 1.45 05-Nov-2001  enami Fix typo in comment.
 1.44 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.43 02-Oct-2001  mycroft branches: 1.43.2;
Add a WSKBD_TYPE_ADB for Macs.
 1.42 18-Sep-2001  ad Get/set keyclick volume.
 1.41 04-Sep-2001  drochner branches: 1.41.2;
add encoding for ISO-2
 1.40 05-Aug-2001  jdolecek introduce hard limit on maximum font size (WSDISPLAY_MAXFONTSZ - 512KB)
and keymap size (WSKBDIO_MAXMAPLEN - 64KB)
 1.39 30-Mar-2001  tsutsui branches: 1.39.2;
Make Sony's fonts ISO8859-1 compliant.
 1.38 20-Mar-2001  reinoud Add RiscPC (arm32) keyboard. It basicly returns AT scancodes but since it has to
use a seperate keyboard driver (pckbdc not available) i cant guarantee that it is
100% compatible with AT scan codes
 1.37 02-Feb-2001  marcus branches: 1.37.2;
Added a fontencoding for the Sony fonts.
 1.36 01-Feb-2001  thorpej Add a display type for the Dreamcast PowerVR.
 1.35 08-Jan-2001  takemura These ioctl commands should be '_IOW' to set value.
WSMOUSEIO_SRES
WSMOUSEIO_SSCALE
WSMOUSEIO_SRATE
 1.34 01-Oct-2000  takemura - Add ioctl commands to wsdisplay which set/get some LCD status,
backlight, brightness and contrast.
- Add 9 command key symbols which make wskbd to call wsdisplay's
iocontrol.
- Add special key map variant KB_MACHDEP. This variant does not
have any real keymap but it's just a placeholder for machine dependent
maps which will be overwrite by machine dependent keyboard driver.
 1.33 15-Sep-2000  drochner add definitions for ISO-7 (greek) support
 1.32 06-Jul-2000  hannken Change type `kbd_t' from `u_int_16_t' to `u_int32_t'.
This eliminates bogus casts from `int *' to `u_int_16_t*'.
 1.31 09-Jun-2000  drochner branches: 1.31.2;
add EGA display type
 1.30 02-Jun-2000  matt Add VAX display types along with the SPARCbook P9100.
 1.29 13-May-2000  bjh21 branches: 1.29.2;
Add Archimedes mouse/kbd/video
 1.28 13-Mar-2000  sato HPC/PsPC keyboard types.
 1.27 12-Mar-2000  takemura Add a new frame buffer identifier for the hpcmips.
 1.26 28-Feb-2000  takemura WSMOUSE_SCALIBCOORDS had not worked because ioctrl code was wrong.
 1.25 18-Jan-2000  deberg add the NeXT mouse type
 1.24 08-Jan-2000  takemura Absolute pointing device support.
- Wsmouse_input() get new argument 'flag', which indicates whether x/y/z are
relative or absolute.
- Wsmouse get new io controls, WSMOUSEIO_SCALIBCOORDS and
WSMOUSEIO_GCALIBCOORDS.
 1.23 07-Jan-2000  enami Don't define WSDISPLAY_FONTORDER_L2R as 0. The function wsfont_lock uses
the value 0 specially.
 1.22 06-Jan-2000  ad Got too excited with cut and paste in previous. Noted by itojun.
 1.21 05-Jan-2000  ad Add two new members to 'struct wsdisplay_font': 'bitorder' and 'byteorder'.
 1.20 20-Sep-1999  nisimura branches: 1.20.2;
Add one new dispaly type for DEC TC TX 8/24bpp framebuffer. Currently acts
as an 8bpp pseudo color device.
 1.19 29-Jul-1999  augustss Add the wsmux pseudo device.
 1.18 15-May-1999  drochner Get rid of the timeout-driven wscons_glue stuff which caused a lot of
headaches.
Now console keyboard and display are connected at autoconfiguration time,
when the last of them is found. Other keyboards / displays remain
unconnected until a new ioctl (WSDISPLAYIO_SETKEYBOARD) is called.
 1.17 03-May-1999  ad Add ioctl definitions for setting mouse resolution, scale factor and sample
rate. Add two new display types (DEC PX, PXG). Replace instances of '???' in
comments about DEC hardware with meaningful representations.
 1.16 12-Feb-1999  drochner branches: 1.16.4;
"NEXT" is a keyboard type, not a keymap variation.
 1.15 28-Jan-1999  dbj wscons based console video & keyboard support for the NeXT
from Matt DeBergalis
 1.14 26-Jan-1999  drochner forgot to commit last week: define wsmouse type constants for busmice
 1.13 13-Jan-1999  drochner change the way fonts are handled: now we have a display-global ioctl
to download fonts and a per-screen call to select a font
allows easier sharing of ressources in the display driver
change the parameters to the load_font driver vector to pass all
available font information
 1.12 09-Jan-1999  drochner add ioctl()s for screen allocation/deallocation
 1.11 30-Dec-1998  augustss Add USB keyboard type.
 1.10 30-Dec-1998  augustss Add a wscons display type `unknown' that the generic VGA driver can
return until someone fixes it for real.
 1.9 30-Dec-1998  augustss Add a special wsmouse type for USB mice.
 1.8 17-Sep-1998  drochner Define a new keyboard eveny type "all keys up". This allows to reduce
the amount of statekeeping in drivers for LK201-like keyboards, and it
might be useful to resync after resets or overflows.
(reused the unused WSCONS_EVENT_KEY_OTHER event ID)
Implement the necessary decoding bits.
 1.7 27-Jul-1998  drochner add definition for pointing device's absolute z coordinates
 1.6 27-Jul-1998  drochner define a z axis for pointing devices which support this
 1.5 21-Jul-1998  drochner Fix ioctl definitions for WSKBDIO_{SET,GET}LEDS.
from Takuya Koumoto <takuya-k@is.aist-nara.ac.jp>
 1.4 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.3 11-Jun-1998  drochner implement a way to get raw keyboard data (for X)
 1.2 07-Apr-1998  hannken Initial import of MI keyboard translation for dev/wscons.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.16.4.2 02-Aug-1999  thorpej Update from trunk.
 1.16.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.20.2.5 21-Apr-2001  bouyer Sync with HEAD
 1.20.2.4 27-Mar-2001  bouyer Sync with HEAD.
 1.20.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.20.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.20.2.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.29.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.31.2.2 16-Aug-2001  tv Pullup [jdolecek]:

sys/dev/wscons/wsdisplay.c 1.52
sys/dev/wscons/wskbd.c 1.42
sys/dev/wscons/wsconsio.h 1.40

Introduce hard limits on wscons font size and keymap size, and
bounds check against those limits.
 1.31.2.1 07-Jul-2000  hannken Pull up revision 1.32:
- kbd_t from u_int_16_t to u_int_32_t.
 1.37.2.12 07-Jan-2003  thorpej Sync with HEAD.
 1.37.2.11 11-Dec-2002  thorpej Sync with HEAD.
 1.37.2.10 18-Oct-2002  nathanw Catch up to -current.
 1.37.2.9 01-Aug-2002  nathanw Catch up to -current.
 1.37.2.8 17-Apr-2002  nathanw Catch up to -current.
 1.37.2.7 28-Feb-2002  nathanw Catch up to -current.
 1.37.2.6 08-Jan-2002  nathanw Catch up to -current.
 1.37.2.5 14-Nov-2001  nathanw Catch up to -current.
 1.37.2.4 08-Oct-2001  nathanw Catch up to -current.
 1.37.2.3 21-Sep-2001  nathanw Catch up to -current.
 1.37.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.37.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.39.2.8 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.39.2.7 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.39.2.6 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.39.2.5 16-Mar-2002  jdolecek Catch up with -current.
 1.39.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.39.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.39.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.39.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.41.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.41.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.43.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.50.2.1 15-Jul-2002  gehenna catch up with -current.
 1.58.2.6 11-Dec-2005  christos Sync with head.
 1.58.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.58.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.58.2.3 04-Feb-2005  skrll Sync with HEAD.
 1.58.2.2 03-Sep-2004  skrll Sync with HEAD
 1.58.2.1 03-Aug-2004  skrll Sync with HEAD
 1.61.2.4 13-Jun-2004  jdc Pull up revision 1.65 (requested by recht in ticket #457).

make the scroll lines ioctl struct take u_int's again. The wsconsctl
command does not deal with shorts well.
 1.61.2.3 07-Jun-2004  tron Pull up revision 1.64 (requested by recht in ticket #451):
White space changes only;
1. put value defines under the fields that they refer too, all the time
not just in some of the ioctls.
2. use #define<tab>value consistently.
 1.61.2.2 07-Jun-2004  tron Pull up revision 1.63 (requested by recht in ticket #451):
Re-group scrolling ioctl's and provide new numbers for them! (thanks to
John Heasley for catching that).
 1.61.2.1 07-Jun-2004  tron Pull up revision 1.62 (requested by recht in ticket #451):
PR/19925: David Ferlier: Add scrolling support to wscons.
 1.70.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.70.6.1 12-Feb-2005  yamt sync with head.
 1.70.4.1 29-Apr-2005  kent sync with -current
 1.73.2.1 03-Jun-2005  riz Pull up revision 1.74 (requested by martin in ticket #370):
Make it possible for a console driver to deliver raw ASCII characters
to wskbd. This is for special cases only, and may even be considered a
hack, but it is cheap and very local.
 1.74.2.4 03-Sep-2007  yamt sync with head.
 1.74.2.3 26-Feb-2007  yamt sync with head.
 1.74.2.2 30-Dec-2006  yamt sync with head.
 1.74.2.1 21-Jun-2006  yamt sync with head.
 1.75.6.1 29-Nov-2005  yamt sync with head.
 1.77.6.1 22-Apr-2006  simonb Sync with head.
 1.77.4.1 09-Sep-2006  rpaulo sync with head
 1.77.2.2 01-Mar-2006  yamt sync with head.
 1.77.2.1 18-Feb-2006  yamt sync with head.
 1.79.10.1 13-Jul-2006  gdamore Merge from HEAD.
 1.79.8.1 22-Jun-2006  chap Complete a sync sys/ with head.
 1.79.2.1 26-Jun-2006  yamt sync with head.
 1.80.6.2 18-Dec-2006  yamt sync with head.
 1.80.6.1 10-Dec-2006  yamt sync with head.
 1.80.4.2 01-Feb-2007  ad Sync with head.
 1.80.4.1 12-Jan-2007  ad Sync with head.
 1.84.8.1 11-Jul-2007  mjf Sync with head.
 1.84.6.3 09-Oct-2007  ad Sync with head.
 1.84.6.2 20-Aug-2007  ad Sync with HEAD.
 1.84.6.1 27-May-2007  ad Sync with head.
 1.84.2.1 15-Apr-2007  yamt sync with head.
 1.85.4.2 03-Sep-2007  skrll Sync with HEAD.
 1.85.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.87.6.2 26-Jul-2007  nonaka add WSDISPLAY_TYPE_PXALCD for PXA2x0 LCD controller.
 1.87.6.1 26-Jul-2007  nonaka file wsconsio.h was added on branch matt-mips64 on 2007-07-26 12:17:15 +0000
 1.87.4.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.88.34.2 03-Mar-2009  skrll Sync with HEAD.
 1.88.34.1 19-Jan-2009  skrll Sync with HEAD.
 1.88.26.3 09-Oct-2010  yamt sync with head
 1.88.26.2 11-Mar-2010  yamt sync with head
 1.88.26.1 04-May-2009  yamt sync with head.
 1.88.22.1 17-Jan-2009  mjf Sync with HEAD.
 1.89.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.92.4.2 12-Jun-2011  rmind sync with head
 1.92.4.1 05-Mar-2011  rmind sync with head
 1.92.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.93.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.93.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.95.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.100.6.2 29-Apr-2012  mrg sync to latest -current.
 1.100.6.1 18-Feb-2012  mrg merge to -current.
 1.100.2.4 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.100.2.3 23-Jan-2013  yamt sync with head
 1.100.2.2 23-May-2012  yamt sync with head.
 1.100.2.1 17-Apr-2012  yamt sync with head
 1.103.2.1 13-Feb-2013  riz Pull up following revision(s) (requested by skrll in ticket #813):

etc/MAKEDEV.tmpl 1.160
etc/etc.evbarm/MAKEDEV.conf 1.9
external/broadcom/rpi-firmware/dist/LICENCE.broadcom 1.1
external/broadcom/rpi-firmware/dist/bootcode.bin 1.1
external/broadcom/rpi-firmware/dist/bootcode.bin 1.2
external/broadcom/rpi-firmware/dist/fixup.dat 1.1
external/broadcom/rpi-firmware/dist/fixup.dat 1.2
external/broadcom/rpi-firmware/dist/fixup_cd.dat 1.1
external/broadcom/rpi-firmware/dist/fixup_cd.dat 1.2
external/broadcom/rpi-firmware/dist/start.elf 1.1
external/broadcom/rpi-firmware/dist/start.elf 1.2
external/broadcom/rpi-firmware/dist/start_cd.elf 1.1
external/broadcom/rpi-firmware/dist/start_cd.elf 1.2
sys/arch/arm/broadcom/bcm2835_bsc.c 1.1 via patch
sys/arch/arm/broadcom/bcm2835_bscreg.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_dotg.c 1.1 via patch
sys/arch/arm/broadcom/bcm2835_emmc.c 1.7 via patch
sys/arch/arm/broadcom/bcm2835_genfb.c 1.4 via patch
sys/arch/arm/broadcom/bcm2835_gpio_subr.c 1.2 via patch
sys/arch/arm/broadcom/bcm2835_gpio_subr.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_gpioreg.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_intr.c 1.3 via patch
sys/arch/arm/broadcom/bcm2835_mbox.c 1.5 via patch
sys/arch/arm/broadcom/bcm2835_mbox.h 1.4 via patch
sys/arch/arm/broadcom/bcm2835_obio.c 1.17 via patch
sys/arch/arm/broadcom/bcm2835_pm.c 1.2 via patch
sys/arch/arm/broadcom/bcm2835_rng.c 1.3 via patch
sys/arch/arm/broadcom/bcm2835_space.c 1.5 via patch
sys/arch/arm/broadcom/bcm2835_spi.c 1.1 via patch
sys/arch/arm/broadcom/bcm2835_spireg.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_tmr.c 1.3 via patch
sys/arch/arm/broadcom/bcm2835reg.h 1.10 via patch
sys/arch/arm/broadcom/files.bcm2835 1.14 via patch
sys/arch/evbarm/conf/RPI 1.23 via patch
sys/arch/evbarm/conf/files.rpi 1.3 via patch
sys/arch/evbarm/conf/mk.rpi 1.2 via patch
sys/arch/evbarm/conf/std.rpi 1.4 via patch
sys/arch/evbarm/rpi/rpi_machdep.c 1.34 via patch
sys/arch/evbarm/rpi/rpi_start.S 1.7 via patch
sys/arch/evbarm/rpi/rpi_vcmbox.c 1.2 via patch
sys/arch/evbarm/rpi/vcio.h 1.1 via patch
sys/arch/evbarm/rpi/vcprop.h 1.7 via patch
sys/conf/files patch
sys/dev/sdmmc/sdhc.c 1.43
sys/dev/sdmmc/sdhcvar.h 1.13
sys/dev/usb/dwc_otg.c 1.45 via patch
sys/dev/usb/dwc_otgreg.h 1.5 via patch
sys/dev/usb/dwc_otgvar.h 1.11 via patch
sys/dev/usb/files.usb 1.126 via patch
sys/dev/usb/if_smsc.c 1.7 via patch
sys/dev/usb/if_smscreg.h 1.1 via patch
sys/dev/usb/if_smscvar.h 1.1 via patch
sys/dev/usb/usbdevices.config patch
sys/dev/usb/usbdevs 1.633 via patch
sys/dev/usb/usbdevs.h regen
sys/dev/usb/usbdevs_data.h regen
sys/dev/wscons/wsconsio.h 1.105,1.107 via patch
sys/dev/wscons/wsdisplayvar.h 1.50
sys/dev/wscons/wsdisplay_util.c 1.2
sys/dev/videomode/edid.c 1.12 via patch

Greatly improved Raspberry Pi support. USB and onboard
Ethernet should work.
[skrll, ticket #813]
 1.104.2.3 03-Dec-2017  jdolecek update from HEAD
 1.104.2.2 23-Jun-2013  tls resync from head
 1.104.2.1 25-Feb-2013  tls resync with head
 1.108.10.2 21-Mar-2015  snj Pull up following revision(s) (requested by jmcneill in ticket #631):
sys/dev/wscons/wsconsio.h: revision 1.112 via patch
sys/dev/wsfb/genfb.c: revision 1.57
add WSDISPLAY_TYPE_MESON
--
support 24bpp framebuffers
 1.108.10.1 14-Nov-2014  martin Pull up following revision(s) (requested by jmcneill in ticket #210):
sys/arch/arm/allwinner/awin_board.c: revisions 1.26-1.27
sys/arch/arm/allwinner/awin_debe.c: revisions 1.1-1.6
sys/arch/arm/allwinner/awin_fb.c: revisions 1.1-1.4
sys/arch/arm/allwinner/awin_hdmi.c: revisions 1.3-1.6,1.9-1.12
sys/arch/arm/allwinner/awin_io.c: revision 1.27
sys/arch/arm/allwinner/awin_reg.h: revisions 1.46-1.47,1.49
sys/arch/arm/allwinner/awin_tcon.c: revisions 1.1-1.5
sys/arch/arm/allwinner/awin_var.h: revisions 1.20-1.22
sys/arch/arm/allwinner/files.awin: revisions 1.22-1.23,1.25
sys/arch/evbarm/awin/awin_machdep.c: revision 1.26
sys/arch/evbarm/conf/BPI: revision 1.10
sys/arch/evbarm/conf/CUBIEBOARD: revision 1.32
sys/arch/evbarm/conf/HUMMINGBIRD_A31: revisions 1.17-1.18
sys/dev/wscons/wsconsio.h: revision 1.109

HDMI framebuffer for Allwinner boards.
 1.108.2.1 10-May-2013  khorben Allocated a wskbd entry for the Nokia N900
 1.109.2.6 28-Aug-2017  skrll Sync with HEAD
 1.109.2.5 05-Feb-2017  skrll Sync with HEAD
 1.109.2.4 09-Jul-2016  skrll Sync with HEAD
 1.109.2.3 22-Sep-2015  skrll Sync with HEAD
 1.109.2.2 06-Jun-2015  skrll Sync with HEAD
 1.109.2.1 06-Apr-2015  skrll Sync with HEAD
 1.115.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.115.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.116.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.118.2.1 12-Jun-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1280):

sys/arch/x86/x86/consinit.c: revision 1.29
sys/dev/hyperv/vmbusvar.h: revision 1.2
sys/dev/hyperv/genfb_vmbusvar.h: revision 1.1
sys/arch/x86/x86/x86_autoconf.c: revision 1.78
sys/arch/x86/x86/identcpu.c: revision 1.91
sys/arch/x86/x86/hyperv.c: revision 1.2
sys/arch/x86/x86/hyperv.c: revision 1.3
sys/arch/x86/x86/hyperv.c: revision 1.4
sys/arch/i386/conf/GENERIC: revision 1.1207
sys/dev/wscons/wsconsio.h: revision 1.123
sys/arch/x86/x86/hypervvar.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.528
sys/dev/hyperv/files.hyperv: revision 1.2
sys/arch/x86/include/autoconf.h: revision 1.6
sys/dev/hyperv/hyperv_common.c: revision 1.2
sys/arch/xen/x86/autoconf.c: revision 1.23
sys/arch/x86/pci/pci_machdep.c: revision 1.86
sys/dev/hyperv/hvkbd.c: revision 1.1
sys/dev/hyperv/hypervvar.h: revision 1.2
sys/dev/acpi/vmbus_acpi.c: revision 1.2
sys/dev/hyperv/vmbus.c: revision 1.3
sys/dev/hyperv/hvkbdvar.h: revision 1.1
sys/dev/hyperv/genfb_vmbus.c: revision 1.1

Added drivers for Hyper-V Synthetic Keyboard and Video device.

Avoid undefined reference to `hyperv_guid_video' without vmbus(4).

Avoid undefined reference to `hyperv_is_gen1' without hyperv(4).

Use efi_probe().
 1.121.4.1 10-Jun-2019  christos Sync with HEAD
 1.126.4.1 03-Feb-2024  martin Pull up following revision(s) (requested by jmcneill in ticket #561):

etc/etc.evbppc/Makefile.inc: revision 1.15
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.2
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.3
sys/arch/evbppc/wii/dev/bwdsp.c: revision 1.2
distrib/utils/embedded/files/evbppc_wii_icon.png: revision 1.1
usr.sbin/sysinst/arch/evbppc/md.h: revision 1.4
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.4
sys/arch/evbppc/wii/dev/viio.h: revision 1.1
sys/arch/evbppc/wii/dev/wiifb.c: revision 1.5
sys/arch/evbppc/wii/dev/mainbus.h: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.1
distrib/utils/embedded/conf/wii.conf: revision 1.2
distrib/utils/embedded/conf/wii.conf: revision 1.3
sys/dev/sdmmc/sdhcvar.h: revision 1.34
sys/dev/sdmmc/sdhc.c: revision 1.118
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.1
distrib/utils/embedded/conf/evbppc.conf: revision 1.1
sys/dev/wsfb/genfb.c: revision 1.91
sys/arch/evbppc/wii/dev/resetbtn.c: revision 1.2
sys/dev/wscons/wsconsio.h: revision 1.127
sys/arch/powerpc/oea/oea_machdep.c: revision 1.85
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.1
sys/arch/evbppc/wii/dev/hollywood.h: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.1
sys/arch/evbppc/conf/std.wii: revision 1.2
sys/arch/evbppc/wii/dev/hollywood.c: revision 1.2
sys/arch/evbppc/conf/std.wii: revision 1.3
sys/arch/powerpc/oea/cpu_subr.c: revision 1.109
sys/arch/evbppc/wii/wii_mmuinit.S: revision 1.1
sys/dev/usb/usb.h: revision 1.124
sys/arch/evbppc/wii/machdep.c: revision 1.1
sys/arch/evbppc/wii/dev/rtcsram.c: revision 1.1
sys/arch/powerpc/include/oea/hid.h: revision 1.14
sys/arch/evbppc/wii/mainbus.c: revision 1.1
sys/arch/evbppc/wii/machdep.c: revision 1.2
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.1
sys/arch/evbppc/wii/mainbus.c: revision 1.2
sys/arch/evbppc/wii/machdep.c: revision 1.3
sys/arch/evbppc/wii/dev/ehci_hollywood.c: revision 1.2
sys/arch/evbppc/wii/mainbus.c: revision 1.3
sys/arch/evbppc/wii/machdep.c: revision 1.4
sys/arch/evbppc/wii/dev/hwgpio.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.1
sys/arch/evbppc/wii/dev/sdhc_hollywood.c: revision 1.2
sys/arch/evbppc/wii/wii_locore.S: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.1
sys/arch/evbppc/wii/wii_locore.S: revision 1.2
sys/arch/evbppc/include/wii.h: revision 1.1
sys/arch/evbppc/conf/files.wii: revision 1.2
sys/arch/evbppc/wii/dev/exi.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.2
sys/arch/evbppc/conf/files.wii: revision 1.3
sys/arch/powerpc/powerpc/clock.c: revision 1.18
sys/arch/evbppc/include/wii.h: revision 1.3
sys/arch/evbppc/conf/files.wii: revision 1.4
sys/arch/evbppc/include/wii.h: revision 1.4
sys/arch/evbppc/wii/dev/exi.h: revision 1.1
sys/arch/evbppc/wii/dev/avenc.c: revision 1.1
sys/arch/evbppc/include/wii.h: revision 1.5
sys/arch/evbppc/include/wii.h: revision 1.6
sys/arch/evbppc/include/wii.h: revision 1.7
sys/arch/evbppc/wii/dev/avenc.h: revision 1.1
distrib/utils/embedded/mkimage: revision 1.79
sys/arch/evbppc/conf/WII: revision 1.1
sys/arch/evbppc/conf/INSTALL_WII: revision 1.1
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.1
sys/arch/evbppc/wii/dev/vireg.h: revision 1.1
sys/arch/evbppc/conf/WII: revision 1.2
distrib/utils/embedded/files/evbppc_wii_meta.xml: revision 1.2
sys/arch/evbppc/wii/dev/vireg.h: revision 1.2
sys/arch/evbppc/conf/WII: revision 1.3
sys/arch/evbppc/conf/WII: revision 1.4
usr.sbin/sysinst/arch/evbppc/md.c: revision 1.11
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.1
sys/dev/usb/ehcivar.h: revision 1.52
sys/arch/evbppc/wii/pic_pi.c: revision 1.1
sys/arch/evbppc/wii/dev/ohci_hollywood.c: revision 1.2
etc/etc.evbppc/ttys: revision 1.8
sys/arch/evbppc/wii/dev/bwai.c: revision 1.1
sys/arch/evbppc/wii/dev/bwai.c: revision 1.2
sys/arch/evbppc/wii/dev/bwai.c: revision 1.3
sys/arch/evbppc/wii/autoconf.c: revision 1.1
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.1
sys/arch/evbppc/wii/dev/bwai.h: revision 1.1
sys/arch/evbppc/wii/autoconf.c: revision 1.2
sys/arch/evbppc/conf/Makefile.wii.inc: revision 1.2

powerpc: oea: Fix prefetchable mappings
Prefetchable mappings need PMAP_NOCACHE to get write-combine semantics.
powerpc: oea: Decode IBM750CL L2 cache information.
sdmmc: add support for optional delay after register write
wscons: Add HOLLYWOOD display and YUY2 pixel format types
wsfb: add support for optional "devcmap" property
A hardware driver can supply a pointer to a 16x 32-bit array to override
the default rasops device colour map in the "devcmap" property.
ehci: add EHCIF_32BIT_ACCESS flag to force 32-bit MMIO
fix comments: HID0 ICFI/DCFI are "flash invalidate", not "flush invalidate"
powerpc: fix delay for large (> ~5sec) values
When calculating the target timebase, promote '1000' on the RHS to ULL
to force 64-bit calculation, otherwise 'n * 1000' will overflow.
usb: increase USB_PORT_RESET_RECOVERY from 10ms to 20ms
I changed this from 250ms to 10ms back in 2021 based on a similar FreeBSD
change, but it seems to be a bit too aggressive for some platforms.
evbppc: Add initial support for the Nintendo Wii
wii: support RB_POWERDOWN
build fix: use dd with count=1 for compat with NetBSD dd(1)
wii: Add NTSC 480p support.
In addition to this, add VIIO_{GET,SET}REGS ioctl support to allow for
poking at video interface registers from userland. This is helpful for
debugging display issues.
wii: Add 128x48 icon to SD card image
wii: Fix a comment
wii: Add drivers for Broadway DSP and Audio interface.
0: [*] audio0 @ bwdsp0: Broadway DSP
playback: 16, 2ch, 48000Hz
record: unavailable
(P-) slinear_be 16/16, 2ch, { 48000 }
wii: Add screenblank support.
wii: Use screen dimming register for screen blanking.
wii: Add GPIO, I2C, and basic A/V encoder driver.
wii: Use A/V encoder volume controls instead of using a software filter.
wii: Simply DSP driver - no interrupt handler required.
wii: provide device names to intr_establish
wii$ intrctl list
interrupt id CPU0 device name(s)
pi irq 14 64769* hollywood0
hollywood irq 36 5872* ehci0
hollywood irq 39 58907* sdhc0
hollywood irq 40 4* sdhc1
hollywood irq 49 0* resetbtn0
pi irq 5 0* bwai0
wii: Add support for passing boot options to the kernel.
wii: Add External interface bus and RTC support
wii: Remove objcopy after kernel build.
HBC will do the right thing.
Add wsvt25 entries (off by default) for ttyE0-ttyE3.
Add support for "PAL" (576i) mode on Wii.
 1.127.2.1 02-Aug-2025  perseant Sync with HEAD
 1.167 19-Sep-2025  mrg avoid a dangling pointer error by making sure all exits don't leave
a pointer that won't be actually used. found by GCC 14.
 1.166 01-Mar-2023  riastradh nouveau: Kick out genfb on firmware framebuffer before initializing.

PR kern/53126
 1.165 17-Jul-2022  riastradh branches: 1.165.4;
wsdisplay(4): KNF: return foo, not return (foo)

No functional change intended.
 1.164 17-Jul-2022  riastradh wsdisplay(4): KASSERT(a && b) -> KASSERT(a); KASSERT(b)

Better diagnostics this way. No other functional change. Omit
needless #ifdef DIAGNOSTIC while here; the compiler can optimize the
dead code away.
 1.163 31-Dec-2021  riastradh libkern: Make KASSERT verify expression is valid if !DIAGNOSTIC.

This way it is no longer necessary to mark variables __diagused if
they are used in KASSERT conditions.

Fix fallout from this by removing now-unnecessary and `#ifdef
DIAGNOSTIC'.

Don't do the same for KDASSERT if !DEBUG -- unlike KASSERT and
DIAGNOSTIC, variables needed by KDASSERT and DEBUG are likely to be
expensive to compute (and potentially difficult for a compiler to
prove flushable), so we don't want to require them under !DEBUG.
 1.162 27-Dec-2020  tsutsui Explicitly include generated ioconf.h for struct cfdrivers.
 1.161 25-Dec-2020  tsutsui Use C99 designated initializers for struct consdev.
 1.160 06-Dec-2019  maxv branches: 1.160.8;
localify
 1.159 10-Nov-2019  chs 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.158 25-Jul-2019  jmcneill Halt the old console on both cnattach and preattach
 1.157 24-Jul-2019  jmcneill Call cn_halt for old console in wsdisplay_preattach too
 1.156 23-Jul-2019  rin Enable us to enter DDB from serial console when WSDISPLAY_MULTICONS
is enabled. This is necessary for machines on which framebuffer
console cannot be disabled at run time.

opt_wsdisplay_compat.h is generated for all ports including those
that do not support wscons.

OK Jared
 1.155 23-Jul-2019  jmcneill Call cn_halt on the old console device
 1.154 07-Feb-2019  mlelstv be consistent in checking cn_getc return value.
 1.153 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.152 30-Jan-2019  jmcneill Suspend multicons output to the old console device while replaying
the vcons msgbuf.
 1.151 30-Jan-2019  jmcneill Revert previous as it does not completely solve the problem of detaching a wsdisplay device
 1.150 30-Jan-2019  jmcneill Remove KASSERT in wsdisplay_cndetach. The caller likely doesn't know the
state of the console, so simply do cleanup if a previous console has been
attached.
 1.149 29-Nov-2018  jmcneill Add hw.wsdisplay.multicons sysctl that can be used to disable mirroring wsdisplay output to serial port.
 1.148 15-Nov-2018  jmcneill WSDISPLAYIO_SFONT: Do not attempt to print to the console in the middle of
resizing when DEBUG is defined.
 1.147 26-Sep-2018  bouyer Introduce wsdisplay_isconsole(struct wsdisplay_softc *), which
returns sc->sc_isconsole
 1.146 18-Sep-2018  mrg fix wsdisplay/wskbd and cngetc() return value issues:
- return -1 for error / no character
- allow 0 as a character

cngetc() itself considers any value >= 0 valid, and this matches
the usage in other drivers that return -1 for "not data", vs
polling until something arrives.

removes ^G from spewing out the askname/etc prompts when no key
has been pressed (these come from cngetsn(), ignoring unknown
non printable characters.)

from @skrll with help from @mlelstv.
 1.145 18-Dec-2017  christos branches: 1.145.2; 1.145.4;
ifdef speeding ticket.
 1.144 18-Dec-2017  jmcneill Add WSDISPLAY_MULTICONS option which allows wsdisplay to cooperate with
the console device being overridden. This allows for simultaneous console
output on fb and debug uart.
 1.143 03-Nov-2017  maya Use M_WAITOK if we aren't going to check for NULL before dereferencing
Same function already uses M_WAITOK unconditionally, so this is a safe change

While here, drop null check of M_WAITOK. it shouldn't fail.
 1.142 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.141 25-Jan-2017  jakllsch Double size of WSDISPLAYIO_SFONT name buffer to 32 characters.

We've got a font known as "DejaVu Sans Mono", and that is 17 bytes
by the time it's NUL terminated.
 1.140 07-Jul-2016  msaitoh branches: 1.140.2; 1.140.4;
KNF. Remove extra spaces. No functional change.
 1.139 24-Aug-2015  pooka to garnish, dust with _KERNEL_OPT
 1.138 25-Jul-2014  dholland branches: 1.138.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.137 16-Mar-2014  dholland branches: 1.137.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.136 21-Jan-2014  mlelstv add function to detach wscons from a console. This allows to
switch the console to a different driver.
 1.135 02-Feb-2012  drochner branches: 1.135.6; 1.135.10;
delete virtual screens on detach - this allows to hot-unplug
a udl@usb monitor without crash
 1.134 24-Apr-2011  rmind branches: 1.134.4; 1.134.8;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.133 11-Apr-2010  drochner branches: 1.133.2;
add just as much "detach" code to keep the box from panicking on
removal of a USB "udl" device
(needs more work, but I got the hardware for a quick test only)
 1.132 11-Mar-2010  mrg branches: 1.132.2;
various aprint_* fixes.
 1.131 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.130 02-Feb-2010  drochner branches: 1.130.2;
give up some silly macros which were only used ~once, and reduce
dependency on "locators.h"
makes the code more LKM frienly
 1.129 02-Feb-2010  drochner add hooks to allow terminal emulations to be installed by LKMs
(these are not available in early bootstrap, so this is not an
option for the system's default emulation)
 1.128 28-Jan-2010  drochner -rename the "KS_GROUP_Ascii" key symbol category to "Plain" because
this is what it meant all the time -- it includes characters >127
-delegate translation of all key symbols >127 to the terminal emulation
layer -- formerly everything non-special was passed to the tty subsystem
directly, involving truncation to a "char", which effectively meant
some ISO-1 assumption
 1.127 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.126 22-Jan-2009  drochner Avoid deadlock in tty code if a terminal emulation responds to
type/status/etc inquiries. (PR kern/37915)
This is clearly a design problem in tty, but we need a cheap fix now.
The problem is that ttyinput() tries to pull a spinlock which
is already held on calls to t_oproc.
The workaround is based on the fact that within wscons code, the
wsdisplay_emulinput() function is only called directly from
wsdisplaystart(). So we can be sure that the tty lock is held,
and use an inofficial entry point in ttc.c which avoids the locking.
These ate certainly more assumptions than needed by the fix
proposed in the PR, but it doesn't affect (and slow down) other
tty drivers.
 1.125 15-Jan-2009  yamt - reduce the number of #ifdefs.
- build compat glues if MODULAR.
 1.124 13-Jan-2009  christos provide wscons_event compatibility with 5.0.
 1.123 07-Nov-2008  he In wsdisplay_kbdholdscreen(), just return if sc->sc_focus is NULL.
There is apparently no guarantee sc->sc_focus will be non-NULL,
as proved by a crash I experienced earlier today (admittedly on 4.0.1).
 1.122 12-Jun-2008  cegger branches: 1.122.2; 1.122.4; 1.122.6;
use device_lookup_private to get softc
use device_lookup to get device_t
 1.121 11-Jun-2008  cegger use device_lookup_private to get sc
ok cube
 1.120 25-Mar-2008  cube branches: 1.120.2; 1.120.4; 1.120.6; 1.120.8;
Split device_t and softc for wskbd(4), wsmouse(4) and that creepy wsmux(4).
 1.119 12-Mar-2008  drochner -add a function to vga_post which can be called from DDB to get a
usable VGA console ("call ddb_vgapost")
-allow to switch from/to screens occupied by an X server if the graphics
device is console and in polling mode (ie DDB)
This together allows to get a DDB session on a VGA console if the
system crashed while X11 was running.
As long as the protocol to tell X servers about virtual screen switches
is as primitive as it is, it is unsafe to restart an X session afterwards.
So this is basically for crash analysis.
 1.118 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.117 20-Feb-2008  drochner branches: 1.117.2; 1.117.6;
-Don't detach/attach the X server in the pmf suspend/resume functions
which are called somewhere in the middle of system suspend. Since the
X server accesses hardware directly it is outside our control whether
the devices it accesses are already/still suspended or not, so the only
way is to detach it before any device suspends and re-attach after
everything is awake again.
-For that, export a function ("wsdisplay_handlex" for now) which is
to be called from central suspend/resume code.
-The right way to handle the (normally impossible) case that the X
server is not detached on suspend is to return an error which should
abort the suspend process. pmf doesn't yet handle errors of device
suspend handlers, so as a temporary measure try to suspend anyway,
to get at least a text console.
-Improve error handling of X server attach/detach and maintain a flag
which tracks whether the X server is really active.
 1.116 13-Feb-2008  drochner make the mutex securing a flag which controls screen switched adaptive
for sanity -- it is not yet in a code path which is called from
keyboard interrupt handlers
 1.115 14-Jan-2008  drochner On suspend/resume, just detach/attach the X server (or whatever might
be using the "syncops" protocol) rather than doing a full switch
to virtual screen 1. The latter doesn't have the expected result if
the X server is running on screen 1, and is too much policy for inside
the kernel anyway.
Introduce a mutex+condvar to synchronize these operations, to replace
the spltty()/tsleep(). (for now only used by the new functions,
should be extended to the normal vt switching code)
 1.114 13-Dec-2007  joerg Switch to console on suspend and shutdown, switch back to where the
system was before on resume. This is the second attempt and got more
complicated due to the async nature of VT_ACTIVE. After the initial
switch, check that we ended up on the first screen and if not, wait for
the switch to happen.
 1.113 09-Dec-2007  jmcneill branches: 1.113.2;
Merge jmcneill-pm branch.
 1.112 19-Nov-2007  ad branches: 1.112.2; 1.112.4;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.111 18-Oct-2007  joerg branches: 1.111.2;
Calling device_private once is enough. Reported by macallan@
 1.110 18-Oct-2007  joerg Initialise the callbacks for tty.t_rstrt_ch in ttymalloc
as all drivers but Sun/SPARC's kd.c use the same arguments.
Separate callout_reset into callout_schedule and the initial
callout_setfunc using that.
 1.109 18-Oct-2007  joerg Use aprint API for output and convert to device_t/softc separation.
 1.108 05-Mar-2007  drochner branches: 1.108.2; 1.108.14; 1.108.16; 1.108.20;
It was probably not a good idea to put that scroll stuff to accessops.
But now that it is there, keep it from crashing the box if there is
no valid focus screen.
 1.107 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.106 16-Nov-2006  christos branches: 1.106.2; 1.106.4; 1.106.8;
__unused removal on arguments; approved by core.
 1.105 06-Nov-2006  macallan add wsdisplay_preattach() to attach an early console that can be overridden
by wsdisplay_cnattach() for instance when a hardware-specific display driver
attaches.
as discussed on tech-kern
 1.104 17-Oct-2006  dogcow now that we have -Wno-unused-parameter, back out all the tremendously ugly
code to gratuitously access said parameters.
 1.103 13-Oct-2006  dogcow More -Wunused fallout. sprinkle __unused when possible; otherwise, use the
do { if (&x) {} } while (/* CONSTCOND */ 0);
construct as suggested by uwe in <20061012224845.GA9449@snark.ptc.spbu.ru>.
 1.102 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.101 01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN, batch #2 from Matt Fleming, thanks!

Also, add forgotten splx() calls in some places.
 1.100 21-Jul-2006  ad branches: 1.100.4; 1.100.6;
- Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.99 28-Jun-2006  drochner add a missing splx() in an error path
 1.98 14-May-2006  elad branches: 1.98.4;
integrate kauth.
 1.97 15-Apr-2006  jmmv Remove the getwschar and putwschar accessops from wsdisplay drivers as
requested by uwe@. These were wrong because they were receiving an
emulcookie yet they were accessops (thus having to receive an accesscookie).
Instead, just handle the WSDISPLAYIO_{GET,PUT}WSCHAR ioctls from the
driver's ioctl accessop.

As this reduces the amount of code needed to handle these operations to
two small functions in each driver, remove the WSDISPLAY_CHARFUNCS kernel
option.

Reviewed by, at least, uwe@ and macallan@. No objections in tech-kern@.
 1.96 13-Apr-2006  macallan pass the right cookie to ioctl() and mmap() instead of struct wsscreen *
 1.95 12-Apr-2006  macallan correct typo
 1.94 12-Apr-2006  jmmv Add an extra cookie to the ioctl and mmap wsdisplay accessops that points
to the screen on which they are being called. The driver cannot guess
this by itself but it is needed to implement, at least, the getwschar and
putwschar functions in the correct place. There are no functional changes
yet.

Tested on i386 (vga, vga_raster, machfb, vesafb), macppc and sparc64.
Suggested and reviewed by macallan@.
 1.93 05-Apr-2006  drochner Use the existing ioctl path to call WSDISPLAYIO_GBORDER/WSDISPLAYIO_SBORDER
instead of a separate accessops entry. There is no need to introduce bloat
for the majority of drivers which don't implement this feature.
This should also resolve PR kern/33186 by Valeriy E. Ushakov.
 1.92 29-Mar-2006  thorpej Use device_cfdata().
 1.91 28-Mar-2006  thorpej Use device_unit().
 1.90 05-Mar-2006  christos branches: 1.90.2; 1.90.4;
cleanup more SET/CLR/ISSET lossage
 1.89 18-Feb-2006  jmcneill branches: 1.89.2;
Bunch of changes to wscons in preparation for splash screen support:
* Add WSDISPLAY_TYPE_VESA for vesafb. While here, fix a typo in a comment.
* Add WSDISPLAYIO_SSPLASH and WSDISPLAYIO_SPROGRESS ioctls. The former
toggles the splash screen on and off, and the latter updates the progress
animation.
* Prevent more than one hw driver from claiming to be the console.
* In vcons, keep two pointers to the screen's vcons_data. This lets us
override the original (ie with null emulops during boot), and restore
them later on.
 1.88 07-Feb-2006  jmmv wsevent cleanup:

- Add a wsevent_inject function that atomically adds a set of events to an
event queue and change all code that directly messed with a queue to use it.
- Replace the WSEVENT_WAKEUP macro with a regular function.
- Make WSEVENT_QSIZE, PWSEVENT and splwsevent private definitions to
wsevent.c, instead of exposing them in the header file.
- Make the wsevent_init function take a process to attach to the queue,
instead of leaving this task to the caller (which always did it).

Reviewed in tech-kern@.
 1.87 11-Dec-2005  christos branches: 1.87.2; 1.87.4; 1.87.6;
merge ktrace-lwp.
 1.86 11-Nov-2005  simonb Call nanotime() directly, instead of doing the
microtime()/TIMEVAL_TO_TIMESPEC() dance.
 1.85 06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.84 21-Jun-2005  ws branches: 1.84.2;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.
 1.83 29-May-2005  christos - sprinkle const.
- avoid variable shadowing.
 1.82 27-Feb-2005  perry nuke trailing whitespace
 1.81 29-Jul-2004  jmmv branches: 1.81.4; 1.81.6;
Implement border color customization in wscons(4), only available for vga(4)
at the moment.

This includes the addition of two new wsdisplay ioctls, WSDISPLAY_{G,S}BORDER,
one to get the actual color and one to set it, respectively. Possible colors
match those defined by ANSI (and listed in wsdisplayvar.h).

It also adds two accessops to the underlying graphics device, getborder and
setborder, which mach their ioctl counterparts.

Two kernel options are added: WSDISPLAY_CUSTOM_BORDER, which enables the
ioctls described above (to customize the border color from userland after
boot), and WSDISPLAY_BORDER_COLOR, which sets the color at boot time.
The former is enabled by default on the GENERIC kernel, but not on INSTALL
(among others). The later is always commented out, leaving the usual black
border as a default.

wsconsctl is modified to allow accessing this value easily. For example,
'wsconsctl -d -w border=blue'.
 1.80 28-Jul-2004  jmmv 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.79 20-Jul-2004  heas Add WSDISPLAYIO_[GS]MODE type _DUMBFB - mapped fb (no registers)
Add WSDISPLAYIO_LINEBYTES ioctl - # bytes/row

Used by ffb driver and XFree wsfb driver module - From OpenBSD
 1.78 03-Jun-2004  christos return ENODEV if functions are not compiled in the kernel.
 1.77 28-May-2004  christos PR/19925: David Ferlier: Add scrolling support to wscons.
 1.76 21-Sep-2003  manu branches: 1.76.2;
Do much more sanity checks when handling entries in the sc_scr array
of struct wsdisplay_softc. Unused entries are NULL, and there were
a lot of places where we did not checked that the caller did not
requested an operation on a NULL entry.

While we are there, one bit of KNFification, and make return code more
consistent by always returning the same code (EINVAL) when a screen
number higer than the maximum is requested.
 1.75 29-Jun-2003  fvdl branches: 1.75.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.74 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.73 06-Mar-2003  matt Add cn_halt and cn_flush entries to consdevs. (needed for dma-only console
devices).
 1.72 20-Jan-2003  simonb Use u_int variables for some variables that are passed to
functions that expect u_int parameters.
Remove a semi-colon after the trailing brace of a function.
 1.71 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.70 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.69 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.68 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.67 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.66 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.65 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.64 26-Jun-2002  christos PR/17402: Add wsmoused support by providing get/set char and events.
 1.63 07-Apr-2002  hannken branches: 1.63.2;
Rename WSDISPLAYIO_USEFONT to WSDISPLAYIO_SFONT.

Approved by Matthias Drochner <drochner@netbsd.org>.
 1.62 17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.61 02-Mar-2002  takemura Added wsmux_set_display() to fix the problem that wskbd wan't connected
to any display if keyboard was attached before display and both aren't console.
 1.60 13-Nov-2001  lukem add/cleanup RCSIDs
 1.59 10-Nov-2001  augustss Make wsdisplay_set_console_kbd() a little less twisted.
 1.58 28-Oct-2001  augustss Put in some tests to see if the input source is NULL before using it.
Suggested by Havard Eidnes <he@netbsd.org>.
 1.57 27-Oct-2001  augustss Cosmetics.
 1.56 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.55 15-Oct-2001  augustss branches: 1.55.2;
Don't use wsmux_getmux() if we NWSMUX == 0. Fixes PR kern/14252.
This is only a stop gap measure until the real wsmux changed get in.
 1.54 13-Oct-2001  augustss ANSIfy.
 1.53 13-Oct-2001  augustss Two changes to the wsmux code:
* Allow the wsmux used by wsdisplay for the keyboard(s) to be explicitely
specified with the kbdmux locator.
* Allow keyboards and mice that have a mux to be opened in the regular way.
These changes should be totally backwards compatible.
 1.52 05-Aug-2001  jdolecek branches: 1.52.2;
introduce hard limit on maximum font size (WSDISPLAY_MAXFONTSZ - 512KB)
and keymap size (WSKBDIO_MAXMAPLEN - 64KB)
 1.51 18-May-2001  drochner branches: 1.51.2;
do this console device lookup thing the right way this time
(This "dev" argument to the console functions is nonsense - nothing
should depend on it.)
 1.50 02-May-2001  scw Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.49 04-Jan-2001  enami branches: 1.49.2;
Redo previous; we need to notify kbd driver.
 1.48 03-Jan-2001  enami Avoid null pointer dereference so that boot -d works again.
 1.47 03-Jan-2001  enami Use device_lookup.
 1.46 30-Dec-2000  sato for calling sc->sc_acessops->pollc,
use wsdisplay_cd.cd_devs[unit] in accessing wsdisplay_softc
instead of casting pointer.
XXX: i compiled it in i386, hpcmips, alpha.
 1.45 30-Dec-2000  mjacob Fix at least alpha kernel builds. You can't pun a pointer to a dev_t on
alpha. This is also a bad idea. I really don't know the ws code at all
or I would just fix the whole issue.
 1.44 30-Dec-2000  sato notify console polling mode or not to lower level framebuffer driver.
notify EMUL mode or not to lower level framebuffer driver.
these may use framebuffer level hardware acceleration/software optimization.
 1.43 04-Dec-2000  ad In wsdisplay_switchtoconsole(), ensure that the switch happens
synchronously. Suggested by drochner.
 1.42 02-Nov-2000  eeh Adapt to the new line discipline scheme.
 1.41 01-Oct-2000  takemura - Add ioctl commands to wsdisplay which set/get some LCD status,
backlight, brightness and contrast.
- Add 9 command key symbols which make wskbd to call wsdisplay's
iocontrol.
- Add special key map variant KB_MACHDEP. This variant does not
have any real keymap but it's just a placeholder for machine dependent
maps which will be overwrite by machine dependent keyboard driver.
 1.40 10-Sep-2000  lukem * rename vga_stdscreen* -> vga_25lscreen*
* in vga_init(), set the screen type to WSCONS_DEFAULT_TYPE, which defaults
to "80x25".
XXX: the code currently makes no attempt to ensure that a font
with the appropriate width & height is available, effectively
limiting this default to either "80x25" or "80x24" at this
time.
* make wsdisplay_screentype_pick() non static, so that vga_init() can use it
 1.39 10-Sep-2000  takemura Introduce WSDISPLAY_NULLSCREEN to allow low level device to detach control
process. Hpcmips frame buffer driver(hpcfb) call wsdisplay_switch with
WSDISPLAY_NULLSCREEN to notify user process of suspend/resume event.
 1.38 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.37 30-Mar-2000  augustss branches: 1.37.4;
Remove register declarations.
 1.36 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.35 06-Mar-2000  thorpej Add cnbell() support.
 1.34 05-Jan-2000  drochner replace embedded _rcsid[] string by __KERNEL_RCSID(), remove _copyright[]
 1.33 06-Dec-1999  drochner -allow the "show_screen" call to the display driver to complete
asynchronously, in the same style like the process attach/detach functions
-intercept the "cnpollc" call which originally went directly to the
keyboard driver and keep track whether the console is in "polling" state
(DDB!)
-pass a NULL callback to the screen switcher and the process attach/detach
functions if the console is "polling", to tell them that asynchronous
completion is forbidden
 1.32 01-Dec-1999  augustss Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.
 1.31 19-Oct-1999  mycroft branches: 1.31.2;
Split wsdisplay_usl_ioctl() into two functions -- one which is screen-dependent
and one which isn't. The latter is now used for ttyEcfg, enabling the
VT-switching ioctls to work on it. (This allows Linux X servers to work when
/emul/linux/dev/tty0 is linked to /dev/ttyEcfg.)
 1.30 12-Oct-1999  jdolecek branches: 1.30.2;
add wsdisplay_switchtoconsole() to allow other parts of kernel to force
the wscons to switch to console; code taken from wsdisplay_shutdownhook(),
which is now just a wrapper around wsdisplay_switchtoconsole()
 1.29 01-Oct-1999  ad branches: 1.29.2;
At shutdown, switch to screen 0 on console display so that we see some
notification from the kernel.
 1.28 16-Sep-1999  jdolecek introduce new variable wsdisplay_defaultscreens (initialized to
WSDISPLAY_DEFAULTSCREENS or 0 if it's not defined) and use it instead
of WSDISPLAY_DEFAULTSCREENS as approptiate, so that number of screens
added on bootup is patchable

move printing of info about added screen into separate routine and
print just one message for all screens added in wsdisplay_common_attach(),
such as:
wsdisplay0: screen 1-7 added (80x25, vt100 emulation)

while here, do minor const poisoning

Reviewed by: drochner
Tested by: jdolecek
 1.27 14-Aug-1999  augustss defopt COMPAT_14
 1.26 29-Jul-1999  augustss Add the wsmux pseudo device.
 1.25 17-May-1999  drochner add some #ifdefs to make it link w/o wskbd
(especially for vax)
 1.24 15-May-1999  drochner Get rid of the timeout-driven wscons_glue stuff which caused a lot of
headaches.
Now console keyboard and display are connected at autoconfiguration time,
when the last of them is found. Other keyboards / displays remain
unconnected until a new ioctl (WSDISPLAYIO_SETKEYBOARD) is called.
 1.23 14-May-1999  drochner Sort out the inclusion of wscons source files: the files are only
compiled if the corresponding devices are configured.
(Files calling wscons functions have to check whether these are present.)
 1.22 23-Mar-1999  drochner branches: 1.22.2; 1.22.4;
If no screen got the "focus" (which happens with serial console or if
the current screen is deleted), automatically give focus to the next
screen created. Saves the need to switch to a usable screen manually.
 1.21 13-Mar-1999  drochner Don't initialize any virtual screens (except the system console) at
autoconfiguration time; this can be done better from rc.local.
(For INSTALL kernels, WSDISPLAY_DEFAULTSCREENS can be defined which
sets up that many screens with default parameters.)
 1.20 08-Feb-1999  sommerfe Don't bother copying output queue into automatic buffer; instead, pass
contiguous chunk of outq to emulation routine. Fix based on patch
from M. Drochner, modified to call output routine once with each
contiguous chunk when the ring buffer wraps around.
 1.19 08-Feb-1999  sommerfe Change WSDISPLAYBURST from OBUFSIZ-1 to OBUFSIZ*4, for a ~15x
improvement in the "cat /usr/share/misc/termcap" benchmark on 486/75

ttwrite queues data for us in OBUFSIZ chunks. If we only consume
OBUFSIZ-1 bytes per call to wsdisplaystart(), we're *guaranteed* to
fall behind when given maximum-sized reads (which will defer
processing the leftovers until ttrstrt gets called, after a timeout)

Note that OBUFSIZ*4 may be overkill; OBUFSIZ*3 may be sufficient to
get maximal performance; OBUFSIZ*2 resulted in only about a 2.5x
performance improvement, but it's 2am and I've done enough tweaking
for the night.
 1.18 26-Jan-1999  drochner improve error handling in 2 cases:
1. If the current screen becomes invalid (ie no focus anymore), always
set the keyboard to translating mode. Otherwise, we could get stuck
because the command keystokes don't come through.
2. Catch errors in attaching to a process (X server) - For this,
implement a callback mechanism similar to the detach case. Add an
argument to report an errno via callback.
 1.17 18-Jan-1999  drochner remove wsdisplay_has_emulator(), this is not meaningful with virtual screens,
and it did not work with external (serial) consoles what can cause that
a display has no screen and thus no "focus"
 1.16 17-Jan-1999  drochner -extend the interface for reset-like commands from the keyboard,
add handling of a "close all" command
-split out code common with wsdisplay_delscreen() into
wsdisplay_closescreen()
-add ttymodem call to signal a HUP to the application if the screen
is closed
-add flag to force a "clear screen" on close (XXX should actually be
controlled from userland)
-remove checks for existence of "reset" entries in the emulations - this
is required now
 1.15 14-Jan-1999  drochner -actually reset the terminal emulator on close()
-add a callback to reset the terminal emulator by keyboard command
 1.14 13-Jan-1999  drochner change the way fonts are handled: now we have a display-global ioctl
to download fonts and a per-screen call to select a font
allows easier sharing of ressources in the display driver
change the parameters to the load_font driver vector to pass all
available font information
 1.13 09-Jan-1999  drochner rename "struct wsdisplay_conf" -> "struct wsscreen_internal" to reflect
its real meaning
support allocation and deallocation of virtual screens at runtime
implement a "control device" (minor number = 255) and ioctl()s for screen
allocation/deallocation
minor fixes to consistency checks / error handling
 1.12 15-Dec-1998  drochner make sure programs cannot write to the screen while it is in graphics mode
 1.11 02-Aug-1998  drochner Split the wskbd_attach arguments into console and autoconfiguration parts
(again); put some constant data into shared structures. This makes it
more look like the mouse part, and it helps USB integration.
Implement wskbd_enable() to enable/disable the keyboard.
 1.10 25-Jul-1998  augustss branches: 1.10.2;
Insert lots of ``#if NWSMOUSE > 0'' and ``#if NWSDISPLAY > 0'' to make it
possible to have a wsmouse and/or wskbd without having a wsdisplay.
 1.9 23-Jul-1998  drochner Switch keyboard to "event mode" on open.
Nuke wskbd_set_translation(). It doesn't fit into the "screen" model.
 1.8 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.7 12-Jun-1998  drochner access the "raw keyboard" flag inside spltty() to make sure there is
no screen switch in between
 1.6 11-Jun-1998  drochner Add calls to process / VT synchronization functions (as provided in
wsdisplay_compat_usl.c).
add "sleeping ok" argument to wsdisplay_switch()
implement a way to get raw keyboard data (for X)
some cleanup
 1.5 14-May-1998  drochner Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.4 07-Apr-1998  drochner Fix calculation of console minor device number.
Being here, remove BROKEN_INDIRECT_CONFIG.
 1.3 07-Apr-1998  hannken Initial import of MI keyboard translation for dev/wscons.
 1.2 27-Mar-1998  drochner let all 8 bits go through
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.10.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.10.2.1 07-Aug-1998  drochner make it compile in paddr_t world
 1.22.4.2 02-Aug-1999  thorpej Update from trunk.
 1.22.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.22.2.1 19-Oct-1999  he Pull up revision 1.31 (requested by mycroft):
Enable VT-switching ioctls on ttyEcfg, which allows Linux X servers
to work when properly configured (with symlink /emul/linux/dev/tty0
-> /dev/ttyEcfg).
 1.29.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.30.2.5 05-Jan-2001  bouyer Sync with HEAD
 1.30.2.4 08-Dec-2000  bouyer Sync with HEAD.
 1.30.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.30.2.2 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.30.2.1 20-Oct-1999  thorpej Sync w/ trunk.
 1.31.2.2 19-Oct-1999  mycroft Split wsdisplay_usl_ioctl() into two functions -- one which is screen-dependent
and one which isn't. The latter is now used for ttyEcfg, enabling the
VT-switching ioctls to work on it. (This allows Linux X servers to work when
/emul/linux/dev/tty0 is linked to /dev/ttyEcfg.)
 1.31.2.1 19-Oct-1999  mycroft file wsdisplay.c was added on branch fvdl-softdep on 1999-10-19 00:03:19 +0000
 1.37.4.3 16-Aug-2001  tv Pullup [jdolecek]:

sys/dev/wscons/wsdisplay.c 1.52
sys/dev/wscons/wskbd.c 1.42
sys/dev/wscons/wsconsio.h 1.40

Introduce hard limits on wscons font size and keymap size, and
bounds check against those limits.
 1.37.4.2 13-Dec-2000  he Pull up revision 1.43 (requested by ad):
Make sure to switch consoles synchronously.
 1.37.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.49.2.11 03-Jan-2003  thorpej Sync with HEAD.
 1.49.2.10 11-Nov-2002  nathanw Catch up to -current
 1.49.2.9 18-Oct-2002  nathanw Catch up to -current.
 1.49.2.8 17-Sep-2002  nathanw Catch up to -current.
 1.49.2.7 01-Aug-2002  nathanw Catch up to -current.
 1.49.2.6 17-Apr-2002  nathanw Catch up to -current.
 1.49.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.49.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.49.2.3 22-Oct-2001  nathanw Catch up to -current.
 1.49.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.49.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.51.2.7 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.51.2.6 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.51.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.51.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.51.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.51.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.51.2.1 10-Jul-2001  lukem implement wsdisplaykqfilter()
 1.52.2.4 13-Oct-2001  fvdl Fix misnamed var.
 1.52.2.3 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.52.2.2 26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.52.2.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.55.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.63.2.2 15-Jul-2002  gehenna catch up with -current.
 1.63.2.1 16-May-2002  gehenna Add the character device switch.
Replace the direct-access to devsw table with calling devsw API.
 1.75.2.7 11-Dec-2005  christos Sync with head.
 1.75.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.75.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.75.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.75.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.75.2.2 03-Aug-2004  skrll Sync with HEAD
 1.75.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.76.2.2 07-Jun-2004  tron Pull up revision 1.78 (requested by recht in ticket #451):
return ENODEV if functions are not compiled in the kernel.
 1.76.2.1 07-Jun-2004  tron Pull up revision 1.77 (requested by recht in ticket #451):
PR/19925: David Ferlier: Add scrolling support to wscons.
 1.81.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.81.4.1 29-Apr-2005  kent sync with -current
 1.84.2.8 17-Mar-2008  yamt sync with head.
 1.84.2.7 27-Feb-2008  yamt sync with head.
 1.84.2.6 21-Jan-2008  yamt sync with head
 1.84.2.5 07-Dec-2007  yamt sync with head
 1.84.2.4 27-Oct-2007  yamt sync with head.
 1.84.2.3 03-Sep-2007  yamt sync with head.
 1.84.2.2 30-Dec-2006  yamt sync with head.
 1.84.2.1 21-Jun-2006  yamt sync with head.
 1.87.6.2 01-Jun-2006  kardel Sync with head.
 1.87.6.1 22-Apr-2006  simonb Sync with head.
 1.87.4.1 09-Sep-2006  rpaulo sync with head
 1.87.2.2 01-Mar-2006  yamt sync with head.
 1.87.2.1 18-Feb-2006  yamt sync with head.
 1.89.2.5 11-Aug-2006  yamt sync with head
 1.89.2.4 24-May-2006  yamt sync with head.
 1.89.2.3 11-Apr-2006  yamt sync with head
 1.89.2.2 01-Apr-2006  yamt sync with head.
 1.89.2.1 13-Mar-2006  yamt sync with head.
 1.90.4.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.90.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.90.2.4 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.90.2.3 19-Apr-2006  elad sync with head.
 1.90.2.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.90.2.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.98.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.100.6.2 10-Dec-2006  yamt sync with head.
 1.100.6.1 22-Oct-2006  yamt sync with head
 1.100.4.1 18-Nov-2006  ad Sync with head.
 1.106.8.1 23-Sep-2007  wrstuden Sync with somewhat-recent netbsd-4.
 1.106.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.106.2.2 18-Nov-2008  bouyer Pull up following revision(s) (requested by he in ticket #1235):
sys/dev/wscons/wsdisplay.c: revision 1.123
In wsdisplay_kbdholdscreen(), just return if sc->sc_focus is NULL.
There is apparently no guarantee sc->sc_focus will be non-NULL,
as proved by a crash I experienced earlier today (admittedly on 4.0.1).
 1.106.2.1 11-Sep-2007  msaitoh Pull up following revision(s) (requested by mlelstv in ticket #858):
sys/dev/wscons/wsdisplay.c: revision 1.108
It was probably not a good idea to put that scroll stuff to accessops.
But now that it is there, keep it from crashing the box if there is
no valid focus screen.
 1.108.20.2 21-Nov-2007  bouyer Sync with HEAD
 1.108.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.108.16.3 23-Mar-2008  matt sync with HEAD
 1.108.16.2 09-Jan-2008  matt sync with HEAD
 1.108.16.1 06-Nov-2007  matt sync with HEAD
 1.108.14.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.108.14.4 21-Nov-2007  joerg Sync with HEAD.
 1.108.14.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.108.14.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.108.14.1 04-Aug-2007  jmcneill Switch to the console screen on suspend, and back to the previous screen
on resume.
 1.108.2.1 23-Oct-2007  ad Sync with head.
 1.111.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.111.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.111.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.112.4.1 11-Dec-2007  yamt sync with head.
 1.112.2.1 26-Dec-2007  ad Sync with head.
 1.113.2.2 19-Jan-2008  bouyer Sync with HEAD
 1.113.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.117.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.117.6.4 29-Jun-2008  mjf Sync with HEAD.
 1.117.6.3 06-Apr-2008  mjf - after some discussion with agc@ i agreed it would be a good idea to move
device_unregister_* to device_deregister_* to be more like the pmf(9)
functions, especially since a lot of the time the function calls are next
to each other.

- add device_register_name() support for dk(4).
 1.117.6.2 03-Apr-2008  mjf Sync with HEAD.
 1.117.6.1 29-Mar-2008  mjf - etc/devfsd.conf: Add some rules to give nodes like /dev/tty and
/dev/null better default modes, i.e. 0666.

- sbin/init: Run devfsd -s before going to multiuser.

- sys/arch: Provide arm32, i386, sparc with a mem_init() function to request
device nodes for /dev/null, /dev/zero, etc.

- sys/dev: Convert rnd, wd, agp, raid, cd, sd, wsdisplay, wskbd, wsmouse,
wsmux, tty, bpf, swap to devfs New World Order.

- sys/fs/devfs: Make the visibility attribute of device nodes configurable.
Also provide a function to mount a devfs on boot.

- sys/kern: Add a new boot flag, -n. This disables devfs support. Unless
the -n flag is specified the kernel will mount a devfs file
system on boot.
 1.117.2.1 24-Mar-2008  keiichi sync with head.
 1.120.8.1 18-Jun-2008  simonb Sync with head.
 1.120.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.120.4.3 11-Aug-2010  yamt sync with head.
 1.120.4.2 11-Mar-2010  yamt sync with head
 1.120.4.1 04-May-2009  yamt sync with head.
 1.120.2.1 17-Jun-2008  yamt sync with head.
 1.122.6.2 06-Feb-2009  snj Pull up following revision(s) (requested by drochner in ticket #417):
sys/dev/wscons/wsdisplay.c: revision 1.126
sys/kern/tty.c: revision 1.230
sys/sys/tty.h: revision 1.86
Avoid deadlock in tty code if a terminal emulation responds to
type/status/etc inquiries. (PR kern/37915)
This is clearly a design problem in tty, but we need a cheap fix now.
The problem is that ttyinput() tries to pull a spinlock which
is already held on calls to t_oproc.
The workaround is based on the fact that within wscons code, the
wsdisplay_emulinput() function is only called directly from
wsdisplaystart(). So we can be sure that the tty lock is held,
and use an inofficial entry point in ttc.c which avoids the locking.
These ate certainly more assumptions than needed by the fix
proposed in the PR, but it doesn't affect (and slow down) other
tty drivers.
 1.122.6.1 18-Nov-2008  snj Pull up following revision(s) (requested by he in ticket #68):
sys/dev/wscons/wsdisplay.c: revision 1.123
In wsdisplay_kbdholdscreen(), just return if sc->sc_focus is NULL.
There is apparently no guarantee sc->sc_focus will be non-NULL,
as proved by a crash I experienced earlier today (admittedly on 4.0.1).
 1.122.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.122.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.122.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.130.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.132.2.2 31-May-2011  rmind sync with head
 1.132.2.1 30-May-2010  rmind sync with head
 1.133.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.134.8.1 18-Feb-2012  mrg merge to -current.
 1.134.4.2 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.134.4.1 17-Apr-2012  yamt sync with head
 1.135.10.1 18-May-2014  rmind sync with head
 1.135.6.2 03-Dec-2017  jdolecek update from HEAD
 1.135.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.137.2.1 10-Aug-2014  tls Rebase.
 1.138.4.4 28-Aug-2017  skrll Sync with HEAD
 1.138.4.3 05-Feb-2017  skrll Sync with HEAD
 1.138.4.2 09-Jul-2016  skrll Sync with HEAD
 1.138.4.1 22-Sep-2015  skrll Sync with HEAD
 1.140.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.140.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.145.4.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.145.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.145.4.1 10-Jun-2019  christos Sync with HEAD
 1.145.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.145.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.145.2.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.160.8.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.165.4.1 20-Mar-2023  martin Pull up following revision(s) (requested by mrg in ticket #122):

sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c: revision 1.11
sys/external/bsd/drm2/nouveau/nouveau_pci.c: revision 1.37
sys/external/bsd/drm2/radeon/radeon_pci.c: revision 1.22
sys/dev/wscons/wsdisplay.c: revision 1.166
sys/dev/wscons/wsdisplayvar.h: revision 1.57

amdgpu: Fix bogus loop invariant assertions in amdgpu_gart_map.
nouveau: Kick out genfb on firmware framebuffer before initializing.

PR kern/53126

radeon: Kick out genfb on firmware framebuffer before initializing.
this is the same change as nouveau_pci.c:1.37, and should fix at
least PR#56714 and i thought at least another PR i can't find right
now. it fixes at least 2 different radeon cards for me on UEFI
booted system.
 1.54 01-Jun-2021  riastradh wsdisplay(4): Use C99 initializer for usl_syncops.

Avoid sketchy function pointer cast while here.
 1.53 23-May-2020  ad branches: 1.53.6;
Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.52 15-Dec-2018  christos - Use kmem_intr_{alloc,free}, because on time out we need to free from an
interrupt context.
- Remove parens from returns and useless casts from void.
 1.51 04-Nov-2017  christos branches: 1.51.2; 1.51.4;
use sizeof(*var) instead of sizeof(type)
 1.50 03-Nov-2017  maya use kmem, don't check for allocation failure with KM_SLEEP
 1.49 24-Aug-2015  pooka to garnish, dust with _KERNEL_OPT
 1.48 19-Feb-2013  macallan branches: 1.48.14;
fix a bunch of _IO() ioctl()s to actually work on LP64/BE
( the data pointer is abused to pass an integer, we get a pointer to it so
we need to deref it to something the same size as a pointer to get the
correct value )
now the PCVT compat code ( which is used for VT switching in and out of X )
works on sparc64
 1.47 01-Jul-2010  rmind branches: 1.47.8; 1.47.18;
Remove pfind() and pgfind(), fix locking in various broken uses of these.
Rename real routines to proc_find() and pgrp_find(), remove PFIND_* flags
and have consistent behaviour. Provide proc_find_raw() for special cases.
Fix memory leak in sysctl_proc_corename().

COMPAT_LINUX: rework ptrace() locking, minimise differences between
different versions per-arch.

Note: while this change adds some formal cosmetics for COMPAT_DARWIN and
COMPAT_IRIX - locking there is utterly broken (for ages).

Fixes PR/43176.
 1.46 04-Oct-2009  christos branches: 1.46.2; 1.46.4;
Don't call usl_sync_check_sig from an interrupt context. Call it only if waitok.
Stack trace: mutex_vector_enter <- usl_sync_check_sig <- usl_detachproc <-
wsdisplay_switch <- wskbd_translate <- wskbd_input <-
pckbd_input <- pckbcintr <- intr_biglock_wrapper <-
Xintr_ioapic_edge1
Reported by Anon Ymous
 1.45 24-Apr-2008  ad branches: 1.45.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.44 14-Jan-2008  drochner branches: 1.44.6; 1.44.8;
restructure things a bit so that proclist_mutex is held between the
p_find() and the psignal() which is its purpose after all
 1.43 18-Oct-2007  joerg branches: 1.43.2; 1.43.8;
Use aprint API for output and convert to device_t/softc separation.
 1.42 16-Oct-2007  joerg branches: 1.42.2;
Use callout_setfunc/callout_schedule instead of callout_reset.
Use mstohz for the calculations.
 1.41 09-Jul-2007  ad branches: 1.41.6; 1.41.8; 1.41.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.40 04-Mar-2007  christos branches: 1.40.2; 1.40.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.39 09-Feb-2007  ad branches: 1.39.2;
Merge newlock2 to head.
 1.38 26-Dec-2006  elad Adapt to recent machdep scope changes.

Pointed out by Kouichirou Hiratsuka, thanks!
 1.37 16-Nov-2006  christos branches: 1.37.2;
__unused removal on arguments; approved by core.
 1.36 11-Nov-2006  bjh21 COMPAT_10 implies COMPAT_11, so there's no need to test both.
Also collapse two tightly-nested #ifs into one.
 1.35 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.34 10-Oct-2006  elad Use kauth(9) instead of securelevel.

okay cube@
 1.33 21-Jul-2006  ad branches: 1.33.4; 1.33.6;
- Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.32 14-May-2006  elad integrate kauth.
 1.31 18-Mar-2006  jmcneill Don't use intarg uninitialized in wsdisplay_usl_ioctl2. Fixes CID 2507
 1.30 11-Dec-2005  christos branches: 1.30.4; 1.30.6; 1.30.8; 1.30.10; 1.30.12;
merge ktrace-lwp.
 1.29 05-Dec-2005  macallan back out the changes to KD* ioctl()s for now, seem to break more than they
do good.
 1.28 05-Dec-2005  macallan - remove a leftover debug printf()
- fix the other cases of _IO() type ioctl() abuse ( mainly keyboard related
stuff )
 1.27 04-Dec-2005  macallan Make the VT_* ioctl()s work in LP64/big endian platforms, like sparc64.
The problem is that these ioctl()s are declared as _IO() and expect to pass an
integer as argument, instead of a pointer. When dereferencing the argument
pointer in the ioctl() handler as an int we get the upper 32bit of the value so
we simply dereference it as long. Other _IO() ioctl()s may need similar fixes.

Tested on sparc64, sparc and macppc.
 1.26 02-Jan-2005  martin branches: 1.26.10;
PR kern/28837: fix undef typo.
 1.25 23-Apr-2004  itojun use bounded string ops
 1.24 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.23 29-Jun-2003  fvdl branches: 1.23.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.22 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.21 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.20 10-Dec-2002  fvdl Silence strict-alias warning.
 1.19 23-Sep-2002  simonb Remove breaks after returns, unreachable returns and returns after
returns(!).
 1.18 17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.17 13-Nov-2001  lukem add/cleanup RCSIDs
 1.16 13-Oct-2001  augustss ANSIfy.
 1.15 10-Sep-2000  simonb branches: 1.15.2; 1.15.4;
KNF - variable declarations.
 1.14 10-Sep-2000  takemura Introduce WSDISPLAY_NULLSCREEN to allow low level device to detach control
process. Hpcmips frame buffer driver(hpcfb) call wsdisplay_switch with
WSDISPLAY_NULLSCREEN to notify user process of suspend/resume event.
 1.13 08-Sep-2000  simonb In wsdisplay_usl_ioctl2(), use a u_long for the request to be passed off
to wsdisplay_internal_ioctl() instead of an int.
With this, the pcvt compat ioctl's work on an Alpha and probably other
64 bit archs.
 1.12 23-Mar-2000  thorpej branches: 1.12.4;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.11 06-Dec-1999  drochner -allow the "show_screen" call to the display driver to complete
asynchronously, in the same style like the process attach/detach functions
-intercept the "cnpollc" call which originally went directly to the
keyboard driver and keep track whether the console is in "polling" state
(DDB!)
-pass a NULL callback to the screen switcher and the process attach/detach
functions if the console is "polling", to tell them that asynchronous
completion is forbidden
 1.10 19-Oct-1999  mycroft branches: 1.10.2;
Split wsdisplay_usl_ioctl() into two functions -- one which is screen-dependent
and one which isn't. The latter is now used for ttyEcfg, enabling the
VT-switching ioctls to work on it. (This allows Linux X servers to work when
/emul/linux/dev/tty0 is linked to /dev/ttyEcfg.)
 1.9 30-May-1999  christos branches: 1.9.2; 1.9.4;
Don't let bd.which be unitialized... Thanks Dave!
 1.8 30-May-1999  christos PR/7665: Dave Sainty: X server bell pitch setting doesn't reflect reality
Applied with a little more error checking.
 1.7 29-Jan-1999  drochner branches: 1.7.2; 1.7.4; 1.7.6;
make the timeout for process/vt synchronization "config" settable and
ddb/gdb patchable
 1.6 26-Jan-1999  drochner improve error handling in 2 cases:
1. If the current screen becomes invalid (ie no focus anymore), always
set the keyboard to translating mode. Otherwise, we could get stuck
because the command keystokes don't come through.
2. Catch errors in attaching to a process (X server) - For this,
implement a callback mechanism similar to the detach case. Add an
argument to report an errno via callback.
 1.5 05-Jul-1998  jonathan * defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID (from unsaved buffers).
TODO: revisit interaction between native compat and emul compat usage.
 1.4 25-Jun-1998  thorpej defopt COMPAT_FREEBSD
 1.3 16-Jun-1998  drochner change initialization order to avoid a race condition if a switch is
performed at the same time
 1.2 13-Jun-1998  drochner clean up if a controlling process exits while a switch is in progress,
initialize the flag used for keeping track of this
 1.1 11-Jun-1998  drochner Implement the VT access and keyboard control ioctl()s needed for
compatibility to PCVT, syscons and the Linux console.
 1.7.6.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.7.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.2.2 19-Oct-1999  he Pull up revision 1.10 (requested by mycroft):
Enable VT-switching ioctls on ttyEcfg, which allows Linux X servers
to work when properly configured (with symlink /emul/linux/dev/tty0
-> /dev/ttyEcfg).
 1.7.2.1 21-Jun-1999  perry pullup 1.7->1.9 (christos): fix X server bell pitch
 1.9.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.2.2 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.9.2.1 20-Oct-1999  thorpej Sync w/ trunk.
 1.10.2.2 19-Oct-1999  mycroft Split wsdisplay_usl_ioctl() into two functions -- one which is screen-dependent
and one which isn't. The latter is now used for ttyEcfg, enabling the
VT-switching ioctls to work on it. (This allows Linux X servers to work when
/emul/linux/dev/tty0 is linked to /dev/ttyEcfg.)
 1.10.2.1 19-Oct-1999  mycroft file wsdisplay_compat_usl.c was added on branch fvdl-softdep on 1999-10-19 00:03:19 +0000
 1.12.4.1 10-Sep-2000  simonb Pull up to 1.5 branch approved by jhawk:
Rev 1.13:
In wsdisplay_usl_ioctl2(), use a u_long for the request to be
passed off to wsdisplay_internal_ioctl() instead of an int.
With this, the pcvt compat ioctl's work on an Alpha and
probably other 64 bit archs.
Rev 1.15:
KNF - variable declarations.
 1.15.4.3 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.15.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.8 19-Dec-2002  thorpej Sync with HEAD.
 1.15.2.7 18-Oct-2002  nathanw Catch up to -current.
 1.15.2.6 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.15.2.5 24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.15.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.15.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.15.2.2 22-Oct-2001  nathanw Catch up to -current.
 1.15.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.23.2.6 11-Dec-2005  christos Sync with head.
 1.23.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.23.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.23.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.23.2.2 03-Aug-2004  skrll Sync with HEAD
 1.23.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.26.10.6 21-Jan-2008  yamt sync with head
 1.26.10.5 27-Oct-2007  yamt sync with head.
 1.26.10.4 03-Sep-2007  yamt sync with head.
 1.26.10.3 26-Feb-2007  yamt sync with head.
 1.26.10.2 30-Dec-2006  yamt sync with head.
 1.26.10.1 21-Jun-2006  yamt sync with head.
 1.30.12.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.30.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.30.10.4 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.30.10.3 19-Apr-2006  elad sync with head.
 1.30.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.30.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.30.8.3 11-Aug-2006  yamt sync with head
 1.30.8.2 24-May-2006  yamt sync with head.
 1.30.8.1 01-Apr-2006  yamt sync with head.
 1.30.6.2 01-Jun-2006  kardel Sync with head.
 1.30.6.1 22-Apr-2006  simonb Sync with head.
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.33.6.2 10-Dec-2006  yamt sync with head.
 1.33.6.1 22-Oct-2006  yamt sync with head
 1.33.4.4 25-Jan-2007  ad pfind() can no longer be used from interrupt context.
 1.33.4.3 19-Jan-2007  ad Acquire proclist_mutex before sending signals.
 1.33.4.2 12-Jan-2007  ad Sync with head.
 1.33.4.1 18-Nov-2006  ad Sync with head.
 1.37.2.1 06-Jan-2007  bouyer Pull up following revision(s) (requested by elad in ticket #317):
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.120
sys/dev/wscons/wsdisplay_compat_usl.c: revision 1.38
Adapt to recent machdep scope changes.
Pointed out by Kouichirou Hiratsuka, thanks!
 1.39.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.40.4.1 11-Jul-2007  mjf Sync with head.
 1.40.2.2 23-Oct-2007  ad Sync with head.
 1.40.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.41.10.1 18-Oct-2007  yamt sync with head.
 1.41.8.2 23-Mar-2008  matt sync with HEAD
 1.41.8.1 06-Nov-2007  matt sync with HEAD
 1.41.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.42.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.43.8.1 19-Jan-2008  bouyer Sync with HEAD
 1.43.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.44.8.1 18-May-2008  yamt sync with head.
 1.44.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.45.2.2 11-Aug-2010  yamt sync with head.
 1.45.2.1 11-Mar-2010  yamt sync with head
 1.46.4.1 03-Jul-2010  rmind sync with head
 1.46.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.47.18.2 03-Dec-2017  jdolecek update from HEAD
 1.47.18.1 25-Feb-2013  tls resync with head
 1.47.8.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.48.14.1 22-Sep-2015  skrll Sync with HEAD
 1.51.4.1 10-Jun-2019  christos Sync with HEAD
 1.51.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.53.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.14 06-Dec-2024  macallan allow placement of the glyph cache anywhere in VRAM
mostly for weird HP graphics hardware that has usable off-screen memory to the
right of the visible screen instead of below it
 1.13 20-Feb-2024  macallan branches: 1.13.2;
remove check for unused bits in attr2idx() - this really wasn't helpful
 1.12 08-Jun-2023  macallan allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions
 1.11 03-Sep-2018  riastradh branches: 1.11.30;
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.10 04-Nov-2017  christos branches: 1.10.2; 1.10.4;
use sizeof(*var) instead of sizeof(type)
 1.9 02-Jun-2017  macallan make glyph caches reconfigurable
 1.8 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.7 24-Aug-2015  pooka to garnish, dust with _KERNEL_OPT
 1.6 13-Jan-2014  macallan branches: 1.6.6;
try not to crash when calling glyphcache_wipe() on an uninitialized cache
first step to fix PR 48492
 1.5 13-Nov-2012  macallan branches: 1.5.2;
glyphcache_init(): bail if we don't have enough off-screen memory to be useful
 1.4 04-Oct-2012  macallan allow caching of glyphs with attributes other than the default
while there, also add support for underlined characters
 1.3 12-Jul-2012  macallan branches: 1.3.2;
deal with negative cache sizes
 1.2 19-Apr-2012  macallan no need to convert cell number to coordinates every time we draw a glyph
from cache - just stick the coordinates directly into the map
 1.1 16-Feb-2012  macallan branches: 1.1.2; 1.1.4;
generic support for caching glyphs in video memory
for speeding up anti-aliased fonts on slow CPUs
 1.1.4.6 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.1.4.5 16-Jan-2013  yamt sync with (a bit old) head
 1.1.4.4 30-Oct-2012  yamt sync with head
 1.1.4.3 23-May-2012  yamt sync with head.
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 16-Feb-2012  yamt file wsdisplay_glyphcache.c was added on branch yamt-pagecache on 2012-04-17 00:08:11 +0000
 1.1.2.3 29-Apr-2012  mrg sync to latest -current.
 1.1.2.2 18-Feb-2012  mrg merge to -current.
 1.1.2.1 16-Feb-2012  mrg file wsdisplay_glyphcache.c was added on branch jmcneill-usbmp on 2012-02-18 07:35:14 +0000
 1.3.2.3 03-Dec-2017  jdolecek update from HEAD
 1.3.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.5.2.1 18-May-2014  rmind sync with head
 1.6.6.2 28-Aug-2017  skrll Sync with HEAD
 1.6.6.1 22-Sep-2015  skrll Sync with HEAD
 1.10.4.1 10-Jun-2019  christos Sync with HEAD
 1.10.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.11.30.1 05-Jul-2023  martin Pull up following revision(s) (requested by abs in ticket #224):

sys/dev/wscons/wsdisplay_vconsvar.h: revision 1.34
sys/dev/wscons/wsdisplay_glyphcachevar.h: revision 1.6
sys/arch/sparc/dev/cgfourteen.c: revision 1.94
sys/arch/sparc/dev/cgfourteen.c: revision 1.95
sys/dev/sbus/mgx.c: revision 1.21
sys/dev/sbus/mgx.c: revision 1.22
sys/dev/sbus/mgx.c: revision 1.23
sys/dev/wscons/wsdisplay_vcons.c: revision 1.65
sys/dev/wscons/wsdisplay_vcons.c: revision 1.66
sys/dev/wscons/wsdisplay_glyphcache.c: revision 1.12
sys/arch/sparc/dev/sxvar.h: revision 1.5
sys/arch/sparc/dev/sx.c: revision 1.6
sys/arch/sparc/dev/sx.c: revision 1.7

make vcons_putchar_buffer() return a flag indicating if anything actually
changed, skip the actual drawing op if nothing did

add flags for drivers to requesr R2L bit/byte-ordered fonts, default to
L2R, chack them in vcons_load_font() instead of just trusting that we'd get
what we need

initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.

use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable

allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions

add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations

adapted from xf86-video-suncg14
- use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells

wait for the engine to go idle before issuing rectfill commands
we get occasional overlap with blit commands if we just wait for fifo slots
needs further investigation, it is possible that not all writes to drawing
engine registers are pipelined and of course we don't have docs

following a hunch...
- cache DEC and FG registers, only write them if the value actually changes
- wait for the engine to go idle before writing DEC
- wait for FIFO slots on everything else
with this we avoid waiting if possible and still avoid overlapping blit and
fill commands
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 06-Dec-2024  macallan allow placement of the glyph cache anywhere in VRAM
mostly for weird HP graphics hardware that has usable off-screen memory to the
right of the visible screen instead of below it
 1.6 08-Jun-2023  macallan branches: 1.6.6;
allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions
 1.5 02-Jun-2017  macallan branches: 1.5.42;
make glyph caches reconfigurable
 1.4 04-Oct-2012  macallan branches: 1.4.14;
allow caching of glyphs with attributes other than the default
while there, also add support for underlined characters
 1.3 22-Apr-2012  uebayasi branches: 1.3.2;
Add newline at end of file; fix ALL build for me.
 1.2 19-Apr-2012  macallan no need to convert cell number to coordinates every time we draw a glyph
from cache - just stick the coordinates directly into the map
 1.1 16-Feb-2012  macallan branches: 1.1.2; 1.1.4;
generic support for caching glyphs in video memory
for speeding up anti-aliased fonts on slow CPUs
 1.1.4.4 30-Oct-2012  yamt sync with head
 1.1.4.3 23-May-2012  yamt sync with head.
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 16-Feb-2012  yamt file wsdisplay_glyphcachevar.h was added on branch yamt-pagecache on 2012-04-17 00:08:11 +0000
 1.1.2.3 29-Apr-2012  mrg sync to latest -current.
 1.1.2.2 18-Feb-2012  mrg merge to -current.
 1.1.2.1 16-Feb-2012  mrg file wsdisplay_glyphcachevar.h was added on branch jmcneill-usbmp on 2012-02-18 07:35:14 +0000
 1.3.2.2 03-Dec-2017  jdolecek update from HEAD
 1.3.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.4.14.1 28-Aug-2017  skrll Sync with HEAD
 1.5.42.1 05-Jul-2023  martin Pull up following revision(s) (requested by abs in ticket #224):

sys/dev/wscons/wsdisplay_vconsvar.h: revision 1.34
sys/dev/wscons/wsdisplay_glyphcachevar.h: revision 1.6
sys/arch/sparc/dev/cgfourteen.c: revision 1.94
sys/arch/sparc/dev/cgfourteen.c: revision 1.95
sys/dev/sbus/mgx.c: revision 1.21
sys/dev/sbus/mgx.c: revision 1.22
sys/dev/sbus/mgx.c: revision 1.23
sys/dev/wscons/wsdisplay_vcons.c: revision 1.65
sys/dev/wscons/wsdisplay_vcons.c: revision 1.66
sys/dev/wscons/wsdisplay_glyphcache.c: revision 1.12
sys/arch/sparc/dev/sxvar.h: revision 1.5
sys/arch/sparc/dev/sx.c: revision 1.6
sys/arch/sparc/dev/sx.c: revision 1.7

make vcons_putchar_buffer() return a flag indicating if anything actually
changed, skip the actual drawing op if nothing did

add flags for drivers to requesr R2L bit/byte-ordered fonts, default to
L2R, chack them in vcons_load_font() instead of just trusting that we'd get
what we need

initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.

use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable

allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions

add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations

adapted from xf86-video-suncg14
- use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells

wait for the engine to go idle before issuing rectfill commands
we get occasional overlap with blit commands if we just wait for fifo slots
needs further investigation, it is possible that not all writes to drawing
engine registers are pipelined and of course we don't have docs

following a hunch...
- cache DEC and FG registers, only write them if the value actually changes
- wait for the engine to go idle before writing DEC
- wait for FIFO slots on everything else
with this we avoid waiting if possible and still avoid overlapping blit and
fill commands
 1.6.6.1 02-Aug-2025  perseant Sync with HEAD
 1.5 26-Feb-2019  msaitoh Whitespace change.
 1.4 06-Sep-2015  dholland branches: 1.4.18;
More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.3 15-May-2001  lukem branches: 1.3.170; 1.3.190;
delint: remove comments from macro args; confuses cpp/lint
 1.2 26-Nov-2000  simonb branches: 1.2.2;
Add multiple include detection - all userland installed headers are now
safe.
 1.1 11-Jun-1998  drochner branches: 1.1.14;
Implement the VT access and keyboard control ioctl()s needed for
compatibility to PCVT, syscons and the Linux console.
 1.1.14.1 08-Dec-2000  bouyer Sync with HEAD.
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.190.1 22-Sep-2015  skrll Sync with HEAD
 1.3.170.1 03-Dec-2017  jdolecek update from HEAD
 1.4.18.1 10-Jun-2019  christos Sync with HEAD
 1.3 11-Jun-2020  thorpej Update for proplib(3) API changes.
 1.2 31-Jan-2013  macallan add ioctl(WSDISPLAYIO_GET_FBINFO)
 1.1 29-Jun-2011  macallan branches: 1.1.2; 1.1.8; 1.1.12;
dumping ground for generic driver convenience functions
So far it contains only a generic WSDISPLAYIO_GET_EDID implementation that
relies on EDID data being passed to drivers as a device property.
 1.1.12.1 25-Feb-2013  tls resync with head
 1.1.8.1 13-Feb-2013  riz Pull up following revision(s) (requested by skrll in ticket #813):

etc/MAKEDEV.tmpl 1.160
etc/etc.evbarm/MAKEDEV.conf 1.9
external/broadcom/rpi-firmware/dist/LICENCE.broadcom 1.1
external/broadcom/rpi-firmware/dist/bootcode.bin 1.1
external/broadcom/rpi-firmware/dist/bootcode.bin 1.2
external/broadcom/rpi-firmware/dist/fixup.dat 1.1
external/broadcom/rpi-firmware/dist/fixup.dat 1.2
external/broadcom/rpi-firmware/dist/fixup_cd.dat 1.1
external/broadcom/rpi-firmware/dist/fixup_cd.dat 1.2
external/broadcom/rpi-firmware/dist/start.elf 1.1
external/broadcom/rpi-firmware/dist/start.elf 1.2
external/broadcom/rpi-firmware/dist/start_cd.elf 1.1
external/broadcom/rpi-firmware/dist/start_cd.elf 1.2
sys/arch/arm/broadcom/bcm2835_bsc.c 1.1 via patch
sys/arch/arm/broadcom/bcm2835_bscreg.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_dotg.c 1.1 via patch
sys/arch/arm/broadcom/bcm2835_emmc.c 1.7 via patch
sys/arch/arm/broadcom/bcm2835_genfb.c 1.4 via patch
sys/arch/arm/broadcom/bcm2835_gpio_subr.c 1.2 via patch
sys/arch/arm/broadcom/bcm2835_gpio_subr.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_gpioreg.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_intr.c 1.3 via patch
sys/arch/arm/broadcom/bcm2835_mbox.c 1.5 via patch
sys/arch/arm/broadcom/bcm2835_mbox.h 1.4 via patch
sys/arch/arm/broadcom/bcm2835_obio.c 1.17 via patch
sys/arch/arm/broadcom/bcm2835_pm.c 1.2 via patch
sys/arch/arm/broadcom/bcm2835_rng.c 1.3 via patch
sys/arch/arm/broadcom/bcm2835_space.c 1.5 via patch
sys/arch/arm/broadcom/bcm2835_spi.c 1.1 via patch
sys/arch/arm/broadcom/bcm2835_spireg.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_tmr.c 1.3 via patch
sys/arch/arm/broadcom/bcm2835reg.h 1.10 via patch
sys/arch/arm/broadcom/files.bcm2835 1.14 via patch
sys/arch/evbarm/conf/RPI 1.23 via patch
sys/arch/evbarm/conf/files.rpi 1.3 via patch
sys/arch/evbarm/conf/mk.rpi 1.2 via patch
sys/arch/evbarm/conf/std.rpi 1.4 via patch
sys/arch/evbarm/rpi/rpi_machdep.c 1.34 via patch
sys/arch/evbarm/rpi/rpi_start.S 1.7 via patch
sys/arch/evbarm/rpi/rpi_vcmbox.c 1.2 via patch
sys/arch/evbarm/rpi/vcio.h 1.1 via patch
sys/arch/evbarm/rpi/vcprop.h 1.7 via patch
sys/conf/files patch
sys/dev/sdmmc/sdhc.c 1.43
sys/dev/sdmmc/sdhcvar.h 1.13
sys/dev/usb/dwc_otg.c 1.45 via patch
sys/dev/usb/dwc_otgreg.h 1.5 via patch
sys/dev/usb/dwc_otgvar.h 1.11 via patch
sys/dev/usb/files.usb 1.126 via patch
sys/dev/usb/if_smsc.c 1.7 via patch
sys/dev/usb/if_smscreg.h 1.1 via patch
sys/dev/usb/if_smscvar.h 1.1 via patch
sys/dev/usb/usbdevices.config patch
sys/dev/usb/usbdevs 1.633 via patch
sys/dev/usb/usbdevs.h regen
sys/dev/usb/usbdevs_data.h regen
sys/dev/wscons/wsconsio.h 1.105,1.107 via patch
sys/dev/wscons/wsdisplayvar.h 1.50
sys/dev/wscons/wsdisplay_util.c 1.2
sys/dev/videomode/edid.c 1.12 via patch

Greatly improved Raspberry Pi support. USB and onboard
Ethernet should work.
[skrll, ticket #813]
 1.1.2.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.70 28-Apr-2025  macallan allow to specify the font's height in WSDISPLAYIO_SFONT.
now you can:
/home/ml# wsfontload -l
Gallant 12x22
Droid Sans Mono 10x20
Droid Sans Mono 12x22
Terminal 8x13
HP ROM 10x20
/home/ml# wsconsctl -dw font="Droid Sans Mono@20"
font -> "Droid Sans Mono@20"
/home/ml# wsconsctl -dw font="Droid Sans Mono@22"
font -> "Droid Sans Mono@22"
/home/ml# wsconsctl -dw font="Droid Sans Mono@15"
wsconsctl: WSDISPLAYIO_SFONT: No such file or directory
 1.69 20-Oct-2024  mlelstv Add WSDISPLAYIO_GFONT ioctl to query the installed font name.
 1.68 09-Feb-2024  andvar branches: 1.68.2;
fix spelling mistakes, mainly in comments and log messages.
 1.67 15-Feb-2023  riastradh dev/wscons/wsdisplay_vcons.c: Sprinkle KNF.
 1.66 14-Feb-2023  macallan add flags for drivers to requesr R2L bit/byte-ordered fonts, default to
L2R, chack them in vcons_load_font() instead of just trusting that we'd get
what we need
 1.65 14-Feb-2023  macallan make vcons_putchar_buffer() return a flag indicating if anything actually
changed, skip the actual drawing op if nothing did
 1.64 18-Jul-2022  martin branches: 1.64.4;
Make it compile w/o warnings for !VCONS_DRAW_INTR
 1.63 17-Jul-2022  riastradh wsdisplay(4): Make most of struct vcons_data private.

More importantly, make sizeof(struct vcons_data) independent of
whether VCONS_DRAW_INTR &c. is defined.

Allocate the private space with kmem rather than in the caller.

This still doesn't have very good separation between interface
parameters and internal state, but it's better than before, and is
necessary to make genfb usable in modules.

In arm_simplefb.c, this removes use of the use_intr member. That
assignment became redundant with the introduction of vcons_earlyinit,
so there's no need to replace it by anything.
 1.62 17-Jul-2022  riastradh wsdisplay(4): KNF: return foo, not return (foo)

No functional change intended.
 1.61 17-Jul-2022  riastradh wsdisplay(4): KASSERT(a && b) -> KASSERT(a); KASSERT(b)

Better diagnostics this way. No other functional change. Omit
needless #ifdef DIAGNOSTIC while here; the compiler can optimize the
dead code away.
 1.60 17-Jul-2022  riastradh wsdisplay(4): Use DPRINTF; reduce #ifdefs.
 1.59 17-Jul-2022  riastradh wsdisplay(4): Insert memory barriers for scr_dirty synchronization.

Otherwise vcons_update_screen in vcons_softintr might attempt to draw
stale data from the buffers on the screen.
 1.58 17-Jul-2022  riastradh wsdisplay(4): Factor out scr_dirty setting.

Reduces #ifdefs. No functional change intended.
 1.57 17-Jul-2022  riastradh wsdisplay(4): Factor out use_intr tests.

Nix a lot of #ifdefs this way. Compiler can take care of dead code
if appropriate. No functional change intended.
 1.56 17-Jul-2022  riastradh wsdisplay(4): Factor out WSDISPLAY_SCROLLSUPPORT logic.

Should find a way to avoid the #ifdefs in the .h file, but this makes
the code a good deal more legible and easier to maitain, at least.
No functional change intended.
 1.55 17-Jul-2022  riastradh wsdisplay(4): Nix trailing whitespace.
 1.54 16-Jul-2022  mlelstv modify screen before updating cache.
 1.53 16-May-2021  mlelstv Try to guess attributes better.
 1.52 16-May-2021  mlelstv No need to check cell count.
 1.51 28-Jan-2021  macallan branches: 1.51.4; 1.51.6;
fix logic botch from previous - if we're asked to draw the cursor somewhere
else and it's still visible we need to clear it
 1.50 26-Jan-2021  macallan - refactor vcons_cursor_noread() a bit so it works the same way as the other
_noread() methods instead of duplicating half of vcons_cursor()
- skip clearing the cursor only if we use all _noread() methods
- clear RI_CURSOR in all copy*_noread() methods as well if we overwrite the
cursor
 1.49 25-Jan-2021  macallan clear the RI_CURSOR flag when we overwrite the cursor so we can skip clearing
it when asked to do it later on
saves a bunch of framebuffer writes
 1.48 21-Jan-2021  macallan introduce a putchar() based implementation of cursor() in order to avoid
framebuffer reads
quite a speedup on arm64 / genfb
 1.47 17-Jan-2021  jmcneill Revert previous and introduce vcons_earlyinit, which is like vcons_init
except it does not setup a vcons_intr thread.
 1.46 17-Jan-2021  jmcneill The change from config_interrupts to a kthread for VCONS_DRAW_INTR init
unfortunately makes it easier to trigger a race that results in characters
not being erased properly at boot. Work around the original issue a
different way by creating a fake device_t and defer initialization until
we are sure that config_interrupt threads are done. This is not ideal and
the race is still present but fixing this properly would require a rewrite
to make this code MP-safe.
 1.45 02-Jan-2021  macallan be more careful when optimizing stretches of blanks into erasecols()
now testpat's output is redrawn properly
 1.44 28-Dec-2020  macallan provide (bug)compatibility with vga in WSDISPLAYIO_{PUT|GET}WSCHAR
if row == 0 treat col as linear index into the text / attribute buffer,
transform into proper coordinates as needed for putchar()

with this wsmoused works as expected
 1.43 23-Dec-2020  macallan fix tpyo
spotted by RVP, thanks!
 1.42 21-Nov-2020  mlelstv Fix previous and tag the right callout...
 1.41 21-Nov-2020  mlelstv Run callout without kernel lock, the softint itself is still protected.
 1.40 31-Jul-2019  rin branches: 1.40.8;
When font is switched, not only putchar, but also other ri_ops can be
changed by backend driver, e.g., see rasops1.c:

https://nxr.netbsd.org/xref/src/sys/dev/rasops/rasops1.c#58
 1.39 01-Dec-2018  msaitoh branches: 1.39.4;
Don't abuse config_interrupts()'s first argument. Use kthread instead of
config_interrupt(). OK'd by jmcneill and macallan.
 1.38 02-Jun-2017  macallan branches: 1.38.8; 1.38.10;
- add a cookie to show_screen_cb()
- call show_screen_cb() when loading a font into a visible screen, so this can
be used to track parameters by drivers that use the glyph cache
 1.37 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.36 26-Apr-2017  macallan properly optimize drawing stretches of blanks that are interrupted only by
a change in background colour or flags
 1.35 08-Nov-2015  christos branches: 1.35.8;
PR/50413: Vicente Chaves: Check the allocattr return and return an error.
 1.34 19-Jul-2015  mlelstv use optimized refresh with VCONS_DRAW_INTR even when in polling mode.
 1.33 10-Nov-2014  jmcneill branches: 1.33.2;
allocate char and attr buffers with M_ZERO
 1.32 18-Mar-2014  riastradh branches: 1.32.4;
Merge riastradh-drm2 to HEAD.
 1.31 21-Jan-2014  mlelstv fix build
 1.30 21-Jan-2014  mlelstv keep track of VCONS_DRAW_INTR screen cache also in erasecols/rows and
copycols/rows methods.
 1.29 15-Sep-2013  martin Remove unused variable
 1.28 28-May-2013  macallan branches: 1.28.2; 1.28.4;
in vcons_redraw_screen():
- if RI_FULLCLEAR is set and we use it to clear the screen, don't draw any
whitespaces with the default background colour
- draw stretches of whitespaces with the same background colour using erasecols
 1.27 04-Jan-2012  macallan branches: 1.27.6;
bump character buffers and cache to 32bit per character so flags we store
in the upper bits don't get lost
now autogenerated line drawing characters work with VCONS_DRAW_INTR and don't
get lost when switching screens
 1.26 25-May-2011  macallan branches: 1.26.4; 1.26.8;
remove VCONS_DRAW_ASYNC
it was always experimental, VCONS_DRAW_INTR is much simpler and Just Works.
 1.25 25-May-2011  macallan add a cache so when we update the screen we only redraw the character cells
that actually changed since last time. This gives a noticeable speedup on
slower hardware with dumb framebuffers.
For now this works with VCONS_DRAW_INTR and VCONS_DONT_READ only.
 1.24 18-Feb-2011  jmcneill add vcons_hard_switch, for switching w/o callouts (eg. entering ddb)
 1.23 09-Feb-2011  jmcneill add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined
 1.22 08-Feb-2011  jmcneill VCONS_DRAW_INTR changes:
- use softint instead of workqueue for drawing
- track scr_dirty with atomic_ops
 1.21 08-Feb-2011  jmcneill abuse config_interrupts to make sure we don't switch to 'intr' mode until
interrupts are enabled
 1.20 08-Feb-2011  jmcneill add support for command buffering in vcons. still a WIP, same limitations
as async drawing (no ddb, needs interrupts). you can try it with options
VCONS_DRAW_INTR. as with async, there are still occasional glitches.
 1.19 25-Jan-2011  macallan Add support for asynchronous drawing in vcons.
This is not finished but good enough for others to play with, enable with
options VCONS_DRAW_ASYNC
With this all drawing operations will be posted to a ring buffer instead
of being run directly, and run by a kernel thread. This avoids having to wait
for drawing operations to finish with the kernel lock held ( to a degree at
least ) and scrolling a (slow) framebuffer console should not disrupt other
operations anymore.
Problems:
- we need to switch back to synchronous operations when panicing or entering
ddb, also re-enable async drawing when leaving ddb
- there are still occasional glitches
tested on an SS20 with cg14 and cg6 for dumb and accelerated cases
 1.18 21-Sep-2010  macallan branches: 1.18.2; 1.18.4;
add separate flags for putchar() based copycols() and copyrows() methods
for hw that can accelerate one but not the other, like Sun's Creator series
VCONS_DONT_READ does the same as before
 1.17 18-Aug-2010  macallan Add copycols() and copyrows() methods which, instead of calling the underlying
driver methods, call the driver's putchar() method to redraw the affected
areas.
For unaccelerated framebuffers where reads are expensive and we can't spare
any memory for a shadow framebuffer. Enabled by setting VCONS_DONT_READ in
scr_flags
 1.16 28-Apr-2008  martin branches: 1.16.20; 1.16.22;
Remove clause 3 and 4 from TNF licenses
 1.15 17-Oct-2007  joerg branches: 1.15.16; 1.15.18; 1.15.20;
Use callout_setfunc/callout_schedule and don't cast function pointers.
 1.14 06-Aug-2007  macallan branches: 1.14.2; 1.14.4; 1.14.6; 1.14.8;
add scrollback support
 1.13 28-Jul-2007  rumble branches: 1.13.4;
Set the 'ri' pointer before use.
 1.12 28-Jul-2007  mjf Implement bounds checking in some places in display driver code to avoid
the possibility of a local user panic.
 1.11 09-Jul-2007  ad branches: 1.11.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.10 04-Mar-2007  christos branches: 1.10.2; 1.10.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 16-Nov-2006  christos branches: 1.9.2; 1.9.4; 1.9.8;
__unused removal on arguments; approved by core.
 1.8 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.7 14-May-2006  elad branches: 1.7.6; 1.7.10; 1.7.12; 1.7.14;
integrate kauth.
 1.6 15-Apr-2006  jmmv branches: 1.6.2;
Remove the getwschar and putwschar accessops from wsdisplay drivers as
requested by uwe@. These were wrong because they were receiving an
emulcookie yet they were accessops (thus having to receive an accesscookie).
Instead, just handle the WSDISPLAYIO_{GET,PUT}WSCHAR ioctls from the
driver's ioctl accessop.

As this reduces the amount of code needed to handle these operations to
two small functions in each driver, remove the WSDISPLAY_CHARFUNCS kernel
option.

Reviewed by, at least, uwe@ and macallan@. No objections in tech-kern@.
 1.5 19-Feb-2006  macallan branches: 1.5.2; 1.5.4; 1.5.6;
add a flag to completely disable drawing on a screen
 1.4 18-Feb-2006  jmcneill Bunch of changes to wscons in preparation for splash screen support:
* Add WSDISPLAY_TYPE_VESA for vesafb. While here, fix a typo in a comment.
* Add WSDISPLAYIO_SSPLASH and WSDISPLAYIO_SPROGRESS ioctls. The former
toggles the splash screen on and off, and the latter updates the progress
animation.
* Prevent more than one hw driver from claiming to be the console.
* In vcons, keep two pointers to the screen's vcons_data. This lets us
override the original (ie with null emulops during boot), and restore
them later on.
 1.3 14-Feb-2006  macallan branches: 1.3.2;
bzero() -> memset()
 1.2 14-Feb-2006  macallan do some extra initialization and zeroing, fixes odd problems on x86
 1.1 12-Feb-2006  macallan framework for generic virtual consoles
 1.3.2.3 01-Mar-2006  yamt sync with head.
 1.3.2.2 18-Feb-2006  yamt sync with head.
 1.3.2.1 14-Feb-2006  yamt file wsdisplay_vcons.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:12 +0000
 1.5.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.5.4.1 19-Apr-2006  elad sync with head.
 1.5.2.1 24-May-2006  yamt sync with head.
 1.6.2.2 22-Apr-2006  simonb Sync with head.
 1.6.2.1 15-Apr-2006  simonb file wsdisplay_vcons.c was added on branch simonb-timecounters on 2006-04-22 11:39:44 +0000
 1.7.14.2 10-Dec-2006  yamt sync with head.
 1.7.14.1 22-Oct-2006  yamt sync with head
 1.7.12.2 09-Sep-2006  rpaulo sync with head
 1.7.12.1 14-May-2006  rpaulo file wsdisplay_vcons.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:56:07 +0000
 1.7.10.1 18-Nov-2006  ad Sync with head.
 1.7.6.5 27-Oct-2007  yamt sync with head.
 1.7.6.4 03-Sep-2007  yamt sync with head.
 1.7.6.3 30-Dec-2006  yamt sync with head.
 1.7.6.2 21-Jun-2006  yamt sync with head.
 1.7.6.1 14-May-2006  yamt file wsdisplay_vcons.c was added on branch yamt-lazymbuf on 2006-06-21 15:08:12 +0000
 1.9.8.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.9.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.9.2.1 30-Jul-2007  liamjfoy Pull up following revision(s) (requested by mjf in ticket #799):
sys/dev/ic/pcdisplay_subr.c: revision 1.33
sys/dev/wscons/wsdisplay_vcons.c: revision 1.12
sys/dev/wscons/wsdisplay_vcons.c: revision 1.13
sys/dev/ic/vga_raster.c: revision 1.29
sys/dev/pci/chipsfb.c: revision 1.10
sys/dev/ic/vga.c: revision 1.95
sys/dev/rasops/rasops.c: revision 1.56
sys/dev/isa/ega.c: revision 1.23
Implement bounds checking in some places in display driver code to avoid
the possibility of a local user panic.
Set the 'ri' pointer before use.
 1.10.4.1 11-Jul-2007  mjf Sync with head.
 1.10.2.3 23-Oct-2007  ad Sync with head.
 1.10.2.2 20-Aug-2007  ad Sync with HEAD.
 1.10.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.11.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.13.4.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.4.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.14.8.2 06-Aug-2007  macallan add scrollback support
 1.14.8.1 06-Aug-2007  macallan file wsdisplay_vcons.c was added on branch matt-mips64 on 2007-08-06 03:11:33 +0000
 1.14.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.14.4.1 18-Oct-2007  yamt sync with head.
 1.14.2.1 06-Nov-2007  matt sync with HEAD
 1.15.20.2 09-Oct-2010  yamt sync with head
 1.15.20.1 16-May-2008  yamt sync with head.
 1.15.18.1 18-May-2008  yamt sync with head.
 1.15.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.22.2 31-May-2011  rmind sync with head
 1.16.22.1 05-Mar-2011  rmind sync with head
 1.16.20.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.18.4.3 05-Mar-2011  bouyer Sync with HEAD
 1.18.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.18.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.26.8.1 18-Feb-2012  mrg merge to -current.
 1.26.4.2 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.26.4.1 17-Apr-2012  yamt sync with head
 1.27.6.3 03-Dec-2017  jdolecek update from HEAD
 1.27.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.6.1 23-Jun-2013  tls resync from head
 1.28.4.1 30-Jan-2014  riastradh Make wsdisplay_vcons likelier to be modularizable too.
 1.28.2.1 18-May-2014  rmind sync with head
 1.32.4.1 11-Nov-2014  martin Pull up following revision(s) (requested by jmcneill in ticket #212):
sys/dev/wscons/wsdisplay_vcons.c: revision 1.33
allocate char and attr buffers with M_ZERO
 1.33.2.3 28-Aug-2017  skrll Sync with HEAD
 1.33.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.33.2.1 22-Sep-2015  skrll Sync with HEAD
 1.35.8.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.38.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.38.10.1 10-Jun-2019  christos Sync with HEAD
 1.38.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.39.4.1 15-Aug-2019  martin Pull up following revision(s) (requested by rin in ticket #56):

sys/dev/rasops/rasops.c: revision 1.120
sys/dev/rasops/rasops.h: revision 1.40
sys/dev/rasops/rasops.c: revision 1.121
sys/dev/rasops/rasops.h: revision 1.41
sys/dev/rasops/rasops.c: revision 1.122
sys/dev/rasops/rasops.h: revision 1.42
sys/dev/rasops/rasops.h: revision 1.43
sys/dev/rasops/rasops.h: revision 1.44
sys/dev/rasops/rasops.h: revision 1.45
sys/dev/rasops/rasops.h: revision 1.46
sys/dev/rasops/rasops.h: revision 1.47
sys/dev/rasops/rasops.h: revision 1.48
sys/dev/rasops/rasops32.c: revision 1.40
sys/dev/rasops/rasops32.c: revision 1.41
sys/dev/rasops/rasops32.c: revision 1.42
sys/dev/rasops/rasops32.c: revision 1.43
sys/dev/rasops/rasops32.c: revision 1.44
sys/dev/rasops/rasops32.c: revision 1.45
sys/dev/rasops/rasops32.c: revision 1.46
sys/dev/rasops/rasops1-4_putchar.h: revision 1.1
sys/dev/rasops/rasops1-4_putchar.h: revision 1.2
sys/dev/rasops/rasops1-4_putchar.h: revision 1.3
sys/dev/rasops/rasops1_putchar_width.h: revision 1.3
sys/dev/rasops/rasops1_putchar_width.h: revision 1.4
sys/dev/rasops/rasops1_putchar_width.h: revision 1.5
sys/dev/rasops/rasops1_putchar_width.h: revision 1.6
sys/dev/rasops/README: revision 1.7
sys/dev/rasops/rasops_putchar_aa.h: revision 1.5
sys/dev/rasops/rasops_putchar_aa.h: revision 1.6
sys/dev/rasops/rasops8.c: revision 1.45
sys/dev/rasops/rasops8.c: revision 1.46
sys/dev/rasops/rasops8.c: revision 1.47
sys/dev/rasops/rasops24.c: revision 1.40
sys/dev/rasops/rasops8.c: revision 1.48
sys/dev/rasops/rasops24.c: revision 1.41
sys/dev/rasops/rasops8.c: revision 1.49
sys/dev/rasops/rasops24.c: revision 1.42
sys/dev/rasops/rasops24.c: revision 1.43
sys/dev/rasops/rasops24.c: revision 1.44
sys/dev/rasops/rasops_masks.c: revision 1.10
doc/CHANGES: revision 1.2566
sys/dev/rasops/rasops24.c: revision 1.45
doc/CHANGES: revision 1.2567
sys/dev/rasops/rasops24.c: revision 1.46
sys/dev/rasops/rasops24.c: revision 1.47
sys/dev/rasops/rasops24.c: revision 1.48
sys/dev/rasops/rasops24.c: revision 1.49
sys/dev/rasops/rasops_bitops.h: revision 1.19
sys/dev/rasops/rasops_putchar_aa.h: file removal
sys/dev/wscons/wsdisplay_vcons.c: revision 1.40
sys/dev/rasops/rasops8.c: revision 1.50
sys/dev/rasops/rasops8.c: revision 1.51
sys/dev/rasops/rasops24.c: revision 1.50
sys/arch/luna68k/dev/omrasops.c: revision 1.21
sys/dev/rasops/rasops_bitops.h: revision 1.20
sys/dev/wsfb/genfb.c: revision 1.68
sys/dev/rasops/rasops_bitops.h: revision 1.21
sys/dev/wsfb/genfb.c: revision 1.69
sys/dev/rasops/rasops_putchar_width.h: revision 1.10
sys/dev/rasops/rasops_bitops.h: revision 1.22
sys/dev/rasops/rasops_putchar_width.h: revision 1.11
sys/dev/rasops/rasops_bitops.h: revision 1.23
sys/dev/rasops/rasops_putchar_width.h: revision 1.12
sys/dev/rasops/rasops_bitops.h: revision 1.24
sys/dev/rasops/rasops_putchar_width.h: revision 1.13
sys/dev/rasops/rasops_bitops.h: revision 1.25
sys/dev/rasops/rasops_putchar_width.h: revision 1.14
sys/dev/rasops/rasops_putchar_width.h: revision 1.15
sys/dev/rasops/rasops1.c: revision 1.32
sys/dev/rasops/rasops1.c: revision 1.33
sys/dev/rasops/rasops1.c: revision 1.34
sys/dev/rasops/rasops1.c: revision 1.35
sys/dev/rasops/rasops1.c: revision 1.36
sys/dev/rasops/rasops1.c: revision 1.37
sys/dev/rasops/rasops4.c: revision 1.21
sys/dev/rasops/rasops4.c: revision 1.22
sys/dev/rasops/rasops4.c: revision 1.23
sys/dev/rasops/rasops4.c: revision 1.24
sys/dev/rasops/rasops4.c: revision 1.25
sys/dev/rasops/rasops4.c: revision 1.26
sys/dev/rasops/rasops4.c: revision 1.27
sys/dev/rasops/rasops4.c: revision 1.28
sys/dev/wsfb/genfb.c: revision 1.70
sys/dev/rasops/rasops2.c: revision 1.27
sys/dev/rasops/rasops2.c: revision 1.28
share/man/man9/rasops.9: revision 1.18
sys/dev/rasops/rasops.c: revision 1.102
sys/dev/rasops/rasops2.c: revision 1.29
share/man/man9/rasops.9: revision 1.19
sys/dev/rasops/rasops.c: revision 1.103
sys/dev/rasops/rasops.c: revision 1.104
sys/dev/rasops/rasops.c: revision 1.105
sys/dev/rasops/rasops.c: revision 1.106
sys/dev/rasops/rasops.c: revision 1.107
sys/dev/rasops/rasops_putchar.h: revision 1.6
sys/dev/rasops/rasops.c: revision 1.108
sys/dev/rasops/rasops_putchar.h: revision 1.7
sys/dev/rasops/rasops.c: revision 1.109
sys/dev/rasops/rasops_putchar.h: revision 1.8
sys/dev/rasops/rasops2.c: revision 1.30
sys/dev/rasops/rasops2.c: revision 1.31
sys/dev/rasops/rasops15.c: revision 1.32
sys/dev/rasops/rasops2.c: revision 1.32
sys/dev/rasops/rasops15.c: revision 1.33
sys/dev/rasops/rasops2.c: revision 1.33
sys/dev/rasops/rasops15.c: revision 1.34
sys/dev/rasops/rasops15.c: revision 1.35
sys/dev/rasops/rasops15.c: revision 1.36
sys/dev/rasops/rasops.c: revision 1.110
sys/dev/rasops/rasops15.c: revision 1.37
sys/dev/rasops/rasops.c: revision 1.111
sys/dev/rasops/rasops15.c: revision 1.38
sys/dev/rasops/rasops.c: revision 1.112
sys/dev/rasops/rasops15.c: revision 1.39
sys/dev/rasops/rasops.c: revision 1.113
sys/dev/rasops/rasops.c: revision 1.114
sys/dev/rasops/rasops.c: revision 1.115
sys/dev/rasops/rasops_masks.h: revision 1.9
sys/dev/rasops/rasops.c: revision 1.116
sys/dev/rasops/rasops.c: revision 1.117
sys/dev/rasops/rasops.c: revision 1.118
sys/dev/rasops/rasops.c: revision 1.119
sys/dev/rasops/rasops.h: revision 1.39

Misc clean-up's:
- protect private stuff in rasops.h by _RASOPS_PRIVATE
- staticify rasops_copycols() and rasops_isgray[]
- G/C unused extern int cold
Switch to per-device stamp, and retire stamp_mutex.

Provide buffer capable of single-row pixels in order to make things simpler.

Factor out copy-paste. No functional changes.
When font is switched, not only putchar, but also other ri_ops can be
changed by backend driver, e.g., see rasops1.c:
https://nxr.netbsd.org/xref/src/sys/dev/rasops/rasops1.c#58
4 is 1 << 2, not 1 << 3...

Fix erasecols and do_cursor for font width >= 32 bits.
Also, some cosmetic clean-up's.

Oops, for rasops_copycols(), we cannot use memmove even if src == dst.
On the other hand, memmove is safe for rasops_copyrows().
Fix unaligned writes to buffer, that are introduced in 1.105:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/rasops/rasops.c#rev1.105

Support font width 32 on monochrome screen.

Remove duplicate substitution. Style. No functional changes.

Correct copy count. This affects ``left-to-right'' copy for region
including word boundary.

Fix a bug in shadow fb support for copycols on 1, 2, and 4bpp screen,
which was introduced in 1.18:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/rasops/rasops_bitops.h#rev1.18

Add general putchar functions for 2 and 4bpp.
Note that 1bpp continues to use its local version in rasops1.c,
which is much faster and simpler.

Cosmetic changes. No functional changes.

Reflect reality.

Notify size of shadow framebuffer if enabled.

Fix unaligned word write's to buffer, introduced in rev 1.42:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/rasops/rasops24.c#rev1.42

Real fix for 24-bpp color:
- When centering screen, locate effective base address of framebuffer to
both word and 24-bit color boundary.
- Consistently convert ri_devcmap to ``big endian'' if not RI_BSWAP.

Also, fix possible bug for 15/16-bpp with RI_BSWAP (not tested).

Protect rasops_copy{rows,cols}() by _RASOPS_PRIVATE.

Use _KERNEL_OPT.

Simplify calculation for 12-byte alignment.
No functional changes.

Fix black color-attribution for depths 2 and 4.

Depth 2 is monochrome.
IMO, it is impossible to support ANSI colors on 2-bpp display; fore-
and background can be same value even if they are different colors
logically.

Fix a critical bug for rasops_copyrows() introduced in rev. 1.90:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/rasops/rasops.c#rev1.90
When src < dst, we have to copy backward.

Simplify rasops_do_cursor():
- Use static masks similar to that used in rasops_bitops.h,
rather than generating them on the fly.
- Use pointer for proper type to avoid unnecessary casts.

Use "hp" instead of "hrp" consistently with other files.
No functional changes.

Stop allocating ri_buf and ri_stamp dynamically. As commented in
rasops.h, it is not safe to use kmem_alloc(9) in rasops_init();
rasops routines can be used for early putchar, which means that
UVM is not fully initialized.

Should fix a problem reported by macallan:
http://mail-index.netbsd.org/tech-kern/2019/08/02/msg025327.html

Instead of using ri_buf, inline function rasops_memcpy32() is
introduced to fill 32bit data efficiently.

Instead of using ri_stamp (per device stamp), stamp_ri is
introduced to distinguish for which device stamp is calculated.

Oops, revert an unintentional change for now.

If RI_CLEAR is set, do not forget to clear real framebuffer.

Modify struct rasops_info again (ride 9.99.4 bump).
- remove ri_buf and friends.
- remove ri_stamp and frieds.
- introduce ri_ul, which will be used for scaling underline with font.

Also add hack for ri_ul; adjust its size to obsoleted member, ri_delta,
which was only used rasops routines internally. Now, size and offsets of
all members of struct rasops_info become same with netbsd-9, -8, and -7,
again. So we can safelly pull up fixes to any release branches!

Scaling dimensions of underline by font height.

Currently,
- offset of underline is fixed to 1-row from bottom of characters, and
- height of underline is fixed to 1.
Both are good for standard 8x16 fonts. However, it is too thin for
larger fonts, especially when used on display of high resolution.
Also, 1-row offset of underline is ugly for small fonts, e.g.,
spleen5x8.
Therefore, adjust offset and height as,
- no changes for standard 16-height fonts.
- scaling by font height for larger fonts.
- set offset to zero for fonts of height smaller than 16.

Merge rasops_putchar_aa.h into rasops_putchar.h.

Support scaling underline dimensions by font height.

Separate general putchar for 1-4bpp from rasops_bitops:
- Support anti-aliasing for 2bpp, which works perfectly!
- Support scaling underline dimensions with font height.

We support anti-aliasing for depth 2.
Use switch appropriately.
- Stop showing struct rasops_info; readers can read the header itself.
- Correct description for optimized font widths.
- Remove strange blank line.

Try to improve formatting and naration.

Make rasops_erase{rows,cols}() public again; hp300/diofb uses them.
Pointed out by martin.

When legacy Apple 4-bpp color palette is used, make green dark so that
kernel messages are printed nicely on white background.

Fix color range overflow; we cannot make bright colors more brighter.

Correctly check whether character is in font in rasops_mapchar().
Also, make sure that in putchar functions for completeness.

Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69
is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.

Set 4-bpp devcmap in a similar manner to non-RGB case of 8-bpp.
No functional changes since this is not in use (4-bpp is monochrome).

Misc style clean up's.
- Introduce and use proper macros.
- Use not ambiguous variable names.
- Unify similar functions as possible as I can.
- G/C unused headers.
- Use #include <dev/rasops/foo.h> instead of "foo.h"

No particular functional changes intended.

My work for rasops(9) was finished (hopefully).

I will send pull-up request for netbsd-9, if there are no new failures
reported within few days.

Fix format in order not to confuse changes2html script.
Minor improvements of wording for my entry.

When using stamp, drop attributions other than back and foreground
colors so that stamp is not updated unnecessarily.
 1.40.8.3 03-Apr-2021  thorpej Sync with HEAD.
 1.40.8.2 03-Jan-2021  thorpej Sync w/ HEAD.
 1.40.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.51.6.1 31-May-2021  cjep sync with head
 1.51.4.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.64.4.1 05-Jul-2023  martin Pull up following revision(s) (requested by abs in ticket #224):

sys/dev/wscons/wsdisplay_vconsvar.h: revision 1.34
sys/dev/wscons/wsdisplay_glyphcachevar.h: revision 1.6
sys/arch/sparc/dev/cgfourteen.c: revision 1.94
sys/arch/sparc/dev/cgfourteen.c: revision 1.95
sys/dev/sbus/mgx.c: revision 1.21
sys/dev/sbus/mgx.c: revision 1.22
sys/dev/sbus/mgx.c: revision 1.23
sys/dev/wscons/wsdisplay_vcons.c: revision 1.65
sys/dev/wscons/wsdisplay_vcons.c: revision 1.66
sys/dev/wscons/wsdisplay_glyphcache.c: revision 1.12
sys/arch/sparc/dev/sxvar.h: revision 1.5
sys/arch/sparc/dev/sx.c: revision 1.6
sys/arch/sparc/dev/sx.c: revision 1.7

make vcons_putchar_buffer() return a flag indicating if anything actually
changed, skip the actual drawing op if nothing did

add flags for drivers to requesr R2L bit/byte-ordered fonts, default to
L2R, chack them in vcons_load_font() instead of just trusting that we'd get
what we need

initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.

use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable

allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions

add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations

adapted from xf86-video-suncg14
- use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells

wait for the engine to go idle before issuing rectfill commands
we get occasional overlap with blit commands if we just wait for fifo slots
needs further investigation, it is possible that not all writes to drawing
engine registers are pipelined and of course we don't have docs

following a hunch...
- cache DEC and FG registers, only write them if the value actually changes
- wait for the engine to go idle before writing DEC
- wait for FIFO slots on everything else
with this we avoid waiting if possible and still avoid overlapping blit and
fill commands
 1.68.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 17-Jan-2021  jmcneill trailing whitespace
 1.3 30-Jan-2019  jmcneill branches: 1.3.12;
Suspend multicons output to the old console device while replaying
the vcons msgbuf.
 1.2 25-May-2011  macallan branches: 1.2.56;
add a cache so when we update the screen we only redraw the character cells
that actually changed since last time. This gives a noticeable speedup on
slower hardware with dumb framebuffers.
For now this works with VCONS_DRAW_INTR and VCONS_DONT_READ only.
 1.1 20-Aug-2009  macallan branches: 1.1.2; 1.1.6; 1.1.8;
add vcons_replay_msgbuf() for use by wsdisplay drivers to replay the message
buffer when attaching so older log messages will show up in the scrollback
buffer
Idea from gimpy
 1.1.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.1 31-May-2011  rmind sync with head
 1.1.2.2 16-Sep-2009  yamt sync with head
 1.1.2.1 20-Aug-2009  yamt file wsdisplay_vcons_util.c was added on branch yamt-nfs-mp on 2009-09-16 13:37:59 +0000
 1.2.56.1 10-Jun-2019  christos Sync with HEAD
 1.3.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.35 25-Jul-2025  martin PR 58582: make rasops and wsdisplay headers idempotent.
 1.34 14-Feb-2023  macallan branches: 1.34.6;
add flags for drivers to requesr R2L bit/byte-ordered fonts, default to
L2R, chack them in vcons_load_font() instead of just trusting that we'd get
what we need
 1.33 17-Jul-2022  riastradh branches: 1.33.4;
wsdisplay(4): Make most of struct vcons_data private.

More importantly, make sizeof(struct vcons_data) independent of
whether VCONS_DRAW_INTR &c. is defined.

Allocate the private space with kmem rather than in the caller.

This still doesn't have very good separation between interface
parameters and internal state, but it's better than before, and is
necessary to make genfb usable in modules.

In arm_simplefb.c, this removes use of the use_intr member. That
assignment became redundant with the introduction of vcons_earlyinit,
so there's no need to replace it by anything.
 1.32 17-Jul-2022  riastradh wsdisplay(4): Factor out WSDISPLAY_SCROLLSUPPORT logic.

Should find a way to avoid the #ifdefs in the .h file, but this makes
the code a good deal more legible and easier to maitain, at least.
No functional change intended.
 1.31 21-Jan-2021  macallan introduce a putchar() based implementation of cursor() in order to avoid
framebuffer reads
quite a speedup on arm64 / genfb
 1.30 17-Jan-2021  jmcneill Revert previous and introduce vcons_earlyinit, which is like vcons_init
except it does not setup a vcons_intr thread.
 1.29 17-Jan-2021  jmcneill Add appropriate memory barriers around sc_busy accesses. Fixes an issue
where character cells are sometimes not erased properly on aarch64 at
boot.
 1.28 16-Jan-2021  jmcneill Instead of defining VCONS_DONT_READ as the raw value of 0x30, instead
define it as (VCONS_NO_COPYCOLS|VCONS_NO_COPYROWS) for clarify. NFC.
 1.27 30-Nov-2018  msaitoh branches: 1.27.12;
Remove extra whitespaces.
 1.26 02-Jun-2017  macallan branches: 1.26.8; 1.26.10;
- add a cookie to show_screen_cb()
- call show_screen_cb() when loading a font into a visible screen, so this can
be used to track parameters by drivers that use the glyph cache
 1.25 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.24 02-Jun-2016  macallan provide a default attribute
 1.23 18-Mar-2014  riastradh branches: 1.23.6;
Merge riastradh-drm2 to HEAD.
 1.22 27-Jan-2013  macallan branches: 1.22.2; 1.22.8;
fix a typo in a comment
 1.21 04-Jan-2012  macallan branches: 1.21.2; 1.21.6;
bump character buffers and cache to 32bit per character so flags we store
in the upper bits don't get lost
now autogenerated line drawing characters work with VCONS_DRAW_INTR and don't
get lost when switching screens
 1.20 25-May-2011  macallan branches: 1.20.4; 1.20.8;
remove VCONS_DRAW_ASYNC
it was always experimental, VCONS_DRAW_INTR is much simpler and Just Works.
 1.19 25-May-2011  macallan add a cache so when we update the screen we only redraw the character cells
that actually changed since last time. This gives a noticeable speedup on
slower hardware with dumb framebuffers.
For now this works with VCONS_DRAW_INTR and VCONS_DONT_READ only.
 1.18 18-Feb-2011  jmcneill add vcons_hard_switch, for switching w/o callouts (eg. entering ddb)
 1.17 09-Feb-2011  jmcneill add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined
 1.16 08-Feb-2011  jmcneill VCONS_DRAW_INTR changes:
- use softint instead of workqueue for drawing
- track scr_dirty with atomic_ops
 1.15 08-Feb-2011  jmcneill abuse config_interrupts to make sure we don't switch to 'intr' mode until
interrupts are enabled
 1.14 08-Feb-2011  jmcneill add support for command buffering in vcons. still a WIP, same limitations
as async drawing (no ddb, needs interrupts). you can try it with options
VCONS_DRAW_INTR. as with async, there are still occasional glitches.
 1.13 25-Jan-2011  macallan Add support for asynchronous drawing in vcons.
This is not finished but good enough for others to play with, enable with
options VCONS_DRAW_ASYNC
With this all drawing operations will be posted to a ring buffer instead
of being run directly, and run by a kernel thread. This avoids having to wait
for drawing operations to finish with the kernel lock held ( to a degree at
least ) and scrolling a (slow) framebuffer console should not disrupt other
operations anymore.
Problems:
- we need to switch back to synchronous operations when panicing or entering
ddb, also re-enable async drawing when leaving ddb
- there are still occasional glitches
tested on an SS20 with cg14 and cg6 for dumb and accelerated cases
 1.12 21-Sep-2010  macallan branches: 1.12.2; 1.12.4;
add separate flags for putchar() based copycols() and copyrows() methods
for hw that can accelerate one but not the other, like Sun's Creator series
VCONS_DONT_READ does the same as before
 1.11 18-Aug-2010  macallan Add copycols() and copyrows() methods which, instead of calling the underlying
driver methods, call the driver's putchar() method to redraw the affected
areas.
For unaccelerated framebuffers where reads are expensive and we can't spare
any memory for a shadow framebuffer. Enabled by setting VCONS_DONT_READ in
scr_flags
 1.10 20-Aug-2009  macallan branches: 1.10.2; 1.10.4;
add vcons_replay_msgbuf() for use by wsdisplay drivers to replay the message
buffer when attaching so older log messages will show up in the scrollback
buffer
Idea from gimpy
 1.9 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8 06-Aug-2007  macallan branches: 1.8.22; 1.8.24; 1.8.26; 1.8.28;
add scrollback support
 1.7 09-Jul-2007  ad branches: 1.7.2; 1.7.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.6 04-Mar-2007  christos branches: 1.6.2; 1.6.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.5 22-Sep-2006  elad branches: 1.5.4;
In struct vcons_data, don't depend on DIAGNOSTIC and always include
switch_poll_count.

okay chs@
 1.4 15-Apr-2006  jmmv branches: 1.4.2; 1.4.8; 1.4.12; 1.4.14; 1.4.16;
Remove the getwschar and putwschar accessops from wsdisplay drivers as
requested by uwe@. These were wrong because they were receiving an
emulcookie yet they were accessops (thus having to receive an accesscookie).
Instead, just handle the WSDISPLAYIO_{GET,PUT}WSCHAR ioctls from the
driver's ioctl accessop.

As this reduces the amount of code needed to handle these operations to
two small functions in each driver, remove the WSDISPLAY_CHARFUNCS kernel
option.

Reviewed by, at least, uwe@ and macallan@. No objections in tech-kern@.
 1.3 19-Feb-2006  macallan branches: 1.3.2; 1.3.4; 1.3.6;
add a flag to completely disable drawing on a screen
 1.2 18-Feb-2006  jmcneill Bunch of changes to wscons in preparation for splash screen support:
* Add WSDISPLAY_TYPE_VESA for vesafb. While here, fix a typo in a comment.
* Add WSDISPLAYIO_SSPLASH and WSDISPLAYIO_SPROGRESS ioctls. The former
toggles the splash screen on and off, and the latter updates the progress
animation.
* Prevent more than one hw driver from claiming to be the console.
* In vcons, keep two pointers to the screen's vcons_data. This lets us
override the original (ie with null emulops during boot), and restore
them later on.
 1.1 12-Feb-2006  macallan branches: 1.1.2;
framework for generic virtual consoles
 1.1.2.3 01-Mar-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 12-Feb-2006  yamt file wsdisplay_vconsvar.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:12 +0000
 1.3.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.3.4.1 19-Apr-2006  elad sync with head.
 1.3.2.1 24-May-2006  yamt sync with head.
 1.4.16.1 22-Oct-2006  yamt sync with head
 1.4.14.2 09-Sep-2006  rpaulo sync with head
 1.4.14.1 15-Apr-2006  rpaulo file wsdisplay_vconsvar.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:56:07 +0000
 1.4.12.1 18-Nov-2006  ad Sync with head.
 1.4.8.4 03-Sep-2007  yamt sync with head.
 1.4.8.3 30-Dec-2006  yamt sync with head.
 1.4.8.2 21-Jun-2006  yamt sync with head.
 1.4.8.1 15-Apr-2006  yamt file wsdisplay_vconsvar.h was added on branch yamt-lazymbuf on 2006-06-21 15:08:12 +0000
 1.4.2.2 22-Apr-2006  simonb Sync with head.
 1.4.2.1 15-Apr-2006  simonb file wsdisplay_vconsvar.h was added on branch simonb-timecounters on 2006-04-22 11:39:44 +0000
 1.5.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.6.4.1 11-Jul-2007  mjf Sync with head.
 1.6.2.2 20-Aug-2007  ad Sync with HEAD.
 1.6.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.7.6.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.7.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.8.28.2 06-Aug-2007  macallan add scrollback support
 1.8.28.1 06-Aug-2007  macallan file wsdisplay_vconsvar.h was added on branch matt-mips64 on 2007-08-06 03:11:33 +0000
 1.8.26.3 09-Oct-2010  yamt sync with head
 1.8.26.2 16-Sep-2009  yamt sync with head
 1.8.26.1 16-May-2008  yamt sync with head.
 1.8.24.1 18-May-2008  yamt sync with head.
 1.8.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.10.4.2 31-May-2011  rmind sync with head
 1.10.4.1 05-Mar-2011  rmind sync with head
 1.10.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.12.4.3 05-Mar-2011  bouyer Sync with HEAD
 1.12.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.12.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.12.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.20.8.1 18-Feb-2012  mrg merge to -current.
 1.20.4.2 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.20.4.1 17-Apr-2012  yamt sync with head
 1.21.6.3 03-Dec-2017  jdolecek update from HEAD
 1.21.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.6.1 25-Feb-2013  tls resync with head
 1.21.2.1 13-Feb-2013  riz Pull up following revision(s) (requested by skrll in ticket #818):
xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c: revision 1.14
xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c: revision 1.15
external/mit/xorg/server/xorg-server/hw/xfree86/xorgos/Makefile: revision 1.32
external/mit/xorg/server/drivers/xf86-input-keyboard/Makefile: revision 1.15
sys/dev/wsfb/genfb.c: revision 1.49
distrib/sets/lists/xserver/md.evbarm: revision 1.1
sys/dev/wscons/wsdisplay_vconsvar.h: revision 1.22
external/mit/xorg/server/xorg-server/Makefile.common: revision 1.24
xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb.h: revision 1.4
external/mit/xorg/server/drivers/Makefile: revision 1.61
sys/dev/wsfb/genfb.c: revision 1.50
enable X11 build for evbarm.
aprint_verbose -> aprint_debug
WSDISPLAY_TYPE_VC4 framebuffer is BGR
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error
default to swkbd mode on evbarm as well, now X without config should work
properly on BeagleBoard, RPi and the like
fix a typo in a comment
use WSDISPLAYIO_GET_FBINFO if available
 1.22.8.1 29-Jan-2014  riastradh Make genfb a little friendlier to modules.

This is not enough to make it actually work as a module itself, but
it's enough to make the i915drm module use genfb.
 1.22.2.1 18-May-2014  rmind sync with head
 1.23.6.2 28-Aug-2017  skrll Sync with HEAD
 1.23.6.1 09-Jul-2016  skrll Sync with HEAD
 1.26.10.1 10-Jun-2019  christos Sync with HEAD
 1.26.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.27.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.33.4.1 05-Jul-2023  martin Pull up following revision(s) (requested by abs in ticket #224):

sys/dev/wscons/wsdisplay_vconsvar.h: revision 1.34
sys/dev/wscons/wsdisplay_glyphcachevar.h: revision 1.6
sys/arch/sparc/dev/cgfourteen.c: revision 1.94
sys/arch/sparc/dev/cgfourteen.c: revision 1.95
sys/dev/sbus/mgx.c: revision 1.21
sys/dev/sbus/mgx.c: revision 1.22
sys/dev/sbus/mgx.c: revision 1.23
sys/dev/wscons/wsdisplay_vcons.c: revision 1.65
sys/dev/wscons/wsdisplay_vcons.c: revision 1.66
sys/dev/wscons/wsdisplay_glyphcache.c: revision 1.12
sys/arch/sparc/dev/sxvar.h: revision 1.5
sys/arch/sparc/dev/sx.c: revision 1.6
sys/arch/sparc/dev/sx.c: revision 1.7

make vcons_putchar_buffer() return a flag indicating if anything actually
changed, skip the actual drawing op if nothing did

add flags for drivers to requesr R2L bit/byte-ordered fonts, default to
L2R, chack them in vcons_load_font() instead of just trusting that we'd get
what we need

initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.

use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable

allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions

add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations

adapted from xf86-video-suncg14
- use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells

wait for the engine to go idle before issuing rectfill commands
we get occasional overlap with blit commands if we just wait for fifo slots
needs further investigation, it is possible that not all writes to drawing
engine registers are pipelined and of course we don't have docs

following a hunch...
- cache DEC and FG registers, only write them if the value actually changes
- wait for the engine to go idle before writing DEC
- wait for FIFO slots on everything else
with this we avoid waiting if possible and still avoid overlapping blit and
fill commands
 1.34.6.1 02-Aug-2025  perseant Sync with HEAD
 1.57 01-Mar-2023  riastradh nouveau: Kick out genfb on firmware framebuffer before initializing.

PR kern/53126
 1.56 29-Jan-2022  uwe branches: 1.56.4;
Default WSDISPLAY_BORDER_COLOR to WS_DEFAULT_BG.
Avoids black overscan area when WS_DEFAULT_BG is set.
 1.55 30-Jan-2019  jmcneill Suspend multicons output to the old console device while replaying
the vcons msgbuf.
 1.54 04-Dec-2018  mlelstv rasops reused wscons attribute bits for internal control.
- make upper 4 attribute bits available for such use
- use wscons flag names instead of literal constants.
 1.53 26-Sep-2018  bouyer Introduce wsdisplay_isconsole(struct wsdisplay_softc *), which
returns sc->sc_isconsole
 1.52 19-May-2017  macallan branches: 1.52.8; 1.52.10;
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.51 21-Jan-2014  mlelstv branches: 1.51.6;
add function to detach wscons from a console. This allows to
switch the console to a different driver.
 1.50 31-Jan-2013  macallan branches: 1.50.2;
add ioctl(WSDISPLAYIO_GET_FBINFO)
 1.49 29-Jun-2011  macallan branches: 1.49.2; 1.49.8; 1.49.12;
declare wsdisplayio_get_edid()
 1.48 02-Feb-2010  drochner give up some silly macros which were only used ~once, and reduce
dependency on "locators.h"
makes the code more LKM frienly
 1.47 25-Mar-2008  cube branches: 1.47.4;
Split device_t and softc for wskbd(4), wsmouse(4) and that creepy wsmux(4).
 1.46 20-Feb-2008  drochner branches: 1.46.6;
-Don't detach/attach the X server in the pmf suspend/resume functions
which are called somewhere in the middle of system suspend. Since the
X server accesses hardware directly it is outside our control whether
the devices it accesses are already/still suspended or not, so the only
way is to detach it before any device suspends and re-attach after
everything is awake again.
-For that, export a function ("wsdisplay_handlex" for now) which is
to be called from central suspend/resume code.
-The right way to handle the (normally impossible) case that the X
server is not detached on suspend is to return an error which should
abort the suspend process. pmf doesn't yet handle errors of device
suspend handlers, so as a temporary measure try to suspend anyway,
to get at least a text console.
-Improve error handling of X server attach/detach and maintain a flag
which tracks whether the X server is really active.
 1.45 13-Dec-2007  joerg Switch to console on suspend and shutdown, switch back to where the
system was before on resume. This is the second attempt and got more
complicated due to the async nature of VT_ACTIVE. After the initial
switch, check that we ended up on the first screen and if not, wait for
the switch to happen.
 1.44 19-Oct-2007  dogcow branches: 1.44.4; 1.44.8;
If you're going to use device_t, may as well include sys/device.h; unb0rks
the build for sparc{,64}.
 1.43 18-Oct-2007  joerg Use aprint API for output and convert to device_t/softc separation.
 1.42 04-Mar-2007  christos branches: 1.42.2; 1.42.14; 1.42.16; 1.42.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.41 06-Nov-2006  macallan branches: 1.41.4;
add wsdisplay_preattach() to attach an early console that can be overridden
by wsdisplay_cnattach() for instance when a hardware-specific display driver
attaches.
as discussed on tech-kern
 1.40 09-Oct-2006  peter KNF: No variable names in the prototype.
 1.39 15-Apr-2006  jmmv branches: 1.39.8; 1.39.10;
Remove the getwschar and putwschar accessops from wsdisplay drivers as
requested by uwe@. These were wrong because they were receiving an
emulcookie yet they were accessops (thus having to receive an accesscookie).
Instead, just handle the WSDISPLAYIO_{GET,PUT}WSCHAR ioctls from the
driver's ioctl accessop.

As this reduces the amount of code needed to handle these operations to
two small functions in each driver, remove the WSDISPLAY_CHARFUNCS kernel
option.

Reviewed by, at least, uwe@ and macallan@. No objections in tech-kern@.
 1.38 12-Apr-2006  jmmv Add an extra cookie to the ioctl and mmap wsdisplay accessops that points
to the screen on which they are being called. The driver cannot guess
this by itself but it is needed to implement, at least, the getwschar and
putwschar functions in the correct place. There are no functional changes
yet.

Tested on i386 (vga, vga_raster, machfb, vesafb), macppc and sparc64.
Suggested and reviewed by macallan@.
 1.37 07-Apr-2006  drochner don't include opt_wsdisplay_border.h here, to limit dependencies
 1.36 05-Apr-2006  drochner Use the existing ioctl path to call WSDISPLAYIO_GBORDER/WSDISPLAYIO_SBORDER
instead of a separate accessops entry. There is no need to introduce bloat
for the majority of drivers which don't implement this feature.
This should also resolve PR kern/33186 by Valeriy E. Ushakov.
 1.35 19-Feb-2006  jmcneill branches: 1.35.2; 1.35.4; 1.35.6;
Multiple inclusion protection.
 1.34 11-Dec-2005  christos branches: 1.34.2; 1.34.4; 1.34.6;
merge ktrace-lwp.
 1.33 29-May-2005  christos branches: 1.33.2;
- sprinkle const.
- avoid variable shadowing.
 1.32 23-May-2005  martin Rename REALWHITE to SNOWWHITE.
While there, add LIGHT versions of the other predefined colours as well.
 1.31 22-May-2005  martin Define a real white color - since WSCOL_WHITE is ANSI-emulation specific
defined as grey (which can't be fixed w/o breaking user config files).
Fixes PR kern/30064.
 1.30 04-Feb-2005  perry branches: 1.30.4;
de-__P
 1.29 29-Jul-2004  jmmv branches: 1.29.4; 1.29.6;
Implement border color customization in wscons(4), only available for vga(4)
at the moment.

This includes the addition of two new wsdisplay ioctls, WSDISPLAY_{G,S}BORDER,
one to get the actual color and one to set it, respectively. Possible colors
match those defined by ANSI (and listed in wsdisplayvar.h).

It also adds two accessops to the underlying graphics device, getborder and
setborder, which mach their ioctl counterparts.

Two kernel options are added: WSDISPLAY_CUSTOM_BORDER, which enables the
ioctls described above (to customize the border color from userland after
boot), and WSDISPLAY_BORDER_COLOR, which sets the color at boot time.
The former is enabled by default on the GENERIC kernel, but not on INSTALL
(among others). The later is always commented out, leaving the usual black
border as a default.

wsconsctl is modified to allow accessing this value easily. For example,
'wsconsctl -d -w border=blue'.
 1.28 28-Jul-2004  jmmv 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.27 28-May-2004  christos move scroll function definition last.
 1.26 28-May-2004  christos PR/19925: David Ferlier: Add scrolling support to wscons.
 1.25 29-Jun-2003  fvdl branches: 1.25.2; 1.25.4;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.24 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.23 15-Oct-2002  junyoung Add modecookie to struct wsscreen_descr, which is used to point to video
mode specific information.
 1.22 04-Jul-2002  junyoung alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.21 26-Jun-2002  christos PR/17402: Add wsmoused support by providing get/set char and events.
 1.20 13-Oct-2001  augustss branches: 1.20.10;
ANSIfy.
 1.19 13-Oct-2001  augustss Two changes to the wsmux code:
* Allow the wsmux used by wsdisplay for the keyboard(s) to be explicitely
specified with the kbdmux locator.
* Allow keyboards and mice that have a mux to be opened in the regular way.
These changes should be totally backwards compatible.
 1.18 30-Dec-2000  sato branches: 1.18.2; 1.18.4;
notify console polling mode or not to lower level framebuffer driver.
notify EMUL mode or not to lower level framebuffer driver.
these may use framebuffer level hardware acceleration/software optimization.
 1.17 10-Sep-2000  lukem * rename vga_stdscreen* -> vga_25lscreen*
* in vga_init(), set the screen type to WSCONS_DEFAULT_TYPE, which defaults
to "80x25".
XXX: the code currently makes no attempt to ensure that a font
with the appropriate width & height is available, effectively
limiting this default to either "80x25" or "80x24" at this
time.
* make wsdisplay_screentype_pick() non static, so that vga_init() can use it
 1.16 10-Sep-2000  takemura Introduce WSDISPLAY_NULLSCREEN to allow low level device to detach control
process. Hpcmips frame buffer driver(hpcfb) call wsdisplay_switch with
WSDISPLAY_NULLSCREEN to notify user process of suspend/resume event.
 1.15 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.14 06-Dec-1999  drochner branches: 1.14.4;
-allow the "show_screen" call to the display driver to complete
asynchronously, in the same style like the process attach/detach functions
-intercept the "cnpollc" call which originally went directly to the
keyboard driver and keep track whether the console is in "polling" state
(DDB!)
-pass a NULL callback to the screen switcher and the process attach/detach
functions if the console is "polling", to tell them that asynchronous
completion is forbidden
 1.13 19-Oct-1999  mycroft branches: 1.13.2;
Split wsdisplay_usl_ioctl() into two functions -- one which is screen-dependent
and one which isn't. The latter is now used for ttyEcfg, enabling the
VT-switching ioctls to work on it. (This allows Linux X servers to work when
/emul/linux/dev/tty0 is linked to /dev/ttyEcfg.)
 1.12 12-Oct-1999  jdolecek branches: 1.12.2;
add wsdisplay_switchtoconsole() to allow other parts of kernel to force
the wscons to switch to console; code taken from wsdisplay_shutdownhook(),
which is now just a wrapper around wsdisplay_switchtoconsole()
 1.11 12-Feb-1999  drochner branches: 1.11.2; 1.11.8;
change the "mapchar" interface to return a "quality" or "match level"
arguments which allows to find approximations for characters which are
not present in a font
 1.10 26-Jan-1999  drochner improve error handling in 2 cases:
1. If the current screen becomes invalid (ie no focus anymore), always
set the keyboard to translating mode. Otherwise, we could get stuck
because the command keystokes don't come through.
2. Catch errors in attaching to a process (X server) - For this,
implement a callback mechanism similar to the detach case. Add an
argument to report an errno via callback.
 1.9 13-Jan-1999  drochner change the way fonts are handled: now we have a display-global ioctl
to download fonts and a per-screen call to select a font
allows easier sharing of ressources in the display driver
change the parameters to the load_font driver vector to pass all
available font information
 1.8 09-Jan-1999  drochner add ioctl()s for screen allocation/deallocation
 1.7 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.6 28-Jul-1998  augustss branches: 1.6.2;
Do locator related defines using defines from locators.h rather
than literal constants.
 1.5 26-Jun-1998  drochner define a "mapping" function which can be used by the emulation module
to display non-ASCII characters
 1.4 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.3 11-Jun-1998  drochner Implement the VT access and keyboard control ioctl()s needed for
compatibility to PCVT, syscons and the Linux console.
 1.2 14-May-1998  drochner Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.6.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.6.2.1 07-Aug-1998  drochner make it compile in paddr_t world
 1.11.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.2.1 19-Oct-1999  he Pull up revision 1.13 (requested by mycroft):
Enable VT-switching ioctls on ttyEcfg, which allows Linux X servers
to work when properly configured (with symlink /emul/linux/dev/tty0
-> /dev/ttyEcfg).
 1.12.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.12.2.2 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.12.2.1 20-Oct-1999  thorpej Sync w/ trunk.
 1.13.2.2 19-Oct-1999  mycroft Split wsdisplay_usl_ioctl() into two functions -- one which is screen-dependent
and one which isn't. The latter is now used for ttyEcfg, enabling the
VT-switching ioctls to work on it. (This allows Linux X servers to work when
/emul/linux/dev/tty0 is linked to /dev/ttyEcfg.)
 1.13.2.1 19-Oct-1999  mycroft file wsdisplayvar.h was added on branch fvdl-softdep on 1999-10-19 00:03:19 +0000
 1.14.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.18.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.18.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.18.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.18.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.20.10.1 15-Jul-2002  gehenna catch up with -current.
 1.25.4.2 07-Jun-2004  tron Pull up revision 1.27 (requested by recht in ticket #451):
move scroll function definition last.
 1.25.4.1 07-Jun-2004  tron Pull up revision 1.26 (requested by recht in ticket #451):
PR/19925: David Ferlier: Add scrolling support to wscons.
 1.25.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.25.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.25.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.25.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.25.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.25.2.2 03-Aug-2004  skrll Sync with HEAD
 1.25.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.29.6.1 12-Feb-2005  yamt sync with head.
 1.29.4.1 29-Apr-2005  kent sync with -current
 1.30.4.2 07-Jun-2005  tron Pull up revision 1.32 (requested by martin in ticket #373):
Rename REALWHITE to SNOWWHITE.
While there, add LIGHT versions of the other predefined colours as well.
 1.30.4.1 04-Jun-2005  tron Pull up revision 1.31 (requested by martin in ticket #371):
Define a real white color - since WSCOL_WHITE is ANSI-emulation specific
defined as grey (which can't be fixed w/o breaking user config files).
Fixes PR kern/30064.
 1.33.2.6 27-Feb-2008  yamt sync with head.
 1.33.2.5 21-Jan-2008  yamt sync with head
 1.33.2.4 27-Oct-2007  yamt sync with head.
 1.33.2.3 03-Sep-2007  yamt sync with head.
 1.33.2.2 30-Dec-2006  yamt sync with head.
 1.33.2.1 21-Jun-2006  yamt sync with head.
 1.34.6.1 22-Apr-2006  simonb Sync with head.
 1.34.4.1 09-Sep-2006  rpaulo sync with head
 1.34.2.1 01-Mar-2006  yamt sync with head.
 1.35.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.35.4.1 19-Apr-2006  elad sync with head.
 1.35.2.2 24-May-2006  yamt sync with head.
 1.35.2.1 11-Apr-2006  yamt sync with head
 1.39.10.2 10-Dec-2006  yamt sync with head.
 1.39.10.1 22-Oct-2006  yamt sync with head
 1.39.8.1 18-Nov-2006  ad Sync with head.
 1.41.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.42.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.42.16.3 23-Mar-2008  matt sync with HEAD
 1.42.16.2 09-Jan-2008  matt sync with HEAD
 1.42.16.1 06-Nov-2007  matt sync with HEAD
 1.42.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.42.2.1 23-Oct-2007  ad Sync with head.
 1.44.8.1 13-Dec-2007  bouyer Sync with HEAD
 1.44.4.1 26-Dec-2007  ad Sync with head.
 1.46.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.47.4.1 11-Mar-2010  yamt sync with head
 1.49.12.3 03-Dec-2017  jdolecek update from HEAD
 1.49.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.49.12.1 25-Feb-2013  tls resync with head
 1.49.8.1 13-Feb-2013  riz Pull up following revision(s) (requested by skrll in ticket #813):

etc/MAKEDEV.tmpl 1.160
etc/etc.evbarm/MAKEDEV.conf 1.9
external/broadcom/rpi-firmware/dist/LICENCE.broadcom 1.1
external/broadcom/rpi-firmware/dist/bootcode.bin 1.1
external/broadcom/rpi-firmware/dist/bootcode.bin 1.2
external/broadcom/rpi-firmware/dist/fixup.dat 1.1
external/broadcom/rpi-firmware/dist/fixup.dat 1.2
external/broadcom/rpi-firmware/dist/fixup_cd.dat 1.1
external/broadcom/rpi-firmware/dist/fixup_cd.dat 1.2
external/broadcom/rpi-firmware/dist/start.elf 1.1
external/broadcom/rpi-firmware/dist/start.elf 1.2
external/broadcom/rpi-firmware/dist/start_cd.elf 1.1
external/broadcom/rpi-firmware/dist/start_cd.elf 1.2
sys/arch/arm/broadcom/bcm2835_bsc.c 1.1 via patch
sys/arch/arm/broadcom/bcm2835_bscreg.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_dotg.c 1.1 via patch
sys/arch/arm/broadcom/bcm2835_emmc.c 1.7 via patch
sys/arch/arm/broadcom/bcm2835_genfb.c 1.4 via patch
sys/arch/arm/broadcom/bcm2835_gpio_subr.c 1.2 via patch
sys/arch/arm/broadcom/bcm2835_gpio_subr.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_gpioreg.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_intr.c 1.3 via patch
sys/arch/arm/broadcom/bcm2835_mbox.c 1.5 via patch
sys/arch/arm/broadcom/bcm2835_mbox.h 1.4 via patch
sys/arch/arm/broadcom/bcm2835_obio.c 1.17 via patch
sys/arch/arm/broadcom/bcm2835_pm.c 1.2 via patch
sys/arch/arm/broadcom/bcm2835_rng.c 1.3 via patch
sys/arch/arm/broadcom/bcm2835_space.c 1.5 via patch
sys/arch/arm/broadcom/bcm2835_spi.c 1.1 via patch
sys/arch/arm/broadcom/bcm2835_spireg.h 1.1 via patch
sys/arch/arm/broadcom/bcm2835_tmr.c 1.3 via patch
sys/arch/arm/broadcom/bcm2835reg.h 1.10 via patch
sys/arch/arm/broadcom/files.bcm2835 1.14 via patch
sys/arch/evbarm/conf/RPI 1.23 via patch
sys/arch/evbarm/conf/files.rpi 1.3 via patch
sys/arch/evbarm/conf/mk.rpi 1.2 via patch
sys/arch/evbarm/conf/std.rpi 1.4 via patch
sys/arch/evbarm/rpi/rpi_machdep.c 1.34 via patch
sys/arch/evbarm/rpi/rpi_start.S 1.7 via patch
sys/arch/evbarm/rpi/rpi_vcmbox.c 1.2 via patch
sys/arch/evbarm/rpi/vcio.h 1.1 via patch
sys/arch/evbarm/rpi/vcprop.h 1.7 via patch
sys/conf/files patch
sys/dev/sdmmc/sdhc.c 1.43
sys/dev/sdmmc/sdhcvar.h 1.13
sys/dev/usb/dwc_otg.c 1.45 via patch
sys/dev/usb/dwc_otgreg.h 1.5 via patch
sys/dev/usb/dwc_otgvar.h 1.11 via patch
sys/dev/usb/files.usb 1.126 via patch
sys/dev/usb/if_smsc.c 1.7 via patch
sys/dev/usb/if_smscreg.h 1.1 via patch
sys/dev/usb/if_smscvar.h 1.1 via patch
sys/dev/usb/usbdevices.config patch
sys/dev/usb/usbdevs 1.633 via patch
sys/dev/usb/usbdevs.h regen
sys/dev/usb/usbdevs_data.h regen
sys/dev/wscons/wsconsio.h 1.105,1.107 via patch
sys/dev/wscons/wsdisplayvar.h 1.50
sys/dev/wscons/wsdisplay_util.c 1.2
sys/dev/videomode/edid.c 1.12 via patch

Greatly improved Raspberry Pi support. USB and onboard
Ethernet should work.
[skrll, ticket #813]
 1.49.2.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.50.2.1 18-May-2014  rmind sync with head
 1.51.6.1 28-Aug-2017  skrll Sync with HEAD
 1.52.10.1 10-Jun-2019  christos Sync with HEAD
 1.52.8.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.52.8.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.56.4.1 20-Mar-2023  martin Pull up following revision(s) (requested by mrg in ticket #122):

sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c: revision 1.11
sys/external/bsd/drm2/nouveau/nouveau_pci.c: revision 1.37
sys/external/bsd/drm2/radeon/radeon_pci.c: revision 1.22
sys/dev/wscons/wsdisplay.c: revision 1.166
sys/dev/wscons/wsdisplayvar.h: revision 1.57

amdgpu: Fix bogus loop invariant assertions in amdgpu_gart_map.
nouveau: Kick out genfb on firmware framebuffer before initializing.

PR kern/53126

radeon: Kick out genfb on firmware framebuffer before initializing.
this is the same change as nouveau_pci.c:1.37, and should fix at
least PR#56714 and i thought at least another PR i can't find right
now. it fixes at least 2 different radeon cards for me on UEFI
booted system.
 1.18 03-Sep-2018  riastradh 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.17 03-Nov-2017  maya branches: 1.17.2; 1.17.4;
Use c99 initializer for wsemul_ops
 1.16 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.15 28-Jan-2010  drochner branches: 1.15.22; 1.15.40;
-rename the "KS_GROUP_Ascii" key symbol category to "Plain" because
this is what it meant all the time -- it includes characters >127
-delegate translation of all key symbols >127 to the terminal emulation
layer -- formerly everything non-special was passed to the tty subsystem
directly, involving truncation to a "char", which effectively meant
some ISO-1 assumption
 1.14 16-Nov-2006  christos branches: 1.14.52;
__unused removal on arguments; approved by core.
 1.13 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.12 28-Aug-2006  christos branches: 1.12.2; 1.12.4;
fix incomplete struct decl.
 1.11 11-Dec-2005  christos branches: 1.11.4; 1.11.8;
merge ktrace-lwp.
 1.10 29-May-2005  christos branches: 1.10.2;
- sprinkle const.
- avoid variable shadowing.
 1.9 27-Feb-2005  perry nuke trailing whitespace
 1.8 13-Oct-2001  augustss branches: 1.8.18; 1.8.26; 1.8.28;
ANSIfy.
 1.7 05-Jan-2000  drochner branches: 1.7.6; 1.7.8;
replace embedded _rcsid[] string by __KERNEL_RCSID(), remove _copyright[]
 1.6 17-Jan-1999  drochner branches: 1.6.8;
define a "clear screen" command to the emulator and complete the
emulation's "reset" implementations as far as useful
 1.5 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.4 20-Jun-1998  drochner add some more ASCII definitions, move NP->FF for consistency
 1.3 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.2 14-May-1998  drochner Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.6.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.7.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.8.28.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.26.1 29-Apr-2005  kent sync with -current
 1.8.18.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.18.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.1 30-Dec-2006  yamt sync with head.
 1.11.8.1 03-Sep-2006  yamt sync with head.
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.12.4.2 10-Dec-2006  yamt sync with head.
 1.12.4.1 22-Oct-2006  yamt sync with head
 1.12.2.1 18-Nov-2006  ad Sync with head.
 1.14.52.1 11-Mar-2010  yamt sync with head
 1.15.40.1 28-Aug-2017  skrll Sync with HEAD
 1.15.22.1 03-Dec-2017  jdolecek update from HEAD
 1.17.4.1 10-Jun-2019  christos Sync with HEAD
 1.17.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.34 01-Jan-2022  hannken Protect KASSERT() with "#ifdef DIAGNOSTIC" as its expression is
undefined otherwise.
 1.33 03-Sep-2018  riastradh 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.32 03-Nov-2017  maya branches: 1.32.2; 1.32.4;
Use c99 initializer for wsemul_ops
 1.31 03-Nov-2017  maya Don't #ifdef DIAGNOSTIC around KASSERTs.

the definition of KASSERT does the same thing
 1.30 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.29 08-Nov-2015  christos Untangle.
 1.28 12-Mar-2010  jdc branches: 1.28.20; 1.28.38;
Add mappings for KS_End/KS_KP_End, so that the `End' key actually does
something.
 1.27 28-Jan-2010  drochner branches: 1.27.2;
-rename the "KS_GROUP_Ascii" key symbol category to "Plain" because
this is what it meant all the time -- it includes characters >127
-delegate translation of all key symbols >127 to the terminal emulation
layer -- formerly everything non-special was passed to the tty subsystem
directly, involving truncation to a "char", which effectively meant
some ISO-1 assumption
 1.26 16-Nov-2006  christos branches: 1.26.52; 1.26.64; 1.26.72;
__unused removal on arguments; approved by core.
 1.25 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.24 28-Aug-2006  christos branches: 1.24.2; 1.24.4;
fix incomplete struct decl.
 1.23 11-Dec-2005  christos branches: 1.23.4; 1.23.8;
merge ktrace-lwp.
 1.22 30-May-2005  christos branches: 1.22.2;
add const.
 1.21 30-May-2005  martin Adapt to recent constification.
 1.20 25-May-2005  martin If the driver supports reverse, try that first - even on color displays.
This removes a XXX and makes us independent of the users default colors.
 1.19 03-Aug-2004  he branches: 1.19.10;
Remove include of "opt_wsmsgattrs.h" here, since that's already done
by wsdisplayvar.h. Fixes build problem for sparc.
 1.18 28-Jul-2004  jmmv 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.17 27-Sep-2002  provos branches: 1.17.6;
remove trailing \n in panic(). approved perry.
 1.16 09-Jul-2002  junyoung switch/case KNF.
 1.15 04-Jul-2002  junyoung alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.14 14-Oct-2001  veego branches: 1.14.10;
Fix a pasto in the last revision.
 1.13 13-Oct-2001  augustss ANSIfy.
 1.12 21-Feb-2001  jdolecek branches: 1.12.2; 1.12.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.11 05-Jan-2000  drochner replace embedded _rcsid[] string by __KERNEL_RCSID(), remove _copyright[]
 1.10 17-Jan-1999  drochner branches: 1.10.8;
define a "clear screen" command to the emulator and complete the
emulation's "reset" implementations as far as useful
 1.9 10-Jan-1999  augustss Change from bcopy/bzero to memxxx. From PR 6778 by
Erik Bertelsen <erik@q610.ebe.uni-c.dk>.
 1.8 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.7 20-Jun-1998  drochner add some more ASCII definitions, move NP->FF for consistency
 1.6 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.5 24-May-1998  drochner fix "Cursor Next Line (CNL)" (did the opposite)
 1.4 19-May-1998  drochner Initialize the "curattr" member of the emulation data in early console
setup -- it is used to fill empty space.
Fixes 2/3 of PR kern/5457 (Jason Thorpe).
 1.3 14-May-1998  drochner Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.2 27-Mar-1998  drochner fix max() vs min() confusion at 2 places
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.10.8.2 12-Mar-2001  bouyer Sync with HEAD.
 1.10.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.12.4.3 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.12.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.12.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.12.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.12.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.14.10.1 15-Jul-2002  gehenna catch up with -current.
 1.17.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.6.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.6.3 18-Sep-2004  skrll Sync with HEAD.
 1.17.6.2 12-Aug-2004  skrll Sync with HEAD.
 1.17.6.1 03-Aug-2004  skrll Sync with HEAD
 1.19.10.1 07-Jun-2005  tron Pull up revision 1.20 (requested by martin in ticket #374):
If the driver supports reverse, try that first - even on color displays.
This removes a XXX and makes us independent of the users default colors.
 1.22.2.1 30-Dec-2006  yamt sync with head.
 1.23.8.1 03-Sep-2006  yamt sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.24.4.2 10-Dec-2006  yamt sync with head.
 1.24.4.1 22-Oct-2006  yamt sync with head
 1.24.2.1 18-Nov-2006  ad Sync with head.
 1.26.72.1 21-Apr-2010  matt sync to netbsd-5
 1.26.64.1 17-Mar-2010  snj Pull up following revision(s) (requested by jdc in ticket #1340):
sys/dev/wscons/wsemul_sun.c: revision 1.28
Add mappings for KS_End/KS_KP_End, so that the `End' key actually does
something.
 1.26.52.2 11-Aug-2010  yamt sync with head.
 1.26.52.1 11-Mar-2010  yamt sync with head
 1.27.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.28.38.2 28-Aug-2017  skrll Sync with HEAD
 1.28.38.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.28.20.1 03-Dec-2017  jdolecek update from HEAD
 1.32.4.1 10-Jun-2019  christos Sync with HEAD
 1.32.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 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.
 1.15 03-Nov-2017  maya Use __arraycount a bunch
Also, DIAGNOSTIC panic -> KASSERT
 1.14 25-Feb-2010  drochner branches: 1.14.20;
retire our private definitions for the scan1/3/5/7/9 DEC graphics
symbols, use the unicode definitions instead (which apparently didn't
exist when I wrote that)
 1.13 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.12 18-Feb-2009  snj branches: 1.12.2;
s/portugese/portuguese/, spotted by Ari Constancio in PR misc/40202.
 1.11 11-Dec-2005  christos branches: 1.11.74; 1.11.84; 1.11.86; 1.11.90; 1.11.92; 1.11.96;
merge ktrace-lwp.
 1.10 28-Jul-2004  jmmv 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.9 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.8 01-Dec-2001  bjh21 branches: 1.8.16;
On a VT100, the "scanline 5" character is also used for box drawing, so
represent it as U+2500 (BOX DRAWINGS LIGHT HORIZONTAL). This makes NetHack
DECgraphics mode work properly on a wscons console using an IBM-encoded font.
 1.7 13-Nov-2001  lukem add/cleanup RCSIDs
 1.6 13-Oct-2001  augustss ANSIfy.
 1.5 18-Jan-2001  jdolecek branches: 1.5.2; 1.5.4;
constify
 1.4 20-Feb-1999  drochner branches: 1.4.8;
complete the font tables for the DEC special fonts; assign some codes
from the private Unicode area (0xe000 ff.) to stuff I didn't find in
the Unicode database
 1.3 12-Feb-1999  drochner change the "mapchar" interface to return a "quality" or "match level"
arguments which allows to find approximations for characters which are
not present in a font
 1.2 11-Jan-1999  drochner Oops, "square root" is Unicode 221a, not 211a!
 1.1 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.4.8.1 11-Feb-2001  bouyer Sync with HEAD.
 1.5.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.5.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.5.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.8.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.16.1 03-Aug-2004  skrll Sync with HEAD
 1.11.96.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.11.92.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.11.90.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.86.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.11.84.1 03-Mar-2009  skrll Sync with HEAD.
 1.11.74.2 11-Mar-2010  yamt sync with head
 1.11.74.1 04-May-2009  yamt sync with head.
 1.12.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.14.20.1 03-Dec-2017  jdolecek update from HEAD
 1.11 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.10 28-Jan-2010  drochner branches: 1.10.2;
-rename the "KS_GROUP_Ascii" key symbol category to "Plain" because
this is what it meant all the time -- it includes characters >127
-delegate translation of all key symbols >127 to the terminal emulation
layer -- formerly everything non-special was passed to the tty subsystem
directly, involving truncation to a "char", which effectively meant
some ISO-1 assumption
 1.9 11-Dec-2005  christos branches: 1.9.74;
merge ktrace-lwp.
 1.8 29-May-2005  christos - sprinkle const.
- avoid variable shadowing.
 1.7 28-Jul-2004  jmmv 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.6 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.5 13-Nov-2001  lukem branches: 1.5.16;
add/cleanup RCSIDs
 1.4 13-Oct-2001  augustss ANSIfy.
 1.3 22-Apr-1999  mycroft branches: 1.3.14; 1.3.16;
Map the Home and End keys as xterm does.
 1.2 14-Jul-1998  drochner branches: 1.2.8; 1.2.10;
fix codes delivered by "Help" and "Do" keys
 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.2.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.8.1 18-Sep-1999  he Pull up revision 1.3:
Map the Home and End keys as xterm does.
 1.3.16.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.14.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.14.1 22-Oct-2001  nathanw Catch up to -current.
 1.5.16.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.16.1 03-Aug-2004  skrll Sync with HEAD
 1.9.74.1 11-Mar-2010  yamt sync with head
 1.10.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.34 03-Aug-2023  uwe wsemul_vt100_subr: fix comment - CPR is not DSR

DSRs (device status report) are 'n', but cursor position report is 'R'
 1.33 03-Aug-2023  uwe wsemul_vt100_subr: fix IL/DL to match specified behavior

Acoording to DEC manuals: "The cursor is reset to the first column.
This sequence is ignored when the cursor is outside the scrolling
region."
 1.32 03-Aug-2023  uwe wsemul_vt100_subr: properly clamp CUU/CUD parameter

If the cursor is outside of the scrolling region the movement should
stop at the screen border. Reported by David Leadbeater.
 1.31 26-Jul-2023  uwe 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.
 1.30 26-Feb-2023  uwe wsemul_vt100_subr: spell edp->tabs assertion with NULL
 1.29 26-Feb-2023  uwe wsemul_vt100_subr: don't assert unsigned ncols >= 0
 1.28 23-Feb-2023  riastradh wscons(4): Paranoia: Clamp numbers of rows and columns.
 1.27 23-Feb-2023  riastradh wscons(4): Ignore nonsense tab stops in vt100 emulation.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.26 18-Jan-2023  christos Add rin, indn, vpa, hpa, and cbt terminfo capabilities (Crystal Kolipe)
 1.25 09-Jan-2023  christos Fix off by one (Crystal Kolipe in tech-kern@)
 1.24 06-Dec-2018  uwe branches: 1.24.30;
#ifdef _KERNEL_OPT
 1.23 03-Sep-2018  riastradh 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.22 05-Jun-2018  uwe branches: 1.22.2;
PR kern/53245 - support SGR 39 (default foreground) and 49 (background).
 1.21 19-May-2017  macallan branches: 1.21.8;
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.20 10-Feb-2010  drochner branches: 1.20.20; 1.20.38;
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.19 11-Dec-2005  christos branches: 1.19.74; 1.19.96;
merge ktrace-lwp.
 1.18 29-May-2005  christos - sprinkle const.
- avoid variable shadowing.
 1.17 28-Jul-2004  jmmv 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.16 23-Apr-2004  itojun use bounded string ops
 1.15 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.14 02-Apr-2003  drochner branches: 1.14.2;
allow to customize how highlighting and underlining text is substituted
if the display doesn't provide this
submitted by xs@kittenz.org per PR kern/18004
 1.13 02-Apr-2003  drochner fix crash due to wrong argument in the (almost useless)
DECRQUPSS escape sequence
 1.12 20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.11 04-Jul-2002  junyoung alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.10 13-Nov-2001  lukem branches: 1.10.8; 1.10.10;
add/cleanup RCSIDs
 1.9 13-Oct-2001  augustss ANSIfy.
 1.8 24-Feb-2001  cgd branches: 1.8.2; 1.8.4;
C requires that labels be followed by statements.
 1.7 28-Apr-2000  mycroft branches: 1.7.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.6 25-Feb-2000  mycroft Only call the cursor method when the cursor state is actually changing.
This avoid corrupting VGA displays in text mode (e.g. the first character
of the prompt when you exit vi).
 1.5 10-Jan-1999  augustss branches: 1.5.8;
Change from bcopy/bzero to memxxx. From PR 6778 by
Erik Bertelsen <erik@q610.ebe.uni-c.dk>.
 1.4 12-Aug-1998  drochner stricter parameter check for scrolling regions
(PR kern/5954 by Dave Huang <khym@bga.com>)
 1.3 29-Jun-1998  drochner fix VT300 tab stop report format
 1.2 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.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.5.8.2 12-Mar-2001  bouyer Sync with HEAD.
 1.5.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.7.4.1 27-May-2003  msaitoh Pullup rev. 1.13 (requested by drochner in ticket #43)

fix crash due to wrong argument in the (almost useless)
DECRQUPSS escape sequence
 1.8.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.8.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.8.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.8.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.10.10.1 25-Jun-2003  grant Pull up revision 1.13 (requested by tron in ticket #1277):

fix crash due to wrong argument in the (almost useless)
DECRQUPSS escape sequence
 1.10.8.1 15-Jul-2002  gehenna catch up with -current.
 1.14.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.19.74.1 11-Mar-2010  yamt sync with head
 1.20.38.1 28-Aug-2017  skrll Sync with HEAD
 1.20.20.1 03-Dec-2017  jdolecek update from HEAD
 1.21.8.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.21.8.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.21.8.1 25-Jun-2018  pgoyette Sync with HEAD
 1.22.2.1 10-Jun-2019  christos Sync with HEAD
 1.24.30.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.
 1.14 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.13 09-Oct-2006  peter branches: 1.13.52; 1.13.74;
KNF: No variable names in the prototype.
 1.12 27-Dec-2005  chs branches: 1.12.20; 1.12.22;
changes for making DIAGNOSTIC not change the kernel ABI:
- for structure fields that are conditionally present,
make those fields always present.
- for functions which are conditionally inline, make them never inline.
- remove some other functions which are conditionally defined but
don't actually do anything anymore.
- make a lock-debugging function conditional on only LOCKDEBUG.

as discussed on tech-kern some time back.
 1.11 11-Dec-2005  christos merge ktrace-lwp.
 1.10 29-May-2005  christos branches: 1.10.2;
- sprinkle const.
- avoid variable shadowing.
 1.9 28-Jul-2004  jmmv 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.8 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.7 19-Apr-2003  christos branches: 1.7.2;
PR/17738: Matthias Drochner, PR/21230: Onno van der Linden: vt100 wscons
crashes restoring cursor. Fixed by adding a flag as suggested.
 1.6 13-Oct-2001  augustss branches: 1.6.12;
ANSIfy.
 1.5 28-Apr-2000  mycroft branches: 1.5.4; 1.5.6; 1.5.8;
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.4 04-Dec-1998  drochner branches: 1.4.10;
always use unsigned numbers for screen positions (for sanity - the libkern
min() et al. did unsigned comparisions before)
make ROWS_ABOVE / ROWS_BELOW return signed values, the negative results
occur if the cursor is outside the scrolling region
 1.3 12-Aug-1998  drochner stricter parameter check for scrolling regions
(PR kern/5954 by Dave Huang <khym@bga.com>)
 1.2 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.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.4.10.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.5.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.5.4.1 27-May-2003  msaitoh Pullup rev. 1.7 (requested by drochner in ticket #43)
vt100 wscons crashes restoring cursor. Fixed by adding a flag as suggested.
Fixes PR#17738, PR#21230
 1.6.12.1 16-Jun-2003  grant Pull up revision 1.7 (requested by drochner in ticket #1277):

PR/17738: Matthias Drochner, PR/21230: Onno van der Linden: vt100 wscons
crashes restoring cursor. Fixed by adding a flag as suggested.
 1.7.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.2.2 30-Dec-2006  yamt sync with head.
 1.10.2.1 21-Jun-2006  yamt sync with head.
 1.12.22.1 22-Oct-2006  yamt sync with head
 1.12.20.1 18-Nov-2006  ad Sync with head.
 1.13.74.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.13.52.1 11-Mar-2010  yamt sync with head
 1.8 02-Feb-2010  drochner add hooks to allow terminal emulations to be installed by LKMs
(these are not available in early bootstrap, so this is not an
option for the system's default emulation)
 1.7 11-Dec-2005  christos branches: 1.7.74;
merge ktrace-lwp.
 1.6 28-Jul-2004  jmmv 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.5 13-Oct-2001  augustss branches: 1.5.18;
ANSIfy.
 1.4 05-Jan-2000  drochner branches: 1.4.6; 1.4.8;
replace embedded _rcsid[] string by __KERNEL_RCSID(), remove _copyright[]
 1.3 15-Jun-1998  drochner branches: 1.3.14;
Fix broken pointer arithmetic.
Being here, add hooks for the highly-desired-but-not-yet-done
vt100 emulation.
 1.2 17-Apr-1998  thorpej defopt the WSEMUL options.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.3.14.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.4.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.5.18.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.18.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.18.1 03-Aug-2004  skrll Sync with HEAD
 1.7.74.1 11-Mar-2010  yamt sync with head
 1.16 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.15 02-Feb-2010  drochner branches: 1.15.22; 1.15.40;
add hooks to allow terminal emulations to be installed by LKMs
(these are not available in early bootstrap, so this is not an
option for the system's default emulation)
 1.14 25-Mar-2008  cube branches: 1.14.4;
Split device_t and softc for wskbd(4), wsmouse(4) and that creepy wsmux(4).
 1.13 09-Oct-2006  peter branches: 1.13.48;
KNF: No variable names in the prototype.
 1.12 11-Dec-2005  christos branches: 1.12.20; 1.12.22;
merge ktrace-lwp.
 1.11 29-May-2005  christos branches: 1.11.2;
- sprinkle const.
- avoid variable shadowing.
 1.10 27-Feb-2005  perry nuke trailing whitespace
 1.9 28-Jul-2004  jmmv branches: 1.9.4; 1.9.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.8 13-Oct-2001  augustss branches: 1.8.18;
ANSIfy.
 1.7 30-May-2001  mrg branches: 1.7.2;
use _KERNEL_OPT
 1.6 17-Jan-1999  drochner branches: 1.6.20;
define a "clear screen" command to the emulator and complete the
emulation's "reset" implementations as far as useful
 1.5 13-Jan-1999  drochner add a hook for resetting the terminal emulator completely or partially
 1.4 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.3 14-May-1998  drochner Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.2 17-Apr-1998  thorpej defopt the WSEMUL options.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.6.20.2 22-Oct-2001  nathanw Catch up to -current.
 1.6.20.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.18.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.18.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.18.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.18.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.18.1 03-Aug-2004  skrll Sync with HEAD
 1.9.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.4.1 29-Apr-2005  kent sync with -current
 1.11.2.1 30-Dec-2006  yamt sync with head.
 1.12.22.1 22-Oct-2006  yamt sync with head
 1.12.20.1 18-Nov-2006  ad Sync with head.
 1.13.48.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.4.1 11-Mar-2010  yamt sync with head
 1.15.40.1 28-Aug-2017  skrll Sync with HEAD
 1.15.22.1 03-Dec-2017  jdolecek update from HEAD
 1.47 26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.46 18-Dec-2020  thorpej Use sel{record,remove}_knote().
 1.45 23-May-2020  ad branches: 1.45.2;
Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.44 04-Apr-2020  pgoyette KNF (Format block comment)

NFCI
 1.43 04-Apr-2020  mlelstv Make default protocol version used by wscons selectable and default
to the current version.

Fixes PR 55103.
 1.42 01-Mar-2019  pgoyette branches: 1.42.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.41 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.40 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.39 14-Jun-2018  uwe branches: 1.39.2;
timespec_to_timespec50 - don't leak kernel memory in struct padding.

On 64-bit machines struct timespec50 has padding between 32-bit tv_sec
and long tv_nsec that is not affected by normal assignment. Scrub it.
The result is most likely about to be passed to the user space by the
caller, so do it here to take care of them all.
 1.38 13-Jun-2018  uwe wsevent_copyout_events50 - don't leak garbage from the kernel stack.

On 64-bit machines struct timespec50 has padding between 32-bit tv_sec
and long tv_nsec that is not affected by normal assignment. Scrub it
before we uiomove struct owscons_event.
 1.37 25-Oct-2017  maya branches: 1.37.2;
Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.36 24-Aug-2015  pooka to garnish, dust with _KERNEL_OPT
 1.35 24-May-2012  abs branches: 1.35.2; 1.35.16;
Add the following above the version = 0 line, just to provide a hint...
/* For binary compat. New code must call WSxxxIO_SETVERSION */
 1.34 18-Feb-2009  yamt branches: 1.34.12; 1.34.16;
wsevent_copyout_events50: fix a bogus panic.
 1.33 13-Feb-2009  apb Use "defopt MODULAR" in sys/conf/files, and #include "opt_modular.h"
in all kernel sources that use the MODULAR option.
Proposed in tech-kern on 18 Jan 2009.
 1.32 16-Jan-2009  yamt branches: 1.32.2;
always use the new version of wscons_event for in-kernel.
 1.31 16-Jan-2009  yamt wsevent_init: always initialize version. pointed out by christos.
 1.30 15-Jan-2009  yamt - reduce the number of #ifdefs.
- build compat glues if MODULAR.
 1.29 14-Jan-2009  christos Allocate the max size needed so that we don't need to realloc in setversion.
Problem pointed out by yamt.
 1.28 13-Jan-2009  christos provide wscons_event compatibility with 5.0.
 1.27 28-Apr-2008  martin branches: 1.27.8;
Remove clause 3 and 4 from TNF licenses
 1.26 24-Apr-2008  ad branches: 1.26.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.25 01-Mar-2008  rmind branches: 1.25.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.24 05-Dec-2007  pooka branches: 1.24.8; 1.24.12;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
 1.23 09-Feb-2007  ad branches: 1.23.18; 1.23.20; 1.23.26; 1.23.28;
Merge newlock2 to head.
 1.22 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.21 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.20 08-Sep-2006  uebayasi branches: 1.20.2;
Typo.
 1.19 07-Jun-2006  kardel branches: 1.19.6;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.18 07-Feb-2006  jmmv branches: 1.18.2; 1.18.8;
wsevent cleanup:

- Add a wsevent_inject function that atomically adds a set of events to an
event queue and change all code that directly messed with a queue to use it.
- Replace the WSEVENT_WAKEUP macro with a regular function.
- Make WSEVENT_QSIZE, PWSEVENT and splwsevent private definitions to
wsevent.c, instead of exposing them in the header file.
- Make the wsevent_init function take a process to attach to the queue,
instead of leaving this task to the caller (which always did it).

Reviewed in tech-kern@.
 1.17 11-Dec-2005  christos branches: 1.17.2; 1.17.4; 1.17.6;
merge ktrace-lwp.
 1.16 07-Aug-2003  agc branches: 1.16.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.15 29-Jun-2003  fvdl branches: 1.15.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.14 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.13 26-Dec-2002  christos Don't leak memory on double init, and don't panic on double fini. Emit
a message when diagnostic.
 1.12 26-Nov-2002  christos si_ -> sel_
 1.11 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.10 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.9 13-Nov-2001  lukem add/cleanup RCSIDs
 1.8 25-Oct-2001  augustss Change back to have a wseventvar in the softc for event sources. This
way the effect of FIOASYNC survives close()/open(). Later versions
of XFree86 relies on this bug/feature.
Also add some more debug stuff.
 1.7 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.6 13-Oct-2001  augustss branches: 1.6.2;
ANSIfy.
 1.5 30-Mar-2000  augustss branches: 1.5.6; 1.5.8;
Remove register declarations.
 1.4 05-Jan-2000  drochner replace embedded _rcsid[] string by __KERNEL_RCSID(), remove _copyright[]
 1.3 10-Jan-1999  augustss branches: 1.3.8;
Change from bcopy/bzero to memxxx. From PR 6778 by
Erik Bertelsen <erik@q610.ebe.uni-c.dk>.
 1.2 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.3.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.5.8.4 02-Oct-2002  jdolecek do not need the (void *) cast for kn_hook anymore
 1.5.8.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.5.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.8.1 08-Sep-2001  thorpej Add kqueue support to wscons events.
 1.5.6.6 29-Dec-2002  thorpej Sync with HEAD.
 1.5.6.5 11-Dec-2002  thorpej Sync with HEAD.
 1.5.6.4 11-Nov-2002  nathanw Catch up to -current
 1.5.6.3 28-Feb-2002  nathanw Catch up to -current.
 1.5.6.2 14-Nov-2001  nathanw Catch up to -current.
 1.5.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.6.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.15.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.2 03-Aug-2004  skrll Sync with HEAD
 1.15.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.16.16.5 17-Mar-2008  yamt sync with head.
 1.16.16.4 07-Dec-2007  yamt sync with head
 1.16.16.3 26-Feb-2007  yamt sync with head.
 1.16.16.2 30-Dec-2006  yamt sync with head.
 1.16.16.1 21-Jun-2006  yamt sync with head.
 1.17.6.2 22-Apr-2006  simonb Update for timecounters - use getnanotime() and time_second variable.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.17.2.1 18-Feb-2006  yamt sync with head.
 1.18.8.1 19-Jun-2006  chap Sync with head.
 1.18.2.2 14-Sep-2006  yamt sync with head.
 1.18.2.1 26-Jun-2006  yamt sync with head.
 1.19.6.2 19-Jan-2007  ad Acquire proclist_mutex before sending signals.
 1.19.6.1 18-Nov-2006  ad Sync with head.
 1.20.2.2 10-Dec-2006  yamt sync with head.
 1.20.2.1 22-Oct-2006  yamt sync with head
 1.23.28.1 08-Dec-2007  ad Sync with head.
 1.23.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.23.20.2 23-Mar-2008  matt sync with HEAD
 1.23.20.1 09-Jan-2008  matt sync with HEAD
 1.23.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.24.12.3 17-Jan-2009  mjf Sync with HEAD.
 1.24.12.2 02-Jun-2008  mjf Sync with HEAD.
 1.24.12.1 03-Apr-2008  mjf Sync with HEAD.
 1.24.8.1 24-Mar-2008  keiichi sync with head.
 1.25.2.1 18-May-2008  yamt sync with head.
 1.26.2.2 04-May-2009  yamt sync with head.
 1.26.2.1 16-May-2008  yamt sync with head.
 1.27.8.2 03-Mar-2009  skrll Sync with HEAD.
 1.27.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.32.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.16.1 02-Jun-2012  mrg sync to latest -current.
 1.34.12.1 30-Oct-2012  yamt sync with head
 1.35.16.1 22-Sep-2015  skrll Sync with HEAD
 1.35.2.1 03-Dec-2017  jdolecek update from HEAD
 1.37.2.10 22-Jan-2019  pgoyette Convert the MODULE_{,VOID_}HOOK_CALL macros to do everything in-line
rather than defining an intermediate hook##call function. Almost
all of the hooks are called only once, and although we lose the
ability of doing things like

if (MODULE_HOOK_CALL(...) == 0) ...

we simplify things quite a bit. With this change, we no longer need
to have both declaration and definition macros, and the definition
no longer needs to have both prototype argument list and a "real"
argument list.

FWIW, the above if now needs to written as

int ret;

MODULE_HOOK_CALL(..., ret);
if (ret == 0) ...

with appropriate use of braces {}.
 1.37.2.9 18-Jan-2019  pgoyette Don't restrict hooks to having only int or void types. Pass the hook's
type to the various macros, as needed.

Allows us to reduce diffs to original in at least one or two places (we
no longer have to provide an additional parameter to the hook routine
for returning a non-int return value).
 1.37.2.8 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.37.2.7 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.37.2.6 29-Sep-2018  pgoyette In MODULE_HOOK_CALL_DECL we don't need to provide the actual argument
list for calling the hook function, nor do we need to provide the
default value (for when the hook has not been set).
 1.37.2.5 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.37.2.4 18-Sep-2018  pgoyette Split the COMPAT_CALL_HOOK to separate the declaration from the
implementation. Some hooks are called from multiple source files,
and the old method resulted in duplicate implementations.

Implement MP-safe hooks for the usb_subr_30 code. Pass the helper
functions as arguments to the compat code so it does not have to
determine if the kernel contains usb code.
 1.37.2.3 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.37.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.37.2.1 24-Mar-2018  pgoyette Move the compat_50-specific code out of wscons/wsevent.c into its own
source file, which is now part of the compat_50 module.
 1.39.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.39.2.1 10-Jun-2019  christos Sync with HEAD
 1.42.4.1 06-Apr-2020  martin Pull up following revision(s) (requested by pgoyette in ticket #820):

sys/dev/wscons/wsevent.c: revision 1.43
sys/dev/wscons/wsevent.c: revision 1.44

Make default protocol version used by wscons selectable and default
to the current version.

Fixes PR 55103.

KNF (Format block comment)
NFCI
 1.45.2.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.5 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.4 01-Mar-2019  pgoyette branches: 1.4.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.3 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 24-Mar-2018  pgoyette branches: 1.1.2;
file wsevent_50.c was initially added on branch pgoyette-compat.
 1.1.2.6 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.5 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.4 17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.1.2.3 14-Jun-2018  pgoyette Keep up with HEAD. The original change in the wsevent_50 compat code
has been moved to sys/time_types.h and will get picked up during the
next sync-with-HEAD
 1.1.2.2 13-Jun-2018  pgoyette Keep up with -HEAD
 1.1.2.1 24-Mar-2018  pgoyette Move the compat_50-specific code out of wscons/wsevent.c into its own
source file, which is now part of the compat_50 module.
 1.4.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.4.2 10-Jun-2019  christos Sync with HEAD
 1.4.4.1 01-Mar-2019  christos file wsevent_50.c was added on branch phil-wifi on 2019-06-10 22:07:36 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 24-Mar-2018  pgoyette branches: 1.1.2;
file wsevent_50.h was initially added on branch pgoyette-compat.
 1.1.2.1 24-Mar-2018  pgoyette Move the compat_50-specific code out of wscons/wsevent.c into its own
source file, which is now part of the compat_50 module.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file wsevent_50.h was added on branch phil-wifi on 2019-06-10 22:07:36 +0000
 1.16 06-Sep-2015  dholland More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.15 16-Jan-2009  yamt branches: 1.15.24; 1.15.42;
always use the new version of wscons_event for in-kernel.
 1.14 15-Jan-2009  yamt - reduce the number of #ifdefs.
- build compat glues if MODULAR.
 1.13 13-Jan-2009  christos provide wscons_event compatibility with 5.0.
 1.12 24-Apr-2008  ad branches: 1.12.2; 1.12.10;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.11 09-Oct-2006  peter branches: 1.11.48; 1.11.50;
KNF: No variable names in the prototype.
 1.10 07-Feb-2006  jmmv branches: 1.10.14; 1.10.16;
wsevent cleanup:

- Add a wsevent_inject function that atomically adds a set of events to an
event queue and change all code that directly messed with a queue to use it.
- Replace the WSEVENT_WAKEUP macro with a regular function.
- Make WSEVENT_QSIZE, PWSEVENT and splwsevent private definitions to
wsevent.c, instead of exposing them in the header file.
- Make the wsevent_init function take a process to attach to the queue,
instead of leaving this task to the caller (which always did it).

Reviewed in tech-kern@.
 1.9 11-Dec-2005  christos branches: 1.9.2; 1.9.4; 1.9.6;
merge ktrace-lwp.
 1.8 07-Aug-2003  agc branches: 1.8.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.7 29-Jun-2003  fvdl branches: 1.7.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.6 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.5 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.4 25-Oct-2001  augustss Change back to have a wseventvar in the softc for event sources. This
way the effect of FIOASYNC survives close()/open(). Later versions
of XFree86 relies on this bug/feature.
Also add some more debug stuff.
 1.3 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.2 13-Oct-2001  augustss branches: 1.2.2;
ANSIfy.
 1.1 22-Mar-1998  drochner branches: 1.1.26; 1.1.28;
Initial import of cgd's new wscons code.
 1.1.28.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.28.1 08-Sep-2001  thorpej Add kqueue support to wscons events.
 1.1.26.3 11-Nov-2002  nathanw Catch up to -current
 1.1.26.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.26.1 22-Oct-2001  nathanw Catch up to -current.
 1.2.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.7.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.2 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.8.16.2 30-Dec-2006  yamt sync with head.
 1.8.16.1 21-Jun-2006  yamt sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.9.2.1 18-Feb-2006  yamt sync with head.
 1.10.16.1 22-Oct-2006  yamt sync with head
 1.10.14.1 18-Nov-2006  ad Sync with head.
 1.11.50.1 18-May-2008  yamt sync with head.
 1.11.48.2 17-Jan-2009  mjf Sync with HEAD.
 1.11.48.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.10.1 19-Jan-2009  skrll Sync with HEAD.
 1.12.2.1 04-May-2009  yamt sync with head.
 1.15.42.1 22-Sep-2015  skrll Sync with HEAD
 1.15.24.1 03-Dec-2017  jdolecek update from HEAD
 1.146 07-Apr-2025  hans wsmouse(4), wskbd(4): less DIAGNOSTIC, more KASSERT

Also, add a DPRINTF to wsmouseclose() and wskbdclose(), mirroring their
respective open functions.
 1.145 23-Mar-2025  hans wskbd(4): fix bogus DIAGNOSTIC checks

Similar to uts(4) and ums(4), these checks should be done always, and
the only thing DIAGNOSTIC about them should be the printing of the
message.
 1.144 27-Dec-2020  tsutsui branches: 1.144.24;
Explicitly include generated ioconf.h for struct cfdrivers.
 1.143 05-Feb-2019  mrg branches: 1.143.12;
- call update_modifier() explicitly for the scrolling keys up event.
 1.142 18-Sep-2018  mrg fix wsdisplay/wskbd and cngetc() return value issues:
- return -1 for error / no character
- allow 0 as a character

cngetc() itself considers any value >= 0 valid, and this matches
the usage in other drivers that return -1 for "not data", vs
polling until something arrives.

removes ^G from spewing out the askname/etc prompts when no key
has been pressed (these come from cngetsn(), ignoring unknown
non printable characters.)

from @skrll with help from @mlelstv.
 1.141 18-Dec-2017  jmcneill branches: 1.141.2; 1.141.4;
If the wskbd driver returns type 0, return "no data" from wskbd_cngetc
 1.140 13-Jun-2017  nat Move duplicate definition of SETBELL macro into wsbelldata.h.
 1.139 11-Jun-2017  nat Seperate the definitions for the console beep. This code will be shared
with a new device.

Ok pgoyette@.
 1.138 10-Dec-2016  christos branches: 1.138.6;
remove VAUDIOSPEAKER, needs to be done differently.
 1.137 08-Dec-2016  nat Add a synthesized pc beeper and keyboard bell for platforms with an audio
device.
 1.136 24-Aug-2015  pooka branches: 1.136.2;
to garnish, dust with _KERNEL_OPT
 1.135 16-Nov-2014  ozaki-r branches: 1.135.2;
Replace callout_stop with callout_halt

In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.

Discussed with martin@ and riastradh@.
 1.134 25-Jul-2014  dholland branches: 1.134.2;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.133 16-Mar-2014  dholland branches: 1.133.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.132 29-Aug-2012  macallan branches: 1.132.2; 1.132.4;
support an optional table to translate scancodes when in event mode
 1.131 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.130 26-Oct-2010  jruoho branches: 1.130.8; 1.130.12; 1.130.14;
Add wskbd_hotkey_deregister() to match wskbd_hotkey_register().

XXX: This is kind of futile; the only user of the wskbd(4)'s hotkey interface
is hpqlb(4), which is a questionable driver, being, by design,
limited only to the laptop model for which the driver was written.
 1.129 01-Jul-2010  ahoka output ^_ on control-/ like xterm does.
 1.128 31-May-2010  dholland PR kern/38900 Arnaud Lacombe: don't try to do WSDISPLAY_SCROLLSUPPORT
things if NWSDISPLAY is 0.

Arguably the right fix is to not allow "options WSDISPLAY_SCROLLSUPPORT"
to be enabled in this case, but AIUI config doesn't know how to encode
rules like that.
 1.127 24-Feb-2010  dyoung branches: 1.127.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.126 28-Jan-2010  drochner branches: 1.126.2;
-rename the "KS_GROUP_Ascii" key symbol category to "Plain" because
this is what it meant all the time -- it includes characters >127
-delegate translation of all key symbols >127 to the terminal emulation
layer -- formerly everything non-special was passed to the tty subsystem
directly, involving truncation to a "char", which effectively meant
some ISO-1 assumption
 1.125 13-Jan-2010  macallan revert brainfart
 1.124 12-Jan-2010  macallan send PMF events for volume control keys
 1.123 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.122 15-Jan-2009  yamt - reduce the number of #ifdefs.
- build compat glues if MODULAR.
 1.121 13-Jan-2009  christos provide wscons_event compatibility with 5.0.
 1.120 12-Jun-2008  cegger branches: 1.120.4;
use device_lookup_private to get softc
use device_lookup to get device_t
 1.119 04-May-2008  martin branches: 1.119.2; 1.119.4;
Move to standard TNF 2 clause license
 1.118 01-May-2008  cegger hpqlb(4): driver for HP Quick Launch buttons - found on HP Pavilion Notebooks
 1.117 27-Apr-2008  cegger branches: 1.117.2;
aprint_verbose -> aprint_verbose_dev
 1.116 05-Apr-2008  cegger branches: 1.116.2;
use aprint_*_dev and device_xname
 1.115 25-Mar-2008  cube Split device_t and softc for wskbd(4), wsmouse(4) and that creepy wsmux(4).
 1.114 28-Feb-2008  dyoung Do not return EBUSY if this is the console.
 1.113 22-Feb-2008  dyoung Return EBUSY and do not detach if we are the console.

Cosmetic: use device_t and accessors. Temporarily use PMF_FN_PROTO,
PMF_FN_ARGS.
 1.112 13-Dec-2007  joerg branches: 1.112.2; 1.112.6;
Stop the key pressed timeout on suspend to avoid virtually hanging keys,
e.g. when calling sysctl -w machdep.sleep_state=3 manually.
 1.111 10-Dec-2007  jmcneill branches: 1.111.2;
Wups, pmf_class_input_deregister is private; use pmf_device_deregister
instead
 1.110 10-Dec-2007  jmcneill Deregister input class handler on detach.
 1.109 09-Dec-2007  jmcneill Merge jmcneill-pm branch.
 1.108 01-Dec-2007  jmcneill branches: 1.108.2; 1.108.4;
aprintify
 1.107 18-Oct-2007  joerg branches: 1.107.2;
Always declare wskbd_repeat to fix build without wsdisplay.
 1.106 16-Oct-2007  joerg branches: 1.106.2;
Use callout_setfunc/callout_schedule instead of callout_reset.
Use mstohz for the calculations.
 1.105 06-Aug-2007  macallan branches: 1.105.2; 1.105.4; 1.105.6;
set the scrollmode flag when entering/leaving scroll mode, send scroll reset
when leaving
 1.104 09-Jul-2007  ad branches: 1.104.2; 1.104.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.103 04-Apr-2007  mishka Revert previous commit until further investigation because it is
known as problematic. Some problems obscured are dead Del key (I
can reproduce this with wscons scroll support) and panic (seen by
<elad> only).
 1.102 02-Apr-2007  mishka Implement locking switcher for alternative layots (many languages
are based on completely different alphabet, and typesetting with
one of modifiers pressed all the time is just a PITA). See
http://mail-index.netbsd.org/tech-kern/2007/03/29/0002.html for
usage details.

While here, perform the following small cleanups:
- KS_Cmd_Scroll* execution should be explicitly interrupted with 'break'.
- Some 'human' cleanups in ksym extraction algorithm (no func. changes).
- Add a note: implemented ksym translation isn't sufficient for l10n.
 1.101 04-Mar-2007  christos branches: 1.101.2; 1.101.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.100 09-Feb-2007  ad branches: 1.100.2;
Merge newlock2 to head.
 1.99 04-Jan-2007  elad Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.98 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.97 17-Oct-2006  dogcow now that we have -Wno-unused-parameter, back out all the tremendously ugly
code to gratuitously access said parameters.
 1.96 13-Oct-2006  dogcow More -Wunused fallout. sprinkle __unused when possible; otherwise, use the
do { if (&x) {} } while (/* CONSTCOND */ 0);
construct as suggested by uwe in <20061012224845.GA9449@snark.ptc.spbu.ru>.
 1.95 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.94 28-Aug-2006  christos branches: 1.94.2; 1.94.4;
fix incomplete initializers
 1.93 21-Jul-2006  ad - Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.92 14-May-2006  elad integrate kauth.
 1.91 14-May-2006  martin Fix typo in comment. From M�ty�s J�nos in PR kern/33477.
 1.90 14-Apr-2006  christos Coverity CID 1084: Don't call suser if we don't have a process context.
 1.89 29-Mar-2006  thorpej Use device_cfdata().
 1.88 28-Mar-2006  thorpej Use device_unit().
 1.87 14-Mar-2006  uwe branches: 1.87.2;
Make this compile with WSKBD_DEBUG again.
 1.86 07-Feb-2006  jmmv branches: 1.86.2; 1.86.4;
wsevent cleanup:

- Add a wsevent_inject function that atomically adds a set of events to an
event queue and change all code that directly messed with a queue to use it.
- Replace the WSEVENT_WAKEUP macro with a regular function.
- Make WSEVENT_QSIZE, PWSEVENT and splwsevent private definitions to
wsevent.c, instead of exposing them in the header file.
- Make the wsevent_init function take a process to attach to the queue,
instead of leaving this task to the caller (which always did it).

Reviewed in tech-kern@.
 1.85 11-Dec-2005  christos branches: 1.85.2; 1.85.4; 1.85.6;
merge ktrace-lwp.
 1.84 11-Nov-2005  simonb Call nanotime() directly, instead of doing the
microtime()/TIMEVAL_TO_TIMESPEC() dance.
 1.83 21-Jun-2005  ws branches: 1.83.2;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.
 1.82 29-May-2005  christos - sprinkle const.
- avoid variable shadowing.
 1.81 08-May-2005  he Enclose some code dependent on wsdisplay in #if NWSDISPLAY > 0 / #endif;
fixes build problem for news68k.

Reviewed by augustss
 1.80 04-May-2005  augustss Make auto repeat of events a compile time option, and have it off by default.
Turn on by WSKBD_EVENT_AUTOREPEAT.
 1.79 03-May-2005  augustss Change the logic for generating auto repeat from the keyboard. Previously
auto repeat was only available in translated mode, but not in event mode.
Now both modes have auto repeat. There are actually a few users of
the event mode, and they deserve auto repeat too. :)

Also make it possible to turn off auto repeat by setting repeat.del1=0.
 1.78 28-Apr-2005  martin Make it possible for a console driver to deliver raw ASCII characters
to wskbd. This is for special cases only, and may even be considered a
hack, but it is cheap and very local.
 1.77 27-Feb-2005  perry branches: 1.77.2;
nuke trailing whitespace
 1.76 03-Jun-2004  christos branches: 1.76.4; 1.76.6;
return ENODEV if functions are not compiled in the kernel.
 1.75 29-May-2004  christos fix scrolling code that was not ifdefed.
 1.74 28-May-2004  christos PR/19925: David Ferlier: Add scrolling support to wscons.
 1.73 08-Feb-2004  bjh21 branches: 1.73.2;
Trailing whitespace cleanup.
 1.72 28-Nov-2003  drochner always check whether a display is attached before calling
wsdisplay_*() functions
 1.71 21-Sep-2003  jdolecek cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@
 1.70 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.69 29-Jun-2003  fvdl branches: 1.69.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.68 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.67 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.66 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.65 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.64 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.63 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.62 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.61 17-Mar-2002  atatat branches: 1.61.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.60 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.59 22-Nov-2001  augustss Add some DIAGNOSTIC tests.
 1.58 13-Nov-2001  lukem add/cleanup RCSIDs
 1.57 10-Nov-2001  augustss Make wsdisplay_set_console_kbd() a little less twisted.
 1.56 07-Nov-2001  augustss Ad a debug message. (With { } this time.)
 1.55 27-Oct-2001  augustss Cosmetics.
 1.54 27-Oct-2001  augustss Cosmetics.
 1.53 27-Oct-2001  augustss Don't enable/disable kbds that belong to a display; they are always enabled.
 1.52 26-Oct-2001  augustss Compare against coreect value to determine if we belong to a mux.
 1.51 26-Oct-2001  augustss Small rearrangement and more error checking.
 1.50 25-Oct-2001  augustss Change back to have a wseventvar in the softc for event sources. This
way the effect of FIOASYNC survives close()/open(). Later versions
of XFree86 relies on this bug/feature.
Also add some more debug stuff.
 1.49 24-Oct-2001  augustss Clear wskbd_console_device when console keyboard is detached.
 1.48 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.47 13-Oct-2001  augustss branches: 1.47.2;
Fix a pasto.
 1.46 13-Oct-2001  augustss Use memset(), not bzero().
 1.45 13-Oct-2001  augustss ANSIfy.
 1.44 13-Oct-2001  augustss Two changes to the wsmux code:
* Allow the wsmux used by wsdisplay for the keyboard(s) to be explicitely
specified with the kbdmux locator.
* Allow keyboards and mice that have a mux to be opened in the regular way.
These changes should be totally backwards compatible.
 1.43 26-Sep-2001  matthias wskbd_rawinput: check sc->sc_displaydv before calling wsdisplay_kbdinput.
 1.42 05-Aug-2001  jdolecek branches: 1.42.2;
introduce hard limit on maximum font size (WSDISPLAY_MAXFONTSZ - 512KB)
and keymap size (WSKBDIO_MAXMAPLEN - 64KB)
 1.41 30-May-2001  lukem branches: 1.41.2;
add missing #include "opt_kgdb.h"
 1.40 23-Mar-2001  lukem #ifdef KGDB, call kgdb_connect(1) if KS_Cmd_Debugger (a la ddb invoking
console_debugger() in the same situation).
this makes it easier to get remote kgdb going if you forget to use boot -d.
 1.39 01-Oct-2000  takemura branches: 1.39.2;
- Add ioctl commands to wsdisplay which set/get some LCD status,
backlight, brightness and contrast.
- Add 9 command key symbols which make wskbd to call wsdisplay's
iocontrol.
- Add special key map variant KB_MACHDEP. This variant does not
have any real keymap but it's just a placeholder for machine dependent
maps which will be overwrite by machine dependent keyboard driver.
 1.38 23-Mar-2000  thorpej branches: 1.38.4;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.37 06-Mar-2000  thorpej Add cnbell() support.
 1.36 22-Jan-2000  drochner pass raw keyboard data unsigned to avoid sign extension
 1.35 05-Jan-2000  drochner replace embedded _rcsid[] string by __KERNEL_RCSID(), remove _copyright[]
 1.34 21-Dec-1999  drochner change decoding function to return multiple symbols per keypress
(through the "internal" structure), derive a METAESC flag from the
layout variant and translate ALT-<key> into ESC <key> if the flag is set
 1.33 01-Dec-1999  augustss Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.
 1.32 01-Dec-1999  augustss Make it compile even if there is no wsdisplay.
 1.31 08-Nov-1999  mycroft branches: 1.31.2;
Apply wrstuden's stopgap change to make alpha/macppc X work without wsmux.
 1.30 16-Aug-1999  augustss branches: 1.30.2; 1.30.4; 1.30.6;
Mention mux # when ignoring it for the console.
 1.29 07-Aug-1999  augustss Make it possible to open wskbd devices for write (i.e. ioctl) even
if it is already open.
 1.28 30-Jul-1999  augustss Eliminate the need for needs-count for wsmux. This should make
wsdisplays work properly again.
 1.27 29-Jul-1999  augustss Add the wsmux pseudo device.
 1.26 06-Jul-1999  augustss Add the detach and activate entry points to the cfattach struct.
 1.25 01-Jul-1999  drochner make it compile if WSDISPLAY_COMPAT_RAWKBD is defined, but NWSDISPLAY not,
reported by Kazushi Marukawa <jam@pobox.com>
 1.24 30-Jun-1999  augustss Make it possible to detach wsmouse and wskbd.
XXX wskbd probably needs some more work.
 1.23 16-May-1999  thorpej Make this build without wsdisplay.
 1.22 15-May-1999  drochner Get rid of the timeout-driven wscons_glue stuff which caused a lot of
headaches.
Now console keyboard and display are connected at autoconfiguration time,
when the last of them is found. Other keyboards / displays remain
unconnected until a new ioctl (WSDISPLAYIO_SETKEYBOARD) is called.
 1.21 14-May-1999  drochner Sort out the inclusion of wscons source files: the files are only
compiled if the corresponding devices are configured.
(Files calling wscons functions have to check whether these are present.)
 1.20 27-Mar-1999  drochner branches: 1.20.4;
remove a diagnostic panic in the keyboard autorepeat timeout() handler.
There is a rece condition which might trigger this but is harmless
otherwise. Leave the handler silently instead.
 1.19 26-Jan-1999  drochner Debugger() -> console_debugger() to honour the ddb_fromconsole sysctl
 1.18 17-Jan-1999  drochner adapt to "reset" interface change, pass "close all" to wsdisplay
 1.17 14-Jan-1999  drochner add a "reset terminal emulator" command pseudo-keysym and call the
corresponding callback if one is hit
 1.16 10-Jan-1999  augustss Remove redundant test if the unit numbers is in range.
 1.15 10-Jan-1999  augustss Change from bcopy/bzero to memxxx. From PR 6778 by
Erik Bertelsen <erik@q610.ebe.uni-c.dk>.
 1.14 28-Dec-1998  hannken Prepare for wsconsctrl:
- clean up keycode defines.
- allow easy parse of wsksymdef.h.
- add misssing KB_IT entry.
- set layout to KB_USER after ioctl WSKBDIO_SETMAP.
 1.13 17-Sep-1998  drochner Define a new keyboard eveny type "all keys up". This allows to reduce
the amount of statekeeping in drivers for LK201-like keyboards, and it
might be useful to resync after resets or overflows.
(reused the unused WSCONS_EVENT_KEY_OTHER event ID)
Implement the necessary decoding bits.
 1.12 02-Aug-1998  drochner Split the wskbd_attach arguments into console and autoconfiguration parts
(again); put some constant data into shared structures. This makes it
more look like the mouse part, and it helps USB integration.
Implement wskbd_enable() to enable/disable the keyboard.
 1.11 23-Jul-1998  drochner Switch keyboard to "event mode" on open.
Nuke wskbd_set_translation(). It doesn't fit into the "screen" model.
 1.10 04-Jul-1998  jonathan defopt DDB.
 1.9 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.8 13-Jun-1998  drochner fix initialization in non-console case
 1.7 11-Jun-1998  drochner add "sleeping ok" argument to wsdisplay_switch()
implement a way to get raw keyboard data (for X)
 1.6 09-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.5 23-May-1998  thorpej Make it possible to build a kernel with a wscons display device but not
a wscons keyboard device.
 1.4 09-Apr-1998  hannken Forgot to initialize sc->ioctl. From Matthias Drochner.
 1.3 09-Apr-1998  hannken Split wscons/wskbd.c's softc into a static and a nonstatic part.
Booting into debugger (-d) now works.
Cleaned wscons/wskbdvar.h. Use the same attach arguments for
console and normal keyboards.
 1.2 07-Apr-1998  hannken Initial import of MI keyboard translation for dev/wscons.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.20.4.3 02-Aug-1999  thorpej Update from trunk.
 1.20.4.2 01-Jul-1999  thorpej Sync w/ -current.
 1.20.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.30.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.30.4.1 15-Nov-1999  fvdl Sync with -current
 1.30.2.2 27-Mar-2001  bouyer Sync with HEAD.
 1.30.2.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.31.2.2 08-Nov-1999  mycroft Apply wrstuden's stopgap change to make alpha/macppc X work without wsmux.
 1.31.2.1 08-Nov-1999  mycroft file wskbd.c was added on branch comdex-fall-1999 on 1999-11-08 04:48:19 +0000
 1.38.4.1 16-Aug-2001  tv Pullup [jdolecek]:

sys/dev/wscons/wsdisplay.c 1.52
sys/dev/wscons/wskbd.c 1.42
sys/dev/wscons/wsconsio.h 1.40

Introduce hard limits on wscons font size and keymap size, and
bounds check against those limits.
 1.39.2.13 03-Jan-2003  thorpej Sync with HEAD.
 1.39.2.12 11-Nov-2002  nathanw Catch up to -current
 1.39.2.11 18-Oct-2002  nathanw Catch up to -current.
 1.39.2.10 17-Sep-2002  nathanw Catch up to -current.
 1.39.2.9 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.39.2.8 28-Feb-2002  nathanw Catch up to -current.
 1.39.2.7 08-Jan-2002  nathanw Catch up to -current.
 1.39.2.6 14-Nov-2001  nathanw Catch up to -current.
 1.39.2.5 22-Oct-2001  nathanw Catch up to -current.
 1.39.2.4 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.39.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.39.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.39.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.41.2.6 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.41.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.41.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.41.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.41.2.2 08-Sep-2001  thorpej Add kqueue support to wscons events.
 1.41.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.42.2.3 01-Oct-2001  fvdl Catch up with -current.
 1.42.2.2 26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.42.2.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.47.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.61.4.1 16-May-2002  gehenna Add the character device switch.
Replace the direct-access to devsw table with calling devsw API.
 1.69.2.8 11-Dec-2005  christos Sync with head.
 1.69.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.69.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.69.2.5 21-Nov-2004  skrll Adapt to branch.
 1.69.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.69.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.69.2.2 03-Aug-2004  skrll Sync with HEAD
 1.69.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.73.2.3 07-Jun-2004  tron Pull up revision 1.76 (requested by recht in ticket #451):
return ENODEV if functions are not compiled in the kernel.
 1.73.2.2 07-Jun-2004  tron Pull up revision 1.75 (requested by recht in ticket #451):
fix scrolling code that was not ifdefed.
 1.73.2.1 07-Jun-2004  tron Pull up revision 1.74 (requested by recht in ticket #451):
PR/19925: David Ferlier: Add scrolling support to wscons.
 1.76.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.76.4.1 29-Apr-2005  kent sync with -current
 1.77.2.1 03-Jun-2005  riz Pull up revision 1.78 (requested by martin in ticket #370):
Make it possible for a console driver to deliver raw ASCII characters
to wskbd. This is for special cases only, and may even be considered a
hack, but it is cheap and very local.
 1.83.2.9 17-Mar-2008  yamt sync with head.
 1.83.2.8 27-Feb-2008  yamt sync with head.
 1.83.2.7 21-Jan-2008  yamt sync with head
 1.83.2.6 07-Dec-2007  yamt sync with head
 1.83.2.5 27-Oct-2007  yamt sync with head.
 1.83.2.4 03-Sep-2007  yamt sync with head.
 1.83.2.3 26-Feb-2007  yamt sync with head.
 1.83.2.2 30-Dec-2006  yamt sync with head.
 1.83.2.1 21-Jun-2006  yamt sync with head.
 1.85.6.2 01-Jun-2006  kardel Sync with head.
 1.85.6.1 22-Apr-2006  simonb Sync with head.
 1.85.4.1 09-Sep-2006  rpaulo sync with head
 1.85.2.1 18-Feb-2006  yamt sync with head.
 1.86.4.4 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.86.4.3 19-Apr-2006  elad sync with head.
 1.86.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.86.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.86.2.4 03-Sep-2006  yamt sync with head.
 1.86.2.3 11-Aug-2006  yamt sync with head
 1.86.2.2 24-May-2006  yamt sync with head.
 1.86.2.1 01-Apr-2006  yamt sync with head.
 1.87.2.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.87.2.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.94.4.2 10-Dec-2006  yamt sync with head.
 1.94.4.1 22-Oct-2006  yamt sync with head
 1.94.2.3 06-Feb-2007  ad Quieten noisy boot messages.
 1.94.2.2 12-Jan-2007  ad Sync with head.
 1.94.2.1 18-Nov-2006  ad Sync with head.
 1.100.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.101.4.1 11-Jul-2007  mjf Sync with head.
 1.101.2.3 23-Oct-2007  ad Sync with head.
 1.101.2.2 20-Aug-2007  ad Sync with HEAD.
 1.101.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.104.6.7 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.104.6.6 01-Dec-2007  jmcneill Sync with HEAD.
 1.104.6.5 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.104.6.4 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.104.6.3 09-Aug-2007  jmcneill Sync with HEAD.
 1.104.6.2 05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.104.6.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.104.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.105.6.2 06-Aug-2007  macallan set the scrollmode flag when entering/leaving scroll mode, send scroll reset
when leaving
 1.105.6.1 06-Aug-2007  macallan file wskbd.c was added on branch matt-mips64 on 2007-08-06 03:07:53 +0000
 1.105.4.1 18-Oct-2007  yamt sync with head.
 1.105.2.3 23-Mar-2008  matt sync with HEAD
 1.105.2.2 09-Jan-2008  matt sync with HEAD
 1.105.2.1 06-Nov-2007  matt sync with HEAD
 1.106.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.107.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.107.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.108.4.1 11-Dec-2007  yamt sync with head.
 1.108.2.1 26-Dec-2007  ad Sync with head.
 1.111.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.112.6.6 17-Jan-2009  mjf Sync with HEAD.
 1.112.6.5 29-Jun-2008  mjf Sync with HEAD.
 1.112.6.4 02-Jun-2008  mjf Sync with HEAD.
 1.112.6.3 06-Apr-2008  mjf - after some discussion with agc@ i agreed it would be a good idea to move
device_unregister_* to device_deregister_* to be more like the pmf(9)
functions, especially since a lot of the time the function calls are next
to each other.

- add device_register_name() support for dk(4).
 1.112.6.2 03-Apr-2008  mjf Sync with HEAD.
 1.112.6.1 29-Mar-2008  mjf - etc/devfsd.conf: Add some rules to give nodes like /dev/tty and
/dev/null better default modes, i.e. 0666.

- sbin/init: Run devfsd -s before going to multiuser.

- sys/arch: Provide arm32, i386, sparc with a mem_init() function to request
device nodes for /dev/null, /dev/zero, etc.

- sys/dev: Convert rnd, wd, agp, raid, cd, sd, wsdisplay, wskbd, wsmouse,
wsmux, tty, bpf, swap to devfs New World Order.

- sys/fs/devfs: Make the visibility attribute of device nodes configurable.
Also provide a function to mount a devfs on boot.

- sys/kern: Add a new boot flag, -n. This disables devfs support. Unless
the -n flag is specified the kernel will mount a devfs file
system on boot.
 1.112.2.1 24-Mar-2008  keiichi sync with head.
 1.116.2.2 17-Jun-2008  yamt sync with head.
 1.116.2.1 18-May-2008  yamt sync with head.
 1.117.2.4 11-Aug-2010  yamt sync with head.
 1.117.2.3 11-Mar-2010  yamt sync with head
 1.117.2.2 04-May-2009  yamt sync with head.
 1.117.2.1 16-May-2008  yamt sync with head.
 1.119.4.1 18-Jun-2008  simonb Sync with head.
 1.119.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.120.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.126.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.126.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.126.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.127.2.2 05-Mar-2011  rmind sync with head
 1.127.2.1 03-Jul-2010  rmind sync with head
 1.130.14.1 07-Dec-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #1201):
sys/kern/kern_ktrace.c: revision 1.166
sys/dev/isa/aps.c: revision 1.16
sys/dev/sysmon/sysmonvar.h: revision 1.45
sys/dev/ir/irframe_tty.c: revision 1.60
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.111-1.112 (patch)
sys/dev/pci/pccbb.c: revision 1.207
sys/dev/wscons/wskbd.c: revision 1.135
sys/dev/usb/ohci.c: revision 1.254
sys/net/if_ecosubr.c: revision 1.41
sys/dev/pcmcia/btbc.c: revision 1.17
sys/arch/x86/x86/via_padlock.c: revision 1.23
sys/dev/sdmmc/sdmmc.c: revision 1.23 (patch)
sys/dev/bluetooth/btkbd.c: revision 1.17
sys/dev/bluetooth/bcsp.c: revision 1.25
sys/arch/x86/pci/fwhrng.c: revision 1.8
sys/dev/ic/nslm7x.c: revision 1.61
share/man/man9/callout.9: revision 1.28 (patch)

Replace callout_stop with callout_halt and ensure the callout
is not running before destroying it.
 1.130.12.1 05-Apr-2012  mrg sync to latest -current.
 1.130.8.3 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.130.8.2 30-Oct-2012  yamt sync with head
 1.130.8.1 17-Apr-2012  yamt sync with head
 1.132.4.1 18-May-2014  rmind sync with head
 1.132.2.2 03-Dec-2017  jdolecek update from HEAD
 1.132.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.133.2.1 10-Aug-2014  tls Rebase.
 1.134.2.1 01-Dec-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #279):
sys/kern/kern_ktrace.c: revision 1.166
sys/dev/isa/aps.c: revision 1.16
sys/dev/sysmon/sysmonvar.h: revision 1.45
sys/dev/ir/irframe_tty.c: revision 1.60
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.111
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.112
sys/dev/pci/pccbb.c: revision 1.207
sys/dev/wscons/wskbd.c: revision 1.135
sys/dev/usb/ohci.c: revision 1.254
sys/net/if_ecosubr.c: revision 1.41
sys/dev/pcmcia/btbc.c: revision 1.17
sys/arch/x86/x86/via_padlock.c: revision 1.23
sys/dev/sdmmc/sdmmc.c: revision 1.23
sys/dev/bluetooth/btkbd.c: revision 1.17
sys/dev/bluetooth/bcsp.c: revision 1.25
sys/arch/x86/pci/fwhrng.c: revision 1.8
sys/dev/ic/nslm7x.c: revision 1.61
share/man/man9/callout.9: revision 1.28
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
Discussed with martin@ and riastradh@.
Make it clear that we should use not callout_stop but callout_halt
before callout_destroy
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
In this case, we need to pass an interlock to callout_halt to wait for
the callout complete.
Reviewed by riastradh@.
Kill sme_callout_mtx and use sme_mtx instead
We can use sme_mtx for the callout as well. Actually we should do so
because sme_events_list and some other data that are touched in the
callout should be protected by sme_mtx, not sme_callout_mtx.
Discussed with riastradh@ in
http://mail-index.netbsd.org/tech-kern/2014/11/11/msg017956.html
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
In this case, we need to pass an interlock to callout_halt to wait for
the callout complete. And also we make sure that SME_CALLOUT_INITIALIZED
is unset before calling callout_halt to prevent the callout from calling
callout_schedule. This is the same as what we did in sys/netinet6/mld6.c@1.61.
Reviewed by riastradh@.
 1.135.2.2 28-Aug-2017  skrll Sync with HEAD
 1.135.2.1 22-Sep-2015  skrll Sync with HEAD
 1.136.2.4 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.136.2.3 26-Jul-2016  pgoyette Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT. This better describes
what we're doing, and why.
 1.136.2.2 19-Jul-2016  pgoyette Instead of repeatedly typing the conditional initialization of the
.d_localcount members in the various {b,c}devsw, define an initializer
macro and use it. This also removes the need for defining new symbols
for each 'struct localcount'.

As suggested by riastradh@
 1.136.2.1 18-Jul-2016  pgoyette Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.
 1.138.6.2 29-Apr-2017  pgoyette Remove more unnecessary #include for sys/localcount.h
 1.138.6.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.141.4.1 10-Jun-2019  christos Sync with HEAD
 1.141.2.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.143.12.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.144.24.1 02-Aug-2025  perseant Sync with HEAD
 1.10 10-Jan-1999  drochner Since ukbd has an own map, this file is not needed anymore.
 1.9 28-Dec-1998  augustss Fix typo.
 1.8 28-Dec-1998  hannken Prepare for wsconsctrl:
- clean up keycode defines.
- allow easy parse of wsksymdef.h.
- add misssing KB_IT entry.
- set layout to KB_USER after ioctl WSKBDIO_SETMAP.
 1.7 17-Sep-1998  drochner Add end mark to list of keymaps.
XXX This file will be removed, it is only left until the USB driver
XXX got an own keymap.
 1.6 01-Sep-1998  drochner -add italian layout, from Dante Profeta <dante@mclink.it>
-name pckbd_keydesc_declk -> pckbd_keydesc_us_declk for consistency
 1.5 15-Jul-1998  drochner rename "LK" -> "declk" for consistency
 1.4 14-Jul-1998  drochner support keyboards with PC interface and DEC layout (LK461)
 1.3 18-Apr-1998  drochner Add danish keymap.
From Soren S. Jorvang (PR kern/5312).
 1.2 18-Apr-1998  drochner Namespace protection: give key description table a more private name.
 1.1 07-Apr-1998  hannken Initial import of MI keyboard translation for dev/wscons.
 1.19 03-Nov-2017  maya Use __arraycount a bunch
Also, DIAGNOSTIC panic -> KASSERT
 1.18 05-Feb-2010  drochner branches: 1.18.22;
add some missing (mostly hungarian or polish) dead accent combinations,
from lkundrak's netbsd-sk_cz-howto
 1.17 28-Jan-2010  drochner -rename the "KS_GROUP_Ascii" key symbol category to "Plain" because
this is what it meant all the time -- it includes characters >127
-delegate translation of all key symbols >127 to the terminal emulation
layer -- formerly everything non-special was passed to the tty subsystem
directly, involving truncation to a "char", which effectively meant
some ISO-1 assumption
 1.16 06-Apr-2009  mkirby Add a Czech (QWERTY) keyboard layout, and teach wscons about latin 2 characters.

Original code from Lubomir Kundrak, adapted to current and cleaned up by me.

Fixes PR kern/16216

ok agc@ jdc@
 1.15 28-Apr-2008  martin branches: 1.15.8; 1.15.10; 1.15.14; 1.15.18;
Remove clause 3 and 4 from TNF licenses
 1.14 29-Jan-2007  hubertf branches: 1.14.40; 1.14.42; 1.14.44;
Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
 1.13 01-Apr-2006  christos branches: 1.13.8;
Greek console keymap from Eye of the Beholder
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.10; 1.12.12;
merge ktrace-lwp.
 1.11 27-Feb-2005  perry branches: 1.11.4;
nuke trailing whitespace
 1.10 15-Nov-2001  lukem branches: 1.10.16; 1.10.24; 1.10.26;
don't need <sys/types.h> when including <sys/param.h>
 1.9 13-Nov-2001  lukem add/cleanup RCSIDs
 1.8 13-Oct-2001  augustss ANSIfy.
 1.7 21-Dec-1999  drochner branches: 1.7.6; 1.7.8;
add a symbol for keyboard variant bits which are not handled by the
mapping code
 1.6 17-Sep-1998  drochner branches: 1.6.12; 1.6.18;
Reorganize the list of keyboard maps: no explicite length counter, use
an end mark instead. This allows to keep keymaps separate from the drivers
referring to them.
 1.5 02-Aug-1998  drochner Split the wskbd_attach arguments into console and autoconfiguration parts
(again); put some constant data into shared structures. This makes it
more look like the mouse part, and it helps USB integration.
Implement wskbd_enable() to enable/disable the keyboard.
 1.4 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.3 20-Apr-1998  hannken Undo change from drochner (Rev 1.4 of wsksymdef.h) and fix PR #5298 and #5299.
 1.2 09-Apr-1998  hannken Split wscons/wskbd.c's softc into a static and a nonstatic part.
Booting into debugger (-d) now works.
Cleaned wscons/wskbdvar.h. Use the same attach arguments for
console and normal keyboards.
 1.1 07-Apr-1998  hannken Initial import of MI keyboard translation for dev/wscons.
 1.6.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.12.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.7.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.6.3 08-Jan-2002  nathanw Catch up to -current.
 1.7.6.2 14-Nov-2001  nathanw Catch up to -current.
 1.7.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.10.26.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.10.24.1 29-Apr-2005  kent sync with -current
 1.10.16.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.4.2 26-Feb-2007  yamt sync with head.
 1.11.4.1 21-Jun-2006  yamt sync with head.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.10.1 19-Apr-2006  elad sync with head.
 1.12.8.1 11-Apr-2006  yamt sync with head
 1.12.6.1 22-Apr-2006  simonb Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.13.8.1 01-Feb-2007  ad Sync with head.
 1.14.44.3 11-Mar-2010  yamt sync with head
 1.14.44.2 04-May-2009  yamt sync with head.
 1.14.44.1 16-May-2008  yamt sync with head.
 1.14.42.1 18-May-2008  yamt sync with head.
 1.14.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.18.1 21-Apr-2010  matt sync to netbsd-5
 1.15.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.10.1 01-Nov-2009  bouyer Apply patch, requested by ahoka in ticket #1111:
sys/dev/pckbport/wskbdmap_mfii.c patch
sys/dev/wscons/wsksymdef.h patch
sys/dev/wscons/wskbdutil.c patch
Add hungarian keyboard layout.
 1.15.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.22.1 03-Dec-2017  jdolecek update from HEAD
 1.20 23-Sep-2022  riastradh wskbd(4): Add include guards.

No functional change intended.
 1.19 02-Sep-2012  he Now that we use keysym_t, make sure <dev/wscons/wsksymvar.h> is included.
Fixes the kernel build for next68k's nextcons.c and mac68k's maccons.c.
 1.18 29-Aug-2012  macallan support an optional table to translate scancodes when in event mode
 1.17 26-Oct-2010  jruoho branches: 1.17.8;
Add wskbd_hotkey_deregister() to match wskbd_hotkey_register().

XXX: This is kind of futile; the only user of the wskbd(4)'s hotkey interface
is hpqlb(4), which is a questionable driver, being, by design,
limited only to the laptop model for which the driver was written.
 1.16 01-May-2008  cegger branches: 1.16.20; 1.16.22;
hpqlb(4): driver for HP Quick Launch buttons - found on HP Pavilion Notebooks
 1.15 25-Mar-2008  cube branches: 1.15.2; 1.15.4;
Split device_t and softc for wskbd(4), wsmouse(4) and that creepy wsmux(4).
 1.14 04-Mar-2007  christos branches: 1.14.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 09-Oct-2006  peter branches: 1.13.4;
KNF: No variable names in the prototype.
 1.12 11-Dec-2005  christos branches: 1.12.20; 1.12.22;
merge ktrace-lwp.
 1.11 13-Oct-2001  augustss branches: 1.11.18; 1.11.34;
ANSIfy.
 1.10 06-Mar-2000  thorpej branches: 1.10.6; 1.10.8;
Add cnbell() support.
 1.9 22-Jan-2000  drochner pass raw keyboard data unsigned to avoid sign extension
 1.8 01-Dec-1999  augustss Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.
 1.7 29-Jul-1999  augustss branches: 1.7.2; 1.7.8;
Add the wsmux pseudo device.
 1.6 02-Aug-1998  drochner branches: 1.6.8;
Split the wskbd_attach arguments into console and autoconfiguration parts
(again); put some constant data into shared structures. This makes it
more look like the mouse part, and it helps USB integration.
Implement wskbd_enable() to enable/disable the keyboard.
 1.5 28-Jul-1998  augustss Do locator related defines using defines from locators.h rather
than literal constants.
 1.4 11-Jun-1998  drochner implement a way to get raw keyboard data (for X)
 1.3 09-Apr-1998  hannken Split wscons/wskbd.c's softc into a static and a nonstatic part.
Booting into debugger (-d) now works.
Cleaned wscons/wskbdvar.h. Use the same attach arguments for
console and normal keyboards.
 1.2 07-Apr-1998  hannken Initial import of MI keyboard translation for dev/wscons.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.6.8.1 02-Aug-1999  thorpej Update from trunk.
 1.7.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.7.2.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.10.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.11.34.3 03-Sep-2007  yamt sync with head.
 1.11.34.2 30-Dec-2006  yamt sync with head.
 1.11.34.1 21-Jun-2006  yamt sync with head.
 1.11.18.1 21-Nov-2004  skrll Adapt to branch.
 1.12.22.1 22-Oct-2006  yamt sync with head
 1.12.20.1 18-Nov-2006  ad Sync with head.
 1.13.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.36.2 02-Jun-2008  mjf Sync with HEAD.
 1.14.36.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.4.1 16-May-2008  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.16.22.1 05-Mar-2011  rmind sync with head
 1.16.20.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.17.8.1 30-Oct-2012  yamt sync with head
 1.78 11-Dec-2023  mlelstv Adjust next key value (it's not used anywhere).
 1.77 22-Sep-2021  nia wscons: add definitions for BÉPO, a standardized, Dvorak-style optimized
keyboard layout for French
 1.76 11-May-2021  nia wscons: add support for the Neo 2 German keyboard layout

Neo is an optimized layout for German and English, similar to
Dvorak for English. It can be used to type most Latin-based languages
and has separate layers for symbols and directional commands.
 1.75 17-Oct-2020  mlelstv branches: 1.75.6; 1.75.8;
Correct KB_NEXT value. No impact since KB_NEXT isn't used anywhere.
 1.74 29-Aug-2020  macallan provide KB_APPLE layout variant which uses Command-F* to switch console screens
mostly for consistent behaviour across *Books which may have ADB or USB
keyboards
 1.73 13-Jul-2020  nia Clarify that KB_TR is the "Q" layout - there's two standards for Turkish.
 1.72 13-Jul-2020  nia Canadian French keyboard layout for ukbd/pckbd
 1.71 13-Jul-2020  nia Add keyboard layout for Latin American Spanish to ukbd/pckbd
 1.70 12-Jul-2020  nia Add Icelandic keyboard layout to ukbd/pckbd.
 1.69 12-Jul-2020  nia Add Estonian layout as a variation of Swedish for ukbd and pckbd
 1.68 12-Jul-2020  nia Add support for the Brazilian keyboard layout to pckbd and ukbd.

This is significantly different from the European Portugese layout,
and was pieced together from Wikipedia, X11 layout files, and to
some extent with trial and error.

Thanks to lun-4 for helping test this.

PR kern/44570
 1.67 19-Feb-2018  maya branches: 1.67.10;
Add Turkish keyboard layout.

from berte in PR kern/53011.
 1.66 22-Apr-2012  khorben branches: 1.66.32;
Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself
 1.65 22-Jul-2011  christos branches: 1.65.2; 1.65.6;
PR/35473: Wigcher Spanninga: Add Dutch keyboard support to wscons
 1.64 28-Jan-2010  drochner -rename the "KS_GROUP_Ascii" key symbol category to "Plain" because
this is what it meant all the time -- it includes characters >127
-delegate translation of all key symbols >127 to the terminal emulation
layer -- formerly everything non-special was passed to the tty subsystem
directly, involving truncation to a "char", which effectively meant
some ISO-1 assumption
 1.63 06-Apr-2009  mkirby Add a Czech (QWERTY) keyboard layout, and teach wscons about latin 2 characters.

Original code from Lubomir Kundrak, adapted to current and cleaned up by me.

Fixes PR kern/16216

ok agc@ jdc@
 1.62 18-Feb-2009  snj s/portugese/portuguese/, spotted by Ari Constancio in PR misc/40202.
 1.61 21-May-2008  ghen branches: 1.61.6; 1.61.8; 1.61.12; 1.61.14; 1.61.16;
Add support for the Colemak keyboard layout variant, see http://colemak.com
 1.60 28-Apr-2008  martin branches: 1.60.2;
Remove clause 3 and 4 from TNF licenses
 1.59 09-Dec-2007  jmcneill branches: 1.59.10; 1.59.12; 1.59.14;
Merge jmcneill-pm branch.
 1.58 04-Apr-2007  mishka branches: 1.58.8; 1.58.10; 1.58.18; 1.58.20;
Revert previous commit until further investigation because it is
known as problematic. Some problems obscured are dead Del key (I
can reproduce this with wscons scroll support) and panic (seen by
<elad> only).
 1.57 02-Apr-2007  mishka Implement locking switcher for alternative layots (many languages
are based on completely different alphabet, and typesetting with
one of modifiers pressed all the time is just a PITA). See
http://mail-index.netbsd.org/tech-kern/2007/03/29/0002.html for
usage details.

While here, perform the following small cleanups:
- KS_Cmd_Scroll* execution should be explicitly interrupted with 'break'.
- Some 'human' cleanups in ksym extraction algorithm (no func. changes).
- Add a note: implemented ksym translation isn't sufficient for l10n.
 1.56 01-Apr-2006  christos branches: 1.56.12; 1.56.20; 1.56.24;
Greek console keymap from Eye of the Beholder
 1.55 11-Dec-2005  christos branches: 1.55.4; 1.55.6; 1.55.8; 1.55.10; 1.55.12;
merge ktrace-lwp.
 1.54 08-Jun-2005  martin branches: 1.54.2;
Add a key symbol for the "Power" key.
 1.53 30-Apr-2005  augustss Remember what keyboard layout is set in the mux, that way new keyboards
can be given the same layout. Fixes kern/19153.
 1.52 04-Apr-2005  martti s/Finish/Finnish/
 1.51 08-Mar-2005  dsl branches: 1.51.2;
Change the wa ythe KB_xxx and KB_ENCTAB are defined so we have all the
data for a single keyboard on one line - including the long name and
default modifiers that sysinst needs.
 1.50 02-Dec-2004  hubertf branches: 1.50.4; 1.50.6;
Try to document keymap names - this really a trip into the obscure.
XXX someone please review!
 1.49 28-May-2004  christos PR/19925: David Ferlier: Add scrolling support to wscons.
 1.48 13-May-2004  pooka Add el-cheapo finnish encoding, i.e. make the name "fi" point to
the swedish keymap, which actually gets set.

inspired by wiz
keymap name blessed by Klaus
 1.47 25-Nov-2002  fvdl branches: 1.47.6; 1.47.8;
Add 'U' to 16-bit hex constants to stop gcc 3.3 from complaining. Shouldn't
really be needed, but.. (from scw and thorpej).
 1.46 25-Oct-2002  martin Add a few symbols.
 1.45 23-Apr-2002  hannken Remove the cyrillic keysyms. This was not done the right way.
Will come back after 1.6 has branched.

Approved by: Matthias Drochner <drochner@netbsd.org>
 1.44 24-Mar-2002  uwe Sync most Cyrillic names with X11 keysym names.
 1.43 17-Mar-2002  augustss Add Cyrillic keysyms. From OpenBSD.
 1.42 17-Mar-2002  augustss Don't forget the symbolc names for the keymaps.
 1.41 17-Mar-2002  augustss Add more language map definitions.
 1.40 11-Nov-2001  martin Add polish keyboard map, from Dawid Szyma_ski <dawszy@netbsd.lubin.pl>.
 1.39 05-Dec-2000  drochner branches: 1.39.2; 1.39.4; 1.39.8;
add some missing definitions for hungarian keymap support
(It won't help much since there is no way to get characters not in
iso-1 or the function key set through the vt100/sun/dumb terminal
emulations:-(
 1.38 13-Oct-2000  mjl Revert previous since the finnish keymap is already present under
the name "sv". Note to myself: Read PRs completely before acting.
Note to Santa Claus: I want a mailing list that carries all follow
ups to PRs!
 1.37 12-Oct-2000  mjl Add finnish keymap, from Heikki Kallasjoki in PR/11186.
 1.36 01-Oct-2000  takemura - Add ioctl commands to wsdisplay which set/get some LCD status,
backlight, brightness and contrast.
- Add 9 command key symbols which make wskbd to call wsdisplay's
iocontrol.
- Add special key map variant KB_MACHDEP. This variant does not
have any real keymap but it's just a placeholder for machine dependent
maps which will be overwrite by machine dependent keyboard driver.
 1.35 06-Jul-2000  hannken Change type `kbd_t' from `u_int_16_t' to `u_int32_t'.
This eliminates bogus casts from `int *' to `u_int_16_t*'.
 1.34 19-May-2000  drochner branches: 1.34.4;
define spanish keymap
 1.33 13-May-2000  bjh21 Oops. Swedish is KB_SV.
 1.32 13-May-2000  bjh21 Add keypad-# and Swedish layout
 1.31 14-Apr-2000  tsarna Add an "iopener" keymap variant, giving us.iopener and
us.iopener.swapctrlcaps. This makes F1 ("Back") into Escape, and shifts
the other keys over by one, so F2-F12 ("Forward"-"Home") become F1-F11.
 1.30 19-Mar-2000  tsarna Make clearer. IMHO, all of this code should stop referring to Control-L
and Control-R, since those suggest ^L and ^R, not Left and Right Control.
 1.29 19-Mar-2000  tsarna Correct a comment
 1.28 05-Mar-2000  soren Add Norwegian keymap from Haavard Lygre.
 1.27 21-Dec-1999  drochner introduce a METAESC keyboard variant bit
 1.26 10-Nov-1999  drochner allow to set multiple keyboard "variants" simultanously.
Follows PR kern/8456 by Michael Eriksson <eramore@era-t.ericsson.se>,
implemented diffently.
 1.25 11-May-1999  drochner branches: 1.25.2; 1.25.4; 1.25.8;
define swedish layout and "dvorak" variant
 1.24 12-Feb-1999  drochner branches: 1.24.2; 1.24.4;
"NEXT" is a keyboard type, not a keymap variation.
 1.23 28-Jan-1999  dbj wscons based console video & keyboard support for the NeXT
from Matt DeBergalis
 1.22 23-Jan-1999  drochner add definitions for the additional modifiers on japanese keyboards
(These are not of use for wscons, but we want to give names to the keys
at least.)
 1.21 17-Jan-1999  drochner define a "close everything" keyboard command
 1.20 15-Jan-1999  drochner add definition for japanese keyboard
 1.19 14-Jan-1999  drochner add a "reset terminal emulator" command pseudo-keysym and call the
corresponding callback if one is hit
 1.18 10-Jan-1999  augustss Rename the "windows" keys and add the new keys to the keyboard maps.
 1.17 10-Jan-1999  augustss Add definitions for Pause and Print_Screen keys.
(Why were these keys missing? Or am I missing something obvious here?)
 1.16 10-Jan-1999  augustss Add definitions for left and right "Windows" keys and menu key.
 1.15 09-Jan-1999  drochner add a definition for the "swap ctl and caps" option
 1.14 06-Jan-1999  drochner add definition for british keyboard
 1.13 28-Dec-1998  hannken Prepare for wsconsctrl:
- clean up keycode defines.
- allow easy parse of wsksymdef.h.
- add misssing KB_IT entry.
- set layout to KB_USER after ioctl WSKBDIO_SETMAP.
 1.12 03-Oct-1998  drochner add definition for french keyboard
 1.11 17-Sep-1998  drochner Add option bit which covers the delta between LK201 and LK401.
 1.10 01-Sep-1998  drochner add definition for italian keyboard
 1.9 15-Jul-1998  drochner rename "LK" -> "declk" for consistency
 1.8 14-Jul-1998  drochner support keyboards with PC interface and DEC layout (LK461)
 1.7 16-Jun-1998  drochner add missing keys for vt100
 1.6 20-Apr-1998  hannken Undo change from drochner (Rev 1.4 of wsksymdef.h) and fix PR #5298 and #5299.
 1.5 18-Apr-1998  drochner Add danish keymap.
From Soren S. Jorvang (PR kern/5312).
 1.4 16-Apr-1998  drochner Don't use KS_GROUP_xxx values which have set something in the lower
8 bits. This allows to OR them with keycodes.
This is probably a workaround for namespace confusion happening else-
where (in wskbdutil.c:ksym_upcase() perhaps?), but it helps without
too much digging into the details.
 1.3 07-Apr-1998  hannken Fix typo.
 1.2 07-Apr-1998  hannken Oops. Forgot RCS ident and copyright.
 1.1 07-Apr-1998  hannken Initial import of MI keyboard translation for dev/wscons.
 1.24.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.24.2.1 04-Dec-1999  he Pull up revision 1.25 (requested by drochner):
Add Swedish and Dvorak keyboard maps for PC keyboards.
 1.25.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.25.4.1 15-Nov-1999  fvdl Sync with -current
 1.25.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.25.2.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.34.4.1 07-Jul-2000  hannken Pull up revision 1.35:
- kbd_t from u_int_16_t to u_int_32_t.
 1.39.8.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.39.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.39.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.39.2.5 11-Dec-2002  thorpej Sync with HEAD.
 1.39.2.4 11-Nov-2002  nathanw Catch up to -current
 1.39.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.39.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.39.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.47.8.1 07-Jun-2004  tron branches: 1.47.8.1.2;
Pull up revision 1.49 (requested by recht in ticket #451):
PR/19925: David Ferlier: Add scrolling support to wscons.
 1.47.8.1.2.4 09-Oct-2005  tron Pull up following revision(s) (requested by riz in ticket #5919):
sys/dev/wscons/wsksymdef.h: revision 1.52
s/Finish/Finnish/
 1.47.8.1.2.3 24-Jul-2005  snj Pull up revision 1.51 (requested by riz in ticket #5524):
Change the wa ythe KB_xxx and KB_ENCTAB are defined so we have all the
data for a single keyboard on one line - including the long name and
default modifiers that sysinst needs.
 1.47.8.1.2.2 24-Jul-2005  snj Pull up revision 1.50 (requested by riz in ticket #5524):
Try to document keymap names - this really a trip into the obscure.
XXX someone please review!
 1.47.8.1.2.1 24-Jul-2005  snj Pull up revision 1.48 (requested by riz in ticket #5524):
Add el-cheapo finnish encoding, i.e. make the name "fi" point to
the swedish keymap, which actually gets set.

inspired by wiz
keymap name blessed by Klaus
 1.47.6.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.47.6.5 08-Mar-2005  skrll Sync with HEAD.
 1.47.6.4 18-Dec-2004  skrll Sync with HEAD.
 1.47.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.47.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.47.6.1 03-Aug-2004  skrll Sync with HEAD
 1.50.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.50.4.1 29-Apr-2005  kent sync with -current
 1.51.2.1 04-Apr-2005  tron Pull up revision 1.52 (requested by martti in ticket #104):
s/Finish/Finnish/
 1.54.2.2 21-Jan-2008  yamt sync with head
 1.54.2.1 21-Jun-2006  yamt sync with head.
 1.55.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.55.10.1 19-Apr-2006  elad sync with head.
 1.55.8.1 11-Apr-2006  yamt sync with head
 1.55.6.1 22-Apr-2006  simonb Sync with head.
 1.55.4.1 09-Sep-2006  rpaulo sync with head
 1.56.24.1 04-Sep-2008  skrll Sync with netbsd-4.
 1.56.20.1 11-Jul-2007  mjf Sync with head.
 1.56.12.1 08-Jun-2008  bouyer Pull up following revision(s) (requested by ghen in ticket #1155):
sys/dev/wscons/wsksymdef.h: revision 1.61
x11/bin/xkbcomp/symbols/pc/Makefile: revision 1.5
sys/dev/sun/wskbdmap_sun.c: revision 1.15
x11/bin/xkbcomp/symbols/Makefile: revision 1.6
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.15
share/man/man4/pckbd.4: revision 1.15
distrib/sets/lists/xbase/mi: revision 1.57
sys/dev/usb/ukbdmap.c: revision 1.20
distrib/sets/lists/xbase4/mi: revision 1.21
xsrc/xfree/xc/programs/xkbcomp/symbols/colemak: revision 1.1
xsrc/xfree/xc/programs/xkbcomp/symbols/pc/colemak: revision 1.1
Add support for the Colemak keyboard layout variant, see http://colemak.com
 1.58.20.1 11-Dec-2007  yamt sync with head.
 1.58.18.1 26-Dec-2007  ad Sync with head.
 1.58.10.1 09-Jan-2008  matt sync with HEAD
 1.58.8.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.59.14.3 11-Mar-2010  yamt sync with head
 1.59.14.2 04-May-2009  yamt sync with head.
 1.59.14.1 16-May-2008  yamt sync with head.
 1.59.12.2 04-Jun-2008  yamt sync with head
 1.59.12.1 18-May-2008  yamt sync with head.
 1.59.10.1 02-Jun-2008  mjf Sync with HEAD.
 1.60.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.61.16.1 21-Apr-2010  matt sync to netbsd-5
 1.61.14.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.61.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.61.8.2 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.61.8.1 01-Nov-2009  bouyer branches: 1.61.8.1.2;
Apply patch, requested by ahoka in ticket #1111:
sys/dev/pckbport/wskbdmap_mfii.c patch
sys/dev/wscons/wsksymdef.h patch
sys/dev/wscons/wskbdutil.c patch
Add hungarian keyboard layout.
 1.61.8.1.2.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.61.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.61.6.1 03-Mar-2009  skrll Sync with HEAD.
 1.65.6.1 29-Apr-2012  mrg sync to latest -current.
 1.65.2.1 23-May-2012  yamt sync with head.
 1.66.32.1 11-Apr-2018  martin Pull up following revision(s) (requested by maya in ticket #735):

sys/dev/wscons/wsksymdef.h: revision 1.67
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.26

Add Turkish keyboard layout.

from berte in PR kern/53011.
 1.67.10.1 13-Jul-2020  martin Pull up following revision(s) (requested by nia in ticket #1002):

sys/dev/wscons/wsksymdef.h: revision 1.68
sys/dev/wscons/wsksymdef.h: revision 1.69
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.28
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.29
sys/dev/hid/hidkbdmap.c: revision 1.10
share/man/man4/pckbd.4: revision 1.23
share/man/man4/wskbd.4: revision 1.18
share/man/man4/wskbd.4: revision 1.19
share/man/man4/pckbd.4: revision 1.25
sys/dev/wscons/wsksymdef.h: revision 1.70
sys/dev/wscons/wsksymdef.h: revision 1.71
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.30
sys/dev/wscons/wsksymdef.h: revision 1.72
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.31
sys/dev/wscons/wsksymdef.h: revision 1.73
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.32
sys/dev/pckbport/wskbdmap_mfii.c: revision 1.33
sys/dev/hid/hidkbdmap.c: revision 1.4
sbin/wsconsctl/wsconsctl.8: revision 1.30
sys/dev/hid/hidkbdmap.c: revision 1.5
etc/wscons.conf: revision 1.20
sys/dev/hid/hidkbdmap.c: revision 1.6
etc/wscons.conf: revision 1.21
sys/dev/hid/hidkbdmap.c: revision 1.7
sys/dev/hid/hidkbdmap.c: revision 1.8
sys/dev/hid/hidkbdmap.c: revision 1.9

Add support for the Brazilian keyboard layout to pckbd and ukbd.

This is significantly different from the European Portugese layout,
and was pieced together from Wikipedia, X11 layout files, and to
some extent with trial and error.

Thanks to lun-4 for helping test this.

PR kern/44570
Update lists of keyboard layouts to add Turkish and Brazilian

Bring br.nodead closer to X11

Add Estonian layout as a variation of Swedish for ukbd and pckbd

Add KB_TR for uhid keyboards (it was PS/2 only, this seems wrong)

Add Icelandic keyboard layout to ukbd/pckbd.

Add keyboard layout for Latin American Spanish to ukbd/pckbd

Canadian French keyboard layout for ukbd/pckbd

Clarify that KB_TR is the "Q" layout - there's two standards for Turkish.

Move description of keyboard layouts to wskbd.4, add newer layouts

Previously, the best reference was pckbd.4. This does not make much
sense to read if you are on, say, an evbarm device with only USB.
wsconsctl.8 contained a vaguer description of supported language names,
which isn't very useful because you can't pass full language names
to the command. Point readers to wskbd.4 instead.

Note in the wskbd.4 page that while all layouts are generally supported
by pckbd(4) and ukbd(4), older keyboard interfaces might only support
a subset.

wskbd.4: Add KB_LA

Point readers at wskbd.4
 1.75.8.1 31-May-2021  cjep sync with head
 1.75.6.1 13-May-2021  thorpej Sync with HEAD.
 1.11 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.10 13-Oct-2001  augustss branches: 1.10.116; 1.10.118; 1.10.120;
ANSIfy.
 1.9 06-Jul-2000  hannken branches: 1.9.2; 1.9.4;
Change type `kbd_t' from `u_int_16_t' to `u_int32_t'.
This eliminates bogus casts from `int *' to `u_int_16_t*'.
 1.8 21-Dec-1999  drochner branches: 1.8.4;
add a symbol for keyboard variant bits which are not handled by the
mapping code
 1.7 17-Sep-1998  drochner branches: 1.7.12; 1.7.18;
Reorganize the list of keyboard maps: no explicite length counter, use
an end mark instead. This allows to keep keymaps separate from the drivers
referring to them.
 1.6 02-Aug-1998  drochner Split the wskbd_attach arguments into console and autoconfiguration parts
(again); put some constant data into shared structures. This makes it
more look like the mouse part, and it helps USB integration.
Implement wskbd_enable() to enable/disable the keyboard.
 1.5 15-Jun-1998  drochner Move the translation of keypad and function keys into the realm of the
terminal emulation. For this, change the interface to wsdisplay_kbdinput()
to take a "keysym_t" as argument. From there, the code is handed to the
appropriate emulation module via a new entry point: "translate".
Nuke the ioctls dealing with global assignment of character sequences
to keypad/function keys.
The "sun" emulation works much better now!
 1.4 09-Apr-1998  hannken Split wscons/wskbd.c's softc into a static and a nonstatic part.
Booting into debugger (-d) now works.
Cleaned wscons/wskbdvar.h. Use the same attach arguments for
console and normal keyboards.
 1.3 07-Apr-1998  hannken Fix typo.
 1.2 07-Apr-1998  hannken Oops. Forgot RCS ident and copyright.
 1.1 07-Apr-1998  hannken Initial import of MI keyboard translation for dev/wscons.
 1.7.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.7.12.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.8.4.1 07-Jul-2000  hannken Pull up revision 1.9:
- kbd_t from u_int_16_t to u_int_32_t.
 1.9.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.10.120.1 16-May-2008  yamt sync with head.
 1.10.118.1 18-May-2008  yamt sync with head.
 1.10.116.1 02-Jun-2008  mjf Sync with HEAD.
 1.75 07-Apr-2025  hans wsmouse(4), wskbd(4): less DIAGNOSTIC, more KASSERT

Also, add a DPRINTF to wsmouseclose() and wskbdclose(), mirroring their
respective open functions.
 1.74 23-Mar-2025  hans wsmouse(4): fix bogus DIAGNOSTIC checks

Similar to wskbd(4), these checks should be done always, and the only
thing DIAGNOSTIC about them should be the printing of the message.
 1.73 30-Jul-2023  riastradh branches: 1.73.6;
wsmouse(4): Make wsmouse_input safe to call from MP-safe interrupts.

XXX pullup-10
 1.72 17-Jul-2022  riastradh branches: 1.72.4;
wsmouse(4): Nix trailing whitespace.
 1.71 17-Jul-2022  riastradh wsmouse(4): KASSERT(a && b) -> KASSERT(a); KASSERT(b)

Better diagnostics. No other functional change.
 1.70 28-Sep-2021  nia wsmouse: add support for "precision scrolling" events and (GET|SET)PARAMS

WSCONS_EVENT_HSCROLL and WSCONS_EVENT_VSCROLL are two new wscons event
types that allow scrolling with a higher precision ("smoothness") than an
emulated scroll wheel, and are useful for touch input drivers.

WSMOUSEIO_GETPARAMS and WSMOUSEIO_SETPARAMS are two new ioctls that allow
the speed and direction of precision scrolling to be configured.

both features were originally implemented in OpenBSD.
 1.69 27-Dec-2020  tsutsui Explicitly include generated ioconf.h for struct cfdrivers.
 1.68 03-Nov-2017  maya branches: 1.68.18;
Remove redundant includes of malloc.h
 1.67 03-Nov-2017  maya Use __arraycount a bunch
Also, DIAGNOSTIC panic -> KASSERT
 1.66 25-Jul-2014  dholland branches: 1.66.8; 1.66.18;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.65 16-Mar-2014  dholland branches: 1.65.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.64 11-Sep-2011  jakllsch branches: 1.64.2; 1.64.12; 1.64.16;
Correct copy/paste error in previous.
 1.63 11-Sep-2011  jakllsch Initialize the W axis value on open as is already done for the other axes.
 1.62 15-Jan-2009  yamt - reduce the number of #ifdefs.
- build compat glues if MODULAR.
 1.61 13-Jan-2009  christos provide wscons_event compatibility with 5.0.
 1.60 12-Jun-2008  cegger branches: 1.60.4;
use device_lookup_private to get softc
use device_lookup to get device_t
 1.59 30-Apr-2008  ad branches: 1.59.2; 1.59.4;
Make various bits of debug code compile again.
 1.58 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.57 05-Apr-2008  cegger branches: 1.57.2; 1.57.4;
use aprint_*_dev and device_xname
 1.56 25-Mar-2008  cube Split device_t and softc for wskbd(4), wsmouse(4) and that creepy wsmux(4).
 1.55 09-Dec-2007  jmcneill branches: 1.55.10;
Merge jmcneill-pm branch.
 1.54 01-Dec-2007  jmcneill branches: 1.54.2; 1.54.4;
aprintify
 1.53 16-Oct-2007  joerg branches: 1.53.4;
Use callout_setfunc/callout_schedule instead of callout_reset.
Use mstohz for the calculations.
 1.52 09-Jul-2007  ad branches: 1.52.6; 1.52.8; 1.52.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.51 04-Mar-2007  christos branches: 1.51.2; 1.51.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.50 16-Nov-2006  christos branches: 1.50.4;
__unused removal on arguments; approved by core.
 1.49 12-Nov-2006  plunky Tidy away wsmouse_input() abstractions and update
documentation to include the W direction.
 1.48 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.47 28-Aug-2006  christos branches: 1.47.2; 1.47.4;
fix incomplete initializers
 1.46 14-May-2006  elad integrate kauth.
 1.45 29-Mar-2006  thorpej Use device_cfdata().
 1.44 28-Mar-2006  thorpej Use device_unit().
 1.43 05-Mar-2006  jmmv branches: 1.43.2; 1.43.4;
Add missing closing parenthesis to a diagnostic message.
 1.42 10-Feb-2006  christos branches: 1.42.2;
fix compilation problems.
 1.41 10-Feb-2006  christos PR/32794: Paul Shupak: Panic in wsmouse code.
Checking the number of events after you've trashed the stack is not very
useful. Instead, break out of the loop if we ran out, printing a message.
Also don't try to inject 0 events; reset our state instead. Maybe having
0 events should be a diagnostic printf at this point? Anyway it is not
nice having the kernel die because the mouse code got confused. Finally,
explain why the array of events is sized funny.
 1.40 07-Feb-2006  jmmv wsevent cleanup:

- Add a wsevent_inject function that atomically adds a set of events to an
event queue and change all code that directly messed with a queue to use it.
- Replace the WSEVENT_WAKEUP macro with a regular function.
- Make WSEVENT_QSIZE, PWSEVENT and splwsevent private definitions to
wsevent.c, instead of exposing them in the header file.
- Make the wsevent_init function take a process to attach to the queue,
instead of leaving this task to the caller (which always did it).

Reviewed in tech-kern@.
 1.39 05-Feb-2006  jmmv Add support to automatically repeat mouse button events in wsmouse(4) and
change wsconsctl(4) so that this is configurable.

This is specially useful for mice that provide page up/down buttons instead
of a real wheel and that do not send events repeatedly from the hardware.
(E.g.: Logitech Marble Mouse.)

No objections in tech-kern@.
 1.38 11-Dec-2005  christos branches: 1.38.2; 1.38.4; 1.38.6;
merge ktrace-lwp.
 1.37 23-Nov-2005  augustss Some devices provide more than three (X, Y, and Z) "directions". So add
a W "coordinate" that can be used for these.
This changes the type of wsmouse_input(). To avoid changing a lot of drivers
a compatibilty #define is provided. Maybe changing all drivers would have
been better?
 1.36 21-Jun-2005  ws branches: 1.36.2; 1.36.8;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.
 1.35 27-Feb-2005  perry nuke trailing whitespace
 1.34 28-Nov-2003  drochner branches: 1.34.8; 1.34.10;
-remove a check of errno against -1, this is nonsense since
we have EPASSTHROUGH
-remove a superflous #if NWSMOUSE
 1.33 21-Sep-2003  jdolecek cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@
 1.32 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.31 29-Jun-2003  fvdl branches: 1.31.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.30 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.29 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.28 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.27 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.26 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.25 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.24 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.23 06-Jun-2002  drochner Don't detach the mouse from the mux just because the mouse device is
opened. Too annoying and unnecessary.
 1.22 22-Nov-2001  augustss branches: 1.22.8;
Add some DIAGNOSTIC tests.
 1.21 13-Nov-2001  lukem add/cleanup RCSIDs
 1.20 07-Nov-2001  enami Have necessary braces.
 1.19 02-Nov-2001  augustss Improve debug messages a little.
 1.18 25-Oct-2001  augustss Change back to have a wseventvar in the softc for event sources. This
way the effect of FIOASYNC survives close()/open(). Later versions
of XFree86 relies on this bug/feature.
Also add some more debug stuff.
 1.17 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.16 13-Oct-2001  augustss branches: 1.16.2;
Fix a (very old) pasto.
 1.15 13-Oct-2001  augustss ANSIfy.
 1.14 13-Oct-2001  augustss Two changes to the wsmux code:
* Allow the wsmux used by wsdisplay for the keyboard(s) to be explicitely
specified with the kbdmux locator.
* Allow keyboards and mice that have a mux to be opened in the regular way.
These changes should be totally backwards compatible.
 1.13 13-Feb-2001  bjh21 branches: 1.13.2; 1.13.4; 1.13.6;
Fix an uninitialised variable which could have caused corruption of the user
button state (and hence spurious mouse clicks) if the event queue filled
up.
 1.12 01-May-2000  takemura Mouse move event should be made before mouse bown event. Without that,
you may got a mouse down event in strange plase.
 1.11 08-Jan-2000  takemura Absolute pointing device support.
- Wsmouse_input() get new argument 'flag', which indicates whether x/y/z are
relative or absolute.
- Wsmouse get new io controls, WSMOUSEIO_SCALIBCOORDS and
WSMOUSEIO_GCALIBCOORDS.
 1.10 05-Jan-2000  drochner replace embedded _rcsid[] string by __KERNEL_RCSID(), remove _copyright[]
 1.9 04-Aug-1999  augustss branches: 1.9.2;
Get the dependencies on NWSMUX right (I hope).
 1.8 29-Jul-1999  augustss Add the wsmux pseudo device.
 1.7 30-Jun-1999  augustss Make it possible to detach wsmouse and wskbd.
XXX wskbd probably needs some more work.
 1.6 10-Jan-1999  augustss branches: 1.6.4;
Remove redundant test if the unit numbers is in range.
 1.5 30-Dec-1998  augustss Allow the wsmouse device to be opened for writing even if it is already
open, this way ioctl() can be performed on it and wsconsctl works.
 1.4 27-Jul-1998  drochner add third axis for pointing devices (flying mice)
 1.3 25-Jul-1998  augustss Insert lots of ``#if NWSMOUSE > 0'' and ``#if NWSDISPLAY > 0'' to make it
possible to have a wsmouse and/or wskbd without having a wsdisplay.
 1.2 09-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.6.4.2 02-Aug-1999  thorpej Update from trunk.
 1.6.4.1 01-Jul-1999  thorpej Sync w/ -current.
 1.9.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.9.2.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.6.2 26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.13.6.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.13.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.13.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.13.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.4.1 08-Sep-2001  thorpej Add kqueue support to wscons events.
 1.13.2.8 03-Jan-2003  thorpej Sync with HEAD.
 1.13.2.7 11-Nov-2002  nathanw Catch up to -current
 1.13.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.13.2.5 17-Sep-2002  nathanw Catch up to -current.
 1.13.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.13.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.13.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.13.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.16.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.22.8.2 20-Jun-2002  gehenna catch up with -current.
 1.22.8.1 16-May-2002  gehenna Add the character device switch.
Replace the direct-access to devsw table with calling devsw API.
 1.31.2.8 11-Dec-2005  christos Sync with head.
 1.31.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.31.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.31.2.5 21-Nov-2004  skrll Adapt to branch.
 1.31.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.31.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.31.2.2 03-Aug-2004  skrll Sync with HEAD
 1.31.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.34.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.34.8.1 29-Apr-2005  kent sync with -current
 1.36.8.1 29-Nov-2005  yamt sync with head.
 1.36.2.6 21-Jan-2008  yamt sync with head
 1.36.2.5 07-Dec-2007  yamt sync with head
 1.36.2.4 27-Oct-2007  yamt sync with head.
 1.36.2.3 03-Sep-2007  yamt sync with head.
 1.36.2.2 30-Dec-2006  yamt sync with head.
 1.36.2.1 21-Jun-2006  yamt sync with head.
 1.38.6.2 22-Apr-2006  simonb Sync with head.
 1.38.6.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.38.4.1 09-Sep-2006  rpaulo sync with head
 1.38.2.1 18-Feb-2006  yamt sync with head.
 1.42.2.3 03-Sep-2006  yamt sync with head.
 1.42.2.2 01-Apr-2006  yamt sync with head.
 1.42.2.1 13-Mar-2006  yamt sync with head.
 1.43.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.43.2.1 19-Apr-2006  elad sync with head.
 1.47.4.2 10-Dec-2006  yamt sync with head.
 1.47.4.1 22-Oct-2006  yamt sync with head
 1.47.2.1 18-Nov-2006  ad Sync with head.
 1.50.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.51.4.1 11-Jul-2007  mjf Sync with head.
 1.51.2.2 23-Oct-2007  ad Sync with head.
 1.51.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.52.10.1 18-Oct-2007  yamt sync with head.
 1.52.8.2 09-Jan-2008  matt sync with HEAD
 1.52.8.1 06-Nov-2007  matt sync with HEAD
 1.52.6.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.52.6.4 01-Dec-2007  jmcneill Sync with HEAD.
 1.52.6.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.52.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.52.6.1 05-Aug-2007  jmcneill Certain devices either don't require a power handler, or are restored
on resume outside of the pnp power management framework. For such devices,
introduce the null power handler, pnp_generic_power.
 1.53.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.53.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.54.4.1 11-Dec-2007  yamt sync with head.
 1.54.2.1 26-Dec-2007  ad Sync with head.
 1.55.10.6 17-Jan-2009  mjf Sync with HEAD.
 1.55.10.5 29-Jun-2008  mjf Sync with HEAD.
 1.55.10.4 02-Jun-2008  mjf Sync with HEAD.
 1.55.10.3 06-Apr-2008  mjf - after some discussion with agc@ i agreed it would be a good idea to move
device_unregister_* to device_deregister_* to be more like the pmf(9)
functions, especially since a lot of the time the function calls are next
to each other.

- add device_register_name() support for dk(4).
 1.55.10.2 03-Apr-2008  mjf Sync with HEAD.
 1.55.10.1 29-Mar-2008  mjf - etc/devfsd.conf: Add some rules to give nodes like /dev/tty and
/dev/null better default modes, i.e. 0666.

- sbin/init: Run devfsd -s before going to multiuser.

- sys/arch: Provide arm32, i386, sparc with a mem_init() function to request
device nodes for /dev/null, /dev/zero, etc.

- sys/dev: Convert rnd, wd, agp, raid, cd, sd, wsdisplay, wskbd, wsmouse,
wsmux, tty, bpf, swap to devfs New World Order.

- sys/fs/devfs: Make the visibility attribute of device nodes configurable.
Also provide a function to mount a devfs on boot.

- sys/kern: Add a new boot flag, -n. This disables devfs support. Unless
the -n flag is specified the kernel will mount a devfs file
system on boot.
 1.57.4.2 04-May-2009  yamt sync with head.
 1.57.4.1 16-May-2008  yamt sync with head.
 1.57.2.2 17-Jun-2008  yamt sync with head.
 1.57.2.1 18-May-2008  yamt sync with head.
 1.59.4.1 18-Jun-2008  simonb Sync with head.
 1.59.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.60.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.64.16.1 18-May-2014  rmind sync with head
 1.64.12.2 03-Dec-2017  jdolecek update from HEAD
 1.64.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.64.2.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.65.2.1 10-Aug-2014  tls Rebase.
 1.66.18.2 29-Apr-2017  pgoyette Remove more unnecessary #include for sys/localcount.h
 1.66.18.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.66.8.3 26-Jul-2016  pgoyette Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT. This better describes
what we're doing, and why.
 1.66.8.2 19-Jul-2016  pgoyette Instead of repeatedly typing the conditional initialization of the
.d_localcount members in the various {b,c}devsw, define an initializer
macro and use it. This also removes the need for defining new symbols
for each 'struct localcount'.

As suggested by riastradh@
 1.66.8.1 18-Jul-2016  pgoyette Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.
 1.68.18.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.72.4.1 20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #892):

sys/dev/wscons/wsmouse.c: revision 1.73

wsmouse(4): Make wsmouse_input safe to call from MP-safe interrupts.
 1.73.6.1 02-Aug-2025  perseant Sync with HEAD
 1.12 28-Sep-2021  nia wsmouse: add support for "precision scrolling" events and (GET|SET)PARAMS

WSCONS_EVENT_HSCROLL and WSCONS_EVENT_VSCROLL are two new wscons event
types that allow scrolling with a higher precision ("smoothness") than an
emulated scroll wheel, and are useful for touch input drivers.

WSMOUSEIO_GETPARAMS and WSMOUSEIO_SETPARAMS are two new ioctls that allow
the speed and direction of precision scrolling to be configured.

both features were originally implemented in OpenBSD.
 1.11 12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.10 04-Mar-2007  christos branches: 1.10.40; 1.10.56;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 12-Nov-2006  plunky branches: 1.9.4;
Tidy away wsmouse_input() abstractions and update
documentation to include the W direction.
 1.8 09-Oct-2006  peter KNF: No variable names in the prototype.
 1.7 11-Dec-2005  christos branches: 1.7.20; 1.7.22;
merge ktrace-lwp.
 1.6 23-Nov-2005  augustss Some devices provide more than three (X, Y, and Z) "directions". So add
a W "coordinate" that can be used for these.
This changes the type of wsmouse_input(). To avoid changing a lot of drivers
a compatibilty #define is provided. Maybe changing all drivers would have
been better?
 1.5 13-Oct-2001  augustss branches: 1.5.18; 1.5.34; 1.5.42;
ANSIfy.
 1.4 08-Jan-2000  takemura branches: 1.4.6; 1.4.8;
Absolute pointing device support.
- Wsmouse_input() get new argument 'flag', which indicates whether x/y/z are
relative or absolute.
- Wsmouse get new io controls, WSMOUSEIO_SCALIBCOORDS and
WSMOUSEIO_GCALIBCOORDS.
 1.3 29-Jul-1999  augustss branches: 1.3.2;
Add the wsmux pseudo device.
 1.2 27-Jul-1998  drochner branches: 1.2.10;
add third axis for pointing devices (flying mice)
 1.1 22-Mar-1998  drochner Initial import of cgd's new wscons code.
 1.2.10.1 02-Aug-1999  thorpej Update from trunk.
 1.3.2.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.4.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.5.42.1 29-Nov-2005  yamt sync with head.
 1.5.34.3 03-Sep-2007  yamt sync with head.
 1.5.34.2 30-Dec-2006  yamt sync with head.
 1.5.34.1 21-Jun-2006  yamt sync with head.
 1.5.18.2 11-Dec-2005  christos Sync with head.
 1.5.18.1 21-Nov-2004  skrll Adapt to branch.
 1.7.22.2 10-Dec-2006  yamt sync with head.
 1.7.22.1 22-Oct-2006  yamt sync with head
 1.7.20.1 18-Nov-2006  ad Sync with head.
 1.9.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.56.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.40.1 16-May-2009  yamt sync with head
 1.68 07-Apr-2025  hans wsmux(4): fix open/close of child devices

Only open child devices which aren't open already, and only close what
we've opened. While here, fix all that #ifdef DIAGNOSTIC stuff. Most of
that should just be KASSERTs.

PR kern/59206
 1.67 23-Mar-2025  hans wsmux(4): fix bogus DIAGNOSTIC checks

Similar to wsmouse(4) and wskbd(4), there are plenty of sanity checks
in this code that should always be done. The only thing DIAGNOSTIC
about them should be the printing of the message.
 1.66 28-Mar-2022  riastradh branches: 1.66.10;
sys: Split struct device into a private device_impl.h.

Include this only inside autoconf itself, and a few files that abuse
autoconf in ways I can't confidently make easy fixes for.

XXX kernel ABI change requires bump -- no more use of struct device
internals allowed, previously done by some drivers
 1.65 10-Nov-2021  msaitoh s/configuraiton/configuration/ in comment.
 1.64 10-Nov-2019  chs 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.63 12-Jun-2017  pgoyette branches: 1.63.6;
There is no longer a NWSBELL (since nothing depends on it), so there's no
need to #include wsbell.h (which is where it used to be defined, as a
result of a needs-flag in files.wscons).

Remove the #include
 1.62 11-Jun-2017  nat New device wsbell - allows for a console beep for non pckbds (usb etc).
Works for platforms without pcppi - can work with spkr at audio and spkr
at pcppi.

To use add the following to your kernel config:
wsbell* at spkr? console?

Ok pgoyette@.
 1.61 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.60 24-Aug-2015  pooka to garnish, dust with _KERNEL_OPT
 1.59 20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.58 25-Jul-2014  dholland branches: 1.58.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.57 16-Mar-2014  dholland branches: 1.57.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.56 23-Nov-2013  christos get rid of CIRCLEQ
 1.55 18-Mar-2013  jmcneill branches: 1.55.6;
If there are no devices attached to the mux and software does
WSxxxIO_SETVERSION, the change doesn't actually get applied to the event
source as wsmux hands off processing of these ioctls to attached devices.
Handle these ioctls directly from the mux device instead of passing them
through, to correct an issue that prevented keyboards and mice from working
in X if there were zero devices attached when the X server started.
 1.54 30-Jan-2012  rmind branches: 1.54.2; 1.54.6;
wsmux_getmux: do not increment nwsmux if allocation fails (might cause buffer
overflow). Simplify slightly.
 1.53 13-Feb-2009  apb branches: 1.53.12; 1.53.16;
Use "defopt MODULAR" in sys/conf/files, and #include "opt_modular.h"
in all kernel sources that use the MODULAR option.
Proposed in tech-kern on 18 Jan 2009.
 1.52 15-Jan-2009  yamt branches: 1.52.2;
- reduce the number of #ifdefs.
- build compat glues if MODULAR.
 1.51 13-Jan-2009  christos provide wscons_event compatibility with 5.0.
 1.50 28-Apr-2008  martin branches: 1.50.8;
Remove clause 3 and 4 from TNF licenses
 1.49 25-Mar-2008  cube branches: 1.49.2; 1.49.4;
Split device_t and softc for wskbd(4), wsmouse(4) and that creepy wsmux(4).
 1.48 04-Mar-2007  christos branches: 1.48.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.47 09-Feb-2007  ad branches: 1.47.2;
Merge newlock2 to head.
 1.46 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.45 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.44 28-Aug-2006  christos branches: 1.44.2; 1.44.4;
fix incomplete initializers
 1.43 28-Mar-2006  thorpej Use device_unit().
 1.42 07-Feb-2006  jmmv branches: 1.42.2; 1.42.4; 1.42.6;
wsevent cleanup:

- Add a wsevent_inject function that atomically adds a set of events to an
event queue and change all code that directly messed with a queue to use it.
- Replace the WSEVENT_WAKEUP macro with a regular function.
- Make WSEVENT_QSIZE, PWSEVENT and splwsevent private definitions to
wsevent.c, instead of exposing them in the header file.
- Make the wsevent_init function take a process to attach to the queue,
instead of leaving this task to the caller (which always did it).

Reviewed in tech-kern@.
 1.41 25-Dec-2005  jmmv branches: 1.41.2; 1.41.4; 1.41.6;
Let this build when WSMUX_DEBUG is set after the merge of ktrace-lwp.
 1.40 11-Dec-2005  christos merge ktrace-lwp.
 1.39 11-Nov-2005  simonb Call nanotime() directly, instead of doing the
microtime()/TIMEVAL_TO_TIMESPEC() dance.
 1.38 21-Jun-2005  ws branches: 1.38.2;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.
 1.37 30-Apr-2005  augustss Remember what keyboard layout is set in the mux, that way new keyboards
can be given the same layout. Fixes kern/19153.
 1.36 27-Feb-2005  perry nuke trailing whitespace
 1.35 23-Sep-2003  simonb branches: 1.35.8; 1.35.10;
Fix uninitialised variable introduced with previous change.

Patch from mlelstv.
 1.34 21-Sep-2003  jdolecek cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@
 1.33 29-Jun-2003  fvdl branches: 1.33.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.32 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.31 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.30 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.29 17-Mar-2002  atatat branches: 1.29.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.28 02-Mar-2002  takemura Added wsmux_set_display() to fix the problem that wskbd wan't connected
to any display if keyboard was attached before display and both aren't console.
 1.27 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.26 22-Nov-2001  augustss Close multiplxees BEFORE removing the event variable they are
using (an interrupt at the wrong point caused disaster).
 1.25 19-Nov-2001  augustss Injecting events into a mux that is not open is not an error.
 1.24 13-Nov-2001  lukem add/cleanup RCSIDs
 1.23 07-Nov-2001  augustss Improve diagniostic message.
 1.22 02-Nov-2001  augustss Improve debug messages a little.
 1.21 29-Oct-2001  augustss Inject events in the right place in the buffer.
 1.20 27-Oct-2001  augustss Cosmetics.
 1.19 27-Oct-2001  augustss Having a display does not preclude the mux from being open.
 1.18 26-Oct-2001  augustss Remove TODO list.
 1.17 26-Oct-2001  augustss Change a debug message.
 1.16 25-Oct-2001  augustss Change back to have a wseventvar in the softc for event sources. This
way the effect of FIOASYNC survives close()/open(). Later versions
of XFree86 relies on this bug/feature.
Also add some more debug stuff.
 1.15 25-Oct-2001  shin make this compile without WSDISPLAY_COMPAT_RAWKBD.
 1.14 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.13 21-Oct-2001  jmc branches: 1.13.2;
Wrap ifdef's cleaner so wsmouse_[add|rem]_mux only get pulled in if NWSMUX > 0.
 1.12 13-Oct-2001  augustss Allow for control devices (minor+128) to make it possible to manipulate
muxes that are in use.
Create muxes on demand.
 1.11 13-Oct-2001  augustss ANSIfy.
 1.10 13-Oct-2001  augustss Two changes to the wsmux code:
* Allow the wsmux used by wsdisplay for the keyboard(s) to be explicitely
specified with the kbdmux locator.
* Allow keyboards and mice that have a mux to be opened in the regular way.
These changes should be totally backwards compatible.
 1.9 28-May-2000  takemura branches: 1.9.4; 1.9.6; 1.9.8;
Add async I/O support.

FIOASYNC ioctrl command had been forwarded from wsmux to each mouse devices
and the devices had set their own event queue async mode. But no one had took
care of the event queue's mode of wsmux itself. Wsmux should make it's own
event queue async mode when it receive FIOASYNC command.
 1.8 08-Nov-1999  augustss branches: 1.8.2;
Return -1 from wsmux_displayioctl() if no muxes components like the ioctl().
 1.7 03-Nov-1999  augustss Don't flag an error when doing ioctl() on a mux without any
multiplexees. Should fix PR 8723.
 1.6 26-Aug-1999  nisimura branches: 1.6.2; 1.6.4; 1.6.6;
One more ioctl() fix. Most of WSDISPLAYIO_xxx were never been called when
no wsmux device is installed.
 1.5 25-Aug-1999  augustss Fix an ioctl() problem. From nisimura@itc.aist-nara.ac.jp (Toru Nishimura).
 1.4 14-Aug-1999  simonb Initialise "error" in wsmux_detach_sc() before testing if it set.
 1.3 07-Aug-1999  augustss Make it possible to open wskbd devices for write (i.e. ioctl) even
if it is already open.
 1.2 30-Jul-1999  augustss branches: 1.2.2;
Eliminate the need for needs-count for wsmux. This should make
wsdisplays work properly again.
 1.1 29-Jul-1999  augustss Add the wsmux pseudo device.
 1.2.2.2 02-Aug-1999  thorpej Update from trunk.
 1.2.2.1 30-Jul-1999  thorpej file wsmux.c was added on branch chs-ubc2 on 1999-08-02 22:10:27 +0000
 1.6.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.4.1 15-Nov-1999  fvdl Sync with -current
 1.6.2.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.8.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.9.8.4 26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.9.8.3 20-Sep-2001  fvdl Use VOP_OPEN in a few cases where it's more appropriate to do so (to
gracefully handle dead vnodes).
 1.9.8.2 18-Sep-2001  fvdl Various changes to make cloning devices possible:

* Add an extra argument (struct vnode **) to VOP_OPEN. If it is
not NULL, specfs will create a cloned (aliased) vnode during
the call, and return it there. The caller should release and
unlock the original vnode if a new vnode was returned. The
new vnode is returned locked.

* Add a flag field to the cdevsw and bdevsw structures.
DF_CLONING indicates that it wants a new vnode for each
open (XXX is there a better way? devprop?)

* If a device is cloning, always call the close entry
point for a VOP_CLOSE.


Also, rewrite cons.c to do the right thing with vnodes. Use VOPs
rather then direct device entry calls. Suggested by mycroft@

Light to moderate testing done an i386 system (arch doesn't matter
though, these are MI changes).
 1.9.8.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.9.6.6 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.9.6.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.6.4 16-Mar-2002  jdolecek Catch up with -current.
 1.9.6.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.9.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.6.1 08-Sep-2001  thorpej Add kqueue support to wscons events.
 1.9.4.7 11-Nov-2002  nathanw Catch up to -current
 1.9.4.6 17-Sep-2002  nathanw Catch up to -current.
 1.9.4.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.9.4.4 28-Feb-2002  nathanw Catch up to -current.
 1.9.4.3 08-Jan-2002  nathanw Catch up to -current.
 1.9.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.9.4.1 22-Oct-2001  nathanw Catch up to -current.
 1.13.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.29.4.1 16-May-2002  gehenna Add the character device switch.
 1.33.2.7 11-Dec-2005  christos Sync with head.
 1.33.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.33.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.33.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.33.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.33.2.2 03-Aug-2004  skrll Sync with HEAD
 1.33.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.35.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.35.8.1 29-Apr-2005  kent sync with -current
 1.38.2.4 03-Sep-2007  yamt sync with head.
 1.38.2.3 26-Feb-2007  yamt sync with head.
 1.38.2.2 30-Dec-2006  yamt sync with head.
 1.38.2.1 21-Jun-2006  yamt sync with head.
 1.41.6.1 22-Apr-2006  simonb Sync with head.
 1.41.4.1 09-Sep-2006  rpaulo sync with head
 1.41.2.1 18-Feb-2006  yamt sync with head.
 1.42.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.42.4.1 19-Apr-2006  elad sync with head.
 1.42.2.2 03-Sep-2006  yamt sync with head.
 1.42.2.1 01-Apr-2006  yamt sync with head.
 1.44.4.2 10-Dec-2006  yamt sync with head.
 1.44.4.1 22-Oct-2006  yamt sync with head
 1.44.2.2 06-Feb-2007  ad Quieten noisy boot messages.
 1.44.2.1 18-Nov-2006  ad Sync with head.
 1.47.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.48.36.6 17-Jan-2009  mjf Sync with HEAD.
 1.48.36.5 02-Jun-2008  mjf Sync with HEAD.
 1.48.36.4 06-Apr-2008  mjf - after some discussion with agc@ i agreed it would be a good idea to move
device_unregister_* to device_deregister_* to be more like the pmf(9)
functions, especially since a lot of the time the function calls are next
to each other.

- add device_register_name() support for dk(4).
 1.48.36.3 04-Apr-2008  mjf * Catch up with selnotify() changes.

* Catch up with some softc changes in HEAD.

* More s/dctl/devfsctl/ changes.

* Remove debugging printfs from init(8) that slipped in by mistake.

* Cosmetic changes in devfsd, allow multiple attributes to be set in
one rule. Switch from err() to syslog() messages.

* Fix etc/devfsd.conf, I'd made some changes previously that had syntax
errors.
 1.48.36.2 03-Apr-2008  mjf Sync with HEAD.
 1.48.36.1 29-Mar-2008  mjf - etc/devfsd.conf: Add some rules to give nodes like /dev/tty and
/dev/null better default modes, i.e. 0666.

- sbin/init: Run devfsd -s before going to multiuser.

- sys/arch: Provide arm32, i386, sparc with a mem_init() function to request
device nodes for /dev/null, /dev/zero, etc.

- sys/dev: Convert rnd, wd, agp, raid, cd, sd, wsdisplay, wskbd, wsmouse,
wsmux, tty, bpf, swap to devfs New World Order.

- sys/fs/devfs: Make the visibility attribute of device nodes configurable.
Also provide a function to mount a devfs on boot.

- sys/kern: Add a new boot flag, -n. This disables devfs support. Unless
the -n flag is specified the kernel will mount a devfs file
system on boot.
 1.49.4.2 04-May-2009  yamt sync with head.
 1.49.4.1 16-May-2008  yamt sync with head.
 1.49.2.1 18-May-2008  yamt sync with head.
 1.50.8.2 03-Mar-2009  skrll Sync with HEAD.
 1.50.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.52.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.53.16.1 18-Feb-2012  mrg merge to -current.
 1.53.12.2 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.53.12.1 17-Apr-2012  yamt sync with head
 1.54.6.3 03-Dec-2017  jdolecek update from HEAD
 1.54.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.54.6.1 23-Jun-2013  tls resync from head
 1.54.2.1 30-Mar-2013  riz Pull up following revision(s) (requested by jmcneill in ticket #848):
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c: revision 1.18
sys/dev/wscons/wsmux.c: revision 1.55
If there are no devices attached to the mux and software does
WSxxxIO_SETVERSION, the change doesn't actually get applied to the event
source as wsmux hands off processing of these ioctls to attached devices.
Handle these ioctls directly from the mux device instead of passing them
through, to correct an issue that prevented keyboards and mice from working
in X if there were zero devices attached when the X server started.
If WSKBDIO_GTYPE succeeds and returns type=0, it is a mux with no keyboard
attached. In this case, assume USB.
 1.55.6.1 18-May-2014  rmind sync with head
 1.57.2.1 10-Aug-2014  tls Rebase.
 1.58.4.3 28-Aug-2017  skrll Sync with HEAD
 1.58.4.2 09-Jul-2016  skrll Sync with HEAD
 1.58.4.1 22-Sep-2015  skrll Sync with HEAD
 1.63.6.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.66.10.1 02-Aug-2025  perseant Sync with HEAD
 1.17 12-Jun-2017  pgoyette Always include declarations/definitions for NWSMUX and NWSDISPLAY even
if they aren't needed. This enables us to have structures of a fixed
size regardless of which child devices are configured, which enables
better modularization.
 1.16 11-Jun-2017  nat New device wsbell - allows for a console beep for non pckbds (usb etc).
Works for platforms without pcppi - can work with spkr at audio and spkr
at pcppi.

To use add the following to your kernel config:
wsbell* at spkr? console?

Ok pgoyette@.
 1.15 23-Nov-2013  christos branches: 1.15.6;
get rid of CIRCLEQ
 1.14 28-Apr-2008  martin branches: 1.14.34; 1.14.44; 1.14.50;
Remove clause 3 and 4 from TNF licenses
 1.13 25-Mar-2008  cube branches: 1.13.2; 1.13.4;
Split device_t and softc for wskbd(4), wsmouse(4) and that creepy wsmux(4).
 1.12 04-Mar-2007  christos branches: 1.12.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 11-Dec-2005  christos branches: 1.11.26;
merge ktrace-lwp.
 1.10 30-Apr-2005  augustss branches: 1.10.2;
Remember what keyboard layout is set in the mux, that way new keyboards
can be given the same layout. Fixes kern/19153.
 1.9 29-Jun-2003  fvdl branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.8 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.7 02-Mar-2002  takemura Added wsmux_set_display() to fix the problem that wskbd wan't connected
to any display if keyboard was attached before display and both aren't console.
 1.6 27-Oct-2001  augustss Cosmetics.
 1.5 25-Oct-2001  augustss Change back to have a wseventvar in the softc for event sources. This
way the effect of FIOASYNC survives close()/open(). Later versions
of XFree86 relies on this bug/feature.
Also add some more debug stuff.
 1.4 24-Oct-2001  augustss Major rototilling of the wsmux code. No user visible changes (except that
many bugs have been fixed).
Changes:
The wskbd, wsmouse, and wsmux are now "sub-classes" of wsevsrc, which is
a source of ws events. This make the structure of those drivers a little
more uniform.
Many bug fixes involving adding and removing devices from muxes.
When a kernel is configured without wsmux there will now be none (unlike
before where you got a console mux anyway).
The kernel now compiles with all combinations of ws devices present.
 1.3 13-Oct-2001  augustss branches: 1.3.2;
ANSIfy.
 1.2 13-Oct-2001  augustss Two changes to the wsmux code:
* Allow the wsmux used by wsdisplay for the keyboard(s) to be explicitely
specified with the kbdmux locator.
* Allow keyboards and mice that have a mux to be opened in the regular way.
These changes should be totally backwards compatible.
 1.1 29-Jul-1999  augustss branches: 1.1.2; 1.1.16; 1.1.18; 1.1.20;
Add the wsmux pseudo device.
 1.1.20.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.1.18.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.18.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.16.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.16.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.16.1 22-Oct-2001  nathanw Catch up to -current.
 1.1.2.2 02-Aug-1999  thorpej Update from trunk.
 1.1.2.1 29-Jul-1999  thorpej file wsmuxvar.h was added on branch chs-ubc2 on 1999-08-02 22:10:27 +0000
 1.3.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.9.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.10.2.2 03-Sep-2007  yamt sync with head.
 1.10.2.1 21-Jun-2006  yamt sync with head.
 1.11.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.36.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.36.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.50.1 18-May-2014  rmind sync with head
 1.14.44.2 03-Dec-2017  jdolecek update from HEAD
 1.14.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.34.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.15.6.1 28-Aug-2017  skrll Sync with HEAD

RSS XML Feed