.TH CONSOLE_IOCTLS 4 "28 Oct 1997" "Linux" "Linux Programmer's Manual" .\" Copyright (c) 1995 Jim Van Zandt and aeb .\" Sun Feb 26 11:46:23 MET 1995 .\" Slightly modified by dirson@debian.org .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, .\" USA. .\" .SH NAME console ioctl's\- ioctl's for console terminal and virtual consoles .SH DESCRIPTION \fBWARNING: If you use the following information you are going to burn yourself.\fP \fBWARNING: ioctl's are undocumented Linux internals, liable to be changed without warning. Use POSIX functions where available.\fP The following Linux-peculiar \fBioctl()\fP requests are supported. Each requires a third argument, assumed here to be \fIargp\fP. .IP \fBKDGETLED\fP Get state of LEDs. \fIargp\fP points to a long int. The lower three bits of \fI*argp\fP 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 .IP \fBKDSETLED\fP Set the LEDs. The LEDs are set to correspond to the lower three bits of \fIargp\fP. 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. .IP \fBKDGKBLED\fP Get keyboard flags CapsLock, NumLock, ScrollLock (not lights). \fIargp\fP 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.) .IP \fBKDSKBLED\fP Set keyboard flags CapsLock, NumLock, ScrollLock (not lights). \fIargp\fP 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.) .IP \fBKDGKBTYPE\fP Get keyboard type. This returns the value KB_101, defined as 0x02. .IP \fBKDADDIO\fP Add I/O port as valid. Equivalent to ioperm(arg,1,1). .IP \fBKDDELIO\fP Delete I/O port as valid. Equivalent to ioperm(arg,1,0). .IP \fBKDENABIO\fP Enable I/O to video board. Equivalent to ioperm(0x3b4, 0x3df-0x3b4+1, 1). .IP \fBKDDISABIO\fP Disable I/O to video board. Equivalent to ioperm(0x3b4, 0x3df-0x3b4+1, 0). .IP \fBKDSETMODE\fP Set text/graphics mode. \fIargp\fP is one of these: KD_TEXT 0x00 KD_GRAPHICS 0x01 .IP \fBKDGETMODE\fP Get text/graphics mode. \fIargp\fP points to a long which is set to one of the above values. .IP \fBKDMKTONE\fP Generate tone of specified length. The lower 16 bits of \fIargp\fP 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, \fIargp\fP = (125<<16) + 0x637 would specify the beep normally associated with a ctrl-G. .IP \fBKIOCSOUND\fP Start or stop sound generation. The lower 16 bits of \fIargp\fP specify the period in clock cycles (that is, \fIargp\fP = 1193180/frequency). \fIargp\fP = 0 turns sound off. In either case, control returns immediately. .IP \fBGIO_FONT\fP Gets screen font in expanded form. \fIargp\fP points to an 8192 byte array. .IP \fBPIO_FONT\fP Sets screen font. Load font into the EGA/VGA character generator. \fIargp\fP points to a 8192 byte map, with 32 bytes per character. Only first \fIN\fP of them are used for an 8x\fIN\fP font (0 < \fIN\fP <= 32). .IP \fBGIO_SCRNMAP\fP Get screen mapping from kernel. \fIargp\fP points to an area of size E_TABSZ. .IP \fBPIO_SCRNMAP\fP Loads the "user definable" (fourth) table in the kernel which maps bytes into console screen symbols. \fIargp\fP points to an area of size E_TABSZ. .IP \fBGIO_UNIMAP\fP Get unicode-to-font mapping from kernel. \fIargp\fP points to a .nf struct unimapdesc { u_short \fIentry_ct\fP; struct unipair *\fIentries\fP; }; .fi where \fIentries\fP points to an array of .nf struct unipair { u_short \fIunicode\fP; u_short \fIfontpos\fP; }; .fi (Since 1.1.92.) .IP \fBPIO_UNIMAP\fP Put unicode-to-font mapping in kernel. \fIargp\fP points to a struct unimapdesc. (Since 1.1.92) .IP \fBPIO_UNIMAPCLR\fP Clear table, possibly advise hash algorithm. \fIargp\fP points to a .nf struct unimapinit { u_short \fIadvised_hashsize\fP; /* 0 if no opinion */ u_short \fIadvised_hashstep\fP; /* 0 if no opinion */ u_short \fIadvised_hashlevel\fP; /* 0 if no opinion */ }; .fi (Since 1.1.92.) .IP \fBKDGKBMODE\fP Gets current keyboard mode. \fIargp\fP points to a long which is set to one of these: K_RAW 0x00 K_XLATE 0x01 K_MEDIUMRAW 0x02 K_UNICODE 0x03 .IP \fBKDSKBMODE\fP Sets current keyboard mode. \fIargp\fP is a long equal to one of the above values. .IP \fBKDGKBMETA\fP Gets meta key handling mode. \fIargp\fP points to a long which is set to one of these: K_METABIT 0x03 set high order bit K_ESCPREFIX 0x04 escape prefix .IP \fBKDSKBMETA\fP Sets meta key handling mode. \fIargp\fP is a long equal to one of the above values. .IP \fBKDGKBENT\fP Gets one entry in key translation table (keycode to action code). \fIargp\fP points to a .nf struct kbentry { u_char \fIkb_table\fP; u_char \fIkb_index\fP; u_short \fIkb_value\fP; }; .fi with the first two members filled in: \fIkb_table\fP selects the key table (0 <= \fIkb_table\fP < MAX_NR_KEYMAPS), and \fIkb_index\fP is the keycode (0 <= \fIkb_index\fP < NR_KEYS). \fIkb_value\fP is set to the corresponding action code, or K_HOLE if there is no such key, or K_NOSUCHMAP if \fIkb_table\fP is invalid. .IP \fBKDSKBENT\fP Sets one entry in translation table. \fIargp\fP points to a struct kbentry. .IP \fBKDGKBSENT\fP Gets one function key string. \fIargp\fP points to a .nf struct kbsentry { u_char \fIkb_func\fP; u_char \fIkb_string\fP[512]; }; .fi \fIkb_string\fP is set to the (NULL terminated) string corresponding to the \fIkb_func\fPth function key action code. .IP \fBKDSKBSENT\fP Sets one function key string entry. \fIargp\fP points to a struct kbsentry. .IP \fBKDGKBDIACR\fP Read kernel accent table. \fIargp\fP points to a .nf struct kbdiacrs { unsigned int \fIkb_cnt\fP; struct kbdiacr \fIkbdiacr\fP[256]; }; .fi where \fIkb_cnt\fP is the number of entries in the array, each of which is a struct kbdiacr { u_char \fIdiacr\fP, \fIbase\fP, \fIresult\fP; }; .IP \fBKDGETKEYCODE\fP Read kernel keycode table entry (scan code to keycode). \fIargp\fP points to a .nf struct kbkeycode { unsigned int \fIscancode\fP, \fIkeycode\fP; }; .fi \fIkeycode\fP is set to correspond to the given \fIscancode\fP. (89 <= \fIscancode\fP <= 255 only. For 1 <= \fIscancode\fP <= 88, \fIkeycode\fP==\fIscancode\fP.) (Since 1.1.63.) .IP \fBKDSETKEYCODE\fP Write kernel keycode table entry. \fIargp\fP points to struct kbkeycode. (Since 1.1.63.) .IP \fBKDSIGACCEPT\fP The calling process indicates its willingness to accept the signal \fIargp\fP when it is generated by pressing an appropriate key combination. (1 <= \fIargp\fP <= NSIG). (See spawn_console() in linux/drivers/char/keyboard.c.) .IP \fBVT_OPENQRY\fP Returns the first available (non-opened) console. \fIargp\fP points to an int which is set to the number of the vt (1 <= \fI*argp\fP <= MAX_NR_CONSOLES). .IP \fBVT_GETMODE\fP Get mode of active vt. \fIargp\fP points to a .nf struct vt_mode { char \fImode\fP; /* vt mode */ char \fIwaitv\fP; /* if set, hang on writes if not active */ short \fIrelsig\fP; /* signal to raise on release req */ short \fIacqsig\fP; /* signal to raise on acquisition */ short \fIfrsig\fP; /* unused (set to 0) */ }; .fi ...which is set to the mode of the active vt. \fImode\fP is set to one of these values: VT_AUTO auto vt switching VT_PROCESS process controls switching VT_ACKACQ acknowledge switch .IP \fBVT_SETMODE\fP Set mode of active vt. \fIargp\fP points to a struct vt_mode. .IP \fBVT_GETSTATE\fP Get global vt state info. \fIargp\fP points to a .nf struct vt_stat { ushort \fIv_active\fP; /* active vt */ ushort \fIv_signal\fP; /* signal to send */ ushort \fIv_state\fP; /* vt bitmask */ }; .fi For each vt in use, the corresponding bit in the \fIv_state\fP member is set. (Kernels 1.0 through 1.1.92.) .IP \fBVT_RELDISP\fP Release a display. .IP \fBVT_ACTIVATE\fP Switch to vt \fIargp\fP (1 <= \fIargp\fP <= MAX_NR_CONSOLES). .IP \fBVT_WAITACTIVE\fP Wait until vt \fIargp\fP has been activated. .IP \fBVT_DISALLOCATE\fP Deallocate the memory associated with vt \fIargp\fP. (Since 1.1.54.) .IP \fBVT_RESIZE\fP Set kernel's idea of screensize. \fIargp\fP points to a .nf struct vt_sizes { ushort \fIv_rows\fP; /* # rows */ ushort \fIv_cols\fP; /* # columns */ ushort \fIv_scrollsize\fP; /* no longer used */ }; .fi (Since 1.1.54.) Note that this does not change the videomode. See resizecons(8). .PP The action of the following ioctls depends on the first byte in the struct pointed to by \fIargp\fP, referred to here as the \fIsubcode\fP. These are legal only for the superuser or the owner of the current tty. .IP "\fBTIOCLINUX, 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.) .IP "\fBTIOCLINUX, subcode=1" Get task information. Disappeared in 1.1.92. .IP "\fBTIOCLINUX, subcode=2" Set selection. \fIargp\fP points to a struct {char \fIsubcode\fP; short \fIxs\fP, \fIys\fP, \fIxe\fP, \fIye\fP; short \fIsel_mode\fP; } \fIxs\fP and \fIys\fP are the starting column and row. \fIxe\fP and \fIye\fP are the ending column and row. (Upper left corner is row=column=1.) \fIsel_mode\fP is 0 for character-by-character selection, 1 for word-by-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. .IP "\fBTIOCLINUX, subcode=3" Paste selection. The characters in the selection buffer are written to \fIfd\fP. .IP "\fBTIOCLINUX, subcode=4" Unblank the screen. .IP "\fBTIOCLINUX, 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.) .IP "\fBTIOCLINUX, subcode=6" \fIargp\fP points to a char which is set to the value of the kernel variable \fIshift_state\fP. (Since 1.1.32.) .IP "\fBTIOCLINUX, subcode=7" \fIargp\fP points to a char which is set to the value of the kernel variable \fIreport_mouse\fP. (Since 1.1.33.) .IP "\fBTIOCLINUX, 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.) .IP "\fBTIOCLINUX, 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.) .IP "\fBTIOCLINUX, subcode=10" Handles the Power Saving feature of the new generation of monitors. VESA screen blanking mode is set to \fIargp\fP, which is one of: \fI0\fP: Screen blanking is disabled. \fI1\fP: 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. \fI2\fP: 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. (\fICaution:\fP Powering down frequently will damage the monitor.) (Since 1.1.76.) .SH "RETURN VALUES" -1 for error, and \fIerrno\fP is set. .SH ERRORS \fIerrno\fP may take on these values: .nf 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 \fIargp\fP is invalid. EPERM permission violation. .fi .SH WARNING 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 .RB ( fdisk (8), .BR hdparm (8), .BR setserial (8), .BR tunelp (8), .BR loadkeys (1), .BR gpm (8), .BR 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. .SH "SEE ALSO" .BR kbd_mode (1), .BR loadkeys (1), .BR dumpkeys (1), .BR mknod (1), .BR setleds (1), .BR setmetamode (1), .BR ioperm (2), .BR termios (2), .BR execve (2), .BR fcntl (2), .BR mt (4), .BR sd (4), .BR tty (4), .BR ttys (4), .BR vcs (4), .BR vcsa (4), .BR mapscrn (8), .BR consolechars (8), .BR resizecons (8), .IR /usr/include/linux/kd.h , .IR /usr/include/linux/vt.h .