From owner-p4-projects@FreeBSD.ORG Mon Jun 6 02:48:04 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 32FDA16A420; Mon, 6 Jun 2005 02:48:04 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0BA0216A41C for ; Mon, 6 Jun 2005 02:48:04 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C05E043D4C for ; Mon, 6 Jun 2005 02:48:03 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j562m3WH017784 for ; Mon, 6 Jun 2005 02:48:03 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j562m36q017781 for perforce@freebsd.org; Mon, 6 Jun 2005 02:48:03 GMT (envelope-from marcel@freebsd.org) Date: Mon, 6 Jun 2005 02:48:03 GMT Message-Id: <200506060248.j562m36q017781@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Cc: Subject: PERFORCE change 78058 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jun 2005 02:48:05 -0000 http://perforce.freebsd.org/chv.cgi?CH=78058 Change 78058 by marcel@marcel_nfs on 2005/06/06 02:47:41 o Don't forget to call kobj_init() for the newly created TE. o Change device special file names from ttyv# to ttyV# so that we don't have syscons specific rc.d scripts trying to do syscons specific (and unspeakable) things to VTC. o Implement UTF-8 to UTF-32 conversion in the TTY oproc function and actually call the TE write method. Affected files ... .. //depot/projects/tty/sys/dev/vtc/vtc_core.c#6 edit .. //depot/projects/tty/sys/dev/vtc/vtc_te.h#4 edit Differences ... ==== //depot/projects/tty/sys/dev/vtc/vtc_core.c#6 (text+ko) ==== @@ -81,6 +81,8 @@ vtc_tty_oproc(struct tty *tp) { struct vtc_te_softc *te; + __wchar_t utf32; + int c, error, utfbytes; te = tp->t_sc; if (te == NULL) @@ -91,7 +93,47 @@ if (tp->t_outq.c_cc > 0) { tp->t_state |= TS_BUSY; - /* XXX loop to display all characters in the buffer. */ + utf32 = te->te_utf32; + utfbytes = te->te_utfbytes; + while (tp->t_outq.c_cc) { + c = getc(&tp->t_outq); + /* + * Conditionalize on the two major character types: + * initial and followup characters. + */ + if ((c & 0xc0) != 0x80) { + /* Initial characters. */ + if (utfbytes != 0) + VTC_TE_WRITE(te, -1); + if ((c & 0xf8) == 0xf0) { + utf32 = c & 0x07; + utfbytes = 3; + } else if ((c & 0xf0) == 0xe0) { + utf32 = c & 0x0f; + utfbytes = 2; + } else if ((c & 0xe0) == 0xc0) { + utf32 = c & 0x1f; + utfbytes = 1; + } else { + KASSERT((c & 0x80) == 0x00, ("oops")); + utf32 = c & 0x7f; + utfbytes = 0; + } + } else { + /* Followup characters. */ + KASSERT((c & 0xc0) == 0x80, ("oops")); + if (utfbytes > 0) { + utf32 = (utf32 << 6) + (c & 0x3f); + utfbytes--; + } + else if (utfbytes == 0) + utfbytes = -1; + } + if (utfbytes == 0) + VTC_TE_WRITE(te, utf32); + } + te->te_utf32 = utf32; + te->te_utfbytes = utfbytes; tp->t_state &= ~TS_BUSY; } @@ -143,6 +185,7 @@ vo->vo_height = height; te = malloc(vt102_class.size, M_VTC, M_WAITOK|M_ZERO); + kobj_init((kobj_t)te, (kobj_class_t)&vt102_class); TAILQ_INSERT_TAIL(&vtc_te_devs, te, te_alldevs); TAILQ_INIT(&te->te_vodevs); TAILQ_INSERT_TAIL(&te->te_vodevs, vo, vo_tedevs); @@ -167,7 +210,7 @@ */ ttyconsolemode(tp, 0); - ttycreate(tp, NULL, 0, MINOR_CALLOUT, "v%r", 0); + ttycreate(tp, NULL, 0, MINOR_CALLOUT, "V%r", 0); return (0); } ==== //depot/projects/tty/sys/dev/vtc/vtc_te.h#4 (text+ko) ==== @@ -41,9 +41,11 @@ struct vtc_te_class *te_class; TAILQ_ENTRY(vtc_te_softc) te_alldevs; TAILQ_HEAD(, vtc_vtout_softc) te_vodevs; - struct tty *te_tty; - int te_maxcol; - int te_maxrow; + struct tty *te_tty; + __wchar_t te_utf32; + int te_utfbytes; + int te_maxcol; + int te_maxrow; }; /*