Date: Sun, 3 Aug 2008 16:31:11 GMT From: Ed Schouten <ed@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 146536 for review Message-ID: <200808031631.m73GVBvW048685@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808031631.m73GVBvW048685>