Debian Codegraph @

upstream/debian-trixie/man2/ioctl_kd.2

raw
1 '\" t
2 .\" Copyright 1995, Jim Van Zandt <[email protected]> and aeb
3 .\" Copyright 1995, <[email protected]>
4 .\" Copyright 1995, <[email protected]>
5 .\" Copyright 1995, "H. Peter Anvin" <[email protected]>
6 .\" Copyright 2024, Alejandro Colomar <[email protected]>
7 .\"
8 .\" SPDX-License-Identifier: GPL-2.0-or-later
9 .\"
10 .\" FIXME The following are not documented:
11 .\" KDFONTOP (since Linux 2.1.111)
12 .\" KDGKBDIACRUC (since Linux 2.6.24)
13 .\" KDSKBDIACR
14 .\" KDSKBDIACRUC (since Linux 2.6.24)
15 .\" KDKBDREP (since Linux 2.1.113)
16 .\" KDMAPDISP (not implemented as at Linux 2.6.27)
17 .\" KDUNMAPDISP (not implemented as at Linux 2.6.27)
18 .\"
19 .TH ioctl_kd 2 2024-06-13 "Linux man-pages 6.9.1"
20 .SH NAME
21 ioctl_kd
22 \-
23 ioctls for console terminal and virtual consoles
24 .SH SYNOPSIS
25 .nf
26 .BR "#include <linux/kd.h>" " /* Definition of op constants */"
27 .B #include <sys/ioctl.h>
28 .P
29 .BI "int ioctl(int " fd ", unsigned long " op ", void *" argp );
30 .fi
31 .SH DESCRIPTION
32 The following Linux-specific
33 .BR ioctl (2)
34 operations are supported for console terminals and virtual consoles.
35 .TP
36 .B KDGETLED
37 Get state of LEDs.
38 .I argp
39 points to a
40 .IR char .
41 The lower three bits
42 of
43 .I *argp
44 are set to the state of the LEDs, as follows:
45 .TS
46 l l l.
47 LED_CAP 0x04 caps lock led
48 LED_NUM 0x02 num lock led
49 LED_SCR 0x01 scroll lock led
50 .TE
51 .TP
52 .B KDSETLED
53 Set the LEDs.
54 The LEDs are set to correspond to the lower three bits of the
55 unsigned long integer in
56 .IR argp .
57 However, if a higher order bit is set,
58 the LEDs revert to normal: displaying the state of the
59 keyboard functions of caps lock, num lock, and scroll lock.
60 .P
61 Before Linux 1.1.54, the LEDs just reflected the state of the corresponding
62 keyboard flags, and KDGETLED/KDSETLED would also change the keyboard
63 flags.
64 Since Linux 1.1.54 the LEDs can be made to display arbitrary
65 information, but by default they display the keyboard flags.
66 The following two ioctls are used to access the keyboard flags.
67 .TP
68 .B KDGKBLED
69 Get keyboard flags CapsLock, NumLock, ScrollLock (not lights).
70 .I argp
71 points to a char which is set to the flag state.
72 The low order three bits (mask 0x7) get the current flag state,
73 and the low order bits of the next nibble (mask 0x70) get
74 the default flag state.
75 (Since Linux 1.1.54.)
76 .TP
77 .B KDSKBLED
78 Set keyboard flags CapsLock, NumLock, ScrollLock (not lights).
79 .I argp
80 is an unsigned long integer that has the desired flag state.
81 The low order three bits (mask 0x7) have the flag state,
82 and the low order bits of the next nibble (mask 0x70) have
83 the default flag state.
84 (Since Linux 1.1.54.)
85 .TP
86 .B KDGKBTYPE
87 Get keyboard type.
88 This returns the value KB_101, defined as 0x02.
89 .TP
90 .B KDADDIO
91 Add I/O port as valid.
92 Equivalent to
93 .IR ioperm(arg,1,1) .
94 .TP
95 .B KDDELIO
96 Delete I/O port as valid.
97 Equivalent to
98 .IR ioperm(arg,1,0) .
99 .TP
100 .B KDENABIO
101 Enable I/O to video board.
102 Equivalent to
103 .IR "ioperm(0x3b4, 0x3df\-0x3b4+1, 1)" .
104 .TP
105 .B KDDISABIO
106 Disable I/O to video board.
107 Equivalent to
108 .IR "ioperm(0x3b4, 0x3df\-0x3b4+1, 0)" .
109 .TP
110 .B KDSETMODE
111 Set text/graphics mode.
112 .I argp
113 is an unsigned integer containing one of:
114 .TS
115 l l.
116 KD_TEXT 0x00
117 KD_GRAPHICS 0x01
118 .TE
119 .TP
120 .B KDGETMODE
121 Get text/graphics mode.
122 .I argp
123 points to an
124 .I int
125 which is set to one
126 of the values shown above for
127 .BR KDSETMODE .
128 .TP
129 .B KDMKTONE
130 Generate tone of specified length.
131 The lower 16 bits of the unsigned long integer in
132 .I argp
133 specify the period in clock cycles,
134 and the upper 16 bits give the duration in msec.
135 If the duration is zero, the sound is turned off.
136 Control returns immediately.
137 For example,
138 .I argp
139 = (125<<16) + 0x637 would specify
140 the beep normally associated with a ctrl-G.
141 (Thus since Linux 0.99pl1; broken in Linux 2.1.49-50.)
142 .TP
143 .B KIOCSOUND
144 Start or stop sound generation.
145 The lower 16 bits of
146 .I argp
147 specify the period in clock cycles
148 (that is,
149 .I argp
150 = 1193180/frequency).
151 .I argp
152 = 0 turns sound off.
153 In either case, control returns immediately.
154 .TP
155 .B GIO_CMAP
156 Get the current default color map from kernel.
157 .I argp
158 points to
159 a 48-byte array.
160 (Since Linux 1.3.3.)
161 .TP
162 .B PIO_CMAP
163 Change the default text-mode color map.
164 .I argp
165 points to a
166 48-byte array which contains, in order, the Red, Green, and Blue
167 values for the 16 available screen colors: 0 is off, and 255 is full
168 intensity.
169 The default colors are, in order: black, dark red, dark
170 green, brown, dark blue, dark purple, dark cyan, light grey, dark
171 grey, bright red, bright green, yellow, bright blue, bright purple,
172 bright cyan, and white.
173 (Since Linux 1.3.3.)
174 .TP
175 .B GIO_FONT
176 Gets 256-character screen font in expanded form.
177 .I argp
178 points to an 8192-byte array.
179 Fails with error code
180 .B EINVAL
181 if the
182 currently loaded font is a 512-character font, or if the console is
183 not in text mode.
184 .TP
185 .B GIO_FONTX
186 Gets screen font and associated information.
187 .I argp
188 points to a
189 .I "struct consolefontdesc"
190 (see
191 .BR PIO_FONTX ).
192 On call, the
193 .I charcount
194 field should be set to the maximum number of
195 characters that would fit in the buffer pointed to by
196 .IR chardata .
197 On return, the
198 .I charcount
199 and
200 .I charheight
201 are filled with
202 the respective data for the currently loaded font, and the
203 .I chardata
204 array contains the font data if the initial value of
205 .I charcount
206 indicated enough space was available; otherwise the
207 buffer is untouched and
208 .I errno
209 is set to
210 .BR ENOMEM .
211 (Since Linux 1.3.1.)
212 .TP
213 .B PIO_FONT
214 Sets 256-character screen font.
215 Load font into the EGA/VGA character
216 generator.
217 .I argp
218 points to an 8192-byte map, with 32 bytes per
219 character.
220 Only the first
221 .I N
222 of them are used for an 8x\fIN\fP font
223 (0 <
224 .I N
225 <= 32).
226 This call also invalidates the Unicode mapping.
227 .TP
228 .B PIO_FONTX
229 Sets screen font and associated rendering information.
230 .I argp
231 points to a
232 .IP
233 .in +4n
234 .EX
235 struct consolefontdesc {
236 unsigned short charcount; /* characters in font
237 (256 or 512) */
238 unsigned short charheight; /* scan lines per
239 character (1\-32) */
240 char *chardata; /* font data in
241 expanded form */
242 };
243 .EE
244 .in
245 .IP
246 If necessary, the screen will be appropriately resized, and
247 .B SIGWINCH
248 sent to the appropriate processes.
249 This call also invalidates the Unicode mapping.
250 (Since Linux 1.3.1.)
251 .TP
252 .B PIO_FONTRESET
253 Resets the screen font, size, and Unicode mapping to the bootup
254 defaults.
255 .I argp
256 is unused, but should be set to NULL to
257 ensure compatibility with future versions of Linux.
258 (Since Linux 1.3.28.)
259 .TP
260 .B GIO_SCRNMAP
261 Get screen mapping from kernel.
262 .I argp
263 points to an area of size
264 E_TABSZ, which is loaded with the font positions used to display each
265 character.
266 This call is likely to return useless information if the
267 currently loaded font is more than 256 characters.
268 .TP
269 .B GIO_UNISCRNMAP
270 Get full Unicode screen mapping from kernel.
271 .I argp
272 points to an
273 area of size
274 .IR "E_TABSZ*sizeof(unsigned short)" ,
275 which is loaded with the
276 Unicodes each character represent.
277 A special set of Unicodes,
278 starting at U+F000, are used to represent "direct to font" mappings.
279 (Since Linux 1.3.1.)
280 .TP
281 .B PIO_SCRNMAP
282 Loads the "user definable" (fourth) table in the kernel which maps
283 bytes into console screen symbols.
284 .I argp
285 points to an area of
286 size E_TABSZ.
287 .TP
288 .B PIO_UNISCRNMAP
289 Loads the "user definable" (fourth) table in the kernel which maps
290 bytes into Unicodes, which are then translated into screen symbols
291 according to the currently loaded Unicode-to-font map.
292 Special Unicodes starting at U+F000 can be used to map directly to the font
293 symbols.
294 (Since Linux 1.3.1.)
295 .TP
296 .B GIO_UNIMAP
297 Get Unicode-to-font mapping from kernel.
298 .I argp
299 points to a
300 .IP
301 .in +4n
302 .EX
303 struct unimapdesc {
304 unsigned short entry_ct;
305 struct unipair *entries;
306 };
307 .EE
308 .in
309 .IP
310 where
311 .I entries
312 points to an array of
313 .IP
314 .in +4n
315 .EX
316 struct unipair {
317 unsigned short unicode;
318 unsigned short fontpos;
319 };
320 .EE
321 .in
322 .IP
323 (Since Linux 1.1.92.)
324 .TP
325 .B PIO_UNIMAP
326 Put unicode-to-font mapping in kernel.
327 .I argp
328 points to a
329 .IR "struct unimapdesc" .
330 (Since Linux 1.1.92)
331 .TP
332 .B PIO_UNIMAPCLR
333 Clear table, possibly advise hash algorithm.
334 .I argp
335 points to a
336 .IP
337 .in +4n
338 .EX
339 struct unimapinit {
340 unsigned short advised_hashsize; /* 0 if no opinion */
341 unsigned short advised_hashstep; /* 0 if no opinion */
342 unsigned short advised_hashlevel; /* 0 if no opinion */
343 };
344 .EE
345 .in
346 .IP
347 (Since Linux 1.1.92.)
348 .TP
349 .B KDGKBMODE
350 Gets current keyboard mode.
351 .I argp
352 points to a
353 .I long
354 which is set to one
355 of these:
356 .TS
357 l l.
358 K_RAW 0x00 /* Raw (scancode) mode */
359 K_XLATE 0x01 /* Translate keycodes using keymap */
360 K_MEDIUMRAW 0x02 /* Medium raw (scancode) mode */
361 K_UNICODE 0x03 /* Unicode mode */
362 K_OFF 0x04 /* Disabled mode; since Linux 2.6.39 */
363 .\" K_OFF: commit 9fc3de9c83565fcaa23df74c2fc414bb6e7efb0a
364 .TE
365 .TP
366 .B KDSKBMODE
367 Sets current keyboard mode.
368 .I argp
369 is a
370 .I long
371 equal to one of the values shown for
372 .BR KDGKBMODE .
373 .TP
374 .B KDGKBMETA
375 Gets meta key handling mode.
376 .I argp
377 points to a
378 .I long
379 which is
380 set to one of these:
381 .TS
382 l l l.
383 K_METABIT 0x03 set high order bit
384 K_ESCPREFIX 0x04 escape prefix
385 .TE
386 .TP
387 .B KDSKBMETA
388 Sets meta key handling mode.
389 .I argp
390 is a
391 .I long
392 equal to one of the values shown above for
393 .BR KDGKBMETA .
394 .TP
395 .B KDGKBENT
396 Gets one entry in key translation table (keycode to action code).
397 .I argp
398 points to a
399 .IP
400 .in +4n
401 .EX
402 struct kbentry {
403 unsigned char kb_table;
404 unsigned char kb_index;
405 unsigned short kb_value;
406 };
407 .EE
408 .in
409 .IP
410 with the first two members filled in:
411 .I kb_table
412 selects the key table (0 <=
413 .I kb_table
414 < MAX_NR_KEYMAPS),
415 and
416 .I kb_index
417 is the keycode (0 <=
418 .I kb_index
419 < NR_KEYS).
420 .I kb_value
421 is set to the corresponding action code,
422 or K_HOLE if there is no such key,
423 or K_NOSUCHMAP if
424 .I kb_table
425 is invalid.
426 .TP
427 .B KDSKBENT
428 Sets one entry in translation table.
429 .I argp
430 points to a
431 .IR "struct kbentry" .
432 .TP
433 .B KDGKBSENT
434 Gets one function key string.
435 .I argp
436 points to a
437 .IP
438 .in +4n
439 .EX
440 struct kbsentry {
441 unsigned char kb_func;
442 unsigned char kb_string[512];
443 };
444 .EE
445 .in
446 .IP
447 .I kb_string
448 is set to the (null-terminated) string corresponding to
449 the
450 .IR kb_func th
451 function key action code.
452 .TP
453 .B KDSKBSENT
454 Sets one function key string entry.
455 .I argp
456 points to a
457 .IR "struct kbsentry" .
458 .TP
459 .B KDGKBDIACR
460 Read kernel accent table.
461 .I argp
462 points to a
463 .IP
464 .in +4n
465 .EX
466 struct kbdiacrs {
467 unsigned int kb_cnt;
468 struct kbdiacr kbdiacr[256];
469 };
470 .EE
471 .in
472 .IP
473 where
474 .I kb_cnt
475 is the number of entries in the array, each of which
476 is a
477 .IP
478 .in +4n
479 .EX
480 struct kbdiacr {
481 unsigned char diacr;
482 unsigned char base;
483 unsigned char result;
484 };
485 .EE
486 .in
487 .TP
488 .B KDGETKEYCODE
489 Read kernel keycode table entry (scan code to keycode).
490 .I argp
491 points to a
492 .IP
493 .in +4n
494 .EX
495 struct kbkeycode {
496 unsigned int scancode;
497 unsigned int keycode;
498 };
499 .EE
500 .in
501 .IP
502 .I keycode
503 is set to correspond to the given
504 .IR scancode .
505 (89 <=
506 .I scancode
507 <= 255 only.
508 For 1 <=
509 .I scancode
510 <= 88,
511 .IR keycode == scancode .)
512 (Since Linux 1.1.63.)
513 .TP
514 .B KDSETKEYCODE
515 Write kernel keycode table entry.
516 .I argp
517 points to a
518 .IR "struct kbkeycode" .
519 (Since Linux 1.1.63.)
520 .TP
521 .B KDSIGACCEPT
522 The calling process indicates its willingness to accept the signal
523 .I argp
524 when it is generated by pressing an appropriate key combination.
525 (1 <=
526 .I argp
527 <= NSIG).
528 (See
529 .IR spawn_console ()
530 in
531 .IR linux/drivers/char/keyboard.c .)
532 .SH RETURN VALUE
533 On success, 0 is returned (except where indicated).
534 On failure, \-1 is returned, and
535 .I errno
536 is set to indicate the error.
537 .SH ERRORS
538 .TP
539 .B EINVAL
540 .I argp
541 is invalid.
542 .SH STANDARDS
543 Linux.
544 .SH SEE ALSO
545 .BR ioctl (2),
546 .BR ioctl_console (2)