console, keyboard, kbd, kbdaux, log, profile, vga - system console

     The console device driver manages a series of devices related to the main
     user  interface:  The system screen and the keyboard.  These two together
     are named "the Console".

  The Screen
     The screen of a PC can be managed by  a  Monochrome  Display  Adapter,  a
     Hercules card, a Color Graphics Adapter, an Enhanced Graphics Adapter, or
     a Video Graphics Array.  To the console driver these devices are seen  as
     a  block  of  video  memory  into  which  characters can be written to be
     displayed, an I/O register that sets  the  video  memory  origin  to  the
     character that is to be displayed on the top-left position of the screen,
     and an I/O register that sets the position of the hardware cursor.   Each
     character  within  video  memory is a two-byte word.  The low byte is the
     character code, and the high byte is the "attribute byte", a set of  bits
     that   controls  the  way  the  character  is  displayed,  character  and
     background colours for  a  colour  card,  or  intensity/underline/reverse
     video for monochrome.

     These are the characteristics of the adapters in text mode:

          Adapter        Usable memory  Mono/Colour
           MDA            4K             M
           Hercules       4K             M
           CGA            16K            C
           EGA            32K            M or C
           VGA            32K            M or C

     MDA and Hercules are the same to the console driver, because the graphics
     mode  of the Hercules is of no use to Minix.  EGA and VGA are also mostly
     seen as the same in text mode.  An EGA adapter is either a monochrome  or
     a  colour  device  depending on the screen attached to it.  A VGA adapter
     can run in either monochrome or colour (grayscale) mode depending on  how
     the Boot Monitor has initialized it.

     The driver uses the video origin to avoid  copying  the  screen  contents
     when  scrolling up or down.  Instead the origin is simply moved one line.
     This is  named  "hardware  scrolling",  as  opposed  to  copying  memory:
     "software scrolling".

     The video origin is also  used  to  implement  several  virtual  consoles
     inside  the  video  memory  of  the adapter.  Each virtual console gets a
     segment of video memory.  The driver chooses which console to display  by
     moving  the  video origin.  Note that an MDA or Hercules adapter can only
     support one console.  CGA can support up to four 80x25 consoles, and  EGA
     and  VGA  can  have  eight.   It is best to configure one less console to
     leave some video memory free so that hardware scrolling has some space to
     work in.

     Character codes are used as indices into a display font that is stored in
     the  adapter.   The  default  font  is the IBM character set, which is an
     ASCII character set in the low 128 codes, and a number  of  mathematical,
     greek,  silly  graphics,  and accented characters in the upper 128 codes.
     This font is fixed in the MDA, Hercules and  CGA  adapters,  but  can  be
     replaced by a user selected font for the EGA and VGA adapters.

     The Minix-vmd console driver assumes  ISO  Latin-1  character  codes  and
     translates  them  to  the  IBM  character  set as well as possible.  This
     translation is disabled when a font is loaded.

     A number of control characters and escape sequences  are  implemented  by
     the  driver.  The result is more or less compatible with the X11 terminal
     emulation program xterm and the VT100  terminal,  and  upward  compatible
     with  the  standard  Minix  console  and the ANSI standard terminal.  The
     termcap(5) type is the same as that of xterm.  Normal characters  written
     to  the  console  are  displayed at the cursor position and the cursor is
     advanced one column to the right.  If an entire line is filled  then  the
     cursor wraps to the first column of the next line when the next character
     must be displayed.  The screen is scrolled up if needed to  start  a  new
     line.   Some  characters  have  special effects when sent to the console.
     Some even have arguments in the form of comma separated decimal  numbers.
     These  numbers  default  to  the lowest possible value when omitted.  The
     top-left  character  is  at  position  (1,  1).   The  following  control
     characters and escape sequences are implemented by the console:

     Sequence  Name                Function
      ^@        Null                Ignored (padding character)
      ^G        Bell                Produce a short tone from the speaker
      ^H        Backspace           Move the cursor back one column,  wrapping
                                    from  the  left  edge  up  one line to the
                                    right edge
      ^I        Horizontal Tab      Move to the next tab stop, with  each  tab
                                    stop  at  columns  1, 9, 25, etc.  Wrap to
                                    the next line if necessary.
      ^J        Line Feed           Move one line down, scrolling  the  screen
                                    up if necessary
      ^K        Vertical Tab        Same as LF
      ^L        Form Feed           Same as LF
      ^M        Carriage Return     Move to column 1
      ^N        Shift Out           Ignored
      ^O        Shift In            Ignored
      ^[        Escape              Start of an escape sequence
      ^[D       Index               Same as LF
      ^[E       Next Line           Same as LF
      ^[M       Reverse Index       Move one line  up,  scrolling  the  screen
                                    down if necessary
      ^[c       Full Reset          Clear the screen,  home  the  cursor,  and
                                    reset all attributes
      ^[[nA     Cursor Up           Move the cursor up n lines
      ^[[nB     Cursor Down         Move the cursor down n lines
      ^[[nC     Cursor Forward      Move the cursor right n columns
      ^[[nD     Cursor Backward     Move the cursor left n columns
      ^[[m;nH   Cursor Position     Move the cursor to line m, column n
      ^[[sJ     Erase in Display    Clear characters as follows:
                                    s = 0: From cursor to end of screen
                                    s = 1: From start of screen to cursor
                                    s = 2: Entire screen
      ^[[sK     Erase in Line       Clear characters as follows:
                                    s = 0: From cursor to end of line
                                    s = 1: From start of line to cursor
                                    s = 2: Entire line
      ^[[nL     Insert Lines        Insert n blank lines
      ^[[nM     Delete Lines        Delete n lines
      ^[[n@     Insert Characters   Insert n blank characters
      ^[[nP     Delete Characters   Delete n characters
      ^[[nm     Character Attribute Set character attribute as follows:
                                    n = 0: Normal (default) attribute
                                    n = 1: Bold (mono) / Yellow (colour)
                                    n = 4: Underline (M) / Light green (C)
                                    n = 5: Blinking (M) / Magenta (C)
                                    n = 7: Reverse Video
                                    n = 30: Black foreground colour
                                    n = 31: Red
                                    n = 32: Green
                                    n = 33: Orange
                                    n = 34: Blue
                                    n = 35: Magenta
                                    n = 36: Light blue
                                    n = 37: White
                                    n = 40 - 47: Same for background colour
      ^[[?3l                        Switch  console  to  80  column  mode  and
                                    reset.   A vertical line of `|' characters
                                    will appear if the console is  in  a  mode
                                    with  more  than 80 columns.  That line is
                                    now the right edge of the screen
      ^[[?3h                        Switch console to full width and reset.
      ^[]2;t^G                      Enable the status  line  and  display  the
                                    string  t  on it, any control code ends t,
                                    but ^G is the proper code

     The console interprets and then ignores several  other  escape  sequences
     for  compatibility  reasons.   Only  the  ignored  control characters are
     listed above.

     The console devices implements the following ioctls to copy  from  or  to
     the font memory on EGA and VGA adapters:

          ioctl(fd, TIOCGFON, u8_t font[256][32]);
          ioctl(fd, TIOCSFON, u8_t font[256][32]);

     Font memory consists  of  256  character  definitions  of  32  lines  per
     character  and  8 pixels per line.  The first line is the topmost line of
     the character.  The leftmost pixel is lit if the most significant bit  of
     a line is set, etc.  How many lines are used depends on the current video
     mode.  The 80x25 video mode used by Minix has  an  8x16  character  cell,
     80x28  has  8x14  characters,  and  132x43  has 8x8 characters.  The boot
     variable console is used by both the Boot Monitor and the console  driver
     to  set  the  video mode, software scrolling on/off, and VGA screen blank
     timeout.  See boot(8).

  The Keyboard
     The keyboard produces key codes for each key that is pressed.  These keys
     are  transformed  into  character  codes  or  sequences  according to the
     current  keyboard  translation  table.   The  format  of  this  table  is
     described in keymap(5).  The character codes can be read from the console
     device unless they map to special hotkeys.  The hotkeys  are  represented
     by  ^"name" like things in the keyboard tables.  The hotkey names and the
     keys they are by default bound to are as follows:

     Name     Key              Function
      reboot   CTRL-ALT-DEL     Send an abort  signal  to  process  1  (init).
                                Init then halts the system
      reboot   CTRL-ALT-KP-.    Likewise for keypad period
      pdmp     CTRL-F1          Process table dump
      mdmp     CTRL-F2          Show memory map
      scroll   CTRL-F3          Toggle software/hardware scrolling
      serdbug  CTRL-F4          Select serial line to copy debug messages to
      netstat  CTRL-F5          Show network statistics
      prio     CTRL-F6          Show scheduler priority table
      loadav   CTRL-F7          Show load averages table
      vmdmp    CTRL-F8          Show virtual memory statistics
      fpemu    CTRL-F9          Floating point emulation toggle (does  nothing
                                as yet)
      debug    CTRL-F10         Toggle kernel debug flag between 0 and 1
      vc0      ALT-F1           Select virtual console 0 (/dev/console)
      vc1      ALT-F2           Select virtual console 1 (/dev/ttyc1)
      vcn      ALT-F(n+1)       Select virtual console n (/dev/ttycn)
      vc-      ALT-Left         Select previous virtual console
      vc+      ALT-Right        Select next virtual console
      st-      ALT-Down         Disable the status line
      st+      ALT-Up           Enable the status line

     The  keyboard  map  is  set  with  the  KIOCSMAP  ioctl   whose   precise
     implementation  cannot  be described here for the author of this text has
     not looked at the new keymap code yet.

  VGA and keyboard devices
     The vga device is used by the X11 server to map the video memory into its
     address space.  Console ouput is then sent to the log device instead, and
     keyboard input is no longer sent to the console but can be  read  as  raw
     scan codes from the kbd device by the X11 server.  The kbdaux is a serial
     input device for a PS/2 style mouse.

  Log device
     The log device can be used by processes to print debug messages onto  the
     console.   The  console  is  a  terminal type device, so it is taken from
     processes when a session leader exits.  This does not happen with the log
     device.   Messages sent to the log device are placed in a circular buffer
     whose contents can be read from the log device and put in a log file  for
     instance.   Several  copies  of  the  log buffer are placed into extended
     memory  on  a  system  crash.   They  are  retrieved  if  the  system  is
     immediately rebooted.

     The profile device implements two ioctls, PIOCSTART, to  turn  on  kernel
     profiling  and  make  profile  data available to be read from the profile
     device, and PIOCSTOP, to stop profiling.  Precise details  are  currently
     hidden within the profile and prof_stop utilities.

     tty(4), keymap(1), keymap(5), profile(8), boot(8).

     Output processing turns Line Feeds into CR LF sequences.  Don't let  this
     surprise  you.   Either  turn  off  output  processing  or use one of the
     synonyms for LF.

     Line Feed is changed into a CR LF sequence in canonical mode.

     The mistreatment of the console and keyboard driver by Philip has not yet
     reached its limit, so one can expect some changes.

     Some  escape  sequences  should  provoke   the   console   into   sending
     identification  codes  back  out.   Processes  may wait forever for these
     codes.  Only processes that try more than the codes listed in  the  xterm
     termcap definition may be troubled by unimplemented weird features.

     Kees J. Bot (