1/*- 2 * Copyright (c) 2009 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 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: user/ed/newcons/sys/kern/subr_terminal.c 256143 2013-10-08 12:01:17Z ray $"); |
32 33#include <sys/param.h> 34#include <sys/cons.h> 35#include <sys/consio.h> 36#include <sys/kernel.h> 37#include <sys/lock.h> 38#include <sys/malloc.h> 39#include <sys/mutex.h> --- 95 unchanged lines hidden (view full) --- 135static void 136terminal_init(struct terminal *tm) 137{ 138 139 if (tm->tm_flags & TF_CONS) 140 mtx_init(&tm->tm_mtx, "trmlck", NULL, MTX_SPIN); 141 teken_init(&tm->tm_emulator, &terminal_drawmethods, tm); 142 teken_set_defattr(&tm->tm_emulator, &default_message); |
143} 144 145struct terminal * 146terminal_alloc(const struct terminal_class *tc, void *softc) 147{ 148 struct terminal *tm; 149 150 tm = malloc(sizeof(struct terminal), M_TERMINAL, M_WAITOK|M_ZERO); --- 246 unchanged lines hidden (view full) --- 397 tty_lock(tp); 398 return (error); 399} 400 401/* 402 * Binding with the kernel and debug console. 403 */ 404 |
405static cn_probe_t termcn_cnprobe; 406static cn_init_t termcn_cninit; 407static cn_term_t termcn_cnterm; 408static cn_getc_t termcn_cngetc; 409static cn_putc_t termcn_cnputc; 410static cn_grab_t termcn_cngrab; 411static cn_ungrab_t termcn_cnungrab; |
412 |
413const struct consdev_ops termcn_cnops = { 414 .cn_probe = termcn_cnprobe, 415 .cn_init = termcn_cninit, 416 .cn_term = termcn_cnterm, 417 .cn_getc = termcn_cngetc, 418 .cn_putc = termcn_cnputc, 419 .cn_grab = termcn_cngrab, 420 .cn_ungrab = termcn_cnungrab, |
421}; 422 |
423void 424termcn_cnregister(struct terminal *tm) 425{ 426 struct consdev *cp; 427 428 cp = tm->consdev; 429 if (cp == NULL) { 430 cp = malloc(sizeof(struct consdev), M_TERMINAL, 431 M_WAITOK|M_ZERO); 432 cp->cn_ops = &termcn_cnops; 433 cp->cn_arg = tm; 434 cp->cn_pri = CN_INTERNAL; 435 sprintf(cp->cn_name, "ttyv0"); 436 437 tm->tm_flags = TF_CONS; 438 tm->consdev = cp; 439 440 terminal_init(tm); 441 } 442 443 /* Attach terminal as console. */ 444 cnadd(cp); 445} 446 |
447static void |
448termcn_cngrab(struct consdev *cp) |
449{ |
450 451} 452 453static void 454termcn_cnungrab(struct consdev *cp) 455{ 456 457} 458 459static void 460termcn_cnprobe(struct consdev *cp) 461{ |
462 struct terminal *tm = cp->cn_arg; 463 |
464 if (tm == NULL) { 465 cp->cn_pri = CN_DEAD; 466 return; 467 } 468 469 tm->consdev = cp; |
470 terminal_init(tm); 471 472 tm->tm_class->tc_cnprobe(tm, cp); 473} 474 475static void |
476termcn_cninit(struct consdev *cp) |
477{ |
478 |
479} 480 481static void |
482termcn_cnterm(struct consdev *cp) |
483{ |
484 |
485} 486 487static int |
488termcn_cngetc(struct consdev *cp) |
489{ 490 struct terminal *tm = cp->cn_arg; 491 492 return (tm->tm_class->tc_cngetc(tm)); 493} 494 495static void |
496termcn_cnputc(struct consdev *cp, int c) |
497{ 498 struct terminal *tm = cp->cn_arg; 499 teken_attr_t backup; 500 char cv = c; 501 502 TERMINAL_LOCK_CONS(tm); 503 if (!(tm->tm_flags & TF_MUTE)) { 504 backup = *teken_get_curattr(&tm->tm_emulator); --- 87 unchanged lines hidden --- |