From owner-p4-projects@FreeBSD.ORG Sun Aug 3 16:31:12 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4D3681065678; Sun, 3 Aug 2008 16:31:12 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 108DE1065672 for ; Sun, 3 Aug 2008 16:31:12 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E8AC58FC21 for ; Sun, 3 Aug 2008 16:31:11 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m73GVB0V048687 for ; Sun, 3 Aug 2008 16:31:11 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m73GVBvW048685 for perforce@freebsd.org; Sun, 3 Aug 2008 16:31:11 GMT (envelope-from ed@FreeBSD.org) Date: Sun, 3 Aug 2008 16:31:11 GMT Message-Id: <200808031631.m73GVBvW048685@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 146536 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: Sun, 03 Aug 2008 16:31:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=146536 Change 146536 by ed@ed_flippo on 2008/08/03 16:30:32 Make nmdm(4) actually work again. I still need to improve several things here: - Unloading is not safe. It doesn't clean up things properly. - We don't destroy nmdm's yet. Affected files ... .. //depot/projects/mpsafetty/sys/dev/nmdm/nmdm.c#3 edit Differences ... ==== //depot/projects/mpsafetty/sys/dev/nmdm/nmdm.c#3 (text+ko) ==== @@ -148,7 +148,7 @@ ns = nmdm_alloc(unit, cred); - if (end[1] == 'A') + if (end[0] == 'A') *dev = ns->ns_part1.np_tty->t_dev; else *dev = ns->ns_part2.np_tty->t_dev; @@ -178,41 +178,39 @@ nmdm_task_tty(void *arg, int pending __unused) { struct tty *tp, *otp; - struct nmdmpart *np = tty_softc(tp); -#if 0 - int c; -#endif + struct nmdmpart *np = arg; + char c; + + tp = np->np_tty; + tty_lock(tp); - tp = arg; otp = np->np_other->np_tty; KASSERT(otp != NULL, ("NULL otp in nmdmstart")); KASSERT(otp != tp, ("NULL otp == tp nmdmstart")); if (np->np_other->np_dcd) { if (!tty_opened(tp)) { np->np_other->np_dcd = 0; - (void)ttydisc_modem(otp, 0); + ttydisc_modem(otp, 0); } } else { if (tty_opened(tp)) { np->np_other->np_dcd = 1; - (void)ttydisc_modem(otp, 1); + ttydisc_modem(otp, 1); } } -#if 0 - while (tp->t_outq.c_cc != 0) { - if (sp->rate && !sp->quota) - return; - if (otp->t_state & TS_TBLOCK) - return; - sp->quota--; - c = getc(&tp->t_outq); - if (otp->t_state & TS_ISOPEN) - ttyld_rint(otp, c); + while (ttydisc_rint_poll(otp) > 0) { + if (np->np_rate && !np->np_quota) + break; + if (ttydisc_getc(tp, &c, 1) != 1) + break; + np->np_quota--; + ttydisc_rint(otp, c, 0); } - if (tp->t_outq.c_cc == 0) - ttwwakeup(tp); -#endif + + ttydisc_rint_done(otp); + + tty_unlock(tp); } static int @@ -236,7 +234,7 @@ } static int -nmdmparam(struct tty *tp, struct termios *t) +nmdm_param(struct tty *tp, struct termios *t) { struct nmdmpart *np = tty_softc(tp); struct tty *tp2; @@ -244,7 +242,7 @@ tp2 = np->np_other->np_tty; - if (!((t->c_cflag | tp2->t_cflag) & CDSR_OFLOW)) { + if (!((t->c_cflag | tp2->t_termios.c_cflag) & CDSR_OFLOW)) { np->np_rate = 0; np->np_other->np_rate = 0; return (0); @@ -261,7 +259,7 @@ for (i = 0; i < 2; i++) { /* Use the slower of our receive and their transmit rate */ - speed = imin(tp2->t_ospeed, t->c_ispeed); + speed = imin(tp2->t_termios.c_ospeed, t->c_ispeed); if (speed == 0) { np->np_rate = 0; np->np_other->np_rate = 0; @@ -289,34 +287,34 @@ t = &tp2->t_termios; tp2 = tp; } + return (0); } -#if 0 static int -nmdmmodem(struct tty *tp, int sigon, int sigoff) +nmdm_modem(struct tty *tp, int sigon, int sigoff) { - struct softpart *sp; - int i; + struct nmdmpart *np = tty_softc(tp); + int i = 0; - sp = tty_softc(tp); if (sigon || sigoff) { if (sigon & SER_DTR) - sp->other->nm_dcd = 1; + np->np_other->np_dcd = 1; if (sigoff & SER_DTR) - sp->other->nm_dcd = 0; - ttyld_modem(sp->other->nm_tty, sp->other->nm_dcd); + np->np_other->np_dcd = 0; + + ttydisc_modem(np->np_other->np_tty, np->np_other->np_dcd); + return (0); } else { - i = 0; - if (sp->nm_dcd) + if (np->np_dcd) i |= SER_DCD; - if (sp->other->nm_dcd) + if (np->np_other->np_dcd) i |= SER_DTR; + return (i); } } -#endif static void nmdm_outwakeup(struct tty *tp)