Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jan 2010 03:42:34 +0000 (UTC)
From:      Neel Natu <neel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r203001 - head/sys/dev/cfe
Message-ID:  <201001260342.o0Q3gYif066947@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: neel
Date: Tue Jan 26 03:42:34 2010
New Revision: 203001
URL: http://svn.freebsd.org/changeset/base/203001

Log:
  Create the "cfecons" tty directly using tty_makedev(). It is not clear what
  the intention of having two ttys pointing to the same cfe console device was.
  
  Also we were not initializing the output[] array passed in as input to
  tty_makedev() so one name of the ttys was garbage.
  
  Fix the code that calls cfe_write() to deal with the case where only a partial
  buffer is written out.
  
  cfe_cngetc() needs to return if there is no character available as input.
  If we don't do this then the cfe_timeout() function will spin forever
  because cfe_cngetc() will only ever return if there is valid input.
  
  Approved by: imp (mentor)

Modified:
  head/sys/dev/cfe/cfe_console.c

Modified: head/sys/dev/cfe/cfe_console.c
==============================================================================
--- head/sys/dev/cfe/cfe_console.c	Tue Jan 26 03:39:10 2010	(r203000)
+++ head/sys/dev/cfe/cfe_console.c	Tue Jan 26 03:42:34 2010	(r203001)
@@ -84,14 +84,12 @@ CONSOLE_DRIVER(cfe);
 static void
 cn_drvinit(void *unused)
 {
-	char output[32];
 	struct tty *tp;
 
 	if (cfe_consdev.cn_pri != CN_DEAD &&
 	    cfe_consdev.cn_name[0] != '\0') {
 		tp = tty_alloc(&cfe_ttydevsw, NULL);
-		tty_makedev(tp, NULL, "%s", output);
-		tty_makealias(tp, "cfecons");
+		tty_makedev(tp, NULL, "cfecons");
 	}
 }
 
@@ -117,15 +115,21 @@ cfe_tty_close(struct tty *tp)
 static void
 cfe_tty_outwakeup(struct tty *tp)
 {
-	int len;
+	int len, written, rc;
 	u_char buf[CFEBURSTLEN];
 
 	for (;;) {
 		len = ttydisc_getc(tp, buf, sizeof buf);
 		if (len == 0)
 			break;
-		while (cfe_write(conhandle, buf, len) == 0)
-			continue;
+
+		written = 0;
+		while (written < len) {
+			rc = cfe_write(conhandle, &buf[written], len - written);
+			if (rc < 0)
+				break;
+			written += rc;
+		}
 	}
 }
 
@@ -184,13 +188,9 @@ cfe_cnterm(struct consdev *cp)
 static int
 cfe_cngetc(struct consdev *cp)
 {
-	int result;
 	unsigned char ch;
 
-	while ((result = cfe_read(conhandle, &ch, 1)) == 0)
-		continue;
-
-	if (result > 0) {
+	if (cfe_read(conhandle, &ch, 1) == 1) {
 #if defined(KDB) && defined(ALT_BREAK_TO_DEBUGGER)
 		int kdb_brk;
 



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