*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Linux man pages -> console_ioctls (4)              
Title
Content
Arch
Section
 

CONSOLE_IOCTLS(4)

Contents


NAME    [Toc]    [Back]

       console ioctl's- ioctl's for console terminal and virtual consoles

DESCRIPTION    [Toc]    [Back]

       WARNING:  If  you  use  the following information you are going to burn
       yourself.

       WARNING: ioctl's are undocumented Linux internals, liable to be changed
       without warning.  Use POSIX functions where available.

       The  following  Linux-peculiar  ioctl()	requests  are supported.  Each
       requires a third argument, assumed here to be argp.

       KDGETLED    [Toc]    [Back]
	      Get state of LEDs.  argp points to a long int.  The lower  three
	      bits of *argp are set to the state of the LEDs, as follows:

		  LED_CAP	0x04   caps lock led
		  LEC_NUM	0x02   num lock led
		  LED_SCR	0x01   scroll lock led


       KDSETLED    [Toc]    [Back]
	      Set the LEDs.  The LEDs are set to correspond to the lower three
	      bits of argp.  However, if a higher order bit is set,  the  LEDs
	      revert to normal: displaying the state of the keyboard functions
	      of caps lock, num lock, and scroll lock.

	      Before 1.1.54, the leds just reflected the state of  the	corresponding
 keyboard flags, and KDGETLED/KDSETLED would also change
	      the keyboard flags. Since 1.1.54 the leds can be made to display
	      arbitrary  information, but by default they display the keyboard
	      flags.  The following two ioctl's are used to  access  the  keyboard
 flags.


       KDGKBLED    [Toc]    [Back]
	      Get  keyboard  flags CapsLock, NumLock, ScrollLock (not lights).
	      argp points to a char which is set to the flag state.   The  low
	      order  three bits (mask 0x7) get the current flag state, and the
	      low order bits of the next nibble (mask 0x70)  get  the  default
	      flag state. (Since 1.1.54.)


       KDSKBLED    [Toc]    [Back]
	      Set  keyboard  flags CapsLock, NumLock, ScrollLock (not lights).
	      argp has the desired flag state.	The low order three bits (mask
	      0x7)  have  the  flag  state, and the low order bits of the next
	      nibble (mask 0x70) have the default flag state. (Since  1.1.54.)


       KDGKBTYPE    [Toc]    [Back]
	      Get  keyboard  type.  This  returns the value KB_101, defined as
	      0x02.


       KDADDIO    [Toc]    [Back]
	      Add I/O port as valid. Equivalent to ioperm(arg,1,1).


       KDDELIO    [Toc]    [Back]
	      Delete I/O port as valid. Equivalent to ioperm(arg,1,0).


       KDENABIO    [Toc]    [Back]
	      Enable  I/O  to  video  board.   Equivalent   to	 ioperm(0x3b4,
	      0x3df-0x3b4+1, 1).


       KDDISABIO    [Toc]    [Back]
	      Disable	I/O   to  video  board.  Equivalent  to  ioperm(0x3b4,
	      0x3df-0x3b4+1, 0).


       KDSETMODE    [Toc]    [Back]
	      Set text/graphics mode.  argp is one of these:

		  KD_TEXT	0x00
		  KD_GRAPHICS	0x01


       KDGETMODE    [Toc]    [Back]
	      Get text/graphics mode.  argp points to a long which is  set  to
	      one of the above values.


       KDMKTONE    [Toc]    [Back]
	      Generate	tone  of  specified length.  The lower 16 bits of argp
	      specify the period in clock cycles, and the upper 16  bits  give
	      the  duration  in  msec.	 If the duration is zero, the sound is
	      turned off.  Control returns immediately.  For example,  argp  =
	      (125<<16)  +  0x637  would  specify the beep normally associated
	      with a ctrl-G.


       KIOCSOUND    [Toc]    [Back]
	      Start or stop sound generation.  The lower 16 bits of argp specify
  the	period	in  clock cycles (that is, argp = 1193180/frequency).
	argp = 0 turns sound off.   In	either	case,  control
	      returns immediately.


       GIO_FONT    [Toc]    [Back]
	      Gets  screen font in expanded form.  argp points to an 8192 byte
	      array.


       PIO_FONT    [Toc]    [Back]
	      Sets screen font.  Load font into the EGA/VGA character  generator.
   argp points to a 8192 byte map, with 32 bytes per character.
  Only first N of them are used for an 8xN font (0  <  N  <=
	      32).


       GIO_SCRNMAP    [Toc]    [Back]
	      Get  screen mapping from kernel.	argp points to an area of size
	      E_TABSZ.


       PIO_SCRNMAP    [Toc]    [Back]
	      Loads the "user definable" (fourth) table in  the  kernel  which
	      maps  bytes into console screen symbols.	argp points to an area
	      of size E_TABSZ.


       GIO_UNIMAP    [Toc]    [Back]
	      Get unicode-to-font mapping from kernel.	argp points to a

	      struct unimapdesc {
		      u_short entry_ct;
		      struct unipair *entries;
	      };

	      where entries points to an array of

	      struct unipair {
		      u_short unicode;
		      u_short fontpos;
	      };

	      (Since 1.1.92.)


       PIO_UNIMAP    [Toc]    [Back]
	      Put unicode-to-font mapping in kernel.  argp points to a	struct
	      unimapdesc.  (Since 1.1.92)


       PIO_UNIMAPCLR    [Toc]    [Back]
	      Clear table, possibly advise hash algorithm.  argp points to a

	      struct unimapinit {
		      u_short advised_hashsize;  /* 0 if no opinion */
		      u_short advised_hashstep;  /* 0 if no opinion */
		      u_short advised_hashlevel; /* 0 if no opinion */
	      };

	      (Since 1.1.92.)


       KDGKBMODE    [Toc]    [Back]
	      Gets  current keyboard mode.  argp points to a long which is set
	      to one of these:

		  K_RAW 	0x00
		  K_XLATE	0x01
		  K_MEDIUMRAW	0x02
		  K_UNICODE	0x03


       KDSKBMODE    [Toc]    [Back]
	      Sets current keyboard mode.  argp is a long equal to one of  the
	      above values.


       KDGKBMETA    [Toc]    [Back]
	      Gets meta key handling mode.  argp points to a long which is set
	      to one of these:

		  K_METABIT	0x03   set high order bit
		  K_ESCPREFIX	0x04   escape prefix


       KDSKBMETA    [Toc]    [Back]
	      Sets meta key handling mode.  argp is a long equal to one of the
	      above values.


       KDGKBENT    [Toc]    [Back]
	      Gets  one  entry	in  key  translation  table (keycode to action
	      code).  argp points to a

	      struct kbentry {
		  u_char kb_table;
		  u_char kb_index;
		  u_short kb_value;
	      };

	      with the first two members filled in: kb_table selects  the  key
	      table (0 <= kb_table < MAX_NR_KEYMAPS), and kb_index is the keycode
 (0 <= kb_index < NR_KEYS).  kb_value is set to  the	corresponding
	action	code,  or  K_HOLE  if there is no such key, or
	      K_NOSUCHMAP if kb_table is invalid.


       KDSKBENT    [Toc]    [Back]
	      Sets one entry in translation table.  argp points  to  a	struct
	      kbentry.


       KDGKBSENT    [Toc]    [Back]
	      Gets one function key string.  argp points to a

	      struct kbsentry {
		  u_char kb_func;
		  u_char kb_string[512];
	      };

	      kb_string  is  set to the (NULL terminated) string corresponding
	      to the kb_functh function key action code.


       KDSKBSENT    [Toc]    [Back]
	      Sets one function key string entry.  argp  points  to  a	struct
	      kbsentry.


       KDGKBDIACR    [Toc]    [Back]
	      Read kernel accent table.  argp points to a

	      struct kbdiacrs {
		  unsigned int kb_cnt;
		  struct kbdiacr kbdiacr[256];
	      };

	      where  kb_cnt  is  the  number  of entries in the array, each of
	      which is a

	      struct kbdiacr { u_char diacr, base, result; };


       KDGETKEYCODE    [Toc]    [Back]
	      Read kernel keycode table entry (scan code  to  keycode).   argp
	      points to a

	      struct kbkeycode { unsigned int scancode, keycode; };

	      keycode  is  set	to  correspond	to the given scancode.	(89 <=
	      scancode <= 255 only.  For 1 <= scancode <=  88,	keycode==scan-
	      code.)  (Since 1.1.63.)


       KDSETKEYCODE    [Toc]    [Back]
	      Write  kernel keycode table entry.  argp points to struct kbkeycode.
  (Since 1.1.63.)


       KDSIGACCEPT    [Toc]    [Back]
	      The calling process indicates its willingness to accept the signal
  argp  when  it  is generated by pressing an appropriate key
	      combination.  (1 <= argp	<=  NSIG).   (See  spawn_console()  in
	      linux/drivers/char/keyboard.c.)


       VT_OPENQRY    [Toc]    [Back]
	      Returns  the  first available (non-opened) console.  argp points
	      to an int which is set to the number of the vt (1  <=  *argp  <=
	      MAX_NR_CONSOLES).


       VT_GETMODE    [Toc]    [Back]
	      Get mode of active vt.  argp points to a

	      struct vt_mode {
		  char mode;	 /* vt mode */
		  char waitv;	 /* if set, hang on writes if not active */
		  short relsig;  /* signal to raise on release req */
		  short acqsig;  /* signal to raise on acquisition */
		  short frsig;	 /* unused (set to 0) */
	      };

	      mode is set to one of these values:

		  VT_AUTO	auto vt switching
		  VT_PROCESS	process controls switching
		  VT_ACKACQ	acknowledge switch


       VT_SETMODE    [Toc]    [Back]
	      Set mode of active vt.  argp points to a struct vt_mode.


       VT_GETSTATE    [Toc]    [Back]
	      Get global vt state info.  argp points to a

	      struct vt_stat {
		  ushort v_active;  /* active vt */
		  ushort v_signal;  /* signal to send */
		  ushort v_state;   /* vt bitmask */
	      };

	      For  each vt in use, the corresponding bit in the v_state member
	      is set.  (Kernels 1.0 through 1.1.92.)


       VT_RELDISP    [Toc]    [Back]
	      Release a display.


       VT_ACTIVATE    [Toc]    [Back]
	      Switch to vt argp (1 <= argp <= MAX_NR_CONSOLES).


       VT_WAITACTIVE    [Toc]    [Back]
	      Wait until vt argp has been activated.


       VT_DISALLOCATE    [Toc]    [Back]
	      Deallocate the memory associated with vt argp.  (Since  1.1.54.)


       VT_RESIZE    [Toc]    [Back]
	      Set kernel's idea of screensize.	argp points to a

	      struct vt_sizes {
		  ushort v_rows;       /* # rows */
		  ushort v_cols;       /* # columns */
		  ushort v_scrollsize; /* no longer used */
	      };

	      (Since  1.1.54.)	Note  that this does not change the videomode.
	      See resizecons(8).

       The action of the following ioctls depends on the  first  byte  in  the
       struct  pointed to by argp, referred to here as the subcode.  These are
       legal only for the superuser or the owner of the current tty.

       TIOCLINUX, subcode=0
	      Dump the screen.	Disappeared in 1.1.92.	(With kernel 1.1.92 or
	      later, read from /dev/vcsN or /dev/vcsaN instead.)


       TIOCLINUX, subcode=1
	      Get task information. Disappeared in 1.1.92.


       TIOCLINUX, subcode=2
	      Set selection.  argp points to a

		 struct {char subcode;
		     short xs, ys, xe, ye;
		     short sel_mode;
		 }

	      xs  and  ys  are the starting column and row.  xe and ye are the
	      ending column and row.  (Upper  left  corner  is	row=column=1.)
	      sel_mode	is 0 for character-by-character selection, 1 for wordby-word
 selection, or 2 for line-by-line selection.   The  indicated
  screen characters are highlighted and saved in the static
	      array sel_buffer in devices/char/console.c.


       TIOCLINUX, subcode=3
	      Paste selection.	The characters in  the	selection  buffer  are
	      written to fd.


       TIOCLINUX, subcode=4
	      Unblank the screen.


       TIOCLINUX, subcode=5
	      Sets  contents of a 256-bit look up table defining characters in
	      a "word", for word-by-word selection.  (Since 1.1.32.)


       TIOCLINUX, subcode=6
	      argp points to a char which is set to the value  of  the	kernel
	      variable shift_state.  (Since 1.1.32.)


       TIOCLINUX, subcode=7
	      argp  points  to	a char which is set to the value of the kernel
	      variable report_mouse.  (Since 1.1.33.)


       TIOCLINUX, subcode=8
	      Dump screen width and height, cursor position, and all the character-attribute
  pairs.	(Kernels  1.1.67  through 1.1.91 only.
	      With kernel 1.1.92 or later, read from /dev/vcsa* instead.)


       TIOCLINUX, subcode=9
	      Restore screen width and height, cursor position,  and  all  the
	      character-attribute pairs.  (Kernels 1.1.67 through 1.1.91 only.
	      With kernel 1.1.92 or later, write to /dev/vcsa* instead.)


       TIOCLINUX, subcode=10
	      Handles the Power Saving feature of the new generation of  monitors.
   VESA  screen  blanking mode is set to argp, which is one
	      of:

		  0: Screen blanking is disabled.

		  1: The current video adapter register  settings  are	saved,
	      then  the controller is programmed to turn off the vertical synchronization
 pulses.  This puts the monitor into "standby" mode.
	      If  your	monitor has an Off_Mode timer, then it will eventually
	      power down by itself.

		  2: The current settings are saved, then  both  the  vertical
	      and horizontal synchronization pulses are turned off.  This puts
	      the monitor into "off" mode.  If your monitor  has  no  Off_Mode
	      timer,  or  if  you  want your monitor to power down immediately
	      when the blank_timer times out, then  you  choose  this  option.
	      (Caution: Powering down frequently will damage the monitor.)

	      (Since 1.1.76.)

