summaryrefslogtreecommitdiffstats
path: root/sys/i4b/driver/i4b_rbch.c
diff options
context:
space:
mode:
authorhm <hm@FreeBSD.org>2000-10-09 13:18:17 +0000
committerhm <hm@FreeBSD.org>2000-10-09 13:18:17 +0000
commit9fc2bc8a46f4f09ca71eaf59e5c203b5d61533fb (patch)
treeca1e99e8eac9fd3f8c8cecbcbfc102b0bfa6f03f /sys/i4b/driver/i4b_rbch.c
parent7fc1fa165474e47dca5d7dfb2584d97d169d686d (diff)
downloadFreeBSD-src-9fc2bc8a46f4f09ca71eaf59e5c203b5d61533fb.zip
FreeBSD-src-9fc2bc8a46f4f09ca71eaf59e5c203b5d61533fb.tar.gz
update to i4b version 0.95.04
Diffstat (limited to 'sys/i4b/driver/i4b_rbch.c')
-rw-r--r--sys/i4b/driver/i4b_rbch.c178
1 files changed, 103 insertions, 75 deletions
diff --git a/sys/i4b/driver/i4b_rbch.c b/sys/i4b/driver/i4b_rbch.c
index d4c9225..53af7bc 100644
--- a/sys/i4b/driver/i4b_rbch.c
+++ b/sys/i4b/driver/i4b_rbch.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* i4b_rbch.c - device driver for raw B channel data
* ---------------------------------------------------
*
- * $Id: i4b_rbch.c,v 1.48 1999/12/13 21:25:24 hm Exp $
+ * $Id: i4b_rbch.c,v 1.52 2000/10/06 08:37:43 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:39:15 1999]
+ * last edit-date: [Mon Oct 2 10:13:09 2000]
*
*---------------------------------------------------------------------------*/
@@ -51,14 +51,29 @@
#include <sys/proc.h>
#include <sys/tty.h>
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
+#include <sys/callout.h>
+#endif
+
#if defined (__NetBSD__) || defined (__OpenBSD__)
extern cc_t ttydefchars;
#define termioschars(t) memcpy((t)->c_cc, &ttydefchars, sizeof((t)->c_cc))
#endif
+#ifdef __FreeBSD__
+
+#if defined(__FreeBSD__) && __FreeBSD__ == 3
+#include "opt_devfs.h"
+#endif
+
+#ifdef DEVFS
+#include <sys/devfsext.h>
+#endif
+
+#endif /* __FreeBSD__ */
+
#ifdef __NetBSD__
#include <sys/filio.h>
-#define bootverbose 0
#endif
#ifdef __FreeBSD__
@@ -79,8 +94,6 @@ extern cc_t ttydefchars;
#ifdef __bsdi__
#include <sys/device.h>
-/* XXX FIXME */
-int bootverbose = 0;
#endif
#ifdef OS_USES_POLL
@@ -125,12 +138,19 @@ static struct rbch_softc {
struct selinfo selp; /* select / poll */
#if defined(__FreeBSD__) && __FreeBSD__ == 3
+#ifdef DEVFS
+ void *devfs_token; /* device filesystem */
+#endif
#endif
#if I4BRBCHACCT
#if defined(__FreeBSD__)
struct callout_handle sc_callout;
#endif
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
+ struct callout sc_callout;
+#endif
+
int sc_iinb; /* isdn driver # of inbytes */
int sc_ioutb; /* isdn driver # of outbytes */
int sc_linb; /* last # of bytes rx'd */
@@ -283,6 +303,12 @@ i4brbchattach()
#if defined(__FreeBSD__)
#if __FreeBSD__ == 3
+#ifdef DEVFS
+ rbch_softc[i].devfs_token =
+ devfs_add_devswf(&i4brbch_cdevsw, i, DV_CHR,
+ UID_ROOT, GID_WHEEL, 0600,
+ "i4brbch%d", i);
+#endif
#else
make_dev(&i4brbch_cdevsw, i,
@@ -294,6 +320,9 @@ i4brbchattach()
#if defined(__FreeBSD__)
callout_handle_init(&rbch_softc[i].sc_callout);
#endif
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
+ callout_init(&rbch_softc[i].sc_callout);
+#endif
rbch_softc[i].sc_fn = 1;
#endif
rbch_softc[i].sc_unit = i;
@@ -313,7 +342,7 @@ i4brbchopen(dev_t dev, int flag, int fmt, struct proc *p)
{
int unit = minor(dev);
- if(unit > NI4BRBCH)
+ if(unit >= NI4BRBCH)
return(ENXIO);
if(rbch_softc[unit].sc_devstate & ST_ISOPEN)
@@ -325,7 +354,7 @@ i4brbchopen(dev_t dev, int flag, int fmt, struct proc *p)
rbch_softc[unit].sc_devstate |= ST_ISOPEN;
- DBGL4(L4_RBCHDBG, "i4brbchopen", ("unit %d, open\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, open", unit);
return(0);
}
@@ -346,7 +375,7 @@ i4brbchclose(dev_t dev, int flag, int fmt, struct proc *p)
rbch_clrq(unit);
- DBGL4(L4_RBCHDBG, "i4brbclose", ("unit %d, closed\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, closed", unit);
return(0);
}
@@ -365,38 +394,45 @@ i4brbchread(dev_t dev, struct uio *uio, int ioflag)
CRIT_VAR;
- DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, enter read\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, enter read", unit);
+ CRIT_BEG;
if(!(sc->sc_devstate & ST_ISOPEN))
{
- DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, read while not open\n", unit));
+ CRIT_END;
+ NDBGL4(L4_RBCHDBG, "unit %d, read while not open", unit);
return(EIO);
}
if((sc->sc_devstate & ST_NOBLOCK))
{
- if(!(sc->sc_devstate & ST_CONNECTED))
+ if(!(sc->sc_devstate & ST_CONNECTED)) {
+ CRIT_END;
return(EWOULDBLOCK);
+ }
if(sc->sc_bprot == BPROT_RHDLC)
iqp = &sc->sc_hdlcq;
else
iqp = isdn_linktab[unit]->rx_queue;
- if(IF_QEMPTY(iqp) && (sc->sc_devstate & ST_ISOPEN))
+ if(IF_QEMPTY(iqp) && (sc->sc_devstate & ST_ISOPEN)) {
+ CRIT_END;
return(EWOULDBLOCK);
}
+ }
else
{
while(!(sc->sc_devstate & ST_CONNECTED))
{
- DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, wait read init\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, wait read init", unit);
if((error = tsleep((caddr_t) &rbch_softc[unit],
TTIPRI | PCATCH,
"rrrbch", 0 )) != 0)
{
- DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, error %d tsleep\n", unit, error));
+ CRIT_END;
+ NDBGL4(L4_RBCHDBG, "unit %d, error %d tsleep", unit, error);
return(error);
}
}
@@ -408,28 +444,25 @@ i4brbchread(dev_t dev, struct uio *uio, int ioflag)
while(IF_QEMPTY(iqp) && (sc->sc_devstate & ST_ISOPEN))
{
- CRIT_BEG;
sc->sc_devstate |= ST_RDWAITDATA;
- CRIT_END;
- DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, wait read data\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, wait read data", unit);
if((error = tsleep((caddr_t) &isdn_linktab[unit]->rx_queue,
TTIPRI | PCATCH,
"rrbch", 0 )) != 0)
{
- DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, error %d tsleep read\n", unit, error));
+ CRIT_END;
+ NDBGL4(L4_RBCHDBG, "unit %d, error %d tsleep read", unit, error);
sc->sc_devstate &= ~ST_RDWAITDATA;
return(error);
}
}
}
- CRIT_BEG;
-
IF_DEQUEUE(iqp, m);
- DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, read %d bytes\n", unit, m->m_len));
+ NDBGL4(L4_RBCHDBG, "unit %d, read %d bytes", unit, m->m_len);
if(m && m->m_len)
{
@@ -437,7 +470,7 @@ i4brbchread(dev_t dev, struct uio *uio, int ioflag)
}
else
{
- DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, error %d uiomove\n", unit, error));
+ NDBGL4(L4_RBCHDBG, "unit %d, error %d uiomove", unit, error);
error = EIO;
}
@@ -462,40 +495,50 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag)
CRIT_VAR;
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, write\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, write", unit);
+ CRIT_BEG;
if(!(sc->sc_devstate & ST_ISOPEN))
{
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, write while not open\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, write while not open", unit);
+ CRIT_END;
return(EIO);
}
if((sc->sc_devstate & ST_NOBLOCK))
{
- if(!(sc->sc_devstate & ST_CONNECTED))
+ if(!(sc->sc_devstate & ST_CONNECTED)) {
+ CRIT_END;
return(EWOULDBLOCK);
- if(IF_QFULL(isdn_linktab[unit]->tx_queue) && (sc->sc_devstate & ST_ISOPEN))
+ }
+ if(IF_QFULL(isdn_linktab[unit]->tx_queue) && (sc->sc_devstate & ST_ISOPEN)) {
+ CRIT_END;
return(EWOULDBLOCK);
}
+ }
else
{
while(!(sc->sc_devstate & ST_CONNECTED))
{
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, write wait init\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, write wait init", unit);
error = tsleep((caddr_t) &rbch_softc[unit],
TTIPRI | PCATCH,
"wrrbch", 0 );
- if(error == ERESTART)
+ if(error == ERESTART) {
+ CRIT_END;
return (ERESTART);
+ }
else if(error == EINTR)
{
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, EINTR during wait init\n", unit));
+ CRIT_END;
+ NDBGL4(L4_RBCHDBG, "unit %d, EINTR during wait init", unit);
return(EINTR);
}
else if(error)
{
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, error %d tsleep init\n", unit, error));
+ CRIT_END;
+ NDBGL4(L4_RBCHDBG, "unit %d, error %d tsleep init", unit, error);
return(error);
}
tsleep((caddr_t) &rbch_softc[unit], TTIPRI | PCATCH, "xrbch", (hz*1));
@@ -503,11 +546,9 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag)
while(IF_QFULL(isdn_linktab[unit]->tx_queue) && (sc->sc_devstate & ST_ISOPEN))
{
- CRIT_BEG;
sc->sc_devstate |= ST_WRWAITEMPTY;
- CRIT_END;
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, write queue full\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, write queue full", unit);
if ((error = tsleep((caddr_t) &isdn_linktab[unit]->tx_queue,
TTIPRI | PCATCH,
@@ -515,27 +556,28 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag)
sc->sc_devstate &= ~ST_WRWAITEMPTY;
if(error == ERESTART)
{
+ CRIT_END;
return(ERESTART);
}
else if(error == EINTR)
{
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, EINTR during wait write\n", unit));
+ CRIT_END;
+ NDBGL4(L4_RBCHDBG, "unit %d, EINTR during wait write", unit);
return(error);
}
else if(error)
{
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, error %d tsleep write\n", unit, error));
+ CRIT_END;
+ NDBGL4(L4_RBCHDBG, "unit %d, error %d tsleep write", unit, error);
return(error);
}
}
}
}
- CRIT_BEG;
-
if(!(sc->sc_devstate & ST_ISOPEN))
{
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, not open anymore\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, not open anymore", unit);
CRIT_END;
return(EIO);
}
@@ -544,7 +586,7 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag)
{
m->m_len = min(BCH_MAX_DATALEN, uio->uio_resid);
- DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, write %d bytes\n", unit, m->m_len));
+ NDBGL4(L4_RBCHDBG, "unit %d, write %d bytes", unit, m->m_len);
error = uiomove(m->m_data, m->m_len, uio);
@@ -580,23 +622,23 @@ i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc *p)
case FIOASYNC: /* Set async mode */
if (*(int *)data)
{
- DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, setting async mode\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, setting async mode", unit);
}
else
{
- DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, clearing async mode\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, clearing async mode", unit);
}
break;
case FIONBIO:
if (*(int *)data)
{
- DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, setting non-blocking mode\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, setting non-blocking mode", unit);
sc->sc_devstate |= ST_NOBLOCK;
}
else
{
- DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, clearing non-blocking mode\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, clearing non-blocking mode", unit);
sc->sc_devstate &= ~ST_NOBLOCK;
}
break;
@@ -604,7 +646,7 @@ i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc *p)
case TIOCCDTR: /* Clear DTR */
if(sc->sc_devstate & ST_CONNECTED)
{
- DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, disconnecting for DTR down\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, disconnecting for DTR down", unit);
i4b_l4_drvrdisc(BDRV_RBCH, unit);
}
break;
@@ -617,7 +659,7 @@ i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc *p)
;
if (l)
{
- DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, attempting dialout to %s\n", unit, (char *)data));
+ NDBGL4(L4_RBCHDBG, "unit %d, attempting dialout to %s", unit, (char *)data);
i4b_l4_dialoutnumber(BDRV_RBCH, unit, l, (char *)data);
break;
}
@@ -625,7 +667,7 @@ i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc *p)
}
case TIOCSDTR: /* Set DTR */
- DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, attempting dialout (DTR)\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, attempting dialout (DTR)", unit);
i4b_l4_dialout(BDRV_RBCH, unit);
break;
@@ -655,7 +697,7 @@ i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc *p)
}
default: /* Unknown stuff */
- DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, ioctl, unknown cmd %lx\n", unit, (u_long)cmd));
+ NDBGL4(L4_RBCHDBG, "unit %d, ioctl, unknown cmd %lx", unit, (u_long)cmd);
error = EINVAL;
break;
}
@@ -737,7 +779,7 @@ i4brbchselect(dev_t dev, int rw, struct proc *p)
if(!(sc->sc_devstate & ST_ISOPEN))
{
splx(s);
- DBGL4(L4_RBCHDBG, "i4brbchselect", ("unit %d, not open anymore\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, not open anymore", unit);
return(1);
}
@@ -814,11 +856,7 @@ rbch_timeout(struct rbch_softc *sc)
i4b_l4_accounting(BDRV_RBCH, unit, ACCT_DURING,
sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_ioutb, sc->sc_iinb);
}
-#if defined(__FreeBSD__)
- sc->sc_callout =
-#endif
- timeout((TIMEOUT_FUNC_T)rbch_timeout,
- (void *)sc, I4BRBCHACCTINTVL*hz);
+ START_TIMER(sc->sc_callout, rbch_timeout, sc, I4BRBCHACCTINTVL*hz);
}
#endif /* I4BRBCHACCT */
@@ -845,16 +883,12 @@ rbch_connect(int unit, void *cdp)
sc->sc_linb = 0;
sc->sc_loutb = 0;
-#if defined(__FreeBSD__)
- sc->sc_callout =
-#endif
- timeout((TIMEOUT_FUNC_T)rbch_timeout,
- (void *)sc, I4BRBCHACCTINTVL*hz);
+ START_TIMER(sc->sc_callout, rbch_timeout, sc, I4BRBCHACCTINTVL*hz);
}
#endif
if(!(sc->sc_devstate & ST_CONNECTED))
{
- DBGL4(L4_RBCHDBG, "rbch_connect", ("unit %d, wakeup\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, wakeup", unit);
sc->sc_devstate |= ST_CONNECTED;
sc->sc_cd = cdp;
wakeup((caddr_t)sc);
@@ -874,14 +908,14 @@ rbch_disconnect(int unit, void *cdp)
if(cd != sc->sc_cd)
{
- DBGL4(L4_RBCHDBG, "rbch_disconnect", ("rbch%d: channel %d not active\n",
- cd->driver_unit, cd->channelid));
+ NDBGL4(L4_RBCHDBG, "rbch%d: channel %d not active",
+ cd->driver_unit, cd->channelid);
return;
}
CRIT_BEG;
- DBGL4(L4_RBCHDBG, "rbch_disconnect", ("unit %d, disconnect\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, disconnect", unit);
sc->sc_devstate &= ~ST_CONNECTED;
@@ -891,13 +925,7 @@ rbch_disconnect(int unit, void *cdp)
i4b_l4_accounting(BDRV_RBCH, unit, ACCT_FINAL,
sc->sc_ioutb, sc->sc_iinb, 0, 0, sc->sc_ioutb, sc->sc_iinb);
-#if defined(__FreeBSD__)
- untimeout((TIMEOUT_FUNC_T)rbch_timeout,
- (void *)sc, sc->sc_callout);
-#else
- untimeout((TIMEOUT_FUNC_T)rbch_timeout, (void *)sc);
-#endif
-
+ STOP_TIMER(sc->sc_callout, rbch_timeout, sc);
#endif
CRIT_END;
}
@@ -937,7 +965,7 @@ rbch_rx_data_rdy(int unit)
if(IF_QFULL(&(rbch_softc[unit].sc_hdlcq)))
{
- DBGL4(L4_RBCHDBG, "rbch_rx_data_rdy", ("unit %d: hdlc rx queue full!\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d: hdlc rx queue full!", unit);
m_freem(m);
}
else
@@ -948,13 +976,13 @@ rbch_rx_data_rdy(int unit)
if(rbch_softc[unit].sc_devstate & ST_RDWAITDATA)
{
- DBGL4(L4_RBCHDBG, "rbch_rx_data_rdy", ("unit %d, wakeup\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, wakeup", unit);
rbch_softc[unit].sc_devstate &= ~ST_RDWAITDATA;
wakeup((caddr_t) &isdn_linktab[unit]->rx_queue);
}
else
{
- DBGL4(L4_RBCHDBG, "rbch_rx_data_rdy", ("unit %d, NO wakeup\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, NO wakeup", unit);
}
selwakeup(&rbch_softc[unit].selp);
}
@@ -969,13 +997,13 @@ rbch_tx_queue_empty(int unit)
{
if(rbch_softc[unit].sc_devstate & ST_WRWAITEMPTY)
{
- DBGL4(L4_RBCHDBG, "rbch_tx_queue_empty", ("unit %d, wakeup\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, wakeup", unit);
rbch_softc[unit].sc_devstate &= ~ST_WRWAITEMPTY;
wakeup((caddr_t) &isdn_linktab[unit]->tx_queue);
}
else
{
- DBGL4(L4_RBCHDBG, "rbch_tx_queue_empty", ("unit %d, NO wakeup\n", unit));
+ NDBGL4(L4_RBCHDBG, "unit %d, NO wakeup", unit);
}
selwakeup(&rbch_softc[unit].selp);
}
OpenPOWER on IntegriCloud