Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jun 2005 02:48:03 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 78058 for review
Message-ID:  <200506060248.j562m36q017781@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
 };
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506060248.j562m36q017781>