summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/i4b/driver/i4b_ipr.c86
-rw-r--r--sys/i4b/driver/i4b_ispppsubr.c114
-rw-r--r--sys/i4b/driver/i4b_rbch.c80
-rw-r--r--sys/i4b/driver/i4b_tel.c79
-rw-r--r--sys/i4b/driver/i4b_trace.c43
-rw-r--r--sys/i4b/include/i4b_global.h25
-rw-r--r--sys/i4b/layer1/ifpi/i4b_ifpi_pci.c16
-rw-r--r--sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c25
-rw-r--r--sys/i4b/layer1/ihfc/i4b_ihfc_drv.c12
-rw-r--r--sys/i4b/layer1/isic/i4b_bchan.c12
-rw-r--r--sys/i4b/layer1/isic/i4b_hscx.c18
-rw-r--r--sys/i4b/layer1/iwic/i4b_iwic_bchan.c24
-rw-r--r--sys/i4b/layer2/i4b_l2.c9
-rw-r--r--sys/i4b/layer2/i4b_mbuf.c26
-rw-r--r--sys/i4b/layer4/i4b_i4bdrv.c30
15 files changed, 381 insertions, 218 deletions
diff --git a/sys/i4b/driver/i4b_ipr.c b/sys/i4b/driver/i4b_ipr.c
index 4aa074a..fd307e6 100644
--- a/sys/i4b/driver/i4b_ipr.c
+++ b/sys/i4b/driver/i4b_ipr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 @@
* i4b_ipr.c - isdn4bsd IP over raw HDLC ISDN network driver
* ---------------------------------------------------------
*
- * $Id: i4b_ipr.c,v 1.59 2000/08/28 07:24:58 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Fri Aug 25 20:25:21 2000]
+ * last edit-date: [Fri Jan 12 15:43:51 2001]
*
*---------------------------------------------------------------------------*
*
@@ -71,7 +69,8 @@
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/errno.h>
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+
+#if defined(__FreeBSD__)
#include <sys/ioccom.h>
#include <sys/sockio.h>
#ifdef IPR_VJ
@@ -120,6 +119,7 @@
#else
#include "bpfilter.h"
#endif
+
#if NBPFILTER > 0 || NBPF > 0
#include <sys/time.h>
#include <net/bpf.h>
@@ -231,16 +231,13 @@ enum ipr_states {
#define THE_UNIT sc->sc_unit
#endif
-#ifdef __FreeBSD__
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
-# define IOCTL_CMD_T u_long
-#else
-#ifdef __NetBSD__
+#if defined __FreeBSD__ || defined __NetBSD__
# define IOCTL_CMD_T u_long
#else
# define IOCTL_CMD_T int
#endif
-#endif
+
+#ifdef __FreeBSD__
PDEVSTATIC void i4biprattach(void *);
PSEUDO_SET(i4biprattach, i4b_ipr);
static int i4biprioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, caddr_t data);
@@ -276,13 +273,11 @@ i4biprattach()
struct ipr_softc *sc = ipr_softc;
int i;
-#ifndef HACK_NO_PSEUDO_ATTACH_MSG
#ifdef IPR_VJ
printf("i4bipr: %d IP over raw HDLC ISDN device(s) attached (VJ header compression)\n", NI4BIPR);
#else
printf("i4bipr: %d IP over raw HDLC ISDN device(s) attached\n", NI4BIPR);
#endif
-#endif
for(i=0; i < NI4BIPR; sc++, i++)
{
@@ -294,9 +289,6 @@ i4biprattach()
#ifdef __FreeBSD__
sc->sc_if.if_name = "ipr";
-#if __FreeBSD__ < 3
- sc->sc_if.if_next = NULL;
-#endif
sc->sc_if.if_unit = i;
#elif defined(__bsdi__)
sc->sc_if.if_name = "ipr";
@@ -324,8 +316,10 @@ i4biprattach()
sc->sc_if.if_snd.ifq_maxlen = I4BIPRMAXQLEN;
sc->sc_fastq.ifq_maxlen = I4BIPRMAXQLEN;
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
mtx_init(&sc->sc_fastq.ifq_mtx, "i4b_ipr_fastq", MTX_DEF);
-
+#endif
sc->sc_if.if_ipackets = 0;
sc->sc_if.if_ierrors = 0;
sc->sc_if.if_opackets = 0;
@@ -368,9 +362,7 @@ i4biprattach()
}
#endif
#endif
-
sc->sc_updown = SOFT_ENA; /* soft enabled */
-
sc->sc_dialresp = DSTAT_NONE; /* no response */
sc->sc_lastdialresp = DSTAT_NONE;
@@ -510,6 +502,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
/* check for space in choosen send queue */
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
if(! IF_HANDOFF(ifq, m, NULL))
{
NDBGL4(L4_IPRDBG, "ipr%d: send queue full!", unit);
@@ -517,6 +510,17 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
sc->sc_if.if_oerrors++;
return(ENOBUFS);
}
+#else
+ if(IF_QFULL(ifq))
+ {
+ NDBGL4(L4_IPRDBG, "ipr%d: send queue full!", unit);
+ IF_DROP(ifq);
+ m_freem(m);
+ splx(s);
+ sc->sc_if.if_oerrors++;
+ return(ENOBUFS);
+ }
+#endif
NDBGL4(L4_IPRDBG, "ipr%d: add packet to send queue!", unit);
@@ -645,11 +649,37 @@ static void
iprclearqueues(struct ipr_softc *sc)
{
int x;
-
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
x = splimp();
IF_DRAIN(&sc->sc_fastq);
IF_DRAIN(&sc->sc_if.if_snd);
splx(x);
+#else
+ struct mbuf *m;
+
+ for(;;)
+ {
+ x = splimp();
+ IF_DEQUEUE(&sc->sc_fastq, m);
+ splx(x);
+ if(m)
+ m_freem(m);
+ else
+ break;
+ }
+
+ for(;;)
+ {
+ x = splimp();
+ IF_DEQUEUE(&sc->sc_if.if_snd, m);
+ splx(x);
+ if(m)
+ m_freem(m);
+ else
+ break;
+ }
+#endif
}
#if I4BIPRACCT
@@ -1047,6 +1077,7 @@ error:
}
#endif /* NBPFILTER > 0 || NBPF > 0 */
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
if(! IF_HANDOFF(&ipintrq, m, NULL))
{
NDBGL4(L4_IPRDBG, "ipr%d: ipintrq full!", unit);
@@ -1057,6 +1088,21 @@ error:
{
schednetisr(NETISR_IP);
}
+#else
+ if(IF_QFULL(&ipintrq))
+ {
+ NDBGL4(L4_IPRDBG, "ipr%d: ipintrq full!", unit);
+ IF_DROP(&ipintrq);
+ sc->sc_if.if_ierrors++;
+ sc->sc_if.if_iqdrops++;
+ m_freem(m);
+ }
+ else
+ {
+ IF_ENQUEUE(&ipintrq, m);
+ schednetisr(NETISR_IP);
+ }
+#endif
}
/*---------------------------------------------------------------------------*
diff --git a/sys/i4b/driver/i4b_ispppsubr.c b/sys/i4b/driver/i4b_ispppsubr.c
index f7823ee..e307573 100644
--- a/sys/i4b/driver/i4b_ispppsubr.c
+++ b/sys/i4b/driver/i4b_ispppsubr.c
@@ -15,18 +15,12 @@
* or modify this software as long as this message is kept with the software,
* all derivative works or modified versions.
*
- * From: Version 2.4, Thu Apr 30 17:17:21 MSD 1997
- *
- * From: if_spppsubr.c,v 1.55 1999/03/30 13:28:26 phk Exp
- *
- * $Id: i4b_ispppsubr.c,v 1.8 2000/09/01 14:11:51 hm Exp $
- *
* $FreeBSD$
*/
#define USE_ISPPP
-#if defined(__NetBSD__) || (defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) || defined(__FreeBSD__)
#include "opt_inet.h"
#include "opt_ipx.h"
#endif
@@ -107,6 +101,7 @@
#include <net/if_sppp.h>
#else
#include <machine/i4b_isppp.h>
+#include <i4b/include/i4b_global.h>
#endif
#else
@@ -116,21 +111,17 @@
#include <machine/cpu.h> /* XXX for softnet */
#endif
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if defined(__FreeBSD__)
# define UNTIMEOUT(fun, arg, handle) untimeout(fun, arg, handle)
# define TIMEOUT(fun, arg1, arg2, handle) handle = timeout(fun, arg1, arg2)
-# define IOCTL_CMD_T u_long
#else
# define UNTIMEOUT(fun, arg, handle) untimeout(fun, arg)
# define TIMEOUT(fun, arg1, arg2, handle) timeout(fun, arg1, arg2)
-#ifdef __FreeBSD__
-# define IOCTL_CMD_T int
-#else
-# define IOCTL_CMD_T u_long
-#endif
#endif
-#if defined(__FreeBSD_version) && (__FreeBSD_version > 300005)
+# define IOCTL_CMD_T u_long
+
+#if defined(__FreeBSD__)
#define HAS_SNPRINTF
#endif
@@ -288,7 +279,8 @@ struct cp {
};
static struct sppp *spppq;
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+
+#if defined(__FreeBSD__)
static struct callout_handle keepalive_ch;
#endif
@@ -675,6 +667,8 @@ isppp_input(struct ifnet *ifp, struct mbuf *m)
/* Check queue. */
s = splimp();
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
if (! IF_HANDOFF(inq, m, NULL)) {
++ifp->if_ierrors;
++ifp->if_iqdrops;
@@ -684,6 +678,19 @@ isppp_input(struct ifnet *ifp, struct mbuf *m)
} else {
sp->pp_last_recv = time_second;
}
+#else
+ if (IF_QFULL (inq)) {
+ /* Queue overflow. */
+ IF_DROP(inq);
+ splx(s);
+ if (debug)
+ log(LOG_DEBUG, SPP_FMT "protocol queue overflow\n",
+ SPP_ARGS(ifp));
+ goto drop;
+ }
+ IF_ENQUEUE(inq, m);
+ sp->pp_last_recv = time_second;
+#endif
splx(s);
}
@@ -875,6 +882,7 @@ nosupport:
return (EAFNOSUPPORT);
}
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
/*
* Queue message on interface, and start output if interface
* not yet active.
@@ -889,6 +897,29 @@ nosupport:
return (rv? rv: ENOBUFS);
}
+#else
+ /*
+ * Queue message on interface, and start output if interface
+ * not yet active.
+ */
+ if (IF_QFULL (ifq)) {
+ IF_DROP (&ifp->if_snd);
+ m_freem (m);
+ ++ifp->if_oerrors;
+ splx (s);
+ return (rv? rv: ENOBUFS);
+ }
+ IF_ENQUEUE (ifq, m);
+ if (! (ifp->if_flags & IFF_OACTIVE))
+ (*ifp->if_start) (ifp);
+
+ /*
+ * Count output packets and bytes.
+ * The packet length includes header, FCS and 1 flag,
+ * according to RFC 1333.
+ */
+ ifp->if_obytes += m->m_pkthdr.len + 3;
+#endif
sp->pp_last_sent = time_second;
splx (s);
return (0);
@@ -922,8 +953,12 @@ isppp_attach(struct ifnet *ifp)
sp->pp_fastq.ifq_maxlen = 32;
sp->pp_cpq.ifq_maxlen = 20;
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
mtx_init(&sp->pp_fastq.ifq_mtx, "i4b_isppp_fastq", MTX_DEF);
mtx_init(&sp->pp_cpq.ifq_mtx, "i4b_isppp_cpq", MTX_DEF);
+#endif
+
sp->pp_loopcnt = 0;
sp->pp_alivecnt = 0;
sp->pp_seq = 0;
@@ -1319,7 +1354,21 @@ sppp_cisco_send(struct sppp *sp, int type, long par1, long par2)
SPP_ARGS(ifp), (u_long)ntohl (ch->type), (u_long)ch->par1,
(u_long)ch->par2, (u_int)ch->rel, (u_int)ch->time0, (u_int)ch->time1);
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
(void) IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3);
+#else
+ if (IF_QFULL (&sp->pp_cpq)) {
+ IF_DROP (&sp->pp_fastq);
+ IF_DROP (&ifp->if_snd);
+ m_freem (m);
+ } else {
+ IF_ENQUEUE (&sp->pp_cpq, m);
+ }
+ if (! (ifp->if_flags & IFF_OACTIVE))
+ (*ifp->if_start) (ifp);
+
+ ifp->if_obytes += m->m_pkthdr.len + 3;
+#endif
}
/*
@@ -1367,8 +1416,25 @@ sppp_cp_send(struct sppp *sp, u_short proto, u_char type,
sppp_print_bytes ((u_char*) (lh+1), len);
log(-1, ">\n");
}
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3))
++ifp->if_oerrors;
+#else
+ if (IF_QFULL (&sp->pp_cpq)) {
+ IF_DROP (&sp->pp_fastq);
+ IF_DROP (&ifp->if_snd);
+ m_freem (m);
+ ++ifp->if_oerrors;
+ } else {
+ IF_ENQUEUE (&sp->pp_cpq, m);
+ }
+
+ if (! (ifp->if_flags & IFF_OACTIVE))
+ (*ifp->if_start) (ifp);
+
+ ifp->if_obytes += m->m_pkthdr.len + 3;
+#endif
}
/*
@@ -4022,8 +4088,24 @@ sppp_auth_send(const struct cp *cp, struct sppp *sp,
sppp_print_bytes((u_char*) (lh+1), len);
log(-1, ">\n");
}
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
if (! IF_HANDOFF_ADJ(&sp->pp_cpq, m, ifp, 3))
++ifp->if_oerrors;
+#else
+ if (IF_QFULL (&sp->pp_cpq)) {
+ IF_DROP (&sp->pp_fastq);
+ IF_DROP (&ifp->if_snd);
+ m_freem (m);
+ ++ifp->if_oerrors;
+ } else {
+ IF_ENQUEUE (&sp->pp_cpq, m);
+ }
+
+ if (! (ifp->if_flags & IFF_OACTIVE))
+ (*ifp->if_start) (ifp);
+
+ ifp->if_obytes += m->m_pkthdr.len + 3;
+#endif
}
/*
diff --git a/sys/i4b/driver/i4b_rbch.c b/sys/i4b/driver/i4b_rbch.c
index 9e7db6a..86644cc 100644
--- a/sys/i4b/driver/i4b_rbch.c
+++ b/sys/i4b/driver/i4b_rbch.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 @@
* i4b_rbch.c - device driver for raw B channel data
* ---------------------------------------------------
*
- * $Id: i4b_rbch.c,v 1.52 2000/10/06 08:37:43 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Mon Oct 2 10:13:09 2000]
+ * last edit-date: [Fri Jan 12 14:32:16 2001]
*
*---------------------------------------------------------------------------*/
@@ -61,10 +59,6 @@ extern cc_t ttydefchars;
#ifdef __FreeBSD__
-#if defined(__FreeBSD__) && __FreeBSD__ == 3
-#include "opt_devfs.h"
-#endif
-
#ifdef DEVFS
#include <sys/devfsext.h>
#endif
@@ -103,7 +97,7 @@ extern cc_t ttydefchars;
#include <sys/ioctl.h>
#endif
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if defined(__FreeBSD__)
#include <sys/filio.h>
#endif
@@ -136,12 +130,6 @@ 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;
@@ -201,7 +189,6 @@ PDEVSTATIC d_select_t i4brbchselect;
#define CDEV_MAJOR 57
-#if defined(__FreeBSD__) && __FreeBSD__ >= 4
static struct cdevsw i4brbch_cdevsw = {
/* open */ i4brbchopen,
/* close */ i4brbchclose,
@@ -218,13 +205,6 @@ static struct cdevsw i4brbch_cdevsw = {
/* flags */ 0,
/* bmaj */ -1
};
-#else
-static struct cdevsw i4brbch_cdevsw = {
- i4brbchopen, i4brbchclose, i4brbchread, i4brbchwrite,
- i4brbchioctl, nostop, noreset, nodevtotty,
- POLLFIELD, nommap, NULL, "i4brbch", NULL, -1
-};
-#endif
static void i4brbchattach(void *);
PSEUDO_SET(i4brbchattach, i4b_rbch);
@@ -239,12 +219,7 @@ PSEUDO_SET(i4brbchattach, i4b_rbch);
static void
i4brbchinit(void *unused)
{
-#if defined(__FreeBSD__) && __FreeBSD__ >= 4
cdevsw_add(&i4brbch_cdevsw);
-#else
- dev_t dev = makedev(CDEV_MAJOR, 0);
- cdevsw_add(&dev, &i4brbch_cdevsw, NULL);
-#endif
}
SYSINIT(i4brbchdev, SI_SUB_DRIVERS,
@@ -300,20 +275,9 @@ i4brbchattach()
for(i=0; i < NI4BRBCH; i++)
{
#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,
UID_ROOT, GID_WHEEL, 0600, "i4brbch%d", i);
#endif
-#endif
#if I4BRBCHACCT
#if defined(__FreeBSD__)
@@ -327,7 +291,9 @@ i4brbchattach()
rbch_softc[i].sc_unit = i;
rbch_softc[i].sc_devstate = ST_IDLE;
rbch_softc[i].sc_hdlcq.ifq_maxlen = I4BRBCHMAXQLEN;
+#if defined(__FreeBSD__) && __FreeBSD__ > 4
mtx_init(&rbch_softc[i].sc_hdlcq.ifq_mtx, "i4b_rbch", MTX_DEF);
+#endif
rbch_softc[i].it_in.c_ispeed = rbch_softc[i].it_in.c_ospeed = 64000;
termioschars(&rbch_softc[i].it_in);
rbch_init_linktab(i);
@@ -590,7 +556,14 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag)
error = uiomove(m->m_data, m->m_len, uio);
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
(void) IF_HANDOFF(isdn_linktab[unit]->tx_queue, m, NULL);
+#else
+ if(IF_QFULL(isdn_linktab[unit]->tx_queue))
+ m_freem(m);
+ else
+ IF_ENQUEUE(isdn_linktab[unit]->tx_queue, m);
+#endif
(*isdn_linktab[unit]->bch_tx_start)(isdn_linktab[unit]->unit, isdn_linktab[unit]->channel);
}
@@ -955,10 +928,22 @@ rbch_rx_data_rdy(int unit)
m->m_pkthdr.len = m->m_len;
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
if (! IF_HANDOFF(&(rbch_softc[unit].sc_hdlcq), m, NULL))
{
NDBGL4(L4_RBCHDBG, "unit %d: hdlc rx queue full!", unit);
}
+#else
+ if(IF_QFULL(&(rbch_softc[unit].sc_hdlcq)))
+ {
+ NDBGL4(L4_RBCHDBG, "unit %d: hdlc rx queue full!", unit);
+ m_freem(m);
+ }
+ else
+ {
+ IF_ENQUEUE(&(rbch_softc[unit].sc_hdlcq), m);
+ }
+#endif
}
if(rbch_softc[unit].sc_devstate & ST_RDWAITDATA)
@@ -1014,10 +999,25 @@ static void
rbch_clrq(int unit)
{
CRIT_VAR;
-
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
CRIT_BEG;
IF_DRAIN(&rbch_softc[unit].sc_hdlcq);
CRIT_END;
+#else
+ struct mbuf *m;
+ for(;;)
+ {
+ CRIT_BEG;
+ IF_DEQUEUE(&rbch_softc[unit].sc_hdlcq, m);
+ CRIT_END;
+
+ if(m)
+ m_freem(m);
+ else
+ break;
+ }
+#endif
}
/*---------------------------------------------------------------------------*
diff --git a/sys/i4b/driver/i4b_tel.c b/sys/i4b/driver/i4b_tel.c
index b34ec16..4ebe716 100644
--- a/sys/i4b/driver/i4b_tel.c
+++ b/sys/i4b/driver/i4b_tel.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 @@
* i4b_tel.c - device driver for ISDN telephony
* --------------------------------------------
*
- * $Id: i4b_tel.c,v 1.51 2000/10/06 08:37:43 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Mon Oct 2 10:06:32 2000]
+ * last edit-date: [Fri Jan 12 14:52:05 2001]
*
*---------------------------------------------------------------------------*/
@@ -44,7 +42,7 @@
#include <sys/param.h>
#include <sys/systm.h>
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__)
#include <sys/ioccom.h>
#include <sys/poll.h>
#else
@@ -61,15 +59,9 @@
#include <sys/tty.h>
#ifdef __FreeBSD__
-
-#if defined(__FreeBSD__) && __FreeBSD__ == 3
-#include "opt_devfs.h"
-#endif
-
#ifdef DEVFS
#include <sys/devfsext.h>
#endif
-
#endif /* __FreeBSD__ */
#ifdef __bsdi__
@@ -94,7 +86,6 @@
/* minor number: lower 6 bits = unit number */
-
#define UNITBITS 6
#define UNITMASK 0x3f
#define UNIT(n) (minor(n) & UNITMASK)
@@ -136,11 +127,6 @@ typedef struct {
struct selinfo selp; /* select / poll */
-#if defined(__FreeBSD__) && __FreeBSD__ == 3
-#ifdef DEVFS
- void *devfs_token; /* token for DEVFS */
-#endif
-#endif
struct i4b_tel_tones tones;
int toneidx;
int toneomega;
@@ -186,8 +172,7 @@ int i4btelpoll __P((dev_t dev, int events, struct proc *p));
int i4btelsel __P((dev_t dev, int rw, struct proc *p));
#endif
-#endif /* __FreeBSD__ */
-
+#endif /* ! __FreeBSD__ */
#if BSD > 199306 && defined(__FreeBSD__)
@@ -208,7 +193,6 @@ PDEVSTATIC d_select_t i4btelsel;
#define CDEV_MAJOR 56
-#if defined(__FreeBSD__) && __FreeBSD__ >= 4
static struct cdevsw i4btel_cdevsw = {
/* open */ i4btelopen,
/* close */ i4btelclose,
@@ -225,13 +209,6 @@ static struct cdevsw i4btel_cdevsw = {
/* flags */ 0,
/* bmaj */ -1
};
-#else
-static struct cdevsw i4btel_cdevsw = {
- i4btelopen, i4btelclose, i4btelread, i4btelwrite,
- i4btelioctl, nostop, noreset, nodevtotty,
- POLLFIELD, nommap, NULL, "i4btel", NULL, -1
-};
-#endif
PDEVSTATIC void i4btelinit(void *unused);
PDEVSTATIC void i4btelattach(void *);
@@ -248,12 +225,7 @@ PSEUDO_SET(i4btelattach, i4b_tel);
PDEVSTATIC void
i4btelinit(void *unused)
{
-#if defined(__FreeBSD__) && __FreeBSD__ >= 4
cdevsw_add(&i4btel_cdevsw);
-#else
- dev_t dev = makedev(CDEV_MAJOR, 0);
- cdevsw_add(&dev, &i4btel_cdevsw, NULL);
-#endif
}
SYSINIT(i4bteldev, SI_SUB_DRIVERS,
@@ -306,9 +278,7 @@ i4btelattach()
{
int i, j;
-#ifndef HACK_NO_PSEUDO_ATTACH_MSG
printf("i4btel: %d ISDN telephony interface device(s) attached\n", NI4BTEL);
-#endif
for(i=0; i < NI4BTEL; i++)
{
@@ -321,17 +291,6 @@ i4btelattach()
tel_sc[i][j].result = 0;
#if defined(__FreeBSD__)
-#if __FreeBSD__ == 3
-
-#ifdef DEVFS
-
-/* XXX */ tel_sc[i][j].devfs_token
- = devfs_add_devswf(&i4btel_cdevsw, i, DV_CHR,
- UID_ROOT, GID_WHEEL, 0600,
- "i4btel%d", i);
-#endif
-
-#else
switch(j)
{
case FUNCTEL: /* normal i4btel device */
@@ -347,7 +306,6 @@ i4btelattach()
break;
}
#endif
-#endif
}
tel_init_linktab(i);
}
@@ -401,6 +359,7 @@ i4btelclose(dev_t dev, int flag, int fmt, struct proc *p)
x = splimp();
sc->devstate &= ~ST_TONE;
+
if((func == FUNCTEL) &&
(sc->isdn_linktab != NULL && sc->isdn_linktab->tx_queue != NULL))
{
@@ -428,7 +387,7 @@ i4btelclose(dev_t dev, int flag, int fmt, struct proc *p)
* i4btelioctl - device driver ioctl routine
*---------------------------------------------------------------------------*/
PDEVSTATIC int
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300003
+#if defined(__FreeBSD__)
i4btelioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
#elif defined(__bsdi__)
i4btelioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
@@ -574,6 +533,7 @@ i4btelread(dev_t dev, struct uio *uio, int ioflag)
{
s = splimp();
IF_LOCK(sc->isdn_linktab->rx_queue);
+
while(IF_QEMPTY(sc->isdn_linktab->rx_queue) &&
(sc->devstate & ST_ISOPEN) &&
(sc->devstate & ST_CONNECTED))
@@ -581,11 +541,16 @@ i4btelread(dev_t dev, struct uio *uio, int ioflag)
sc->devstate |= ST_RDWAITDATA;
NDBGL4(L4_TELDBG, "i4btel%d, queue empty!", unit);
-
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
if((error = msleep((caddr_t) &sc->isdn_linktab->rx_queue,
- &sc->isdn_linktab->rx_queue->ifq_mtx,
+ &sc->isdn_linktab->rx_queue->ifq_mtx,
+ TTIPRI | PCATCH,
+ "rtel", 0 )) != 0)
+#else
+ if((error = tsleep((caddr_t) &sc->isdn_linktab->rx_queue,
TTIPRI | PCATCH,
"rtel", 0 )) != 0)
+#endif
{
sc->devstate &= ~ST_RDWAITDATA;
IF_UNLOCK(sc->isdn_linktab->rx_queue);
@@ -711,12 +676,16 @@ i4btelwrite(dev_t dev, struct uio * uio, int ioflag)
(sc->devstate & ST_ISOPEN))
{
sc->devstate |= ST_WRWAITEMPTY;
-
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
if((error = msleep((caddr_t) &sc->isdn_linktab->tx_queue,
&sc->isdn_linktab->tx_queue->ifq_mtx,
TTIPRI | PCATCH, "wtel", 0)) != 0)
+#else
+ if((error = tsleep((caddr_t) &sc->isdn_linktab->tx_queue,
+ TTIPRI | PCATCH, "wtel", 0)) != 0)
+#endif
{
- sc->devstate &= ~ST_WRWAITEMPTY;
+ sc->devstate &= ~ST_WRWAITEMPTY;
IF_UNLOCK(sc->isdn_linktab->tx_queue);
splx(s);
return(error);
@@ -753,8 +722,14 @@ i4btelwrite(dev_t dev, struct uio * uio, int ioflag)
/* always reverse bitorder to line */
mtod(m,u_char *)[i] = bitreverse[mtod(m,u_char *)[i]];
}
-
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
(void) IF_HANDOFF(sc->isdn_linktab->tx_queue, m, NULL);
+#else
+ if(IF_QFULL(sc->isdn_linktab->tx_queue))
+ m_freem(m);
+ else
+ IF_ENQUEUE(sc->isdn_linktab->tx_queue, m);
+#endif
(*sc->isdn_linktab->bch_tx_start)(sc->isdn_linktab->unit, sc->isdn_linktab->channel);
}
diff --git a/sys/i4b/driver/i4b_trace.c b/sys/i4b/driver/i4b_trace.c
index ff29c01..7be9cfc 100644
--- a/sys/i4b/driver/i4b_trace.c
+++ b/sys/i4b/driver/i4b_trace.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 +27,7 @@
* i4btrc - device driver for trace data read device
* ---------------------------------------------------
*
- * $Id: i4b_trace.c,v 1.27 2000/06/02 16:14:35 hm Exp $
- *
- * last edit-date: [Fri Jun 2 17:48:19 2000]
+ * last edit-date: [Fri Jan 12 14:18:12 2001]
*
* $FreeBSD$
*
@@ -131,7 +129,6 @@ static d_poll_t i4btrcpoll;
#define CDEV_MAJOR 59
-#if defined(__FreeBSD__) && __FreeBSD__ >= 4
static struct cdevsw i4btrc_cdevsw = {
/* open */ i4btrcopen,
/* close */ i4btrcclose,
@@ -148,13 +145,6 @@ static struct cdevsw i4btrc_cdevsw = {
/* flags */ 0,
/* bmaj */ -1
};
-#else
-static struct cdevsw i4btrc_cdevsw = {
- i4btrcopen, i4btrcclose, i4btrcread, nowrite,
- i4btrcioctl, nostop, noreset, nodevtotty,
- POLLFIELD, nommap, NULL, "i4btrc", NULL, -1
-};
-#endif
/*---------------------------------------------------------------------------*
* interface init routine
@@ -162,12 +152,7 @@ static struct cdevsw i4btrc_cdevsw = {
static
void i4btrcinit(void *unused)
{
-#if defined(__FreeBSD__) && __FreeBSD__ >= 4
cdevsw_add(&i4btrc_cdevsw);
-#else
- dev_t dev = makedev(CDEV_MAJOR, 0);
- cdevsw_add(&dev, &i4btrc_cdevsw, NULL);
-#endif
}
SYSINIT(i4btrcdev, SI_SUB_DRIVERS,
@@ -221,31 +206,21 @@ i4btrcattach()
#endif
{
int i;
-
-#ifndef HACK_NO_PSEUDO_ATTACH_MSG
+
printf("i4btrc: %d ISDN trace device(s) attached\n", NI4BTRC);
-#endif
for(i=0; i < NI4BTRC; i++)
{
#if defined(__FreeBSD__)
-#if __FreeBSD__ < 4
-
-#ifdef DEVFS
- devfs_token[i]
- = devfs_add_devswf(&i4btrc_cdevsw, i, DV_CHR,
- UID_ROOT, GID_WHEEL, 0600,
- "i4btrc%d", i);
-#endif
-
-#else
make_dev(&i4btrc_cdevsw, i,
UID_ROOT, GID_WHEEL, 0600, "i4btrc%d", i);
#endif
-#endif
trace_queue[i].ifq_maxlen = IFQ_MAXLEN;
+
+#if __FreeBSD__ > 4
mtx_init(&trace_queue[i].ifq_mtx, "i4b_trace", MTX_DEF);
+#endif
device_state[i] = ST_IDLE;
}
}
@@ -449,10 +424,16 @@ i4btrcread(dev_t dev, struct uio * uio, int ioflag)
{
device_state[unit] |= ST_WAITDATA;
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
if((error = msleep((caddr_t) &trace_queue[unit],
&trace_queue[unit].ifq_mtx,
TTIPRI | PCATCH,
"bitrc", 0 )) != 0)
+#else
+ if((error = tsleep((caddr_t) &trace_queue[unit],
+ TTIPRI | PCATCH,
+ "bitrc", 0 )) != 0)
+#endif
{
device_state[unit] &= ~ST_WAITDATA;
IF_UNLOCK(&trace_queue[unit]);
diff --git a/sys/i4b/include/i4b_global.h b/sys/i4b/include/i4b_global.h
index 9bf3025..d4dc77d 100644
--- a/sys/i4b/include/i4b_global.h
+++ b/sys/i4b/include/i4b_global.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 @@
* i4b_global.h - i4b global include file
* --------------------------------------
*
- * $Id: i4b_global.h,v 1.27 2000/08/28 07:24:58 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Thu Aug 24 12:38:50 2000]
+ * last edit-date: [Mon Jan 15 15:47:40 2001]
*
*---------------------------------------------------------------------------*/
@@ -42,6 +40,25 @@
* hiding OS differences in the kernel
*---------------------------------------------------------------------------*/
+/*-------------------------------------------------*/
+/* hide SMP changes in FreeBSD 5.x-current for 4.x */
+/*-------------------------------------------------*/
+
+#if defined(__FreeBSD__) && __FreeBSD__ <= 4
+
+#define IF_LOCK(a)
+#define IF_UNLOCK(a)
+#define _IF_QFULL(a) IF_QFULL((a))
+#define _IF_ENQUEUE(a, b) IF_ENQUEUE((a), (b))
+#define _IF_DEQUEUE(a, b) IF_DEQUEUE((a), (b))
+#define _IF_PREPEND(a, b) IF_PREPEND((a), (b))
+
+/* get back DELAY() */
+
+#include <machine/clock.h>
+
+#endif
+
/*---------------*/
/* time handling */
/*---------------*/
diff --git a/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c b/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c
index 06f8d9d..d14deb4 100644
--- a/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c
+++ b/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c
@@ -37,7 +37,7 @@
*
* $FreeBSD$
*
- * last edit-date: [Fri Jun 2 13:58:02 2000]
+ * last edit-date: [Fri Jan 12 17:01:26 2001]
*
*---------------------------------------------------------------------------*/
@@ -648,6 +648,7 @@ avma1pp_attach_avma1pp(device_t dev)
/* init the ISAC */
ifpi_isac_init(sc);
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
/* Init the channel mutexes */
chan = &sc->sc_chan[HSCX_CH_A];
mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp_rx", MTX_DEF);
@@ -655,6 +656,7 @@ avma1pp_attach_avma1pp(device_t dev)
chan = &sc->sc_chan[HSCX_CH_B];
mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp_rx", MTX_DEF);
mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp_tx", MTX_DEF);
+#endif
/* init the "HSCX" */
avma1pp_bchannel_setup(sc->sc_unit, HSCX_CH_A, BPROT_NONE, 0);
@@ -872,8 +874,18 @@ avma1pp_hscx_intr(int h_chan, u_int stat, struct l1_softc *sc)
/* move rx'd data to rx queue */
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
(void) IF_HANDOFF(&chan->rx_queue, chan->in_mbuf, NULL);
-
+#else
+ if(!(IF_QFULL(&chan->rx_queue)))
+ {
+ IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf);
+ }
+ else
+ {
+ i4b_Bfreembuf(chan->in_mbuf);
+ }
+#endif
/* signal upper layer that data are available */
(*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
diff --git a/sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c b/sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c
index bc69399..d91f5e1 100644
--- a/sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c
+++ b/sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c
@@ -33,12 +33,9 @@
* i4b_ifpnp_avm.c: AVM Fritz!Card PnP hardware driver
* ---------------------------------------------------
*
- * $Id: i4b_ifpnp_avm.c,v 1.3 2000/05/29 15:41:41 hm Exp $
- * $Ust: src/i4b/layer1-nb/ifpnp/i4b_ifpnp_avm.c,v 1.6 2000/04/18 08:32:32 ust Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Mon May 29 15:24:43 2000]
+ * last edit-date: [Fri Jan 12 17:05:28 2001]
*
*---------------------------------------------------------------------------*/
@@ -798,9 +795,18 @@ avm_pnp_hscx_intr(int h_chan, u_int stat, u_int cnt, struct l1_softc *sc)
activity = ACT_RX;
/* move rx'd data to rx queue */
-
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
(void) IF_HANDOFF(&chan->rx_queue, chan->in_mbuf, NULL);
-
+#else
+ if(!(IF_QFULL(&chan->rx_queue)))
+ {
+ IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf);
+ }
+ else
+ {
+ i4b_Bfreembuf(chan->in_mbuf);
+ }
+#endif
/* signal upper layer that data are available */
(*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
@@ -1038,7 +1044,10 @@ avm_pnp_bchannel_setup(int unit, int h_chan, int bprot, int activate)
/* receiver part */
chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avm_pnp_rx", MTX_DEF);
+#endif
i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */
@@ -1053,8 +1062,10 @@ avm_pnp_bchannel_setup(int unit, int h_chan, int bprot, int activate)
/* transmitter part */
chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
- mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avm_pnp_tx", MTX_DEF);
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
+ mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avm_pnp_tx", MTX_DEF);
+#endif
i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */
chan->txcount = 0; /* reset tx counter */
diff --git a/sys/i4b/layer1/ihfc/i4b_ihfc_drv.c b/sys/i4b/layer1/ihfc/i4b_ihfc_drv.c
index ebf5cb1..722e856 100644
--- a/sys/i4b/layer1/ihfc/i4b_ihfc_drv.c
+++ b/sys/i4b/layer1/ihfc/i4b_ihfc_drv.c
@@ -30,9 +30,7 @@
* Everything which has got anything to do with the
* HFC-1/S/SP chips has been put here.
*
- * last edit-date: [Wed Jul 19 09:39:42 2000]
- *
- * $Id: i4b_ihfc_drv.c,v 1.11 2000/09/19 13:50:36 hm Exp $
+ * last edit-date: [Fri Jan 12 17:06:52 2001]
*
* $FreeBSD$
*
@@ -360,8 +358,10 @@ ihfc_init (ihfc_sc_t *sc, u_char chan, int prot, int activate)
RESET_SOFT_CHAN(sc, chan);
S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
- mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
+ mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
+#endif
if (!activate) continue;
if (S_HFC & HFC_1)
@@ -383,8 +383,10 @@ ihfc_init (ihfc_sc_t *sc, u_char chan, int prot, int activate)
RESET_SOFT_CHAN(sc, chan);
S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
- mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
+ mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
+#endif
S_PROT = prot;
if (!activate) continue;
diff --git a/sys/i4b/layer1/isic/i4b_bchan.c b/sys/i4b/layer1/isic/i4b_bchan.c
index c937790..86946f1 100644
--- a/sys/i4b/layer1/isic/i4b_bchan.c
+++ b/sys/i4b/layer1/isic/i4b_bchan.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 @@
* i4b_bchan.c - B channel handling L1 procedures
* ----------------------------------------------
*
- * $Id: i4b_bchan.c,v 1.6 2000/05/29 15:41:41 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Mon May 29 16:42:26 2000]
+ * last edit-date: [Fri Jan 12 16:52:15 2001]
*
*---------------------------------------------------------------------------*/
@@ -92,7 +90,10 @@ isic_bchannel_setup(int unit, int h_chan, int bprot, int activate)
/* receiver part */
chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
mtx_init(&chan->rx_queue.ifq_mtx, "i4b_isic_rx", MTX_DEF);
+#endif
i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */
@@ -107,7 +108,10 @@ isic_bchannel_setup(int unit, int h_chan, int bprot, int activate)
/* transmitter part */
chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
mtx_init(&chan->tx_queue.ifq_mtx, "i4b_isic_tx", MTX_DEF);
+#endif
i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */
diff --git a/sys/i4b/layer1/isic/i4b_hscx.c b/sys/i4b/layer1/isic/i4b_hscx.c
index 79e74b8..6383cba 100644
--- a/sys/i4b/layer1/isic/i4b_hscx.c
+++ b/sys/i4b/layer1/isic/i4b_hscx.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 @@
* i4b - Siemens HSCX chip (B-channel) handling
* --------------------------------------------
*
- * $Id: i4b_hscx.c,v 1.7 2000/05/29 15:41:41 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Mon May 29 16:44:50 2000]
+ * last edit-date: [Mon Jan 15 15:50:42 2001]
*
*---------------------------------------------------------------------------*/
@@ -270,8 +268,18 @@ isic_hscx_irq(register struct l1_softc *sc, u_char ista, int h_chan, u_char ex_i
if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len)))
activity = ACT_RX;
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
(void) IF_HANDOFF(&chan->rx_queue, chan->in_mbuf, NULL);
-
+#else
+ if(!(IF_QFULL(&chan->rx_queue)))
+ {
+ IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf);
+ }
+ else
+ {
+ i4b_Bfreembuf(chan->in_mbuf);
+ }
+#endif
/* signal upper driver that data is available */
(*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
diff --git a/sys/i4b/layer1/iwic/i4b_iwic_bchan.c b/sys/i4b/layer1/iwic/i4b_iwic_bchan.c
index 0b8fa26..a636f24 100644
--- a/sys/i4b/layer1/iwic/i4b_iwic_bchan.c
+++ b/sys/i4b/layer1/iwic/i4b_iwic_bchan.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1999, 2000 Dave Boyce. All rights reserved.
*
- * Copyright (c) 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 2000, 2001 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,11 +29,9 @@
* i4b_iwic - isdn4bsd Winbond W6692 driver
* ----------------------------------------
*
- * $Id: i4b_iwic_bchan.c,v 1.8 2000/05/29 15:41:42 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Mon May 29 16:48:56 2000]
+ * last edit-date: [Fri Jan 12 16:57:01 2001]
*
*---------------------------------------------------------------------------*/
@@ -239,8 +237,18 @@ iwic_bchan_xirq(struct iwic_softc *sc, int chan_no)
if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len)))
activity = ACT_RX;
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
(void) IF_HANDOFF(&chan->rx_queue, chan->in_mbuf, NULL);
-
+#else
+ if(!(IF_QFULL(&chan->rx_queue)))
+ {
+ IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf);
+ }
+ else
+ {
+ i4b_Bfreembuf(chan->in_mbuf);
+ }
+#endif
/* signal upper driver that data is available */
(*chan->iwic_drvr_linktab->bch_rx_data_ready)(chan->iwic_drvr_linktab->unit);
@@ -410,7 +418,10 @@ iwic_bchannel_setup(int unit, int chan_no, int bprot, int activate)
/* receiver part */
chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
mtx_init(&chan->rx_queue.ifq_mtx, "i4b_iwic_rx", MTX_DEF);
+#endif
i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */
@@ -425,7 +436,10 @@ iwic_bchannel_setup(int unit, int chan_no, int bprot, int activate)
/* transmitter part */
chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
mtx_init(&chan->tx_queue.ifq_mtx, "i4b_iwic_tx", MTX_DEF);
+#endif
i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */
diff --git a/sys/i4b/layer2/i4b_l2.c b/sys/i4b/layer2/i4b_l2.c
index b3f79a6..0383812 100644
--- a/sys/i4b/layer2/i4b_l2.c
+++ b/sys/i4b/layer2/i4b_l2.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 @@
* i4b_l2.c - ISDN layer 2 (Q.921)
* -------------------------------
*
- * $Id: i4b_l2.c,v 1.35 2000/08/24 11:48:57 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Thu Aug 24 13:40:35 2000]
+ * last edit-date: [Fri Jan 12 16:43:31 2001]
*
*---------------------------------------------------------------------------*/
@@ -277,7 +275,10 @@ i4b_mph_status_ind(int unit, int status, int parm)
case STI_ATTACH:
l2sc->unit = unit;
l2sc->i_queue.ifq_maxlen = IQUEUE_MAXLEN;
+
+#if defined(__FreeBSD__) && __FreeBSD__ > 4
mtx_init(&l2sc->i_queue.ifq_mtx, "i4b_l2sc", MTX_DEF);
+#endif
l2sc->ua_frame = NULL;
bzero(&l2sc->stat, sizeof(lapdstat_t));
i4b_l2_unit_init(unit);
diff --git a/sys/i4b/layer2/i4b_mbuf.c b/sys/i4b/layer2/i4b_mbuf.c
index 0537a5e..665ff67 100644
--- a/sys/i4b/layer2/i4b_mbuf.c
+++ b/sys/i4b/layer2/i4b_mbuf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 @@
* i4b - mbuf handling support routines
* ------------------------------------
*
- * $Id: i4b_mbuf.c,v 1.15 2000/05/29 15:41:42 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Mon May 29 16:55:18 2000]
+ * last edit-date: [Sat Jan 13 13:15:45 2001]
*
*---------------------------------------------------------------------------*/
@@ -141,8 +139,17 @@ void
i4b_Dcleanifq(struct ifqueue *ifq)
{
int x = splimp();
-
+
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
IF_DRAIN(ifq);
+#else
+ struct mbuf *m;
+ while(!IF_QEMPTY(ifq))
+ {
+ IF_DEQUEUE(ifq, m);
+ i4b_Dfreembuf(m);
+ }
+#endif
splx(x);
}
@@ -218,7 +225,16 @@ i4b_Bcleanifq(struct ifqueue *ifq)
{
int x = splimp();
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
IF_DRAIN(ifq);
+#else
+ struct mbuf *m;
+ while(!IF_QEMPTY(ifq))
+ {
+ IF_DEQUEUE(ifq, m);
+ i4b_Bfreembuf(m);
+ }
+#endif
splx(x);
}
diff --git a/sys/i4b/layer4/i4b_i4bdrv.c b/sys/i4b/layer4/i4b_i4bdrv.c
index 118926d..3aef6cb 100644
--- a/sys/i4b/layer4/i4b_i4bdrv.c
+++ b/sys/i4b/layer4/i4b_i4bdrv.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2001 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,9 @@
* i4b_i4bdrv.c - i4b userland interface driver
* --------------------------------------------
*
- * $Id: i4b_i4bdrv.c,v 1.59 2000/10/06 08:37:43 hm Exp $
- *
* $FreeBSD$
*
- * last edit-date: [Mon Oct 2 09:55:28 2000]
+ * last edit-date: [Fri Jan 12 16:49:34 2001]
*
*---------------------------------------------------------------------------*/
@@ -39,7 +37,6 @@
#include "i4bipr.h"
#include "i4btel.h"
-
#if NI4B > 1
#error "only 1 (one) i4b device possible!"
#endif
@@ -258,25 +255,17 @@ i4battach(void *dummy)
i4battach()
#endif
{
-#ifndef HACK_NO_PSEUDO_ATTACH_MSG
printf("i4b: ISDN call control device attached\n");
-#endif
- i4b_rdqueue.ifq_maxlen = IFQ_MAXLEN;
- mtx_init(&i4b_rdqueue.ifq_mtx, "i4b_rdqueue", MTX_DEF);
-#if defined(__FreeBSD__)
-#if __FreeBSD__ == 3
+ i4b_rdqueue.ifq_maxlen = IFQ_MAXLEN;
-#ifdef DEVFS
- devfs_token = devfs_add_devswf(&i4b_cdevsw, 0, DV_CHR,
- UID_ROOT, GID_WHEEL, 0600,
- "i4b");
+#if defined(__FreeBSD__) && __FreeBSD__ > 4
+ mtx_init(&i4b_rdqueue.ifq_mtx, "i4b_rdqueue", MTX_DEF);
#endif
-#else
+#if defined(__FreeBSD__)
make_dev(&i4b_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "i4b");
#endif
-#endif
}
/*---------------------------------------------------------------------------*
@@ -333,8 +322,13 @@ i4bread(dev_t dev, struct uio *uio, int ioflag)
while(IF_QEMPTY(&i4b_rdqueue))
{
readflag = 1;
+#if defined (__FreeBSD__) && __FreeBSD__ > 4
error = msleep((caddr_t) &i4b_rdqueue, &i4b_rdqueue.ifq_mtx,
- (PZERO + 1) | PCATCH, "bird", 0);
+ (PZERO + 1) | PCATCH, "bird", 0);
+#else
+ error = tsleep((caddr_t) &i4b_rdqueue, (PZERO + 1) | PCATCH,
+ "bird", 0);
+#endif
if (error != 0) {
IF_UNLOCK(&i4b_rdqueue);
splx(x);
OpenPOWER on IntegriCloud