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