Lines Matching refs:tm

57 #define	TERMINAL_LOCK(tm)	do {					\
58 if ((tm)->tm_flags & TF_CONS) \
59 mtx_lock_spin(&(tm)->tm_mtx); \
60 else if ((tm)->tm_tty != NULL) \
61 tty_lock((tm)->tm_tty); \
63 #define TERMINAL_UNLOCK(tm) do { \
64 if ((tm)->tm_flags & TF_CONS) \
65 mtx_unlock_spin(&(tm)->tm_mtx); \
66 else if ((tm)->tm_tty != NULL) \
67 tty_unlock((tm)->tm_tty); \
69 #define TERMINAL_LOCK_TTY(tm) do { \
70 if ((tm)->tm_flags & TF_CONS) \
71 mtx_lock_spin(&(tm)->tm_mtx); \
73 #define TERMINAL_UNLOCK_TTY(tm) do { \
74 if ((tm)->tm_flags & TF_CONS) \
75 mtx_unlock_spin(&(tm)->tm_mtx); \
77 #define TERMINAL_LOCK_CONS(tm) mtx_lock_spin(&(tm)->tm_mtx)
78 #define TERMINAL_UNLOCK_CONS(tm) mtx_unlock_spin(&(tm)->tm_mtx)
163 terminal_init(struct terminal *tm)
166 if (tm->tm_flags & TF_CONS)
167 mtx_init(&tm->tm_mtx, "trmlck", NULL, MTX_SPIN);
168 teken_init(&tm->tm_emulator, &terminal_drawmethods, tm);
169 teken_set_defattr(&tm->tm_emulator, &default_message);
175 struct terminal *tm;
177 tm = malloc(sizeof(struct terminal), M_TERMINAL, M_WAITOK|M_ZERO);
178 terminal_init(tm);
180 tm->tm_class = tc;
181 tm->tm_softc = softc;
183 return (tm);
187 terminal_sync_ttysize(struct terminal *tm)
191 tp = tm->tm_tty;
196 tty_set_winsize(tp, &tm->tm_winsize);
201 terminal_maketty(struct terminal *tm, const char *fmt, ...)
211 tp = tty_alloc(&terminal_tty_class, tm);
213 tm->tm_tty = tp;
214 terminal_sync_ttysize(tm);
218 terminal_set_cursor(struct terminal *tm, const term_pos_t *pos)
221 teken_set_cursor(&tm->tm_emulator, pos);
225 terminal_set_winsize_blank(struct terminal *tm, const struct winsize *size,
230 tm->tm_winsize = *size;
236 TERMINAL_LOCK(tm);
238 teken_set_winsize_noreset(&tm->tm_emulator, &r.tr_end);
240 teken_set_winsize(&tm->tm_emulator, &r.tr_end);
241 TERMINAL_UNLOCK(tm);
243 if ((blank != 0) && !(tm->tm_flags & TF_MUTE))
244 tm->tm_class->tc_fill(tm, &r,
247 terminal_sync_ttysize(tm);
251 terminal_set_winsize(struct terminal *tm, const struct winsize *size)
254 terminal_set_winsize_blank(tm, size, 1,
265 terminal_mute(struct terminal *tm, int yes)
268 TERMINAL_LOCK(tm);
270 tm->tm_flags |= TF_MUTE;
272 tm->tm_flags &= ~TF_MUTE;
273 TERMINAL_UNLOCK(tm);
277 terminal_input_char(struct terminal *tm, term_char_t c)
281 tp = tm->tm_tty;
330 terminal_input_raw(struct terminal *tm, char c)
334 tp = tm->tm_tty;
345 terminal_input_special(struct terminal *tm, unsigned int k)
350 tp = tm->tm_tty;
354 str = teken_get_sequence(&tm->tm_emulator, k);
371 struct terminal *tm = tty_softc(tp);
373 tm->tm_class->tc_opened(tm, 1);
380 struct terminal *tm = tty_softc(tp);
382 tm->tm_class->tc_opened(tm, 0);
388 struct terminal *tm = tty_softc(tp);
394 TERMINAL_LOCK_TTY(tm);
395 if (!(tm->tm_flags & TF_MUTE)) {
396 tm->tm_flags &= ~TF_BELL;
397 teken_input(&tm->tm_emulator, obuf, olen);
398 flags |= tm->tm_flags;
400 TERMINAL_UNLOCK_TTY(tm);
403 TERMINAL_LOCK_TTY(tm);
404 if (!(tm->tm_flags & TF_MUTE))
405 tm->tm_class->tc_done(tm);
406 TERMINAL_UNLOCK_TTY(tm);
408 tm->tm_class->tc_bell(tm);
414 struct terminal *tm = tty_softc(tp);
427 p = teken_get_cursor(&tm->tm_emulator);
431 p = teken_get_winsize(&tm->tm_emulator);
435 teken_get_defattr_cons25(&tm->tm_emulator, &fg, &bg);
451 error = tm->tm_class->tc_ioctl(tm, cmd, data, td);
460 struct terminal *tm = tty_softc(tp);
462 return (tm->tm_class->tc_mmap(tm, offset, paddr, nprot, memattr));
488 termcn_cnregister(struct terminal *tm)
492 cp = tm->consdev;
497 cp->cn_arg = tm;
501 tm->tm_flags = TF_CONS;
502 tm->consdev = cp;
504 terminal_init(tm);
514 struct terminal *tm = cp->cn_arg;
516 tm->tm_class->tc_cngrab(tm);
522 struct terminal *tm = cp->cn_arg;
524 tm->tm_class->tc_cnungrab(tm);
530 struct terminal *tm = cp->cn_arg;
532 if (tm == NULL) {
537 tm->consdev = cp;
538 terminal_init(tm);
540 tm->tm_class->tc_cnprobe(tm, cp);
558 struct terminal *tm = cp->cn_arg;
560 return (tm->tm_class->tc_cngetc(tm));
566 struct terminal *tm = cp->cn_arg;
570 TERMINAL_LOCK_CONS(tm);
571 if (!(tm->tm_flags & TF_MUTE)) {
572 backup = *teken_get_curattr(&tm->tm_emulator);
573 teken_set_curattr(&tm->tm_emulator, &kernel_message);
574 teken_input(&tm->tm_emulator, &cv, 1);
575 teken_set_curattr(&tm->tm_emulator, &backup);
576 tm->tm_class->tc_done(tm);
578 TERMINAL_UNLOCK_CONS(tm);
588 struct terminal *tm = softc;
590 tm->tm_flags |= TF_BELL;
596 struct terminal *tm = softc;
598 tm->tm_class->tc_cursor(tm, p);
605 struct terminal *tm = softc;
607 tm->tm_class->tc_putchar(tm, p, TCHAR_CREATE(c, a));
614 struct terminal *tm = softc;
616 tm->tm_class->tc_fill(tm, r, TCHAR_CREATE(c, a));
622 struct terminal *tm = softc;
624 tm->tm_class->tc_copy(tm, r, p);
630 struct terminal *tm = softc;
632 tm->tm_class->tc_param(tm, cmd, arg);
639 struct terminal *tm = softc;
651 tp = tm->tm_tty;