diff options
-rw-r--r-- | sys/dev/ic/com.c | 65 | ||||
-rw-r--r-- | sys/dev/ic/comvar.h | 7 |
2 files changed, 32 insertions, 40 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 7ea9661638d..3701c1737fd 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.59 2001/03/15 17:52:20 deraadt Exp $ */ +/* $OpenBSD: com.c,v 1.60 2001/03/15 18:47:52 art Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -223,7 +223,7 @@ comspeedcomspeed(freq, speed) return -1; return x; -#undef divrnd +#undef divrnd(n, q) } int @@ -243,7 +243,7 @@ comprobe1(iot, ioh) } else break; } - if (i >= 32) + if (i >= 32) return 0; return 1; @@ -285,7 +285,7 @@ comprobeHAYESP(hayespioh, sc) printf(": ESP"); - /* Check ESP Self Test bits. */ + /* Check ESP Self Test bits. */ /* Check for ESP version 2.0: bits 4,5,6 == 010 */ bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_GETTEST); val = bus_space_read_1(iot, hayespioh, HAYESP_STATUS1); /* Clear reg 1 */ @@ -346,7 +346,7 @@ comprobe(parent, match, aux) if (1) { struct cfdata *cf = match; struct commulti_attach_args *ca = aux; - + if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ca->ca_slave) return (0); @@ -473,7 +473,7 @@ comattach(parent, self, aux) if (iobase == comconsaddr) { comconsattached = 1; - /* + /* * Need to reset baud rate, etc. of next print so reset * comconsinit. Also make sure console is always "hardwired". */ @@ -675,11 +675,7 @@ comattach(parent, self, aux) cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit); printf("%s: console\n", sc->sc_dev.dv_xname); - } - - timeout_set(&sc->sc_poll_tmo, compoll, sc); - timeout_set(&sc->sc_diag_tmo, comdiag, sc); - timeout_set(&sc->sc_dtr_tmo, com_raisedtr, sc); + } /* * If there are no enable/disable functions, assume the device @@ -702,7 +698,7 @@ com_enable_debugport(sc) bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_ier, sc->sc_ier); SET(sc->sc_mcr, MCR_DTR | MCR_RTS | MCR_IENABLE); bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_mcr, sc->sc_mcr); - + splx(s); } #endif /* KGDB */ @@ -734,9 +730,9 @@ com_detach(self, flags) ttyfree(sc->sc_tty); } - timeout_del(&sc->sc_poll_tmo); - timeout_del(&sc->sc_dtr_tmo); - timeout_del(&sc->sc_diag_tmo); + untimeout(compoll, NULL); + untimeout(com_raisedtr, sc); + untimeout(comdiag, sc); return (0); } @@ -788,7 +784,7 @@ comopen(dev, flag, mode, p) struct tty *tp; int s; int error = 0; - + if (unit >= com_cd.cd_ndevs) return ENXIO; sc = com_cd.cd_devs[unit]; @@ -839,7 +835,7 @@ comopen(dev, flag, mode, p) ttsetwater(tp); if (comsopen++ == 0) - timeout_add(&sc->sc_poll_tmo, 1); + timeout(compoll, NULL, 1); sc->sc_ibufp = sc->sc_ibuf = sc->sc_ibufs[0]; sc->sc_ibufhigh = sc->sc_ibuf + COM_IHIGHWATER; @@ -876,7 +872,7 @@ comopen(dev, flag, mode, p) /* Set 16550 compatibility mode */ bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_SETMODE); - bus_space_write_1(iot, hayespioh, HAYESP_CMD2, + bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_MODE_FIFO|HAYESP_MODE_RTS| HAYESP_MODE_SCALE); @@ -887,7 +883,7 @@ comopen(dev, flag, mode, p) /* Set flow control levels */ bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_SETRXFLOW); - bus_space_write_1(iot, hayespioh, HAYESP_CMD2, + bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_HIBYTE(HAYESP_RXHIWMARK)); bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_LOBYTE(HAYESP_RXHIWMARK)); @@ -924,7 +920,7 @@ comopen(dev, flag, mode, p) * Set the FIFO threshold based on the receive speed. */ for (;;) { - bus_space_write_1(iot, ioh, com_fifo, 0); + bus_space_write_1(iot, ioh, com_fifo, 0); delay(100); (void) bus_space_read_1(iot, ioh, com_data); bus_space_write_1(iot, ioh, com_fifo, fifo | @@ -932,7 +928,7 @@ comopen(dev, flag, mode, p) delay(100); if(!ISSET(bus_space_read_1(iot, ioh, com_lsr), LSR_RXRDY)) - break; + break; } if (sc->sc_uarttype == COM_UART_TI16750) bus_space_write_1(iot, ioh, com_lcr, lcr); @@ -1000,7 +996,7 @@ comopen(dev, flag, mode, p) return (*linesw[tp->t_line].l_open)(dev, tp); } - + int comclose(dev, flag, mode, p) dev_t dev; @@ -1024,14 +1020,14 @@ comclose(dev, flag, mode, p) /* tty device is waiting for carrier; drop dtr then re-raise */ CLR(sc->sc_mcr, MCR_DTR | MCR_RTS); bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); - timeout_add(&sc->sc_dtr_tmo, hz * 2); + timeout(com_raisedtr, sc, hz * 2); } else { /* no one else waiting; turn off the uart */ compwroff(sc); } CLR(tp->t_state, TS_BUSY | TS_FLUSH); if (--comsopen == 0) - timeout_del(&sc->sc_poll_tmo); + untimeout(compoll, NULL); sc->sc_cua = 0; splx(s); ttyclose(tp); @@ -1105,10 +1101,10 @@ comread(dev, uio, flag) { struct com_softc *sc = com_cd.cd_devs[DEVUNIT(dev)]; struct tty *tp = sc->sc_tty; - + return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); } - + int comwrite(dev, uio, flag) dev_t dev; @@ -1117,7 +1113,7 @@ comwrite(dev, uio, flag) { struct com_softc *sc = com_cd.cd_devs[DEVUNIT(dev)]; struct tty *tp = sc->sc_tty; - + return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); } @@ -1130,7 +1126,7 @@ comtty(dev) return (tp); } - + static u_char tiocm_xxx2mcr(data) int data; @@ -1237,9 +1233,9 @@ comioctl(dev, cmd, data, flag, p) case TIOCSFLAGS: { int userbits, driverbits = 0; - error = suser(p->p_ucred, &p->p_acflag); + error = suser(p->p_ucred, &p->p_acflag); if (error != 0) - return(EPERM); + return(EPERM); userbits = *(int *)data; if (ISSET(userbits, TIOCFLAG_SOFTCAR) || @@ -1499,6 +1495,7 @@ comdiag(arg) floods = sc->sc_floods; sc->sc_floods = 0; splx(s); + log(LOG_WARNING, "%s: %d silo overflow%s, %d ibuf overflow%s\n", sc->sc_dev.dv_xname, overflows, overflows == 1 ? "" : "s", @@ -1570,10 +1567,10 @@ compoll(arg) while (ibufp < ibufend) { c = *ibufp++; - if (ISSET(*ibufp, LSR_OE)) { + if (*ibufp & LSR_OE) { sc->sc_overflows++; if (sc->sc_errors++ == 0) - timeout_add(&sc->sc_diag_tmo, 60 * hz); + timeout(comdiag, sc, 60 * hz); } /* This is ugly, but fast. */ c |= lsrmap[(*ibufp++ & (LSR_BI|LSR_FE|LSR_PE)) >> 2]; @@ -1582,7 +1579,7 @@ compoll(arg) } out: - timeout_add(&sc->sc_poll_tmo, 1); + timeout(compoll, NULL, 1); } #ifdef KGDB @@ -1706,7 +1703,7 @@ comintr(arg) if (p >= sc->sc_ibufend) { sc->sc_floods++; if (sc->sc_errors++ == 0) - timeout_add(&sc->sc_diag_tmo, 60 * hz); + timeout(comdiag, sc, 60 * hz); } else { *p++ = data; *p++ = lsr; diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h index d750efa76bf..8c2222b0035 100644 --- a/sys/dev/ic/comvar.h +++ b/sys/dev/ic/comvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: comvar.h,v 1.20 2001/03/15 17:52:20 deraadt Exp $ */ +/* $OpenBSD: comvar.h,v 1.21 2001/03/15 18:47:53 art Exp $ */ /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */ /* @@ -62,8 +62,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/timeout.h> - struct commulti_attach_args { int ca_slave; /* slave number */ @@ -81,9 +79,6 @@ struct com_softc { void *sc_ih; bus_space_tag_t sc_iot; struct tty *sc_tty; - struct timeout sc_dtr_tmo; - struct timeout sc_diag_tmo; - struct timeout sc_poll_tmo; int sc_overflows; int sc_floods; |