1CONSOLE_IOCTLS(4) Linux Programmer's Manual CONSOLE_IOCTLS(4)
2
3
4
6 console ioctl - ioctl's for console terminal and virtual consoles
7
9 The following Linux-specific ioctl() requests are supported. Each
10 requires a third argument, assumed here to be argp.
11
12 KDGETLED
13 Get state of LEDs. argp points to a long int. The lower three
14 bits of *argp are set to the state of the LEDs, as follows:
15
16 LED_CAP 0x04 caps lock led
17 LEC_NUM 0x02 num lock led
18 LED_SCR 0x01 scroll lock led
19
20
21 KDSETLED
22 Set the LEDs. The LEDs are set to correspond to the lower three
23 bits of argp. However, if a higher order bit is set, the LEDs
24 revert to normal: displaying the state of the keyboard functions
25 of caps lock, num lock, and scroll lock.
26
27 Before 1.1.54, the LEDs just reflected the state of the corresponding
28 keyboard flags, and KDGETLED/KDSETLED would also change the keyboard
29 flags. Since 1.1.54 the leds can be made to display arbitrary informa‐
30 tion, but by default they display the keyboard flags. The following
31 two ioctl's are used to access the keyboard flags.
32
33
34 KDGKBLED
35 Get keyboard flags CapsLock, NumLock, ScrollLock (not lights).
36 argp points to a char which is set to the flag state. The low
37 order three bits (mask 0x7) get the current flag state, and the
38 low order bits of the next nibble (mask 0x70) get the default
39 flag state. (Since 1.1.54.)
40
41
42 KDSKBLED
43 Set keyboard flags CapsLock, NumLock, ScrollLock (not lights).
44 argp has the desired flag state. The low order three bits (mask
45 0x7) have the flag state, and the low order bits of the next
46 nibble (mask 0x70) have the default flag state. (Since 1.1.54.)
47
48
49 KDGKBTYPE
50 Get keyboard type. This returns the value KB_101, defined as
51 0x02.
52
53
54 KDADDIO
55 Add I/O port as valid. Equivalent to ioperm(arg,1,1).
56
57
58 KDDELIO
59 Delete I/O port as valid. Equivalent to ioperm(arg,1,0).
60
61
62 KDENABIO
63 Enable I/O to video board. Equivalent to ioperm(0x3b4,
64 0x3df-0x3b4+1, 1).
65
66
67 KDDISABIO
68 Disable I/O to video board. Equivalent to ioperm(0x3b4,
69 0x3df-0x3b4+1, 0).
70
71
72 KDSETMODE
73 Set text/graphics mode. argp is one of these:
74
75 KD_TEXT 0x00
76 KD_GRAPHICS 0x01
77
78
79 KDGETMODE
80 Get text/graphics mode. argp points to a long which is set to
81 one of the above values.
82
83
84 KDMKTONE
85 Generate tone of specified length. The lower 16 bits of argp
86 specify the period in clock cycles, and the upper 16 bits give
87 the duration in msec. If the duration is zero, the sound is
88 turned off. Control returns immediately. For example, argp =
89 (125<<16) + 0x637 would specify the beep normally associated
90 with a ctrl-G. (Thus since 0.99pl1; broken in 2.1.49-50.)
91
92
93 KIOCSOUND
94 Start or stop sound generation. The lower 16 bits of argp spec‐
95 ify the period in clock cycles (that is, argp = 1193180/fre‐
96 quency). argp = 0 turns sound off. In either case, control
97 returns immediately.
98
99
100 GIO_CMAP
101 Get the current default colour map from kernel. argp points to
102 a 48-byte array. (Since 1.3.3.)
103
104
105 PIO_CMAP
106 Change the default text-mode colour map. argp points to a
107 48-byte array which contains, in order, the Red, Green, and Blue
108 values for the 16 available screen colours: 0 is off, and 255 is
109 full intensity. The default colours are, in order: black, dark
110 red, dark green, brown, dark blue, dark purple, dark cyan, light
111 grey, dark grey, bright red, bright green, yellow, bright blue,
112 bright purple, bright cyan and white. (Since 1.3.3.)
113
114
115 GIO_FONT
116 Gets 256-character screen font in expanded form. argp points to
117 an 8192 byte array. Fails with error code EINVAL if the cur‐
118 rently loaded font is a 512-character font, or if the console is
119 not in text mode.
120
121
122 GIO_FONTX
123 Gets screen font and associated information. argp points to a
124 struct consolefontdesc (see PIO_FONTX). On call, the charcount
125 field should be set to the maximum number of characters that
126 would fit in the buffer pointed to by chardata. On return, the
127 charcount and charheight are filled with the respective data for
128 the currently loaded font, and the chardata array contains the
129 font data if the initial value of charcount indicated enough
130 space was available; otherwise the buffer is untouched and errno
131 is set to ENOMEM. (Since 1.3.1.)
132
133
134 PIO_FONT
135 Sets 256-character screen font. Load font into the EGA/VGA
136 character generator. argp points to a 8192 byte map, with 32
137 bytes per character. Only first N of them are used for an 8xN
138 font (0 < N <= 32). This call also invalidates the Unicode map‐
139 ping.
140
141
142 PIO_FONTX
143 Sets screen font and associated rendering information. argp
144 points to a
145
146 struct consolefontdesc {
147 u_short charcount; /* characters in font (256 or 512) */
148 u_short charheight; /* scan lines per character (1-32) */
149 char *chardata; /* font data in expanded form */
150 };
151
152 If necessary, the screen will be appropriately resized, and SIG‐
153 WINCH sent to the appropriate processes. This call also invali‐
154 dates the Unicode mapping. (Since 1.3.1.)
155
156
157 PIO_FONTRESET
158 Resets the screen font, size and Unicode mapping to the bootup
159 defaults. argp is unused, but should be set to NULL to ensure
160 compatibility with future versions of Linux. (Since 1.3.28.)
161
162
163 GIO_SCRNMAP
164 Get screen mapping from kernel. argp points to an area of size
165 E_TABSZ, which is loaded with the font positions used to display
166 each character. This call is likely to return useless informa‐
167 tion if the currently loaded font is more than 256 characters.
168
169
170 GIO_UNISCRNMAP
171 Get full Unicode screen mapping from kernel. argp points to an
172 area of size E_TABSZ*sizeof(unsigned short), which is loaded
173 with the Unicodes each character represent. A special set of
174 Unicodes, starting at U+F000, are used to represent ``direct to
175 font'' mappings. (Since 1.3.1.)
176
177
178 PIO_SCRNMAP
179 Loads the ``user definable'' (fourth) table in the kernel which
180 maps bytes into console screen symbols. argp points to an area
181 of size E_TABSZ.
182
183
184 PIO_UNISCRNMAP
185 Loads the ``user definable'' (fourth) table in the kernel which
186 maps bytes into Unicodes, which are then translated into screen
187 symbols according to the currently loaded Unicode-to-font map.
188 Special Unicodes starting at U+F000 can be used to map directly
189 to the font symbols. (Since 1.3.1.)
190
191
192 GIO_UNIMAP
193 Get Unicode-to-font mapping from kernel. argp points to a
194
195 struct unimapdesc {
196 u_short entry_ct;
197 struct unipair *entries;
198 };
199
200 where entries points to an array of
201
202 struct unipair {
203 u_short unicode;
204 u_short fontpos;
205 };
206
207 (Since 1.1.92.)
208
209
210 PIO_UNIMAP
211 Put unicode-to-font mapping in kernel. argp points to a struct
212 unimapdesc. (Since 1.1.92)
213
214
215 PIO_UNIMAPCLR
216 Clear table, possibly advise hash algorithm. argp points to a
217
218 struct unimapinit {
219 u_short advised_hashsize; /* 0 if no opinion */
220 u_short advised_hashstep; /* 0 if no opinion */
221 u_short advised_hashlevel; /* 0 if no opinion */
222 };
223
224 (Since 1.1.92.)
225
226
227 KDGKBMODE
228 Gets current keyboard mode. argp points to a long which is set
229 to one of these:
230
231 K_RAW 0x00
232 K_XLATE 0x01
233 K_MEDIUMRAW 0x02
234 K_UNICODE 0x03
235
236
237 KDSKBMODE
238 Sets current keyboard mode. argp is a long equal to one of the
239 above values.
240
241
242 KDGKBMETA
243 Gets meta key handling mode. argp points to a long which is set
244 to one of these:
245
246 K_METABIT 0x03 set high order bit
247 K_ESCPREFIX 0x04 escape prefix
248
249
250 KDSKBMETA
251 Sets meta key handling mode. argp is a long equal to one of the
252 above values.
253
254
255 KDGKBENT
256 Gets one entry in key translation table (keycode to action
257 code). argp points to a
258
259 struct kbentry {
260 u_char kb_table;
261 u_char kb_index;
262 u_short kb_value;
263 };
264
265 with the first two members filled in: kb_table selects the key
266 table (0 <= kb_table < MAX_NR_KEYMAPS), and kb_index is the key‐
267 code (0 <= kb_index < NR_KEYS). kb_value is set to the corre‐
268 sponding action code, or K_HOLE if there is no such key, or
269 K_NOSUCHMAP if kb_table is invalid.
270
271
272 KDSKBENT
273 Sets one entry in translation table. argp points to a struct
274 kbentry.
275
276
277 KDGKBSENT
278 Gets one function key string. argp points to a
279
280 struct kbsentry {
281 u_char kb_func;
282 u_char kb_string[512];
283 };
284
285 kb_string is set to the (NULL terminated) string corresponding
286 to the kb_functh function key action code.
287
288
289 KDSKBSENT
290 Sets one function key string entry. argp points to a struct
291 kbsentry.
292
293
294 KDGKBDIACR
295 Read kernel accent table. argp points to a
296
297 struct kbdiacrs {
298 unsigned int kb_cnt;
299 struct kbdiacr kbdiacr[256];
300 };
301
302 where kb_cnt is the number of entries in the array, each of
303 which is a
304
305 struct kbdiacr { u_char diacr, base, result; };
306
307
308 KDGETKEYCODE
309 Read kernel keycode table entry (scan code to keycode). argp
310 points to a
311
312 struct kbkeycode { unsigned int scancode, keycode; };
313
314 keycode is set to correspond to the given scancode. (89 <=
315 scancode <= 255 only. For 1 <= scancode <= 88, keycode==scan‐
316 code.) (Since 1.1.63.)
317
318
319 KDSETKEYCODE
320 Write kernel keycode table entry. argp points to struct kbkey‐
321 code. (Since 1.1.63.)
322
323
324 KDSIGACCEPT
325 The calling process indicates its willingness to accept the sig‐
326 nal argp when it is generated by pressing an appropriate key
327 combination. (1 <= argp <= NSIG). (See spawn_console() in
328 linux/drivers/char/keyboard.c.)
329
330
331 VT_OPENQRY
332 Returns the first available (non-opened) console. argp points
333 to an int which is set to the number of the vt (1 <= *argp <=
334 MAX_NR_CONSOLES).
335
336
337 VT_GETMODE
338 Get mode of active vt. argp points to a
339
340 struct vt_mode {
341 char mode; /* vt mode */
342 char waitv; /* if set, hang on writes if not active */
343 short relsig; /* signal to raise on release req */
344 short acqsig; /* signal to raise on acquisition */
345 short frsig; /* unused (set to 0) */
346 };
347
348 ...which is set to the mode of the active vt. mode is set to
349 one of these values:
350
351 VT_AUTO auto vt switching
352 VT_PROCESS process controls switching
353 VT_ACKACQ acknowledge switch
354
355
356 VT_SETMODE
357 Set mode of active vt. argp points to a struct vt_mode.
358
359
360 VT_GETSTATE
361 Get global vt state info. argp points to a
362
363 struct vt_stat {
364 ushort v_active; /* active vt */
365 ushort v_signal; /* signal to send */
366 ushort v_state; /* vt bitmask */
367 };
368
369 For each vt in use, the corresponding bit in the v_state member
370 is set. (Kernels 1.0 through 1.1.92.)
371
372
373 VT_RELDISP
374 Release a display.
375
376
377 VT_ACTIVATE
378 Switch to vt argp (1 <= argp <= MAX_NR_CONSOLES).
379
380
381 VT_WAITACTIVE
382 Wait until vt argp has been activated.
383
384
385 VT_DISALLOCATE
386 Deallocate the memory associated with vt argp. (Since 1.1.54.)
387
388
389 VT_RESIZE
390 Set the kernel's idea of screensize. argp points to a
391
392 struct vt_sizes {
393 ushort v_rows; /* # rows */
394 ushort v_cols; /* # columns */
395 ushort v_scrollsize; /* no longer used */
396 };
397
398 Note that this does not change the videomode. See resize‐
399 cons(8). (Since 1.1.54.)
400
401
402 VT_RESIZEX
403 Set the kernel's idea of various screen parameters. argp points
404 to a
405
406 struct vt_consize {
407 ushort v_rows; /* number of rows */
408 ushort v_cols; /* number of columns */
409 ushort v_vlin; /* number of pixel rows on screen */
410 ushort v_clin; /* number of pixel rows per character */
411 ushort v_vcol; /* number of pixel columns on screen */
412 ushort v_ccol; /* number of pixel columns per character */
413 };
414
415 Any parameter may be set to zero, indicating ``no change'', but
416 if multiple parameters are set, they must be self-consistent.
417 Note that this does not change the videomode. See resize‐
418 cons(8). (Since 1.3.3.)
419
420
421 The action of the following ioctls depends on the first byte in the
422 struct pointed to by argp, referred to here as the subcode. These are
423 legal only for the superuser or the owner of the current tty.
424
425 TIOCLINUX, subcode=0
426 Dump the screen. Disappeared in 1.1.92. (With kernel 1.1.92 or
427 later, read from /dev/vcsN or /dev/vcsaN instead.)
428
429
430 TIOCLINUX, subcode=1
431 Get task information. Disappeared in 1.1.92.
432
433
434 TIOCLINUX, subcode=2
435 Set selection. argp points to a
436
437 struct {char subcode;
438 short xs, ys, xe, ye;
439 short sel_mode;
440 }
441
442 xs and ys are the starting column and row. xe and ye are the
443 ending column and row. (Upper left corner is row=column=1.)
444 sel_mode is 0 for character-by-character selection, 1 for word-
445 by-word selection, or 2 for line-by-line selection. The indi‐
446 cated screen characters are highlighted and saved in the static
447 array sel_buffer in devices/char/console.c.
448
449
450 TIOCLINUX, subcode=3
451 Paste selection. The characters in the selection buffer are
452 written to fd.
453
454
455 TIOCLINUX, subcode=4
456 Unblank the screen.
457
458
459 TIOCLINUX, subcode=5
460 Sets contents of a 256-bit look up table defining characters in
461 a "word", for word-by-word selection. (Since 1.1.32.)
462
463
464 TIOCLINUX, subcode=6
465 argp points to a char which is set to the value of the kernel
466 variable shift_state. (Since 1.1.32.)
467
468
469 TIOCLINUX, subcode=7
470 argp points to a char which is set to the value of the kernel
471 variable report_mouse. (Since 1.1.33.)
472
473
474 TIOCLINUX, subcode=8
475 Dump screen width and height, cursor position, and all the char‐
476 acter-attribute pairs. (Kernels 1.1.67 through 1.1.91 only.
477 With kernel 1.1.92 or later, read from /dev/vcsa* instead.)
478
479
480 TIOCLINUX, subcode=9
481 Restore screen width and height, cursor position, and all the
482 character-attribute pairs. (Kernels 1.1.67 through 1.1.91 only.
483 With kernel 1.1.92 or later, write to /dev/vcsa* instead.)
484
485
486 TIOCLINUX, subcode=10
487 Handles the Power Saving feature of the new generation of moni‐
488 tors. VESA screen blanking mode is set to argp[1], which gov‐
489 erns what screen blanking does:
490
491 0: Screen blanking is disabled.
492
493 1: The current video adapter register settings are saved,
494 then the controller is programmed to turn off the vertical syn‐
495 chronization pulses. This puts the monitor into "standby" mode.
496 If your monitor has an Off_Mode timer, then it will eventually
497 power down by itself.
498
499 2: The current settings are saved, then both the vertical
500 and horizontal synchronization pulses are turned off. This puts
501 the monitor into "off" mode. If your monitor has no Off_Mode
502 timer, or if you want your monitor to power down immediately
503 when the blank_timer times out, then you choose this option.
504 (Caution: Powering down frequently will damage the monitor.)
505
506 (Since 1.1.76.)
507
508
510 On success, 0 is returned. On error -1 is returned, and errno is set.
511
513 errno may take on these values:
514
515
516 EBADF The file descriptor is invalid.
517
518 ENOTTY The file descriptor is not associated with a character special
519 device, or the specified request does not apply to it.
520
521 EINVAL The file descriptor or argp is invalid.
522
523 EPERM Insufficient permission.
524
526 Do not regard this man page as documentation of the Linux console
527 ioctl's. This is provided for the curious only, as an alternative to
528 reading the source. Ioctl's are undocumented Linux internals, liable to
529 be changed without warning. (And indeed, this page more or less
530 describes the situation as of kernel version 1.1.94; there are many
531 minor and not-so-minor differences with earlier versions.)
532
533 Very often, ioctl's are introduced for communication between the kernel
534 and one particular well-known program (fdisk, hdparm, setserial,
535 tunelp, loadkeys, selection, setfont, etc.), and their behavior will be
536 changed when required by this particular program.
537
538 Programs using these ioctl's will not be portable to other versions of
539 Unix, will not work on older versions of Linux, and will not work on
540 future versions of Linux.
541
542 Use POSIX functions.
543
544
546 dumpkeys(1), kbd_mode(1), loadkeys(1), mknod(1), setleds(1), setmeta‐
547 mode(1), execve(2), fcntl(2), ioperm(2), termios(3), console(4), con‐
548 sole_codes(4), mt(4), sd(4), tty(4), tty_ioctl(4), ttyS(4), vcs(4),
549 vcsa(4), charsets(7), mapscrn(8), resizecons(8), setfont(8),
550 /usr/include/linux/kd.h, /usr/include/linux/vt.h
551
552
553
554Linux 1995-09-18 CONSOLE_IOCTLS(4)