Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Jun 2006 21:07:20 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 99465 for review
Message-ID:  <200606172107.k5HL7K0c016288@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=99465

Change 99465 by kmacy@kmacy_storage:sun4v_work on 2006/06/17 21:06:54

	correctly handle character buffering

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hvcons.c#6 edit

Differences ...

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hvcons.c#6 (text+ko) ====

@@ -60,11 +60,14 @@
 	.d_flags =	D_TTY | D_NEEDGIANT,
 };
 
+#define PCBURST 16
 static struct tty		*hvcn_tp = NULL;
 static struct resource          *hvcn_irq;
 static void                     *hvcn_intrhand;
 
-static int prevchar = 0; 
+static int bufindex;
+static int buflen;
+static u_char buf[PCBURST];
 static int			polltime;
 static struct callout_handle	hvcn_timeouthandle
     = CALLOUT_HANDLE_INITIALIZER(&hvcn_timeouthandle);
@@ -266,20 +269,23 @@
 static void
 hvcn_tty_start(struct tty *tp)
 {
-	int c;
-	
+
         if (!(tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))) {
 		tp->t_state |= TS_BUSY;
-		
-		if (prevchar && (hv_cnputchar(prevchar) != H_EWOULDBLOCK))
-			prevchar = 0;
-		while (tp->t_outq.c_cc != 0) {
-			c = prevchar = getc(&tp->t_outq);
 
-			if (hv_cnputchar(prevchar) == H_EWOULDBLOCK)
-				break;
-			prevchar = 0;
-		}		
+		do {
+			if (buflen == 0) {
+				buflen = q_to_b(&tp->t_outq, buf, PCBURST);
+				bufindex = 0;
+			}
+			while (buflen) {
+				if (hv_cnputchar(buf[bufindex]) == H_EWOULDBLOCK)
+					goto done;
+				bufindex++;
+				buflen--;
+			}
+		} while (tp->t_outq.c_cc != 0);
+	done:
 		tp->t_state &= ~TS_BUSY;
 		ttwwakeup(tp);
 	}
@@ -306,7 +312,7 @@
 		if (tp->t_state & TS_ISOPEN) 
 			ttyld_rint(tp, c);
 
-	if (tp->t_outq.c_cc != 0 || prevchar != 0) 
+	if (tp->t_outq.c_cc != 0 || buflen != 0) 
 		hvcn_tty_start(tp);
 }
 



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