vt_core.c (271973) | vt_core.c (273036) |
---|---|
1/*- 2 * Copyright (c) 2009, 2013 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Ed Schouten under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Portions of this software were developed by Oleksandr Rybalko --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009, 2013 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Ed Schouten under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Portions of this software were developed by Oleksandr Rybalko --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: stable/10/sys/dev/vt/vt_core.c 271973 2014-09-22 16:13:33Z dumbbell $"); | 34__FBSDID("$FreeBSD: stable/10/sys/dev/vt/vt_core.c 273036 2014-10-13 13:50:51Z dumbbell $"); |
35 36#include "opt_compat.h" 37 38#include <sys/param.h> 39#include <sys/consio.h> 40#include <sys/eventhandler.h> 41#include <sys/fbio.h> 42#include <sys/kbio.h> --- 250 unchanged lines hidden (view full) --- 293static void 294vt_switch_timer(void *arg) 295{ 296 297 vt_late_window_switch((struct vt_window *)arg); 298} 299 300static int | 35 36#include "opt_compat.h" 37 38#include <sys/param.h> 39#include <sys/consio.h> 40#include <sys/eventhandler.h> 41#include <sys/fbio.h> 42#include <sys/kbio.h> --- 250 unchanged lines hidden (view full) --- 293static void 294vt_switch_timer(void *arg) 295{ 296 297 vt_late_window_switch((struct vt_window *)arg); 298} 299 300static int |
301vt_save_kbd_mode(struct vt_window *vw, keyboard_t *kbd) 302{ 303 int mode, ret; 304 305 mode = 0; 306 ret = kbdd_ioctl(kbd, KDGKBMODE, (caddr_t)&mode); 307 if (ret == ENOIOCTL) 308 ret = ENODEV; 309 if (ret != 0) 310 return (ret); 311 312 vw->vw_kbdmode = mode; 313 314 return (0); 315} 316 317static int 318vt_update_kbd_mode(struct vt_window *vw, keyboard_t *kbd) 319{ 320 int ret; 321 322 ret = kbdd_ioctl(kbd, KDSKBMODE, (caddr_t)&vw->vw_kbdmode); 323 if (ret == ENOIOCTL) 324 ret = ENODEV; 325 326 return (ret); 327} 328 329static int 330vt_save_kbd_state(struct vt_window *vw, keyboard_t *kbd) 331{ 332 int state, ret; 333 334 state = 0; 335 ret = kbdd_ioctl(kbd, KDGKBSTATE, (caddr_t)&state); 336 if (ret == ENOIOCTL) 337 ret = ENODEV; 338 if (ret != 0) 339 return (ret); 340 341 vw->vw_kbdstate &= ~LOCK_MASK; 342 vw->vw_kbdstate |= state & LOCK_MASK; 343 344 return (0); 345} 346 347static int 348vt_update_kbd_state(struct vt_window *vw, keyboard_t *kbd) 349{ 350 int state, ret; 351 352 state = vw->vw_kbdstate & LOCK_MASK; 353 ret = kbdd_ioctl(kbd, KDSKBSTATE, (caddr_t)&state); 354 if (ret == ENOIOCTL) 355 ret = ENODEV; 356 357 return (ret); 358} 359 360static int 361vt_save_kbd_leds(struct vt_window *vw, keyboard_t *kbd) 362{ 363 int leds, ret; 364 365 leds = 0; 366 ret = kbdd_ioctl(kbd, KDGETLED, (caddr_t)&leds); 367 if (ret == ENOIOCTL) 368 ret = ENODEV; 369 if (ret != 0) 370 return (ret); 371 372 vw->vw_kbdstate &= ~LED_MASK; 373 vw->vw_kbdstate |= leds & LED_MASK; 374 375 return (0); 376} 377 378static int 379vt_update_kbd_leds(struct vt_window *vw, keyboard_t *kbd) 380{ 381 int leds, ret; 382 383 leds = vw->vw_kbdstate & LED_MASK; 384 ret = kbdd_ioctl(kbd, KDSETLED, (caddr_t)&leds); 385 if (ret == ENOIOCTL) 386 ret = ENODEV; 387 388 return (ret); 389} 390 391static int |
|
301vt_window_preswitch(struct vt_window *vw, struct vt_window *curvw) 302{ 303 304 DPRINTF(40, "%s\n", __func__); 305 curvw->vw_switch_to = vw; 306 /* Set timer to allow switch in case when process hang. */ 307 callout_reset(&vw->vw_proc_dead_timer, hz * vt_deadtimer, 308 vt_switch_timer, (void *)vw); --- 95 unchanged lines hidden (view full) --- 404 vd->vd_driver->vd_postswitch(vd); 405 406 vt_resume_flush_timer(vd, 0); 407 408 /* Restore per-window keyboard mode. */ 409 mtx_lock(&Giant); 410 kbd = kbd_get_keyboard(vd->vd_keyboard); 411 if (kbd != NULL) { | 392vt_window_preswitch(struct vt_window *vw, struct vt_window *curvw) 393{ 394 395 DPRINTF(40, "%s\n", __func__); 396 curvw->vw_switch_to = vw; 397 /* Set timer to allow switch in case when process hang. */ 398 callout_reset(&vw->vw_proc_dead_timer, hz * vt_deadtimer, 399 vt_switch_timer, (void *)vw); --- 95 unchanged lines hidden (view full) --- 495 vd->vd_driver->vd_postswitch(vd); 496 497 vt_resume_flush_timer(vd, 0); 498 499 /* Restore per-window keyboard mode. */ 500 mtx_lock(&Giant); 501 kbd = kbd_get_keyboard(vd->vd_keyboard); 502 if (kbd != NULL) { |
412 kbdd_ioctl(kbd, KDSKBMODE, (void *)&vw->vw_kbdmode); | 503 if (curvw->vw_kbdmode == K_XLATE) 504 vt_save_kbd_state(curvw, kbd); 505 506 vt_update_kbd_mode(vw, kbd); 507 vt_update_kbd_state(vw, kbd); |
413 } 414 mtx_unlock(&Giant); 415 DPRINTF(10, "%s(ttyv%d) done\n", __func__, vw->vw_number); 416 417 return (0); 418} 419 420static inline void --- 176 unchanged lines hidden (view full) --- 597 if (console == 0) 598 VT_UNLOCK(vd); 599} 600 601static int 602vt_processkey(keyboard_t *kbd, struct vt_device *vd, int c) 603{ 604 struct vt_window *vw = vd->vd_curwindow; | 508 } 509 mtx_unlock(&Giant); 510 DPRINTF(10, "%s(ttyv%d) done\n", __func__, vw->vw_number); 511 512 return (0); 513} 514 515static inline void --- 176 unchanged lines hidden (view full) --- 692 if (console == 0) 693 VT_UNLOCK(vd); 694} 695 696static int 697vt_processkey(keyboard_t *kbd, struct vt_device *vd, int c) 698{ 699 struct vt_window *vw = vd->vd_curwindow; |
605 int state = 0; | |
606 607#if VT_ALT_TO_ESC_HACK 608 if (c & RELKEY) { 609 switch (c & ~RELKEY) { 610 case (SPCLKEY | RALT): 611 if (vt_enable_altgr != 0) 612 break; 613 case (SPCLKEY | LALT): --- 46 unchanged lines hidden (view full) --- 660 case PREV: 661 /* Switch to previous VT. */ 662 c = (vw->vw_number - 1) % VT_MAXWINDOWS; 663 vw = vd->vd_windows[c]; 664 if (vw != NULL) 665 vt_proc_window_switch(vw); 666 return (0); 667 case SLK: { | 700 701#if VT_ALT_TO_ESC_HACK 702 if (c & RELKEY) { 703 switch (c & ~RELKEY) { 704 case (SPCLKEY | RALT): 705 if (vt_enable_altgr != 0) 706 break; 707 case (SPCLKEY | LALT): --- 46 unchanged lines hidden (view full) --- 754 case PREV: 755 /* Switch to previous VT. */ 756 c = (vw->vw_number - 1) % VT_MAXWINDOWS; 757 vw = vd->vd_windows[c]; 758 if (vw != NULL) 759 vt_proc_window_switch(vw); 760 return (0); 761 case SLK: { |
668 669 kbdd_ioctl(kbd, KDGKBSTATE, (caddr_t)&state); | 762 vt_save_kbd_state(vw, kbd); |
670 VT_LOCK(vd); | 763 VT_LOCK(vd); |
671 if (state & SLKED) { | 764 if (vw->vw_kbdstate & SLKED) { |
672 /* Turn scrolling on. */ 673 vw->vw_flags |= VWF_SCROLL; 674 VTBUF_SLCK_ENABLE(&vw->vw_buf); 675 } else { 676 /* Turn scrolling off. */ 677 vw->vw_flags &= ~VWF_SCROLL; 678 VTBUF_SLCK_DISABLE(&vw->vw_buf); 679 vt_scroll(vw, 0, VHS_END); --- 516 unchanged lines hidden (view full) --- 1196} 1197 1198static int 1199vtterm_cngetc(struct terminal *tm) 1200{ 1201 struct vt_window *vw = tm->tm_softc; 1202 struct vt_device *vd = vw->vw_device; 1203 keyboard_t *kbd; | 765 /* Turn scrolling on. */ 766 vw->vw_flags |= VWF_SCROLL; 767 VTBUF_SLCK_ENABLE(&vw->vw_buf); 768 } else { 769 /* Turn scrolling off. */ 770 vw->vw_flags &= ~VWF_SCROLL; 771 VTBUF_SLCK_DISABLE(&vw->vw_buf); 772 vt_scroll(vw, 0, VHS_END); --- 516 unchanged lines hidden (view full) --- 1289} 1290 1291static int 1292vtterm_cngetc(struct terminal *tm) 1293{ 1294 struct vt_window *vw = tm->tm_softc; 1295 struct vt_device *vd = vw->vw_device; 1296 keyboard_t *kbd; |
1204 int state; | |
1205 u_int c; 1206 1207 if (vw->vw_kbdsq && *vw->vw_kbdsq) 1208 return (*vw->vw_kbdsq++); 1209 | 1297 u_int c; 1298 1299 if (vw->vw_kbdsq && *vw->vw_kbdsq) 1300 return (*vw->vw_kbdsq++); 1301 |
1210 state = 0; | |
1211 /* Make sure the splash screen is not there. */ 1212 if (vd->vd_flags & VDF_SPLASH) { 1213 /* Remove splash */ 1214 vd->vd_flags &= ~VDF_SPLASH; 1215 /* Mark screen as invalid to force update */ 1216 vd->vd_flags |= VDF_INVALID; 1217 vt_flush(vd); 1218 } 1219 1220 /* Stripped down keyboard handler. */ 1221 kbd = kbd_get_keyboard(vd->vd_keyboard); 1222 if (kbd == NULL) 1223 return (-1); 1224 1225 /* Force keyboard input mode to K_XLATE */ | 1302 /* Make sure the splash screen is not there. */ 1303 if (vd->vd_flags & VDF_SPLASH) { 1304 /* Remove splash */ 1305 vd->vd_flags &= ~VDF_SPLASH; 1306 /* Mark screen as invalid to force update */ 1307 vd->vd_flags |= VDF_INVALID; 1308 vt_flush(vd); 1309 } 1310 1311 /* Stripped down keyboard handler. */ 1312 kbd = kbd_get_keyboard(vd->vd_keyboard); 1313 if (kbd == NULL) 1314 return (-1); 1315 1316 /* Force keyboard input mode to K_XLATE */ |
1226 c = K_XLATE; 1227 kbdd_ioctl(kbd, KDSKBMODE, (void *)&c); | 1317 vw->vw_kbdmode = K_XLATE; 1318 vt_update_kbd_mode(vw, kbd); |
1228 1229 /* Switch the keyboard to polling to make it work here. */ 1230 kbdd_poll(kbd, TRUE); 1231 c = kbdd_read_char(kbd, 0); 1232 kbdd_poll(kbd, FALSE); 1233 if (c & RELKEY) 1234 return (-1); 1235 1236 if (vw->vw_flags & VWF_SCROLL) { 1237 vt_scrollmode_kbdevent(vw, c, 1/* Console mode */); 1238 vt_flush(vd); 1239 return (-1); 1240 } 1241 1242 /* Stripped down handling of vt_kbdevent(), without locking, etc. */ 1243 if (c & SPCLKEY) { 1244 switch (c) { 1245 case SPCLKEY | SLK: | 1319 1320 /* Switch the keyboard to polling to make it work here. */ 1321 kbdd_poll(kbd, TRUE); 1322 c = kbdd_read_char(kbd, 0); 1323 kbdd_poll(kbd, FALSE); 1324 if (c & RELKEY) 1325 return (-1); 1326 1327 if (vw->vw_flags & VWF_SCROLL) { 1328 vt_scrollmode_kbdevent(vw, c, 1/* Console mode */); 1329 vt_flush(vd); 1330 return (-1); 1331 } 1332 1333 /* Stripped down handling of vt_kbdevent(), without locking, etc. */ 1334 if (c & SPCLKEY) { 1335 switch (c) { 1336 case SPCLKEY | SLK: |
1246 kbdd_ioctl(kbd, KDGKBSTATE, (caddr_t)&state); 1247 if (state & SLKED) { | 1337 vt_save_kbd_state(vw, kbd); 1338 if (vw->vw_kbdstate & SLKED) { |
1248 /* Turn scrolling on. */ 1249 vw->vw_flags |= VWF_SCROLL; 1250 VTBUF_SLCK_ENABLE(&vw->vw_buf); 1251 } else { 1252 /* Turn scrolling off. */ 1253 vt_scroll(vw, 0, VHS_END); 1254 vw->vw_flags &= ~VWF_SCROLL; 1255 VTBUF_SLCK_DISABLE(&vw->vw_buf); --- 50 unchanged lines hidden (view full) --- 1306 * Make sure the keyboard is accessible even when the kbd device 1307 * driver is disabled. 1308 */ 1309 kbdd_enable(kbd); 1310 1311 /* We shall always use the keyboard in the XLATE mode here. */ 1312 vw->vw_prev_kbdmode = vw->vw_kbdmode; 1313 vw->vw_kbdmode = K_XLATE; | 1339 /* Turn scrolling on. */ 1340 vw->vw_flags |= VWF_SCROLL; 1341 VTBUF_SLCK_ENABLE(&vw->vw_buf); 1342 } else { 1343 /* Turn scrolling off. */ 1344 vt_scroll(vw, 0, VHS_END); 1345 vw->vw_flags &= ~VWF_SCROLL; 1346 VTBUF_SLCK_DISABLE(&vw->vw_buf); --- 50 unchanged lines hidden (view full) --- 1397 * Make sure the keyboard is accessible even when the kbd device 1398 * driver is disabled. 1399 */ 1400 kbdd_enable(kbd); 1401 1402 /* We shall always use the keyboard in the XLATE mode here. */ 1403 vw->vw_prev_kbdmode = vw->vw_kbdmode; 1404 vw->vw_kbdmode = K_XLATE; |
1314 (void)kbdd_ioctl(kbd, KDSKBMODE, (caddr_t)&vw->vw_kbdmode); | 1405 vt_update_kbd_mode(vw, kbd); |
1315 1316 kbdd_poll(kbd, TRUE); 1317} 1318 1319static void 1320vtterm_cnungrab(struct terminal *tm) 1321{ 1322 struct vt_device *vd; --- 8 unchanged lines hidden (view full) --- 1331 return; 1332 1333 if (--vw->vw_grabbed > 0) 1334 return; 1335 1336 kbdd_poll(kbd, FALSE); 1337 1338 vw->vw_kbdmode = vw->vw_prev_kbdmode; | 1406 1407 kbdd_poll(kbd, TRUE); 1408} 1409 1410static void 1411vtterm_cnungrab(struct terminal *tm) 1412{ 1413 struct vt_device *vd; --- 8 unchanged lines hidden (view full) --- 1422 return; 1423 1424 if (--vw->vw_grabbed > 0) 1425 return; 1426 1427 kbdd_poll(kbd, FALSE); 1428 1429 vw->vw_kbdmode = vw->vw_prev_kbdmode; |
1339 (void)kbdd_ioctl(kbd, KDSKBMODE, (caddr_t)&vw->vw_kbdmode); | 1430 vt_update_kbd_mode(vw, kbd); |
1340 kbdd_disable(kbd); 1341} 1342 1343static void 1344vtterm_opened(struct terminal *tm, int opened) 1345{ 1346 struct vt_window *vw = tm->tm_softc; 1347 struct vt_device *vd = vw->vw_device; --- 537 unchanged lines hidden (view full) --- 1885 case GIO_KEYMAP: 1886 case PIO_KEYMAP: 1887 case GIO_DEADKEYMAP: 1888 case PIO_DEADKEYMAP: 1889 case GETFKEY: 1890 case SETFKEY: 1891 case KDGKBINFO: 1892 case KDGKBTYPE: | 1431 kbdd_disable(kbd); 1432} 1433 1434static void 1435vtterm_opened(struct terminal *tm, int opened) 1436{ 1437 struct vt_window *vw = tm->tm_softc; 1438 struct vt_device *vd = vw->vw_device; --- 537 unchanged lines hidden (view full) --- 1976 case GIO_KEYMAP: 1977 case PIO_KEYMAP: 1978 case GIO_DEADKEYMAP: 1979 case PIO_DEADKEYMAP: 1980 case GETFKEY: 1981 case SETFKEY: 1982 case KDGKBINFO: 1983 case KDGKBTYPE: |
1893 case KDSKBSTATE: /* set keyboard state (locks) */ 1894 case KDGKBSTATE: /* get keyboard state (locks) */ | |
1895 case KDGETREPEAT: /* get keyboard repeat & delay rates */ 1896 case KDSETREPEAT: /* set keyboard repeat & delay rates (new) */ | 1984 case KDGETREPEAT: /* get keyboard repeat & delay rates */ 1985 case KDSETREPEAT: /* set keyboard repeat & delay rates (new) */ |
1897 case KDSETLED: /* set keyboard LED status */ 1898 case KDGETLED: /* get keyboard LED status */ | |
1899 case KBADDKBD: /* add/remove keyboard to/from mux */ 1900 case KBRELKBD: { 1901 error = 0; 1902 1903 mtx_lock(&Giant); 1904 kbd = kbd_get_keyboard(vd->vd_keyboard); 1905 if (kbd != NULL) 1906 error = kbdd_ioctl(kbd, cmd, data); 1907 mtx_unlock(&Giant); 1908 if (error == ENOIOCTL) { 1909 if (cmd == KDGKBTYPE) { 1910 /* always return something? XXX */ 1911 *(int *)data = 0; 1912 } else { 1913 return (ENODEV); 1914 } 1915 } 1916 return (error); 1917 } | 1986 case KBADDKBD: /* add/remove keyboard to/from mux */ 1987 case KBRELKBD: { 1988 error = 0; 1989 1990 mtx_lock(&Giant); 1991 kbd = kbd_get_keyboard(vd->vd_keyboard); 1992 if (kbd != NULL) 1993 error = kbdd_ioctl(kbd, cmd, data); 1994 mtx_unlock(&Giant); 1995 if (error == ENOIOCTL) { 1996 if (cmd == KDGKBTYPE) { 1997 /* always return something? XXX */ 1998 *(int *)data = 0; 1999 } else { 2000 return (ENODEV); 2001 } 2002 } 2003 return (error); 2004 } |
2005 case KDGKBSTATE: { /* get keyboard state (locks) */ 2006 error = 0; 2007 2008 if (vw == vd->vd_curwindow) { 2009 mtx_lock(&Giant); 2010 kbd = kbd_get_keyboard(vd->vd_keyboard); 2011 if (kbd != NULL) 2012 error = vt_save_kbd_state(vw, kbd); 2013 mtx_unlock(&Giant); 2014 2015 if (error != 0) 2016 return (error); 2017 } 2018 2019 *(int *)data = vw->vw_kbdstate & LOCK_MASK; 2020 2021 return (error); 2022 } 2023 case KDSKBSTATE: { /* set keyboard state (locks) */ 2024 int state; 2025 2026 state = *(int *)data; 2027 if (state & ~LOCK_MASK) 2028 return (EINVAL); 2029 2030 vw->vw_kbdstate &= ~LOCK_MASK; 2031 vw->vw_kbdstate |= state; 2032 2033 error = 0; 2034 if (vw == vd->vd_curwindow) { 2035 mtx_lock(&Giant); 2036 kbd = kbd_get_keyboard(vd->vd_keyboard); 2037 if (kbd != NULL) 2038 error = vt_update_kbd_state(vw, kbd); 2039 mtx_unlock(&Giant); 2040 } 2041 2042 return (error); 2043 } 2044 case KDGETLED: { /* get keyboard LED status */ 2045 error = 0; 2046 2047 if (vw == vd->vd_curwindow) { 2048 mtx_lock(&Giant); 2049 kbd = kbd_get_keyboard(vd->vd_keyboard); 2050 if (kbd != NULL) 2051 error = vt_save_kbd_leds(vw, kbd); 2052 mtx_unlock(&Giant); 2053 2054 if (error != 0) 2055 return (error); 2056 } 2057 2058 *(int *)data = vw->vw_kbdstate & LED_MASK; 2059 2060 return (error); 2061 } 2062 case KDSETLED: { /* set keyboard LED status */ 2063 int leds; 2064 2065 leds = *(int *)data; 2066 if (leds & ~LED_MASK) 2067 return (EINVAL); 2068 2069 vw->vw_kbdstate &= ~LED_MASK; 2070 vw->vw_kbdstate |= leds; 2071 2072 error = 0; 2073 if (vw == vd->vd_curwindow) { 2074 mtx_lock(&Giant); 2075 kbd = kbd_get_keyboard(vd->vd_keyboard); 2076 if (kbd != NULL) 2077 error = vt_update_kbd_leds(vw, kbd); 2078 mtx_unlock(&Giant); 2079 } 2080 2081 return (error); 2082 } |
|
1918 case KDGKBMODE: { | 2083 case KDGKBMODE: { |
1919 int mode = -1; | 2084 error = 0; |
1920 | 2085 |
1921 mtx_lock(&Giant); 1922 kbd = kbd_get_keyboard(vd->vd_keyboard); 1923 if (kbd != NULL) { 1924 kbdd_ioctl(kbd, KDGKBMODE, (void *)&mode); | 2086 if (vw == vd->vd_curwindow) { 2087 mtx_lock(&Giant); 2088 kbd = kbd_get_keyboard(vd->vd_keyboard); 2089 if (kbd != NULL) 2090 error = vt_save_kbd_mode(vw, kbd); 2091 mtx_unlock(&Giant); 2092 2093 if (error != 0) 2094 return (error); |
1925 } | 2095 } |
1926 mtx_unlock(&Giant); 1927 DPRINTF(20, "mode %d, vw_kbdmode %d\n", mode, vw->vw_kbdmode); 1928 *(int *)data = mode; 1929 return (0); | 2096 2097 *(int *)data = vw->vw_kbdmode; 2098 2099 return (error); |
1930 } 1931 case KDSKBMODE: { 1932 int mode; 1933 1934 mode = *(int *)data; 1935 switch (mode) { 1936 case K_XLATE: 1937 case K_RAW: 1938 case K_CODE: 1939 vw->vw_kbdmode = mode; | 2100 } 2101 case KDSKBMODE: { 2102 int mode; 2103 2104 mode = *(int *)data; 2105 switch (mode) { 2106 case K_XLATE: 2107 case K_RAW: 2108 case K_CODE: 2109 vw->vw_kbdmode = mode; |
1940 if (vw == vd->vd_curwindow) { 1941 keyboard_t *kbd; 1942 error = 0; | |
1943 | 2110 |
2111 error = 0; 2112 if (vw == vd->vd_curwindow) { |
|
1944 mtx_lock(&Giant); 1945 kbd = kbd_get_keyboard(vd->vd_keyboard); | 2113 mtx_lock(&Giant); 2114 kbd = kbd_get_keyboard(vd->vd_keyboard); |
1946 if (kbd != NULL) { 1947 error = kbdd_ioctl(kbd, KDSKBMODE, 1948 (void *)&mode); 1949 } | 2115 if (kbd != NULL) 2116 error = vt_update_kbd_mode(vw, kbd); |
1950 mtx_unlock(&Giant); 1951 } | 2117 mtx_unlock(&Giant); 2118 } |
1952 return (0); | 2119 2120 return (error); |
1953 default: 1954 return (EINVAL); 1955 } 1956 } 1957 case FBIOGTYPE: 1958 case FBIO_GETWINORG: /* get frame buffer window origin */ 1959 case FBIO_GETDISPSTART: /* get display start address */ 1960 case FBIO_GETLINEWIDTH: /* get scan line width in bytes */ --- 11 unchanged lines hidden (view full) --- 1972 case CONS_BELLTYPE: /* set bell type sound */ 1973 if ((*(int *)data) & CONS_QUIET_BELL) 1974 vd->vd_flags |= VDF_QUIET_BELL; 1975 else 1976 vd->vd_flags &= ~VDF_QUIET_BELL; 1977 return (0); 1978 case CONS_GETINFO: { 1979 vid_info_t *vi = (vid_info_t *)data; | 2121 default: 2122 return (EINVAL); 2123 } 2124 } 2125 case FBIOGTYPE: 2126 case FBIO_GETWINORG: /* get frame buffer window origin */ 2127 case FBIO_GETDISPSTART: /* get display start address */ 2128 case FBIO_GETLINEWIDTH: /* get scan line width in bytes */ --- 11 unchanged lines hidden (view full) --- 2140 case CONS_BELLTYPE: /* set bell type sound */ 2141 if ((*(int *)data) & CONS_QUIET_BELL) 2142 vd->vd_flags |= VDF_QUIET_BELL; 2143 else 2144 vd->vd_flags &= ~VDF_QUIET_BELL; 2145 return (0); 2146 case CONS_GETINFO: { 2147 vid_info_t *vi = (vid_info_t *)data; |
2148 if (vi->size != sizeof(struct vid_info)) 2149 return (EINVAL); |
|
1980 | 2150 |
2151 if (vw == vd->vd_curwindow) { 2152 kbd = kbd_get_keyboard(vd->vd_keyboard); 2153 if (kbd != NULL) 2154 vt_save_kbd_state(vw, kbd); 2155 } 2156 |
|
1981 vi->m_num = vd->vd_curwindow->vw_number + 1; | 2157 vi->m_num = vd->vd_curwindow->vw_number + 1; |
2158 vi->mk_keylock = vw->vw_kbdstate & LOCK_MASK; |
|
1982 /* XXX: other fields! */ 1983 return (0); 1984 } 1985 case CONS_GETVERS: 1986 *(int *)data = 0x200; 1987 return (0); 1988 case CONS_MODEINFO: 1989 /* XXX */ --- 98 unchanged lines hidden (view full) --- 2088 if (kbd == NULL) { 2089 mtx_unlock(&Giant); 2090 return (EINVAL); 2091 } 2092 i = kbd_allocate(kbd->kb_name, kbd->kb_unit, 2093 (void *)vd, vt_kbdevent, vd); 2094 if (i >= 0) { 2095 if (vd->vd_keyboard != -1) { | 2159 /* XXX: other fields! */ 2160 return (0); 2161 } 2162 case CONS_GETVERS: 2163 *(int *)data = 0x200; 2164 return (0); 2165 case CONS_MODEINFO: 2166 /* XXX */ --- 98 unchanged lines hidden (view full) --- 2265 if (kbd == NULL) { 2266 mtx_unlock(&Giant); 2267 return (EINVAL); 2268 } 2269 i = kbd_allocate(kbd->kb_name, kbd->kb_unit, 2270 (void *)vd, vt_kbdevent, vd); 2271 if (i >= 0) { 2272 if (vd->vd_keyboard != -1) { |
2273 vt_save_kbd_state(vd->vd_curwindow, kbd); |
|
2096 kbd_release(kbd, (void *)vd); 2097 } 2098 kbd = kbd_get_keyboard(i); 2099 vd->vd_keyboard = i; 2100 | 2274 kbd_release(kbd, (void *)vd); 2275 } 2276 kbd = kbd_get_keyboard(i); 2277 vd->vd_keyboard = i; 2278 |
2101 (void)kbdd_ioctl(kbd, KDSKBMODE, 2102 (caddr_t)&vd->vd_curwindow->vw_kbdmode); | 2279 vt_update_kbd_mode(vd->vd_curwindow, kbd); 2280 vt_update_kbd_state(vd->vd_curwindow, kbd); |
2103 } else { 2104 error = EPERM; /* XXX */ 2105 } 2106 } 2107 mtx_unlock(&Giant); 2108 return (error); 2109 case CONS_RELKBD: /* release the current keyboard */ 2110 mtx_lock(&Giant); 2111 error = 0; 2112 if (vd->vd_keyboard != -1) { 2113 kbd = kbd_get_keyboard(vd->vd_keyboard); 2114 if (kbd == NULL) { 2115 mtx_unlock(&Giant); 2116 return (EINVAL); 2117 } | 2281 } else { 2282 error = EPERM; /* XXX */ 2283 } 2284 } 2285 mtx_unlock(&Giant); 2286 return (error); 2287 case CONS_RELKBD: /* release the current keyboard */ 2288 mtx_lock(&Giant); 2289 error = 0; 2290 if (vd->vd_keyboard != -1) { 2291 kbd = kbd_get_keyboard(vd->vd_keyboard); 2292 if (kbd == NULL) { 2293 mtx_unlock(&Giant); 2294 return (EINVAL); 2295 } |
2296 vt_save_kbd_state(vd->vd_curwindow, kbd); |
|
2118 error = kbd_release(kbd, (void *)vd); 2119 if (error == 0) { 2120 vd->vd_keyboard = -1; 2121 } 2122 } 2123 mtx_unlock(&Giant); 2124 return (error); 2125 case VT_ACTIVATE: { --- 346 unchanged lines hidden --- | 2297 error = kbd_release(kbd, (void *)vd); 2298 if (error == 0) { 2299 vd->vd_keyboard = -1; 2300 } 2301 } 2302 mtx_unlock(&Giant); 2303 return (error); 2304 case VT_ACTIVATE: { --- 346 unchanged lines hidden --- |