Chapter 29. Console drivers

Table of Contents

29.1. wscons
29.1.1. Virtual consoles
29.1.2. 50 lines text mode with wscons
29.1.3. Keyboard mappings
29.1.4. Cut&paste on the console with wsmoused
29.1.5. Enable scrollback on the console
29.2. pccons

In NetBSD versions before 1.4 the user could choose between two different drivers for screen and keyboard, pccons (specific for i386) and pcvt. In NetBSD 1.4 the new wscons multiplatform driver appeared, which has substituted the previous drivers, of which pccons is still supported as it uses less system ressources and is used for install floppies due to that.

29.1. wscons

Wscons is NetBSD's standard console driver. It offers virtual terminals on i386, support for international keyboards, mouse handling, etc. The capabilities of wscons can vary depending on the port, the i386 version is very feature rich.

29.1.1. Virtual consoles

The number of pre-allocated virtual console is controlled by the following option

options     WSDISPLAY_DEFAULTSCREENS=4

Other consoles can be added by enabling the relevant lines in the /etc/wscons.conf file: the comment mark (#) must be removed from the lines beginning with “screen x”. In the following example a fifth console is added to the four pre-allocated ones:

# screens to create
#       idx     screen  emul
#screen 0       -       vt100
screen 1        -       vt100
screen 2        -       vt100
screen 3        -       vt100
screen  4       -       -
#screen 4       80x25bf vt100
#screen 5       80x50   vt100

The rc.wscons script transforms each of the non commented lines in a call to the wsconscfg command: the columns become the parameters of the call. The idx column becomes the index parameter, the screen column becomes the -t type parameter (which defines the type of screen: rows and columns, number of colors, ...) and the emul column becomes the -e emul parameter, which defines the emulation. For example:

screen 3       -       vt100

becomes a call to:

wsconscfg -e vt100 3

Please note that it is possible to have a (harmless) conflict between the consoles pre-allocated by the kernel and the consoles allocated at boot time through /etc/wscons.conf. If during boot the system tries to allocate an already allocated screen, the following message will be displayed:

wsconscfg: WSDISPLAYIO_ADDSCREEN: Device busy

The soulution is to comment out the offending lines in /etc/wscons.conf.

The virtual console must also be active in /etc/ttys, so that NetBSD runs the getty(8) program to ask for login. For example:

console "/usr/libexec/getty Pc"         pc3     off secure
ttyE0   "/usr/libexec/getty Pc"         vt220   on secure
ttyE1   "/usr/libexec/getty Pc"         vt220   on secure
ttyE2   "/usr/libexec/getty Pc"         vt220   on secure
ttyE3   "/usr/libexec/getty Pc"         vt220   off secure
...

When starting up the X server, it will look for a virtual console with no getty(8) program running, e.g. one console should left as "off" in /etc/ttys. The line

ttyE3   "/usr/libexec/getty Pc"         vt220   off secure

of /etc/ttys is used by the X server for this purpose. To use a screen different from number 4, a parameter of the form vtn must be passed to the X server, where n is the number of the function key used to activate the screen for X.

For example, “screen 7” could be enabled in /etc/wscons.conf and X could be started with “vt8”. If you use xdm you must edit /usr/X11R6/lib/X11/xdm/Xserver. For example:

:0 local /usr/X11R6/bin/X +kb dpms -bpp 16 dpms vt8

For xdm3d the path is different: /usr/X11R6/share/xdm3d/Xservers.

29.1.2. 50 lines text mode with wscons

A text mode with 50 lines can be used starting with version 1.4.1 of NetBSD. This mode is activated in the /etc/wscons.conf. The following line must be uncommented:

font ibm  -  8  ibm  /usr/share/pcvt/fonts/vt220l.808

Then the following lines must be modified:

#screen 0       80x50   vt100
screen  1       80x50   vt100
screen  2       80x50   vt100
screen  3       80x50   vt100
screen  4       80x50   vt100
screen  5       80x50   vt100
screen  6       80x50   vt100
screen  7       80x50   vt100

This configuration enables eight screens, which can be accessed with the key combination Ctrl-Alt-Fn (where n varies from 1 to 8); the corresponding devices are ttyE0..ttyE7. To enable them and get a login prompt, /etc/ttys must be modified:

ttyE0   "/usr/libexec/getty Pc"         vt220   on secure
ttyE1   "/usr/libexec/getty Pc"         vt220   on secure
ttyE2   "/usr/libexec/getty Pc"         vt220   on secure
ttyE3   "/usr/libexec/getty Pc"         vt220   on secure
ttyE4   "/usr/libexec/getty Pc"         vt220   on secure
ttyE5   "/usr/libexec/getty Pc"         vt220   on secure
ttyE6   "/usr/libexec/getty Pc"         vt220   on secure
ttyE7   "/usr/libexec/getty Pc"         vt220   on secure

It is not possible to modify the 80x25 setting of screen 0, probably to guarantee that even in case of problems there is always a working screen.

29.1.3. Keyboard mappings

Wscons also allows setting the keymap to map the keys on various national keyboards to the right characters. E.g. to set the keymap for an italian keymap, run:

# wsconsctl -k -w encoding=it
encoding -> it

This setting will last until the next reboot. To make it permanent, add a “encoding”line to /etc/wscons.conf: it will be executed automatically the next time you reboot.

# cp /etc/wscons.conf /etc/wscons.conf.orig
# echo encoding it >>/etc/wscons.conf

Please be careful and type two “>” characters. If you type only one “>”, you will overwrite the file instead of adding a line. But that's why we always make backup files before touching critical files!

A full list of keyboard mappings can be found in /usr/src/sys/dev/wscons/wsksymdef.h:

  • be - Belgian

  • de - German

  • dk - Danish

  • es - Spanish

  • fr - French

  • hu - Hungarian

  • it - Italian

  • jp - Japanese

  • no - Norwegian

  • pl - Polish

  • pt - Portugese

  • ru - Russian

  • sf - Swiss French

  • sg - Swiss German

  • sv - Swedish

  • ua - Ukrainian

  • uk - UK-English

  • us - US-English

29.1.4. Cut&paste on the console with wsmoused

It is possible to use the mouse on the wscons console to mark (cut) text with one mouse button, and insert (paste) it again with another button. To enable cut&paste in wscons, you first need to build support for it into the kernel, which is disabled by default. To so so, enable the following option:

options WSDISPLAY_CHARFUNCS             # mouse console support

Beware that this option won't work in conjunction with the VGA_RASTERCONSOLE option. See Chapter 28, Compiling the kernel for more information on building the kernel.

After the kernel is built, enable "wsmoused" in /etc/rc.conf, and start it:

# echo wsmoused=yes >>/etc/rc.conf
# sh /etc/rc.d/wsmoused start 

After that you can use the mouse to mark text with the left mouse button, and paste it with the right one. To tune the behaviour of wsmoused(8) see its manpage, which also describes the format of the wsmoused.conf(5) config file, an example of which can be found in /usr/share/examples/wsmoused.

29.1.5. Enable scrollback on the console

You can enable scrolling back on wscons consoles by compiling the WSDISPLAY_SCROLLSUPPORT option into your kernel. Make sure you don't have option VGA_RASTERCONSOLE enabled at the same time though! See Chapter 28, Compiling the kernel for instructions on building a kernel.

When you have a kernel with options WSDISPLAY_SCROLLSUPPORT running, you can scroll up on the console by pressing SHIFT plus PAGE UP/DOWN. Please note that this may not work on your system console (ttyE0)!

29.2. pccons

This console driver doesn't offer virtual consoles and utility programs for configuration but takes up very little space. Due to this, it can be found on the i386 install floppy.

To enable it, put the following line in your kernel config file:

pc0 at isa? port 0x60 irq 1 # pccons generic PC console driver

You can also set one of several options to compile in a non-english keymap:

# Keyboard layout configuration for pccons
#options        FRENCH_KBD
#options        FINNISH_KBD
#options        GERMAN_KBD
#options        NORWEGIAN_KBD

Remove the comment character in front of one of this to enable the corresponding keymap, then follow the instructions in Chapter 28, Compiling the kernel to rebuild your kernel.

In general, you shouldn't need pccons though, and wscons should fit all your needs.