From owner-svn-src-all@FreeBSD.ORG Tue Jan 26 03:42:34 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EBB9B1065676; Tue, 26 Jan 2010 03:42:34 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C26478FC16; Tue, 26 Jan 2010 03:42:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0Q3gYhu066949; Tue, 26 Jan 2010 03:42:34 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0Q3gYif066947; Tue, 26 Jan 2010 03:42:34 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201001260342.o0Q3gYif066947@svn.freebsd.org> From: Neel Natu Date: Tue, 26 Jan 2010 03:42:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203001 - head/sys/dev/cfe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2010 03:42:35 -0000 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;