Penguin
Blame: console_ioctl(4)
EditPageHistoryDiffInfoLikePages
Annotated edit history of console_ioctl(4) version 4, including all changes. View license author blame.
Rev Author # Line
1 perry 1 CONSOLE_IOCTLS
2 !!!CONSOLE_IOCTLS
3 NAME
4 DESCRIPTION
5 RETURN VALUE
6 ERRORS
7 WARNING
8 SEE ALSO
9 ----
10 !!NAME
11
12
13 console ioctl - ioctl's for console terminal and virtual consoles
14 !!DESCRIPTION
15
16
17 __WARNING: If you use the following information you are
18 going to burn yourself.__
19
20
21 __WARNING: ioctl's are undocumented Linux internals, liable
22 to be changed without warning. Use POSIX
23 functions.__
24
25
26 The following Linux-peculiar __ioctl()__ requests are
27 supported. Each requires a third argument, assumed here to
28 be ''argp''.
29
30
31 __KDGETLED__
32
33
34 Get state of LEDs. ''argp'' points to a long int. The
35 lower three bits of ''*argp'' are set to the state of the
36 LEDs, as follows:
37
38
39 LED_CAP 0x04 caps lock led LEC_NUM 0x02 num lock led LED_SCR
40 0x01 scroll lock led
41
42
43 __KDSETLED__
44
45
46 Set the LEDs. The LEDs are set to correspond to the lower
47 three bits of ''argp''. However, if a higher order bit is
48 set, the LEDs revert to normal: displaying the state of the
49 keyboard functions of caps lock, num lock, and scroll
50 lock.
51
52
53 Before 1.1.54, the LEDs just reflected the state of the
54 corresponding keyboard flags, and KDGETLED/KDSETLED would
55 also change the keyboard flags. Since 1.1.54 the leds can be
56 made to display arbitrary information, but by default they
57 display the keyboard flags. The following two ioctl's are
58 used to access the keyboard flags.
59
60
61 __KDGKBLED__
62
63
3 perry 64 Get keyboard flags !CapsLock, !NumLock, !ScrollLock (not
1 perry 65 lights). ''argp'' points to a char which is set to the
66 flag state. The low order three bits (mask 0x7) get the
67 current flag state, and the low order bits of the next
68 nibble (mask 0x70) get the default flag state. (Since
69 1.1.54.)
70
71
72 __KDSKBLED__
73
74
3 perry 75 Set keyboard flags !CapsLock, !NumLock, !ScrollLock (not
1 perry 76 lights). ''argp'' has the desired flag state. The low
77 order three bits (mask 0x7) have the flag state, and the low
78 order bits of the next nibble (mask 0x70) have the default
79 flag state. (Since 1.1.54.)
80
81
82 __KDGKBTYPE__
83
84
85 Get keyboard type. This returns the value KB_101, defined as
86 0x02.
87
88
89 __KDADDIO__
90
91
92 Add I/O port as valid. Equivalent to
93 ioperm(arg,1,1).
94
95
96 __KDDELIO__
97
98
99 Delete I/O port as valid. Equivalent to
100 ioperm(arg,1,0).
101
102
103 __KDENABIO__
104
105
106 Enable I/O to video board. Equivalent to ioperm(0x3b4,
107 0x3df-0x3b4+1, 1).
108
109
110 __KDDISABIO__
111
112
113 Disable I/O to video board. Equivalent to ioperm(0x3b4,
114 0x3df-0x3b4+1, 0).
115
116
117 __KDSETMODE__
118
119
120 Set text/graphics mode. ''argp'' is one of
121 these:
122
123
124 KD_TEXT 0x00 KD_GRAPHICS 0x01
125
126
127 __KDGETMODE__
128
129
130 Get text/graphics mode. ''argp'' points to a long which
131 is set to one of the above values.
132
133
134 __KDMKTONE__
135
136
137 Generate tone of specified length. The lower 16 bits of
138 ''argp'' specify the period in clock cycles, and the
139 upper 16 bits give the duration in msec. If the duration is
140 zero, the sound is turned off. Control returns immediately.
141 For example, ''argp'' = (125
142 ''
143
144
145 __KIOCSOUND__
146
147
148 Start or stop sound generation. The lower 16 bits of
149 ''argp'' specify the period in clock cycles (that is,
150 ''argp'' = 1193180/frequency). ''argp'' = 0 turns
151 sound off. In either case, control returns
152 immediately.
153
154
155 __GIO_CMAP__
156
157
158 Get the current default colour map from kernel. ''argp''
159 points to a 48-byte array. (Since 1.3.3.)
160
161
162 __PIO_CMAP__
163
164
165 Change the default text-mode colour map. ''argp'' points
166 to a 48-byte array which contains, in order, the Red, Green,
167 and Blue values for the 16 available screen colours: 0 is
168 off, and 255 is full intensity. The default colours are, in
169 order: black, dark red, dark green, brown, dark blue, dark
170 purple, dark cyan, light grey, dark grey, bright red, bright
171 green, yellow, bright blue, bright purple, bright cyan and
172 white. (Since 1.3.3.)
173
174
175 __GIO_FONT__
176
177
178 Gets 256-character screen font in expanded form. ''argp''
179 points to an 8192 byte array. Fails with error code
180 __EINVAL__ if the currently loaded font is a
181 512-character font, or if the console is not in text
182 mode.
183
184
185 __GIO_FONTX__
186
187
188 Gets screen font and associated information. ''argp''
189 points to a struct consolefontdesc (see __PIO_FONTX__).
190 On call, the ''charcount'' field should be set to the
191 maximum number of characters that would fit in the buffer
192 pointed to by ''chardata''. On return, the
193 ''charcount'' and ''charheight'' are filled with the
194 respective data for the currently loaded font, and the
195 ''chardata'' array contains the font data if the initial
196 value of ''charcount'' indicated enough space was
197 available; otherwise the buffer is untouched and
198 ''errno'' is set to __ENOMEM__. (Since
199 1.3.1.)
200
201
202 __PIO_FONT__
203
204
205 Sets 256-character screen font. Load font into the EGA/VGA
206 character generator. ''argp'' points to a 8192 byte map,
207 with 32 bytes per character. Only first ''N'' of them are
208 used for an 8x''N'' font (0 ''N''
209 ''
210
211
212 __PIO_FONTX__
213
214
215 Sets screen font and associated rendering information.
216 ''argp'' points to a
217
218
219 struct consolefontdesc {
220 u_short ''charcount''; /* characters in font (256 or 512) */
221 u_short ''charheight''; /* scan lines per character (1-32) */
222 char *''chardata''; /* font data in expanded form */
223 };
224 If necessary, the screen will be appropriately resized, and __SIGWINCH__ sent to the appropriate processes. This call also invalidates the Unicode mapping. (Since 1.3.1.)
225
226
227 __PIO_FONTRESET__
228
229
230 Resets the screen font, size and Unicode mapping to the
231 bootup defaults. ''argp'' is unused, but should be set to
232 __NULL__ to ensure compatibility with future versions of
233 Linux. (Since 1.3.28.)
234
235
236 __GIO_SCRNMAP__
237
238
239 Get screen mapping from kernel. ''argp'' points to an
240 area of size E_TABSZ, which is loaded with the font
241 positions used to display each character. This call is
242 likely to return useless information if the currently loaded
243 font is more than 256 characters.
244
245
246 __GIO_UNISCRNMAP__
247
248
249 Get full Unicode screen mapping from kernel. ''argp''
250 points to an area of size E_TABSZ*sizeof(unsigned short),
251 which is loaded with the Unicodes each character represent.
252 A special set of Unicodes, starting at U+F000, are used to
253 represent ``direct to font'' mappings. (Since
254 1.3.1.)
255
256
257 __PIO_SCRNMAP__
258
259
260 Loads the ``user definable'' (fourth) table in the kernel
261 which maps bytes into console screen symbols. ''argp''
262 points to an area of size E_TABSZ.
263
264
265 __PIO_UNISCRNMAP__
266
267
268 Loads the ``user definable'' (fourth) table in the kernel
269 which maps bytes into Unicodes, which are then translated
270 into screen symbols according to the currently loaded
271 Unicode-to-font map. Special Unicodes starting at U+F000 can
272 be used to map directly to the font symbols. (Since
273 1.3.1.)
274
275
276 __GIO_UNIMAP__
277
278
279 Get Unicode-to-font mapping from kernel. ''argp'' points
280 to a
281
282
283 struct unimapdesc {
284 u_short ''entry_ct'';
285 struct unipair *''entries'';
286 };
287 where ''entries'' points to an array of
288
289
290 struct unipair {
291 u_short ''unicode'';
292 u_short ''fontpos'';
293 };
294 (Since 1.1.92.)
295
296
297 __PIO_UNIMAP__
298
299
300 Put unicode-to-font mapping in kernel. ''argp'' points to
301 a struct unimapdesc. (Since 1.1.92)
302
303
304 __PIO_UNIMAPCLR__
305
306
307 Clear table, possibly advise hash algorithm. ''argp''
308 points to a
309
310
311 struct unimapinit {
312 u_short ''advised_hashsize''; /* 0 if no opinion */
313 u_short ''advised_hashstep''; /* 0 if no opinion */
314 u_short ''advised_hashlevel''; /* 0 if no opinion */
315 };
316 (Since 1.1.92.)
317
318
319 __KDGKBMODE__
320
321
322 Gets current keyboard mode. ''argp'' points to a long
323 which is set to one of these:
324
325
326 K_RAW 0x00 K_XLATE 0x01 K_MEDIUMRAW 0x02 K_UNICODE
327 0x03
328
329
330 __KDSKBMODE__
331
332
333 Sets current keyboard mode. ''argp'' is a long equal to
334 one of the above values.
335
336
337 __KDGKBMETA__
338
339
340 Gets meta key handling mode. ''argp'' points to a long
341 which is set to one of these:
342
343
344 K_METABIT 0x03 set high order bit K_ESCPREFIX 0x04 escape
345 prefix
346
347
348 __KDSKBMETA__
349
350
351 Sets meta key handling mode. ''argp'' is a long equal to
352 one of the above values.
353
354
355 __KDGKBENT__
356
357
358 Gets one entry in key translation table (keycode to action
359 code). ''argp'' points to a
360
361
362 struct kbentry {
363 u_char ''kb_table'';
364 u_char ''kb_index'';
365 u_short ''kb_value'';
366 };
367 with the first two members filled in: ''kb_table'' selects the key table (0 ''kb_table'' ''kb_index'' is the keycode (0 ''kb_index'' ''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.
368
369
370 __KDSKBENT__
371
372
373 Sets one entry in translation table. ''argp'' points to a
374 struct kbentry.
375
376
377 __KDGKBSENT__
378
379
380 Gets one function key string. ''argp'' points to
381 a
382
383
384 struct kbsentry {
385 u_char ''kb_func'';
386 u_char ''kb_string''[[512];
387 };
388 ''kb_string'' is set to the (NULL terminated) string corresponding to the ''kb_func''th function key action code.
389
390
391 __KDSKBSENT__
392
393
394 Sets one function key string entry. ''argp'' points to a
395 struct kbsentry.
396
397
398 __KDGKBDIACR__
399
400
401 Read kernel accent table. ''argp'' points to
402 a
403
404
405 struct kbdiacrs {
406 unsigned int ''kb_cnt'';
407 struct kbdiacr ''kbdiacr''[[256];
408 };
409 where ''kb_cnt'' is the number of entries in the array, each of which is a
410
411
412 struct kbdiacr { u_char ''diacr'', ''base'',
413 ''result''; };
414
415
416 __KDGETKEYCODE__
417
418
419 Read kernel keycode table entry (scan code to keycode).
420 ''argp'' points to a
421
422
423 struct kbkeycode { unsigned int ''scancode'', ''keycode''; };
424 ''keycode'' is set to correspond to the given ''scancode''. (89 ''scancode'' ''scancode'' ''keycode''==''scancode''.) (Since 1.1.63.)
425
426
427 __KDSETKEYCODE__
428
429
430 Write kernel keycode table entry. ''argp'' points to
431 struct kbkeycode. (Since 1.1.63.)
432
433
434 __KDSIGACCEPT__
435
436
437 The calling process indicates its willingness to accept the
438 signal ''argp'' when it is generated by pressing an
439 appropriate key combination. (1 ''argp''
440 ''
441
442
443 __VT_OPENQRY__
444
445
446 Returns the first available (non-opened) console.
447 ''argp'' points to an int which is set to the number of
448 the vt (1 ''*argp''
449 ''
450
451
452 __VT_GETMODE__
453
454
455 Get mode of active vt. ''argp'' points to a
456
457
458 struct vt_mode {
459 char ''mode''; /* vt mode */
460 char ''waitv''; /* if set, hang on writes if not active */
461 short ''relsig''; /* signal to raise on release req */
462 short ''acqsig''; /* signal to raise on acquisition */
463 short ''frsig''; /* unused (set to 0) */
464 };
465 ''mode'' is set to one of these values:
466
467
468 VT_AUTO auto vt switching VT_PROCESS process controls
469 switching VT_ACKACQ acknowledge switch
470
471
472 __VT_SETMODE__
473
474
475 Set mode of active vt. ''argp'' points to a struct
476 vt_mode.
477
478
479 __VT_GETSTATE__
480
481
482 Get global vt state info. ''argp'' points to
483 a
484
485
486 struct vt_stat {
487 ushort ''v_active''; /* active vt */
488 ushort ''v_signal''; /* signal to send */
489 ushort ''v_state''; /* vt bitmask */
490 };
491 For each vt in use, the corresponding bit in the ''v_state'' member is set. (Kernels 1.0 through 1.1.92.)
492
493
494 __VT_RELDISP__
495
496
497 Release a display.
498
499
500 __VT_ACTIVATE__
501
502
503 Switch to vt ''argp'' (1 ''argp''
504 ''
505
506
507 __VT_WAITACTIVE__
508
509
510 Wait until vt ''argp'' has been activated.
511
512
513 __VT_DISALLOCATE__
514
515
516 Deallocate the memory associated with vt ''argp''. (Since
517 1.1.54.)
518
519
520 __VT_RESIZE__
521
522
523 Set the kernel's idea of screensize. ''argp'' points to
524 a
525
526
527 struct vt_sizes {
528 ushort ''v_rows''; /* # rows */
529 ushort ''v_cols''; /* # columns */
530 ushort ''v_scrollsize''; /* no longer used */
531 };
532 Note that this does not change the videomode. See resizecons(8). (Since 1.1.54.)
533
534
535 __VT_RESIZEX__
536
537
538 Set the kernel's idea of various screen parameters.
539 ''argp'' points to a
540
541
542 struct vt_consize {
543 ushort ''v_rows''; /* number of rows */
544 ushort ''v_cols''; /* number of columns */
545 ushort ''v_vlin''; /* number of pixel rows on screen */
546 ushort ''v_clin''; /* number of pixel rows per character */
547 ushort ''v_vcol''; /* number of pixel columns on screen */
548 ushort ''v_ccol''; /* number of pixel columns per character */
549 };
550 Any parameter may be set to zero, indicating ``no change'', but if multiple parameters are set, they must be self-consistent. Note that this does not change the videomode. See resizecons(8). (Since 1.3.3.)
551
552
553 The action of the following ioctls depends on the first byte
554 in the struct pointed to by ''argp'', referred to here as
555 the ''subcode''. These are legal only for the superuser
556 or the owner of the current tty.
557
558
559 __TIOCLINUX, subcode=0__
560
561
562 Dump the screen. Disappeared in 1.1.92. (With kernel 1.1.92
563 or later, read from /dev/vcsN or /dev/vcsaN
564 instead.)
565
566
567 __TIOCLINUX, subcode=1__
568
569
570 Get task information. Disappeared in 1.1.92.
571
572
573 __TIOCLINUX, subcode=2__
574
575
576 Set selection. ''argp'' points to a
577
578
579 struct {char ''subcode''; short ''xs'', ''ys'',
580 ''xe'', ''ye''; short ''sel_mode''; }
581
582
583 ''xs'' and ''ys'' are the starting column and row.
584 ''xe'' and ''ye'' are the ending column and row.
585 (Upper left corner is row=column=1.) ''sel_mode'' is 0
586 for character-by-character selection, 1 for word-by-word
587 selection, or 2 for line-by-line selection. The indicated
588 screen characters are highlighted and saved in the static
589 array sel_buffer in devices/char/console.c.
590
591
592 __TIOCLINUX, subcode=3__
593
594
595 Paste selection. The characters in the selection buffer are
596 written to ''fd''.
597
598
599 __TIOCLINUX, subcode=4__
600
601
602 Unblank the screen.
603
604
605 __TIOCLINUX, subcode=5__
606
607
608 Sets contents of a 256-bit look up table defining characters
609 in a
610
611
612 __TIOCLINUX, subcode=6__
613
614
615 ''argp'' points to a char which is set to the value of
616 the kernel variable ''shift_state''. (Since
617 1.1.32.)
618
619
620 __TIOCLINUX, subcode=7__
621
622
623 ''argp'' points to a char which is set to the value of
624 the kernel variable ''report_mouse''. (Since
625 1.1.33.)
626
627
628 __TIOCLINUX, subcode=8__
629
630
631 Dump screen width and height, cursor position, and all the
632 character-attribute pairs. (Kernels 1.1.67 through 1.1.91
633 only. With kernel 1.1.92 or later, read from /dev/vcsa*
634 instead.)
635
636
637 __TIOCLINUX, subcode=9__
638
639
640 Restore screen width and height, cursor position, and all
641 the character-attribute pairs. (Kernels 1.1.67 through
642 1.1.91 only. With kernel 1.1.92 or later, write to
643 /dev/vcsa* instead.)
644
645
646 __TIOCLINUX, subcode=10__
647
648
649 Handles the Power Saving feature of the new generation of
650 monitors. VESA screen blanking mode is set to
651 ''argp''[[1], which governs what screen blanking
652 does:
653
654
655 ''0'': Screen blanking is disabled.
656
657
658 ''1'': The current video adapter register settings are
659 saved, then the controller is programmed to turn off the
660 vertical synchronization pulses. This puts the monitor into
661 ''
662
663
664 ''2'': The current settings are saved, then both the
665 vertical and horizontal synchronization pulses are turned
666 off. This puts the monitor into
667 ''Caution:'' Powering
668 down frequently will damage the monitor.)
669
670
671 (Since 1.1.76.)
672 !!RETURN VALUE
673
674
675 -1 for error, and ''errno'' is set.
676 !!ERRORS
677
678
679 ''errno'' may take on these values:
680
681
682 __EBADF__
683
684
685 file descriptor is invalid.
686
687
688 __ENOTTY__
689
690
691 file descriptor is not associated with a character special
692 device, or the specified request does not apply to
693 it.
694
695
696 __EINVAL__
697
698
699 file descriptor or ''argp'' is invalid.
700
701
702 __EPERM__
703
704
705 permission violation.
706 !!WARNING
707
708
709 Do not regard this man page as documentation of the Linux
710 console ioctl's. This is provided for the curious only, as
711 an alternative to reading the source. Ioctl's are
712 undocumented Linux internals, liable to be changed without
713 warning. (And indeed, this page more or less describes the
714 situation as of kernel version 1.1.94; there are many minor
715 and not-so-minor differences with earlier
716 versions.)
717
718
719 Very often, ioctl's are introduced for communication between
720 the kernel and one particular well-known program (fdisk,
721 hdparm, setserial, tunelp, loadkeys, selection, setfont,
722 etc.), and their behavior will be changed when required by
723 this particular program.
724
725
726 Programs using these ioctl's will not be portable to other
727 versions of Unix, will not work on older versions of Linux,
728 and will not work on future versions of Linux.
729
730
731 Use POSIX functions.
732 !!SEE ALSO
733
734
4 perry 735 kbd_mode(1), loadkeys(1), dumpkeys(1),
1 perry 736 mknod(1), setleds(1), setmetamode(1),
737 ioperm(2), termios(2), execve(2),
4 perry 738 fcntl(2), console(4), console_codes(4),
1 perry 739 mt(4), sd(4), tty(4), ttys(4),
740 vcs(4), vcsa(4), charsets(7),
741 mapscrn(8), setfont(8), resizecons(8),
742 ''/usr/include/linux/kd.h'',
743 ''/usr/include/linux/vt.h''
744 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.