1 .\" Copyright (c) 1995 Jim Van Zandt <jrv@vanzandt.mv.com> and aeb
2 .\" Sun Feb 26 11:46:23 MET 1995
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 .\" GNU General Public License for more details.
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, write to the Free
21 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
24 .\" Modified, Sun Feb 26 15:04:20 1995, faith@cs.unc.edu
25 .\" Modified, Thu Apr 20 22:08:17 1995, jrv@vanzandt.mv.com
26 .\" Modified, Mon Sep 18 22:32:47 1995, hpa@storm.net (H. Peter Anvin)
27 .\" FIXME The following are not documented:
28 .\" KDFONTOP (since 2.1.111)
29 .\" KDGKBDIACRUC (since 2.6.24)
31 .\" KDSKBDIACRUC (since 2.6.24)
32 .\" KDKBDREP (since 2.1.113)
33 .\" KDMAPDISP (not implemented as at 2.6.27)
34 .\" KDUNMAPDISP (not implemented as at 2.6.27)
35 .\" VT_LOCKSWITCH (since 1.3.47, needs CAP_SYS_TTY_CONFIG)
36 .\" VT_UNLOCKSWITCH (since 1.3.47, needs CAP_SYS_TTY_CONFIG)
37 .\" VT_GETHIFONTMASK (since 2.6.18)
39 .TH CONSOLE_IOCTL 4 2009-02-28 "Linux" "Linux Programmer's Manual"
41 console_ioctl \- ioctl's for console terminal and virtual consoles
43 The following Linux-specific
45 requests are supported.
46 Each requires a third argument, assumed here to be \fIargp\fP.
49 \fIargp\fP points to a \fIchar\fP.
51 of \fI*argp\fP are set to the state of the LEDs, as follows:
53 LED_CAP 0x04 caps lock led
54 LEC_NUM 0x02 num lock led
55 LED_SCR 0x01 scroll lock led
58 The LEDs are set to correspond to the lower three bits of
60 However, if a higher order bit is set,
61 the LEDs revert to normal: displaying the state of the
62 keyboard functions of caps lock, num lock, and scroll lock.
64 Before 1.1.54, the LEDs just reflected the state of the corresponding
65 keyboard flags, and KDGETLED/KDSETLED would also change the keyboard
67 Since 1.1.54 the leds can be made to display arbitrary
68 information, but by default they display the keyboard flags.
69 The following two ioctl's are used to access the keyboard flags.
71 Get keyboard flags CapsLock, NumLock, ScrollLock (not lights).
72 \fIargp\fP points to a char which is set to the flag state.
73 The low order three bits (mask 0x7) get the current flag state,
74 and the low order bits of the next nibble (mask 0x70) get
75 the default flag state.
78 Set keyboard flags CapsLock, NumLock, ScrollLock (not lights).
79 \fIargp\fP has the desired flag state.
80 The low order three bits (mask 0x7) have the flag state,
81 and the low order bits of the next nibble (mask 0x70) have
82 the default flag state.
86 This returns the value KB_101, defined as 0x02.
88 Add I/O port as valid.
89 Equivalent to \fIioperm(arg,1,1)\fP.
91 Delete I/O port as valid.
92 Equivalent to \fIioperm(arg,1,0)\fP.
94 Enable I/O to video board.
95 Equivalent to \fIioperm(0x3b4, 0x3df-0x3b4+1, 1)\fP.
97 Disable I/O to video board.
98 Equivalent to \fIioperm(0x3b4, 0x3df-0x3b4+1, 0)\fP.
100 Set text/graphics mode.
101 \fIargp\fP is one of these:
106 Get text/graphics mode.
107 \fIargp\fP points to a \fIlong\fP which is set to one
110 Generate tone of specified length.
111 The lower 16 bits of \fIargp\fP specify the period in clock cycles,
112 and the upper 16 bits give the duration in msec.
113 If the duration is zero, the sound is turned off.
114 Control returns immediately.
115 For example, \fIargp\fP = (125<<16) + 0x637 would specify
116 the beep normally associated with a ctrl-G.
117 (Thus since 0.99pl1; broken in 2.1.49-50.)
119 Start or stop sound generation.
121 \fIargp\fP specify the period in clock cycles
122 (that is, \fIargp\fP = 1193180/frequency).
123 \fIargp\fP = 0 turns sound off.
124 In either case, control returns immediately.
126 Get the current default color map from kernel.
131 Change the default text-mode color map.
132 \fIargp\fP points to a
133 48-byte array which contains, in order, the Red, Green, and Blue
134 values for the 16 available screen colors: 0 is off, and 255 is full
136 The default colors are, in order: black, dark red, dark
137 green, brown, dark blue, dark purple, dark cyan, light grey, dark
138 grey, bright red, bright green, yellow, bright blue, bright purple,
139 bright cyan and white.
142 Gets 256-character screen font in expanded form.
143 \fIargp\fP points to an 8192 byte array.
144 Fails with error code \fBEINVAL\fP if the
145 currently loaded font is a 512-character font, or if the console is
148 Gets screen font and associated information.
149 \fIargp\fP points to a
150 \fIstruct consolefontdesc\fP (see \fBPIO_FONTX\fP).
152 \fIcharcount\fP field should be set to the maximum number of
153 characters that would fit in the buffer pointed to by \fIchardata\fP.
154 On return, the \fIcharcount\fP and \fIcharheight\fP are filled with
155 the respective data for the currently loaded font, and the
156 \fIchardata\fP array contains the font data if the initial value of
157 \fIcharcount\fP indicated enough space was available; otherwise the
158 buffer is untouched and \fIerrno\fP is set to \fBENOMEM\fP.
161 Sets 256-character screen font.
162 Load font into the EGA/VGA character
164 \fIargp\fP points to a 8192 byte map, with 32 bytes per
166 Only first \fIN\fP of them are used for an 8x\fIN\fP font
168 This call also invalidates the Unicode mapping.
170 Sets screen font and associated rendering information.
176 struct consolefontdesc {
177 unsigned short charcount; /* characters in font
179 unsigned short charheight; /* scan lines per
181 char *chardata; /* font data in
187 If necessary, the screen will be appropriately resized, and
188 \fBSIGWINCH\fP sent to the appropriate processes.
189 This call also invalidates the Unicode mapping.
191 .IP \fBPIO_FONTRESET\fP
192 Resets the screen font, size and Unicode mapping to the bootup
194 \fIargp\fP is unused, but should be set to NULL to
195 ensure compatibility with future versions of Linux.
197 .IP \fBGIO_SCRNMAP\fP
198 Get screen mapping from kernel.
199 \fIargp\fP points to an area of size
200 E_TABSZ, which is loaded with the font positions used to display each
202 This call is likely to return useless information if the
203 currently loaded font is more than 256 characters.
204 .IP \fBGIO_UNISCRNMAP\fP
205 Get full Unicode screen mapping from kernel.
206 \fIargp\fP points to an
207 area of size E_TABSZ*sizeof(unsigned short), which is loaded with the
208 Unicodes each character represent.
209 A special set of Unicodes,
210 starting at U+F000, are used to represent "direct to font" mappings.
212 .IP \fBPIO_SCRNMAP\fP
213 Loads the "user definable" (fourth) table in the kernel which maps
214 bytes into console screen symbols.
215 \fIargp\fP points to an area of
217 .IP \fBPIO_UNISCRNMAP\fP
218 Loads the "user definable" (fourth) table in the kernel which maps
219 bytes into Unicodes, which are then translated into screen symbols
220 according to the currently loaded Unicode-to-font map.
221 Special Unicodes starting at U+F000 can be used to map directly to the font
225 Get Unicode-to-font mapping from kernel.
226 \fIargp\fP points to a
231 unsigned short entry_ct;
232 struct unipair *entries;
237 where \fIentries\fP points to an array of
242 unsigned short unicode;
243 unsigned short fontpos;
250 Put unicode-to-font mapping in kernel.
251 \fIargp\fP points to a
252 \fIstruct unimapdesc\fP.
254 .IP \fBPIO_UNIMAPCLR\fP
255 Clear table, possibly advise hash algorithm.
256 \fIargp\fP points to a
261 unsigned short advised_hashsize; /* 0 if no opinion */
262 unsigned short advised_hashstep; /* 0 if no opinion */
263 unsigned short advised_hashlevel; /* 0 if no opinion */
270 Gets current keyboard mode.
271 \fIargp\fP points to a \fIlong\fP which is set to one
279 Sets current keyboard mode.
280 \fIargp\fP is a \fIlong\fP equal to one of the above values.
282 Gets meta key handling mode.
283 \fIargp\fP points to a \fIlong\fP which is
286 K_METABIT 0x03 set high order bit
287 K_ESCPREFIX 0x04 escape prefix
289 Sets meta key handling mode.
290 \fIargp\fP is a \fIlong\fP equal to one of the above values.
292 Gets one entry in key translation table (keycode to action code).
293 \fIargp\fP points to a
298 unsigned char kb_table;
299 unsigned char kb_index;
300 unsigned short kb_value;
305 with the first two members filled in:
306 \fIkb_table\fP selects the key table (0 <= \fIkb_table\fP < MAX_NR_KEYMAPS),
307 and \fIkb_index\fP is the keycode (0 <= \fIkb_index\fP < NR_KEYS).
308 \fIkb_value\fP is set to the corresponding action code,
309 or K_HOLE if there is no such key,
310 or K_NOSUCHMAP if \fIkb_table\fP is invalid.
312 Sets one entry in translation table.
314 a \fIstruct kbentry\fP.
316 Gets one function key string.
317 \fIargp\fP points to a
322 unsigned char kb_func;
323 unsigned char kb_string[512];
328 \fIkb_string\fP is set to the (null-terminated) string corresponding to
329 the \fIkb_func\fPth function key action code.
331 Sets one function key string entry.
333 a \fIstruct kbsentry\fP.
335 Read kernel accent table.
336 \fIargp\fP points to a
342 struct kbdiacr kbdiacr[256];
347 where \fIkb_cnt\fP is the number of entries in the array, each of which
355 unsigned char result;
359 .IP \fBKDGETKEYCODE\fP
360 Read kernel keycode table entry (scan code to keycode).
361 \fIargp\fP points to a
366 unsigned int scancode;
367 unsigned int keycode;
372 \fIkeycode\fP is set to correspond to the given \fIscancode\fP.
373 (89 <= \fIscancode\fP <= 255 only.
374 For 1 <= \fIscancode\fP <= 88, \fIkeycode\fP==\fIscancode\fP.)
376 .IP \fBKDSETKEYCODE\fP
377 Write kernel keycode table entry.
379 a \fIstruct kbkeycode\fP.
381 .IP \fBKDSIGACCEPT\fP
382 The calling process indicates its willingness to accept the signal
383 \fIargp\fP when it is generated by pressing an appropriate key combination.
384 (1 <= \fIargp\fP <= NSIG).
385 (See spawn_console() in linux/drivers/char/keyboard.c.)
387 Returns the first available (non-opened) console.
388 \fIargp\fP points to an \fIint\fP which is set to the
389 number of the vt (1 <= \fI*argp\fP <= MAX_NR_CONSOLES).
391 Get mode of active vt.
392 \fIargp\fP points to a
397 char mode; /* vt mode */
398 char waitv; /* if set, hang on writes if not active */
399 short relsig; /* signal to raise on release req */
400 short acqsig; /* signal to raise on acquisition */
401 short frsig; /* unused (set to 0) */
406 which is set to the mode of the active vt.
407 \fImode\fP is set to one of these values:
409 VT_AUTO auto vt switching
410 VT_PROCESS process controls switching
411 VT_ACKACQ acknowledge switch
413 Set mode of active vt.
415 a \fIstruct vt_mode\fP.
416 .IP \fBVT_GETSTATE\fP
417 Get global vt state info.
418 \fIargp\fP points to a
423 unsigned short v_active; /* active vt */
424 unsigned short v_signal; /* signal to send */
425 unsigned short v_state; /* vt bit mask */
430 For each vt in use, the corresponding bit in the \fIv_state\fP member is set.
431 (Kernels 1.0 through 1.1.92.)
434 .IP \fBVT_ACTIVATE\fP
435 Switch to vt \fIargp\fP (1 <= \fIargp\fP <= MAX_NR_CONSOLES).
436 .IP \fBVT_WAITACTIVE\fP
437 Wait until vt \fIargp\fP has been activated.
438 .IP \fBVT_DISALLOCATE\fP
439 Deallocate the memory associated with vt \fIargp\fP.
442 Set the kernel's idea of screensize.
443 \fIargp\fP points to a
448 unsigned short v_rows; /* # rows */
449 unsigned short v_cols; /* # columns */
450 unsigned short v_scrollsize; /* no longer used */
455 Note that this does not change the videomode.
460 Set the kernel's idea of various screen parameters.
461 \fIargp\fP points to a
466 unsigned short v_rows; /* number of rows */
467 unsigned short v_cols; /* number of columns */
468 unsigned short v_vlin; /* number of pixel rows
470 unsigned short v_clin; /* number of pixel rows
472 unsigned short v_vcol; /* number of pixel columns
474 unsigned short v_ccol; /* number of pixel columns
480 Any parameter may be set to zero, indicating "no change", but if
481 multiple parameters are set, they must be self-consistent.
482 Note that this does not change the videomode.
487 The action of the following ioctls depends on the first byte in the struct
488 pointed to by \fIargp\fP, referred to here as the \fIsubcode\fP.
489 These are legal only for the superuser or the owner of the current tty.
490 .IP "\fBTIOCLINUX, subcode=0\fP"
492 Disappeared in 1.1.92. (With kernel 1.1.92 or later, read from
493 /dev/vcsN or /dev/vcsaN instead.)
494 .IP "\fBTIOCLINUX, subcode=1\fP"
495 Get task information.
496 Disappeared in 1.1.92.
497 .IP "\fBTIOCLINUX, subcode=2\fP"
499 \fIargp\fP points to a
505 short xs, ys, xe, ye;
511 \fIxs\fP and \fIys\fP are the starting column and row.
512 \fIxe\fP and \fIye\fP are the ending
514 (Upper left corner is row=column=1.)
515 \fIsel_mode\fP is 0 for character-by-character selection,
516 1 for word-by-word selection,
517 or 2 for line-by-line selection.
518 The indicated screen characters are highlighted and saved
519 in the static array sel_buffer in devices/char/console.c.
520 .IP "\fBTIOCLINUX, subcode=3\fP"
522 The characters in the selection buffer are
524 .IP "\fBTIOCLINUX, subcode=4\fP"
526 .IP "\fBTIOCLINUX, subcode=5\fP"
527 Sets contents of a 256-bit look up table defining characters in a "word",
528 for word-by-word selection.
530 .IP "\fBTIOCLINUX, subcode=6\fP"
531 \fIargp\fP points to a char which is set to the value of the kernel
532 variable \fIshift_state\fP.
534 .IP "\fBTIOCLINUX, subcode=7\fP"
535 \fIargp\fP points to a char which is set to the value of the kernel
536 variable \fIreport_mouse\fP.
538 .IP "\fBTIOCLINUX, subcode=8\fP"
539 Dump screen width and height, cursor position, and all the
540 character-attribute pairs.
541 (Kernels 1.1.67 through 1.1.91 only.
542 With kernel 1.1.92 or later, read from /dev/vcsa* instead.)
543 .IP "\fBTIOCLINUX, subcode=9\fP"
544 Restore screen width and height, cursor position, and all the
545 character-attribute pairs.
546 (Kernels 1.1.67 through 1.1.91 only.
547 With kernel 1.1.92 or later, write to /dev/vcsa* instead.)
548 .IP "\fBTIOCLINUX, subcode=10\fP"
549 Handles the Power Saving
550 feature of the new generation of monitors.
551 VESA screen blanking mode is set to \fIargp\fP[1], which governs what
552 screen blanking does:
554 \fI0\fP: Screen blanking is disabled.
556 \fI1\fP: The current video adapter
557 register settings are saved, then the controller is programmed to turn off
558 the vertical synchronization pulses.
559 This puts the monitor into "standby" mode.
560 If your monitor has an Off_Mode timer, then
561 it will eventually power down by itself.
564 settings are saved, then both the vertical and horizontal
565 synchronization pulses are turned off.
566 This puts the monitor into "off" mode.
567 If your monitor has no Off_Mode timer,
568 or if you want your monitor to power down immediately when the
569 blank_timer times out, then you choose this option.
570 (\fICaution:\fP Powering down frequently will damage the monitor.)
574 On success, 0 is returned.
575 On error \-1 is returned, and \fIerrno\fP is set.
577 \fIerrno\fP may take on these values:
580 The file descriptor is invalid.
583 The file descriptor is not associated with a character special device,
584 or the specified request does not apply to it.
587 The file descriptor or \fIargp\fP is invalid.
590 Insufficient permission.
593 Do not regard this man page as documentation of the Linux console ioctl's.
594 This is provided for the curious only, as an alternative to reading the
596 Ioctl's are undocumented Linux internals, liable to be changed
598 (And indeed, this page more or less describes the
599 situation as of kernel version 1.1.94;
600 there are many minor and not-so-minor
601 differences with earlier versions.)
603 Very often, ioctl's are introduced for communication between the
604 kernel and one particular well-known program (fdisk, hdparm, setserial,
605 tunelp, loadkeys, selection, setfont, etc.), and their behavior will be
606 changed when required by this particular program.
608 Programs using these ioctl's will not be portable to other versions
609 of UNIX, will not work on older versions of Linux, and will not work
610 on future versions of Linux.
625 .BR console_codes (4),
637 .IR /usr/include/linux/kd.h ,
638 .I /usr/include/linux/vt.h