Lines Matching +full:beeper +full:- +full:hz

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1992-1998 Søren Schmidt
95 #define KEYCODE_BS 0x0e /* "<-- Backspace" key, XXX */
97 /* NULL-safe version of "tty_opened()" */
102 static int sc_console_unit = -1;
118 static int enable_bell = TRUE; /* enable beeper */
273 /* ec -- emergency console. */
306 fb = main_console.sc->adp->va_window; in ec_putc()
312 mysize = xsize * (ysize - 2 * yborder); in ec_putc()
317 -1 : in ec_putc()
320 c == '\r' ? -column : c == '\n' ? xsize - column : 1); in ec_putc()
321 if (width == 0 || (width < 0 && ind < -width)) in ec_putc()
334 while (--width != 0); in ec_putc()
362 * However, when syscons is being probed as the low-level console, in scvidprobe()
394 { -1, { "Unknown", "Unknown" } }, in adapter_name()
398 for (i = 0; names[i].type != -1; ++i) in adapter_name()
399 if (names[i].type == adp->va_type) in adapter_name()
401 return names[i].name[(adp->va_flags & V_ADP_COLOR) ? 0 : 1]; in adapter_name()
411 if (scp->status & SLKED || in sctty_outwakeup()
412 (scp == scp->sc->cur_scp && scp->sc->blink_in_progress)) in sctty_outwakeup()
419 SC_VIDEO_LOCK(scp->sc); in sctty_outwakeup()
421 SC_VIDEO_UNLOCK(scp->sc); in sctty_outwakeup()
433 stc->st_index = index; in sc_alloc_tty()
434 stc->st_stat = NULL; in sc_alloc_tty()
457 vidd_get_info(sc->adp, vmode, &info) != 0 || in sc_set_vesa_mode()
467 if (vidd_get_info(sc->adp, i, &info) == 0 && in sc_set_vesa_mode()
476 vidd_get_info(sc->adp, vmode, &info); in sc_set_vesa_mode()
482 fontsize = scp->font_size; in sc_set_vesa_mode()
493 if ((sc->fonts_loaded & FONT_8) == 0) in sc_set_vesa_mode()
495 font = sc->font_8; in sc_set_vesa_mode()
498 if ((sc->fonts_loaded & FONT_14) == 0) in sc_set_vesa_mode()
500 font = sc->font_14; in sc_set_vesa_mode()
503 if ((sc->fonts_loaded & FONT_16) == 0) in sc_set_vesa_mode()
505 font = sc->font_16; in sc_set_vesa_mode()
512 if ((sc->flags & SC_SPLASH_SCRN) != 0) in sc_set_vesa_mode()
513 splash_term(sc->adp); in sc_set_vesa_mode()
516 if (scp->history != NULL) { in sc_set_vesa_mode()
517 sc_vtb_append(&scp->vtb, 0, scp->history, in sc_set_vesa_mode()
518 scp->ypos * scp->xsize + scp->xpos); in sc_set_vesa_mode()
519 scp->history_pos = sc_vtb_tail(scp->history); in sc_set_vesa_mode()
522 vidd_set_mode(sc->adp, vmode); in sc_set_vesa_mode()
523 scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN); in sc_set_vesa_mode()
524 scp->status &= ~(GRAPHICS_MODE | MOUSE_VISIBLE); in sc_set_vesa_mode()
525 scp->xpixel = info.vi_width; in sc_set_vesa_mode()
526 scp->ypixel = info.vi_height; in sc_set_vesa_mode()
527 scp->xsize = scp->xpixel / 8; in sc_set_vesa_mode()
528 scp->ysize = scp->ypixel / fontsize; in sc_set_vesa_mode()
529 scp->xpos = 0; in sc_set_vesa_mode()
530 scp->ypos = scp->ysize - 1; in sc_set_vesa_mode()
531 scp->xoff = scp->yoff = 0; in sc_set_vesa_mode()
532 scp->font = font; in sc_set_vesa_mode()
533 scp->font_size = fontsize; in sc_set_vesa_mode()
534 scp->font_width = 8; in sc_set_vesa_mode()
535 scp->start = scp->xsize * scp->ysize - 1; in sc_set_vesa_mode()
536 scp->end = 0; in sc_set_vesa_mode()
537 scp->cursor_pos = scp->cursor_oldpos = scp->xsize * scp->xsize; in sc_set_vesa_mode()
538 scp->mode = sc->initial_mode = vmode; in sc_set_vesa_mode()
539 sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, scp->xsize, scp->ysize, in sc_set_vesa_mode()
540 (void *)sc->adp->va_window, FALSE); in sc_set_vesa_mode()
549 sc_set_border(scp, scp->border); in sc_set_vesa_mode()
551 scp->status &= ~UNKNOWN_MODE; in sc_set_vesa_mode()
553 if ((sc->flags & SC_SPLASH_SCRN) != 0) in sc_set_vesa_mode()
554 splash_init(sc->adp, scsplash_callback, sc); in sc_set_vesa_mode()
584 if (sc_console->tsw->te_size > 0) { in sc_attach_unit()
585 sc_ktsw = sc_console->tsw; in sc_attach_unit()
586 /* assert(sc_console->ts != NULL); */ in sc_attach_unit()
587 oldts = sc_console->ts; in sc_attach_unit()
589 ts = malloc(sc_console->tsw->te_size, M_DEVBUF, in sc_attach_unit()
591 (*sc_console->tsw->te_init)( in sc_attach_unit()
593 sc_console->ts = ts; in sc_attach_unit()
594 (*sc_console->tsw->te_default_attr)(sc_console, in sc_attach_unit()
598 sc_console->ts = oldts; in sc_attach_unit()
599 (*sc_console->tsw->te_default_attr)( in sc_attach_unit()
607 sc->config = flags; in sc_attach_unit()
608 callout_init(&sc->ctimeout, 0); in sc_attach_unit()
609 callout_init(&sc->cblink, 0); in sc_attach_unit()
610 scp = sc_get_stat(sc->dev[0]); in sc_attach_unit()
615 if ((sc->config & SC_VESAMODE) != 0) in sc_attach_unit()
627 (void)kbdd_ioctl(sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); in sc_attach_unit()
628 update_kbd_state(scp, scp->status, LOCK_MASK); in sc_attach_unit()
631 unit, adapter_name(sc->adp), sc->vtys, sc->config); in sc_attach_unit()
634 if (sc->adapter >= 0) in sc_attach_unit()
635 printf(" fb%d", sc->adapter); in sc_attach_unit()
636 if (sc->kbd != NULL) in sc_attach_unit()
637 printf(", kbd%d", sc->kbd->kb_index); in sc_attach_unit()
638 if (scp->tsw) in sc_attach_unit()
640 scp->tsw->te_name, scp->tsw->te_desc); in sc_attach_unit()
654 for (vc = 0; vc < sc->vtys; vc++) { in sc_attach_unit()
655 if (sc->dev[vc] == NULL) { in sc_attach_unit()
656 sc->dev[vc] = sc_alloc_tty(vc, vc + unit * MAXCONS); in sc_attach_unit()
657 if (vc == 0 && sc->dev == main_devs) in sc_attach_unit()
658 SC_STAT(sc->dev[0]) = &main_console; in sc_attach_unit()
669 dev->si_drv1 = sc->dev[0]; in sc_attach_unit()
713 return ((sc_console != NULL) ? sc_console->sc->unit : -1); in scdevtounit()
715 return -1; in scdevtounit()
729 ("scopen: dev:%s, unit:%d, vty:%d\n", devtoname(tp->t_dev), unit, in sctty_open()
738 /* Use the current setting of the <-- key as default VERASE. */ in sctty_open()
740 if (sc->kbd != NULL) { in sctty_open()
742 (void)kbdd_ioctl(sc->kbd, GIO_KEYMAPENT, (caddr_t)&key); in sctty_open()
743 tp->t_termios.c_cc[VERASE] = key.key.map[0]; in sctty_open()
753 if (!tp->t_winsize.ws_col && !tp->t_winsize.ws_row) { in sctty_open()
754 tp->t_winsize.ws_col = scp->xsize; in sctty_open()
755 tp->t_winsize.ws_row = scp->ysize; in sctty_open()
770 DPRINTF(5, ("sc%d: scclose(), ", scp->sc->unit)); in sctty_close()
772 if ((scp == scp->sc->cur_scp) && in sctty_close()
773 (scp->sc->unit == sc_console_unit)) in sctty_close()
781 scp->pid = 0; in sctty_close()
782 scp->proc = NULL; in sctty_close()
783 scp->smode.mode = VT_AUTO; in sctty_close()
785 sc_vtb_destroy(&scp->vtb); in sctty_close()
786 sc_vtb_destroy(&scp->scr); in sctty_close()
787 sc_free_history_buffer(scp, scp->ysize); in sctty_close()
792 scp->pid = 0; in sctty_close()
793 scp->proc = NULL; in sctty_close()
794 scp->smode.mode = VT_AUTO; in sctty_close()
796 scp->kbd_mode = K_XLATE; in sctty_close()
797 if (scp == scp->sc->cur_scp) in sctty_close()
799 scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); in sctty_close()
824 /* assert(thiskbd == sc->kbd) */ in sckbdevent()
832 sc->kbd = NULL; in sckbdevent()
833 kbd_release(thiskbd, (void *)&sc->kbd); in sckbdevent()
843 * the Xaccel-2.1 keyboard hang, but it can't hurt. XXX in sckbdevent()
846 cur_tty = SC_DEV(sc, sc->cur_scp->index); in sckbdevent()
850 if ((*sc->cur_scp->tsw->te_input)(sc->cur_scp, c, cur_tty)) in sckbdevent()
858 cp = (*sc->cur_scp->tsw->te_fkeystr)(sc->cur_scp, c); in sckbdevent()
879 sc->cur_scp->status |= MOUSE_HIDDEN; in sckbdevent()
926 sc = scp->sc; in sctty_ioctl()
928 if (scp->tsw) { in sctty_ioctl()
929 error = (*scp->tsw->te_ioctl)(scp, tp, cmd, data, td); in sctty_ioctl()
942 *(int *)data = (sc->adp->va_flags & V_ADP_COLOR) ? 1 : 0; in sctty_ioctl()
957 sc_change_cursor_shape(scp, *(int *)data, -1, -1); in sctty_ioctl()
965 cap = &sc->curs_attr; in sctty_ioctl()
968 cap = &scp->base_curs_attr; in sctty_ioctl()
971 cap = &sc->dflt_curs_attr; in sctty_ioctl()
974 cap = &scp->dflt_curs_attr; in sctty_ioctl()
978 ((int *)data)[1] = cap->bg[0]; in sctty_ioctl()
979 ((int *)data)[2] = cap->bg[1]; in sctty_ioctl()
981 ((int *)data)[1] = cap->mouse_ba; in sctty_ioctl()
982 ((int *)data)[2] = cap->mouse_ia; in sctty_ioctl()
984 ((int *)data)[1] = cap->base; in sctty_ioctl()
985 ((int *)data)[2] = cap->height; in sctty_ioctl()
987 ((int *)data)[0] = cap->flags; in sctty_ioctl()
999 sc->flags |= SC_VISUAL_BELL; in sctty_ioctl()
1001 sc->flags &= ~SC_VISUAL_BELL; in sctty_ioctl()
1003 sc->flags |= SC_QUIET_BELL; in sctty_ioctl()
1005 sc->flags &= ~SC_QUIET_BELL; in sctty_ioctl()
1011 if (ptr->size == sizeof(struct vid_info)) { in sctty_ioctl()
1012 ptr->m_num = sc->cur_scp->index; in sctty_ioctl()
1013 ptr->font_size = scp->font_size; in sctty_ioctl()
1014 ptr->mv_col = scp->xpos; in sctty_ioctl()
1015 ptr->mv_row = scp->ypos; in sctty_ioctl()
1016 ptr->mv_csz = scp->xsize; in sctty_ioctl()
1017 ptr->mv_rsz = scp->ysize; in sctty_ioctl()
1018 ptr->mv_hsz = in sctty_ioctl()
1019 (scp->history != NULL) ? scp->history->vtb_rows : 0; in sctty_ioctl()
1024 * ptr->mv_norm.fore in sctty_ioctl()
1025 * ptr->mv_norm.back in sctty_ioctl()
1026 * ptr->mv_rev.fore in sctty_ioctl()
1027 * ptr->mv_rev.back in sctty_ioctl()
1029 ptr->mv_grfc.fore = 0; /* not supported */ in sctty_ioctl()
1030 ptr->mv_grfc.back = 0; /* not supported */ in sctty_ioctl()
1031 ptr->mv_ovscan = scp->border; in sctty_ioctl()
1032 if (scp == sc->cur_scp) in sctty_ioctl()
1034 ptr->mk_keylock = scp->status & LOCK_MASK; in sctty_ioctl()
1054 *(int *)data = (sc->flags & SC_SCRN_IDLE) && in sctty_ioctl()
1055 (!ISGRAPHSC(sc->cur_scp) || in sctty_ioctl()
1056 (sc->cur_scp->status & SAVER_RUNNING)); in sctty_ioctl()
1075 scp->status |= SAVER_RUNNING; in sctty_ioctl()
1077 scp->status &= ~SAVER_RUNNING; in sctty_ioctl()
1084 (scp->status & SAVER_RUNNING)) in sctty_ioctl()
1085 scp->status &= ~SAVER_RUNNING; in sctty_ioctl()
1102 sc->scrn_time_stamp -= scrn_blank_time; in sctty_ioctl()
1113 void *outp = ptr->buf; in sctty_ioctl()
1115 if (ptr->x < 0 || ptr->y < 0 || ptr->xsize < 0 || in sctty_ioctl()
1116 ptr->ysize < 0) in sctty_ioctl()
1123 hist_rsz = (scp->history != NULL) ? scp->history->vtb_rows : 0; in sctty_ioctl()
1124 if (((u_int)ptr->x + ptr->xsize) > scp->xsize || in sctty_ioctl()
1125 ((u_int)ptr->y + ptr->ysize) > (scp->ysize + hist_rsz)) { in sctty_ioctl()
1130 lsize = scp->xsize * sizeof(u_int16_t); in sctty_ioctl()
1131 csize = ptr->xsize * sizeof(u_int16_t); in sctty_ioctl()
1133 frbp = scp->vtb.vtb_buffer + scp->ysize * lsize + in sctty_ioctl()
1134 ptr->x * sizeof(u_int16_t); in sctty_ioctl()
1136 outp = (char *)outp + ptr->ysize * csize; in sctty_ioctl()
1138 if (scp->history != NULL) in sctty_ioctl()
1139 hstp = scp->history->vtb_buffer + in sctty_ioctl()
1140 sc_vtb_tail(scp->history) * sizeof(u_int16_t) + in sctty_ioctl()
1141 ptr->x * sizeof(u_int16_t); in sctty_ioctl()
1146 for (lnum = 0; lnum < (ptr->y + ptr->ysize); lnum++) { in sctty_ioctl()
1147 if (lnum < scp->ysize) { in sctty_ioctl()
1148 frbp -= lsize; in sctty_ioctl()
1150 hstp -= lsize; in sctty_ioctl()
1151 if (hstp < scp->history->vtb_buffer) in sctty_ioctl()
1152 hstp += scp->history->vtb_rows * lsize; in sctty_ioctl()
1155 if (lnum < ptr->y) in sctty_ioctl()
1157 outp = (char *)outp - csize; in sctty_ioctl()
1172 DPRINTF(5, ("%s%d: VT_SETMODE ", SC_DRIVER_NAME, sc->unit)); in sctty_ioctl()
1173 if (scp->smode.mode == VT_PROCESS) { in sctty_ioctl()
1174 p1 = pfind(scp->pid); in sctty_ioctl()
1175 if (scp->proc == p1 && scp->proc != td->td_proc) { in sctty_ioctl()
1185 if (mode->mode == VT_AUTO) { in sctty_ioctl()
1186 scp->smode.mode = VT_AUTO; in sctty_ioctl()
1187 scp->proc = NULL; in sctty_ioctl()
1188 scp->pid = 0; in sctty_ioctl()
1190 if ((scp == sc->cur_scp) && in sctty_ioctl()
1191 (sc->unit == sc_console_unit)) in sctty_ioctl()
1200 if (!ISSIGVALID(mode->relsig) || in sctty_ioctl()
1201 !ISSIGVALID(mode->acqsig) || in sctty_ioctl()
1202 !ISSIGVALID(mode->frsig)) { in sctty_ioctl()
1207 DPRINTF(5, ("VT_PROCESS %d, ", td->td_proc->p_pid)); in sctty_ioctl()
1208 bcopy(data, &scp->smode, sizeof(struct vt_mode)); in sctty_ioctl()
1209 scp->proc = td->td_proc; in sctty_ioctl()
1210 scp->pid = scp->proc->p_pid; in sctty_ioctl()
1211 if ((scp == sc->cur_scp) && in sctty_ioctl()
1212 (sc->unit == sc_console_unit)) in sctty_ioctl()
1221 bcopy(&scp->smode, data, sizeof(struct vt_mode)); in sctty_ioctl()
1237 if ((scp != sc->cur_scp) || (scp->smode.mode != VT_PROCESS)) { in sctty_ioctl()
1242 if (scp->proc != td->td_proc) { in sctty_ioctl()
1252 sc->unit)); in sctty_ioctl()
1258 sc->unit)); in sctty_ioctl()
1264 sc->unit)); in sctty_ioctl()
1273 for (i = sc->first_vty; i < sc->first_vty + sc->vtys; i++) { in sctty_ioctl()
1290 i = (*(int *)data == 0) ? scp->index : (*(int *)data - 1); in sctty_ioctl()
1292 error = sc_clean_up(sc->cur_scp); in sctty_ioctl()
1307 i = (*(int *)data == 0) ? scp->index : (*(int *)data - 1); in sctty_ioctl()
1308 if ((i < sc->first_vty) || (i >= sc->first_vty + sc->vtys)) in sctty_ioctl()
1310 if (i == sc->cur_scp->index) in sctty_ioctl()
1317 *(int *)data = sc->cur_scp->index + 1; in sctty_ioctl()
1321 *(int *)data = scp->index + 1; in sctty_ioctl()
1326 sc->flags |= SC_SCRN_VTYLOCK; in sctty_ioctl()
1328 sc->flags &= ~SC_SCRN_VTYLOCK; in sctty_ioctl()
1335 error = securelevel_gt(td->td_ucred, 0); in sctty_ioctl()
1339 td->td_frame->tf_eflags |= PSL_IOPL; in sctty_ioctl()
1341 td->td_frame->tf_rflags |= PSL_IOPL; in sctty_ioctl()
1347 td->td_frame->tf_eflags &= ~PSL_IOPL; in sctty_ioctl()
1349 td->td_frame->tf_rflags &= ~PSL_IOPL; in sctty_ioctl()
1363 scp->status &= ~LOCK_MASK; in sctty_ioctl()
1364 scp->status |= *(int *)data; in sctty_ioctl()
1365 if (scp == sc->cur_scp) in sctty_ioctl()
1366 update_kbd_state(scp, scp->status, LOCK_MASK); in sctty_ioctl()
1370 if (scp == sc->cur_scp) in sctty_ioctl()
1372 *(int *)data = scp->status & LOCK_MASK; in sctty_ioctl()
1377 error = kbdd_ioctl(sc->kbd, cmd, data); in sctty_ioctl()
1392 error = kbdd_ioctl(sc->kbd, KDSETRAD, data); in sctty_ioctl()
1409 scp->kbd_mode = *(int *)data; in sctty_ioctl()
1410 if (scp == sc->cur_scp) in sctty_ioctl()
1411 (void)kbdd_ioctl(sc->kbd, KDSKBMODE, data); in sctty_ioctl()
1419 *(int *)data = scp->kbd_mode; in sctty_ioctl()
1423 error = kbdd_ioctl(sc->kbd, cmd, data); in sctty_ioctl()
1438 (((*(int *)data) >> 16) & 0xffff) * hz / 1000); in sctty_ioctl()
1440 sc_bell(scp, scp->bell_pitch, scp->bell_duration); in sctty_ioctl()
1450 case KIOCSOUND: /* make tone (*data) hz */ in sctty_ioctl()
1451 if (scp == sc->cur_scp) { in sctty_ioctl()
1460 error = kbdd_ioctl(sc->kbd, cmd, data); in sctty_ioctl()
1477 scp->status &= ~LED_MASK; in sctty_ioctl()
1478 scp->status |= *(int *)data; in sctty_ioctl()
1479 if (scp == sc->cur_scp) in sctty_ioctl()
1480 update_kbd_leds(scp, scp->status); in sctty_ioctl()
1484 if (scp == sc->cur_scp) in sctty_ioctl()
1486 *(int *)data = scp->status & LED_MASK; in sctty_ioctl()
1491 error = kbdd_ioctl(sc->kbd, cmd, data); in sctty_ioctl()
1514 if (sc->kbd != newkbd) { in sctty_ioctl()
1515 i = kbd_allocate(newkbd->kb_name, newkbd->kb_unit, in sctty_ioctl()
1516 (void *)&sc->kbd, sckbdevent, sc); in sctty_ioctl()
1517 /* i == newkbd->kb_index */ in sctty_ioctl()
1519 if (sc->kbd != NULL) { in sctty_ioctl()
1520 save_kbd_state(sc->cur_scp); in sctty_ioctl()
1522 sc->kbd, (void *)&sc->kbd); in sctty_ioctl()
1524 sc->kbd = in sctty_ioctl()
1525 kbd_get_keyboard(i); /* sc->kbd == newkbd */ in sctty_ioctl()
1526 (void)kbdd_ioctl(sc->kbd, KDSKBMODE, in sctty_ioctl()
1527 (caddr_t)&sc->cur_scp->kbd_mode); in sctty_ioctl()
1528 update_kbd_state(sc->cur_scp, in sctty_ioctl()
1529 sc->cur_scp->status, LOCK_MASK); in sctty_ioctl()
1541 if (sc->kbd != NULL) { in sctty_ioctl()
1542 save_kbd_state(sc->cur_scp); in sctty_ioctl()
1543 error = kbd_release(sc->kbd, (void *)&sc->kbd); in sctty_ioctl()
1545 sc->kbd = NULL; in sctty_ioctl()
1554 if (((term_info_t *)data)->ti_index == 0) { in sctty_ioctl()
1555 sw = scp->tsw; in sctty_ioctl()
1558 ((term_info_t *)data)->ti_index); in sctty_ioctl()
1561 strncpy(((term_info_t *)data)->ti_name, sw->te_name, in sctty_ioctl()
1562 sizeof(((term_info_t *)data)->ti_name)); in sctty_ioctl()
1563 strncpy(((term_info_t *)data)->ti_desc, sw->te_desc, in sctty_ioctl()
1564 sizeof(((term_info_t *)data)->ti_desc)); in sctty_ioctl()
1565 ((term_info_t *)data)->ti_flags = 0; in sctty_ioctl()
1568 ((term_info_t *)data)->ti_name[0] = '\0'; in sctty_ioctl()
1569 ((term_info_t *)data)->ti_desc[0] = '\0'; in sctty_ioctl()
1570 ((term_info_t *)data)->ti_flags = 0; in sctty_ioctl()
1577 error = sc_init_emulator(scp, ((term_info_t *)data)->ti_name); in sctty_ioctl()
1583 bcopy(&sc->scr_map, data, sizeof(sc->scr_map)); in sctty_ioctl()
1587 bcopy(data, &sc->scr_map, sizeof(sc->scr_map)); in sctty_ioctl()
1588 for (i = 0; i < sizeof(sc->scr_map); i++) { in sctty_ioctl()
1589 sc->scr_rmap[sc->scr_map[i]] = i; in sctty_ioctl()
1605 error = kbdd_ioctl(sc->kbd, cmd, data); in sctty_ioctl()
1613 if (!ISFONTAVAIL(sc->adp->va_flags)) in sctty_ioctl()
1615 bcopy(data, sc->font_8, 8 * 256); in sctty_ioctl()
1616 sc->fonts_loaded |= FONT_8; in sctty_ioctl()
1622 if (ISTEXTSC(sc->cur_scp) && (sc->cur_scp->font_size < 14)) in sctty_ioctl()
1623 sc_load_font(sc->cur_scp, 0, 8, 8, sc->font_8, 0, 256); in sctty_ioctl()
1627 if (!ISFONTAVAIL(sc->adp->va_flags)) in sctty_ioctl()
1629 if (sc->fonts_loaded & FONT_8) { in sctty_ioctl()
1630 bcopy(sc->font_8, data, 8 * 256); in sctty_ioctl()
1636 if (!ISFONTAVAIL(sc->adp->va_flags)) in sctty_ioctl()
1638 bcopy(data, sc->font_14, 14 * 256); in sctty_ioctl()
1639 sc->fonts_loaded |= FONT_14; in sctty_ioctl()
1645 if (ISTEXTSC(sc->cur_scp) && (sc->cur_scp->font_size >= 14) && in sctty_ioctl()
1646 (sc->cur_scp->font_size < 16)) in sctty_ioctl()
1648 sc->cur_scp, 0, 14, 8, sc->font_14, 0, 256); in sctty_ioctl()
1652 if (!ISFONTAVAIL(sc->adp->va_flags)) in sctty_ioctl()
1654 if (sc->fonts_loaded & FONT_14) { in sctty_ioctl()
1655 bcopy(sc->font_14, data, 14 * 256); in sctty_ioctl()
1661 if (!ISFONTAVAIL(sc->adp->va_flags)) in sctty_ioctl()
1663 bcopy(data, sc->font_16, 16 * 256); in sctty_ioctl()
1664 sc->fonts_loaded |= FONT_16; in sctty_ioctl()
1670 if (ISTEXTSC(sc->cur_scp) && (sc->cur_scp->font_size >= 16)) in sctty_ioctl()
1672 sc->cur_scp, 0, 16, 8, sc->font_16, 0, 256); in sctty_ioctl()
1676 if (!ISFONTAVAIL(sc->adp->va_flags)) in sctty_ioctl()
1678 if (sc->fonts_loaded & FONT_16) { in sctty_ioctl()
1679 bcopy(sc->font_16, data, 16 * 256); in sctty_ioctl()
1698 return sctty_ioctl(dev->si_drv1, cmd, data, td); in consolectl_ioctl()
1713 (void)sctty_ioctl(dev->si_drv1, CONS_MOUSECTL, (caddr_t)&info, td); in consolectl_close()
1725 cp->cn_pri = CN_DEAD; in sc_cnprobe()
1729 cp->cn_pri = sc_get_cons_priority(&unit, &flags); in sc_cnprobe()
1733 cp->cn_pri = CN_DEAD; in sc_cnprobe()
1738 if (cp->cn_pri == CN_DEAD) in sc_cnprobe()
1742 strcpy(cp->cn_name, "ttyv0"); in sc_cnprobe()
1754 sc_console = sc_get_stat(sc_get_softc(unit, SC_KERNEL_CONSOLE)->dev[0]); in sc_cninit()
1778 (*sc_ktsw->te_term)(sc_console, &ts); in sc_cnterm()
1784 sc_console_unit = -1; in sc_cnterm()
1805 sp->kbd_locked = !kdb_active && mtx_trylock(&Giant); in sccnkbdlock()
1811 if (sp->kbd_locked) in sccnkbdunlock()
1813 sp->kbd_locked = FALSE; in sccnkbdunlock()
1823 * - if kdb_active and video_mtx is not owned by anyone, then lock in sccnscrlock()
1825 * - if !kdb_active, try to acquire video_mtx without blocking or in sccnscrlock()
1832 sp->kdb_locked = sc->video_mtx.mtx_lock == MTX_UNOWNED || in sccnscrlock()
1834 sp->mtx_locked = FALSE; in sccnscrlock()
1836 sp->kdb_locked = FALSE; in sccnscrlock()
1838 sp->mtx_locked = mtx_trylock_spin_flags( in sccnscrlock()
1839 &sc->video_mtx, MTX_QUIET) != 0; in sccnscrlock()
1841 sp->kdb_locked = TRUE; in sccnscrlock()
1842 sp->mtx_locked = FALSE; in sccnscrlock()
1845 if (sp->mtx_locked) in sccnscrlock()
1855 if (sp->mtx_locked) in sccnscrunlock()
1856 mtx_unlock_spin(&sc->video_mtx); in sccnscrunlock()
1857 sp->mtx_locked = sp->kdb_locked = FALSE; in sccnscrunlock()
1867 sp->kbd_opened = FALSE; in sccnopen()
1868 sp->scr_opened = FALSE; in sccnopen()
1869 sp->kbd_locked = FALSE; in sccnopen()
1872 if (!(flags & 1) || sc->kbd == NULL) in sccnopen()
1881 kbdd_enable(sc->kbd); in sccnopen()
1886 (void)kbdd_ioctl(sc->kbd, KDSKBMODE, (caddr_t)&kbd_mode); in sccnopen()
1887 sc->kbd_open_level++; in sccnopen()
1888 kbdd_poll(sc->kbd, TRUE); in sccnopen()
1890 sp->kbd_opened = TRUE; in sccnopen()
1895 if (!sp->kdb_locked && !sp->mtx_locked) in sccnopen()
1897 sp->scr_opened = TRUE; in sccnopen()
1904 if (!cold && sc->cur_scp->index != sc_console->index && in sccnopen()
1905 sc->cur_scp->smode.mode == VT_AUTO && in sccnopen()
1906 sc_console->smode.mode == VT_AUTO) in sccnopen()
1907 sc_switch_scr(sc, sc_console->index); in sccnopen()
1913 sp->scr_opened = FALSE; in sccnclose()
1916 if (!sp->kbd_opened) in sccnclose()
1919 /* Restore keyboard mode (for the current, possibly-changed scp). */ in sccnclose()
1920 kbdd_poll(sc->kbd, FALSE); in sccnclose()
1921 if (--sc->kbd_open_level == 0) in sccnclose()
1923 sc->kbd, KDSKBMODE, (caddr_t)&sc->cur_scp->kbd_mode); in sccnclose()
1925 kbdd_disable(sc->kbd); in sccnclose()
1926 sp->kbd_opened = FALSE; in sccnclose()
1948 sc = sc_console->sc; in sc_cngrab()
1949 lev = atomic_fetchadd_int(&sc->grab_level, 1); in sc_cngrab()
1951 sccnopen(sc, &sc->grab_state[lev], 1 | 2); in sc_cngrab()
1952 sccnscrunlock(sc, &sc->grab_state[lev]); in sc_cngrab()
1953 sccnkbdunlock(sc, &sc->grab_state[lev]); in sc_cngrab()
1963 sc = sc_console->sc; in sc_cnungrab()
1964 lev = atomic_load_acq_int(&sc->grab_level) - 1; in sc_cnungrab()
1966 sccnkbdlock(sc, &sc->grab_state[lev]); in sc_cnungrab()
1967 sccnscrlock(sc, &sc->grab_state[lev]); in sc_cnungrab()
1968 sccnclose(sc, &sc->grab_state[lev]); in sc_cnungrab()
1970 atomic_add_int(&sc->grab_level, -1); in sc_cnungrab()
1995 sccnopen(scp->sc, &st, 0); in sc_cnputc()
2016 if (scp == scp->sc->cur_scp && scp->status & SLKED) { in sc_cnputc()
2017 scp->status &= ~SLKED; in sc_cnputc()
2018 update_kbd_state(scp, scp->status, SLKED); in sc_cnputc()
2019 if (scp->status & BUFFER_SAVED) { in sc_cnputc()
2022 scp->status &= ~BUFFER_SAVED; in sc_cnputc()
2023 scp->status |= CURSOR_ENABLED; in sc_cnputc()
2032 tp = SC_DEV(scp->sc, scp->index); in sc_cnputc()
2046 if (atomic_load_acq_int(&sc_cnputc_loghead) - in sc_cnputc()
2050 /* Console output has a per-CPU "input" state. Switch for it. in sc_cnputc()
2054 oldtsw = scp->tsw; in sc_cnputc()
2055 oldts = scp->ts; in sc_cnputc()
2056 scp->tsw = sc_ktsw; in sc_cnputc()
2057 scp->ts = ts; in sc_cnputc()
2058 (*scp->tsw->te_sync)(scp); in sc_cnputc()
2061 (*scp->tsw->te_default_attr)( in sc_cnputc()
2066 scp->tsw = oldtsw; in sc_cnputc()
2067 scp->ts = oldts; in sc_cnputc()
2068 (*scp->tsw->te_sync)(scp); in sc_cnputc()
2070 (*scp->tsw->te_default_attr)( in sc_cnputc()
2078 sccnclose(scp->sc, &st); in sc_cnputc()
2088 sccnopen(sc_console->sc, &st, 1); in sc_cngetc()
2092 sccnclose(sc_console->sc, &st); in sc_cngetc()
2093 return -1; /* means no keyboard since we fudged the locking */ in sc_cngetc()
2097 sccnclose(sc_console->sc, &st); in sc_cngetc()
2114 if (sp->scr_opened) in sc_cngetc_locked()
2116 scp = sc_console->sc->cur_scp; /* XXX */ in sc_cngetc_locked()
2117 if (sp->scr_opened) in sc_cngetc_locked()
2123 c = scgetc(scp->sc, SCGETC_CN | SCGETC_NONBLOCK, sp); in sc_cngetc_locked()
2129 p = (*scp->tsw->te_fkeystr)(scp, c); in sc_cngetc_locked()
2137 scp->sc->kbd, KEYCHAR(c), (size_t *)&fkeycp); in sc_cngetc_locked()
2148 return -1; in sc_cngetc_locked()
2156 /* this is a cut-down version of scrn_timer()... */ in sccnupdate()
2158 if (suspend_in_progress || scp->sc->font_loading_in_progress) in sccnupdate()
2163 } else if (scp != scp->sc->cur_scp) { in sccnupdate()
2168 scp->sc->flags &= ~SC_SCRN_IDLE; in sccnupdate()
2170 if ((saver_mode != CONS_LKM_SAVER) || !(scp->sc->flags & SC_SCRN_IDLE)) in sccnupdate()
2171 if (scp->sc->flags & SC_SCRN_BLANKED) in sccnupdate()
2172 stop_scrn_saver(scp->sc, current_saver); in sccnupdate()
2175 if (scp != scp->sc->cur_scp || scp->sc->blink_in_progress || in sccnupdate()
2176 scp->sc->switch_in_progress) in sccnupdate()
2180 * when write_in_progress is non-zero. XXX in sccnupdate()
2183 if (!ISGRAPHSC(scp) && !(scp->sc->flags & SC_SCRN_BLANKED)) in sccnupdate()
2200 sc = sc_console->sc; in scrn_timer()
2205 scp = sc->cur_scp; in scrn_timer()
2208 if (suspend_in_progress || sc->font_loading_in_progress) in scrn_timer()
2211 if ((sc->kbd == NULL) && (sc->config & SC_AUTODETECT_KBD)) { in scrn_timer()
2215 kbdidx = sc_allocate_keyboard(sc, -1); in scrn_timer()
2217 sc->kbd = kbd_get_keyboard(kbdidx); in scrn_timer()
2218 (void)kbdd_ioctl(sc->kbd, KDSKBMODE, in scrn_timer()
2219 (caddr_t)&sc->cur_scp->kbd_mode); in scrn_timer()
2220 update_kbd_state(sc->cur_scp, in scrn_timer()
2221 sc->cur_scp->status, LOCK_MASK); in scrn_timer()
2230 if (time_uptime > sc->scrn_time_stamp + scrn_blank_time) in scrn_timer()
2231 sc->flags |= SC_SCRN_IDLE; in scrn_timer()
2233 sc->flags &= ~SC_SCRN_IDLE; in scrn_timer()
2235 sc->scrn_time_stamp = time_uptime; in scrn_timer()
2236 sc->flags &= ~SC_SCRN_IDLE; in scrn_timer()
2241 if ((saver_mode != CONS_LKM_SAVER) || !(sc->flags & SC_SCRN_IDLE)) in scrn_timer()
2242 if (sc->flags & SC_SCRN_BLANKED) in scrn_timer()
2247 if (sc->blink_in_progress || sc->switch_in_progress || in scrn_timer()
2248 sc->write_in_progress) in scrn_timer()
2252 scp = sc->cur_scp; /* cur_scp may have changed... */ in scrn_timer()
2253 if (!ISGRAPHSC(scp) && !(sc->flags & SC_SCRN_BLANKED)) in scrn_timer()
2258 if ((saver_mode == CONS_LKM_SAVER) && (sc->flags & SC_SCRN_IDLE)) in scrn_timer()
2259 if (!ISGRAPHSC(scp) || (sc->flags & SC_SCRN_BLANKED)) in scrn_timer()
2270 if (ISGRAPHSC(scp) && !(sc->flags & SC_SCRN_BLANKED)) in scrn_timer()
2275 &sc->ctimeout, SBT_1S / rate, 0, scrn_timer, sc, C_PREL(1)); in scrn_timer()
2297 /* assert(scp == scp->sc->cur_scp) */ in scrn_update()
2299 SC_VIDEO_LOCK(scp->sc); in scrn_update()
2303 if (scp->status & MOUSE_VISIBLE) { in scrn_update()
2304 s = scp->mouse_pos; in scrn_update()
2305 e = scp->mouse_pos + scp->xsize + 1; in scrn_update()
2306 if ((scp->status & (MOUSE_MOVED | MOUSE_HIDDEN)) || in scrn_update()
2307 and_region(&s, &e, scp->start, scp->end) || in scrn_update()
2308 ((scp->status & CURSOR_ENABLED) && in scrn_update()
2309 (scp->cursor_pos != scp->cursor_oldpos) && in scrn_update()
2310 (and_region(&s, &e, scp->cursor_pos, scp->cursor_pos) || in scrn_update()
2311 and_region(&s, &e, scp->cursor_oldpos, in scrn_update()
2312 scp->cursor_oldpos)))) { in scrn_update()
2314 if (scp->end >= scp->xsize * scp->ysize) in scrn_update()
2315 scp->end = scp->xsize * scp->ysize - 1; in scrn_update()
2322 if (scp->end >= scp->xsize * scp->ysize) { in scrn_update()
2323 printf("scrn_update(): scp->end %d > size_of_screen!!\n", in scrn_update()
2324 scp->end); in scrn_update()
2325 scp->end = scp->xsize * scp->ysize - 1; in scrn_update()
2327 if (scp->start < 0) { in scrn_update()
2328 printf("scrn_update(): scp->start %d < 0\n", scp->start); in scrn_update()
2329 scp->start = 0; in scrn_update()
2334 if (scp->start <= scp->end) { in scrn_update()
2335 if (scp->mouse_cut_end >= 0) { in scrn_update()
2337 if (scp->mouse_cut_start <= scp->mouse_cut_end) { in scrn_update()
2338 start = scp->mouse_cut_start; in scrn_update()
2339 end = scp->mouse_cut_end; in scrn_update()
2341 start = scp->mouse_cut_end; in scrn_update()
2342 end = scp->mouse_cut_start - 1; in scrn_update()
2346 /* does the cut-mark region overlap with the update in scrn_update()
2348 if (and_region(&s, &e, scp->start, scp->end)) { in scrn_update()
2349 (*scp->rndr->draw)(scp, s, e - s + 1, TRUE); in scrn_update()
2351 e = start - 1; in scrn_update()
2352 if (and_region(&s, &e, scp->start, scp->end)) in scrn_update()
2353 (*scp->rndr->draw)( in scrn_update()
2354 scp, s, e - s + 1, FALSE); in scrn_update()
2356 e = scp->xsize * scp->ysize - 1; in scrn_update()
2357 if (and_region(&s, &e, scp->start, scp->end)) in scrn_update()
2358 (*scp->rndr->draw)( in scrn_update()
2359 scp, s, e - s + 1, FALSE); in scrn_update()
2361 (*scp->rndr->draw)(scp, scp->start, in scrn_update()
2362 scp->end - scp->start + 1, FALSE); in scrn_update()
2365 (*scp->rndr->draw)( in scrn_update()
2366 scp, scp->start, scp->end - scp->start + 1, FALSE); in scrn_update()
2372 scp->end = 0; in scrn_update()
2373 scp->start = scp->xsize * scp->ysize - 1; in scrn_update()
2374 SC_VIDEO_UNLOCK(scp->sc); in scrn_update()
2379 if (scp->status & CURSOR_ENABLED) { in scrn_update()
2380 s = scp->start; in scrn_update()
2381 e = scp->end; in scrn_update()
2383 if (scp->cursor_pos != scp->cursor_oldpos) { in scrn_update()
2386 &s, &e, scp->cursor_oldpos, scp->cursor_oldpos)) in scrn_update()
2391 &s, &e, scp->cursor_pos, scp->cursor_pos)) in scrn_update()
2395 else if (scp->curs_attr.flags & CONS_BLINK_CURSOR) in scrn_update()
2397 (*scp->rndr->blink_cursor)(scp, scp->cursor_pos, in scrn_update()
2398 sc_inside_cutmark(scp, scp->cursor_pos)); in scrn_update()
2404 if (scp->sc->flags & SC_MOUSE_ENABLED) { in scrn_update()
2405 if (!(scp->status & (MOUSE_VISIBLE | MOUSE_HIDDEN))) { in scrn_update()
2406 scp->status &= ~MOUSE_MOVED; in scrn_update()
2412 scp->end = 0; in scrn_update()
2413 scp->start = scp->xsize * scp->ysize - 1; in scrn_update()
2415 SC_VIDEO_UNLOCK(scp->sc); in scrn_update()
2430 sc->flags &= ~SC_SAVER_FAILED; in scsplash_callback()
2463 scp = sc->cur_scp; in scsplash_saver()
2465 if (!(sc->flags & SC_SAVER_FAILED)) { in scsplash_saver()
2466 if (!(sc->flags & SC_SCRN_BLANKED)) in scsplash_saver()
2467 set_scrn_saver_mode(scp, -1, NULL, 0); in scsplash_saver()
2468 switch (splash(sc->adp, TRUE)) { in scsplash_saver()
2476 sc->flags |= SC_SAVER_FAILED; in scsplash_saver()
2485 if ((sc->flags & SC_SCRN_BLANKED) && in scsplash_saver()
2486 (splash(sc->adp, FALSE) == 0)) in scsplash_saver()
2545 /* assert(scp == scp->sc->cur_scp) */ in set_scrn_saver_mode()
2549 scp->splash_save_mode = scp->mode; in set_scrn_saver_mode()
2550 scp->splash_save_status = scp->status & (GRAPHICS_MODE | PIXEL_MODE); in set_scrn_saver_mode()
2551 scp->status &= ~(GRAPHICS_MODE | PIXEL_MODE); in set_scrn_saver_mode()
2552 scp->status |= (UNKNOWN_MODE | SAVER_RUNNING); in set_scrn_saver_mode()
2553 scp->sc->flags |= SC_SCRN_BLANKED; in set_scrn_saver_mode()
2558 scp->mode = mode; in set_scrn_saver_mode()
2560 if (scp->sc->adp->va_info.vi_flags & V_INFO_GRAPHICS) in set_scrn_saver_mode()
2561 scp->status |= GRAPHICS_MODE; in set_scrn_saver_mode()
2564 vidd_load_palette(scp->sc->adp, pal); in set_scrn_saver_mode()
2570 scp->mode = scp->splash_save_mode; in set_scrn_saver_mode()
2571 scp->status &= ~(UNKNOWN_MODE | SAVER_RUNNING); in set_scrn_saver_mode()
2572 scp->status |= scp->splash_save_status; in set_scrn_saver_mode()
2585 /* assert(scp == scp->sc->cur_scp) */ in restore_scrn_saver_mode()
2587 mode = scp->mode; in restore_scrn_saver_mode()
2588 status = scp->status; in restore_scrn_saver_mode()
2589 scp->mode = scp->splash_save_mode; in restore_scrn_saver_mode()
2590 scp->status &= ~(UNKNOWN_MODE | SAVER_RUNNING); in restore_scrn_saver_mode()
2591 scp->status |= scp->splash_save_status; in restore_scrn_saver_mode()
2592 scp->sc->flags &= ~SC_SCRN_BLANKED; in restore_scrn_saver_mode()
2596 --scrn_blanked; in restore_scrn_saver_mode()
2603 if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_DIRECT) in restore_scrn_saver_mode()
2604 vidd_load_palette(scp->sc->adp, scp->sc->palette2); in restore_scrn_saver_mode()
2607 vidd_load_palette(scp->sc->adp, scp->sc->palette); in restore_scrn_saver_mode()
2609 --scrn_blanked; in restore_scrn_saver_mode()
2613 scp->mode = mode; in restore_scrn_saver_mode()
2614 scp->status = status; in restore_scrn_saver_mode()
2626 if (sc->flags & SC_SCRN_BLANKED) in stop_scrn_saver()
2629 mark_all(sc->cur_scp); in stop_scrn_saver()
2630 if (sc->delayed_next_scr) in stop_scrn_saver()
2631 sc_switch_scr(sc, sc->delayed_next_scr - 1); in stop_scrn_saver()
2643 if (sc && !(sc->flags & SC_SCRN_BLANKED)) { in wait_scrn_saver_stop()
2673 if (sc->cur_scp == NULL) in sc_switch_scr()
2677 if (sc->flags & SC_SCRN_VTYLOCK) { in sc_switch_scr()
2678 sc_bell(sc->cur_scp, sc->cur_scp->bell_pitch, in sc_switch_scr()
2679 sc->cur_scp->bell_duration); in sc_switch_scr()
2684 if ((sc->flags & SC_SCRN_BLANKED) || sc->write_in_progress || in sc_switch_scr()
2685 sc->blink_in_progress) { in sc_switch_scr()
2686 sc->delayed_next_scr = next_scr + 1; in sc_switch_scr()
2691 sc->delayed_next_scr = 0; in sc_switch_scr()
2694 cur_scp = sc->cur_scp; in sc_switch_scr()
2697 if (sc->switch_in_progress && (cur_scp->smode.mode == VT_PROCESS) && in sc_switch_scr()
2698 cur_scp->proc) { in sc_switch_scr()
2699 p = pfind(cur_scp->pid); in sc_switch_scr()
2700 if (cur_scp->proc != p) { in sc_switch_scr()
2705 * up. NOTE:`cur_scp->proc' and `cur_scp->smode.mode' in sc_switch_scr()
2710 cur_scp->pid)); in sc_switch_scr()
2711 if (cur_scp->status & SWITCH_WAIT_REL) { in sc_switch_scr()
2721 } else if (cur_scp->status & SWITCH_WAIT_ACQ) { in sc_switch_scr()
2745 if (cur_scp->status & SWITCH_WAIT_REL) { in sc_switch_scr()
2746 switch (sc->switch_in_progress++) { in sc_switch_scr()
2768 } else if (cur_scp->status & SWITCH_WAIT_ACQ) { in sc_switch_scr()
2769 switch (sc->switch_in_progress++) { in sc_switch_scr()
2794 if ((next_scr < sc->first_vty) || in sc_switch_scr()
2795 (next_scr >= sc->first_vty + sc->vtys) || sc->switch_in_progress) { in sc_switch_scr()
2807 tp = SC_DEV(sc, cur_scp->index); in sc_switch_scr()
2808 if ((cur_scp->index != next_scr) && tty_opened_ns(tp) && in sc_switch_scr()
2809 (cur_scp->smode.mode == VT_AUTO) && ISGRAPHSC(cur_scp)) { in sc_switch_scr()
2822 if ((sc_console == NULL) || (next_scr != sc_console->index)) { in sc_switch_scr()
2830 if (kdb_active && SC_STAT(tp)->smode.mode == VT_PROCESS) { in sc_switch_scr()
2839 ++sc->switch_in_progress; in sc_switch_scr()
2840 sc->old_scp = cur_scp; in sc_switch_scr()
2841 sc->new_scp = sc_get_stat(SC_DEV(sc, next_scr)); in sc_switch_scr()
2842 if (sc->new_scp == sc->old_scp) { in sc_switch_scr()
2843 sc->switch_in_progress = 0; in sc_switch_scr()
2846 * the lock is in an in-between state, e.g., when we stop at in sc_switch_scr()
2860 vt_proc_alive(sc->old_scp); in sc_switch_scr()
2861 vt_proc_alive(sc->new_scp); in sc_switch_scr()
2865 if (signal_vt_rel(sc->old_scp)) { in sc_switch_scr()
2880 if (signal_vt_acq(sc->cur_scp)) { in sc_switch_scr()
2885 sc->switch_in_progress = 0; in sc_switch_scr()
2886 if (sc->unit == sc_console_unit) in sc_switch_scr()
2897 vt_proc_alive(sc->new_scp); in do_switch_scr()
2902 /* sc->cur_scp == sc->new_scp */ in do_switch_scr()
2903 wakeup(VTY_WCHAN(sc, sc->cur_scp->index)); in do_switch_scr()
2906 if (!signal_vt_acq(sc->cur_scp)) { in do_switch_scr()
2907 sc->switch_in_progress = 0; in do_switch_scr()
2908 if (sc->unit == sc_console_unit) in do_switch_scr()
2920 if (scp->proc) { in vt_proc_alive()
2921 if ((p = pfind(scp->pid)) != NULL) in vt_proc_alive()
2923 if (scp->proc == p) in vt_proc_alive()
2925 scp->proc = NULL; in vt_proc_alive()
2926 scp->smode.mode = VT_AUTO; in vt_proc_alive()
2927 DPRINTF(5, ("vt controlling process %d died\n", scp->pid)); in vt_proc_alive()
2935 if (scp->smode.mode != VT_PROCESS) in signal_vt_rel()
2937 scp->status |= SWITCH_WAIT_REL; in signal_vt_rel()
2938 PROC_LOCK(scp->proc); in signal_vt_rel()
2939 kern_psignal(scp->proc, scp->smode.relsig); in signal_vt_rel()
2940 PROC_UNLOCK(scp->proc); in signal_vt_rel()
2941 DPRINTF(5, ("sending relsig to %d\n", scp->pid)); in signal_vt_rel()
2948 if (scp->smode.mode != VT_PROCESS) in signal_vt_acq()
2950 if (scp->sc->unit == sc_console_unit) in signal_vt_acq()
2952 scp->status |= SWITCH_WAIT_ACQ; in signal_vt_acq()
2953 PROC_LOCK(scp->proc); in signal_vt_acq()
2954 kern_psignal(scp->proc, scp->smode.acqsig); in signal_vt_acq()
2955 PROC_UNLOCK(scp->proc); in signal_vt_acq()
2956 DPRINTF(5, ("sending acqsig to %d\n", scp->pid)); in signal_vt_acq()
2963 if (scp == scp->sc->old_scp && scp->status & SWITCH_WAIT_REL) { in finish_vt_rel()
2964 scp->status &= ~SWITCH_WAIT_REL; in finish_vt_rel()
2966 *s = do_switch_scr(scp->sc, *s); in finish_vt_rel()
2968 scp->sc->switch_in_progress = 0; in finish_vt_rel()
2977 if (scp == scp->sc->new_scp && scp->status & SWITCH_WAIT_ACQ) { in finish_vt_acq()
2978 scp->status &= ~SWITCH_WAIT_ACQ; in finish_vt_acq()
2979 scp->sc->switch_in_progress = 0; in finish_vt_acq()
2991 sc_move_cursor(sc->old_scp, sc->old_scp->xpos, sc->old_scp->ypos); in exchange_scr()
2992 if (!ISGRAPHSC(sc->old_scp)) in exchange_scr()
2993 sc_remove_cursor_image(sc->old_scp); in exchange_scr()
2994 if (sc->old_scp->kbd_mode == K_XLATE) in exchange_scr()
2995 save_kbd_state(sc->old_scp); in exchange_scr()
2998 scp = sc->cur_scp = sc->new_scp; in exchange_scr()
2999 if (sc->old_scp->mode != scp->mode || ISUNKNOWNSC(sc->old_scp)) in exchange_scr()
3002 sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, scp->xsize, scp->ysize, in exchange_scr()
3003 (void *)sc->adp->va_window, FALSE); in exchange_scr()
3004 scp->status |= MOUSE_HIDDEN; in exchange_scr()
3005 sc_move_cursor(scp, scp->xpos, scp->ypos); in exchange_scr()
3009 if (ISGRAPHSC(sc->old_scp)) { in exchange_scr()
3011 if (sc->adp->va_info.vi_mem_model == V_INFO_MM_DIRECT) in exchange_scr()
3012 vidd_load_palette(sc->adp, sc->palette2); in exchange_scr()
3015 vidd_load_palette(sc->adp, sc->palette); in exchange_scr()
3018 sc_set_border(scp, scp->border); in exchange_scr()
3021 if (sc->kbd_open_level == 0 && sc->old_scp->kbd_mode != scp->kbd_mode) in exchange_scr()
3022 (void)kbdd_ioctl(sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); in exchange_scr()
3023 update_kbd_state(scp, scp->status, LOCK_MASK); in exchange_scr()
3033 if (!sticky_splash && scp == scp->sc->cur_scp && !sc_saver_keyb_only) in sc_puts()
3037 if (scp->tsw) in sc_puts()
3038 (*scp->tsw->te_puts)(scp, buf, len); in sc_puts()
3039 if (scp->sc->delayed_next_scr) in sc_puts()
3040 sc_switch_scr(scp->sc, scp->sc->delayed_next_scr - 1); in sc_puts()
3046 /* assert(scp == scp->sc->cur_scp); */ in sc_draw_cursor_image()
3047 SC_VIDEO_LOCK(scp->sc); in sc_draw_cursor_image()
3048 (*scp->rndr->draw_cursor)(scp, scp->cursor_pos, in sc_draw_cursor_image()
3049 scp->curs_attr.flags & CONS_BLINK_CURSOR, TRUE, in sc_draw_cursor_image()
3050 sc_inside_cutmark(scp, scp->cursor_pos)); in sc_draw_cursor_image()
3051 scp->cursor_oldpos = scp->cursor_pos; in sc_draw_cursor_image()
3052 SC_VIDEO_UNLOCK(scp->sc); in sc_draw_cursor_image()
3058 /* assert(scp == scp->sc->cur_scp); */ in sc_remove_cursor_image()
3059 SC_VIDEO_LOCK(scp->sc); in sc_remove_cursor_image()
3060 (*scp->rndr->draw_cursor)(scp, scp->cursor_oldpos, in sc_remove_cursor_image()
3061 scp->curs_attr.flags & CONS_BLINK_CURSOR, FALSE, in sc_remove_cursor_image()
3062 sc_inside_cutmark(scp, scp->cursor_oldpos)); in sc_remove_cursor_image()
3063 SC_VIDEO_UNLOCK(scp->sc); in sc_remove_cursor_image()
3069 /* assert(scp == scp->sc->cur_scp); */ in update_cursor_image()
3078 scp->curs_attr = scp->base_curs_attr; in sc_set_cursor_image()
3079 if (scp->curs_attr.flags & CONS_HIDDEN_CURSOR) { in sc_set_cursor_image()
3080 /* hidden cursor is internally represented as zero-height in sc_set_cursor_image()
3082 scp->curs_attr.flags = CONS_CHAR_CURSOR; in sc_set_cursor_image()
3083 scp->curs_attr.base = scp->curs_attr.height = 0; in sc_set_cursor_image()
3084 } else if (scp->curs_attr.flags & CONS_CHAR_CURSOR) { in sc_set_cursor_image()
3085 scp->curs_attr.base = in sc_set_cursor_image()
3086 imin(scp->base_curs_attr.base, scp->font_size - 1); in sc_set_cursor_image()
3087 scp->curs_attr.height = imin(scp->base_curs_attr.height, in sc_set_cursor_image()
3088 scp->font_size - scp->curs_attr.base); in sc_set_cursor_image()
3090 scp->curs_attr.base = 0; in sc_set_cursor_image()
3091 scp->curs_attr.height = scp->font_size; in sc_set_cursor_image()
3094 /* assert(scp == scp->sc->cur_scp); */ in sc_set_cursor_image()
3095 SC_VIDEO_LOCK(scp->sc); in sc_set_cursor_image()
3096 (*scp->rndr->set_cursor)(scp, scp->curs_attr.base, in sc_set_cursor_image()
3097 scp->curs_attr.height, scp->curs_attr.flags & CONS_BLINK_CURSOR); in sc_set_cursor_image()
3098 SC_VIDEO_UNLOCK(scp->sc); in sc_set_cursor_image()
3105 cap->bg[0] = base & 0xff; in sc_adjust_ca()
3106 cap->bg[1] = height & 0xff; in sc_adjust_ca()
3108 cap->mouse_ba = base & 0xff; in sc_adjust_ca()
3109 cap->mouse_ia = height & 0xff; in sc_adjust_ca()
3112 cap->base = base; in sc_adjust_ca()
3114 cap->height = height; in sc_adjust_ca()
3116 cap->flags = flags & CONS_CURSOR_ATTRS; in sc_adjust_ca()
3123 if ((scp == scp->sc->cur_scp) && !ISGRAPHSC(scp)) in change_cursor_shape()
3127 scp->base_curs_attr = scp->dflt_curs_attr; in change_cursor_shape()
3129 sc_adjust_ca(&scp->dflt_curs_attr, flags, base, height); in change_cursor_shape()
3130 scp->base_curs_attr = scp->dflt_curs_attr; in change_cursor_shape()
3132 sc_adjust_ca(&scp->base_curs_attr, flags, base, height); in change_cursor_shape()
3134 if ((scp == scp->sc->cur_scp) && !ISGRAPHSC(scp)) { in change_cursor_shape()
3148 if (flags == -1) in sc_change_cursor_shape()
3160 sc = scp->sc; in sc_change_cursor_shape()
3162 sc->curs_attr = sc->dflt_curs_attr; in sc_change_cursor_shape()
3164 sc_adjust_ca(&sc->dflt_curs_attr, flags, base, height); in sc_change_cursor_shape()
3165 sc->curs_attr = sc->dflt_curs_attr; in sc_change_cursor_shape()
3167 sc_adjust_ca(&sc->curs_attr, flags, base, height); in sc_change_cursor_shape()
3169 for (i = sc->first_vty; i < sc->first_vty + sc->vtys; ++i) { in sc_change_cursor_shape()
3174 scp->dflt_curs_attr = sc->curs_attr; in sc_change_cursor_shape()
3175 change_cursor_shape(scp, CONS_RESET_CURSOR, -1, -1); in sc_change_cursor_shape()
3231 dflt_kattrtab[i % (nitems(dflt_kattrtab) - 1)]; in scinit()
3241 if ((sc->flags & SC_INIT_DONE) == 0) in scinit()
3245 if (sc->adapter >= 0) { in scinit()
3246 vid_release(sc->adp, (void *)&sc->adapter); in scinit()
3247 adp = sc->adp; in scinit()
3248 sc->adp = NULL; in scinit()
3250 if (sc->kbd != NULL) { in scinit()
3252 sc->kbd->kb_index)); in scinit()
3253 i = kbd_release(sc->kbd, (void *)&sc->kbd); in scinit()
3255 if (sc->kbd != NULL) { in scinit()
3258 unit, sc->kbd->kb_index, sc->kbd->kb_unit, in scinit()
3259 sc->kbd->kb_flags)); in scinit()
3261 sc->kbd = NULL; in scinit()
3263 sc->adapter = vid_allocate("*", unit, (void *)&sc->adapter); in scinit()
3264 sc->adp = vid_get_adapter(sc->adapter); in scinit()
3265 /* assert((sc->adapter >= 0) && (sc->adp != NULL)) */ in scinit()
3270 sc->kbd = kbd_get_keyboard(kbdidx); in scinit()
3271 if (sc->kbd != NULL) { in scinit()
3274 sc->kbd->kb_index, sc->kbd->kb_unit, in scinit()
3275 sc->kbd->kb_flags)); in scinit()
3278 if (!(sc->flags & SC_INIT_DONE) || (adp != sc->adp)) { in scinit()
3279 sc->initial_mode = sc->adp->va_initial_mode; in scinit()
3283 sc->font_8 = font_8; in scinit()
3284 sc->font_14 = font_14; in scinit()
3285 sc->font_16 = font_16; in scinit()
3286 } else if (sc->font_8 == NULL) { in scinit()
3288 sc->font_8 = malloc(sizeof(font_8), M_DEVBUF, M_WAITOK); in scinit()
3289 sc->font_14 = in scinit()
3291 sc->font_16 = in scinit()
3298 vidd_read_hw_cursor(sc->adp, &col, &row); in scinit()
3299 vidd_set_hw_cursor(sc->adp, -1, -1); in scinit()
3302 sc->first_vty = unit * MAXCONS; in scinit()
3303 sc->vtys = MAXCONS; /* XXX: should be configurable */ in scinit()
3310 sc->dev = main_devs; in scinit()
3312 init_scp(sc, sc->first_vty, scp); in scinit()
3313 sc_vtb_init(&scp->vtb, VTB_MEMORY, scp->xsize, in scinit()
3314 scp->ysize, (void *)sc_buffer, FALSE); in scinit()
3317 (*scp->tsw->te_default_attr)( in scinit()
3321 sc->dev = malloc(sizeof(struct tty *) * sc->vtys, in scinit()
3323 sc->dev[0] = sc_alloc_tty(0, unit * MAXCONS); in scinit()
3324 scp = alloc_scp(sc, sc->first_vty); in scinit()
3325 SC_STAT(sc->dev[0]) = scp; in scinit()
3327 sc->cur_scp = scp; in scinit()
3330 sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, scp->xsize, scp->ysize, in scinit()
3331 (void *)scp->sc->adp->va_window, FALSE); in scinit()
3333 sc_vtb_copy(&scp->scr, 0, &scp->vtb, 0, in scinit()
3334 scp->xsize * scp->ysize); in scinit()
3337 if (col >= scp->xsize) in scinit()
3339 if (row >= scp->ysize) in scinit()
3340 row = scp->ysize - 1; in scinit()
3341 scp->xpos = col; in scinit()
3342 scp->ypos = row; in scinit()
3343 scp->cursor_pos = scp->cursor_oldpos = row * scp->xsize + col; in scinit()
3344 (*scp->tsw->te_sync)(scp); in scinit()
3346 sc->dflt_curs_attr.base = 0; in scinit()
3347 sc->dflt_curs_attr.height = howmany(scp->font_size, 8); in scinit()
3348 sc->dflt_curs_attr.flags = 0; in scinit()
3349 sc->dflt_curs_attr.bg[0] = FG_RED; in scinit()
3350 sc->dflt_curs_attr.bg[1] = FG_LIGHTGREY; in scinit()
3351 sc->dflt_curs_attr.bg[2] = FG_BLUE; in scinit()
3352 sc->dflt_curs_attr.mouse_ba = FG_WHITE; in scinit()
3353 sc->dflt_curs_attr.mouse_ia = FG_RED; in scinit()
3354 sc->curs_attr = sc->dflt_curs_attr; in scinit()
3355 scp->base_curs_attr = scp->dflt_curs_attr = sc->curs_attr; in scinit()
3356 scp->curs_attr = scp->base_curs_attr; in scinit()
3359 sc_mouse_move(scp, scp->xpixel / 2, scp->ypixel / 2); in scinit()
3368 sc->fonts_loaded = 0; in scinit()
3369 if (ISFONTAVAIL(sc->adp->va_flags)) { in scinit()
3371 bcopy(dflt_font_8, sc->font_8, sizeof(dflt_font_8)); in scinit()
3372 bcopy(dflt_font_14, sc->font_14, sizeof(dflt_font_14)); in scinit()
3373 bcopy(dflt_font_16, sc->font_16, sizeof(dflt_font_16)); in scinit()
3374 sc->fonts_loaded = FONT_16 | FONT_14 | FONT_8; in scinit()
3375 if (scp->font_size < 14) { in scinit()
3376 sc_load_font(scp, 0, 8, 8, sc->font_8, 0, 256); in scinit()
3377 } else if (scp->font_size >= 16) { in scinit()
3379 scp, 0, 16, 8, sc->font_16, 0, 256); in scinit()
3382 scp, 0, 14, 8, sc->font_14, 0, 256); in scinit()
3385 if (scp->font_size < 14) { in scinit()
3386 sc_save_font(scp, 0, 8, 8, sc->font_8, 0, 256); in scinit()
3387 sc->fonts_loaded = FONT_8; in scinit()
3388 } else if (scp->font_size >= 16) { in scinit()
3390 scp, 0, 16, 8, sc->font_16, 0, 256); in scinit()
3391 sc->fonts_loaded = FONT_16; in scinit()
3394 scp, 0, 14, 8, sc->font_14, 0, 256); in scinit()
3395 sc->fonts_loaded = FONT_14; in scinit()
3404 vidd_save_palette(sc->adp, sc->palette); in scinit()
3406 for (i = 0; i < sizeof(sc->palette2); i++) in scinit()
3407 sc->palette2[i] = i / 3; in scinit()
3412 if (!(sc->flags & SC_SPLASH_SCRN)) { in scinit()
3414 splash_init(sc->adp, scsplash_callback, sc); in scinit()
3415 sc->flags |= SC_SPLASH_SCRN; in scinit()
3421 if (sc->flags & SC_INIT_DONE) in scinit()
3425 for (i = 0; i < sizeof(sc->scr_map); i++) in scinit()
3426 sc->scr_map[i] = sc->scr_rmap[i] = i; in scinit()
3428 sc->flags |= SC_INIT_DONE; in scinit()
3443 if (sc->flags & SC_SPLASH_SCRN) { in scterm()
3444 splash_term(sc->adp); in scterm()
3445 sc->flags &= ~SC_SPLASH_SCRN; in scterm()
3450 /* move the hardware cursor to the upper-left corner */ in scterm()
3451 vidd_set_hw_cursor(sc->adp, 0, 0); in scterm()
3455 if (sc->kbd != NULL) in scterm()
3456 kbd_release(sc->kbd, &sc->kbd); in scterm()
3457 if (sc->adapter >= 0) in scterm()
3458 vid_release(sc->adp, &sc->adapter); in scterm()
3461 scp = sc_get_stat(sc->dev[0]); in scterm()
3462 if (scp->tsw) in scterm()
3463 (*scp->tsw->te_term)(scp, &scp->ts); in scterm()
3464 mtx_destroy(&sc->video_mtx); in scterm()
3468 free(scp->ts, M_DEVBUF); in scterm()
3470 free(sc->dev, M_DEVBUF); in scterm()
3473 free(sc->tty, M_DEVBUF); in scterm()
3476 free(sc->font_8, M_DEVBUF); in scterm()
3477 free(sc->font_14, M_DEVBUF); in scterm()
3478 free(sc->font_16, M_DEVBUF); in scterm()
3483 sc->adapter = -1; in scterm()
3491 KASSERT(sc_console->sc != NULL, ("sc_console->sc != NULL")); in scshutdown()
3492 KASSERT(sc_console->sc->cur_scp != NULL, in scshutdown()
3493 ("sc_console->sc->cur_scp != NULL")); in scshutdown()
3496 if (!cold && sc_console->sc->cur_scp->index != sc_console->index && in scshutdown()
3497 sc_console->sc->cur_scp->smode.mode == VT_AUTO && in scshutdown()
3498 sc_console->smode.mode == VT_AUTO) in scshutdown()
3499 sc_switch_scr(sc_console->sc, sc_console->index); in scshutdown()
3509 KASSERT(sc_console->sc != NULL, ("sc_console->sc != NULL")); in scsuspend()
3510 KASSERT(sc_console->sc->cur_scp != NULL, in scsuspend()
3511 ("sc_console->sc->cur_scp != NULL")); in scsuspend()
3513 sc_susp_scr = sc_console->sc->cur_scp->index; in scsuspend()
3514 if (sc_no_suspend_vtswitch || sc_susp_scr == sc_console->index) { in scsuspend()
3516 sc_susp_scr = -1; in scsuspend()
3520 sc_switch_scr(sc_console->sc, sc_console->index); in scsuspend()
3521 if (!sc_console->sc->switch_in_progress) in scsuspend()
3523 pause("scsuspend", hz); in scsuspend()
3533 KASSERT(sc_console->sc != NULL, ("sc_console->sc != NULL")); in scresume()
3534 KASSERT(sc_console->sc->cur_scp != NULL, in scresume()
3535 ("sc_console->sc->cur_scp != NULL")); in scresume()
3539 update_font(sc_console->sc->cur_scp); in scresume()
3542 sc_switch_scr(sc_console->sc, sc_susp_scr); in scresume()
3552 if (scp->sc->flags & SC_SCRN_BLANKED) { in sc_clean_up()
3555 if ((error = wait_scrn_saver_stop(scp->sc))) in sc_clean_up()
3559 scp->status |= MOUSE_HIDDEN; in sc_clean_up()
3571 old = scp->vtb; in sc_alloc_scr_buffer()
3572 sc_vtb_init(&new, VTB_MEMORY, scp->xsize, scp->ysize, NULL, wait); in sc_alloc_scr_buffer()
3575 scp->cursor_oldpos = scp->cursor_pos; in sc_alloc_scr_buffer()
3580 sc_vtb_copy(&old, 0, &new, 0, scp->xsize * scp->ysize); in sc_alloc_scr_buffer()
3581 scp->vtb = new; in sc_alloc_scr_buffer()
3583 scp->vtb = new; in sc_alloc_scr_buffer()
3589 sc_mouse_move(scp, scp->xpixel / 2, scp->ypixel / 2); in sc_alloc_scr_buffer()
3625 scp->index = vty; in init_scp()
3626 scp->sc = sc; in init_scp()
3627 scp->status = 0; in init_scp()
3628 scp->mode = sc->initial_mode; in init_scp()
3629 vidd_get_info(sc->adp, scp->mode, &info); in init_scp()
3631 scp->status |= GRAPHICS_MODE; in init_scp()
3632 scp->xpixel = info.vi_width; in init_scp()
3633 scp->ypixel = info.vi_height; in init_scp()
3634 scp->xsize = info.vi_width / info.vi_cwidth; in init_scp()
3635 scp->ysize = info.vi_height / info.vi_cheight; in init_scp()
3636 scp->font_size = 0; in init_scp()
3637 scp->font = NULL; in init_scp()
3639 scp->xsize = info.vi_width; in init_scp()
3640 scp->ysize = info.vi_height; in init_scp()
3641 scp->xpixel = scp->xsize * info.vi_cwidth; in init_scp()
3642 scp->ypixel = scp->ysize * info.vi_cheight; in init_scp()
3645 scp->font_size = info.vi_cheight; in init_scp()
3646 scp->font_width = info.vi_cwidth; in init_scp()
3649 scp->font = sc->font_8; in init_scp()
3651 scp->font = sc->font_16; in init_scp()
3653 scp->font = sc->font_14; in init_scp()
3655 scp->font = NULL; in init_scp()
3658 sc_vtb_init(&scp->vtb, VTB_MEMORY, 0, 0, NULL, FALSE); in init_scp()
3659 sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, 0, 0, NULL, FALSE); in init_scp()
3660 scp->xoff = scp->yoff = 0; in init_scp()
3661 scp->xpos = scp->ypos = 0; in init_scp()
3662 scp->start = scp->xsize * scp->ysize - 1; in init_scp()
3663 scp->end = 0; in init_scp()
3664 scp->tsw = NULL; in init_scp()
3665 scp->ts = NULL; in init_scp()
3666 scp->rndr = NULL; in init_scp()
3667 scp->border = (SC_NORM_ATTR >> 4) & 0x0f; in init_scp()
3668 scp->base_curs_attr = scp->dflt_curs_attr = sc->curs_attr; in init_scp()
3669 scp->mouse_cut_start = scp->xsize * scp->ysize; in init_scp()
3670 scp->mouse_cut_end = -1; in init_scp()
3671 scp->mouse_signal = 0; in init_scp()
3672 scp->mouse_pid = 0; in init_scp()
3673 scp->mouse_proc = NULL; in init_scp()
3674 scp->kbd_mode = K_XLATE; in init_scp()
3675 scp->bell_pitch = bios_value.bell_pitch; in init_scp()
3676 scp->bell_duration = BELL_DURATION; in init_scp()
3677 scp->status |= (bios_value.shift_state & NLKED); in init_scp()
3678 scp->status |= CURSOR_ENABLED | MOUSE_HIDDEN; in init_scp()
3679 scp->pid = 0; in init_scp()
3680 scp->proc = NULL; in init_scp()
3681 scp->smode.mode = VT_AUTO; in init_scp()
3682 scp->history = NULL; in init_scp()
3683 scp->history_pos = 0; in init_scp()
3684 scp->history_size = 0; in init_scp()
3696 sw = scp->tsw; in sc_init_emulator()
3703 if (strcmp(sw->te_renderer, "*") != 0) { in sc_init_emulator()
3704 rndr = sc_render_match(scp, sw->te_renderer, in sc_init_emulator()
3705 scp->status & (GRAPHICS_MODE | PIXEL_MODE)); in sc_init_emulator()
3708 rndr = sc_render_match(scp, scp->sc->adp->va_name, in sc_init_emulator()
3709 scp->status & (GRAPHICS_MODE | PIXEL_MODE)); in sc_init_emulator()
3714 if (sw == scp->tsw) { in sc_init_emulator()
3715 error = (*sw->te_init)(scp, &scp->ts, SC_TE_WARM_INIT); in sc_init_emulator()
3716 scp->rndr = rndr; in sc_init_emulator()
3717 scp->rndr->init(scp); in sc_init_emulator()
3723 if (sc_malloc && (sw->te_size > 0)) in sc_init_emulator()
3724 p = malloc(sw->te_size, M_DEVBUF, M_NOWAIT); in sc_init_emulator()
3727 error = (*sw->te_init)(scp, &p, SC_TE_COLD_INIT); in sc_init_emulator()
3731 if (scp->tsw) in sc_init_emulator()
3732 (*scp->tsw->te_term)(scp, &scp->ts); in sc_init_emulator()
3733 if (scp->ts != NULL) in sc_init_emulator()
3734 free(scp->ts, M_DEVBUF); in sc_init_emulator()
3735 scp->tsw = sw; in sc_init_emulator()
3736 scp->ts = p; in sc_init_emulator()
3737 scp->rndr = rndr; in sc_init_emulator()
3738 scp->rndr->init(scp); in sc_init_emulator()
3740 (*sw->te_default_attr)(scp, SC_NORM_ATTR, SC_NORM_REV_ATTR); in sc_init_emulator()
3747 * scgetc(flags) - get character from keyboard.
3764 if (sc->kbd == NULL) in scgetc()
3771 sccnupdate(sc->cur_scp); in scgetc()
3773 scp = sc->cur_scp; in scgetc()
3778 c = kbdd_read_char(sc->kbd, !(flags & SCGETC_NONBLOCK)); in scgetc()
3798 if (sc->kbd_open_level == 0 && scp->kbd_mode != K_XLATE) in scgetc()
3801 /* if scroll-lock pressed allow history browsing */ in scgetc()
3802 if (!ISGRAPHSC(scp) && scp->history && scp->status & SLKED) { in scgetc()
3803 scp->status &= ~CURSOR_ENABLED; in scgetc()
3807 if (!(scp->status & BUFFER_SAVED)) { in scgetc()
3808 scp->status |= BUFFER_SAVED; in scgetc()
3841 for (i = 0; i < scp->ysize; i++) in scgetc()
3853 for (i = 0; i < scp->ysize; i++) in scgetc()
3885 sc->kbd, KDGKBSTATE, (caddr_t)&f); in scgetc()
3887 scp->status |= SLKED; in scgetc()
3889 if (scp->status & SLKED) { in scgetc()
3890 scp->status &= ~SLKED; in scgetc()
3892 if (scp->status & in scgetc()
3898 scp->status &= in scgetc()
3900 scp->status |= in scgetc()
3905 /* Only safe in Giant-locked in scgetc()
3907 tp = SC_DEV(sc, scp->index); in scgetc()
3922 /* NON-LOCKING KEYS */ in scgetc()
3935 if (!(sc->flags & SC_SCRN_BLANKED)) in scgetc()
3943 if (!(sc->flags & SC_SCRN_BLANKED)) { in scgetc()
3945 sc->scrn_time_stamp -= scrn_blank_time; in scgetc()
3953 if (sc->flags & SC_SCRN_BLANKED) { in scgetc()
4009 this_scr = scp->index; in scgetc()
4010 for (i = (this_scr - sc->first_vty + 1) % in scgetc()
4011 sc->vtys; in scgetc()
4012 sc->first_vty + i != this_scr; in scgetc()
4013 i = (i + 1) % sc->vtys) { in scgetc()
4015 SC_DEV(sc, sc->first_vty + i); in scgetc()
4018 scp->sc, sc->first_vty + i); in scgetc()
4025 this_scr = scp->index; in scgetc()
4026 for (i = (this_scr - sc->first_vty + sc->vtys - in scgetc()
4028 sc->vtys; in scgetc()
4029 sc->first_vty + i != this_scr; in scgetc()
4030 i = (i + sc->vtys - 1) % sc->vtys) { in scgetc()
4032 SC_DEV(sc, sc->first_vty + i); in scgetc()
4035 scp->sc, sc->first_vty + i); in scgetc()
4044 sc_switch_scr(scp->sc, in scgetc()
4045 sc->first_vty + KEYCHAR(c) - F_SCR); in scgetc()
4049 if (!(sc->flags & SC_SCRN_BLANKED)) in scgetc()
4058 kdb_alt_break(c, &sc->sc_altbrk); in scgetc()
4060 if (!(sc->flags & SC_SCRN_BLANKED)) in scgetc()
4075 if (scp != scp->sc->cur_scp) in sctty_mmap()
4076 return -1; in sctty_mmap()
4077 return vidd_mmap(scp->sc->adp, offset, paddr, nprot, memattr); in sctty_mmap()
4085 if (!(scp->status & GRAPHICS_MODE)) { in update_font()
4086 if (!(scp->status & PIXEL_MODE) && in update_font()
4087 ISFONTAVAIL(scp->sc->adp->va_flags)) { in update_font()
4088 if (scp->font_size < 14) { in update_font()
4089 if (scp->sc->fonts_loaded & FONT_8) in update_font()
4091 scp->sc->font_8, 0, 256); in update_font()
4092 } else if (scp->font_size >= 16) { in update_font()
4093 if (scp->sc->fonts_loaded & FONT_16) in update_font()
4095 scp->sc->font_16, 0, 256); in update_font()
4097 if (scp->sc->fonts_loaded & FONT_14) in update_font()
4099 scp->sc->font_14, 0, 256); in update_font()
4121 error = kbdd_ioctl(scp->sc->kbd, KDGKBSTATE, (caddr_t)&state); in save_kbd_state()
4125 scp->status &= ~LOCK_MASK; in save_kbd_state()
4126 scp->status |= state; in save_kbd_state()
4138 error = kbdd_ioctl(scp->sc->kbd, KDGKBSTATE, (caddr_t)&state); in update_kbd_state()
4148 error = kbdd_ioctl(scp->sc->kbd, KDSKBSTATE, (caddr_t)&state); in update_kbd_state()
4160 error = kbdd_ioctl(scp->sc->kbd, KDSETLED, (caddr_t)&which); in update_kbd_leds()
4172 if (vidd_get_info(scp->sc->adp, scp->mode, &info)) in set_mode()
4176 if (scp != scp->sc->cur_scp) in set_mode()
4180 vidd_set_mode(scp->sc->adp, scp->mode); in set_mode()
4181 scp->rndr->init(scp); in set_mode()
4182 sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, scp->xsize, scp->ysize, in set_mode()
4183 (void *)scp->sc->adp->va_window, FALSE); in set_mode()
4187 sc_set_border(scp, scp->border); in set_mode()
4196 SC_VIDEO_LOCK(scp->sc); in sc_set_border()
4197 (*scp->rndr->draw_border)(scp, color); in sc_set_border()
4198 SC_VIDEO_UNLOCK(scp->sc); in sc_set_border()
4208 sc = scp->sc; in sc_load_font()
4209 sc->font_loading_in_progress = TRUE; in sc_load_font()
4210 vidd_load_font(sc->adp, page, size, width, buf, base, count); in sc_load_font()
4211 sc->font_loading_in_progress = FALSE; in sc_load_font()
4220 sc = scp->sc; in sc_save_font()
4221 sc->font_loading_in_progress = TRUE; in sc_save_font()
4222 vidd_save_font(sc->adp, page, size, width, buf, base, count); in sc_save_font()
4223 sc->font_loading_in_progress = FALSE; in sc_save_font()
4229 vidd_show_font(scp->sc->adp, page); in sc_show_font()
4239 tp = SC_DEV(scp->sc, scp->sc->cur_scp->index); in sc_paste()
4242 rmap = scp->sc->scr_rmap; in sc_paste()
4243 for (; count > 0; --count) in sc_paste()
4253 tp = SC_DEV(scp->sc, scp->sc->cur_scp->index); in sc_respond()
4265 * we convert it back to Hz.
4266 * duration is in ticks of 1/hz.
4274 if (scp != scp->sc->cur_scp && (scp->sc->flags & SC_QUIET_BELL)) in sc_bell()
4277 if (scp->sc->flags & SC_VISUAL_BELL) { in sc_bell()
4278 if (scp->sc->blink_in_progress) in sc_bell()
4280 scp->sc->blink_in_progress = 3; in sc_bell()
4281 if (scp != scp->sc->cur_scp) in sc_bell()
4282 scp->sc->blink_in_progress += 2; in sc_bell()
4283 blink_screen(scp->sc->cur_scp); in sc_bell()
4285 if (scp != scp->sc->cur_scp) in sc_bell()
4287 sysbeep(1193182 / pitch, SBT_1S * duration / hz); in sc_bell()
4305 if (ISGRAPHSC(scp) || (scp->sc->blink_in_progress <= 1)) { in blink_screen()
4306 scp->sc->blink_in_progress = 0; in blink_screen()
4308 tp = SC_DEV(scp->sc, scp->index); in blink_screen()
4311 if (scp->sc->delayed_next_scr) in blink_screen()
4312 sc_switch_scr(scp->sc, scp->sc->delayed_next_scr - 1); in blink_screen()
4314 (*scp->rndr->draw)(scp, 0, scp->xsize * scp->ysize, in blink_screen()
4315 scp->sc->blink_in_progress & 1); in blink_screen()
4316 scp->sc->blink_in_progress--; in blink_screen()
4317 callout_reset_sbt(&scp->sc->cblink, SBT_1S / 15, 0, in blink_screen()
4324 * to store the per-screen current status. This is the case when the
4341 * if found, add all non-busy keyboards to "kbdmux". Otherwise look for
4353 kbd_allocate("kbdmux", -1, (void *)&sc->kbd, sckbdevent, sc); in sc_allocate_keyboard()
4354 if (idx0 != -1) { in sc_allocate_keyboard()
4357 for (idx = kbd_find_keyboard2("*", -1, 0); idx != -1; in sc_allocate_keyboard()
4358 idx = kbd_find_keyboard2("*", -1, idx + 1)) { in sc_allocate_keyboard()
4365 strcpy(ki.kb_name, k->kb_name); in sc_allocate_keyboard()
4366 ki.kb_unit = k->kb_unit; in sc_allocate_keyboard()
4372 "*", unit, (void *)&sc->kbd, sckbdevent, sc); in sc_allocate_keyboard()