summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/com.c65
-rw-r--r--sys/dev/ic/comvar.h7
2 files changed, 40 insertions, 32 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index 5e11caa6bca..007568dd1e5 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com.c,v 1.57 2001/01/24 09:38:04 hugh Exp $ */
+/* $OpenBSD: com.c,v 1.58 2001/03/13 02:53:51 mickey Exp $ */
/* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */
/*
@@ -222,7 +222,7 @@ comspeed(speed)
return -1;
return x;
-#undef divrnd(n, q)
+#undef divrnd
}
int
@@ -242,7 +242,7 @@ comprobe1(iot, ioh)
} else
break;
}
- if (i >= 32)
+ if (i >= 32)
return 0;
return 1;
@@ -284,7 +284,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 */
@@ -345,7 +345,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);
@@ -471,7 +471,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".
*/
@@ -673,7 +673,11 @@ 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
@@ -696,7 +700,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 */
@@ -728,9 +732,9 @@ com_detach(self, flags)
ttyfree(sc->sc_tty);
}
- untimeout(compoll, NULL);
- untimeout(com_raisedtr, sc);
- untimeout(comdiag, sc);
+ timeout_del(&sc->sc_poll_tmo);
+ timeout_del(&sc->sc_dtr_tmo);
+ timeout_del(&sc->sc_diag_tmo);
return (0);
}
@@ -782,7 +786,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];
@@ -833,7 +837,7 @@ comopen(dev, flag, mode, p)
ttsetwater(tp);
if (comsopen++ == 0)
- timeout(compoll, NULL, 1);
+ timeout_add(&sc->sc_poll_tmo, 1);
sc->sc_ibufp = sc->sc_ibuf = sc->sc_ibufs[0];
sc->sc_ibufhigh = sc->sc_ibuf + COM_IHIGHWATER;
@@ -870,7 +874,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);
@@ -881,7 +885,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));
@@ -918,7 +922,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 |
@@ -926,7 +930,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);
@@ -994,7 +998,7 @@ comopen(dev, flag, mode, p)
return (*linesw[tp->t_line].l_open)(dev, tp);
}
-
+
int
comclose(dev, flag, mode, p)
dev_t dev;
@@ -1018,14 +1022,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(com_raisedtr, sc, hz * 2);
+ timeout_add(&sc->sc_dtr_tmo, hz * 2);
} else {
/* no one else waiting; turn off the uart */
compwroff(sc);
}
CLR(tp->t_state, TS_BUSY | TS_FLUSH);
if (--comsopen == 0)
- untimeout(compoll, NULL);
+ timeout_del(&sc->sc_poll_tmo);
sc->sc_cua = 0;
splx(s);
ttyclose(tp);
@@ -1099,10 +1103,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;
@@ -1111,7 +1115,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));
}
@@ -1124,7 +1128,7 @@ comtty(dev)
return (tp);
}
-
+
static u_char
tiocm_xxx2mcr(data)
int data;
@@ -1231,9 +1235,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) ||
@@ -1493,7 +1497,6 @@ 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",
@@ -1565,10 +1568,10 @@ compoll(arg)
while (ibufp < ibufend) {
c = *ibufp++;
- if (*ibufp & LSR_OE) {
+ if (ISSET(*ibufp, LSR_OE)) {
sc->sc_overflows++;
if (sc->sc_errors++ == 0)
- timeout(comdiag, sc, 60 * hz);
+ timeout_add(&sc->sc_diag_tmo, 60 * hz);
}
/* This is ugly, but fast. */
c |= lsrmap[(*ibufp++ & (LSR_BI|LSR_FE|LSR_PE)) >> 2];
@@ -1577,7 +1580,7 @@ compoll(arg)
}
out:
- timeout(compoll, NULL, 1);
+ timeout_add(&sc->sc_poll_tmo, 1);
}
#ifdef KGDB
@@ -1701,7 +1704,7 @@ comintr(arg)
if (p >= sc->sc_ibufend) {
sc->sc_floods++;
if (sc->sc_errors++ == 0)
- timeout(comdiag, sc, 60 * hz);
+ timeout_add(&sc->sc_diag_tmo, 60 * hz);
} else {
*p++ = data;
*p++ = lsr;
diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h
index f5f3bc9cb32..693b4e6f277 100644
--- a/sys/dev/ic/comvar.h
+++ b/sys/dev/ic/comvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: comvar.h,v 1.18 2001/01/24 09:38:04 hugh Exp $ */
+/* $OpenBSD: comvar.h,v 1.19 2001/03/13 02:53:52 mickey Exp $ */
/* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */
/*
@@ -62,6 +62,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/timeout.h>
+
struct commulti_attach_args {
int ca_slave; /* slave number */
@@ -79,6 +81,9 @@ 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;