Deleted Added
full compact
subr_terminal.c (243802) subr_terminal.c (256143)
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>
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 243802 2012-12-02 22:21:40Z nwhitehorn $");
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);
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}
145
146struct terminal *
147terminal_alloc(const struct terminal_class *tc, void *softc)
148{
149 struct terminal *tm;
150
151 tm = malloc(sizeof(struct terminal), M_TERMINAL, M_WAITOK|M_ZERO);

--- 246 unchanged lines hidden (view full) ---

398 tty_lock(tp);
399 return (error);
400}
401
402/*
403 * Binding with the kernel and debug console.
404 */
405
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
406static cn_probe_t termcn_probe;
407static cn_init_t termcn_init;
408static cn_term_t termcn_term;
409static cn_getc_t termcn_getc;
410static cn_putc_t termcn_putc;
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;
411
412
412const struct consdev_ops termcn_ops = {
413 .cn_probe = termcn_probe,
414 .cn_init = termcn_init,
415 .cn_term = termcn_term,
416 .cn_getc = termcn_getc,
417 .cn_putc = termcn_putc,
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,
418};
419
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
420static void
447static void
421termcn_probe(struct consdev *cp)
448termcn_cngrab(struct consdev *cp)
422{
449{
450
451}
452
453static void
454termcn_cnungrab(struct consdev *cp)
455{
456
457}
458
459static void
460termcn_cnprobe(struct consdev *cp)
461{
423 struct terminal *tm = cp->cn_arg;
424
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;
425 terminal_init(tm);
426
427 tm->tm_class->tc_cnprobe(tm, cp);
428}
429
430static void
470 terminal_init(tm);
471
472 tm->tm_class->tc_cnprobe(tm, cp);
473}
474
475static void
431termcn_init(struct consdev *cp)
476termcn_cninit(struct consdev *cp)
432{
477{
478
433}
434
435static void
479}
480
481static void
436termcn_term(struct consdev *cp)
482termcn_cnterm(struct consdev *cp)
437{
483{
484
438}
439
440static int
485}
486
487static int
441termcn_getc(struct consdev *cp)
488termcn_cngetc(struct consdev *cp)
442{
443 struct terminal *tm = cp->cn_arg;
444
445 return (tm->tm_class->tc_cngetc(tm));
446}
447
448static void
489{
490 struct terminal *tm = cp->cn_arg;
491
492 return (tm->tm_class->tc_cngetc(tm));
493}
494
495static void
449termcn_putc(struct consdev *cp, int c)
496termcn_cnputc(struct consdev *cp, int c)
450{
451 struct terminal *tm = cp->cn_arg;
452 teken_attr_t backup;
453 char cv = c;
454
455 TERMINAL_LOCK_CONS(tm);
456 if (!(tm->tm_flags & TF_MUTE)) {
457 backup = *teken_get_curattr(&tm->tm_emulator);

--- 87 unchanged lines hidden ---
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 ---