From owner-svn-src-user@FreeBSD.ORG Tue Oct 8 12:01:18 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 3EBB8A80; Tue, 8 Oct 2013 12:01:18 +0000 (UTC) (envelope-from ray@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2CA772D38; Tue, 8 Oct 2013 12:01:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r98C1IHO079865; Tue, 8 Oct 2013 12:01:18 GMT (envelope-from ray@svn.freebsd.org) Received: (from ray@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r98C1HX3079862; Tue, 8 Oct 2013 12:01:17 GMT (envelope-from ray@svn.freebsd.org) Message-Id: <201310081201.r98C1HX3079862@svn.freebsd.org> From: Aleksandr Rybalko Date: Tue, 8 Oct 2013 12:01:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r256143 - in user/ed/newcons/sys: kern sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Oct 2013 12:01:18 -0000 Author: ray Date: Tue Oct 8 12:01:17 2013 New Revision: 256143 URL: http://svnweb.freebsd.org/changeset/base/256143 Log: o Rename methods according to "consdev style". o Add cngrab/cnungrab methods. o Allow later console attach with termcn_cnregister(). Sponsored by: The FreeBSD Foundation Modified: user/ed/newcons/sys/kern/subr_terminal.c user/ed/newcons/sys/sys/terminal.h Modified: user/ed/newcons/sys/kern/subr_terminal.c ============================================================================== --- user/ed/newcons/sys/kern/subr_terminal.c Tue Oct 8 11:51:20 2013 (r256142) +++ user/ed/newcons/sys/kern/subr_terminal.c Tue Oct 8 12:01:17 2013 (r256143) @@ -140,7 +140,6 @@ terminal_init(struct terminal *tm) mtx_init(&tm->tm_mtx, "trmlck", NULL, MTX_SPIN); teken_init(&tm->tm_emulator, &terminal_drawmethods, tm); teken_set_defattr(&tm->tm_emulator, &default_message); - } struct terminal * @@ -403,42 +402,90 @@ termtty_ioctl(struct tty *tp, u_long cmd * Binding with the kernel and debug console. */ -static cn_probe_t termcn_probe; -static cn_init_t termcn_init; -static cn_term_t termcn_term; -static cn_getc_t termcn_getc; -static cn_putc_t termcn_putc; - -const struct consdev_ops termcn_ops = { - .cn_probe = termcn_probe, - .cn_init = termcn_init, - .cn_term = termcn_term, - .cn_getc = termcn_getc, - .cn_putc = termcn_putc, +static cn_probe_t termcn_cnprobe; +static cn_init_t termcn_cninit; +static cn_term_t termcn_cnterm; +static cn_getc_t termcn_cngetc; +static cn_putc_t termcn_cnputc; +static cn_grab_t termcn_cngrab; +static cn_ungrab_t termcn_cnungrab; + +const struct consdev_ops termcn_cnops = { + .cn_probe = termcn_cnprobe, + .cn_init = termcn_cninit, + .cn_term = termcn_cnterm, + .cn_getc = termcn_cngetc, + .cn_putc = termcn_cnputc, + .cn_grab = termcn_cngrab, + .cn_ungrab = termcn_cnungrab, }; +void +termcn_cnregister(struct terminal *tm) +{ + struct consdev *cp; + + cp = tm->consdev; + if (cp == NULL) { + cp = malloc(sizeof(struct consdev), M_TERMINAL, + M_WAITOK|M_ZERO); + cp->cn_ops = &termcn_cnops; + cp->cn_arg = tm; + cp->cn_pri = CN_INTERNAL; + sprintf(cp->cn_name, "ttyv0"); + + tm->tm_flags = TF_CONS; + tm->consdev = cp; + + terminal_init(tm); + } + + /* Attach terminal as console. */ + cnadd(cp); +} + static void -termcn_probe(struct consdev *cp) +termcn_cngrab(struct consdev *cp) +{ + +} + +static void +termcn_cnungrab(struct consdev *cp) +{ + +} + +static void +termcn_cnprobe(struct consdev *cp) { struct terminal *tm = cp->cn_arg; + if (tm == NULL) { + cp->cn_pri = CN_DEAD; + return; + } + + tm->consdev = cp; terminal_init(tm); tm->tm_class->tc_cnprobe(tm, cp); } static void -termcn_init(struct consdev *cp) +termcn_cninit(struct consdev *cp) { + } static void -termcn_term(struct consdev *cp) +termcn_cnterm(struct consdev *cp) { + } static int -termcn_getc(struct consdev *cp) +termcn_cngetc(struct consdev *cp) { struct terminal *tm = cp->cn_arg; @@ -446,7 +493,7 @@ termcn_getc(struct consdev *cp) } static void -termcn_putc(struct consdev *cp, int c) +termcn_cnputc(struct consdev *cp, int c) { struct terminal *tm = cp->cn_arg; teken_attr_t backup; Modified: user/ed/newcons/sys/sys/terminal.h ============================================================================== --- user/ed/newcons/sys/sys/terminal.h Tue Oct 8 11:51:20 2013 (r256142) +++ user/ed/newcons/sys/sys/terminal.h Tue Oct 8 12:01:17 2013 (r256143) @@ -128,6 +128,7 @@ struct terminal { #define TF_MUTE 0x1 /* Drop incoming data. */ #define TF_BELL 0x2 /* Bell needs to be sent. */ #define TF_CONS 0x4 /* Console device (needs spinlock). */ + struct consdev *consdev; }; #ifdef _KERNEL @@ -140,8 +141,10 @@ void terminal_input_char(struct terminal void terminal_input_raw(struct terminal *tm, char c); void terminal_input_special(struct terminal *tm, unsigned int k); +void termcn_cnregister(struct terminal *tm); + /* Kernel console helper interface. */ -extern const struct consdev_ops termcn_ops; +extern const struct consdev_ops termcn_cnops; #define TERMINAL_DECLARE_EARLY(name, class, softc) \ static struct terminal name = { \ @@ -149,7 +152,7 @@ extern const struct consdev_ops termcn_o .tm_softc = softc, \ .tm_flags = TF_CONS, \ }; \ - CONSOLE_DEVICE(name ## _consdev, termcn_ops, &name) + CONSOLE_DEVICE(name ## _consdev, termcn_cnops, &name) #endif /* _KERNEL */