Date: Fri, 8 Aug 2008 20:58:10 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 146933 for review Message-ID: <200808082058.m78KwAoj042171@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=146933 Change 146933 by peter@peter_overcee on 2008/08/08 20:58:10 Reduce compile errors from 6 pages to 1 page. This is just the easy part though. No locking or semantics changes yet. Affected files ... .. //depot/projects/mpsafetty/sys/dev/si/si.c#2 edit Differences ... ==== //depot/projects/mpsafetty/sys/dev/si/si.c#2 (text+ko) ==== @@ -44,7 +44,6 @@ #include "opt_compat.h" #include "opt_debug_si.h" #include "opt_eisa.h" -#include "opt_tty.h" #include <sys/param.h> #include <sys/systm.h> @@ -95,13 +94,13 @@ static void si_command(struct si_port *, int, int); static int si_Sioctl(struct cdev *, u_long, caddr_t, int, struct thread *); static void si_start(struct tty *); -static void si_stop(struct tty *, int); +/* static void si_stop(struct tty *, int); */ static timeout_t si_lstart; -static t_break_t sibreak; -static t_close_t siclose; -static t_modem_t simodem; -static t_open_t siopen; +static tsw_ioctl_t siioctl; +static tsw_close_t siclose; +static tsw_modem_t simodem; +static tsw_open_t siopen; static int siparam(struct tty *, struct termios *); @@ -126,6 +125,12 @@ devclass_t si_devclass; + +struct speedtab { + int sp_speed; /* Speed. */ + int sp_code; /* Code. */ +}; + #ifndef B2000 /* not standard, but the hardware knows it. */ # define B2000 2000 #endif @@ -261,6 +266,30 @@ *d++ = *s++; } +static int +ttspeedtab(int speed, struct speedtab *table) +{ + if (speed == 0) + return (0); /* hangup */ + for ( ; table->sp_speed > 0; table++) + if (table->sp_speed <= speed) /* nearest one, rounded down */ + return (table->sp_code); + return (1); /* 50, min and not hangup */ +} + + +static struct ttydevsw si_tty_class = { + .tsw_flags = TF_INITLOCK|TF_CALLOUT, + .tsw_open = siopen, + .tsw_close = siclose, + .tsw_outwakeup = si_start, + /* .tsw_stop = si_stop */ + .tsw_ioctl = siioctl, + .tsw_param = siparam, + .tsw_modem = simodem, +}; + + /* * Attach the device. Initialize the card. */ @@ -579,17 +608,8 @@ sprintf(pp->sp_name, "si%r%r", unit, (int)(pp - sc->sc_ports)); #endif - tp = pp->sp_tty = ttyalloc(); - tp->t_sc = pp; - tp->t_break = sibreak; - tp->t_close = siclose; - tp->t_modem = simodem; - tp->t_open = siopen; - tp->t_oproc = si_start; - tp->t_param = siparam; - tp->t_stop = si_stop; - ttycreate(tp, TS_CALLOUT, "A%r%r", unit, - (int)(pp - sc->sc_ports)); + tp = pp->sp_tty = tty_alloc(&si_tty_class, pp, NULL); + tty_makedev(tp, NULL, "A%r%r", unit, (int)(pp - sc->sc_ports)); } try_next2: if (modp->sm_next == 0) { @@ -620,7 +640,7 @@ } static int -siopen(struct tty *tp, struct cdev *dev) +siopen(struct tty *tp) { mtx_assert(&Giant, MA_OWNED); @@ -642,24 +662,28 @@ struct si_port *pp; mtx_assert(&Giant, MA_OWNED); - pp = tp->t_sc; + pp = tty_softc(tp); (void) si_command(pp, FCLOSE, SI_WAIT); } -static void -sibreak(struct tty *tp, int sig) +static int +siioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) { struct si_port *pp; mtx_assert(&Giant, MA_OWNED); - pp = tp->t_sc; - if (sig) + pp = tty_softc(tp); + switch (cmd) { + case TIOCSBRK: si_command(pp, SBREAK, SI_WAIT); - else + return (0); + case TIOCCBRK: si_command(pp, EBREAK, SI_WAIT); + return (0); + } + return (0); } - /* * Handle the Specialix ioctls on the control dev. */ @@ -805,7 +829,7 @@ static int siparam(struct tty *tp, struct termios *t) { - struct si_port *pp = tp->t_sc; + struct si_port *pp = tty_softc(tp); volatile struct si_channel *ccbp; int oldspl, cflag, iflag, oflag, lflag; int error = 0; /* shutup gcc */ @@ -981,7 +1005,7 @@ volatile struct si_channel *ccbp; int x; - pp = tp->t_sc; + pp = tty_softc(tp); DPRINT((pp, DBG_ENTRY|DBG_MODEM, "simodem(%x,%x)\n", sigon, sigoff)); mtx_assert(&Giant, MA_OWNED); ccbp = pp->sp_ccb; /* Find channel address */ @@ -1021,15 +1045,18 @@ mtx_assert(&Giant, MA_OWNED); if (hi_ip & IP_DCD) { if (!(pp->sp_last_hi_ip & IP_DCD)) { - DPRINT((pp, DBG_INTR, "modem carr on t_line %d\n", - tp->t_line)); - (void)ttyld_modem(tp, 1); + DPRINT((pp, DBG_INTR, "modem carr on%d\n")); + (void)ttydisc_modem(tp, 1); } } else { if (pp->sp_last_hi_ip & IP_DCD) { DPRINT((pp, DBG_INTR, "modem carr off\n")); - if (ttyld_modem(tp, 0)) +#if 0 /* XXX mpsafetty ttyld_modem used to tell us to shutdown the port or not */ + if (ttydisc_modem(tp, 0)) (void) simodem(tp, 0, SER_DTR | SER_RTS); +#else + ttydisc_modem(tp, 0); +#endif } } pp->sp_last_hi_ip = hi_ip; @@ -1234,7 +1261,7 @@ */ if (ccbp->hi_state & ST_BREAK) { if (isopen) - ttyld_rint(tp, TTY_BI); + ttydisc_rint(tp, 0, TRE_BREAK); ccbp->hi_state &= ~ST_BREAK; /* A Bit iffy this */ DPRINT((pp, DBG_INTR, "si_intr break\n")); } @@ -1323,6 +1350,7 @@ * reasonably fast (usually 40 instructions * plus call overhead). */ +#if 0 if (tp->t_state & TS_CAN_BYPASS_L_RINT) { /* block if the driver supports it */ @@ -1348,6 +1376,7 @@ si_start(tp); } } else { +#endif /* * It'd be nice to not have to go through the * function call overhead for each char here. @@ -1356,10 +1385,12 @@ */ for(x = 0; x < n; x++) { i = si_rxbuf[x]; - if (ttyld_rint(tp, i) == -1) + if (ttydisc_rint(tp, i, 0) == -1) pp->sp_delta_overflows++; } +#if 0 } +#endif goto more_rx; /* try for more until RXbuf is empty */ end_rx: @@ -1399,7 +1430,7 @@ mtx_assert(&Giant, MA_OWNED); qp = &tp->t_outq; - pp = tp->t_sc; + pp = tty_softc(tp); DPRINT((pp, DBG_ENTRY|DBG_START, "si_start(%x) t_state %x sp_state %x t_outq.c_cc %d\n", @@ -1506,6 +1537,7 @@ splx(oldspl); } +#if 0 /* XXX mpsafetty */ /* * Stop output on a line. called at spltty(); */ @@ -1516,7 +1548,7 @@ struct si_port *pp; mtx_assert(&Giant, MA_OWNED); - pp = tp->t_sc; + pp = tty_softc(tp); ccbp = pp->sp_ccb; DPRINT((pp, DBG_ENTRY|DBG_STOP, "si_stop(%x,%x)\n", tp, rw)); @@ -1541,6 +1573,7 @@ } #endif } +#endif /* * Issue a command to the host card CPU.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808082058.m78KwAoj042171>