RETURN VALUES    [Toc]    [Back]

       -1 for error, and errno is set.

ERRORS    [Toc]    [Back]

       errno may take on these values:

       EBADF	 file descriptor is invalid.
       ENOTTY	 file descriptor is not associated with a character
		 special device, or the specified request does not
		 apply to it.
       EINVAL	 file descriptor or argp is invalid.
       EPERM	 permission violation.

WARNING    [Toc]    [Back]

       Do  not	regard	this  man  page  as documentation of the Linux console
       ioctl's.  This is provided for the curious only, as an  alternative  to
       reading the source. Ioctl's are undocumented Linux internals, liable to
       be changed without  warning.  (And  indeed,  this  page	more  or  less
       describes  the  situation  as  of kernel version 1.1.94; there are many
       minor and not-so-minor differences with earlier versions.)

       Very often, ioctl's are introduced for communication between the kernel
       and  one  particular  well-known  program  (fdisk(8), hdparm(8), setse-
       rial(8), tunelp(8), loadkeys(1), gpm(8),  consolechars(8),  etc.),  and
       their  behavior	will be changed when required by these particular programs.


       Programs using these ioctl's will not be portable to other versions  of
       Unix,  will  not  work on older versions of Linux, and will not work on
       future versions of Linux.

       Use POSIX functions.

SEE ALSO    [Toc]    [Back]

      
      
       kbd_mode(1), loadkeys(1), dumpkeys(1), mknod(1),  setleds(1),  setmeta-
       mode(1),  ioperm(2),  termios(2),  execve(2),  fcntl(2),  mt(4), sd(4),
       tty(4), ttys(4), vcs(4), vcsa(4), mapscrn(8), consolechars(8),  resize-
       cons(8), /usr/include/linux/kd.h, /usr/include/linux/vt.h.



Linux				  28 Oct 1997		     CONSOLE_IOCTLS(4)
[ Back ]
 Similar pages
Name OS Title
console Linux console terminal and virtual consoles
console_ioctl Linux ioctl's for console terminal and virtual consoles
streamio HP-UX STREAMS ioctl commands
streamio IRIX STREAMS ioctl commands
streamio Tru64 STREAMS ioctl commands
bio OpenBSD ioctl tunnel pseudo-device
ioctl_list Linux list of ioctl calls in Linux/i386 kernel
timod Tru64 STREAMS module for converting ioctl() calls into TI messages
ioctl NetBSD how to implement a new ioctl call to access device drivers
proc Tru64 The process (/proc) file system and associated ioctl requests
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service