Return to BSD News archive
Newsgroups: comp.os.386bsd.questions
Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!osuunx.ucc.okstate.edu!moe.ksu.ksu.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!usc!news.isi.edu!gremlin!lazarus.nrtc.northrop.com!dec
From: dec@lazarus.nrtc.northrop.com (Dwight E. Cass)
Subject: [FreeBSD 1.0 Release/syscons]: My keyboard goes away under X
Message-ID: <CGI211.u0@gremlin.nrtc.northrop.com>
Summary: syscons mini-FAQ
Keywords: FreeBSD, syscons
Sender: news@gremlin.nrtc.northrop.com (Usenet News Manager)
Organization: Northrop Automation Sciences Laboratory, Pico Rivera, CA
Date: Sun, 14 Nov 1993 20:53:24 GMT
Lines: 403
As many of you are now aware, FreeBSD 1.0 RELEASE has done something
to aggravate the problem with loosing your keyboard under X. The problem
as I understand it, is that the system has to deal with two different
devices referencing the same physical device in two different modes
(/dev/vga in raw mode and /dev/console and translated mode). Over time,
the system forgets which of these devices really owns the keyboard and
X looses.
One workaround to this problem is to upgrade to the syscons console driver.
However, its not quite that simple, and there are a few pitfalls (all of
which I fell into :-) ) which you should watch out for when doing this
upgrade. So, the following is a long summary of what I have learned,
done as a mini-FAQ, and I hope it helps you.
1. What is syscons?
[The following is a reduction of information from the
syscons-0.1.tar file originally on ref.tfs.com with the
current information verified by examination of the code]
syscons is an "enhanced" version of the pccons console driver, which
supports up to twelve (12) virtual consoles (VTYs) selectable via
changeable key sequences, a text mode screen saver (displays a field
of stars), some SCO ANSI ESC sequences including ANSI color attributes,
insert/delete line/character, 80x25 and 80x50 text modes on vga displays,
and a collection of various SYSV386/SCO compatible ioctls including:
KDGKBMODE Get keyboard mode (RAW, XLATE)
KDSKBMODE Set keyboard mode
KDMKTONE Sound the bell
KIOCSOUND Generate a specific Hz tone
KDGETMODE Get display mode (TEXT, GRAPHICS)
KDSETMODE Set display mode (TEXT, GRAPHICS, and a
non-restoring TEXT mode)
KDENABIO Allow IO operations
KDDISABIO Disallow IO operations
KDGKBTYPE Get keyboard type (not yet implemented)
KDGETLED Get LED status
KDSETLED Set LED status
KDSETRAD Set keyboard delay & repeat rate
KDSBORDER Set display border
KDGKBSTATE Get keyboard state
KDSKBSTATE Set keyboard state
GIO_KEYMAP Get keyboard mapping table
PIO_KEYMAP Set Keyboard mapping table
GIO_SCRNMAP Get screen output translation map
PIO_SCRNMAP Set screen output translation map
GIO_FONTXX Get size XX font, where XX is 8x8, 8x14, or 8x16
PIO_FONTXX Set size XX font
GETFKEY Get function key definition
SETFKEY Set function key definition
CONS_BLANKTIME Set screensaver timeout
CONS_80x25TEXT Set 80x25 char text mode
CONS_80x50TEXT Set 80x50 char text mode
CONS_GETVERS Get current syscons version
CONS_GETINFO Get current vty display state
VT_GETMODE Get screen switcher mode
VT_SETMODE Set screen switcher mode
VT_RELDISP Primary screen switcher IOCTL
VT_OPENQRY Get next free VTY
VT_GETACTIVE Get number of active VTYs
VT_ACTIVATE Switch to specific VTY
VT_WAITACTIVATE Wait for switch to happen
CONSOLE_X_MODE? Support for old way of doing X support
1a. What are the syscons ANSI ESC sequences?
The following ANSI ESC sequences are supported (\E = ESCape):
\EM Up 1 line and scroll if at top of screen
\Ec Move cursor home and clear screen
\r Move cursor to beginning of row
\n Move down one row
\E[r;cf Move cursor to row r, column c
\E[r;cH Move cursor to row r, column c (same as above)
\E[rJ Clear display, r specifies type of clear operation:
r = 0: Clear from cursor to end of display (default)
r = 1: Clear from beginning of display to cursor
r = 2: Clear entire display
\E[rK Clear line, r specified type of clear operation:
r = 0: Clear from cursor to end of line (default)
r = 1: Clear from beginning of line to cursor
r = 2: Clear entire line
\E[rz Switch to VTY r (r = 0: /dev/ttyv0), default is don't
switch.
\E[=p;dB Change bell duration to pitch p (in Hz) and
duration d (in 1/10ths of a second)
\E[=t;bC Change cursor shape to start at scan line t
and end at scan line b
\E[x;y;zm Change display attributes, x, y, and z can be:
0: reset to normal
1: bold text
4: underline
5: blink
7: reverse video
30: black foreground color
31: blue foreground color
32: green foreground color
33: cyan foreground color
34: red foreground color
35: violet foreground color
36: orange foreground color
37: light gray foreground color
40-47: same as 30-37, except background color
For the following sequences, r defaults to 1:
\E[rA Move up r rows
\E[rB Move down r rows
\E[re Move down r rows
\E[rC Move right r columns
\E[ra Move right r columns
\E[rD Move left r columns
\E[rE Move cursor to start of line and r lines down
\E[rF Move cursor to start of line and r lines up
\E[rL Insert r lines at after the current row
\E[rM Delete r lines starting with the current row
\E[r@ Insert r characters after current column
\E[rP Delete r characters starting with current column
\E[rX Delete r characters starting with current column,
but only from the current row
\E[rS Scroll up r rows
\E[rT Scroll down r rows
\E[rZ Move backwards r tabstops
\E[r` Move cursor to column r
\E[rd Move cursor to row r
For the following sequences, ANSI colors are defined as:
0 black 8 dark grey
1 dark red 9 bright red
2 green 10 bright green
3 orange 11 yellow
4 blue 12 bright blue
5 violet 13 bright violet
6 cyan 14 bright cyan
7 light grey 15 white
and Direct colors are defined as:
0 black 8 dark grey
1 blue 9 bright blue
2 green 10 bright green
3 cyan 11 bright cyan
4 red 12 bright red
5 violet 13 bright violet
6 orange 14 yellow
7 light grey 15 white
\E[x;yx Change display attributes
x = 0: reset attributes
x = 1: set ANSI normal background color, y = ANSI color
x = 2: set ANSI normal foreground color, y = ANSI color
x = 3: set normal color directly, colors numbers are
expressed in decimal using the direct color
map, but are bit encoded as two 4 bit field,
background and foreground. Thus, a blue
background with yellow foreground is \E[3;30x
(30 = 0x1E)
x = 5: set ANSI reverse video background color,
y = ANSI color
x = 6: set ANSI reverse video foreground color, use
y = ANSI color
x = 7: set reverse video color directly, use colors
from x = 3
\E[=yA Change display border color, y = Direct color
\E[=yF Set ANSI normal foreground color, y = ANSI color
\E[=yG Set ANSI normal background color, y = ANSI color
\E[=yH Set ANSI reverse video foreground color, y = ANSI color
\E[=yI Set ANSI reverse video background color, y = ANSI color
2. How do you switch from pccons to syscons?
From the kernel point of view, this is a really easy job. First, you
will need to modify your kernel configuration file and change the
following line:
device pc0 at isa? port "IO_KBD" tty irq 1 vector pcrint
to the following (arrows indicate the only changes):
device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr
^^^ ^^^^^^
You should also specify a number of virtual consoles (VTYs).
To do this, add the line:
options "NCONS=N" # N = number of virtual consoles desired
** For X support, you MUST specify at least two virtual consoles. **
Once your configuration file has been modified, rebuild your kernel.
Before you reboot, you must also create the virtual console devices
and modify your /etc/ttys to know about these new consoles. To make
the new devices:
cd /dev
./MAKEDEV vtyN # N = number of virtual consoles configured
rm /dev/vga # You will no longer need this...
The MAKEDEV script will generate a collection of /dev/ttyv? devices,
one for each virtual console, from 0 to b. You must now change your
/etc/ttys file to use these devices. In the simplest case (just to
make sure you can reboot), simply change the first line:
vga "/usr/libexec/getty Pc" pc3 on secure
to the following:
ttyv0 "/usr/libexec/getty Pc" pc3 on secure
^^^^^
This will start a getty on at least the console device. If you want
gettys on other virtual consoles you can add additional lines, such
as:
ttyv1 "/usr/libexec/getty Pc" pc3 on secure
ttyv2 "/usr/libexec/getty Pc" pc3 on secure
*** WARNING: MAKE SURE THAT THERE IS AT LEAST ONE FREE VTY FOR X ***
At this point, you can reboot your system, and you should now be
running the syscons console driver - congratulations!
2a. Is pc3 still the right terminal type for syscons?
pc3 seems to work fine for syscons (and I actually like how well
it does work), but there are people who suggest switching to cons25,
the ANSI 80x25 terminal definition. I think the best thing to do
is to build a new termcap entry specifically for syscons (I am working
on such an entry right now), but until then, its your choice.
3. How do I make XFree86 use syscons?
XFree86 version 2.0 has the code to detect and use the syscons virtual
console (VTY) mechanisms. If you are running XFree86 version 1.3, all
you have to do is grab the XFree86-2.0-SVGA.tar.gz file, extract the
server and replace the /usr/X386/bin/XF86_SVGA program. When you next
start X - it will tell you that it has seen syscons version 1.0, and
which VTY has been allocated for this X display.
3a. But XFree86 1.2 and XFree86 1.3 are running just fine - why change?
The problem is that neither XFree86 1.2 and 1.3 know about syscons
VTYs. These versions of X use the pccons CONSOLE_X_MODE? ioctls
to enter and exit X mode. As such, you are right back to same problem,
and if you were loosing your keyboard with pccons, you will loose
your keyboard in this mode.
3b. Why do I have to have a free VTY for X?
The problem you are trying to avoid is having both X and tty mode
on the device used as /dev/console. When this condition occurs under
FreeBSD 1.0 RELEASE - X looses. As such, allowing X to use a free
VTY leaves your actual console (/dev/ttyv0) in text mode and everything
continues to work fine.
As far as I am concerned: THIS IS A WORKAROUND TO A BUG IN FreeBSD.
3c. I only configured one VTY and X came up just fine - so what's the
problem?
If XFree86 2.0 is unable to find a free VTY, it will attempt to simply
change the mode of the current VTY. Again, the problem is that you are
back to the original pccons bug: you have both X and tty mode on the
device used as /dev/console - X looses.
3d. So I have X started on a free VTY and now I see a collection of error
messages after X starts on /dev/ttyv0 - why?
xinit passes the stdout file descriptor to the .xinitrc script. Now
that the console device is left in text mode, any errors being reported
by that script are appearing on the stdout device.
3e. I run xdm and don't have a getty on /dev/vga, do I now have to run
a getty on /dev/ttyv0?
No - /dev/ttyv0 will remain an output only console device.
4. How do you switch from VTY to VTY in syscons?
The default magic sequence is: hold down CTRL and ALT, then press
the function key for the VTY which you want to switch to. For example,
to switch to /dev/ttyv0 - hold down CTRL and ALT then press F1.
This will work to switch back and forth between text and X sessions.
4a. I switched to a new VTY and now it thinks all my characters are
control characters - why?
There is a race condition when a VTY switch happens which causes the
new VTY to sometimes become confused about the state of the CTRL and
ALT keys. I have found that you need to hold both of these keys down
until the screen stablizes then release them both. If you forget
(as I often do), just press and release both buttons to reset the
correct state.
5. Can I now run more than one X display?
YES. The first time you start X (via either startx or xinit), X will
default to using display 0, screen 0 (:0.0). To start another X
session, you need to start another display, thus if you are using
startx, you would type:
startx -- :1
That would allocate the next available VTY, and start display one on
that VTY.
WARNING: Only use this command from a text mode VTY!
5a. Oops - I started X from within an xterm and now the display has gone
crazy and I think my machine is burning up (actually, the speaker is
crackling loudly). What happened?
There seems to be a bug in syscons which causes it to get very
confused when you use an ioctl to initiate a programmatic switch
from a graphics mode VTY to a graphics mode VTY. I have found that
sometimes you can get the console back by using the keyboard sequence
to switch to another VTY - but generally this is reboot the system time.
6. Is there a utility program to get to some of the other syscons features?
Yes - the syscons program allows you to change the screen saver timeout
(or disable it altogether), change the screen size, change the keyboard
delay and repeat rates, switch VTYs, program a function key, and install
screen output maps, keyboard maps, and fonts. There is a man page
available (man syscons) to describe how to use this program.
6a. Can I use the syscons program to add "Switch to VTY X" commands to my
X window manager menus?
NO. The following obvious command, executed from a VTY, does work:
syscons -t 1 < /dev/ttyv0
However, as mentioned in 5a, syscons will get confused if you attempt
to use an ioctl to programmatically switch from a VTY in graphics mode
to a VTY in graphics mode. This WILL work to switch from X to a text
mode VTY.
6b. Is there any programmatic method for switching between VTYs that
does work?
Yes - the \E[rz sequence seems to have no problem in switching
between VTYs. Remember that r = 0 for /dev/ttyv0, thus the sequence
is \E[0z to switch to the console. Remember that this sequence must be
sent to a syscons terminal. I have found that echoing to stdout from
my window manager works just fine, or you can echo directly to
/dev/ttyv0 (or any syscons VTY).
6c. I want to switch to /dev/ttyv0 using syscons - why do I have to say: -t 1?
Remember the /dev/com?? numbering issue? Unix devices typically
start with 0, but syscons thinks the first VTY is number 1. Unlike
the /dev/com issue (we are trying to forget DOS, right?), there is a
reason for thinking of the first VTY as number 1 - the VTY numbering
matches their corresponding function keys (F1 is VTY1, F2 is VTY2, etc.).
7. I have an ET4000 VGA card and like the 80x50 text mode, but when I
start X it has clock selection problems. What's wrong?
[The following is from /usr/X386/lib/X11/etc/README.tseng
from the XFree86 version 2.0 distribution].
XFree86 has some problems getting the clock selection right with some
ET4000 boards when the server is started from a high-resolution text mode.
The clock selection is always correct when the server is started from a
standard 80x25 text mode.
This problem is indicated when the reported clocks are different when the
server is started from the high-resolution text mode from what they are
when it is started from the 80x25 text mode. To allow the server to work
correctly from the high-resolution text mode, there are some Option flags
that may be set in Xconfig. To find out which flags to set, start the
server with the -probeonly flag from an 80x25 text mode and look at the
information printed by the server. If the line:
VGAXXX: ET4000: Initial hibit state: low
is printed, put the following in the VGA256 and VGA2 sections of
your Xconfig:
Option "hibit_low"
If the line:
VGAXXX: ET4000: Initial hibit state: high
is printed, put the following in the VGA256 and VGA2 sections of
your Xconfig:
Option "hibit_high"
I hope this helps everyone avoid the mistakes I made.
/dec
Dwight E. Cass dec@nrtc.northrop.com | You are in a
Automation Sciences Laboratory, Northrop Corporation | twisty maze of
8900 East Washington Blvd, Pico Rivera CA 90660-3783 | Sendmail rules,
(310) 948-9981 | all obscure...