[Midnightbsd-cvs] src: i4b/capi: removing isdn 4 bsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Sep 12 20:53:33 EDT 2008


Log Message:
-----------
removing isdn 4 bsd

Removed Files:
-------------
    src/sys/i4b/capi:
        README
        capi.h
        capi_l4if.c
        capi_llif.c
        capi_msgs.c
        capi_msgs.h
    src/sys/i4b/capi/iavc:
        iavc.h
        iavc_card.c
        iavc_isa.c
        iavc_lli.c
        iavc_pci.c
    src/sys/i4b/driver:
        i4b_ctl.c
        i4b_ing.c
        i4b_ipr.c
        i4b_isppp.c
        i4b_rbch.c
        i4b_tel.c
        i4b_trace.c
    src/sys/i4b/include:
        i4b_global.h
        i4b_isdnq931.h
        i4b_l1l2.h
        i4b_l2l3.h
        i4b_l3l4.h
        i4b_mbuf.h
    src/sys/i4b/layer1:
        i4b_hdlc.c
        i4b_hdlc.h
        i4b_l1.h
        i4b_l1dmux.c
        i4b_l1lib.c
    src/sys/i4b/layer1/ifpi:
        i4b_ifpi_ext.h
        i4b_ifpi_isac.c
        i4b_ifpi_l1.c
        i4b_ifpi_l1fsm.c
        i4b_ifpi_pci.c
    src/sys/i4b/layer1/ifpi2:
        i4b_ifpi2_ext.h
        i4b_ifpi2_isacsx.c
        i4b_ifpi2_isacsx.h
        i4b_ifpi2_l1.c
        i4b_ifpi2_l1fsm.c
        i4b_ifpi2_pci.c
    src/sys/i4b/layer1/ifpnp:
        i4b_ifpnp_avm.c
        i4b_ifpnp_ext.h
        i4b_ifpnp_isac.c
        i4b_ifpnp_l1.c
        i4b_ifpnp_l1fsm.c
    src/sys/i4b/layer1/ihfc:
        i4b_ihfc.h
        i4b_ihfc_drv.c
        i4b_ihfc_drv.h
        i4b_ihfc_ext.h
        i4b_ihfc_l1if.c
        i4b_ihfc_pnp.c
    src/sys/i4b/layer1/isic:
        i4b_asuscom_ipac.c
        i4b_avm_a1.c
        i4b_bchan.c
        i4b_ctx_s0P.c
        i4b_diva.c
        i4b_drn_ngo.c
        i4b_dynalink.c
        i4b_elsa_pcc16.c
        i4b_elsa_qs1i.c
        i4b_elsa_qs1p.c
        i4b_hscx.c
        i4b_hscx.h
        i4b_ipac.h
        i4b_isac.c
        i4b_isac.h
        i4b_isic.c
        i4b_isic.h
        i4b_isic_ext.h
        i4b_isic_isa.c
        i4b_isic_pnp.c
        i4b_itk_ix1.c
        i4b_l1.c
        i4b_l1fsm.c
        i4b_siemens_isurf.c
        i4b_sws.c
        i4b_tel_s016.c
        i4b_tel_s0163.c
        i4b_tel_s08.c
        i4b_usr_sti.c
    src/sys/i4b/layer1/itjc:
        i4b_hdlc.h
        i4b_itjc_ext.h
        i4b_itjc_isac.c
        i4b_itjc_l1.c
        i4b_itjc_l1fsm.c
        i4b_itjc_pci.c
    src/sys/i4b/layer1/iwic:
        i4b_iwic.h
        i4b_iwic_bchan.c
        i4b_iwic_dchan.c
        i4b_iwic_ext.h
        i4b_iwic_fsm.c
        i4b_iwic_l1if.c
        i4b_iwic_pci.c
        i4b_w6692.h
    src/sys/i4b/layer2:
        i4b_iframe.c
        i4b_l2.c
        i4b_l2.h
        i4b_l2fsm.c
        i4b_l2fsm.h
        i4b_l2timer.c
        i4b_lme.c
        i4b_mbuf.c
        i4b_sframe.c
        i4b_tei.c
        i4b_uframe.c
        i4b_util.c
    src/sys/i4b/layer3:
        i4b_l2if.c
        i4b_l3.h
        i4b_l3fsm.c
        i4b_l3fsm.h
        i4b_l3timer.c
        i4b_l4if.c
        i4b_q931.c
        i4b_q931.h
        i4b_q932fac.c
        i4b_q932fac.h
    src/sys/i4b/layer4:
        i4b_i4bdrv.c
        i4b_l4.c
        i4b_l4.h
        i4b_l4mgmt.c
        i4b_l4timer.c

-------------- next part --------------
--- sys/i4b/driver/i4b_rbch.c
+++ /dev/null
@@ -1,826 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_rbch.c - device driver for raw B channel data
- *	---------------------------------------------------
- *	last edit-date: [Sun Mar 17 09:51:03 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/driver/i4b_rbch.c,v 1.35 2005/01/06 22:18:18 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/uio.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/filio.h>
-#include <sys/tty.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_rbch_ioctl.h>
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-#include <sys/ioccom.h>
-#include <sys/poll.h>
-
-static drvr_link_t rbch_drvr_linktab[NI4BRBCH];
-static isdn_link_t *isdn_linktab[NI4BRBCH];
-
-#define I4BRBCHACCT		1 	/* enable accounting messages */
-#define	I4BRBCHACCTINTVL	2	/* accounting msg interval in secs */
-
-static struct rbch_softc {
-	int sc_unit;			/* unit number 		*/
-
-	int sc_devstate;		/* state of driver	*/
-#define ST_IDLE		0x00
-#define ST_CONNECTED	0x01
-#define ST_ISOPEN	0x02
-#define ST_RDWAITDATA	0x04
-#define ST_WRWAITEMPTY	0x08
-#define ST_NOBLOCK	0x10
-
-	int sc_bprot;			/* B-ch protocol used	*/
-	call_desc_t *sc_cd;		/* Call Descriptor */
-	struct termios it_in;
-
-	struct ifqueue sc_hdlcq;	/* hdlc read queue	*/
-#define I4BRBCHMAXQLEN	10
-
-	struct selinfo selp;		/* select / poll	*/
-
-#if I4BRBCHACCT
-	struct callout_handle sc_callout;
-	int		sc_iinb;	/* isdn driver # of inbytes	*/
-	int		sc_ioutb;	/* isdn driver # of outbytes	*/
-	int		sc_linb;	/* last # of bytes rx'd		*/
-	int		sc_loutb;	/* last # of bytes tx'd 	*/
-	int		sc_fn;		/* flag, first null acct	*/
-#endif	
-} rbch_softc[NI4BRBCH];
-
-static void rbch_rx_data_rdy(int unit);
-static void rbch_tx_queue_empty(int unit);
-static void rbch_connect(int unit, void *cdp);
-static void rbch_disconnect(int unit, void *cdp);
-static void rbch_init_linktab(int unit);
-static void rbch_clrq(int unit);
-
-static 	d_open_t	i4brbchopen;
-static 	d_close_t	i4brbchclose;
-static 	d_read_t	i4brbchread;
-static 	d_read_t	i4brbchwrite;
-static 	d_ioctl_t	i4brbchioctl;
-static 	d_poll_t	i4brbchpoll;
-
-
-static struct cdevsw i4brbch_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
-	.d_open =	i4brbchopen,
-	.d_close =	i4brbchclose,
-	.d_read =	i4brbchread,
-	.d_write =	i4brbchwrite,
-	.d_ioctl =	i4brbchioctl,
-	.d_poll =	i4brbchpoll,
-	.d_name =	"i4brbch",
-};
-
-static void i4brbchattach(void *);
-PSEUDO_SET(i4brbchattach, i4b_rbch);
-
-/*===========================================================================*
- *			DEVICE DRIVER ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	interface attach routine
- *---------------------------------------------------------------------------*/
-static void
-i4brbchattach(void *dummy)
-{
-	int i;
-
-	printf("i4brbch: %d raw B channel access device(s) attached\n", NI4BRBCH);
-	
-	for(i=0; i < NI4BRBCH; i++)
-	{
-		make_dev(&i4brbch_cdevsw, i,
-			UID_ROOT, GID_WHEEL, 0600, "i4brbch%d", i);
-
-#if I4BRBCHACCT
-		callout_handle_init(&rbch_softc[i].sc_callout);
-		rbch_softc[i].sc_fn = 1;
-#endif
-		rbch_softc[i].sc_unit = i;
-		rbch_softc[i].sc_devstate = ST_IDLE;
-		rbch_softc[i].sc_hdlcq.ifq_maxlen = I4BRBCHMAXQLEN;
-
-		if(!mtx_initialized(&rbch_softc[i].sc_hdlcq.ifq_mtx))
-			mtx_init(&rbch_softc[i].sc_hdlcq.ifq_mtx, "i4b_rbch", NULL, MTX_DEF);
-
-		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);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	open rbch device
- *---------------------------------------------------------------------------*/
-static int
-i4brbchopen(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	int unit = minor(dev);
-	
-	if(unit >= NI4BRBCH)
-		return(ENXIO);
-
-	if(rbch_softc[unit].sc_devstate & ST_ISOPEN)
-		return(EBUSY);
-
-#if 0
-	rbch_clrq(unit);
-#endif
-	
-	rbch_softc[unit].sc_devstate |= ST_ISOPEN;		
-
-	NDBGL4(L4_RBCHDBG, "unit %d, open", unit);	
-
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	close rbch device
- *---------------------------------------------------------------------------*/
-static int
-i4brbchclose(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	int unit = minor(dev);
-	struct rbch_softc *sc = &rbch_softc[unit];
-	
-	if(sc->sc_devstate & ST_CONNECTED)
-		i4b_l4_drvrdisc(BDRV_RBCH, unit);
-
-	sc->sc_devstate &= ~ST_ISOPEN;		
-
-	rbch_clrq(unit);
-	
-	NDBGL4(L4_RBCHDBG, "unit %d, closed", unit);
-	
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	read from rbch device
- *---------------------------------------------------------------------------*/
-static int
-i4brbchread(struct cdev *dev, struct uio *uio, int ioflag)
-{
-	struct mbuf *m;
-	int error = 0;
-	int unit = minor(dev);
-	struct ifqueue *iqp;
-	struct rbch_softc *sc = &rbch_softc[unit];
-
-	CRIT_VAR;
-	
-	NDBGL4(L4_RBCHDBG, "unit %d, enter read", unit);
-	
-	CRIT_BEG;
-	if(!(sc->sc_devstate & ST_ISOPEN))
-	{
-		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)) {
-			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)) {
-			CRIT_END;
-			return(EWOULDBLOCK);
-	}
-	}
-	else
-	{
-		while(!(sc->sc_devstate & ST_CONNECTED))
-		{
-			NDBGL4(L4_RBCHDBG, "unit %d, wait read init", unit);
-		
-			if((error = tsleep( &rbch_softc[unit],
-					   I4BPRI | PCATCH,
-					   "rrrbch", 0 )) != 0)
-			{
-				CRIT_END;
-				NDBGL4(L4_RBCHDBG, "unit %d, error %d tsleep", unit, error);
-				return(error);
-			}
-		}
-
-		if(sc->sc_bprot == BPROT_RHDLC)
-			iqp = &sc->sc_hdlcq;
-		else
-			iqp = isdn_linktab[unit]->rx_queue;	
-
-		while(IF_QEMPTY(iqp) && (sc->sc_devstate & ST_ISOPEN))
-		{
-			sc->sc_devstate |= ST_RDWAITDATA;
-		
-			NDBGL4(L4_RBCHDBG, "unit %d, wait read data", unit);
-		
-			if((error = tsleep( &isdn_linktab[unit]->rx_queue,
-					   I4BPRI | PCATCH,
-					   "rrbch", 0 )) != 0)
-			{
-				CRIT_END;
-				NDBGL4(L4_RBCHDBG, "unit %d, error %d tsleep read", unit, error);
-				sc->sc_devstate &= ~ST_RDWAITDATA;
-				return(error);
-			}
-		}
-	}
-
-	IF_DEQUEUE(iqp, m);
-
-	NDBGL4(L4_RBCHDBG, "unit %d, read %d bytes", unit, m->m_len);
-	
-	if(m && m->m_len)
-	{
-		error = uiomove(m->m_data, m->m_len, uio);
-	}
-	else
-	{
-		NDBGL4(L4_RBCHDBG, "unit %d, error %d uiomove", unit, error);
-		error = EIO;
-	}
-		
-	if(m)
-		i4b_Bfreembuf(m);
-
-	CRIT_END;
-
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	write to rbch device
- *---------------------------------------------------------------------------*/
-static int
-i4brbchwrite(struct cdev *dev, struct uio * uio, int ioflag)
-{
-	struct mbuf *m;
-	int error = 0;
-	int unit = minor(dev);
-	struct rbch_softc *sc = &rbch_softc[unit];
-
-	CRIT_VAR;
-	
-	NDBGL4(L4_RBCHDBG, "unit %d, write", unit);	
-
-	CRIT_BEG;
-	if(!(sc->sc_devstate & ST_ISOPEN))
-	{
-		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)) {
-			CRIT_END;
-			return(EWOULDBLOCK);
-		}
-		if(_IF_QFULL(isdn_linktab[unit]->tx_queue) && (sc->sc_devstate & ST_ISOPEN)) {
-			CRIT_END;
-			return(EWOULDBLOCK);
-	}
-	}
-	else
-	{
-		while(!(sc->sc_devstate & ST_CONNECTED))
-		{
-			NDBGL4(L4_RBCHDBG, "unit %d, write wait init", unit);
-		
-			error = tsleep( &rbch_softc[unit],
-						   I4BPRI | PCATCH,
-						   "wrrbch", 0 );
-			if(error == ERESTART) {
-				CRIT_END;
-				return (ERESTART);
-			}
-			else if(error == EINTR)
-			{
-				CRIT_END;
-				NDBGL4(L4_RBCHDBG, "unit %d, EINTR during wait init", unit);
-				return(EINTR);
-			}
-			else if(error)
-			{
-				CRIT_END;
-				NDBGL4(L4_RBCHDBG, "unit %d, error %d tsleep init", unit, error);
-				return(error);
-			}
-			tsleep( &rbch_softc[unit], I4BPRI | PCATCH, "xrbch", (hz*1));
-		}
-
-		while(_IF_QFULL(isdn_linktab[unit]->tx_queue) && (sc->sc_devstate & ST_ISOPEN))
-		{
-			sc->sc_devstate |= ST_WRWAITEMPTY;
-
-			NDBGL4(L4_RBCHDBG, "unit %d, write queue full", unit);
-		
-			if ((error = tsleep( &isdn_linktab[unit]->tx_queue,
-					    I4BPRI | PCATCH,
-					    "wrbch", 0)) != 0) {
-				sc->sc_devstate &= ~ST_WRWAITEMPTY;
-				if(error == ERESTART)
-				{
-					CRIT_END;
-					return(ERESTART);
-				}
-				else if(error == EINTR)
-				{
-					CRIT_END;
-					NDBGL4(L4_RBCHDBG, "unit %d, EINTR during wait write", unit);
-					return(error);
-				}
-				else if(error)
-				{
-					CRIT_END;
-					NDBGL4(L4_RBCHDBG, "unit %d, error %d tsleep write", unit, error);
-					return(error);
-				}
-			}
-		}
-	}
-
-	if(!(sc->sc_devstate & ST_ISOPEN))
-	{
-		NDBGL4(L4_RBCHDBG, "unit %d, not open anymore", unit);
-		CRIT_END;
-		return(EIO);
-	}
-
-	if((m = i4b_Bgetmbuf(BCH_MAX_DATALEN)) != NULL)
-	{
-		m->m_len = min(BCH_MAX_DATALEN, uio->uio_resid);
-
-		NDBGL4(L4_RBCHDBG, "unit %d, write %d bytes", unit, m->m_len);
-		
-		error = uiomove(m->m_data, m->m_len, uio);
-
-		(void) IF_HANDOFF(isdn_linktab[unit]->tx_queue, m, NULL);
-
-		(*isdn_linktab[unit]->bch_tx_start)(isdn_linktab[unit]->unit, isdn_linktab[unit]->channel);
-	}
-
-	CRIT_END;
-	
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	rbch device ioctl handlibg
- *---------------------------------------------------------------------------*/
-static int
-i4brbchioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
-{
-	int error = 0;
-	int unit = minor(dev);
-	struct rbch_softc *sc = &rbch_softc[unit];
-	
-	switch(cmd)
-	{
-		case FIOASYNC:	/* Set async mode */
-			if (*(int *)data)
-			{
-				NDBGL4(L4_RBCHDBG, "unit %d, setting async mode", unit);
-			}
-			else
-			{
-				NDBGL4(L4_RBCHDBG, "unit %d, clearing async mode", unit);
-			}
-			break;
-
-		case FIONBIO:
-			if (*(int *)data)
-			{
-				NDBGL4(L4_RBCHDBG, "unit %d, setting non-blocking mode", unit);
-				sc->sc_devstate |= ST_NOBLOCK;
-			}
-			else
-			{
-				NDBGL4(L4_RBCHDBG, "unit %d, clearing non-blocking mode", unit);
-				sc->sc_devstate &= ~ST_NOBLOCK;
-			}
-			break;
-
-		case TIOCCDTR:	/* Clear DTR */
-			if(sc->sc_devstate & ST_CONNECTED)
-			{
-				NDBGL4(L4_RBCHDBG, "unit %d, disconnecting for DTR down", unit);
-				i4b_l4_drvrdisc(BDRV_RBCH, unit);
-			}
-			break;
-
-		case I4B_RBCH_DIALOUT:
-                {
-			size_t l;
-
-			for (l = 0; l < TELNO_MAX && ((char *)data)[l]; l++)
-				;
-			if (l)
-			{
-				NDBGL4(L4_RBCHDBG, "unit %d, attempting dialout to %s", unit, (char *)data);
-				i4b_l4_dialoutnumber(BDRV_RBCH, unit, l, (char *)data);
-				break;
-			}
-			/* FALLTHROUGH to SDTR */
-		}
-
-		case TIOCSDTR:	/* Set DTR */
-			NDBGL4(L4_RBCHDBG, "unit %d, attempting dialout (DTR)", unit);
-			i4b_l4_dialout(BDRV_RBCH, unit);
-			break;
-
-		case TIOCSETA:	/* Set termios struct */
-			break;
-
-		case TIOCGETA:	/* Get termios struct */
-			*(struct termios *)data = sc->it_in;
-			break;
-
-		case TIOCMGET:
-			*(int *)data = TIOCM_LE|TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR;
-			if (sc->sc_devstate & ST_CONNECTED)
-				*(int *)data |= TIOCM_CD;
-			break;
-
-		case I4B_RBCH_VR_REQ:
-                {
-			msg_vr_req_t *mvr;
-
-			mvr = (msg_vr_req_t *)data;
-
-			mvr->version = VERSION;
-			mvr->release = REL;
-			mvr->step = STEP;			
-			break;
-		}
-
-		default:	/* Unknown stuff */
-			NDBGL4(L4_RBCHDBG, "unit %d, ioctl, unknown cmd %lx", unit, (u_long)cmd);
-			error = EINVAL;
-			break;
-	}
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	device driver poll
- *---------------------------------------------------------------------------*/
-static int
-i4brbchpoll(struct cdev *dev, int events, struct thread *td)
-{
-	int revents = 0;	/* Events we found */
-	int s;
-	int unit = minor(dev);
-	struct rbch_softc *sc = &rbch_softc[unit];
-	
-	/* We can't check for anything but IN or OUT */
-
-	s = splhigh();
-
-	if(!(sc->sc_devstate & ST_ISOPEN))
-	{
-		splx(s);
-		return(POLLNVAL);
-	}
-
-	/*
-	 * Writes are OK if we are connected and the
-         * transmit queue can take them
-	 */
-	 
-	if((events & (POLLOUT|POLLWRNORM)) &&
-	   (sc->sc_devstate & ST_CONNECTED) &&
-	   !_IF_QFULL(isdn_linktab[unit]->tx_queue))
-	{
-		revents |= (events & (POLLOUT|POLLWRNORM));
-	}
-	
-	/* ... while reads are OK if we have any data */
-
-	if((events & (POLLIN|POLLRDNORM)) &&
-	   (sc->sc_devstate & ST_CONNECTED))
-	{
-		struct ifqueue *iqp;
-
-		if(sc->sc_bprot == BPROT_RHDLC)
-			iqp = &sc->sc_hdlcq;
-		else
-			iqp = isdn_linktab[unit]->rx_queue;	
-
-		if(!IF_QEMPTY(iqp))
-			revents |= (events & (POLLIN|POLLRDNORM));
-	}
-		
-	if(revents == 0)
-		selrecord(td, &sc->selp);
-
-	splx(s);
-	return(revents);
-}
-
-#if I4BRBCHACCT
-/*---------------------------------------------------------------------------*
- *	watchdog routine
- *---------------------------------------------------------------------------*/
-static void
-rbch_timeout(struct rbch_softc *sc)
-{
-	bchan_statistics_t bs;
-	int unit = sc->sc_unit;
-
-	/* get # of bytes in and out from the HSCX driver */ 
-	
-	(*isdn_linktab[unit]->bch_stat)
-		(isdn_linktab[unit]->unit, isdn_linktab[unit]->channel, &bs);
-
-	sc->sc_ioutb += bs.outbytes;
-	sc->sc_iinb += bs.inbytes;
-	
-	if((sc->sc_iinb != sc->sc_linb) || (sc->sc_ioutb != sc->sc_loutb) || sc->sc_fn) 
-	{
-		int ri = (sc->sc_iinb - sc->sc_linb)/I4BRBCHACCTINTVL;
-		int ro = (sc->sc_ioutb - sc->sc_loutb)/I4BRBCHACCTINTVL;
-
-		if((sc->sc_iinb == sc->sc_linb) && (sc->sc_ioutb == sc->sc_loutb))
-			sc->sc_fn = 0;
-		else
-			sc->sc_fn = 1;
-			
-		sc->sc_linb = sc->sc_iinb;
-		sc->sc_loutb = sc->sc_ioutb;
-
-		i4b_l4_accounting(BDRV_RBCH, unit, ACCT_DURING,
-			 sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_ioutb, sc->sc_iinb);
- 	}
-	START_TIMER(sc->sc_callout, rbch_timeout, sc, I4BRBCHACCTINTVL*hz);
-}
-#endif /* I4BRBCHACCT */
-
-/*===========================================================================*
- *			ISDN INTERFACE ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from L4 handler at connect time
- *---------------------------------------------------------------------------*/
-static void
-rbch_connect(int unit, void *cdp)
-{
-	call_desc_t *cd = (call_desc_t *)cdp;
-	struct rbch_softc *sc = &rbch_softc[unit];
-
-	sc->sc_bprot = cd->bprot;
-
-#if I4BRBCHACCT
-	if(sc->sc_bprot == BPROT_RHDLC)
-	{	
-		sc->sc_iinb = 0;
-		sc->sc_ioutb = 0;
-		sc->sc_linb = 0;
-		sc->sc_loutb = 0;
-
-		START_TIMER(sc->sc_callout, rbch_timeout, sc, I4BRBCHACCTINTVL*hz);
-	}
-#endif		
-	if(!(sc->sc_devstate & ST_CONNECTED))
-	{
-		NDBGL4(L4_RBCHDBG, "unit %d, wakeup", unit);
-		sc->sc_devstate |= ST_CONNECTED;
-		sc->sc_cd = cdp;
-		wakeup(sc);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from L4 handler at disconnect time
- *---------------------------------------------------------------------------*/
-static void
-rbch_disconnect(int unit, void *cdp)
-{
-	call_desc_t *cd = (call_desc_t *)cdp;
-	struct rbch_softc *sc = &rbch_softc[unit];
-
-	CRIT_VAR;
-	
-        if(cd != sc->sc_cd)
-	{
-		NDBGL4(L4_RBCHDBG, "rbch%d: channel %d not active",
-			cd->driver_unit, cd->channelid);
-		return;
-	}
-
-	CRIT_BEG;
-	
-	NDBGL4(L4_RBCHDBG, "unit %d, disconnect", unit);
-
-	sc->sc_devstate &= ~ST_CONNECTED;
-
-	sc->sc_cd = NULL;
-	
-#if I4BRBCHACCT
-	i4b_l4_accounting(BDRV_RBCH, unit, ACCT_FINAL,
-		 sc->sc_ioutb, sc->sc_iinb, 0, 0, sc->sc_ioutb, sc->sc_iinb);
-
-	STOP_TIMER(sc->sc_callout, rbch_timeout, sc);
-#endif		
-	CRIT_END;
-}
-	
-/*---------------------------------------------------------------------------*
- *	feedback from daemon in case of dial problems
- *---------------------------------------------------------------------------*/
-static void
-rbch_dialresponse(int unit, int status, cause_t cause)
-{
-}
-	
-/*---------------------------------------------------------------------------*
- *	interface up/down
- *---------------------------------------------------------------------------*/
-static void
-rbch_updown(int unit, int updown)
-{
-}
-	
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when a new frame (mbuf) has been received and is to be put on
- *	the rx queue.
- *---------------------------------------------------------------------------*/
-static void
-rbch_rx_data_rdy(int unit)
-{
-	if(rbch_softc[unit].sc_bprot == BPROT_RHDLC)
-	{
-		register struct mbuf *m;
-		
-		if((m = *isdn_linktab[unit]->rx_mbuf) == NULL)
-			return;
-
-		m->m_pkthdr.len = m->m_len;
-
-		if (! IF_HANDOFF(&(rbch_softc[unit].sc_hdlcq), m, NULL))
-		{
-			NDBGL4(L4_RBCHDBG, "unit %d: hdlc rx queue full!", unit);
-		}
-	}
-
-	if(rbch_softc[unit].sc_devstate & ST_RDWAITDATA)
-	{
-		NDBGL4(L4_RBCHDBG, "unit %d, wakeup", unit);
-		rbch_softc[unit].sc_devstate &= ~ST_RDWAITDATA;
-		wakeup( &isdn_linktab[unit]->rx_queue);
-	}
-	else
-	{
-		NDBGL4(L4_RBCHDBG, "unit %d, NO wakeup", unit);
-	}
-	selwakeuppri(&rbch_softc[unit].selp, I4BPRI);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when the last frame has been sent out and there is no
- *	further frame (mbuf) in the tx queue.
- *---------------------------------------------------------------------------*/
-static void
-rbch_tx_queue_empty(int unit)
-{
-	if(rbch_softc[unit].sc_devstate & ST_WRWAITEMPTY)
-	{
-		NDBGL4(L4_RBCHDBG, "unit %d, wakeup", unit);
-		rbch_softc[unit].sc_devstate &= ~ST_WRWAITEMPTY;
-		wakeup( &isdn_linktab[unit]->tx_queue);
-	}
-	else
-	{
-		NDBGL4(L4_RBCHDBG, "unit %d, NO wakeup", unit);
-	}
-	selwakeuppri(&rbch_softc[unit].selp, TTOPRI);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	each time a packet is received or transmitted
- *---------------------------------------------------------------------------*/
-static void
-rbch_activity(int unit, int rxtx)
-{
-	if (rbch_softc[unit].sc_cd)
-		rbch_softc[unit].sc_cd->last_active_time = SECOND;
-	selwakeuppri(&rbch_softc[unit].selp, I4BPRI);
-}
-
-/*---------------------------------------------------------------------------*
- *	clear an hdlc rx queue for a rbch unit
- *---------------------------------------------------------------------------*/
-static void
-rbch_clrq(int unit)
-{
-	CRIT_VAR;
-
-	CRIT_BEG;
-	IF_DRAIN(&rbch_softc[unit].sc_hdlcq);
-	CRIT_END;
-}
-				
-/*---------------------------------------------------------------------------*
- *	return this drivers linktab address
- *---------------------------------------------------------------------------*/
-drvr_link_t *
-rbch_ret_linktab(int unit)
-{
-	rbch_init_linktab(unit);
-	return(&rbch_drvr_linktab[unit]);
-}
-
-/*---------------------------------------------------------------------------*
- *	setup the isdn_linktab for this driver
- *---------------------------------------------------------------------------*/
-void
-rbch_set_linktab(int unit, isdn_link_t *ilt)
-{
-	isdn_linktab[unit] = ilt;
-}
-
-/*---------------------------------------------------------------------------*
- *	initialize this drivers linktab
- *---------------------------------------------------------------------------*/
-static void
-rbch_init_linktab(int unit)
-{
-	rbch_drvr_linktab[unit].unit = unit;
-	rbch_drvr_linktab[unit].bch_rx_data_ready = rbch_rx_data_rdy;
-	rbch_drvr_linktab[unit].bch_tx_queue_empty = rbch_tx_queue_empty;
-	rbch_drvr_linktab[unit].bch_activity = rbch_activity;	
-	rbch_drvr_linktab[unit].line_connected = rbch_connect;
-	rbch_drvr_linktab[unit].line_disconnected = rbch_disconnect;
-	rbch_drvr_linktab[unit].dial_response = rbch_dialresponse;
-	rbch_drvr_linktab[unit].updown_ind = rbch_updown;	
-}
-
-/*===========================================================================*/
--- sys/i4b/driver/i4b_trace.c
+++ /dev/null
@@ -1,430 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4btrc - device driver for trace data read device
- *	---------------------------------------------------
- *	last edit-date: [Sun Mar 17 09:52:51 2002]
- *
- *	NOTE: the code assumes that SPLI4B >= splimp !
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/driver/i4b_trace.c,v 1.32 2005/01/06 22:18:18 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/ioccom.h>
-#include <sys/conf.h>
-#include <sys/uio.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <sys/tty.h>
-
-#include <machine/i4b_trace.h>
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-static struct ifqueue trace_queue[NI4BTRC];
-
-static int device_state[NI4BTRC];
-#define ST_IDLE		0x00
-#define ST_ISOPEN	0x01
-#define ST_WAITDATA	0x02
-
-static int analyzemode = 0;
-static int rxunit = -1;
-static int txunit = -1;
-static int outunit = -1;
-
-static d_open_t	i4btrcopen;
-static d_close_t i4btrcclose;
-static d_read_t i4btrcread;
-static d_ioctl_t i4btrcioctl;
-static d_poll_t i4btrcpoll;
-
-
-static struct cdevsw i4btrc_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
-	.d_open =	i4btrcopen,
-	.d_close =	i4btrcclose,
-	.d_read =	i4btrcread,
-	.d_ioctl =	i4btrcioctl,
-	.d_poll =	i4btrcpoll,
-	.d_name =	"i4btrc",
-};
-
-static void i4btrcattach(void *);
-PSEUDO_SET(i4btrcattach, i4b_trace);
-
-int get_trace_data_from_l1(i4b_trace_hdr_t *hdr, int len, char *buf);
-
-/*---------------------------------------------------------------------------*
- *	interface attach routine
- *---------------------------------------------------------------------------*/
-static void
-i4btrcattach(void *dummy)
-{
-	int i;
-
-	printf("i4btrc: %d ISDN trace device(s) attached\n", NI4BTRC);
-	
-	for(i=0; i < NI4BTRC; i++)
-	{
-		make_dev(&i4btrc_cdevsw, i,
-				     UID_ROOT, GID_WHEEL, 0600, "i4btrc%d", i);
-		trace_queue[i].ifq_maxlen = IFQ_MAXLEN;
-
-		if(!mtx_initialized(&trace_queue[i].ifq_mtx))
-			mtx_init(&trace_queue[i].ifq_mtx, "i4b_trace", NULL, MTX_DEF);
-
-		device_state[i] = ST_IDLE;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	get_trace_data_from_l1()
- *	------------------------
- *	is called from layer 1, adds timestamp to trace data and puts
- *	it into a queue, from which it can be read from the i4btrc
- *	device. The unit number in the trace header selects the minor
- *	device's queue the data is put into.
- *---------------------------------------------------------------------------*/
-int
-get_trace_data_from_l1(i4b_trace_hdr_t *hdr, int len, char *buf)
-{
-	struct mbuf *m;
-	int x;
-	int unit;
-	int trunc = 0;
-	int totlen = len + sizeof(i4b_trace_hdr_t);
-
-	/*
-	 * for telephony (or better non-HDLC HSCX mode) we get 
-	 * (MCLBYTE + sizeof(i4b_trace_hdr_t)) length packets
-	 * to put into the queue to userland. because of this
-	 * we detect this situation, strip the length to MCLBYTES
-	 * max size, and infor the userland program of this fact
-	 * by putting the no of truncated bytes into hdr->trunc.
-	 */
-	 
-	if(totlen > MCLBYTES)
-	{
-		trunc = 1;
-		hdr->trunc = totlen - MCLBYTES;
-		totlen = MCLBYTES;
-	}
-	else
-	{
-		hdr->trunc = 0;
-	}
-
-	/* set length of trace record */
-	
-	hdr->length = totlen;
-	
-	/* check valid unit no */
-	
-	if((unit = hdr->unit) >= NI4BTRC)
-	{
-		printf("i4b_trace: get_trace_data_from_l1 - unit > NI4BTRC!\n"); 
-		return(0);
-	}
-
-	/* get mbuf */
-	
-	if(!(m = i4b_Bgetmbuf(totlen)))
-	{
-		printf("i4b_trace: get_trace_data_from_l1 - i4b_getmbuf() failed!\n");
-		return(0);
-	}
-
-	/* check if we are in analyzemode */
-	
-	if(analyzemode && (unit == rxunit || unit == txunit))
-	{
-		if(unit == rxunit)
-			hdr->dir = FROM_NT;
-		else
-			hdr->dir = FROM_TE;
-		unit = outunit;			
-	}
-
-	IF_LOCK(&trace_queue[unit]);
-
-	if(_IF_QFULL(&trace_queue[unit]))
-	{
-		struct mbuf *m1;
-
-		x = SPLI4B();
-		_IF_DEQUEUE(&trace_queue[unit], m1);
-		splx(x);		
-
-		i4b_Bfreembuf(m1);
-	}
-	
-	/* copy trace header */
-	memcpy(m->m_data, hdr, sizeof(i4b_trace_hdr_t));
-
-	/* copy trace data */
-	if(trunc)
-		memcpy(&m->m_data[sizeof(i4b_trace_hdr_t)], buf, totlen-sizeof(i4b_trace_hdr_t));
-	else
-		memcpy(&m->m_data[sizeof(i4b_trace_hdr_t)], buf, len);
-
-	x = SPLI4B();
-	
-	_IF_ENQUEUE(&trace_queue[unit], m);
-	IF_UNLOCK(&trace_queue[unit]);
-	
-	if(device_state[unit] & ST_WAITDATA)
-	{
-		device_state[unit] &= ~ST_WAITDATA;
-		wakeup( &trace_queue[unit]);
-	}
-
-	splx(x);
-	
-	return(1);
-}
-
-/*---------------------------------------------------------------------------*
- *	open trace device
- *---------------------------------------------------------------------------*/
-static int
-i4btrcopen(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	int x;
-	int unit = minor(dev);
-
-	if(unit >= NI4BTRC)
-		return(ENXIO);
-
-	if(device_state[unit] & ST_ISOPEN)
-		return(EBUSY);
-
-	if(analyzemode && (unit == outunit || unit == rxunit || unit == txunit))
-		return(EBUSY);
-
-	x = SPLI4B();
-	
-	device_state[unit] = ST_ISOPEN;		
-
-	splx(x);
-	
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	close trace device
- *---------------------------------------------------------------------------*/
-static int
-i4btrcclose(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	int unit = minor(dev);
-	int i, x;
-	int cno = -1;
-
-	for(i=0; i < nctrl; i++)
-	{
-		if((ctrl_desc[i].ctrl_type == CTRL_PASSIVE) &&
-			(ctrl_desc[i].unit == unit))
-		{
-			cno = i;
-			break;
-		}
-	}
-
-	if(analyzemode && (unit == outunit))
-	{
-		analyzemode = 0;		
-		outunit = -1;
-		
-		if(cno >= 0)
-		{
-			(*ctrl_desc[cno].N_MGMT_COMMAND)(rxunit, CMR_SETTRACE, TRACE_OFF);
-			(*ctrl_desc[cno].N_MGMT_COMMAND)(txunit, CMR_SETTRACE, TRACE_OFF);
-		}
-		rxunit = -1;
-		txunit = -1;
-	}
-	
-	if(cno >= 0)
-	{
-			(*ctrl_desc[cno].N_MGMT_COMMAND)(ctrl_desc[cno].unit, CMR_SETTRACE, TRACE_OFF);
-	}
-
-	x = SPLI4B();
-	device_state[unit] = ST_IDLE;
-	splx(x);
-	
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	read from trace device
- *---------------------------------------------------------------------------*/
-static int
-i4btrcread(struct cdev *dev, struct uio * uio, int ioflag)
-{
-	struct mbuf *m;
-	int x;
-	int error = 0;
-	int unit = minor(dev);
-	
-	if(!(device_state[unit] & ST_ISOPEN))
-		return(EIO);
-
-	x = SPLI4B();
-	
-	IF_LOCK(&trace_queue[unit]);
-
-	while(IF_QEMPTY(&trace_queue[unit]) && (device_state[unit] & ST_ISOPEN))
-	{
-		device_state[unit] |= ST_WAITDATA;
-		
-		if((error = msleep( &trace_queue[unit],
-					&trace_queue[unit].ifq_mtx,
-					I4BPRI | PCATCH,
-					"bitrc", 0 )) != 0)
-		{
-			device_state[unit] &= ~ST_WAITDATA;
-			IF_UNLOCK(&trace_queue[unit]);
-			splx(x);
-			return(error);
-		}
-	}
-
-	_IF_DEQUEUE(&trace_queue[unit], m);
-	IF_UNLOCK(&trace_queue[unit]);
-
-	if(m && m->m_len)
-		error = uiomove(m->m_data, m->m_len, uio);
-	else
-		error = EIO;
-		
-	if(m)
-		i4b_Bfreembuf(m);
-
-	splx(x);
-	
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	poll device
- *---------------------------------------------------------------------------*/
-static int
-i4btrcpoll(struct cdev *dev, int events, struct thread *td)
-{
-	return(ENODEV);
-}
-
-/*---------------------------------------------------------------------------*
- *	device driver ioctl routine
- *---------------------------------------------------------------------------*/
-static int
-i4btrcioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
-{
-	int error = 0;
-	int unit = minor(dev);
-	i4b_trace_setupa_t *tsa;
-	int i;
-	int cno = -1;
-
-	/* find the first passive controller matching our unit no */
-
-	for(i=0; i < nctrl; i++)
-	{
-		if((ctrl_desc[i].ctrl_type == CTRL_PASSIVE) &&
-			(ctrl_desc[i].unit == unit))
-		{
-			cno = i;
-			break;
-		}
-	}
-	
-	switch(cmd)
-	{
-		case I4B_TRC_SET:
-			if(cno < 0)
-				return ENOTTY;
-			(*ctrl_desc[cno].N_MGMT_COMMAND)(ctrl_desc[cno].unit, CMR_SETTRACE, (void *)*(unsigned int *)data);
-			break;
-
-		case I4B_TRC_SETA:
-			tsa = (i4b_trace_setupa_t *)data;
-
-			if(tsa->rxunit >= 0 && tsa->rxunit < NI4BTRC)
-				rxunit = tsa->rxunit;
-			else
-				error = EINVAL;
-
-			if(tsa->txunit >= 0 && tsa->txunit < NI4BTRC)
-				txunit = tsa->txunit;
-			else
-				error = EINVAL;
-
-			if(error)
-			{
-				outunit = -1;
-				rxunit = -1;
-				txunit = -1;
-			}
-			else
-			{
-				if(cno < 0)
-					return ENOTTY;
-					
-				outunit = unit;
-				analyzemode = 1;
-				(*ctrl_desc[cno].N_MGMT_COMMAND)(rxunit, CMR_SETTRACE, (int *)(tsa->rxflags & (TRACE_I | TRACE_D_RX | TRACE_B_RX)));
-				(*ctrl_desc[cno].N_MGMT_COMMAND)(txunit, CMR_SETTRACE, (int *)(tsa->txflags & (TRACE_I | TRACE_D_RX | TRACE_B_RX)));
-			}
-			break;
-
-		case I4B_TRC_RESETA:
-			analyzemode = 0;		
-			outunit = -1;
-			rxunit = -1;
-			txunit = -1;
-			break;
-			
-		default:
-			error = ENOTTY;
-			break;
-	}
-	return(error);
-}
--- sys/i4b/driver/i4b_tel.c
+++ /dev/null
@@ -1,1664 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_tel.c - device driver for ISDN telephony
- *	--------------------------------------------
- *	last edit-date: [Tue Aug 27 13:54:08 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/driver/i4b_tel.c,v 1.36 2005/01/06 22:18:18 imp Exp $");
-
-#include "opt_i4b.h"
-
-#undef I4BTELDEBUG
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/ioccom.h>
-#include <sys/poll.h>
-#include <sys/conf.h>
-#include <sys/uio.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <sys/tty.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_tel_ioctl.h>
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-/* minor number: lower 6 bits = unit number */
-#define UNITBITS	6
-#define UNITMASK	0x3f
-#define	UNIT(n)		(minor(n) & UNITMASK)
-
-/* minor number: upper 2 bits = function number */
-
-#define FUNCMASK	0x03
-#define	FUNC(n)		(((minor(n)) >> UNITBITS) & FUNCMASK)
-
-#define FUNCTEL		0	/* 0 = normal i4btel device	*/
-#define FUNCDIAL	1	/* 1 = i4bteld dialout device	*/
-
-#define NOFUNCS		2	/* number of device classes	*/
-
-typedef struct {
-
-	/* used only in func = FUNCTEL */
-
-	drvr_link_t		drvr_linktab;	/* driver linktab */
-	isdn_link_t 		*isdn_linktab;	/* isdn linktab	*/
-	int 			audiofmt;	/* audio format conversion */
-	u_char			*rcvttab;	/* conversion table on read */
-	u_char			*wcvttab;	/* conversion table on write */
-	call_desc_t		*cdp;		/* call descriptor pointer */
-
-	/* used only in func = FUNCDIAL */
-
-	char			result;		/* result code for dial dev */	
-
-	/* used in func = FUNCDIAL and func = FUNCTEL*/
-	
-	int 			devstate;	/* state of this unit	*/
-#define ST_IDLE		0x00		/* idle */
-#define ST_CONNECTED	0x01		/* isdn connected state */
-#define ST_ISOPEN	0x02		/* userland opened */
-#define ST_RDWAITDATA	0x04		/* userland read waiting */
-#define ST_WRWAITEMPTY	0x08		/* userland write waiting */
-#define ST_TONE		0x10		/* tone generator */
-
-	struct selinfo		selp;		/* select / poll */
-
-	struct i4b_tel_tones	tones;
-	int			toneidx;
-	int			toneomega;
-	int			tonefreq;
-
-} tel_sc_t;
-
-static tel_sc_t tel_sc[NI4BTEL][NOFUNCS];
-	
-/* forward decl */
-
-static void tel_rx_data_rdy(int unit);
-static void tel_tx_queue_empty(int unit);
-static void tel_init_linktab(int unit);
-static void tel_connect(int unit, void *cdp);
-static void tel_disconnect(int unit, void *cdp);
-static void tel_tone(tel_sc_t *sc);
-
-/* audio format conversion tables */
-static unsigned char a2u_tab[];
-static unsigned char u2a_tab[];
-static unsigned char bitreverse[];
-static u_char sinetab[];
-
-static d_open_t i4btelopen;
-static d_close_t i4btelclose;
-static d_read_t i4btelread;
-static d_read_t i4btelwrite;
-static d_ioctl_t i4btelioctl;
-static d_poll_t i4btelpoll;
-
-
-static struct cdevsw i4btel_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
-	.d_open =	i4btelopen,
-	.d_close =	i4btelclose,
-	.d_read =	i4btelread,
-	.d_write =	i4btelwrite,
-	.d_ioctl =	i4btelioctl,
-	.d_poll =	i4btelpoll,
-	.d_name =	"i4btel",
-};
-
-static void i4btelattach(void *);
-
-PSEUDO_SET(i4btelattach, i4b_tel);
-
-/*===========================================================================*
- *			DEVICE DRIVER ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	interface attach routine
- *---------------------------------------------------------------------------*/
-static void
-i4btelattach(void *dummy)
-{
-	int i, j;
-
-	printf("i4btel: %d ISDN telephony interface device(s) attached\n", NI4BTEL);
-	
-	for(i=0; i < NI4BTEL; i++)
-	{
-		for(j=0; j < NOFUNCS; j++)
-		{
-			tel_sc[i][j].devstate = ST_IDLE;
-			tel_sc[i][j].audiofmt = CVT_NONE;
-			tel_sc[i][j].rcvttab = 0;
-			tel_sc[i][j].wcvttab = 0;
-			tel_sc[i][j].result = 0;
-
-			switch(j)
-			{
-				case FUNCTEL:	/* normal i4btel device */
-				  	make_dev(&i4btel_cdevsw, i,
-						UID_ROOT, GID_WHEEL,
-						0600, "i4btel%d", i);
-					break;
-				
-				case FUNCDIAL:	/* i4bteld dialout device */
-				  	make_dev(&i4btel_cdevsw, i+(1<<UNITBITS),
-						UID_ROOT, GID_WHEEL,
-						0600, "i4bteld%d", i);
-					break;
-			}
-		}
-		tel_init_linktab(i);		
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	open tel device
- *---------------------------------------------------------------------------*/
-static int
-i4btelopen(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	int unit = UNIT(dev);
-	int func = FUNC(dev);
-	
-	tel_sc_t *sc;
-	
-	if(unit >= NI4BTEL)
-		return(ENXIO);
-
-	sc = &tel_sc[unit][func];		
-
-	if(sc->devstate & ST_ISOPEN)
-		return(EBUSY);
-
-	sc->devstate |= ST_ISOPEN;		
-
-	if(func == FUNCDIAL)
-	{
-		sc->result = 0;
-	}
-	
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	close tel device
- *---------------------------------------------------------------------------*/
-static int
-i4btelclose(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	int unit = UNIT(dev);
-	int func = FUNC(dev);
-	tel_sc_t *sc;
-	int error = 0;
-	int x;
-	
-	if(unit > NI4BTEL)
-		return(ENXIO);
-
-	sc = &tel_sc[unit][func];		
-
-	x = splimp();
-	sc->devstate &= ~ST_TONE;		
-
-	if((func == FUNCTEL) &&
-	   (sc->isdn_linktab != NULL && sc->isdn_linktab->tx_queue != NULL))
-	{
-		while(!(IF_QEMPTY(sc->isdn_linktab->tx_queue)))
-		{
-			sc->devstate |= ST_WRWAITEMPTY;
-	
-			if((error = tsleep( &sc->isdn_linktab->tx_queue,
-					I4BPRI | PCATCH, "wtcl", 0)) != 0)
-			{
-				break;
-			}
-		}
-		sc->devstate &= ~ST_WRWAITEMPTY;		
-	}
-
-	sc->devstate &= ~ST_ISOPEN;		
-	splx(x);
-	wakeup( &sc->tones);
-
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4btelioctl - device driver ioctl routine
- *---------------------------------------------------------------------------*/
-static int
-i4btelioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
-{
-	int unit = UNIT(dev);
-	int func = FUNC(dev);
-	int error = 0;
-        struct mbuf *m;
-        int s;
-
-	tel_sc_t *sc = &tel_sc[unit][func];
-
-	if(func == FUNCTEL)
-	{
-		switch(cmd)
-		{
-			case I4B_TEL_GETAUDIOFMT:
-				*(int *)data = sc->audiofmt;
-				break;
-			
-			case I4B_TEL_SETAUDIOFMT:
-				switch (*(int *)data)
-				{
-					case CVT_NONE:
-						sc->rcvttab = 0;
-						sc->wcvttab = 0;
-						break;
-					case CVT_ALAW2ULAW:
-						/* ISDN: a-law */
-						/* user: u-law */ 
-						sc->rcvttab = a2u_tab;
-						sc->wcvttab = u2a_tab;
-						break;
-					case CVT_ULAW2ALAW:
-						/* ISDN: u-law */
-						/* user: a-law */ 
-						sc->rcvttab = u2a_tab;
-						sc->wcvttab = a2u_tab;
-						break;
-					default:
-						error = ENODEV;
-						break;
-				}
-				if(error == 0)
-					sc->audiofmt = *(int *)data;
-				break;
-	
-			case I4B_TEL_EMPTYINPUTQUEUE:
-				s = splimp();
-				while((sc->devstate & ST_CONNECTED)	&&
-					(sc->devstate & ST_ISOPEN) 	&&
-					!IF_QEMPTY(sc->isdn_linktab->rx_queue))
-				{
-					IF_DEQUEUE(sc->isdn_linktab->rx_queue, m);
-					if(m)
-						i4b_Bfreembuf(m);
-				}
-				splx(s);
-				break;
-
-			case I4B_TEL_VR_REQ:
-                	{
-				msg_vr_req_t *mvr;
-
-				mvr = (msg_vr_req_t *)data;
-
-				mvr->version = VERSION;
-				mvr->release = REL;
-				mvr->step = STEP;			
-				break;
-			}
-			case I4B_TEL_TONES:
-			{
-				struct i4b_tel_tones *tt;
-
-				tt = (struct i4b_tel_tones *)data;
-				s = splimp();
-				while ((sc->devstate & ST_TONE) && 
-				    sc->tones.duration[sc->toneidx] != 0) {
-					if((error = tsleep( &sc->tones,
-					    I4BPRI | PCATCH, "rtone", 0 )) != 0) {
-					    	splx(s);
-						return(error);
-					}
-				} 
-				if(!(sc->devstate & ST_ISOPEN)) {
-					splx(s);
-					return (EIO);
-				}
-				if(!(sc->devstate & ST_CONNECTED)) {
-					splx(s);
-					return (EIO);
-				}
-
-				sc->tones = *tt;
-				sc->toneidx = 0;
-				sc->tonefreq = tt->frequency[0];
-				sc->devstate |= ST_TONE;
-				splx(s);
-				tel_tone(sc);
-				break;
-			}
-	
-			default:
-				error = ENOTTY;
-				break;
-		}
-	}
-	else if(func == FUNCDIAL)
-	{
-		switch(cmd)
-		{
-			default:
-				error = ENOTTY;
-				break;
-		}
-	}		
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	read from tel device
- *---------------------------------------------------------------------------*/
-static int
-i4btelread(struct cdev *dev, struct uio *uio, int ioflag)
-{
-	int unit = UNIT(dev);
-	int func = FUNC(dev);
-
-	struct mbuf *m;
-	int s;
-	int error = 0;
-
-	tel_sc_t *sc = &tel_sc[unit][func];
-	
-	if(!(sc->devstate & ST_ISOPEN))
-		return(EIO);
-
-	if(func == FUNCTEL)
-	{
-		s = splimp();
-		IF_LOCK(sc->isdn_linktab->rx_queue);
-
-		while((sc->devstate & ST_ISOPEN)        &&
-		      (sc->devstate & ST_CONNECTED)	&&
-		      IF_QEMPTY(sc->isdn_linktab->rx_queue))		
-		{
-			sc->devstate |= ST_RDWAITDATA;
-
-			NDBGL4(L4_TELDBG, "i4btel%d, queue empty!", unit);
-
-			if((error = msleep( &sc->isdn_linktab->rx_queue,
-					&sc->isdn_linktab->rx_queue->ifq_mtx,
-					I4BPRI | PCATCH,
-					"rtel", 0 )) != 0)
-			{
-				sc->devstate &= ~ST_RDWAITDATA;
-				IF_UNLOCK(sc->isdn_linktab->rx_queue);
-				splx(s);
-				return(error);
-			}
-		}
-	
-		if(!(sc->devstate & ST_ISOPEN))
-		{
-			IF_UNLOCK(sc->isdn_linktab->rx_queue);
-			splx(s);
-			return(EIO);
-		}
-	
-		if(!(sc->devstate & ST_CONNECTED))
-		{
-			IF_UNLOCK(sc->isdn_linktab->rx_queue);
-			splx(s);
-			return(EIO);
-		}
-		
-	
-		_IF_DEQUEUE(sc->isdn_linktab->rx_queue, m);
-		IF_UNLOCK(sc->isdn_linktab->rx_queue);
-		
-		if(m && m->m_len > 0)
-		{
-			register int i;
-
-		        for(i = 0; i < m->m_len; i++)
-		        {
-		        	/* always reverse bit order from line */
-				mtod(m,u_char *)[i] = bitreverse[mtod(m,u_char *)[i]];
-
-				/* convert if necessary */
-				if(sc->rcvttab)
-	                                mtod(m,u_char *)[i] = sc->rcvttab[mtod(m,u_char *)[i]];
-	                }
-			error = uiomove(m->m_data, m->m_len, uio);
-
-			NDBGL4(L4_TELDBG, "i4btel%d, mbuf (%d bytes), uiomove %d!", unit, m->m_len, error);
-		}
-		else
-		{
-			NDBGL4(L4_TELDBG, "i4btel%d, empty mbuf from queue!", unit);
-			error = EIO;
-		}
-			
-		if(m)
-			i4b_Bfreembuf(m);
-	
-		splx(s);
-	}
-	else if(func == FUNCDIAL)
-	{
-		s = splimp();
-		while((sc->result == 0) && (sc->devstate & ST_ISOPEN))
-		{
-			sc->devstate |= ST_RDWAITDATA;
-	
-			NDBGL4(L4_TELDBG, "i4btel%d, wait for result!", unit);
-			
-			if((error = tsleep( &sc->result,
-						I4BPRI | PCATCH,
-						"rtel1", 0 )) != 0)
-			{
-				sc->devstate &= ~ST_RDWAITDATA;
-				splx(s);
-				NDBGL4(L4_TELDBG, "i4btel%d, wait for result: sleep error!", unit);
-				return(error);
-			}
-		}
-	
-		if(!(sc->devstate & ST_ISOPEN))
-		{
-			splx(s);
-			NDBGL4(L4_TELDBG, "i4btel%d, wait for result: device closed!", unit);
-			return(EIO);
-		}
-	
-		if(sc->result != 0)
-		{
-			NDBGL4(L4_TELDBG, "i4btel%d, wait for result: 0x%02x!", unit, sc->result);
-			error = uiomove(&sc->result, 1, uio);
-			sc->result = 0;
-		}
-		else
-		{
-			NDBGL4(L4_TELDBG, "i4btel%d, wait for result: result=0!", unit);
-			error = EIO;
-		}
-
-		splx(s);			
-	}
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	write to tel device
- *---------------------------------------------------------------------------*/
-static int
-i4btelwrite(struct cdev *dev, struct uio * uio, int ioflag)
-{
-	int unit = UNIT(dev);
-	int func = FUNC(dev);
-	struct mbuf *m;
-	int s;
-	int error = 0;
-	tel_sc_t *sc = &tel_sc[unit][func];
-	
-	if(!(sc->devstate & ST_ISOPEN))
-	{
-		return(EIO);
-	}
-
-	if(func == FUNCTEL)
-	{
-		s = splimp();
-		
-		if(!(sc->devstate & ST_CONNECTED)) {
-			splx(s);
-			return(EIO);
-		}
-			
-		sc->devstate &= ~ST_TONE;		
-		IF_LOCK(sc->isdn_linktab->tx_queue);
-		while((_IF_QFULL(sc->isdn_linktab->tx_queue)) &&
-		      (sc->devstate & ST_ISOPEN))
-		{
-			sc->devstate |= ST_WRWAITEMPTY;
-
-			if((error = msleep( &sc->isdn_linktab->tx_queue,
-					&sc->isdn_linktab->tx_queue->ifq_mtx,
-					I4BPRI | PCATCH, "wtel", 0)) != 0)
-			{
-				sc->devstate &= ~ST_WRWAITEMPTY;
-				IF_UNLOCK(sc->isdn_linktab->tx_queue);
-				splx(s);
-				return(error);
-			}
-		}
-		IF_UNLOCK(sc->isdn_linktab->tx_queue);
-	
-		if(!(sc->devstate & ST_ISOPEN))
-		{
-			splx(s);
-			return(EIO);
-		}
-	
-		if(!(sc->devstate & ST_CONNECTED))
-		{
-			splx(s);
-			return(EIO);
-		}
-
-		if((m = i4b_Bgetmbuf(BCH_MAX_DATALEN)) != NULL)
-		{
-			register int i;
-			
-			m->m_len = min(BCH_MAX_DATALEN, uio->uio_resid);
-	
-			error = uiomove(m->m_data, m->m_len, uio);
-	
-		        for(i = 0; i < m->m_len; i++)
-		        {
-				/* convert if necessary */
-				if(sc->wcvttab)
-					mtod(m,u_char *)[i] = sc->wcvttab[mtod(m,u_char *)[i]];
-
-				/* always reverse bitorder to line */
-				mtod(m,u_char *)[i] = bitreverse[mtod(m,u_char *)[i]];
-			}
-			(void) IF_HANDOFF(sc->isdn_linktab->tx_queue, m, NULL);
-			(*sc->isdn_linktab->bch_tx_start)(sc->isdn_linktab->unit, sc->isdn_linktab->channel);
-		}
-	
-		splx(s);
-	}
-	else if(func == FUNCDIAL)
-	{
-#define CMDBUFSIZ 80 
-		char cmdbuf[CMDBUFSIZ];
-		int len = min(CMDBUFSIZ-1, uio->uio_resid);
-	
-		error = uiomove(cmdbuf, len, uio);
-
-		if(cmdbuf[0] == CMD_DIAL)
-		{
-			i4b_l4_dialoutnumber(BDRV_TEL, unit, len-1, &cmdbuf[1]);
-		}
-		else if(cmdbuf[0] == CMD_HUP)
-		{
-			i4b_l4_drvrdisc(BDRV_TEL, unit);
-		}
-		else if(cmdbuf[0] == CMD_KEYP)
-		{
-			i4b_l4_keypad(BDRV_TEL, unit, len-1, &cmdbuf[1]);
-		}
-	}
-	else
-	{
-		error = EIO;
-	}		
-	
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	
- *---------------------------------------------------------------------------*/
-#define NTONESAMP 32
-static void
-tel_tone(tel_sc_t *sc)
-{
-	struct mbuf *m;
-	u_char *p;
-	int i;
-
-	if((m = i4b_Bgetmbuf(NTONESAMP)) == NULL) {
-		printf("no mbuf in tel_tone\n");
-		return;
-	}
-	p = m->m_data;
-	m->m_len = 0;
-	for (i = 0; i < NTONESAMP && (sc->devstate & ST_TONE); i++) {
-
-		if (sc->tones.duration[sc->toneidx] > 0) {
-			if (--sc->tones.duration[sc->toneidx] == 0) {
-				sc->toneidx++;
-				if (sc->toneidx == I4B_TEL_MAXTONES) {
-					sc->devstate &= ~ST_TONE;
-					sc->toneomega = 0;
-					sc->tonefreq = 0;
-				} else if (sc->tones.frequency[sc->toneidx] == 0 &&
-					   sc->tones.duration[sc->toneidx] == 0) {
-					sc->devstate &= ~ST_TONE;
-					sc->toneomega = 0;
-					sc->tonefreq = 0;
-				} else {
-					sc->tonefreq = sc->tones.frequency[sc->toneidx];
-				}
-				if (sc->tones.duration[sc->toneidx] == 0) {
-					wakeup( &sc->tones);
-				}
-			}
-		}
-
-		sc->toneomega += sc->tonefreq;
-		if (sc->toneomega >= 8000)
-			sc->toneomega -= 8000;
-		*p++ = bitreverse[sinetab[sc->toneomega]];
-		m->m_len++;
-	}
-	IF_ENQUEUE(sc->isdn_linktab->tx_queue, m);
-	(*sc->isdn_linktab->bch_tx_start)(sc->isdn_linktab->unit, sc->isdn_linktab->channel);
-}
-
-/*---------------------------------------------------------------------------*
- *	device driver poll
- *---------------------------------------------------------------------------*/
-static int
-i4btelpoll(struct cdev *dev, int events, struct thread *td)
-{
-	int revents = 0;	/* Events we found */
-	int s;
-	int unit = UNIT(dev);
-	int func = FUNC(dev);	
-
-	tel_sc_t *sc = &tel_sc[unit][func];
-	
-	s = splhigh();
-
-	if(!(sc->devstate & ST_ISOPEN))
-	{
-		NDBGL4(L4_TELDBG, "i4btel%d, !ST_ISOPEN", unit);
-		splx(s);
-		return(0);
-	}
-
-	if(func == FUNCTEL)
-	{
-		/*
-		 * Writes are OK if we are connected and the
-	         * transmit queue can take them
-		 */
-		 
-		if((events & (POLLOUT|POLLWRNORM))	&&
-			(sc->devstate & ST_CONNECTED)	&&
-			(sc->isdn_linktab != NULL)	&&
-			(!_IF_QFULL(sc->isdn_linktab->tx_queue)))
-		{
-			NDBGL4(L4_TELDBG, "i4btel%d, POLLOUT", unit);
-			revents |= (events & (POLLOUT|POLLWRNORM));
-		}
-		
-		/* ... while reads are OK if we have any data */
-	
-		if((events & (POLLIN|POLLRDNORM))	&&
-			(sc->devstate & ST_CONNECTED)	&&
-			(sc->isdn_linktab != NULL)	&&
-			(!IF_QEMPTY(sc->isdn_linktab->rx_queue)))
-		{
-			NDBGL4(L4_TELDBG, "i4btel%d, POLLIN", unit);
-			revents |= (events & (POLLIN|POLLRDNORM));
-		}
-			
-		if(revents == 0)
-		{
-			NDBGL4(L4_TELDBG, "i4btel%d, selrecord", unit);
-			selrecord(td, &sc->selp);
-		}
-	}
-	else if(func == FUNCDIAL)
-	{
-		if(events & (POLLOUT|POLLWRNORM))
-		{
-			NDBGL4(L4_TELDBG, "i4bteld%d,  POLLOUT", unit);
-			revents |= (events & (POLLOUT|POLLWRNORM));
-		}
-
-		if(events & (POLLIN|POLLRDNORM))
-		{
-			NDBGL4(L4_TELDBG, "i4bteld%d,  POLLIN, result = %d", unit, sc->result);
-			if(sc->result != 0)
-				revents |= (events & (POLLIN|POLLRDNORM));
-		}
-			
-		if(revents == 0)
-		{
-			NDBGL4(L4_TELDBG, "i4bteld%d,  selrecord", unit);
-			selrecord(td, &sc->selp);
-		}
-	}
-	splx(s);
-	return(revents);
-}
-
-/*===========================================================================*
- *			ISDN INTERFACE ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
-*	this routine is called from L4 handler at connect time
- *---------------------------------------------------------------------------*/
-static void
-tel_connect(int unit, void *cdp)
-{
-	tel_sc_t *sc = &tel_sc[unit][FUNCTEL];
-
-	/* audio device */
-	
-	sc->cdp = (call_desc_t *)cdp;
-
-	sc->devstate |= ST_CONNECTED;
-
-	/* dialer device */
-	
-	sc = &tel_sc[unit][FUNCDIAL];
-
-	if(sc->devstate & ST_ISOPEN)
-	{
-		NDBGL4(L4_TELDBG, "i4btel%d, tel_connect!", unit);		
-		sc->result = RSP_CONN;
-
-		if(sc->devstate & ST_RDWAITDATA)
-		{
-			sc->devstate &= ~ST_RDWAITDATA;
-			wakeup( &sc->result);
-		}
-		selwakeuppri(&sc->selp, I4BPRI);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from L4 handler at disconnect time
- *---------------------------------------------------------------------------*/
-static void
-tel_disconnect(int unit, void *cdp)
-{
-/*	call_desc_t *cd = (call_desc_t *)cdp; */
-
-	tel_sc_t *sc = &tel_sc[unit][FUNCTEL];
-	
-	/* audio device */
-	
-	sc->devstate &= ~ST_CONNECTED;
-
-	if(sc->devstate & ST_RDWAITDATA)
-	{
-		sc->devstate &= ~ST_RDWAITDATA;
-		wakeup( &sc->isdn_linktab->rx_queue);
-	}
-
-	if(sc->devstate & ST_WRWAITEMPTY)
-	{
-		sc->devstate &= ~ST_WRWAITEMPTY;
-		wakeup( &sc->isdn_linktab->tx_queue);
-	}
-
-	/* dialer device */
-	
-	sc = &tel_sc[unit][FUNCDIAL];
-
-	if(sc->devstate & ST_ISOPEN)
-	{
-		NDBGL4(L4_TELDBG, "i4btel%d, tel_disconnect!", unit);
-		sc->result = RSP_HUP;
-
-		if(sc->devstate & ST_RDWAITDATA)
-		{
-			sc->devstate &= ~ST_RDWAITDATA;
-			wakeup( &sc->result);
-		}
-		selwakeuppri(&sc->selp, I4BPRI);
-
-		if (sc->devstate & ST_TONE) {
-			sc->devstate &= ~ST_TONE;
-			wakeup( &sc->tones);
-		}
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	feedback from daemon in case of dial problems
- *---------------------------------------------------------------------------*/
-static void
-tel_dialresponse(int unit, int status, cause_t cause)
-{	
-	tel_sc_t *sc = &tel_sc[unit][FUNCDIAL];
-
-	NDBGL4(L4_TELDBG, "i4btel%d,  status=%d, cause=0x%4x", unit, status, cause);
-
-	if((sc->devstate == ST_ISOPEN) && status)
-	{
-		NDBGL4(L4_TELDBG, "i4btel%d, tel_dialresponse!", unit);		
-		sc->result = RSP_NOA;
-
-		if(sc->devstate & ST_RDWAITDATA)
-		{
-			sc->devstate &= ~ST_RDWAITDATA;
-			wakeup( &sc->result);
-		}
-		selwakeuppri(&sc->selp, I4BPRI);
-	}
-}
-	
-/*---------------------------------------------------------------------------*
- *	interface up/down
- *---------------------------------------------------------------------------*/
-static void
-tel_updown(int unit, int updown)
-{
-}
-	
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when a new frame (mbuf) has been received and was put on
- *	the rx queue.
- *---------------------------------------------------------------------------*/
-static void
-tel_rx_data_rdy(int unit)
-{
-	tel_sc_t *sc = &tel_sc[unit][FUNCTEL];
-	
-	if(sc->devstate & ST_RDWAITDATA)
-	{
-		sc->devstate &= ~ST_RDWAITDATA;
-		wakeup( &sc->isdn_linktab->rx_queue);
-	}
-	selwakeuppri(&sc->selp, TTOPRI);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when the last frame has been sent out and there is no
- *	further frame (mbuf) in the tx queue.
- *---------------------------------------------------------------------------*/
-static void
-tel_tx_queue_empty(int unit)
-{
-	tel_sc_t *sc = &tel_sc[unit][FUNCTEL];
-
-	if(sc->devstate & ST_WRWAITEMPTY)
-	{
-		sc->devstate &= ~ST_WRWAITEMPTY;
-		wakeup( &sc->isdn_linktab->tx_queue);
-	}
-	if(sc->devstate & ST_TONE) {
-		tel_tone(sc);
-	} else {
-		selwakeuppri(&sc->selp, I4BPRI);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	each time a packet is received or transmitted.
- *---------------------------------------------------------------------------*/
-static void
-tel_activity(int unit, int rxtx)
-{
-	if(tel_sc[unit][FUNCTEL].cdp)
-		tel_sc[unit][FUNCTEL].cdp->last_active_time = SECOND;
-}
-
-/*---------------------------------------------------------------------------*
- *	return this drivers linktab address
- *---------------------------------------------------------------------------*/
-drvr_link_t *
-tel_ret_linktab(int unit)
-{
-	tel_sc_t *sc = &tel_sc[unit][FUNCTEL];
-	
-	tel_init_linktab(unit);
-	return(&sc->drvr_linktab);
-}
-
-/*---------------------------------------------------------------------------*
- *	setup the isdn_linktab for this driver
- *---------------------------------------------------------------------------*/
-void
-tel_set_linktab(int unit, isdn_link_t *ilt)
-{
-	tel_sc_t *sc = &tel_sc[unit][FUNCTEL];
-	sc->isdn_linktab = ilt;
-}
-
-/*---------------------------------------------------------------------------*
- *	initialize this drivers linktab
- *---------------------------------------------------------------------------*/
-static void
-tel_init_linktab(int unit)
-{
-	tel_sc_t *sc = &tel_sc[unit][FUNCTEL];
-	
-	sc->drvr_linktab.unit = unit;
-	sc->drvr_linktab.bch_rx_data_ready = tel_rx_data_rdy;
-	sc->drvr_linktab.bch_tx_queue_empty = tel_tx_queue_empty;
-	sc->drvr_linktab.bch_activity = tel_activity;	
-	sc->drvr_linktab.line_connected = tel_connect;
-	sc->drvr_linktab.line_disconnected = tel_disconnect;
-	sc->drvr_linktab.dial_response = tel_dialresponse;
-	sc->drvr_linktab.updown_ind = tel_updown;	
-}
-
-/*===========================================================================*
- *	AUDIO FORMAT CONVERSION (produced by running g711conv)
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	A-law to u-law conversion
- *---------------------------------------------------------------------------*/
-static unsigned char a2u_tab[256] = {
-/* 00 */	0x2a, 0x2b, 0x28, 0x29, 0x2e, 0x2f, 0x2c, 0x2d, 
-/* 08 */	0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25, 
-/* 10 */	0x39, 0x3a, 0x37, 0x38, 0x3d, 0x3e, 0x3b, 0x3c, 
-/* 18 */	0x31, 0x32, 0x30, 0x30, 0x35, 0x36, 0x33, 0x34, 
-/* 20 */	0x0a, 0x0b, 0x08, 0x09, 0x0e, 0x0f, 0x0c, 0x0d, 
-/* 28 */	0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 
-/* 30 */	0x1a, 0x1b, 0x18, 0x19, 0x1e, 0x1f, 0x1c, 0x1d, 
-/* 38 */	0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 
-/* 40 */	0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 
-/* 48 */	0x5d, 0x5d, 0x5c, 0x5c, 0x5f, 0x5f, 0x5e, 0x5e, 
-/* 50 */	0x74, 0x76, 0x70, 0x72, 0x7c, 0x7e, 0x78, 0x7a, 
-/* 58 */	0x6a, 0x6b, 0x68, 0x69, 0x6e, 0x6f, 0x6c, 0x6d, 
-/* 60 */	0x48, 0x49, 0x46, 0x47, 0x4c, 0x4d, 0x4a, 0x4b, 
-/* 68 */	0x40, 0x41, 0x3f, 0x3f, 0x44, 0x45, 0x42, 0x43, 
-/* 70 */	0x56, 0x57, 0x54, 0x55, 0x5a, 0x5b, 0x58, 0x59, 
-/* 78 */	0x4f, 0x4f, 0x4e, 0x4e, 0x52, 0x53, 0x50, 0x51, 
-/* 80 */	0xaa, 0xab, 0xa8, 0xa9, 0xae, 0xaf, 0xac, 0xad, 
-/* 88 */	0xa2, 0xa3, 0xa0, 0xa1, 0xa6, 0xa7, 0xa4, 0xa5, 
-/* 90 */	0xb9, 0xba, 0xb7, 0xb8, 0xbd, 0xbe, 0xbb, 0xbc, 
-/* 98 */	0xb1, 0xb2, 0xb0, 0xb0, 0xb5, 0xb6, 0xb3, 0xb4, 
-/* a0 */	0x8a, 0x8b, 0x88, 0x89, 0x8e, 0x8f, 0x8c, 0x8d, 
-/* a8 */	0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 
-/* b0 */	0x9a, 0x9b, 0x98, 0x99, 0x9e, 0x9f, 0x9c, 0x9d, 
-/* b8 */	0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 
-/* c0 */	0xe2, 0xe3, 0xe0, 0xe1, 0xe6, 0xe7, 0xe4, 0xe5, 
-/* c8 */	0xdd, 0xdd, 0xdc, 0xdc, 0xdf, 0xdf, 0xde, 0xde, 
-/* d0 */	0xf4, 0xf6, 0xf0, 0xf2, 0xfc, 0xfe, 0xf8, 0xfa, 
-/* d8 */	0xea, 0xeb, 0xe8, 0xe9, 0xee, 0xef, 0xec, 0xed, 
-/* e0 */	0xc8, 0xc9, 0xc6, 0xc7, 0xcc, 0xcd, 0xca, 0xcb, 
-/* e8 */	0xc0, 0xc1, 0xbf, 0xbf, 0xc4, 0xc5, 0xc2, 0xc3, 
-/* f0 */	0xd6, 0xd7, 0xd4, 0xd5, 0xda, 0xdb, 0xd8, 0xd9, 
-/* f8 */	0xcf, 0xcf, 0xce, 0xce, 0xd2, 0xd3, 0xd0, 0xd1
-};
-
-/*---------------------------------------------------------------------------*
- *	u-law to A-law conversion
- *---------------------------------------------------------------------------*/
-static unsigned char u2a_tab[256] = {
-/* 00 */	0x2a, 0x2b, 0x28, 0x29, 0x2e, 0x2f, 0x2c, 0x2d, 
-/* 08 */	0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25, 
-/* 10 */	0x3a, 0x3b, 0x38, 0x39, 0x3e, 0x3f, 0x3c, 0x3d, 
-/* 18 */	0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35, 
-/* 20 */	0x0a, 0x0b, 0x08, 0x09, 0x0e, 0x0f, 0x0c, 0x0d, 
-/* 28 */	0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 
-/* 30 */	0x1b, 0x18, 0x19, 0x1e, 0x1f, 0x1c, 0x1d, 0x12, 
-/* 38 */	0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6a, 
-/* 40 */	0x68, 0x69, 0x6e, 0x6f, 0x6c, 0x6d, 0x62, 0x63, 
-/* 48 */	0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7a, 0x78, 
-/* 50 */	0x7e, 0x7f, 0x7c, 0x7d, 0x72, 0x73, 0x70, 0x71, 
-/* 58 */	0x76, 0x77, 0x74, 0x75, 0x4b, 0x49, 0x4f, 0x4d, 
-/* 60 */	0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45, 
-/* 68 */	0x5a, 0x5b, 0x58, 0x59, 0x5e, 0x5f, 0x5c, 0x5d, 
-/* 70 */	0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51, 
-/* 78 */	0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0x55, 
-/* 80 */	0xaa, 0xab, 0xa8, 0xa9, 0xae, 0xaf, 0xac, 0xad, 
-/* 88 */	0xa2, 0xa3, 0xa0, 0xa1, 0xa6, 0xa7, 0xa4, 0xa5, 
-/* 90 */	0xba, 0xbb, 0xb8, 0xb9, 0xbe, 0xbf, 0xbc, 0xbd, 
-/* 98 */	0xb2, 0xb3, 0xb0, 0xb1, 0xb6, 0xb7, 0xb4, 0xb5, 
-/* a0 */	0x8a, 0x8b, 0x88, 0x89, 0x8e, 0x8f, 0x8c, 0x8d, 
-/* a8 */	0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 
-/* b0 */	0x9b, 0x98, 0x99, 0x9e, 0x9f, 0x9c, 0x9d, 0x92, 
-/* b8 */	0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xea, 
-/* c0 */	0xe8, 0xe9, 0xee, 0xef, 0xec, 0xed, 0xe2, 0xe3, 
-/* c8 */	0xe0, 0xe1, 0xe6, 0xe7, 0xe4, 0xe5, 0xfa, 0xf8, 
-/* d0 */	0xfe, 0xff, 0xfc, 0xfd, 0xf2, 0xf3, 0xf0, 0xf1, 
-/* d8 */	0xf6, 0xf7, 0xf4, 0xf5, 0xcb, 0xc9, 0xcf, 0xcd, 
-/* e0 */	0xc2, 0xc3, 0xc0, 0xc1, 0xc6, 0xc7, 0xc4, 0xc5, 
-/* e8 */	0xda, 0xdb, 0xd8, 0xd9, 0xde, 0xdf, 0xdc, 0xdd, 
-/* f0 */	0xd2, 0xd2, 0xd3, 0xd3, 0xd0, 0xd0, 0xd1, 0xd1, 
-/* f8 */	0xd6, 0xd6, 0xd7, 0xd7, 0xd4, 0xd4, 0xd5, 0xd5
-};
-  
-/*---------------------------------------------------------------------------*
- *	reverse bits in a byte
- *---------------------------------------------------------------------------*/
-static unsigned char bitreverse[256] = {
-/* 00 */	0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 
-/* 08 */	0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 
-/* 10 */	0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 
-/* 18 */	0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 
-/* 20 */	0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 
-/* 28 */	0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 
-/* 30 */	0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 
-/* 38 */	0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 
-/* 40 */	0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 
-/* 48 */	0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 
-/* 50 */	0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 
-/* 58 */	0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 
-/* 60 */	0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 
-/* 68 */	0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 
-/* 70 */	0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 
-/* 78 */	0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 
-/* 80 */	0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 
-/* 88 */	0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 
-/* 90 */	0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 
-/* 98 */	0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 
-/* a0 */	0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 
-/* a8 */	0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 
-/* b0 */	0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 
-/* b8 */	0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 
-/* c0 */	0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 
-/* c8 */	0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 
-/* d0 */	0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 
-/* d8 */	0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 
-/* e0 */	0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 
-/* e8 */	0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 
-/* f0 */	0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 
-/* f8 */	0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
-};
-
-static u_char sinetab[8000] = { 213, 213, 213, 213, 213, 213, 213, 212,
-212, 212, 212, 212, 212, 215, 215, 215, 215, 215, 215, 214, 214,
-214, 214, 214, 214, 209, 209, 209, 209, 209, 209, 209, 208, 208,
-208, 208, 208, 208, 211, 211, 211, 211, 211, 211, 210, 210, 210,
-210, 210, 210, 221, 221, 221, 221, 221, 221, 220, 220, 220, 220,
-220, 220, 220, 223, 223, 223, 223, 223, 223, 222, 222, 222, 222,
-222, 222, 217, 217, 217, 217, 217, 217, 216, 216, 216, 216, 216,
-216, 216, 219, 219, 219, 219, 219, 219, 218, 218, 218, 218, 218,
-218, 197, 197, 197, 197, 197, 197, 196, 196, 196, 196, 196, 196,
-196, 199, 199, 199, 199, 199, 199, 198, 198, 198, 198, 198, 198,
-193, 193, 193, 193, 193, 193, 192, 192, 192, 192, 192, 192, 192,
-195, 195, 195, 195, 195, 195, 194, 194, 194, 194, 194, 194, 205,
-205, 205, 205, 205, 205, 204, 204, 204, 204, 204, 204, 204, 207,
-207, 207, 207, 207, 207, 206, 206, 206, 206, 206, 206, 201, 201,
-201, 201, 201, 201, 200, 200, 200, 200, 200, 200, 200, 203, 203,
-203, 203, 203, 203, 202, 202, 202, 202, 202, 202, 245, 245, 245,
-245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 244, 244, 244,
-244, 244, 244, 244, 244, 244, 244, 244, 244, 247, 247, 247, 247,
-247, 247, 247, 247, 247, 247, 247, 247, 247, 246, 246, 246, 246,
-246, 246, 246, 246, 246, 246, 246, 246, 246, 241, 241, 241, 241,
-241, 241, 241, 241, 241, 241, 241, 241, 240, 240, 240, 240, 240,
-240, 240, 240, 240, 240, 240, 240, 240, 243, 243, 243, 243, 243,
-243, 243, 243, 243, 243, 243, 243, 243, 242, 242, 242, 242, 242,
-242, 242, 242, 242, 242, 242, 242, 242, 253, 253, 253, 253, 253,
-253, 253, 253, 253, 253, 253, 253, 253, 252, 252, 252, 252, 252,
-252, 252, 252, 252, 252, 252, 252, 255, 255, 255, 255, 255, 255,
-255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254,
-254, 254, 254, 254, 254, 254, 254, 249, 249, 249, 249, 249, 249,
-249, 249, 249, 249, 249, 249, 249, 248, 248, 248, 248, 248, 248,
-248, 248, 248, 248, 248, 248, 248, 251, 251, 251, 251, 251, 251,
-251, 251, 251, 251, 251, 251, 251, 250, 250, 250, 250, 250, 250,
-250, 250, 250, 250, 250, 250, 250, 229, 229, 229, 229, 229, 229,
-229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229,
-229, 229, 229, 229, 229, 229, 229, 228, 228, 228, 228, 228, 228,
-228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228,
-228, 228, 228, 228, 228, 228, 228, 228, 231, 231, 231, 231, 231,
-231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
-231, 231, 231, 231, 231, 231, 231, 231, 231, 230, 230, 230, 230,
-230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
-230, 230, 230, 230, 230, 230, 230, 230, 230, 225, 225, 225, 225,
-225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
-225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 224, 224,
-224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224,
-224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 227,
-227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
-227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
-227, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
-226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
-226, 226, 226, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237,
-237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237,
-237, 237, 237, 237, 237, 236, 236, 236, 236, 236, 236, 236, 236,
-236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
-236, 236, 236, 236, 236, 236, 236, 236, 239, 239, 239, 239, 239,
-239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
-239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 238, 238,
-238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238,
-238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238,
-238, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233,
-233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233,
-233, 233, 233, 233, 233, 232, 232, 232, 232, 232, 232, 232, 232,
-232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232,
-232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 235, 235, 235,
-235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235,
-235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235,
-235, 235, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
-234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
-234, 234, 234, 234, 234, 234, 234, 149, 149, 149, 149, 149, 149,
-149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
-149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
-149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
-149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
-149, 149, 149, 149, 149, 149, 149, 148, 148, 148, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
-156, 156, 156, 156, 156, 156, 156, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
-157, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
-146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
-147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144,
-144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
-145, 145, 145, 145, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
-150, 150, 150, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
-151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
-148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
-149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
-149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
-149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
-149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
-149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
-234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
-234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
-234, 234, 234, 234, 234, 235, 235, 235, 235, 235, 235, 235, 235,
-235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235,
-235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 232, 232, 232,
-232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232,
-232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232,
-232, 232, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233,
-233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233,
-233, 233, 233, 233, 233, 233, 238, 238, 238, 238, 238, 238, 238,
-238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238,
-238, 238, 238, 238, 238, 238, 238, 238, 238, 239, 239, 239, 239,
-239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
-239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 236,
-236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
-236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
-236, 236, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237,
-237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237,
-237, 237, 237, 237, 226, 226, 226, 226, 226, 226, 226, 226, 226,
-226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226,
-226, 226, 226, 226, 226, 226, 227, 227, 227, 227, 227, 227, 227,
-227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
-227, 227, 227, 227, 227, 227, 227, 227, 224, 224, 224, 224, 224,
-224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224,
-224, 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, 225, 225,
-225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
-225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 230, 230,
-230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
-230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 231, 231,
-231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
-231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 228,
-228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228,
-228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228,
-229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229,
-229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229,
-250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
-251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
-248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
-249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
-254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
-255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
-252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 253,
-253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 242,
-242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 243,
-243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 240,
-240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 241,
-241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, 246, 246,
-246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 247, 247,
-247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 244, 244,
-244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 245, 245, 245,
-245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 202, 202, 202,
-202, 202, 202, 203, 203, 203, 203, 203, 203, 200, 200, 200, 200,
-200, 200, 200, 201, 201, 201, 201, 201, 201, 206, 206, 206, 206,
-206, 206, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 204,
-204, 204, 205, 205, 205, 205, 205, 205, 194, 194, 194, 194, 194,
-194, 195, 195, 195, 195, 195, 195, 192, 192, 192, 192, 192, 192,
-192, 193, 193, 193, 193, 193, 193, 198, 198, 198, 198, 198, 198,
-199, 199, 199, 199, 199, 199, 196, 196, 196, 196, 196, 196, 196,
-197, 197, 197, 197, 197, 197, 218, 218, 218, 218, 218, 218, 219,
-219, 219, 219, 219, 219, 216, 216, 216, 216, 216, 216, 216, 217,
-217, 217, 217, 217, 217, 222, 222, 222, 222, 222, 222, 223, 223,
-223, 223, 223, 223, 220, 220, 220, 220, 220, 220, 220, 221, 221,
-221, 221, 221, 221, 210, 210, 210, 210, 210, 210, 211, 211, 211,
-211, 211, 211, 208, 208, 208, 208, 208, 208, 209, 209, 209, 209,
-209, 209, 209, 214, 214, 214, 214, 214, 214, 215, 215, 215, 215,
-215, 215, 212, 212, 212, 212, 212, 212, 213, 213, 213, 213, 213,
-213, 213, 90, 90, 90, 85, 85, 85, 85, 85, 85, 84, 84, 84, 84, 84,
-84, 87, 87, 87, 87, 87, 87, 86, 86, 86, 86, 86, 86, 81, 81, 81,
-81, 81, 81, 81, 80, 80, 80, 80, 80, 80, 83, 83, 83, 83, 83, 83,
-82, 82, 82, 82, 82, 82, 93, 93, 93, 93, 93, 93, 93, 92, 92, 92,
-92, 92, 92, 95, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 89,
-89, 89, 89, 89, 89, 88, 88, 88, 88, 88, 88, 88, 91, 91, 91, 91,
-91, 91, 90, 90, 90, 90, 90, 90, 69, 69, 69, 69, 69, 69, 68, 68,
-68, 68, 68, 68, 68, 71, 71, 71, 71, 71, 71, 70, 70, 70, 70, 70,
-70, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 64, 67, 67,
-67, 67, 67, 67, 66, 66, 66, 66, 66, 66, 77, 77, 77, 77, 77, 77,
-76, 76, 76, 76, 76, 76, 76, 79, 79, 79, 79, 79, 79, 78, 78, 78,
-78, 78, 78, 73, 73, 73, 73, 73, 73, 73, 72, 72, 72, 72, 72, 72,
-75, 75, 75, 75, 75, 75, 74, 74, 74, 74, 74, 74, 117, 117, 117, 117,
-117, 117, 117, 117, 117, 117, 117, 117, 117, 116, 116, 116, 116,
-116, 116, 116, 116, 116, 116, 116, 116, 116, 119, 119, 119, 119,
-119, 119, 119, 119, 119, 119, 119, 119, 118, 118, 118, 118, 118,
-118, 118, 118, 118, 118, 118, 118, 118, 113, 113, 113, 113, 113,
-113, 113, 113, 113, 113, 113, 113, 113, 112, 112, 112, 112, 112,
-112, 112, 112, 112, 112, 112, 112, 115, 115, 115, 115, 115, 115,
-115, 115, 115, 115, 115, 115, 115, 114, 114, 114, 114, 114, 114,
-114, 114, 114, 114, 114, 114, 114, 125, 125, 125, 125, 125, 125,
-125, 125, 125, 125, 125, 125, 125, 124, 124, 124, 124, 124, 124,
-124, 124, 124, 124, 124, 124, 124, 127, 127, 127, 127, 127, 127,
-127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126,
-126, 126, 126, 126, 126, 126, 121, 121, 121, 121, 121, 121, 121,
-121, 121, 121, 121, 121, 121, 120, 120, 120, 120, 120, 120, 120,
-120, 120, 120, 120, 120, 120, 123, 123, 123, 123, 123, 123, 123,
-123, 123, 123, 123, 123, 123, 122, 122, 122, 122, 122, 122, 122,
-122, 122, 122, 122, 122, 122, 101, 101, 101, 101, 101, 101, 101,
-101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101,
-101, 101, 101, 101, 101, 101, 101, 100, 100, 100, 100, 100, 100,
-100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
-100, 100, 100, 100, 100, 100, 100, 103, 103, 103, 103, 103, 103,
-103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
-103, 103, 103, 103, 103, 103, 103, 103, 102, 102, 102, 102, 102,
-102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
-102, 102, 102, 102, 102, 102, 102, 102, 102, 97, 97, 97, 97, 97,
-97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
-97, 97, 97, 97, 97, 97, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
-96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
-96, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
-99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98,
-98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
-98, 98, 98, 98, 98, 98, 98, 98, 98, 109, 109, 109, 109, 109, 109,
-109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
-109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 108, 108, 108,
-108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108,
-108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 111,
-111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
-111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
-111, 111, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
-110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
-110, 110, 110, 110, 110, 110, 105, 105, 105, 105, 105, 105, 105,
-105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
-105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 104, 104, 104,
-104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
-104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
-104, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
-107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
-107, 107, 107, 107, 107, 107, 106, 106, 106, 106, 106, 106, 106,
-106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 21,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-20, 20, 20, 20, 20, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-17, 17, 17, 17, 17, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 20, 20, 20, 20, 20, 20,
-20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
-106, 106, 106, 106, 106, 106, 107, 107, 107, 107, 107, 107, 107,
-107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
-107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 104, 104,
-104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
-104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
-104, 104, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
-105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
-105, 105, 105, 105, 105, 105, 110, 110, 110, 110, 110, 110, 110,
-110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
-110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 111, 111, 111,
-111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
-111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
-108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108,
-108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108,
-108, 108, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
-109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
-109, 109, 109, 109, 109, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
-98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
-98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
-99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 96, 96,
-96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
-96, 96, 96, 96, 96, 96, 96, 96, 96, 97, 97, 97, 97, 97, 97, 97,
-97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
-97, 97, 97, 97, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
-102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
-102, 102, 102, 102, 103, 103, 103, 103, 103, 103, 103, 103, 103,
-103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
-103, 103, 103, 103, 103, 100, 100, 100, 100, 100, 100, 100, 100,
-100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
-100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 101, 101, 101,
-101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101,
-101, 101, 101, 101, 101, 101, 122, 122, 122, 122, 122, 122, 122,
-122, 122, 122, 122, 122, 122, 123, 123, 123, 123, 123, 123, 123,
-123, 123, 123, 123, 123, 123, 120, 120, 120, 120, 120, 120, 120,
-120, 120, 120, 120, 120, 120, 121, 121, 121, 121, 121, 121, 121,
-121, 121, 121, 121, 121, 121, 126, 126, 126, 126, 126, 126, 126,
-126, 126, 126, 126, 126, 126, 127, 127, 127, 127, 127, 127, 127,
-127, 127, 127, 127, 127, 124, 124, 124, 124, 124, 124, 124, 124,
-124, 124, 124, 124, 124, 125, 125, 125, 125, 125, 125, 125, 125,
-125, 125, 125, 125, 125, 114, 114, 114, 114, 114, 114, 114, 114,
-114, 114, 114, 114, 114, 115, 115, 115, 115, 115, 115, 115, 115,
-115, 115, 115, 115, 115, 112, 112, 112, 112, 112, 112, 112, 112,
-112, 112, 112, 112, 113, 113, 113, 113, 113, 113, 113, 113, 113,
-113, 113, 113, 113, 118, 118, 118, 118, 118, 118, 118, 118, 118,
-118, 118, 118, 118, 119, 119, 119, 119, 119, 119, 119, 119, 119,
-119, 119, 119, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
-116, 116, 116, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
-117, 117, 117, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 72,
-72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73, 73, 78, 78, 78, 78,
-78, 78, 79, 79, 79, 79, 79, 79, 76, 76, 76, 76, 76, 76, 76, 77,
-77, 77, 77, 77, 77, 66, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67,
-67, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 70, 70,
-70, 70, 70, 70, 71, 71, 71, 71, 71, 71, 68, 68, 68, 68, 68, 68,
-68, 69, 69, 69, 69, 69, 69, 90, 90, 90, 90, 90, 90, 91, 91, 91,
-91, 91, 91, 88, 88, 88, 88, 88, 88, 88, 89, 89, 89, 89, 89, 89,
-94, 94, 94, 94, 94, 94, 95, 95, 95, 95, 95, 95, 92, 92, 92, 92,
-92, 92, 93, 93, 93, 93, 93, 93, 93, 82, 82, 82, 82, 82, 82, 83,
-83, 83, 83, 83, 83, 80, 80, 80, 80, 80, 80, 81, 81, 81, 81, 81,
-81, 81, 86, 86, 86, 86, 86, 86, 87, 87, 87, 87, 87, 87, 84, 84,
-84, 84, 84, 84, 85, 85, 85, 85, 85, 85, 90, 90, 90 };
-
-/*===========================================================================*/
--- sys/i4b/driver/i4b_ctl.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ctl.c - i4b system control port driver
- *	------------------------------------------
- *	last edit-date: [Sun Mar 17 09:49:24 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/driver/i4b_ctl.c,v 1.26 2005/01/06 22:18:18 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/ioccom.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer2/i4b_l2.h>
-
-static int openflag = 0;
-
-static	d_open_t	i4bctlopen;
-static	d_close_t	i4bctlclose;
-static	d_ioctl_t	i4bctlioctl;
-static	d_poll_t	i4bctlpoll;
-
-
-static struct cdevsw i4bctl_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
-	.d_open =	i4bctlopen,
-	.d_close =	i4bctlclose,
-	.d_ioctl =	i4bctlioctl,
-	.d_poll =	i4bctlpoll,
-	.d_name =	"i4bctl",
-};
-
-static void i4bctlattach(void *);
-PSEUDO_SET(i4bctlattach, i4b_i4bctldrv);
-
-/*---------------------------------------------------------------------------*
- *	interface attach routine
- *---------------------------------------------------------------------------*/
-static void
-i4bctlattach(void *dummy)
-{
-	printf("i4bctl: ISDN system control port attached\n");
-	make_dev(&i4bctl_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "i4bctl");
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bctlopen - device driver open routine
- *---------------------------------------------------------------------------*/
-static int
-i4bctlopen(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	if(minor(dev))
-		return (ENXIO);
-
-	if(openflag)
-		return (EBUSY);
-	
-	openflag = 1;
-	
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bctlclose - device driver close routine
- *---------------------------------------------------------------------------*/
-static int
-i4bctlclose(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	openflag = 0;
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bctlioctl - device driver ioctl routine
- *---------------------------------------------------------------------------*/
-static int
-i4bctlioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
-{
-#if DO_I4B_DEBUG
-	ctl_debug_t *cdbg;	
-	int error = 0;
-#endif
-	
-#if !DO_I4B_DEBUG
-       return(ENODEV);
-#else
-	if(minor(dev))
-		return(ENODEV);
-
-	switch(cmd)
-	{
-		case I4B_CTL_GET_DEBUG:
-			cdbg = (ctl_debug_t *)data;
-			cdbg->l1 = i4b_l1_debug;
-			cdbg->l2 = i4b_l2_debug;
-			cdbg->l3 = i4b_l3_debug;
-			cdbg->l4 = i4b_l4_debug;
-			break;
-		
-		case I4B_CTL_SET_DEBUG:
-			cdbg = (ctl_debug_t *)data;
-			i4b_l1_debug = cdbg->l1;
-			i4b_l2_debug = cdbg->l2;
-			i4b_l3_debug = cdbg->l3;
-			i4b_l4_debug = cdbg->l4;
-			break;
-
-                case I4B_CTL_GET_CHIPSTAT:
-                {
-                        struct chipstat *cst;
-			cst = (struct chipstat *)data;
-			(*ctrl_desc[cst->driver_unit].N_MGMT_COMMAND)(cst->driver_unit, CMR_GCST, cst);
-                        break;
-                }
-
-                case I4B_CTL_CLR_CHIPSTAT:
-                {
-                        struct chipstat *cst;
-			cst = (struct chipstat *)data;
-			(*ctrl_desc[cst->driver_unit].N_MGMT_COMMAND)(cst->driver_unit, CMR_CCST, cst);
-                        break;
-                }
-
-                case I4B_CTL_GET_LAPDSTAT:
-                {
-                        l2stat_t *l2s;
-                        l2_softc_t *sc;
-                        l2s = (l2stat_t *)data;
-
-                        if( l2s->unit < 0 || l2s->unit > MAXL1UNITS)
-                        {
-                        	error = EINVAL;
-				break;
-			}
-			  
-			sc = &l2_softc[l2s->unit];
-
-			bcopy(&sc->stat, &l2s->lapdstat, sizeof(lapdstat_t));
-                        break;
-                }
-
-                case I4B_CTL_CLR_LAPDSTAT:
-                {
-                        int *up;
-                        l2_softc_t *sc;
-                        up = (int *)data;
-
-                        if( *up < 0 || *up > MAXL1UNITS)
-                        {
-                        	error = EINVAL;
-				break;
-			}
-			  
-			sc = &l2_softc[*up];
-
-			bzero(&sc->stat, sizeof(lapdstat_t));
-                        break;
-                }
-
-		default:
-			error = ENOTTY;
-			break;
-	}
-	return(error);
-#endif /* DO_I4B_DEBUG */
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bctlpoll - device driver poll routine
- *---------------------------------------------------------------------------*/
-static int
-i4bctlpoll (struct cdev *dev, int events, struct thread *td)
-{
-	return (ENODEV);
-}
--- sys/i4b/driver/i4b_ipr.c
+++ /dev/null
@@ -1,1034 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ipr.c - isdn4bsd IP over raw HDLC ISDN network driver
- *	---------------------------------------------------------
- *	last edit-date: [Sun Mar 17 09:32:58 2002]
- *
- *---------------------------------------------------------------------------*
- *
- *	statistics counter usage (interface lifetime):
- *	----------------------------------------------
- *	sc->sc_ifp->if_ipackets	# of received packets
- *	sc->sc_ifp->if_ierrors	# of error packets not going to upper layers
- *	sc->sc_ifp->if_opackets	# of transmitted packets
- *	sc->sc_ifp->if_oerrors	# of error packets not being transmitted
- *	sc->sc_ifp->if_collisions	# of invalid ip packets after VJ decompression
- *	sc->sc_ifp->if_ibytes	# of bytes coming in from the line (before VJ)
- *	sc->sc_ifp->if_obytes	# of bytes going out to the line (after VJ)
- *	sc->sc_ifp->if_imcasts	  (currently unused)
- *	sc->sc_ifp->if_omcasts	# of frames sent out of the fastqueue
- *	sc->sc_ifp->if_iqdrops	# of frames dropped on input because queue full
- *	sc->sc_ifp->if_noproto	# of frames dropped on output because !AF_INET
- *
- *	statistics counter usage (connection lifetime):
- *	-----------------------------------------------
- *	sc->sc_iinb		# of ISDN incoming bytes from HSCX
- *	sc->sc_ioutb		# of ISDN outgoing bytes from HSCX
- *	sc->sc_inb		# of incoming bytes after decompression
- *	sc->sc_outb		# of outgoing bytes before compression
- *
- *---------------------------------------------------------------------------*/ 
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/driver/i4b_ipr.c,v 1.34.2.1 2005/08/25 05:01:19 rwatson Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <sys/ioccom.h>
-#include <sys/sockio.h>
-#include <sys/kernel.h>
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/netisr.h>
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-
-#ifdef IPR_VJ
-#include <sys/malloc.h>
-#include <net/slcompress.h>       
-#define IPR_COMPRESS IFF_LINK0  /* compress TCP traffic */
-#define IPR_AUTOCOMP IFF_LINK1  /* auto-enable TCP compression */
-
-/*---------------------------------------------------------------------------
- * NOTICE: using NO separate buffer relies on the assumption, that the HSCX
- * IRQ handler _always_ allocates a single, continuous mbuf cluster large
- * enough to hold the maximum MTU size if the ipr interface !
- *
- * CAUTION: i have re-defined IPR_VJ_USEBUFFER because it makes problems
- *          with 2 i4b's back to back running cvs over ssh, cvs simply
- *          aborts because it gets bad data. Everything else (telnet/ftp?etc)
- *          functions fine. 
- *---------------------------------------------------------------------------*/
-#define IPR_VJ_USEBUFFER	/* define to use an allocated separate buffer*/
-				/* undef to uncompress in the mbuf itself    */
-#endif /* IPR_VJ */
-
-#include <sys/time.h>
-#include <net/bpf.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-NET_NEEDS_GIANT("i4b_ipr");
-
-#define I4BIPRMTU	1500		/* regular MTU */
-#define I4BIPRMAXMTU	2000		/* max MTU */
-#define I4BIPRMINMTU	500		/* min MTU */
-
-#define I4BIPRMAXQLEN	50		/* max queue length */
-
-#define I4BIPRACCT	1		/* enable accounting messages */
-#define	I4BIPRACCTINTVL	2		/* accounting msg interval in secs */
-#define I4BIPRADJFRXP	1		/* adjust 1st rxd packet */
-
-/* initialized by L4 */
-
-static drvr_link_t ipr_drvr_linktab[NI4BIPR];
-static isdn_link_t *isdn_linktab[NI4BIPR];
-
-struct ipr_softc {
-	struct ifnet	*sc_ifp;	/* network-visible interface	*/
-	int		sc_state;	/* state of the interface	*/
-	call_desc_t	*sc_cdp;	/* ptr to call descriptor	*/
-	int		sc_updown;	/* soft state of interface	*/
-	struct ifqueue  sc_fastq;	/* interactive traffic		*/
-	int		sc_dialresp;	/* dialresponse			*/
-	int		sc_lastdialresp;/* last dialresponse		*/
-	struct callout_handle	sc_callout;
-	
-#if I4BIPRACCT
-	int		sc_iinb;	/* isdn driver # of inbytes	*/
-	int		sc_ioutb;	/* isdn driver # of outbytes	*/
-	int		sc_inb;		/* # of bytes rx'd		*/
-	int		sc_outb;	/* # of bytes tx'd	 	*/
-	int		sc_linb;	/* last # of bytes rx'd		*/
-	int		sc_loutb;	/* last # of bytes tx'd 	*/
-	int		sc_fn;		/* flag, first null acct	*/
-#endif	
-
-#ifdef I4BIPRADJFRXP
-	int		sc_first_pkt;	/* flag, first rxd packet	*/
-#endif
-
-#if IPR_LOG
-	int		sc_log_first;	/* log first n packets          */
-#endif
-
-#ifdef IPR_VJ
-	struct slcompress sc_compr;	/* tcp compression data		*/
-#ifdef IPR_VJ_USEBUFFER
-	u_char		*sc_cbuf;	/* tcp decompression buffer	*/
-#endif
-#endif
-
-} ipr_softc[NI4BIPR];
-
-enum ipr_states {
-	ST_IDLE,			/* initialized, ready, idle	*/
-	ST_DIALING,			/* dialling out to remote	*/
-	ST_CONNECTED_W,			/* connected to remote		*/
-	ST_CONNECTED_A,			/* connected to remote		*/
-};
-
-static void i4biprattach(void *);
-PSEUDO_SET(i4biprattach, i4b_ipr);
-static int i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
-
-static void iprwatchdog(struct ifnet *ifp);
-static void ipr_init_linktab(int unit);
-static void ipr_tx_queue_empty(int unit);
-static int i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rtp);
-static void iprclearqueues(struct ipr_softc *sc);
-
-/*===========================================================================*
- *			DEVICE DRIVER ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	interface attach routine at kernel boot time
- *---------------------------------------------------------------------------*/
-static void
-i4biprattach(void *dummy)
-{
-	struct ipr_softc *sc = ipr_softc;
-	int i;
-
-#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
-	
-	for(i=0; i < NI4BIPR; sc++, i++)
-	{
-		ipr_init_linktab(i);
-
-		NDBGL4(L4_DIALST, "setting dial state to ST_IDLE");
-
-		sc->sc_ifp = if_alloc(IFT_ISDNBASIC);
-		if (sc->sc_ifp == NULL)
-			panic("i4b_ipr.c, i4biprattach: cannot if_alloc()");
-
-		sc->sc_ifp->if_softc = sc;
-		sc->sc_state = ST_IDLE;
-		if_initname(sc->sc_ifp, "ipr", i);
-
-
-#ifdef	IPR_VJ
-		sc->sc_ifp->if_flags = IFF_POINTOPOINT | IFF_SIMPLEX | IPR_AUTOCOMP;
-#else
-		sc->sc_ifp->if_flags = IFF_POINTOPOINT | IFF_SIMPLEX;
-#endif
-
-		sc->sc_ifp->if_mtu = I4BIPRMTU;
-		sc->sc_ifp->if_ioctl = i4biprioctl;
-		sc->sc_ifp->if_output = i4biproutput;
-
-		sc->sc_ifp->if_snd.ifq_maxlen = I4BIPRMAXQLEN;
-		sc->sc_fastq.ifq_maxlen = I4BIPRMAXQLEN;
-
-		if(!mtx_initialized(&sc->sc_fastq.ifq_mtx))
-			mtx_init(&sc->sc_fastq.ifq_mtx, "i4b_ipr_fastq", NULL, MTX_DEF);
-
-		sc->sc_ifp->if_ipackets = 0;
-		sc->sc_ifp->if_ierrors = 0;
-		sc->sc_ifp->if_opackets = 0;
-		sc->sc_ifp->if_oerrors = 0;
-		sc->sc_ifp->if_collisions = 0;
-		sc->sc_ifp->if_ibytes = 0;
-		sc->sc_ifp->if_obytes = 0;
-		sc->sc_ifp->if_imcasts = 0;
-		sc->sc_ifp->if_omcasts = 0;
-		sc->sc_ifp->if_iqdrops = 0;
-		sc->sc_ifp->if_noproto = 0;
-
-#if I4BIPRACCT
-		sc->sc_ifp->if_timer = 0;	
-		sc->sc_ifp->if_watchdog = iprwatchdog;	
-		sc->sc_iinb = 0;
-		sc->sc_ioutb = 0;
-		sc->sc_inb = 0;
-		sc->sc_outb = 0;
-		sc->sc_linb = 0;
-		sc->sc_loutb = 0;
-		sc->sc_fn = 1;
-#endif
-
-#if IPR_LOG
-		sc->sc_log_first = IPR_LOG;
-#endif
-
-#ifdef IPR_VJ
-		sl_compress_init(&sc->sc_compr, -1);
-
-#ifdef IPR_VJ_USEBUFFER
-		if(!((sc->sc_cbuf =
-		   (u_char *)malloc(I4BIPRMAXMTU+128, M_DEVBUF, M_WAITOK))))
-		{
-			panic("i4b_ipr.c, i4biprattach: VJ malloc failed");
-		}
-#endif
-#endif
-		sc->sc_updown = SOFT_ENA;	/* soft enabled */
-		sc->sc_dialresp = DSTAT_NONE;	/* no response */
-		sc->sc_lastdialresp = DSTAT_NONE;
-		
-		if_attach(sc->sc_ifp);
-
-		bpfattach(sc->sc_ifp, DLT_NULL, sizeof(u_int32_t));
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	output a packet to the ISDN B-channel
- *---------------------------------------------------------------------------*/
-static int
-i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
-	 struct rtentry *rtp)
-{
-	struct ipr_softc *sc;
-	int unit;
-	int s;
-	struct ifqueue *ifq;
-	struct ip *ip;
-	u_int32_t af;
-	
-	s = SPLI4B();
-
-	sc = ifp->if_softc;
-	unit = ifp->if_dunit;
-
-	/* BPF writes need to be handled specially. */
-	if(dst->sa_family == AF_UNSPEC)
-	{
-		bcopy(dst->sa_data, &af, sizeof(af));
-		dst->sa_family = af;
-	}
-
-	/* check for IP */
-	
-	if(dst->sa_family != AF_INET)
-	{
-		if_printf(ifp, "af%d not supported\n", dst->sa_family);
-		m_freem(m);
-		splx(s);
-		sc->sc_ifp->if_noproto++;
-		sc->sc_ifp->if_oerrors++;
-		return(EAFNOSUPPORT);
-	}
-
-	/* check interface state = UP */
-	
-	if(!(ifp->if_flags & IFF_UP))
-	{
-		NDBGL4(L4_IPRDBG, "ipr%d: interface is DOWN!", unit);
-		m_freem(m);
-		splx(s);
-		sc->sc_ifp->if_oerrors++;
-		return(ENETDOWN);
-	}
-
-	/* dial if necessary */
-	
-	if(sc->sc_state == ST_IDLE || sc->sc_state == ST_DIALING)
-	{
-
-#ifdef NOTDEF
-		switch(sc->sc_dialresp)
-		{
-			case DSTAT_TFAIL:	/* transient failure */
-				NDBGL4(L4_IPRDBG, "ipr%d: transient dial failure!", unit);
-				m_freem(m);
-				iprclearqueues(sc);
-				sc->sc_dialresp = DSTAT_NONE;
-				splx(s);
-				sc->sc_ifp->if_oerrors++;
-				return(ENETUNREACH);
-				break;
-
-			case DSTAT_PFAIL:	/* permanent failure */
-				NDBGL4(L4_IPRDBG, "ipr%d: permanent dial failure!", unit);
-				m_freem(m);
-				iprclearqueues(sc);
-				sc->sc_dialresp = DSTAT_NONE;
-				splx(s);
-				sc->sc_ifp->if_oerrors++;
-				return(EHOSTUNREACH);				
-				break;
-
-			case DSTAT_INONLY:	/* no dialout allowed*/
-				NDBGL4(L4_IPRDBG, "ipr%d: dialout not allowed failure!", unit);
-				m_freem(m);
-				iprclearqueues(sc);
-				sc->sc_dialresp = DSTAT_NONE;
-				splx(s);
-				sc->sc_ifp->if_oerrors++;
-				return(EHOSTUNREACH);				
-				break;
-		}
-#endif
-
-		NDBGL4(L4_IPRDBG, "ipr%d: send dial request message!", unit);
-		NDBGL4(L4_DIALST, "ipr%d: setting dial state to ST_DIALING", unit);
-		i4b_l4_dialout(BDRV_IPR, unit);
-		sc->sc_state = ST_DIALING;
-	}
-
-#if IPR_LOG
-	if(sc->sc_log_first > 0)
-	{
-		--(sc->sc_log_first);
-		i4b_l4_packet_ind(BDRV_IPR, unit, 1, m );
-	}
-#endif
-
-	/* update access time */
-	
-	microtime(&sc->sc_ifp->if_lastchange);
-
-	/*
-	 * check, if type of service indicates interactive, i.e. telnet,
-	 * traffic. in case it is interactive, put it into the fast queue,
-	 * else (i.e. ftp traffic) put it into the "normal" queue
-	 */
-
-	ip = mtod(m, struct ip *);		/* get ptr to ip header */
-	 
-	if(ip->ip_tos & IPTOS_LOWDELAY)
-		ifq = &sc->sc_fastq;
-	else
-	        ifq = (struct ifqueue *)&sc->sc_ifp->if_snd;
-
-	/* check for space in choosen send queue */
-	
-	if(! IF_HANDOFF(ifq, m, NULL))
-	{
-		NDBGL4(L4_IPRDBG, "ipr%d: send queue full!", unit);
-		splx(s);
-		sc->sc_ifp->if_oerrors++;
-		return(ENOBUFS);
-	}
-	
-	NDBGL4(L4_IPRDBG, "ipr%d: add packet to send queue!", unit);
-	
-	ipr_tx_queue_empty(unit);
-
-	splx(s);
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- *	process ioctl
- *---------------------------------------------------------------------------*/
-static int
-i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
-{
-	struct ipr_softc *sc = ifp->if_softc;
-	struct ifreq *ifr = (struct ifreq *)data;
-	struct ifaddr *ifa = (struct ifaddr *)data;
-	int s;
-	int error = 0;
-
-	s = SPLI4B();
-	
-	switch (cmd)
-	{
-		case SIOCAIFADDR:	/* add interface address */
-		case SIOCSIFADDR:	/* set interface address */
-		case SIOCSIFDSTADDR:	/* set interface destination address */
-			if(ifa->ifa_addr->sa_family != AF_INET)
-				error = EAFNOSUPPORT;
-			else
-				sc->sc_ifp->if_flags |= IFF_UP;
-			microtime(&sc->sc_ifp->if_lastchange);
-			break;
-
-		case SIOCSIFFLAGS:	/* set interface flags */
-			if(!(ifr->ifr_flags & IFF_UP))
-			{
-				if(sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)
-				{
-					/* disconnect ISDN line */
-					i4b_l4_drvrdisc(BDRV_IPR,
-					    ifp->if_dunit);
-					sc->sc_ifp->if_drv_flags &=
-					    ~IFF_DRV_RUNNING;
-				}
-
-				sc->sc_state = ST_IDLE;
-
-				/* empty queues */
-
-				iprclearqueues(sc);
-			}
-
-			if(ifr->ifr_flags & IFF_DEBUG)
-			{
-				/* enable debug messages */
-			}
-			
-			microtime(&sc->sc_ifp->if_lastchange);
-			break;
-
-		case SIOCSIFMTU:	/* set interface MTU */
-			if(ifr->ifr_mtu > I4BIPRMAXMTU)
-				error = EINVAL;
-			else if(ifr->ifr_mtu < I4BIPRMINMTU)
-				error = EINVAL;
-			else
-			{
-				ifp->if_mtu = ifr->ifr_mtu;
-				microtime(&sc->sc_ifp->if_lastchange);
-			}
-			break;
-#if 0
-	/* not needed for FreeBSD, done in sl_compress_init() (-hm) */
-	
-			/* need to add an ioctl:	set VJ max slot ID
-			 * #define IPRIOCSMAXCID	_IOW('I', XXX, int)
-			 */
-#ifdef IPR_VJ
-		case IPRIOCSMAXCID:
-			{
-			struct thread *td = curthread;	/* XXX */
-
-			if((error = suser(td)))
-				return (error);
-		        sl_compress_setup(sc->sc_compr, *(int *)data);
-			}
-			break;
-#endif
-#endif /* #if 0 */
-
-		default:
-			error = EINVAL;
-			break;
-	}
-	splx(s);
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	clear the interface's send queues
- *---------------------------------------------------------------------------*/
-static void
-iprclearqueues(struct ipr_softc *sc)
-{
-	int x;
-
-	x = splimp();
-	IF_DRAIN(&sc->sc_fastq);
-	IF_DRAIN(&sc->sc_ifp->if_snd);
-	splx(x);
-}
-        
-#if I4BIPRACCT
-/*---------------------------------------------------------------------------*
- *	watchdog routine
- *---------------------------------------------------------------------------*/
-static void
-iprwatchdog(struct ifnet *ifp)
-{
-	int unit = ifp->if_dunit;
-	struct ipr_softc *sc = ifp->if_softc;
-	bchan_statistics_t bs;
-	
-	/* get # of bytes in and out from the HSCX driver */ 
-	
-	(*isdn_linktab[unit]->bch_stat)
-		(isdn_linktab[unit]->unit, isdn_linktab[unit]->channel, &bs);
-
-	sc->sc_ioutb += bs.outbytes;
-	sc->sc_iinb += bs.inbytes;
-	
-	if((sc->sc_iinb != sc->sc_linb) || (sc->sc_ioutb != sc->sc_loutb) || sc->sc_fn) 
-	{
-		int ri = (sc->sc_iinb - sc->sc_linb)/I4BIPRACCTINTVL;
-		int ro = (sc->sc_ioutb - sc->sc_loutb)/I4BIPRACCTINTVL;
-
-		if((sc->sc_iinb == sc->sc_linb) && (sc->sc_ioutb == sc->sc_loutb))
-			sc->sc_fn = 0;
-		else
-			sc->sc_fn = 1;
-			
-		sc->sc_linb = sc->sc_iinb;
-		sc->sc_loutb = sc->sc_ioutb;
-
-		i4b_l4_accounting(BDRV_IPR, unit, ACCT_DURING,
-			 sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_outb, sc->sc_inb);
- 	}
-	sc->sc_ifp->if_timer = I4BIPRACCTINTVL; 	
-}
-#endif /* I4BIPRACCT */
-
-/*===========================================================================*
- *			ISDN INTERFACE ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	start transmitting after connect
- *---------------------------------------------------------------------------*/
-static void
-i4bipr_connect_startio(struct ipr_softc *sc)
-{
-	int s = SPLI4B();
-	
-	if(sc->sc_state == ST_CONNECTED_W)
-	{
-		sc->sc_state = ST_CONNECTED_A;
-		ipr_tx_queue_empty(sc->sc_ifp->if_dunit);
-	}
-
-	splx(s);
-}
- 
-/*---------------------------------------------------------------------------*
- *	this routine is called from L4 handler at connect time
- *---------------------------------------------------------------------------*/
-static void
-ipr_connect(int unit, void *cdp)
-{
-	struct ipr_softc *sc = &ipr_softc[unit];
-	int s;
-
-	sc->sc_cdp = (call_desc_t *)cdp;
-
-	s = SPLI4B();
-
-	NDBGL4(L4_DIALST, "ipr%d: setting dial state to ST_CONNECTED", unit);
-
-	sc->sc_ifp->if_drv_flags |= IFF_DRV_RUNNING;
-	sc->sc_state = ST_CONNECTED_W;
-
-	sc->sc_dialresp = DSTAT_NONE;
-	sc->sc_lastdialresp = DSTAT_NONE;	
-	
-#if I4BIPRACCT
-	sc->sc_iinb = 0;
-	sc->sc_ioutb = 0;
-	sc->sc_inb = 0;
-	sc->sc_outb = 0;
-	sc->sc_linb = 0;
-	sc->sc_loutb = 0;
-	sc->sc_ifp->if_timer = I4BIPRACCTINTVL;
-#endif
-
-#ifdef I4BIPRADJFRXP
-	sc->sc_first_pkt = 1;
-#endif
-
-	/*
-	 * Sometimes ISDN B-channels are switched thru asymmetic. This
-	 * means that under such circumstances B-channel data (the first
-	 * three packets of a TCP connection in my case) may get lost,
-	 * causing a large delay until the connection is started.
-	 * When the sending of the very first packet of a TCP connection
-	 * is delayed for a to be empirically determined delay (close
-	 * to a second in my case) those packets go thru and the TCP
-	 * connection comes up "almost" immediately (-hm).
-	 */
-
-	if(sc->sc_cdp->isdntxdelay > 0)
-	{
-		int delay;
-
-		if (hz == 100) {
-			delay = sc->sc_cdp->isdntxdelay;	/* avoid any rounding */
-		} else {
-			delay = sc->sc_cdp->isdntxdelay*hz;
-			delay /= 100;
-		}
-
-		START_TIMER(sc->sc_callout, (TIMEOUT_FUNC_T)i4bipr_connect_startio, (void *)sc,  delay);
-	}
-	else
-	{
-		sc->sc_state = ST_CONNECTED_A;
-		ipr_tx_queue_empty(unit);
-	}
-
-	splx(s);
-
-	/* we don't need any negotiation - pass event back right now */
-	i4b_l4_negcomplete(sc->sc_cdp);
-}
-	
-/*---------------------------------------------------------------------------*
- *	this routine is called from L4 handler at disconnect time
- *---------------------------------------------------------------------------*/
-static void
-ipr_disconnect(int unit, void *cdp)
-{
-	call_desc_t *cd = (call_desc_t *)cdp;
-	struct ipr_softc *sc = &ipr_softc[unit];
-
-	/* new stuff to check that the active channel is being closed */
-
-	if (cd != sc->sc_cdp)
-	{
-		NDBGL4(L4_IPRDBG, "ipr%d: channel %d not active",
-				cd->driver_unit, cd->channelid);
-		return;
-	}
-
-#if I4BIPRACCT
-	sc->sc_ifp->if_timer = 0;
-#endif
-
-#if IPR_LOG
-	/* show next IPR_LOG packets again */
-	sc->sc_log_first = IPR_LOG;
-#endif
-
-	i4b_l4_accounting(BDRV_IPR, cd->driver_unit, ACCT_FINAL,
-		 sc->sc_ioutb, sc->sc_iinb, 0, 0, sc->sc_outb, sc->sc_inb);
-	
-	sc->sc_cdp = (call_desc_t *)0;	
-
-	NDBGL4(L4_DIALST, "setting dial state to ST_IDLE");
-
-	sc->sc_dialresp = DSTAT_NONE;
-	sc->sc_lastdialresp = DSTAT_NONE;	
-
-	sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
-	sc->sc_state = ST_IDLE;
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is used to give a feedback from userland daemon
- *	in case of dial problems
- *---------------------------------------------------------------------------*/
-static void
-ipr_dialresponse(int unit, int status, cause_t cause)
-{
-	struct ipr_softc *sc = &ipr_softc[unit];
-	sc->sc_dialresp = status;
-
-	NDBGL4(L4_IPRDBG, "ipr%d: last=%d, this=%d",
-		unit, sc->sc_lastdialresp, sc->sc_dialresp);
-
-	if(status != DSTAT_NONE)
-	{
-		NDBGL4(L4_IPRDBG, "ipr%d: clearing queues", unit);
-		iprclearqueues(sc);
-	}
-}
-	
-/*---------------------------------------------------------------------------*
- *	interface soft up/down
- *---------------------------------------------------------------------------*/
-static void
-ipr_updown(int unit, int updown)
-{
-	struct ipr_softc *sc = &ipr_softc[unit];
-	sc->sc_updown = updown;
-}
-	
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when a new frame (mbuf) has been received and was put on
- *	the rx queue. It is assumed that this routines runs at
- *	pri level splimp() ! Keep it short !
- *---------------------------------------------------------------------------*/
-static void
-ipr_rx_data_rdy(int unit)
-{
-	register struct ipr_softc *sc = &ipr_softc[unit];
-	register struct mbuf *m;
-
-#ifdef IPR_VJ
-#ifdef IPR_VJ_USEBUFFER
-	u_char *cp = sc->sc_cbuf;
-#endif	
-	int len, c;
-#endif
-	
-	if((m = *isdn_linktab[unit]->rx_mbuf) == NULL)
-		return;
-
-	m->m_pkthdr.rcvif = sc->sc_ifp;
-
-	m->m_pkthdr.len = m->m_len;
-
-	microtime(&sc->sc_ifp->if_lastchange);
-
-#ifdef I4BIPRADJFRXP
-
-	/*
-	 * The very first packet after the B channel is switched thru
-	 * has very often several bytes of random data prepended. This
-	 * routine looks where the IP header starts and removes the
-	 * the bad data.
-	 */
-
-	if(sc->sc_first_pkt)
-	{
-		unsigned char *mp = m->m_data;
-		int i;
-		
-		sc->sc_first_pkt = 0;
-
-		for(i = 0; i < m->m_len; i++, mp++)
-		{
-			if( ((*mp & 0xf0) == 0x40) &&
-			    ((*mp & 0x0f) >= 0x05) )
-			{
-				m->m_data = mp;
-				m->m_pkthdr.len -= i;				
-				break;
-			}
-		}
-	}
-#endif
-		
-	sc->sc_ifp->if_ipackets++;
-	sc->sc_ifp->if_ibytes += m->m_pkthdr.len;
-
-#ifdef	IPR_VJ
-	if((c = (*(mtod(m, u_char *)) & 0xf0)) != (IPVERSION << 4))
-	{
-		/* copy data to buffer */
-
-		len = m->m_len;
-
-#ifdef IPR_VJ_USEBUFFER
-/* XXX */	m_copydata(m, 0, len, cp);
-#endif
-		
-		if(c & 0x80)
-		{
-			c = TYPE_COMPRESSED_TCP;
-		}
-		else if(c == TYPE_UNCOMPRESSED_TCP)
-		{
-#ifdef IPR_VJ_USEBUFFER
-			*cp &= 0x4f;		/* XXX */
-#else
-			*(mtod(m, u_char *)) &= 0x4f; 			
-#endif			
-		}
-
-		/*
-		 * We've got something that's not an IP packet.
-		 * If compression is enabled, try to decompress it.
-		 * Otherwise, if `auto-enable' compression is on and
-		 * it's a reasonable packet, decompress it and then
-		 * enable compression.  Otherwise, drop it.
-		 */
-		if(sc->sc_ifp->if_flags & IPR_COMPRESS)
-		{
-#ifdef IPR_VJ_USEBUFFER
-			len = sl_uncompress_tcp(&cp,len,(u_int)c,&sc->sc_compr);
-#else
-			len = sl_uncompress_tcp((u_char **)&m->m_data, len,
-					(u_int)c, &sc->sc_compr);
-#endif			
-
-			if(len <= 0)
-			{
-#ifdef DEBUG_IPR_VJ
-				printf("i4b_ipr, ipr_rx_data_rdy: len <= 0 IPR_COMPRESS!\n");
-#endif
-				goto error;
-			}
-		}
-		else if((sc->sc_ifp->if_flags & IPR_AUTOCOMP) &&
-			(c == TYPE_UNCOMPRESSED_TCP) && (len >= 40))
-		{
-#ifdef IPR_VJ_USEBUFFER
-			len = sl_uncompress_tcp(&cp,len,(u_int)c,&sc->sc_compr);
-#else
-			len = sl_uncompress_tcp((u_char **)&m->m_data, len,
-					(u_int)c, &sc->sc_compr);
-#endif
-
-			if(len <= 0)
-			{
-#ifdef DEBUG_IPR_VJ
-				printf("i4b_ipr, ipr_rx_data_rdy: len <= 0 IPR_AUTOCOMP!\n");
-#endif
-				goto error;
-			}
-
-			sc->sc_ifp->if_flags |= IPR_COMPRESS;
-		}
-		else
-		{
-#ifdef DEBUG_IPR_VJ
-			printf("i4b_ipr, ipr_input: invalid ip packet!\n");
-#endif
-
-error:
-			sc->sc_ifp->if_ierrors++;
-			sc->sc_ifp->if_collisions++;
-			m_freem(m);
-			return;
-		}
-#ifdef IPR_VJ_USEBUFFER
-/* XXX */	m_copyback(m, 0, len, cp);
-#else
-		m->m_len = m->m_pkthdr.len = len;
-#endif
-	}
-#endif
-
-#if I4BIPRACCT
-	/* NB. do the accounting after decompression!		*/
-	sc->sc_inb += m->m_pkthdr.len;
-#endif
-
-#if IPR_LOG
-	if(sc->sc_log_first > 0)
-	{
-		--(sc->sc_log_first);
-		i4b_l4_packet_ind(BDRV_IPR, unit, 0, m );
-	}
-#endif
-
-	if(sc->sc_ifp->if_bpf)
-	{
-		/* prepend the address family as a four byte field */		
-		struct mbuf mm;
-		u_int af = AF_INET;
-		mm.m_next = m;
-		mm.m_len = 4;
-		mm.m_data = (char *)⁡
-		BPF_MTAP(sc->sc_ifp, &mm);
-	}
-
-	if(netisr_queue(NETISR_IP, m))	/* (0) on success. */
-	{
-		NDBGL4(L4_IPRDBG, "ipr%d: ipintrq full!", unit);
-		sc->sc_ifp->if_ierrors++;
-		sc->sc_ifp->if_iqdrops++;		
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when the last frame has been sent out and there is no
- *	further frame (mbuf) in the tx queue.
- *---------------------------------------------------------------------------*/
-static void
-ipr_tx_queue_empty(int unit)
-{
-	register struct ipr_softc *sc = &ipr_softc[unit];
-	register struct mbuf *m;
-#ifdef	IPR_VJ	
-	struct ip *ip;	
-#endif
-	int x = 0;
-
-	if(sc->sc_state != ST_CONNECTED_A)
-		return;
-		
-	for(;;)
-	{
-                IF_DEQUEUE(&sc->sc_fastq, m);
-                if(m)
-                {
-			sc->sc_ifp->if_omcasts++;
-		}
-		else
-		{
-			IF_DEQUEUE(&sc->sc_ifp->if_snd, m);
-			if(m == NULL)
-				break;
-		}
-
-		microtime(&sc->sc_ifp->if_lastchange);
-		
-		if(sc->sc_ifp->if_bpf)
-		{
-			/* prepend the address family as a four byte field */
-	
-			struct mbuf mm;
-			u_int af = AF_INET;
-			mm.m_next = m;
-			mm.m_len = 4;
-			mm.m_data = (char *)⁡
-			BPF_MTAP(sc->sc_ifp, &mm);
-		}
-	
-#if I4BIPRACCT
-		sc->sc_outb += m->m_pkthdr.len;	/* size before compression */
-#endif
-
-#ifdef IPR_VJ	
-		if((ip = mtod(m, struct ip *))->ip_p == IPPROTO_TCP)
-		{
-			if(sc->sc_ifp->if_flags & IPR_COMPRESS)
-			{
-				*mtod(m, u_char *) |= sl_compress_tcp(m, ip,
-					&sc->sc_compr, 1);
-			}
-		}
-#endif
-		x = 1;
-
-		IF_LOCK(isdn_linktab[unit]->tx_queue);
-		if(_IF_QFULL(isdn_linktab[unit]->tx_queue))
-		{
-			NDBGL4(L4_IPRDBG, "ipr%d: tx queue full!", unit);
-			m_freem(m);
-		}
-		else
-		{
-			sc->sc_ifp->if_obytes += m->m_pkthdr.len;
-
-			sc->sc_ifp->if_opackets++;
-
-			_IF_ENQUEUE(isdn_linktab[unit]->tx_queue, m);
-
-		}
-		IF_UNLOCK(isdn_linktab[unit]->tx_queue);
-	}
-
-	if(x)
-		(*isdn_linktab[unit]->bch_tx_start)(isdn_linktab[unit]->unit, isdn_linktab[unit]->channel);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	each time a packet is received or transmitted. It should
- *	be used to implement an activity timeout mechanism.
- *---------------------------------------------------------------------------*/
-static void
-ipr_activity(int unit, int rxtx)
-{
-	ipr_softc[unit].sc_cdp->last_active_time = SECOND;
-}
-
-/*---------------------------------------------------------------------------*
- *	return this drivers linktab address
- *---------------------------------------------------------------------------*/
-drvr_link_t *
-ipr_ret_linktab(int unit)
-{
-	return(&ipr_drvr_linktab[unit]);
-}
-
-/*---------------------------------------------------------------------------*
- *	setup the isdn_linktab for this driver
- *---------------------------------------------------------------------------*/
-void
-ipr_set_linktab(int unit, isdn_link_t *ilt)
-{
-	isdn_linktab[unit] = ilt;
-}
-
-/*---------------------------------------------------------------------------*
- *	initialize this drivers linktab
- *---------------------------------------------------------------------------*/
-static void
-ipr_init_linktab(int unit)
-{
-	ipr_drvr_linktab[unit].unit = unit;
-	ipr_drvr_linktab[unit].bch_rx_data_ready = ipr_rx_data_rdy;
-	ipr_drvr_linktab[unit].bch_tx_queue_empty = ipr_tx_queue_empty;
-	ipr_drvr_linktab[unit].bch_activity = ipr_activity;
-	ipr_drvr_linktab[unit].line_connected = ipr_connect;
-	ipr_drvr_linktab[unit].line_disconnected = ipr_disconnect;
-	ipr_drvr_linktab[unit].dial_response = ipr_dialresponse;
-	ipr_drvr_linktab[unit].updown_ind = ipr_updown;	
-}
-
-/*===========================================================================*/
--- sys/i4b/driver/i4b_isppp.c
+++ /dev/null
@@ -1,677 +0,0 @@
-/*-
- *   Copyright (c) 1997 Joerg Wunsch. All rights reserved.
- *
- *   Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_isppp.c - isdn4bsd kernel SyncPPP driver
- *	--------------------------------------------
- *
- * 	Uses Serge Vakulenko's sppp backend (originally contributed with
- *	the "cx" driver for Cronyx's HDLC-in-hardware device).  This driver
- *	is only the glue between sppp and i4b.
- *
- *	last edit-date: [Sat Mar  9 14:09:27 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/driver/i4b_isppp.c,v 1.30.2.1 2005/08/25 05:01:19 rwatson Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <sys/ioccom.h>
-#include <sys/sockio.h>
-#include <sys/kernel.h>
-
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/if_sppp.h>
-
-#include <sys/time.h>
-#include <net/bpf.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-NET_NEEDS_GIANT("i4b_isppp");
-
-#define ISPPP_FMT	"isp%d: "
-#define	ISPPP_ARG(sc)	(sc->sc_ifp->if_dunit)
-#define	PDEVSTATIC	static
-#define IFP2UNIT(ifp)	(ifp)->if_dunit
-		
-#  define CALLOUT_INIT(chan)		callout_handle_init(chan)
-#  define TIMEOUT(fun, arg, chan, tick)	chan = timeout(fun, arg, tick)
-#  define UNTIMEOUT(fun, arg, chan)	untimeout(fun, arg, chan)
-#  define IOCTL_CMD_T u_long
-
-PDEVSTATIC void i4bispppattach(void *);
-PSEUDO_SET(i4bispppattach, i4b_isppp);
-
-#define I4BISPPPACCT		1	/* enable accounting messages */
-#define	I4BISPPPACCTINTVL	2	/* accounting msg interval in secs */
-#define I4BISPPPDISCDEBUG	1	
-
-#define PPP_HDRLEN   		4	/* 4 octetts PPP header length	*/
-
-struct i4bisppp_softc {
-	struct ifnet *sc_ifp;
-
-	int	sc_state;	/* state of the interface	*/
-	call_desc_t *sc_cdp;	/* ptr to call descriptor	*/
-
-#ifdef I4BISPPPACCT
-	int sc_iinb;		/* isdn driver # of inbytes	*/
-	int sc_ioutb;		/* isdn driver # of outbytes	*/
-	int sc_inb;		/* # of bytes rx'd		*/
-	int sc_outb;		/* # of bytes tx'd	 	*/
-	int sc_linb;		/* last # of bytes rx'd		*/
-	int sc_loutb;		/* last # of bytes tx'd 	*/
-	int sc_fn;		/* flag, first null acct	*/
-#endif
-
-	struct callout_handle sc_ch;
-} i4bisppp_softc[NI4BISPPP];
-
-static void	i4bisppp_init_linktab(int unit);
-static int	i4bisppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, caddr_t data);
-
-#if 0
-static void	i4bisppp_send(struct ifnet *ifp);
-#endif
-
-static void	i4bisppp_start(struct ifnet *ifp);
-
-#if 0 /* never used ??? */
-static void	i4bisppp_timeout(void *cookie);
-#endif
-
-static void	i4bisppp_tls(struct sppp *sp);
-static void	i4bisppp_tlf(struct sppp *sp);
-static void	i4bisppp_state_changed(struct sppp *sp, int new_state);
-static void	i4bisppp_negotiation_complete(struct sppp *sp);
-static void	i4bisppp_watchdog(struct ifnet *ifp);
-time_t   	i4bisppp_idletime(int unit);
-
-/* initialized by L4 */
-
-static drvr_link_t i4bisppp_drvr_linktab[NI4BISPPP];
-static isdn_link_t *isdn_linktab[NI4BISPPP];
-
-enum i4bisppp_states {
-	ST_IDLE,			/* initialized, ready, idle	*/
-	ST_DIALING,			/* dialling out to remote	*/
-	ST_CONNECTED,			/* connected to remote		*/
-};
-
-/*===========================================================================*
- *			DEVICE DRIVER ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	interface attach routine at kernel boot time
- *---------------------------------------------------------------------------*/
-PDEVSTATIC void
-i4bispppattach(void *dummy)
-{
-	struct i4bisppp_softc *sc = i4bisppp_softc;
-	struct ifnet *ifp;
-	int i;
-
-#ifdef SPPP_VJ
-	printf("i4bisppp: %d ISDN SyncPPP device(s) attached (VJ header compression)\n", NI4BISPPP);
-#else
-	printf("i4bisppp: %d ISDN SyncPPP device(s) attached\n", NI4BISPPP);
-#endif
-
-	for(i = 0; i < NI4BISPPP; sc++, i++) {
-		i4bisppp_init_linktab(i);
-		ifp = sc->sc_ifp = if_alloc(IFT_PPP);
-		if (ifp == NULL) {
-			panic("isp%d: cannot if_alloc()", i);
-		}
-		
-		ifp->if_softc = sc;
-		if_initname(sc->sc_ifp, "isp", i);
-		ifp->if_mtu = PP_MTU;
-		ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT;
-		/*
-		 * XXX: If there were a detach function this would
-		 * require that it use if_free_type().  Not sure if this
-		 * type makes sense.
-		 */
-		ifp->if_type = IFT_ISDNBASIC;
-		sc->sc_state = ST_IDLE;
-
-		ifp->if_ioctl = i4bisppp_ioctl;
-
-		/* actually initialized by sppp_attach() */
-		/* ifp->if_output = sppp_output; */
-
-		ifp->if_start = i4bisppp_start;
-
-		ifp->if_hdrlen = 0;
-		ifp->if_addrlen = 0;
-		ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
-
-		ifp->if_ipackets = 0;
-		ifp->if_ierrors = 0;
-		ifp->if_opackets = 0;
-		ifp->if_oerrors = 0;
-		ifp->if_collisions = 0;
-		ifp->if_ibytes = 0;
-		ifp->if_obytes = 0;
-		ifp->if_imcasts = 0;
-		ifp->if_omcasts = 0;
-		ifp->if_iqdrops = 0;
-		ifp->if_noproto = 0;
-
-#if I4BISPPPACCT
-		ifp->if_timer = 0;	
-		ifp->if_watchdog = i4bisppp_watchdog;	
-		sc->sc_iinb = 0;
-		sc->sc_ioutb = 0;
-		sc->sc_inb = 0;
-		sc->sc_outb = 0;
-		sc->sc_linb = 0;
-		sc->sc_loutb = 0;
-		sc->sc_fn = 1;
-#endif
-
-		IFP2SP(sc->sc_ifp)->pp_tls = i4bisppp_tls;
-		IFP2SP(sc->sc_ifp)->pp_tlf = i4bisppp_tlf;
-		IFP2SP(sc->sc_ifp)->pp_con = i4bisppp_negotiation_complete;
-		IFP2SP(sc->sc_ifp)->pp_chg = i4bisppp_state_changed;
-
-		sppp_attach(sc->sc_ifp);
-
-		if_attach(sc->sc_ifp);
-
-		CALLOUT_INIT(&sc->sc_ch);
-		
-		bpfattach(sc->sc_ifp, DLT_PPP, PPP_HDRLEN);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	process ioctl
- *---------------------------------------------------------------------------*/
-static int
-i4bisppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, caddr_t data)
-{
-	struct i4bisppp_softc *sc = ifp->if_softc;
-#if 0
-	struct sppp *sp = IFP2SP(sc->sc_ifp);
-	struct ifaddr *ifa = (struct ifaddr *) data;
-	struct ifreq *ifr = (struct ifreq *) data;
-#endif
-
-	int error;
-
-	error = sppp_ioctl(sc->sc_ifp, cmd, data);
-	if (error)
-		return error;
-
-	switch(cmd) {
-	case SIOCSIFFLAGS:
-#if 0 /* never used ??? */
-		x = splimp();
-		if ((ifp->if_flags & IFF_UP) == 0)
-			UNTIMEOUT(i4bisppp_timeout, (void *)sp, sc->sc_ch);
-		splx(x);
-#endif
-		break;
-	}
-
-	return 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	start output to ISDN B-channel
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_start(struct ifnet *ifp)
-{
-	struct i4bisppp_softc *sc = ifp->if_softc;
-	struct mbuf *m;
-	/* int s; */
-	int unit = IFP2UNIT(ifp);
-
-	if (sppp_isempty(ifp))
-		return;
-
-	if(sc->sc_state != ST_CONNECTED)
-		return;
-
-	/*
-	 * s = splimp();
-	 * ifp->if_drv_flags |= IFF_DRV_OACTIVE; // - need to clear this somewhere
-	 * splx(s);
-	 */
-
-	while ((m = sppp_dequeue(sc->sc_ifp)) != NULL)
-	{
-
-		BPF_MTAP(ifp, m);
-
-		microtime(&ifp->if_lastchange);
-
-		IF_LOCK(isdn_linktab[unit]->tx_queue);
-		if(_IF_QFULL(isdn_linktab[unit]->tx_queue))
-		{
-			NDBGL4(L4_ISPDBG, "isp%d, tx queue full!", unit);
-			m_freem(m);
-		}
-		else
-		{
-#if 0
-			sc->sc_ifp->if_obytes += m->m_pkthdr.len;
-#endif
-			sc->sc_outb += m->m_pkthdr.len;
-			sc->sc_ifp->if_opackets++;
-
-			_IF_ENQUEUE(isdn_linktab[unit]->tx_queue, m);
-		}
-		IF_UNLOCK(isdn_linktab[unit]->tx_queue);
-	}
-	isdn_linktab[unit]->bch_tx_start(isdn_linktab[unit]->unit,
-					 isdn_linktab[unit]->channel);
-}
-
-#ifdef I4BISPPPACCT
-/*---------------------------------------------------------------------------*
- *	watchdog routine
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_watchdog(struct ifnet *ifp)
-{
-	struct i4bisppp_softc *sc = ifp->if_softc;
-	int unit = IFP2UNIT(ifp);
-	bchan_statistics_t bs;
-	
-	(*isdn_linktab[unit]->bch_stat)
-		(isdn_linktab[unit]->unit, isdn_linktab[unit]->channel, &bs);
-
-	sc->sc_ioutb += bs.outbytes;
-	sc->sc_iinb += bs.inbytes;
-	
-	if((sc->sc_iinb != sc->sc_linb) || (sc->sc_ioutb != sc->sc_loutb) || sc->sc_fn)
-	{
-		int ri = (sc->sc_iinb - sc->sc_linb)/I4BISPPPACCTINTVL;
-		int ro = (sc->sc_ioutb - sc->sc_loutb)/I4BISPPPACCTINTVL;
-
-		if((sc->sc_iinb == sc->sc_linb) && (sc->sc_ioutb == sc->sc_loutb))
-			sc->sc_fn = 0;
-		else
-			sc->sc_fn = 1;
-			
-		sc->sc_linb = sc->sc_iinb;
-		sc->sc_loutb = sc->sc_ioutb;
-
-		i4b_l4_accounting(BDRV_ISPPP, unit, ACCT_DURING,
-			 sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_outb, sc->sc_inb);
- 	}
-	sc->sc_ifp->if_timer = I4BISPPPACCTINTVL; 	
-
-#if 0 /* old stuff, keep it around */
-	printf(ISPPP_FMT "transmit timeout\n", ISPPP_ARG(sc));
-	i4bisppp_start(ifp);
-#endif
-}
-#endif /* I4BISPPPACCT */
-
-/*
- *===========================================================================*
- *			SyncPPP layer interface routines
- *===========================================================================*
- */
-
-#if 0 /* never used ??? */
-/*---------------------------------------------------------------------------*
- *	just an alias for i4bisppp_tls, but of type timeout_t
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_timeout(void *cookie)
-{
-	i4bisppp_tls((struct sppp *)cookie);
-}
-#endif
-
-/*---------------------------------------------------------------------------*
- *	PPP this-layer-started action
- *---------------------------------------------------------------------------*
- */
-static void
-i4bisppp_tls(struct sppp *sp)
-{
-	struct ifnet *ifp = SP2IFP(sp);
-	struct i4bisppp_softc *sc = ifp->if_softc;
-
-	if(sc->sc_state == ST_CONNECTED)
-		return;
-
-	i4b_l4_dialout(BDRV_ISPPP, IFP2UNIT(ifp));
-}
-
-/*---------------------------------------------------------------------------*
- *	PPP this-layer-finished action
- *---------------------------------------------------------------------------*
- */
-static void
-i4bisppp_tlf(struct sppp *sp)
-{
-        struct ifnet *ifp = SP2IFP(sp);
-	struct i4bisppp_softc *sc = ifp->if_softc;
-/*	call_desc_t *cd = sc->sc_cdp;	*/
-	
-	if(sc->sc_state != ST_CONNECTED)
-		return;
-
-#if 0 /* never used ??? */
-	UNTIMEOUT(i4bisppp_timeout, (void *)sp, sc->sc_ch);
-#endif
-
-	i4b_l4_drvrdisc(BDRV_ISPPP, IFP2UNIT(ifp));
-}
-/*---------------------------------------------------------------------------*
- *	PPP interface phase change
- *---------------------------------------------------------------------------*
- */
-static void
-i4bisppp_state_changed(struct sppp *sp, int new_state)
-{
-	struct i4bisppp_softc *sc = SP2IFP(sp)->if_softc;
-	
-	i4b_l4_ifstate_changed(sc->sc_cdp, new_state);
-}
-
-/*---------------------------------------------------------------------------*
- *	PPP control protocol negotiation complete (run ip-up script now)
- *---------------------------------------------------------------------------*
- */
-static void
-i4bisppp_negotiation_complete(struct sppp *sp)
-{
-	struct i4bisppp_softc *sc = SP2IFP(sp)->if_softc;
-	
-	i4b_l4_negcomplete(sc->sc_cdp);
-}
-
-/*===========================================================================*
- *			ISDN INTERFACE ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from L4 handler at connect time
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_connect(int unit, void *cdp)
-{
-	struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
-	struct sppp *sp = IFP2SP(sc->sc_ifp);
-	int s = splimp();
-
-	sc->sc_cdp = (call_desc_t *)cdp;
-	sc->sc_state = ST_CONNECTED;
-
-#if I4BISPPPACCT
-	sc->sc_iinb = 0;
-	sc->sc_ioutb = 0;
-	sc->sc_inb = 0;
-	sc->sc_outb = 0;
-	sc->sc_linb = 0;
-	sc->sc_loutb = 0;
-	sc->sc_ifp->if_timer = I4BISPPPACCTINTVL;
-#endif
-	
-#if 0 /* never used ??? */
-	UNTIMEOUT(i4bisppp_timeout, (void *)sp, sc->sc_ch);
-#endif
-
-	sp->pp_up(sp);		/* tell PPP we are ready */
-
-	sp->pp_last_sent = sp->pp_last_recv = SECOND;
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from L4 handler at disconnect time
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_disconnect(int unit, void *cdp)
-{
-	call_desc_t *cd = (call_desc_t *)cdp;
-	struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
-	struct sppp *sp = IFP2SP(sc->sc_ifp);
-
-	int s = splimp();
-
-	/* new stuff to check that the active channel is being closed */
-	if (cd != sc->sc_cdp)
-	{
-		NDBGL4(L4_ISPDBG, "isp%d, channel%d not active!", unit, cd->channelid);
-		splx(s);
-		return;
-	}
-
-#if I4BISPPPACCT
-	sc->sc_ifp->if_timer = 0;
-#endif
-
-	i4b_l4_accounting(BDRV_ISPPP, unit, ACCT_FINAL,
-		 sc->sc_ioutb, sc->sc_iinb, 0, 0, sc->sc_outb, sc->sc_inb);
-	
-	if (sc->sc_state == ST_CONNECTED)
-	{
-#if 0 /* never used ??? */
-		UNTIMEOUT(i4bisppp_timeout, (void *)sp, sc->sc_ch);
-#endif
-		sc->sc_cdp = (call_desc_t *)0;	
-		/* do this here because pp_down calls i4bisppp_tlf */
-		sc->sc_state = ST_IDLE;
-		sp->pp_down(sp);	/* tell PPP we have hung up */
-	}
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is used to give a feedback from userland demon
- *	in case of dial problems
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_dialresponse(int unit, int status, cause_t cause)
-{
-	struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
-	struct sppp *sp = IFP2SP(sc->sc_ifp);
-
-	NDBGL4(L4_ISPDBG, "isp%d: status=%d, cause=%d", unit, status, cause);
-
-	if(status != DSTAT_NONE)
-	{
-		struct mbuf *m;
-		
-		NDBGL4(L4_ISPDBG, "isp%d: clearing queues", unit);
-
-		if(!(sppp_isempty(sc->sc_ifp)))
-		{
-			while((m = sppp_dequeue(sc->sc_ifp)) != NULL)
-				m_freem(m);
-		}
-
-		sc->sc_cdp = (call_desc_t *)0;	
-		/* do this here because pp_down calls i4bisppp_tlf */
-		sc->sc_state = ST_IDLE;
-
-		/*
-		 * Ahh, sppp doesn't like to get a down event when
-		 * dialing fails. So first tell it that we are up
-		 * (doesn't hurt us since sc_state != ST_CONNECTED)
-		 * and then go down.
-		 */
-		sp->pp_up(sp);
-		sp->pp_down(sp);
-	}
-}
-	
-/*---------------------------------------------------------------------------*
- *	interface up/down
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_updown(int unit, int updown)
-{
-	/* could probably do something useful here */
-}
-	
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when a new frame (mbuf) has been received and was put on
- *	the rx queue.
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_rx_data_rdy(int unit)
-{
-	struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
-	struct mbuf *m;
-	int s;
-	
-	if((m = *isdn_linktab[unit]->rx_mbuf) == NULL)
-		return;
-
-	m->m_pkthdr.rcvif = sc->sc_ifp;
-	m->m_pkthdr.len = m->m_len;
-
-	microtime(&sc->sc_ifp->if_lastchange);
-
-	sc->sc_ifp->if_ipackets++;
-#if 0
-	sc->sc_ifp->if_ibytes += m->m_pkthdr.len;
-#endif
-
-#if I4BISPPPACCT
-	sc->sc_inb += m->m_pkthdr.len;
-#endif
-	
-#ifdef I4BISPPPDEBUG
-	printf("i4bisppp_rx_data_ready: received packet!\n");
-#endif
-
-	BPF_MTAP(sc->sc_ifp, m);
-
-	s = splimp();
-
-	sppp_input(sc->sc_ifp, m);
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when the last frame has been sent out and there is no
- *	further frame (mbuf) in the tx queue.
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_tx_queue_empty(int unit)
-{
-	i4bisppp_start((&i4bisppp_softc[unit])->sc_ifp);	
-}
-
-/*---------------------------------------------------------------------------*
- *	THIS should be used instead of last_active_time to implement
- *	an activity timeout mechanism.
- *
- *	Sending back the time difference unneccessarily complicates the
- *	idletime checks in i4b_l4.c. Return the largest time instead.
- *	That way the code in i4b_l4.c needs only minimal changes.
- *---------------------------------------------------------------------------*/
-time_t
-i4bisppp_idletime(int unit)
-{
-	struct sppp *sp = IFP2SP((&i4bisppp_softc[unit])->sc_ifp);
-
-	return((sp->pp_last_recv < sp->pp_last_sent) ?
-			sp->pp_last_sent : sp->pp_last_recv);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	each time a packet is received or transmitted. It should
- *	be used to implement an activity timeout mechanism.
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_activity(int unit, int rxtx)
-{
-	i4bisppp_softc[unit].sc_cdp->last_active_time = SECOND;
-}
-
-/*---------------------------------------------------------------------------*
- *	return this drivers linktab address
- *---------------------------------------------------------------------------*/
-drvr_link_t *
-i4bisppp_ret_linktab(int unit)
-{
-	return(&i4bisppp_drvr_linktab[unit]);
-}
-
-/*---------------------------------------------------------------------------*
- *	setup the isdn_linktab for this driver
- *---------------------------------------------------------------------------*/
-void
-i4bisppp_set_linktab(int unit, isdn_link_t *ilt)
-{
-	isdn_linktab[unit] = ilt;
-}
-
-/*---------------------------------------------------------------------------*
- *	initialize this drivers linktab
- *---------------------------------------------------------------------------*/
-static void
-i4bisppp_init_linktab(int unit)
-{
-	i4bisppp_drvr_linktab[unit].unit = unit;
-	i4bisppp_drvr_linktab[unit].bch_rx_data_ready = i4bisppp_rx_data_rdy;
-	i4bisppp_drvr_linktab[unit].bch_tx_queue_empty = i4bisppp_tx_queue_empty;
-	i4bisppp_drvr_linktab[unit].bch_activity = i4bisppp_activity;
-	i4bisppp_drvr_linktab[unit].line_connected = i4bisppp_connect;
-	i4bisppp_drvr_linktab[unit].line_disconnected = i4bisppp_disconnect;
-	i4bisppp_drvr_linktab[unit].dial_response = i4bisppp_dialresponse;	
-	i4bisppp_drvr_linktab[unit].updown_ind = i4bisppp_updown;	
-}
-
-/*===========================================================================*/
--- sys/i4b/driver/i4b_ing.c
+++ /dev/null
@@ -1,854 +0,0 @@
-/*-
- * Copyright (c) 1999, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ing.c - isdn4bsd B-channel to netgraph driver
- *	-------------------------------------------------
- *	last edit-date: [Sat Mar  9 14:09:53 2002]
- *
- *---------------------------------------------------------------------------*/ 
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/driver/i4b_ing.c,v 1.24 2005/01/06 22:18:18 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <sys/malloc.h>
-
-#include <net/if.h>
-
-#include <netgraph/ng_message.h>
-#include <netgraph/ng_parse.h>
-#include <netgraph/netgraph.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-#define I4BINGACCT	1		/* enable accounting messages */
-#define	I4BINGACCTINTVL	2		/* accounting msg interval in secs */
-
-#define I4BINGMAXQLEN	50		/* max queue length */
-
-/* initialized by L4 */
-
-static drvr_link_t ing_drvr_linktab[NI4BING];
-static isdn_link_t *isdn_linktab[NI4BING];
-
-struct ing_softc {
-	int		sc_unit;	/* unit number			*/
-	int		sc_state;	/* state of the interface	*/
-	call_desc_t	*sc_cdp;	/* ptr to call descriptor	*/
-	int		sc_updown;	/* soft state of interface	*/
-	struct ifqueue  sc_fastq;	/* interactive traffic		*/
-	int		sc_dialresp;	/* dialresponse			*/
-	int		sc_lastdialresp;/* last dialresponse		*/
-	
-#if I4BINGACCT
-	struct callout_handle sc_callout;
-	int		sc_iinb;	/* isdn driver # of inbytes	*/
-	int		sc_ioutb;	/* isdn driver # of outbytes	*/
-	int		sc_inb;		/* # of bytes rx'd		*/
-	int		sc_outb;	/* # of bytes tx'd	 	*/
-	int		sc_linb;	/* last # of bytes rx'd		*/
-	int		sc_loutb;	/* last # of bytes tx'd 	*/
-	int		sc_fn;		/* flag, first null acct	*/
-#endif	
-
-	int		sc_inpkt;	/* incoming packets		*/
-	int		sc_outpkt;	/* outgoing packets		*/	
-
-	struct ifqueue  xmitq_hipri;    /* hi-priority transmit queue */
-	struct ifqueue  xmitq;	  /* transmit queue */
-		
-	node_p		node;		/* back pointer to node */
-	char		nodename[NG_NODESIZ]; /* store our node name */
-	hook_p  	debughook;
-	hook_p  	hook;	
-
-	u_int   	packets_in;	/* packets in from downstream */
-	u_int   	packets_out;	/* packets out towards downstream */
-	u_int32_t	flags;
-
-} ing_softc[NI4BING];
-
-enum ing_states {
-	ST_IDLE,			/* initialized, ready, idle	*/
-	ST_DIALING,			/* dialling out to remote	*/
-	ST_CONNECTED			/* connected to remote		*/
-};
-
-static void i4bingattach(void *);
-
-PSEUDO_SET(i4bingattach, i4b_ing);
-
-static void ing_init_linktab(int unit);
-static void ing_tx_queue_empty(int unit);
-
-/* ========= NETGRAPH ============= */
-
-#define NG_ING_NODE_TYPE	"i4bing"	/* node type name */
-#define NGM_ING_COOKIE		947513046	/* node type cookie */
-
-/* Hook names */
-#define NG_ING_HOOK_DEBUG	"debug"
-#define NG_ING_HOOK_RAW		"rawdata"
-
-/* Netgraph commands understood by this node type */
-enum {
-	NGM_ING_SET_FLAG = 1,
-	NGM_ING_GET_STATUS,
-};
-
-/* This structure is returned by the NGM_ING_GET_STATUS command */
-struct ngingstat {
-	u_int   packets_in;	/* packets in from downstream */
-	u_int   packets_out;	/* packets out towards downstream */
-};
-
-/*
- * This is used to define the 'parse type' for a struct ngingstat, which
- * is bascially a description of how to convert a binary struct ngingstat
- * to an ASCII string and back.  See ng_parse.h for more info.
- *
- * This needs to be kept in sync with the above structure definition
- */
-#define NG_ING_STATS_TYPE_INFO	{				\
-	  { "packets_in",	&ng_parse_int32_type	},	\
-	  { "packets_out",	&ng_parse_int32_type	},	\
-	  { NULL },						\
-}
-
-/*
- * This section contains the netgraph method declarations for the
- * sample node. These methods define the netgraph 'type'.
- */
-
-static ng_constructor_t	ng_ing_constructor;
-static ng_rcvmsg_t	ng_ing_rcvmsg;
-static ng_shutdown_t	ng_ing_shutdown;
-static ng_newhook_t	ng_ing_newhook;
-static ng_connect_t	ng_ing_connect;
-static ng_rcvdata_t	ng_ing_rcvdata;
-static ng_disconnect_t	ng_ing_disconnect;
-
-/* Parse type for struct ngingstat */
-static const struct
-	ng_parse_struct_field ng_ing_stat_type_fields[] =
-	NG_ING_STATS_TYPE_INFO;
-
-static const struct ng_parse_type ng_ing_stat_type = {
-	&ng_parse_struct_type,
-	&ng_ing_stat_type_fields
-};
-
-/* List of commands and how to convert arguments to/from ASCII */
-
-static const struct ng_cmdlist ng_ing_cmdlist[] = {
-	{
-		NGM_ING_COOKIE,
-		NGM_ING_GET_STATUS,
-		"getstatus",
-		NULL,
-		&ng_ing_stat_type,
-	},
-	{
-		NGM_ING_COOKIE,
-		NGM_ING_SET_FLAG,
-		"setflag",
-		&ng_parse_int32_type,
-		NULL
-	},
-	{ 0 }
-};
-
-/* Netgraph node type descriptor */
-static struct ng_type typestruct = {
-	.version =	NG_ABI_VERSION,
-	.name =		NG_ING_NODE_TYPE,
-	.constructor =	ng_ing_constructor,
-	.rcvmsg =	ng_ing_rcvmsg,
-	.shutdown =	ng_ing_shutdown,
-	.newhook =	ng_ing_newhook,
-	.connect =	ng_ing_connect,
-	.rcvdata =	ng_ing_rcvdata,
-	.disconnect =	ng_ing_disconnect,
-	.cmdlist =	ng_ing_cmdlist,
-};
-
-NETGRAPH_INIT_ORDERED(ing, &typestruct, SI_SUB_DRIVERS, SI_ORDER_ANY);
-
-/*===========================================================================*
- *			DEVICE DRIVER ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	interface attach routine at kernel boot time
- *---------------------------------------------------------------------------*/
-static void
-i4bingattach(void *dummy)
-{
-	struct ing_softc *sc = ing_softc;
-	int i;
-	int ret;
-
-	printf("i4bing: %d i4b NetGraph ISDN B-channel device(s) attached\n", NI4BING);
-	
-	for(i=0; i < NI4BING; sc++, i++)
-	{
-		sc->sc_unit = i;
-		
-		ing_init_linktab(i);
-
-		NDBGL4(L4_DIALST, "setting dial state to ST_IDLE");
-
-		sc->sc_state = ST_IDLE;
-		
-		sc->sc_fastq.ifq_maxlen = I4BINGMAXQLEN;
-		if(!mtx_initialized(&sc->sc_fastq.ifq_mtx))
-			mtx_init(&sc->sc_fastq.ifq_mtx, "i4b_ing_fastq", NULL, MTX_DEF);
-		
-#if I4BINGACCT
-		callout_handle_init(&sc->sc_callout);
-		sc->sc_iinb = 0;
-		sc->sc_ioutb = 0;
-		sc->sc_inb = 0;
-		sc->sc_outb = 0;
-		sc->sc_linb = 0;
-		sc->sc_loutb = 0;
-		sc->sc_fn = 1;
-#endif
-
-		sc->sc_inpkt = 0;
-		sc->sc_outpkt = 0;		
-
-		sc->sc_updown = SOFT_ENA;	/* soft enabled */
-
-		sc->sc_dialresp = DSTAT_NONE;	/* no response */
-		sc->sc_lastdialresp = DSTAT_NONE;
-		
-		/* setup a netgraph node */
-
-		if ((ret = ng_make_node_common(&typestruct, &sc->node)))
-		{
-			printf("ing: ng_make_node_common, ret = %d\n!", ret);
-		}
-
-		/* name the netgraph node */
-
-		sprintf(sc->nodename, "%s%d", NG_ING_NODE_TYPE, sc->sc_unit);
-		if((ret = ng_name_node(sc->node, sc->nodename)))
-		{
-			printf("ing: ng_name node, ret = %d\n!", ret);
-			NG_NODE_UNREF(sc->node);
-			break;
-		}
-
-		NG_NODE_SET_PRIVATE(sc->node, sc);
-
-		sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
-		sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
-		if(!mtx_initialized(&sc->xmitq.ifq_mtx))
-			mtx_init(&sc->xmitq.ifq_mtx, "i4b_ing_xmitq", NULL, MTX_DEF);
-		if(!mtx_initialized(&sc->xmitq_hipri.ifq_mtx))
-			mtx_init(&sc->xmitq_hipri.ifq_mtx, "i4b_ing_hipri", NULL, MTX_DEF);
-	}
-}
-
-#ifdef I4BINGACCT
-/*---------------------------------------------------------------------------*
- *	accounting timeout routine
- *---------------------------------------------------------------------------*/
-static void
-ing_timeout(struct ing_softc *sc)
-{
-	bchan_statistics_t bs;
-	int unit = sc->sc_unit;
-
-	/* get # of bytes in and out from the HSCX driver */ 
-	
-	(*isdn_linktab[unit]->bch_stat)
-		(isdn_linktab[unit]->unit, isdn_linktab[unit]->channel, &bs);
-
-	sc->sc_ioutb += bs.outbytes;
-	sc->sc_iinb += bs.inbytes;
-	
-	if((sc->sc_iinb != sc->sc_linb) || (sc->sc_ioutb != sc->sc_loutb) || sc->sc_fn) 
-	{
-		int ri = (sc->sc_iinb - sc->sc_linb)/I4BINGACCTINTVL;
-		int ro = (sc->sc_ioutb - sc->sc_loutb)/I4BINGACCTINTVL;
-
-		if((sc->sc_iinb == sc->sc_linb) && (sc->sc_ioutb == sc->sc_loutb))
-			sc->sc_fn = 0;
-		else
-			sc->sc_fn = 1;
-			
-		sc->sc_linb = sc->sc_iinb;
-		sc->sc_loutb = sc->sc_ioutb;
-
-		i4b_l4_accounting(BDRV_ING, unit, ACCT_DURING,
-			 sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_ioutb, sc->sc_iinb);
- 	}
-
-	sc->sc_callout = timeout((TIMEOUT_FUNC_T)ing_timeout,
-					(void *)sc, I4BINGACCTINTVL*hz);
-}
-#endif /* I4BINGACCT */
-
-#if 0
-/*---------------------------------------------------------------------------*
- *	clear the interface's send queues
- *---------------------------------------------------------------------------*/
-static void
-ingclearqueue(struct ifqueue *iq)
-{
-	int x;
-	
-	x = splimp();
-	IF_DRAIN(iq);
-	splx(x);
-}
-#endif
-
-/*===========================================================================*
- *			ISDN INTERFACE ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from L4 handler at connect time
- *---------------------------------------------------------------------------*/
-static void
-ing_connect(int unit, void *cdp)
-{
-	struct ing_softc *sc = &ing_softc[unit];
-	int s;
-
-	sc->sc_cdp = (call_desc_t *)cdp;
-
-	s = SPLI4B();
-
-	NDBGL4(L4_DIALST, "ing%d: setting dial state to ST_CONNECTED", unit);
-
-	sc->sc_dialresp = DSTAT_NONE;
-	sc->sc_lastdialresp = DSTAT_NONE;	
-	
-#if I4BINGACCT
-	sc->sc_iinb = 0;
-	sc->sc_ioutb = 0;
-	sc->sc_inb = 0;
-	sc->sc_outb = 0;
-	sc->sc_linb = 0;
-	sc->sc_loutb = 0;
-	sc->sc_callout = timeout((TIMEOUT_FUNC_T)ing_timeout,
-				(void *)sc, I4BINGACCTINTVL*hz);
-#endif
-
-	sc->sc_state = ST_CONNECTED;
-	
-	splx(s);
-}
-	
-/*---------------------------------------------------------------------------*
- *	this routine is called from L4 handler at disconnect time
- *---------------------------------------------------------------------------*/
-static void
-ing_disconnect(int unit, void *cdp)
-{
-	call_desc_t *cd = (call_desc_t *)cdp;
-	struct ing_softc *sc = &ing_softc[unit];
-
-	/* new stuff to check that the active channel is being closed */
-
-	if (cd != sc->sc_cdp)
-	{
-		NDBGL4(L4_INGDBG, "ing%d: channel %d not active",
-				cd->driver_unit, cd->channelid);
-		return;
-	}
-
-#if I4BINGACCT
-	untimeout((TIMEOUT_FUNC_T)ing_timeout,
-		(void *)sc, sc->sc_callout);
-#endif
-
-	i4b_l4_accounting(BDRV_ING, cd->driver_unit, ACCT_FINAL,
-		 sc->sc_ioutb, sc->sc_iinb, 0, 0, sc->sc_outb, sc->sc_inb);
-	
-	sc->sc_cdp = (call_desc_t *)0;	
-
-	NDBGL4(L4_DIALST, "setting dial state to ST_IDLE");
-
-	sc->sc_dialresp = DSTAT_NONE;
-	sc->sc_lastdialresp = DSTAT_NONE;	
-
-	sc->sc_state = ST_IDLE;
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is used to give a feedback from userland daemon
- *	in case of dial problems
- *---------------------------------------------------------------------------*/
-static void
-ing_dialresponse(int unit, int status, cause_t cause)
-{
-	struct ing_softc *sc = &ing_softc[unit];
-	sc->sc_dialresp = status;
-
-	NDBGL4(L4_INGDBG, "ing%d: last=%d, this=%d",
-		unit, sc->sc_lastdialresp, sc->sc_dialresp);
-
-	if(status != DSTAT_NONE)
-	{
-		NDBGL4(L4_INGDBG, "ing%d: clearing queues", unit);
-/*		ingclearqueues(sc); */
-	}
-}
-	
-/*---------------------------------------------------------------------------*
- *	interface soft up/down
- *---------------------------------------------------------------------------*/
-static void
-ing_updown(int unit, int updown)
-{
-	struct ing_softc *sc = &ing_softc[unit];
-	sc->sc_updown = updown;
-}
-	
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when a new frame (mbuf) has been received and was put on
- *	the rx queue. It is assumed that this routines runs at
- *	pri level splimp() ! Keep it short !
- *---------------------------------------------------------------------------*/
-static void
-ing_rx_data_rdy(int unit)
-{
-	register struct ing_softc *sc = &ing_softc[unit];
-	register struct mbuf *m;
-	int error;
-	
-	if((m = *isdn_linktab[unit]->rx_mbuf) == NULL)
-		return;
-
-#if I4BINGACCT
-	sc->sc_inb += m->m_pkthdr.len;
-#endif
-
-	m->m_pkthdr.rcvif = NULL;
-
-	sc->sc_inpkt++;
-	
-	NG_SEND_DATA_ONLY(error, sc->hook, m);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	when the last frame has been sent out and there is no
- *	further frame (mbuf) in the tx queue.
- *---------------------------------------------------------------------------*/
-static void
-ing_tx_queue_empty(int unit)
-{
-	register struct ing_softc *sc = &ing_softc[unit];
-	register struct mbuf *m;
-	int x = 0;
-
-	if(sc->sc_state != ST_CONNECTED)
-		return;
-		
-	for(;;)
-	{
-		IF_DEQUEUE(&sc->xmitq_hipri, m);
-
-		if(m == NULL)
-		{
-			IF_DEQUEUE(&sc->xmitq, m);
-			if(m == NULL)
-				break;
-		}
-	
-#if I4BINGACCT
-		sc->sc_outb += m->m_pkthdr.len;
-#endif
-
-		x = 1;
-
-		if(! IF_HANDOFF(isdn_linktab[unit]->tx_queue, m, NULL))
-		{
-			NDBGL4(L4_INGDBG, "ing%d: tx queue full!", unit);
-		}
-	}
-
-	if(x)
-		(*isdn_linktab[unit]->bch_tx_start)(isdn_linktab[unit]->unit, isdn_linktab[unit]->channel);
-}
-
-/*---------------------------------------------------------------------------*
- *	this routine is called from the HSCX interrupt handler
- *	each time a packet is received or transmitted. It should
- *	be used to implement an activity timeout mechanism.
- *---------------------------------------------------------------------------*/
-static void
-ing_activity(int unit, int rxtx)
-{
-	ing_softc[unit].sc_cdp->last_active_time = SECOND;
-}
-
-/*---------------------------------------------------------------------------*
- *	return this drivers linktab address
- *---------------------------------------------------------------------------*/
-drvr_link_t *
-ing_ret_linktab(int unit)
-{
-	return(&ing_drvr_linktab[unit]);
-}
-
-/*---------------------------------------------------------------------------*
- *	setup the isdn_linktab for this driver
- *---------------------------------------------------------------------------*/
-void
-ing_set_linktab(int unit, isdn_link_t *ilt)
-{
-	isdn_linktab[unit] = ilt;
-}
-
-/*---------------------------------------------------------------------------*
- *	initialize this drivers linktab
- *---------------------------------------------------------------------------*/
-static void
-ing_init_linktab(int unit)
-{
-	ing_drvr_linktab[unit].unit = unit;
-	ing_drvr_linktab[unit].bch_rx_data_ready = ing_rx_data_rdy;
-	ing_drvr_linktab[unit].bch_tx_queue_empty = ing_tx_queue_empty;
-	ing_drvr_linktab[unit].bch_activity = ing_activity;
-	ing_drvr_linktab[unit].line_connected = ing_connect;
-	ing_drvr_linktab[unit].line_disconnected = ing_disconnect;
-	ing_drvr_linktab[unit].dial_response = ing_dialresponse;
-	ing_drvr_linktab[unit].updown_ind = ing_updown;	
-}
-
-/*===========================================================================*
- *			NETGRAPH INTERFACE ROUTINES
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- * It is not possible or allowable to create a node of this type.
- * If the hardware exists, it will already have created it.
- *---------------------------------------------------------------------------*/
-static int
-ng_ing_constructor(node_p node)
-{
-	return(EINVAL);
-}
-
-/*---------------------------------------------------------------------------*
- * Give our ok for a hook to be added...
- * Add the hook's private info to the hook structure.
- *---------------------------------------------------------------------------*/
-static int
-ng_ing_newhook(node_p node, hook_p hook, const char *name)
-{
-	struct ing_softc *sc = NG_NODE_PRIVATE(node);
-
-	/*
-	 * check if it's our friend the debug hook
-	 */
-	if(strcmp(name, NG_ING_HOOK_DEBUG) == 0)
-	{
-		NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
-		sc->debughook = hook;
-		return (0);
-	}
-	/*
-	 * Check for raw mode hook.
-	 */
-	if(strcmp(name, NG_ING_HOOK_RAW) == 0)
-	{
-		NG_HOOK_SET_PRIVATE(hook, sc);
-		sc->hook = hook;
-		return (0);
-	}
-
-	return (EINVAL);
-}
-
-/*---------------------------------------------------------------------------*
- * Get a netgraph control message.
- * Check it is one we understand. If needed, send a response.
- * We could save the address for an async action later, but don't here.
- * Always free the message.
- * The response should be in a malloc'd region that the caller can 'free'.
- * A response is not required.
- *---------------------------------------------------------------------------*/
-static int
-ng_ing_rcvmsg(node_p node, item_p item, hook_p lasthook)
-{
-	struct ing_softc *sc = NG_NODE_PRIVATE(node);
-
-	struct ng_mesg *resp = NULL;
-	int error = 0;
-	struct ng_mesg *msg;
-
-	NGI_GET_MSG(item, msg);
-
-	if(msg->header.typecookie == NGM_GENERIC_COOKIE)
-	{
-		switch(msg->header.cmd)
-		{
-			case NGM_TEXT_STATUS:
-			{
-				char *arg;
-				char *p;
-				int pos = 0;
-
-				NG_MKRESPONSE(resp, msg, sizeof(struct ng_mesg) + NG_TEXTRESPONSE, M_NOWAIT);
-
-				if (resp == NULL)
-				{
-					error = ENOMEM;
-					break;
-				}
-				arg = (char *) resp->data;
-
-				switch(sc->sc_state)
-				{
-			    		case ST_IDLE:
-						p = "idle";
-						break;
-				    	case ST_DIALING:
-						p = "dialing";
-						break;
-				    	case ST_CONNECTED:
-						p = "connected";
-						break;
-				    	default:
-						p = "???";
-						break;
-			    	}
-
-				pos = sprintf(arg, "state = %s (%d)\n", p, sc->sc_state);
-#if I4BINGACCT
-				pos += sprintf(arg + pos, "%d bytes in, %d bytes out\n", sc->sc_inb, sc->sc_outb);
-#endif			    
-				pos += sprintf(arg + pos, "%d pkts in, %d pkts out\n", sc->sc_inpkt, sc->sc_outpkt);
-
-				resp->header.arglen = pos + 1;
-				break;
-			}
-
-			default:
-				error = EINVAL;
-				break;
-		}
-	}
-	else if(msg->header.typecookie == NGM_ING_COOKIE)
-	{
-		switch (msg->header.cmd)
-		{
-			case NGM_ING_GET_STATUS:
-			{
-				struct ngingstat *stats;
-
-				NG_MKRESPONSE(resp, msg, sizeof(*stats), M_NOWAIT);
-
-				if (!resp)
-				{
-					error = ENOMEM;
-					break;
-				}
-
-				stats = (struct ngingstat *) resp->data;
-				stats->packets_in = sc->packets_in;
-				stats->packets_out = sc->packets_out;
-				break;
-			}
-
-			case NGM_ING_SET_FLAG:
-				if (msg->header.arglen != sizeof(u_int32_t))
-				{
-					error = EINVAL;
-					break;
-				}
-				sc->flags = *((u_int32_t *) msg->data);
-				break;
-
-			default:
-				error = EINVAL;		/* unknown command */
-				break;
-		}
-	}
-	else
-	{
-		error = EINVAL;			/* unknown cookie type */
-	}
-
-	/* Take care of synchronous response, if any */
-	NG_RESPOND_MSG(error, node, item, resp);
-	/* Free the message and return */
-	NG_FREE_MSG(msg);
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- * get data from another node and transmit it out on a B-channel
- *---------------------------------------------------------------------------*/
-static int
-ng_ing_rcvdata(hook_p hook, item_p item)
-{
-	struct ing_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
-	struct ifqueue  *xmitq_p;
-	int s;
-	struct mbuf *m;
-	struct ng_tag_prio *ptag;
-	
-	NGI_GET_M(item, m);
-	NG_FREE_ITEM(item);
-
-	if(NG_HOOK_PRIVATE(hook) == NULL)
-	{
-		NG_FREE_M(m);
-		return(ENETDOWN);
-	}
-	
-	if(sc->sc_state == ST_IDLE || sc->sc_state == ST_DIALING)
-	{
-		i4b_l4_dialout(BDRV_ING, sc->sc_unit);
-		sc->sc_state = ST_DIALING;
-	}
-
-	sc->sc_outpkt++;
-	
-       /*
-	* Now queue the data for when it can be sent
-	*/
-	if ((ptag = (struct ng_tag_prio *)m_tag_locate(m, NGM_GENERIC_COOKIE,
-	    NG_TAG_PRIO, NULL)) != NULL && (ptag->priority > NG_PRIO_CUTOFF) )
-		xmitq_p = (&sc->xmitq_hipri);
-	else
-		xmitq_p = (&sc->xmitq);
-
-	s = splimp();
-
-	IF_LOCK(xmitq_p);
-	if (_IF_QFULL(xmitq_p))
-	{
-		_IF_DROP(xmitq_p);
-		IF_UNLOCK(xmitq_p);
-		splx(s);
-		NG_FREE_M(m);
-		return(ENOBUFS);
-	}
-
-	_IF_ENQUEUE(xmitq_p, m);
-	IF_UNLOCK(xmitq_p);
-
-	ing_tx_queue_empty(sc->sc_unit);
-
-	splx(s);
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- * Do local shutdown processing..
- * If we are a persistant device, we might refuse to go away, and
- * we'd only remove our links and reset ourself.
- *---------------------------------------------------------------------------*/
-static int
-ng_ing_shutdown(node_p node)
-{
-	struct ing_softc *sc = NG_NODE_PRIVATE(node);
-	int	ret;
-
-	NG_NODE_UNREF(node);
-
-	sc->packets_in = 0;		/* reset stats */
-	sc->packets_out = 0;
-
-	if ((ret = ng_make_node_common(&typestruct, &sc->node)))
-	{
-		printf("ing: ng_make_node_common, ret = %d\n!", ret);
-	}
-
-	/* name the netgraph node */
-	sprintf(sc->nodename, "%s%d", NG_ING_NODE_TYPE, sc->sc_unit);
-	if((ret = ng_name_node(sc->node, sc->nodename)))
-	{
-		printf("ing: ng_name node, ret = %d\n!", ret);
-		NG_NODE_UNREF(sc->node);
-		return (0);
-	}
-
-	NG_NODE_SET_PRIVATE(sc->node, sc);
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- * This is called once we've already connected a new hook to the other node.
- *---------------------------------------------------------------------------*/
-static int
-ng_ing_connect(hook_p hook)
-{
-	/* probably not at splnet, force outward queueing */
-	NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
-	return (0);
-}
-
-/*
- * Dook disconnection
- *
- * For this type, removal of the last link destroys the node
- */
-static int
-ng_ing_disconnect(hook_p hook)
-{
-	struct ing_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
-	int s;
-	
-	if(NG_HOOK_PRIVATE(hook))
-	{
-		s = splimp();
-		splx(s);
-	}
-	else
-	{
-		sc->debughook = NULL;
-	}
-	return (0);
-}
-
-/*===========================================================================*/
--- sys/i4b/include/i4b_mbuf.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b - mbuf handling support routines
- *	--------------------------------------
- *
- * $FreeBSD: src/sys/i4b/include/i4b_mbuf.h,v 1.9 2005/01/06 22:18:18 imp Exp $
- *
- *	last edit-date: [Sat Mar  9 15:58:11 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_MBUF_H_
-#define _I4B_MBUF_H_
-
-/* layer 1 / layer 2 comunication: 3rd ph_data_req parameter */
-#define MBUF_DONTFREE	0
-#define MBUF_FREE	1	
-
-#define IF_QEMPTY(ifq)	((ifq)->ifq_len == 0)
-
-struct mbuf *i4b_Dgetmbuf( int );
-void i4b_Dfreembuf( struct mbuf *m );
-void i4b_Dcleanifq( struct ifqueue * );
-
-struct mbuf *i4b_Bgetmbuf( int );
-void i4b_Bfreembuf( struct mbuf *m );
-void i4b_Bcleanifq( struct ifqueue * );
-
-#endif /* _I4B_MBUF_H_ */
-
-/* EOF */
--- sys/i4b/include/i4b_l3l4.h
+++ /dev/null
@@ -1,274 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l3l4.h - layer 3 / layer 4 interface
- *	------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/include/i4b_l3l4.h,v 1.14 2005/01/06 22:18:18 imp Exp $
- *
- *	last edit-date: [Sun Aug 11 12:52:41 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L3L4_H_
-#define _I4B_L3L4_H_
-
-#define T303VAL	(hz*4)			/* 4 seconds timeout		*/
-#define T305VAL	(hz*30)			/* 30 seconds timeout		*/
-#define T308VAL	(hz*4)			/* 4 seconds timeout		*/
-#define T309VAL	(hz*90)			/* 90 seconds timeout		*/
-#define T310VAL	(hz*60)			/* 30-120 seconds timeout	*/
-#define T313VAL	(hz*4)			/* 4 seconds timeout		*/
-#define T400DEF	(hz*10)			/* 10 seconds timeout		*/
-
-#define MAX_BCHAN 30
-#define N_CALL_DESC (MAX_CONTROLLERS*MAX_BCHAN)	/* no of call descriptors */
-
-extern int nctrl;		/* number of controllers detected in system */
-
-typedef struct bchan_statistics {
-	int outbytes;
-	int inbytes;
-} bchan_statistics_t;
-
-/*---------------------------------------------------------------------------*
- * table of things the driver needs to know about the b channel
- * it is connected to for data transfer
- *---------------------------------------------------------------------------*/
-typedef struct i4l_isdn_bchan_linktab {
-	int unit;
-	int channel;
-	void (*bch_config)(int unit, int channel, int bprot, int updown);
-	void (*bch_tx_start)(int unit, int channel);
-	void (*bch_stat)(int unit, int channel, bchan_statistics_t *bsp);	
-	struct ifqueue *tx_queue;
-	struct ifqueue *rx_queue;	/* data xfer for NON-HDLC traffic   */
-	struct mbuf **rx_mbuf;		/* data xfer for HDLC based traffic */
-} isdn_link_t;
-
-/*---------------------------------------------------------------------------*
- * table of things the b channel handler needs to know  about
- * the driver it is connected to for data transfer
- *---------------------------------------------------------------------------*/
-typedef struct i4l_driver_bchan_linktab {
-	int unit;
-	void (*bch_rx_data_ready)(int unit);
-	void (*bch_tx_queue_empty)(int unit);
-	void (*bch_activity)(int unit, int rxtx);
-#define ACT_RX 0
-#define ACT_TX 1
-	void (*line_connected)(int unit, void *cde);
-	void (*line_disconnected)(int unit, void *cde);
-	void (*dial_response)(int unit, int stat, cause_t cause);
-	void (*updown_ind)(int unit, int updown);		
-} drvr_link_t;
-
-/* global linktab functions for controller types (aka hardware drivers) */
-struct ctrl_type_desc {
-	isdn_link_t* (*get_linktab)(int unit, int channel);
-	void (*set_linktab)(int unit, int channel, drvr_link_t *dlt);
-};
-extern struct ctrl_type_desc ctrl_types[];
-
-/* global linktab functions for RBCH userland driver */
-
-drvr_link_t *rbch_ret_linktab(int unit);
-void rbch_set_linktab(int unit, isdn_link_t *ilt);
-
-/* global linktab functions for IPR network driver */
-
-drvr_link_t *ipr_ret_linktab(int unit);
-void ipr_set_linktab(int unit, isdn_link_t *ilt);
-
-/* global linktab functions for TEL userland driver */
-
-drvr_link_t *tel_ret_linktab(int unit);
-void tel_set_linktab(int unit, isdn_link_t *ilt);
-
-/* global linktab functions for ISPPP userland driver */
-
-drvr_link_t *i4bisppp_ret_linktab(int unit);
-void i4bisppp_set_linktab(int unit, isdn_link_t *ilt);
-
-/* global linktab functions for ING network driver */
-
-drvr_link_t *ing_ret_linktab(int unit);
-void ing_set_linktab(int unit, isdn_link_t *ilt);
-
-
-/*---------------------------------------------------------------------------*
- *	this structure describes one call/connection on one B-channel
- *	and all its parameters
- *---------------------------------------------------------------------------*/
-typedef struct
-{
-	u_int	cdid;			/* call descriptor id		*/
-	int	controller;		/* isdn controller number	*/
-	int	cr;			/* call reference value		*/
-
-	int	crflag;			/* call reference flag		*/
-#define CRF_ORIG	0		/* originating side		*/
-#define CRF_DEST	1		/* destinating side		*/
-
-	int	channelid;		/* channel id value		*/
-	int	channelexcl;		/* channel exclusive		*/
-
-	int	bprot;			/* B channel protocol BPROT_XXX */
-
-	int	bcap;			/* special bearer capabilities BCAP_XXX */	
-
-	int	driver;			/* driver to use for B channel	*/
-	int	driver_unit;		/* unit for above driver number	*/
-	
-	cause_t	cause_in;		/* cause value from NT	*/
-	cause_t	cause_out;		/* cause value to NT	*/
-
-	int	call_state;		/* from incoming SETUP	*/
-	
-	u_char	dst_telno[TELNO_MAX];	/* destination number	*/
-	u_char	dst_subaddr[SUBADDR_MAX];	/* destination subaddr	*/
-	u_char	src_telno[TELNO_MAX];	/* source number	*/
-	u_char	src_subaddr[SUBADDR_MAX];	/* source subaddr	*/
-
-	int	dst_ton;		/* destination type of number */
-	int	src_ton;		/* source type of number */
-
-	int	scr_ind;		/* screening ind for incoming call */
-	int	prs_ind;		/* presentation ind for incoming call */
-	
-	int	Q931state;		/* Q.931 state for call	*/
-	int	event;			/* event to be processed */
-
-	int	response;		/* setup response type	*/
-
-	int	T303;			/* SETUP sent response timeout	*/
-	int	T303_first_to;		/* first timeout flag		*/
-
-	int	T305;			/* DISC without PROG IND	*/
-
-	int	T308;			/* RELEASE sent response timeout*/
-	int	T308_first_to;		/* first timeout flag		*/
-
-	int	T309;			/* data link disconnect timeout	*/
-
-	int	T310;			/* CALL PROC received		*/
-
-	int	T313;			/* CONNECT sent timeout		*/ 
-
-	int	T400;			/* L4 timeout */
-
-	isdn_link_t	*ilt;		/* isdn B channel linktab	*/
-	drvr_link_t	*dlt;		/* driver linktab		*/
-
-	int	dir;			/* outgoing or incoming call	*/
-#define DIR_OUTGOING	0
-#define DIR_INCOMING	1
-
-	int	timeout_active;		/* idle timeout() active flag	*/
-
-	int	callouts_inited;	/* must init before use */
-	struct	callout_handle	idle_timeout_handle;
-	struct	callout_handle	T303_callout;
-	struct	callout_handle	T305_callout;
-	struct	callout_handle	T308_callout;
-	struct	callout_handle	T309_callout;
-	struct	callout_handle	T310_callout;
-	struct	callout_handle	T313_callout;
-	struct	callout_handle	T400_callout;
-
-	int	idletime_state;		/* wait for idle_time begin	*/
-#define IST_IDLE	0	/* shorthold mode disabled 	*/
-#define IST_NONCHK	1	/* in non-checked window	*/
-#define IST_CHECK	2	/* in idle check window		*/
-#define IST_SAFE	3	/* in safety zone		*/
-
-	time_t	idletimechk_start;	/* check idletime window start	*/
-	time_t	connect_time;		/* time connect was made	*/
-	time_t	last_active_time;	/* last time with activity	*/
-
-					/* for incoming connections:	*/
-	time_t	max_idle_time;		/* max time without activity	*/
-
-					/* for outgoing connections:	*/	
-	msg_shorthold_t shorthold_data;	/* shorthold data to use */
-
-	int	aocd_flag;		/* AOCD used for unitlength calc*/
-	time_t	last_aocd_time;		/* last time AOCD received	*/
-	int	units;			/* number of AOCD charging units*/
-	int	units_type;		/* units type: AOCD, AOCE	*/
-	int	cunits;			/* calculated units		*/
-
-	int	isdntxdelay;		/* isdn tx delay after connect	*/
-
-	u_char	display[DISPLAY_MAX];	/* display information element	*/
-	char	datetime[DATETIME_MAX];	/* date/time information element*/
-	u_char	keypad[KEYPAD_MAX];	/* keypad facility		*/	
-} call_desc_t;
-
-extern call_desc_t call_desc[N_CALL_DESC];
-
-/* forward decl. */
-struct isdn_diagnostic_request;
-struct isdn_dr_prot;
-
-/*---------------------------------------------------------------------------*
- *	this structure "describes" one controller
- *---------------------------------------------------------------------------*/
-typedef struct
-{
-	int	unit;			/* unit number of this contr.	*/
-	int	ctrl_type;		/* controller type   (CTRL_XXX)	*/
-	int	card_type;		/* card manufacturer (CARD_XXX) */
-
-	int	protocol;		/* D-channel protocol type */
-
-	int	dl_est;			/* layer 2 established	*/
-#define DL_DOWN	0
-#define DL_UP	1	
-
-        int     nbch;                   /* number of b channels */
-	int	bch_state[MAX_BCHAN];	/* states of the b channels */
-#define BCH_ST_FREE	0	/* free to be used, idle */
-#define BCH_ST_RSVD	1	/* reserved, may become free or used */
-#define BCH_ST_USED	2	/* in use for data transfer */
-
-	int	tei;			/* current tei or -1 if invalid */
-
-	/* pointers to functions to be called from L4 */
-	
-	void	(*N_CONNECT_REQUEST)	(unsigned int);	
-	void	(*N_CONNECT_RESPONSE)	(unsigned int, int, int);
-	void	(*N_DISCONNECT_REQUEST)	(unsigned int, int);
-	void	(*N_ALERT_REQUEST)	(unsigned int);	
-	int     (*N_DOWNLOAD)		(int unit, int numprotos, struct isdn_dr_prot *protocols);
-	int     (*N_DIAGNOSTICS)	(int unit, struct isdn_diagnostic_request*);
-	void	(*N_MGMT_COMMAND)	(int unit, int cmd, void *);
-} ctrl_desc_t;
-
-extern ctrl_desc_t ctrl_desc[MAX_CONTROLLERS];
-
-#endif /* _I4B_Q931_H_ */
--- sys/i4b/include/i4b_l2l3.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l2l3.h - i4b layer 2 / layer 3 interactions
- *	-----------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/include/i4b_l2l3.h,v 1.9 2005/01/06 22:18:18 imp Exp $
- *
- *	last edit-date: [Sat Mar  9 15:55:16 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L2L3_H_
-#define _I4B_L2L3_H_
-
-extern struct i4b_l2l3_func i4b_l2l3_func;
-
-struct i4b_l2l3_func
-{
-	/* Layer 2 --> Layer 3 */
-	/* =================== */
-
-	int	(*DL_ESTABLISH_IND) (int);
-	int	(*DL_ESTABLISH_CNF) (int);
-	
-	int	(*DL_RELEASE_IND) (int);
-	int	(*DL_RELEASE_CNF) (int);
-
-	int	(*DL_DATA_IND) (int, struct mbuf *);
-
-	int	(*DL_UNIT_DATA_IND) (int, struct mbuf *);	
-	
-#define DL_Est_Ind(unit)		\
-	((*i4b_l2l3_func.DL_ESTABLISH_IND)(unit))
-#define DL_Est_Cnf(unit)		\
-	((*i4b_l2l3_func.DL_ESTABLISH_CNF)(unit))
-#define DL_Rel_Ind(unit)		\
-	((*i4b_l2l3_func.DL_RELEASE_IND)(unit))
-#define DL_Rel_Cnf(unit)		\
-	((*i4b_l2l3_func.DL_RELEASE_CNF)(unit))
-#define DL_Data_Ind(unit, data)		\
-	((*i4b_l2l3_func.DL_DATA_IND)(unit, data))
-#define DL_Unit_Data_Ind(unit, data)	\
-	((*i4b_l2l3_func.DL_UNIT_DATA_IND)(unit, data))
-	
-#define DL_Est_Ind_A			\
-	(i4b_l2l3_func.DL_ESTABLISH_IND)
-#define DL_Est_Cnf_A			\
-	(i4b_l2l3_func.DL_ESTABLISH_CNF)
-#define DL_Rel_Ind_A			\
-	(i4b_l2l3_func.DL_RELEASE_IND)
-#define DL_Rel_Cnf_A			\
-	(i4b_l2l3_func.DL_RELEASE_CNF)
-	
-	/* Layer 3 --> Layer 2 */	
-	/* =================== */
-
-	int	(*DL_ESTABLISH_REQ) (int);
-	
-	int	(*DL_RELEASE_REQ) (int);
-
-	int	(*DL_DATA_REQ) (int, struct mbuf *);
-
-	int	(*DL_UNIT_DATA_REQ) (int, struct mbuf *);	
-	
-#define DL_Est_Req(unit)		\
-	((*i4b_l2l3_func.DL_ESTABLISH_REQ)(unit))
-#define DL_Rel_Req(unit)		\
-	((*i4b_l2l3_func.DL_RELEASE_REQ)(unit))
-#define DL_Data_Req(unit, data)		\
-	((*i4b_l2l3_func.DL_DATA_REQ)(unit, data))
-#define DL_Unit_Data_Req(unit, data)	\
-	((*i4b_l2l3_func.DL_UNIT_DATA_REQ)(unit, data))
-
-	/* Layer 2 --> Layer 3 management */
-	/* ============================== */
-
-	int	(*MDL_STATUS_IND) (int, int, int); 	/* L2 --> L3 status */
-	
-#define MDL_Status_Ind(unit, status, parm)		\
-	((*i4b_l2l3_func.MDL_STATUS_IND)(unit, status, parm))
-
-	/* Layer 3 --> Layer 2 management */
-	/* ============================== */
-
-	int	(*MDL_COMMAND_REQ) (int, int, void *);	/* L3 --> L2 command */
-
-#define MDL_Command_Req(unit, command, parm)		\
-	((*i4b_l2l3_func.MDL_COMMAND_REQ)(unit, command, parm))
-};
-
-#endif /* _I4B_L2L3_H_ */
--- sys/i4b/include/i4b_isdnq931.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_isdnq931.h - DSS1 layer 3 message types
- *	-------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/include/i4b_isdnq931.h,v 1.9 2005/01/06 22:18:18 imp Exp $
- *
- *	last edit-date: [Sat Mar  9 15:53:49 2002]
- *
- *---------------------------------------------------------------------------*/
-
-/* protocol discriminators */
-
-#define PD_Q931		0x08	/* Q.931/I.451				*/
-
-/* Q.931 single octett information element identifiers */
-
-#define IEI_SENDCOMPL	0xa1	/* sending complete			*/
-
-/* Q.931 variable length information element identifiers */
-
-#define IEI_SEGMMSG	0x00	/* segmented message			*/
-#define	IEI_BEARERCAP	0x04	/* bearer capabilities			*/
-#define	IEI_CAUSE	0x08	/* cause 				*/
-#define IEI_CALLID	0x10	/* call identity			*/
-#define IEI_CALLSTATE	0x14	/* call state				*/
-#define IEI_CHANNELID	0x18	/* channel identification 		*/
-#define IEI_PROGRESSI	0x1e	/* progress indicator			*/
-#define IEI_NETSPCFAC	0x20	/* network specific facilities		*/
-#define IEI_NOTIFIND	0x27	/* notification indicator		*/
-#define IEI_DISPLAY	0x28	/* display				*/
-#define IEI_DATETIME	0x29	/* date/time				*/
-#define IEI_KEYPAD	0x2c	/* keypad facility			*/
-#define IEI_SIGNAL	0x34	/* signal				*/
-#define IEI_INFRATE	0x40	/* information rate			*/
-#define IEI_ETETDEL	0x42	/* end to end transit delay		*/
-#define IEI_TDELSELIND	0x43	/* transit delay selection and indication */
-#define IEI_PLBPARMS	0x44	/* packet layer binary parameters	*/
-#define IEI_PLWSIZE	0x45	/* packet layer window size		*/
-#define IEI_PSIZE	0x46	/* packet size				*/
-#define IEI_CUG		0x47	/* closed user group			*/
-#define IEI_REVCHRGI	0x4a	/* reverse charge indication		*/
-#define IEI_CALLINGPN	0x6c	/* calling party number			*/
-#define IEI_CALLINGPS	0x6d	/* calling party subaddress		*/
-#define IEI_CALLEDPN	0x70	/* called party number			*/
-#define IEI_CALLEDPS	0x71	/* called party subaddress		*/
-#define IEI_REDIRNO	0x74	/* redirecting number			*/
-#define IEI_TRNSEL	0x78	/* transit network selection		*/
-#define IEI_RESTARTI	0x79	/* restart indicator			*/
-#define IEI_LLCOMPAT	0x7c	/* low layer compatibility		*/
-#define IEI_HLCOMPAT	0x7d	/* high layer compatibility		*/
-#define IEI_USERUSER	0x7e	/* user-user				*/
-#define IEI_ESCAPE	0x7f	/* escape for extension			*/
-
-/* Q.932 variable length information element identifiers */
-
-#define IEI_EXTFAC	0x0d	/* extended facility			*/
-#define IEI_FACILITY	0x1c	/* facility				*/
-#define IEI_INFOREQ	0x32	/* information request 			*/
-#define IEI_FEATACT	0x38	/* feature activation 			*/
-#define IEI_FEATIND	0x39	/* feature indication			*/
-#define IEI_SERVPID	0x3a	/* service profile identification	*/
-#define IEI_ENDPTID	0x3b	/* endpoint identifier			*/
-
-/* Q.933 variable length information element identifiers */
-
-#define IEI_DATALCID	0x19	/* data link connection identifier	*/
-#define IEI_LLCOREP	0x48	/* link layer core parameters		*/
-#define IEI_LLPROTP	0x49	/* link layer protocol parameters	*/
-#define IEI_X213PRI	0x50	/* X.213 priority 			*/
-#define IEI_REPORTT	0x51	/* report type				*/
-#define IEI_LNKITYVERF	0x53	/* link integrity verification		*/
-#define IEI_PVCSTAT	0x57	/* PVC status				*/
-
-/* Q.95x variable length information element identifiers */
-
-#define IEI_PRECLEV	0x41	/* precedence level			*/
-#define IEI_CONCTDNO	0x4c	/* connected number			*/
-#define IEI_CONCTDSA	0x4d	/* connected subaddress			*/
-#define IEI_REDICNNO	0x76	/* redirection number			*/
-
-/* single octett information elements */
-
-#define SOIE_SHIFT	0x90	/* shift codeset			*/
-#define	 SHIFT_LOCK	0x08	/* shift codeset, locking shift bit	*/
-#define SOIE_MDSC	0xa0	/* more data AND/OR sending complete	*/
-#define SOIE_SENDC	0xa1	/* sending complete			*/
-#define SOIE_CONGL	0xb0	/* congestion level			*/
-#define SOIE_REPTI	0xd0	/* repeat indicator			*/
-
-/* codesets */
-
-#define	CODESET_0	0	/* codeset 0, normal DSS1 codeset	*/
-
-/* Q.931/Q.932 message types (see Q.931 03/93 p10 and p311) */
-
-/* call establishment messages */
-
-#define ALERT			0x01
-#define CALL_PROCEEDING		0x02
-#define PROGRESS		0x03
-#define SETUP			0x05
-#define CONNECT			0x07
-#define SETUP_ACKNOWLEDGE	0x0d
-#define CONNECT_ACKNOWLEDGE	0x0f
-
-/* call information phase messages */
-
-#define USER_INFORMATION	0x20
-#define SUSPEND_REJECT		0x21
-#define RESUME_REJECT		0x22
-#define HOLD			0x24
-#define SUSPEND			0x25
-#define RESUME			0x26
-#define HOLD_ACKNOWLEDGE	0x28
-#define SUSPEND_ACKNOWLEDGE	0x2d
-#define RESUME_ACKNOWLEDGE	0x2e
-#define HOLD_REJECT		0x30
-#define RETRIEVE		0x31
-#define RETRIEVE_ACKNOWLEDGE	0x32
-#define RETRIEVE_REJECT		0x37
-
-/* call clearing */
-
-#define DISCONNECT		0x45
-#define RESTART			0x46
-#define RELEASE			0x4d
-#define RESTART_ACKNOWLEDGE	0x4e
-#define RELEASE_COMPLETE	0x5a
-
-/* misc messages */
-
-#define SEGMENT			0x60
-#define FACILITY		0x62
-#define REGISTER		0x64
-#define NOTIFY			0x6e
-#define STATUS_ENQUIRY		0x75
-#define CONGESTION_CONTROL	0x79
-#define INFORMATION		0x7b
-#define STATUS			0x7d
-
-/* EOF */
--- sys/i4b/include/i4b_global.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_global.h - i4b global include file
- *	--------------------------------------
- *
- * $FreeBSD: src/sys/i4b/include/i4b_global.h,v 1.13 2005/01/06 22:18:18 imp Exp $
- *
- *	last edit-date: [Sun Mar 17 09:55:26 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_GLOBAL_H_
-#define _I4B_GLOBAL_H_
-
-/*---------------------------------------------------------------------------*
- *	hiding OS differences in the kernel
- *---------------------------------------------------------------------------*/ 
-
-#if defined(__FreeBSD__) && __FreeBSD__ >= 5
-/*
- * Deprecated LKM interface.
- */
-#include <sys/module.h>
-#define	PSEUDO_SET(sym, name) \
-	static int name ## _modevent(module_t mod, int type, void *data) \
-	{ \
-		void (*initfunc)(void *) = (void (*)(void *))data; \
-		switch (type) { \
-		case MOD_LOAD: \
-			/* printf(#name " module load\n"); */ \
-			initfunc(NULL); \
-			break; \
-		case MOD_UNLOAD: \
-			printf(#name " module unload - not possible for this module type\n"); \
-			return EINVAL; \
-		default: \
-			return EOPNOTSUPP; \
-		} \
-		return 0; \
-	} \
-	static moduledata_t name ## _mod = { \
-		#name, \
-		name ## _modevent, \
-		(void *)sym \
-	}; \
-	DECLARE_MODULE(name, name ## _mod, SI_SUB_PSEUDO, SI_ORDER_ANY)
-#endif
-
-/*---------------*/
-/* time handling */
-/*---------------*/
-
-#include <sys/param.h>
-
-#define TIMEOUT_FUNC_T	timeout_t *
-#define SECOND		time_second
-#define MICROTIME(x)	getmicrotime(&(x))
-
-/*----------------*/
-/* timer handling */
-/*----------------*/
-
-#define START_TIMER(XHANDLE, XF, XSC, XTIME) XHANDLE = timeout((TIMEOUT_FUNC_T)XF, (void*)XSC, XTIME)
-#define	STOP_TIMER(XHANDLE, XF, XSC)	untimeout((TIMEOUT_FUNC_T)XF, (void*)XSC, XHANDLE)
-
-/*---------------------------------------------------------------------------*
- *	misc globally used things in the kernel
- *---------------------------------------------------------------------------*/ 
-
-/* timer states */
-
-#define TIMER_IDLE	1		/* a timer is running	*/
-#define TIMER_ACTIVE	2		/* a timer is idle	*/
-
-/* priority */
-#define I4BPRI		(PSOCK + 1)
-
-/* i4b's spl */
-
-#define	SPLI4B()	splimp()	/* spl for i4b		*/
-
-/* critial code region handling macros */
-
-#define CRIT_VAR	int _svd_spl_	/* declare variable	*/
-#define CRIT_BEG	_svd_spl_ = SPLI4B()	/* save spl	*/
-#define CRIT_END	splx(_svd_spl_)	/* restore spl		*/
-
-/* definitions for the STATUS indications L1 -> L2 -> L3 */
-
-#define	STI_ATTACH	0	/* attach at boot time			*/
-#define	STI_L1STAT	1	/* layer 1 status			*/
-#define	STI_L2STAT	2	/* layer 2 status			*/
-#define	STI_TEIASG	3	/* TEI assignments			*/
-#define	STI_PDEACT	4	/* Layer 1 T4 expired = persistent deactivation */
-#define STI_NOL1ACC	5	/* no outgoing L1 access possible	*/
-
-/* definitions for the COMMAND requests L3 -> L2 -> L1 */
-
-#define CMR_DOPEN	0	/* daemon opened /dev/i4b		*/
-#define CMR_DCLOSE	1	/* daemon closed /dev/i4b		*/
-#define CMR_SETTRACE	2	/* set D-channel and B-channel trace	*/
-#define CMR_GCST	3	/* get chipset statistics		*/
-#define CMR_CCST	4	/* clear chipset statistics		*/
-
-#endif /* _I4B_GLOBAL_H_ */
--- sys/i4b/include/i4b_l1l2.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l1l2.h - i4b layer 1 / layer 2 interactions
- *	---------------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/include/i4b_l1l2.h,v 1.9 2005/01/06 22:18:18 imp Exp $
- *
- *	last edit-date: [Sat Mar  9 15:54:49 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L1L2_H_
-#define _I4B_L1L2_H_
-
-#include <machine/i4b_trace.h>
-
-extern struct i4b_l1l2_func i4b_l1l2_func;
-
-struct i4b_l1l2_func
-{
-	/* Layer 1 --> Layer 2 */
-	/* =================== */
-
-	int	(*PH_DATA_IND) (int, struct mbuf *);
-	int	(*PH_ACTIVATE_IND) (int);
-	int	(*PH_DEACTIVATE_IND) (int);
-
-#define PH_Data_Ind(unit, data)		\
-	((*i4b_l1l2_func.PH_DATA_IND)(unit, data))
-#define PH_Act_Ind(unit)		\
-	((*i4b_l1l2_func.PH_ACTIVATE_IND)(unit))
-#define PH_Deact_Ind(unit)		\
-	((*i4b_l1l2_func.PH_DEACTIVATE_IND)(unit))
-
-
-	/* Layer 2 --> Layer 1 */	
-	/* =================== */
-	
-	int	(*PH_DATA_REQ) (int, struct mbuf *, int);
-	int	(*PH_ACTIVATE_REQ) (int);
-
-#define PH_Data_Req(unit, data, freeflag)	\
-	((*i4b_l1l2_func.PH_DATA_REQ)(unit, data, freeflag))
-#define PH_Act_Req(unit)			\
-	((*i4b_l1l2_func.PH_ACTIVATE_REQ)(unit))
-
-	/* Layer 1 --> upstream, ISDN trace data */
-	/* ===================================== */
-	int	(*MPH_TRACE_IND) (i4b_trace_hdr_t *, int, unsigned char *);
-
-#define MPH_Trace_Ind(header, length, pointer)	\
-	((*i4b_l1l2_func.MPH_TRACE_IND)(header, length, pointer))
-
-	/* L1/L2 management command and status information */
-	/* =============================================== */
-	int	(*MPH_STATUS_IND) (int, int, int);
-	int	(*MPH_COMMAND_REQ) (int, int, void *);
-
-#define MPH_Status_Ind(unit, status, parm)	\
-	((*i4b_l1l2_func.MPH_STATUS_IND)(unit, status, parm))
-#define MPH_Command_Req(unit, command, parm)	\
-	((*i4b_l1l2_func.MPH_COMMAND_REQ)(unit, command, parm))
-};
-	
-#endif /* _I4B_L1L2_H_ */
--- sys/i4b/layer1/i4b_l1lib.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * Copyright (c) 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l1lib.c - general useful L1 procedures
- *	------------------------------------------
- *	$Id: i4b_l1lib.c,v 1.3 2000/05/29 15:41:41 hm Exp $
- *      last edit-date: [Mon May 29 15:24:21 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/i4b_l1lib.c,v 1.5 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#define TEL_IDLE_MIN (BCH_MAX_DATALEN/2)
-
-/*---------------------------------------------------------------------------*
- *	telephony silence detection
- *---------------------------------------------------------------------------*/
-int
-i4b_l1_bchan_tel_silence(unsigned char *data, int len)
-{
-	register int i = 0;
-	register int j = 0;
-
-	/* count idle bytes */
-	
-	for(;i < len; i++)
-	{
-		if((*data >= 0xaa) && (*data <= 0xac))
-			j++;
-		data++;
-	}
-
-#ifdef NOTDEF
-	printf("i4b_l1_bchan_tel_silence: got %d silence bytes in frame\n", j);
-#endif
-	
-	if(j < (TEL_IDLE_MIN))
-		return(0);
-	else
-		return(1);
-
-}
--- sys/i4b/layer1/i4b_l1.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------*
- *
- *	i4b_l1.h - isdn4bsd layer 1 header file
- *	---------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/i4b_l1.h,v 1.14 2005/01/06 22:18:19 imp Exp $
- *
- *      last edit-date: [Tue Jan 23 17:04:57 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L1_H_
-#define _I4B_L1_H_
-
-#include <i4b/include/i4b_l3l4.h>
-
-#define SEC_DELAY		1000000	/* one second DELAY for DELAY*/
-
-#define MAX_DFRAME_LEN		264	/* max length of a D frame */
-
-#define min(a,b)		((a)<(b)?(a):(b))
-
-/* L1DRVR_XXXX moved to i4b_ioctl.h */
-
-#define L0DRVR(du) (((du) >> 8) & 0xff)
-#define L0UNIT(du) ((du) & 0xff)
-
-#define L0DRVRUNIT(d, u) ( (((d) << 8) & 0xff00) | ((u) & 0xff))
-
-#define L0ISICUNIT(u) ( (((L1DRVR_ISIC) << 8) & 0xff00) | ((u) & 0xff))
-#define L0IWICUNIT(u) ( (((L1DRVR_IWIC) << 8) & 0xff00) | ((u) & 0xff))
-#define L0IFPIUNIT(u) ( (((L1DRVR_IFPI) << 8) & 0xff00) | ((u) & 0xff))
-#define L0IHFCUNIT(u) ( (((L1DRVR_IHFC) << 8) & 0xff00) | ((u) & 0xff))
-#define L0IFPNPUNIT(u) ( (((L1DRVR_IFPNP) << 8) & 0xff00) | ((u) & 0xff))
-#define L0ICCHPUNIT(u) ( (((L1DRVR_ICCHP) << 8) & 0xff00) | ((u) & 0xff))
-#define L0ITJCUNIT(u) ( (((L1DRVR_ITJC) << 8) & 0xff00) | ((u) & 0xff))
-#define L0IFPI2UNIT(u) ( (((L1DRVR_IFPI2) << 8) & 0xff00) | ((u) & 0xff))
-
-/* jump table for the multiplex functions */
-struct i4b_l1mux_func {
-	isdn_link_t * (*ret_linktab)(int, int);
-	void (*set_linktab)(int, int, drvr_link_t *);
-	int (*mph_command_req)(int, int, void *);
-	int (*ph_data_req)(int, struct mbuf *, int);
-	int (*ph_activate_req)(int);
-};
-
-int i4b_l1_ph_data_ind(int unit, struct mbuf *m);
-int i4b_l1_ph_activate_ind(int unit);
-int i4b_l1_ph_deactivate_ind(int unit);
-int i4b_l1_mph_status_ind(int, int, int, struct i4b_l1mux_func *);
-
-isdn_link_t *i4b_l1_ret_linktab(int unit, int channel);
-void i4b_l1_set_linktab(int unit, int channel, drvr_link_t *dlt);
-
-int i4b_l1_trace_ind(i4b_trace_hdr_t *, int, u_char *);
-
-/* i4b_l1lib.c */
-
-int i4b_l1_bchan_tel_silence(unsigned char *data, int len);
-
-#endif /* _I4B_L1_H_ */
--- sys/i4b/layer1/i4b_hdlc.h
+++ /dev/null
@@ -1,300 +0,0 @@
-/*-
- * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_hdlc.h - software-HDLC header file
- *	--------------------------------------
- *
- *	$Id: i4b_hdlc.h,v 1.5 2000/08/28 07:41:19 hm Exp $
- *
- * $FreeBSD: src/sys/i4b/layer1/i4b_hdlc.h,v 1.6 2005/01/06 22:18:19 imp Exp $
- *
- *	last edit-date: [Wed Jul 19 09:41:13 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_HDLC_H_
-#define _I4B_HDLC_H_
-
-extern const u_short HDLC_FCS_TAB[256];
-extern const u_short HDLC_BIT_TAB[256];
-
-/*---------------------------------------------------------------------------*
- *	HDLC_DECODE
- *	===========
- *
- *	u_char:  flag, blevel
- *	u_short: crc, ib, tmp, tmp2, len
- *
- *	next: 'continue' or 'goto xxx'
- *
- *	cfr: complete frame
- *	nfr: new frame
- *	     NOTE: must setup 'len' and 'dst', so that 'dst' may be written
- *		   at most 'len' times.
- *
- *	rab: abort
- *	rdd: read data (read byte is stored in 'tmp2')
- *	rdo: overflow
- *
- *	d: dummy
- *
- *	NOTE: setting flag to '0' and len to '0' => recover from rdu
- *	NOTE: bits[8 .. ] of tmp2 may be used to store custom data/flags
- *	NOTE: these variables have to be 'suspended' / 'resumed' somehow:
- *		flag, blevel, crc, ib, tmp, len
- *	NOTE: zero is default value for all variables.
- *	NOTE: each time 'dst' is written, 'len' is decreased by one.
- *---------------------------------------------------------------------------*/
-
-#define HDLC_DECODE(dst, len, tmp, tmp2, blevel, ib, crc, flag,	rddcmd, nfrcmd,	\
-		 cfrcmd, rabcmd, rdocmd, nextcmd, d) 				\
-										\
-	rddcmd;									\
-										\
-	ib  += HDLC_BIT_TAB[(u_char)tmp2];					\
-										\
-	if ((u_char)ib >= 5)							\
-	{									\
-		if (ib & 0x20)		/* de-stuff (msb) */			\
-		{								\
-			if ((u_char)tmp2 == 0x7e) goto j0##d;			\
-			tmp2 += tmp2 & 0x7f;					\
-			blevel--;						\
-										\
-			if ((ib += 0x100) & 0xc) tmp2 |= 1; /* */		\
-		}								\
-										\
-		ib &= ~0xe0;							\
-										\
-		if ((u_char)ib == 6)	/* flag seq (lsb) */			\
-		{								\
-		 j0##d:	if (flag >= 2)						\
-			{							\
-				len += (4 - flag) & 3;	/* remove CRC bytes */	\
-				crc ^= 0xf0b8;					\
-				cfrcmd;						\
-				len = 0;					\
-			}							\
-										\
-			flag   = 1;						\
-										\
-			blevel = (ib >> 8) & 0xf;				\
-			tmp    = ((u_char)tmp2) >> blevel;			\
-			blevel = 8 - blevel;					\
-										\
-			ib >>= 12;						\
-										\
-			nextcmd;						\
-		}								\
-		if ((u_char)ib >= 7)	/* abort (msb & lsb) */			\
-		{								\
-			if (flag >= 2)						\
-			{							\
-				rabcmd;						\
-				len = 0;					\
-			}							\
-										\
-			flag = 0;						\
-										\
-			ib >>= 12;						\
-										\
-			nextcmd;						\
-		}								\
-		if ((u_char)ib == 5)	/* de-stuff (lsb) */			\
-		{								\
-			tmp2 = (tmp2 | (tmp2 + 1)) & ~0x1;			\
-			blevel--;						\
-		}								\
-		if (blevel > 7)		/* EO - bits */				\
-		{								\
-			tmp |= (u_char)tmp2 >> (8 - (blevel &= 7));		\
-										\
-			ib >>= 12;						\
-										\
-			nextcmd;						\
-		}								\
-	}									\
-										\
-	tmp |= (u_char)tmp2 << blevel;						\
-										\
-	if (!len--)								\
-	{									\
-		len++;								\
-										\
-		if (!flag++) { flag--; goto j5##d;} /* hunt mode */		\
-										\
-		switch (flag)							\
-		{   case 2: 		/* new frame */				\
-			nfrcmd;							\
-			crc = -1;						\
-			if (!len--) { len++; flag++; goto j4##d; }		\
-			goto j3##d;						\
-		    case 3:		/* CRC (lsb's) */			\
-		    case 4:		/* CRC (msb's) */			\
-			goto j4##d;						\
-		    case 5:		/* RDO */				\
-			rdocmd;							\
-			flag = 0;						\
-			break;							\
-		}								\
-	}									\
-	else									\
-	{ 									\
-	 j3##d:	dst = (u_char)tmp;						\
-	 j4##d: crc = (HDLC_FCS_TAB[(u_char)(tmp ^ crc)] ^ (u_char)(crc >> 8));	\
-	}									\
-										\
- j5##d:	ib >>= 12;								\
-	tmp >>= 8;								\
-
-/*------ end of HDLC_DECODE -------------------------------------------------*/
-
-
-/*---------------------------------------------------------------------------*
- *	HDLC_ENCODE
- *	===========
- *
- *	u_char:  flag, src
- *	u_short: tmp2, blevel, ib, crc, len
- *	u_int:   tmp
- *
- *	gfr: This is the place where you free the last [mbuf] chain, and get
- *	     the next one. If a mbuf is available the code should setup 'len'
- *	     and 'src' so that 'src' may be read 'len' times. If no mbuf is
- *	     available leave 'len' and 'src' untouched.
- *
- *	wrd: write data (output = (u_char)tmp)
- *
- *	d: dummy
- *
- *	NOTE: setting flag to '-2' and len to '0' => abort bytes will be sent
- *	NOTE: these variables have to be 'suspended' / 'resumed' somehow:
- *		flag, blevel, crc, ib, tmp, len
- *	NOTE: zero is default value for all variables.
- *	NOTE: each time 'src' is read, 'len' is decreased by one.
- *	NOTE: neither cmd's should exit through 'goto' or 'break' statements.
- *---------------------------------------------------------------------------*/
-
-#define HDLC_ENCODE(src, len, tmp, tmp2, blevel, ib, crc, flag, gfrcmd, wrdcmd, d) \
-										\
-	if (blevel >= 0x800) { blevel -= 0x800; goto j4##d; }			\
-										\
-	if (!len--)								\
-	{									\
-		len++;								\
-										\
-		switch(++flag)							\
-		{ default:			/* abort */			\
-			tmp  = blevel = 0;	/* zero is default */		\
-			tmp2 = 0xff;						\
-			goto j3##d;						\
-		  case 1:			/* 1st time FS */		\
-		  case 2:			/* 2nd time FS */		\
-			tmp2 = 0x7e;						\
-			goto j3##d;						\
-		  case 3:							\
-			gfrcmd;			/* get new frame */		\
-			if (!len--)						\
-			{							\
-				len++;						\
-				flag--;		/* don't proceed */		\
-				tmp2 = 0x7e;					\
-				goto j3##d;	/* final FS */			\
-			}							\
-			else							\
-			{							\
-				crc = -1;					\
-				ib  = 0;					\
-				goto j1##d; 	/* first byte */		\
-			}							\
-		  case 4:							\
-			crc ^= -1;						\
-			tmp2 = (u_char)crc;					\
-			goto j2##d;		/* CRC (lsb's) */		\
-		  case 5:							\
-			tmp2  = (u_char)(crc >> 8);				\
-			flag  = 1;						\
-			goto j2##d;		/* CRC (msb's) */		\
-		}								\
-	}									\
- 	else									\
-  	{ j1##d	:								\
-		tmp2 = (u_char)src;						\
-		crc =(HDLC_FCS_TAB[(u_char)(crc ^ tmp2)] ^ (u_char)(crc >> 8));	\
-	  j2##d:								\
-										\
-		ib >>= 12;							\
-		ib  += HDLC_BIT_TAB[(u_char)tmp2];				\
-										\
-		if ((u_char)ib >= 5)	/* stuffing */				\
-		{								\
-			blevel &= ~0xff;					\
-										\
-			if (ib & 0xc0)		/* bit stuff (msb) */		\
-			{							\
-				tmp2 += tmp2 & (0xff * (ib & 0xc0));		\
-				ib %= 0x5000;					\
-				blevel++;					\
-			}							\
-										\
-			ib &= ~0xf0;						\
-										\
-			if ((u_char)ib >= 5)	/* bit stuff (lsb) */		\
-			{							\
-				tmp2 += tmp2 & ~0x1f >> ((ib - (ib >> 8) + 1)	\
-								& 7);		\
-				blevel++;					\
-										\
-				if ((u_char)ib >= 10)	/* bit stuff (msb) */	\
-				{						\
-					tmp2 += tmp2 & ~0x7ff >> ((ib - 	\
-							(ib >> 8) + 1) & 7);	\
-					blevel++;				\
-				}						\
-				if (ib & 0x8000)	/* bit walk */		\
-				{						\
-					ib = ((u_char)ib % 5) << 12;		\
-				}						\
-			}							\
-										\
-			tmp    |= tmp2 << (u_char)(blevel >> 8);		\
-			blevel += (u_char)blevel << 8;				\
-		}								\
-		else		/* no stuffing */				\
-		{								\
-		  j3##d:tmp    |= tmp2 << (u_char)(blevel >> 8);		\
-		}								\
-	}									\
-										\
- j4##d:	wrdcmd;									\
-	tmp >>= 8;								\
-
-/*------ end of HDLC_ENCODE -------------------------------------------------*/
-
-
-#endif /* _I4B_HDLC_H_ */
-
--- sys/i4b/layer1/i4b_l1dmux.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l1dmux.c - isdn4bsd layer 1 driver multiplexer
- *	--------------------------------------------------
- *      last edit-date: [Wed Jan 10 16:43:24 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/i4b_l1dmux.c,v 1.8 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_l1l2.h>
-#include <i4b/include/i4b_global.h>
-
-/*
- * this code is nothing but a big dynamic switch to multiplex and demultiplex
- * layer 1 hardware isdn drivers to a common layer 2.
- *
- * when a card is successfully attached at system boot time, the driver for
- * this card calls the routine i4b_l1_mph_status_ind() with status = STI_ATTACH.
- *
- * This command is used to setup the tables for converting a "driver unit" and
- * "driver type" pair (encoded in the calls from the hardware driver to the
- * routines in this source file) to a "unit number" used in layer 2 and the
- * layers above (up to and including the isdnd daemon) and for converting
- * layer 2 units back to calling the appropriate driver and driver unit
- * number.
- *
- * Example: in my setup, a Winbond (iwic) card is probed first and gets
- * driver unit number 0, driver type 1 in layer 1. This becomes unit
- * number 0 in layer 2 and up. The second card probed is a Teles card
- * (isic) and gets driver unit number 0, driver type 0 in layer 1. This
- * becomes unit number 1 in layer 1 and up.
- *
- * To add support for a new driver, add a new driver number to i4b_l1.h:
- * currently we have L1DRVR_ISIC and L1DRVR_IWIC, so you would add
- * L1DRVR_FOO. More you would want to add a L0FOOUNIT to encode unit
- * numbers in your driver. You then have to add a l1foounittab[] and
- * add an entry to the getl1tab() routine for your driver. The only
- * thing left now is to write your driver with the support functions
- * for this multiplexer ;-)
- */
- 
-unsigned int i4b_l1_debug = L1_DEBUG_DEFAULT;
-
-static int l1isicunittab[MAXL1UNITS];
-
-static int l1iwicunittab[MAXL1UNITS];
-
-static int l1ifpiunittab[MAXL1UNITS];
-
-static int l1ifpi2unittab[MAXL1UNITS];
-
-static int l1ihfcunittab[MAXL1UNITS];
-
-static int l1ifpnpunittab[MAXL1UNITS];
-
-static int l1itjcunittab[MAXL1UNITS];
-
-static int numl1units = 0;
-
-static int l1drvunittab[MAXL1UNITS];
-static struct i4b_l1mux_func *l1mux_func[MAXL1DRVR];
-
-static int i4b_l1_ph_data_req(int, struct mbuf *, int);
-static int i4b_l1_ph_activate_req(int);
-
-/* from i4btrc driver i4b_trace.c */
-int get_trace_data_from_l1(int unit, int what, int len, char *buf);
-
-/* from layer 2 */
-int i4b_ph_data_ind(int unit, struct mbuf *m);
-int i4b_ph_activate_ind(int unit);
-int i4b_ph_deactivate_ind(int unit);
-int i4b_mph_status_ind(int, int, int);
-
-/* layer 1 lme */
-int i4b_l1_mph_command_req(int, int, void *);
-
-/*---------------------------------------------------------------------------*
- *	jump table: interface function pointers L1/L2 interface 
- *---------------------------------------------------------------------------*/
-struct i4b_l1l2_func i4b_l1l2_func = {
-
-	/* Layer 1 --> Layer 2 */
-	
-	(int (*)(int, struct mbuf *))		i4b_ph_data_ind,
-	(int (*)(int)) 				i4b_ph_activate_ind,
-	(int (*)(int))				i4b_ph_deactivate_ind,
-
-	/* Layer 2 --> Layer 1 */
-
-	(int (*)(int, struct mbuf *, int))	i4b_l1_ph_data_req,
-
-	(int (*)(int))				i4b_l1_ph_activate_req,
-
-	/* Layer 1 --> trace interface driver, ISDN trace data */
-
-	(int (*)(i4b_trace_hdr_t *, int, u_char *)) get_trace_data_from_l1,
-
-	/* Driver control and status information */
-
-	(int (*)(int, int, int))		i4b_mph_status_ind,
-	(int (*)(int, int, void *))		i4b_l1_mph_command_req,
-};
-
-/*---------------------------------------------------------------------------*
- *	return a pointer to a layer 0 drivers unit tab
- *---------------------------------------------------------------------------*/
-static __inline int *
-getl1tab(int drv)
-{
-	switch(drv)
-	{
-		case L1DRVR_ISIC:
-			return(l1isicunittab);
-			break;
-		case L1DRVR_IWIC:
-			return(l1iwicunittab);
-			break;
-		case L1DRVR_IFPI:
-			return(l1ifpiunittab);
-			break;
-		case L1DRVR_IFPI2:
-			return(l1ifpi2unittab);
-			break;
-		case L1DRVR_IHFC:
-			return(l1ihfcunittab);
-			break;
-		case L1DRVR_IFPNP:
-			return(l1ifpnpunittab);
-			break;
-		case L1DRVR_ITJC:
-			return(l1itjcunittab);
-			break;
-		default:
-			return(NULL);
-			break;
-	}
-}
-
-/*===========================================================================*
- *	B - Channel (data transfer)
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	return the address of ISDN drivers linktab	
- *---------------------------------------------------------------------------*/
-isdn_link_t *
-i4b_l1_ret_linktab(int unit, int channel)
-{
-	int drv_unit, ch_unit;
- 
-	drv_unit = L0DRVR(l1drvunittab[unit]);
-	ch_unit = L0UNIT(l1drvunittab[unit]);
- 
-	NDBGL1(L1_PRIM, "unit %d -> drv %d / drvunit %d", unit, drv_unit, ch_unit);
-
-	if (drv_unit >= MAXL1DRVR || l1mux_func[drv_unit] == NULL
-	    || l1mux_func[drv_unit]->ret_linktab == NULL)
-		panic("i4b_l1_ret_linktab: unknown driver type %d\n", drv_unit);
-
-	return(l1mux_func[drv_unit]->ret_linktab(ch_unit, channel));
-}
- 
-/*---------------------------------------------------------------------------*
- *	set the ISDN driver linktab
- *---------------------------------------------------------------------------*/
-void
-i4b_l1_set_linktab(int unit, int channel, drvr_link_t *dlt)
-{
-	int drv_unit, ch_unit;
- 
-	drv_unit = L0DRVR(l1drvunittab[unit]);
-	ch_unit = L0UNIT(l1drvunittab[unit]);
- 
-	NDBGL1(L1_PRIM, "unit %d -> drv %d / drvunit %d", unit, drv_unit, ch_unit);
-
-	if (drv_unit >= MAXL1DRVR || l1mux_func[drv_unit] == NULL
-	    || l1mux_func[drv_unit]->set_linktab == NULL)
-		panic("i4b_l1_set_linktab: unknown driver type %d\n", drv_unit);
-
-	l1mux_func[drv_unit]->set_linktab(ch_unit, channel, dlt);
-}
-
-/*===========================================================================*
- *	trace D- and B-Channel support
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	L0 -> L1 trace information to trace driver
- *---------------------------------------------------------------------------*/
-int
-i4b_l1_trace_ind(i4b_trace_hdr_t *hdr, int len, u_char *data)
-{
-	register int *tab;
-	
-	if((tab = getl1tab(L0DRVR(hdr->unit))) == NULL)
-		panic("i4b_l1_trace_ind: unknown driver type %d\n", L0DRVR(hdr->unit));
-
-	NDBGL1(L1_PRIM, "(drv %d / drvunit %d) -> unit %d", L0DRVR(hdr->unit), L0UNIT(hdr->unit), tab[L0UNIT(hdr->unit)]);
-	
-	hdr->unit = tab[L0UNIT(hdr->unit)];
-
-	return(MPH_Trace_Ind(hdr, len, data));
-}
-
-/*===========================================================================*
- *	D - Channel (signalling)
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- *	L0 -> L1 status indication from hardware
- *---------------------------------------------------------------------------*/
-int
-i4b_l1_mph_status_ind(int drv_unit, int status, int parm, struct i4b_l1mux_func *l1mux_func_p)
-{
-	register int *tab;
-	
-	/*
-	 * in case the status STI_ATTACH is sent from the hardware, the
-	 * driver has just attached itself and we need to initialize
-	 * the tables and assorted variables.
-	 */
-
-	if(status == STI_ATTACH)
-	{
-		if (l1mux_func_p == (struct i4b_l1mux_func *)0)
-			panic("i4b_l1_mph_status_ind: i4b_l1mux_func pointer is NULL\n");
-
-		if(numl1units < MAXL1UNITS)
-		{
-			if((tab = getl1tab(L0DRVR(drv_unit))) == NULL)
-				panic("i4b_l1_mph_status_ind: unknown driver type %d\n", L0DRVR(drv_unit));
-			
-			tab[L0UNIT(drv_unit)] = numl1units;
-
-			l1drvunittab[numl1units] = drv_unit;
-
-			l1mux_func[L0DRVR(drv_unit)] = l1mux_func_p;
-
-			switch(L0DRVR(drv_unit))
-			{
-				case L1DRVR_ISIC:
-					printf("isic%d: passive stack unit %d\n", L0UNIT(drv_unit), numl1units);
-					break;
-				case L1DRVR_IWIC:
-					printf("iwic%d: passive stack unit %d\n", L0UNIT(drv_unit), numl1units);
-					break;
-				case L1DRVR_IFPI:
-					printf("ifpi%d: passive stack unit %d\n", L0UNIT(drv_unit), numl1units);
-					break;
-				case L1DRVR_IFPI2:
-					printf("ifpi2-%d: passive stack unit %d\n", L0UNIT(drv_unit), numl1units);
-					break;
-				case L1DRVR_IFPNP:
-					printf("ifpnp%d: passive stack unit %d\n", L0UNIT(drv_unit), numl1units);
-					break;
-				case L1DRVR_IHFC:
-					printf("ihfc%d: passive stack unit %d\n", L0UNIT(drv_unit), numl1units);
-					break;
-				case L1DRVR_ITJC:
-					printf("itjc%d: passive stack unit %d\n", L0UNIT(drv_unit), numl1units);
-					break;
-			}
-			
-			NDBGL1(L1_PRIM, "ATTACH drv %d, drvunit %d -> unit %d", L0DRVR(drv_unit), L0UNIT(drv_unit), numl1units);
-
-			numl1units++;			
-		}
-	}
-
-	if((tab = getl1tab(L0DRVR(drv_unit))) == NULL)	
-		panic("i4b_l1_mph_status_ind: unknown driver type %d\n", L0DRVR(drv_unit));
-
-	NDBGL1(L1_PRIM, "(drv %d / drvunit %d) -> unit %d\n", L0DRVR(drv_unit), L0UNIT(drv_unit), tab[L0UNIT(drv_unit)]);
-	
-	return(MPH_Status_Ind(tab[L0UNIT(drv_unit)], status, parm));
-}
-
-/*---------------------------------------------------------------------------*
- *	L0 -> L1 data from hardware
- *---------------------------------------------------------------------------*/
-int
-i4b_l1_ph_data_ind(int drv_unit, struct mbuf *data)
-{
-	register int *tab;
-
-	if((tab = getl1tab(L0DRVR(drv_unit))) == NULL)	
-		panic("i4b_l1_ph_data_ind: unknown driver type %d\n", L0DRVR(drv_unit));
-
-#if 0
-	NDBGL1(L1_PRIM, "(drv %d / drvunit %d) -> unit %d", L0DRVR(drv_unit), L0UNIT(drv_unit), tab[L0UNIT(drv_unit)]);
-#endif
-
-	return(PH_Data_Ind(tab[L0UNIT(drv_unit)], data));
-}
-
-/*---------------------------------------------------------------------------*
- *	L0 -> L1 activate indication from hardware
- *---------------------------------------------------------------------------*/
-int
-i4b_l1_ph_activate_ind(int drv_unit)
-{
-	register int *tab;
-
-	if((tab = getl1tab(L0DRVR(drv_unit))) == NULL)	
-		panic("i4b_l1_ph_activate_ind: unknown driver type %d\n", L0DRVR(drv_unit));
-
-	NDBGL1(L1_PRIM, "(drv %d / drvunit %d) -> unit %d", L0DRVR(drv_unit), L0UNIT(drv_unit), tab[L0UNIT(drv_unit)]);
-
-	return(PH_Act_Ind(tab[L0UNIT(drv_unit)]));
-}
-
-/*---------------------------------------------------------------------------*
- *	L0 -> L1 deactivate indication from hardware
- *---------------------------------------------------------------------------*/
-int
-i4b_l1_ph_deactivate_ind(int drv_unit)
-{
-	register int *tab;
-	
-	if((tab = getl1tab(L0DRVR(drv_unit))) == NULL)
-		panic("i4b_l1_ph_deactivate_ind: unknown driver type %d\n", L0DRVR(drv_unit));
-
-	NDBGL1(L1_PRIM, "(drv %d / drvunit %d) -> unit %d", L0DRVR(drv_unit), L0UNIT(drv_unit), tab[L0UNIT(drv_unit)]);		
-
-	return(PH_Deact_Ind(tab[L0UNIT(drv_unit)]));
-}
-	
-/*---------------------------------------------------------------------------*
- *	L2 -> L1 command to hardware
- *---------------------------------------------------------------------------*/
-int
-i4b_l1_mph_command_req(int unit, int command, void * parm)
-{
-	register int drv_unit = L0DRVR(l1drvunittab[unit]);
-	register int ch_unit = L0UNIT(l1drvunittab[unit]);
- 
-	NDBGL1(L1_PRIM, "unit %d -> drv %d / drvunit %d", unit, drv_unit, ch_unit);
-
-	if (drv_unit >= MAXL1DRVR || l1mux_func[drv_unit] == NULL
-	    || l1mux_func[drv_unit]->mph_command_req == NULL)
-		panic("i4b_l1_mph_command_req: unknown driver type %d\n", drv_unit);
- 
-	return(l1mux_func[drv_unit]->mph_command_req(ch_unit, command, parm));
-}
-
-/*---------------------------------------------------------------------------*
- *	L2 -> L1 data to be transmitted to hardware
- *---------------------------------------------------------------------------*/
-static int
-i4b_l1_ph_data_req(int unit, struct mbuf *data, int flag)
-{
-	register int drv_unit = L0DRVR(l1drvunittab[unit]);
-	register int ch_unit = L0UNIT(l1drvunittab[unit]);
-
-#if 0
-	NDBGL1(L1_PRIM, "unit %d -> drv %d / drvunit %d", unit, drv_unit, ch_unit);
-#endif
-	
-	if (drv_unit >= MAXL1DRVR || l1mux_func[drv_unit] == NULL
-	    || l1mux_func[drv_unit]->ph_data_req == NULL)
-		panic("i4b_l1_ph_data_req: unknown driver type %d\n", drv_unit);
-
-	return(l1mux_func[drv_unit]->ph_data_req(ch_unit, data, flag));
-}
-
-/*---------------------------------------------------------------------------*
- *	L2 -> L1 activate request to hardware
- *---------------------------------------------------------------------------*/
-static int
-i4b_l1_ph_activate_req(int unit)
-{
-	register int drv_unit = L0DRVR(l1drvunittab[unit]);
-	register int ch_unit = L0UNIT(l1drvunittab[unit]);
- 
-	NDBGL1(L1_PRIM, "unit %d -> drv %d / drvunit %d", unit, drv_unit, ch_unit);
-
-	if (drv_unit >= MAXL1DRVR || l1mux_func[drv_unit] == NULL
-	    || l1mux_func[drv_unit]->ph_activate_req == NULL)
-		panic("i4b_l1_ph_activate_req: unknown driver type %d\n", drv_unit);
-
-	return(l1mux_func[drv_unit]->ph_activate_req(ch_unit));
-}
-
-/* EOF */
--- sys/i4b/layer1/i4b_hdlc.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*-
- * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_hdlc.c - software-HDLC constant tables
- *	------------------------------------------
- *	$Id: i4b_hdlc.h,v 1.5 2000/08/28 07:41:19 hm Exp $
- *	last edit-date: [Wed Jul 19 09:41:13 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/i4b_hdlc.c,v 1.3 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/types.h>
-
-/*---------------------------------------------------------------------------*
- *	HDLC CRC table
- *
- * Usage:
- *	crc = (HDLC_FCS_TAB[(u_char)(crc ^ byte of data)] ^ (u_char)(crc >> 8));
- *
- *	For more information see RFC 1662 (p. 10)
- *---------------------------------------------------------------------------*/
-const uint16_t HDLC_FCS_TAB[256] = { 0x0000, 
-        0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 
-        0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 
-        0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 
-        0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 
-        0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 
-        0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 
-        0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 
-        0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 
-        0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 
-        0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 
-        0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 
-        0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 
-        0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 
-        0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 
-        0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 
-        0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 
-        0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 
-        0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 
-        0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 
-        0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 
-        0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 
-        0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 
-        0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 
-        0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 
-        0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 
-        0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 
-        0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 
-        0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 
-        0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 
-        0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 
-        0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 
-        0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 
-};
-
-/*---------------------------------------------------------------------------*
- *	HDLC bit table
- *	==============	
- *
- *	bits[0..3]:	A value which tells how many set bits there are at the
- *		   	beginning of the byte.
- *
- *	bits[4..7]:	Special bytes like 0x7e, 0x7d, 0xfd ... are flagged here
- *			NOTE: Special bytes also means 'abort' bytes (7 or more
- *			      continuous set bits)
- *
- *	bits[8..11]:	A copy of bits[0..3] but only incremented by one.
- *		     	NOTE: 0x7e has value '8' instead of '0'. Internal reasons.
- *
- *	bits[12..15]: 	A value which tells how many set bits there are at the
- *		      	end of the byte.
- *			NOTE: 0xff has both '8' incoming and '8' outgoing bits.
- *
- *---------------------------------------------------------------------------*/
-const uint16_t HDLC_BIT_TAB[256] = { 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0403, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0504, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0403, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0605, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0403, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0504, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0403, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0160, 0x0706, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0403, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0504, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0403, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0605, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0403, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0504, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x0100, 0x0201, 0x0100, 0x0403, 0x0100, 
-        0x0201, 0x0100, 0x0302, 0x01a0, 0x02a1, 0x0860, 0x0807, 0x1100, 
-        0x1201, 0x1100, 0x1302, 0x1100, 0x1201, 0x1100, 0x1403, 0x1100, 
-        0x1201, 0x1100, 0x1302, 0x1100, 0x1201, 0x1100, 0x1504, 0x1100, 
-        0x1201, 0x1100, 0x1302, 0x1100, 0x1201, 0x1100, 0x1403, 0x1100, 
-        0x1201, 0x1100, 0x1302, 0x1100, 0x1201, 0x1100, 0x1605, 0x1100, 
-        0x1201, 0x1100, 0x1302, 0x1100, 0x1201, 0x1100, 0x1403, 0x1100, 
-        0x1201, 0x1100, 0x1302, 0x1100, 0x1201, 0x1100, 0x1504, 0x1100, 
-        0x1201, 0x1100, 0x1302, 0x1100, 0x1201, 0x1100, 0x1403, 0x1100, 
-        0x1201, 0x1100, 0x1302, 0x1100, 0x1201, 0x1160, 0x1706, 0x2100, 
-        0x2201, 0x2100, 0x2302, 0x2100, 0x2201, 0x2100, 0x2403, 0x2100, 
-        0x2201, 0x2100, 0x2302, 0x2100, 0x2201, 0x2100, 0x2504, 0x2100, 
-        0x2201, 0x2100, 0x2302, 0x2100, 0x2201, 0x2100, 0x2403, 0x2100, 
-        0x2201, 0x2100, 0x2302, 0x2100, 0x2201, 0x2100, 0x2605, 0x3100, 
-        0x3201, 0x3100, 0x3302, 0x3100, 0x3201, 0x3100, 0x3403, 0x3100, 
-        0x3201, 0x3100, 0x3302, 0x3100, 0x3201, 0x3100, 0x3504, 0x4100, 
-        0x4201, 0x4100, 0x4302, 0x4100, 0x4201, 0x4100, 0x4403, 0x5100, 
-        0x5201, 0x5100, 0x5302, 0x6180, 0x6281, 0x7150, 0x8908 
-};
--- sys/i4b/layer1/ifpi/i4b_ifpi_l1.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpi_l1.c - AVM Fritz PCI layer 1 handler
- *	---------------------------------------------
- *	$Id: i4b_ifpi_l1.c,v 1.4 2000/06/02 16:14:36 hm Exp $ 
- *      last edit-date: [Fri Jun  2 14:54:30 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpi/i4b_ifpi_l1.c,v 1.8 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-
-#include <i4b/layer1/ifpi/i4b_ifpi_ext.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-DATA-REQUEST
- *	=========================
- *
- *	parms:
- *		unit		physical interface unit number
- *		m		mbuf containing L2 frame to be sent out
- *		freeflag	MBUF_FREE: free mbuf here after having sent
- *						it out
- *				MBUF_DONTFREE: mbuf is freed by Layer 2
- *	returns:
- *		==0	fail, nothing sent out
- *		!=0	ok, frame sent out
- *
- *---------------------------------------------------------------------------*/
-int
-ifpi_ph_data_req(int unit, struct mbuf *m, int freeflag)
-{
-	u_char cmd;
-	int s;
-	struct l1_softc *sc = ifpi_scp[unit];
-
-#ifdef NOTDEF
-	NDBGL1(L1_PRIM, "PH-DATA-REQ, unit %d, freeflag=%d", unit, freeflag);
-#endif
-
-	if(m == NULL)			/* failsafe */
-		return (0);
-
-	s = SPLI4B();
-
-	if(sc->sc_I430state == ST_F3)	/* layer 1 not running ? */
-	{
-		NDBGL1(L1_I_ERR, "still in state F3!");
-		ifpi_ph_activate_req(unit);
-	}
-
-	if(sc->sc_state & ISAC_TX_ACTIVE)
-	{
-		if(sc->sc_obuf2 == NULL)
-		{
-			sc->sc_obuf2 = m;		/* save mbuf ptr */
-
-			if(freeflag)
-				sc->sc_freeflag2 = 1;	/* IRQ must mfree */
-			else
-				sc->sc_freeflag2 = 0;	/* IRQ must not mfree */
-
-			NDBGL1(L1_I_MSG, "using 2nd ISAC TX buffer, state = %s", ifpi_printstate(sc));
-
-			if(sc->sc_trace & TRACE_D_TX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0IFPIUNIT(unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_TE;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-			}
-			splx(s);
-			return(1);
-		}
-
-		NDBGL1(L1_I_ERR, "No Space in TX FIFO, state = %s", ifpi_printstate(sc));
-	
-		if(freeflag == MBUF_FREE)
-			i4b_Dfreembuf(m);			
-	
-		splx(s);
-		return (0);
-	}
-
-	if(sc->sc_trace & TRACE_D_TX)
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0IFPIUNIT(unit);
-		hdr.type = TRC_CH_D;
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_dcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-	}
-	
-	sc->sc_state |= ISAC_TX_ACTIVE;	/* set transmitter busy flag */
-
-	NDBGL1(L1_I_MSG, "ISAC_TX_ACTIVE set");
-
-	sc->sc_freeflag = 0;		/* IRQ must NOT mfree */
-	
-	ISAC_WRFIFO(m->m_data, min(m->m_len, ISAC_FIFO_LEN)); /* output to TX fifo */
-
-	if(m->m_len > ISAC_FIFO_LEN)	/* message > 32 bytes ? */
-	{
-		sc->sc_obuf = m;	/* save mbuf ptr */
-		sc->sc_op = m->m_data + ISAC_FIFO_LEN; 	/* ptr for irq hdl */
-		sc->sc_ol = m->m_len - ISAC_FIFO_LEN;	/* length for irq hdl */
-
-		if(freeflag)
-			sc->sc_freeflag = 1;	/* IRQ must mfree */
-		
-		cmd = ISAC_CMDR_XTF;
-	}
-	else
-	{
-		sc->sc_obuf = NULL;
-		sc->sc_op = NULL;
-		sc->sc_ol = 0;
-
-		if(freeflag)
-			i4b_Dfreembuf(m);
-
-		cmd = ISAC_CMDR_XTF | ISAC_CMDR_XME;
-  	}
-
-	ISAC_WRITE(I_CMDR, cmd);
-	ISACCMDRWRDELAY();
-
-	splx(s);
-	
-	return(1);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-ACTIVATE-REQUEST
- *	=============================
- *
- *	parms:
- *		unit	physical interface unit number
- *
- *	returns:
- *		==0	
- *		!=0	
- *
- *---------------------------------------------------------------------------*/
-int
-ifpi_ph_activate_req(int unit)
-{
-	struct l1_softc *sc = ifpi_scp[unit];
-	NDBGL1(L1_PRIM, "PH-ACTIVATE-REQ, unit %d", unit);
-	ifpi_next_state(sc, EV_PHAR);
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	command from the upper layers
- *---------------------------------------------------------------------------*/
-int
-ifpi_mph_command_req(int unit, int command, void *parm)
-{
-	struct l1_softc *sc = ifpi_scp[unit];
-
-	switch(command)
-	{
-		case CMR_DOPEN:		/* daemon running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DOPEN", unit);
-			sc->sc_enabled = 1;			
-			break;
-			
-		case CMR_DCLOSE:	/* daemon not running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DCLOSE", unit);
-			sc->sc_enabled = 0;
-			break;
-
-		case CMR_SETTRACE:
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_SETTRACE, parm = %d", unit, (unsigned int)parm);
-			sc->sc_trace = (unsigned int)parm;
-			break;
-		
-		default:
-			NDBGL1(L1_ERROR, "ERROR, unknown command = %d, unit = %d, parm = %d", command, unit, (unsigned int)parm);
-			break;
-	}
-
-	return(0);
-}
--- sys/i4b/layer1/ifpi/i4b_ifpi_isac.c
+++ /dev/null
@@ -1,658 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpi_isac.c - i4b Fritz PCI ISAC handler
- *	--------------------------------------------
- *	$Id: i4b_ifpi_isac.c,v 1.3 2000/05/29 15:41:41 hm Exp $ 
- *      last edit-date: [Mon May 29 15:22:52 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpi/i4b_ifpi_isac.c,v 1.8 2005/01/06 22:18:19 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/layer1/ifpi/i4b_ifpi_ext.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-static u_char ifpi_isac_exir_hdlr(register struct l1_softc *sc, u_char exir);
-static void ifpi_isac_ind_hdlr(register struct l1_softc *sc, int ind);
-
-/*---------------------------------------------------------------------------*
- *	ISAC interrupt service routine
- *---------------------------------------------------------------------------*/
-void
-ifpi_isac_irq(struct l1_softc *sc, int ista)
-{
-	register u_char c = 0;
-	NDBGL1(L1_F_MSG, "unit %d: ista = 0x%02x", sc->sc_unit, ista);
-
-	if(ista & ISAC_ISTA_EXI)	/* extended interrupt */
-	{
-		c |= ifpi_isac_exir_hdlr(sc, ISAC_READ(I_EXIR));
-	}
-	
-	if(ista & ISAC_ISTA_RME)	/* receive message end */
-	{
-		register int rest;
-		u_char rsta;
-
-		/* get rx status register */
-		
-		rsta = ISAC_READ(I_RSTA);
-
-		if((rsta & ISAC_RSTA_MASK) != 0x20)
-		{
-			int error = 0;
-			
-			if(!(rsta & ISAC_RSTA_CRC))	/* CRC error */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: CRC error", sc->sc_unit);
-			}
-	
-			if(rsta & ISAC_RSTA_RDO)	/* ReceiveDataOverflow */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Data Overrun error", sc->sc_unit);
-			}
-	
-			if(rsta & ISAC_RSTA_RAB)	/* ReceiveABorted */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Receive Aborted error", sc->sc_unit);
-			}
-
-			if(error == 0)			
-				NDBGL1(L1_I_ERR, "unit %d: RME unknown error, RSTA = 0x%02x!", sc->sc_unit, rsta);
-
-			i4b_Dfreembuf(sc->sc_ibuf);
-
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-
-			ISAC_WRITE(I_CMDR, ISAC_CMDR_RMC|ISAC_CMDR_RRES);
-			ISACCMDRWRDELAY();
-
-			return;
-		}
-
-		rest = (ISAC_READ(I_RBCL) & (ISAC_FIFO_LEN-1));
-
-		if(rest == 0)
-			rest = ISAC_FIFO_LEN;
-
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(rest)) != NULL)
-				sc->sc_ib = sc->sc_ibuf->m_data;
-			else
-				panic("ifpi_isac_irq: RME, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - rest))
-		{
-			ISAC_RDFIFO(sc->sc_ib, rest);
-			sc->sc_ilen += rest;
-			
-			sc->sc_ibuf->m_pkthdr.len =
-				sc->sc_ibuf->m_len = sc->sc_ilen;
-
-			if(sc->sc_trace & TRACE_D_RX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0IFPIUNIT(sc->sc_unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_NT;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, sc->sc_ibuf->m_len, sc->sc_ibuf->m_data);
-			}
-
-			c |= ISAC_CMDR_RMC;
-
-			if(sc->sc_enabled &&
-			   (ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S))
-			{
-				i4b_l1_ph_data_ind(L0IFPIUNIT(sc->sc_unit), sc->sc_ibuf);
-			}
-			else
-			{
-				i4b_Dfreembuf(sc->sc_ibuf);
-			}
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RME, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-		}
-
-		sc->sc_ibuf = NULL;
-		sc->sc_ib = NULL;
-		sc->sc_ilen = 0;
-	}
-
-	if(ista & ISAC_ISTA_RPF)	/* receive fifo full */
-	{
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(MAX_DFRAME_LEN)) != NULL)
-				sc->sc_ib= sc->sc_ibuf->m_data;
-			else
-				panic("ifpi_isac_irq: RPF, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - ISAC_FIFO_LEN))
-		{
-			ISAC_RDFIFO(sc->sc_ib, ISAC_FIFO_LEN);
-			sc->sc_ilen += ISAC_FIFO_LEN;			
-			sc->sc_ib += ISAC_FIFO_LEN;
-			c |= ISAC_CMDR_RMC;
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RPF, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;			
-		}
-	}
-
-	if(ista & ISAC_ISTA_XPR)	/* transmit fifo empty (XPR bit set) */
-	{
-		if((sc->sc_obuf2 != NULL) && (sc->sc_obuf == NULL))
-		{
-			sc->sc_freeflag = sc->sc_freeflag2;
-			sc->sc_obuf = sc->sc_obuf2;
-			sc->sc_op = sc->sc_obuf->m_data;
-			sc->sc_ol = sc->sc_obuf->m_len;
-			sc->sc_obuf2 = NULL;
-#ifdef NOTDEF			
-			printf("ob2=%x, op=%x, ol=%d, f=%d #",
-				sc->sc_obuf,
-				sc->sc_op,
-				sc->sc_ol,
-				sc->sc_state);
-#endif				
-		}
-		else
-		{
-#ifdef NOTDEF
-			printf("ob=%x, op=%x, ol=%d, f=%d #",
-				sc->sc_obuf,
-				sc->sc_op,
-				sc->sc_ol,
-				sc->sc_state);
-#endif
-		}			
-		
-		if(sc->sc_obuf)
-		{			
-			ISAC_WRFIFO(sc->sc_op, min(sc->sc_ol, ISAC_FIFO_LEN));
-	
-			if(sc->sc_ol > ISAC_FIFO_LEN)	/* length > 32 ? */
-			{
-				sc->sc_op += ISAC_FIFO_LEN; /* bufferptr+32 */
-				sc->sc_ol -= ISAC_FIFO_LEN; /* length - 32 */
-				c |= ISAC_CMDR_XTF;	    /* set XTF bit */
-			}
-			else
-			{
-				if(sc->sc_freeflag)
-				{
-					i4b_Dfreembuf(sc->sc_obuf);
-					sc->sc_freeflag = 0;
-				}
-				sc->sc_obuf = NULL;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-	
-				c |= ISAC_CMDR_XTF | ISAC_CMDR_XME;
-			}
-		}
-		else
-		{
-			sc->sc_state &= ~ISAC_TX_ACTIVE;
-		}
-	}
-	
-	if(ista & ISAC_ISTA_CISQ)	/* channel status change CISQ */
-	{
-		register u_char ci;
-	
-		/* get command/indication rx register*/
-	
-		ci = ISAC_READ(I_CIRR);
-
-		/* if S/Q IRQ, read SQC reg to clr SQC IRQ */
-	
-		if(ci & ISAC_CIRR_SQC)
-			(void) ISAC_READ(I_SQRR);
-
-		/* C/I code change IRQ (flag already cleared by CIRR read) */
-	
-		if(ci & ISAC_CIRR_CIC0)
-			ifpi_isac_ind_hdlr(sc, (ci >> 2) & 0xf);
-	}
-	
-	if(c)
-	{
-		ISAC_WRITE(I_CMDR, c);
-		ISACCMDRWRDELAY();
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	ISAC L1 Extended IRQ handler
- *---------------------------------------------------------------------------*/
-static u_char
-ifpi_isac_exir_hdlr(register struct l1_softc *sc, u_char exir)
-{
-	u_char c = 0;
-	
-	if(exir & ISAC_EXIR_XMR)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Message Repeat");
-
-		c |= ISAC_CMDR_XRES;
-	}
-	
-	if(exir & ISAC_EXIR_XDU)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Data Underrun");
-
-		c |= ISAC_CMDR_XRES;
-	}
-
-	if(exir & ISAC_EXIR_PCE)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Protocol Error");
-	}
-
-	if(exir & ISAC_EXIR_RFO)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Rx Frame Overflow");
-
-		c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-	}
-
-	if(exir & ISAC_EXIR_SOV)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Sync Xfer Overflow");
-	}
-
-	if(exir & ISAC_EXIR_MOS)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Monitor Status");
-	}
-
-	if(exir & ISAC_EXIR_SAW)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-		
-		NDBGL1(L1_I_ERR, "EXIRQ Subscriber Awake");
-	}
-
-	if(exir & ISAC_EXIR_WOV)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-
-		NDBGL1(L1_I_ERR, "EXIRQ Watchdog Timer Overflow");
-	}
-
-	return(c);
-}
-
-/*---------------------------------------------------------------------------*
- *	ISAC L1 Indication handler
- *---------------------------------------------------------------------------*/
-static void
-ifpi_isac_ind_hdlr(register struct l1_softc *sc, int ind)
-{
-	register int event;
-	
-	switch(ind)
-	{
-		case ISAC_CIRR_IAI8:
-			NDBGL1(L1_I_CICO, "rx AI8 in state %s", ifpi_printstate(sc));
-			if(sc->sc_bustyp == BUS_TYPE_IOM2)
-				ifpi_isac_l1_cmd(sc, CMD_AR8);
-			event = EV_INFO48;
-			i4b_l1_mph_status_ind(L0IFPIUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-			
-		case ISAC_CIRR_IAI10:
-			NDBGL1(L1_I_CICO, "rx AI10 in state %s", ifpi_printstate(sc));
-			if(sc->sc_bustyp == BUS_TYPE_IOM2)
-				ifpi_isac_l1_cmd(sc, CMD_AR10);
-			event = EV_INFO410;
-			i4b_l1_mph_status_ind(L0IFPIUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-
-		case ISAC_CIRR_IRSY:
-			NDBGL1(L1_I_CICO, "rx RSY in state %s", ifpi_printstate(sc));
-			event = EV_RSY;
-			break;
-
-		case ISAC_CIRR_IPU:
-			NDBGL1(L1_I_CICO, "rx PU in state %s", ifpi_printstate(sc));
-			event = EV_PU;
-			break;
-
-		case ISAC_CIRR_IDR:
-			NDBGL1(L1_I_CICO, "rx DR in state %s", ifpi_printstate(sc));
-			ifpi_isac_l1_cmd(sc, CMD_DIU);
-			event = EV_DR;			
-			break;
-			
-		case ISAC_CIRR_IDID:
-			NDBGL1(L1_I_CICO, "rx DID in state %s", ifpi_printstate(sc));
-			event = EV_INFO0;
-			i4b_l1_mph_status_ind(L0IFPIUNIT(sc->sc_unit), STI_L1STAT, LAYER_IDLE, NULL);
-			break;
-
-		case ISAC_CIRR_IDIS:
-			NDBGL1(L1_I_CICO, "rx DIS in state %s", ifpi_printstate(sc));
-			event = EV_DIS;
-			break;
-
-		case ISAC_CIRR_IEI:
-			NDBGL1(L1_I_CICO, "rx EI in state %s", ifpi_printstate(sc));
-			ifpi_isac_l1_cmd(sc, CMD_DIU);
-			event = EV_EI;
-			break;
-
-		case ISAC_CIRR_IARD:
-			NDBGL1(L1_I_CICO, "rx ARD in state %s", ifpi_printstate(sc));
-			event = EV_INFO2;
-			break;
-
-		case ISAC_CIRR_ITI:
-			NDBGL1(L1_I_CICO, "rx TI in state %s", ifpi_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISAC_CIRR_IATI:
-			NDBGL1(L1_I_CICO, "rx ATI in state %s", ifpi_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISAC_CIRR_ISD:
-			NDBGL1(L1_I_CICO, "rx SD in state %s", ifpi_printstate(sc));
-			event = EV_INFO0;
-			break;
-		
-		default:
-			NDBGL1(L1_I_ERR, "UNKNOWN Indication 0x%x in state %s", ind, ifpi_printstate(sc));
-			event = EV_INFO0;
-			break;
-	}
-	ifpi_next_state(sc, event);
-}
-
-/*---------------------------------------------------------------------------*
- *	execute a layer 1 command
- *---------------------------------------------------------------------------*/	
-void
-ifpi_isac_l1_cmd(struct l1_softc *sc, int command)
-{
-	u_char cmd;
-
-#ifdef I4B_SMP_WORKAROUND
-
-	/* XXXXXXXXXXXXXXXXXXX */
-	
-	/*
-	 * patch from Wolfgang Helbig:
-	 *
-	 * Here is a patch that makes i4b work on an SMP:
-	 * The card (TELES 16.3) didn't interrupt on an SMP machine.
-	 * This is a gross workaround, but anyway it works *and* provides
-	 * some information as how to finally fix this problem.
-	 */
-	
-	HSCX_WRITE(0, H_MASK, 0xff);
-	HSCX_WRITE(1, H_MASK, 0xff);
-	ISAC_WRITE(I_MASK, 0xff);
-	DELAY(100);
-	HSCX_WRITE(0, H_MASK, HSCX_A_IMASK);
-	HSCX_WRITE(1, H_MASK, HSCX_B_IMASK);
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	/* XXXXXXXXXXXXXXXXXXX */
-	
-#endif /* I4B_SMP_WORKAROUND */
-
-	if(command < 0 || command > CMD_ILL)
-	{
-		NDBGL1(L1_I_ERR, "illegal cmd 0x%x in state %s", command, ifpi_printstate(sc));
-		return;
-	}
-                                           
-	if(sc->sc_bustyp == BUS_TYPE_IOM2)
-		cmd = ISAC_CIX0_LOW;
-	else
-		cmd = 0;
-
-	switch(command)
-	{
-		case CMD_TIM:
-			NDBGL1(L1_I_CICO, "tx TIM in state %s", ifpi_printstate(sc));
-			cmd |= (ISAC_CIXR_CTIM << 2);
-			break;
-
-		case CMD_RS:
-			NDBGL1(L1_I_CICO, "tx RS in state %s", ifpi_printstate(sc));
-			cmd |= (ISAC_CIXR_CRS << 2);
-			break;
-
-		case CMD_AR8:
-			NDBGL1(L1_I_CICO, "tx AR8 in state %s", ifpi_printstate(sc));
-			cmd |= (ISAC_CIXR_CAR8 << 2);
-			break;
-
-		case CMD_AR10:
-			NDBGL1(L1_I_CICO, "tx AR10 in state %s", ifpi_printstate(sc));
-			cmd |= (ISAC_CIXR_CAR10 << 2);
-			break;
-
-		case CMD_DIU:
-			NDBGL1(L1_I_CICO, "tx DIU in state %s", ifpi_printstate(sc));
-			cmd |= (ISAC_CIXR_CDIU << 2);
-			break;
-	}
-	ISAC_WRITE(I_CIXR, cmd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L1 ISAC initialization
- *---------------------------------------------------------------------------*/
-int
-ifpi_isac_init(struct l1_softc *sc)
-{
-	ISAC_IMASK = 0xff;		/* disable all irqs */
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	if(sc->sc_bustyp != BUS_TYPE_IOM2)
-	{
-		NDBGL1(L1_I_SETUP, "configuring for IOM-1 mode");
-
-		/* ADF2: Select mode IOM-1 */		
-		ISAC_WRITE(I_ADF2, 0x00);
-
-		/* SPCR: serial port control register:
-		 *	SPU - software power up = 0
-		 *	SAC - SIP port high Z
-		 *	SPM - timing mode 0
-		 *	TLP - test loop = 0
-		 *	C1C, C2C - B1 and B2 switched to/from SPa
-		 */
-		ISAC_WRITE(I_SPCR, ISAC_SPCR_C1C1|ISAC_SPCR_C2C1);
-
-		/* SQXR: S/Q channel xmit register:
-                 *	SQIE - S/Q IRQ enable = 0
-		 *	SQX1-4 - Fa bits = 1
-		 */
-		ISAC_WRITE(I_SQXR, ISAC_SQXR_SQX1|ISAC_SQXR_SQX2|ISAC_SQXR_SQX3|ISAC_SQXR_SQX4);
-
-		/* ADF1: additional feature reg 1:
-		 *	WTC - watchdog = 0
-		 *	TEM - test mode = 0
-		 *	PFS - pre-filter = 0
-		 *	CFS - IOM clock/frame always active
-		 *	FSC1/2 - polarity of 8kHz strobe
-		 *	ITF - interframe fill = idle
-		 */	
-		ISAC_WRITE(I_ADF1, ISAC_ADF1_FC2);	/* ADF1 */
-
-		/* STCR: sync transfer control reg:
-		 *	TSF - terminal secific functions = 0
-		 *	TBA - TIC bus address = 7
-		 *	STx/SCx = 0
-		 */
-		ISAC_WRITE(I_STCR, ISAC_STCR_TBA2|ISAC_STCR_TBA1|ISAC_STCR_TBA0);
-
-		/* MODE: Mode Register:
-		 *	MDSx - transparent mode 2
-		 *	TMD  - timer mode = external
-		 *	RAC  - Receiver enabled
-		 *	DIMx - digital i/f mode
-		 */
-		ISAC_WRITE(I_MODE, ISAC_MODE_MDS2|ISAC_MODE_MDS1|ISAC_MODE_RAC|ISAC_MODE_DIM0);
-	}
-	else
-	{
-		NDBGL1(L1_I_SETUP, "configuring for IOM-2 mode");
-
-		/* ADF2: Select mode IOM-2 */		
-		ISAC_WRITE(I_ADF2, ISAC_ADF2_IMS);
-
-		/* SPCR: serial port control register:
-		 *	SPU - software power up = 0
-		 *	SPM - timing mode 0
-		 *	TLP - test loop = 0
-		 *	C1C, C2C - B1 + C1 and B2 + IC2 monitoring
-		 */
-		ISAC_WRITE(I_SPCR, 0x00);
-
-		/* SQXR: S/Q channel xmit register:
-		 *	IDC  - IOM direction = 0 (master)
-		 *	CFS  - Config Select = 0 (clock always active)
-		 *	CI1E - C/I channel 1 IRQ enable = 0
-                 *	SQIE - S/Q IRQ enable = 0
-		 *	SQX1-4 - Fa bits = 1
-		 */
-		ISAC_WRITE(I_SQXR, ISAC_SQXR_SQX1|ISAC_SQXR_SQX2|ISAC_SQXR_SQX3|ISAC_SQXR_SQX4);
-
-		/* ADF1: additional feature reg 1:
-		 *	WTC - watchdog = 0
-		 *	TEM - test mode = 0
-		 *	PFS - pre-filter = 0
-		 *	IOF - IOM i/f off = 0
-		 *	ITF - interframe fill = idle
-		 */	
-		ISAC_WRITE(I_ADF1, 0x00);
-
-		/* STCR: sync transfer control reg:
-		 *	TSF - terminal secific functions = 0
-		 *	TBA - TIC bus address = 7
-		 *	STx/SCx = 0
-		 */
-		ISAC_WRITE(I_STCR, ISAC_STCR_TBA2|ISAC_STCR_TBA1|ISAC_STCR_TBA0);
-
-		/* MODE: Mode Register:
-		 *	MDSx - transparent mode 2
-		 *	TMD  - timer mode = external
-		 *	RAC  - Receiver enabled
-		 *	DIMx - digital i/f mode
-		 */
-		ISAC_WRITE(I_MODE, ISAC_MODE_MDS2|ISAC_MODE_MDS1|ISAC_MODE_RAC|ISAC_MODE_DIM0);
-	}
-
-#ifdef NOTDEF
-	/*
-	 * XXX a transmitter reset causes an ISAC tx IRQ which will not
-	 * be serviced at attach time under some circumstances leaving
-	 * the associated IRQ line on the ISA bus active. This prevents
-	 * any further interrupts to be serviced because no low -> high
-	 * transition can take place anymore. (-hm)
-	 */
-	 
-	/* command register:
-	 *	RRES - HDLC receiver reset
-	 *	XRES - transmitter reset
-	 */
-	ISAC_WRITE(I_CMDR, ISAC_CMDR_RRES|ISAC_CMDR_XRES);
-	ISACCMDRWRDELAY();
-#endif
-	
-	/* enabled interrupts:
-	 * ===================
-	 * RME  - receive message end
-	 * RPF  - receive pool full
-	 * XPR  - transmit pool ready
-	 * CISQ - CI or S/Q channel change
-	 * EXI  - extended interrupt
-	 */
-
-	ISAC_IMASK = ISAC_MASK_RSC |	/* auto mode only	*/
-		     ISAC_MASK_TIN | 	/* timer irq		*/
-		     ISAC_MASK_SIN;	/* sync xfer irq	*/
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	return(0);
-}
--- sys/i4b/layer1/ifpi/i4b_ifpi_pci.c
+++ /dev/null
@@ -1,1494 +0,0 @@
-/*-
- *   Copyright (c) 1999, 2000 Gary Jennejohn. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpi_pci.c: AVM Fritz!Card PCI hardware driver
- *	--------------------------------------------------
- *	$Id: i4b_ifpi_pci.c,v 1.4 2000/06/02 11:58:56 hm Exp $
- *      last edit-date: [Fri Jan 12 17:01:26 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c,v 1.17 2005/01/06 22:18:19 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/bus.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/layer1/ifpi/i4b_ifpi_ext.h>
-
-#define PCI_AVMA1_VID 0x1244
-#define PCI_AVMA1_DID 0x0a00
-
-/* prototypes */
-
-static void avma1pp_disable(device_t);
-static void avma1pp_intr(void *);
-static void hscx_write_reg(int, u_int, u_int, struct l1_softc *);
-static u_char hscx_read_reg(int, u_int, struct l1_softc *);
-static u_int hscx_read_reg_int(int, u_int, struct l1_softc *);
-static void hscx_read_fifo(int, void *, size_t, struct l1_softc *);
-static void hscx_write_fifo(int, void *, size_t, struct l1_softc *);
-static void avma1pp_hscx_int_handler(struct l1_softc *);
-static void avma1pp_hscx_intr(int, u_int, struct l1_softc *);
-static void avma1pp_init_linktab(struct l1_softc *);
-static void avma1pp_bchannel_setup(int, int, int, int);
-static void avma1pp_bchannel_start(int, int);
-static void avma1pp_hscx_init(struct l1_softc *, int, int);
-static void avma1pp_bchannel_stat(int, int, bchan_statistics_t *);
-static void avma1pp_set_linktab(int, int, drvr_link_t *);
-static isdn_link_t * avma1pp_ret_linktab(int, int);
-static int avma1pp_pci_probe(device_t);
-static int avma1pp_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
-int avma1pp_attach_avma1pp(device_t);
-static void ifpi_isac_intr(struct l1_softc *sc);
-
-static device_method_t avma1pp_pci_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		avma1pp_pci_probe),
-	DEVMETHOD(device_attach,	avma1pp_attach_avma1pp),
-	DEVMETHOD(device_shutdown,	avma1pp_disable),
-
-	/* bus interface */
-	DEVMETHOD(bus_print_child,	bus_generic_print_child),
-	DEVMETHOD(bus_driver_added,	bus_generic_driver_added),
-
-	{ 0, 0 }
-};
-
-#if 0 /* use what's in l1_softc */
-/* a minimal softc for the Fritz!Card PCI */
-struct avma1pp_softc 
-{
-	bus_space_handle_t	avma1pp_bhandle;
-	bus_space_tag_t		avma1pp_btag;
-	void			*avma1pp_intrhand;
-	struct resource		*avma1pp_irq;
-	struct resource		*avma1pp_res;
-	/* pointer to ifpi_sc */
-	struct l1_softc	*avma1pp_isc;
-};
-#endif
-
-static driver_t avma1pp_pci_driver = {
-	"ifpi",
-	avma1pp_pci_methods,
-	sizeof(struct l1_softc)
-};
-
-static devclass_t avma1pp_pci_devclass;
-
-DRIVER_MODULE(avma1pp, pci, avma1pp_pci_driver, avma1pp_pci_devclass, 0, 0);
-
-/* jump table for multiplex routines */
-
-struct i4b_l1mux_func avma1pp_l1mux_func = {
-	avma1pp_ret_linktab,
-	avma1pp_set_linktab,
-	ifpi_mph_command_req,
-	ifpi_ph_data_req,
-	ifpi_ph_activate_req,
-};
-
-struct l1_softc *ifpi_scp[IFPI_MAXUNIT];
-
-/*---------------------------------------------------------------------------*
- *	AVM PCI Fritz!Card special registers
- *---------------------------------------------------------------------------*/
-
-/*
- *	register offsets from i/o base
- */
-#define STAT0_OFFSET            0x02
-#define STAT1_OFFSET            0x03
-#define ADDR_REG_OFFSET         0x04
-/*#define MODREG_OFFSET		0x06
-#define VERREG_OFFSET           0x07*/
-
-/* these 2 are used to select an ISAC register set */
-#define ISAC_LO_REG_OFFSET	0x04
-#define ISAC_HI_REG_OFFSET	0x06
-
-/* offset higher than this goes to the HI register set */
-#define MAX_LO_REG_OFFSET	0x2f
-
-/* mask for the offset */
-#define ISAC_REGSET_MASK	0x0f
-
-/* the offset from the base to the ISAC registers */
-#define ISAC_REG_OFFSET		0x10
-
-/* the offset from the base to the ISAC FIFO */
-#define ISAC_FIFO		0x02
-
-/* not really the HSCX, but sort of */
-#define HSCX_FIFO		0x00
-#define HSCX_STAT		0x04
-
-/*
- *	AVM PCI Status Latch 0 read only bits
- */
-#define ASL_IRQ_ISAC            0x01    /* ISAC  interrupt, active low */
-#define ASL_IRQ_HSCX            0x02    /* HSX   interrupt, active low */
-#define ASL_IRQ_TIMER           0x04    /* Timer interrupt, active low */
-#define ASL_IRQ_BCHAN           ASL_IRQ_HSCX
-/* actually active LOW */
-#define ASL_IRQ_Pending         (ASL_IRQ_ISAC | ASL_IRQ_HSCX | ASL_IRQ_TIMER)
-
-/*
- *	AVM Status Latch 0 write only bits
- */
-#define ASL_RESET_ALL           0x01  /* reset siemens IC's, active 1 */
-#define ASL_TIMERDISABLE        0x02  /* active high */
-#define ASL_TIMERRESET          0x04  /* active high */
-#define ASL_ENABLE_INT          0x08  /* active high */
-#define ASL_TESTBIT	        0x10  /* active high */
-
-/*
- *	AVM Status Latch 1 write only bits
- */
-#define ASL1_INTSEL              0x0f  /* active high */
-#define ASL1_ENABLE_IOM          0x80  /* active high */
-
-/*
- * "HSCX" mode bits
- */
-#define  HSCX_MODE_ITF_FLG	0x01
-#define  HSCX_MODE_TRANS	0x02
-#define  HSCX_MODE_CCR_7	0x04
-#define  HSCX_MODE_CCR_16	0x08
-#define  HSCX_MODE_TESTLOOP	0x80
-
-/*
- * "HSCX" status bits
- */
-#define  HSCX_STAT_RME		0x01
-#define  HSCX_STAT_RDO		0x10
-#define  HSCX_STAT_CRCVFRRAB	0x0E
-#define  HSCX_STAT_CRCVFR	0x06
-#define  HSCX_STAT_RML_MASK	0x3f00
-
-/*
- * "HSCX" interrupt bits
- */
-#define  HSCX_INT_XPR		0x80
-#define  HSCX_INT_XDU		0x40
-#define  HSCX_INT_RPR		0x20
-#define  HSCX_INT_MASK		0xE0
-
-/*
- * "HSCX" command bits
- */
-#define  HSCX_CMD_XRS		0x80
-#define  HSCX_CMD_XME		0x01
-#define  HSCX_CMD_RRS		0x20
-#define  HSCX_CMD_XML_MASK	0x3f00
-
-/*
- * Commands and parameters are sent to the "HSCX" as a long, but the
- * fields are handled as bytes.
- *
- * The long contains:
- *	(prot << 16)|(txl << 8)|cmd
- *
- * where:
- *	prot = protocol to use
- *	txl = transmit length
- *	cmd = the command to be executed
- *
- * The fields are defined as u_char in struct l1_softc.
- *
- * Macro to coalesce the byte fields into a u_int
- */
-#define AVMA1PPSETCMDLONG(f) (f) = ((sc->avma1pp_cmd) | (sc->avma1pp_txl << 8) \
- 					| (sc->avma1pp_prot << 16))
-
-/*
- * to prevent deactivating the "HSCX" when both channels are active we
- * define an HSCX_ACTIVE flag which is or'd into the channel's state
- * flag in avma1pp_bchannel_setup upon active and cleared upon deactivation.
- * It is set high to allow room for new flags.
- */
-#define HSCX_AVMA1PP_ACTIVE	0x1000 
-
-/*---------------------------------------------------------------------------*
- *	AVM read fifo routines
- *---------------------------------------------------------------------------*/
-
-static void
-avma1pp_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(btag, bhandle,  ADDR_REG_OFFSET, ISAC_FIFO);
-			bus_space_read_multi_1(btag, bhandle,  ISAC_REG_OFFSET, buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			hscx_read_fifo(0, buf, size, sc);
-			break;
-		case ISIC_WHAT_HSCXB:
-			hscx_read_fifo(1, buf, size, sc);
-			break;
-	}
-}
-
-static void
-hscx_read_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
-{
-	u_int32_t *ip;
-	size_t cnt;
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	bus_space_write_4(btag, bhandle, ADDR_REG_OFFSET, chan);
-	ip = (u_int32_t *)buf;
-	cnt = 0;
-	/* what if len isn't a multiple of sizeof(int) and buf is */
-	/* too small ???? */
-	while (cnt < len)
-	{
-		*ip++ = bus_space_read_4(btag, bhandle, ISAC_REG_OFFSET);
-		cnt += 4;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM write fifo routines
- *---------------------------------------------------------------------------*/
-static void
-avma1pp_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(btag, bhandle,  ADDR_REG_OFFSET, ISAC_FIFO);
-			bus_space_write_multi_1(btag, bhandle,  ISAC_REG_OFFSET, (u_int8_t*)buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			hscx_write_fifo(0, buf, size, sc);
-			break;
-		case ISIC_WHAT_HSCXB:
-			hscx_write_fifo(1, buf, size, sc);
-			break;
-	}
-}
-
-static void
-hscx_write_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
-{
-	u_int32_t *ip;
-	size_t cnt;
-	l1_bchan_state_t *Bchan = &sc->sc_chan[chan];
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-
-	sc->avma1pp_cmd &= ~HSCX_CMD_XME;
-	sc->avma1pp_txl = 0;
-	if (Bchan->out_mbuf_cur == NULL)
-	{
-	  if (Bchan->bprot != BPROT_NONE)
-		 sc->avma1pp_cmd |= HSCX_CMD_XME;
-	}
-	if (len != sc->sc_bfifolen)
-		sc->avma1pp_txl = len;
-	
-	cnt = 0; /* borrow cnt */
-	AVMA1PPSETCMDLONG(cnt);
-	hscx_write_reg(chan, HSCX_STAT, cnt, sc);
-
-	ip = (u_int32_t *)buf;
-	cnt = 0;
-	while (cnt < len)
-	{
-		bus_space_write_4(btag, bhandle, ISAC_REG_OFFSET, *ip);
-		ip++;
-		cnt += 4;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM write register routines
- *---------------------------------------------------------------------------*/
-
-static void
-avma1pp_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	u_char reg_bank;
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET;
-#ifdef AVMA1PCI_DEBUG
-			printf("write_reg bank %d  off %ld.. ", (int)reg_bank, (long)offs);
-#endif
-			/* set the register bank */
-			bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, reg_bank);
-			bus_space_write_1(btag, bhandle, ISAC_REG_OFFSET + (offs & ISAC_REGSET_MASK), data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			hscx_write_reg(0, offs, data, sc);
-			break;
-		case ISIC_WHAT_HSCXB:
-			hscx_write_reg(1, offs, data, sc);
-			break;
-	}
-}
-
-static void
-hscx_write_reg(int chan, u_int off, u_int val, struct l1_softc *sc)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	/* point at the correct channel */
-	bus_space_write_4(btag, bhandle, ADDR_REG_OFFSET, chan);
-	bus_space_write_4(btag, bhandle, ISAC_REG_OFFSET + off, val);
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM read register routines
- *---------------------------------------------------------------------------*/
-static u_int8_t
-avma1pp_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	u_char reg_bank;
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET;
-#ifdef AVMA1PCI_DEBUG
-			printf("read_reg bank %d  off %ld.. ", (int)reg_bank, (long)offs);
-#endif
-			/* set the register bank */
-			bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, reg_bank);
-			return(bus_space_read_1(btag, bhandle, ISAC_REG_OFFSET +
-				(offs & ISAC_REGSET_MASK)));
-		case ISIC_WHAT_HSCXA:
-			return hscx_read_reg(0, offs, sc);
-		case ISIC_WHAT_HSCXB:
-			return hscx_read_reg(1, offs, sc);
-	}
-	return 0;
-}
-
-static u_char
-hscx_read_reg(int chan, u_int off, struct l1_softc *sc)
-{
-	return(hscx_read_reg_int(chan, off, sc) & 0xff);
-}
-
-/*
- * need to be able to return an int because the RBCH is in the 2nd
- * byte.
- */
-static u_int
-hscx_read_reg_int(int chan, u_int off, struct l1_softc *sc)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	/* point at the correct channel */
-	bus_space_write_4(btag, bhandle, ADDR_REG_OFFSET, chan);
-	return(bus_space_read_4(btag, bhandle, ISAC_REG_OFFSET + off));
-}
-
-/*---------------------------------------------------------------------------*
- *	avma1pp_probe - probe for a card
- *---------------------------------------------------------------------------*/
-static int
-avma1pp_pci_probe(dev)
-	device_t		dev;
-{
-	u_int16_t		did, vid;
-
-	vid = pci_get_vendor(dev);
-	did = pci_get_device(dev);
-
-	if ((vid == PCI_AVMA1_VID) && (did == PCI_AVMA1_DID)) {
-		device_set_desc(dev, "AVM Fritz!Card PCI");
-		return(0);
-	}
-
-	return(ENXIO);
-}
-
-/*---------------------------------------------------------------------------*
- *	avma1pp_attach_avma1pp - attach Fritz!Card PCI
- *---------------------------------------------------------------------------*/
-int
-avma1pp_attach_avma1pp(device_t dev)
-{
-	struct l1_softc *sc;
-	u_int v;
-	int unit, error = 0;
-	int s;
-	u_int16_t did, vid;
-	void *ih = 0;
-	bus_space_handle_t bhandle;
-	bus_space_tag_t btag; 
-	l1_bchan_state_t *chan;
-
-	s = splimp();
-
-	vid = pci_get_vendor(dev);
-	did = pci_get_device(dev);
-	sc = device_get_softc(dev);
-	unit = device_get_unit(dev);
-	bzero(sc, sizeof(struct l1_softc));
-
-	/* probably not really required */
-	if(unit >= IFPI_MAXUNIT) {
-		printf("avma1pp%d: Error, unit >= IFPI_MAXUNIT!\n", unit);
-		splx(s);
-		return(ENXIO);
-	}
-
-	if ((vid != PCI_AVMA1_VID) && (did != PCI_AVMA1_DID)) {
-		printf("avma1pp%d: unknown device!?\n", unit);
-		goto fail;
-	}
-
-	ifpi_scp[unit] = sc;
-
-	sc->sc_resources.io_rid[0] = PCIR_BAR(1);
-	sc->sc_resources.io_base[0] = bus_alloc_resource_any(dev,
-		SYS_RES_IOPORT, &sc->sc_resources.io_rid[0], RF_ACTIVE);
-
-	if (sc->sc_resources.io_base[0] == NULL) {
-		printf("avma1pp%d: couldn't map IO port\n", unit);
-		error = ENXIO;
-		goto fail;
-	}
-
-	bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	/* Allocate interrupt */
-	sc->sc_resources.irq_rid = 0;
-	sc->sc_resources.irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
-		&sc->sc_resources.irq_rid, RF_SHAREABLE | RF_ACTIVE);
-
-	if (sc->sc_resources.irq == NULL) {
-		bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(1), sc->sc_resources.io_base[0]);
-		printf("avma1pp%d: couldn't map interrupt\n", unit);
-		error = ENXIO;
-		goto fail;
-	}
-
-	error = bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET, avma1pp_intr, sc, &ih);
-
-	if (error) {
-		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_resources.irq);
-		bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(1), sc->sc_resources.io_base[0]);
-		printf("avma1pp%d: couldn't set up irq\n", unit);
-		goto fail;
-	}
-
-	sc->sc_unit = unit;
-
-	/* end of new-bus stuff */
-
-	ISAC_BASE = (caddr_t)ISIC_WHAT_ISAC;
-
-	HSCX_A_BASE = (caddr_t)ISIC_WHAT_HSCXA;
-	HSCX_B_BASE = (caddr_t)ISIC_WHAT_HSCXB;
-
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = avma1pp_read_reg;
-	sc->writereg = avma1pp_write_reg;
-
-	sc->readfifo = avma1pp_read_fifo;
-	sc->writefifo = avma1pp_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_AVMA1PCI;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	/* set up some other miscellaneous things */
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* reset the card */
-	/* the Linux driver does this to clear any pending ISAC interrupts */
-	v = 0;
-	v = ISAC_READ(I_STAR);
-#ifdef AVMA1PCI_DEBUG
-	printf("avma1pp_attach: I_STAR %x...", v);
-#endif
-	v = ISAC_READ(I_MODE);
-#ifdef AVMA1PCI_DEBUG
-	printf("avma1pp_attach: I_MODE %x...", v);
-#endif
-	v = ISAC_READ(I_ADF2);
-#ifdef AVMA1PCI_DEBUG
-	printf("avma1pp_attach: I_ADF2 %x...", v);
-#endif
-	v = ISAC_READ(I_ISTA);
-#ifdef AVMA1PCI_DEBUG
-	printf("avma1pp_attach: I_ISTA %x...", v);
-#endif
-	if (v & ISAC_ISTA_EXI)
-	{
-		 v = ISAC_READ(I_EXIR);
-#ifdef AVMA1PCI_DEBUG
-		 printf("avma1pp_attach: I_EXIR %x...", v);
-#endif
-	}
-	v = ISAC_READ(I_CIRR);
-#ifdef AVMA1PCI_DEBUG
-	printf("avma1pp_attach: I_CIRR %x...", v);
-#endif
-	ISAC_WRITE(I_MASK, 0xff);
-	/* the Linux driver does this to clear any pending HSCX interrupts */
-	v = hscx_read_reg_int(0, HSCX_STAT, sc);
-#ifdef AVMA1PCI_DEBUG
-	printf("avma1pp_attach: 0 HSCX_STAT %x...", v);
-#endif
-	v = hscx_read_reg_int(1, HSCX_STAT, sc);
-#ifdef AVMA1PCI_DEBUG
-	printf("avma1pp_attach: 1 HSCX_STAT %x\n", v);
-#endif
-
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_TIMERRESET|ASL_ENABLE_INT|ASL_TIMERDISABLE);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-#ifdef AVMA1PCI_DEBUG
-	bus_space_write_1(btag, bhandle, STAT1_OFFSET, ASL1_ENABLE_IOM|sc->sc_irq);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-	v = bus_space_read_1(btag, bhandle, STAT1_OFFSET);
-	printf("after reset: S1 %#x\n", v);
-
-	v = bus_space_read_4(btag, bhandle, 0);
-	printf("avma1pp_attach_avma1pp: v %#x\n", v);
-#endif
-
-   /* from here to the end would normally be done in isic_pciattach */
-
-	 printf("ifpi%d: ISAC %s (IOM-%c)\n", unit,
-  		"2085 Version A1/A2 or 2086/2186 Version 1.1",
-		 sc->sc_bustyp == BUS_TYPE_IOM1 ? '1' : '2');
-
-	/* init the ISAC */
-	ifpi_isac_init(sc);
-
-#if defined (__FreeBSD__) && __FreeBSD__ > 4
-	/* Init the channel mutexes */
-	chan = &sc->sc_chan[HSCX_CH_A];
-	if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
-		mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp_rx", NULL, MTX_DEF);
-	if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
-		mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp_tx", NULL, MTX_DEF);
-	chan = &sc->sc_chan[HSCX_CH_B];
-	if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
-		mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp_rx", NULL, MTX_DEF);
-	if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
-		mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp_tx", NULL, MTX_DEF);
-#endif
-
-	/* init the "HSCX" */
-	avma1pp_bchannel_setup(sc->sc_unit, HSCX_CH_A, BPROT_NONE, 0);
-	
-	avma1pp_bchannel_setup(sc->sc_unit, HSCX_CH_B, BPROT_NONE, 0);
-
-	/* can't use the normal B-Channel stuff */
-	avma1pp_init_linktab(sc);
-
-	/* set trace level */
-
-	sc->sc_trace = TRACE_OFF;
-
-	sc->sc_state = ISAC_IDLE;
-
-	sc->sc_ibuf = NULL;
-	sc->sc_ib = NULL;
-	sc->sc_ilen = 0;
-
-	sc->sc_obuf = NULL;
-	sc->sc_op = NULL;
-	sc->sc_ol = 0;
-	sc->sc_freeflag = 0;
-
-	sc->sc_obuf2 = NULL;
-	sc->sc_freeflag2 = 0;
-
-#if defined(__FreeBSD__) && __FreeBSD__ >=3
-	callout_handle_init(&sc->sc_T3_callout);
-	callout_handle_init(&sc->sc_T4_callout);	
-#endif
-	
-	/* init higher protocol layers */
-	
-	i4b_l1_mph_status_ind(L0IFPIUNIT(sc->sc_unit), STI_ATTACH, sc->sc_cardtyp, &avma1pp_l1mux_func);
-
-  fail:
-	splx(s);
-	return(error);
-}
-
-/*
- * this is the real interrupt routine
- */
-static void
-avma1pp_hscx_intr(int h_chan, u_int stat, struct l1_softc *sc)
-{
-	register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int activity = -1;
-	u_int param = 0;
-	
-	NDBGL1(L1_H_IRQ, "%#x", stat);
-
-	if((stat & HSCX_INT_XDU) && (chan->bprot != BPROT_NONE))/* xmit data underrun */
-	{
-		chan->stat_XDU++;			
-		NDBGL1(L1_H_XFRERR, "xmit data underrun");
-		/* abort the transmission */
-		sc->avma1pp_txl = 0;
-		sc->avma1pp_cmd |= HSCX_CMD_XRS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, HSCX_STAT, param, sc);
-		sc->avma1pp_cmd &= ~HSCX_CMD_XRS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, HSCX_STAT, param, sc);
-
-		if (chan->out_mbuf_head != NULL)  /* don't continue to transmit this buffer */
-		{
-			i4b_Bfreembuf(chan->out_mbuf_head);
-			chan->out_mbuf_cur = chan->out_mbuf_head = NULL;
-		}
-	}
-
-	/*
-	 * The following is based on examination of the Linux driver.
-	 *
-	 * The logic here is different than with a "real" HSCX; all kinds
-	 * of information (interrupt/status bits) are in stat.
-	 *		HSCX_INT_RPR indicates a receive interrupt
-	 *			HSCX_STAT_RDO indicates an overrun condition, abort -
-	 *			otherwise read the bytes ((stat & HSCX_STZT_RML_MASK) >> 8)
-	 *			HSCX_STAT_RME indicates end-of-frame and apparently any
-	 *			CRC/framing errors are only reported in this state.
-	 *				if ((stat & HSCX_STAT_CRCVFRRAB) != HSCX_STAT_CRCVFR)
-	 *					CRC/framing error
-	 */
-	
-	if(stat & HSCX_INT_RPR)
-	{
-		register int fifo_data_len;
-		int error = 0;
-		/* always have to read the FIFO, so use a scratch buffer */
-		u_char scrbuf[HSCX_FIFO_LEN];
-
-		if(stat & HSCX_STAT_RDO)
-		{
-			chan->stat_RDO++;
-			NDBGL1(L1_H_XFRERR, "receive data overflow");
-			error++;				
-		}
-
-		/*
-		 * check whether we're receiving data for an inactive B-channel
-		 * and discard it. This appears to happen for telephony when
-		 * both B-channels are active and one is deactivated. Since
-		 * it is not really possible to deactivate the channel in that
-		 * case (the ASIC seems to deactivate _both_ channels), the
-		 * "deactivated" channel keeps receiving data which can lead
-		 * to exhaustion of mbufs and a kernel panic.
-		 *
-		 * This is a hack, but it's the only solution I can think of
-		 * without having the documentation for the ASIC.
-		 * GJ - 28 Nov 1999
-		 */
-		 if (chan->state == HSCX_IDLE)
-		 {
-			NDBGL1(L1_H_XFRERR, "toss data from %d", h_chan);
-			error++;
-		 }
-
-		fifo_data_len = ((stat & HSCX_STAT_RML_MASK) >> 8);
-		
-		if(fifo_data_len == 0)
-			fifo_data_len = sc->sc_bfifolen;
-
-		/* ALWAYS read data from HSCX fifo */
-	
-		HSCX_RDFIFO(h_chan, scrbuf, fifo_data_len);
-		chan->rxcount += fifo_data_len;
-
-		/* all error conditions checked, now decide and take action */
-		
-		if(error == 0)
-		{
-			if(chan->in_mbuf == NULL)
-			{
-				if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-					panic("L1 avma1pp_hscx_intr: RME, cannot allocate mbuf!\n");
-				chan->in_cbptr = chan->in_mbuf->m_data;
-				chan->in_len = 0;
-			}
-
-			if((chan->in_len + fifo_data_len) <= BCH_MAX_DATALEN)
-			{
-			   	/* OK to copy the data */
-				bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
-				chan->in_cbptr += fifo_data_len;
-				chan->in_len += fifo_data_len;
-
-				/* setup mbuf data length */
-					
-				chan->in_mbuf->m_len = chan->in_len;
-				chan->in_mbuf->m_pkthdr.len = chan->in_len;
-
-				if(sc->sc_trace & TRACE_B_RX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IFPIUNIT(sc->sc_unit);
-					hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_NT;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-				}
-
-				if (stat & HSCX_STAT_RME)
-				{
-				  if((stat & HSCX_STAT_CRCVFRRAB) == HSCX_STAT_CRCVFR)
-				  {
-					 (*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
-					 activity = ACT_RX;
-				
-					 /* mark buffer ptr as unused */
-					
-					 chan->in_mbuf = NULL;
-					 chan->in_cbptr = NULL;
-					 chan->in_len = 0;
-				  }
-				  else
-				  {
-						chan->stat_CRC++;
-						NDBGL1(L1_H_XFRERR, "CRC/RAB");
-					  if (chan->in_mbuf != NULL)
-					  {
-						  i4b_Bfreembuf(chan->in_mbuf);
-						  chan->in_mbuf = NULL;
-						  chan->in_cbptr = NULL;
-						  chan->in_len = 0;
-					  }
-				  }
-				}
-			} /* END enough space in mbuf */
-			else
-			{
-				 if(chan->bprot == BPROT_NONE)
-				 {
-					  /* setup mbuf data length */
-				
-					  chan->in_mbuf->m_len = chan->in_len;
-					  chan->in_mbuf->m_pkthdr.len = chan->in_len;
-
-					  if(sc->sc_trace & TRACE_B_RX)
-					  {
-							i4b_trace_hdr_t hdr;
-							hdr.unit = L0IFPIUNIT(sc->sc_unit);
-							hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-							hdr.dir = FROM_NT;
-							hdr.count = ++sc->sc_trace_bcount;
-							MICROTIME(hdr.time);
-							i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-						}
-
-					  if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len)))
-						 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);
-
-					  /* alloc new buffer */
-				
-					  if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-						 panic("L1 avma1pp_hscx_intr: RPF, cannot allocate new mbuf!\n");
-	
-					  /* setup new data ptr */
-				
-					  chan->in_cbptr = chan->in_mbuf->m_data;
-	
-					  /* OK to copy the data */
-					  bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
-
-					  chan->in_cbptr += fifo_data_len;
-					  chan->in_len = fifo_data_len;
-
-					  chan->rxcount += fifo_data_len;
-					}
-				 else
-					{
-					  NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RPF, in_len=%d", chan->in_len);
-					  chan->in_cbptr = chan->in_mbuf->m_data;
-					  chan->in_len = 0;
-					}
-			  }
-		} /* if(error == 0) */
-		else
-		{
-		  	/* land here for RDO */
-			if (chan->in_mbuf != NULL)
-			{
-				i4b_Bfreembuf(chan->in_mbuf);
-				chan->in_mbuf = NULL;
-				chan->in_cbptr = NULL;
-				chan->in_len = 0;
-			}
-			sc->avma1pp_txl = 0;
-			sc->avma1pp_cmd |= HSCX_CMD_RRS;
-			AVMA1PPSETCMDLONG(param);
-			hscx_write_reg(h_chan, HSCX_STAT, param, sc);
-			sc->avma1pp_cmd &= ~HSCX_CMD_RRS;
-			AVMA1PPSETCMDLONG(param);
-			hscx_write_reg(h_chan, HSCX_STAT, param, sc);
-		}
-	}
-
-
-	/* transmit fifo empty, new data can be written to fifo */
-	
-	if(stat & HSCX_INT_XPR)
-	{
-		/*
-		 * for a description what is going on here, please have
-		 * a look at isic_bchannel_start() in i4b_bchan.c !
-		 */
-
-		NDBGL1(L1_H_IRQ, "unit %d, chan %d - XPR, Tx Fifo Empty!", sc->sc_unit, h_chan);
-
-		if(chan->out_mbuf_cur == NULL) 	/* last frame is transmitted */
-		{
-			IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-
-			if(chan->out_mbuf_head == NULL)
-			{
-				chan->state &= ~HSCX_TX_ACTIVE;
-				(*chan->isic_drvr_linktab->bch_tx_queue_empty)(chan->isic_drvr_linktab->unit);
-			}
-			else
-			{
-				chan->state |= HSCX_TX_ACTIVE;
-				chan->out_mbuf_cur = chan->out_mbuf_head;
-				chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-				chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-
-				if(sc->sc_trace & TRACE_B_TX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IFPIUNIT(sc->sc_unit);
-					hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_TE;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-				}
-				
-				if(chan->bprot == BPROT_NONE)
-				{
-					if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-						activity = ACT_TX;
-				}
-				else
-				{
-					activity = ACT_TX;
-				}
-			}
-		}
-			
-		avma1pp_hscx_fifo(chan, sc);
-	}
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
-}
-
-/*
- * this is the main routine which checks each channel and then calls
- * the real interrupt routine as appropriate
- */
-static void
-avma1pp_hscx_int_handler(struct l1_softc *sc)
-{
-	u_int stat;
-
-	/* has to be a u_int because the byte count is in the 2nd byte */
-	stat = hscx_read_reg_int(0, HSCX_STAT, sc);
-	if (stat & HSCX_INT_MASK)
-	  avma1pp_hscx_intr(0, stat, sc);
-	stat = hscx_read_reg_int(1, HSCX_STAT, sc);
-	if (stat & HSCX_INT_MASK)
-	  avma1pp_hscx_intr(1, stat, sc);
-}
-
-static void
-avma1pp_disable(device_t dev)
-{
-	struct l1_softc *sc = device_get_softc(dev);
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE);
-}
-
-static void
-avma1pp_intr(void *xsc)
-{
-	u_char stat;
-	struct l1_softc *sc;
-	bus_space_handle_t bhandle;
-	bus_space_tag_t btag; 
-
-	sc = xsc;
-	bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	stat = bus_space_read_1(btag, bhandle, STAT0_OFFSET);
-	NDBGL1(L1_H_IRQ, "stat %x", stat);
-	/* was there an interrupt from this card ? */
-	if ((stat & ASL_IRQ_Pending) == ASL_IRQ_Pending)
-		return; /* no */
-	/* interrupts are low active */
-	if (!(stat & ASL_IRQ_TIMER))
-	  NDBGL1(L1_H_IRQ, "timer interrupt ???");
-	if (!(stat & ASL_IRQ_HSCX))
-	{
-	  NDBGL1(L1_H_IRQ, "HSCX");
-		avma1pp_hscx_int_handler(sc);
-	}
-	if (!(stat & ASL_IRQ_ISAC))
-	{
-	  NDBGL1(L1_H_IRQ, "ISAC");
-		ifpi_isac_intr(sc);
-	}
-}
-
-static void
-avma1pp_hscx_init(struct l1_softc *sc, int h_chan, int activate)
-{
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	u_int param = 0;
-
-	NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
-		sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
-
-	if (activate == 0)
-	{
-		/* only deactivate if both channels are idle */
-		if (sc->sc_chan[HSCX_CH_A].state != HSCX_IDLE ||
-			sc->sc_chan[HSCX_CH_B].state != HSCX_IDLE)
-		{
-			return;
-		}
-		sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
-		sc->avma1pp_prot = HSCX_MODE_TRANS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, HSCX_STAT, param, sc);
-		return;
-	}
-	if(chan->bprot == BPROT_RHDLC)
-	{
-		  NDBGL1(L1_BCHAN, "BPROT_RHDLC");
-
-		/* HDLC Frames, transparent mode 0 */
-		sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
-		sc->avma1pp_prot = HSCX_MODE_ITF_FLG;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, HSCX_STAT, param, sc);
-		sc->avma1pp_cmd = HSCX_CMD_XRS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, HSCX_STAT, param, sc);
-		sc->avma1pp_cmd = 0;
-	}
-	else
-	{
-		  NDBGL1(L1_BCHAN, "BPROT_NONE??");
-
-		/* Raw Telephony, extended transparent mode 1 */
-		sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
-		sc->avma1pp_prot = HSCX_MODE_TRANS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, HSCX_STAT, param, sc);
-		sc->avma1pp_cmd = HSCX_CMD_XRS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, HSCX_STAT, param, sc);
-		sc->avma1pp_cmd = 0;
-	}
-}
-
-static void
-avma1pp_bchannel_setup(int unit, int h_chan, int bprot, int activate)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-
-	int s = SPLI4B();
-	
-	if(activate == 0)
-	{
-		/* deactivation */
-		chan->state = HSCX_IDLE;
-		avma1pp_hscx_init(sc, h_chan, activate);
-	}
-		
-	NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
-		sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
-
-	/* general part */
-
-	chan->unit = sc->sc_unit;	/* unit number */
-	chan->channel = h_chan;		/* B channel */
-	chan->bprot = bprot;		/* B channel protocol */
-	chan->state = HSCX_IDLE;	/* B channel state */
-
-	/* receiver part */
-
-	chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-	i4b_Bcleanifq(&chan->rx_queue);	/* clean rx queue */
-
-	chan->rxcount = 0;		/* reset rx counter */
-	
-	i4b_Bfreembuf(chan->in_mbuf);	/* clean rx mbuf */
-
-	chan->in_mbuf = NULL;		/* reset mbuf ptr */
-	chan->in_cbptr = NULL;		/* reset mbuf curr ptr */
-	chan->in_len = 0;		/* reset mbuf data len */
-	
-	/* transmitter part */
-
-	chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
-	
-	i4b_Bcleanifq(&chan->tx_queue);	/* clean tx queue */
-
-	chan->txcount = 0;		/* reset tx counter */
-	
-	i4b_Bfreembuf(chan->out_mbuf_head);	/* clean tx mbuf */
-
-	chan->out_mbuf_head = NULL;	/* reset head mbuf ptr */
-	chan->out_mbuf_cur = NULL;	/* reset current mbuf ptr */	
-	chan->out_mbuf_cur_ptr = NULL;	/* reset current mbuf data ptr */
-	chan->out_mbuf_cur_len = 0;	/* reset current mbuf data cnt */
-	
-	if(activate != 0)
-	{
-		/* activation */
-		avma1pp_hscx_init(sc, h_chan, activate);
-		chan->state |= HSCX_AVMA1PP_ACTIVE;
-	}
-
-	splx(s);
-}
-
-static void
-avma1pp_bchannel_start(int unit, int h_chan)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int s;
-	int activity = -1;
-
-	s = SPLI4B();				/* enter critical section */
-	if(chan->state & HSCX_TX_ACTIVE)	/* already running ? */
-	{
-		splx(s);
-		return;				/* yes, leave */
-	}
-
-	/* get next mbuf from queue */
-	
-	IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-	
-	if(chan->out_mbuf_head == NULL)		/* queue empty ? */
-	{
-		splx(s);			/* leave critical section */
-		return;				/* yes, exit */
-	}
-
-	/* init current mbuf values */
-	
-	chan->out_mbuf_cur = chan->out_mbuf_head;
-	chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;	
-	
-	/* activity indicator for timeout handling */
-
-	if(chan->bprot == BPROT_NONE)
-	{
-		if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-			activity = ACT_TX;
-	}
-	else
-	{
-		activity = ACT_TX;
-	}
-
-	chan->state |= HSCX_TX_ACTIVE;		/* we start transmitting */
-	
-	if(sc->sc_trace & TRACE_B_TX)	/* if trace, send mbuf to trace dev */
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0IFPIUNIT(sc->sc_unit);
-		hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_bcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-	}			
-
-	avma1pp_hscx_fifo(chan, sc);
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
-
-	splx(s);	
-}
-
-/*---------------------------------------------------------------------------*
- *	return the address of isic drivers linktab	
- *---------------------------------------------------------------------------*/
-static isdn_link_t *
-avma1pp_ret_linktab(int unit, int channel)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan = &sc->sc_chan[channel];
-
-	return(&chan->isic_isdn_linktab);
-}
- 
-/*---------------------------------------------------------------------------*
- *	set the driver linktab in the b channel softc
- *---------------------------------------------------------------------------*/
-static void
-avma1pp_set_linktab(int unit, int channel, drvr_link_t *dlt)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan = &sc->sc_chan[channel];
-
-	chan->isic_drvr_linktab = dlt;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	initialize our local linktab
- *---------------------------------------------------------------------------*/
-static void
-avma1pp_init_linktab(struct l1_softc *sc)
-{
-	l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A];
-	isdn_link_t *lt = &chan->isic_isdn_linktab;
-
-	/* make sure the hardware driver is known to layer 4 */
-	/* avoid overwriting if already set */
-	if (ctrl_types[CTRL_PASSIVE].set_linktab == NULL)
-	{
-		ctrl_types[CTRL_PASSIVE].set_linktab = i4b_l1_set_linktab;
-		ctrl_types[CTRL_PASSIVE].get_linktab = i4b_l1_ret_linktab;
-	}
-
-	/* local setup */
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_A;
-	lt->bch_config = avma1pp_bchannel_setup;
-	lt->bch_tx_start = avma1pp_bchannel_start;
-	lt->bch_stat = avma1pp_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-                                                
-	chan = &sc->sc_chan[HSCX_CH_B];
-	lt = &chan->isic_isdn_linktab;
-
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_B;
-	lt->bch_config = avma1pp_bchannel_setup;
-	lt->bch_tx_start = avma1pp_bchannel_start;
-	lt->bch_stat = avma1pp_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-}
-
-/*
- * use this instead of isic_bchannel_stat in i4b_bchan.c because it's static
- */
-static void
-avma1pp_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int s;
-
-	s = SPLI4B();
-	
-	bsp->outbytes = chan->txcount;
-	bsp->inbytes = chan->rxcount;
-
-	chan->txcount = 0;
-	chan->rxcount = 0;
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	fill HSCX fifo with data from the current mbuf
- *	Put this here until it can go into i4b_hscx.c
- *---------------------------------------------------------------------------*/
-static int
-avma1pp_hscx_fifo(l1_bchan_state_t *chan, struct l1_softc *sc)
-{
-	int len;
-	int nextlen;
-	int i;
-	int cmd = 0;
-	/* using a scratch buffer simplifies writing to the FIFO */
-	u_char scrbuf[HSCX_FIFO_LEN];
-
-	len = 0;
-
-	/*
-	 * fill the HSCX tx fifo with data from the current mbuf. if
-	 * current mbuf holds less data than HSCX fifo length, try to
-	 * get the next mbuf from (a possible) mbuf chain. if there is
-	 * not enough data in a single mbuf or in a chain, then this
-	 * is the last mbuf and we tell the HSCX that it has to send
-	 * CRC and closing flag
-	 */
-	 
-	while(chan->out_mbuf_cur && len != sc->sc_bfifolen)
-	{
-		nextlen = min(chan->out_mbuf_cur_len, sc->sc_bfifolen - len);
-
-#ifdef NOTDEF
-		printf("i:mh=%p, mc=%p, mcp=%p, mcl=%d l=%d nl=%d # ",
-			chan->out_mbuf_head,
-			chan->out_mbuf_cur,			
-			chan->out_mbuf_cur_ptr,
-			chan->out_mbuf_cur_len,
-			len,
-			nextlen);
-#endif
-
-		cmd |= HSCX_CMDR_XTF;
-		/* collect the data in the scratch buffer */
-		for (i = 0; i < nextlen; i++)
-			scrbuf[i + len] = chan->out_mbuf_cur_ptr[i];
-
-		len += nextlen;
-		chan->txcount += nextlen;
-	
-		chan->out_mbuf_cur_ptr += nextlen;
-		chan->out_mbuf_cur_len -= nextlen;
-			
-		if(chan->out_mbuf_cur_len == 0) 
-		{
-			if((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL)
-			{
-				chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-				chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	
-				if(sc->sc_trace & TRACE_B_TX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IFPIUNIT(sc->sc_unit);
-					hdr.type = (chan->channel == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_TE;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-				}
-			}
-			else
-			{
-				if (chan->bprot != BPROT_NONE)
-					cmd |= HSCX_CMDR_XME;
-				i4b_Bfreembuf(chan->out_mbuf_head);
-				chan->out_mbuf_head = NULL;
-			}
-		}
-	}
-	/* write what we have from the scratch buf to the HSCX fifo */
-	if (len != 0)
-		HSCX_WRFIFO(chan->channel, scrbuf, len);
-	return(cmd);
-}
-
-/*---------------------------------------------------------------------------*
- *	ifpi - ISAC interrupt routine
- *---------------------------------------------------------------------------*/
-static void
-ifpi_isac_intr(struct l1_softc *sc)
-{
-	register u_char isac_irq_stat;
-
-	for(;;)
-	{
-		/* get isac irq status */
-		isac_irq_stat = ISAC_READ(I_ISTA);
-
-		if(isac_irq_stat)
-			ifpi_isac_irq(sc, isac_irq_stat); /* isac handler */
-		else
-			break;
-	}
-
-	ISAC_WRITE(I_MASK, 0xff);
-
-	DELAY(100);
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-}
-
-/*---------------------------------------------------------------------------*
- *	ifpi_recover - try to recover from irq lockup
- *---------------------------------------------------------------------------*/
-void
-ifpi_recover(struct l1_softc *sc)
-{
-	u_char byte;
-	
-	/* get isac irq status */
-
-	byte = ISAC_READ(I_ISTA);
-
-	NDBGL1(L1_ERROR, "  ISAC: ISTA = 0x%x", byte);
-	
-	if(byte & ISAC_ISTA_EXI)
-		NDBGL1(L1_ERROR, "  ISAC: EXIR = 0x%x", (u_char)ISAC_READ(I_EXIR));
-
-	if(byte & ISAC_ISTA_CISQ)
-	{
-		byte = ISAC_READ(I_CIRR);
-	
-		NDBGL1(L1_ERROR, "  ISAC: CISQ = 0x%x", byte);
-		
-		if(byte & ISAC_CIRR_SQC)
-			NDBGL1(L1_ERROR, "  ISAC: SQRR = 0x%x", (u_char)ISAC_READ(I_SQRR));
-	}
-
-	NDBGL1(L1_ERROR, "  ISAC: IMASK = 0x%x", ISAC_IMASK);
-
-	ISAC_WRITE(I_MASK, 0xff);	
-	DELAY(100);
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-}
--- sys/i4b/layer1/ifpi/i4b_ifpi_l1fsm.c
+++ /dev/null
@@ -1,509 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpi_l1fsm.c - AVM Fritz PCI layer 1 I.430 state machine
- *	------------------------------------------------------------
- *	$Id: i4b_ifpi_l1fsm.c,v 1.4 2000/05/29 15:41:41 hm Exp $ 
- *      last edit-date: [Mon May 29 15:23:15 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpi/i4b_ifpi_l1fsm.c,v 1.8 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer1/ifpi/i4b_ifpi_ext.h>
-
-#if DO_I4B_DEBUG
-static char *state_text[N_STATES] = {
-	"F3 Deactivated",
-	"F4 Awaiting Signal",
-	"F5 Identifying Input",
-	"F6 Synchronized",
-	"F7 Activated",
-	"F8 Lost Framing",
-	"Illegal State"	
-};
-
-static char *event_text[N_EVENTS] = {
-	"EV_PHAR PH_ACT_REQ",
-	"EV_T3 Timer 3 expired",
-	"EV_INFO0 INFO0 received",
-	"EV_RSY Level Detected",
-	"EV_INFO2 INFO2 received",
-	"EV_INFO48 INFO4 received",
-	"EV_INFO410 INFO4 received",
-	"EV_DR Deactivate Req",
-	"EV_PU Power UP",
-	"EV_DIS Disconnected",
-	"EV_EI Error Ind",
-	"Illegal Event"
-};
-#endif
-
-/* Function prototypes */
-
-static void timer3_expired (struct l1_softc *sc);
-static void T3_start (struct l1_softc *sc);
-static void T3_stop (struct l1_softc *sc);
-static void F_T3ex (struct l1_softc *sc);
-static void timer4_expired (struct l1_softc *sc);
-static void T4_start (struct l1_softc *sc);
-static void T4_stop (struct l1_softc *sc);
-static void F_AI8 (struct l1_softc *sc);
-static void F_AI10 (struct l1_softc *sc);
-static void F_I01 (struct l1_softc *sc);
-static void F_I02 (struct l1_softc *sc);
-static void F_I03 (struct l1_softc *sc);
-static void F_I2 (struct l1_softc *sc);
-static void F_ill (struct l1_softc *sc);
-static void F_NULL (struct l1_softc *sc);
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer3_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T3)
-	{
-		NDBGL1(L1_T_ERR, "state = %s", ifpi_printstate(sc));
-		sc->sc_I430T3 = 0;
-
-		/* XXX try some recovery here XXX */
-
-		ifpi_recover(sc);
-
-		sc->sc_init_tries++;	/* increment retry count */
-
-/*XXX*/		if(sc->sc_init_tries > 4)
-		{
-			int s = SPLI4B();
-
-			sc->sc_init_tries = 0;
-			
-			if(sc->sc_obuf2 != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf2);
-				sc->sc_obuf2 = NULL;
-			}
-			if(sc->sc_obuf != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf);
-				sc->sc_obuf = NULL;
-				sc->sc_freeflag = 0;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-			}
-
-			splx(s);
-
-			i4b_l1_mph_status_ind(L0IFPIUNIT(sc->sc_unit), STI_NOL1ACC, 0, NULL);
-		}
-		
-		ifpi_next_state(sc, EV_T3);		
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 start
- *---------------------------------------------------------------------------*/	
-static void
-T3_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpi_printstate(sc));
-	sc->sc_I430T3 = 1;
-	sc->sc_T3_callout = timeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, 2*hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 stop
- *---------------------------------------------------------------------------*/	
-static void
-T3_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpi_printstate(sc));
-
-	sc->sc_init_tries = 0;	/* init connect retry count */
-	
-	if(sc->sc_I430T3)
-	{
-		sc->sc_I430T3 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, sc->sc_T3_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_T3ex(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_T3ex executing");
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0IFPIUNIT(sc->sc_unit));
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer4_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T4)
-	{
-		NDBGL1(L1_T_MSG, "state = %s", ifpi_printstate(sc));
-		sc->sc_I430T4 = 0;
-		i4b_l1_mph_status_ind(L0IFPIUNIT(sc->sc_unit), STI_PDEACT, 0, NULL);
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 start
- *---------------------------------------------------------------------------*/	
-static void
-T4_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpi_printstate(sc));
-	sc->sc_I430T4 = 1;
-	sc->sc_T4_callout = timeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 stop
- *---------------------------------------------------------------------------*/	
-static void
-T4_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpi_printstate(sc));
-
-	if(sc->sc_I430T4)
-	{
-		sc->sc_I430T4 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, sc->sc_T4_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI8
- *---------------------------------------------------------------------------*/	
-static void
-F_AI8(struct l1_softc *sc)
-{
-	T4_stop(sc);
-
-	NDBGL1(L1_F_MSG, "FSM function F_AI8 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0IFPIUNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_8;
-		
-		hdr.unit = L0IFPIUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI10
- *---------------------------------------------------------------------------*/	
-static void
-F_AI10(struct l1_softc *sc)
-{
-	T4_stop(sc);
-	
-	NDBGL1(L1_F_MSG, "FSM function F_AI10 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0IFPIUNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_10;
-		
-		hdr.unit = L0IFPIUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in states F3 .. F5
- *---------------------------------------------------------------------------*/	
-static void
-F_I01(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I01 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0IFPIUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F6
- *---------------------------------------------------------------------------*/	
-static void
-F_I02(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I02 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0IFPIUNIT(sc->sc_unit));
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0IFPIUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F7 or F8
- *---------------------------------------------------------------------------*/	
-static void
-F_I03(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I03 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0IFPIUNIT(sc->sc_unit));
-
-	T4_start(sc);
-	
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0IFPIUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: activate request
- *---------------------------------------------------------------------------*/	
-static void
-F_AR(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_AR executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO1_8;
-		
-		hdr.unit = L0IFPIUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_TE;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-
-	ifpi_isac_l1_cmd(sc, CMD_AR8);
-
-	T3_start(sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO2
- *---------------------------------------------------------------------------*/	
-static void
-F_I2(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I2 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO2;
-		
-		hdr.unit = L0IFPIUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}		
-
-}
-
-/*---------------------------------------------------------------------------*
- *	illegal state default action
- *---------------------------------------------------------------------------*/	
-static void
-F_ill(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_ERR, "FSM function F_ill executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	No action
- *---------------------------------------------------------------------------*/	
-static void
-F_NULL(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_NULL executing");
-}
-
-
-/*---------------------------------------------------------------------------*
- *	layer 1 state transition table
- *---------------------------------------------------------------------------*/	
-struct ifpi_state_tab {
-	void (*func) (struct l1_softc *sc);	/* function to execute */
-	int newstate;				/* next state */
-} ifpi_state_tab[N_EVENTS][N_STATES] = {
-
-/* STATE:	F3			F4			F5			F6			F7			F8			ILLEGAL STATE     */
-/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/* EV_PHAR x*/	{{F_AR,   ST_F4},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_ill,  ST_ILL},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_T3   x*/	{{F_NULL, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO0 */	{{F_I01,  ST_F3},	{F_I01,  ST_F4},	{F_I01,  ST_F5},	{F_I02,  ST_F3},	{F_I03,  ST_F3},	{F_I03,  ST_F3},	{F_ill, ST_ILL}},
-/* EV_RSY  x*/	{{F_NULL, ST_F3},	{F_NULL, ST_F5},	{F_NULL, ST_F5}, 	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO2 */	{{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_ill, ST_ILL}},
-/* EV_INFO48*/	{{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_NULL, ST_F7},	{F_AI8,  ST_F7},	{F_ill, ST_ILL}},
-/* EV_INFO41*/	{{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_NULL, ST_F7},	{F_AI10, ST_F7},	{F_ill, ST_ILL}},
-/* EV_DR    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_PU    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_DIS   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}},
-/* EV_EI    */	{{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_ill, ST_ILL}},
-/* EV_ILL   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}}
-};
-
-/*---------------------------------------------------------------------------*
- *	event handler
- *---------------------------------------------------------------------------*/	
-void
-ifpi_next_state(struct l1_softc *sc, int event)
-{
-	int currstate, newstate;
-
-	if(event >= N_EVENTS)
-		panic("i4b_l1fsm.c: event >= N_EVENTS\n");
-
-	currstate = sc->sc_I430state;
-
-	if(currstate >= N_STATES)
-		panic("i4b_l1fsm.c: currstate >= N_STATES\n");	
-
-	newstate = ifpi_state_tab[event][currstate].newstate;
-
-	if(newstate >= N_STATES)
-		panic("i4b_l1fsm.c: newstate >= N_STATES\n");	
-	
-	NDBGL1(L1_F_MSG, "FSM event [%s]: [%s => %s]", event_text[event],
-                                           state_text[currstate],
-                                           state_text[newstate]);
-
-        (*ifpi_state_tab[event][currstate].func)(sc);
-
-	if(newstate == ST_ILL)
-	{
-		newstate = ST_F3;
-		NDBGL1(L1_F_ERR, "FSM Illegal State ERROR, oldstate = %s, newstate = %s, event = %s!",
-					state_text[currstate],
-					state_text[newstate],
-					event_text[event]);
-	}
-
-	sc->sc_I430state = newstate;
-}
-
-#if DO_I4B_DEBUG
-/*---------------------------------------------------------------------------*
- *	return pointer to current state description
- *---------------------------------------------------------------------------*/	
-char *
-ifpi_printstate(struct l1_softc *sc)
-{
-	return((char *) state_text[sc->sc_I430state]);
-}
-#endif
--- sys/i4b/layer1/ifpi/i4b_ifpi_ext.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright (c) 2000 Gary Jennejohn. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_ifpi - Fritz!Card PCI for split layers
- *      ------------------------------------------
- *
- *	$Id: i4b_ifpi_ext.h,v 1.2 2000/06/02 16:14:36 hm Exp $
- *
- * $FreeBSD: src/sys/i4b/layer1/ifpi/i4b_ifpi_ext.h,v 1.2 2005/01/06 22:18:19 imp Exp $
- *
- *      last edit-date: [Fri Jun  2 14:53:31 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_IFPI_EXT_H_
-#define _I4B_IFPI_EXT_H_
-
-#include <i4b/include/i4b_l3l4.h>
-
-void ifpi_set_linktab(int unit, int channel, drvr_link_t * dlt);
-isdn_link_t *ifpi_ret_linktab(int unit, int channel);
-
-int ifpi_ph_data_req(int unit, struct mbuf *m, int freeflag);
-int ifpi_ph_activate_req(int unit);
-int ifpi_mph_command_req(int unit, int command, void *parm);
-
-void ifpi_isac_irq(struct l1_softc *sc, int ista);
-void ifpi_isac_l1_cmd(struct l1_softc *sc, int command);
-int ifpi_isac_init(struct l1_softc *sc);
-
-void ifpi_recover(struct l1_softc *sc);
-char * ifpi_printstate(struct l1_softc *sc);
-void ifpi_next_state(struct l1_softc *sc, int event);
-
-#define IFPI_MAXUNIT 4
-extern struct l1_softc *ifpi_scp[IFPI_MAXUNIT];
-
-#endif /* _I4B_IFPI_EXT_H_ */
--- sys/i4b/layer1/ifpi2/i4b_ifpi2_ext.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * Copyright (c) 2001 Gary Jennejohn. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_ifpi2 - Fritz!Card PCI Version 2 for split layers
- *      ------------------------------------------
- *
- *	$Id$
- *
- * $FreeBSD: src/sys/i4b/layer1/ifpi2/i4b_ifpi2_ext.h,v 1.2 2005/01/06 22:18:19 imp Exp $
- *
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_IFPI2_EXT_H_
-#define _I4B_IFPI2_EXT_H_
-
-#include <i4b/include/i4b_l3l4.h>
-
-void ifpi2_set_linktab(int , int , drvr_link_t * );
-isdn_link_t *ifpi2_ret_linktab(int , int );
-
-int ifpi2_ph_data_req(int , struct mbuf *, int );
-int ifpi2_ph_activate_req(int );
-int ifpi2_mph_command_req(int , int , void *);
-
-void ifpi2_isacsx_irq(struct l1_softc *, int );
-void ifpi2_isacsx_l1_cmd(struct l1_softc *, int );
-int ifpi2_isacsx_init(struct l1_softc *);
-
-void ifpi2_recover(struct l1_softc *);
-char * ifpi2_printstate(struct l1_softc *);
-void ifpi2_next_state(struct l1_softc *, int );
-
-#define IFPI2_MAXUNIT 4
-extern struct l1_softc *ifpi2_scp[IFPI2_MAXUNIT];
-
-/* the ISACSX has 2 mask registers of interest - cannot use ISAC_IMASK */
-extern unsigned char isacsx_imaskd;
-extern unsigned char isacsx_imask;
-
-#endif /* _I4B_IFPI2_EXT_H_ */
--- sys/i4b/layer1/ifpi2/i4b_ifpi2_isacsx.c
+++ /dev/null
@@ -1,593 +0,0 @@
-/*-
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
- * Copyright (c) 2001 Gary Jennejohn. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpi2_isac.c - i4b Fritz PCI Version 2 ISACSX handler
- *	--------------------------------------------
- *	$Id$ 
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpi2/i4b_ifpi2_isacsx.c,v 1.5 2005/01/06 22:18:19 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/layer1/ifpi2/i4b_ifpi2_ext.h>
-#include <i4b/layer1/ifpi2/i4b_ifpi2_isacsx.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-static u_char ifpi2_isacsx_exir_hdlr(register struct l1_softc *sc, u_char exir);
-static void ifpi2_isacsx_ind_hdlr(register struct l1_softc *sc, int ind);
-
-/* the ISACSX has 2 mask registers of interest - cannot use ISAC_IMASK */
-unsigned char isacsx_imaskd;
-unsigned char isacsx_imask;
-
-/*---------------------------------------------------------------------------*
- *	ISACSX interrupt service routine
- *---------------------------------------------------------------------------*/
-void
-ifpi2_isacsx_irq(struct l1_softc *sc, int ista)
-{
-	register u_char c = 0;
-	register u_char istad = 0;
-
-	NDBGL1(L1_F_MSG, "unit %d: ista = 0x%02x", sc->sc_unit, ista);
-
-	/* was it an HDLC interrupt ? */
-	if (ista & ISACSX_ISTA_ICD)
-	{
-		istad = ISAC_READ(I_ISTAD);
-		NDBGL1(L1_F_MSG, "unit %d: istad = 0x%02x", sc->sc_unit, istad);
-
-		if(istad & (ISACSX_ISTAD_RFO|ISACSX_ISTAD_XMR|ISACSX_ISTAD_XDU))
-		{
-			/* not really EXIR, but very similar */
-			c |= ifpi2_isacsx_exir_hdlr(sc, istad);
-		}
-	}
-	
-	if(istad & ISACSX_ISTAD_RME)	/* receive message end */
-	{
-		register int rest;
-		u_char rsta;
-
-		/* get rx status register */
-		
-		rsta = ISAC_READ(I_RSTAD);
-
-		/* Check for Frame and CRC valid */
-		if((rsta & ISACSX_RSTAD_MASK) != (ISACSX_RSTAD_VFR|ISACSX_RSTAD_CRC))
-		{
-			int error = 0;
-			
-			if(!(rsta & ISACSX_RSTAD_VFR))	/* VFR error */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Frame not valid error", sc->sc_unit);
-			}
-	
-			if(!(rsta & ISACSX_RSTAD_CRC))	/* CRC error */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: CRC error", sc->sc_unit);
-			}
-	
-			if(rsta & ISACSX_RSTAD_RDO)	/* ReceiveDataOverflow */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Data Overrun error", sc->sc_unit);
-			}
-	
-			if(rsta & ISACSX_RSTAD_RAB)	/* ReceiveABorted */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Receive Aborted error", sc->sc_unit);
-			}
-
-			if(error == 0)			
-				NDBGL1(L1_I_ERR, "unit %d: RME unknown error, RSTAD = 0x%02x!", sc->sc_unit, rsta);
-
-			i4b_Dfreembuf(sc->sc_ibuf);
-
-			c |= ISACSX_CMDRD_RMC|ISACSX_CMDRD_RRES;
-
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-
-			ISAC_WRITE(I_CMDRD, ISACSX_CMDRD_RMC|ISACSX_CMDRD_RRES);
-
-			return;
-		}
-
-		rest = (ISAC_READ(I_RBCLD) & (ISACSX_FIFO_LEN-1));
-
-		if(rest == 0)
-			rest = ISACSX_FIFO_LEN;
-
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(rest)) != NULL)
-				sc->sc_ib = sc->sc_ibuf->m_data;
-			else
-				panic("ifpi2_isacsx_irq: RME, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - rest))
-		{
-			ISAC_RDFIFO(sc->sc_ib, rest);
-			 /* the  last byte contains status, strip it */
-			sc->sc_ilen += rest - 1;
-			
-			sc->sc_ibuf->m_pkthdr.len =
-				sc->sc_ibuf->m_len = sc->sc_ilen;
-
-			if(sc->sc_trace & TRACE_D_RX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_NT;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, sc->sc_ibuf->m_len, sc->sc_ibuf->m_data);
-			}
-
-			c |= ISACSX_CMDRD_RMC;
-
-			if(sc->sc_enabled &&
-			   (ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S))
-			{
-				i4b_l1_ph_data_ind(L0IFPI2UNIT(sc->sc_unit), sc->sc_ibuf);
-			}
-			else
-			{
-				i4b_Dfreembuf(sc->sc_ibuf);
-			}
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RME, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			c |= ISACSX_CMDRD_RMC|ISACSX_CMDRD_RRES;
-		}
-
-		sc->sc_ibuf = NULL;
-		sc->sc_ib = NULL;
-		sc->sc_ilen = 0;
-	}
-
-	if(istad & ISACSX_ISTAD_RPF)	/* receive fifo full */
-	{
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(MAX_DFRAME_LEN)) != NULL)
-				sc->sc_ib= sc->sc_ibuf->m_data;
-			else
-				panic("ifpi2_isacsx_irq: RPF, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - ISACSX_FIFO_LEN))
-		{
-			ISAC_RDFIFO(sc->sc_ib, ISACSX_FIFO_LEN);
-			sc->sc_ilen += ISACSX_FIFO_LEN;			
-			sc->sc_ib += ISACSX_FIFO_LEN;
-			c |= ISACSX_CMDRD_RMC;
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RPF, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-			c |= ISACSX_CMDRD_RMC|ISACSX_CMDRD_RRES;			
-		}
-	}
-
-	if(istad & ISACSX_ISTAD_XPR)	/* transmit fifo empty (XPR bit set) */
-	{
-		if((sc->sc_obuf2 != NULL) && (sc->sc_obuf == NULL))
-		{
-			sc->sc_freeflag = sc->sc_freeflag2;
-			sc->sc_obuf = sc->sc_obuf2;
-			sc->sc_op = sc->sc_obuf->m_data;
-			sc->sc_ol = sc->sc_obuf->m_len;
-			sc->sc_obuf2 = NULL;
-#ifdef NOTDEF			
-			printf("ob2=%x, op=%x, ol=%d, f=%d #",
-				sc->sc_obuf,
-				sc->sc_op,
-				sc->sc_ol,
-				sc->sc_state);
-#endif				
-		}
-		else
-		{
-#ifdef NOTDEF
-			printf("ob=%x, op=%x, ol=%d, f=%d #",
-				sc->sc_obuf,
-				sc->sc_op,
-				sc->sc_ol,
-				sc->sc_state);
-#endif
-		}			
-		
-		if(sc->sc_obuf)
-		{			
-			ISAC_WRFIFO(sc->sc_op, min(sc->sc_ol, ISACSX_FIFO_LEN));
-	
-			if(sc->sc_ol > ISACSX_FIFO_LEN)	/* length > 32 ? */
-			{
-				sc->sc_op += ISACSX_FIFO_LEN; /* bufferptr+32 */
-				sc->sc_ol -= ISACSX_FIFO_LEN; /* length - 32 */
-				c |= ISACSX_CMDRD_XTF;	    /* set XTF bit */
-			}
-			else
-			{
-				if(sc->sc_freeflag)
-				{
-					i4b_Dfreembuf(sc->sc_obuf);
-					sc->sc_freeflag = 0;
-				}
-				sc->sc_obuf = NULL;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-	
-				c |= ISACSX_CMDRD_XTF | ISACSX_CMDRD_XME;
-			}
-		}
-		else
-		{
-			sc->sc_state &= ~ISAC_TX_ACTIVE;
-		}
-	}
-	
-	if(ista & ISACSX_ISTA_CIC)	/* channel status change CISQ */
-	{
-		register u_char ci;
-	
-		/* get command/indication rx register*/
-	
-		ci = ISAC_READ(I_CIR0);
-
-		/* C/I code change IRQ (flag already cleared by CIR0 read) */
-	
-		if(ci & ISACSX_CIR0_CIC0)
-			ifpi2_isacsx_ind_hdlr(sc, (ci >> 4) & 0xf);
-	}
-	
-	if(c)
-	{
-		ISAC_WRITE(I_CMDRD, c);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	ISACSX L1 Extended IRQ handler
- *---------------------------------------------------------------------------*/
-static u_char
-ifpi2_isacsx_exir_hdlr(register struct l1_softc *sc, u_char exir)
-{
-	u_char c = 0;
-	
-	if(exir & ISACSX_ISTAD_XMR)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Message Repeat");
-
-		c |= ISACSX_CMDRD_XRES;
-	}
-	
-	if(exir & ISACSX_ISTAD_XDU)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Data Underrun");
-
-		c |= ISACSX_CMDRD_XRES;
-	}
-
-	if(exir & ISACSX_ISTAD_RFO)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Rx Frame Overflow");
-
-		c |= ISACSX_CMDRD_RMC;
-	}
-
-#if 0 /* all blocked per default */
-	if(exir & ISACSX_EXIR_SOV)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Sync Xfer Overflow");
-	}
-
-	if(exir & ISACSX_EXIR_MOS)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Monitor Status");
-	}
-
-	if(exir & ISACSX_EXIR_SAW)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-		
-		NDBGL1(L1_I_ERR, "EXIRQ Subscriber Awake");
-	}
-
-	if(exir & ISACSX_EXIR_WOV)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-
-		NDBGL1(L1_I_ERR, "EXIRQ Watchdog Timer Overflow");
-	}
-#endif
-
-	return(c);
-}
-
-/*---------------------------------------------------------------------------*
- *	ISACSX L1 Indication handler
- *---------------------------------------------------------------------------*/
-static void
-ifpi2_isacsx_ind_hdlr(register struct l1_softc *sc, int ind)
-{
-	register int event;
-	
-	switch(ind)
-	{
-		case ISACSX_CIR0_IAI8:
-			NDBGL1(L1_I_CICO, "rx AI8 in state %s", ifpi2_printstate(sc));
-			if(sc->sc_bustyp == BUS_TYPE_IOM2)
-				ifpi2_isacsx_l1_cmd(sc, CMD_AR8);
-			event = EV_INFO48;
-			i4b_l1_mph_status_ind(L0IFPI2UNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-			
-		case ISACSX_CIR0_IAI10:
-			NDBGL1(L1_I_CICO, "rx AI10 in state %s", ifpi2_printstate(sc));
-			if(sc->sc_bustyp == BUS_TYPE_IOM2)
-				ifpi2_isacsx_l1_cmd(sc, CMD_AR10);
-			event = EV_INFO410;
-			i4b_l1_mph_status_ind(L0IFPI2UNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-
-		case ISACSX_CIR0_IRSY:
-			NDBGL1(L1_I_CICO, "rx RSY in state %s", ifpi2_printstate(sc));
-			event = EV_RSY;
-			break;
-
-		case ISACSX_CIR0_IPU:
-			NDBGL1(L1_I_CICO, "rx PU in state %s", ifpi2_printstate(sc));
-			event = EV_PU;
-			break;
-
-		case ISACSX_CIR0_IDR:
-			NDBGL1(L1_I_CICO, "rx DR in state %s", ifpi2_printstate(sc));
-			ifpi2_isacsx_l1_cmd(sc, CMD_DIU);
-			event = EV_DR;			
-			break;
-			
-		case ISACSX_CIR0_IDID:
-			NDBGL1(L1_I_CICO, "rx DID in state %s", ifpi2_printstate(sc));
-			event = EV_INFO0;
-			i4b_l1_mph_status_ind(L0IFPI2UNIT(sc->sc_unit), STI_L1STAT, LAYER_IDLE, NULL);
-			break;
-
-		case ISACSX_CIR0_IDIS:
-			NDBGL1(L1_I_CICO, "rx DIS in state %s", ifpi2_printstate(sc));
-			event = EV_DIS;
-			break;
-
-		case ISACSX_CIR0_IEI:
-			NDBGL1(L1_I_CICO, "rx EI in state %s", ifpi2_printstate(sc));
-			ifpi2_isacsx_l1_cmd(sc, CMD_DIU);
-			event = EV_EI;
-			break;
-
-		case ISACSX_CIR0_IARD:
-			NDBGL1(L1_I_CICO, "rx ARD in state %s", ifpi2_printstate(sc));
-			event = EV_INFO2;
-			break;
-
-		case ISACSX_CIR0_ITI:
-			NDBGL1(L1_I_CICO, "rx TI in state %s", ifpi2_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISACSX_CIR0_IATI:
-			NDBGL1(L1_I_CICO, "rx ATI in state %s", ifpi2_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISACSX_CIR0_ISD:
-			NDBGL1(L1_I_CICO, "rx SD in state %s", ifpi2_printstate(sc));
-			event = EV_INFO0;
-			break;
-		
-		default:
-			NDBGL1(L1_I_ERR, "UNKNOWN Indication 0x%x in state %s", ind, ifpi2_printstate(sc));
-			event = EV_INFO0;
-			break;
-	}
-	ifpi2_next_state(sc, event);
-}
-
-/*---------------------------------------------------------------------------*
- *	execute a layer 1 command
- *---------------------------------------------------------------------------*/	
-void
-ifpi2_isacsx_l1_cmd(struct l1_softc *sc, int command)
-{
-	u_char cmd;
-
-#ifdef I4B_SMP_WORKAROUND
-
-	/* XXXXXXXXXXXXXXXXXXX */
-	
-	/*
-	 * patch from Wolfgang Helbig:
-	 *
-	 * Here is a patch that makes i4b work on an SMP:
-	 * The card (TELES 16.3) didn't interrupt on an SMP machine.
-	 * This is a gross workaround, but anyway it works *and* provides
-	 * some information as how to finally fix this problem.
-	 */
-	
-	HSCX_WRITE(0, H_MASK, 0xff);
-	HSCX_WRITE(1, H_MASK, 0xff);
-	ISAC_WRITE(I_MASKD, 0xff);
-	ISAC_WRITE(I_MASK, 0xff);
-	DELAY(100);
-	HSCX_WRITE(0, H_MASK, HSCX_A_IMASK);
-	HSCX_WRITE(1, H_MASK, HSCX_B_IMASK);
-	ISAC_WRITE(I_MASKD, isacsx_imaskd);
-	ISAC_WRITE(I_MASK, isacsx_imask);
-
-	/* XXXXXXXXXXXXXXXXXXX */
-	
-#endif /* I4B_SMP_WORKAROUND */
-
-	if(command < 0 || command > CMD_ILL)
-	{
-		NDBGL1(L1_I_ERR, "illegal cmd 0x%x in state %s", command, ifpi2_printstate(sc));
-		return;
-	}
-                                           
-	cmd = ISACSX_CIX0_LOW;
-
-	switch(command)
-	{
-		case CMD_TIM:
-			NDBGL1(L1_I_CICO, "tx TIM in state %s", ifpi2_printstate(sc));
-			cmd |= (ISACSX_CIX0_CTIM << 4);
-			break;
-
-		case CMD_RS:
-			NDBGL1(L1_I_CICO, "tx RS in state %s", ifpi2_printstate(sc));
-			cmd |= (ISACSX_CIX0_CRS << 4);
-			break;
-
-		case CMD_AR8:
-			NDBGL1(L1_I_CICO, "tx AR8 in state %s", ifpi2_printstate(sc));
-			cmd |= (ISACSX_CIX0_CAR8 << 4);
-			break;
-
-		case CMD_AR10:
-			NDBGL1(L1_I_CICO, "tx AR10 in state %s", ifpi2_printstate(sc));
-			cmd |= (ISACSX_CIX0_CAR10 << 4);
-			break;
-
-		case CMD_DIU:
-			NDBGL1(L1_I_CICO, "tx DIU in state %s", ifpi2_printstate(sc));
-			cmd |= (ISACSX_CIX0_CDIU << 4);
-			break;
-	}
-	ISAC_WRITE(I_CIX0, cmd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L1 ISACSX initialization
- *---------------------------------------------------------------------------*/
-int
-ifpi2_isacsx_init(struct l1_softc *sc)
-{
-	isacsx_imaskd = 0xff;		/* disable all irqs */
-	isacsx_imask = 0xff;		/* disable all irqs */
-
-	ISAC_WRITE(I_MASKD, isacsx_imaskd);
-	ISAC_WRITE(I_MASK, isacsx_imask);
-
-	/* the ISACSX only runs in IOM-2 mode */
-	NDBGL1(L1_I_SETUP, "configuring for IOM-2 mode");
-
-	/* TR_CONF0: Transceiver Configuration Register 0:
-	 *	DIS_TR - transceiver enabled
-	 *	EN_ICV - normal operation
-	 *	EXLP - no external loop
-	 *	LDD - automatic clock generation
-	 */
-	ISAC_WRITE(I_WTR_CONF0, 0);
-
-	/* TR_CONF2: Transceiver Configuration Register 1:
-	 *	DIS_TX - transmitter enabled
-	 *	PDS - phase deviation 2 S-bits
-	 *	RLP - remote line loop open
-	 */
-	ISAC_WRITE(I_WTR_CONF2, 0);
-
-	/* MODED: Mode Register:
-	 *	MDSx - transparent mode 0
-	 *	TMD  - timer mode = external
-	 *	RAC  - Receiver enabled
-	 *	DIMx - digital i/f mode
-	 */
-	ISAC_WRITE(I_WMODED, ISACSX_MODED_MDS2|ISACSX_MODED_MDS1|ISACSX_MODED_RAC|ISACSX_MODED_DIM0);
-
-	/* enabled interrupts:
-	 * ===================
-	 * RME  - receive message end
-	 * RPF  - receive pool full
-	 * RPO  - receive pool overflow
-	 * XPR  - transmit pool ready
-	 * XMR  - transmit message repeat
-	 * XDU  - transmit data underrun
-	 */
-
-	isacsx_imaskd = ISACSX_MASKD_LOW;
-	ISAC_WRITE(I_MASKD, isacsx_imaskd);
-
-	/* enabled interrupts:
-	 * ===================
-	 * ICD - HDLC interrupt from D-channel
-	 * CIC - C/I channel change
-	 */
-
-	isacsx_imask = ~(ISACSX_MASK_ICD | ISACSX_MASK_CIC);
-
-	ISAC_WRITE(I_MASK, isacsx_imask);
-
-	return(0);
-}
--- sys/i4b/layer1/ifpi2/i4b_ifpi2_l1fsm.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpi2_l1fsm.c - AVM Fritz PCI layer 1 I.430 state machine
- *	------------------------------------------------------------
- *	$Id$ 
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpi2/i4b_ifpi2_l1fsm.c,v 1.5 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer1/ifpi2/i4b_ifpi2_ext.h>
-
-#if DO_I4B_DEBUG
-static char *state_text[N_STATES] = {
-	"F3 Deactivated",
-	"F4 Awaiting Signal",
-	"F5 Identifying Input",
-	"F6 Synchronized",
-	"F7 Activated",
-	"F8 Lost Framing",
-	"Illegal State"	
-};
-
-static char *event_text[N_EVENTS] = {
-	"EV_PHAR PH_ACT_REQ",
-	"EV_T3 Timer 3 expired",
-	"EV_INFO0 INFO0 received",
-	"EV_RSY Level Detected",
-	"EV_INFO2 INFO2 received",
-	"EV_INFO48 INFO4 received",
-	"EV_INFO410 INFO4 received",
-	"EV_DR Deactivate Req",
-	"EV_PU Power UP",
-	"EV_DIS Disconnected",
-	"EV_EI Error Ind",
-	"Illegal Event"
-};
-#endif
-
-/* Function prototypes */
-
-static void timer3_expired (struct l1_softc *sc);
-static void T3_start (struct l1_softc *sc);
-static void T3_stop (struct l1_softc *sc);
-static void F_T3ex (struct l1_softc *sc);
-static void timer4_expired (struct l1_softc *sc);
-static void T4_start (struct l1_softc *sc);
-static void T4_stop (struct l1_softc *sc);
-static void F_AI8 (struct l1_softc *sc);
-static void F_AI10 (struct l1_softc *sc);
-static void F_I01 (struct l1_softc *sc);
-static void F_I02 (struct l1_softc *sc);
-static void F_I03 (struct l1_softc *sc);
-static void F_I2 (struct l1_softc *sc);
-static void F_ill (struct l1_softc *sc);
-static void F_NULL (struct l1_softc *sc);
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer3_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T3)
-	{
-		NDBGL1(L1_T_ERR, "state = %s", ifpi2_printstate(sc));
-		sc->sc_I430T3 = 0;
-
-		/* XXX try some recovery here XXX */
-
-		ifpi2_recover(sc);
-
-		sc->sc_init_tries++;	/* increment retry count */
-
-/*XXX*/		if(sc->sc_init_tries > 4)
-		{
-			int s = SPLI4B();
-
-			sc->sc_init_tries = 0;
-			
-			if(sc->sc_obuf2 != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf2);
-				sc->sc_obuf2 = NULL;
-			}
-			if(sc->sc_obuf != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf);
-				sc->sc_obuf = NULL;
-				sc->sc_freeflag = 0;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-			}
-
-			splx(s);
-
-			i4b_l1_mph_status_ind(L0IFPI2UNIT(sc->sc_unit), STI_NOL1ACC, 0, NULL);
-		}
-		
-		ifpi2_next_state(sc, EV_T3);		
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 start
- *---------------------------------------------------------------------------*/	
-static void
-T3_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpi2_printstate(sc));
-	sc->sc_I430T3 = 1;
-	sc->sc_T3_callout = timeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, 2*hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 stop
- *---------------------------------------------------------------------------*/	
-static void
-T3_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpi2_printstate(sc));
-
-	sc->sc_init_tries = 0;	/* init connect retry count */
-	
-	if(sc->sc_I430T3)
-	{
-		sc->sc_I430T3 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, sc->sc_T3_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_T3ex(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_T3ex executing");
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0IFPI2UNIT(sc->sc_unit));
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer4_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T4)
-	{
-		NDBGL1(L1_T_MSG, "state = %s", ifpi2_printstate(sc));
-		sc->sc_I430T4 = 0;
-		i4b_l1_mph_status_ind(L0IFPI2UNIT(sc->sc_unit), STI_PDEACT, 0, NULL);
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 start
- *---------------------------------------------------------------------------*/	
-static void
-T4_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpi2_printstate(sc));
-	sc->sc_I430T4 = 1;
-	sc->sc_T4_callout = timeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 stop
- *---------------------------------------------------------------------------*/	
-static void
-T4_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpi2_printstate(sc));
-
-	if(sc->sc_I430T4)
-	{
-		sc->sc_I430T4 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, sc->sc_T4_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI8
- *---------------------------------------------------------------------------*/	
-static void
-F_AI8(struct l1_softc *sc)
-{
-	T4_stop(sc);
-
-	NDBGL1(L1_F_MSG, "FSM function F_AI8 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0IFPI2UNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_8;
-		
-		hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI10
- *---------------------------------------------------------------------------*/	
-static void
-F_AI10(struct l1_softc *sc)
-{
-	T4_stop(sc);
-	
-	NDBGL1(L1_F_MSG, "FSM function F_AI10 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0IFPI2UNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_10;
-		
-		hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in states F3 .. F5
- *---------------------------------------------------------------------------*/	
-static void
-F_I01(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I01 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F6
- *---------------------------------------------------------------------------*/	
-static void
-F_I02(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I02 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0IFPI2UNIT(sc->sc_unit));
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F7 or F8
- *---------------------------------------------------------------------------*/	
-static void
-F_I03(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I03 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0IFPI2UNIT(sc->sc_unit));
-
-	T4_start(sc);
-	
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: activate request
- *---------------------------------------------------------------------------*/	
-static void
-F_AR(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_AR executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO1_8;
-		
-		hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_TE;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-
-	ifpi2_isacsx_l1_cmd(sc, CMD_AR8);
-
-	T3_start(sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO2
- *---------------------------------------------------------------------------*/	
-static void
-F_I2(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I2 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO2;
-		
-		hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}		
-
-}
-
-/*---------------------------------------------------------------------------*
- *	illegal state default action
- *---------------------------------------------------------------------------*/	
-static void
-F_ill(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_ERR, "FSM function F_ill executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	No action
- *---------------------------------------------------------------------------*/	
-static void
-F_NULL(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_NULL executing");
-}
-
-
-/*---------------------------------------------------------------------------*
- *	layer 1 state transition table
- *---------------------------------------------------------------------------*/	
-struct ifpi2_state_tab {
-	void (*func) (struct l1_softc *sc);	/* function to execute */
-	int newstate;				/* next state */
-} ifpi2_state_tab[N_EVENTS][N_STATES] = {
-
-/* STATE:	F3			F4			F5			F6			F7			F8			ILLEGAL STATE     */
-/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/* EV_PHAR x*/	{{F_AR,   ST_F4},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_ill,  ST_ILL},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_T3   x*/	{{F_NULL, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO0 */	{{F_I01,  ST_F3},	{F_I01,  ST_F4},	{F_I01,  ST_F5},	{F_I02,  ST_F3},	{F_I03,  ST_F3},	{F_I03,  ST_F3},	{F_ill, ST_ILL}},
-/* EV_RSY  x*/	{{F_NULL, ST_F3},	{F_NULL, ST_F5},	{F_NULL, ST_F5}, 	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO2 */	{{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_ill, ST_ILL}},
-/* EV_INFO48*/	{{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_NULL, ST_F7},	{F_AI8,  ST_F7},	{F_ill, ST_ILL}},
-/* EV_INFO41*/	{{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_NULL, ST_F7},	{F_AI10, ST_F7},	{F_ill, ST_ILL}},
-/* EV_DR    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_PU    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_DIS   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}},
-/* EV_EI    */	{{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_ill, ST_ILL}},
-/* EV_ILL   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}}
-};
-
-/*---------------------------------------------------------------------------*
- *	event handler
- *---------------------------------------------------------------------------*/	
-void
-ifpi2_next_state(struct l1_softc *sc, int event)
-{
-	int currstate, newstate;
-
-	if(event >= N_EVENTS)
-		panic("i4b_l1fsm.c: event >= N_EVENTS\n");
-
-	currstate = sc->sc_I430state;
-
-	if(currstate >= N_STATES)
-		panic("i4b_l1fsm.c: currstate >= N_STATES\n");	
-
-	newstate = ifpi2_state_tab[event][currstate].newstate;
-
-	if(newstate >= N_STATES)
-		panic("i4b_l1fsm.c: newstate >= N_STATES\n");	
-	
-	NDBGL1(L1_F_MSG, "FSM event [%s]: [%s => %s]", event_text[event],
-                                           state_text[currstate],
-                                           state_text[newstate]);
-
-        (*ifpi2_state_tab[event][currstate].func)(sc);
-
-	if(newstate == ST_ILL)
-	{
-		newstate = ST_F3;
-		NDBGL1(L1_F_ERR, "FSM Illegal State ERROR, oldstate = %s, newstate = %s, event = %s!",
-					state_text[currstate],
-					state_text[newstate],
-					event_text[event]);
-	}
-
-	sc->sc_I430state = newstate;
-}
-
-#if DO_I4B_DEBUG
-/*---------------------------------------------------------------------------*
- *	return pointer to current state description
- *---------------------------------------------------------------------------*/	
-char *
-ifpi2_printstate(struct l1_softc *sc)
-{
-	return((char *) state_text[sc->sc_I430state]);
-}
-#endif
--- sys/i4b/layer1/ifpi2/i4b_ifpi2_pci.c
+++ /dev/null
@@ -1,1449 +0,0 @@
-/*-
- *   Copyright (c) 2001 Gary Jennejohn. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpi2_pci.c: AVM Fritz!Card PCI hardware driver
- *	--------------------------------------------------
- *	$Id$
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpi2/i4b_ifpi2_pci.c,v 1.17 2005/01/06 22:18:19 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/bus.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-/*#include <i4b/layer1/isic/i4b_isac.h>*/
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/layer1/ifpi2/i4b_ifpi2_ext.h>
-#include <i4b/layer1/ifpi2/i4b_ifpi2_isacsx.h>
-
-#define PCI_AVMA1_VID 0x1244
-#define PCI_AVMA1_V2_DID 0x0e00
-
-/* prototypes */
-static void avma1pp2_disable(device_t);
-static void avma1pp2_intr(void *);
-static void hscx_write_reg(int, u_int, struct l1_softc *);
-static u_char hscx_read_reg(int, struct l1_softc *);
-static u_int hscx_read_reg_int(int, struct l1_softc *);
-static void hscx_read_fifo(int, void *, size_t, struct l1_softc *);
-static void hscx_write_fifo(int, void *, size_t, struct l1_softc *);
-static void avma1pp2_hscx_int_handler(struct l1_softc *);
-static void avma1pp2_hscx_intr(int, u_int, struct l1_softc *);
-static void avma1pp2_init_linktab(struct l1_softc *);
-static void avma1pp2_bchannel_setup(int, int, int, int);
-static void avma1pp2_bchannel_start(int, int);
-static void avma1pp2_hscx_init(struct l1_softc *, int, int);
-static void avma1pp2_bchannel_stat(int, int, bchan_statistics_t *);
-static void avma1pp2_set_linktab(int, int, drvr_link_t *);
-static isdn_link_t * avma1pp2_ret_linktab(int, int);
-static int avma1pp2_pci_probe(device_t);
-static int avma1pp2_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
-int avma1pp2_attach_avma1pp(device_t);
-static void ifpi2_isacsx_intr(struct l1_softc *sc);
-
-static device_method_t avma1pp2_pci_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		avma1pp2_pci_probe),
-	DEVMETHOD(device_attach,	avma1pp2_attach_avma1pp),
-	DEVMETHOD(device_shutdown,	avma1pp2_disable),
-
-	/* bus interface */
-	DEVMETHOD(bus_print_child,	bus_generic_print_child),
-	DEVMETHOD(bus_driver_added,	bus_generic_driver_added),
-
-	{ 0, 0 }
-};
-
-static driver_t avma1pp2_pci_driver = {
-	"ifpi2-",
-	avma1pp2_pci_methods,
-	sizeof(struct l1_softc)
-};
-
-static devclass_t avma1pp2_pci_devclass;
-
-DRIVER_MODULE(avma1pp2, pci, avma1pp2_pci_driver, avma1pp2_pci_devclass, 0, 0);
-
-/* jump table for multiplex routines */
-
-struct i4b_l1mux_func avma1pp2_l1mux_func = {
-	avma1pp2_ret_linktab,
-	avma1pp2_set_linktab,
-	ifpi2_mph_command_req,
-	ifpi2_ph_data_req,
-	ifpi2_ph_activate_req,
-};
-
-struct l1_softc *ifpi2_scp[IFPI2_MAXUNIT];
-
-/*---------------------------------------------------------------------------*
- *	AVM PCI Fritz!Card V. 2 special registers
- *---------------------------------------------------------------------------*/
-
-/*
- *	AVM PCI Status Latch 0 read only bits
- */
-#define ASL_IRQ_ISAC            0x01    /* ISAC  interrupt, active high */
-#define ASL_IRQ_HSCX            0x02    /* HSX   interrupt, active high */
-#define ASL_IRQ_TIMER           0x04    /* Timer interrupt, active high */
-#define ASL_IRQ_BCHAN           ASL_IRQ_HSCX
-/* actually active high */
-#define ASL_IRQ_Pending         (ASL_IRQ_ISAC | ASL_IRQ_HSCX | ASL_IRQ_TIMER)
-
-/*
- *	AVM PCI Status Latch 0 read only bits
- */
-#define ASL_RESET		0x01
-#define ASL_TIMERRESET 		0x04
-#define ASL_ENABLE_INT		0x08
-
-/*
- * "HSCX" status bits
- */
-#define  HSCX_STAT_RME		0x01
-#define  HSCX_STAT_RDO		0x10
-#define  HSCX_STAT_CRCVFRRAB	0x0E
-#define  HSCX_STAT_CRCVFR	0x06
-#define  HSCX_STAT_RML_MASK	0x3f00
-
-/*
- * "HSCX" interrupt bits
- */
-#define  HSCX_INT_XPR		0x80
-#define  HSCX_INT_XDU		0x40
-#define  HSCX_INT_RPR		0x20
-#define  HSCX_INT_MASK		0xE0
-
-/*
- * "HSCX" command bits
- */
-#define  HSCX_CMD_XRS		0x80
-#define  HSCX_CMD_XME		0x01
-#define  HSCX_CMD_RRS		0x20
-#define  HSCX_CMD_XML_MASK	0x3f00
-
-/* "HSCX" mode bits */
-#define HSCX_MODE_ITF_FLG 	0x01
-#define HSCX_MODE_TRANS 	0x02
-
-/* offsets to various registers in the ASIC, evidently */
-#define  STAT0_OFFSET   	0x02
-
-#define  HSCX_FIFO1     	0x10
-#define  HSCX_FIFO2     	0x18
-
-#define  HSCX_STAT1     	0x14
-#define  HSCX_STAT2     	0x1c
-
-#define  ISACSX_INDEX   	0x04
-#define  ISACSX_DATA    	0x08
-
-/*
- * Commands and parameters are sent to the "HSCX" as a long, but the
- * fields are handled as bytes.
- *
- * The long contains:
- *	(prot << 16)|(txl << 8)|cmd
- *
- * where:
- *	prot = protocol to use
- *	txl = transmit length
- *	cmd = the command to be executed
- *
- * The fields are defined as u_char in struct l1_softc.
- *
- * Macro to coalesce the byte fields into a u_int
- */
-#define AVMA1PPSETCMDLONG(f) (f) = ((sc->avma1pp_cmd) | (sc->avma1pp_txl << 8) \
- 					| (sc->avma1pp_prot << 16))
-
-/*
- * to prevent deactivating the "HSCX" when both channels are active we
- * define an HSCX_ACTIVE flag which is or'd into the channel's state
- * flag in avma1pp2_bchannel_setup upon active and cleared upon deactivation.
- * It is set high to allow room for new flags.
- */
-#define HSCX_AVMA1PP_ACTIVE	0x1000 
-
-/*---------------------------------------------------------------------------*
- *	AVM read fifo routines
- *---------------------------------------------------------------------------*/
-
-static void
-avma1pp2_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-	int i;
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_4(btag, bhandle, ISACSX_INDEX, 0);
-			/* evidently each byte must be read as a long */
-			for (i = 0; i < size; i++)
-				((u_int8_t *)buf)[i] = (u_int8_t)bus_space_read_4(btag, bhandle, ISACSX_DATA);
-			break;
-		case ISIC_WHAT_HSCXA:
-			hscx_read_fifo(0, buf, size, sc);
-			break;
-		case ISIC_WHAT_HSCXB:
-			hscx_read_fifo(1, buf, size, sc);
-			break;
-	}
-}
-
-static void
-hscx_read_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
-{
-	u_int32_t *ip;
-	size_t cnt;
-	int dataoff;
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	dataoff = chan ? HSCX_FIFO2 : HSCX_FIFO1;
-	
-	ip = (u_int32_t *)buf;
-	cnt = 0;
-	/* what if len isn't a multiple of sizeof(int) and buf is */
-	/* too small ???? */
-	while (cnt < len)
-	{
-		*ip++ = bus_space_read_4(btag, bhandle, dataoff);
-		cnt += 4;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM write fifo routines
- *---------------------------------------------------------------------------*/
-static void
-avma1pp2_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-	int i;
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_4(btag, bhandle,  ISACSX_INDEX, 0);
-			/* evidently each byte must written as a long */
-			for (i = 0; i < size; i++)
-				bus_space_write_4(btag, bhandle,  ISACSX_DATA, ((unsigned char *)buf)[i]);
-			break;
-		case ISIC_WHAT_HSCXA:
-			hscx_write_fifo(0, buf, size, sc);
-			break;
-		case ISIC_WHAT_HSCXB:
-			hscx_write_fifo(1, buf, size, sc);
-			break;
-	}
-}
-
-static void
-hscx_write_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
-{
-	u_int32_t *ip;
-	size_t cnt;
-	int dataoff;
-	l1_bchan_state_t *Bchan = &sc->sc_chan[chan];
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	dataoff = chan ? HSCX_FIFO2 : HSCX_FIFO1;
-	
-	sc->avma1pp_cmd &= ~HSCX_CMD_XME;
-	sc->avma1pp_txl = 0;
-	if (Bchan->out_mbuf_cur == NULL)
-	{
-	  if (Bchan->bprot != BPROT_NONE)
-		 sc->avma1pp_cmd |= HSCX_CMD_XME;
-	}
-	if (len != sc->sc_bfifolen)
-		sc->avma1pp_txl = len;
-	
-	cnt = 0; /* borrow cnt */
-	AVMA1PPSETCMDLONG(cnt);
-	hscx_write_reg(chan, cnt, sc);
-
-	ip = (u_int32_t *)buf;
-	cnt = 0;
-	while (cnt < len)
-	{
-		bus_space_write_4(btag, bhandle, dataoff, *ip);
-		ip++;
-		cnt += 4;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM write register routines
- *---------------------------------------------------------------------------*/
-
-static void
-avma1pp2_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_4(btag, bhandle, ISACSX_INDEX, offs);
-			bus_space_write_4(btag, bhandle, ISACSX_DATA, data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			hscx_write_reg(0, data, sc);
-			break;
-		case ISIC_WHAT_HSCXB:
-			hscx_write_reg(1, data, sc);
-			break;
-	}
-}
-
-static void
-hscx_write_reg(int chan, u_int val, struct l1_softc *sc)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-	u_int off;
-
-	off = (chan == 0 ? HSCX_STAT1 : HSCX_STAT2);
-
-	bus_space_write_4(btag, bhandle, off, val);
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM read register routines
- *---------------------------------------------------------------------------*/
-static u_int8_t
-avma1pp2_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-	u_int8_t val;
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_4(btag, bhandle, ISACSX_INDEX, offs);
-			val = (u_int8_t)bus_space_read_4(btag, bhandle, ISACSX_DATA);
-			return(val);
-		case ISIC_WHAT_HSCXA:
-			return hscx_read_reg(0, sc);
-		case ISIC_WHAT_HSCXB:
-			return hscx_read_reg(1, sc);
-	}
-	return 0;
-}
-
-static u_char
-hscx_read_reg(int chan, struct l1_softc *sc)
-{
-	return(hscx_read_reg_int(chan, sc) & 0xff);
-}
-
-/*
- * need to be able to return an int because the RBCH is in the 2nd
- * byte.
- */
-static u_int
-hscx_read_reg_int(int chan, struct l1_softc *sc)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-	u_int off;
-
-	off = (chan == 0 ? HSCX_STAT1 : HSCX_STAT2);
-	return(bus_space_read_4(btag, bhandle, off));
-}
-
-/*---------------------------------------------------------------------------*
- *	avma1pp2_probe - probe for a card
- *---------------------------------------------------------------------------*/
-static int
-avma1pp2_pci_probe(dev)
-	device_t		dev;
-{
-	u_int16_t		did, vid;
-
-	vid = pci_get_vendor(dev);
-	did = pci_get_device(dev);
-
-	if ((vid == PCI_AVMA1_VID) && (did == PCI_AVMA1_V2_DID)) {
-		device_set_desc(dev, "AVM Fritz!Card PCI Version 2");
-		return(0);
-	}
-
-	return(ENXIO);
-}
-
-/*---------------------------------------------------------------------------*
- *	avma1pp2_attach_avma1pp - attach Fritz!Card PCI
- *---------------------------------------------------------------------------*/
-int
-avma1pp2_attach_avma1pp(device_t dev)
-{
-	struct l1_softc *sc;
-	u_int v;
-	int unit, error = 0;
-	int s;
-	u_int16_t did, vid;
-	void *ih = 0;
-	bus_space_handle_t bhandle;
-	bus_space_tag_t btag; 
-	l1_bchan_state_t *chan;
-
-	s = splimp();
-
-	vid = pci_get_vendor(dev);
-	did = pci_get_device(dev);
-	sc = device_get_softc(dev);
-	unit = device_get_unit(dev);
-	bzero(sc, sizeof(struct l1_softc));
-
-	/* probably not really required */
-	if(unit >= IFPI2_MAXUNIT) {
-		printf("ifpi2-%d: Error, unit >= IFPI_MAXUNIT!\n", unit);
-		splx(s);
-		return(ENXIO);
-	}
-
-	if ((vid != PCI_AVMA1_VID) && (did != PCI_AVMA1_V2_DID)) {
-		printf("ifpi2-%d: unknown device!?\n", unit);
-		goto fail;
-	}
-
-	ifpi2_scp[unit] = sc;
-
-	sc->sc_resources.io_rid[0] = PCIR_BAR(1);
-	sc->sc_resources.io_base[0] = bus_alloc_resource_any(dev,
-		SYS_RES_IOPORT, &sc->sc_resources.io_rid[0], RF_ACTIVE);
-
-	if (sc->sc_resources.io_base[0] == NULL) {
-		printf("ifpi2-%d: couldn't map IO port\n", unit);
-		error = ENXIO;
-		goto fail;
-	}
-
-	bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	/* Allocate interrupt */
-	sc->sc_resources.irq_rid = 0;
-	sc->sc_resources.irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
-		&sc->sc_resources.irq_rid, RF_SHAREABLE | RF_ACTIVE);
-
-	if (sc->sc_resources.irq == NULL) {
-		bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(1), sc->sc_resources.io_base[0]);
-		printf("ifpi2-%d: couldn't map interrupt\n", unit);
-		error = ENXIO;
-		goto fail;
-	}
-
-	error = bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET, avma1pp2_intr, sc, &ih);
-
-	if (error) {
-		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_resources.irq);
-		bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(1), sc->sc_resources.io_base[0]);
-		printf("ifpi2-%d: couldn't set up irq\n", unit);
-		goto fail;
-	}
-
-	sc->sc_unit = unit;
-
-	/* end of new-bus stuff */
-
-	ISAC_BASE = (caddr_t)ISIC_WHAT_ISAC;
-
-	HSCX_A_BASE = (caddr_t)ISIC_WHAT_HSCXA;
-	HSCX_B_BASE = (caddr_t)ISIC_WHAT_HSCXB;
-
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = avma1pp2_read_reg;
-	sc->writereg = avma1pp2_write_reg;
-
-	sc->readfifo = avma1pp2_read_fifo;
-	sc->writefifo = avma1pp2_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_AVMA1PCI_V2;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	/* set up some other miscellaneous things */
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* reset the card */
-	/* the Linux driver does this to clear any pending ISAC interrupts */
-	v = 0;
-	v = ISAC_READ(I_RMODED);
-#ifdef AVMA1PCI_V2_DEBUG
-	printf("avma1pp2_attach: I_MODED %x...", v);
-#endif
-	v = ISAC_READ(I_ISTAD);
-#ifdef AVMA1PCI_V2_DEBUG
-	printf("avma1pp2_attach: I_ISTAD %x...", v);
-#endif
-	v = ISAC_READ(I_ISTA);
-#ifdef AVMA1PCI_V2_DEBUG
-	printf("avma1pp2_attach: I_ISTA %x...", v);
-#endif
-	ISAC_WRITE(I_MASKD, 0xff);
-	ISAC_WRITE(I_MASK, 0xff);
-	/* the Linux driver does this to clear any pending HSCX interrupts */
-	v = hscx_read_reg_int(0, sc);
-#ifdef AVMA1PCI_V2_DEBUG
-	printf("avma1pp2_attach: 0 HSCX_STAT %x...", v);
-#endif
-	v = hscx_read_reg_int(1, sc);
-#ifdef AVMA1PCI_V2_DEBUG
-	printf("avma1pp2_attach: 1 HSCX_STAT %x\n", v);
-#endif
-
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, 0);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, 0);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_TIMERRESET);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_ENABLE_INT);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-
-   /* from here to the end would normally be done in isic_pciattach */
-
-	 printf("ifpi2-%d: ISACSX %s\n", unit, "PSB3186");
-
-	/* init the ISAC */
-	ifpi2_isacsx_init(sc);
-
-#if defined (__FreeBSD__) && __FreeBSD__ > 4
-	/* Init the channel mutexes */
-	chan = &sc->sc_chan[HSCX_CH_A];
-	if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
-		mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp2_rx", NULL, MTX_DEF);
-	if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
-		mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp2_tx", NULL, MTX_DEF);
-	chan = &sc->sc_chan[HSCX_CH_B];
-	if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
-		mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp2_rx", NULL, MTX_DEF);
-	if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
-		mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp2_tx", NULL, MTX_DEF);
-#endif
-
-	/* init the "HSCX" */
-	avma1pp2_bchannel_setup(sc->sc_unit, HSCX_CH_A, BPROT_NONE, 0);
-	
-	avma1pp2_bchannel_setup(sc->sc_unit, HSCX_CH_B, BPROT_NONE, 0);
-
-	/* can't use the normal B-Channel stuff */
-	avma1pp2_init_linktab(sc);
-
-	/* set trace level */
-
-	sc->sc_trace = TRACE_OFF;
-
-	sc->sc_state = ISAC_IDLE;
-
-	sc->sc_ibuf = NULL;
-	sc->sc_ib = NULL;
-	sc->sc_ilen = 0;
-
-	sc->sc_obuf = NULL;
-	sc->sc_op = NULL;
-	sc->sc_ol = 0;
-	sc->sc_freeflag = 0;
-
-	sc->sc_obuf2 = NULL;
-	sc->sc_freeflag2 = 0;
-
-#if defined(__FreeBSD__) && __FreeBSD__ >=3
-	callout_handle_init(&sc->sc_T3_callout);
-	callout_handle_init(&sc->sc_T4_callout);	
-#endif
-	
-	/* init higher protocol layers */
-	
-	i4b_l1_mph_status_ind(L0IFPI2UNIT(sc->sc_unit), STI_ATTACH, sc->sc_cardtyp, &avma1pp2_l1mux_func);
-
-  fail:
-	splx(s);
-	return(error);
-}
-
-/*
- * this is the real interrupt routine
- */
-static void
-avma1pp2_hscx_intr(int h_chan, u_int stat, struct l1_softc *sc)
-{
-	register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int activity = -1;
-	u_int param = 0;
-	
-	NDBGL1(L1_H_IRQ, "%#x", stat);
-
-	if((stat & HSCX_INT_XDU) && (chan->bprot != BPROT_NONE))/* xmit data underrun */
-	{
-		chan->stat_XDU++;			
-		NDBGL1(L1_H_XFRERR, "xmit data underrun");
-		/* abort the transmission */
-		sc->avma1pp_txl = 0;
-		sc->avma1pp_cmd |= HSCX_CMD_XRS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, param, sc);
-		sc->avma1pp_cmd &= ~HSCX_CMD_XRS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, param, sc);
-
-		if (chan->out_mbuf_head != NULL)  /* don't continue to transmit this buffer */
-		{
-			i4b_Bfreembuf(chan->out_mbuf_head);
-			chan->out_mbuf_cur = chan->out_mbuf_head = NULL;
-		}
-	}
-
-	/*
-	 * The following is based on examination of the Linux driver.
-	 *
-	 * The logic here is different than with a "real" HSCX; all kinds
-	 * of information (interrupt/status bits) are in stat.
-	 *		HSCX_INT_RPR indicates a receive interrupt
-	 *			HSCX_STAT_RDO indicates an overrun condition, abort -
-	 *			otherwise read the bytes ((stat & HSCX_STZT_RML_MASK) >> 8)
-	 *			HSCX_STAT_RME indicates end-of-frame and apparently any
-	 *			CRC/framing errors are only reported in this state.
-	 *				if ((stat & HSCX_STAT_CRCVFRRAB) != HSCX_STAT_CRCVFR)
-	 *					CRC/framing error
-	 */
-	
-	if(stat & HSCX_INT_RPR)
-	{
-		register int fifo_data_len;
-		int error = 0;
-		/* always have to read the FIFO, so use a scratch buffer */
-		u_char scrbuf[HSCX_FIFO_LEN];
-
-		if(stat & HSCX_STAT_RDO)
-		{
-			chan->stat_RDO++;
-			NDBGL1(L1_H_XFRERR, "receive data overflow");
-			error++;				
-		}
-
-		/*
-		 * check whether we're receiving data for an inactive B-channel
-		 * and discard it. This appears to happen for telephony when
-		 * both B-channels are active and one is deactivated. Since
-		 * it is not really possible to deactivate the channel in that
-		 * case (the ASIC seems to deactivate _both_ channels), the
-		 * "deactivated" channel keeps receiving data which can lead
-		 * to exhaustion of mbufs and a kernel panic.
-		 *
-		 * This is a hack, but it's the only solution I can think of
-		 * without having the documentation for the ASIC.
-		 * GJ - 28 Nov 1999
-		 */
-		 if (chan->state == HSCX_IDLE)
-		 {
-			NDBGL1(L1_H_XFRERR, "toss data from %d", h_chan);
-			error++;
-		 }
-
-		fifo_data_len = ((stat & HSCX_STAT_RML_MASK) >> 8);
-		
-		if(fifo_data_len == 0)
-			fifo_data_len = sc->sc_bfifolen;
-
-		/* ALWAYS read data from HSCX fifo */
-	
-		HSCX_RDFIFO(h_chan, scrbuf, fifo_data_len);
-		chan->rxcount += fifo_data_len;
-
-		/* all error conditions checked, now decide and take action */
-		
-		if(error == 0)
-		{
-			if(chan->in_mbuf == NULL)
-			{
-				if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-					panic("L1 avma1pp2_hscx_intr: RME, cannot allocate mbuf!\n");
-				chan->in_cbptr = chan->in_mbuf->m_data;
-				chan->in_len = 0;
-			}
-
-			if((chan->in_len + fifo_data_len) <= BCH_MAX_DATALEN)
-			{
-			   	/* OK to copy the data */
-				bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
-				chan->in_cbptr += fifo_data_len;
-				chan->in_len += fifo_data_len;
-
-				/* setup mbuf data length */
-					
-				chan->in_mbuf->m_len = chan->in_len;
-				chan->in_mbuf->m_pkthdr.len = chan->in_len;
-
-				if(sc->sc_trace & TRACE_B_RX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-					hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_NT;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-				}
-
-				if (stat & HSCX_STAT_RME)
-				{
-				  if((stat & HSCX_STAT_CRCVFRRAB) == HSCX_STAT_CRCVFR)
-				  {
-					 (*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
-					 activity = ACT_RX;
-				
-					 /* mark buffer ptr as unused */
-					
-					 chan->in_mbuf = NULL;
-					 chan->in_cbptr = NULL;
-					 chan->in_len = 0;
-				  }
-				  else
-				  {
-						chan->stat_CRC++;
-						NDBGL1(L1_H_XFRERR, "CRC/RAB");
-					  if (chan->in_mbuf != NULL)
-					  {
-						  i4b_Bfreembuf(chan->in_mbuf);
-						  chan->in_mbuf = NULL;
-						  chan->in_cbptr = NULL;
-						  chan->in_len = 0;
-					  }
-				  }
-				}
-			} /* END enough space in mbuf */
-			else
-			{
-				 if(chan->bprot == BPROT_NONE)
-				 {
-					  /* setup mbuf data length */
-				
-					  chan->in_mbuf->m_len = chan->in_len;
-					  chan->in_mbuf->m_pkthdr.len = chan->in_len;
-
-					  if(sc->sc_trace & TRACE_B_RX)
-					  {
-							i4b_trace_hdr_t hdr;
-							hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-							hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-							hdr.dir = FROM_NT;
-							hdr.count = ++sc->sc_trace_bcount;
-							MICROTIME(hdr.time);
-							i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-						}
-
-					  if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len)))
-						 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);
-
-					  /* alloc new buffer */
-				
-					  if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-						 panic("L1 avma1pp2_hscx_intr: RPF, cannot allocate new mbuf!\n");
-	
-					  /* setup new data ptr */
-				
-					  chan->in_cbptr = chan->in_mbuf->m_data;
-	
-					  /* OK to copy the data */
-					  bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
-
-					  chan->in_cbptr += fifo_data_len;
-					  chan->in_len = fifo_data_len;
-
-					  chan->rxcount += fifo_data_len;
-					}
-				 else
-					{
-					  NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RPF, in_len=%d", chan->in_len);
-					  chan->in_cbptr = chan->in_mbuf->m_data;
-					  chan->in_len = 0;
-					}
-			  }
-		} /* if(error == 0) */
-		else
-		{
-		  	/* land here for RDO */
-			if (chan->in_mbuf != NULL)
-			{
-				i4b_Bfreembuf(chan->in_mbuf);
-				chan->in_mbuf = NULL;
-				chan->in_cbptr = NULL;
-				chan->in_len = 0;
-			}
-			sc->avma1pp_txl = 0;
-			sc->avma1pp_cmd |= HSCX_CMD_RRS;
-			AVMA1PPSETCMDLONG(param);
-			hscx_write_reg(h_chan, param, sc);
-			sc->avma1pp_cmd &= ~HSCX_CMD_RRS;
-			AVMA1PPSETCMDLONG(param);
-			hscx_write_reg(h_chan, param, sc);
-		}
-	}
-
-
-	/* transmit fifo empty, new data can be written to fifo */
-	
-	if(stat & HSCX_INT_XPR)
-	{
-		/*
-		 * for a description what is going on here, please have
-		 * a look at isic_bchannel_start() in i4b_bchan.c !
-		 */
-
-		NDBGL1(L1_H_IRQ, "unit %d, chan %d - XPR, Tx Fifo Empty!", sc->sc_unit, h_chan);
-
-		if(chan->out_mbuf_cur == NULL) 	/* last frame is transmitted */
-		{
-			IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-
-			if(chan->out_mbuf_head == NULL)
-			{
-				chan->state &= ~HSCX_TX_ACTIVE;
-				(*chan->isic_drvr_linktab->bch_tx_queue_empty)(chan->isic_drvr_linktab->unit);
-			}
-			else
-			{
-				chan->state |= HSCX_TX_ACTIVE;
-				chan->out_mbuf_cur = chan->out_mbuf_head;
-				chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-				chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-
-				if(sc->sc_trace & TRACE_B_TX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-					hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_TE;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-				}
-				
-				if(chan->bprot == BPROT_NONE)
-				{
-					if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-						activity = ACT_TX;
-				}
-				else
-				{
-					activity = ACT_TX;
-				}
-			}
-		}
-			
-		avma1pp2_hscx_fifo(chan, sc);
-	}
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
-}
-
-/*
- * this is the main routine which checks each channel and then calls
- * the real interrupt routine as appropriate
- */
-static void
-avma1pp2_hscx_int_handler(struct l1_softc *sc)
-{
-	u_int stat;
-
-	/* has to be a u_int because the byte count is in the 2nd byte */
-	stat = hscx_read_reg_int(0, sc);
-	if (stat & HSCX_INT_MASK)
-	  avma1pp2_hscx_intr(0, stat, sc);
-	stat = hscx_read_reg_int(1, sc);
-	if (stat & HSCX_INT_MASK)
-	  avma1pp2_hscx_intr(1, stat, sc);
-}
-
-static void
-avma1pp2_disable(device_t dev)
-{
-	struct l1_softc *sc = device_get_softc(dev);
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	/* could be still be wrong, but seems to prevent hangs */
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, 0x00);
-}
-
-static void
-avma1pp2_intr(void *xsc)
-{
-	u_char stat;
-	struct l1_softc *sc;
-	bus_space_handle_t bhandle;
-	bus_space_tag_t btag; 
-
-	sc = xsc;
-	bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	stat = bus_space_read_1(btag, bhandle, STAT0_OFFSET);
-	NDBGL1(L1_H_IRQ, "stat %x", stat);
-	/* was there an interrupt from this card ? */
-	if ((stat & ASL_IRQ_Pending) == 0)
-		return; /* no */
-	/* For slow machines loop as long as an interrupt is active */
-	for (; ((stat & ASL_IRQ_Pending) != 0) ;)
-	{
-		/* interrupts are high active */
-		if (stat & ASL_IRQ_TIMER)
-			NDBGL1(L1_H_IRQ, "timer interrupt ???");
-		if (stat & ASL_IRQ_HSCX)
-		{
-			NDBGL1(L1_H_IRQ, "HSCX");
-			avma1pp2_hscx_int_handler(sc);
-		}
-		if (stat & ASL_IRQ_ISAC)
-		{
-		       NDBGL1(L1_H_IRQ, "ISAC");
-		       ifpi2_isacsx_intr(sc);
-		}
-		stat = bus_space_read_1(btag, bhandle, STAT0_OFFSET);
-		NDBGL1(L1_H_IRQ, "stat %x", stat);
-
-	}
-}
-
-static void
-avma1pp2_hscx_init(struct l1_softc *sc, int h_chan, int activate)
-{
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	u_int param = 0;
-
-	NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
-		sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
-
-	sc->avma1pp_cmd = sc->avma1pp_prot = sc->avma1pp_txl = 0;
-
-	if (activate == 0)
-	{
-		/* only deactivate if both channels are idle */
-		if (sc->sc_chan[HSCX_CH_A].state != HSCX_IDLE ||
-			sc->sc_chan[HSCX_CH_B].state != HSCX_IDLE)
-		{
-			return;
-		}
-		sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
-		sc->avma1pp_prot = HSCX_MODE_TRANS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, param, sc);
-		return;
-	}
-	if(chan->bprot == BPROT_RHDLC)
-	{
-		  NDBGL1(L1_BCHAN, "BPROT_RHDLC");
-
-		/* HDLC Frames, transparent mode 0 */
-		sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
-		sc->avma1pp_prot = HSCX_MODE_ITF_FLG;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, param, sc);
-		sc->avma1pp_cmd = HSCX_CMD_XRS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, param, sc);
-		sc->avma1pp_cmd = 0;
-	}
-	else
-	{
-		  NDBGL1(L1_BCHAN, "BPROT_NONE??");
-
-		/* Raw Telephony, extended transparent mode 1 */
-		sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
-		sc->avma1pp_prot = HSCX_MODE_TRANS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, param, sc);
-		sc->avma1pp_cmd = HSCX_CMD_XRS;
-		AVMA1PPSETCMDLONG(param);
-		hscx_write_reg(h_chan, param, sc);
-		sc->avma1pp_cmd = 0;
-	}
-}
-
-static void
-avma1pp2_bchannel_setup(int unit, int h_chan, int bprot, int activate)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi2_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-
-	int s = SPLI4B();
-	
-	if(activate == 0)
-	{
-		/* deactivation */
-		chan->state = HSCX_IDLE;
-		avma1pp2_hscx_init(sc, h_chan, activate);
-	}
-		
-	NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
-		sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
-
-	/* general part */
-
-	chan->unit = sc->sc_unit;	/* unit number */
-	chan->channel = h_chan;		/* B channel */
-	chan->bprot = bprot;		/* B channel protocol */
-	chan->state = HSCX_IDLE;	/* B channel state */
-
-	/* receiver part */
-
-	chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-	i4b_Bcleanifq(&chan->rx_queue);	/* clean rx queue */
-
-	chan->rxcount = 0;		/* reset rx counter */
-	
-	i4b_Bfreembuf(chan->in_mbuf);	/* clean rx mbuf */
-
-	chan->in_mbuf = NULL;		/* reset mbuf ptr */
-	chan->in_cbptr = NULL;		/* reset mbuf curr ptr */
-	chan->in_len = 0;		/* reset mbuf data len */
-	
-	/* transmitter part */
-
-	chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
-	
-	i4b_Bcleanifq(&chan->tx_queue);	/* clean tx queue */
-
-	chan->txcount = 0;		/* reset tx counter */
-	
-	i4b_Bfreembuf(chan->out_mbuf_head);	/* clean tx mbuf */
-
-	chan->out_mbuf_head = NULL;	/* reset head mbuf ptr */
-	chan->out_mbuf_cur = NULL;	/* reset current mbuf ptr */	
-	chan->out_mbuf_cur_ptr = NULL;	/* reset current mbuf data ptr */
-	chan->out_mbuf_cur_len = 0;	/* reset current mbuf data cnt */
-	
-	if(activate != 0)
-	{
-		/* activation */
-		avma1pp2_hscx_init(sc, h_chan, activate);
-		chan->state |= HSCX_AVMA1PP_ACTIVE;
-	}
-
-	splx(s);
-}
-
-static void
-avma1pp2_bchannel_start(int unit, int h_chan)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi2_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int s;
-	int activity = -1;
-
-	s = SPLI4B();				/* enter critical section */
-	if(chan->state & HSCX_TX_ACTIVE)	/* already running ? */
-	{
-		splx(s);
-		return;				/* yes, leave */
-	}
-
-	/* get next mbuf from queue */
-	
-	IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-	
-	if(chan->out_mbuf_head == NULL)		/* queue empty ? */
-	{
-		splx(s);			/* leave critical section */
-		return;				/* yes, exit */
-	}
-
-	/* init current mbuf values */
-	
-	chan->out_mbuf_cur = chan->out_mbuf_head;
-	chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;	
-	
-	/* activity indicator for timeout handling */
-
-	if(chan->bprot == BPROT_NONE)
-	{
-		if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-			activity = ACT_TX;
-	}
-	else
-	{
-		activity = ACT_TX;
-	}
-
-	chan->state |= HSCX_TX_ACTIVE;		/* we start transmitting */
-	
-	if(sc->sc_trace & TRACE_B_TX)	/* if trace, send mbuf to trace dev */
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-		hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_bcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-	}			
-
-	avma1pp2_hscx_fifo(chan, sc);
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
-
-	splx(s);	
-}
-
-/*---------------------------------------------------------------------------*
- *	return the address of isic drivers linktab	
- *---------------------------------------------------------------------------*/
-static isdn_link_t *
-avma1pp2_ret_linktab(int unit, int channel)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi2_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan = &sc->sc_chan[channel];
-
-	return(&chan->isic_isdn_linktab);
-}
- 
-/*---------------------------------------------------------------------------*
- *	set the driver linktab in the b channel softc
- *---------------------------------------------------------------------------*/
-static void
-avma1pp2_set_linktab(int unit, int channel, drvr_link_t *dlt)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi2_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan = &sc->sc_chan[channel];
-
-	chan->isic_drvr_linktab = dlt;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	initialize our local linktab
- *---------------------------------------------------------------------------*/
-static void
-avma1pp2_init_linktab(struct l1_softc *sc)
-{
-	l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A];
-	isdn_link_t *lt = &chan->isic_isdn_linktab;
-
-	/* make sure the hardware driver is known to layer 4 */
-	/* avoid overwriting if already set */
-	if (ctrl_types[CTRL_PASSIVE].set_linktab == NULL)
-	{
-		ctrl_types[CTRL_PASSIVE].set_linktab = i4b_l1_set_linktab;
-		ctrl_types[CTRL_PASSIVE].get_linktab = i4b_l1_ret_linktab;
-	}
-
-	/* local setup */
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_A;
-	lt->bch_config = avma1pp2_bchannel_setup;
-	lt->bch_tx_start = avma1pp2_bchannel_start;
-	lt->bch_stat = avma1pp2_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-                                                
-	chan = &sc->sc_chan[HSCX_CH_B];
-	lt = &chan->isic_isdn_linktab;
-
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_B;
-	lt->bch_config = avma1pp2_bchannel_setup;
-	lt->bch_tx_start = avma1pp2_bchannel_start;
-	lt->bch_stat = avma1pp2_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-}
-
-/*
- * use this instead of isic_bchannel_stat in i4b_bchan.c because it's static
- */
-static void
-avma1pp2_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = ifpi2_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int s;
-
-	s = SPLI4B();
-	
-	bsp->outbytes = chan->txcount;
-	bsp->inbytes = chan->rxcount;
-
-	chan->txcount = 0;
-	chan->rxcount = 0;
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	fill HSCX fifo with data from the current mbuf
- *	Put this here until it can go into i4b_hscx.c
- *---------------------------------------------------------------------------*/
-static int
-avma1pp2_hscx_fifo(l1_bchan_state_t *chan, struct l1_softc *sc)
-{
-	int len;
-	int nextlen;
-	int i;
-	int cmd = 0;
-	/* using a scratch buffer simplifies writing to the FIFO */
-	u_char scrbuf[HSCX_FIFO_LEN];
-
-	len = 0;
-
-	/*
-	 * fill the HSCX tx fifo with data from the current mbuf. if
-	 * current mbuf holds less data than HSCX fifo length, try to
-	 * get the next mbuf from (a possible) mbuf chain. if there is
-	 * not enough data in a single mbuf or in a chain, then this
-	 * is the last mbuf and we tell the HSCX that it has to send
-	 * CRC and closing flag
-	 */
-	 
-	while(chan->out_mbuf_cur && len != sc->sc_bfifolen)
-	{
-		nextlen = min(chan->out_mbuf_cur_len, sc->sc_bfifolen - len);
-
-#ifdef NOTDEF
-		printf("i:mh=%p, mc=%p, mcp=%p, mcl=%d l=%d nl=%d # ",
-			chan->out_mbuf_head,
-			chan->out_mbuf_cur,			
-			chan->out_mbuf_cur_ptr,
-			chan->out_mbuf_cur_len,
-			len,
-			nextlen);
-#endif
-
-		cmd |= HSCX_CMDR_XTF;
-		/* collect the data in the scratch buffer */
-		for (i = 0; i < nextlen; i++)
-			scrbuf[i + len] = chan->out_mbuf_cur_ptr[i];
-
-		len += nextlen;
-		chan->txcount += nextlen;
-	
-		chan->out_mbuf_cur_ptr += nextlen;
-		chan->out_mbuf_cur_len -= nextlen;
-			
-		if(chan->out_mbuf_cur_len == 0) 
-		{
-			if((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL)
-			{
-				chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-				chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	
-				if(sc->sc_trace & TRACE_B_TX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IFPI2UNIT(sc->sc_unit);
-					hdr.type = (chan->channel == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_TE;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-				}
-			}
-			else
-			{
-				if (chan->bprot != BPROT_NONE)
-					cmd |= HSCX_CMDR_XME;
-				i4b_Bfreembuf(chan->out_mbuf_head);
-				chan->out_mbuf_head = NULL;
-			}
-		}
-	}
-	/* write what we have from the scratch buf to the HSCX fifo */
-	if (len != 0)
-		HSCX_WRFIFO(chan->channel, scrbuf, len);
-	return(cmd);
-}
-
-/*---------------------------------------------------------------------------*
- *	ifpi2 - ISAC interrupt routine
- *---------------------------------------------------------------------------*/
-static void
-ifpi2_isacsx_intr(struct l1_softc *sc)
-{
-	register u_char isacsx_irq_stat;
-
-	for(;;)
-	{
-		/* get isac irq status */
-		/* ISTA tells us whether it was a C/I or HDLC int. */
-		isacsx_irq_stat = ISAC_READ(I_ISTA);
-
-		if(isacsx_irq_stat)
-			ifpi2_isacsx_irq(sc, isacsx_irq_stat); /* isac handler */
-		else
-			break;
-	}
-
-	ISAC_WRITE(I_MASKD, 0xff);
-	ISAC_WRITE(I_MASK, 0xff);
-
-	DELAY(100);
-
-	ISAC_WRITE(I_MASKD, isacsx_imaskd);
-	ISAC_WRITE(I_MASK, isacsx_imask);
-}
-
-/*---------------------------------------------------------------------------*
- *	ifpi2_recover - try to recover from irq lockup
- *---------------------------------------------------------------------------*/
-void
-ifpi2_recover(struct l1_softc *sc)
-{
-	printf("ifpi2_recover %d\n", sc->sc_unit);
-#if 0 /* fix me later */
-	u_char byte;
-	
-	/* get isac irq status */
-
-	byte = ISAC_READ(I_ISTA);
-
-	NDBGL1(L1_ERROR, "  ISAC: ISTA = 0x%x", byte);
-	
-	if(byte & ISACSX_ISTA_EXI)
-		NDBGL1(L1_ERROR, "  ISAC: EXIR = 0x%x", (u_char)ISAC_READ(I_EXIR));
-
-	if(byte & ISACSX_ISTA_CISQ)
-	{
-		byte = ISAC_READ(I_CIRR);
-	
-		NDBGL1(L1_ERROR, "  ISAC: CISQ = 0x%x", byte);
-		
-		if(byte & ISACSX_CIRR_SQC)
-			NDBGL1(L1_ERROR, "  ISAC: SQRR = 0x%x", (u_char)ISAC_READ(I_SQRR));
-	}
-
-	NDBGL1(L1_ERROR, "  ISAC: IMASK = 0x%x", ISACSX_IMASK);
-
-	ISAC_WRITE(I_MASKD, 0xff);	
-	ISAC_WRITE(I_MASK, 0xff);	
-	DELAY(100);
-	ISAC_WRITE(I_MASKD, isacsx_imaskd);
-	ISAC_WRITE(I_MASK, isacsx_imask);
-#endif
-}
--- sys/i4b/layer1/ifpi2/i4b_ifpi2_l1.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*-
- * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
- * Copyright (c) 2001 Gary Jennejohn. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpi2_l1.c - AVM Fritz PCI Version 2 layer 1 handler
- *	---------------------------------------------
- *	$Id$ 
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpi2/i4b_ifpi2_l1.c,v 1.6 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-
-#include <i4b/layer1/ifpi2/i4b_ifpi2_ext.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-DATA-REQUEST
- *	=========================
- *
- *	parms:
- *		unit		physical interface unit number
- *		m		mbuf containing L2 frame to be sent out
- *		freeflag	MBUF_FREE: free mbuf here after having sent
- *						it out
- *				MBUF_DONTFREE: mbuf is freed by Layer 2
- *	returns:
- *		==0	fail, nothing sent out
- *		!=0	ok, frame sent out
- *
- *---------------------------------------------------------------------------*/
-int
-ifpi2_ph_data_req(int unit, struct mbuf *m, int freeflag)
-{
-	u_char cmd;
-	int s;
-	struct l1_softc *sc = ifpi2_scp[unit];
-
-#ifdef NOTDEF
-	NDBGL1(L1_PRIM, "PH-DATA-REQ, unit %d, freeflag=%d", unit, freeflag);
-#endif
-
-	if(m == NULL)			/* failsafe */
-		return (0);
-
-	s = SPLI4B();
-
-	if(sc->sc_I430state == ST_F3)	/* layer 1 not running ? */
-	{
-		NDBGL1(L1_I_ERR, "still in state F3!");
-		ifpi2_ph_activate_req(unit);
-	}
-
-	if(sc->sc_state & ISAC_TX_ACTIVE)
-	{
-		if(sc->sc_obuf2 == NULL)
-		{
-			sc->sc_obuf2 = m;		/* save mbuf ptr */
-
-			if(freeflag)
-				sc->sc_freeflag2 = 1;	/* IRQ must mfree */
-			else
-				sc->sc_freeflag2 = 0;	/* IRQ must not mfree */
-
-			NDBGL1(L1_I_MSG, "using 2nd ISAC TX buffer, state = %s", ifpi2_printstate(sc));
-
-			if(sc->sc_trace & TRACE_D_TX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0IFPI2UNIT(unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_TE;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-			}
-			splx(s);
-			return(1);
-		}
-
-		NDBGL1(L1_I_ERR, "No Space in TX FIFO, state = %s", ifpi2_printstate(sc));
-	
-		if(freeflag == MBUF_FREE)
-			i4b_Dfreembuf(m);			
-	
-		splx(s);
-		return (0);
-	}
-
-	if(sc->sc_trace & TRACE_D_TX)
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0IFPI2UNIT(unit);
-		hdr.type = TRC_CH_D;
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_dcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-	}
-	
-	sc->sc_state |= ISAC_TX_ACTIVE;	/* set transmitter busy flag */
-
-	NDBGL1(L1_I_MSG, "ISAC_TX_ACTIVE set");
-
-	sc->sc_freeflag = 0;		/* IRQ must NOT mfree */
-	
-	ISAC_WRFIFO(m->m_data, min(m->m_len, ISAC_FIFO_LEN)); /* output to TX fifo */
-
-	if(m->m_len > ISAC_FIFO_LEN)	/* message > 32 bytes ? */
-	{
-		sc->sc_obuf = m;	/* save mbuf ptr */
-		sc->sc_op = m->m_data + ISAC_FIFO_LEN; 	/* ptr for irq hdl */
-		sc->sc_ol = m->m_len - ISAC_FIFO_LEN;	/* length for irq hdl */
-
-		if(freeflag)
-			sc->sc_freeflag = 1;	/* IRQ must mfree */
-		
-		cmd = ISAC_CMDR_XTF;
-	}
-	else
-	{
-		sc->sc_obuf = NULL;
-		sc->sc_op = NULL;
-		sc->sc_ol = 0;
-
-		if(freeflag)
-			i4b_Dfreembuf(m);
-
-		cmd = ISAC_CMDR_XTF | ISAC_CMDR_XME;
-  	}
-
-	ISAC_WRITE(I_CMDR, cmd);
-	ISACCMDRWRDELAY();
-
-	splx(s);
-	
-	return(1);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-ACTIVATE-REQUEST
- *	=============================
- *
- *	parms:
- *		unit	physical interface unit number
- *
- *	returns:
- *		==0	
- *		!=0	
- *
- *---------------------------------------------------------------------------*/
-int
-ifpi2_ph_activate_req(int unit)
-{
-	struct l1_softc *sc = ifpi2_scp[unit];
-	NDBGL1(L1_PRIM, "PH-ACTIVATE-REQ, unit %d", unit);
-	ifpi2_next_state(sc, EV_PHAR);
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	command from the upper layers
- *---------------------------------------------------------------------------*/
-int
-ifpi2_mph_command_req(int unit, int command, void *parm)
-{
-	struct l1_softc *sc = ifpi2_scp[unit];
-
-	switch(command)
-	{
-		case CMR_DOPEN:		/* daemon running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DOPEN", unit);
-			sc->sc_enabled = 1;			
-			break;
-			
-		case CMR_DCLOSE:	/* daemon not running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DCLOSE", unit);
-			sc->sc_enabled = 0;
-			break;
-
-		case CMR_SETTRACE:
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_SETTRACE, parm = %d", unit, (unsigned int)parm);
-			sc->sc_trace = (unsigned int)parm;
-			break;
-		
-		default:
-			NDBGL1(L1_ERROR, "ERROR, unknown command = %d, unit = %d, parm = %d", command, unit, (unsigned int)parm);
-			break;
-	}
-
-	return(0);
-}
--- sys/i4b/layer1/ifpi2/i4b_ifpi2_isacsx.h
+++ /dev/null
@@ -1,574 +0,0 @@
-/*-
- *   Copyright (c) 2001 Gary Jennejohn. All rights reserved. 
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/ifpi2/i4b_ifpi2_isacsx.h,v 1.2 2005/01/06 22:18:19 imp Exp $
- *
- *
- *---------------------------------------------------------------------------*/
- 
-#ifndef I4B_ISACSX_H_
-#define I4B_ISACSX_H_
-
-#define ISACSX_FIFO_LEN	32	/* 32 bytes FIFO on chip */
-
-#define ISACSX_V13 0x01
-
-/*
- * definitions of registers and bits for the ISAC-SX ISDN chip.
- */
- 
-typedef struct isacsx_reg {
-
-	/* 32 byte deep FIFO always first */
-
-	unsigned char isacsx_fifo [ISACSX_FIFO_LEN];
-
-	/* most registers can be read/written, but have different names */
-	/* so define a union with read/write names to make that clear */
-
-	union {
-		struct {
-			unsigned char isacsx_istad;
-			unsigned char isacsx_stard;
-			unsigned char isacsx_moded;
-			unsigned char isacsx_exmd1;
-			unsigned char isacsx_timr1;
-			unsigned char dummy_25;
-			unsigned char isacsx_rbcld;
-			unsigned char isacsx_rbchd;
-			unsigned char isacsx_rstad;
-			unsigned char isacsx_tmd;
-			unsigned char dummy_2a;
-			unsigned char dummy_2b;
-			unsigned char dummy_2c;
-			unsigned char dummy_2d;
-			unsigned char isacsx_cir0;
-			unsigned char isacsx_codr1;
-			unsigned char isacsx_tr_conf0;
-			unsigned char isacsx_tr_conf1;
-			unsigned char isacsx_tr_conf2;
-			unsigned char isacsx_tr_sta;
-			unsigned char dummy_34;
-			unsigned char isacsx_sqrr1;
-			unsigned char isacsx_sqrr2;
-			unsigned char isacsx_sqrr3;
-			unsigned char isacsx_istatr;
-			unsigned char isacsx_masktr;
-			unsigned char dummy_3a;
-			unsigned char dummy_3b;
-			unsigned char isacsx_acgf2;
-			unsigned char dummy_3d;
-			unsigned char dummy_3e;
-			unsigned char dummy_3f;
-			unsigned char isacsx_cda10;
-			unsigned char isacsx_cda11;
-			unsigned char isacsx_cda20;
-			unsigned char isacsx_cda21;
-			unsigned char isacsx_cda_tsdp10;
-			unsigned char isacsx_cda_tsdp11;
-			unsigned char isacsx_cda_tsdp20;
-			unsigned char isacsx_cda_tsdp21;
-			unsigned char dummy_48;
-			unsigned char dummy_49;
-			unsigned char dummy_4a;
-			unsigned char dummy_4b;
-			unsigned char isacsx_tr_tsdp_bc1;
-			unsigned char isacsx_tr_tsdp_bc2;
-			unsigned char isacsx_cda1_cr;
-			unsigned char isacsx_cda2_cr;
-			unsigned char isacsx_tr_cr;
-			unsigned char dummy_51;
-			unsigned char dummy_52;
-			unsigned char isacsx_dci_cr;
-			unsigned char isacsx_mon_cr;
-			unsigned char isacsx_sds_cr;
-			unsigned char dummy_56;
-			unsigned char isacsx_iom_cr;
-			unsigned char isacsx_sti;
-			unsigned char isacsx_msti;
-			unsigned char isacsx_sds_conf;
-			unsigned char isacsx_mcda;
-			unsigned char isacsx_mor;
-			unsigned char isacsx_mosr;
-			unsigned char isacsx_mocr;
-			unsigned char isacsx_msta;
-			unsigned char isacsx_ista;
-			unsigned char isacsx_auxi;
-			unsigned char isacsx_mode1;
-			unsigned char isacsx_mode2;
-			unsigned char isacsx_id;
-			unsigned char isacsx_timr2;
-			unsigned char dummy_66;
-			unsigned char dummy_67;
-			unsigned char dummy_68;
-			unsigned char dummy_69;
-			unsigned char dummy_6a;
-			unsigned char dummy_6b;
-			unsigned char dummy_6c;
-			unsigned char dummy_6d;
-			unsigned char dummy_6e;
-			unsigned char dummy_6f;
-		} isacsx_r;
-		struct {
-			unsigned char isacsx_maskd;
-			unsigned char isacsx_cmdrd;
-			unsigned char isacsx_moded;
-			unsigned char isacsx_exmd1;
-			unsigned char isacsx_timr1;
-			unsigned char isacsx_sap1;
-			unsigned char isacsx_sap2;
-			unsigned char isacsx_tei1;
-			unsigned char isacsx_tei2;
-			unsigned char isacsx_tmd;
-			unsigned char dummy_2a;
-			unsigned char dummy_2b;
-			unsigned char dummy_2c;
-			unsigned char dummy_2d;
-			unsigned char isacsx_cix0;
-			unsigned char isacsx_codx1;
-			unsigned char isacsx_tr_conf0;
-			unsigned char isacsx_tr_conf1;
-			unsigned char isacsx_tr_conf2;
-			unsigned char dummy_33;
-			unsigned char dummy_34;
-			unsigned char isacsx_sqrx1;
-			unsigned char dummy_36;
-			unsigned char dummy_37;
-			unsigned char dummy_38;
-			unsigned char isacsx_masktr;
-			unsigned char dummy_3a;
-			unsigned char dummy_3b;
-			unsigned char isacsx_acgf2;
-			unsigned char dummy_3d;
-			unsigned char dummy_3e;
-			unsigned char dummy_3f;
-			unsigned char isacsx_cda10;
-			unsigned char isacsx_cda11;
-			unsigned char isacsx_cda20;
-			unsigned char isacsx_cda21;
-			unsigned char isacsx_cda_tsdp10;
-			unsigned char isacsx_cda_tsdp11;
-			unsigned char isacsx_cda_tsdp20;
-			unsigned char isacsx_cda_tsdp21;
-			unsigned char dummy_48;
-			unsigned char dummy_49;
-			unsigned char dummy_4a;
-			unsigned char dummy_4b;
-			unsigned char isacsx_tr_tsdp_bc1;
-			unsigned char isacsx_tr_tsdp_bc2;
-			unsigned char isacsx_cda1_cr;
-			unsigned char isacsx_cda2_cr;
-			unsigned char isacsx_tr_cr;
-			unsigned char dummy_51;
-			unsigned char dummy_52;
-			unsigned char isacsx_dci_cr;
-			unsigned char isacsx_mon_cr;
-			unsigned char isacsx_sds_cr;
-			unsigned char dummy_56;
-			unsigned char isacsx_iom_cr;
-			unsigned char isacsx_asti;
-			unsigned char isacsx_msti;
-			unsigned char isacsx_sds_conf;
-			unsigned char dummy_5b;
-			unsigned char isacsx_mox;
-			unsigned char dummy_5d;
-			unsigned char isacsx_mocr;
-			unsigned char isacsx_mconf;
-			unsigned char isacsx_mask;
-			unsigned char isacsx_auxm;
-			unsigned char isacsx_mode1;
-			unsigned char isacsx_mode2;
-			unsigned char isacsx_sres;
-			unsigned char isacsx_timr2;
-			unsigned char dummy_66;
-			unsigned char dummy_67;
-			unsigned char dummy_68;
-			unsigned char dummy_69;
-			unsigned char dummy_6a;
-			unsigned char dummy_6b;
-			unsigned char dummy_6c;
-			unsigned char dummy_6d;
-			unsigned char dummy_6e;
-			unsigned char dummy_6f;
-		} isacsx_w;
-	} isacsx_rw;
-} isacsx_reg_t;
-
-#define REG_OFFSET(type, field) (int)(&(((type *)0)->field))
-
-/* ISACSX read registers */
-
-#define i_istad isacsx_rw.isacsx_r.isacsx_istad
-#define I_ISTAD REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_istad)
-#define i_stard isacsx_rw.isacsx_r.isacsx_stard
-#define I_STARD REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_stard)
-#define i_rmoded isacsx_rw.isacsx_r.isacsx_moded
-#define I_RMODED REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_moded)
-#define i_rexmd1 isacsx_rw.isacsx_r.isacsx_exmd1
-#define I_REXMD1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_exmd1)
-#define i_rtimr1 isacsx_rw.isacsx_r.isacsx_timr1
-#define I_RTIMR1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_timr1)
-#define i_rbcld isacsx_rw.isacsx_r.isacsx_rbcld
-#define I_RBCLD REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_rbcld)
-#define i_rbchd isacsx_rw.isacsx_r.isacsx_rbchd
-#define I_RBCHD REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_rbchd)
-#define i_rstad isacsx_rw.isacsx_r.isacsx_rstad
-#define I_RSTAD REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_rstad)
-#define i_rtmd isacsx_rw.isacsx_r.isacsx_tmd
-#define I_RTMD REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tmd)
-#define i_cir0 isacsx_rw.isacsx_r.isacsx_cir0
-#define I_CIR0 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cir0)
-#define i_codr1 isacsx_rw.isacsx_r.isacsx_codr1
-#define I_CODR1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_codr1)
-#define i_rtr_conf0 isacsx_rw.isacsx_r.isacsx_tr_conf0
-#define I_RTR_CONF0 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tr_conf0)
-#define i_rtr_conf1 isacsx_rw.isacsx_r.isacsx_tr_conf1
-#define I_RTR_CONF1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tr_conf1)
-#define i_rtr_conf2 isacsx_rw.isacsx_r.isacsx_tr_conf2
-#define I_RTR_CONF2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tr_conf2)
-#define i_sta isacsx_rw.isacsx_r.isacsx_sta
-#define I_STA REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_sta)
-#define i_sqrr1 isacsx_rw.isacsx_r.isacsx_sqrr1
-#define I_SQRR1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_sqrr1)
-#define i_sqrr2 isacsx_rw.isacsx_r.isacsx_sqrr2
-#define I_SQRR2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_sqrr2)
-#define i_sqrr3 isacsx_rw.isacsx_r.isacsx_sqrr3
-#define I_SQRR3 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_sqrr3)
-#define i_istatr isacsx_rw.isacsx_r.isacsx_istatr
-#define I_ISTATR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_istatr)
-#define i_rmasktr isacsx_rw.isacsx_r.isacsx_masktr
-#define I_RMASKTR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_masktr)
-#define i_racgf2 isacsx_rw.isacsx_r.isacsx_acgf2
-#define I_RACGF2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_acgf2)
-#define i_rcda10 isacsx_rw.isacsx_r.isacsx_cda10
-#define I_RCDA10 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda10)
-#define i_rcda11 isacsx_rw.isacsx_r.isacsx_cda11
-#define I_RCDA11 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda11)
-#define i_rcda20 isacsx_rw.isacsx_r.isacsx_cda20
-#define I_RCDA20 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda20)
-#define i_rcda21 isacsx_rw.isacsx_r.isacsx_cda21
-#define I_RCDA21 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda21)
-#define i_cda_tsdp10 isacsx_rw.isacsx_r.isacsx_cda_tsdp10
-#define I_CDA_TSDP10 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda_tsdp10)
-#define i_cda_tsdp11 isacsx_rw.isacsx_r.isacsx_cda_tsdp11
-#define I_CDA_TSDP11 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda_tsdp11)
-#define i_cda_tsdp20 isacsx_rw.isacsx_r.isacsx_cda_tsdp20
-#define I_CDA_TSDP20 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda_tsdp20)
-#define i_cda_tsdp21 isacsx_rw.isacsx_r.isacsx_cda_tsdp21
-#define I_CDA_TSDP21 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda_tsdp21)
-#define i_tr_tsdp_bc1 isacsx_rw.isacsx_r.isacsx_tr_tsdp_bc1
-#define I_TR_TSDP_BC1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tr_tsdp_bc1)
-#define i_tr_tsdp_bc2 isacsx_rw.isacsx_r.isacsx_tr_tsdp_bc2
-#define I_TR_TSDP_BC2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tr_tsdp_bc2)
-#define i_cda1_cr isacsx_rw.isacsx_r.isacsx_cda1_cr
-#define I_CDA1_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda1_cr)
-#define i_cda2_cr isacsx_rw.isacsx_r.isacsx_cda2_cr
-#define I_CDA2_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda2_cr)
-#define i_tr_cr isacsx_rw.isacsx_r.isacsx_tr_cr
-#define I_TR_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tr_cr)
-#define i_dci_cr isacsx_rw.isacsx_r.isacsx_dci_cr
-#define I_DCI_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_dci_cr)
-#define i_mon_cr isacsx_rw.isacsx_r.isacsx_mon_cr
-#define I_MON_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_mon_cr)
-#define i_sds_cr isacsx_rw.isacsx_r.isacsx_sds_cr
-#define I_SDS_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_sds_cr)
-#define i_iom_cr isacsx_rw.isacsx_r.isacsx_iom_cr
-#define I_IOM_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_iom_cr)
-#define i_sti isacsx_rw.isacsx_r.isacsx_sti
-#define I_STI REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_sti)
-#define i_msti isacsx_rw.isacsx_r.isacsx_msti
-#define I_MSTI REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_msti)
-#define i_sds_conf isacsx_rw.isacsx_r.isacsx_sds_conf
-#define I_SDS_CONF REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_sds_conf)
-#define i_mcda isacsx_rw.isacsx_r.isacsx_mcda
-#define I_MCDA REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_mcda)
-#define i_mor isacsx_rw.isacsx_r.isacsx_mor
-#define I_MOR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_mor)
-#define i_mosr isacsx_rw.isacsx_r.isacsx_mosr
-#define I_MOSR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_mosr)
-#define i_rmocr isacsx_rw.isacsx_r.isacsx_mocr
-#define I_RMOCR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_mocr)
-#define i_msta isacsx_rw.isacsx_r.isacsx_msta
-#define I_MSTA REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_msta)
-#define i_ista isacsx_rw.isacsx_r.isacsx_ista
-#define I_ISTA REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_ista)
-#define i_auxi isacsx_rw.isacsx_r.isacsx_auxi
-#define I_AUXI REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_auxi)
-#define i_rmode1 isacsx_rw.isacsx_r.isacsx_mode1
-#define I_RMODE1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_mode1)
-#define i_rmode2 isacsx_rw.isacsx_r.isacsx_mode2
-#define I_RMODE2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_mode2)
-#define i_id isacsx_rw.isacsx_r.isacsx_id
-#define I_ID REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_id)
-#define i_rtimr2 isacsx_rw.isacsx_r.isacsx_timr2
-#define I_RTIMR2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_timr2)
-
-/* ISAC write registers - isacsx_mode, isacsx_timr, isacsx_star2, isacsx_spcr, */
-/* isacsx_c1r, isacsx_c2r, isacsx_adf2 see read registers */
-
-#define i_maskd isacsx_rw.isacsx_w.isacsx_maskd
-#define I_MASKD REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_maskd)
-#define i_cmdrd isacsx_rw.isacsx_w.isacsx_cmdrd
-#define I_CMDRD REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_cmdrd)
-#define i_wmoded isacsx_rw.isacsx_w.isacsx_moded
-#define I_WMODED REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_moded)
-#define i_wexmd1 isacsx_rw.isacsx_w.isacsx_exmd1
-#define I_WEXMD1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_exmd1)
-#define i_wtimr1 isacsx_rw.isacsx_w.isacsx_timr1
-#define I_WTIMR1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_timr1)
-#define i_sap1 isacsx_rw.isacsx_w.isacsx_sap1
-#define I_SAP1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_sap1)
-#define i_sap2 isacsx_rw.isacsx_w.isacsx_sap2
-#define I_SAP2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_sap2)
-#define i_tei1 isacsx_rw.isacsx_w.isacsx_tei1
-#define i_tei2 isacsx_rw.isacsx_w.isacsx_tei2
-#define i_wtmd isacsx_rw.isacsx_w.isacsx_tmd
-#define I_WTMD REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_tmd)
-#define i_cix0 isacsx_rw.isacsx_w.isacsx_cix0
-#define I_CIX0 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_cix0)
-#define i_codx1 isacsx_rw.isacsx_w.isacsx_codx1
-#define I_CODX1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_codx1)
-#define i_wtr_conf0 isacsx_rw.isacsx_w.isacsx_tr_conf0
-#define I_WTR_CONF0 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_tr_conf0)
-#define i_wtr_conf1 isacsx_rw.isacsx_w.isacsx_tr_conf1
-#define I_WTR_CONF1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_tr_conf1)
-#define i_wtr_conf2 isacsx_rw.isacsx_w.isacsx_tr_conf2
-#define I_WTR_CONF2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_tr_conf2)
-#define i_sqrx1 isacsx_rw.isacsx_w.isacsx_sqrx1
-#define I_SQRX1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_sqrx1)
-#define i_wmasktr isacsx_rw.isacsx_w.isacsx_masktr
-#define I_WMASKTR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_masktr)
-#define i_wacgf2 isacsx_rw.isacsx_w.isacsx_acgf2
-#define I_WACGF2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_acgf2)
-#define i_wcda10 isacsx_rw.isacsx_w.isacsx_cda10
-#define I_WCDA10 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_cda10)
-#define i_wcda11 isacsx_rw.isacsx_r.isacsx_cda11
-#define I_WCDA11 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda11)
-#define i_wcda20 isacsx_rw.isacsx_r.isacsx_cda20
-#define I_WCDA20 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda20)
-#define i_wcda21 isacsx_rw.isacsx_r.isacsx_cda21
-#define I_WCDA21 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda21)
-#define i_cda_tsdp10 isacsx_rw.isacsx_r.isacsx_cda_tsdp10
-#define I_CDA_TSDP10 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda_tsdp10)
-#define i_cda_tsdp11 isacsx_rw.isacsx_r.isacsx_cda_tsdp11
-#define I_CDA_TSDP11 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda_tsdp11)
-#define i_cda_tsdp20 isacsx_rw.isacsx_r.isacsx_cda_tsdp20
-#define I_CDA_TSDP20 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda_tsdp20)
-#define i_cda_tsdp21 isacsx_rw.isacsx_r.isacsx_cda_tsdp21
-#define I_CDA_TSDP21 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda_tsdp21)
-#define i_tr_tsdp_bc1 isacsx_rw.isacsx_r.isacsx_tr_tsdp_bc1
-#define I_TR_TSDP_BC1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tr_tsdp_bc1)
-#define i_tr_tsdp_bc2 isacsx_rw.isacsx_r.isacsx_tr_tsdp_bc2
-#define I_TR_TSDP_BC2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tr_tsdp_bc2)
-#define i_cda1_cr isacsx_rw.isacsx_r.isacsx_cda1_cr
-#define I_CDA1_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda1_cr)
-#define i_cda2_cr isacsx_rw.isacsx_r.isacsx_cda2_cr
-#define I_CDA2_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_cda2_cr)
-#define i_tr_cr isacsx_rw.isacsx_r.isacsx_tr_cr
-#define I_TR_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_tr_cr)
-#define i_dci_cr isacsx_rw.isacsx_r.isacsx_dci_cr
-#define I_DCI_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_dci_cr)
-#define i_mon_cr isacsx_rw.isacsx_r.isacsx_mon_cr
-#define I_MON_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_mon_cr)
-#define i_sds_cr isacsx_rw.isacsx_r.isacsx_sds_cr
-#define I_SDS_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_sds_cr)
-#define i_iom_cr isacsx_rw.isacsx_r.isacsx_iom_cr
-#define I_IOM_CR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_iom_cr)
-#define i_asti isacsx_rw.isacsx_r.isacsx_asti
-#define I_ASTI REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_asti)
-#define i_msti isacsx_rw.isacsx_r.isacsx_msti
-#define I_MSTI REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_msti)
-#define i_sds_conf isacsx_rw.isacsx_r.isacsx_sds_conf
-#define I_SDS_CONF REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_r.isacsx_sds_conf)
-#define i_mox isacsx_rw.isacsx_w.isacsx_mox
-#define I_MOX REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_mox)
-#define i_wmocr isacsx_rw.isacsx_w.isacsx_mocr
-#define I_WMOCR REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_mocr)
-#define i_mconf isacsx_rw.isacsx_w.isacsx_mconf
-#define I_MCONF REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_mconf)
-#define i_mask isacsx_rw.isacsx_w.isacsx_mask
-#define I_MASK REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_mask)
-#define i_auxm isacsx_rw.isacsx_w.isacsx_auxm
-#define I_AUXM REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_auxm)
-#define i_wmode1 isacsx_rw.isacsx_w.isacsx_mode1
-#define I_WMODE1 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_mode1)
-#define i_wmode2 isacsx_rw.isacsx_w.isacsx_mode2
-#define I_WMODE2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_mode2)
-#define i_sres isacsx_rw.isacsx_w.isacsx_sres
-#define I_SRES REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_sres)
-#define i_wtimr2 isacsx_rw.isacsx_w.isacsx_timr2
-#define I_WTIMR2 REG_OFFSET(isacsx_reg_t, isacsx_rw.isacsx_w.isacsx_timr2)
-
-#define ISACSX_ISTAD_RME  0x80
-#define ISACSX_ISTAD_RPF  0x40
-#define ISACSX_ISTAD_RFO  0x20
-#define ISACSX_ISTAD_XPR  0x10
-#define ISACSX_ISTAD_XMR  0x08
-#define ISACSX_ISTAD_XDU  0x04
-
-#define ISACSX_MASKD_RME  0x80
-#define ISACSX_MASKD_RPF  0x40
-#define ISACSX_MASKD_RFO  0x20
-#define ISACSX_MASKD_XPR  0x10
-#define ISACSX_MASKD_XMR  0x08
-#define ISACSX_MASKD_XDU  0x04
-/* these must always be set */
-#define ISACSX_MASKD_LOW  0x03
-#define ISACSX_MASKD_ALL  0xff
-
-#define ISACSX_STARD_XDOV 0x80
-#define ISACSX_STARD_XFW  0x40
-#define ISACSX_STARD_RAC1 0x08
-#define ISACSX_STARD_XAC1 0x02
-
-#define ISACSX_CMDRD_RMC  0x80
-#define ISACSX_CMDRD_RRES 0x40
-#define ISACSX_CMDRD_STI  0x10
-#define ISACSX_CMDRD_XTF  0x08
-#define ISACSX_CMDRD_XME  0x02
-#define ISACSX_CMDRD_XRES 0x01
-
-#define ISACSX_MODED_MDS2 0x80
-#define ISACSX_MODED_MDS1 0x40
-#define ISACSX_MODED_MDS0 0x20
-#define ISACSX_MODED_RAC  0x08
-#define ISACSX_MODED_DIM2 0x04
-#define ISACSX_MODED_DIM1 0x02
-#define ISACSX_MODED_DIM0 0x01
-
-/* default */
-#define ISACSX_EXMD1_XFBS_32  0x00 /* XFIFO is 32 bytes */
-#define ISACSX_EXMD1_XFBS_16  0x80 /* XFIFO is 16 bytes */
-/* default */
-#define ISACSX_EXMD1_RFBS_32  0x00 /* XFIFO is 32 bytes */
-#define ISACSX_EXMD1_RFBS_16  0x20 /* XFIFO is 16 bytes */
-#define ISACSX_EXMD1_RFBS_08  0x40 /* XFIFO is 8 bytes */
-#define ISACSX_EXMD1_RFBS_04  0x60 /* XFIFO is 4 bytes */
-#define ISACSX_EXMD1_SRA      0x10
-#define ISACSX_EXMD1_XCRC     0x08
-#define ISACSX_EXMD1_RCRC     0x04
-#define ISACSX_EXMD1_ITF      0x01
-
-#define ISACSX_RSTAD_VFR  0x80
-#define ISACSX_RSTAD_RDO  0x40
-#define ISACSX_RSTAD_CRC  0x20
-#define ISACSX_RSTAD_RAB  0x10
-#define ISACSX_RSTAD_SA1  0x08
-#define ISACSX_RSTAD_SA0  0x04
-#define ISACSX_RSTAD_CR   0x02
-#define ISACSX_RSTAD_TA   0x01
-
-#define ISACSX_RSTAD_MASK 0xf0	/* the interesting bits */
-
-#define ISACSX_RBCHD_OV   0x10
-/* the other 4 bits are the high bits of the receive byte count */
-
-#define ISACSX_CIR0_CIC0  0x08
-/* CODR0 >> 4 */
-#define ISACSX_CIR0_IPU   0x07
-#define ISACSX_CIR0_IDR   0x00
-#define ISACSX_CIR0_ISD   0x02
-#define ISACSX_CIR0_IDIS  0x03
-#define ISACSX_CIR0_IEI   0x06
-#define ISACSX_CIR0_IRSY  0x04
-#define ISACSX_CIR0_IARD  0x08
-#define ISACSX_CIR0_ITI   0x0a
-#define ISACSX_CIR0_IATI  0x0b
-#define ISACSX_CIR0_IAI8  0x0c
-#define ISACSX_CIR0_IAI10 0x0d
-#define ISACSX_CIR0_IDID  0x0f
-
-#define ISACSX_IOM_CR_SPU      0x80
-#define ISACSX_IOM_CR_CI_CS    0x20
-#define ISACSX_IOM_CR_TIC_DIS  0x10
-#define ISACSX_IOM_CR_EN_BCL   0x08
-#define ISACSX_IOM_CR_CLKM     0x04
-#define ISACSX_IOM_CR_DIS_OD   0x02
-#define ISACSX_IOM_CR_DIS_IOM  0x01
-
-#define ISACSX_CI_MASK	0x0f
-
-#define ISACSX_CIX0_BAC  0x01
-/* in IOM-2 mode the low bits are always 1 */
-#define ISACSX_CIX0_LOW  0x0e
-/* C/I codes from bits 7-4 (>> 4 & 0xf) */
-/* the commands */
-#define ISACSX_CIX0_CTIM  0
-#define ISACSX_CIX0_CRS   0x01
-/* test mode only */
-#define ISACSX_CIX0_CSSSP  0x02
-/* test mode only */
-#define ISACSX_CIX0_CSSCP  0x03
-#define ISACSX_CIX0_CAR8  0x08
-#define ISACSX_CIX0_CAR10 0x09
-#define ISACSX_CIX0_CARL  0x0a
-#define ISACSX_CIX0_CDIU  0x0f
-
-/* Interrupt, General Configuration Registers */
-
-#define ISACSX_ISTA_ST    0x20
-#define ISACSX_ISTA_CIC   0x10
-#define ISACSX_ISTA_AUX   0x08
-#define ISACSX_ISTA_TRAN  0x04
-#define ISACSX_ISTA_MOS   0x02
-#define ISACSX_ISTA_ICD   0x01
-
-#define ISACSX_MASK_ST    0x20
-#define ISACSX_MASK_CIC   0x10
-#define ISACSX_MASK_AUX   0x08
-#define ISACSX_MASK_TRAN  0x04
-#define ISACSX_MASK_MOS   0x02
-#define ISACSX_MASK_ICD   0x01
-
-#define ISACSX_AUXI_EAW   0x20
-#define ISACSX_AUXI_WOV   0x10
-#define ISACSX_AUXI_TIN2  0x08
-#define ISACSX_AUXI_TIN1  0x04
-
-#define ISACSX_AUXM_EAW   0x20
-#define ISACSX_AUXM_WOV   0x10
-#define ISACSX_AUXM_TIN2  0x08
-#define ISACSX_AUXM_TIN1  0x04
-
-#define ISACSX_MODE1_WTC1 0x10
-#define ISACSX_MODE1_WTC2 0x08
-#define ISACSX_MODE1_CFS  0x04
-#define ISACSX_MODE1_RSS2 0x02
-#define ISACSX_MODE1_RSS1 0x01
-
-#define ISACSX_MODE2_INT_POL 0x08
-#define ISACSX_MODE2_PPSDX   0x01
-
-#define ISACSX_ID_MASK 0x2F /* 0x01 = Version 1.3 */
-
-#endif /* I4B_ISACSX_H_ */
--- sys/i4b/layer1/ifpnp/i4b_ifpnp_l1fsm.c
+++ /dev/null
@@ -1,510 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpnp_l1fsm.c - AVM Fritz PnP layer 1 I.430 state machine
- *	-------------------------------------------------------------
- *	$Id: i4b_ifpnp_l1fsm.c,v 1.4 2000/05/29 15:41:41 hm Exp $ 
- *	$Ust: src/i4b/layer1-nb/ifpnp/i4b_ifpnp_l1fsm.c,v 1.4 2000/04/18 08:03:05 ust Exp $
- *      last edit-date: [Mon May 29 15:25:04 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpnp/i4b_ifpnp_l1fsm.c,v 1.7 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer1/ifpnp/i4b_ifpnp_ext.h>
-
-#if DO_I4B_DEBUG
-static char *state_text[N_STATES] = {
-	"F3 Deactivated",
-	"F4 Awaiting Signal",
-	"F5 Identifying Input",
-	"F6 Synchronized",
-	"F7 Activated",
-	"F8 Lost Framing",
-	"Illegal State"	
-};
-
-static char *event_text[N_EVENTS] = {
-	"EV_PHAR PH_ACT_REQ",
-	"EV_T3 Timer 3 expired",
-	"EV_INFO0 INFO0 received",
-	"EV_RSY Level Detected",
-	"EV_INFO2 INFO2 received",
-	"EV_INFO48 INFO4 received",
-	"EV_INFO410 INFO4 received",
-	"EV_DR Deactivate Req",
-	"EV_PU Power UP",
-	"EV_DIS Disconnected",
-	"EV_EI Error Ind",
-	"Illegal Event"
-};
-#endif
-
-/* Function prototypes */
-
-static void timer3_expired (struct l1_softc *sc);
-static void T3_start (struct l1_softc *sc);
-static void T3_stop (struct l1_softc *sc);
-static void F_T3ex (struct l1_softc *sc);
-static void timer4_expired (struct l1_softc *sc);
-static void T4_start (struct l1_softc *sc);
-static void T4_stop (struct l1_softc *sc);
-static void F_AI8 (struct l1_softc *sc);
-static void F_AI10 (struct l1_softc *sc);
-static void F_I01 (struct l1_softc *sc);
-static void F_I02 (struct l1_softc *sc);
-static void F_I03 (struct l1_softc *sc);
-static void F_I2 (struct l1_softc *sc);
-static void F_ill (struct l1_softc *sc);
-static void F_NULL (struct l1_softc *sc);
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer3_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T3)
-	{
-		NDBGL1(L1_T_ERR, "state = %s", ifpnp_printstate(sc));
-		sc->sc_I430T3 = 0;
-
-		/* XXX try some recovery here XXX */
-
-		ifpnp_recover(sc);
-
-		sc->sc_init_tries++;	/* increment retry count */
-
-/*XXX*/		if(sc->sc_init_tries > 4)
-		{
-			int s = SPLI4B();
-
-			sc->sc_init_tries = 0;
-			
-			if(sc->sc_obuf2 != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf2);
-				sc->sc_obuf2 = NULL;
-			}
-			if(sc->sc_obuf != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf);
-				sc->sc_obuf = NULL;
-				sc->sc_freeflag = 0;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-			}
-
-			splx(s);
-
-			i4b_l1_mph_status_ind(L0IFPNPUNIT(sc->sc_unit), STI_NOL1ACC, 0, NULL);
-		}
-		
-		ifpnp_next_state(sc, EV_T3);		
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 start
- *---------------------------------------------------------------------------*/	
-static void
-T3_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpnp_printstate(sc));
-	sc->sc_I430T3 = 1;
-	sc->sc_T3_callout = timeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, 2*hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 stop
- *---------------------------------------------------------------------------*/	
-static void
-T3_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpnp_printstate(sc));
-
-	sc->sc_init_tries = 0;	/* init connect retry count */
-	
-	if(sc->sc_I430T3)
-	{
-		sc->sc_I430T3 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, sc->sc_T3_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_T3ex(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_T3ex executing");
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0IFPNPUNIT(sc->sc_unit));
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer4_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T4)
-	{
-		NDBGL1(L1_T_MSG, "state = %s", ifpnp_printstate(sc));
-		sc->sc_I430T4 = 0;
-		i4b_l1_mph_status_ind(L0IFPNPUNIT(sc->sc_unit), STI_PDEACT, 0, NULL);
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 start
- *---------------------------------------------------------------------------*/	
-static void
-T4_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpnp_printstate(sc));
-	sc->sc_I430T4 = 1;
-	sc->sc_T4_callout = timeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 stop
- *---------------------------------------------------------------------------*/	
-static void
-T4_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", ifpnp_printstate(sc));
-
-	if(sc->sc_I430T4)
-	{
-		sc->sc_I430T4 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, sc->sc_T4_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI8
- *---------------------------------------------------------------------------*/	
-static void
-F_AI8(struct l1_softc *sc)
-{
-	T4_stop(sc);
-
-	NDBGL1(L1_F_MSG, "FSM function F_AI8 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0IFPNPUNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_8;
-		
-		hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI10
- *---------------------------------------------------------------------------*/	
-static void
-F_AI10(struct l1_softc *sc)
-{
-	T4_stop(sc);
-	
-	NDBGL1(L1_F_MSG, "FSM function F_AI10 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0IFPNPUNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_10;
-		
-		hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in states F3 .. F5
- *---------------------------------------------------------------------------*/	
-static void
-F_I01(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I01 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F6
- *---------------------------------------------------------------------------*/	
-static void
-F_I02(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I02 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0IFPNPUNIT(sc->sc_unit));
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F7 or F8
- *---------------------------------------------------------------------------*/	
-static void
-F_I03(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I03 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0IFPNPUNIT(sc->sc_unit));
-
-	T4_start(sc);
-	
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: activate request
- *---------------------------------------------------------------------------*/	
-static void
-F_AR(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_AR executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO1_8;
-		
-		hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_TE;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-
-	ifpnp_isac_l1_cmd(sc, CMD_AR8);
-
-	T3_start(sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO2
- *---------------------------------------------------------------------------*/	
-static void
-F_I2(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I2 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO2;
-		
-		hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}		
-
-}
-
-/*---------------------------------------------------------------------------*
- *	illegal state default action
- *---------------------------------------------------------------------------*/	
-static void
-F_ill(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_ERR, "FSM function F_ill executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	No action
- *---------------------------------------------------------------------------*/	
-static void
-F_NULL(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_NULL executing");
-}
-
-
-/*---------------------------------------------------------------------------*
- *	layer 1 state transition table
- *---------------------------------------------------------------------------*/	
-struct ifpnp_state_tab {
-	void (*func) (struct l1_softc *sc);	/* function to execute */
-	int newstate;				/* next state */
-} ifpnp_state_tab[N_EVENTS][N_STATES] = {
-
-/* STATE:	F3			F4			F5			F6			F7			F8			ILLEGAL STATE     */
-/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/* EV_PHAR x*/	{{F_AR,   ST_F4},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_ill,  ST_ILL},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_T3   x*/	{{F_NULL, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO0 */	{{F_I01,  ST_F3},	{F_I01,  ST_F4},	{F_I01,  ST_F5},	{F_I02,  ST_F3},	{F_I03,  ST_F3},	{F_I03,  ST_F3},	{F_ill, ST_ILL}},
-/* EV_RSY  x*/	{{F_NULL, ST_F3},	{F_NULL, ST_F5},	{F_NULL, ST_F5}, 	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO2 */	{{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_ill, ST_ILL}},
-/* EV_INFO48*/	{{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_NULL, ST_F7},	{F_AI8,  ST_F7},	{F_ill, ST_ILL}},
-/* EV_INFO41*/	{{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_NULL, ST_F7},	{F_AI10, ST_F7},	{F_ill, ST_ILL}},
-/* EV_DR    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_PU    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_DIS   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}},
-/* EV_EI    */	{{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_ill, ST_ILL}},
-/* EV_ILL   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}}
-};
-
-/*---------------------------------------------------------------------------*
- *	event handler
- *---------------------------------------------------------------------------*/	
-void
-ifpnp_next_state(struct l1_softc *sc, int event)
-{
-	int currstate, newstate;
-
-	if(event >= N_EVENTS)
-		panic("i4b_l1fsm.c: event >= N_EVENTS\n");
-
-	currstate = sc->sc_I430state;
-
-	if(currstate >= N_STATES)
-		panic("i4b_l1fsm.c: currstate >= N_STATES\n");	
-
-	newstate = ifpnp_state_tab[event][currstate].newstate;
-
-	if(newstate >= N_STATES)
-		panic("i4b_l1fsm.c: newstate >= N_STATES\n");	
-	
-	NDBGL1(L1_F_MSG, "FSM event [%s]: [%s => %s]", event_text[event],
-                                           state_text[currstate],
-                                           state_text[newstate]);
-
-        (*ifpnp_state_tab[event][currstate].func)(sc);
-
-	if(newstate == ST_ILL)
-	{
-		newstate = ST_F3;
-		NDBGL1(L1_F_ERR, "FSM Illegal State ERROR, oldstate = %s, newstate = %s, event = %s!",
-					state_text[currstate],
-					state_text[newstate],
-					event_text[event]);
-	}
-
-	sc->sc_I430state = newstate;
-}
-
-#if DO_I4B_DEBUG
-/*---------------------------------------------------------------------------*
- *	return pointer to current state description
- *---------------------------------------------------------------------------*/	
-char *
-ifpnp_printstate(struct l1_softc *sc)
-{
-	return((char *) state_text[sc->sc_I430state]);
-}
-#endif
--- sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c
+++ /dev/null
@@ -1,1391 +0,0 @@
-/*-
- *   Copyright (c) 1999, 2000 Udo Schweigert. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpnp_avm.c: AVM Fritz!Card PnP hardware driver
- *	---------------------------------------------------
- *      last edit-date: [Fri Jan 12 17:05:28 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c,v 1.12 2005/01/06 22:18:19 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/bus.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <isa/isavar.h>
-
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/layer1/ifpnp/i4b_ifpnp_ext.h>
-
-/* prototypes */
-static void avm_pnp_intr(void *);
-static void hscx_write_reg(int, u_int, struct l1_softc *, u_int);
-static void hscx_write_reg_val(int, u_int, u_int8_t, struct l1_softc *);
-static u_int hscx_read_reg(int, u_int, struct l1_softc *);
-static void hscx_read_fifo(int, void *, size_t, struct l1_softc *);
-static void hscx_write_fifo(int, void *, size_t, struct l1_softc *);
-static void avm_pnp_hscx_int_handler(struct l1_softc *);
-static void avm_pnp_hscx_intr(int, u_int, u_int, struct l1_softc *);
-static void avm_pnp_init_linktab(struct l1_softc *);
-static void avm_pnp_bchannel_setup(int, int, int, int);
-static void avm_pnp_bchannel_start(int, int);
-static void avm_pnp_hscx_init(struct l1_softc *, int, int);
-static void avm_pnp_bchannel_stat(int, int, bchan_statistics_t *);
-static void avm_pnp_set_linktab(int, int, drvr_link_t *);
-static isdn_link_t * avm_pnp_ret_linktab(int, int);
-static int avm_pnp_probe(device_t);
-static int avm_pnp_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
-int avm_pnp_attach(device_t);
-static void ifpnp_isac_intr(struct l1_softc *sc);
-
-static device_method_t avm_pnp_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		avm_pnp_probe),
-	DEVMETHOD(device_attach,	avm_pnp_attach),
-	{ 0, 0 }
-};
-
-static driver_t avm_pnp_driver = {
-	"ifpnp",
-	avm_pnp_methods,
-	sizeof(struct l1_softc)
-};
-
-static devclass_t avm_pnp_devclass;
-
-DRIVER_MODULE(avm_pnp, isa, avm_pnp_driver, avm_pnp_devclass, 0, 0);
-
-/* jump table for multiplex routines */
-
-struct i4b_l1mux_func avm_pnp_l1mux_func = {
-	avm_pnp_ret_linktab,
-	avm_pnp_set_linktab,
-	ifpnp_mph_command_req,
-	ifpnp_ph_data_req,
-	ifpnp_ph_activate_req,
-};
-
-struct l1_softc *ifpnp_scp[IFPNP_MAXUNIT];
-
-/*---------------------------------------------------------------------------*
- *	AVM PnP Fritz!Card special registers
- *---------------------------------------------------------------------------*/
-
-/*
- *	register offsets from i/o base
- */
-#define CLASS_OFFSET            0x00
-#define REVISION_OFFSET         0x01
-#define STAT0_OFFSET            0x02
-#define STAT1_OFFSET            0x03
-#define ADDR_REG_OFFSET         0x04
-/*#define MODREG_OFFSET		0x06
-#define VERREG_OFFSET           0x07*/
-
-/* these 2 are used to select an ISAC register set */
-#define ISAC_LO_REG_OFFSET	0x04
-#define ISAC_HI_REG_OFFSET	0x06
-
-/* offset higher than this goes to the HI register set */
-#define MAX_LO_REG_OFFSET	0x2f
-
-/* mask for the offset */
-#define ISAC_REGSET_MASK	0x0f
-
-/* the offset from the base to the ISAC registers */
-#define ISAC_REG_OFFSET		0x10
-
-/* the offset from the base to the ISAC FIFO */
-#define ISAC_FIFO		0x02
-
-/* not really the HSCX, but sort of */
-#define HSCX_FIFO		0x00
-#define HSCX_STAT		0x04
-
-/*
- *	AVM PnP Status Latch 0 read only bits
- */
-#define ASL_IRQ_ISAC            0x01    /* ISAC  interrupt, active low */
-#define ASL_IRQ_HSCX            0x02    /* HSX   interrupt, active low */
-#define ASL_IRQ_TIMER           0x04    /* Timer interrupt, active low */
-#define ASL_IRQ_BCHAN           ASL_IRQ_HSCX
-/* actually active LOW */
-#define ASL_IRQ_Pending         (ASL_IRQ_ISAC | ASL_IRQ_HSCX | ASL_IRQ_TIMER)
-
-/*
- *	AVM Status Latch 0 write only bits
- */
-#define ASL_RESET_ALL           0x01  /* reset siemens IC's, active 1 */
-#define ASL_TIMERDISABLE        0x02  /* active high */
-#define ASL_TIMERRESET          0x04  /* active high */
-#define ASL_ENABLE_INT          0x08  /* active high */
-#define ASL_TESTBIT	        0x10  /* active high */
-
-/*
- *	AVM Status Latch 1 write only bits
- */
-#define ASL1_INTSEL              0x0f  /* active high */
-#define ASL1_ENABLE_IOM          0x80  /* active high */
-
-/*
- * "HSCX" mode bits
- */
-#define  HSCX_MODE_ITF_FLG	0x01
-#define  HSCX_MODE_TRANS	0x02
-#define  HSCX_MODE_CCR_7	0x04
-#define  HSCX_MODE_CCR_16	0x08
-#define  HSCX_MODE_TESTLOOP	0x80
-
-/*
- * "HSCX" status bits
- */
-#define  HSCX_STAT_RME		0x01
-#define  HSCX_STAT_RDO		0x10
-#define  HSCX_STAT_CRCVFRRAB	0x0E
-#define  HSCX_STAT_CRCVFR	0x06
-#define  HSCX_STAT_RML_MASK	0x3f00
-
-/*
- * "HSCX" interrupt bits
- */
-#define  HSCX_INT_XPR		0x80
-#define  HSCX_INT_XDU		0x40
-#define  HSCX_INT_RPR		0x20
-#define  HSCX_INT_MASK		0xE0
-
-/*
- * "HSCX" command bits
- */
-#define  HSCX_CMD_XRS		0x80
-#define  HSCX_CMD_XME		0x01
-#define  HSCX_CMD_RRS		0x20
-#define  HSCX_CMD_XML_MASK	0x3f00
-
-/*
- * to prevent deactivating the "HSCX" when both channels are active we
- * define an HSCX_ACTIVE flag which is or'd into the channel's state
- * flag in avm_pnp_bchannel_setup upon active and cleared upon deactivation.
- * It is set high to allow room for new flags.
- */
-#define HSCX_AVMA1PP_ACTIVE	0x1000 
-
-/*---------------------------------------------------------------------------*
- *	AVM read fifo routines
- *---------------------------------------------------------------------------*/
-
-static void
-avm_pnp_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(btag, bhandle,  ADDR_REG_OFFSET, ISAC_FIFO);
-			bus_space_read_multi_1(btag, bhandle,  ISAC_REG_OFFSET, buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			hscx_read_fifo(0, buf, size, sc);
-			break;
-		case ISIC_WHAT_HSCXB:
-			hscx_read_fifo(1, buf, size, sc);
-			break;
-	}
-}
-
-static void
-hscx_read_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
-{
-	u_int8_t *ip;
-	size_t cnt;
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, chan);
-	ip = (u_int8_t *)buf;
-	cnt = 0;
-	while (cnt++ < len)
-	{
-		*ip++ = bus_space_read_1(btag, bhandle, ISAC_REG_OFFSET);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM write fifo routines
- *---------------------------------------------------------------------------*/
-static void
-avm_pnp_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(btag, bhandle,  ADDR_REG_OFFSET, ISAC_FIFO);
-			bus_space_write_multi_1(btag, bhandle,  ISAC_REG_OFFSET, (u_int8_t*)buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			hscx_write_fifo(0, buf, size, sc);
-			break;
-		case ISIC_WHAT_HSCXB:
-			hscx_write_fifo(1, buf, size, sc);
-			break;
-	}
-}
-
-static void
-hscx_write_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
-{
-	u_int8_t *ip;
-	size_t cnt;
-	l1_bchan_state_t *Bchan = &sc->sc_chan[chan];
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	sc->avma1pp_cmd &= ~HSCX_CMD_XME;
-	sc->avma1pp_txl = 0;
-
-	if (Bchan->out_mbuf_cur == NULL)
-	{
-	  if (Bchan->bprot != BPROT_NONE)
-		 sc->avma1pp_cmd |= HSCX_CMD_XME;
-	}
-	if (len != sc->sc_bfifolen)
-		sc->avma1pp_txl = len;
-	
-	hscx_write_reg(chan, HSCX_STAT, sc, 3);
-
-	ip = (u_int8_t *)buf;
-	cnt = 0;
-	while (cnt++ < len)
-	{
-		bus_space_write_1(btag, bhandle, ISAC_REG_OFFSET, *ip++);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM write register routines
- *---------------------------------------------------------------------------*/
-
-static void
-avm_pnp_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	u_char reg_bank;
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET;
-			/* set the register bank */
-			bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, reg_bank);
-			bus_space_write_1(btag, bhandle, ISAC_REG_OFFSET + (offs & ISAC_REGSET_MASK), data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			hscx_write_reg_val(0, offs, data, sc);
-			break;
-		case ISIC_WHAT_HSCXB:
-			hscx_write_reg_val(1, offs, data, sc);
-			break;
-	}
-}
-
-static void
-hscx_write_reg(int chan, u_int off, struct l1_softc *sc, u_int which)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	/* point at the correct channel */
-	bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, chan);
-	if (which & 4) 
-		bus_space_write_1(btag, bhandle, ISAC_REG_OFFSET + off + 2, sc->avma1pp_prot);
-	if (which & 2) 
-		bus_space_write_1(btag, bhandle, ISAC_REG_OFFSET + off + 1, sc->avma1pp_txl);
-	if (which & 1) 
-		bus_space_write_1(btag, bhandle, ISAC_REG_OFFSET + off, sc->avma1pp_cmd);
-}
-
-static void
-hscx_write_reg_val(int chan, u_int off, u_int8_t val, struct l1_softc *sc)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	/* point at the correct channel */
-	bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, chan);
-	bus_space_write_1(btag, bhandle, ISAC_REG_OFFSET + off, val);
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM read register routines
- *---------------------------------------------------------------------------*/
-static u_int8_t
-avm_pnp_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	u_char reg_bank;
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET;
-			/* set the register bank */
-			bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, reg_bank);
-			return(bus_space_read_1(btag, bhandle, ISAC_REG_OFFSET +
-				(offs & ISAC_REGSET_MASK)));
-		case ISIC_WHAT_HSCXA:
-			return hscx_read_reg(0, offs, sc);
-		case ISIC_WHAT_HSCXB:
-			return hscx_read_reg(1, offs, sc);
-	}
-	return 0;
-}
-
-static u_int
-hscx_read_reg(int chan, u_int off, struct l1_softc *sc)
-{
-	bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	/* point at the correct channel */
-	bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, chan);
-	return(bus_space_read_1(btag, bhandle, ISAC_REG_OFFSET + off));
-}
-
-
-static struct ifpnp_ids {
-	u_long vend_id;
-	char *id_str;
-} ifpnp_ids[] = {
-	{ 0x0009cd06,		"AVM Fritz!Card PnP"		},	
-	{ 0, 0 }
-};
-
-/*---------------------------------------------------------------------------*
- *	avm_pnp_probe - probe for a card
- *---------------------------------------------------------------------------*/
-static int
-avm_pnp_probe(dev)
-	device_t		dev;
-{
-	struct ifpnp_ids *ids;			/* pnp id's */
-	char *string = NULL;				/* the name */
-	u_int32_t vend_id = isa_get_vendorid(dev); 	/* vendor id */
-
-	/* search table of knowd id's */
-	
-	for(ids = ifpnp_ids; ids->vend_id != 0; ids++)
-	{
-		if(vend_id == ids->vend_id)
-		{
-			string = ids->id_str;
-			break;
-		}
-	}
-	
-	if(string)		/* set name if we have one */
-	{
-		device_set_desc(dev, string);	/* set description */
-		return 0;
-	}
-	else
-	{
-		return ENXIO;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	avm_pnp_attach - attach Fritz!Card PnP
- *---------------------------------------------------------------------------*/
-int
-avm_pnp_attach(device_t dev)
-{
-	struct l1_softc *sc;
-	u_int v;
-	int unit, error = 0;
-	int s;
-	u_int16_t vid;
-	void *ih = 0;
-	bus_space_handle_t bhandle;
-	bus_space_tag_t btag; 
-
-	s = splimp();
-
-	vid = isa_get_vendorid(dev);
-	sc = device_get_softc(dev);
-	unit = device_get_unit(dev);
-	bzero(sc, sizeof(struct l1_softc));
-
-	/* probably not really required */
-	if(unit >= IFPNP_MAXUNIT) {
-		printf("avm_pnp%d: Error, unit >= IFPNP_MAXUNIT!\n", unit);
-		splx(s);
-		return(ENXIO);
-	}
-
-	ifpnp_scp[unit] = sc;
-
-
-	/* get io_base */
-	if(!(sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE ) ))
-	{
-		printf("avm_pnp_attach: Couldn't get my io_base.\n");
-		return ENXIO;                                       
-	}
-	if (sc->sc_resources.io_base[0] == NULL) {
-		printf("avm_pnp%d: couldn't map IO port\n", unit);
-		error = ENXIO;
-		goto fail;
-	}
-
-	bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	btag = rman_get_bustag(sc->sc_resources.io_base[0]);
-
-	/* will not be used for pnp devices */
-	sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
-
-	/* get irq, release io_base if we don't get it */
-
-	if(!(sc->sc_resources.irq =
-			bus_alloc_resource_any(dev, SYS_RES_IRQ,
-					       &sc->sc_resources.irq_rid,
-					       RF_ACTIVE)))
-	{
-		printf("avm_pnp%d: Could not get irq.\n",unit);
-		error = ENXIO;                                       
-		goto fail;
-	}
-
-	/* not needed */
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-	bus_setup_intr(dev,sc->sc_resources.irq,INTR_TYPE_NET,
-				(void(*)(void*))avm_pnp_intr, sc,&ih);
-	sc->sc_unit = unit;
-
-	/* end of new-bus stuff */
-
-	ISAC_BASE = (caddr_t)ISIC_WHAT_ISAC;
-
-	HSCX_A_BASE = (caddr_t)ISIC_WHAT_HSCXA;
-	HSCX_B_BASE = (caddr_t)ISIC_WHAT_HSCXB;
-
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = avm_pnp_read_reg;
-	sc->writereg = avm_pnp_write_reg;
-
-	sc->readfifo = avm_pnp_read_fifo;
-	sc->writefifo = avm_pnp_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_AVM_PNP;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	/* set up some other miscellaneous things */
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* reset the card */
-	/* the Linux driver does this to clear any pending ISAC interrupts */
-	v = 0;
-	v = ISAC_READ(I_STAR);
-	v = ISAC_READ(I_MODE);
-	v = ISAC_READ(I_ADF2);
-	v = ISAC_READ(I_ISTA);
-	if (v & ISAC_ISTA_EXI)
-	{
-		 v = ISAC_READ(I_EXIR);
-	}
-	v = ISAC_READ(I_CIRR);
-	ISAC_WRITE(I_MASK, 0xff);
-	/* the Linux driver does this to clear any pending HSCX interrupts */
-	v = hscx_read_reg(0, HSCX_STAT, sc);
-	v = hscx_read_reg(1, HSCX_STAT, sc);
-
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-	bus_space_write_1(btag, bhandle, STAT1_OFFSET, ASL1_ENABLE_IOM|sc->sc_irq);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-	bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_TIMERRESET|ASL_ENABLE_INT|ASL_TIMERDISABLE);
-	DELAY(SEC_DELAY/100); /* 10 ms */
-
-	 printf("ifpnp%d: AVM Fritz!Card PnP Class %#x Revision %d \n", unit,
-			bus_space_read_1(btag, bhandle, CLASS_OFFSET),
-			bus_space_read_1(btag, bhandle, REVISION_OFFSET));
-
-	 printf("ifpnp%d: ISAC %s (IOM-%c)\n", unit,
-  		"2085 Version A1/A2 or 2086/2186 Version 1.1",
-		 sc->sc_bustyp == BUS_TYPE_IOM1 ? '1' : '2');
-
-
-	/* init the ISAC */
-	ifpnp_isac_init(sc);
-
-	/* init the "HSCX" */
-	avm_pnp_bchannel_setup(sc->sc_unit, HSCX_CH_A, BPROT_NONE, 0);
-	
-	avm_pnp_bchannel_setup(sc->sc_unit, HSCX_CH_B, BPROT_NONE, 0);
-
-	/* can't use the normal B-Channel stuff */
-	avm_pnp_init_linktab(sc);
-
-	/* set trace level */
-
-	sc->sc_trace = TRACE_OFF;
-
-	sc->sc_state = ISAC_IDLE;
-
-	sc->sc_ibuf = NULL;
-	sc->sc_ib = NULL;
-	sc->sc_ilen = 0;
-
-	sc->sc_obuf = NULL;
-	sc->sc_op = NULL;
-	sc->sc_ol = 0;
-	sc->sc_freeflag = 0;
-
-	sc->sc_obuf2 = NULL;
-	sc->sc_freeflag2 = 0;
-
-	callout_handle_init(&sc->sc_T3_callout);
-	callout_handle_init(&sc->sc_T4_callout);	
-	
-	/* init higher protocol layers */
-	
-	i4b_l1_mph_status_ind(L0IFPNPUNIT(sc->sc_unit), STI_ATTACH, sc->sc_cardtyp, &avm_pnp_l1mux_func);
-
-  fail:
-	splx(s);
-	return(error);
-}
-
-/*
- * this is the real interrupt routine
- */
-static void
-avm_pnp_hscx_intr(int h_chan, u_int stat, u_int cnt, struct l1_softc *sc)
-{
-	register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int activity = -1;
-	
-	NDBGL1(L1_H_IRQ, "%#x", stat);
-
-	if((stat & HSCX_INT_XDU) && (chan->bprot != BPROT_NONE))/* xmit data underrun */
-	{
-		chan->stat_XDU++;			
-		NDBGL1(L1_H_XFRERR, "xmit data underrun");
-		/* abort the transmission */
-		sc->avma1pp_txl = 0;
-		sc->avma1pp_cmd |= HSCX_CMD_XRS;
-		hscx_write_reg(h_chan, HSCX_STAT, sc, 1);
-		sc->avma1pp_cmd &= ~HSCX_CMD_XRS;
-		hscx_write_reg(h_chan, HSCX_STAT, sc, 1);
-
-		if (chan->out_mbuf_head != NULL)  /* don't continue to transmit this buffer */
-		{
-			i4b_Bfreembuf(chan->out_mbuf_head);
-			chan->out_mbuf_cur = chan->out_mbuf_head = NULL;
-		}
-	}
-
-	/*
-	 * The following is based on examination of the Linux driver.
-	 *
-	 * The logic here is different than with a "real" HSCX; all kinds
-	 * of information (interrupt/status bits) are in stat.
-	 *		HSCX_INT_RPR indicates a receive interrupt
-	 *			HSCX_STAT_RDO indicates an overrun condition, abort -
-	 *			otherwise read the bytes ((stat & HSCX_STZT_RML_MASK) >> 8)
-	 *			HSCX_STAT_RME indicates end-of-frame and apparently any
-	 *			CRC/framing errors are only reported in this state.
-	 *				if ((stat & HSCX_STAT_CRCVFRRAB) != HSCX_STAT_CRCVFR)
-	 *					CRC/framing error
-	 */
-	
-	if(stat & HSCX_INT_RPR)
-	{
-		register int fifo_data_len;
-		int error = 0;
-		/* always have to read the FIFO, so use a scratch buffer */
-		u_char scrbuf[HSCX_FIFO_LEN];
-
-		if(stat & HSCX_STAT_RDO)
-		{
-			chan->stat_RDO++;
-			NDBGL1(L1_H_XFRERR, "receive data overflow");
-			error++;				
-		}
-
-		/*
-		 * check whether we're receiving data for an inactive B-channel
-		 * and discard it. This appears to happen for telephony when
-		 * both B-channels are active and one is deactivated. Since
-		 * it is not really possible to deactivate the channel in that
-		 * case (the ASIC seems to deactivate _both_ channels), the
-		 * "deactivated" channel keeps receiving data which can lead
-		 * to exhaustion of mbufs and a kernel panic.
-		 *
-		 * This is a hack, but it's the only solution I can think of
-		 * without having the documentation for the ASIC.
-		 * GJ - 28 Nov 1999
-		 */
-		 if (chan->state == HSCX_IDLE)
-		 {
-			NDBGL1(L1_H_XFRERR, "toss data from %d", h_chan);
-			error++;
-		 }
-
-		fifo_data_len = cnt;
-		
-		if(fifo_data_len == 0)
-			fifo_data_len = sc->sc_bfifolen;
-
-		/* ALWAYS read data from HSCX fifo */
-	
-		HSCX_RDFIFO(h_chan, scrbuf, fifo_data_len);
-		chan->rxcount += fifo_data_len;
-
-		/* all error conditions checked, now decide and take action */
-		
-		if(error == 0)
-		{
-			if(chan->in_mbuf == NULL)
-			{
-				if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-					panic("L1 avm_pnp_hscx_intr: RME, cannot allocate mbuf!\n");
-				chan->in_cbptr = chan->in_mbuf->m_data;
-				chan->in_len = 0;
-			}
-
-			if((chan->in_len + fifo_data_len) <= BCH_MAX_DATALEN)
-			{
-			   	/* OK to copy the data */
-				bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
-				chan->in_cbptr += fifo_data_len;
-				chan->in_len += fifo_data_len;
-
-				/* setup mbuf data length */
-					
-				chan->in_mbuf->m_len = chan->in_len;
-				chan->in_mbuf->m_pkthdr.len = chan->in_len;
-
-				if(sc->sc_trace & TRACE_B_RX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-					hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_NT;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-				}
-
-				if (stat & HSCX_STAT_RME)
-				{
-				  if((stat & HSCX_STAT_CRCVFRRAB) == HSCX_STAT_CRCVFR)
-				  {
-					 (*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
-					 activity = ACT_RX;
-				
-					 /* mark buffer ptr as unused */
-					
-					 chan->in_mbuf = NULL;
-					 chan->in_cbptr = NULL;
-					 chan->in_len = 0;
-				  }
-				  else
-				  {
-						chan->stat_CRC++;
-						NDBGL1(L1_H_XFRERR, "CRC/RAB");
-					  if (chan->in_mbuf != NULL)
-					  {
-						  i4b_Bfreembuf(chan->in_mbuf);
-						  chan->in_mbuf = NULL;
-						  chan->in_cbptr = NULL;
-						  chan->in_len = 0;
-					  }
-				  }
-				}
-			} /* END enough space in mbuf */
-			else
-			{
-				 if(chan->bprot == BPROT_NONE)
-				 {
-					  /* setup mbuf data length */
-				
-					  chan->in_mbuf->m_len = chan->in_len;
-					  chan->in_mbuf->m_pkthdr.len = chan->in_len;
-
-					  if(sc->sc_trace & TRACE_B_RX)
-					  {
-							i4b_trace_hdr_t hdr;
-							hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-							hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-							hdr.dir = FROM_NT;
-							hdr.count = ++sc->sc_trace_bcount;
-							MICROTIME(hdr.time);
-							i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-						}
-
-					  if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len)))
-						 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);
-
-					  /* alloc new buffer */
-				
-					  if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-						 panic("L1 avm_pnp_hscx_intr: RPF, cannot allocate new mbuf!\n");
-	
-					  /* setup new data ptr */
-				
-					  chan->in_cbptr = chan->in_mbuf->m_data;
-	
-					  /* OK to copy the data */
-					  bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
-
-					  chan->in_cbptr += fifo_data_len;
-					  chan->in_len = fifo_data_len;
-
-					  chan->rxcount += fifo_data_len;
-					}
-				 else
-					{
-					  NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RPF, in_len=%d", chan->in_len);
-					  chan->in_cbptr = chan->in_mbuf->m_data;
-					  chan->in_len = 0;
-					}
-			  }
-		} /* if(error == 0) */
-		else
-		{
-		  	/* land here for RDO */
-			if (chan->in_mbuf != NULL)
-			{
-				i4b_Bfreembuf(chan->in_mbuf);
-				chan->in_mbuf = NULL;
-				chan->in_cbptr = NULL;
-				chan->in_len = 0;
-			}
-			sc->avma1pp_txl = 0;
-			sc->avma1pp_cmd |= HSCX_CMD_RRS;
-			hscx_write_reg(h_chan, HSCX_STAT, sc, 1);
-			sc->avma1pp_cmd &= ~HSCX_CMD_RRS;
-			hscx_write_reg(h_chan, HSCX_STAT, sc, 1);
-		}
-	}
-
-
-	/* transmit fifo empty, new data can be written to fifo */
-	
-	if(stat & HSCX_INT_XPR)
-	{
-		/*
-		 * for a description what is going on here, please have
-		 * a look at isic_bchannel_start() in i4b_bchan.c !
-		 */
-
-		NDBGL1(L1_H_IRQ, "unit %d, chan %d - XPR, Tx Fifo Empty!", sc->sc_unit, h_chan);
-
-		if(chan->out_mbuf_cur == NULL) 	/* last frame is transmitted */
-		{
-			IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-
-			if(chan->out_mbuf_head == NULL)
-			{
-				chan->state &= ~HSCX_TX_ACTIVE;
-				(*chan->isic_drvr_linktab->bch_tx_queue_empty)(chan->isic_drvr_linktab->unit);
-			}
-			else
-			{
-				chan->state |= HSCX_TX_ACTIVE;
-				chan->out_mbuf_cur = chan->out_mbuf_head;
-				chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-				chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-
-				if(sc->sc_trace & TRACE_B_TX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-					hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_TE;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-				}
-				
-				if(chan->bprot == BPROT_NONE)
-				{
-					if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-						activity = ACT_TX;
-				}
-				else
-				{
-					activity = ACT_TX;
-				}
-			}
-		}
-			
-		avm_pnp_hscx_fifo(chan, sc);
-	}
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
-}
-
-/*
- * this is the main routine which checks each channel and then calls
- * the real interrupt routine as appropriate
- */
-static void
-avm_pnp_hscx_int_handler(struct l1_softc *sc)
-{
-	u_char stat = 0;
-	u_char cnt = 0;
-
-	stat = hscx_read_reg(0, HSCX_STAT, sc);
-	if (stat & HSCX_INT_RPR)
-	  cnt = hscx_read_reg(0, HSCX_STAT+1, sc);
-	if (stat & HSCX_INT_MASK)
-	  avm_pnp_hscx_intr(0, stat, cnt, sc);
-
-	cnt = 0;
-	stat = hscx_read_reg(1, HSCX_STAT, sc);
-	if (stat & HSCX_INT_RPR)
-	  cnt = hscx_read_reg(1, HSCX_STAT+1, sc);
-	if (stat & HSCX_INT_MASK)
-	  avm_pnp_hscx_intr(1, stat, cnt, sc);
-}
-
-static void
-avm_pnp_intr(void *xsc)
-{
-	u_char stat;
-	struct l1_softc *sc;
-	bus_space_handle_t bhandle;
-	bus_space_tag_t btag; 
-
-	sc = xsc;
-	bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	btag = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	stat = bus_space_read_1(btag, bhandle, STAT0_OFFSET);
-	NDBGL1(L1_H_IRQ, "stat %x", stat);
-	/* was there an interrupt from this card ? */
-	if ((stat & ASL_IRQ_Pending) == ASL_IRQ_Pending)
-		return; /* no */
-	/* interrupts are low active */
-	if (!(stat & ASL_IRQ_TIMER))
-	  NDBGL1(L1_H_IRQ, "timer interrupt ???");
-	if (!(stat & ASL_IRQ_HSCX))
-	{
-	  NDBGL1(L1_H_IRQ, "HSCX");
-		avm_pnp_hscx_int_handler(sc);
-	}
-	if (!(stat & ASL_IRQ_ISAC))
-	{
-	  NDBGL1(L1_H_IRQ, "ISAC");
-		ifpnp_isac_intr(sc);
-	}
-}
-
-static void
-avm_pnp_hscx_init(struct l1_softc *sc, int h_chan, int activate)
-{
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-
-	NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
-		sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
-
-	if (activate == 0)
-	{
-		/* only deactivate if both channels are idle */
-		if (sc->sc_chan[HSCX_CH_A].state != HSCX_IDLE ||
-			sc->sc_chan[HSCX_CH_B].state != HSCX_IDLE)
-		{
-			return;
-		}
-		sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
-		sc->avma1pp_prot = HSCX_MODE_TRANS;
-		hscx_write_reg(h_chan, HSCX_STAT, sc, 5);
-		return;
-	}
-	if(chan->bprot == BPROT_RHDLC)
-	{
-		  NDBGL1(L1_BCHAN, "BPROT_RHDLC");
-
-		/* HDLC Frames, transparent mode 0 */
-		sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
-		sc->avma1pp_prot = HSCX_MODE_ITF_FLG;
-		hscx_write_reg(h_chan, HSCX_STAT, sc, 5);
-		sc->avma1pp_cmd = HSCX_CMD_XRS;
-		hscx_write_reg(h_chan, HSCX_STAT, sc, 1);
-		sc->avma1pp_cmd = 0;
-	}
-	else
-	{
-		  NDBGL1(L1_BCHAN, "BPROT_NONE??");
-
-		/* Raw Telephony, extended transparent mode 1 */
-		sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
-		sc->avma1pp_prot = HSCX_MODE_TRANS;
-		hscx_write_reg(h_chan, HSCX_STAT, sc, 5);
-		sc->avma1pp_cmd = HSCX_CMD_XRS;
-		hscx_write_reg(h_chan, HSCX_STAT, sc, 1);
-		sc->avma1pp_cmd = 0;
-	}
-}
-
-static void
-avm_pnp_bchannel_setup(int unit, int h_chan, int bprot, int activate)
-{
-	struct l1_softc *sc = ifpnp_scp[unit];
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-
-	int s = SPLI4B();
-	
-	if(activate == 0)
-	{
-		/* deactivation */
-		chan->state = HSCX_IDLE;
-		avm_pnp_hscx_init(sc, h_chan, activate);
-	}
-		
-	NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
-		sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
-
-	/* general part */
-
-	chan->unit = sc->sc_unit;	/* unit number */
-	chan->channel = h_chan;		/* B channel */
-	chan->bprot = bprot;		/* B channel protocol */
-	chan->state = HSCX_IDLE;	/* B channel state */
-
-	/* receiver part */
-
-	chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-#if defined (__FreeBSD__) && __FreeBSD__ > 4
-	if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
-		mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avm_pnp_rx", NULL, MTX_DEF);
-#endif
-
-	i4b_Bcleanifq(&chan->rx_queue);	/* clean rx queue */
-
-	chan->rxcount = 0;		/* reset rx counter */
-	
-	i4b_Bfreembuf(chan->in_mbuf);	/* clean rx mbuf */
-
-	chan->in_mbuf = NULL;		/* reset mbuf ptr */
-	chan->in_cbptr = NULL;		/* reset mbuf curr ptr */
-	chan->in_len = 0;		/* reset mbuf data len */
-	
-	/* transmitter part */
-
-	chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-#if defined (__FreeBSD__) && __FreeBSD__ > 4
-	if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
-		mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avm_pnp_tx", NULL, MTX_DEF);
-#endif
-	i4b_Bcleanifq(&chan->tx_queue);	/* clean tx queue */
-
-	chan->txcount = 0;		/* reset tx counter */
-	
-	i4b_Bfreembuf(chan->out_mbuf_head);	/* clean tx mbuf */
-
-	chan->out_mbuf_head = NULL;	/* reset head mbuf ptr */
-	chan->out_mbuf_cur = NULL;	/* reset current mbuf ptr */	
-	chan->out_mbuf_cur_ptr = NULL;	/* reset current mbuf data ptr */
-	chan->out_mbuf_cur_len = 0;	/* reset current mbuf data cnt */
-	
-	if(activate != 0)
-	{
-		/* activation */
-		avm_pnp_hscx_init(sc, h_chan, activate);
-		chan->state |= HSCX_AVMA1PP_ACTIVE;
-	}
-
-	splx(s);
-}
-
-static void
-avm_pnp_bchannel_start(int unit, int h_chan)
-{
-	struct l1_softc *sc = ifpnp_scp[unit];
-	register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int s;
-	int activity = -1;
-
-	s = SPLI4B();				/* enter critical section */
-	if(chan->state & HSCX_TX_ACTIVE)	/* already running ? */
-	{
-		splx(s);
-		return;				/* yes, leave */
-	}
-
-	/* get next mbuf from queue */
-	
-	IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-	
-	if(chan->out_mbuf_head == NULL)		/* queue empty ? */
-	{
-		splx(s);			/* leave critical section */
-		return;				/* yes, exit */
-	}
-
-	/* init current mbuf values */
-	
-	chan->out_mbuf_cur = chan->out_mbuf_head;
-	chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;	
-	
-	/* activity indicator for timeout handling */
-
-	if(chan->bprot == BPROT_NONE)
-	{
-		if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-			activity = ACT_TX;
-	}
-	else
-	{
-		activity = ACT_TX;
-	}
-
-	chan->state |= HSCX_TX_ACTIVE;		/* we start transmitting */
-	
-	if(sc->sc_trace & TRACE_B_TX)	/* if trace, send mbuf to trace dev */
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-		hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_bcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-	}			
-
-	avm_pnp_hscx_fifo(chan, sc);
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
-
-	splx(s);	
-}
-
-/*---------------------------------------------------------------------------*
- *	return the address of isic drivers linktab	
- *---------------------------------------------------------------------------*/
-static isdn_link_t *
-avm_pnp_ret_linktab(int unit, int channel)
-{
-	struct l1_softc *sc = ifpnp_scp[unit];
-	l1_bchan_state_t *chan = &sc->sc_chan[channel];
-
-	return(&chan->isic_isdn_linktab);
-}
- 
-/*---------------------------------------------------------------------------*
- *	set the driver linktab in the b channel softc
- *---------------------------------------------------------------------------*/
-static void
-avm_pnp_set_linktab(int unit, int channel, drvr_link_t *dlt)
-{
-	struct l1_softc *sc = ifpnp_scp[unit];
-	l1_bchan_state_t *chan = &sc->sc_chan[channel];
-
-	chan->isic_drvr_linktab = dlt;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	initialize our local linktab
- *---------------------------------------------------------------------------*/
-static void
-avm_pnp_init_linktab(struct l1_softc *sc)
-{
-	l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A];
-	isdn_link_t *lt = &chan->isic_isdn_linktab;
-
-	/* make sure the hardware driver is known to layer 4 */
-	/* avoid overwriting if already set */
-	if (ctrl_types[CTRL_PASSIVE].set_linktab == NULL)
-	{
-		ctrl_types[CTRL_PASSIVE].set_linktab = avm_pnp_set_linktab;
-		ctrl_types[CTRL_PASSIVE].get_linktab = avm_pnp_ret_linktab;
-	}
-
-	/* local setup */
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_A;
-	lt->bch_config = avm_pnp_bchannel_setup;
-	lt->bch_tx_start = avm_pnp_bchannel_start;
-	lt->bch_stat = avm_pnp_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-                                                
-	chan = &sc->sc_chan[HSCX_CH_B];
-	lt = &chan->isic_isdn_linktab;
-
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_B;
-	lt->bch_config = avm_pnp_bchannel_setup;
-	lt->bch_tx_start = avm_pnp_bchannel_start;
-	lt->bch_stat = avm_pnp_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-}
-
-/*
- * use this instead of isic_bchannel_stat in i4b_bchan.c because it's static
- */
-static void
-avm_pnp_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp)
-{
-	struct l1_softc *sc = ifpnp_scp[unit];
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int s;
-
-	s = SPLI4B();
-	
-	bsp->outbytes = chan->txcount;
-	bsp->inbytes = chan->rxcount;
-
-	chan->txcount = 0;
-	chan->rxcount = 0;
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	fill HSCX fifo with data from the current mbuf
- *	Put this here until it can go into i4b_hscx.c
- *---------------------------------------------------------------------------*/
-static int
-avm_pnp_hscx_fifo(l1_bchan_state_t *chan, struct l1_softc *sc)
-{
-	int len;
-	int nextlen;
-	int i;
-	int cmd = 0;
-	/* using a scratch buffer simplifies writing to the FIFO */
-	u_char scrbuf[HSCX_FIFO_LEN];
-
-	len = 0;
-
-	/*
-	 * fill the HSCX tx fifo with data from the current mbuf. if
-	 * current mbuf holds less data than HSCX fifo length, try to
-	 * get the next mbuf from (a possible) mbuf chain. if there is
-	 * not enough data in a single mbuf or in a chain, then this
-	 * is the last mbuf and we tell the HSCX that it has to send
-	 * CRC and closing flag
-	 */
-	 
-	while(chan->out_mbuf_cur && len != sc->sc_bfifolen)
-	{
-		nextlen = min(chan->out_mbuf_cur_len, sc->sc_bfifolen - len);
-
-#ifdef NOTDEF
-		printf("i:mh=%p, mc=%p, mcp=%p, mcl=%d l=%d nl=%d # ",
-			chan->out_mbuf_head,
-			chan->out_mbuf_cur,			
-			chan->out_mbuf_cur_ptr,
-			chan->out_mbuf_cur_len,
-			len,
-			nextlen);
-#endif
-
-		cmd |= HSCX_CMDR_XTF;
-		/* collect the data in the scratch buffer */
-		for (i = 0; i < nextlen; i++)
-			scrbuf[i + len] = chan->out_mbuf_cur_ptr[i];
-
-		len += nextlen;
-		chan->txcount += nextlen;
-	
-		chan->out_mbuf_cur_ptr += nextlen;
-		chan->out_mbuf_cur_len -= nextlen;
-			
-		if(chan->out_mbuf_cur_len == 0) 
-		{
-			if((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL)
-			{
-				chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-				chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	
-				if(sc->sc_trace & TRACE_B_TX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-					hdr.type = (chan->channel == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_TE;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-				}
-			}
-			else
-			{
-				if (chan->bprot != BPROT_NONE)
-					cmd |= HSCX_CMDR_XME;
-				i4b_Bfreembuf(chan->out_mbuf_head);
-				chan->out_mbuf_head = NULL;
-			}
-		}
-	}
-	/* write what we have from the scratch buf to the HSCX fifo */
-	if (len != 0)
-		HSCX_WRFIFO(chan->channel, scrbuf, len);
-	return(cmd);
-}
-
-/*---------------------------------------------------------------------------*
- *	ifpnp - ISAC interrupt routine
- *---------------------------------------------------------------------------*/
-static void
-ifpnp_isac_intr(struct l1_softc *sc)
-{
-	register u_char isac_irq_stat;
-
-	for(;;)
-	{
-		/* get isac irq status */
-		isac_irq_stat = ISAC_READ(I_ISTA);
-
-		if(isac_irq_stat)
-			ifpnp_isac_irq(sc, isac_irq_stat); /* isac handler */
-		else
-			break;
-	}
-
-	ISAC_WRITE(I_MASK, 0xff);
-
-	DELAY(100);
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-}
-
-/*---------------------------------------------------------------------------*
- *	ifpnp_recover - try to recover from irq lockup
- *---------------------------------------------------------------------------*/
-void
-ifpnp_recover(struct l1_softc *sc)
-{
-	u_char byte;
-	
-	/* get isac irq status */
-
-	byte = ISAC_READ(I_ISTA);
-
-	NDBGL1(L1_ERROR, "  ISAC: ISTA = 0x%x", byte);
-	
-	if(byte & ISAC_ISTA_EXI)
-		NDBGL1(L1_ERROR, "  ISAC: EXIR = 0x%x", (u_char)ISAC_READ(I_EXIR));
-
-	if(byte & ISAC_ISTA_CISQ)
-	{
-		byte = ISAC_READ(I_CIRR);
-	
-		NDBGL1(L1_ERROR, "  ISAC: CISQ = 0x%x", byte);
-		
-		if(byte & ISAC_CIRR_SQC)
-			NDBGL1(L1_ERROR, "  ISAC: SQRR = 0x%x", (u_char)ISAC_READ(I_SQRR));
-	}
-
-	NDBGL1(L1_ERROR, "  ISAC: IMASK = 0x%x", ISAC_IMASK);
-
-	ISAC_WRITE(I_MASK, 0xff);	
-	DELAY(100);
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-}
--- sys/i4b/layer1/ifpnp/i4b_ifpnp_ext.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * Copyright (c) 2000 Gary Jennejohn. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_ifpnp - Fritz!Card PnP for split layers
- *      -------------------------------------------
- *
- *	$Id: i4b_ifpnp_ext.h,v 1.2 2000/06/02 16:14:36 hm Exp $
- *	$Ust: src/i4b/layer1-nb/ifpnp/i4b_ifpnp_ext.h,v 1.4 2000/04/18 08:03:05 ust Exp $
- *
- * $FreeBSD: src/sys/i4b/layer1/ifpnp/i4b_ifpnp_ext.h,v 1.2 2005/01/06 22:18:19 imp Exp $
- *
- *      last edit-date: [Fri Jun  2 14:54:57 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_IFPNP_EXT_H_
-#define _I4B_IFPNP_EXT_H_
-
-#include <i4b/include/i4b_l3l4.h>
-
-void ifpnp_set_linktab(int unit, int channel, drvr_link_t * dlt);
-isdn_link_t *ifpnp_ret_linktab(int unit, int channel);
-
-int ifpnp_ph_data_req(int unit, struct mbuf *m, int freeflag);
-int ifpnp_ph_activate_req(int unit);
-int ifpnp_mph_command_req(int unit, int command, void *parm);
-
-void ifpnp_isac_irq(struct l1_softc *sc, int ista);
-void ifpnp_isac_l1_cmd(struct l1_softc *sc, int command);
-int ifpnp_isac_init(struct l1_softc *sc);
-
-void ifpnp_recover(struct l1_softc *sc);
-char * ifpnp_printstate(struct l1_softc *sc);
-void ifpnp_next_state(struct l1_softc *sc, int event);
-
-#define IFPNP_MAXUNIT 4
-extern struct l1_softc *ifpnp_scp[IFPNP_MAXUNIT];
-
-#endif /* _I4B_IFPNP_EXT_H_ */
--- sys/i4b/layer1/ifpnp/i4b_ifpnp_l1.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpnp_l1.c - AVM Fritz PnP layer 1 handler
- *	----------------------------------------------
- *	$Id: i4b_ifpnp_l1.c,v 1.4 2000/06/02 16:14:36 hm Exp $ 
- *	$Ust: src/i4b/layer1-nb/ifpnp/i4b_ifpnp_l1.c,v 1.4 2000/04/18 08:03:05 ust Exp $ 
- *      last edit-date: [Fri Jun  2 14:55:49 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpnp/i4b_ifpnp_l1.c,v 1.7 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-
-#include <i4b/layer1/ifpnp/i4b_ifpnp_ext.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-DATA-REQUEST
- *	=========================
- *
- *	parms:
- *		unit		physical interface unit number
- *		m		mbuf containing L2 frame to be sent out
- *		freeflag	MBUF_FREE: free mbuf here after having sent
- *						it out
- *				MBUF_DONTFREE: mbuf is freed by Layer 2
- *	returns:
- *		==0	fail, nothing sent out
- *		!=0	ok, frame sent out
- *
- *---------------------------------------------------------------------------*/
-int
-ifpnp_ph_data_req(int unit, struct mbuf *m, int freeflag)
-{
-	u_char cmd;
-	int s;
-	struct l1_softc *sc = ifpnp_scp[unit];
-
-#ifdef NOTDEF
-	NDBGL1(L1_PRIM, "PH-DATA-REQ, unit %d, freeflag=%d", unit, freeflag);
-#endif
-
-	if(m == NULL)			/* failsafe */
-		return (0);
-
-	s = SPLI4B();
-
-	if(sc->sc_I430state == ST_F3)	/* layer 1 not running ? */
-	{
-		NDBGL1(L1_I_ERR, "still in state F3!");
-		ifpnp_ph_activate_req(unit);
-	}
-
-	if(sc->sc_state & ISAC_TX_ACTIVE)
-	{
-		if(sc->sc_obuf2 == NULL)
-		{
-			sc->sc_obuf2 = m;		/* save mbuf ptr */
-
-			if(freeflag)
-				sc->sc_freeflag2 = 1;	/* IRQ must mfree */
-			else
-				sc->sc_freeflag2 = 0;	/* IRQ must not mfree */
-
-			NDBGL1(L1_I_MSG, "using 2nd ISAC TX buffer, state = %s", ifpnp_printstate(sc));
-
-			if(sc->sc_trace & TRACE_D_TX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0IFPNPUNIT(unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_TE;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-			}
-			splx(s);
-			return(1);
-		}
-
-		NDBGL1(L1_I_ERR, "No Space in TX FIFO, state = %s", ifpnp_printstate(sc));
-	
-		if(freeflag == MBUF_FREE)
-			i4b_Dfreembuf(m);			
-	
-		splx(s);
-		return (0);
-	}
-
-	if(sc->sc_trace & TRACE_D_TX)
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0IFPNPUNIT(unit);
-		hdr.type = TRC_CH_D;
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_dcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-	}
-	
-	sc->sc_state |= ISAC_TX_ACTIVE;	/* set transmitter busy flag */
-
-	NDBGL1(L1_I_MSG, "ISAC_TX_ACTIVE set");
-
-	sc->sc_freeflag = 0;		/* IRQ must NOT mfree */
-	
-	ISAC_WRFIFO(m->m_data, min(m->m_len, ISAC_FIFO_LEN)); /* output to TX fifo */
-
-	if(m->m_len > ISAC_FIFO_LEN)	/* message > 32 bytes ? */
-	{
-		sc->sc_obuf = m;	/* save mbuf ptr */
-		sc->sc_op = m->m_data + ISAC_FIFO_LEN; 	/* ptr for irq hdl */
-		sc->sc_ol = m->m_len - ISAC_FIFO_LEN;	/* length for irq hdl */
-
-		if(freeflag)
-			sc->sc_freeflag = 1;	/* IRQ must mfree */
-		
-		cmd = ISAC_CMDR_XTF;
-	}
-	else
-	{
-		sc->sc_obuf = NULL;
-		sc->sc_op = NULL;
-		sc->sc_ol = 0;
-
-		if(freeflag)
-			i4b_Dfreembuf(m);
-
-		cmd = ISAC_CMDR_XTF | ISAC_CMDR_XME;
-  	}
-
-	ISAC_WRITE(I_CMDR, cmd);
-	ISACCMDRWRDELAY();
-
-	splx(s);
-	
-	return(1);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-ACTIVATE-REQUEST
- *	=============================
- *
- *	parms:
- *		unit	physical interface unit number
- *
- *	returns:
- *		==0	
- *		!=0	
- *
- *---------------------------------------------------------------------------*/
-int
-ifpnp_ph_activate_req(int unit)
-{
-	struct l1_softc *sc = ifpnp_scp[unit];
-	NDBGL1(L1_PRIM, "PH-ACTIVATE-REQ, unit %d\n", unit);
-	ifpnp_next_state(sc, EV_PHAR);
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	command from the upper layers
- *---------------------------------------------------------------------------*/
-int
-ifpnp_mph_command_req(int unit, int command, void *parm)
-{
-	struct l1_softc *sc = ifpnp_scp[unit];
-
-	switch(command)
-	{
-		case CMR_DOPEN:		/* daemon running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DOPEN", unit);
-			sc->sc_enabled = 1;			
-			break;
-			
-		case CMR_DCLOSE:	/* daemon not running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DCLOSE", unit);
-			sc->sc_enabled = 0;
-			break;
-
-		case CMR_SETTRACE:
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_SETTRACE, parm = %d", unit, (unsigned int)parm);
-			sc->sc_trace = (unsigned int)parm;
-			break;
-		
-		default:
-			NDBGL1(L1_ERROR, "ERROR, unknown command = %d, unit = %d, parm = %d", command, unit, (unsigned int)parm);
-			break;
-	}
-
-	return(0);
-}
--- sys/i4b/layer1/ifpnp/i4b_ifpnp_isac.c
+++ /dev/null
@@ -1,659 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ifpnp_isac.c - i4b Fritz PnP ISAC handler
- *	---------------------------------------------
- *	$Id: i4b_ifpnp_isac.c,v 1.3 2000/05/29 15:41:41 hm Exp $ 
- *	$Ust: src/i4b/layer1-nb/ifpnp/i4b_ifpnp_isac.c,v 1.4 2000/04/18 08:03:05 ust Exp $
- *      last edit-date: [Mon May 29 15:24:49 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ifpnp/i4b_ifpnp_isac.c,v 1.7 2005/01/06 22:18:19 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/layer1/ifpnp/i4b_ifpnp_ext.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-static u_char ifpnp_isac_exir_hdlr(register struct l1_softc *sc, u_char exir);
-static void ifpnp_isac_ind_hdlr(register struct l1_softc *sc, int ind);
-
-/*---------------------------------------------------------------------------*
- *	ISAC interrupt service routine
- *---------------------------------------------------------------------------*/
-void
-ifpnp_isac_irq(struct l1_softc *sc, int ista)
-{
-	register u_char c = 0;
-	NDBGL1(L1_F_MSG, "unit %d: ista = 0x%02x", sc->sc_unit, ista);
-
-	if(ista & ISAC_ISTA_EXI)	/* extended interrupt */
-	{
-		c |= ifpnp_isac_exir_hdlr(sc, ISAC_READ(I_EXIR));
-	}
-	
-	if(ista & ISAC_ISTA_RME)	/* receive message end */
-	{
-		register int rest;
-		u_char rsta;
-
-		/* get rx status register */
-		
-		rsta = ISAC_READ(I_RSTA);
-
-		if((rsta & ISAC_RSTA_MASK) != 0x20)
-		{
-			int error = 0;
-			
-			if(!(rsta & ISAC_RSTA_CRC))	/* CRC error */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: CRC error", sc->sc_unit);
-			}
-	
-			if(rsta & ISAC_RSTA_RDO)	/* ReceiveDataOverflow */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Data Overrun error", sc->sc_unit);
-			}
-	
-			if(rsta & ISAC_RSTA_RAB)	/* ReceiveABorted */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Receive Aborted error", sc->sc_unit);
-			}
-
-			if(error == 0)			
-				NDBGL1(L1_I_ERR, "unit %d: RME unknown error, RSTA = 0x%02x!", sc->sc_unit, rsta);
-
-			i4b_Dfreembuf(sc->sc_ibuf);
-
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-
-			ISAC_WRITE(I_CMDR, ISAC_CMDR_RMC|ISAC_CMDR_RRES);
-			ISACCMDRWRDELAY();
-
-			return;
-		}
-
-		rest = (ISAC_READ(I_RBCL) & (ISAC_FIFO_LEN-1));
-
-		if(rest == 0)
-			rest = ISAC_FIFO_LEN;
-
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(rest)) != NULL)
-				sc->sc_ib = sc->sc_ibuf->m_data;
-			else
-				panic("ifpnp_isac_irq: RME, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - rest))
-		{
-			ISAC_RDFIFO(sc->sc_ib, rest);
-			sc->sc_ilen += rest;
-			
-			sc->sc_ibuf->m_pkthdr.len =
-				sc->sc_ibuf->m_len = sc->sc_ilen;
-
-			if(sc->sc_trace & TRACE_D_RX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0IFPNPUNIT(sc->sc_unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_NT;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, sc->sc_ibuf->m_len, sc->sc_ibuf->m_data);
-			}
-
-			c |= ISAC_CMDR_RMC;
-
-			if(sc->sc_enabled &&
-			   (ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S))
-			{
-				i4b_l1_ph_data_ind(L0IFPNPUNIT(sc->sc_unit), sc->sc_ibuf);
-			}
-			else
-			{
-				i4b_Dfreembuf(sc->sc_ibuf);
-			}
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RME, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-		}
-
-		sc->sc_ibuf = NULL;
-		sc->sc_ib = NULL;
-		sc->sc_ilen = 0;
-	}
-
-	if(ista & ISAC_ISTA_RPF)	/* receive fifo full */
-	{
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(MAX_DFRAME_LEN)) != NULL)
-				sc->sc_ib= sc->sc_ibuf->m_data;
-			else
-				panic("ifpnp_isac_irq: RPF, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - ISAC_FIFO_LEN))
-		{
-			ISAC_RDFIFO(sc->sc_ib, ISAC_FIFO_LEN);
-			sc->sc_ilen += ISAC_FIFO_LEN;			
-			sc->sc_ib += ISAC_FIFO_LEN;
-			c |= ISAC_CMDR_RMC;
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RPF, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;			
-		}
-	}
-
-	if(ista & ISAC_ISTA_XPR)	/* transmit fifo empty (XPR bit set) */
-	{
-		if((sc->sc_obuf2 != NULL) && (sc->sc_obuf == NULL))
-		{
-			sc->sc_freeflag = sc->sc_freeflag2;
-			sc->sc_obuf = sc->sc_obuf2;
-			sc->sc_op = sc->sc_obuf->m_data;
-			sc->sc_ol = sc->sc_obuf->m_len;
-			sc->sc_obuf2 = NULL;
-#ifdef NOTDEF			
-			printf("ob2=%x, op=%x, ol=%d, f=%d #",
-				sc->sc_obuf,
-				sc->sc_op,
-				sc->sc_ol,
-				sc->sc_state);
-#endif				
-		}
-		else
-		{
-#ifdef NOTDEF
-			printf("ob=%x, op=%x, ol=%d, f=%d #",
-				sc->sc_obuf,
-				sc->sc_op,
-				sc->sc_ol,
-				sc->sc_state);
-#endif
-		}			
-		
-		if(sc->sc_obuf)
-		{			
-			ISAC_WRFIFO(sc->sc_op, min(sc->sc_ol, ISAC_FIFO_LEN));
-	
-			if(sc->sc_ol > ISAC_FIFO_LEN)	/* length > 32 ? */
-			{
-				sc->sc_op += ISAC_FIFO_LEN; /* bufferptr+32 */
-				sc->sc_ol -= ISAC_FIFO_LEN; /* length - 32 */
-				c |= ISAC_CMDR_XTF;	    /* set XTF bit */
-			}
-			else
-			{
-				if(sc->sc_freeflag)
-				{
-					i4b_Dfreembuf(sc->sc_obuf);
-					sc->sc_freeflag = 0;
-				}
-				sc->sc_obuf = NULL;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-	
-				c |= ISAC_CMDR_XTF | ISAC_CMDR_XME;
-			}
-		}
-		else
-		{
-			sc->sc_state &= ~ISAC_TX_ACTIVE;
-		}
-	}
-	
-	if(ista & ISAC_ISTA_CISQ)	/* channel status change CISQ */
-	{
-		register u_char ci;
-	
-		/* get command/indication rx register*/
-	
-		ci = ISAC_READ(I_CIRR);
-
-		/* if S/Q IRQ, read SQC reg to clr SQC IRQ */
-	
-		if(ci & ISAC_CIRR_SQC)
-			(void) ISAC_READ(I_SQRR);
-
-		/* C/I code change IRQ (flag already cleared by CIRR read) */
-	
-		if(ci & ISAC_CIRR_CIC0)
-			ifpnp_isac_ind_hdlr(sc, (ci >> 2) & 0xf);
-	}
-	
-	if(c)
-	{
-		ISAC_WRITE(I_CMDR, c);
-		ISACCMDRWRDELAY();
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	ISAC L1 Extended IRQ handler
- *---------------------------------------------------------------------------*/
-static u_char
-ifpnp_isac_exir_hdlr(register struct l1_softc *sc, u_char exir)
-{
-	u_char c = 0;
-	
-	if(exir & ISAC_EXIR_XMR)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Message Repeat");
-
-		c |= ISAC_CMDR_XRES;
-	}
-	
-	if(exir & ISAC_EXIR_XDU)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Data Underrun");
-
-		c |= ISAC_CMDR_XRES;
-	}
-
-	if(exir & ISAC_EXIR_PCE)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Protocol Error");
-	}
-
-	if(exir & ISAC_EXIR_RFO)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Rx Frame Overflow");
-
-		c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-	}
-
-	if(exir & ISAC_EXIR_SOV)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Sync Xfer Overflow");
-	}
-
-	if(exir & ISAC_EXIR_MOS)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Monitor Status");
-	}
-
-	if(exir & ISAC_EXIR_SAW)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-		
-		NDBGL1(L1_I_ERR, "EXIRQ Subscriber Awake");
-	}
-
-	if(exir & ISAC_EXIR_WOV)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-
-		NDBGL1(L1_I_ERR, "EXIRQ Watchdog Timer Overflow");
-	}
-
-	return(c);
-}
-
-/*---------------------------------------------------------------------------*
- *	ISAC L1 Indication handler
- *---------------------------------------------------------------------------*/
-static void
-ifpnp_isac_ind_hdlr(register struct l1_softc *sc, int ind)
-{
-	register int event;
-	
-	switch(ind)
-	{
-		case ISAC_CIRR_IAI8:
-			NDBGL1(L1_I_CICO, "rx AI8 in state %s", ifpnp_printstate(sc));
-			if(sc->sc_bustyp == BUS_TYPE_IOM2)
-				ifpnp_isac_l1_cmd(sc, CMD_AR8);
-			event = EV_INFO48;
-			i4b_l1_mph_status_ind(L0IFPNPUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-			
-		case ISAC_CIRR_IAI10:
-			NDBGL1(L1_I_CICO, "rx AI10 in state %s", ifpnp_printstate(sc));
-			if(sc->sc_bustyp == BUS_TYPE_IOM2)
-				ifpnp_isac_l1_cmd(sc, CMD_AR10);
-			event = EV_INFO410;
-			i4b_l1_mph_status_ind(L0IFPNPUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-
-		case ISAC_CIRR_IRSY:
-			NDBGL1(L1_I_CICO, "rx RSY in state %s", ifpnp_printstate(sc));
-			event = EV_RSY;
-			break;
-
-		case ISAC_CIRR_IPU:
-			NDBGL1(L1_I_CICO, "rx PU in state %s", ifpnp_printstate(sc));
-			event = EV_PU;
-			break;
-
-		case ISAC_CIRR_IDR:
-			NDBGL1(L1_I_CICO, "rx DR in state %s", ifpnp_printstate(sc));
-			ifpnp_isac_l1_cmd(sc, CMD_DIU);
-			event = EV_DR;			
-			break;
-			
-		case ISAC_CIRR_IDID:
-			NDBGL1(L1_I_CICO, "rx DID in state %s", ifpnp_printstate(sc));
-			event = EV_INFO0;
-			i4b_l1_mph_status_ind(L0IFPNPUNIT(sc->sc_unit), STI_L1STAT, LAYER_IDLE, NULL);
-			break;
-
-		case ISAC_CIRR_IDIS:
-			NDBGL1(L1_I_CICO, "rx DIS in state %s", ifpnp_printstate(sc));
-			event = EV_DIS;
-			break;
-
-		case ISAC_CIRR_IEI:
-			NDBGL1(L1_I_CICO, "rx EI in state %s", ifpnp_printstate(sc));
-			ifpnp_isac_l1_cmd(sc, CMD_DIU);
-			event = EV_EI;
-			break;
-
-		case ISAC_CIRR_IARD:
-			NDBGL1(L1_I_CICO, "rx ARD in state %s", ifpnp_printstate(sc));
-			event = EV_INFO2;
-			break;
-
-		case ISAC_CIRR_ITI:
-			NDBGL1(L1_I_CICO, "rx TI in state %s", ifpnp_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISAC_CIRR_IATI:
-			NDBGL1(L1_I_CICO, "rx ATI in state %s", ifpnp_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISAC_CIRR_ISD:
-			NDBGL1(L1_I_CICO, "rx SD in state %s", ifpnp_printstate(sc));
-			event = EV_INFO0;
-			break;
-		
-		default:
-			NDBGL1(L1_I_ERR, "UNKNOWN Indication 0x%x in state %s", ind, ifpnp_printstate(sc));
-			event = EV_INFO0;
-			break;
-	}
-	ifpnp_next_state(sc, event);
-}
-
-/*---------------------------------------------------------------------------*
- *	execute a layer 1 command
- *---------------------------------------------------------------------------*/	
-void
-ifpnp_isac_l1_cmd(struct l1_softc *sc, int command)
-{
-	u_char cmd;
-
-#ifdef I4B_SMP_WORKAROUND
-
-	/* XXXXXXXXXXXXXXXXXXX */
-	
-	/*
-	 * patch from Wolfgang Helbig:
-	 *
-	 * Here is a patch that makes i4b work on an SMP:
-	 * The card (TELES 16.3) didn't interrupt on an SMP machine.
-	 * This is a gross workaround, but anyway it works *and* provides
-	 * some information as how to finally fix this problem.
-	 */
-	
-	HSCX_WRITE(0, H_MASK, 0xff);
-	HSCX_WRITE(1, H_MASK, 0xff);
-	ISAC_WRITE(I_MASK, 0xff);
-	DELAY(100);
-	HSCX_WRITE(0, H_MASK, HSCX_A_IMASK);
-	HSCX_WRITE(1, H_MASK, HSCX_B_IMASK);
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	/* XXXXXXXXXXXXXXXXXXX */
-	
-#endif /* I4B_SMP_WORKAROUND */
-
-	if(command < 0 || command > CMD_ILL)
-	{
-		NDBGL1(L1_I_ERR, "illegal cmd 0x%x in state %s", command, ifpnp_printstate(sc));
-		return;
-	}
-                                           
-	if(sc->sc_bustyp == BUS_TYPE_IOM2)
-		cmd = ISAC_CIX0_LOW;
-	else
-		cmd = 0;
-
-	switch(command)
-	{
-		case CMD_TIM:
-			NDBGL1(L1_I_CICO, "tx TIM in state %s", ifpnp_printstate(sc));
-			cmd |= (ISAC_CIXR_CTIM << 2);
-			break;
-
-		case CMD_RS:
-			NDBGL1(L1_I_CICO, "tx RS in state %s", ifpnp_printstate(sc));
-			cmd |= (ISAC_CIXR_CRS << 2);
-			break;
-
-		case CMD_AR8:
-			NDBGL1(L1_I_CICO, "tx AR8 in state %s", ifpnp_printstate(sc));
-			cmd |= (ISAC_CIXR_CAR8 << 2);
-			break;
-
-		case CMD_AR10:
-			NDBGL1(L1_I_CICO, "tx AR10 in state %s", ifpnp_printstate(sc));
-			cmd |= (ISAC_CIXR_CAR10 << 2);
-			break;
-
-		case CMD_DIU:
-			NDBGL1(L1_I_CICO, "tx DIU in state %s", ifpnp_printstate(sc));
-			cmd |= (ISAC_CIXR_CDIU << 2);
-			break;
-	}
-	ISAC_WRITE(I_CIXR, cmd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L1 ISAC initialization
- *---------------------------------------------------------------------------*/
-int
-ifpnp_isac_init(struct l1_softc *sc)
-{
-	ISAC_IMASK = 0xff;		/* disable all irqs */
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	if(sc->sc_bustyp != BUS_TYPE_IOM2)
-	{
-		NDBGL1(L1_I_SETUP, "configuring for IOM-1 mode");
-
-		/* ADF2: Select mode IOM-1 */		
-		ISAC_WRITE(I_ADF2, 0x00);
-
-		/* SPCR: serial port control register:
-		 *	SPU - software power up = 0
-		 *	SAC - SIP port high Z
-		 *	SPM - timing mode 0
-		 *	TLP - test loop = 0
-		 *	C1C, C2C - B1 and B2 switched to/from SPa
-		 */
-		ISAC_WRITE(I_SPCR, ISAC_SPCR_C1C1|ISAC_SPCR_C2C1);
-
-		/* SQXR: S/Q channel xmit register:
-                 *	SQIE - S/Q IRQ enable = 0
-		 *	SQX1-4 - Fa bits = 1
-		 */
-		ISAC_WRITE(I_SQXR, ISAC_SQXR_SQX1|ISAC_SQXR_SQX2|ISAC_SQXR_SQX3|ISAC_SQXR_SQX4);
-
-		/* ADF1: additional feature reg 1:
-		 *	WTC - watchdog = 0
-		 *	TEM - test mode = 0
-		 *	PFS - pre-filter = 0
-		 *	CFS - IOM clock/frame always active
-		 *	FSC1/2 - polarity of 8kHz strobe
-		 *	ITF - interframe fill = idle
-		 */	
-		ISAC_WRITE(I_ADF1, ISAC_ADF1_FC2);	/* ADF1 */
-
-		/* STCR: sync transfer control reg:
-		 *	TSF - terminal secific functions = 0
-		 *	TBA - TIC bus address = 7
-		 *	STx/SCx = 0
-		 */
-		ISAC_WRITE(I_STCR, ISAC_STCR_TBA2|ISAC_STCR_TBA1|ISAC_STCR_TBA0);
-
-		/* MODE: Mode Register:
-		 *	MDSx - transparent mode 2
-		 *	TMD  - timer mode = external
-		 *	RAC  - Receiver enabled
-		 *	DIMx - digital i/f mode
-		 */
-		ISAC_WRITE(I_MODE, ISAC_MODE_MDS2|ISAC_MODE_MDS1|ISAC_MODE_RAC|ISAC_MODE_DIM0);
-	}
-	else
-	{
-		NDBGL1(L1_I_SETUP, "configuring for IOM-2 mode");
-
-		/* ADF2: Select mode IOM-2 */		
-		ISAC_WRITE(I_ADF2, ISAC_ADF2_IMS);
-
-		/* SPCR: serial port control register:
-		 *	SPU - software power up = 0
-		 *	SPM - timing mode 0
-		 *	TLP - test loop = 0
-		 *	C1C, C2C - B1 + C1 and B2 + IC2 monitoring
-		 */
-		ISAC_WRITE(I_SPCR, 0x00);
-
-		/* SQXR: S/Q channel xmit register:
-		 *	IDC  - IOM direction = 0 (master)
-		 *	CFS  - Config Select = 0 (clock always active)
-		 *	CI1E - C/I channel 1 IRQ enable = 0
-                 *	SQIE - S/Q IRQ enable = 0
-		 *	SQX1-4 - Fa bits = 1
-		 */
-		ISAC_WRITE(I_SQXR, ISAC_SQXR_SQX1|ISAC_SQXR_SQX2|ISAC_SQXR_SQX3|ISAC_SQXR_SQX4);
-
-		/* ADF1: additional feature reg 1:
-		 *	WTC - watchdog = 0
-		 *	TEM - test mode = 0
-		 *	PFS - pre-filter = 0
-		 *	IOF - IOM i/f off = 0
-		 *	ITF - interframe fill = idle
-		 */	
-		ISAC_WRITE(I_ADF1, 0x00);
-
-		/* STCR: sync transfer control reg:
-		 *	TSF - terminal secific functions = 0
-		 *	TBA - TIC bus address = 7
-		 *	STx/SCx = 0
-		 */
-		ISAC_WRITE(I_STCR, ISAC_STCR_TBA2|ISAC_STCR_TBA1|ISAC_STCR_TBA0);
-
-		/* MODE: Mode Register:
-		 *	MDSx - transparent mode 2
-		 *	TMD  - timer mode = external
-		 *	RAC  - Receiver enabled
-		 *	DIMx - digital i/f mode
-		 */
-		ISAC_WRITE(I_MODE, ISAC_MODE_MDS2|ISAC_MODE_MDS1|ISAC_MODE_RAC|ISAC_MODE_DIM0);
-	}
-
-#ifdef NOTDEF
-	/*
-	 * XXX a transmitter reset causes an ISAC tx IRQ which will not
-	 * be serviced at attach time under some circumstances leaving
-	 * the associated IRQ line on the ISA bus active. This prevents
-	 * any further interrupts to be serviced because no low -> high
-	 * transition can take place anymore. (-hm)
-	 */
-	 
-	/* command register:
-	 *	RRES - HDLC receiver reset
-	 *	XRES - transmitter reset
-	 */
-	ISAC_WRITE(I_CMDR, ISAC_CMDR_RRES|ISAC_CMDR_XRES);
-	ISACCMDRWRDELAY();
-#endif
-	
-	/* enabled interrupts:
-	 * ===================
-	 * RME  - receive message end
-	 * RPF  - receive pool full
-	 * XPR  - transmit pool ready
-	 * CISQ - CI or S/Q channel change
-	 * EXI  - extended interrupt
-	 */
-
-	ISAC_IMASK = ISAC_MASK_RSC |	/* auto mode only	*/
-		     ISAC_MASK_TIN | 	/* timer irq		*/
-		     ISAC_MASK_SIN;	/* sync xfer irq	*/
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	return(0);
-}
--- sys/i4b/layer1/ihfc/i4b_ihfc_pnp.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/*-
- * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ihfc_pnp.c - common hfc ISA PnP-bus interface
- *	-------------------------------------------------
- *	- Everything which has got anything to to with "PnP" bus setup has
- *	  been put here, except the chip spesific "PnP" setup.
- *
- *      last edit-date: [Tue Jan 23 16:03:33 2001]
- *      $Id: i4b_ihfc_pnp.c,v 1.9 2000/09/19 13:50:36 hm Exp $
- *     
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ihfc/i4b_ihfc_pnp.c,v 1.10 2005/01/06 22:18:20 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <i4b/include/i4b_global.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/ihfc/i4b_ihfc.h>
-#include <i4b/layer1/ihfc/i4b_ihfc_ext.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <isa/isavar.h>
-
-/*---------------------------------------------------------------------------*
- *	Softc
- *---------------------------------------------------------------------------*/
-ihfc_sc_t		ihfc_softc[IHFC_MAXUNIT];
-
-/*---------------------------------------------------------------------------*
- *	Prototypes
- *---------------------------------------------------------------------------*/
-static int ihfc_isa_probe	(device_t dev);
-static int ihfc_pnp_probe	(device_t dev);
-static int ihfc_pnp_attach	(device_t dev);
-static int ihfc_pnp_detach 	(device_t dev, u_int flag);
-static int ihfc_pnp_shutdown	(device_t dev);
-
-const struct ihfc_pnp_ids
-{
-	u_long	vid;		/* vendor id			*/
-	int	flag;		/*				*/
-	u_char	hfc;		/* chip type 			*/
-	u_char	iirq;		/* internal irq			*/
-	u_short	iio;		/* internal io-address		*/
-	u_char  stdel;		/* S/T delay compensation	*/
-}
-	ihfc_pnp_ids[] =
-{
-	{ 0x10262750, CARD_TYPEP_16_3C,   HFC_S,  2, 0x200, 0x2d},
-	{ 0x20262750, CARD_TYPEP_16_3C,   HFC_SP, 0, 0x000, 0x0f},
-	{ 0x1411d805, CARD_TYPEP_ACERP10, HFC_S,  1, 0x300, 0x0e},
-	{ 0 }
-};
-
-typedef const struct ihfc_pnp_ids ihfc_id_t;
-
-/*---------------------------------------------------------------------------*
- *	PCB layout
- *
- *	IIRQx: Internal IRQ cross reference for a card
- *	IRQx : Supported IRQ's for a card
- *	IOx  : Supported IO-bases for a card
- *
- *	IO0, IRQ0, IIRQ0: TELEINT ISDN SPEED No. 1
- *		   IIRQ3: Teles 16.3c PnP (B version)
- *---------------------------------------------------------------------------*/
-		      /* IRQ  ->  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f */
-#define	IIRQ0 ((const u_char []){ 0, 0, 0, 1, 2, 3, 0, 4, 0, 0, 5, 6, 0, 0, 0, 0 })
-#define IRQ0  ((const u_char []){          3, 4, 5,    7,     0xa, 0xb, 0 })
-
-#define IO0   ((const u_long []){ 0x300, 0x330, 0x278, 0x2e8, 0 })
-
-#define IIRQ3 ((const u_char []){ 0, 0, 0, 7, 0, 1, 0, 0, 0, 2, 3, 4, 5, 0, 0, 6 })
-
-/*---------------------------------------------------------------------------*
- *	ISA PnP setup
- *---------------------------------------------------------------------------*/
-static device_method_t ihfc_pnp_methods[] = 
-{
-	DEVMETHOD(device_probe,		ihfc_pnp_probe),
-	DEVMETHOD(device_attach,	ihfc_pnp_attach),
-	DEVMETHOD(device_shutdown,	ihfc_pnp_shutdown),
-	{ 0, 0 }
-};                              
-
-static driver_t ihfc_pnp_driver = 
-{
-	"ihfc",
-	ihfc_pnp_methods,
-	0,
-};
-
-static devclass_t ihfc_devclass;
-
-DRIVER_MODULE(ihfcpnp, isa, ihfc_pnp_driver, ihfc_devclass, 0, 0);
-
-/*---------------------------------------------------------------------------*
- *      probe for ISA "PnP" card
- *---------------------------------------------------------------------------*/
-static int
-ihfc_pnp_probe(device_t dev)
-{
-	u_int 	       unit = device_get_unit(dev);	/* get unit	  */
-	u_int32_t	vid = isa_get_vendorid(dev); 	/* vendor id	  */
-	ihfc_id_t      *ids = &ihfc_pnp_ids[0];		/* ids ptr	  */
-	ihfc_sc_t 	*sc = &ihfc_softc[unit];	/* softc	  */
-	u_char	       flag = 0;			/* flag		  */
-	void         *dummy = 0;			/* a dummy	  */
-
-	HFC_VAR;
-
-	if (unit >= IHFC_MAXUNIT)
-	{
-		printf("ihfc%d: Error, unit %d >= IHFC_MAXUNIT", unit, unit);
-		return ENXIO;
-	}
-
-	if (!vid) return ihfc_isa_probe(dev);
-
-	HFC_BEG;
-
-	for ( ;(ids->vid); ids++)
-	{
-		if (ids->vid == vid)
-		{
-			flag = 0;
-
-			bzero(sc, sizeof(ihfc_sc_t));		/* reset data structure.*
-								 * Zero is default for  *
-								 * most, so calling the *
-								 * int. handler now will*
-								 * not be a problem.    */
-
-			S_IOBASE[0] = bus_alloc_resource(
-				dev, SYS_RES_IOPORT, &S_IORID[0],
-				0UL, ~0UL, 2, RF_ACTIVE
-				);
-
-			S_IRQ = bus_alloc_resource_any(
-				dev, SYS_RES_IRQ, &S_IRQRID,
-				RF_ACTIVE
-				);
-
-			S_DLP     = IHFC_DLP;		/* set D-priority	*/
-			S_HFC	  = ids->hfc;		/* set chip type	*/
-			S_I4BFLAG = ids->flag;		/* set flag		*/
-			S_NTMODE  = IHFC_NTMODE;	/* set mode		*/
-			S_STDEL   = ids->stdel;		/* set delay		*/
-
-			S_I4BUNIT = L0IHFCUNIT(unit);	/* set "i4b" unit	*/
-			S_TRACE   = TRACE_OFF;		/* set trace mask	*/
-			S_UNIT 	  = unit;		/* set up unit numbers	*/
-
-			if (S_IOBASE[0] && S_IRQ)
-			{
-				if (ids->iio)
-				{
-					S_IIO  = ids->iio;
-					S_IIRQ = ids->iirq;
-				}
-				else
-				{
-					S_IIO  = rman_get_start(S_IOBASE[0]) & 0x3ff;
-					S_IIRQ = IIRQ3[rman_get_start(S_IRQ) & 0xf];
-				}
-
-				/* setup interrupt routine now to avvoid stray	*
-				 * interrupts.					*/
-
-				bus_setup_intr(dev, S_IRQ, INTR_TYPE_NET, (void(*)(void*))
-					HFC_INTR, sc, &dummy);
-
-				flag = 1;
-
-				if (!HFC_CONTROL(sc, 1))
-				{
-					HFC_END;
-					return 0;	/* success */
-				}
-				else
-				{
-					printf("ihfc%d: Chip seems corrupted. "
-					"Please hard reboot your computer!\n",
-					unit);					
-				}
-			}
-
-			ihfc_pnp_detach(dev, flag);
-		}
-	}
-
-	HFC_END;
-	return ENXIO;	/* failure */
-}
-
-/*---------------------------------------------------------------------------*
- *      probe for "ISA" cards
- *---------------------------------------------------------------------------*/
-static int
-ihfc_isa_probe(device_t dev)
-{
-	u_int 	        unit = device_get_unit(dev);	/* get unit	  */
-	ihfc_sc_t        *sc = &ihfc_softc[unit];	/* softc	  */
-	const u_char    *irq = &IRQ0[0]; 		/* irq's to try   */
-	const u_long *iobase = &IO0[0];			/* iobases to try */
-	u_char	        flag = 0;			/* flag		  */
-	void          *dummy = 0;			/* a dummy	  */
-
-	HFC_VAR;
-
-	bzero(sc, sizeof(ihfc_sc_t));		/* reset data structure	 *
-						 * We must reset the     *
-						 * datastructure here,	 *
-						 * else we risk zero-out *
-						 * our gotten resources. */
-	HFC_BEG;
-
-  j0:	while(*irq) 	/* get supported IRQ */
-	{
-		if ((S_IRQ = bus_alloc_resource(
-			dev, SYS_RES_IRQ, &S_IRQRID,
-			*irq, *irq, 1, RF_ACTIVE
-			)
-		   ))
-				break;
-		else
-				irq++;
-	}
-
-	while(*iobase)	/* get supported IO-PORT */
-	{
-		if ((S_IOBASE[0] = bus_alloc_resource(
-		   	dev, SYS_RES_IOPORT, &S_IORID[0],
-			*iobase, *iobase, 2, RF_ACTIVE
-			)
-		   ))
-			 	break;
-		else
-				iobase++;
-	}
-
-	flag = 0;
-
-	if (*irq && *iobase)	/* we got our resources, now test chip */
-	{
-		S_DLP     = IHFC_DLP;		/* set D-priority	*/
-		S_HFC	  = HFC_1;		/* set chip type	*/
-		S_I4BFLAG = CARD_TYPEP_TELEINT_NO_1; /* set flag	*/
-		S_NTMODE  = IHFC_NTMODE;	/* set mode		*/
-		S_STDEL   = 0x00;		/* set delay (not used)	*/
-
-		S_I4BUNIT = L0IHFCUNIT(unit);	/* set "i4b" unit	*/
-		S_TRACE   = TRACE_OFF;		/* set trace mask	*/
-		S_UNIT 	  = unit;		/* set up unit numbers	*/
-
-		S_IIRQ	  = IIRQ0[*irq];	/* set internal irq	*/
-		S_IIO	  = *iobase;		/* set internal iobase	*/
-
-		/* setup interrupt routine now to avvoid stray	*
-		 * interrupts.					*/
-
-		bus_setup_intr(dev, S_IRQ, INTR_TYPE_NET, (void(*)(void*))
-			HFC_INTR, sc, &dummy);
-
-		flag = 1;
-
-		if (!HFC_CONTROL(sc, 1))
-		{
-			device_set_desc(dev, "TELEINT ISDN SPEED No. 1");
-
-			HFC_END;
-			return 0;	/* success */
-		}
-	}
-
-	ihfc_pnp_detach(dev, flag);
-
-	if (*irq && *++iobase) goto j0;	/* try again */
-
-	HFC_END;
-
-	printf("ihfc%d: Chip not found. "
-	"A hard reboot may help!\n", unit);
-
-	return ENXIO;	/* failure */
-}
-
-/*---------------------------------------------------------------------------*
- *      attach ISA "PnP" card
- *---------------------------------------------------------------------------*/
-static int
-ihfc_pnp_attach(device_t dev)
-{
-	u_int	   unit = device_get_unit(dev);		/* get unit	*/
-	ihfc_sc_t   *sc	= &ihfc_softc[unit];		/* softc	*/
-	HFC_VAR;
- 
-	HFC_BEG;
-
-	ihfc_B_linkinit(sc);	/* Setup B-Channel linktabs */
-
-	i4b_l1_mph_status_ind(S_I4BUNIT, STI_ATTACH, S_I4BFLAG, &ihfc_l1mux_func);
-	
-	HFC_INIT(sc, 0, 0, 1);	/* Setup D - Channel */
-
-	HFC_INIT(sc, 2, 0, 0);	/* Init B1 - Channel */
-	HFC_INIT(sc, 4, 0, 0); 	/* Init B2 - Channel */
-
-	HFC_END;
-	return 0;	/* success */
-
-	HFC_END;
-	return ENXIO;	/* failure */
-}
-
-/*---------------------------------------------------------------------------*
- *      shutdown for our ISA PnP card
- *---------------------------------------------------------------------------*/
-static int
-ihfc_pnp_shutdown(device_t dev)
-{
-	u_int	   unit = device_get_unit(dev);		/* get unit	*/
-	ihfc_sc_t   *sc	= &ihfc_softc[unit];		/* softc	*/
-	HFC_VAR;
-
-	HFC_BEG;
-
-	if (unit >= IHFC_MAXUNIT)
-	{
-		printf("ihfc%d: Error, unit %d >= IHFC_MAXUNIT", unit, unit);
-		goto f0;
-	}
-
-	HFC_CONTROL(sc, 2);	/* shutdown chip */
-
-	HFC_END;
-	return 0;
-  f0:
-	HFC_END;
-	return ENXIO;
-
-}
-
-/*---------------------------------------------------------------------------*
- *      detach for our ISA PnP card
- *
- *	flag:	bit[0] set: teardown interrupt handler too
- *---------------------------------------------------------------------------*/
-static int
-ihfc_pnp_detach (device_t dev, u_int flag)
-{
-	u_int	   unit = device_get_unit(dev);		/* get unit	*/
-	ihfc_sc_t   *sc	= &ihfc_softc[unit];		/* softc	*/
-	u_char 	      i;
-
-	if (unit >= IHFC_MAXUNIT)
-	{
-		printf("ihfc%d: Error, unit %d >= IHFC_MAXUNIT", unit, unit);
-		return 0;
-	}
-
-	/* free interrupt resources */
-
-	if(S_IRQ)
-	{
-		if (flag & 1)
-		{
-			/* tear down interrupt handler */
-			bus_teardown_intr(dev, S_IRQ, (void(*)(void *))HFC_INTR);
-		}
-
-		/* free irq */
-		bus_release_resource(dev, SYS_RES_IRQ, S_IRQRID, S_IRQ);
-
-		S_IRQRID = 0;
-		S_IRQ = 0;
-	}
-
-
-	/* free iobases */
-
-	for (i = IHFC_IO_BASES; i--;)
-	{
-		if(S_IOBASE[i])
-		{
-			bus_release_resource(dev, SYS_RES_IOPORT,
-					S_IORID[i], S_IOBASE[i]);
-			S_IORID[i] = 0;
-			S_IOBASE[i] = 0;			
-		}
-	}
-
-	return 0;
-}
--- sys/i4b/layer1/ihfc/i4b_ihfc.h
+++ /dev/null
@@ -1,338 +0,0 @@
-/*-
- * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ihfc.h - ihfc common header file
- *	------------------------------------
- *
- *	last edit-date: [Wed Jul 19 09:40:45 2000]
- *
- *	$Id: i4b_ihfc.h,v 1.9 2000/09/19 13:50:36 hm Exp $
- *
- * $FreeBSD: src/sys/i4b/layer1/ihfc/i4b_ihfc.h,v 1.2 2005/01/06 22:18:19 imp Exp $
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_IHFC_H_
-#define _I4B_IHFC_H_
-
-#include <i4b/include/i4b_l3l4.h>
-
-/*---------------------------------------------------------------------------*
- *	global stuff						(HFC-1/S/SP)
- *---------------------------------------------------------------------------*/
-#define DCH_MAX_LEN		264	/* max length of a D frame */
-
-#define IHFC_ACTIVATION_TIMEOUT	3*hz	/* S0-bus must activate before this time */
-
-#define IHFC_IO_BASES		1
-
-#define IHFC_DISBUSYTO		500	/* do at least 500 inb's before giving up */
-#define IHFC_NONBUSYTO		8000	/* do at least 8000 inb's before giving up */
-
-#define IHFC_NTMODE		0	/* use TE-mode as default 	 */
-#define IHFC_DLP		0	/* use (8/9) priority as default */
-
-#define	IHFC_MAXUNIT		4
-
-/* #define IHFC_DEBUG	internal debugging enabled  *
- * #undef  IHFC_DEBUG	internal debugging disabled */
-
-/* chan:           *
- * 0 - D1 (tx)     *
- * 1 - D1 (rx)     *
- * 2 - B1 (tx)     *
- * 3 - B1 (rx)     *
- * 4 - B2 (tx)     *
- * 5 - B2 (rx)     */
-
-#define HFC_1			0x01	/* HFC		2B	*/
-#define HFC_S			0x02	/* HFC - S	2BDS0	*/
-#define HFC_SP			0x04	/* HFC - SP	2BDS0	*/
-#define HFC_SPCI		0x08	/* HFC - SPCI	2BDS0 X */
-#define HFC_S2M			0x10	/* HFC - S2M	2BDS0 X */
-#define HFC_USB			0x20	/* HFC - USB	2BDS0 X */
-
-/*---------------------------------------------------------------------------*
- *	"Help Fix Corruption" macros				(HFC-1/S/SP)
- *
- *	NOTE: If the code does not run at splhigh, we will sporadically
- *	lose bytes. On fast PC's (200 Mhz), this is very little noticable.
- *---------------------------------------------------------------------------*/
-#define HFC_VAR	int _s_			/* declare variable	*/
-#define HFC_BEG	_s_ = splhigh()		/* save spl		*/
-#define HFC_END	splx(_s_)		/* restore spl		*/
-
-/*---------------------------------------------------------------------------*
- *	macros related to i4b linking				(HFC-1/S/SP)
- *---------------------------------------------------------------------------*/
-#define S_BLINK		sc->sc_blinktab[(chan > 3) ? 1 : 0]
-#define S_BDRVLINK	sc->sc_bdrvlinktab[(chan > 3) ? 1 : 0]
-
-/*---------------------------------------------------------------------------*
- *	macros related to ihfc_sc				(HFC-1/S/SP)
- *---------------------------------------------------------------------------*/
-
-/* statemachine */
-
-#define S_IOM2		(sc->sc_config.i_adf2 & 0x80)
-	/* 0x80: IOM2 mode selected */
-
-#define S_DLP		(sc->sc_config.dlp)
-#define S_NTMODE	(sc->sc_config.ntmode)
-#define S_STDEL		(sc->sc_config.stdel)
-
-#define	S_PHSTATE	sc->sc_statemachine.state
-#define	S_STM_T3	sc->sc_statemachine.T3
-#define	S_STM_T3CALLOUT	sc->sc_statemachine.T3callout
-
-/* unitnumbers */
-
-#define S_UNIT		sc->sc_unit
-#define S_FLAG		sc->sc_flag
-#define S_I4BUNIT	sc->sc_i4bunit
-#define S_I4BFLAG	sc->sc_i4bflag
-
-/* ISA bus setup */
-
-#define S_IOBASE	sc->sc_resources.io_base
-#define S_IORID		sc->sc_resources.io_rid
-#define S_IRQ		sc->sc_resources.irq
-#define S_IRQRID	sc->sc_resources.irq_rid
-
-/* hardware setup */
-
-#define S_HFC		sc->sc_config.chiptype
-#define S_IIO		sc->sc_config.iio
-#define S_IIRQ		sc->sc_config.iirq
-
-/* registers of the HFC-S/SP	(write only) */
-
-#define S_HFC_CONFIG	sc->sc_config.cirm
-
-#define S_CIRM		sc->sc_config.cirm
-#define S_CTMT		sc->sc_config.ctmt
-#define S_TEST		sc->sc_config.test
-#define S_SCTRL		sc->sc_config.sctrl
-#define S_CLKDEL	sc->sc_config.clkdel
-#define S_INT_M1	sc->sc_config.int_m1
-#define S_INT_M2	sc->sc_config.int_m2
-#define S_CONNECT	sc->sc_config.connect
-#define S_SCTRL_R	sc->sc_config.sctrl_r
-#define S_MST_MODE	sc->sc_config.mst_mode
-
-/* registers of the HFC-S/SP 	(read only) */
-
-#define S_INT_S1	sc->sc_config.int_s1
-
-/* registers of the ISAC 	(write only) */
-
-#define S_ISAC_CONFIG	sc->sc_config.i_adf2
-
-#define	S_ADF1		sc->sc_config.i_adf1
-#define	S_ADF2		sc->sc_config.i_adf2
-#define	S_MASK		sc->sc_config.i_mask
-#define	S_MODE		sc->sc_config.i_mode
-#define	S_SPCR		sc->sc_config.i_spcr
-#define	S_SQXR		sc->sc_config.i_sqxr
-#define	S_STCR		sc->sc_config.i_stcr
-#define	S_STAR2		sc->sc_config.i_star2
-
-/* registers of the ISAC 	(read only) */
-
-#define	S_ISTA		sc->sc_config.i_ista
-
-/* state of the softc */
-
-#define	S_ENABLED	sc->sc_enabled
-#define S_INTR_ACTIVE	sc->sc_intr_active
-
-/* SOFT-HDLC */
-
-#define S_HDLC_IB	sc->sc_fifo.chan[chan].hdlc.ib		/* u_short */
-#define S_HDLC_CRC	sc->sc_fifo.chan[chan].hdlc.crc		/* u_short */
-#define S_HDLC_TMP	sc->sc_fifo.chan[chan].hdlc.tmp		/* u_int   */
-#define S_HDLC_FLAG	sc->sc_fifo.chan[chan].hdlc.flag	/* u_char  */
-#define S_HDLC_BLEVEL	sc->sc_fifo.chan[chan].hdlc.blevel	/* u_short */
-
-/* stats */
-
-#define S_BYTES		sc->sc_fifo.chan[chan].bytes
-
-/* "Z"-values */
-
-#define S_HDLC_DZ_TAB	sc->sc_fifo.dztable
-
-/* filters */
-
-#define S_PROT		sc->sc_fifo.chan[chan].prot
-#define S_FILTER	sc->sc_fifo.chan[chan].filter
-#define S_ACTIVITY	sc->sc_fifo.chan[chan].activity
-#define S_LAST_CHAN	sc->sc_fifo.last_chan
-
-/* soft reset */
-
-#define RESET_SOFT_CHAN(sc, chan)	bzero(&sc->sc_fifo.chan[chan], sizeof(sc->sc_fifo.chan[0]))
-
-/* trace */
-
-#define S_TRACE		sc->sc_trace
-#define S_DTRACECOUNT	sc->sc_Dtracecount
-#define S_BTRACECOUNT	sc->sc_Btracecount
-
-/* mbuf */
-
-#define S_MBUF		sc->sc_fifo.chan[chan].buffer.mbuf
-#define S_MBUFDUMMY	sc->sc_fifo.chan[chan].buffer.mbufdummy
-#define S_MBUFLEN	sc->sc_fifo.chan[chan].buffer.mbuf->m_len
-#define S_MBUFPKTHDR	sc->sc_fifo.chan[chan].buffer.mbuf->m_pkthdr
-#define S_MBUFDATA	sc->sc_fifo.chan[chan].buffer.mbuf->m_data
-#define S_MBUFDAT	sc->sc_fifo.chan[chan].buffer.mbuf->m_dat
-
-#define S_IFQUEUE	sc->sc_fifo.chan[chan].buffer.ifqueue
-
-/* hfc control */
-
-#define HFC_INIT	ihfc_init
-#define HFC_INTR	((S_HFC & HFC_1) ? ihfc_intr1 : ihfc_intr2)
-#define HFC_FSM		ihfc_fsm
-#define HFC_CONTROL	ihfc_control
-
-/* softc parts */
-
-struct ihfc_sc;
-
-struct sc_resources {
-	struct resource * io_base[IHFC_IO_BASES];
-	int	      	  io_rid [IHFC_IO_BASES];
-	struct resource * irq;
-	int	     	  irq_rid;
-};
-
-struct hdlc {
-	u_char  flag;
-	u_short blevel;
-	u_short crc;
-	u_short ib;
-	u_int   tmp;
-};
-
-struct buffer {
-	struct ifqueue	ifqueue;	/* data queue	*/
-	struct mbuf    	*mbuf;		/* current mbuf	*/
-	struct mbuf	*mbufdummy;	/* temporary	*/
-};
-
-struct chan {
-	struct hdlc	hdlc;
-	u_int		bytes;
-	u_int		prot;
-	struct buffer	buffer;
-	void (*filter)(struct ihfc_sc *sc, u_char chan);
-};
-
-struct sc_fifo {
-	struct	chan chan[6];
-	u_short	dztable[16];
-	u_char	last_chan;
-};
-
-struct sc_config {
-	/* software only: */
-
-	u_short	chiptype;	/* chiptype (eg. HFC_1)	*/
-	u_char  dlp;		/* D-priority		*/
-	u_short	iio;		/* internal IO		*/
-	u_char	iirq;		/* internal IRQ		*/
-	u_char  ntmode;		/* mode 		*/
-	u_char	stdel;		/* S/T delay		*/
-
-	/* write only: */
-	u_char cirm;
-	u_char ctmt;
-	u_char int_m1;
-	u_char int_m2;
-	u_char mst_mode;
-	u_char clkdel;
-	u_char sctrl;
-	u_char connect;
-	u_char test;
-	u_char sctrl_r;
-
-	/* isac write only - hfc-1: */
-	u_char i_adf2;
-	u_char i_spcr;
-	u_char i_sqxr;
-	u_char i_adf1;
-	u_char i_stcr;
-	u_char i_mode;
-	u_char i_mask;
-	u_char i_star2;
-
-	/* read only: */
-	u_char int_s1;
-
-	/* isac read only - hfc-1: */
-	u_char i_ista;
-};
-
-struct sc_statemachine {
-	u_char			state;		/* see i4b_ihfc_drv.h */
-	u_char			usync;
-	u_char			T3;		/* T3 running 	      */
-	struct callout_handle	T3callout;
-};
-
-/*---------------------------------------------------------------------------*
- *	HFC softc
- *---------------------------------------------------------------------------*/
-typedef	struct	ihfc_sc
-{	int			sc_unit;
-	int			sc_flag;
-
-	int			sc_i4bunit;	/* L0IHFCUNIT(sc_unit)	 */
-	int			sc_i4bflag;	/* FLAG_TEL_S0_16_3C ..	 */
-
-	u_char			sc_enabled;	/* daemon running if set */
-	u_char			sc_intr_active;	/* interrupt is active	 */
-
-	int			sc_trace;
-	u_int			sc_Btracecount;
-	u_int			sc_Dtracecount;
-
-	struct sc_config	sc_config;
-	struct sc_resources	sc_resources;
-	struct sc_statemachine	sc_statemachine;
-
-	isdn_link_t		sc_blinktab[2];
-	drvr_link_t		*sc_bdrvlinktab[2];
-
-	struct sc_fifo 		sc_fifo;
-} ihfc_sc_t;
-
-extern ihfc_sc_t	ihfc_softc[];
-
-#endif /* _I4B_IHFC_H_ */
--- sys/i4b/layer1/ihfc/i4b_ihfc_ext.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ihfc_ext.h - ihfc common prototypes
- *	---------------------------------------
- *
- *      last edit-date: [Wed Jul 19 09:40:59 2000]
- *
- *      $Id: i4b_ihfc_ext.h,v 1.6 2000/08/20 07:14:08 hm Exp $
- *
- * $FreeBSD: src/sys/i4b/layer1/ihfc/i4b_ihfc_ext.h,v 1.2 2005/01/06 22:18:19 imp Exp $
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef I4B_IHFC_EXT_H_
-#define I4B_IHFC_EXT_H_
-
-#include <i4b/include/i4b_l3l4.h>
-
-
-/* prototypes from i4b_ihfc_l1if.c */
-
-extern struct i4b_l1mux_func ihfc_l1mux_func;
-
-void	      ihfc_B_linkinit	(ihfc_sc_t *sc);
-struct mbuf * ihfc_getmbuf	(ihfc_sc_t *sc, u_char chan);
-void          ihfc_putmbuf	(ihfc_sc_t *sc, u_char chan, struct mbuf *m);
-
-
-/* prototypes from i4b_ihfc_drv.c */
-
-void         ihfc_intr1 	(ihfc_sc_t *sc);
-void         ihfc_intr2 	(ihfc_sc_t *sc);
-
-int          ihfc_control	(ihfc_sc_t *sc,   int flag);
-void         ihfc_fsm 		(ihfc_sc_t *sc,   int flag);
-int          ihfc_init 		(ihfc_sc_t *sc,   u_char chan, int prot, int activate);
-
-#endif /* I4B_IHFC_EXT_H_ */
--- sys/i4b/layer1/ihfc/i4b_ihfc_l1if.c
+++ /dev/null
@@ -1,510 +0,0 @@
-/*-
- * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ihfc_l1.c - hfc layer 1 handler
- *	-----------------------------------
- *	The idea of this file is to separate hfcs/sp/pci data/signal
- *	handling and the I4B data/signal handling.
- *
- *	Everything which has got anything to do with I4B has been put here!
- *
- *      last edit-date: [Wed Jul 19 09:41:03 2000]
- *      $Id: i4b_ihfc_l1if.c,v 1.10 2000/09/19 13:50:36 hm Exp $
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ihfc/i4b_ihfc_l1if.c,v 1.13 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/ihfc/i4b_ihfc.h>
-#include <i4b/layer1/ihfc/i4b_ihfc_ext.h>
-
-/*---------------------------------------------------------------------------*
- *	Local prototypes
- *
- *	NOTE: The prototypes for get/putmbuf and B_linkinit 
- *		have been put in i4b_hfc_ext.h for global hfc use.
- *
- *	NOTE: channel != chan
- *---------------------------------------------------------------------------*/
-static
-isdn_link_t   * ihfc_B_ret_linktab   (int unit, int channel);
-static 	void	ihfc_B_set_linktab   (int unit, int channel, drvr_link_t *B_linktab);
-
-static 	void	ihfc_B_start         (int unit, int chan);
-static 	void	ihfc_B_stat          (int unit, int chan, bchan_statistics_t *bsp);
-	void	ihfc_B_setup         (int unit, int chan, int bprot, int activate);
-
-static	int	ihfc_mph_command_req (int unit, int command, void *parm);
-
-static	int	ihfc_ph_activate_req (int unit);
-static	int	ihfc_ph_data_req     (int unit, struct mbuf *m, int freeflag);
-
-static  void	ihfc_T3_expired      (ihfc_sc_t *sc);
-
-/*---------------------------------------------------------------------------*
- *	Our I4B L1 mulitplexer link
- *---------------------------------------------------------------------------*/
-struct i4b_l1mux_func ihfc_l1mux_func = {
-	ihfc_B_ret_linktab,
-	ihfc_B_set_linktab,
-	ihfc_mph_command_req,
-	ihfc_ph_data_req,
-	ihfc_ph_activate_req,
-};
-
-/*---------------------------------------------------------------------------*
- *	L2 -> L1: PH-DATA-REQUEST (D-Channel)
- *
- *	NOTE: We may get called here from ihfc_hdlc_Dread or isac_hdlc_Dread
- *	via the upper layers.
- *---------------------------------------------------------------------------*/
-static int
-ihfc_ph_data_req(int unit, struct mbuf *m, int freeflag)
-{
-	ihfc_sc_t *sc = &ihfc_softc[unit];
-	u_char chan = 0;
-	HFC_VAR;
-
-	if (!m) return 0;
-
-	HFC_BEG;
-
-	if(S_PHSTATE != 3)
-	{
-		NDBGL1(L1_PRIM, "L1 was not running: "
-			"ihfc_ph_activate_req(unit = %d)!", unit);
-
-			ihfc_ph_activate_req(unit);
-	}
-
-	/* "Allow" I-frames (-hp) */
-
-	if (freeflag == MBUF_DONTFREE)	m = m_copypacket(m, M_DONTWAIT);
-
-	if (!_IF_QFULL(&S_IFQUEUE) && m)
-	{
-		IF_ENQUEUE(&S_IFQUEUE, m);
-
-		ihfc_B_start(unit, chan);	/* (recycling) */
-	}
-	else
-	{
-		NDBGL1(L1_ERROR, "No frame out (unit = %d)", unit);
-		if (m) i4b_Dfreembuf(m);
-
-		HFC_END;
-		return 0;
-	}
-
-	if (S_INTR_ACTIVE) S_INT_S1 |= 0x04;
-
-	HFC_END;
-
-	return 1;
-}
-
-/*---------------------------------------------------------------------------*
- *	L2 -> L1: PH-ACTIVATE-REQUEST (B-channel and D-channel)
- *---------------------------------------------------------------------------*/
-static int
-ihfc_ph_activate_req(int unit)
-{
-	ihfc_sc_t *sc = &ihfc_softc[unit];
-	HFC_VAR;
-
-	HFC_BEG;
-
-	if ((!S_STM_T3) && (S_PHSTATE != 3))
-	{
-		HFC_FSM(sc, 1);
-
-		S_STM_T3 = 1;
-		S_STM_T3CALLOUT = timeout((TIMEOUT_FUNC_T)
-					ihfc_T3_expired, (ihfc_sc_t *)sc,
-					IHFC_ACTIVATION_TIMEOUT);
-	}
-
-	HFC_END;
-	return 0;
-}
-/*---------------------------------------------------------------------------*
- *	T3 timeout - persistant deactivation
- *---------------------------------------------------------------------------*/
-static void
-ihfc_T3_expired(ihfc_sc_t *sc)
-{
-	u_char chan = 0;
-	HFC_VAR;
-
-	HFC_BEG;
-
-	S_STM_T3 = 0;
-
-	if (S_PHSTATE != 3)	/* line was not activated */
-	{
-		i4b_Dcleanifq(&S_IFQUEUE);
-		i4b_l1_ph_deactivate_ind(S_I4BUNIT);
-
-		i4b_l1_mph_status_ind(S_I4BUNIT, STI_PDEACT, 0, 0);
-
-		HFC_FSM(sc, 2);		/* L1 deactivate */
-	}
-
-	HFC_END;
-}
-
-/*---------------------------------------------------------------------------*
- *	Command from the upper layers (B-channel and D-channel)
- *---------------------------------------------------------------------------*/
-static int
-ihfc_mph_command_req(int unit, int command, void *parm)
-{
-	ihfc_sc_t *sc = &ihfc_softc[unit];
-
-	switch(command)
-	{
-		case CMR_DOPEN:		/* daemon running */
-			NDBGL1(L1_PRIM,
-				"unit %d, command = CMR_DOPEN", unit);
-			S_ENABLED = 1;
-			break;
-			
-		case CMR_DCLOSE:	/* daemon not running */
-			NDBGL1(L1_PRIM,
-				"unit %d, command = CMR_DCLOSE", unit);
-			S_ENABLED = 0;
-			break;
-
-		case CMR_SETTRACE:	/* set new trace mask */
-			NDBGL1(L1_PRIM,
-				"unit %d, command = CMR_SETTRACE, parm = %d",
-				unit, (unsigned int)parm);
-			S_TRACE = (unsigned int)parm;
-			break;
-
-		case CMR_GCST:		/* get chip statistic */
-			NDBGL1(L1_PRIM,
-				"unit %d, command = CMR_GCST, parm = %d",
-				unit, (unsigned int)parm);
-
-			#define CST ((struct chipstat *)parm)
-
-			CST->driver_type = L1DRVR_IHFC;
-
-			/* XXX CST->xxxx_stat = xxx; */
-
-			#undef CST
-			break;
-
-		default:
-			NDBGL1(L1_ERROR, 
-				"ERROR, unknown command = %d, unit = %d, parm = %d",
-				command, unit, (unsigned int)parm);
-			break;
-	}
-
-	return 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	Data source switch for Read channels - 1, 3 and 5 (B and D-Channel)
- *---------------------------------------------------------------------------*/
-void
-ihfc_putmbuf (ihfc_sc_t *sc, u_char chan, struct mbuf *m)
-{
-	i4b_trace_hdr_t hdr;
-
-	if (chan < 2)
-	{
-		if(S_TRACE & TRACE_D_RX)
-		{
-			hdr.count = ++S_DTRACECOUNT;
-			hdr.dir   = FROM_NT;
-			hdr.type  = TRC_CH_D;
-			hdr.unit  = S_I4BUNIT;
-
-			MICROTIME(hdr.time);
-
-			i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-		}
-
-		if (!S_ENABLED) { i4b_Dfreembuf(m); return; }
-
-		m->m_pkthdr.len = m->m_len;
-	
-		i4b_l1_ph_data_ind(S_I4BUNIT, m);
-	}
-	else
-	{
-		if(S_TRACE & TRACE_B_RX)
-		{
-			hdr.count = ++S_BTRACECOUNT;
-			hdr.dir   = FROM_NT;
-			hdr.type  = (chan < 4) ? TRC_CH_B1 : TRC_CH_B2;
-			hdr.unit  = S_I4BUNIT;
-
-			MICROTIME(hdr.time);
-
-			i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-		}
-
-		if (!S_ENABLED) { i4b_Bfreembuf(m); return; }
-
-		if (S_PROT == BPROT_NONE)
-		{
-			if(!i4b_l1_bchan_tel_silence(m->m_data, m->m_len))
-			{
-				S_BDRVLINK->bch_activity(S_BDRVLINK->unit, ACT_RX);
-			}
-
-			if (!_IF_QFULL(&S_IFQUEUE))
-			{
-				S_BYTES += m->m_len;
-				IF_ENQUEUE(&S_IFQUEUE, m);
-				S_BDRVLINK->bch_rx_data_ready(S_BDRVLINK->unit);
-			}
-
-			return;
-		}
-
-		if (S_PROT == BPROT_RHDLC)
-		{
-			S_MBUFDUMMY = m;
-			S_BYTES    += m->m_pkthdr.len = m->m_len;
-			S_BDRVLINK->bch_rx_data_ready(S_BDRVLINK->unit);
-			S_MBUFDUMMY = NULL;
-
-			return;
-		}
-
-		NDBGL1(L1_ERROR, "Unknown protocol: %d", S_PROT);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Data destinator switch for write channels - 0, 2 and 4
- *---------------------------------------------------------------------------*/
-struct mbuf *
-ihfc_getmbuf (ihfc_sc_t *sc, u_char chan)
-{
-	register struct mbuf  *m;
-	i4b_trace_hdr_t hdr;
-
-	if (chan < 2)
-	{
-		IF_DEQUEUE(&S_IFQUEUE, m);
-
-		if((S_TRACE & TRACE_D_TX) && m)
-		{
-			hdr.count = ++S_DTRACECOUNT;
-			hdr.dir   = FROM_TE;
-			hdr.type  = TRC_CH_D;
-			hdr.unit  = S_I4BUNIT;
-
-			MICROTIME(hdr.time);
-
-			i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-		}
-	}
-	else
-	{
-		IF_DEQUEUE(&S_IFQUEUE, m);
-
-		if (!m)
-		{
-			S_BDRVLINK->bch_tx_queue_empty(S_BDRVLINK->unit);
-
-			IF_DEQUEUE(&S_IFQUEUE, m);
-		}
-		if (m)
-		{
-		 	if(!i4b_l1_bchan_tel_silence(m->m_data, m->m_len))
-			{
-				S_BDRVLINK->bch_activity(S_BDRVLINK->unit, ACT_TX);
-			}
-
-			S_BYTES += m->m_len;
-
-			if(S_TRACE & TRACE_B_TX)
-			{
-				hdr.count = ++S_BTRACECOUNT;
-				hdr.dir   = FROM_TE;
-				hdr.type  = (chan < 4) ? TRC_CH_B1 : TRC_CH_B2;
-				hdr.unit  = S_I4BUNIT;
-
-				MICROTIME(hdr.time);
-
-				i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-			}
-		}
-	}
-
-	return(m);
-}
-
-/*---------------------------------------------------------------------------*
- *	Initialize rx/tx data structures (B-channel)
- *---------------------------------------------------------------------------*/
-void
-ihfc_B_setup(int unit, int chan, int bprot, int activate)
-{
-	ihfc_sc_t *sc = &ihfc_softc[unit];
-	HFC_VAR;
-
-	if (((u_int)chan > 5) || ((u_int)chan < 2)) return;
-
-	HFC_BEG;
-
-	HFC_INIT(sc, chan, bprot, activate);
-
-	HFC_END;
-}
-
-/*---------------------------------------------------------------------------*
- *	Start transmission (B-channel or D-channel tx)
- *	NOTE: if "chan" variable is corrupted, it will not cause any harm,
- *	but data may be lost and there may be software sync. errors.
- *---------------------------------------------------------------------------*/
-static void
-ihfc_B_start(int unit, int chan)
-{
-	ihfc_sc_t *sc = &ihfc_softc[unit];
-	HFC_VAR;
-
-	if ((u_int)chan > 5) return;
-
-	HFC_BEG;
-
-	if (S_FILTER && !S_MBUF && !S_INTR_ACTIVE)
-	{
-		S_INTR_ACTIVE |= 2;	/* never know what *
-                                         * they put in the *
-                                         * L2 code         */
-
-		S_FILTER(sc, chan);	/* quick tx */
-
-		S_INTR_ACTIVE &= ~2;
-	}
-
-	HFC_END;
-}
-
-/*---------------------------------------------------------------------------*
- *	Fill statistics struct (B-channel)
- *---------------------------------------------------------------------------*/
-static void
-ihfc_B_stat(int unit, int chan, bchan_statistics_t *bsp)
-{
-	ihfc_sc_t *sc = &ihfc_softc[unit];
-	HFC_VAR;
-
-	if ((u_int)chan > 5) return;
-
-	chan &= ~1;
-
-	HFC_BEG;
-
-	bsp->inbytes  = S_BYTES; S_BYTES = 0;
-
-	chan++;
-
-	bsp->outbytes = S_BYTES; S_BYTES = 0;
-
-	HFC_END;
-}
-
-/*---------------------------------------------------------------------------*
- *	Return the address of IHFC linktab to I4B (B-channel)
- *---------------------------------------------------------------------------*/
-static isdn_link_t *
-ihfc_B_ret_linktab(int unit, int channel)
-{
-	ihfc_sc_t *sc = &ihfc_softc[unit];
-
-	if (channel < 2)
-		return(&sc->sc_blinktab[channel]);
-	else
-		return 0;
-}
- 
-/*---------------------------------------------------------------------------*
- *	Set the I4B driver linktab for IHFC use (B-channel)
- *---------------------------------------------------------------------------*/
-static void
-ihfc_B_set_linktab(int unit, int channel, drvr_link_t *B_linktab)
-{
-	ihfc_sc_t *sc = &ihfc_softc[unit];
-
-	if (channel < 2)
-		sc->sc_bdrvlinktab[channel] = B_linktab;
-}
-
-/*---------------------------------------------------------------------------*
- *	Initialize linktab for I4B use (B-channel)
- *---------------------------------------------------------------------------*/
-void
-ihfc_B_linkinit(ihfc_sc_t *sc)
-{
-	u_char chan;
-
-	/* make sure the hardware driver is known to layer 4 */
-	ctrl_types[CTRL_PASSIVE].set_linktab = i4b_l1_set_linktab;
-	ctrl_types[CTRL_PASSIVE].get_linktab = i4b_l1_ret_linktab;
-
-	for (chan = 2; chan < 6; chan++)
-	{
-		S_BLINK.unit          = S_UNIT;
-		S_BLINK.channel       = chan;		/* point to tx-chan */
-		S_BLINK.bch_config    = ihfc_B_setup;
-		S_BLINK.bch_tx_start  = ihfc_B_start;
-		S_BLINK.bch_stat      = ihfc_B_stat;
-		
-		/* This is a transmit channel (even) */
-		S_BLINK.tx_queue   = &S_IFQUEUE;
-		chan++;
-		/* This is a receive channel (odd) */
-		S_BLINK.rx_queue   = &S_IFQUEUE;
-		S_BLINK.rx_mbuf    = &S_MBUFDUMMY;
-	}
-}
--- sys/i4b/layer1/ihfc/i4b_ihfc_drv.c
+++ /dev/null
@@ -1,1760 +0,0 @@
-/*-
- * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ihfc_drv.c - ihfc ISA PnP-bus interface
- *	-------------------------------------------
- *	Everything which has got anything to do with the
- *	HFC-1/S/SP chips has been put here.
- *
- *	last edit-date: [Fri Jan 12 17:06:52 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/ihfc/i4b_ihfc_drv.c,v 1.16 2005/01/06 22:18:19 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <sys/mbuf.h>
-
-#include <i4b/include/i4b_mbuf.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/i4b_hdlc.h>
-#include <i4b/layer1/ihfc/i4b_ihfc.h>
-#include <i4b/layer1/ihfc/i4b_ihfc_ext.h>
-#include <i4b/layer1/ihfc/i4b_ihfc_drv.h>
-
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-
-/*---------------------------------------------------------------------------*
- *	Local prototypes
- *---------------------------------------------------------------------------*/
-	void 	ihfc_loadconfig   (ihfc_sc_t *sc);
-
-static  void	ihfc_trans_Bread  (ihfc_sc_t *sc, u_char chan);
-static  void	ihfc_trans_Bwrite (ihfc_sc_t *sc, u_char chan);
-static 	void	ihfc_hdlc_Bread   (ihfc_sc_t *sc, u_char chan);
-static	void	ihfc_hdlc_Bwrite  (ihfc_sc_t *sc, u_char chan);
-static  void	ihfc_hdlc_Dread   (ihfc_sc_t *sc, u_char chan);
-static  void	ihfc_hdlc_Dwrite  (ihfc_sc_t *sc, u_char chan);
-
-static  void	ihfc_isac_Dread   (ihfc_sc_t *sc, u_char chan);
-static  void	ihfc_isac_Dwrite  (ihfc_sc_t *sc, u_char chan);
-
-	void	ihfc_cmdr_hdlr 	  (ihfc_sc_t *sc, u_char cmdr);
-	void	ihfc_exir_hdlr 	  (ihfc_sc_t *sc, u_char exir);
-
-	void	ihfc_sq		  (ihfc_sc_t *sc);
-
-static	void	ihfc_test_Bread	  (ihfc_sc_t *sc, u_char chan);
-static 	void	ihfc_test_Bwrite  (ihfc_sc_t *sc, u_char chan);
-
-u_short		ihfc_Bsel_fifo	  (ihfc_sc_t *sc, u_char chan, u_char flag);
-u_int32_t	ihfc_Dsel_fifo	  (ihfc_sc_t *sc, u_char chan, u_char flag);
-
-
-/*---------------------------------------------------------------------------*
- *	Commonly used ISA bus commands
- *---------------------------------------------------------------------------*/
-#define IHFC_DATA_OFFSET	0
-#define IHFC_REG_OFFSET		1
-
-#define BUS_VAR			bus_space_handle_t h = rman_get_bushandle(S_IOBASE[0]); \
-				bus_space_tag_t    t = rman_get_bustag   (S_IOBASE[0])
-
-#define SET_REG(reg)		bus_space_write_1(t,h, IHFC_REG_OFFSET, reg)
-#define GET_STAT		bus_space_read_1 (t,h, IHFC_REG_OFFSET)
-
-#define READ_DATA_1		bus_space_read_1 (t,h, IHFC_DATA_OFFSET)
-#define READ_BOTH_2		bus_space_read_2 (t,h, IHFC_DATA_OFFSET)
-
-#define	WRITE_DATA_1(data)	bus_space_write_1(t,h, IHFC_DATA_OFFSET, data)
-#define WRITE_BOTH_2(data)	bus_space_write_2(t,h, IHFC_DATA_OFFSET, data)
-
-#define DISBUSY(okcmd, tocmd)						\
-{									\
-	if (GET_STAT & 1)						\
-	{								\
-		register u_char a;					\
-		register u_int to = IHFC_DISBUSYTO;			\
-									\
-		while(((a = GET_STAT) & 1) && --to);			\
-									\
-		if (!to)						\
-		{							\
-			NDBGL1(L1_ERROR, "DISBUSY-TIMEOUT! (a=%04x, "	\
-			"unit=%d)", a, S_UNIT);				\
-			tocmd;						\
-		}							\
-		else							\
-		{							\
-			okcmd;						\
-		}							\
-	}								\
-	else								\
-	{								\
-		okcmd;							\
-	}								\
-}
-
-#define WAITBUSY_2(okcmd, tocmd)					\
-	{								\
-		register u_short a;					\
-		register u_int to = IHFC_NONBUSYTO;			\
-									\
-		while((~(a = READ_BOTH_2) & 0x100) && --to);		\
-									\
-		if (!to)						\
-		{							\
-			NDBGL1(L1_ERROR, "NONBUSY-TIMEOUT! (a=%04x, "	\
-			"unit=%d)", a, S_UNIT);				\
-			tocmd;						\
-		}							\
-		else							\
-		{							\
-			okcmd;						\
-		}							\
-	}
-
-/*---------------------------------------------------------------------------*
- *	Control function					(HFC-1/S/SP)
- *	
- *	Flag:
- *		1: reset and unlock chip (at boot only)
- *		2: prepare for shutdown  (at shutdown only)
- *		3: reset and resume
- *		4: select TE-mode        (boot default)
- *		5: select NT-mode        (only HFC-S/SP/PCI)
- *
- *	Returns != 0 on errornous chip
- *---------------------------------------------------------------------------*/
-int
-ihfc_control(ihfc_sc_t *sc, int flag)
-{
-	BUS_VAR;
-
-	if (flag == 3) goto reset0;
-	if (flag == 4)
-	{
-		S_NTMODE = 0;
-		goto mode0;
-	}
-	if (flag == 5)
-	{
-		S_NTMODE = 1;
-		goto mode0;
-	}
-	if (flag == 1)
-	{
-		WRITE_BOTH_2(0x5400 | S_IIO);	/* enable IO (HFC-1/S) */
-
-		S_LAST_CHAN = -1;
-
-		/* HFC-S/SP configuration */
-
-		S_CIRM     = S_IIRQ|0x10; /* IRQ, 8K fifo mode		*/
-		S_CLKDEL   = 0x00;	  /* 12.288mhz			*/
-		S_CTMT     = 0x03;	  /* transperant mode		*/
-		S_CONNECT  = 0x00;	  /* B channel data flow	*/
-		S_INT_M1   = 0x40;	  /* interrupt mask		*/
-		S_INT_M2   = 0x08;	  /* enable interrupt output	*/
-		S_MST_MODE = 0x01; 	  /* master mode		*/
-		S_SCTRL    = 0x50;	  /* S/Q on, non cap. line mode */
-		S_SCTRL_R  = 0x00;	  /* B channel receive disable	*/
-		S_TEST     = 0x00;	  /* no need for awake enable	*/
-
-		if (S_HFC & (HFC_1 | HFC_S))	/* configure timer (50ms) */
-		{
-			S_CTMT   |= 0x08;
-		}
-		else
-		{
-			S_CTMT   |= 0x14;
-		}
-
-		/* HFC-1 ISAC configuration (IOM-2 mode) */
-
-		S_ADF1	   = 0x00;	/* */
-		S_ADF2	   = 0x80;	/* select mode IOM-2		*/
-		S_SPCR	   = 0x00;	/* B channel send disable (0x10 for test loop) */
-		S_MASK	   = 0xfb;	/* enable CISQ			*/
-		S_MODE	   = 0xc9;	/* receiver enabled		*/
-		S_SQXR	   = 0x0f;	/* master, clock always active	*/
-		S_STCR	   = 0x70;	/* TIC bus address = 7		*/
-		S_STAR2	   = 0x04;	/* enable S/Q			*/
-
-	  mode0:
-		if (S_NTMODE)		/* configure NT- or TE-mode */
-		{
-			S_SCTRL  |=  0x04; 	/* NT mode	*/
-			S_CLKDEL &= ~0x7f;	/* clear delay 	*/
-			S_CLKDEL |=  0x6c; 	/* set delay	*/
-		}
-		else
-		{
-			S_SCTRL  &= ~0x04;	/* TE mode	*/
-			S_STDEL  &=  0x7f;	/* use mask!	*/
-			S_CLKDEL &= ~0x7f;	/* clear delay	*/
-			S_CLKDEL |= S_STDEL;	/* set delay 	*/
-		}
-		if (S_DLP)		/* configure D-priority */
-		{
-			S_SCTRL  |= 0x08;	/* (10/11) */
-		}
-		else
-		{
-			S_SCTRL  &= ~0x08;	/* (8/9) */
-		}
-
-	  reset0:
-		/* chip reset (HFC-1/S/SP) */
-
-		if (S_HFC & HFC_1)
-		{
-			SET_REG((S_CIRM | 0xc8) & 0xdf);
-
-			DELAY(10);	/* HFC-2B manual recommends a 4	*
-					 * clock cycle delay after CIRM	*
-					 * write with reset=1. A 1us	*
-					 * delay, should do for 7.68mhz,*
-					 * but just in case I make that	*
-					 * 10us.			*/
-
-			SET_REG((S_CIRM | 0xc0) & 0xdf);
-
-			DELAY(250);	/* ISAC manual says reset pulse	*
-					 * length is 125us. Accessing	*
-					 * ISAC before those 125us, we	*
-					 * may risk chip corruption and *
-					 * irq failure. The HFC-2B also *
-					 * needs some delay to recover, *
-					 * so we add some us.		*/
-		}
-		else
-		{
-			SET_REG(0x18);
-
-			WRITE_DATA_1(S_CIRM | 8);
-
-			DELAY(10);	/* HFC-2BDS0 manual recommends 	*
-					 * a 4 clock cycle delay after	*
-					 * CIRM write with reset=1.	*
-					 * A 1us delay, should do for	*
-					 * 12.288mhz, but just in case	*
-					 * I make that 10us.		*/
-
-			WRITE_DATA_1(S_CIRM);
-
-			DELAY(25);	/* HFC-2BDS0 needs some time to	*
-					 * recover after CIRM write 	*
-					 * with reset=0. Experiments 	*
-					 * show this delay should be	*
-					 * 8-9us. Just in case we make	*
-					 * that 25us.			*/
-		}
-
-		{
-			/* HFC-1/S/SP chip test				*
-			 * 						*
-			 * NOTE: after reset the HFC-1/S/SP should be	*
-			 * in a mode where it is always non-busy/non-	*
-			 * processing, and bit[0] of STATUS/DISBUSY 	*
-			 * register, should always return binary '0'	*
-			 * until we configure the chips for normal 	*
-			 * operation.					*/
-#ifdef IHFC_DEBUG
-			printf("ihfc: GET_STAT value is: 0x%x\n", GET_STAT);
-#endif
-			SET_REG(0x30);
-
-			if ((GET_STAT & 1) || (READ_DATA_1 & 0xf)) goto f0;
-		}
-
-		ihfc_loadconfig(sc);
-		
-		if (S_HFC & HFC_1) ihfc_cmdr_hdlr(sc, 0x41);	/* rres, xres */
-
-		S_PHSTATE = 0;
-		HFC_FSM(sc, 0);
-	}
-
-	if (flag == 2)
-	{
-		if (S_HFC & HFC_1) S_CIRM &= ~0x03;	/* disable interrupt */
-
-		S_SQXR	   |=  0x40;	/* power down */
-
-		S_INT_M2   &= ~0x01;
-		S_MASK	   |=  0x02;
-
-		S_SPCR	   &= ~0x0f;	/* send 1's only */
-		S_SCTRL	   &= ~0x83;	/* send 1's only + enable oscillator */
-
-		ihfc_loadconfig(sc);
-	}
-
-	return(0);	/* success */
-
-  f0:
-	return(1);	/* failure */
-}
-
-/*---------------------------------------------------------------------------*
- *	Softc initializer and hardware setup			(HFC-1/S/SP)
- *
- *	Returns: 0 on success
- *		 1 on failure
- *---------------------------------------------------------------------------*/
-int
-ihfc_init (ihfc_sc_t *sc, u_char chan, int prot, int activate)
-{
-	if (chan > 5) goto f0;
-
-	chan &= ~1;
-
-	do
-	{	if (chan < 2)			/* D-Channel */
-		{
-			i4b_Dfreembuf(S_MBUF);
-			if (!IF_QEMPTY(&S_IFQUEUE)) i4b_Dcleanifq(&S_IFQUEUE);
-
-			RESET_SOFT_CHAN(sc, chan);
-
-			S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
-
-#if defined (__FreeBSD__) && __FreeBSD__ > 4
-			if(!mtx_initialized(&S_IFQUEUE.ifq_mtx))
-				mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", NULL, MTX_DEF);
-#endif
-			if (!activate) continue;
-
-			if (S_HFC & HFC_1)
-			{
-				S_FILTER  = (chan & 1) ? ihfc_isac_Dread :
-							 ihfc_isac_Dwrite;
-			}
-			else
-			{
-				S_FILTER  = (chan & 1) ? ihfc_hdlc_Dread :
-							 ihfc_hdlc_Dwrite;
-			}
-		}
-		else				/* B-Channel */
-		{
-			i4b_Bfreembuf(S_MBUF);
-			if (!IF_QEMPTY(&S_IFQUEUE))  i4b_Bcleanifq(&S_IFQUEUE);
-
-			RESET_SOFT_CHAN(sc, chan);
-
-			S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
-
-#if defined (__FreeBSD__) && __FreeBSD__ > 4
-			if(!mtx_initialized(&S_IFQUEUE.ifq_mtx))
-				mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", NULL, MTX_DEF);
-#endif
-			S_PROT = prot;
-
-			if (!activate) continue;
-
-			switch(prot)
-			{	case(BPROT_NONE):
-					S_FILTER = (chan & 1) ? 
-						ihfc_trans_Bread : 
-						ihfc_trans_Bwrite;
-					break;
-				case(BPROT_RHDLC):
-					S_FILTER = (chan & 1) ? 
-						ihfc_hdlc_Bread : 
-						ihfc_hdlc_Bwrite;
-					break;
-				case(5):
-					S_FILTER = (chan & 1) ? 
-						ihfc_test_Bread : 
-						ihfc_test_Bwrite;
-					break;
-			}
-		}
-	} while (++chan & 1);
-
-	S_MASK	  |=  0xfb;	/* disable all, but CISQ interrupt (ISAC)	*/
-	S_INT_M1  &=  0x40;	/* disable all, but TE/NT state machine (HFC)	*/
-	S_SCTRL   &= ~0x03;	/* B1/B2 send disable (HFC)			*/
-	S_SPCR	  &= ~0x0f;	/* B1/B2 send disable (ISAC)			*/
-	S_SCTRL_R &= ~0x03;	/* B1/B2 receive disable (HFC)			*/
-
-	chan = 0;
-	if (S_FILTER)			/* D-Channel active		*/
-	{
-		S_MASK   &= 0x2e;	/* enable RME, RPF, XPR, EXI	*/
-		S_INT_M1 |= 0x24;	/* enable D-receive, D-transmit */
-	}
-
-	chan = 2;
-	if (S_FILTER)			/* B1-Channel active		*/
-	{
-		S_SCTRL   |= 1;		/* send enable (HFC)		*/
-		S_SPCR	  |= 8;		/* send enable (ISAC)		*/
-		S_SCTRL_R |= 1;		/* receive enable (HFC)		*/
-		S_INT_M1  |=  0x80;	/* timer enable (HFC)		*/
-		S_INT_M1  &= ~0x04;	/* let D-channel use timer too	*/
-	}
-
-	chan = 4;
-	if (S_FILTER)			/* B2-Channel active		*/
-	{
-		S_SCTRL   |= 2;		/* send enable (HFC)		*/
-		S_SPCR	  |= 2;		/* send enable (ISAC)		*/
-		S_SCTRL_R |= 2;		/* receive enable (HFC)		*/
-		S_INT_M1  |=  0x80;	/* timer enable (HFC)		*/
-		S_INT_M1  &= ~0x04;	/* let D-channel use timer too	*/
-	}
-
-	ihfc_loadconfig(sc);
-
-	/* XXX  reset timer? */
-
-	return 0;	/* success */
-  f0:
-	return 1;	/* failure */
-}
-
-/*---------------------------------------------------------------------------*
- *	Load configuration data					(HFC-1/S/SP)
- *---------------------------------------------------------------------------*/
-void 
-ihfc_loadconfig(ihfc_sc_t *sc)
-{
-	BUS_VAR;
-
-	if (S_HFC & HFC_1)
-	{
-		/* HFC-1 chips w/ISAC: */
-
-		const u_char *src = (void *)&S_ISAC_CONFIG;
-		const u_char *dst = (void *)&isac_configtable;
-
-		SET_REG((S_CIRM | 0xc0) & 0xdf);
-
-		S_CTMT = (S_CTMT & ~0x14) | ((S_INT_M1 >> 5) & 0x4);
-
-		SET_REG((S_CTMT | 0xe0) & 0xff);
-
-		while(*dst)
-		{
-			SET_REG(*dst++);	/* set register	*/
-
-			/* write configuration */	
-			DISBUSY(WRITE_DATA_1(*src++), break);
-		}
-	}
-	else
-	{
-		/* HFC-S/SP chips: */
-
-		const u_char *src = (void *)&S_HFC_CONFIG;
-		const u_char *dst = (void *)&ihfc_configtable;
-
-		while(*dst)
-		{
-			SET_REG(*dst++);	/* set register		*/
-			WRITE_DATA_1(*src++);	/* write configuration	*/
-		}
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Function State Machine handler (PH layer)		(HFC-1/S/SP)
- *
- *	Flag: 0 = Refresh softc S_PHSTATE + take hints
- *	      1 = Activate
- *	      2 = Deactivate
- *
- *	NOTE: HFC-1 only supports TE mode.
- *---------------------------------------------------------------------------*/
-void
-ihfc_fsm(ihfc_sc_t *sc, int flag)
-{
-	const struct ihfc_FSMtable *fsmtab;
-	u_char ihfc_cmd = 0;
-	u_char isac_cmd = 0;
-	u_char tmp;
-	BUS_VAR;
-
-	/* get current state (rx/downstream) */
-
-	if (S_HFC & HFC_1)
-	{
-		SET_REG(0x31); DISBUSY(tmp = (READ_DATA_1 >> 2) & 0xf, return);
-
-		fsmtab = (S_NTMODE) ? &ihfc_TEtable2[tmp]:
-				      &ihfc_TEtable2[tmp];
-	}
-	else
-	{
-		SET_REG(0x30); tmp = READ_DATA_1 & 0xf;
-
-		fsmtab = (S_NTMODE) ? &ihfc_NTtable[tmp]:
-				      &ihfc_TEtable[tmp];
-	}
-
-	if (fsmtab->string)
-	{
-		NDBGL1(L1_I_CICO, "%s (ind=0x%x, flag=%d, unit=%d).",
-			fsmtab->string, tmp, flag, S_UNIT);
-	}
-	else
-	{
-		NDBGL1(L1_I_ERR, "Illegal indicatation (ind=0x%x, "
-			"flag=%d, unit=%d).", tmp, flag, S_UNIT);
-	}
-
-	/* indication machine / state change					*
-	 *									*
-	 * Whenever the state of the S0-line changes, we check to see in which	*
-	 * direction the change went. Generally upwards means activate, and	*
-	 * downwards means deactivate.						*
-	 * The test signal is used to ensure proper syncronization.		*/
-
-	if (fsmtab->state == 0)	/* deactivated indication */
-	{
-		if (S_PHSTATE != 0)
-		{
-			isac_cmd = 0x3c; /* deactivate DUI */
-
-			i4b_l1_ph_deactivate_ind(S_I4BUNIT);
-		}
-	}
-	if (fsmtab->state == 2)	/* syncronized indication */
-	{
-		if (S_PHSTATE != 2)
-		{
-			if (S_NTMODE) ihfc_cmd = 0x80;
-		}
-	}
-	if (fsmtab->state == 3)	/* activated indication */
-	{
-		if (S_PHSTATE != 3)
-		{
-			isac_cmd = (S_DLP) ? 0x24  /* activate AR10 */
-					   : 0x20; /* activate AR8  */
-
-			i4b_l1_ph_activate_ind(S_I4BUNIT);
-		}
-	}
-	if (fsmtab->state == 4)	/* error indication */
-	{
-		if (S_PHSTATE < 4)
-		{
-			isac_cmd = 0x3c; /* deactivate DUI */
-		}
-	}
-
-	S_PHSTATE = fsmtab->state;
-
-	if ((flag == 1) && (fsmtab->state != 3))
-	{
-		isac_cmd = (S_DLP) ? 0x24 : 0x20;
-		ihfc_cmd = 0x60;
-	}
-	if ((flag == 2) && (fsmtab->state != 0))
-	{
-		isac_cmd = 0x3c;
-		ihfc_cmd = 0x40;
-	}
-
-	/* set new state (tx / upstream)				      *
-	 *								      *
-	 * NOTE: HFC-S/SP and ISAC transmitters are always active when 	      *
-	 * activated state is reached. The bytes sent to the S0-bus are all   *
-	 * high impedance, so they do not disturb.			      *
-	 * The HFC-1 has a separate SIEMENS S0-device.			      */
-
-	if (S_HFC & HFC_1)
-	{
-		if (isac_cmd)
-		{
-			if (S_IOM2) isac_cmd |= 3;
-
-			SET_REG(0x31); DISBUSY(WRITE_DATA_1(isac_cmd), );
-
-			NDBGL1(L1_I_CICO, "(isac_cmd=0x%x, unit=%d).",
-				isac_cmd, S_UNIT);
-		}
-	}
-	else
-	{
-		if (ihfc_cmd || (fsmtab->state == 5))
-		{
-			SET_REG(0x30); WRITE_DATA_1(ihfc_cmd);
-
-			NDBGL1(L1_I_CICO, "(ihfc_cmd=0x%x, unit=%d).",
-				ihfc_cmd, S_UNIT);
-		}
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	S/Q - channel handler (read)				(HFC-S/SP)
- *---------------------------------------------------------------------------*/
-void
-ihfc_sq (ihfc_sc_t *sc)
-{
-	const struct ihfc_SQtable *SQtab;
-	register u_char a = 0;
-	BUS_VAR;
-
-	if (S_HFC & HFC_1)
-	{
-		SET_REG(0x31);
-		DISBUSY(a = READ_DATA_1, a = 0);
-
-		if (a & 0x80)
-		{
-			SET_REG(0x3b);
-			DISBUSY(a = READ_DATA_1, a = 0);
-		}
-	}
-	else
-	{
-		SET_REG(0x34);
-		a = READ_DATA_1;
-	}
-
-	SQtab = (S_NTMODE) ? &ihfc_Qtable[a & 7]:
-			     &ihfc_Stable[a & 7];
-
-	if (a & 0x10)
-	{
-		if (SQtab->string)
-		{
-			NDBGL1(L1_I_CICO, "%s (unit=%d, int=%x)",
-				SQtab->string, S_UNIT, S_INT_S1);
-		}
-		else
-		{
-			NDBGL1(L1_ERROR, "Unknown indication = %x (unit=%d)",
-				 a & 7, S_UNIT);
-		}
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Interrupt handler					(HFC-1)
- *---------------------------------------------------------------------------*/
-void
-ihfc_intr1 (ihfc_sc_t *sc)
-{
-	u_char chan;
-	u_char tmp;
-	BUS_VAR;
-	HFC_VAR;
-
-	HFC_BEG;
-
-	SET_REG(0x20); tmp = GET_STAT; DISBUSY(S_ISTA |= READ_DATA_1, );
-
-	if (S_ISTA & 0x04)	/* CIRQ */
-	{
-		HFC_FSM(sc, 0);
-
-		ihfc_sq(sc);
-	}
-
-	S_INTR_ACTIVE = 1;
-
-	if (S_ISTA & 0xc0)	/* RPF or RME */
-	{
-		chan = 1;
-		if (S_FILTER) S_FILTER(sc, chan);
-	}
-	if (S_ISTA & 0x10)	/* XPR */
-	{
-		chan = 0;
-		if (S_FILTER) S_FILTER(sc, chan);
-	}
-	if (tmp & 0x04)		/* Timer elapsed (50ms) */
-	{
-		SET_REG((S_CTMT | 0xf0) & 0xff);
-
-		chan = 6;
-		while(chan--)
-		{
-			if (chan == 1) break;
-			if (S_FILTER) S_FILTER(sc, chan);
-
-			HFC_END;
-			DELAY(10);
-			HFC_BEG;
-		}
-	}
-
-	S_INTR_ACTIVE = 0;
-		
-	if (S_ISTA & 0x01)	/* EXIR */
-	{
-		SET_REG(0x24); DISBUSY(ihfc_exir_hdlr(sc, READ_DATA_1), );
-	}
-
-	S_ISTA &= ~(0x1 | 0x4);
-
-	HFC_END;
-}
-
-/*---------------------------------------------------------------------------*
- *	Interrupt handler					(HFC-S/SP)
- *---------------------------------------------------------------------------*/
-void
-ihfc_intr2 (ihfc_sc_t *sc)
-{
-	u_char chan;
-	BUS_VAR;
-	HFC_VAR;
-
-	HFC_BEG;
-
-	SET_REG(0x1e); S_INT_S1 = READ_DATA_1;	/* this will enable new interrupts! */
-
-	if (S_INT_S1 & 0x40)
-	{
-		HFC_FSM(sc, 0); 	/* statemachine changed */
-
-		ihfc_sq(sc);
-	}
-
-	S_INTR_ACTIVE = 1;
-
-	if (S_INT_S1 & 0x20)		/* D-Channel frame (rx) */
-	{
-		chan = 1;
-		if (S_FILTER) S_FILTER(sc, chan);
-	}
-	if (S_INT_S1 & 0x04)		/* D-Channel frame (tx) */
-	{
-		chan = 0;
-		if (S_FILTER && (~S_INT_S1 & 0x80)) S_FILTER(sc, chan);
-	}
-	if (S_INT_S1 & 0x80)		/* Timer elapsed (50ms) */
-	{
-		chan = 6;
-		while(chan--)
-		{
-			if (chan == 1) continue;
-			if (S_FILTER) S_FILTER(sc, chan);
-
-			HFC_END;
-			DELAY(10);
-			HFC_BEG;
-		}
-	}
-
-	S_INTR_ACTIVE = 0;
-
-	HFC_END;
-}
-
-/*---------------------------------------------------------------------------*
- *	Select a Bfifo						(HFC-1/S/SP)
- *	and return bytes in FIFO
- *
- *	(this code is optimized)
- *---------------------------------------------------------------------------*/
-u_short
-ihfc_Bsel_fifo(ihfc_sc_t *sc, u_char chan, u_char flag)
-{
-	register u_char	 reg = 0x7e + chan;
-	register u_short tmp = 0x100;
-	register u_short z1;
-	register u_short z2;
-
-	BUS_VAR;
-
-	if (S_HFC & (HFC_1 | HFC_S))
-	{
-		if (S_LAST_CHAN != chan)
-		{
-			SET_REG(reg);
-			DISBUSY(WAITBUSY_2( , return 0), return 0);
-
-			S_LAST_CHAN = chan;
-		}
-	}
-	else
-	{
-		SET_REG(0x10);
-		WRITE_DATA_1(chan - 2);
-		DISBUSY( , return 0);
-	}
-
-#define FAST_READ (u_char)(tmp = READ_BOTH_2)
-#define	FAST_STAT if (tmp & 0x100) DISBUSY( , return 0);
-
-		SET_REG(reg     ); FAST_STAT;	z1  = FAST_READ;
-		SET_REG(reg += 4); FAST_STAT; 	z1 |= FAST_READ << 8;
-		SET_REG(reg += 4); FAST_STAT;	z2  = FAST_READ;
-		SET_REG(reg += 4); FAST_STAT;	z2 |= READ_DATA_1 << 8;
-
-#undef FAST_READ
-#undef FAST_STAT
-
-	z1 &= 0x1fff;
-	z2 &= 0x1fff;
-	
-	z1 = 0x5ff - (z2 = z1 - z2 + ((z2 <= z1) ? 0 : 0x600));
-
-	if (chan & 1)
-		return(z2);	/* receive channel */
-	else
-		return(z1);	/* transmit channel */
-}
-
-/*---------------------------------------------------------------------------*
- *	Select a Dfifo						(HFC-S/SP)
- *	and return bytes, and frames in FIFO
- *
- *	Flag values:
- *		0x00: select new fifo + update counters
- *		0x10: increment f1 + update counters
- *		0x20: increment f2 + update counters
- *
- *	NOTE: The upper 16bits holds the number of frames in the FIFO.
- *	NOTE: FIFO has to be selected before you can use flags 0x10/0x20.
- *---------------------------------------------------------------------------*/
-u_int32_t
-ihfc_Dsel_fifo(ihfc_sc_t *sc, u_char chan, u_char flag)
-{
-	register u_char	 reg = 0x90 + chan;
-	register u_short tmp = 0x100;
-	register u_char  f1;
-	register u_char  f2;
-	register u_short z1;
-	register u_short z2;
-
-	BUS_VAR;
-
-	if (S_HFC & (HFC_1 | HFC_S))
-	{
-		switch(flag)
-		{
-			case(0x10):
-			case(0x20):
-				SET_REG(reg);
-				if (~GET_STAT & 1)
-					WAITBUSY_2( , return 0);
-
-				SET_REG(0xa2 - (flag & 0x10) + chan);
-				DISBUSY(READ_DATA_1, return 0);
-
-				SET_REG(reg);
-				if (~GET_STAT & 1)
-					WAITBUSY_2( , return 0);
-				break;
-
-			default:
-				if (S_LAST_CHAN != chan)
-				{
-					SET_REG(reg);
-					DISBUSY(WAITBUSY_2( , return 0), return 0);
-
-					S_LAST_CHAN = chan;
-				}
-				break;
-		}
-	}
-	else
-	{
-		switch(flag)
-		{
-			case(0x10):
-			case(0x20):
-				SET_REG(0xb8 - (flag & 0x10) + chan);
-				READ_DATA_1;
-
-				DISBUSY( , return 0);
-
-				if (chan & 1)
-				{
-					/* Before reading a FIFO a change *
-					 * FIFO operation must be done.	  *
-					 * (see HFC-SP manual p.38)	  */
-
-					SET_REG(0x10);
-					WRITE_DATA_1(chan | 4);
-
-					DISBUSY( , return 0);
-				}
-				break;
-
-			default:
-				SET_REG(0x10);
-				WRITE_DATA_1(chan | 4);
-
-				DISBUSY( , return 0);
-				break;
-		}
-	}
-
-#define FAST_READ (u_char)(tmp = READ_BOTH_2)
-#define	FAST_STAT if (tmp & 0x100) DISBUSY( , return 0);
-
-		if (S_HFC & HFC_SP) reg = 0x80 + chan;
-
-		SET_REG(reg     ); FAST_STAT;	z1  = FAST_READ;
-		SET_REG(reg += 4); FAST_STAT; 	z1 |= FAST_READ << 8;
-		SET_REG(reg += 4); FAST_STAT;	z2  = FAST_READ;
-		SET_REG(reg += 4); FAST_STAT;	z2 |= FAST_READ << 8;
-
-		if (S_HFC & HFC_SP) reg += 0x26;
-
-		SET_REG(reg -= 2); FAST_STAT; f1  = FAST_READ;
-		SET_REG(reg += 4); FAST_STAT; f2  = READ_DATA_1;
-
-#undef FAST_READ
-#undef FAST_STAT
-
-	if (~chan & 1)
-	{					/* XXX was Z1                */
-		S_HDLC_DZ_TAB[f1 & 0xf] = z2;	/* We keep track of the 'Z'  *
-						 * values for D-channel (tx),*
-						 * so we may calculate the # *
-						 * of FIFO bytes free when   *
-						 * f1 != f2.		     */
-		z2 = S_HDLC_DZ_TAB[f2 & 0xf];
-	}
-
-	z1 = 0x1ff - (z2 = (z1 - z2) & 0x1ff);
-	f1 = 0xf   - (f2 = (f1 - f2) & 0xf);
-
-	if (chan & 1)
-		return(z2 | (f2 << 16));	/* receive channel */
-	else
-		return(z1 | (f1 << 16));	/* transmit channel */
-}
-
-
-/*---------------------------------------------------------------------------*
- *	Data handler for D channel(write) - chan 0		(HFC-S/SP)
- *---------------------------------------------------------------------------*/
-static void
-ihfc_hdlc_Dwrite (ihfc_sc_t *sc, u_char chan)
-{
-	register u_int32_t  sendlen;
-	register u_short    len;
-	register u_char	  * src;
-
-	BUS_VAR;
-
-	if (!S_MBUF && IF_QEMPTY(&S_IFQUEUE)) return;
-
-	sendlen = ihfc_Dsel_fifo(sc, chan, 0);	/* select new fifo	    *
-						 * NOTE: the 16 higher bits *
-						 * contain the # of frame-  *
-						 * etries free in the FIFO  */
-	while (sendlen & ~0xffff)
-	{
-		if (!S_MBUF)
-		{
-			if (!(S_MBUF = ihfc_getmbuf(sc, chan))) goto j1;
-		}
-
-		src = S_MBUFDATA;
-		len = S_MBUFLEN;
-
-		if (len >= 0x1ff) goto j0;	/* frame is too big: skip! */
-
-		sendlen &= 0xffff;		/* only keep # of *
-						 * bytes free	  */
-
-		SET_REG((S_HFC & HFC_SP) ? 0xac : 0x96);
-
-		while (sendlen--)
-		{
-			if (!len--) break;
-
-			DISBUSY(WRITE_DATA_1(*src++), sendlen = -1; len++; break);
-		}
-
-		if (!++sendlen)			/* out of fifo: suspend */
-		{
-			S_MBUFDATA = src;
-			S_MBUFLEN  = len;
-			break;
-		}
-
-		sendlen = ihfc_Dsel_fifo(sc, chan, 0x10);	/* inc F1 */
-	   j0:
-		i4b_Dfreembuf(S_MBUF);
-		S_MBUF = NULL;
-	}
-  j1:
-	return;
-}
-
-/*---------------------------------------------------------------------------*
- *	Data handler for D channel(read) - chan 1		(HFC-S/SP)
- *
- *	NOTE: Max framelength is (511 - 3) = 508 bytes, when only one frame
- *	      is received at a time.
- *---------------------------------------------------------------------------*/
-static void
-ihfc_hdlc_Dread (ihfc_sc_t *sc, u_char chan)
-{
-	register u_char	    tmp = -1;
-	register u_char	    to = 15;
-	register u_int32_t  reclen;
-	register u_short    crc;
-	register u_short    len;
-	register u_char	  * dst;
-
-	BUS_VAR;
-
-	reclen = ihfc_Dsel_fifo(sc, chan, 0);	/* select new fifo	    *
-						 * NOTE: the higher 16 bits *
-						 * contain the # of frames  *
-						 * to receive.		    */
-	while ((reclen & ~0xffff) && to--)
-	{
-		reclen &= 0xffff;		/* only keep # of	*
-						 * bytes to receive	*/
-
-		if (!(S_MBUF = i4b_Dgetmbuf(DCH_MAX_LEN)))
-			panic("ihfc_hdlc_Dread: No mbufs(unit=%d)!\n", S_UNIT);
-
-		SET_REG((S_HFC & HFC_SP) ? 0xbd : 0xa7);
-
-		if ((reclen > 2) && (reclen <= (DCH_MAX_LEN+2)))
-		{
-			dst = S_MBUFDATA;
-			len = S_MBUFLEN = (reclen += 1) - 3;
-		}
-		else
-		{
-			len = 0;
-			dst = NULL;
-		}
-
-		crc = -1;	/* NOTE: after a "F1" or "Z1" hardware overflow	*
-				 * it appears not to be necessary to reset the 	*
-				 * HFC-1/S or SP chips to continue proper	*
-				 * operation, only and only, if we always read	*
-				 * "Z1-Z2+1" bytes when F1!=F2 followed by a 	*
-				 * F2-counter increment. The bi-effect of doing	*
-				 * this is the "STAT" field may say frame is ok	*
-				 * when the frame is actually bad.		*
-				 * The simple solution is to re-CRC the frame	*
-				 * including "STAT" field to see if we get	*
-				 * CRC == 0x3933. Then we're 99% sure all	*
-				 * frames received are good.			*/
-
-		while(reclen--)
-		{
-			DISBUSY(tmp = READ_DATA_1, break);
-			if (len) { len--; *dst++ = tmp; }
-
-			crc = (HDLC_FCS_TAB[(u_char)(tmp ^ crc)] ^ (u_char)(crc >> 8));
-		}
-
-		crc ^= 0x3933;
-
-		if (!tmp && !crc)
-		{
-			ihfc_putmbuf(sc, chan, S_MBUF);
-			S_MBUF = NULL;
-		}
-		else
-		{
-			NDBGL1(L1_ERROR, "Frame error (len=%d, stat=0x%x, "
-				"crc=0x%x, unit=%d)", S_MBUFLEN, (u_char)tmp, crc,
-				S_UNIT);
-
-			i4b_Dfreembuf(S_MBUF);
-			S_MBUF = NULL;
-		}
-
-		reclen = ihfc_Dsel_fifo(sc, chan, 0x20);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	EXIR error handler - ISAC 	(D - channel)		(HFC-1)
- *---------------------------------------------------------------------------*/
-void
-ihfc_exir_hdlr (ihfc_sc_t *sc, u_char exir)
-{
-	register u_char a;
-	register u_char cmd;
-
-	for (a = 0, cmd = 0; exir; a++, exir >>= 1)
-	{
-		if (exir & 1)
-		{
-			NDBGL1(L1_I_ERR, "%s. (unit=%d)",
-				ihfc_EXIRtable[a].string, S_UNIT);
-			cmd |= ihfc_EXIRtable[a].cmd;
-		}
-	}
-
-	if (cmd) ihfc_cmdr_hdlr(sc, cmd);
-}
-
-/*---------------------------------------------------------------------------*
- *	CMDR handler - ISAC 	(D - channel)			(HFC-1)
- *---------------------------------------------------------------------------*/
-void
-ihfc_cmdr_hdlr (ihfc_sc_t *sc, u_char cmdr)
-{
-	BUS_VAR;
-
-	SET_REG(0x21); DISBUSY(WRITE_DATA_1(cmdr); DELAY(30), );
-}
-
-/*---------------------------------------------------------------------------*
- *	Data handler for D channel(write) - chan 0 		(HFC-1)
- *---------------------------------------------------------------------------*/
-static void
-ihfc_isac_Dwrite (ihfc_sc_t *sc, u_char chan)
-{
-	register u_char   sendlen = 32;
-	register u_char   cmd = 0;
-	register u_short  len;
-	register u_char * src;
-
-	BUS_VAR;
-
-	if (~S_ISTA & 0x10) goto j0;
-
-	if (!S_MBUF)
-		if (!(S_MBUF = ihfc_getmbuf(sc, chan))) goto j0;
-
-	len = S_MBUFLEN;
-	src = S_MBUFDATA;
-
-	SET_REG(0x00);
-
-	while(sendlen--)	/* write data */
-	{
-		if (!len--) break;
-		DISBUSY(WRITE_DATA_1(*src++), goto a0);
-	}
-
-	cmd |= 0x08;
-	
-	if (!++sendlen)		/* suspend */
-	{
-		S_MBUFLEN  = len;
-		S_MBUFDATA = src;
-	}
-	else
-	{
-	   a0:
-		i4b_Dfreembuf(S_MBUF);
-		S_MBUF = NULL;
-
-		cmd |= 0x02;
-	}
-
-	if (cmd) ihfc_cmdr_hdlr(sc, cmd);
-
-	S_ISTA &= ~0x10;
-  j0:
-	return;
-}
-
-/*---------------------------------------------------------------------------*
- *	Data handler for D channel(read) - chan 1 		(HFC-1)
- *---------------------------------------------------------------------------*/
-static void
-ihfc_isac_Dread (ihfc_sc_t *sc, u_char chan)
-{
-	register u_char   cmd = 0;
-	register u_char   reclen;
-	register u_short  tmp;
-	register u_short  len;
-	register u_char * dst;
-
-	BUS_VAR;
-
-	if (!(S_ISTA & 0xc0)) goto j1;	/* only receive data *
-					 * on interrupt	     */
-
-	if (!S_MBUF)
-	{
-		if (!(S_MBUF = i4b_Dgetmbuf(DCH_MAX_LEN)))
-			panic("ihfc%d: (D) Out of mbufs!\n", S_UNIT);
-	}
-
-	len = S_MBUFLEN;
-	dst = S_MBUFDATA + (DCH_MAX_LEN - len);
-
-	if (S_ISTA & 0x80)	/* RME */
-	{
-		SET_REG(0x27); DISBUSY(tmp = (READ_DATA_1 ^ 0x20), goto j0);
-
-		if (tmp & 0x70) goto j0;	/* error */
-
-		SET_REG(0x25); DISBUSY(tmp = (READ_DATA_1 & 0x1f), goto j0);
-
-		reclen = (tmp) ? tmp : 32;
-	}
-	else			/* RPF */
-	{
-		reclen = 32;
-	}
-
-	if ((len -= reclen) <= DCH_MAX_LEN)	/* get data */
-	{
-		SET_REG(0x00);
-
-		while(reclen--)
-		{
-			DISBUSY(*dst++ = READ_DATA_1, goto j0);
-		}
-	}
-	else		/* soft rdo or error */
-	{
-	  j0:	i4b_Dfreembuf(S_MBUF);
-		S_MBUF = NULL;
-		
-		cmd |= 0x40;
-
-		NDBGL1(L1_I_ERR, "Frame error (unit=%d)", S_UNIT);
-	}
-
-	if (S_ISTA & 0x80) 	/* frame complete */
-	{
-		if (S_MBUF)
-		{
-			S_MBUFLEN = (DCH_MAX_LEN - len);
-			ihfc_putmbuf(sc, chan, S_MBUF);
-			S_MBUF = NULL;
-		}
-	}
-
-	if (S_MBUF)	/* suspend */
-	{
-		S_MBUFLEN = len;
-	}
-
-	ihfc_cmdr_hdlr(sc, cmd | 0x80);
-
-	S_ISTA &= ~0xc0;
-  j1:
-	return;
-}
-
-/*---------------------------------------------------------------------------*
- *	Data handler for B channel(write) - chan 2 and 4	(HFC-1/S/SP)
- *
- *	NOTE: No XDU checking!
- *---------------------------------------------------------------------------*/
-static void
-ihfc_trans_Bwrite (ihfc_sc_t *sc, u_char chan)
-{
-	register u_short  sendlen;
-	register u_short  len;
-	register u_char * src;
-
-	BUS_VAR;
-
-	if (!S_MBUF && IF_QEMPTY(&S_IFQUEUE)) return;
-
-	sendlen = (u_short)ihfc_Bsel_fifo(sc, chan, 0);
-
-	SET_REG(0xaa + chan);
-
-	while (1)
-	{
-		if (!S_MBUF)
-		{
-			S_MBUF = ihfc_getmbuf(sc, chan);
-			if (!S_MBUF) break;
-		}
-
-		src = S_MBUFDATA;
-		len = S_MBUFLEN;
-
-		while (sendlen--)
-		{
-			if (!len--) break;
-
-			DISBUSY(WRITE_DATA_1(*src++), sendlen = -1; len++; break);
-		}
-
-		if (!++sendlen)		/* out of fifo: Suspend */
-		{
-			S_MBUFDATA = src;
-			S_MBUFLEN  = len;
-			break;
-		}
-
-		i4b_Dfreembuf(S_MBUF);
-		S_MBUF = NULL;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Data handler for B channel(read) - chan 3 and 5		(HFC-1/S/SP)
- *	(this code is optimized)
- *---------------------------------------------------------------------------*/
-static void
-ihfc_trans_Bread (ihfc_sc_t *sc, u_char chan)
-{
-	register u_short  reclen;
-	register u_short  tmp;
-	register u_short  len;
-	register u_char	* dst;
-
-	BUS_VAR;
-
-	reclen = (u_short)ihfc_Bsel_fifo(sc, chan, 0);
-
-	while (1)
-	{
-		SET_REG(0xba + chan);
-
-		tmp = 0x100;
-
-		if (!S_MBUF)
-			if (!(S_MBUF = i4b_Bgetmbuf(BCH_MAX_DATALEN)))
-				panic("ihfc%d: (B) Out of mbufs!\n", S_UNIT);
-
-		len   = S_MBUFLEN;
-		dst   = S_MBUFDATA + (BCH_MAX_DATALEN - len);
-
-		while (reclen--)
-		{
-			if (!len--) break;
-
-			if (tmp & 0x100) DISBUSY( , reclen = -1; len++; break);
-			*dst++ = (u_char)(tmp = READ_BOTH_2);
-		}
-
-		if (~tmp & 0x100)
-		{
-			SET_REG(0x30);
-			READ_DATA_1;	/* a read to the data port	*
-					 * will disable the internal	*
-					 * disbusy signal for HFC-1/S	*
-					 * chips. This is neccessary	*
-					 * to avvoid data loss.		*/
-		}
-
-		if (!++reclen)		/* out of fifo: suspend */
-		{
-			S_MBUFLEN = len;
-			break;
-		}
-
-		S_MBUFLEN = (BCH_MAX_DATALEN - ++len);
-
-		ihfc_putmbuf(sc, chan, S_MBUF);
-
-		S_MBUF = NULL;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Data handler for B channel(write) - chan 2 and 4	(HFC-1/S/SP)
- *	
- *	NOTE: Software HDLC encoding!
- *---------------------------------------------------------------------------*/
-static void
-ihfc_hdlc_Bwrite (ihfc_sc_t *sc, u_char chan)
-{
-	register u_short  blevel  = S_HDLC_BLEVEL;
-	register u_char   flag    = S_HDLC_FLAG;
-	register u_int    tmp     = S_HDLC_TMP;
-	register u_short  crc     = S_HDLC_CRC;
-	register u_short  ib      = S_HDLC_IB;
-	register u_char * src     = NULL;
-	register u_short  len     = 0;
-	register u_short  sendlen;
-	register u_short  tmp2;
-
-	BUS_VAR;
-
-	if (!S_MBUF && IF_QEMPTY(&S_IFQUEUE) && (flag == 2)) return;
-
-	sendlen = (u_short)ihfc_Bsel_fifo(sc, chan, 0);
-
-	SET_REG(0xaa + chan);
-
-	if (S_MBUF)
-	{
-		/* resume */
-
-		src = S_MBUFDATA; 
-		len = S_MBUFLEN;
-
-		if (sendlen == 0x5ff)
-		{ 
-			/* XDU */
-
-			flag = -2;
-			len  = 0;
-
-			NDBGL1(L1_S_ERR, "XDU (unit=%d)", S_UNIT);
-		}
-	}
-
-	while (sendlen--)
-	{
-		HDLC_ENCODE(*src++, len, tmp, tmp2, blevel, ib, crc, flag,
-		{/* gfr */
-			i4b_Bfreembuf(S_MBUF);
-			S_MBUF = ihfc_getmbuf(sc, chan);
-
-			if (S_MBUF)
-			{
-				src = S_MBUFDATA;
-				len = S_MBUFLEN;
-			}
-			else
-			{
-				sendlen = 0;	/* Exit after final FS, *
-						 * else the buffer will *
-						 * only be filled with  *
-						 * "0x7e"-bytes!        */
-			}
-		},
-		{/* wrd */
-			
-			DISBUSY(WRITE_DATA_1((u_char)tmp), sendlen = 0);
-		},
-		d );
-	}
-
-	if (S_MBUF)		/* suspend */
-	{
-		S_MBUFDATA = src;
-		S_MBUFLEN  = len;
-	}
-
-	S_HDLC_IB	= ib;
-	S_HDLC_BLEVEL	= blevel;
-	S_HDLC_TMP  	= tmp;
-	S_HDLC_FLAG 	= flag;
-	S_HDLC_CRC  	= crc;
-}
-
-/*---------------------------------------------------------------------------*
- *	Data handler for B channel(read) - chan 3 and 5		(HFC-1/S/SP)
- *	
- *	NOTE: Software HDLC decoding!
- *---------------------------------------------------------------------------*/
-static void
-ihfc_hdlc_Bread (ihfc_sc_t *sc, u_char chan)
-{
-	register u_char   blevel = S_HDLC_BLEVEL;
-		 u_char   flag   = S_HDLC_FLAG;
-	register u_short  crc    = S_HDLC_CRC;
-	register u_int    tmp    = S_HDLC_TMP;
-	register u_short  ib     = S_HDLC_IB;
-	register u_char * dst    = NULL;
-	register u_short  tmp2   = 0x100;
-	register u_short  len    = 0;
-	register u_short  reclen;
-
-	BUS_VAR;
-
-	if (S_MBUF)
-	{
-		/* resume */
-
-		len = S_MBUFLEN;
-		dst = S_MBUFDATA + (BCH_MAX_DATALEN - len);
-	}
-
-	reclen = (u_short)ihfc_Bsel_fifo(sc, chan, 0);
-
-	SET_REG(0xba + chan);
-
-	while (reclen--)
-	{
-		HDLC_DECODE(*dst++, len, tmp, tmp2, blevel, ib, crc, flag,
-		{/* rdd */
-			/* if (tmp2 & 0x100) while (GET_STAT & 1);
-			 * tmp2 = READ_BOTH_2;
-			 */
-
-			DISBUSY(tmp2 = READ_DATA_1, reclen = 0; tmp2 = 0);
-		},
-		{/* nfr */
-			if (!(S_MBUF = i4b_Bgetmbuf(BCH_MAX_DATALEN)))
-				panic("ihfc:(B) Out of mbufs!\n");
-				
-			dst = S_MBUFDATA;
-			len = BCH_MAX_DATALEN;
-		},
-		{/* cfr */
-			len = (BCH_MAX_DATALEN - len);
-
-			if ((!len) || (len > BCH_MAX_DATALEN))
-			{
-				/* NOTE: frames without any data,               *
-				 * only crc field, should be silently discared. */
-
-				i4b_Bfreembuf(S_MBUF);
-				NDBGL1(L1_S_MSG, "Bad frame (len=%d, unit=%d)", len, S_UNIT);
-				goto s0;
-			}
-
-			if (crc)
-			{	i4b_Bfreembuf(S_MBUF);
-				NDBGL1(L1_S_ERR, "CRC (crc=0x%04x, len=%d, unit=%d)", crc, len, S_UNIT);
-				goto s0;
-			}
-
-			S_MBUFLEN = len;
-
-			ihfc_putmbuf(sc, chan, S_MBUF);
-		 s0:
-			S_MBUF = NULL;
-		},
-		{/* rab */
-			i4b_Bfreembuf(S_MBUF);
-			S_MBUF = NULL;
-
-			NDBGL1(L1_S_MSG, "Read Abort (unit=%d)", S_UNIT);
-		},
-		{/* rdo */
-			i4b_Bfreembuf(S_MBUF);
-			S_MBUF = NULL;
-
-			NDBGL1(L1_S_ERR, "RDO (unit=%d)", S_UNIT);
-		},
-		continue,
-		d);
-	}
-
-	/* SET_REG(0x30);
-	 * if (~tmp2 & 0x100) READ_DATA_1;	kill disbusy signal
-	 */
-
-	if (S_MBUF) S_MBUFLEN = len;	/* suspend */
-
-	S_HDLC_IB 	= ib;
-	S_HDLC_CRC	= crc;
-	S_HDLC_TMP	= tmp;
-	S_HDLC_FLAG 	= flag;
-	S_HDLC_BLEVEL	= blevel;
-}
-
-/*---------------------------------------------------------------------------*
- *	Data handler for B channel(write) - chan 2 and 4	(HFC-1/S/SP)
- *
- *	This filter generates a pattern which is recognized
- *	and examinated and verified by ihfc_test_Bread.
- *
- *	NOTE: This filter is only for testing purpose.
- *---------------------------------------------------------------------------*/
-static void
-ihfc_test_Bwrite (ihfc_sc_t *sc, u_char chan)
-{
-	struct mbuf *m;
-
-	register u_char	 fb;
-	register u_short sendlen, tlen;
-	register u_short xlen = S_HDLC_IB;
-	BUS_VAR;
-
-	goto j0;
-
-	while((m = ihfc_getmbuf(sc, chan)))	/* internal loop */
-	{
-		if (chan == 2)
-			ihfc_putmbuf(sc, 5, m);
-		else
-			ihfc_putmbuf(sc, 3, m);
-	}
-
-	j0:
-
-	sendlen = /* (u_short)ihfc_Bsel_fifo(sc, chan, 0); */ 0;
-
-	if (sendlen == 0x5ff) printf("(send empty)");
-
-	SET_REG(0xaa + chan);
-
-	S_BYTES += sendlen;
-
-	tlen    = S_HDLC_CRC;
-
-	if (sendlen > 0x400) printf("(slow: %d)", sendlen);
-
-	fb = 0x80;
-
-	while (sendlen--)
-	{
-		if (!tlen--) fb |= 0x20;
-
-		if (!xlen--)
-		{
-			while(GET_STAT & 1);
-			WRITE_DATA_1(0x3e);
-			xlen = 200;
-		}
-		else
-		{
-			while(GET_STAT & 1);
-			WRITE_DATA_1((xlen + 1) & 0xef);
-		}
-
-		fb = 0;
-	}
-
-	S_HDLC_IB = xlen;
-}
-
-/*---------------------------------------------------------------------------*
- *	Data handler for B channel(read) - chan 3 and 5		(HFC-1/S/SP)
- *
- *	This filter examins and verifies the pattern
- *	generated by ihfc_test_Bwrite.
- *
- *	NOTE: This filter is only for testing purpose.
- *---------------------------------------------------------------------------*/
-static void
-ihfc_test_Bread (ihfc_sc_t *sc, u_char chan)
-{
-	static u_short toterrors = 0;
-
-	register u_short reclen, len, tlen;
-	register u_char fb, tmp;
-
-	register u_short xlen = S_HDLC_IB;
-	register u_char *dst = NULL;
-	register u_char error = S_HDLC_TMP;
-	register u_char ecount = S_HDLC_FLAG;
-
-	BUS_VAR;
-
-	if (S_UNIT != 0) return;
-
-	reclen = /* (u_short)ihfc_Bsel_fifo(sc, chan, 0); */ 0;
-
-	S_BYTES += reclen;
-
-	tlen   = S_HDLC_CRC;
-
-	fb = 0x40;
-
-	if (S_MBUF)
-	{
-		len = S_MBUFLEN;
-		dst = S_MBUFDATA + (BCH_MAX_DATALEN - len);
-	}
-	else
-	{
-		len = 0;
-	}
-
-	SET_REG(0xba + chan);
-
-	while (reclen--)
-	{
-/*		if (tmp2 & 0x100) while(GET_STAT & 1);
- *		tmp = (u_char)(tmp2 = READ_BOTH_2);
- */
-		if (GET_STAT & 1)
-		{	
-			/* if (!(++busy % 4)) reclen++; */
-			while(GET_STAT & 1);
-		}
-
-		tmp = READ_DATA_1;
-
-		if ((tmp & 0x3f) == 0x3e)
-		{
-			if ((BCH_MAX_DATALEN - len) != 201) error |= 4;
-
-			if ((S_MBUF) && (error))
-			{
-				if (len) { len--; *dst++ = error; }
-				if (len) { len--; *dst++ = xlen+1; }
-				if (len) { len--; *dst++ = ecount; }
-
-				S_MBUFLEN = BCH_MAX_DATALEN - len;
-
-				if (S_TRACE & TRACE_B_RX)
-					ihfc_putmbuf(sc, chan, S_MBUF);
-				else
-					i4b_Bfreembuf(S_MBUF);
-
-				S_MBUF = NULL;
-				printf("(error%d, %d, %d)", S_UNIT, ecount, toterrors++);
-			}
-
-			i4b_Bfreembuf(S_MBUF);
-			S_MBUF = i4b_Bgetmbuf(BCH_MAX_DATALEN);
-
-			dst = S_MBUFDATA;
-			len = BCH_MAX_DATALEN;
-
-			xlen = 200;
-			error = 0;
-			ecount = 0;
-
-		/*	SET_REG(0xba + chan); */
-		}
-		else
-		{
-			if (!xlen) error |= 2;
-			if ((tmp ^ xlen--) & 0xef) { error |= 1; ecount++; }
-		}
-		if (!tlen--) fb |= 0x20;
-
-		if (len--)
-		{
-			*dst++ = (tmp | fb);
-		}
-		else
-		{
-			len++;
-		}
-
-		fb = 0;
-	}
-
-	if (S_MBUF)
-	{
-		S_MBUFLEN = len;
-	}
-
-	S_HDLC_IB = xlen;
-	S_HDLC_TMP = error;
-	S_HDLC_FLAG = ecount;
-}
--- sys/i4b/layer1/ihfc/i4b_ihfc_drv.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/*-
- * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ihfc_drv.h - include file for the HFC-1/S/SP driver
- *	-------------------------------------------------------
- *
- *	last edit-date: [Wed Jul 19 09:40:55 2000]
- *
- *	$Id: i4b_ihfc_drv.h,v 1.7 2000/09/19 13:50:36 hm Exp $
- *
- * $FreeBSD: src/sys/i4b/layer1/ihfc/i4b_ihfc_drv.h,v 1.2 2005/01/06 22:18:19 imp Exp $
- *
- *---------------------------------------------------------------------------*/
-#ifndef	I4B_IHFC_DRV_H_
-#define I4B_IHFC_DRV_H_
-
-/*---------------------------------------------------------------------------*
- *	Ramptables related fifo					(HFC-1/S/SP)
- *
- *	The HFC-SP chip only uses ihfc_xxx[2] values for D-channel!
- *	NOTE: These tables are not used anymore.
- *---------------------------------------------------------------------------*
- * 
- *             w - write, r - read:   D1_w  D1_r  B1_w  B1_r  B2_w  B2_r
- * const u_char ihfc_readtable[6]  = {0xa6, 0xa7, 0xbc, 0xbd, 0xbe, 0xbf};
- * const u_char ihfc_writetable[6] = {0x96, 0x97, 0xac, 0xad, 0xae, 0xaf};
- * const u_char ihfc_f1inctable[6] = {0x92, 0x93, 0xa8, 0xa9, 0xaa, 0xab};	
- * const u_char ihfc_f2inctable[6] = {0xa2, 0xa3, 0xb8, 0xb9, 0xba, 0xbb};
- * 
- * const	struct { u_char z1L, z1H, z2L, z2H, f1, f2, dummy; } 
- * 	ihfc_countertable[6] = {
- * 	{0x90, 0x94, 0x98, 0x9c, 0x9a, 0x9e, 0x00},	D1_w
- *	{0x91, 0x95, 0x99, 0x9d, 0x9b, 0x9f, 0x00},	D1_r
- * 	{0x80, 0x84, 0x88, 0x8c, 0xb0, 0xb4, 0x00},	B1_w
- * 	{0x81, 0x85, 0x89, 0x8d, 0xb1, 0xb5, 0x00},	B1_r
- * 	{0x82, 0x86, 0x8a, 0x8e, 0xb2, 0xb6, 0x00},	B2_w
- * 	{0x83, 0x87, 0x8b, 0x8f, 0xb3, 0xb7, 0x00}	B2_r
- * 	};
- *---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*
- *	Ramptables related to configuration			(HFC-1/S/SP)
- *
- *	NOTE: Write registers only
- *---------------------------------------------------------------------------*/
-const u_char ihfc_configtable[11] =
-{
-	0x18, 0x19, 0x1a,	/* cirm, ctmt, int_m1		*/
-	0x1b, 0x2e, 0x37,	/* int_m2, mst_mode, clkdel	*/
-	0x31, 0x2f, 0x32,	/* sctrl, connect, test/sctrl_e */
-	0x33, 0x00		/* sctrl_r			*/
-};
-const u_char isac_configtable[9] =
-{
-	0x39, 0x30, 0x3b,	/* adf2, spcr, sqxr	*/
-	0x38, 0x37, 0x22,	/* adf1, stcr, mode	*/
-	0x20, 0x2b, 0x00	/* mask, star2		*/
-};
-
-/*---------------------------------------------------------------------------*
- *	Ramptables related to statemachine			(HFC-1/S/SP)
- *
- * state:
- *	0 = deactivated
- * 	1 = pending
- *	2 = syncronized
- *	3 = activated
- *	4 = error
- *	5 = reset
- *     -1 = illegal
- *---------------------------------------------------------------------------*/
-
-const struct ihfc_FSMtable { u_char state, *string; } 
-
-	ihfc_TEtable[16] = 	/* HFC-S/SP	- TE */
-{
-	{ 0x05 ,"Reset"					},
-	{ 0xff , 0 					},
-	{ 0x01 ,"Sensing"				},
-	{ 0x00 ,"Deactivated"				},
-	{ 0x01 ,"Awaiting signal"			},
-	{ 0x01 ,"Identifying input"			},
-	{ 0x02 ,"Syncronized"				},
-	{ 0x03 ,"Activated"				},
-	{ 0x04 ,"Lost framing"				},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0	 				},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					}
-}, 
-	ihfc_NTtable[16] = 	/* HFC-S/SP	- NT */
-{
-	{ 0x05 ,"Reset"					},
-	{ 0x00 ,"Deactive"				},
-	{ 0x02 ,"Pending activation"			},
-	{ 0x03 ,"Active"				},
-	{ 0x01 ,"Pending deactivation"			},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					}
-},
-	ihfc_TEtable2[16] =	/* HFC-1/ISAC 	- TE */
-{
-	{ 0x00 ,"Deactivate request"			},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0xff , 0 					},
-	{ 0x01 ,"Level detected"			},
-	{ 0xff , 0 					},
-	{ 0x04 ,"Error indication"			},
-	{ 0x00 ,"Power-up"		 		},
-	{ 0x02 ,"Activate request downstream" 		},
-	{ 0xff , 0 					},
-	{ 0x00 ,"Test indication"			},
-	{ 0x00 ,"Awake test indication"			},
-	{ 0x03 ,"Activate ind. with priority class 8" 	},
-	{ 0x03 ,"Activate ind. with priority class 10"	},
-	{ 0xff , 0 					},
-	{ 0x00 ,"Deactivate indication downstream" 	}
-};
-
-/*---------------------------------------------------------------------------*
- *	Ramptable related to ISAC EXIR				(HFC-1)
- *
- *	cmd: command to execute, if any.
- *
- *---------------------------------------------------------------------------*/
-const struct ihfc_EXIRtable { u_char cmd, *string; }
-
-	ihfc_EXIRtable[8] =
-{
-	{ 0x00 ,"Watchdog Timer Overflow"		},
-	{ 0x00 ,"Subscriber Awake"			},
-	{ 0x00 ,"Monitor Status"			},
-	{ 0x00 ,"Rx Sync Xfer Overflow"			},
-	{ 0xc0 ,"Rx Frame Overflow"			}, /* RMC + RRES */
-	{ 0x00 ,"Protocol Error"			},
-	{ 0x01 ,"Tx Data Underrun"			}, /* XRES */
-	{ 0x01 ,"Tx Message Repeat"			}, /* XRES */
-};
-
-/*---------------------------------------------------------------------------*
- *	Ramptables related to S/Q - channel			(HFC-1/S/SP)
- *
- *	From TE's viewpoint:
- *	Q: commands to NT
- *	S: indications from NT
- *
- *	From NT's viewpoint:
- *	Q: indications from TE
- *	S: commands to TE
- *	
- *	cmd: not used
- *---------------------------------------------------------------------------*/
-const struct ihfc_SQtable { u_char cmd, *string; }
-
-	ihfc_Qtable[16] =
-{
-	{ 0x00, "Loss of Power indication"		},
-	{ 0x00, "ST request"				},
-	{ 0x00, 0					},
-	{ 0x00, "LoopBack request (B1/B2)"		},
-	{ 0x00, 0					},
-	{ 0x00, 0					},
-	{ 0x00, 0					},
-	{ 0x00, "LoopBack request (B1)"			},
-	{ 0x00, 0					},
-	{ 0x00, 0					},
-	{ 0x00, 0					},
-	{ 0x00, "LoopBack request (B2)"			},
-	{ 0x00, "V-DCE slave mode"			},
-	{ 0x00, "V-DTE slave mode"			},
-	{ 0x00, 0					},
-	{ 0x00, "Idle"					}
-},
-	ihfc_Stable[16] =
-{
-	{ 0x00, "Idle"					},
-	{ 0x00, "ST Fail"				},
-	{ 0x00, "ST Pass"				},
-	{ 0x00, "Disruptive Operation Indication"	},
-	{ 0x00, "DTSE-OUT"				},
-	{ 0x00, "V-DCE master mode"			},
-	{ 0x00, "ST Indication"				},
-	{ 0x00, "DTSE-IN"				},
-	{ 0x00, "LoopBack indication (B1/B2)"		},
-	{ 0x00, "Loss of Received Signal indication"	},
-	{ 0x00, "LoopBack indication (B2)"		},
-	{ 0x00, "DTSE-IN and OUT"			},
-	{ 0x00, "LoopBack indication (B1)"		},
-	{ 0x00, "Loss of power indication"		}
-};
-
-
-#endif /* I4B_IHFC_DRV_H_ */
-
--- sys/i4b/layer1/isic/i4b_tel_s0163.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*-
- *   Copyright (c) 1996 Arne Helme. All rights reserved.
- *   Copyright (c) 1996 Gary Jennejohn. 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
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	isic - I4B Siemens ISDN Chipset Driver for Teles S0/16.3
- *	========================================================
- *      last edit-date: [Wed Jan 24 09:27:40 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_tel_s0163.c,v 1.9 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(TEL_S0_16_3)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-static u_char intr_no[] = { 1, 1, 0, 2, 4, 6, 1, 1, 1, 0, 8, 10, 12, 1, 1, 14 };
-
-#define ISAC_OFFS	0x400
-#define	HSCXA_OFFS	0xc00
-#define HSCXB_OFFS	0x800
-
-/*---------------------------------------------------------------------------*
- *      Teles S0/16.3 read fifo routine
- *---------------------------------------------------------------------------*/
-static void
-tels0163_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[what+1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+1]);
-	bus_space_read_multi_1(t,h,0x1e,buf,size);
-}
-
-/*---------------------------------------------------------------------------*
- *      Teles S0/16.3 write fifo routine
- *---------------------------------------------------------------------------*/
-static void
-tels0163_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[what+1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+1]);
-	bus_space_write_multi_1(t,h,0x1e,buf,size);
-}
-
-/*---------------------------------------------------------------------------*
- *      Teles S0/16.3 ISAC put register routine
- *---------------------------------------------------------------------------*/
-static void
-tels0163_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[what+1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+1]);
-	bus_space_write_1(t,h,offs - 0x20,data);
-}
-
-/*---------------------------------------------------------------------------*
- *	Teles S0/16.3 ISAC get register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-tels0163_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[what+1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+1]);
-	return bus_space_read_1(t,h,offs - 0x20);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_probe_s0163 - probe routine for Teles S0/16.3
- *---------------------------------------------------------------------------*/
-int
-isic_probe_s0163(device_t dev)
-{
-	size_t unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = 0;	/* pointer to softc */
-	void *ih = 0;			/* dummy */
-	bus_space_tag_t    t;		/* bus things */
-	bus_space_handle_t h;
-	u_int8_t b0,b1,b2;		/* signature */
-
-	/* check max unit range */
-
-	if(unit >= ISIC_MAXUNIT)
-	{
-		printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Teles 16.3!\n",
-				unit, unit);
-		return(ENXIO);	
-	}
-
-	sc = &l1_sc[unit];			/* get pointer to softc */
-	sc->sc_unit = unit;			/* set unit */
-
-	/* see if an io base was supplied */
-	
-	if(!(sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get iobase for Teles S0/16.3.\n",
-				unit);
-		return(ENXIO);
-	}
-
-	/* set io base */
-
-	sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
-	/* Release the resource -  re-allocate later with correct size	*/
-        bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_resources.io_rid[0],
-			sc->sc_resources.io_base[0]);
-	
-	switch(sc->sc_port)
-	{
-		case 0xd80:
-		case 0xe80:
-		case 0xf80:
-			break;
-			
-		case 0x180:
-		case 0x280:
-		case 0x380:
-			printf("isic%d: Error, instead of using iobase 0x%x for your Teles S0/16.3,\n",
-				unit, sc->sc_port);
-			printf("isic%d:        please use 0x%x in the kernel configuration file!\n",
-				unit, sc->sc_port+0xc00);			
-			isic_detach_common(dev);
-			return(ENXIO);
-			break;
-	
-		default:
-			printf("isic%d: Error, invalid iobase 0x%x specified for Teles S0/16.3!\n",
-				unit, sc->sc_port);
-			isic_detach_common(dev);
-			return(ENXIO);
-			break;
-	}
-	
-	/* set io port resources */
-
-	sc->sc_resources.io_rid[0] = 0;	
-	bus_set_resource(dev, SYS_RES_IOPORT, 0, sc->sc_port, 0x20);
-	sc->sc_resources.io_base[0] =
-		bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-				       &sc->sc_resources.io_rid[0],
-				       RF_ACTIVE);
-	if(!sc->sc_resources.io_base[0])
-	{
-		printf("isic%d: Error allocating io at 0x%x for Teles S0/16.3!\n",
-			unit, sc->sc_port);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-	sc->sc_resources.io_rid[1] = 1;	
-	bus_set_resource(dev, SYS_RES_IOPORT, 1,
-		sc->sc_port-ISAC_OFFS, 0x20);
-	sc->sc_resources.io_base[1] =
-		bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-				       &sc->sc_resources.io_rid[1],
-				       RF_ACTIVE);
-	if(!sc->sc_resources.io_base[1])
-	{
-		printf("isic%d: Error allocating io at 0x%x for Teles S0/16.3!\n",
-			unit, sc->sc_port-ISAC_OFFS);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-	
-	sc->sc_resources.io_rid[2] = 2;
-	bus_set_resource(dev, SYS_RES_IOPORT, 2,
-		sc->sc_port-HSCXA_OFFS, 0x20);
-	sc->sc_resources.io_base[2] =
-		bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-				       &sc->sc_resources.io_rid[2],
-				       RF_ACTIVE);
-	if(!sc->sc_resources.io_base[2])
-	{
-		printf("isic%d: Error allocating io at 0x%x for Teles S0/16.3!\n",
-			unit, sc->sc_port-HSCXA_OFFS);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	sc->sc_resources.io_rid[3] = 3;
-	bus_set_resource(dev, SYS_RES_IOPORT, 3,
-		sc->sc_port-HSCXB_OFFS, 0x20);
-	sc->sc_resources.io_base[3] =
-		bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-				       &sc->sc_resources.io_rid[3],
-				       RF_ACTIVE);
-	if(!sc->sc_resources.io_base[3])
-	{
-		printf("isic%d: Error allocating io at 0x%x for Teles S0/16.3!\n",
-			unit, sc->sc_port-HSCXB_OFFS);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = tels0163_read_reg;
-	sc->writereg = tels0163_write_reg;
-
-	sc->readfifo = tels0163_read_fifo;
-	sc->writefifo = tels0163_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp= CARD_TYPEP_16_3;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	b0 = bus_space_read_1(t, h, 0);
-	b1 = bus_space_read_1(t, h, 1);
-	b2 = bus_space_read_1(t, h, 2);
-	
-	if ( b0 != 0x51 && b0 != 0x10 ) {
-		printf("isic%d: Error, signature 1 0x%x != 0x51 or 0x10 for Teles S0/16.3!\n",
-			unit, b0);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-	
-	if ( b1 != 0x93 ) {
-		printf("isic%d: Error, signature 2 0x%x != 0x93 for Teles S0/16.3!\n",
-			unit, b1);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-	if (( b2 != 0x1c ) && ( b2 != 0x1f )) {
-		printf("isic%d: Error, signature 3 0x%x != (0x1c || 0x1f) for Teles S0/16.3!\n",
-			unit, b2);
-		isic_detach_common(dev);
-		return ENXIO;	
-	}
-	
-	/* 
-	 * Read HSCX A/B VSTR.  Expected value for the S0/16.3 card is
-	 * 0x05 or 0x04 (for older 16.3's) in the least significant bits.
-	 */
-	 
-	if( (((HSCX_READ(0, H_VSTR) & 0xf) != 0x5) &&
-	     ((HSCX_READ(0, H_VSTR) & 0xf) != 0x4))	||
-            (((HSCX_READ(1, H_VSTR) & 0xf) != 0x5) &&
-	     ((HSCX_READ(1, H_VSTR) & 0xf) != 0x4)) )  
-	{
-		printf("isic%d: HSCX VSTR test failed for Teles S0/16.3\n",
-			unit);
-		printf("isic%d: HSC0: VSTR: %#x\n",
-			unit, HSCX_READ(0, H_VSTR));
-		printf("isic%d: HSC1: VSTR: %#x\n",
-			unit, HSCX_READ(1, H_VSTR));
-		isic_detach_common(dev);
-		return (ENXIO);
-	}                   
-
-	/* get our irq */
-
-	if(!(sc->sc_resources.irq =
-		bus_alloc_resource_any(dev, SYS_RES_IRQ,
-				       &sc->sc_resources.irq_rid,
-				       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get IRQ for Teles S0/16.3.\n",unit);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	/* get the irq number */
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-
-	switch(sc->sc_irq)
-	{
-		case 2:
-		case 9:
-		case 5:
-		case 10:
-		case 12:
-		case 15:
-			break;
-
-		default:
-			printf("isic%d: Error, invalid IRQ [%d] specified for Teles S0/16.3!\n",
-				unit, sc->sc_irq);
-			isic_detach_common(dev);
-			return(ENXIO);
-			break;
-	}
-
-	/* register interupt routine */
-	bus_setup_intr(dev, sc->sc_resources.irq,
-			INTR_TYPE_NET,
-			(void(*)(void *))(isicintr),
-			sc, &ih);
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_s0163 - attach Teles S0/16.3 and compatibles
- *---------------------------------------------------------------------------*/
-int
-isic_attach_s0163(device_t dev)
-{
-	unsigned int unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = &l1_sc[unit];
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	/* configure IRQ */
-	
-	DELAY(SEC_DELAY / 10);
-	bus_space_write_1(t, h, 4, intr_no[sc->sc_irq]);
-
-	DELAY(SEC_DELAY / 10);
-	bus_space_write_1(t, h, 4, intr_no[sc->sc_irq] | 0x01);
-
-	return (0);
-}
-
-#endif /* defined(TEL_S0_16_3) */
--- sys/i4b/layer1/isic/i4b_avm_a1.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/*-
- *   Copyright (c) 1996 Andrew Gordon. 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
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_avm_a1.c - AVM A1/Fritz passive card driver for isdn4bsd
- *	------------------------------------------------------------
- *      last edit-date: [Wed Jan 24 09:25:23 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_avm_a1.c,v 1.9 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(AVM_A1)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-/*---------------------------------------------------------------------------*
- *	AVM A1 and AVM Fritz! Card special registers
- *---------------------------------------------------------------------------*/
-
-#define	AVM_CONF_REG	0x1800		/* base offset for config register */
-#define	AVM_CONF_IRQ	0x1801		/* base offset for IRQ register    */
-					/* config register write           */
-#define	 AVM_CONF_WR_RESET	0x01	/* 1 = RESET ISAC and HSCX         */
-#define	 AVM_CONF_WR_CCL	0x02	/* 1 = clear counter low nibble    */
-#define	 AVM_CONF_WR_CCH	0x04	/* 1 = clear counter high nibble   */
-#define	 AVM_CONF_WR_IRQEN	0x08	/* 1 = enable IRQ                  */
-#define	 AVM_CONF_WR_TEST	0x10	/* test bit                        */
-					/* config register read            */
-#define	 AVM_CONF_RD_IIRQ	0x01	/* 0 = ISAC IRQ active             */
-#define	 AVM_CONF_RD_HIRQ	0x02	/* 0 = HSCX IRQ active             */
-#define	 AVM_CONF_RD_CIRQ	0x04    /* 0 = counter IRQ active          */
-#define	 AVM_CONF_RD_ZER1	0x08	/* unused, always read 0           */
-#define	 AVM_CONF_RD_TEST	0x10	/* test bit read back              */
-#define	 AVM_CONF_RD_ZER2	0x20	/* unused, always read 0           */
-
-#define AVM_ISAC_R_OFFS		(0x1400-0x20)
-#define AVM_HSCXA_R_OFFS	(0x400-0x20)
-#define AVM_HSCXB_R_OFFS	(0xc00-0x20)
-#define AVM_ISAC_F_OFFS		(0x1400-0x20-0x3e0)
-#define AVM_HSCXA_F_OFFS	(0x400-0x20-0x3e0)
-#define AVM_HSCXB_F_OFFS	(0xc00-0x20-0x3e0)
-
-/*---------------------------------------------------------------------------*
- *	AVM read fifo routine
- *---------------------------------------------------------------------------*/
-static void
-avma1_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[what+4]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+4]);
-	bus_space_read_multi_1(t, h, 0, buf, size);
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM write fifo routine
- *---------------------------------------------------------------------------*/
-static void
-avma1_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[what+4]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+4]);
-	bus_space_write_multi_1(t, h, 0, (u_int8_t*)buf, size);
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM write register routine
- *---------------------------------------------------------------------------*/
-static void
-avma1_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[what+1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+1]);
-	bus_space_write_1(t, h, offs, data);
-}
-
-/*---------------------------------------------------------------------------*
- *	AVM read register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-avma1_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[what+1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+1]);
-	return bus_space_read_1(t, h, offs);
-}
-
-/*---------------------------------------------------------------------------*
- *	allocate an io port
- *---------------------------------------------------------------------------*/
-static int
-isic_alloc_port(device_t dev, int rid, u_int base, u_int len)
-{ 
-	size_t unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];
-
-	sc->sc_resources.io_rid[rid] = rid;
-
-	bus_set_resource(dev, SYS_RES_IOPORT, rid, base, len);
-
-	if(!(sc->sc_resources.io_base[rid] =
-		bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-				       &sc->sc_resources.io_rid[rid],
-				       RF_ACTIVE)))
-	{
-		printf("isic%d: Error, failed to reserve io #%d!\n", unit, rid);
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_probe_avma1 - probe for AVM A1 and compatibles
- *---------------------------------------------------------------------------*/
-int
-isic_probe_avma1(device_t dev)
-{
-	size_t unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = 0;	/* pointer to softc */
-	void *ih = 0;			/* dummy */
-	bus_space_tag_t    t;		/* bus things */
-	bus_space_handle_t h;
-	u_char savebyte;
-	u_char byte;
-
-	/* check max unit range */
-
-	if(unit >= ISIC_MAXUNIT)
-	{
-		printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for AVM A1/Fritz!\n",
-				unit, unit);
-		return(ENXIO);	
-	}
-
-	sc = &l1_sc[unit];			/* get pointer to softc */
-	sc->sc_unit = unit;			/* set unit */
-
-	/* see if an io base was supplied */
-	
-	if(!(sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get iobase for AVM A1/Fritz!\n",
-				unit);
-		return(ENXIO);
-	}
-
-	/* set io base */
-
-	sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
-	
-	/* release io base */
-	
-        bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_resources.io_rid[0],
-			sc->sc_resources.io_base[0]);
-
-	switch(sc->sc_port)
-	{
-		case 0x200:
-		case 0x240:
-		case 0x300:
-		case 0x340:		
-			break;
-			
-		default:
-			printf("isic%d: Error, invalid iobase 0x%x specified for AVM A1/Fritz!\n",
-				unit, sc->sc_port);
-			return(ENXIO);
-			break;
-	}
-
-	if(isic_alloc_port(dev, 0, sc->sc_port+AVM_CONF_REG, 0x20))
-		return(ENXIO);
-
-	if(isic_alloc_port(dev, 1, sc->sc_port+AVM_ISAC_R_OFFS, 0x20))
-		return(ENXIO);
-
-	if(isic_alloc_port(dev, 2, sc->sc_port+AVM_HSCXA_R_OFFS, 0x20))
-		return(ENXIO);
-
-	if(isic_alloc_port(dev, 3, sc->sc_port+AVM_HSCXB_R_OFFS, 0x20))
-		return(ENXIO);
-
-	if(isic_alloc_port(dev, 4, sc->sc_port+AVM_ISAC_F_OFFS, 0x20))
-		return(ENXIO);
-
-	if(isic_alloc_port(dev, 5, sc->sc_port+AVM_HSCXA_F_OFFS, 0x20))
-		return(ENXIO);
-
-	if(isic_alloc_port(dev, 6, sc->sc_port+AVM_HSCXB_F_OFFS, 0x20))
-		return(ENXIO);
-
-	/* get our irq */
-
-	if(!(sc->sc_resources.irq =
-		bus_alloc_resource_any(dev, SYS_RES_IRQ,
-				       &sc->sc_resources.irq_rid, RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get an irq for AVM A1/Fritz!\n",unit);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	/* get the irq number */
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-
-	/* register interupt routine */
-	bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET,
-			(void(*)(void *))(isicintr),
-			sc, &ih);
-
-	/* check IRQ validity */
-
-	switch(sc->sc_irq)
-	{
-		case 3:
-		case 4:
-		case 5:
-		case 6:
-		case 7:
-		case 8:
-		case 10:
-		case 11:
-		case 12:
-		case 13:
-		case 14:
-		case 15:
-			break;
-			
-		default:
-			printf("isic%d: Error, invalid IRQ [%d] specified for AVM A1/Fritz!\n",
-				unit, sc->sc_irq);
-			isic_detach_common(dev);
-			return(ENXIO);
-			break;
-	}		
-
-	sc->clearirq = NULL;
-	sc->readreg = avma1_read_reg;
-	sc->writereg = avma1_write_reg;
-
-	sc->readfifo = avma1_read_fifo;
-	sc->writefifo = avma1_write_fifo;
-
-	/* setup card type */
-
-	sc->sc_cardtyp = CARD_TYPEP_AVMA1;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* 
-	 * Read HSCX A/B VSTR.
-	 * Expected value for AVM A1 is 0x04 or 0x05 and for the
-	 * AVM Fritz!Card is 0x05 in the least significant bits.
-	 */
-
-	if( (((HSCX_READ(0, H_VSTR) & 0xf) != 0x5) &&
-	     ((HSCX_READ(0, H_VSTR) & 0xf) != 0x4))	||
-            (((HSCX_READ(1, H_VSTR) & 0xf) != 0x5) &&
-	     ((HSCX_READ(1, H_VSTR) & 0xf) != 0x4)) )  
-	{
-		printf("isic%d: HSCX VSTR test failed for AVM A1/Fritz\n",
-			unit);
-		printf("isic%d: HSC0: VSTR: %#x\n",
-			unit, HSCX_READ(0, H_VSTR));
-		printf("isic%d: HSC1: VSTR: %#x\n",
-			unit, HSCX_READ(1, H_VSTR));
-		return(ENXIO);
-	}                   
-
-	/* AVM A1 or Fritz! control register bits:	*/
-	/*        read                write		*/
-	/* 0x01  hscx irq*           RESET		*/
-	/* 0x02  isac irq*           clear counter1	*/
-	/* 0x04  counter irq*        clear counter2	*/
-	/* 0x08  always 0            irq enable		*/
-	/* 0x10  read test bit       set test bit	*/
-	/* 0x20  always 0            unused		*/
-
-	/*
-	 * XXX the following test may be destructive, to prevent the
-	 * worst case, we save the byte first, and in case the test
-	 * fails, we write back the saved byte .....
-	 */
-
-	t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	savebyte = bus_space_read_1(t, h, 0);
-	
-	/* write low to test bit */
-
-	bus_space_write_1(t, h, 0, 0x00);
-	
-	/* test bit and next higher and lower bit must be 0 */
-
-	if((byte = bus_space_read_1(t, h, 0) & 0x38) != 0x00)
-	{
-		printf("isic%d: Error, probe-1 failed, 0x%02x should be 0x00 for AVM A1/Fritz!\n",
-				unit, byte);
-		bus_space_write_1(t, h, 0, savebyte);
-		return(ENXIO);
-	}
-
-	/* write high to test bit */
-
-	bus_space_write_1(t, h, 0, 0x10);
-	
-	/* test bit must be high, next higher and lower bit must be 0 */
-
-	if((byte = bus_space_read_1(t, h, 0) & 0x38) != 0x10)
-	{
-		printf("isic%d: Error, probe-2 failed, 0x%02x should be 0x10 for AVM A1/Fritz!\n",
-				unit, byte);
-		bus_space_write_1(t, h, 0, savebyte);
-		return(ENXIO);
-	}
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_avma1 - attach AVM A1 and compatibles
- *---------------------------------------------------------------------------*/
-int
-isic_attach_avma1(device_t dev)
-{
-	size_t unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	/* reset ISAC/HSCX */
-
-	bus_space_write_1(t, h, 0, 0x00);
-	DELAY(SEC_DELAY / 10);
-
-	bus_space_write_1(t, h, 0, AVM_CONF_WR_RESET);
-	DELAY(SEC_DELAY / 10);
-
-	bus_space_write_1(t, h, 0, 0x00);
-	DELAY(SEC_DELAY / 10);
-
-	/* setup IRQ */
-
-	bus_space_write_1(t, h, 1, sc->sc_irq);
-	DELAY(SEC_DELAY / 10);
-
-	/* enable IRQ, disable counter IRQ */
-
-	bus_space_write_1(t, h, 0, AVM_CONF_WR_IRQEN |
-				AVM_CONF_WR_CCH | AVM_CONF_WR_CCL);
-	DELAY(SEC_DELAY / 10);
-
-	return(0);
-}
-
-#endif /* defined(AVM_A1) */
--- sys/i4b/layer1/isic/i4b_elsa_qs1p.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	isic - I4B Siemens ISDN Chipset Driver for ELSA MicroLink ISDN/PCI
- *	==================================================================
- *      last edit-date: [Wed Jan 24 09:09:28 2001]
- *
- *	Note: ELSA Quickstep 1000pro PCI = ELSA MicroLink ISDN/PCI
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_elsa_qs1p.c,v 1.14 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(ELSA_QS1PCI)
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/bus.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_ipac.h>
-
-#define MEM0_BAR	0
-#define PORT0_BAR	1
-#define PORT1_BAR	3
-
-#define ELSA_PORT0_MAPOFF	PCIR_BAR(PORT0_BAR)
-#define ELSA_PORT1_MAPOFF	PCIR_BAR(PORT1_BAR)
-
-#define PCI_QS1000_DID	0x1000
-#define PCI_QS1000_VID	0x1048
-
-/* masks for register encoded in base addr */
-
-#define ELSA_BASE_MASK		0x0ffff
-#define ELSA_OFF_MASK		0xf0000
-
-/* register id's to be encoded in base addr */
-
-#define ELSA_IDISAC		0x00000
-#define ELSA_IDHSCXA		0x10000
-#define ELSA_IDHSCXB		0x20000
-#define ELSA_IDIPAC		0x40000
-
-/* offsets from base address */
-
-#define ELSA_OFF_ALE		0x00
-#define ELSA_OFF_RW		0x01
-
-
-static int eqs1p_pci_probe(device_t dev);
-static int eqs1p_pci_attach(device_t dev);
-
-static device_method_t eqs1p_pci_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		eqs1p_pci_probe),
-	DEVMETHOD(device_attach,	eqs1p_pci_attach),
-	{ 0, 0 }
-};
-
-static driver_t eqs1p_pci_driver = {
-	"isic",
-	eqs1p_pci_methods,
-	0
-};
-
-static devclass_t eqs1p_pci_devclass;
-
-DRIVER_MODULE(eqs1p, pci, eqs1p_pci_driver, eqs1p_pci_devclass, 0, 0);
-
-/*---------------------------------------------------------------------------*
- *      ELSA MicroLink ISDN/PCI fifo read routine
- *---------------------------------------------------------------------------*/
-static void
-eqs1pp_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[1]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_ISAC_OFF);
-			bus_space_read_multi_1(t, h, ELSA_OFF_RW, buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_HSCXA_OFF);
-			bus_space_read_multi_1(t, h, ELSA_OFF_RW, buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_HSCXB_OFF);
-			bus_space_read_multi_1(t, h, ELSA_OFF_RW, buf, size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      ELSA MicroLink ISDN/PCI fifo write routine
- *---------------------------------------------------------------------------*/
-static void
-eqs1pp_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[1]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_ISAC_OFF);
-			bus_space_write_multi_1(t, h, ELSA_OFF_RW, (u_int8_t*)buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_HSCXA_OFF);
-			bus_space_write_multi_1(t, h, ELSA_OFF_RW, (u_int8_t*)buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_HSCXB_OFF);
-			bus_space_write_multi_1(t, h, ELSA_OFF_RW, (u_int8_t*)buf, size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      ELSA MicroLink ISDN/PCI register write routine
- *---------------------------------------------------------------------------*/
-static void
-eqs1pp_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[1]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_ISAC_OFF+offs);
-			bus_space_write_1(t, h, ELSA_OFF_RW, data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_HSCXA_OFF+offs);
-			bus_space_write_1(t, h, ELSA_OFF_RW, data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_HSCXB_OFF+offs);
-			bus_space_write_1(t, h, ELSA_OFF_RW, data);
-			break;
-		case ISIC_WHAT_IPAC:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_IPAC_OFF+offs);
-			bus_space_write_1(t, h, ELSA_OFF_RW, data);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	ELSA MicroLink ISDN/PCI register read routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-eqs1pp_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[1]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[1]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_ISAC_OFF+offs);
-			return bus_space_read_1(t, h, ELSA_OFF_RW);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_HSCXA_OFF+offs);
-			return bus_space_read_1(t, h, ELSA_OFF_RW);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_HSCXB_OFF+offs);
-			return bus_space_read_1(t, h, ELSA_OFF_RW);
-		case ISIC_WHAT_IPAC:
-			bus_space_write_1(t, h, ELSA_OFF_ALE, IPAC_IPAC_OFF+offs);
-			return bus_space_read_1(t, h, ELSA_OFF_RW);
-	}
-	return 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	avma1pp_probe - probe for a card
- *---------------------------------------------------------------------------*/
-static int
-eqs1p_pci_probe(device_t dev)
-{
-	if((pci_get_vendor(dev) == PCI_QS1000_VID) &&
-	   (pci_get_device(dev) == PCI_QS1000_DID))
-	{
-		device_set_desc(dev, "ELSA MicroLink ISDN/PCI");
-		return(0);
-	}
-	return(ENXIO);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_Eqs1pp - attach for ELSA MicroLink ISDN/PCI
- *---------------------------------------------------------------------------*/
-static int
-eqs1p_pci_attach(device_t dev)
-{
-	bus_space_tag_t t;
-	bus_space_handle_t h;
-	struct l1_softc *sc;
-	void *ih = 0;
-	int unit = device_get_unit(dev);
-	
-	/* check max unit range */
-	
-	if(unit >= ISIC_MAXUNIT)
-	{
-		printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for ELSA MicroLink ISDN/PCI!\n",
-				unit, unit);
-		return(ENXIO);	
-	}	
-
-	sc = &l1_sc[unit];		/* get softc */	
-	
-	sc->sc_unit = unit;
-
-	/* get io_base */
-
-	sc->sc_resources.io_rid[0] = ELSA_PORT0_MAPOFF;
-	
-	if(!(sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Couldn't get first iobase for ELSA MicroLink ISDN/PCI!\n", unit);
-		return(ENXIO);                                       
-	}
-
-	sc->sc_resources.io_rid[1] = ELSA_PORT1_MAPOFF;
-	
-	if(!(sc->sc_resources.io_base[1] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[1],
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Couldn't get second iobase for ELSA MicroLink ISDN/PCI!\n", unit);
-		isic_detach_common(dev);
-		return(ENXIO);                                       
-	}
-
-	sc->sc_port = rman_get_start(sc->sc_resources.io_base[1]);
-
-	if(!(sc->sc_resources.irq =
-			bus_alloc_resource_any(dev, SYS_RES_IRQ,
-					       &sc->sc_resources.irq_rid,
-					       RF_ACTIVE | RF_SHAREABLE)))
-	{
-		printf("isic%d: Could not get irq for ELSA MicroLink ISDN/PCI!\n",unit);
-		isic_detach_common(dev);
-		return(ENXIO);                                       
-	}
-	
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = eqs1pp_read_reg;
-	sc->writereg = eqs1pp_write_reg;
-
-	sc->readfifo = eqs1pp_read_fifo;
-	sc->writefifo = eqs1pp_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_ELSAQS1PCI;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	/* setup chip type = IPAC ! */
-	
-	sc->sc_ipac = 1;
-	sc->sc_bfifolen = IPAC_BFIFO_LEN;
-
-	if(isic_attach_common(dev))
-	{
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-
-	if(bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET,
-				(void(*)(void*))isicintr,
-				sc, &ih))
-	{
-		printf("isic%d: Couldn't set up irq for ELSA MicroLink ISDN/PCI!\n", unit);
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-
-	/* enable hscx/isac irq's */
-
-	IPAC_WRITE(IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
-
-	IPAC_WRITE(IPAC_ACFG, 0);	/* outputs are open drain */
-	IPAC_WRITE(IPAC_AOE,		/* aux 5..2 are inputs, 7, 6 outputs */
-		(IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2));
-	IPAC_WRITE(IPAC_ATX, 0xff);	/* set all output lines high */
-
-	t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	
-        bus_space_write_1(t, h, 0x4c, 0x41);	/* enable card interrupt */
-        
-	return(0);
-}
-
-#endif /* defined(ELSA_QS1PCI) */
--- sys/i4b/layer1/isic/i4b_tel_s08.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*-
- *   Copyright (c) 1996 Arne Helme. All rights reserved.
- *   Copyright (c) 1996 Gary Jennejohn. 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
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	isic - I4B Siemens ISDN Chipset Driver for Teles S0/8 and clones
- *	================================================================
- *      last edit-date: [Wed Jan 24 09:27:58 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_tel_s08.c,v 1.10 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(TEL_S0_8)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/md_var.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#define TELES_S08_MEMSIZE 0x1000
-
-static const bus_size_t offset[] = { 0x100, 0x180, 0x1c0 };
-
-/*---------------------------------------------------------------------------*
- *	Teles S0/8 write register routine
- *---------------------------------------------------------------------------*/
-static void
-tels08_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.mem);
-
-	offs += offset[what];
-
-	if (offs & 0x01)
-		offs |= 0x200;
-
-	bus_space_write_1(t, h, offs, data);
-}
-
-/*---------------------------------------------------------------------------*
- *	Teles S0/8 read register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-tels08_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.mem);
-
-	offs += offset[what];
-
-	if (offs & 0x01)
-		offs |= 0x200;
-
-	return bus_space_read_1(t, h, offs);
-}
-
-/*---------------------------------------------------------------------------*
- *	Teles S0/8 fifo write access
- *---------------------------------------------------------------------------*/
-static void
-tels08_write_fifo(struct l1_softc *sc, int what, void *data, size_t size)
-{
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.mem);
-	bus_space_write_region_1(t, h, offset[what], data, size);
-}
-
-/*---------------------------------------------------------------------------*
- *	Teles S0/8 fifo read access
- *---------------------------------------------------------------------------*/
-static void
-tels08_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.mem);
-	bus_space_read_region_1(t, h, offset[what], buf, size);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_probe_s08 - probe for Teles S0/8 and compatibles
- *---------------------------------------------------------------------------*/
-int
-isic_probe_s08(device_t dev)
-{
-	size_t unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = 0;		/* pointer to softc */
-	void *ih = 0;				/* dummy */
-
-	/* check max unit range */
-
-	if(unit >= ISIC_MAXUNIT)
-	{
-		printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Teles S0/8!\n",
-				unit, unit);
-		return(ENXIO);	
-	}
-
-	sc = &l1_sc[unit];		/* get pointer to softc */
-	sc->sc_unit = unit;		/* set unit */
-
-	/* see if an io base was supplied */
-
-	if((sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE)))
-	{
-		/* the S0/8 is completely memory mapped ! */
-		
-	 	bus_release_resource(dev,SYS_RES_IOPORT,
-				     sc->sc_resources.io_rid[0],
-				     sc->sc_resources.io_base[0]);
-		printf("isic%d: Error, iobase specified for Teles S0/8!\n", unit);
-		return(ENXIO);
-	}
-
-	/* allocate memory */
-
-	if(!(sc->sc_resources.mem =
-		bus_alloc_resource(dev, SYS_RES_MEMORY,
-				&sc->sc_resources.mem_rid,
-				0ul, ~0ul, TELES_S08_MEMSIZE, RF_ACTIVE)))
-	{
-		printf("isic%d: Could not allocate memory for Teles S0/8!\n", unit);
-		return(ENXIO);
-	}
-
-	/* 
-	 * get virtual addr. it's just needed to see if it is in
-	 * the valid range
-	 */
-
-	sc->sc_vmem_addr = rman_get_virtual(sc->sc_resources.mem);
-		
-	/* check if inside memory range of 0xA0000 .. 0xDF000 */
-
-	if((kvtop(sc->sc_vmem_addr) < 0xa0000) ||
-	   (kvtop(sc->sc_vmem_addr) > 0xdf000))
-	{
-		printf("isic%d: Error, mem addr 0x%x outside 0xA0000-0xDF000 for Teles S0/8!\n",
-				unit, kvtop(sc->sc_vmem_addr));
-		bus_release_resource(dev,SYS_RES_MEMORY,
-				     sc->sc_resources.mem_rid,
-				     sc->sc_resources.mem);
-		sc->sc_resources.mem = 0;
-		return(ENXIO);
-	}
-	
-	/* setup ISAC access routines */
-
-	sc->clearirq = NULL;
-
-	sc->readreg = tels08_read_reg;
-	sc->writereg = tels08_write_reg;
-
-	sc->readfifo = tels08_read_fifo;
-	sc->writefifo = tels08_write_fifo;
-
-	sc->sc_cardtyp = CARD_TYPEP_8;		/* setup card type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM1;		/* setup IOM bus type */
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* setup ISAC base addr, though we don't really need it */
-	
-	ISAC_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x100);
-
-	/* setup HSCX base addr */
-	
-	HSCX_A_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x180);
-	HSCX_B_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x1c0);
-
-	/* allocate our irq */
-
-	if(!(sc->sc_resources.irq =
-			bus_alloc_resource_any(dev, SYS_RES_IRQ,
-					       &sc->sc_resources.irq_rid,
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not allocate irq for Teles S0/8!\n",unit);
-
-	 	bus_release_resource(dev,SYS_RES_MEMORY,
-				     sc->sc_resources.mem_rid,
-				     sc->sc_resources.mem);
-
-		sc->sc_resources.mem = 0;
-		return ENXIO;
-	}
-
-	/* get the irq number */
-
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-	
-	/* check IRQ validity */
-
-	switch(sc->sc_irq)
-	{
-		case 2:
-		case 9:		/* XXX */
-		case 3:
-		case 4:
-		case 5:
-		case 6:
-		case 7:
-			break;
-			
-		default:
-			printf("isic%d: Error, invalid IRQ [%d] specified for Teles S0/8!\n",
-				unit, sc->sc_irq);
-			bus_release_resource(dev,SYS_RES_IRQ,
-			                     sc->sc_resources.irq_rid,
-			                     sc->sc_resources.irq);
-			sc->sc_resources.irq = 0;
-		 	bus_release_resource(dev,SYS_RES_MEMORY,
-					     sc->sc_resources.mem_rid,
-					     sc->sc_resources.mem);
-			sc->sc_resources.mem = 0;
-			return(ENXIO);
-			break;
-	}
-
-	/* register interupt routine */
-
-	bus_setup_intr(dev, sc->sc_resources.irq,
-			INTR_TYPE_NET,
-			(void(*)(void *))(isicintr),
-			sc, &ih);
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_s08 - attach Teles S0/8 and compatibles
- *---------------------------------------------------------------------------*/
-int
-isic_attach_s08(device_t dev)
-{
-	struct l1_softc *sc = &l1_sc[device_get_unit(dev)];
-	bus_space_tag_t t = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.mem);
-
-	/* set card off */
-
-	bus_space_write_1(t, h, 0x80, 0);
-
-	DELAY(SEC_DELAY / 5);
-
-	/* set card on */
-
-	bus_space_write_1(t, h, 0x80, 1);
-
-	DELAY(SEC_DELAY / 5);
-
-	return 0;
-}
-
-#endif /* defined(TEL_S0_8) */
--- sys/i4b/layer1/isic/i4b_isic_isa.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_isic_isa.c - ISA bus interface
- *	==================================
- *      last edit-date: [Wed Jan 24 09:30:19 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_isic_isa.c,v 1.9 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-
-#include <sys/bus.h>
-#include <isa/isavar.h>
-
-struct l1_softc l1_sc[ISIC_MAXUNIT];
-
-static int isic_isa_probe(device_t dev);
-static int isic_isa_attach(device_t dev);
-
-static device_method_t isic_methods[] = {
-	DEVMETHOD(device_probe,		isic_isa_probe),
-	DEVMETHOD(device_attach,	isic_isa_attach),
-	{ 0, 0 }
-};
-
-static driver_t isic_driver = {
-	"isic",
-	isic_methods,
-	0
-};
-
-static devclass_t isic_devclass;
-
-DRIVER_MODULE(isic, isa, isic_driver, isic_devclass, 0, 0);
-
-/*---------------------------------------------------------------------------*
- *	probe for ISA non-PnP cards
- *---------------------------------------------------------------------------*/
-static int
-isic_isa_probe(device_t dev)
-{
-	int ret = ENXIO;
-
-	if(isa_get_vendorid(dev))	/* no PnP probes here */
-		return ENXIO;
-
-	switch(device_get_flags(dev))
-	{
-#ifdef TEL_S0_16
-		case CARD_TYPEP_16:
-			ret = isic_probe_s016(dev);
-			break;
-#endif
-
-#ifdef TEL_S0_8
-		case CARD_TYPEP_8:
-			ret = isic_probe_s08(dev);
-			break;
-#endif
-
-#ifdef ELSA_PCC16
-		case CARD_TYPEP_PCC16:
-			ret = isic_probe_Epcc16(dev);
-			break;
-#endif
-
-#ifdef TEL_S0_16_3
-		case CARD_TYPEP_16_3:
-			ret = isic_probe_s0163(dev);		
-			break;
-#endif
-
-#ifdef AVM_A1
-		case CARD_TYPEP_AVMA1:
-			ret = isic_probe_avma1(dev);
-			break;
-#endif
-
-#ifdef USR_STI
-		case CARD_TYPEP_USRTA:
-			ret = isic_probe_usrtai(dev);		
-			break;
-#endif
-
-#ifdef ITKIX1
-		case CARD_TYPEP_ITKIX1:
-			ret = isic_probe_itkix1(dev);
-			break;
-#endif
-
-		default:
-			printf("isic%d: probe, unknown flag: %d\n",
-				device_get_unit(dev), device_get_flags(dev));
-			break;
-	}
-	return(ret);
-}
-
-/*---------------------------------------------------------------------------*
- *	attach for ISA non-PnP cards
- *---------------------------------------------------------------------------*/
-static int
-isic_isa_attach(device_t dev)
-{
-	int ret = ENXIO;
-
-	struct l1_softc *sc = &l1_sc[device_get_unit(dev)];
-
-	sc->sc_unit = device_get_unit(dev);
-	
-	/* card dependent setup */
-
-	switch(sc->sc_cardtyp)
-	{
-#ifdef TEL_S0_16
-		case CARD_TYPEP_16:
-			ret = isic_attach_s016(dev);
-			break;
-#endif
-
-#ifdef TEL_S0_8
-		case CARD_TYPEP_8:
-			ret = isic_attach_s08(dev);
-			break;
-#endif
-
-#ifdef ELSA_PCC16
-		case CARD_TYPEP_PCC16:
-			ret = isic_attach_Epcc16(dev);
-			break;
-#endif
-
-#ifdef TEL_S0_16_3
-		case CARD_TYPEP_16_3:
-			ret = isic_attach_s0163(dev);
-			break;
-#endif
-
-#ifdef AVM_A1
-		case CARD_TYPEP_AVMA1:
-			ret = isic_attach_avma1(dev);
-			break;
-#endif
-
-#ifdef USR_STI
-		case CARD_TYPEP_USRTA:
-			ret = isic_attach_usrtai(dev);		
-			break;
-#endif
-
-#ifdef ITKIX1
-		case CARD_TYPEP_ITKIX1:
-			ret = isic_attach_itkix1(dev);
-			break;
-#endif
-
-		default:
-			printf("isic%d: attach, unknown flag: %d\n",
-				device_get_unit(dev), device_get_flags(dev));
-			break;
-	}
-
-	if(ret)
-		return(ret);
-		
-	ret = isic_attach_common(dev);
-
-	return(ret);
-}
--- sys/i4b/layer1/isic/i4b_l1.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l1.c - isdn4bsd layer 1 handler
- *	-----------------------------------
- *      last edit-date: [Wed Jan 24 09:12:03 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_l1.c,v 1.8 2005/01/06 22:18:20 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-DATA-REQUEST
- *	=========================
- *
- *	parms:
- *		unit		physical interface unit number
- *		m		mbuf containing L2 frame to be sent out
- *		freeflag	MBUF_FREE: free mbuf here after having sent
- *						it out
- *				MBUF_DONTFREE: mbuf is freed by Layer 2
- *	returns:
- *		==0	fail, nothing sent out
- *		!=0	ok, frame sent out
- *
- *---------------------------------------------------------------------------*/
-int
-isic_ph_data_req(int unit, struct mbuf *m, int freeflag)
-{
-	u_char cmd;
-	int s;
-	struct l1_softc *sc = &l1_sc[unit];
-
-#ifdef NOTDEF
-	NDBGL1(L1_PRIM, "unit %d, freeflag=%d", unit, freeflag);
-#endif
-
-	if(m == NULL)			/* failsafe */
-		return (0);
-
-	s = SPLI4B();
-
-	if(sc->sc_I430state == ST_F3)	/* layer 1 not running ? */
-	{
-		NDBGL1(L1_I_ERR, "still in state F3!");
-		isic_ph_activate_req(unit);
-	}
-
-	if(sc->sc_state & ISAC_TX_ACTIVE)
-	{
-		if(sc->sc_obuf2 == NULL)
-		{
-			sc->sc_obuf2 = m;		/* save mbuf ptr */
-
-			if(freeflag)
-				sc->sc_freeflag2 = 1;	/* IRQ must mfree */
-			else
-				sc->sc_freeflag2 = 0;	/* IRQ must not mfree */
-
-			NDBGL1(L1_I_MSG, "using 2nd ISAC TX buffer, state = %s", isic_printstate(sc));
-
-			if(sc->sc_trace & TRACE_D_TX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0ISICUNIT(unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_TE;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-			}
-			splx(s);
-			return(1);
-		}
-
-		NDBGL1(L1_I_ERR, "No Space in TX FIFO, state = %s", isic_printstate(sc));
-	
-		if(freeflag == MBUF_FREE)
-			i4b_Dfreembuf(m);			
-	
-		splx(s);
-		return (0);
-	}
-
-	if(sc->sc_trace & TRACE_D_TX)
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0ISICUNIT(unit);
-		hdr.type = TRC_CH_D;
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_dcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-	}
-	
-	sc->sc_state |= ISAC_TX_ACTIVE;	/* set transmitter busy flag */
-
-	NDBGL1(L1_I_MSG, "ISAC_TX_ACTIVE set");
-
-	sc->sc_freeflag = 0;		/* IRQ must NOT mfree */
-	
-	ISAC_WRFIFO(m->m_data, min(m->m_len, ISAC_FIFO_LEN)); /* output to TX fifo */
-
-	if(m->m_len > ISAC_FIFO_LEN)	/* message > 32 bytes ? */
-	{
-		sc->sc_obuf = m;	/* save mbuf ptr */
-		sc->sc_op = m->m_data + ISAC_FIFO_LEN; 	/* ptr for irq hdl */
-		sc->sc_ol = m->m_len - ISAC_FIFO_LEN;	/* length for irq hdl */
-
-		if(freeflag)
-			sc->sc_freeflag = 1;	/* IRQ must mfree */
-		
-		cmd = ISAC_CMDR_XTF;
-	}
-	else
-	{
-		sc->sc_obuf = NULL;
-		sc->sc_op = NULL;
-		sc->sc_ol = 0;
-
-		if(freeflag)
-			i4b_Dfreembuf(m);
-
-		cmd = ISAC_CMDR_XTF | ISAC_CMDR_XME;
-  	}
-
-	ISAC_WRITE(I_CMDR, cmd);
-	ISACCMDRWRDELAY();
-
-	splx(s);
-	
-	return(1);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-ACTIVATE-REQUEST
- *	=============================
- *
- *	parms:
- *		unit	physical interface unit number
- *
- *	returns:
- *		==0	
- *		!=0	
- *
- *---------------------------------------------------------------------------*/
-int
-isic_ph_activate_req(int unit)
-{
-	struct l1_softc *sc = &l1_sc[unit];
-	NDBGL1(L1_PRIM, "unit %d", unit);
-	isic_next_state(sc, EV_PHAR);
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	command from the upper layers
- *---------------------------------------------------------------------------*/
-int
-isic_mph_command_req(int unit, int command, void *parm)
-{
-	struct l1_softc *sc = &l1_sc[unit];
-
-	switch(command)
-	{
-		case CMR_DOPEN:		/* daemon running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DOPEN", unit);
-			sc->sc_enabled = 1;			
-			break;
-			
-		case CMR_DCLOSE:	/* daemon not running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DCLOSE", unit);
-			sc->sc_enabled = 0;
-			break;
-
-		case CMR_SETTRACE:
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_SETTRACE, parm = %d", unit, (unsigned int)parm);
-			sc->sc_trace = (unsigned int)parm;
-			break;
-		
-		case CMR_GCST:
-			{
-			struct chipstat *cst;
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_GCST, parm = %d", unit, (unsigned int)parm);
-                        cst = (struct chipstat *)parm;
-                        cst->driver_type = L1DRVR_ISIC;
-			cst->stats.hscxstat.unit = sc->sc_unit;
-			cst->stats.hscxstat.chan = cst->driver_bchannel;
-			cst->stats.hscxstat.vfr = sc->sc_chan[cst->driver_bchannel].stat_VFR;
-			cst->stats.hscxstat.rdo = sc->sc_chan[cst->driver_bchannel].stat_RDO;
-			cst->stats.hscxstat.crc = sc->sc_chan[cst->driver_bchannel].stat_CRC;
-			cst->stats.hscxstat.rab = sc->sc_chan[cst->driver_bchannel].stat_RAB;
-			cst->stats.hscxstat.xdu = sc->sc_chan[cst->driver_bchannel].stat_XDU;
-			cst->stats.hscxstat.rfo = sc->sc_chan[cst->driver_bchannel].stat_RFO;
-			break;
-			}
-		default:
-			NDBGL1(L1_ERROR, "ERROR, unknown command = %d, unit = %d, parm = %d", command, unit, (unsigned int)parm);
-			break;
-	}
-
-	return(0);
-}
--- sys/i4b/layer1/isic/i4b_isic_ext.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------*
- *
- *	i4b_l1.h - isdn4bsd layer 1 header file
- *	---------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/isic/i4b_isic_ext.h,v 1.3 2005/01/06 22:18:20 imp Exp $
- *
- *      last edit-date: [Wed Jan 24 09:11:12 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_ISIC_EXT_H_
-#define _I4B_ISIC_EXT_H_
-
-#include <i4b/include/i4b_l3l4.h>
-
-int isic_ph_data_req(int unit, struct mbuf *m, int freeflag);
-int isic_ph_activate_req(int unit);
-int isic_mph_command_req(int unit, int command, void *parm);
-
-void isic_set_linktab(int unit, int channel, drvr_link_t *dlt);
-isdn_link_t *isic_ret_linktab(int unit, int channel);
-
-#endif /* _I4B_ISIC_H_ */
--- sys/i4b/layer1/isic/i4b_siemens_isurf.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/*-
- *   Copyright (c) 1999, 2000 Udo Schweigert. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	Siemens I-Surf 2.0 PnP specific routines for isic driver
- *	--------------------------------------------------------
- *	Based on ELSA Quickstep 1000pro PCI driver (i4b_elsa_qs1p.c)
- *	In case of trouble please contact Udo Schweigert <ust at cert.siemens.de>
- *
- *      last edit-date: [Wed Jan 24 09:13:25 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_siemens_isurf.c,v 1.8 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(SIEMENS_ISURF2)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_ipac.h>
-
-/* masks for register encoded in base addr */
-
-#define SIE_ISURF_BASE_MASK		0x0ffff
-#define SIE_ISURF_OFF_MASK		0xf0000
-
-/* register id's to be encoded in base addr */
-
-#define SIE_ISURF_IDISAC		0x00000
-#define SIE_ISURF_IDHSCXA		0x10000
-#define SIE_ISURF_IDHSCXB		0x20000
-#define SIE_ISURF_IDIPAC		0x40000
-
-/* offsets from base address */
-
-#define SIE_ISURF_OFF_ALE		0x00
-#define SIE_ISURF_OFF_RW		0x01
-
-/*---------------------------------------------------------------------------*
- *      Siemens I-Surf 2.0 PnP ISAC get fifo routine
- *---------------------------------------------------------------------------*/
-static void 
-siemens_isurf_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_ISAC_OFF);
-			bus_space_read_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXA_OFF);
-			bus_space_read_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXB_OFF);
-			bus_space_read_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      Siemens I-Surf 2.0 PnP ISAC put fifo routine
- *---------------------------------------------------------------------------*/
-static void 
-siemens_isurf_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_ISAC_OFF);
-			bus_space_write_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXA_OFF);
-			bus_space_write_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXB_OFF);
-			bus_space_write_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      Siemens I-Surf 2.0 PnP ISAC put register routine
- *---------------------------------------------------------------------------*/
-static void
-siemens_isurf_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_ISAC_OFF);
-			bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXA_OFF);
-			bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXB_OFF);
-			bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
-			break;
-		case ISIC_WHAT_IPAC:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_IPAC_OFF);
-			bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Siemens I-Surf 2.0 PnP ISAC get register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-siemens_isurf_read_reg(struct l1_softc *sc,int what,bus_size_t reg)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_ISAC_OFF);
-			return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXA_OFF);
-			return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXB_OFF);
-			return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
-		case ISIC_WHAT_IPAC:
-			bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_IPAC_OFF);
-			return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
-		default:
-			return 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_siemens_isurf - attach for Siemens I-Surf 2.0 PnP
- *---------------------------------------------------------------------------*/
-int
-isic_attach_siemens_isurf(device_t dev)
-{
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];	
-	
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = siemens_isurf_read_reg;
-	sc->writereg = siemens_isurf_write_reg;
-
-	sc->readfifo = siemens_isurf_read_fifo;
-	sc->writefifo = siemens_isurf_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_SIE_ISURF2;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	/* setup chip type = IPAC ! */
-	
-	sc->sc_ipac = 1;
-	sc->sc_bfifolen = IPAC_BFIFO_LEN;
-
-	/* enable hscx/isac irq's */
-
-	IPAC_WRITE(IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
-
-	IPAC_WRITE(IPAC_ACFG, 0);	/* outputs are open drain */
-	IPAC_WRITE(IPAC_AOE,		/* aux 5..2 are inputs, 7, 6 outputs */
-		(IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2));
-	IPAC_WRITE(IPAC_ATX, 0xff);	/* set all output lines high */
-
-	return(0);
-}
-#endif /* defined(SIEMENS_ISURF2) */
--- sys/i4b/layer1/isic/i4b_ipac.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_ipac.h - definitions for the Siemens IPAC PSB2115 chip
- *	==========================================================
- *
- * $FreeBSD: src/sys/i4b/layer1/isic/i4b_ipac.h,v 1.3 2005/01/06 22:18:20 imp Exp $
- *
- *      last edit-date: [Wed Jan 24 09:10:09 2001]
- *
- *---------------------------------------------------------------------------
- */
- 
-#ifndef _I4B_IPAC_H_
-#define _I4B_IPAC_H_
-
-#define IPAC_BFIFO_LEN	64	/* 64 bytes B-channel FIFO on chip	*/
-
-#define IPAC_HSCXA_OFF	0x00
-#define IPAC_HSCXB_OFF	0x40
-#define IPAC_ISAC_OFF	0x80
-#define IPAC_IPAC_OFF	0xc0
-
-/* chip version */
-
-#define	IPAC_V11	0x01	/* IPAC Version 1.1 */
-#define	IPAC_V12	0x02	/* IPAC Version 1.2 */
-
-/*
- * definitions of registers and bits for the IPAC ISDN chip.
- */
- 
-typedef struct ipac_reg {
-
-	/* most registers can be read/written, but have different names */
-	/* so define a union with read/write names to make that clear */
-
-	union {
-		struct {
-			unsigned char ipac_conf;
-			unsigned char ipac_ista;
-			unsigned char ipac_id;
-			unsigned char ipac_acfg;
-			unsigned char ipac_aoe;
-			unsigned char ipac_arx;
-			unsigned char ipac_pita1;
-			unsigned char ipac_pita2;
-			unsigned char ipac_pota1;
-			unsigned char ipac_pota2;
-			unsigned char ipac_pcfg;
-			unsigned char ipac_scfg;
-			unsigned char ipac_timr2;
-		} ipac_r;
-		struct {
-			unsigned char ipac_conf;
-			unsigned char ipac_mask;
-			unsigned char ipac_dummy;
-			unsigned char ipac_acfg;
-			unsigned char ipac_aoe;
-			unsigned char ipac_atx;
-			unsigned char ipac_pita1;
-			unsigned char ipac_pita2;
-			unsigned char ipac_pota1;
-			unsigned char ipac_pota2;
-			unsigned char ipac_pcfg;
-			unsigned char ipac_scfg;
-			unsigned char ipac_timr2;
-		} ipac_w;
-	} ipac_rw;
-} ipac_reg_t;
-
-#define REG_OFFSET(type, field) (int)(&(((type *)0)->field))
-
-/* IPAC read registers */
-
-#define IPAC_CONF  REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_conf)
-#define IPAC_ISTA  REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_ista)
-#define IPAC_ID    REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_id)
-#define IPAC_ACFG  REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_acfg)
-#define IPAC_AOE   REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_aoe)
-#define IPAC_ARX   REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_arx)
-#define IPAC_PITA1 REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_pita1)
-#define IPAC_PITA2 REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_pita2)
-#define IPAC_POTA1 REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_pota1)
-#define IPAC_POTA2 REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_pota2)
-#define IPAC_PCFG  REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_pcfg)
-#define IPAC_SCFG  REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_scfg)
-#define IPAC_TIMR2 REG_OFFSET(ipac_reg_t, ipac_rw.ipac_r.ipac_timr2)
-
-/* IPAC write registers */
-
-#define IPAC_MASK  REG_OFFSET(ipac_reg_t, ipac_rw.ipac_w.ipac_mask)
-#define IPAC_ATX   REG_OFFSET(ipac_reg_t, ipac_rw.ipac_w.ipac_atx)
-
-/* register bits */
-
-#define IPAC_CONF_AMP  0x80
-#define IPAC_CONF_CFS  0x40
-#define IPAC_CONF_TEM  0x20
-#define IPAC_CONF_PDS  0x10
-#define IPAC_CONF_IDH  0x08
-#define IPAC_CONF_SGO  0x04
-#define IPAC_CONF_ODS  0x02
-#define IPAC_CONF_IOF  0x01
-
-#define IPAC_ISTA_INT1 0x80
-#define IPAC_ISTA_INT0 0x40
-#define IPAC_ISTA_ICD  0x20
-#define IPAC_ISTA_EXD  0x10
-#define IPAC_ISTA_ICA  0x08
-#define IPAC_ISTA_EXA  0x04
-#define IPAC_ISTA_ICB  0x02
-#define IPAC_ISTA_EXB  0x01
-
-#define IPAC_MASK_INT1 0x80
-#define IPAC_MASK_INT0 0x40
-#define IPAC_MASK_ICD  0x20
-#define IPAC_MASK_EXD  0x10
-#define IPAC_MASK_ICA  0x08
-#define IPAC_MASK_EXA  0x04
-#define IPAC_MASK_ICB  0x02
-#define IPAC_MASK_EXB  0x01
-
-#define IPAC_ACFG_OD7  0x80
-#define IPAC_ACFG_OD6  0x40
-#define IPAC_ACFG_OD5  0x20
-#define IPAC_ACFG_OD4  0x10
-#define IPAC_ACFG_OD3  0x08
-#define IPAC_ACFG_OD2  0x04
-#define IPAC_ACFG_EL1  0x02
-#define IPAC_ACFG_EL2  0x01
-
-#define IPAC_AOE_OE7   0x80
-#define IPAC_AOE_OE6   0x40
-#define IPAC_AOE_OE5   0x20
-#define IPAC_AOE_OE4   0x10
-#define IPAC_AOE_OE3   0x08
-#define IPAC_AOE_OE2   0x04
-
-#define IPAC_ARX_AR7   0x80
-#define IPAC_ARX_AR6   0x40
-#define IPAC_ARX_AR5   0x20
-#define IPAC_ARX_AR4   0x10
-#define IPAC_ARX_AR3   0x08
-#define IPAC_ARX_AR2   0x04
-
-#define IPAC_ATX_AT7   0x80
-#define IPAC_ATX_AT6   0x40
-#define IPAC_ATX_AT5   0x20
-#define IPAC_ATX_AT4   0x10
-#define IPAC_ATX_AT3   0x08
-#define IPAC_ATX_AT2   0x04
-
-#define IPAC_PITA1_ENA  0x80
-#define IPAC_PITA1_DUDD 0x40
-
-#define IPAC_PITA2_ENA  0x80
-#define IPAC_PITA2_DUDD 0x40
-
-#define IPAC_POTA1_ENA  0x80
-#define IPAC_POTA1_DUDD 0x40
-
-#define IPAC_POTA2_ENA  0x80
-#define IPAC_POTA2_DUDD 0x40
-
-#define IPAC_PCFG_DPS  0x80
-#define IPAC_PCFG_ACL  0x40
-#define IPAC_PCFG_LED  0x20
-#define IPAC_PCFG_PLD  0x10
-#define IPAC_PCFG_FBS  0x08
-#define IPAC_PCFG_CSL2 0x04
-#define IPAC_PCFG_CSL1 0x02
-#define IPAC_PCFG_CSL0 0x01
-
-#define IPAC_SCFG_PRI  0x80
-#define IPAC_SCFG_TXD  0x40
-#define IPAC_SCFG_TLEN 0x20
-
-#define IPAC_TIMR2_TMD 0x80
-
-#endif /* _I4B_IPAC_H_ */
--- sys/i4b/layer1/isic/i4b_hscx.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/*-
- *   Copyright (c) 1996, 2000 Gary Jennejohn. All rights reserved. 
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/isic/i4b_hscx.h,v 1.3 2005/01/06 22:18:20 imp Exp $
- *
- *      last edit-date: [Wed Jan 24 09:09:51 2001]
- *
- *---------------------------------------------------------------------------*/
- 
-#ifndef I4B_HSCX_H_
-#define I4B_HSCX_H_
-
-enum HSCX_VERSIONS {
-	HSCX_VA1,	/* 82525 A1  */
-	HSCX_UNKN1,	/* unknown 1 */	
-	HSCX_VA2,	/* 82525 A2  */
-	HSCX_UNKN3,	/* unknown 3 */
-	HSCX_VA3,	/* 82525 A3  */
-	HSCX_V21,	/* 82525 2.1 */	
-	HSCX_UNKN	/* unknown version */
-};
-
-#define HSCX_CH_A	0	/* channel A */
-#define HSCX_CH_B	1	/* channel B */
-
-#define HSCX_FIFO_LEN	32	/* 32 bytes FIFO on chip */
-
-/*
- * definitions of registers and bits for the HSCX ISDN chip.
- */
- 
-typedef struct hscx_reg {
-
-	/* 32 byte deep FIFO always first */
-
-	unsigned char hscx_fifo [HSCX_FIFO_LEN];
-
-	/* most registers can be read/written, but have different names */
-	/* so define a union with read/write names to make that clear */
-
-	union {
-		struct {
-			unsigned char hscx_ista;
-			unsigned char hscx_star;
-			unsigned char hscx_mode;
-			unsigned char hscx_timr;
-			unsigned char hscx_exir;
-			unsigned char hscx_rbcl;
-			unsigned char dummy_26;
-			unsigned char hscx_rsta;
-			unsigned char hscx_ral1;
-			unsigned char hscx_rhcr;
-			unsigned char dummy_2a;
-			unsigned char dummy_2b;
-			unsigned char hscx_ccr2;
-			unsigned char hscx_rbch;
-			unsigned char hscx_vstr;
-			unsigned char hscx_ccr;
-			unsigned char dummy_30;
-			unsigned char dummy_31;
-			unsigned char dummy_32;
-			unsigned char dummy_33;
-		} hscx_r;
-		struct {
-			unsigned char hscx_mask;
-			unsigned char hscx_cmdr;
-			unsigned char hscx_mode;
-			unsigned char hscx_timr;
-			unsigned char hscx_xad1;
-			unsigned char hscx_xad2;
-			unsigned char hscx_rah1;
-			unsigned char hscx_rah2;
-			unsigned char hscx_ral1;
-			unsigned char hscx_ral2;
-			unsigned char hscx_xbcl;
-			unsigned char hscx_bgr;
-			unsigned char hscx_ccr2;
-			unsigned char hscx_xbch;
-			unsigned char hscx_rlcr;
-			unsigned char hscx_ccr1;
-			unsigned char hscx_tsax;
-			unsigned char hscx_tsar;
-			unsigned char hscx_xccr;
-			unsigned char hscx_rccr;
-		} hscx_w;
-	} hscx_rw;
-} hscx_reg_t;
-
-#define REG_OFFSET(type, field) (int)(&(((type *)0)->field))
-
-/* HSCX read registers */
-
-#define h_ista hscx_rw.hscx_r.hscx_ista
-#define H_ISTA REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_ista)
-#define h_star hscx_rw.hscx_r.hscx_star
-#define H_STAR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_star)
-#define h_mode hscx_rw.hscx_r.hscx_mode
-#define H_MODE REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_mode)
-#define h_timr hscx_rw.hscx_r.hscx_timr
-#define H_TIMR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_timr)
-#define h_exir hscx_rw.hscx_r.hscx_exir
-#define H_EXIR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_exir)
-#define h_rbcl hscx_rw.hscx_r.hscx_rbcl
-#define H_RBCL REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_rbcl)
-#define h_rsta hscx_rw.hscx_r.hscx_rsta
-#define H_RSTA REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_rsta)
-#define h_ral1 hscx_rw.hscx_r.hscx_ral1
-#define H_RAL1 REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_ral1)
-#define h_rhcr hscx_rw.hscx_r.hscx_rhcr
-#define H_RHCR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_rhcr)
-#define h_ccr2 hscx_rw.hscx_r.hscx_ccr2
-#define H_CCR2 REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_ccr2)
-#define h_rbch hscx_rw.hscx_r.hscx_rbch
-#define H_RBCH REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_rbch)
-#define h_vstr hscx_rw.hscx_r.hscx_vstr
-#define H_VSTR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_vstr)
-#define h_ccr hscx_rw.hscx_r.hscx_ccr
-#define H_CCR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_r.hscx_ccr)
-
-/* HSCX write registers - for hscx_mode, hscx_timr, hscx_ral1, hscx_ccr2 */
-/* see read registers */
-
-#define h_mask hscx_rw.hscx_w.hscx_mask
-#define H_MASK REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_mask)
-#define h_cmdr hscx_rw.hscx_w.hscx_cmdr
-#define H_CMDR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_cmdr)
-#define h_xad1 hscx_rw.hscx_w.hscx_xad1
-#define H_XAD1 REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_xad1)
-#define h_xad2 hscx_rw.hscx_w.hscx_xad2
-#define H_XAD2 REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_xad2)
-#define h_rah1 hscx_rw.hscx_w.hscx_rah1
-#define H_RAH1 REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_rah1)
-#define h_rah2 hscx_rw.hscx_w.hscx_rah2
-#define H_RAH2 REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_rah2)
-#define h_ral2 hscx_rw.hscx_w.hscx_ral2
-#define H_RAL2 REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_ral2)
-#define h_xbcl hscx_rw.hscx_w.hscx_xbcl
-#define H_XBCL REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_xbcl)
-#define h_bgr hscx_rw.hscx_w.hscx_bgr
-#define H_BGR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_bgr)
-#define h_xbch hscx_rw.hscx_w.hscx_xbch
-#define H_XBCH REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_xbch)
-#define h_rlcr hscx_rw.hscx_w.hscx_rlcr
-#define H_RLCR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_rlcr)
-#define h_ccr1 hscx_rw.hscx_w.hscx_ccr1
-#define H_CCR1 REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_ccr1)
-#define h_tsax hscx_rw.hscx_w.hscx_tsax
-#define H_TSAX REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_tsax)
-#define h_tsar hscx_rw.hscx_w.hscx_tsar
-#define H_TSAR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_tsar)
-#define h_xccr hscx_rw.hscx_w.hscx_xccr
-#define H_XCCR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_xccr)
-#define h_rccr hscx_rw.hscx_w.hscx_rccr
-#define H_RCCR REG_OFFSET(hscx_reg_t, hscx_rw.hscx_w.hscx_rccr)
-
-#define HSCX_ISTA_RME  0x80
-#define HSCX_ISTA_RPF  0x40
-#define HSCX_ISTA_RSC  0x20
-#define HSCX_ISTA_XPR  0x10
-#define HSCX_ISTA_TIN  0x08
-#define HSCX_ISTA_ICA  0x04
-#define HSCX_ISTA_EXA  0x02
-#define HSCX_ISTA_EXB  0x01
-
-#define HSCX_MASK_RME  0x80
-#define HSCX_MASK_RPF  0x40
-#define HSCX_MASK_RSC  0x20
-#define HSCX_MASK_XPR  0x10
-#define HSCX_MASK_TIN  0x08
-#define HSCX_MASK_ICA  0x04
-#define HSCX_MASK_EXA  0x02
-#define HSCX_MASK_EXB  0x01
-
-#define HSCX_EXIR_XMR  0x80
-#define HSCX_EXIR_XDU  0x40
-#define HSCX_EXIR_PCE  0x20
-#define HSCX_EXIR_RFO  0x10
-#define HSCX_EXIR_CSC  0x08
-#define HSCX_EXIR_RFS  0x04
-
-/* the other bits are always 0 */
-
-#define HSCX_STAR_XDOV 0x80
-#define HSCX_STAR_XFW  0x40
-#define HSCX_STAR_XRNR 0x20
-#define HSCX_STAR_RRNR 0x10
-#define HSCX_STAR_RLI  0x08
-#define HSCX_STAR_CEC  0x04
-#define HSCX_STAR_CTS  0x02
-#define HSCX_STAR_WFA  0x01
-
-#define HSCX_CMDR_RMC  0x80
-#define HSCX_CMDR_RHR  0x40
-/* also known as XREP in transparent mode */
-#define HSCX_CMDR_RNR  0x20
-#define HSCX_CMDR_STI  0x10
-#define HSCX_CMDR_XTF  0x08
-#define HSCX_CMDR_XIF  0x04
-#define HSCX_CMDR_XME  0x02
-#define HSCX_CMDR_XRES 0x01
-
-#define HSCX_MODE_MDS1 0x80
-#define HSCX_MODE_MDS0 0x40
-#define HSCX_MODE_ADM  0x20
-#define HSCX_MODE_TMD  0x10
-#define HSCX_MODE_RAC  0x08
-#define HSCX_MODE_RTS  0x04
-#define HSCX_MODE_TRS  0x02
-#define HSCX_MODE_TLP  0x01
-
-#define HSCX_RSTA_VFR  0x80
-#define HSCX_RSTA_RDO  0x40
-#define HSCX_RSTA_CRC  0x20
-#define HSCX_RSTA_RAB  0x10
-#define HSCX_RSTA_HA1  0x08
-#define HSCX_RSTA_HA0  0x04
-#define HSCX_RSTA_CR   0x02
-#define HSCX_RSTA_LA   0x01
-
-#define HSCX_RSTA_MASK 0xf0	/* the interesting ones */
-
-/* only used in DMA mode */
-#define HSCX_XBCH_DMA  0x80
-#define HSCX_XBCH_NRM  0x40
-#define HSCX_XBCH_CAS  0x20
-#define HSCX_XBCH_XC   0x10
-/* the rest are bits 11 thru 8 of the byte count */
-
-#define HSCX_RBCH_DMA  0x80
-#define HSCX_RBCH_NRM  0x40
-#define HSCX_RBCH_CAS  0x20
-#define HSCX_RBCH_OV   0x10
-/* the rest are bits 11 thru 8 of the byte count */
-
-#define HSCX_VSTR_CD   0x80
-/* bits 6 thru 4 are 0 */
-/* bits 3 thru 0 are the version number */
-
-#define HSCX_RLCR_RC   0x80
-/* the rest of the bits are used to set the received length */
-
-#define HSCX_CCR1_PU   0x80
-/* bits 6 and 5 are SC1 SC0 */
-#define HSCX_CCR1_ODS  0x10
-#define HSCX_CCR1_ITF  0x08
-#define HSCX_CCR1_CM2  0x04
-#define HSCX_CCR1_CM1  0x02
-#define HSCX_CCR1_CM0  0x01
-
-/* for clock mode 5 */
-#define HSCX_CCR2_SOC2 0x80
-#define HSCX_CCR2_SOC1 0x40
-#define HSCX_CCR2_XCS0 0x20
-#define HSCX_CCR2_RCS0 0x10
-#define HSCX_CCR2_TIO  0x08
-#define HSCX_CCR2_CIE  0x04
-#define HSCX_CCR2_RIE  0x02
-#define HSCX_CCR2_DIV  0x01
-
-/* bits 7 thru 2 are TSNX */
-#define HSCX_TSAX_XCS2 0x02
-#define HSCX_TSAX_XCS1 0x01
-
-/* bits 7 thru 2 are TSNR */
-#define HSCX_TSAR_RCS2 0x02
-#define HSCX_TSAR_RCS1 0x01
-
-#endif /* I4B_HSCX_H_ */
--- sys/i4b/layer1/isic/i4b_isac.c
+++ /dev/null
@@ -1,655 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_isac.c - i4b siemens isdn chipset driver ISAC handler
- *	---------------------------------------------------------
- *      last edit-date: [Wed Jan 24 09:10:36 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_isac.c,v 1.8 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-static u_char isic_isac_exir_hdlr(register struct l1_softc *sc, u_char exir);
-static void isic_isac_ind_hdlr(register struct l1_softc *sc, int ind);
-
-/*---------------------------------------------------------------------------*
- *	ISAC interrupt service routine
- *---------------------------------------------------------------------------*/
-void
-isic_isac_irq(struct l1_softc *sc, int ista)
-{
-	register u_char c = 0;
-	NDBGL1(L1_F_MSG, "unit %d: ista = 0x%02x", sc->sc_unit, ista);
-
-	if(ista & ISAC_ISTA_EXI)	/* extended interrupt */
-	{
-		c |= isic_isac_exir_hdlr(sc, ISAC_READ(I_EXIR));
-	}
-	
-	if(ista & ISAC_ISTA_RME)	/* receive message end */
-	{
-		register int rest;
-		u_char rsta;
-
-		/* get rx status register */
-		
-		rsta = ISAC_READ(I_RSTA);
-
-		if((rsta & ISAC_RSTA_MASK) != 0x20)
-		{
-			int error = 0;
-			
-			if(!(rsta & ISAC_RSTA_CRC))	/* CRC error */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: CRC error", sc->sc_unit);
-			}
-	
-			if(rsta & ISAC_RSTA_RDO)	/* ReceiveDataOverflow */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Data Overrun error", sc->sc_unit);
-			}
-	
-			if(rsta & ISAC_RSTA_RAB)	/* ReceiveABorted */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Receive Aborted error", sc->sc_unit);
-			}
-
-			if(error == 0)			
-				NDBGL1(L1_I_ERR, "unit %d: RME unknown error, RSTA = 0x%02x!", sc->sc_unit, rsta);
-
-			i4b_Dfreembuf(sc->sc_ibuf);
-
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-
-			ISAC_WRITE(I_CMDR, ISAC_CMDR_RMC|ISAC_CMDR_RRES);
-			ISACCMDRWRDELAY();
-
-			return;
-		}
-
-		rest = (ISAC_READ(I_RBCL) & (ISAC_FIFO_LEN-1));
-
-		if(rest == 0)
-			rest = ISAC_FIFO_LEN;
-
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(rest)) != NULL)
-				sc->sc_ib = sc->sc_ibuf->m_data;
-			else
-				panic("isic_isac_irq: RME, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - rest))
-		{
-			ISAC_RDFIFO(sc->sc_ib, rest);
-			sc->sc_ilen += rest;
-			
-			sc->sc_ibuf->m_pkthdr.len =
-				sc->sc_ibuf->m_len = sc->sc_ilen;
-
-			if(sc->sc_trace & TRACE_D_RX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0ISICUNIT(sc->sc_unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_NT;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, sc->sc_ibuf->m_len, sc->sc_ibuf->m_data);
-			}
-
-			c |= ISAC_CMDR_RMC;
-
-			if(sc->sc_enabled &&
-			   (ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S))
-			{
-				i4b_l1_ph_data_ind(L0ISICUNIT(sc->sc_unit), sc->sc_ibuf);
-			}
-			else
-			{
-				i4b_Dfreembuf(sc->sc_ibuf);
-			}
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RME, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-		}
-
-		sc->sc_ibuf = NULL;
-		sc->sc_ib = NULL;
-		sc->sc_ilen = 0;
-	}
-
-	if(ista & ISAC_ISTA_RPF)	/* receive fifo full */
-	{
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(MAX_DFRAME_LEN)) != NULL)
-				sc->sc_ib= sc->sc_ibuf->m_data;
-			else
-				panic("isic_isac_irq: RPF, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - ISAC_FIFO_LEN))
-		{
-			ISAC_RDFIFO(sc->sc_ib, ISAC_FIFO_LEN);
-			sc->sc_ilen += ISAC_FIFO_LEN;			
-			sc->sc_ib += ISAC_FIFO_LEN;
-			c |= ISAC_CMDR_RMC;
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RPF, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;			
-		}
-	}
-
-	if(ista & ISAC_ISTA_XPR)	/* transmit fifo empty (XPR bit set) */
-	{
-		if((sc->sc_obuf2 != NULL) && (sc->sc_obuf == NULL))
-		{
-			sc->sc_freeflag = sc->sc_freeflag2;
-			sc->sc_obuf = sc->sc_obuf2;
-			sc->sc_op = sc->sc_obuf->m_data;
-			sc->sc_ol = sc->sc_obuf->m_len;
-			sc->sc_obuf2 = NULL;
-#ifdef NOTDEF			
-			printf("ob2=%x, op=%x, ol=%d, f=%d #",
-				sc->sc_obuf,
-				sc->sc_op,
-				sc->sc_ol,
-				sc->sc_state);
-#endif				
-		}
-		else
-		{
-#ifdef NOTDEF
-			printf("ob=%x, op=%x, ol=%d, f=%d #",
-				sc->sc_obuf,
-				sc->sc_op,
-				sc->sc_ol,
-				sc->sc_state);
-#endif
-		}			
-		
-		if(sc->sc_obuf)
-		{			
-			ISAC_WRFIFO(sc->sc_op, min(sc->sc_ol, ISAC_FIFO_LEN));
-	
-			if(sc->sc_ol > ISAC_FIFO_LEN)	/* length > 32 ? */
-			{
-				sc->sc_op += ISAC_FIFO_LEN; /* bufferptr+32 */
-				sc->sc_ol -= ISAC_FIFO_LEN; /* length - 32 */
-				c |= ISAC_CMDR_XTF;	    /* set XTF bit */
-			}
-			else
-			{
-				if(sc->sc_freeflag)
-				{
-					i4b_Dfreembuf(sc->sc_obuf);
-					sc->sc_freeflag = 0;
-				}
-				sc->sc_obuf = NULL;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-	
-				c |= ISAC_CMDR_XTF | ISAC_CMDR_XME;
-			}
-		}
-		else
-		{
-			sc->sc_state &= ~ISAC_TX_ACTIVE;
-		}
-	}
-	
-	if(ista & ISAC_ISTA_CISQ)	/* channel status change CISQ */
-	{
-		register u_char ci;
-	
-		/* get command/indication rx register*/
-	
-		ci = ISAC_READ(I_CIRR);
-
-		/* if S/Q IRQ, read SQC reg to clr SQC IRQ */
-	
-		if(ci & ISAC_CIRR_SQC)
-			(void) ISAC_READ(I_SQRR);
-
-		/* C/I code change IRQ (flag already cleared by CIRR read) */
-	
-		if(ci & ISAC_CIRR_CIC0)
-			isic_isac_ind_hdlr(sc, (ci >> 2) & 0xf);
-	}
-	
-	if(c)
-	{
-		ISAC_WRITE(I_CMDR, c);
-		ISACCMDRWRDELAY();
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	ISAC L1 Extended IRQ handler
- *---------------------------------------------------------------------------*/
-static u_char
-isic_isac_exir_hdlr(register struct l1_softc *sc, u_char exir)
-{
-	u_char c = 0;
-	
-	if(exir & ISAC_EXIR_XMR)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Message Repeat");
-
-		c |= ISAC_CMDR_XRES;
-	}
-	
-	if(exir & ISAC_EXIR_XDU)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Data Underrun");
-
-		c |= ISAC_CMDR_XRES;
-	}
-
-	if(exir & ISAC_EXIR_PCE)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Protocol Error");
-	}
-
-	if(exir & ISAC_EXIR_RFO)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Rx Frame Overflow");
-
-		c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-	}
-
-	if(exir & ISAC_EXIR_SOV)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Sync Xfer Overflow");
-	}
-
-	if(exir & ISAC_EXIR_MOS)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Monitor Status");
-	}
-
-	if(exir & ISAC_EXIR_SAW)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-		
-		NDBGL1(L1_I_ERR, "EXIRQ Subscriber Awake");
-	}
-
-	if(exir & ISAC_EXIR_WOV)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-
-		NDBGL1(L1_I_ERR, "EXIRQ Watchdog Timer Overflow");
-	}
-
-	return(c);
-}
-
-/*---------------------------------------------------------------------------*
- *	ISAC L1 Indication handler
- *---------------------------------------------------------------------------*/
-static void
-isic_isac_ind_hdlr(register struct l1_softc *sc, int ind)
-{
-	register int event;
-	
-	switch(ind)
-	{
-		case ISAC_CIRR_IAI8:
-			NDBGL1(L1_I_CICO, "rx AI8 in state %s", isic_printstate(sc));
-			if(sc->sc_bustyp == BUS_TYPE_IOM2)
-				isic_isac_l1_cmd(sc, CMD_AR8);
-			event = EV_INFO48;
-			i4b_l1_mph_status_ind(L0ISICUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-			
-		case ISAC_CIRR_IAI10:
-			NDBGL1(L1_I_CICO, "rx AI10 in state %s", isic_printstate(sc));
-			if(sc->sc_bustyp == BUS_TYPE_IOM2)
-				isic_isac_l1_cmd(sc, CMD_AR10);
-			event = EV_INFO410;
-			i4b_l1_mph_status_ind(L0ISICUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-
-		case ISAC_CIRR_IRSY:
-			NDBGL1(L1_I_CICO, "rx RSY in state %s", isic_printstate(sc));
-			event = EV_RSY;
-			break;
-
-		case ISAC_CIRR_IPU:
-			NDBGL1(L1_I_CICO, "rx PU in state %s", isic_printstate(sc));
-			event = EV_PU;
-			break;
-
-		case ISAC_CIRR_IDR:
-			NDBGL1(L1_I_CICO, "rx DR in state %s", isic_printstate(sc));
-			isic_isac_l1_cmd(sc, CMD_DIU);
-			event = EV_DR;			
-			break;
-			
-		case ISAC_CIRR_IDID:
-			NDBGL1(L1_I_CICO, "rx DID in state %s", isic_printstate(sc));
-			event = EV_INFO0;
-			i4b_l1_mph_status_ind(L0ISICUNIT(sc->sc_unit), STI_L1STAT, LAYER_IDLE, NULL);
-			break;
-
-		case ISAC_CIRR_IDIS:
-			NDBGL1(L1_I_CICO, "rx DIS in state %s", isic_printstate(sc));
-			event = EV_DIS;
-			break;
-
-		case ISAC_CIRR_IEI:
-			NDBGL1(L1_I_CICO, "rx EI in state %s", isic_printstate(sc));
-			isic_isac_l1_cmd(sc, CMD_DIU);
-			event = EV_EI;
-			break;
-
-		case ISAC_CIRR_IARD:
-			NDBGL1(L1_I_CICO, "rx ARD in state %s", isic_printstate(sc));
-			event = EV_INFO2;
-			break;
-
-		case ISAC_CIRR_ITI:
-			NDBGL1(L1_I_CICO, "rx TI in state %s", isic_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISAC_CIRR_IATI:
-			NDBGL1(L1_I_CICO, "rx ATI in state %s", isic_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISAC_CIRR_ISD:
-			NDBGL1(L1_I_CICO, "rx SD in state %s", isic_printstate(sc));
-			event = EV_INFO0;
-			break;
-		
-		default:
-			NDBGL1(L1_I_ERR, "UNKNOWN Indication 0x%x in state %s", ind, isic_printstate(sc));
-			event = EV_INFO0;
-			break;
-	}
-	isic_next_state(sc, event);
-}
-
-/*---------------------------------------------------------------------------*
- *	execute a layer 1 command
- *---------------------------------------------------------------------------*/	
-void
-isic_isac_l1_cmd(struct l1_softc *sc, int command)
-{
-	u_char cmd;
-
-#ifdef I4B_SMP_WORKAROUND
-
-	/* XXXXXXXXXXXXXXXXXXX */
-	
-	/*
-	 * patch from Wolfgang Helbig:
-	 *
-	 * Here is a patch that makes i4b work on an SMP:
-	 * The card (TELES 16.3) didn't interrupt on an SMP machine.
-	 * This is a gross workaround, but anyway it works *and* provides
-	 * some information as how to finally fix this problem.
-	 */
-	
-	HSCX_WRITE(0, H_MASK, 0xff);
-	HSCX_WRITE(1, H_MASK, 0xff);
-	ISAC_WRITE(I_MASK, 0xff);
-	DELAY(100);
-	HSCX_WRITE(0, H_MASK, HSCX_A_IMASK);
-	HSCX_WRITE(1, H_MASK, HSCX_B_IMASK);
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	/* XXXXXXXXXXXXXXXXXXX */
-	
-#endif /* I4B_SMP_WORKAROUND */
-
-	if(command < 0 || command > CMD_ILL)
-	{
-		NDBGL1(L1_I_ERR, "illegal cmd 0x%x in state %s", command, isic_printstate(sc));
-		return;
-	}
-                                           
-	if(sc->sc_bustyp == BUS_TYPE_IOM2)
-		cmd = ISAC_CIX0_LOW;
-	else
-		cmd = 0;
-
-	switch(command)
-	{
-		case CMD_TIM:
-			NDBGL1(L1_I_CICO, "tx TIM in state %s", isic_printstate(sc));
-			cmd |= (ISAC_CIXR_CTIM << 2);
-			break;
-
-		case CMD_RS:
-			NDBGL1(L1_I_CICO, "tx RS in state %s", isic_printstate(sc));
-			cmd |= (ISAC_CIXR_CRS << 2);
-			break;
-
-		case CMD_AR8:
-			NDBGL1(L1_I_CICO, "tx AR8 in state %s", isic_printstate(sc));
-			cmd |= (ISAC_CIXR_CAR8 << 2);
-			break;
-
-		case CMD_AR10:
-			NDBGL1(L1_I_CICO, "tx AR10 in state %s", isic_printstate(sc));
-			cmd |= (ISAC_CIXR_CAR10 << 2);
-			break;
-
-		case CMD_DIU:
-			NDBGL1(L1_I_CICO, "tx DIU in state %s", isic_printstate(sc));
-			cmd |= (ISAC_CIXR_CDIU << 2);
-			break;
-	}
-	ISAC_WRITE(I_CIXR, cmd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L1 ISAC initialization
- *---------------------------------------------------------------------------*/
-int
-isic_isac_init(struct l1_softc *sc)
-{
-	ISAC_IMASK = 0xff;		/* disable all irqs */
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	if(sc->sc_bustyp != BUS_TYPE_IOM2)
-	{
-		NDBGL1(L1_I_SETUP, "configuring for IOM-1 mode");
-
-		/* ADF2: Select mode IOM-1 */		
-		ISAC_WRITE(I_ADF2, 0x00);
-
-		/* SPCR: serial port control register:
-		 *	SPU - software power up = 0
-		 *	SAC - SIP port high Z
-		 *	SPM - timing mode 0
-		 *	TLP - test loop = 0
-		 *	C1C, C2C - B1 and B2 switched to/from SPa
-		 */
-		ISAC_WRITE(I_SPCR, ISAC_SPCR_C1C1|ISAC_SPCR_C2C1);
-
-		/* SQXR: S/Q channel xmit register:
-                 *	SQIE - S/Q IRQ enable = 0
-		 *	SQX1-4 - Fa bits = 1
-		 */
-		ISAC_WRITE(I_SQXR, ISAC_SQXR_SQX1|ISAC_SQXR_SQX2|ISAC_SQXR_SQX3|ISAC_SQXR_SQX4);
-
-		/* ADF1: additional feature reg 1:
-		 *	WTC - watchdog = 0
-		 *	TEM - test mode = 0
-		 *	PFS - pre-filter = 0
-		 *	CFS - IOM clock/frame always active
-		 *	FSC1/2 - polarity of 8kHz strobe
-		 *	ITF - interframe fill = idle
-		 */	
-		ISAC_WRITE(I_ADF1, ISAC_ADF1_FC2);	/* ADF1 */
-
-		/* STCR: sync transfer control reg:
-		 *	TSF - terminal secific functions = 0
-		 *	TBA - TIC bus address = 7
-		 *	STx/SCx = 0
-		 */
-		ISAC_WRITE(I_STCR, ISAC_STCR_TBA2|ISAC_STCR_TBA1|ISAC_STCR_TBA0);
-
-		/* MODE: Mode Register:
-		 *	MDSx - transparent mode 2
-		 *	TMD  - timer mode = external
-		 *	RAC  - Receiver enabled
-		 *	DIMx - digital i/f mode
-		 */
-		ISAC_WRITE(I_MODE, ISAC_MODE_MDS2|ISAC_MODE_MDS1|ISAC_MODE_RAC|ISAC_MODE_DIM0);
-	}
-	else
-	{
-		NDBGL1(L1_I_SETUP, "configuring for IOM-2 mode");
-
-		/* ADF2: Select mode IOM-2 */		
-		ISAC_WRITE(I_ADF2, ISAC_ADF2_IMS);
-
-		/* SPCR: serial port control register:
-		 *	SPU - software power up = 0
-		 *	SPM - timing mode 0
-		 *	TLP - test loop = 0
-		 *	C1C, C2C - B1 + C1 and B2 + IC2 monitoring
-		 */
-		ISAC_WRITE(I_SPCR, 0x00);
-
-		/* SQXR: S/Q channel xmit register:
-		 *	IDC  - IOM direction = 0 (master)
-		 *	CFS  - Config Select = 0 (clock always active)
-		 *	CI1E - C/I channel 1 IRQ enable = 0
-                 *	SQIE - S/Q IRQ enable = 0
-		 *	SQX1-4 - Fa bits = 1
-		 */
-		ISAC_WRITE(I_SQXR, ISAC_SQXR_SQX1|ISAC_SQXR_SQX2|ISAC_SQXR_SQX3|ISAC_SQXR_SQX4);
-
-		/* ADF1: additional feature reg 1:
-		 *	WTC - watchdog = 0
-		 *	TEM - test mode = 0
-		 *	PFS - pre-filter = 0
-		 *	IOF - IOM i/f off = 0
-		 *	ITF - interframe fill = idle
-		 */	
-		ISAC_WRITE(I_ADF1, 0x00);
-
-		/* STCR: sync transfer control reg:
-		 *	TSF - terminal secific functions = 0
-		 *	TBA - TIC bus address = 7
-		 *	STx/SCx = 0
-		 */
-		ISAC_WRITE(I_STCR, ISAC_STCR_TBA2|ISAC_STCR_TBA1|ISAC_STCR_TBA0);
-
-		/* MODE: Mode Register:
-		 *	MDSx - transparent mode 2
-		 *	TMD  - timer mode = external
-		 *	RAC  - Receiver enabled
-		 *	DIMx - digital i/f mode
-		 */
-		ISAC_WRITE(I_MODE, ISAC_MODE_MDS2|ISAC_MODE_MDS1|ISAC_MODE_RAC|ISAC_MODE_DIM0);
-	}
-
-#ifdef NOTDEF
-	/*
-	 * XXX a transmitter reset causes an ISAC tx IRQ which will not
-	 * be serviced at attach time under some circumstances leaving
-	 * the associated IRQ line on the ISA bus active. This prevents
-	 * any further interrupts to be serviced because no low -> high
-	 * transition can take place anymore. (-hm)
-	 */
-	 
-	/* command register:
-	 *	RRES - HDLC receiver reset
-	 *	XRES - transmitter reset
-	 */
-	ISAC_WRITE(I_CMDR, ISAC_CMDR_RRES|ISAC_CMDR_XRES);
-	ISACCMDRWRDELAY();
-#endif
-	
-	/* enabled interrupts:
-	 * ===================
-	 * RME  - receive message end
-	 * RPF  - receive pool full
-	 * XPR  - transmit pool ready
-	 * CISQ - CI or S/Q channel change
-	 * EXI  - extended interrupt
-	 */
-
-	ISAC_IMASK = ISAC_MASK_RSC |	/* auto mode only	*/
-		     ISAC_MASK_TIN | 	/* timer irq		*/
-		     ISAC_MASK_SIN;	/* sync xfer irq	*/
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	return(0);
-}
--- sys/i4b/layer1/isic/i4b_tel_s016.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/*-
- *   Copyright (c) 1996 Arne Helme. All rights reserved.
- *   Copyright (c) 1996 Gary Jennejohn. 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
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	isic - I4B Siemens ISDN Chipset Driver for Teles S0/16 and clones
- *	=================================================================
- *      last edit-date: [Wed Jan 24 09:27:24 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_tel_s016.c,v 1.10 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(TEL_S0_16)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/md_var.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#define TELES_S016_MEMSIZE 0x1000
-
-static u_char intr_no[] = { 1, 1, 0, 2, 4, 6, 1, 1, 1, 0, 8, 10, 12, 1, 1, 14 };
-static const bus_size_t offset[] = { 0x100, 0x180, 0x1c0 };
-
-/*---------------------------------------------------------------------------*
- *	Teles S0/16 write register routine
- *---------------------------------------------------------------------------*/
-static void
-tels016_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.mem);
-
-	offs += offset[what];
-
-	if (offs & 0x01)
-		offs |= 0x200;
-
-	bus_space_write_1(t, h, offs, data);
-}
-
-/*---------------------------------------------------------------------------*
- *	Teles S0/16 read register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-tels016_read_reg(struct l1_softc *sc,	int what, bus_size_t offs)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.mem);
-
-	offs += offset[what];
-
-	if(offs & 0x01)
-		offs |= 0x200;
-
-	return bus_space_read_1(t, h, offs);
-}
-
-/*---------------------------------------------------------------------------*
- *	Teles S0/16 fifo write routine
- *---------------------------------------------------------------------------*/
-static void
-tels016_write_fifo(struct l1_softc *sc, int what, void *data, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.mem);
-	bus_space_write_region_1(t, h, offset[what], data, size);
-}
-
-/*---------------------------------------------------------------------------*
- *	Teles S0/16 fifo read routine
- *---------------------------------------------------------------------------*/
-static void
-tels016_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.mem);
-	bus_space_read_region_1(t, h, offset[what], buf, size);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_probe_s016 - probe for Teles S0/16 and compatibles
- *---------------------------------------------------------------------------*/
-int
-isic_probe_s016(device_t dev)
-{
-	size_t unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = 0;		/* softc */
-	void *ih = 0;				/* dummy */
-	u_int8_t b0,b1,b2;			/* for signature */
-	bus_space_tag_t    t;			/* bus things */
-	bus_space_handle_t h;
-
-	/* check max unit range */
-
-	if(unit >= ISIC_MAXUNIT)
-	{
-		printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Teles S0/16!\n",
-				unit, unit);
-		return(ENXIO);	
-	}
-
-	sc = &l1_sc[unit];			/* get pointer to softc */
-	sc->sc_unit = unit;			/* set unit */
-
-	/* see if an io base was supplied */
-
-	if(!(sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not allocate i/o port for Teles S0/16.\n", unit);
-		return(ENXIO);
-	}
-
-	sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
-
-	/*
-	 * check if the provided io port is valid
-	 */
-
-	switch(sc->sc_port)
-	{
-		case 0xd80:
-		case 0xe80:
-		case 0xf80:
-			break;
-
-		default:
-			printf("isic%d: Error, invalid iobase 0x%x specified for Teles S0/16!\n",
-				unit, sc->sc_port);
-			isic_detach_common(dev);
-			return(ENXIO);
-			break;
-	}
-
-	/* allocate memory resource */
-
-	if(!(sc->sc_resources.mem =
-			bus_alloc_resource(dev, SYS_RES_MEMORY,
-					&sc->sc_resources.mem_rid,
-					0ul, ~0ul, TELES_S016_MEMSIZE,
-					RF_ACTIVE)))
-	{
-		printf("isic%d: Could not allocate memory for Teles S0/16.\n", unit);
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-
-	/* 
-	 * get virtual addr.
-	 */
-	sc->sc_vmem_addr = rman_get_virtual(sc->sc_resources.mem);
-
-	/*
-	 * check for valid adresses
-	 */
-	switch(kvtop(sc->sc_vmem_addr))
-	{
-		case 0xc0000:
-		case 0xc2000:
-		case 0xc4000:
-		case 0xc6000:
-		case 0xc8000:
-		case 0xca000:
-		case 0xcc000:
-		case 0xce000:
-		case 0xd0000:
-		case 0xd2000:
-		case 0xd4000:
-		case 0xd6000:
-		case 0xd8000:
-		case 0xda000:
-		case 0xdc000:
-		case 0xde000:
-			break;
-
-		default:
-			printf("isic%d: Error, invalid memory address 0x%x for Teles S0/16!\n",
-				unit, kvtop(sc->sc_vmem_addr));
-			isic_detach_common(dev);
-			return(ENXIO);
-			break;
-	}		
-	
-	/* setup ISAC access routines */
-
-	sc->clearirq = NULL;
-
-	sc->readreg = tels016_read_reg;
-	sc->writereg = tels016_write_reg;
-
-	sc->readfifo = tels016_read_fifo;
-	sc->writefifo = tels016_write_fifo;
-
-	/* setup card type */
-	sc->sc_cardtyp = CARD_TYPEP_16;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM1;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* setup ISAC base addr, though we don't really need it */
-	
-	ISAC_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x100);
-
-	/* setup HSCX base addr */
-	
-	HSCX_A_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x180);
-	HSCX_B_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x1c0);
-
-	t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	/* get signature bytes */
-	b0 = bus_space_read_1(t, h, 0);
-	b1 = bus_space_read_1(t, h, 1);
-	b2 = bus_space_read_1(t, h, 2);
-
-	/* check signature bytes */
-	if(b0 != 0x51)
-	{
-		printf("isic%d: Error, signature 1 0x%x != 0x51 for Teles S0/16!\n",
-			unit, b0);
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-	
-	if(b1 != 0x93)
-	{
-		printf("isic%d: Error, signature 2 0x%x != 0x93 for Teles S0/16!\n",
-			unit, b1);
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-	
-	if((b2 != 0x1e) && (b2 != 0x1f))
-	{
-		printf("isic%d: Error, signature 3 0x%x != 0x1e or 0x1f for Teles S0/16!\n",
-			unit, b2);
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-
-	/* get our irq */
-
-	if(!(sc->sc_resources.irq =
-			bus_alloc_resource_any(dev, SYS_RES_IRQ,
-					       &sc->sc_resources.irq_rid,
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not allocate irq for Teles S0/16.\n", unit);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	/* register interupt routine */
-
-	bus_setup_intr(dev, sc->sc_resources.irq,
-			INTR_TYPE_NET,
-			(void(*)(void *))(isicintr),
-			sc, &ih);
-
-	/* get the irq number */
-	
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-
-	/* check IRQ validity */
-
-	if((intr_no[sc->sc_irq]) == 1)
-	{
-		printf("isic%d: Error, invalid IRQ [%d] specified for Teles S0/16!\n",
-			unit, sc->sc_irq);
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-	
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_s016 - attach Teles S0/16 and compatibles
- *---------------------------------------------------------------------------*/
-int
-isic_attach_s016(device_t dev)
-{
-	struct l1_softc *sc = &l1_sc[device_get_unit(dev)];
-	u_long irq;
-
-	bus_space_tag_t    ta = rman_get_bustag(sc->sc_resources.mem);
-	bus_space_handle_t ha = rman_get_bushandle(sc->sc_resources.mem);
-	bus_space_tag_t    tb = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t hb = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	/* is this right for FreeBSD or off by one ? */
-	irq = intr_no[sc->sc_irq];
-
-	/* configure IRQ */
-
-	irq |= ((u_long) sc->sc_vmem_addr) >> 9;
-
-	DELAY(SEC_DELAY / 10);
-	bus_space_write_1(tb, hb, 4, irq);
-
-	DELAY(SEC_DELAY / 10);
-	bus_space_write_1(tb, hb, 4, irq | 0x01);
-
-	DELAY(SEC_DELAY / 5);
-
-	/* set card bit off */
-
-	bus_space_write_1(ta, ha, 0x80, 0);
-	DELAY(SEC_DELAY / 5);
-
-	/* set card bit on */
-	
-	bus_space_write_1(ta, ha, 0x80, 1);
-	DELAY(SEC_DELAY / 5);
-
-	return 0;
-}
-
-#endif /* defined(TEL_S0_16) */
--- sys/i4b/layer1/isic/i4b_l1fsm.c
+++ /dev/null
@@ -1,506 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l1fsm.c - isdn4bsd layer 1 I.430 state machine
- *	--------------------------------------------------
- *      last edit-date: [Wed Jan 24 09:12:18 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_l1fsm.c,v 1.8 2005/01/06 22:18:20 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/include/i4b_mbuf.h>
-
-#if DO_I4B_DEBUG
-static char *state_text[N_STATES] = {
-	"F3 Deactivated",
-	"F4 Awaiting Signal",
-	"F5 Identifying Input",
-	"F6 Synchronized",
-	"F7 Activated",
-	"F8 Lost Framing",
-	"Illegal State"	
-};
-
-static char *event_text[N_EVENTS] = {
-	"EV_PHAR PH_ACT_REQ",
-	"EV_T3 Timer 3 expired",
-	"EV_INFO0 INFO0 received",
-	"EV_RSY Level Detected",
-	"EV_INFO2 INFO2 received",
-	"EV_INFO48 INFO4 received",
-	"EV_INFO410 INFO4 received",
-	"EV_DR Deactivate Req",
-	"EV_PU Power UP",
-	"EV_DIS Disconnected",
-	"EV_EI Error Ind",
-	"Illegal Event"
-};
-#endif
-
-/* Function prototypes */
-
-static void timer3_expired (struct l1_softc *sc);
-static void T3_start (struct l1_softc *sc);
-static void T3_stop (struct l1_softc *sc);
-static void F_T3ex (struct l1_softc *sc);
-static void timer4_expired (struct l1_softc *sc);
-static void T4_start (struct l1_softc *sc);
-static void T4_stop (struct l1_softc *sc);
-static void F_AI8 (struct l1_softc *sc);
-static void F_AI10 (struct l1_softc *sc);
-static void F_I01 (struct l1_softc *sc);
-static void F_I02 (struct l1_softc *sc);
-static void F_I03 (struct l1_softc *sc);
-static void F_I2 (struct l1_softc *sc);
-static void F_ill (struct l1_softc *sc);
-static void F_NULL (struct l1_softc *sc);
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer3_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T3)
-	{
-		NDBGL1(L1_T_ERR, "state = %s", isic_printstate(sc));
-		sc->sc_I430T3 = 0;
-
-		/* XXX try some recovery here XXX */
-
-		isic_recover(sc);
-
-		sc->sc_init_tries++;	/* increment retry count */
-
-/*XXX*/		if(sc->sc_init_tries > 4)
-		{
-			int s = SPLI4B();
-
-			sc->sc_init_tries = 0;
-			
-			if(sc->sc_obuf2 != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf2);
-				sc->sc_obuf2 = NULL;
-			}
-			if(sc->sc_obuf != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf);
-				sc->sc_obuf = NULL;
-				sc->sc_freeflag = 0;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-			}
-
-			splx(s);
-
-			i4b_l1_mph_status_ind(L0ISICUNIT(sc->sc_unit), STI_NOL1ACC, 0, NULL);
-		}
-		
-		isic_next_state(sc, EV_T3);		
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 start
- *---------------------------------------------------------------------------*/	
-static void
-T3_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", isic_printstate(sc));
-	sc->sc_I430T3 = 1;
-	sc->sc_T3_callout = timeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, 2*hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 stop
- *---------------------------------------------------------------------------*/	
-static void
-T3_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", isic_printstate(sc));
-
-	sc->sc_init_tries = 0;	/* init connect retry count */
-	
-	if(sc->sc_I430T3)
-	{
-		sc->sc_I430T3 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, sc->sc_T3_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_T3ex(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_T3ex executing");
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0ISICUNIT(sc->sc_unit));
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer4_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T4)
-	{
-		NDBGL1(L1_T_MSG, "state = %s", isic_printstate(sc));
-		sc->sc_I430T4 = 0;
-		i4b_l1_mph_status_ind(L0ISICUNIT(sc->sc_unit), STI_PDEACT, 0, NULL);
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 start
- *---------------------------------------------------------------------------*/	
-static void
-T4_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", isic_printstate(sc));
-	sc->sc_I430T4 = 1;
-	sc->sc_T4_callout = timeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 stop
- *---------------------------------------------------------------------------*/	
-static void
-T4_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", isic_printstate(sc));
-
-	if(sc->sc_I430T4)
-	{
-		sc->sc_I430T4 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, sc->sc_T4_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI8
- *---------------------------------------------------------------------------*/	
-static void
-F_AI8(struct l1_softc *sc)
-{
-	T4_stop(sc);
-
-	NDBGL1(L1_F_MSG, "FSM function F_AI8 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0ISICUNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_8;
-		
-		hdr.unit = L0ISICUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI10
- *---------------------------------------------------------------------------*/	
-static void
-F_AI10(struct l1_softc *sc)
-{
-	T4_stop(sc);
-	
-	NDBGL1(L1_F_MSG, "FSM function F_AI10 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0ISICUNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_10;
-		
-		hdr.unit = L0ISICUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in states F3 .. F5
- *---------------------------------------------------------------------------*/	
-static void
-F_I01(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I01 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0ISICUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F6
- *---------------------------------------------------------------------------*/	
-static void
-F_I02(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I02 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0ISICUNIT(sc->sc_unit));
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0ISICUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F7 or F8
- *---------------------------------------------------------------------------*/	
-static void
-F_I03(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I03 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0ISICUNIT(sc->sc_unit));
-
-	T4_start(sc);
-	
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0ISICUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: activate request
- *---------------------------------------------------------------------------*/	
-static void
-F_AR(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_AR executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO1_8;
-		
-		hdr.unit = L0ISICUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_TE;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-
-	isic_isac_l1_cmd(sc, CMD_AR8);
-
-	T3_start(sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO2
- *---------------------------------------------------------------------------*/	
-static void
-F_I2(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I2 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO2;
-		
-		hdr.unit = L0ISICUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}		
-
-}
-
-/*---------------------------------------------------------------------------*
- *	illegal state default action
- *---------------------------------------------------------------------------*/	
-static void
-F_ill(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_ERR, "FSM function F_ill executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	No action
- *---------------------------------------------------------------------------*/	
-static void
-F_NULL(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_NULL executing");
-}
-
-
-/*---------------------------------------------------------------------------*
- *	layer 1 state transition table
- *---------------------------------------------------------------------------*/	
-struct isic_state_tab {
-	void (*func) (struct l1_softc *sc);	/* function to execute */
-	int newstate;				/* next state */
-} isic_state_tab[N_EVENTS][N_STATES] = {
-
-/* STATE:	F3			F4			F5			F6			F7			F8			ILLEGAL STATE     */
-/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/* EV_PHAR x*/	{{F_AR,   ST_F4},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_ill,  ST_ILL},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_T3   x*/	{{F_NULL, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO0 */	{{F_I01,  ST_F3},	{F_I01,  ST_F4},	{F_I01,  ST_F5},	{F_I02,  ST_F3},	{F_I03,  ST_F3},	{F_I03,  ST_F3},	{F_ill, ST_ILL}},
-/* EV_RSY  x*/	{{F_NULL, ST_F3},	{F_NULL, ST_F5},	{F_NULL, ST_F5}, 	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO2 */	{{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_ill, ST_ILL}},
-/* EV_INFO48*/	{{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_NULL, ST_F7},	{F_AI8,  ST_F7},	{F_ill, ST_ILL}},
-/* EV_INFO41*/	{{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_NULL, ST_F7},	{F_AI10, ST_F7},	{F_ill, ST_ILL}},
-/* EV_DR    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_PU    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_DIS   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}},
-/* EV_EI    */	{{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_ill, ST_ILL}},
-/* EV_ILL   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}}
-};
-
-/*---------------------------------------------------------------------------*
- *	event handler
- *---------------------------------------------------------------------------*/	
-void
-isic_next_state(struct l1_softc *sc, int event)
-{
-	int currstate, newstate;
-
-	if(event >= N_EVENTS)
-		panic("i4b_l1fsm.c: event >= N_EVENTS\n");
-
-	currstate = sc->sc_I430state;
-
-	if(currstate >= N_STATES)
-		panic("i4b_l1fsm.c: currstate >= N_STATES\n");	
-
-	newstate = isic_state_tab[event][currstate].newstate;
-
-	if(newstate >= N_STATES)
-		panic("i4b_l1fsm.c: newstate >= N_STATES\n");	
-	
-	NDBGL1(L1_F_MSG, "FSM event [%s]: [%s => %s]", event_text[event],
-                                           state_text[currstate],
-                                           state_text[newstate]);
-
-        (*isic_state_tab[event][currstate].func)(sc);
-
-	if(newstate == ST_ILL)
-	{
-		newstate = ST_F3;
-		NDBGL1(L1_F_ERR, "FSM Illegal State ERROR, oldstate = %s, newstate = %s, event = %s!",
-					state_text[currstate],
-					state_text[newstate],
-					event_text[event]);
-	}
-
-	sc->sc_I430state = newstate;
-}
-
-#if DO_I4B_DEBUG
-/*---------------------------------------------------------------------------*
- *	return pointer to current state description
- *---------------------------------------------------------------------------*/	
-char *
-isic_printstate(struct l1_softc *sc)
-{
-	return((char *) state_text[sc->sc_I430state]);
-}
-#endif
--- sys/i4b/layer1/isic/i4b_ctx_s0P.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	isic - I4B Siemens ISDN Chipset Driver for Creatix/Teles PnP
- *	============================================================
- *	last edit-date: [Wed Jan 24 09:07:22 2001]
- *
- *	Note: this driver works for the Creatix ISDN S0-16 P+P and
- *	      for the Teles S0/16.3 PnP card. Although they are not
- *            the same hardware and don't share the same PnP config
- *            information, once the base addresses are set, the
- *            offsets are same and therefore they can use the same
- *            driver.
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_ctx_s0P.c,v 1.11 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if (defined(CRTX_S0_P) || defined(TEL_S0_16_3_P) || defined(COMPAQ_M610))
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-/*---------------------------------------------------------------------------*
- *      Creatix / Teles PnP ISAC get fifo routine
- *---------------------------------------------------------------------------*/
-static void
-ctxs0P_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[what+2]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+2]);
-	bus_space_read_multi_1(t,h,0x3e,buf,size);
-}
-
-/*---------------------------------------------------------------------------*
- *      Creatix / Teles PnP ISAC put fifo routine
- *---------------------------------------------------------------------------*/
-static void
-ctxs0P_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[what+2]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+2]);
-	bus_space_write_multi_1(t,h,0x3e,buf,size);
-}
-
-/*---------------------------------------------------------------------------*
- *      Creatix / Teles PnP ISAC put register routine
- *---------------------------------------------------------------------------*/
-static void
-ctxs0P_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[what+2]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+2]);
-	bus_space_write_1(t,h,offs,data);
-}
-
-/*---------------------------------------------------------------------------*
- *	Creatix / Teles PnP ISAC get register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-ctxs0P_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[what+2]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[what+2]);
-	return bus_space_read_1(t,h,offs);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_Cs0P - attach Creatix / Teles PnP
- *---------------------------------------------------------------------------*/
-int
-isic_attach_Cs0P(device_t dev)
-{
-	u_int32_t iobase1;
-	u_int32_t iobase2;
-	u_int32_t iocfg = 0;	/* quiet bogus gcc warning */
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];	
-	bus_space_tag_t t;
-	bus_space_handle_t h;
-
-	/*
-	 * this card needs a second io_base,
-	 * free resources if we don't get it
-	 */
-
-	sc->sc_resources.io_rid[1] = 1;
-	
-	if(!(sc->sc_resources.io_base[1] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[1],
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get io area 1 for Creatix / Teles PnP!\n", unit);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	/*
-	 * Compaq M610 has a cfg io area,
-	 * we need it
-	 */
-
-	if (sc->sc_cardtyp == CARD_TYPEP_COMPAQ_M610)
-	{
-		sc->sc_resources.io_rid[2] = 2;
-	
-		if(!(sc->sc_resources.io_base[2] =
-				bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-						&sc->sc_resources.io_rid[2],
-						RF_ACTIVE)))
-		{
-			printf("isic%d: Could not get cfg io area for Compaq Microcom 610\n", unit);
-			isic_detach_common(dev);
-			return ENXIO;
-		}
-
-		iocfg = rman_get_start(sc->sc_resources.io_base[2]);
-
-	        bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_resources.io_rid[2],
-				sc->sc_resources.io_base[2]);
-	}
-
-	/* remember the io base addresses */
-	
-	if (sc->sc_cardtyp != CARD_TYPEP_COMPAQ_M610)
-	{
-		iobase1 = rman_get_start(sc->sc_resources.io_base[0]);
-		iobase2 = rman_get_start(sc->sc_resources.io_base[1]);
-	}
-	else
-	{
-		iobase1 = rman_get_start(sc->sc_resources.io_base[1]);
-		iobase2 = rman_get_start(sc->sc_resources.io_base[0]);
-	}
-
-	/*
-	 * because overlapping resources are invalid,
-	 * release the first and second io port resource
-	 */
-	
-        bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_resources.io_rid[0],
-			sc->sc_resources.io_base[0]);
-	
-        bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_resources.io_rid[1],
-			sc->sc_resources.io_base[1]);
-
-	/* set and allocate a base io address for the ISAC chip */
-	
-	sc->sc_resources.io_rid[2] = 2;
-	
-	bus_set_resource(dev, SYS_RES_IOPORT, 2, iobase1-0x20, 0x40);
-
-	if(!(sc->sc_resources.io_base[2] =
-		bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-				       &sc->sc_resources.io_rid[2],
-				       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get io area 2 for Creatix / Teles PnP!\n", unit);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-
-	/* set and allocate a resource for the HSCX channel A */
-	
-	sc->sc_resources.io_rid[3] = 3;
-
-/*XXX*/	/* FIXME !!!!
-	 * the width of the resource is too small, there are accesses
-	 * to it with an offset of 0x3e into the next resource. anyway,
-         * it seems to work and i have no idea how to do 2 resources
-	 * overlapping each other.
-	 */
-
-#if 0
-	bus_set_resource(dev, SYS_RES_IOPORT, 3, iobase2-0x20, 0x20);
-#else
-	bus_set_resource(dev, SYS_RES_IOPORT, 3, iobase2-0x20, 0x10);
-#endif
-
-	if(!(sc->sc_resources.io_base[3] =
-		bus_alloc_resource_any(dev,SYS_RES_IOPORT,
-				       &sc->sc_resources.io_rid[3],
-				       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get io area 3 for Creatix / Teles PnP!\n", unit);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	/* set and allocate a resources for the HSCX channel B */
-	
-	sc->sc_resources.io_rid[4] = 4;
-	
-	bus_set_resource(dev, SYS_RES_IOPORT, 4, iobase2, 0x40);
-
-	if(!(sc->sc_resources.io_base[4] =
-		bus_alloc_resource_any(dev,SYS_RES_IOPORT,
-				       &sc->sc_resources.io_rid[4],
-				       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get io area 4 for Creatix / Teles PnP!\n", unit);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	/*
-	 * set and allocate a resource for the cfg io
-	 * for compaq m610
-	 */
-
-	if (sc->sc_cardtyp == CARD_TYPEP_COMPAQ_M610)
-	{
-		sc->sc_resources.io_rid[5] = 5;
-
-		bus_set_resource(dev, SYS_RES_IOPORT, 5, iocfg, 0x01);
-
-		if(!(sc->sc_resources.io_base[5] =
-			bus_alloc_resource_any(dev,SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[5],
-					       RF_ACTIVE)))
-		{
-			printf("isic%d: Could not get cfg io area for Compaq Microcom 610!\n", unit);
-			isic_detach_common(dev);
-			return ENXIO;
-		}
-	}
-
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = ctxs0P_read_reg;
-	sc->writereg = ctxs0P_write_reg;
-
-	sc->readfifo = ctxs0P_read_fifo;
-	sc->writefifo = ctxs0P_write_fifo;
-
-	/* setup card type */
-
-	if (sc->sc_cardtyp != CARD_TYPEP_COMPAQ_M610)
-		sc->sc_cardtyp = CARD_TYPEP_CS0P;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* enable the card */
-	
-	if (sc->sc_cardtyp != CARD_TYPEP_COMPAQ_M610)
-	{
-		t = rman_get_bustag(sc->sc_resources.io_base[2]);
-		h = rman_get_bushandle(sc->sc_resources.io_base[2]);
-	
-		bus_space_write_1(t, h, 0x3c, 0);
-		DELAY(SEC_DELAY / 10);
-
-		bus_space_write_1(t, h, 0x3c, 1);
-		DELAY(SEC_DELAY / 10);
-	}
-	else
-	{
-		t = rman_get_bustag(sc->sc_resources.io_base[5]);
-		h = rman_get_bushandle(sc->sc_resources.io_base[5]);
-
-		bus_space_write_1(t, h, 0xff, 0);
-		DELAY(SEC_DELAY / 10);
-
-		bus_space_write_1(t, h, 0x00, 1);
-		DELAY(SEC_DELAY / 10);
-	}
-
-	return 0;
-}
-
-#endif /* (defined(CRTX_S0_P) || defined(TEL_S0_16_3_P) || defined(COMPAQ_M610)) */
-
--- sys/i4b/layer1/isic/i4b_usr_sti.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_usr_sti.c - USRobotics Sportster ISDN TA intern (Tina-pp)
- *	-------------------------------------------------------------
- *      last edit-date: [Wed Jan 24 09:28:12 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_usr_sti.c,v 1.9 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(USR_STI)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-/*---------------------------------------------------------------------------*
- *	USR Sportster TA intern special registers
- *---------------------------------------------------------------------------*/
-#define USR_HSCXA_OFF	0x0000
-#define USR_HSCXB_OFF	0x4000
-#define USR_INTL_OFF	0x8000
-#define USR_ISAC_OFF	0xc000
-
-#define USR_RES_BIT	0x80	/* 0 = normal, 1 = reset ISAC/HSCX	*/
-#define USR_INTE_BIT	0x40	/* 0 = IRQ disabled, 1 = IRQ's enabled	*/
-#define USR_IL_MASK	0x07	/* IRQ level config			*/
-
-static u_char intr_no[] = { 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 3, 4, 5, 0, 6, 7 };
-
-#define ADDR(reg)	\
-	(((reg/4) * 1024) + ((reg%4) * 2))
-
-#ifdef USRTA_DEBUG_PORTACCESS
-int debugcntr;
-#define USRTA_DEBUG(fmt) \
-		if (++debugcntr < 1000) printf fmt;
-#else
-#define USRTA_DEBUG(fmt)
-#endif
-
-/*---------------------------------------------------------------------------*
- *	USRobotics read fifo routine
- *---------------------------------------------------------------------------*/
-static void		
-usrtai_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	register int offset = 0;
-	register unsigned int base = 0;
-
-USRTA_DEBUG(("usrtai_read_fifo: what %d size %d\n", what, size))
-	switch (what)
-	{
-		case ISIC_WHAT_ISAC:
-			base = (unsigned int)ISAC_BASE;
-			break;
-		case ISIC_WHAT_HSCXA:
-			base = (unsigned int)HSCX_A_BASE;
-			break;
-		case ISIC_WHAT_HSCXB:
-			base = (unsigned int)HSCX_B_BASE;
-			break;
-		default:
-			printf("usrtai_read_fifo: invalid what %d\n", what);
-			return;
-	}
-
-	for(;size > 0; size--, offset++)	
-	{
-		*((u_char *)buf + offset) = inb(base + ADDR(offset));
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	USRobotics write fifo routine
- *---------------------------------------------------------------------------*/
-static void
-usrtai_write_fifo(struct l1_softc *sc, int what, void *data, size_t size)
-{
-	register int offset = 0;
-	register unsigned int base = 0;
-
-USRTA_DEBUG(("usrtai_write_fifo: what %d size %d\n", what, size))
-	switch (what)
-	{
-		case ISIC_WHAT_ISAC:
-			base = (unsigned int)ISAC_BASE;
-			break;
-		case ISIC_WHAT_HSCXA:
-			base = (unsigned int)HSCX_A_BASE;
-			break;
-		case ISIC_WHAT_HSCXB:
-			base = (unsigned int)HSCX_B_BASE;
-			break;
-		default:
-			printf("usrtai_write_fifo: invalid what %d\n", what);
-			return;
-	}
-
-	
-	for(;size > 0; size--, offset++)
-	{
-		outb(base + ADDR(offset), *((u_char *)data + offset));
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	USRobotics write register routine
- *---------------------------------------------------------------------------*/
-static void
-usrtai_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	register unsigned int base = 0;
-
-USRTA_DEBUG(("usrtai_write_reg: what %d ADDR(%d) %d data %#x\n", what, offs, ADDR(offs), data))
-	switch (what)
-	{
-		case ISIC_WHAT_ISAC:
-			base = (unsigned int)ISAC_BASE;
-			break;
-		case ISIC_WHAT_HSCXA:
-			base = (unsigned int)HSCX_A_BASE;
-			break;
-		case ISIC_WHAT_HSCXB:
-			base = (unsigned int)HSCX_B_BASE;
-			break;
-		default:
-			printf("usrtai_write_reg invalid what %d\n", what);
-			return;
-	}
-
-	outb(base + ADDR(offs), (u_char)data);
-}
-
-/*---------------------------------------------------------------------------*
- *	USRobotics read register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-usrtai_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	register unsigned int base = 0;
-	u_int8_t byte;
-
-USRTA_DEBUG(("usrtai_read_reg: what %d ADDR(%d) %d..", what, offs, ADDR(offs)))
-	switch (what)
-	{
-		case ISIC_WHAT_ISAC:
-			base = (unsigned int)ISAC_BASE;
-			break;
-		case ISIC_WHAT_HSCXA:
-			base = (unsigned int)HSCX_A_BASE;
-			break;
-		case ISIC_WHAT_HSCXB:
-			base = (unsigned int)HSCX_B_BASE;
-			break;
-		default:
-			printf("usrtai_read_reg: invalid what %d\n", what);
-			return(0);
-	}
-
-	byte = inb(base + ADDR(offs));
-USRTA_DEBUG(("usrtai_read_reg: got %#x\n", byte))
-	return(byte);
-}
-
-/*---------------------------------------------------------------------------*
- *	allocate an io port - based on code in isa_isic.c
- *---------------------------------------------------------------------------*/
-static int
-usrtai_alloc_port(device_t dev)
-{ 
-	size_t unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];
-	int i, num = 0;
-	bus_size_t base;
-
-	/* 49 io mappings: 1 config and 48x8 registers */
-
-	/* config at offset 0x8000 */
-	base = sc->sc_port + 0x8000;
-	if (base < 0 || base > 0x0ffff)
-		return 1;
-	sc->sc_resources.io_rid[num] = num;
-
-	bus_set_resource(dev, SYS_RES_IOPORT, num, base, 1);
-
-	if(!(sc->sc_resources.io_base[num] =
-		bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-				       &sc->sc_resources.io_rid[num],
-				       RF_ACTIVE)))
-	{
-		printf("isic%d: Error, failed to reserve io #%dport %#x!\n", unit, num, base);
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-	num++;
-
-	/* HSCX A at offset 0 */
-	base = sc->sc_port;
-	for (i = 0; i < 16; i++) {
-		if (base+i*1024 < 0 || base+i*1024+8 > 0x0ffff)
-			return 1;
-		sc->sc_resources.io_rid[num] = num;
-
-		bus_set_resource(dev, SYS_RES_IOPORT, num, base+i*1024, 8);
-
-		if(!(sc->sc_resources.io_base[num] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[num],
-					       RF_ACTIVE)))
-		{
-			printf("isic%d: Error, failed to reserve io #%d port %#x!\n", unit, num, base+i*1024);
-			isic_detach_common(dev);
-			return(ENXIO);
-		}
-		++num;
-	}
-
-	/* HSCX B at offset 0x4000 */
-	base = sc->sc_port + 0x4000;
-	for (i = 0; i < 16; i++) {
-		if (base+i*1024 < 0 || base+i*1024+8 > 0x0ffff)
-			return 1;
-		sc->sc_resources.io_rid[num] = num;
-
-		bus_set_resource(dev, SYS_RES_IOPORT, num, base+i*1024, 8);
-
-		if(!(sc->sc_resources.io_base[num] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[num],
-					       RF_ACTIVE)))
-		{
-			printf("isic%d: Error, failed to reserve io #%d port %#x!\n", unit, num, base+i*1024);
-			isic_detach_common(dev);
-			return(ENXIO);
-		}
-		++num;
-	}
-
-	/* ISAC at offset 0xc000 */
-	base = sc->sc_port + 0xc000;
-	for (i = 0; i < 16; i++) {
-		if (base+i*1024 < 0 || base+i*1024+8 > 0x0ffff)
-			return 1;
-		sc->sc_resources.io_rid[num] = num;
-
-		bus_set_resource(dev, SYS_RES_IOPORT, num, base+i*1024, 8);
-
-		if(!(sc->sc_resources.io_base[num] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[num],
-					       RF_ACTIVE)))
-		{
-			printf("isic%d: Error, failed to reserve io #%d port %#x!\n", unit, num, base+i*1024);
-			isic_detach_common(dev);
-			return(ENXIO);
-		}
-		++num;
-	}
-
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_probe_usrtai - probe for USR
- *---------------------------------------------------------------------------*/
-int
-isic_probe_usrtai(device_t dev)
-{
-	size_t unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = 0;	/* pointer to softc */
-	void *ih = 0;			/* dummy */
-
-	/* check max unit range */
-
-	if(unit >= ISIC_MAXUNIT)
-	{
-		printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for USR Sportster TA!\n",
-				unit, unit);
-		return(ENXIO);	
-	}
-
-	sc = &l1_sc[unit];			/* get pointer to softc */
-	sc->sc_unit = unit;			/* set unit */
-
-	/* see if an io base was supplied */
-	
-	if(!(sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get iobase for USR Sportster TA!\n",
-				unit);
-		return(ENXIO);
-	}
-
-	/* set io base */
-
-	sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
-	
-	/* release io base */
-	
-	bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_resources.io_rid[0],
-		sc->sc_resources.io_base[0]);
-
-
-	/* check if we got an iobase */
-
-	switch(sc->sc_port)
-	{
-		case 0x200:
-		case 0x208:
-		case 0x210:
-		case 0x218:
-		case 0x220:
-		case 0x228:
-		case 0x230:
-		case 0x238:
-		case 0x240:
-		case 0x248:
-		case 0x250:
-		case 0x258:
-		case 0x260:
-		case 0x268:
-		case 0x270:
-		case 0x278:
-			break;
-			
-		default:
-			printf("isic%d: Error, invalid iobase 0x%x specified for USR Sportster TA!\n",
-				unit, sc->sc_port);
-			return(0);
-			break;
-	}
-
-	/* allocate all the ports needed */
-
-	if(usrtai_alloc_port(dev))
-	{
-		printf("isic%d: Could not get the ports for USR Sportster TA!\n", unit);
-		isic_detach_common(dev);
-		return(ENXIO);
-	}
-
-	/* get our irq */
-
-	if(!(sc->sc_resources.irq =
-		bus_alloc_resource_any(dev, SYS_RES_IRQ,
-				       &sc->sc_resources.irq_rid,
-				       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get an irq for USR Sportster TA!\n",unit);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	/* get the irq number */
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-
-	/* register interrupt routine */
-	bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET,
-			(void(*)(void *))(isicintr),
-			sc, &ih);
-
-	/* check IRQ validity */
-
-	if(intr_no[sc->sc_irq] == 0)
-	{
-		printf("isic%d: Error, invalid IRQ [%d] specified for USR Sportster TA!\n",
-			unit, sc->sc_irq);
-		return(1);
-	}
-
-	/* setup ISAC access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = usrtai_read_reg;
-	sc->writereg = usrtai_write_reg;
-
-	sc->readfifo = usrtai_read_fifo;
-	sc->writefifo = usrtai_write_fifo;
-
-	/* setup card type */
-
-	sc->sc_cardtyp = CARD_TYPEP_USRTA;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-	
-	/* setup ISAC and HSCX base addr */
-	
-	ISAC_BASE   = (caddr_t)sc->sc_port + USR_ISAC_OFF;
-	HSCX_A_BASE = (caddr_t)sc->sc_port + USR_HSCXA_OFF;
-	HSCX_B_BASE = (caddr_t)sc->sc_port + USR_HSCXB_OFF;
-
-	/* 
-	 * Read HSCX A/B VSTR.  Expected value for USR Sportster TA based
-	 * boards is 0x05 in the least significant bits.
-	 */
-
-	if( ((HSCX_READ(0, H_VSTR) & 0xf) != 0x5) ||
-            ((HSCX_READ(1, H_VSTR) & 0xf) != 0x5) )
-	{
-		printf("isic%d: HSCX VSTR test failed for USR Sportster TA\n",
-			unit);
-		printf("isic%d: HSC0: VSTR: %#x\n",
-			unit, HSCX_READ(0, H_VSTR));
-		printf("isic%d: HSC1: VSTR: %#x\n",
-			unit, HSCX_READ(1, H_VSTR));
-		return (1);
-	}                   
-	
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_usrtai - attach USR
- *---------------------------------------------------------------------------*/
-int
-isic_attach_usrtai(device_t dev)
-{
-	u_char irq = 0;
-	size_t unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = 0;	/* pointer to softc */
-	
-	sc = &l1_sc[unit];			/* get pointer to softc */
-
-	/* reset the HSCX and ISAC chips */
-	
-	outb(sc->sc_port + USR_INTL_OFF, USR_RES_BIT);
-	DELAY(SEC_DELAY / 10);
-
-	outb(sc->sc_port + USR_INTL_OFF, 0x00);
-	DELAY(SEC_DELAY / 10);
-
-	/* setup IRQ */
-
-	if((irq = intr_no[sc->sc_irq]) == 0)
-	{
-		printf("isic%d: Attach error, invalid IRQ [%d] specified for USR Sportster TA!\n",
-			unit, sc->sc_irq);
-		return(1);
-	}
-
-	/* configure and enable irq */
-
-	outb(sc->sc_port + USR_INTL_OFF, irq | USR_INTE_BIT);
-	DELAY(SEC_DELAY / 10);
-
-	return (0);
-}
-
-#endif /* defined(USR_STI) */
--- sys/i4b/layer1/isic/i4b_hscx.c
+++ /dev/null
@@ -1,648 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b - Siemens HSCX chip (B-channel) handling
- *	--------------------------------------------
- *      last edit-date: [Sat Mar  9 16:01:49 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_hscx.c,v 1.11 2005/01/06 22:18:20 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-/*---------------------------------------------------------------------------*
- *	HSCX IRQ Handler
- *---------------------------------------------------------------------------*/
-void
-isic_hscx_irq(register struct l1_softc *sc, u_char ista, int h_chan, u_char ex_irq)
-{
-	register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	u_char exir = 0;
-	int activity = -1;
-	u_char cmd = 0;
-
-	NDBGL1(L1_H_IRQ, "%#x", ista);
-
-	if(ex_irq)
-	{
-		/* get channel extended irq reg */
-
-		exir = HSCX_READ(h_chan, H_EXIR);
-
-		if(exir & HSCX_EXIR_RFO)
-		{
-			chan->stat_RFO++;
-			NDBGL1(L1_H_XFRERR, "ex_irq: receive data overflow");
-		}
-
-		if((exir & HSCX_EXIR_XDU) && (chan->bprot != BPROT_NONE))/* xmit data underrun */
-		{
-			chan->stat_XDU++;			
-			NDBGL1(L1_H_XFRERR, "ex_irq: xmit data underrun");
-			isic_hscx_cmd(sc, h_chan, HSCX_CMDR_XRES);
-
-			if (chan->out_mbuf_head != NULL)  /* don't continue to transmit this buffer */
-			{
-				i4b_Bfreembuf(chan->out_mbuf_head);
-				chan->out_mbuf_cur = chan->out_mbuf_head = NULL;
-			}
-		}
-
-	}
-
-	/* rx message end, end of frame */
-	
-	if(ista & HSCX_ISTA_RME)
-	{
-		register int fifo_data_len;
-		u_char rsta;		
-		int error = 0;
-
-		rsta = HSCX_READ(h_chan, H_RSTA);
-
-		if((rsta & 0xf0) != 0xa0)
-		{
-			if((rsta & HSCX_RSTA_VFR) == 0)
-			{
-				chan->stat_VFR++;
-				cmd |= (HSCX_CMDR_RHR);
-				NDBGL1(L1_H_XFRERR, "received invalid Frame");
-				error++;
-			}
-	
-			if(rsta & HSCX_RSTA_RDO)
-			{
-				chan->stat_RDO++;
-				NDBGL1(L1_H_XFRERR, "receive data overflow");
-				error++;				
-			}
-			
-			if((rsta & HSCX_RSTA_CRC) == 0)
-			{
-				chan->stat_CRC++;
-				cmd |= (HSCX_CMDR_RHR);
-				NDBGL1(L1_H_XFRERR, "CRC check failed");
-				error++;
-			}
-			
-			if(rsta & HSCX_RSTA_RAB)
-			{
-				chan->stat_RAB++;				
-				NDBGL1(L1_H_XFRERR, "Receive message aborted");
-				error++;
-			}
-		}
-
-		fifo_data_len = ((HSCX_READ(h_chan, H_RBCL)) &
-						((sc->sc_bfifolen)-1));
-		
-		if(fifo_data_len == 0)
-			fifo_data_len = sc->sc_bfifolen;
-
-		/* all error conditions checked, now decide and take action */
-		
-		if(error == 0)
-		{
-			if(chan->in_mbuf == NULL)
-			{
-				if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-					panic("L1 isic_hscx_irq: RME, cannot allocate mbuf!\n");
-				chan->in_cbptr = chan->in_mbuf->m_data;
-				chan->in_len = 0;
-			}
-
-			fifo_data_len -= 1; /* last byte in fifo is RSTA ! */
-			
-			if((chan->in_len + fifo_data_len) <= BCH_MAX_DATALEN)
-			{
-				/* read data from HSCX fifo */
-	
-				HSCX_RDFIFO(h_chan, chan->in_cbptr, fifo_data_len);
-
-				cmd |= (HSCX_CMDR_RMC);
-				isic_hscx_cmd(sc, h_chan, cmd);
-				cmd = 0;
-				
-		                chan->in_len += fifo_data_len;
-				chan->rxcount += fifo_data_len;
-
-				/* setup mbuf data length */
-					
-				chan->in_mbuf->m_len = chan->in_len;
-				chan->in_mbuf->m_pkthdr.len = chan->in_len;
-		
-				if(sc->sc_trace & TRACE_B_RX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0ISICUNIT(sc->sc_unit);
-					hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_NT;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-				}
-
-				(*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
-
-				activity = ACT_RX;
-				
-				/* mark buffer ptr as unused */
-					
-				chan->in_mbuf = NULL;
-				chan->in_cbptr = NULL;
-				chan->in_len = 0;
-			}
-			else
-			{
-				NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RME, in_len=%d, fifolen=%d", chan->in_len, fifo_data_len);
-				chan->in_cbptr = chan->in_mbuf->m_data;
-				chan->in_len = 0;
-				cmd |= (HSCX_CMDR_RHR | HSCX_CMDR_RMC);	
-			}
-		}
-		else
-		{
-			if (chan->in_mbuf != NULL)
-			{
-				i4b_Bfreembuf(chan->in_mbuf);
-				chan->in_mbuf = NULL;
-				chan->in_cbptr = NULL;
-				chan->in_len = 0;
-			}
-			cmd |= (HSCX_CMDR_RMC);
-		}
-	}
-
-	/* rx fifo full */
-
-	if(ista & HSCX_ISTA_RPF)
-	{
-		if(chan->in_mbuf == NULL)
-		{
-			if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-				panic("L1 isic_hscx_irq: RPF, cannot allocate mbuf!\n");
-			chan->in_cbptr = chan->in_mbuf->m_data;
-			chan->in_len = 0;
-		}
-
-		chan->rxcount += sc->sc_bfifolen;
-		
-		if((chan->in_len + sc->sc_bfifolen) <= BCH_MAX_DATALEN)
-		{
-			/* read data from HSCX fifo */
-
-			HSCX_RDFIFO(h_chan, chan->in_cbptr, sc->sc_bfifolen);
-
-			chan->in_cbptr += sc->sc_bfifolen;
-	                chan->in_len += sc->sc_bfifolen;
-		}
-		else
-		{
-			if(chan->bprot == BPROT_NONE)
-			{
-				/* setup mbuf data length */
-				
-				chan->in_mbuf->m_len = chan->in_len;
-				chan->in_mbuf->m_pkthdr.len = chan->in_len;
-
-				if(sc->sc_trace & TRACE_B_RX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0ISICUNIT(sc->sc_unit);
-					hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_NT;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-				}
-
-				/* silence detection */
-				
-				if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len)))
-					activity = ACT_RX;
-
-				(void) IF_HANDOFF(&chan->rx_queue, chan->in_mbuf, NULL);
-
-				/* signal upper driver that data is available */
-
-				(*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
-				
-				/* alloc new buffer */
-				
-				if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-					panic("L1 isic_hscx_irq: RPF, cannot allocate new mbuf!\n");
-	
-				/* setup new data ptr */
-				
-				chan->in_cbptr = chan->in_mbuf->m_data;
-	
-				/* read data from HSCX fifo */
-	
-				HSCX_RDFIFO(h_chan, chan->in_cbptr, sc->sc_bfifolen);
-
-				chan->in_cbptr += sc->sc_bfifolen;
-				chan->in_len = sc->sc_bfifolen;
-
-				chan->rxcount += sc->sc_bfifolen;
-			}
-			else
-			{
-				NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RPF, in_len=%d", chan->in_len);
-				chan->in_cbptr = chan->in_mbuf->m_data;
-				chan->in_len = 0;
-				cmd |= (HSCX_CMDR_RHR);
-			}
-		}
-		
-		/* command to release fifo space */
-		
-		cmd |= HSCX_CMDR_RMC;
-	}
-
-	/* transmit fifo empty, new data can be written to fifo */
-	
-	if(ista & HSCX_ISTA_XPR)
-	{
-		/*
-		 * for a description what is going on here, please have
-		 * a look at isic_bchannel_start() in i4b_bchan.c !
-		 */
-		 
-		int activity = -1;
-		int len;
-		int nextlen;
-
-		NDBGL1(L1_H_IRQ, "unit %d, chan %d - XPR, Tx Fifo Empty!", sc->sc_unit, h_chan);
-
-		if(chan->out_mbuf_cur == NULL) 	/* last frame is transmitted */
-		{
-			IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-
-			if(chan->out_mbuf_head == NULL)
-			{
-				chan->state &= ~HSCX_TX_ACTIVE;
-				(*chan->isic_drvr_linktab->bch_tx_queue_empty)(chan->isic_drvr_linktab->unit);
-			}
-			else
-			{
-				chan->state |= HSCX_TX_ACTIVE;
-				chan->out_mbuf_cur = chan->out_mbuf_head;
-				chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-				chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-
-				if(sc->sc_trace & TRACE_B_TX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0ISICUNIT(sc->sc_unit);
-					hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_TE;
-					hdr.count = ++sc->sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-				}
-				
-				if(chan->bprot == BPROT_NONE)
-				{
-					if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-						activity = ACT_TX;
-				}
-				else
-				{
-					activity = ACT_TX;
-				}
-			}
-		}
-			
-		len = 0;
-
-		while(chan->out_mbuf_cur && len != sc->sc_bfifolen)
-		{
-			nextlen = min(chan->out_mbuf_cur_len, sc->sc_bfifolen - len);
-
-#ifdef NOTDEF			
-			printf("i:mh=%x, mc=%x, mcp=%x, mcl=%d l=%d nl=%d # ",
-				chan->out_mbuf_head,
-				chan->out_mbuf_cur,			
-				chan->out_mbuf_cur_ptr,
-				chan->out_mbuf_cur_len,
-				len,
-				next_len);
-#endif
-
-			isic_hscx_waitxfw(sc, h_chan);	/* necessary !!! */
-			
-			HSCX_WRFIFO(h_chan, chan->out_mbuf_cur_ptr, nextlen);
-			cmd |= HSCX_CMDR_XTF;
-	
-			len += nextlen;
-			chan->txcount += nextlen;
-	
-			chan->out_mbuf_cur_ptr += nextlen;
-			chan->out_mbuf_cur_len -= nextlen;
-			
-			if(chan->out_mbuf_cur_len == 0) 
-			{
-				if((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL)
-				{
-					chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-					chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	
-					if(sc->sc_trace & TRACE_B_TX)
-					{
-						i4b_trace_hdr_t hdr;
-						hdr.unit = L0ISICUNIT(sc->sc_unit);
-						hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-						hdr.dir = FROM_TE;
-						hdr.count = ++sc->sc_trace_bcount;
-						MICROTIME(hdr.time);
-						i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-					}
-				}
-				else
-				{
-					if (chan->bprot != BPROT_NONE)
-						cmd |= HSCX_CMDR_XME;
-					i4b_Bfreembuf(chan->out_mbuf_head);
-					chan->out_mbuf_head = NULL;
-				}
-
-			}
-		}
-	}
-
-	if(cmd)		/* is there a command for the HSCX ? */
-	{
-		isic_hscx_cmd(sc, h_chan, cmd);	/* yes, to HSCX */
-	}
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
-}
-
-/*---------------------------------------------------------------------------*
- *	HSCX initialization
- *
- *	for telephony: extended transparent mode 1
- *	for raw hdlc:  transparent mode 0
- *---------------------------------------------------------------------------*/
-void
-isic_hscx_init(struct l1_softc *sc, int h_chan, int activate)
-{	
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-
-	HSCX_WRITE(h_chan, H_MASK, 0xff);		/* mask irq's */
-
-	if(sc->sc_ipac)
-	{
-		/* CCR1: Power Up, Clock Mode 5 */
-		HSCX_WRITE(h_chan, H_CCR1, HSCX_CCR1_PU  |	/* power up */
-			      HSCX_CCR1_CM1);	/* IPAC clock mode 5 */
-	}
-	else
-	{
-		/* CCR1: Power Up, Clock Mode 5 */
-		HSCX_WRITE(h_chan, H_CCR1, HSCX_CCR1_PU  |	/* power up */
-			      HSCX_CCR1_CM2 |	/* HSCX clock mode 5 */
-			      HSCX_CCR1_CM0);
-	}
-		
-	/* XAD1: Transmit Address Byte 1 */
-	HSCX_WRITE(h_chan, H_XAD1, 0xff);
-	
-	/* XAD2: Transmit Address Byte 2 */
-	HSCX_WRITE(h_chan, H_XAD2, 0xff);
-
-	/* RAH2: Receive Address Byte High Reg. 2 */
-	HSCX_WRITE(h_chan, H_RAH2, 0xff);
-	
-	/* XBCH: reset Transmit Byte Count High */
-	HSCX_WRITE(h_chan, H_XBCH, 0x00);
-	
-	/* RLCR: reset Receive Length Check Register */
-	HSCX_WRITE(h_chan, H_RLCR, 0x00);
-	
-	/* CCR2: set tx/rx clock shift bit 0	*/
-	/*       disable CTS irq, disable RIE irq*/
-	HSCX_WRITE(h_chan, H_CCR2, HSCX_CCR2_XCS0|HSCX_CCR2_RCS0);
-
-	/* XCCR: tx bit count per time slot */
-	HSCX_WRITE(h_chan, H_XCCR, 0x07);
-
-	/* RCCR: rx bit count per time slot */
-	HSCX_WRITE(h_chan, H_RCCR, 0x07);
-	
-	if(sc->sc_bustyp == BUS_TYPE_IOM2)
-	{
-		switch(h_chan) 
-		{
-			case HSCX_CH_A:	/* Prepare HSCX channel A */
-				/* TSAX: tx clock shift bits 1 & 2	*/
-				/*       tx time slot number		*/
-		        	HSCX_WRITE(h_chan, H_TSAX, 0x2f);
-
-				/* TSAR: rx clock shift bits 1 & 2	*/
-				/*       rx time slot number		*/
-				HSCX_WRITE(h_chan, H_TSAR, 0x2f);
-				break;
-
-			case HSCX_CH_B: /* Prepare HSCX channel B */
-				/* TSAX: tx clock shift bits 1 & 2	*/
-				/*       tx time slot number		*/
-				HSCX_WRITE(h_chan, H_TSAX, 0x03);
-
-				/* TSAR: rx clock shift bits 1 & 2	*/
-				/*       rx time slot number		*/
-				HSCX_WRITE(h_chan, H_TSAR, 0x03);
-				break;
-		}
-	}
-	else	/* IOM 1 setup */
-	{
-		/* TSAX: tx clock shift bits 1 & 2	*/
-		/*       tx time slot number		*/
-		HSCX_WRITE(h_chan, H_TSAX, 0x07);
-
-		/* TSAR: rx clock shift bits 1 & 2	*/
-		/*       rx time slot number		*/
-		HSCX_WRITE(h_chan, H_TSAR, 0x07);
-	}
-
-	if(activate)
-	{
-		if(chan->bprot == BPROT_RHDLC)
-		{
-		  /* HDLC Frames, transparent mode 0 */
-		  HSCX_WRITE(h_chan, H_MODE,
-		     HSCX_MODE_MDS1|HSCX_MODE_RAC|HSCX_MODE_RTS);
-		}
-		else
-		{
-		  /* Raw Telephony, extended transparent mode 1 */
-		  HSCX_WRITE(h_chan, H_MODE,
-		     HSCX_MODE_MDS1|HSCX_MODE_MDS0|HSCX_MODE_ADM|HSCX_MODE_RTS);
-		}
-#if 0
-		isic_hscx_cmd(sc, h_chan, HSCX_CMDR_RHR|HSCX_CMDR_XRES);
-#else
-		isic_hscx_cmd(sc, h_chan, HSCX_CMDR_RHR);
-#endif
-	}
-	else
-	{
-		/* TSAX: tx time slot */
-		HSCX_WRITE(h_chan, H_TSAX, 0xff);
-
-		/* TSAR: rx time slot */
-		HSCX_WRITE(h_chan, H_TSAR, 0xff);
-
-		/* Raw Telephony, extended transparent mode 1 */
-		HSCX_WRITE(h_chan, H_MODE,
-		   HSCX_MODE_MDS1|HSCX_MODE_MDS0|HSCX_MODE_ADM|HSCX_MODE_RTS);
-	}
-
- 	/* don't touch ICA, EXA and EXB bits, this could be HSCX_CH_B */	
-	/* always disable RSC and TIN */
-
-	chan->hscx_mask |= HSCX_MASK_RSC | HSCX_MASK_TIN;
-
-	if(activate)
-	{
-		/* enable */
-		chan->hscx_mask &= ~(HSCX_MASK_RME | HSCX_MASK_RPF | HSCX_MASK_XPR);
-	}
-	else
-	{
-		/* disable */
-		chan->hscx_mask |= HSCX_MASK_RME | HSCX_MASK_RPF | HSCX_MASK_XPR;
-	}
-
-	/* handle ICA, EXA, and EXB via interrupt mask of channel b */
-
-	if (h_chan == HSCX_CH_A)
-	{
-		if (activate) 
-			HSCX_B_IMASK &= ~(HSCX_MASK_EXA | HSCX_MASK_ICA);
-		else
-			HSCX_B_IMASK |= HSCX_MASK_EXA | HSCX_MASK_ICA;
-		HSCX_WRITE(HSCX_CH_A, H_MASK, HSCX_A_IMASK);
-		HSCX_WRITE(HSCX_CH_B, H_MASK, HSCX_B_IMASK);
-	}
-	else
-	{
-		if (activate)
-			HSCX_B_IMASK &= ~HSCX_MASK_EXB;
-		else
-			HSCX_B_IMASK |= HSCX_MASK_EXB;
-		HSCX_WRITE(HSCX_CH_B, H_MASK, HSCX_B_IMASK);
-	}
-
-	/* clear spurious interrupts left over */
-
-	if(h_chan == HSCX_CH_A)
-	{
-		HSCX_READ(h_chan, H_EXIR);
-		HSCX_READ(h_chan, H_ISTA);
-	}
-	else  /* mask ICA, because it must not be cleared by reading ISTA */
-	{
-		HSCX_WRITE(HSCX_CH_B, H_MASK, HSCX_B_IMASK | HSCX_MASK_ICA);
-		HSCX_READ(h_chan, H_EXIR);
-		HSCX_READ(h_chan, H_ISTA);
-		HSCX_WRITE(HSCX_CH_B, H_MASK, HSCX_B_IMASK);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	write command to HSCX command register
- *---------------------------------------------------------------------------*/
-void
-isic_hscx_cmd(struct l1_softc *sc, int h_chan, unsigned char cmd)
-{	
-	int timeout = 20;
-
-	while(((HSCX_READ(h_chan, H_STAR)) & HSCX_STAR_CEC) && timeout)
-	{
-		DELAY(10);
-		timeout--;
-	}
-
-	if(timeout == 0)
-	{
-		NDBGL1(L1_H_ERR, "HSCX wait for CEC timeout!");
-	}
-
-	HSCX_WRITE(h_chan, H_CMDR, cmd);	
-}
-
-/*---------------------------------------------------------------------------*
- *	wait for HSCX transmit FIFO write enable
- *---------------------------------------------------------------------------*/
-void
-isic_hscx_waitxfw(struct l1_softc *sc, int h_chan)
-{	
-#define WAITVAL 50
-#define WAITTO	200
-
-	int timeout = WAITTO;
-
-	while((!(((HSCX_READ(h_chan, H_STAR)) &
-		(HSCX_STAR_CEC | HSCX_STAR_XFW)) == HSCX_STAR_XFW)) && timeout)
-	{
-		DELAY(WAITVAL);
-		timeout--;
-	}
-
-	if(timeout == 0)
-	{
-		NDBGL1(L1_H_ERR, "HSCX wait for XFW timeout!");
-	}
-	else if (timeout != WAITTO)
-	{
-		NDBGL1(L1_H_XFRERR, "HSCX wait for XFW time: %d uS", (WAITTO-timeout)*50);
-	}
-}
--- sys/i4b/layer1/isic/i4b_elsa_qs1i.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	isic - I4B Siemens ISDN Chipset Driver for ELSA Quickstep 1000pro ISA
- *	=====================================================================
- *      last edit-date: [Wed Jan 24 09:09:03 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_elsa_qs1i.c,v 1.8 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(ELSA_QS1ISA)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-static void i4b_eq1i_clrirq(struct l1_softc *sc);
-
-/* masks for register encoded in base addr */
-
-#define ELSA_BASE_MASK		0x0ffff
-#define ELSA_OFF_MASK		0xf0000
-
-/* register id's to be encoded in base addr */
-
-#define ELSA_IDISAC		0x00000
-#define ELSA_IDHSCXA		0x10000
-#define ELSA_IDHSCXB		0x20000
-
-/* offsets from base address */
-
-#define ELSA_OFF_ISAC		0x00
-#define ELSA_OFF_HSCX		0x02
-#define ELSA_OFF_OFF		0x03
-#define ELSA_OFF_CTRL		0x04
-#define ELSA_OFF_CFG		0x05
-#define ELSA_OFF_TIMR		0x06
-#define ELSA_OFF_IRQ		0x07
-
-/* control register (write access) */
-
-#define ELSA_CTRL_LED_YELLOW	0x02
-#define ELSA_CTRL_LED_GREEN	0x08
-#define ELSA_CTRL_RESET		0x20
-#define ELSA_CTRL_TIMEREN	0x80
-#define ELSA_CTRL_SECRET	0x50
-
-/*---------------------------------------------------------------------------*
- *      ELSA QuickStep 1000pro/ISA clear IRQ routine
- *---------------------------------------------------------------------------*/
-static void
-i4b_eq1i_clrirq(struct l1_softc *sc)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_write_1(t, h, ELSA_OFF_IRQ, 0);
-}
-
-/*---------------------------------------------------------------------------*
- *      ELSA QuickStep 1000pro/ISA ISAC get fifo routine
- *---------------------------------------------------------------------------*/
-static void
-eqs1pi_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
-			bus_space_read_multi_1(t, h, ELSA_OFF_ISAC, buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
-			bus_space_read_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40);
-			bus_space_read_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      ELSA QuickStep 1000pro/ISA ISAC put fifo routine
- *---------------------------------------------------------------------------*/
-static void
-eqs1pi_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
-			bus_space_write_multi_1(t, h, ELSA_OFF_ISAC, buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
-			bus_space_write_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40);
-			bus_space_write_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      ELSA QuickStep 1000pro/ISA ISAC put register routine
- *---------------------------------------------------------------------------*/
-static void
-eqs1pi_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
-			bus_space_write_1(t, h, ELSA_OFF_ISAC, data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
-			bus_space_write_1(t, h, ELSA_OFF_HSCX, data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40+offs);
-			bus_space_write_1(t, h, ELSA_OFF_HSCX, data);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	ELSA QuickStep 1000pro/ISA ISAC get register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-eqs1pi_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
-			return bus_space_read_1(t, h, ELSA_OFF_ISAC);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
-			return bus_space_read_1(t, h, ELSA_OFF_HSCX);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40+offs);
-			return bus_space_read_1(t, h, ELSA_OFF_HSCX);
-	}
-	return 0;
-}
-
-/*---------------------------------------------------------------------------*
- * isic_attach_Eqs1pi - attach for ELSA QuickStep 1000pro/ISA
- *---------------------------------------------------------------------------*/
-int
-isic_attach_Eqs1pi(device_t dev)
-{
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];	
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	u_char byte = ELSA_CTRL_SECRET;
-
-	/* setup access routines */
-
-	sc->clearirq = i4b_eq1i_clrirq;
-	sc->readreg = eqs1pi_read_reg;
-	sc->writereg = eqs1pi_write_reg;
-
-	sc->readfifo = eqs1pi_read_fifo;
-	sc->writefifo = eqs1pi_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_ELSAQS1ISA;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;	
-
-	/* enable the card */
-	
-	byte &= ~ELSA_CTRL_RESET;
-        bus_space_write_1(t, h, ELSA_OFF_CTRL, byte);
-        DELAY(20);
-	byte |= ELSA_CTRL_RESET;
-        bus_space_write_1(t, h, ELSA_OFF_CTRL, byte);
-
-        DELAY(20);
-        bus_space_write_1(t, h, ELSA_OFF_IRQ, 0xff);
-
-	return 0;
-}
-#endif /* defined(ELSA_QS1ISA) */
--- sys/i4b/layer1/isic/i4b_bchan.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_bchan.c - B channel handling L1 procedures
- *	----------------------------------------------
- *      last edit-date: [Sat Mar  9 16:00:56 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_bchan.c,v 1.13 2005/01/06 22:18:20 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-static void isic_bchannel_start(int unit, int h_chan);
-static void isic_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp);
-
-/*---------------------------------------------------------------------------*
- *	initialize one B channels rx/tx data structures and init/deinit HSCX
- *---------------------------------------------------------------------------*/
-void
-isic_bchannel_setup(int unit, int h_chan, int bprot, int activate)
-{
-	struct l1_softc *sc = &l1_sc[unit];
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-
-	int s = SPLI4B();
-	
-	if(activate == 0)
-	{
-		/* deactivation */
-		isic_hscx_init(sc, h_chan, activate);
-	}
-		
-	NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
-		sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
-
-	/* general part */
-
-	chan->unit = sc->sc_unit;	/* unit number */
-	chan->channel = h_chan;	/* B channel */
-	chan->bprot = bprot;		/* B channel protocol */
-	chan->state = HSCX_IDLE;	/* B channel state */
-
-	/* receiver part */
-
-	chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-	if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
-		mtx_init(&chan->rx_queue.ifq_mtx, "i4b_isic_rx", NULL, MTX_DEF);
-
-	i4b_Bcleanifq(&chan->rx_queue);	/* clean rx queue */
-
-	chan->rxcount = 0;		/* reset rx counter */
-	
-	i4b_Bfreembuf(chan->in_mbuf);	/* clean rx mbuf */
-
-	chan->in_mbuf = NULL;		/* reset mbuf ptr */
-	chan->in_cbptr = NULL;		/* reset mbuf curr ptr */
-	chan->in_len = 0;		/* reset mbuf data len */
-	
-	/* transmitter part */
-
-	chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-	if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
-		mtx_init(&chan->tx_queue.ifq_mtx, "i4b_isic_tx", NULL, MTX_DEF);
-	
-	i4b_Bcleanifq(&chan->tx_queue);	/* clean tx queue */
-
-	chan->txcount = 0;		/* reset tx counter */
-	
-	i4b_Bfreembuf(chan->out_mbuf_head);	/* clean tx mbuf */
-
-	chan->out_mbuf_head = NULL;	/* reset head mbuf ptr */
-	chan->out_mbuf_cur = NULL;	/* reset current mbuf ptr */	
-	chan->out_mbuf_cur_ptr = NULL;	/* reset current mbuf data ptr */
-	chan->out_mbuf_cur_len = 0;	/* reset current mbuf data cnt */
-	
-	if(activate != 0)
-	{
-		/* activation */
-		isic_hscx_init(sc, h_chan, activate);
-	}
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	start transmission on a b channel
- *---------------------------------------------------------------------------*/
-static void
-isic_bchannel_start(int unit, int h_chan)
-{
-	struct l1_softc *sc = &l1_sc[unit];
-	register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	register int next_len;
-	register int len;
-
-	int s;
-	int activity = -1;
-	int cmd = 0;
-
-	s = SPLI4B();				/* enter critical section */
-	if(chan->state & HSCX_TX_ACTIVE)	/* already running ? */
-	{
-		splx(s);
-		return;				/* yes, leave */
-	}
-
-	/* get next mbuf from queue */
-	
-	IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-	
-	if(chan->out_mbuf_head == NULL)		/* queue empty ? */
-	{
-		splx(s);			/* leave critical section */
-		return;				/* yes, exit */
-	}
-
-	/* init current mbuf values */
-	
-	chan->out_mbuf_cur = chan->out_mbuf_head;
-	chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;	
-	
-	/* activity indicator for timeout handling */
-
-	if(chan->bprot == BPROT_NONE)
-	{
-		if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-			activity = ACT_TX;
-	}
-	else
-	{
-		activity = ACT_TX;
-	}
-
-	chan->state |= HSCX_TX_ACTIVE;		/* we start transmitting */
-	
-	if(sc->sc_trace & TRACE_B_TX)	/* if trace, send mbuf to trace dev */
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0ISICUNIT(unit);
-		hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_bcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-	}			
-
-	len = 0;	/* # of chars put into HSCX tx fifo this time */
-
-	/*
-	 * fill the HSCX tx fifo with data from the current mbuf. if
-	 * current mbuf holds less data than HSCX fifo length, try to
-	 * get the next mbuf from (a possible) mbuf chain. if there is
-	 * not enough data in a single mbuf or in a chain, then this
-	 * is the last mbuf and we tell the HSCX that it has to send
-	 * CRC and closing flag
-	 */
-	 
-	while((len < sc->sc_bfifolen) && chan->out_mbuf_cur)
-	{
-		/*
-		 * put as much data into the HSCX fifo as is
-		 * available from the current mbuf
-		 */
-		 
-		if((len + chan->out_mbuf_cur_len) >= sc->sc_bfifolen)
-			next_len = sc->sc_bfifolen - len;
-		else
-			next_len = chan->out_mbuf_cur_len;
-
-#ifdef NOTDEF		
-		printf("b:mh=%x, mc=%x, mcp=%x, mcl=%d l=%d nl=%d # ",
-			chan->out_mbuf_head,
-			chan->out_mbuf_cur,			
-			chan->out_mbuf_cur_ptr,
-			chan->out_mbuf_cur_len,
-			len,
-			next_len);
-#endif
-
-		/* wait for tx fifo write enabled */
-
-		isic_hscx_waitxfw(sc, h_chan);
-
-		/* write what we have from current mbuf to HSCX fifo */
-
-		HSCX_WRFIFO(h_chan, chan->out_mbuf_cur_ptr, next_len);
-
-		len += next_len;		/* update # of bytes written */
-		chan->txcount += next_len;	/* statistics */
-		chan->out_mbuf_cur_ptr += next_len;	/* data ptr */
-		chan->out_mbuf_cur_len -= next_len;	/* data len */
-
-		/*
-		 * in case the current mbuf (of a possible chain) data
-		 * has been put into the fifo, check if there is a next
-		 * mbuf in the chain. If there is one, get ptr to it
-		 * and update the data ptr and the length
-		 */
-		 
-		if((chan->out_mbuf_cur_len <= 0)	&&
-		  ((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL))
-		{
-			chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-			chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-
-			if(sc->sc_trace & TRACE_B_TX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0ISICUNIT(unit);
-				hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-				hdr.dir = FROM_TE;
-				hdr.count = ++sc->sc_trace_bcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-			}			
-		}
-	}
-
-	/*
-	 * if there is either still data in the current mbuf and/or
-	 * there is a successor on the chain available issue just
-	 * a XTF (transmit) command to HSCX. if ther is no more
-	 * data available from the current mbuf (-chain), issue
-	 * an XTF and an XME (message end) command which will then
-	 * send the CRC and the closing HDLC flag sequence
-	 */
-	 
-	if(chan->out_mbuf_cur && (chan->out_mbuf_cur_len > 0))
-	{
-		/*
-		 * more data available, send current fifo out.
-		 * next xfer to HSCX tx fifo is done in the
-		 * HSCX interrupt routine.
-		 */
-		 
-		cmd |= HSCX_CMDR_XTF;
-	}
-	else
-	{
-		/* end of mbuf chain */
-	
-		if(chan->bprot == BPROT_NONE)
-			cmd |= HSCX_CMDR_XTF;
-		else
-			cmd |= HSCX_CMDR_XTF | HSCX_CMDR_XME;
-		
-		i4b_Bfreembuf(chan->out_mbuf_head);	/* free mbuf chain */
-		
-		chan->out_mbuf_head = NULL;
-		chan->out_mbuf_cur = NULL;			
-		chan->out_mbuf_cur_ptr = NULL;
-		chan->out_mbuf_cur_len = 0;
-	}
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
-
-	if(cmd)
-		isic_hscx_cmd(sc, h_chan, cmd);
-		
-	splx(s);	
-}
-
-/*---------------------------------------------------------------------------*
- *	fill statistics struct
- *---------------------------------------------------------------------------*/
-static void
-isic_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp)
-{
-	struct l1_softc *sc = &l1_sc[unit];
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int s;
-
-	s = SPLI4B();
-	
-	bsp->outbytes = chan->txcount;
-	bsp->inbytes = chan->rxcount;
-
-	chan->txcount = 0;
-	chan->rxcount = 0;
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	return the address of isic drivers linktab	
- *---------------------------------------------------------------------------*/
-isdn_link_t *
-isic_ret_linktab(int unit, int channel)
-{
-	struct l1_softc *sc = &l1_sc[unit];
-	l1_bchan_state_t *chan = &sc->sc_chan[channel];
-
-	return(&chan->isic_isdn_linktab);
-}
- 
-/*---------------------------------------------------------------------------*
- *	set the driver linktab in the b channel softc
- *---------------------------------------------------------------------------*/
-void
-isic_set_linktab(int unit, int channel, drvr_link_t *dlt)
-{
-	struct l1_softc *sc = &l1_sc[unit];
-	l1_bchan_state_t *chan = &sc->sc_chan[channel];
-
-	chan->isic_drvr_linktab = dlt;
-}
-
-/*---------------------------------------------------------------------------*
- *	initialize our local linktab
- *---------------------------------------------------------------------------*/
-void
-isic_init_linktab(struct l1_softc *sc)
-{
-	l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A];
-	isdn_link_t *lt = &chan->isic_isdn_linktab;
-
-	/* make sure the hardware driver is known to layer 4 */
-	ctrl_types[CTRL_PASSIVE].set_linktab = i4b_l1_set_linktab;
-	ctrl_types[CTRL_PASSIVE].get_linktab = i4b_l1_ret_linktab;
-
-	/* local setup */
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_A;
-	lt->bch_config = isic_bchannel_setup;
-	lt->bch_tx_start = isic_bchannel_start;
-	lt->bch_stat = isic_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-                                                
-	chan = &sc->sc_chan[HSCX_CH_B];
-	lt = &chan->isic_isdn_linktab;
-
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_B;
-	lt->bch_config = isic_bchannel_setup;
-	lt->bch_tx_start = isic_bchannel_start;
-	lt->bch_stat = isic_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-}
--- sys/i4b/layer1/isic/i4b_isic.h
+++ /dev/null
@@ -1,330 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------*
- *
- *	i4b_l1.h - isdn4bsd layer 1 header file
- *	---------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/isic/i4b_isic.h,v 1.5 2005/04/08 03:37:20 nyan Exp $
- *
- *      last edit-date: [Fri Jan 26 13:55:12 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_ISIC_H_
-#define _I4B_ISIC_H_
-
-#include <sys/resource.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#include <machine/resource.h>
-
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer1/isic/i4b_isic_ext.h>
-
-/*---------------------------------------------------------------------------
- *      isic driver: max no of units
- *      Teles/Creatix/Neuhaus cards have a hardware limitation
- *      as one is able to set 3 (sometimes 4) different configurations by
- *      jumpers so a maximum of 3 (4) cards per ISA bus is possible.
- *---------------------------------------------------------------------------*/
-#define ISIC_MAXUNIT	3	/* max no of supported units 0..3 */
-
-#define INFO_IO_BASES	50	/* 49 needed for USR */
-
-struct i4b_info {
-	struct resource * io_base[INFO_IO_BASES];
-	int               io_rid [INFO_IO_BASES];
-	struct resource * irq;
-	int               irq_rid;
-	struct resource * mem;
-	int               mem_rid;
-};
-
-/*---------------------------------------------------------------------------*
- *	l1_bchan_state: the state of one B channel
- *---------------------------------------------------------------------------*/
-typedef struct
-{
-	int		unit;		/* cards unit number	*/
-	int		channel;	/* which channel is this*/
-	caddr_t		hscx;		/* HSCX address		*/
-	u_char		hscx_mask;	/* HSCX interrupt mask	*/
-	int		bprot;		/* B channel protocol	*/
-	int		state;		/* this channels state	*/
-#define HSCX_IDLE	0x00		/* channel idle 	*/
-#define HSCX_TX_ACTIVE	0x01		/* tx running		*/
-
-	/* receive data from ISDN */
-
-	struct ifqueue	rx_queue;	/* receiver queue	*/
-
-	int		rxcount;	/* rx statistics counter*/
-
-	struct	mbuf	*in_mbuf;	/* rx input buffer	*/
-	u_char 		*in_cbptr;	/* curr buffer pointer	*/
-	int		in_len;		/* rx input buffer len	*/
-	
-	/* transmit data to ISDN */
-
-	struct ifqueue	tx_queue;	/* transmitter queue	*/
-
-	int		txcount;	/* tx statistics counter*/
-
-	struct mbuf	*out_mbuf_head;	/* first mbuf in possible chain	*/
-	struct mbuf	*out_mbuf_cur;	/* current mbuf in possbl chain */
-	unsigned char	*out_mbuf_cur_ptr; /* data pointer into mbuf	*/
-	int		out_mbuf_cur_len; /* remaining bytes in mbuf	*/	
-	
-	/* link between b channel and driver */
-	
-	isdn_link_t	isic_isdn_linktab;	/* b channel addresses	*/
-	drvr_link_t	*isic_drvr_linktab;	/* ptr to driver linktab*/
-
-	/* statistics */
-
-	/* RSTA */
-	
-	int		stat_VFR;	/* HSCX RSTA Valid FRame */
-	int		stat_RDO;	/* HSCX RSTA Rx Data Overflow */	
-	int		stat_CRC;	/* HSCX RSTA CRC */
-	int		stat_RAB;	/* HSCX RSTA Rx message ABorted */
-
-	/* EXIR */
-
-	int		stat_XDU;	/* HSCX EXIR tx data underrun */
-	int		stat_RFO;	/* HSCX EXIR rx frame overflow */
-	
-} l1_bchan_state_t;
-
-/*---------------------------------------------------------------------------*
- *	l1_softc: the state of the layer 1 of the D channel
- *---------------------------------------------------------------------------*/
-struct l1_softc
-{
-	int		sc_unit;	/* unit number		*/
-	int		sc_irq;		/* interrupt vector	*/
-	struct i4b_info	sc_resources;
-
-	int		sc_port;	/* port base address	*/
-
-	int		sc_cardtyp;	/* CARD_TYPEP_xxxx	*/
-
-	int		sc_bustyp;	/* IOM1 or IOM2		*/
-#define BUS_TYPE_IOM1  0x01
-#define BUS_TYPE_IOM2  0x02
-
-	int		sc_trace;	/* output protocol data for tracing */
-	unsigned int	sc_trace_dcount;/* d channel trace frame counter */
-	unsigned int	sc_trace_bcount;/* b channel trace frame counter */
-
-	int		sc_state;	/* ISAC state flag	*/
-#define ISAC_IDLE	0x00		/* state = idle */
-#define ISAC_TX_ACTIVE	0x01		/* state = transmitter active */
-
-	int		sc_init_tries;	/* no of out tries to access S0 */
-	
-	caddr_t		sc_vmem_addr;	/* card RAM virtual memory base */
-	caddr_t		sc_isac;	/* ISAC port base addr	*/
-#define ISAC_BASE	(sc->sc_isac)
-
-	caddr_t		sc_ipacbase;	/* IPAC port base addr	*/
-#define IPAC_BASE	(sc->sc_ipacbase)
-
-	u_char		sc_isac_mask;	/* ISAC IRQ mask	*/
-#define ISAC_IMASK	(sc->sc_isac_mask)
-
-	l1_bchan_state_t	sc_chan[2];	/* B-channel state	*/
-#define HSCX_A_BASE	(sc->sc_chan[0].hscx)
-#define HSCX_A_IMASK	(sc->sc_chan[0].hscx_mask)
-#define HSCX_B_BASE	(sc->sc_chan[1].hscx)
-#define HSCX_B_IMASK	(sc->sc_chan[1].hscx_mask)
-
-	struct mbuf	*sc_ibuf;	/* input buffer mgmt	*/
-	u_short		sc_ilen;
-	u_char		*sc_ib;
-					/* this is for the irq TX routine */
-	struct mbuf	*sc_obuf;	/* pointer to an mbuf with TX frame */
-	u_char		*sc_op;		/* ptr to next chunk of frame to tx */
-	int		sc_ol;		/* length of remaining frame to tx */
-	int		sc_freeflag;	/* m_freem mbuf if set */
-
-	struct mbuf	*sc_obuf2;	/* pointer to an mbuf with TX frame */
-	int		sc_freeflag2;	/* m_freem mbuf if set */	
-	
-	int		sc_isac_version;	/* version number of ISAC */
-	int		sc_hscx_version;	/* version number of HSCX */
-	int		sc_ipac_version;	/* version number of IPAC */
-	
-	int		sc_I430state;	/* I.430 state F3 .... F8 */
-
-	int		sc_I430T3;	/* I.430 Timer T3 running */	
-
-	struct callout_handle sc_T3_callout;
-
-	int		sc_I430T4;	/* Timer T4 running */	
-
-	struct callout_handle sc_T4_callout;
-
-	/*
-	 * byte fields for the AVM Fritz!Card PCI. These are packed into
-	 * a u_int in the driver.
-	 */
-	u_char		avma1pp_cmd;
-	u_char		avma1pp_txl;
-	u_char		avma1pp_prot;
-
-	int		sc_enabled;	/* daemon is running */
-
-	int		sc_ipac;	/* flag, running on ipac */
-	int		sc_bfifolen;	/* length of b channel fifos */
-
-#define	ISIC_WHAT_ISAC	0
-#define	ISIC_WHAT_HSCXA	1
-#define	ISIC_WHAT_HSCXB	2
-#define	ISIC_WHAT_IPAC	3
-
-	u_int8_t (*readreg)   (struct l1_softc *sc, int what, bus_size_t offs);
-	void	 (*writereg)  (struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data);
-	void	 (*readfifo)  (struct l1_softc *sc, int what, void *buf, size_t size);
-	void	 (*writefifo) (struct l1_softc *sc, int what, void *data, size_t size);
-	void	 (*clearirq)  (struct l1_softc *sc);
-
-#define	ISAC_READ(r)		(*sc->readreg)(sc, ISIC_WHAT_ISAC, (r))
-#define	ISAC_WRITE(r,v)		(*sc->writereg)(sc, ISIC_WHAT_ISAC, (r), (v))
-#define	ISAC_RDFIFO(b,s)	(*sc->readfifo)(sc, ISIC_WHAT_ISAC, (b), (s))
-#define	ISAC_WRFIFO(b,s)	(*sc->writefifo)(sc, ISIC_WHAT_ISAC, (b), (s))
-
-#define	HSCX_READ(n,r)		(*sc->readreg)(sc, ISIC_WHAT_HSCXA+(n), (r))
-#define	HSCX_WRITE(n,r,v)	(*sc->writereg)(sc, ISIC_WHAT_HSCXA+(n), (r), (v))
-#define	HSCX_RDFIFO(n,b,s)	(*sc->readfifo)(sc, ISIC_WHAT_HSCXA+(n), (b), (s))
-#define	HSCX_WRFIFO(n,b,s)	(*sc->writefifo)(sc, ISIC_WHAT_HSCXA+(n), (b), (s))
-
-#define IPAC_READ(r)		(*sc->readreg)(sc, ISIC_WHAT_IPAC, (r))
-#define IPAC_WRITE(r, v)	(*sc->writereg)(sc, ISIC_WHAT_IPAC, (r), (v))
-};
-
-/*---------------------------------------------------------------------------*
- *	possible I.430/ISAC states
- *---------------------------------------------------------------------------*/
-enum I430states {
-	ST_F3,		/* F3 Deactivated	*/
-	ST_F4,		/* F4 Awaiting Signal	*/
-	ST_F5,		/* F5 Identifying Input */
-	ST_F6,		/* F6 Synchronized	*/
-	ST_F7,		/* F7 Activated		*/
-	ST_F8,		/* F8 Lost Framing	*/
-	ST_ILL,		/* Illegal State	*/	
-	N_STATES
-};
-
-/*---------------------------------------------------------------------------*
- *	possible I.430/ISAC events
- *---------------------------------------------------------------------------*/
-enum I430events {
-	EV_PHAR,	/* PH ACTIVATE REQUEST 		*/
-	EV_T3,		/* Timer 3 expired 		*/
-	EV_INFO0,	/* receiving INFO0 		*/
-	EV_RSY,		/* receiving any signal		*/
-	EV_INFO2,	/* receiving INFO2		*/
-	EV_INFO48,	/* receiving INFO4 pri 8/9 	*/
-	EV_INFO410,	/* receiving INFO4 pri 10/11	*/	
-	EV_DR,		/* Deactivate Request 		*/	
-	EV_PU,		/* Power UP			*/
-	EV_DIS,		/* Disconnected (only 2085) 	*/
-	EV_EI,		/* Error Indication 		*/
-	EV_ILL,		/* Illegal Event 		*/
-	N_EVENTS
-};
-
-enum I430commands {
-	CMD_TIM,	/*	Timing				*/
-	CMD_RS,		/*	Reset				*/
-	CMD_AR8,	/*	Activation request pri 8	*/
-	CMD_AR10,	/*	Activation request pri 10	*/
-	CMD_DIU,	/*	Deactivate Indication Upstream	*/
-	CMD_ILL		/*	Illegal command			*/
-};
-
-#define N_COMMANDS CMD_ILL
-
-extern struct l1_softc l1_sc[];
-
-extern void isicintr(struct l1_softc *sc);
-extern int  isic_attach_common(device_t dev);
-extern void isic_detach_common(device_t dev);
-extern void isic_recover(struct l1_softc *sc);
-
-extern void isic_bchannel_setup (int unit, int hscx_channel, int bprot, int activate );
-
-extern void isic_init_linktab ( struct l1_softc *sc );
-extern int  isic_isac_init ( struct l1_softc *sc );
-extern void isic_isac_irq ( struct l1_softc *sc, int r );
-extern void isic_isac_l1_cmd ( struct l1_softc *sc, int command );
-extern void isic_next_state ( struct l1_softc *sc, int event );
-extern char *isic_printstate ( struct l1_softc *sc );
-
-extern int  isic_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
-extern void isic_hscx_init ( struct l1_softc *sc, int hscx_channel, int activate );
-extern void isic_hscx_irq ( struct l1_softc *sc, u_char ista, int hscx_channel, u_char ex_irq );
-extern int  isic_hscx_silence ( unsigned char *data, int len );
-extern void isic_hscx_cmd( struct l1_softc *sc, int h_chan, unsigned char cmd );
-extern void isic_hscx_waitxfw( struct l1_softc *sc, int h_chan );
-
-extern int  isic_probe_s016 (device_t dev);
-extern int  isic_attach_s016 (device_t dev);
-
-extern int  isic_probe_s08 (device_t dev);
-extern int  isic_attach_s08 (device_t dev);
-
-extern int  isic_probe_Epcc16 (device_t dev);
-extern int  isic_attach_Epcc16 (device_t dev);
-
-extern int  isic_probe_s0163 (device_t dev);
-extern int  isic_attach_s0163 (device_t dev);
-
-extern int  isic_probe_avma1 (device_t dev);
-extern int  isic_attach_avma1 (device_t dev);
-
-extern int  isic_probe_usrtai (device_t dev);
-extern int  isic_attach_usrtai (device_t dev);
-
-extern int  isic_probe_itkix1 (device_t dev);
-extern int  isic_attach_itkix1 (device_t dev);
-
-extern int  isic_attach_drnngo (device_t dev);
-extern int  isic_attach_Cs0P (device_t dev);
-extern int  isic_attach_Eqs1pi(device_t dev);
-extern int  isic_attach_sws(device_t dev);
-extern int  isic_attach_siemens_isurf(device_t dev);
-extern int  isic_attach_asi(device_t dev);
-extern int  isic_attach_Dyn(device_t dev);
-extern int  isic_attach_diva(device_t dev);
-extern int  isic_attach_diva_ipac(device_t dev);
-
-#endif /* _I4B_ISIC_H_ */
--- sys/i4b/layer1/isic/i4b_diva.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/*-
- *   Copyright (c) 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
- *   are met:
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	Eicon Diehl DIVA 2.0 or 2.02 (ISA PnP) support for isic driver
- *	--------------------------------------------------------------
- *      last edit-date: [Fri Jan 26 13:57:10 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_diva.c,v 1.4 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined EICON_DIVA
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_ipac.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-/* offsets from base address */
-
-#define DIVA_IPAC_OFF_ALE	0x00
-#define DIVA_IPAC_OFF_RW	0x01
-
-#define DIVA_ISAC_OFF_RW	0x02
-#define DIVA_ISAC_OFF_ALE	0x06
-
-#define DIVA_HSCX_OFF_RW	0x00
-#define DIVA_HSCX_OFF_ALE	0x04
-
-#define DIVA_CTRL_OFF		0x07
-#define		DIVA_CTRL_RDIST	0x01
-#define		DIVA_CTRL_WRRST	0x08
-#define		DIVA_CTRL_WRLDA	0x20
-#define		DIVA_CTRL_WRLDB	0x40
-#define		DIVA_CTRL_WRICL	0x80
-
-/* HSCX channel base offsets */
-
-#define DIVA_HSCXA		0x00
-#define DIVA_HSCXB		0x40
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.02
- *---------------------------------------------------------------------------*/
-static void 
-diva_ipac_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,IPAC_ISAC_OFF);
-			bus_space_read_multi_1(t,h,DIVA_IPAC_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,IPAC_HSCXA_OFF);
-			bus_space_read_multi_1(t,h,DIVA_IPAC_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,IPAC_HSCXB_OFF);
-			bus_space_read_multi_1(t,h,DIVA_IPAC_OFF_RW,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.02
- *---------------------------------------------------------------------------*/
-static void 
-diva_ipac_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,IPAC_ISAC_OFF);
-			bus_space_write_multi_1(t,h,DIVA_IPAC_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,IPAC_HSCXA_OFF);
-			bus_space_write_multi_1(t,h,DIVA_IPAC_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,IPAC_HSCXB_OFF);
-			bus_space_write_multi_1(t,h,DIVA_IPAC_OFF_RW,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.02
- *---------------------------------------------------------------------------*/
-static void
-diva_ipac_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,reg+IPAC_ISAC_OFF);
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_RW,data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,reg+IPAC_HSCXA_OFF);
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_RW,data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,reg+IPAC_HSCXB_OFF);
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_RW,data);
-			break;
-		case ISIC_WHAT_IPAC:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,reg+IPAC_IPAC_OFF);
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_RW,data);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.02
- *---------------------------------------------------------------------------*/
-static u_int8_t
-diva_ipac_read_reg(struct l1_softc *sc,int what,bus_size_t reg)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,reg+IPAC_ISAC_OFF);
-			return bus_space_read_1(t,h,DIVA_IPAC_OFF_RW);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,reg+IPAC_HSCXA_OFF);
-			return bus_space_read_1(t,h,DIVA_IPAC_OFF_RW);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,reg+IPAC_HSCXB_OFF);
-			return bus_space_read_1(t,h,DIVA_IPAC_OFF_RW);
-		case ISIC_WHAT_IPAC:
-			bus_space_write_1(t,h,DIVA_IPAC_OFF_ALE,reg+IPAC_IPAC_OFF);
-			return bus_space_read_1(t,h,DIVA_IPAC_OFF_RW);
-		default:
-			return 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.02
- *---------------------------------------------------------------------------*/
-int
-isic_attach_diva_ipac(device_t dev)
-{
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];	
-	
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = diva_ipac_read_reg;
-	sc->writereg = diva_ipac_write_reg;
-
-	sc->readfifo = diva_ipac_read_fifo;
-	sc->writefifo = diva_ipac_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_DIVA_ISA;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	/* setup chip type = IPAC */
-	
-	sc->sc_ipac = 1;
-	sc->sc_bfifolen = IPAC_BFIFO_LEN;
-
-	/* enable hscx/isac irq's */
-
-	IPAC_WRITE(IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
-
-	IPAC_WRITE(IPAC_ACFG, 0);	/* outputs are open drain */
-
-	IPAC_WRITE(IPAC_AOE,		/* aux 5..2 are inputs, 7, 6 outputs */
-		(IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2));
-
-	IPAC_WRITE(IPAC_ATX, 0xff);	/* set all output lines high */
-
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.0
- *---------------------------------------------------------------------------*/
-static void 
-diva_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,DIVA_ISAC_OFF_ALE,0);
-			bus_space_read_multi_1(t,h,DIVA_ISAC_OFF_RW,buf,size);
-			break;
-
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_ALE,DIVA_HSCXA);
-			bus_space_read_multi_1(t,h,DIVA_HSCX_OFF_RW,buf,size);
-			break;
-
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_ALE,DIVA_HSCXB);
-			bus_space_read_multi_1(t,h,DIVA_HSCX_OFF_RW,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.0
- *---------------------------------------------------------------------------*/
-static void 
-diva_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,DIVA_ISAC_OFF_ALE,0);
-			bus_space_write_multi_1(t,h,DIVA_ISAC_OFF_RW,buf,size);
-			break;
-
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_ALE,DIVA_HSCXA);
-			bus_space_write_multi_1(t,h,DIVA_HSCX_OFF_RW,buf,size);
-			break;
-
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_ALE,DIVA_HSCXB);
-			bus_space_write_multi_1(t,h,DIVA_HSCX_OFF_RW,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.0
- *---------------------------------------------------------------------------*/
-static void
-diva_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,DIVA_ISAC_OFF_ALE,reg);
-			bus_space_write_1(t,h,DIVA_ISAC_OFF_RW,data);
-			break;
-
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_ALE,reg+DIVA_HSCXA);
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_RW,data);
-			break;
-
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_ALE,reg+DIVA_HSCXB);
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_RW,data);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.0
- *---------------------------------------------------------------------------*/
-static u_int8_t
-diva_read_reg(struct l1_softc *sc,int what,bus_size_t reg)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,DIVA_ISAC_OFF_ALE,reg);
-			return bus_space_read_1(t,h,DIVA_ISAC_OFF_RW);
-
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_ALE,reg+DIVA_HSCXA);
-			return bus_space_read_1(t,h,DIVA_HSCX_OFF_RW);
-
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,DIVA_HSCX_OFF_ALE,reg+DIVA_HSCXB);
-			return bus_space_read_1(t,h,DIVA_HSCX_OFF_RW);
-
-		default:
-			return 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Eicon Diehl DIVA 2.0
- *---------------------------------------------------------------------------*/
-int
-isic_attach_diva(device_t dev)
-{
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];	
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = diva_read_reg;
-	sc->writereg = diva_write_reg;
-
-	sc->readfifo = diva_read_fifo;
-	sc->writefifo = diva_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_DIVA_ISA;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	/* setup chip type = ISAC/HSCX */
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* Read HSCX A/B VSTR.  Expected value is 0x05 (V2.1). */
-
-	if( ((HSCX_READ(0, H_VSTR) & 0xf) != 0x5) || 
-	    ((HSCX_READ(1, H_VSTR) & 0xf) != 0x5) )
-	{
-		printf("isic%d: HSCX VSTR test failed for Eicon DIVA 2.0\n",
-			sc->sc_unit);
-		printf("isic%d: HSC0: VSTR: %#x\n",
-			sc->sc_unit, HSCX_READ(0, H_VSTR));
-		printf("isic%d: HSC1: VSTR: %#x\n",
-			sc->sc_unit, HSCX_READ(1, H_VSTR));
-		return ENXIO;
-	}
-	/* reset on */
-	bus_space_write_1(t,h,DIVA_CTRL_OFF,0);
-	DELAY(100);
-	/* reset off */
-	bus_space_write_1(t,h,DIVA_CTRL_OFF,DIVA_CTRL_WRRST);
-	return(0);
-}
-
-#endif /* defined EICON_DIVA */
--- sys/i4b/layer1/isic/i4b_dynalink.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*-
- *   Copyright (c) 1998 Martijn Plak. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	isdn4bsd layer1 driver for Dynalink IS64PH isdn TA
- *	==================================================
- *      last edit-date: [Wed Jan 24 09:08:03 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_dynalink.c,v 1.8 2005/01/06 22:18:20 imp Exp $");
-
-/*	NOTES:
-	
-	This driver was written for the Dynalink IS64PH ISDN TA, based on two 
-	Siemens chips (HSCX 21525 and ISAC 2186). It is sold in the Netherlands.
-	
-	model numbers found on (my) card:
-		IS64PH, TAS100H-N, P/N:89590555, TA200S100045521
-	
-	chips: 	
-		Siemens PSB 21525N, HSCX TE V2.1
-		Siemens PSB 2186N, ISAC-S TE V1.1
-		95MS14, PNP
-	
-	plug-and-play info: 
-		device id 	"ASU1688" 
-		vendor id 	0x88167506 
-		serial 		0x00000044
-		i/o port	4 byte alignment, 4 bytes requested, 
-				10 bit i/o decoding, 0x100-0x3f8 (?)
-		irq		3,4,5,9,10,11,12,15, high true, edge sensitive
-			
-	At the moment I'm writing this Dynalink is replacing this card with 
-	one based on a single Siemens chip (IPAC). It will apparently be sold 
-	under the same model name.
-
-	This driver might also work for Asuscom cards.
-*/
-
-#include "opt_i4b.h"
-
-#if defined(DYNALINK)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-/* io address mapping */
-#define ISAC		0
-#define HSCX		1
-#define	ADDR		2
-
-/* ADDR bits */
-#define ADDRMASK	0x7F
-#define RESET		0x80
-
-/* HSCX register offsets */
-#define HSCXA		0x00
-#define HSCXB		0x40
-
-/*	LOW-LEVEL DEVICE ACCESS
-*/
-
-static void             
-dynalink_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ADDR, 0);
-			bus_space_read_multi_1(t, h, ISAC, buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ADDR, HSCXA);
-			bus_space_read_multi_1(t, h, HSCX, buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ADDR, HSCXB);
-			bus_space_read_multi_1(t, h, HSCX, buf, size);
-			break;
-	}
-}
-
-static void
-dynalink_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ADDR, 0);
-			bus_space_write_multi_1(t, h, ISAC, (u_int8_t*)buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ADDR, HSCXA);
-			bus_space_write_multi_1(t, h, HSCX, (u_int8_t*)buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ADDR, HSCXB);
-			bus_space_write_multi_1(t, h, HSCX, (u_int8_t*)buf, size);
-			break;
-	}
-}
-
-static void
-dynalink_write_reg(struct l1_softc *sc, int what, bus_size_t reg, u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ADDR, reg);
-			bus_space_write_1(t, h, ISAC, data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ADDR, HSCXA+reg);
-			bus_space_write_1(t, h, HSCX, data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ADDR, HSCXB+reg);
-			bus_space_write_1(t, h, HSCX, data);
-			break;
-	}
-}
-
-static u_int8_t
-dynalink_read_reg(struct l1_softc *sc, int what, bus_size_t reg)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ADDR, reg);
-			return bus_space_read_1(t, h, ISAC);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ADDR, HSCXA+reg);
-			return bus_space_read_1(t, h, HSCX);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ADDR, HSCXB+reg);
-			return bus_space_read_1(t, h, HSCX);
-	}
-	return 0;
-}
-
-/* attach callback routine */
-int
-isic_attach_Dyn(device_t dev)
-{
-	int unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = &l1_sc[unit];		/* pointer to softc */
-
-	struct i4b_info *  info = &(sc->sc_resources);
-	bus_space_tag_t    t = rman_get_bustag(info->io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(info->io_base[0]);
-
-	/* fill in l1_softc structure */
-	sc->readreg	= dynalink_read_reg;
-	sc->writereg	= dynalink_write_reg;
-	sc->readfifo	= dynalink_read_fifo;
-	sc->writefifo	= dynalink_write_fifo;
-	sc->clearirq	= NULL;
-	sc->sc_cardtyp = CARD_TYPEP_DYNALINK;
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* Read HSCX A/B VSTR.  Expected value is 0x05 (V2.1). */
-	if( ((HSCX_READ(0, H_VSTR) & 0xf) != 0x5) || 
-	    ((HSCX_READ(1, H_VSTR) & 0xf) != 0x5) )
-	{
-		printf("isic%d: HSCX VSTR test failed for Dynalink\n",
-			sc->sc_unit);
-		printf("isic%d: HSC0: VSTR: %#x\n",
-			sc->sc_unit, HSCX_READ(0, H_VSTR));
-		printf("isic%d: HSC1: VSTR: %#x\n",
-			sc->sc_unit, HSCX_READ(1, H_VSTR));
-		return ENXIO;
-	}
-
-	/* reset card */
-	bus_space_write_1(t,h,ADDR,RESET);
-	DELAY(SEC_DELAY / 10);
-	bus_space_write_1(t,h,ADDR,0);
-	DELAY(SEC_DELAY / 10);
-
-	return 0;                
-}
-
-#endif /* defined(DYNALINK) */
--- sys/i4b/layer1/isic/i4b_asuscom_ipac.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*-
- * Copyright (c) 1999 Ari Suutari. 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	isic - I4B Siemens ISDN Chipset Driver for Asuscom ISDNlink 128K PnP
- *	=====================================================================
- *
- * 	This driver works with Asuscom ISDNlink 128K PnP ISA adapter,
- * 	which is based on Siemens IPAC chip (my card probes as ASU1690).
- *	Older Asuscom ISA cards are based on different chipset
- *	(containing two chips) - for those cards, one might want
- *	to try the Dynalink driver.
- *
- *	This driver is heavily based on ELSA Quickstep 1000pro PCI
- *	driver written by Hellmuth Michaelis. Card initialization
- *	code is modeled after Linux i4l driver written by Karsten
- *	Keil.
- *
- *      last edit-date: [Wed Jan 24 09:06:30 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_asuscom_ipac.c,v 1.8 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined (ASUSCOM_IPAC)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_ipac.h>
-
-/* masks for register encoded in base addr */
-
-#define ASI_BASE_MASK		0x0ffff
-#define ASI_OFF_MASK		0xf0000
-
-/* register id's to be encoded in base addr */
-
-#define ASI_IDISAC		0x00000
-#define ASI_IDHSCXA		0x10000
-#define ASI_IDHSCXB		0x20000
-#define ASI_IDIPAC		0x40000
-
-/* offsets from base address */
-
-#define ASI_OFF_ALE		0x00
-#define ASI_OFF_RW		0x01
-
-/*---------------------------------------------------------------------------*
- *      Asuscom ISDNlink 128K ISAC get fifo routine
- *---------------------------------------------------------------------------*/
-static void 
-asi_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_ISAC_OFF);
-			bus_space_read_multi_1(t,h,ASI_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXA_OFF);
-			bus_space_read_multi_1(t,h,ASI_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXB_OFF);
-			bus_space_read_multi_1(t,h,ASI_OFF_RW,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      Asuscom ISDNlink 128K ISAC put fifo routine
- *---------------------------------------------------------------------------*/
-static void 
-asi_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_ISAC_OFF);
-			bus_space_write_multi_1(t,h,ASI_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXA_OFF);
-			bus_space_write_multi_1(t,h,ASI_OFF_RW,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXB_OFF);
-			bus_space_write_multi_1(t,h,ASI_OFF_RW,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      Asuscom ISDNlink 128K ISAC put register routine
- *---------------------------------------------------------------------------*/
-static void
-asi_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_ISAC_OFF);
-			bus_space_write_1(t,h,ASI_OFF_RW,data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXA_OFF);
-			bus_space_write_1(t,h,ASI_OFF_RW,data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXB_OFF);
-			bus_space_write_1(t,h,ASI_OFF_RW,data);
-			break;
-		case ISIC_WHAT_IPAC:
-			bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_IPAC_OFF);
-			bus_space_write_1(t,h,ASI_OFF_RW,data);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Asuscom ISDNlink 128K ISAC get register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-asi_read_reg(struct l1_softc *sc,int what,bus_size_t reg)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what )
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_ISAC_OFF);
-			return bus_space_read_1(t,h,ASI_OFF_RW);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXA_OFF);
-			return bus_space_read_1(t,h,ASI_OFF_RW);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXB_OFF);
-			return bus_space_read_1(t,h,ASI_OFF_RW);
-		case ISIC_WHAT_IPAC:
-			bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_IPAC_OFF);
-			return bus_space_read_1(t,h,ASI_OFF_RW);
-		default:
-			return 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_siemens_isurf - attach for Asuscom ISDNlink 128K
- *---------------------------------------------------------------------------*/
-int
-isic_attach_asi(device_t dev)
-{
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];	
-	
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = asi_read_reg;
-	sc->writereg = asi_write_reg;
-
-	sc->readfifo = asi_read_fifo;
-	sc->writefifo = asi_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_ASUSCOMIPAC;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	/* setup chip type = IPAC ! */
-	
-	sc->sc_ipac = 1;
-	sc->sc_bfifolen = IPAC_BFIFO_LEN;
-
-	/* enable hscx/isac irq's */
-/*
- * This has been taken from Linux driver.
- * (Removed initialization that was not applicaple to
- * this board or was already register default setting.)
- */
-	IPAC_WRITE (IPAC_ACFG, 0xff);	/* Setup AUX pin modes		*/
-	IPAC_WRITE (IPAC_AOE, 0x0);	/* Setup AUX pin modes		*/
-	IPAC_WRITE (IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
-
-	return(0);
-}
-#endif /* defined (ASUSCOM_IPAC) */
--- sys/i4b/layer1/isic/i4b_isac.h
+++ /dev/null
@@ -1,389 +0,0 @@
-/*-
- *   Copyright (c) 1996, 2000 Gary Jennejohn. All rights reserved. 
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/isic/i4b_isac.h,v 1.3 2005/01/06 22:18:20 imp Exp $
- *
- *      last edit-date: [Wed Jan 24 09:10:42 2001]
- *
- *---------------------------------------------------------------------------*/
- 
-#ifndef I4B_ISAC_H_
-#define I4B_ISAC_H_
-
-/*
- * The ISAC databook specifies a delay of 2.5 DCL clock cycles between
- * writes to the ISAC command register CMDR. This is the delay used to
- * satisfy this requirement.
- */
-
-#define I4B_ISAC_CMDRWRDELAY	30
-
-#if (I4B_ISAC_CMDRWRDELAY > 0)
-#define ISACCMDRWRDELAY() DELAY(I4B_ISAC_CMDRWRDELAY)
-#else
-#warning "I4B_ISAC_CMDRWRDELAY set to 0!"
-#define ISACCMDRWRDELAY()
-#endif
- 
-enum ISAC_VERSIONS {
-	ISAC_VA,	/* 2085 A1 or A2, 2086/2186 V1.1	*/
-	ISAC_VB1,	/* 2085 B1				*/
-	ISAC_VB2,	/* 2085 B2				*/
-	ISAC_VB3,	/* 2085 B3/V2.3				*/
-	ISAC_UNKN	/* unknown version			*/
-};
-
-#define ISAC_FIFO_LEN	32	/* 32 bytes FIFO on chip */
-
-/*
- * definitions of registers and bits for the ISAC ISDN chip.
- */
- 
-typedef struct isac_reg {
-
-	/* 32 byte deep FIFO always first */
-
-	unsigned char isac_fifo [ISAC_FIFO_LEN];
-
-	/* most registers can be read/written, but have different names */
-	/* so define a union with read/write names to make that clear */
-
-	union {
-		struct {
-			unsigned char isac_ista;
-			unsigned char isac_star;
-			unsigned char isac_mode;
-			unsigned char isac_timr;
-			unsigned char isac_exir;
-			unsigned char isac_rbcl;
-			unsigned char isac_sapr;
-			unsigned char isac_rsta;
-			unsigned char dummy_28;
-			unsigned char isac_rhcr;
-			unsigned char isac_rbch;
-			unsigned char isac_star2;
-			unsigned char dummy_2c;
-			unsigned char dummy_2d;
-			unsigned char dummy_2e;
-			unsigned char dummt_2f;
-			unsigned char isac_spcr;
-			unsigned char isac_cirr;
-			unsigned char isac_mor;
-			unsigned char isac_sscr;
-			unsigned char isac_sfcr;
-			unsigned char isac_c1r;
-			unsigned char isac_c2r;
-			unsigned char isac_b1cr;
-			unsigned char isac_b2cr;
-			unsigned char isac_adf2;
-			unsigned char isac_mosr;
-			unsigned char isac_sqrr;
-		} isac_r;
-		struct {
-			unsigned char isac_mask;
-			unsigned char isac_cmdr;
-			unsigned char isac_mode;
-			unsigned char isac_timr;
-			unsigned char isac_xad1;
-			unsigned char isac_xad2;
-			unsigned char isac_sap1;
-			unsigned char isac_sap2;
-			unsigned char isac_tei1;
-			unsigned char isac_tei2;
-			unsigned char dummy_2a;
-			unsigned char isac_star2;
-			unsigned char dummy_2c;
-			unsigned char dummy_2d;
-			unsigned char dummy_2e;
-			unsigned char dummt_2f;
-			unsigned char isac_spcr;
-			unsigned char isac_cixr;
-			unsigned char isac_mox;
-			unsigned char isac_sscx;
-			unsigned char isac_sfcw;
-			unsigned char isac_c1r;
-			unsigned char isac_c2r;
-			unsigned char isac_stcr;
-			unsigned char isac_adf1;
-			unsigned char isac_adf2;
-			unsigned char isac_mocr;
-			unsigned char isac_sqxr;
-		} isac_w;
-	} isac_rw;
-} isac_reg_t;
-
-#define REG_OFFSET(type, field) (int)(&(((type *)0)->field))
-
-/* ISAC read registers */
-
-#define i_ista isac_rw.isac_r.isac_ista
-#define I_ISTA REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_ista)
-#define i_star isac_rw.isac_r.isac_star
-#define I_STAR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_star)
-#define i_mode isac_rw.isac_r.isac_mode
-#define I_MODE REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_mode)
-#define i_timr isac_rw.isac_r.isac_timr
-#define I_TIMR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_timr)
-#define i_exir isac_rw.isac_r.isac_exir
-#define I_EXIR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_exir)
-#define i_rbcl isac_rw.isac_r.isac_rbcl
-#define I_RBCL REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_rbcl)
-#define i_sapr isac_rw.isac_r.isac_sapr
-#define I_SAPR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_sapr)
-#define i_rsta isac_rw.isac_r.isac_rsta
-#define I_RSTA REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_rsta)
-#define i_rhcr isac_rw.isac_r.isac_rhcr
-#define I_RHCR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_rhcr)
-#define i_rbch isac_rw.isac_r.isac_rbch
-#define I_RBCH REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_rbch)
-#define i_star2 isac_rw.isac_r.isac_star2
-#define I_STAR2 REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_star2)
-#define i_spcr isac_rw.isac_r.isac_spcr
-#define I_SPCR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_spcr)
-#define i_cirr isac_rw.isac_r.isac_cirr
-#define I_CIRR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_cirr)
-#define i_mor isac_rw.isac_r.isac_mor
-#define I_MOR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_mor)
-#define i_sscr isac_rw.isac_r.isac_sscr
-#define I_SSCR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_sscr)
-#define i_sfcr isac_rw.isac_r.isac_sfcr
-#define I_SFCR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_sfcr)
-#define i_c1r isac_rw.isac_r.isac_c1r
-#define I_C1R REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_c1r)
-#define i_c2r isac_rw.isac_r.isac_c2r
-#define I_C2R REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_c2r)
-#define i_b1cr isac_rw.isac_r.isac_b1cr
-#define I_B1CR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_b1cr)
-#define i_b2cr isac_rw.isac_r.isac_b2cr
-#define I_B2CR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_b2cr)
-#define i_adf2 isac_rw.isac_r.isac_adf2
-#define I_ADF2 REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_adf2)
-#define i_mosr isac_rw.isac_r.isac_mosr
-#define I_MOSR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_mosr)
-#define i_sqrr isac_rw.isac_r.isac_sqrr
-#define I_SQRR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_sqrr)
-
-/* ISAC write registers - isac_mode, isac_timr, isac_star2, isac_spcr, */
-/* isac_c1r, isac_c2r, isac_adf2 see read registers */
-
-#define i_mask isac_rw.isac_w.isac_mask
-#define I_MASK REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_mask)
-#define i_cmdr isac_rw.isac_w.isac_cmdr
-#define I_CMDR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_cmdr)
-#define i_xad1 isac_rw.isac_w.isac_xad1
-#define I_XAD1 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_xad1)
-#define i_xad2 isac_rw.isac_w.isac_xad2
-#define I_XAD2 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_xad2)
-#define i_sap1 isac_rw.isac_w.isac_sap1
-#define I_SAP1 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sap1)
-#define i_sap2 isac_rw.isac_w.isac_sap2
-#define I_SAP2 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sap2)
-#define i_tei1 isac_rw.isac_w.isac_tei1
-#define i_tei2 isac_rw.isac_w.isac_tei2
-#define i_cixr isac_rw.isac_w.isac_cixr
-#define I_CIXR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_cixr)
-#define I_CIX0 I_CIXR
-#define i_mox isac_rw.isac_w.isac_mox
-#define I_MOX REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_mox)
-#define i_sscx isac_rw.isac_w.isac_sscx
-#define I_SSCX REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sscx)
-#define i_sfcw isac_rw.isac_w.isac_sfcw
-#define I_SFCW REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sfcw)
-#define i_stcr isac_rw.isac_w.isac_stcr
-#define I_STCR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_stcr)
-#define i_adf1 isac_rw.isac_w.isac_adf1
-#define I_ADF1 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_adf1)
-#define i_mocr isac_rw.isac_w.isac_mocr
-#define I_MOCR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_mocr)
-#define i_sqxr isac_rw.isac_w.isac_sqxr
-#define I_SQXR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sqxr)
-
-#define ISAC_ISTA_RME  0x80
-#define ISAC_ISTA_RPF  0x40
-#define ISAC_ISTA_RSC  0x20
-#define ISAC_ISTA_XPR  0x10
-#define ISAC_ISTA_TIN  0x08
-#define ISAC_ISTA_CISQ 0x04
-#define ISAC_ISTA_SIN  0x02
-#define ISAC_ISTA_EXI  0x01
-
-#define ISAC_MASK_RME  0x80
-#define ISAC_MASL_RPF  0x40
-#define ISAC_MASK_RSC  0x20
-#define ISAC_MASK_XPR  0x10
-#define ISAC_MASK_TIN  0x08
-#define ISAC_MASK_CISQ 0x04
-#define ISAC_MASK_SIN  0x02
-#define ISAC_MASK_EXI  0x01
-#define ISAC_MASK_ALL  0xff
-
-#define ISAC_STAR_XDOV 0x80
-#define ISAC_STAR_XFW  0x40
-#define ISAC_STAR_XRNR 0x20
-#define ISAC_STAR_RRNR 0x10
-#define ISAC_STAR_MBR  0x08
-#define ISAC_STAR_MAC1 0x04
-#define ISAC_STAR_BVS  0x02
-#define ISAC_STAR_MAC0 0x01
-
-#define ISAC_CMDR_RMC  0x80
-#define ISAC_CMDR_RRES 0x40
-#define ISAC_CMDR_RNR  0x20
-#define ISAC_CMDR_STI  0x10
-#define ISAC_CMDR_XTF  0x08
-#define ISAC_CMDR_XIF  0x04
-#define ISAC_CMDR_XME  0x02
-#define ISAC_CMDR_XRES 0x01
-
-#define ISAC_MODE_MDS2 0x80
-#define ISAC_MODE_MDS1 0x40
-#define ISAC_MODE_MDS0 0x20
-#define ISAC_MODE_TMD  0x10
-#define ISAC_MODE_RAC  0x08
-#define ISAC_MODE_DIM2 0x04
-#define ISAC_MODE_DIM1 0x02
-#define ISAC_MODE_DIM0 0x01
-
-#define ISAC_EXIR_XMR  0x80
-#define ISAC_EXIR_XDU  0x40
-#define ISAC_EXIR_PCE  0x20
-#define ISAC_EXIR_RFO  0x10
-#define ISAC_EXIR_SOV  0x08
-#define ISAC_EXIR_MOS  0x04
-#define ISAC_EXIR_SAW  0x02
-#define ISAC_EXIR_WOV  0x01
-
-#define ISAC_RSTA_RDA  0x80
-#define ISAC_RSTA_RDO  0x40
-#define ISAC_RSTA_CRC  0x20
-#define ISAC_RSTA_RAB  0x10
-#define ISAC_RSTA_SA1  0x08
-#define ISAC_RSTA_SA0  0x04
-#define ISAC_RSTA_CR   0x02
-#define ISAC_RSTA_TA   0x01
-
-#define ISAC_RSTA_MASK 0x70	/* the interesting bits */
-
-#define ISAC_RBCH_XAC  0x80
-#define ISAC_RBCH_VN1  0x40
-#define ISAC_RBCH_VN0  0x20
-#define ISAC_RBCH_OV   0x10
-/* the other 4 bits are the high bits of the receive byte count */
-
-#define ISAC_SPCR_SPU  0x80
-#define ISAC_SPCR_SAC  0x40
-#define ISAC_SPCR_SPM  0x20
-#define ISAC_SPCR_TLP  0x10
-#define ISAC_SPCR_C1C1 0x08
-#define ISAC_SPCR_C1C0 0x04
-#define ISAC_SPCR_C2C1 0x02
-#define ISAC_SPCR_C2C0 0x01
-
-#define ISAC_CIRR_SQC  0x80
-#define ISAC_CIRR_BAS  0x40
-/* bits 5-2 CODR */
-#define ISAC_CIRR_CIC0 0x02
-/* bit 0 is always 0 */
-/* C/I codes from bits 5-2 (>> 2 & 0xf) */
-/* the indications */
-#define ISAC_CIRR_IPU   0x07
-#define ISAC_CIRR_IDR   0x00
-#define ISAC_CIRR_ISD   0x02
-#define ISAC_CIRR_IDIS  0x03
-#define ISAC_CIRR_IEI   0x06
-#define ISAC_CIRR_IRSY  0x04
-#define ISAC_CIRR_IARD  0x08
-#define ISAC_CIRR_ITI   0x0a
-#define ISAC_CIRR_IATI  0x0b
-#define ISAC_CIRR_IAI8  0x0c
-#define ISAC_CIRR_IAI10 0x0d
-#define ISAC_CIRR_IDID  0x0f
-
-#define ISAC_CI_MASK	0x0f
-
-#define ISAC_CIXR_RSS  0x80
-#define ISAC_CIXR_BAC  0x40
-/* bits 5-2 CODX */
-#define ISAC_CIXR_TCX  0x02
-#define ISAC_CIXR_ECX  0x01
-/* in IOM-2 mode the low bits are always 1 */
-#define ISAC_CIX0_LOW  0x03
-/* C/I codes from bits 5-2 (>> 2 & 0xf) */
-/* the commands */
-#define ISAC_CIXR_CTIM  0
-#define ISAC_CIXR_CRS   0x01
-#define ISAC_CIXR_CSCZ  0x04
-#define ISAC_CIXR_CSSZ  0x02
-#define ISAC_CIXR_CAR8  0x08
-#define ISAC_CIXR_CAR10 0x09
-#define ISAC_CIXR_CARL  0x0a
-#define ISAC_CIXR_CDIU  0x0f
-
-#define ISAC_STCR_TSF  0x80
-#define ISAC_STCR_TBA2 0x40
-#define ISAC_STCR_TBA1 0x20
-#define ISAC_STCR_TBA0 0x10
-#define ISAC_STCR_ST1  0x08
-#define ISAC_STCR_ST0  0x04
-#define ISAC_STCR_SC1  0x02
-#define ISAC_STCR_SC0  0x01
-
-#define ISAC_ADF1_WTC1 0x80
-#define ISAC_ADF1_WTC2 0x40
-#define ISAC_ADF1_TEM  0x20
-#define ISAC_ADF1_PFS  0x10
-#define ISAC_ADF1_CFS  0x08
-#define ISAC_ADF1_FC2  0x04
-#define ISAC_ADF1_FC1  0x02
-#define ISAC_ADF1_ITF  0x01
-
-#define ISAC_ADF2_IMS  0x80
-/* all other bits are 0 */
-
-/* bits 7-5 are always 0 */
-#define ISAC_SQRR_SYN  0x10
-#define ISAC_SQRR_SQR1 0x08
-#define ISAC_SQRR_SQR2 0x04
-#define ISAC_SQRR_SQR3 0x02
-#define ISAC_SQRR_SQR4 0x01
-
-#define ISAC_SQXR_IDC  0x80
-#define ISAC_SQXR_CFS  0x40
-#define ISAC_SQXR_CI1E 0x20
-#define ISAC_SQXR_SQIE 0x10
-#define ISAC_SQXR_SQX1 0x08
-#define ISAC_SQXR_SQX2 0x04
-#define ISAC_SQXR_SQX3 0x02
-#define ISAC_SQXR_SQX4 0x01
-
-#endif /* I4B_ISAC_H_ */
--- sys/i4b/layer1/isic/i4b_isic.c
+++ /dev/null
@@ -1,494 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_isic.c - global isic stuff
- *	==============================
- *      last edit-date: [Wed Jan 24 09:29:42 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_isic.c,v 1.7 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isic_ext.h>
-#include <i4b/layer1/isic/i4b_ipac.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/include/i4b_global.h>
-
-static char *ISACversion[] = {
-	"2085 Version A1/A2 or 2086/2186 Version 1.1",
-	"2085 Version B1",
-	"2085 Version B2",
-	"2085 Version V2.3 (B3)",
-	"Unknown Version"
-};
-
-static char *HSCXversion[] = {
-	"82525 Version A1",
-	"Unknown (0x01)",
-	"82525 Version A2",
-	"Unknown (0x03)",
-	"82525 Version A3",
-	"82525 or 21525 Version 2.1",
-	"Unknown Version"
-};
-
-/* jump table for multiplex routines */
-struct i4b_l1mux_func isic_l1mux_func = {
-	isic_ret_linktab,
-	isic_set_linktab,
-	isic_mph_command_req,
-	isic_ph_data_req,
-	isic_ph_activate_req,
-};
-
-/*---------------------------------------------------------------------------*
- *	isic - device driver interrupt routine
- *---------------------------------------------------------------------------*/
-void
-isicintr(struct l1_softc *sc)
-{
-	if(sc->sc_ipac == 0)	/* HSCX/ISAC interupt routine */
-	{
-		u_char was_hscx_irq = 0;
-		u_char was_isac_irq = 0;
-
-		register u_char hscx_irq_stat;
-		register u_char isac_irq_stat;
-
-		for(;;)
-		{
-			/* get hscx irq status from hscx b ista */
-			hscx_irq_stat =
-	 	    	    HSCX_READ(HSCX_CH_B, H_ISTA) & ~HSCX_B_IMASK;
-	
-			/* get isac irq status */
-			isac_irq_stat = ISAC_READ(I_ISTA);
-	
-			/* do as long as there are pending irqs in the chips */
-			if(!hscx_irq_stat && !isac_irq_stat)
-				break;
-	
-			if(hscx_irq_stat & (HSCX_ISTA_RME | HSCX_ISTA_RPF |
-					    HSCX_ISTA_RSC | HSCX_ISTA_XPR |
-					    HSCX_ISTA_TIN | HSCX_ISTA_EXB))
-			{
-				isic_hscx_irq(sc, hscx_irq_stat,
-						HSCX_CH_B,
-						hscx_irq_stat & HSCX_ISTA_EXB);
-				was_hscx_irq = 1;			
-			}
-			
-			if(hscx_irq_stat & (HSCX_ISTA_ICA | HSCX_ISTA_EXA))
-			{
-				isic_hscx_irq(sc,
-				    HSCX_READ(HSCX_CH_A, H_ISTA) & ~HSCX_A_IMASK,
-				    HSCX_CH_A,
-				    hscx_irq_stat & HSCX_ISTA_EXA);
-				was_hscx_irq = 1;
-			}
-	
-			if(isac_irq_stat)
-			{
-				isic_isac_irq(sc, isac_irq_stat); /* isac handler */
-				was_isac_irq = 1;
-			}
-		}
-
-		HSCX_WRITE(0, H_MASK, 0xff);
-		ISAC_WRITE(I_MASK, 0xff);
-		HSCX_WRITE(1, H_MASK, 0xff);
-	
-#ifdef ELSA_QS1ISA
-		DELAY(80);
-		
-		if((sc->sc_cardtyp == CARD_TYPEP_ELSAQS1ISA) && (sc->clearirq))
-		{
-			sc->clearirq(sc);
-		}
-#else
-		DELAY(100);
-#endif	
-	
-		HSCX_WRITE(0, H_MASK, HSCX_A_IMASK);
-		ISAC_WRITE(I_MASK, ISAC_IMASK);
-		HSCX_WRITE(1, H_MASK, HSCX_B_IMASK);
-	}
-	else	/* IPAC interrupt routine */
-	{
-		register u_char ipac_irq_stat;
-		register u_char was_ipac_irq = 0;
-
-		for(;;)
-		{
-			/* get global irq status */
-			
-			ipac_irq_stat = (IPAC_READ(IPAC_ISTA)) & 0x3f;
-			
-			/* check hscx a */
-			
-			if(ipac_irq_stat & (IPAC_ISTA_ICA | IPAC_ISTA_EXA))
-			{
-				/* HSCX A interrupt */
-				isic_hscx_irq(sc, HSCX_READ(HSCX_CH_A, H_ISTA),
-						HSCX_CH_A,
-						ipac_irq_stat & IPAC_ISTA_EXA);
-				was_ipac_irq = 1;			
-			}
-			if(ipac_irq_stat & (IPAC_ISTA_ICB | IPAC_ISTA_EXB))
-			{
-				/* HSCX B interrupt */
-				isic_hscx_irq(sc, HSCX_READ(HSCX_CH_B, H_ISTA),
-						HSCX_CH_B,
-						ipac_irq_stat & IPAC_ISTA_EXB);
-				was_ipac_irq = 1;			
-			}
-			if(ipac_irq_stat & IPAC_ISTA_ICD)
-			{
-				/* ISAC interrupt */
-				isic_isac_irq(sc, ISAC_READ(I_ISTA));
-				was_ipac_irq = 1;
-			}
-			if(ipac_irq_stat & IPAC_ISTA_EXD)
-			{
-				/* force ISAC interrupt handling */
-				isic_isac_irq(sc, ISAC_ISTA_EXI);
-				was_ipac_irq = 1;
-			}
-	
-			/* do as long as there are pending irqs in the chip */
-			if(!ipac_irq_stat)
-				break;
-		}
-
-		IPAC_WRITE(IPAC_MASK, 0xff);
-		DELAY(50);
-		IPAC_WRITE(IPAC_MASK, 0xc0);
-	}		
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_recover - try to recover from irq lockup
- *---------------------------------------------------------------------------*/
-void
-isic_recover(struct l1_softc *sc)
-{
-	u_char byte;
-	
-	/* get hscx irq status from hscx b ista */
-
-	byte = HSCX_READ(HSCX_CH_B, H_ISTA);
-
-	NDBGL1(L1_ERROR, "HSCX B: ISTA = 0x%x", byte);
-
-	if(byte & HSCX_ISTA_ICA)
-		NDBGL1(L1_ERROR, "HSCX A: ISTA = 0x%x", (u_char)HSCX_READ(HSCX_CH_A, H_ISTA));
-
-	if(byte & HSCX_ISTA_EXB)
-		NDBGL1(L1_ERROR, "HSCX B: EXIR = 0x%x", (u_char)HSCX_READ(HSCX_CH_B, H_EXIR));
-
-	if(byte & HSCX_ISTA_EXA)
-		NDBGL1(L1_ERROR, "HSCX A: EXIR = 0x%x", (u_char)HSCX_READ(HSCX_CH_A, H_EXIR));
-
-	/* get isac irq status */
-
-	byte = ISAC_READ(I_ISTA);
-
-	NDBGL1(L1_ERROR, "  ISAC: ISTA = 0x%x", byte);
-	
-	if(byte & ISAC_ISTA_EXI)
-		NDBGL1(L1_ERROR, "  ISAC: EXIR = 0x%x", (u_char)ISAC_READ(I_EXIR));
-
-	if(byte & ISAC_ISTA_CISQ)
-	{
-		byte = ISAC_READ(I_CIRR);
-	
-		NDBGL1(L1_ERROR, "  ISAC: CISQ = 0x%x", byte);
-		
-		if(byte & ISAC_CIRR_SQC)
-			NDBGL1(L1_ERROR, "  ISAC: SQRR = 0x%x", (u_char)ISAC_READ(I_SQRR));
-	}
-
-	NDBGL1(L1_ERROR, "HSCX B: IMASK = 0x%x", HSCX_B_IMASK);
-	NDBGL1(L1_ERROR, "HSCX A: IMASK = 0x%x", HSCX_A_IMASK);
-
-	HSCX_WRITE(0, H_MASK, 0xff);
-	HSCX_WRITE(1, H_MASK, 0xff);
-	DELAY(100);	
-	HSCX_WRITE(0, H_MASK, HSCX_A_IMASK);
-	HSCX_WRITE(1, H_MASK, HSCX_B_IMASK);
-	DELAY(100);
-
-	NDBGL1(L1_ERROR, "  ISAC: IMASK = 0x%x", ISAC_IMASK);
-
-	ISAC_WRITE(I_MASK, 0xff);	
-	DELAY(100);
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_attach_common - common attach routine for all busses
- *---------------------------------------------------------------------------*/
-int
-isic_attach_common(device_t dev)
-{
-	char *drvid = NULL;
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];
-	
-	sc->sc_unit = unit;
-	
-	sc->sc_isac_version = 0;
-	sc->sc_hscx_version = 0;
-
-	if(sc->sc_ipac)
-	{
-		sc->sc_ipac_version = IPAC_READ(IPAC_ID);
-
-		switch(sc->sc_ipac_version)
-  		{
-			case IPAC_V11:
-			case IPAC_V12:
-  				break;
-
-  			default:
-  				printf("isic%d: Error, IPAC version %d unknown!\n",
-  					unit, sc->sc_ipac_version);
-  				return(0);
-  				break;
-		}
-	}
-	else
-	{
-		sc->sc_isac_version = ((ISAC_READ(I_RBCH)) >> 5) & 0x03;
-	
-		switch(sc->sc_isac_version)
-		{
-			case ISAC_VA:
-			case ISAC_VB1:
-			case ISAC_VB2:
-			case ISAC_VB3:
-				break;
-	
-			default:
-				printf("isic%d: Error, ISAC version %d unknown!\n",
-					unit, sc->sc_isac_version);
-				return ENXIO;
-				break;
-		}
-
-		sc->sc_hscx_version = HSCX_READ(0, H_VSTR) & 0xf;
-
-		switch(sc->sc_hscx_version)
-		{
-			case HSCX_VA1:
-			case HSCX_VA2:
-			case HSCX_VA3:
-			case HSCX_V21:
-				break;
-				
-			default:
-				printf("isic%d: Error, HSCX version %d unknown!\n",
-					unit, sc->sc_hscx_version);
-				return ENXIO;
-				break;
-		}
-	}
-	
-	isic_isac_init(sc);		/* ISAC setup */
-
-	/* HSCX setup */
-
-	isic_bchannel_setup(sc->sc_unit, HSCX_CH_A, BPROT_NONE, 0);
-	
-	isic_bchannel_setup(sc->sc_unit, HSCX_CH_B, BPROT_NONE, 0);
-
-	isic_init_linktab(sc);		/* setup linktab */
-
-	sc->sc_trace = TRACE_OFF;	/* set trace level */
-
-	sc->sc_state = ISAC_IDLE;	/* set state */
-
-	sc->sc_ibuf = NULL;		/* input buffering */
-	sc->sc_ib = NULL;
-	sc->sc_ilen = 0;
-
-	sc->sc_obuf = NULL;		/* output buffering */
-	sc->sc_op = NULL;
-	sc->sc_ol = 0;
-	sc->sc_freeflag = 0;
-
-	sc->sc_obuf2 = NULL;		/* second output buffer */
-	sc->sc_freeflag2 = 0;
-
-	/* timer setup */
-	
-	callout_handle_init(&sc->sc_T3_callout);
-	callout_handle_init(&sc->sc_T4_callout);	
-	
-	/* init higher protocol layers */
-	
-	i4b_l1_mph_status_ind(L0ISICUNIT(sc->sc_unit), STI_ATTACH, sc->sc_cardtyp, &isic_l1mux_func);
-
-	/* announce manufacturer and card type for ISA cards */
-	
-	switch(sc->sc_cardtyp)
-	{
-		case CARD_TYPEP_8:
-			drvid = "Teles S0/8 (or compatible)";
-			break;
-
-		case CARD_TYPEP_16:
-			drvid = "Teles S0/16 (or compatible)";
-			break;
-
-		case CARD_TYPEP_16_3:
-			drvid = "Teles S0/16.3";
-			break;
-
-		case CARD_TYPEP_AVMA1:
-			drvid = "AVM A1 or Fritz!Card Classic";
-			break;
-
-		case CARD_TYPEP_PCFRITZ:
-			drvid = "AVM Fritz!Card PCMCIA";
-			break;
-
-		case CARD_TYPEP_USRTA:
-			drvid = "USRobotics Sportster ISDN TA intern";
-			break;
-
-		case CARD_TYPEP_ITKIX1:
-			drvid = "ITK ix1 micro";
-			break;
-
-		case CARD_TYPEP_PCC16:
-			drvid = "ELSA MicroLink ISDN/PCC-16";
-			break;
-
-		default:
-			drvid = NULL;	/* pnp/pci cards announce themselves */
-			break;
-	}
-
-	if(drvid)
-		printf("isic%d: %s\n", unit, drvid);
-	
-	if(bootverbose)
-	{
-		/* announce chip versions */
-		
-		if(sc->sc_ipac)
-		{
-			if(sc->sc_ipac_version == IPAC_V11)
-				printf("isic%d: IPAC PSB2115 Version 1.1\n", unit);
-			else
-				printf("isic%d: IPAC PSB2115 Version 1.2\n", unit);
-		}
-		else
-		{
-			printf("isic%d: ISAC %s (IOM-%c)\n",
-				unit,
-				ISACversion[sc->sc_isac_version],
-				sc->sc_bustyp == BUS_TYPE_IOM1 ? '1' : '2');
-
-			printf("isic%d: HSCX %s\n",
-				unit,
-				HSCXversion[sc->sc_hscx_version]);
-		}
-	}
-	return 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_detach_common - common detach routine for all busses
- *---------------------------------------------------------------------------*/
-void
-isic_detach_common(device_t dev)
-{
-	struct l1_softc *sc = &l1_sc[device_get_unit(dev)];
-	int i;
-
-	sc->sc_cardtyp = CARD_TYPEP_UNK;
-
-	/* free interrupt resources */
-	
-	if(sc->sc_resources.irq)
-	{
-		/* tear down interupt handler */
-		bus_teardown_intr(dev, sc->sc_resources.irq,
-					(void(*)(void *))isicintr);
-
-		/* free irq */
-		bus_release_resource(dev, SYS_RES_IRQ,
-					sc->sc_resources.irq_rid,
-					sc->sc_resources.irq);
-		sc->sc_resources.irq_rid = 0;
-		sc->sc_resources.irq = 0;
-	}
-
-	/* free memory resource */
-	
-	if(sc->sc_resources.mem)
-	{
-		bus_release_resource(dev,SYS_RES_MEMORY,
-					sc->sc_resources.mem_rid,
-					sc->sc_resources.mem);
-		sc->sc_resources.mem_rid = 0;
-		sc->sc_resources.mem = 0;
-	}
-
-	/* free iobases */
-
-	for(i=0; i < INFO_IO_BASES ; i++)
-	{
-		if(sc->sc_resources.io_base[i])
-		{
-			bus_release_resource(dev, SYS_RES_IOPORT,
-						sc->sc_resources.io_rid[i],
-						sc->sc_resources.io_base[i]);
-			sc->sc_resources.io_rid[i] = 0;
-			sc->sc_resources.io_base[i] = 0;			
-		}
-	}
-}
--- sys/i4b/layer1/isic/i4b_sws.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*-
- *   Copyright (c) 1998, 2000 German Tischler. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- * Card format:
- * 
- * iobase + 0 : reset on  (0x03)
- * iobase + 1 : reset off (0x0)
- * iobase + 2 : isac read/write
- * iobase + 3 : hscx read/write ( offset 0-0x3f    hscx0 , 
- *                                offset 0x40-0x7f hscx1 )
- * iobase + 4 : offset for indirect adressing
- *
- *---------------------------------------------------------------------------
- *
- *	isic - I4B Siemens ISDN Chipset Driver for SWS cards
- *	====================================================
- *	last edit-date: [Wed Jan 24 08:58:57 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_sws.c,v 1.8 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined (SEDLBAUER)
-
-#define SWS_RESON  0 /* reset on                 */
-#define SWS_RESOFF 1 /* reset off                */
-#define SWS_ISAC   2 /* ISAC                     */
-#define SWS_HSCX0  3 /* HSCX0                    */
-#define SWS_RW     4 /* indirect access register */
-#define SWS_HSCX1  5 /* this is for fakeing that we mean hscx1, though */
-                     /* access is done through hscx0                   */
-
-#define SWS_REGS   8 /* we use an area of 8 bytes for io */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-/*---------------------------------------------------------------------------*
- *      SWS P&P ISAC get fifo routine
- *---------------------------------------------------------------------------*/
-static void
-sws_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size) {
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what ) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,SWS_RW,0x0);
-			bus_space_read_multi_1(t,h,SWS_ISAC,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,SWS_RW,0x0);
-			bus_space_read_multi_1(t,h,SWS_HSCX0,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,SWS_RW,0x0+0x40);
-			bus_space_read_multi_1(t,h,SWS_HSCX0,buf,size);
-			break;
-	}
-}
-
-static void
-sws_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size) {
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what ) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,SWS_RW,0x0);
-			bus_space_write_multi_1(t,h,SWS_ISAC,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,SWS_RW,0x0);
-			bus_space_write_multi_1(t,h,SWS_HSCX0,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,SWS_RW,0x0+0x40);
-			bus_space_write_multi_1(t,h,SWS_HSCX0,buf,size);
-			break;
-	}
-}
-
-static void
-sws_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data) {
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what ) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,SWS_RW,reg);
-			bus_space_write_1(t,h,SWS_ISAC,data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,SWS_RW,reg);
-			bus_space_write_1(t,h,SWS_HSCX0,data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,SWS_RW,reg+0x40);
-			bus_space_write_1(t,h,SWS_HSCX0,data);
-			break;
-	}
-}
-
-static u_char
-sws_read_reg (struct l1_softc *sc,int what,bus_size_t reg) {
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch ( what ) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t,h,SWS_RW,reg);
-			return bus_space_read_1(t,h,SWS_ISAC);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t,h,SWS_RW,reg);
-			return bus_space_read_1(t,h,SWS_HSCX0);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t,h,SWS_RW,reg+0x40);
-			return bus_space_read_1(t,h,SWS_HSCX0);
-		default:
-			return 0;
-	}
-}
-
-/* attach callback routine */
-int
-isic_attach_sws(device_t dev)
-{
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];	
-	
-	struct i4b_info * info = &(sc->sc_resources);
-        bus_space_tag_t    t = rman_get_bustag(info->io_base[0]);
-        bus_space_handle_t h = rman_get_bushandle(info->io_base[0]);
-
-	/* fill in l1_softc structure */
-	sc->readreg     = sws_read_reg;
-	sc->writereg    = sws_write_reg;
-	sc->readfifo    = sws_read_fifo;
-	sc->writefifo   = sws_write_fifo;
-	sc->clearirq    = NULL;
-	sc->sc_cardtyp  = CARD_TYPEP_SWS;
-	sc->sc_bustyp   = BUS_TYPE_IOM2;
-	sc->sc_ipac     = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	/* 
-	 * Read HSCX A/B VSTR.  Expected value for the SWS PnP card is
-	 * 0x05 ( = version 2.1 ) in the least significant bits.
-	 */
-
-	if( ((HSCX_READ(0, H_VSTR) & 0xf) != 0x5) ||
-            ((HSCX_READ(1, H_VSTR) & 0xf) != 0x5) )
-	{
-		printf("isic%d: HSCX VSTR test failed for SWS PnP\n",
-			sc->sc_unit);
-		printf("isic%d: HSC0: VSTR: %#x\n",
-			sc->sc_unit, HSCX_READ(0, H_VSTR));
-		printf("isic%d: HSC1: VSTR: %#x\n",
-			sc->sc_unit, HSCX_READ(1, H_VSTR));
-		return (ENXIO);
-	}                   
-
-	/* reset card */
-	bus_space_write_1(t,h,SWS_RESON,0x3);
-	DELAY(SEC_DELAY / 5);
-	bus_space_write_1(t,h,SWS_RESOFF,0x0);
-	DELAY(SEC_DELAY / 5);
-
-	return(0);
-}
-#endif /* defined(SEDLBAUER) */
--- sys/i4b/layer1/isic/i4b_isic_pnp.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*-
- *   Copyright (c) 1998 Eivind Eklund. All rights reserved.
- *
- *   Copyright (c) 1998, 1999 German Tischler. All rights reserved.
- *
- *   Copyright (c) 1998, 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
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_isic_pnp.c - i4b pnp support
- *	--------------------------------
- *      last edit-date: [Fri Jan 26 14:01:04 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_isic_pnp.c,v 1.12 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-
-#include <isa/isavar.h>
-
-#define VID_TEL163PNP		0x10212750	/* Teles 16.3 PnP	*/
-#define VID_CREATIXPP		0x0000980e	/* Creatix S0/16 P+P	*/
-#define VID_DYNALINK		0x88167506	/* Dynalink		*/
-#define VID_SEDLBAUER		0x0100274c	/* Sedlbauer WinSpeed	*/
-#define VID_NICCYGO		0x5001814c	/* Neuhaus Niccy GO@	*/
-#define VID_ELSAQS1P		0x33019315	/* ELSA Quickstep1000pro*/
-#define VID_ITK0025 		0x25008b26	/* ITK Ix1 Micro V3	*/
-#define VID_AVMPNP		0x0009cd06	/* AVM Fritz! PnP	*/
-#define VID_SIESURF2		0x2000254d	/* Siemens I-Surf 2.0 PnP*/
-#define VID_ASUSCOM_IPAC	0x90167506	/* Asuscom (with IPAC)	*/	
-#define VID_EICON_DIVA_20	0x7100891c	/* Eicon DIVA 2.0 ISAC/HSCX */
-#define VID_EICON_DIVA_202	0xa100891c      /* Eicon DIVA 2.02 IPAC	*/
-#define VID_COMPAQ_M610		0x0210110e	/* Compaq Microcom 610	*/
-
-static struct isic_pnp_ids {
-	u_long vend_id;
-	char *id_str;
-} isic_pnp_ids[] = {
-#if defined(TEL_S0_16_3_P) || defined(CRTX_S0_P) || defined(COMPAQ_M610)
-	{ VID_TEL163PNP,	"Teles S0/16.3 PnP"		},
-	{ VID_CREATIXPP,	"Creatix S0/16 PnP"		},
-	{ VID_COMPAQ_M610,	"Compaq Microcom 610"		},
-#endif
-#ifdef DYNALINK
-	{ VID_DYNALINK,		"Dynalink IS64PH"		},
-#endif
-#ifdef SEDLBAUER
-	{ VID_SEDLBAUER,	"Sedlbauer WinSpeed"		},
-#endif
-#ifdef DRN_NGO
-	{ VID_NICCYGO,		"Dr.Neuhaus Niccy Go@"		},
-#endif
-#ifdef ELSA_QS1ISA
-	{ VID_ELSAQS1P,		"ELSA QuickStep 1000pro"	},	
-#endif
-#ifdef ITKIX1
-	{ VID_ITK0025,		"ITK ix1 Micro V3.0"    	},
-#endif
-#ifdef AVM_PNP
-	{ VID_AVMPNP,		"AVM Fritz!Card PnP"		},	
-#endif
-#ifdef SIEMENS_ISURF2
-	{ VID_SIESURF2,		"Siemens I-Surf 2.0 PnP"	},
-#endif
-#ifdef ASUSCOM_IPAC
- 	{ VID_ASUSCOM_IPAC,	"Asuscom ISDNLink 128 PnP"	},
-#endif
-#ifdef EICON_DIVA
-	{ VID_EICON_DIVA_20,	"Eicon.Diehl DIVA 2.0 ISA PnP"	},
-	{ VID_EICON_DIVA_202,	"Eicon.Diehl DIVA 2.02 ISA PnP"	},
-#endif
-	{ 0, 0 }
-};
-
-static int isic_pnp_probe(device_t dev);
-static int isic_pnp_attach(device_t dev);
-
-static device_method_t isic_pnp_methods[] = {
-	DEVMETHOD(device_probe,		isic_pnp_probe),
-	DEVMETHOD(device_attach,	isic_pnp_attach),
-	{ 0, 0 }
-};
-                                
-static driver_t isic_pnp_driver = {
-	"isic",
-	isic_pnp_methods,
-	0,
-};
-
-static devclass_t isic_devclass;
-
-DRIVER_MODULE(isicpnp, isa, isic_pnp_driver, isic_devclass, 0, 0);
-
-/*---------------------------------------------------------------------------*
- *      probe for ISA PnP cards
- *---------------------------------------------------------------------------*/
-static int
-isic_pnp_probe(device_t dev)
-{
-	struct isic_pnp_ids *ids;			/* pnp id's */
-	char *string = NULL;				/* the name */
-	u_int32_t vend_id = isa_get_vendorid(dev); 	/* vendor id */
-
-	/* search table of knowd id's */
-	
-	for(ids = isic_pnp_ids; ids->vend_id != 0; ids++)
-	{
-		if(vend_id == ids->vend_id)
-		{
-			string = ids->id_str;
-			break;
-		}
-	}
-	
-	if(string)		/* set name if we have one */
-	{
-		device_set_desc(dev, string);	/* set description */
-		return 0;
-	}
-	else
-	{
-		return ENXIO;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      attach for ISA PnP cards
- *---------------------------------------------------------------------------*/
-static int
-isic_pnp_attach(device_t dev)
-{
-	u_int32_t vend_id = isa_get_vendorid(dev);	/* vendor id */
-	unsigned int unit = device_get_unit(dev);	/* get unit */
-	const char *name = device_get_desc(dev);	/* get description */
-	struct l1_softc *sc = 0;			/* softc */
-	void *ih = 0;					/* a dummy */
-	int ret;
- 
-	/* see if we are out of bounds */
-	
-	if(unit >= ISIC_MAXUNIT)
-	{
-		printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for %s\n", unit, unit, name);
-		return ENXIO;
-	}
-
-	/* get information structure for this unit */
-
-	sc = &l1_sc[unit];
-
-	/* get io_base */
-	if(!(sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE ) ))
-	{
-		printf("isic_pnp_attach: Couldn't get my io_base.\n");
-		return ENXIO;                                       
-	}
-	
-	/* will not be used for pnp devices */
-
-	sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
-
-	/* get irq, release io_base if we don't get it */
-
-	if(!(sc->sc_resources.irq =
-			bus_alloc_resource_any(dev, SYS_RES_IRQ,
-					       &sc->sc_resources.irq_rid,
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get irq.\n",unit);
-		isic_detach_common(dev);
-		return ENXIO;                                       
-	}
-	
-	/* not needed */
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-
-
-	/* set flag so we know what this card is */
-
-	ret = ENXIO;
-	
-	switch(vend_id)
-	{
-#if defined(TEL_S0_16_3_P) || defined(CRTX_S0_P) || defined(COMPAQ_M610)
-		case VID_TEL163PNP:
-			sc->sc_cardtyp = CARD_TYPEP_163P;
-			ret = isic_attach_Cs0P(dev);
-			break;
-
-		case VID_CREATIXPP:
-			sc->sc_cardtyp = CARD_TYPEP_CS0P;
-			ret = isic_attach_Cs0P(dev);
-			break;
-
-		case VID_COMPAQ_M610:
-			sc->sc_cardtyp = CARD_TYPEP_COMPAQ_M610;
-			ret = isic_attach_Cs0P(dev);
-			break;
-#endif
-#ifdef DYNALINK
-		case VID_DYNALINK:
-			sc->sc_cardtyp = CARD_TYPEP_DYNALINK;
-			ret = isic_attach_Dyn(dev);
-			break;
-#endif
-#ifdef SEDLBAUER
-		case VID_SEDLBAUER:
-			sc->sc_cardtyp = CARD_TYPEP_SWS;
-			ret = isic_attach_sws(dev);
-			break;
-#endif
-#ifdef DRN_NGO
-		case VID_NICCYGO:
-			sc->sc_cardtyp = CARD_TYPEP_DRNNGO;
-			ret = isic_attach_drnngo(dev);
-			break;
-#endif
-#ifdef ELSA_QS1ISA
-		case VID_ELSAQS1P:
-			sc->sc_cardtyp = CARD_TYPEP_ELSAQS1ISA;
-			ret = isic_attach_Eqs1pi(dev);
-			break;
-#endif
-#ifdef ITKIX1
-		case VID_ITK0025:
-			sc->sc_cardtyp = CARD_TYPEP_ITKIX1;
-			ret = isic_attach_itkix1(dev);
-			break;
-#endif			
-#ifdef SIEMENS_ISURF2
-		case VID_SIESURF2:
-			sc->sc_cardtyp = CARD_TYPEP_SIE_ISURF2;
-			ret = isic_attach_siemens_isurf(dev);
-			break;
-#endif
-#ifdef ASUSCOM_IPAC
-		case VID_ASUSCOM_IPAC:
-			sc->sc_cardtyp = CARD_TYPEP_ASUSCOMIPAC;
-			ret = isic_attach_asi(dev);
-			break;
-#endif
-#ifdef EICON_DIVA
-		case VID_EICON_DIVA_20:
-			sc->sc_cardtyp = CARD_TYPEP_DIVA_ISA;
-			ret = isic_attach_diva(dev);
-			break;
-		
-		case VID_EICON_DIVA_202:
-			sc->sc_cardtyp = CARD_TYPEP_DIVA_ISA;
-			ret = isic_attach_diva_ipac(dev);
-			break;
-#endif
-		default:
-			printf("isic%d: Error, no driver for %s\n", unit, name);
-			ret = ENXIO;
-			break;		
-	}
-
-	if(ret)
-	{
-		isic_detach_common(dev);
-		return ENXIO;                                       
-	}		
-		
-	if(isic_attach_common(dev))
-	{
-		/* unset flag */
-		sc->sc_cardtyp = CARD_TYPEP_UNK;
-
-		/* free irq here, it hasn't been attached yet */
-		bus_release_resource(dev,SYS_RES_IRQ,sc->sc_resources.irq_rid,
-					sc->sc_resources.irq);
-		sc->sc_resources.irq = 0;
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-	else
-	{
-		/* setup intr routine */
-		bus_setup_intr(dev,sc->sc_resources.irq,INTR_TYPE_NET,
-				(void(*)(void*))isicintr,
-				sc,&ih);
-		return 0;
-	}
-}
--- sys/i4b/layer1/isic/i4b_itk_ix1.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Martin Husemann <martin at rumolt.teuto.de>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_itk_ix1.c - ITK ix1 micro passive card driver for isdn4bsd
- *	--------------------------------------------------------------
- *      last edit-date: [Wed Jan 24 09:27:06 2001]
- *
- *---------------------------------------------------------------------------
- *
- * The ITK ix1 micro ISDN card is an ISA card with one region
- * of four io ports mapped and a fixed irq all jumpered on the card.
- * Access to the board is straight forward and simmilar to
- * the ELSA and DYNALINK cards. If a PCI version of this card
- * exists all we need is probably a pci-bus attachment, all
- * this low level routines should work imediately.
- *
- * To reset the card:
- *   - write 0x01 to ITK_CONFIG
- *   - wait >= 10 ms
- *   - write 0x00 to ITK_CONFIG
- *
- * To read or write data:
- *  - write address to ITK_ALE port
- *  - read data from or write data to ITK_ISAC_DATA port or ITK_HSCX_DATA port
- * The two HSCX channel registers are offset by HSCXA (0x00) and HSCXB (0x40).
- *
- * The probe routine was derived by trial and error from a representative
- * sample of two cards ;-) The standard way (checking HSCX versions)
- * was extended by reading a zero from a non existant HSCX register (register
- * 0xff). Reading the config register gives varying results, so this doesn't
- * seem to be used as an id register (like the Teles S0/16.3).
- *
- * If the probe fails for your card use "options ITK_PROBE_DEBUG" to get
- * additional debug output.
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_itk_ix1.c,v 1.10 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(ITKIX1)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-#include <i4b/layer1/i4b_l1.h>
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-/* Register offsets */
-#define	ITK_ISAC_DATA	0
-#define	ITK_HSCX_DATA	1
-#define	ITK_ALE		2
-#define	ITK_CONFIG	3
-
-/* Size of IO range to allocate for this card */
-#define	ITK_IO_SIZE	4
-
-/* Register offsets for the two HSCX channels */
-#define	HSCXA	0
-#define	HSCXB	0x40
-
-static void
-itkix1_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	switch (what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ITK_ALE, 0);
-			bus_space_read_multi_1(t, h, ITK_ISAC_DATA, buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ITK_ALE, HSCXA);
-			bus_space_read_multi_1(t, h, ITK_HSCX_DATA, buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ITK_ALE, HSCXB);
-			bus_space_read_multi_1(t, h, ITK_HSCX_DATA, buf, size);
-			break;
-	}
-}
-
-static void
-itkix1_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	switch (what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ITK_ALE, 0);
-			bus_space_write_multi_1(t, h, ITK_ISAC_DATA, (u_int8_t*)buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ITK_ALE, HSCXA);
-			bus_space_write_multi_1(t, h, ITK_HSCX_DATA, (u_int8_t*)buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ITK_ALE, HSCXB);
-			bus_space_write_multi_1(t, h, ITK_HSCX_DATA, (u_int8_t*)buf, size);
-			break;
-	}
-}
-
-static void
-itkix1_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	switch (what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ITK_ALE, offs);
-			bus_space_write_1(t, h, ITK_ISAC_DATA, data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ITK_ALE, HSCXA+offs);
-			bus_space_write_1(t, h, ITK_HSCX_DATA, data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ITK_ALE, HSCXB+offs);
-			bus_space_write_1(t, h, ITK_HSCX_DATA, data);
-			break;
-	}
-}
-
-static u_int8_t
-itkix1_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	switch (what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ITK_ALE, offs);
-			return bus_space_read_1(t, h, ITK_ISAC_DATA);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ITK_ALE, HSCXA+offs);
-			return bus_space_read_1(t, h, ITK_HSCX_DATA);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ITK_ALE, HSCXB+offs);
-			return bus_space_read_1(t, h, ITK_HSCX_DATA);
-	}
-	return 0;
-}
-
-/*
- * Probe for card
- */
-int
-isic_probe_itkix1(device_t dev)
-{	
-	size_t unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = 0;		/* softc */
-	void *ih = 0;				/* dummy */
-	bus_space_tag_t    t;			/* bus things */
-	bus_space_handle_t h;
-	u_int8_t hd, hv1, hv2, saveale;
-	int ret;
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("Checking unit %u\n", unit);
-	#endif
-
-	/* check max unit range */
-	if(unit >= ISIC_MAXUNIT)
-	{
-		printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for ITK IX1!\n",
-				unit, unit);
-		return ENXIO;	
-	}
-
-	sc = &l1_sc[unit];			/* get pointer to softc */
-	sc->sc_unit = unit;			/* set unit */
-	
-	#if defined(ITK_PROBE_DEBUG)
-	printf("Allocating io base...");
-	#endif
-	
-	if(!(sc->sc_resources.io_base[0] =
-		bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-	        		&sc->sc_resources.io_rid[0],
-	                        RF_ACTIVE)))
-	{
-		printf("isic%d: Could not allocate i/o port for ITK IX1.\n", unit);
-		return ENXIO;
-	}
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("done.\n");
-	#endif
-
-	sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
-	t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("Allocating irq...");
-	#endif
-
-	/* get our irq */
-	if(!(sc->sc_resources.irq =
-			bus_alloc_resource_any(dev, SYS_RES_IRQ,
-						&sc->sc_resources.irq_rid,
-						RF_ACTIVE)))
-	{
-		printf("isic%d: Could not allocate irq for ITK IX1.\n", unit);
-		bus_release_resource(dev,SYS_RES_IOPORT,
-				sc->sc_resources.io_rid[0],
-				sc->sc_resources.io_base[0]);
-		return ENXIO;
-	}
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("done.\n");
-	#endif
-
-	/* get the irq number */
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("Setting up access routines...");
-	#endif
-	
-	/* setup access routines */
-	sc->clearirq = NULL;
-	sc->readreg = itkix1_read_reg;
-	sc->writereg = itkix1_write_reg;
-	sc->readfifo = itkix1_read_fifo;
-	sc->writefifo = itkix1_write_fifo;
-
-	/* setup card type */	
-	sc->sc_cardtyp = CARD_TYPEP_ITKIX1;
-
-	/* setup IOM bus type */
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("done.\n");
-	#endif
-
-	/* register interupt routine */
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("Setting up access interupt...");
-	#endif
-
-	bus_setup_intr(dev, sc->sc_resources.irq,
-			INTR_TYPE_NET,
-			(void(*)(void *))(isicintr),
-			sc, &ih);
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("done.\n");
-
-	printf("Doing probe stuff...");
-	#endif
-	
-	/* save old value of this port, we're stomping over it */
-	saveale = bus_space_read_1(t, h, ITK_ALE);
-
-	/* select invalid register */
-	bus_space_write_1(t, h, ITK_ALE, 0xff);
-	/* get HSCX data for this non existent register */
-	hd = bus_space_read_1(t, h, ITK_HSCX_DATA);
-	/* get HSCX version info */
-	bus_space_write_1(t, h, ITK_ALE, HSCXA + H_VSTR);
-	hv1 = bus_space_read_1(t, h, ITK_HSCX_DATA);
-	bus_space_write_1(t, h, ITK_ALE, HSCXB + H_VSTR);
-	hv2 = bus_space_read_1(t, h, ITK_HSCX_DATA);
-
-	ret =  (hd == 0) && ((hv1 & 0x0f) == 0x05) && ((hv2 & 0x0f) == 0x05);
-	/* succeed if version bits are OK and we got a zero from the
-	 * non existent register. we found verison 0x05 and 0x04
-	 * out there... */
-	ret =  (hd == 0)
-		&& (((hv1 & 0x0f) == 0x05) || ((hv1 & 0x0f) == 0x04))
-		&& (((hv2 & 0x0f) == 0x05) || ((hv2 & 0x0f) == 0x04));
-
-	/* retstore save value if we fail (if we succeed the old value
-	 * has no meaning) */
-	if (!ret)
-		bus_space_write_1(t, h, ITK_ALE, saveale);
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("done.\n");
-
-	printf("Doing second probe stuff...");
-	#endif
-
-	hv1 = HSCX_READ(0, H_VSTR) & 0xf;
-	hv2 = HSCX_READ(1, H_VSTR) & 0xf;
-	/* Read HSCX A/B VSTR.  Expected value is 0x05 (V2.1) or 0x04 (V2.0). */
-	if((hv1 != 0x05 && hv1 != 0x04) || (hv2 != 0x05 && hv2 != 0x04))
-	{
-		printf("isic%d: HSCX VSTR test failed for ITK ix1 micro\n",
-			unit);
-		printf("isic%d: HSC0: VSTR: %#x\n",
-			unit, HSCX_READ(0, H_VSTR));
-		printf("isic%d: HSC1: VSTR: %#x\n",
-			unit, HSCX_READ(1, H_VSTR));
-		isic_detach_common(dev);
-		return ENXIO;
-	}  
-
-	#if defined(ITK_PROBE_DEBUG)
-	printf("done.\n");
-	#endif
-
-#if defined(ITK_PROBE_DEBUG)
-	printf("\nITK ix1 micro probe: hscx = 0x%02x, v1 = 0x%02x, v2 = 0x%02x, would have %s\n",
-		hd, hv1, hv2, ret ? "succeeded" : "failed");
-	isic_detach_common(dev);
-	return ENXIO;
-#else
-	if ( ret )
-	{
-		return 0;
-	}
-	else
-	{
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-#endif
-}
-
-/*
- *  Attach card
- */
-int
-isic_attach_itkix1(device_t dev)
-{
-	size_t unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = &l1_sc[unit];
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]); 
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	/* setup access routines */
-	sc->clearirq = NULL;
-	sc->readreg = itkix1_read_reg;
-	sc->writereg = itkix1_write_reg;
-	sc->readfifo = itkix1_read_fifo;
-	sc->writefifo = itkix1_write_fifo;
-
-	/* setup card type */	
-	sc->sc_cardtyp = CARD_TYPEP_ITKIX1;
-
-	/* setup IOM bus type */
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-
-	bus_space_write_1(t, h, ITK_CONFIG, 1);
-	DELAY(SEC_DELAY / 10);
-	bus_space_write_1(t, h, ITK_CONFIG, 0);
-	DELAY(SEC_DELAY / 10);
-
-	return 0;
-}
-
-#endif /* defined(ITKIX1) */
--- sys/i4b/layer1/isic/i4b_elsa_pcc16.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/*-
- * Copyright (c) 1999, 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	isic - I4B driver for ELSA MicroLink ISDN/PCC-16 and ELSA PCFpro
- *	================================================================
- *      last edit-date: [Sun Oct 21 09:42:17 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_elsa_pcc16.c,v 1.10 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(ELSA_PCC16)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-static void i4b_epcc16_clrirq(struct l1_softc *sc);
-
-/* masks for register encoded in base addr */
-
-#define ELSA_BASE_MASK		0x0ffff
-#define ELSA_OFF_MASK		0xf0000
-
-/* register id's to be encoded in base addr */
-
-#define ELSA_IDISAC		0x00000
-#define ELSA_IDHSCXA		0x10000
-#define ELSA_IDHSCXB		0x20000
-
-/* offsets from base address */
-
-#define ELSA_OFF_ISAC		0x00
-#define ELSA_OFF_HSCX		0x02
-#define ELSA_OFF_OFF		0x03
-#define ELSA_OFF_CTRL		0x04
-#define ELSA_OFF_CFG		0x05
-#define ELSA_OFF_TIMR		0x06
-#define ELSA_OFF_IRQ		0x07
-
-/* control register (write access) */
-
-#define ELSA_CTRL_LED_YELLOW	0x02
-#define ELSA_CTRL_LED_GREEN	0x08
-#define ELSA_CTRL_RESET		0x20
-#define ELSA_CTRL_TIMEREN	0x80
-#define ELSA_CTRL_SECRET	0x50
-
-/*---------------------------------------------------------------------------*
- *      ELSA MicroLink ISDN/PCC-16 clear IRQ routine
- *---------------------------------------------------------------------------*/
-static void
-i4b_epcc16_clrirq(struct l1_softc *sc)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	bus_space_write_1(t, h, ELSA_OFF_IRQ, 0);
-}
-
-/*---------------------------------------------------------------------------*
- *      ELSA MicroLink ISDN/PCC-16 ISAC get fifo routine
- *---------------------------------------------------------------------------*/
-static void
-epcc16_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
-			bus_space_read_multi_1(t, h, ELSA_OFF_ISAC, buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
-			bus_space_read_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40);
-			bus_space_read_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      ELSA MicroLink ISDN/PCC-16 ISAC put fifo routine
- *---------------------------------------------------------------------------*/
-static void
-epcc16_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
-			bus_space_write_multi_1(t, h, ELSA_OFF_ISAC, buf, size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
-			bus_space_write_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40);
-			bus_space_write_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      ELSA MicroLink ISDN/PCC-16 ISAC put register routine
- *---------------------------------------------------------------------------*/
-static void
-epcc16_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
-			bus_space_write_1(t, h, ELSA_OFF_ISAC, data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
-			bus_space_write_1(t, h, ELSA_OFF_HSCX, data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40+offs);
-			bus_space_write_1(t, h, ELSA_OFF_HSCX, data);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	ELSA MicroLink ISDN/PCC-16 ISAC get register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-epcc16_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	switch (what) {
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
-			return bus_space_read_1(t, h, ELSA_OFF_ISAC);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
-			return bus_space_read_1(t, h, ELSA_OFF_HSCX);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40+offs);
-			return bus_space_read_1(t, h, ELSA_OFF_HSCX);
-	}
-	return 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_detach_Epcc16 - detach for ELSA MicroLink ISDN/PCC-16
- *---------------------------------------------------------------------------*/
-static void
-isic_detach_Epcc16(device_t dev)
-{
-	struct l1_softc *sc = &l1_sc[device_get_unit(dev)];
-
-	if ( sc->sc_resources.irq )
-	{
-		bus_teardown_intr(dev,sc->sc_resources.irq,
-			(void(*)(void *))isicintr);
-		bus_release_resource(dev,SYS_RES_IRQ,
-					sc->sc_resources.irq_rid,
-					sc->sc_resources.irq);
-		sc->sc_resources.irq = 0;
-	}
-	
-	if ( sc->sc_resources.io_base[0] ) {
-		bus_release_resource(dev,SYS_RES_IOPORT,
-					sc->sc_resources.io_rid[0],
-					sc->sc_resources.io_base[0]);
-		sc->sc_resources.io_base[0] = 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	isic_probe_Epcc16 - probe for ELSA MicroLink ISDN/PCC-16
- *---------------------------------------------------------------------------*/
-int
-isic_probe_Epcc16(device_t dev)
-{
-	size_t unit = device_get_unit(dev);	/* get unit */
-	struct l1_softc *sc = 0;		/* pointer to softc */
-	void *ih = 0;				/* dummy */
-
-	/* check max unit range */
-	if(unit >= ISIC_MAXUNIT)
-	{
-		printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for ELSA PCC-16!\n",
-				unit, unit);
-		return(ENXIO);	
-	}
-
-	sc = &l1_sc[unit];		/* get pointer to softc */
-	sc->sc_unit = unit;		/* set unit */
-
-	/* see if an io base was supplied */
-	
-	if(!(sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get iobase for ELSA PCC-16.\n",
-				unit);
-		return(ENXIO);
-	}
-
-	/* check if we got an iobase */
-
-	sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]);
-
-	switch(sc->sc_port)
-	{
-		case 0x160:
-		case 0x170:
-		case 0x260:
-		case 0x360:
-			break;
-		default:
-			printf("isic%d: Error, invalid iobase 0x%x specified for ELSA MicroLink ISDN/PCC-16!\n",
-				unit, sc->sc_port);
-			isic_detach_Epcc16(dev);
-			return(ENXIO);
-			break;
-	}
-
-	/* setup access routines */
-
-	sc->clearirq = i4b_epcc16_clrirq;
-	sc->readreg = epcc16_read_reg;
-	sc->writereg = epcc16_write_reg;
-
-	sc->readfifo = epcc16_read_fifo;
-	sc->writefifo = epcc16_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_PCC16;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;	
-
-	/* 
-	 * Read HSCX A/B VSTR.  Expected value for the ELSA PCC-16
-	 * is 0x05 ( = version 2.1 ) in the least significant bits.
-	 */
-
-	if( ((HSCX_READ(0, H_VSTR) & 0xf) != 0x5) ||
-            ((HSCX_READ(1, H_VSTR) & 0xf) != 0x5) )
-	{
-		/* patch from "Doobee R . Tzeck" <drt at ailis.de>:
-		 * I own an ELSA PCFpro. To my knowledge, the ELSA PCC16 is
-		 * a stripped down Version on the PCFpro. By patching the
-		 * card detection routine for the PPC16 I was able to use
-		 * the PPC16 driver for the PCFpro.
-		 */
-		if( ((HSCX_READ(0, H_VSTR) & 0xf) != 0x85) ||
-		    ((HSCX_READ(1, H_VSTR) & 0xf) != 0x85) )
-		{
-			printf("isic%d: HSCX VSTR test failed for ELSA MicroLink ISDN/PCC-16\n",
-				unit);
-			isic_detach_Epcc16(dev);
-			printf("isic%d: HSC0: VSTR: %#x\n",
-				unit, HSCX_READ(0, H_VSTR));
-			printf("isic%d: HSC1: VSTR: %#x\n",
-				unit, HSCX_READ(1, H_VSTR));
-			return (ENXIO);
-		}
-		else
-		{
-			printf("isic%d: ELSA MicroLink ISDN/PCFpro found, going to tread it as PCC-16\n",
-				unit);
-		}
-	}
-
-	/* get our irq */
-
-	if(!(sc->sc_resources.irq =
-			bus_alloc_resource_any(dev, SYS_RES_IRQ,
-					       &sc->sc_resources.irq_rid,
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Could not get an irq.\n",unit);
-		isic_detach_Epcc16(dev);
-		return ENXIO;
-	}
-
-	/* get the irq number */
-	sc->sc_irq = rman_get_start(sc->sc_resources.irq);
-
-	/* check IRQ validity */	
-	switch(sc->sc_irq)
-	{
-		case 2:
-		case 9:		
-		case 3:		
-		case 5:
-		case 10:
-		case 11:
-		case 15:		
-			break;
-			
-		default:
-			printf("isic%d: Error, invalid IRQ [%d] specified for ELSA MicroLink ISDN/PCC-16!\n",
-				unit, sc->sc_irq);
-			isic_detach_Epcc16(dev);
-			return(ENXIO);
-			break;
-	}
-
-	/* register interupt routine */
-	bus_setup_intr(dev,sc->sc_resources.irq,INTR_TYPE_NET,
-			(void(*)(void *))(isicintr),
-			sc,&ih);
-
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- * isic_attach_Epcc16 - attach for ELSA MicroLink ISDN/PCC-16
- *---------------------------------------------------------------------------*/
-int
-isic_attach_Epcc16(device_t dev)
-{
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];	
-	bus_space_tag_t    t = rman_get_bustag(sc->sc_resources.io_base[0]);
-	bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	u_char byte = ELSA_CTRL_SECRET;
-
-	byte &= ~ELSA_CTRL_RESET;
-        bus_space_write_1(t, h, ELSA_OFF_CTRL, byte);
-        DELAY(20);
-	byte |= ELSA_CTRL_RESET;
-        bus_space_write_1(t, h, ELSA_OFF_CTRL, byte);
-
-        DELAY(20);
-        bus_space_write_1(t, h, ELSA_OFF_IRQ, 0xff);
-
-	return 0;
-}
-
-#endif /* defined(ELSA_PCC16) */
--- sys/i4b/layer1/isic/i4b_drn_ngo.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_drn_ngo.c - Dr. Neuhaus Niccy GO@ and SAGEM Cybermod
- *	--------------------------------------------------------
- *      last edit-date: [Wed Jan 24 09:07:44 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/isic/i4b_drn_ngo.c,v 1.9 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#if defined(DRN_NGO)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-/*---------------------------------------------------------------------------*
- *	Niccy GO@ definitions
- *
- *	the card uses 2 i/o addressranges each using 2 bytes
- *
- *	addressrange 0:
- *		offset 0 - ISAC dataregister
- *		offset 1 - HSCX dataregister
- *	addressrange 1:
- *		offset 0 - ISAC addressregister
- *		offset 1 - HSCX addressregister
- *
- *	to access an ISAC/HSCX register, you have to write the register
- *	number into the ISAC or HSCX addressregister and then read/write
- *	data for the ISAC/HSCX register into/from the corresponding
- *	dataregister.
- *
- *	Thanks to Klaus Muehle of Dr. Neuhaus Telekommunikation for giving
- *	out this information!
- *                                                     
- *---------------------------------------------------------------------------*/
-#define NICCY_PORT_MIN	0x200
-#define NICCY_PORT_MAX	0x3e0
-
-#define HSCX_ABIT	0x1000		/* flag, HSCX A is meant */
-#define HSCX_BBIT	0x2000		/* flag, HSCX B is meant */
-
-#define HSCX_BOFF	0x40
-
-#define ADDR_OFF	2		/* address register range offset */
-
-#define ISAC_DATA	0
-#define HSCX_DATA	1
-
-#define ISAC_ADDR	0
-#define HSCX_ADDR	1
-
-/*---------------------------------------------------------------------------*
- *	Dr. Neuhaus Niccy GO@ read fifo routine
- *---------------------------------------------------------------------------*/
-static void
-drnngo_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t tdata, tadr;
-	bus_space_handle_t hdata, hadr;
-
-	tdata = rman_get_bustag(sc->sc_resources.io_base[0]);
-	hdata = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	tadr = rman_get_bustag(sc->sc_resources.io_base[1]);
-	hadr = rman_get_bushandle(sc->sc_resources.io_base[1]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1     (tadr ,hadr, ISAC_ADDR,0x0);
-			bus_space_read_multi_1(tdata,hdata,ISAC_DATA,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1     (tadr ,hadr ,HSCX_ADDR,0x0);
-			bus_space_read_multi_1(tdata,hdata,HSCX_DATA,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1     (tadr ,hadr ,HSCX_ADDR,HSCX_BOFF);
-			bus_space_read_multi_1(tdata,hdata,HSCX_DATA,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Dr. Neuhaus Niccy GO@ write fifo routine
- *---------------------------------------------------------------------------*/
-static void
-drnngo_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	bus_space_tag_t tdata, tadr;
-	bus_space_handle_t hdata, hadr;
-
-	tdata = rman_get_bustag(sc->sc_resources.io_base[0]);
-	hdata = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	tadr = rman_get_bustag(sc->sc_resources.io_base[1]);
-	hadr = rman_get_bushandle(sc->sc_resources.io_base[1]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1      (tadr ,hadr, ISAC_ADDR,0x0);
-			bus_space_write_multi_1(tdata,hdata,ISAC_DATA,buf,size);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1      (tadr ,hadr ,HSCX_ADDR,0x0);
-			bus_space_write_multi_1(tdata,hdata,HSCX_DATA,buf,size);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1      (tadr ,hadr ,HSCX_ADDR,HSCX_BOFF);
-			bus_space_write_multi_1(tdata,hdata,HSCX_DATA,buf,size);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Dr. Neuhaus Niccy GO@ write register routine
- *---------------------------------------------------------------------------*/
-static void 
-drnngo_write_reg(struct l1_softc *sc, int what, bus_size_t reg, u_int8_t data)
-{
-	bus_space_tag_t tdata, tadr;
-	bus_space_handle_t hdata, hadr;
-
-	tdata = rman_get_bustag(sc->sc_resources.io_base[0]);
-	hdata = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	tadr = rman_get_bustag(sc->sc_resources.io_base[1]);
-	hadr = rman_get_bushandle(sc->sc_resources.io_base[1]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(tadr ,hadr, ISAC_ADDR,reg);
-			bus_space_write_1(tdata,hdata,ISAC_DATA,data);
-			break;
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(tadr ,hadr ,HSCX_ADDR,reg);
-			bus_space_write_1(tdata,hdata,HSCX_DATA,data);
-			break;
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(tadr ,hadr ,HSCX_ADDR,reg+HSCX_BOFF);
-			bus_space_write_1(tdata,hdata,HSCX_DATA,data);
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Dr. Neuhaus Niccy GO@ read register routine
- *---------------------------------------------------------------------------*/
-static u_int8_t
-drnngo_read_reg(struct l1_softc *sc, int what, bus_size_t reg)
-{
-	bus_space_tag_t tdata, tadr;
-	bus_space_handle_t hdata, hadr;
-
-	tdata = rman_get_bustag(sc->sc_resources.io_base[0]);
-	hdata = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	tadr = rman_get_bustag(sc->sc_resources.io_base[1]);
-	hadr = rman_get_bushandle(sc->sc_resources.io_base[1]);
-
-	switch(what)
-	{
-		case ISIC_WHAT_ISAC:
-			bus_space_write_1(tadr ,hadr, ISAC_ADDR,reg);
-			return bus_space_read_1(tdata,hdata,ISAC_DATA);
-		case ISIC_WHAT_HSCXA:
-			bus_space_write_1(tadr ,hadr ,HSCX_ADDR,reg);
-			return bus_space_read_1(tdata,hdata,HSCX_DATA);
-		case ISIC_WHAT_HSCXB:
-			bus_space_write_1(tadr ,hadr ,HSCX_ADDR,reg+HSCX_BOFF);
-			return bus_space_read_1(tdata,hdata,HSCX_DATA);
-		default:
-			return 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      probe for ISA PnP cards
- *---------------------------------------------------------------------------*/
-int
-isic_attach_drnngo(device_t dev)
-{
-	int unit = device_get_unit(dev);
-	struct l1_softc *sc = &l1_sc[unit];
-
-	sc->sc_resources.io_rid[1] = 1;	
-
-	/*
-	 * this card needs a second io_base,
-	 * free resources if we don't get it
-	 */
-
-	if(!(sc->sc_resources.io_base[1] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[1],
-					       RF_ACTIVE)))
-	{
-		printf("isic%d: Failed to get second io base.\n", unit);
-		isic_detach_common(dev);
-		return ENXIO;
-	}
-
-	/* setup ISAC access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = drnngo_read_reg;
-	sc->writereg = drnngo_write_reg;
-
-	sc->readfifo = drnngo_read_fifo;
-	sc->writefifo = drnngo_write_fifo;
-
-	/* setup card type */
-
-	sc->sc_cardtyp = CARD_TYPEP_DRNNGO;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = HSCX_FIFO_LEN;
-	
-	return (0);
-}
-
-#endif /* defined(DRN_NGO) */
--- sys/i4b/capi/capi_l4if.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/*-
- * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* capi/capi_l4if.c	The CAPI i4b L4/device interface.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/capi/capi_l4if.c,v 1.7 2005/01/06 22:18:18 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-#include <i4b/capi/capi.h>
-#include <i4b/capi/capi_msgs.h>
-
-static void n_connect_request(u_int cdid);
-static void n_connect_response(u_int cdid, int response, int cause);
-static void n_disconnect_request(u_int cdid, int cause);
-static void n_alert_request(u_int cdid);
-static void n_mgmt_command(int unit, int cmd, void *parm);
-static int  n_download(int unit, int, struct isdn_dr_prot *);
-
-capi_softc_t *capi_sc[MAX_CONTROLLERS] = { NULL, };
-int ncapi = 0;
-
-/*
-//  i4b_capi_{ret,set}_linktab
-//      i4b driver glue.
-//
-//  i4b_capi_bch_config
-//      Called by i4b driver to flush + {en,dis}able a channel.
-//
-//  i4b_capi_bch_start_tx
-//      Called by i4b driver to transmit a queued mbuf.
-//
-//  i4b_capi_bch_stat
-//      Called by i4b driver to obtain statistics information.
-*/
-
-static isdn_link_t *
-i4b_capi_ret_linktab(int unit, int channel)
-{
-    capi_softc_t *sc = capi_sc[unit];
-    return &sc->sc_bchan[channel].capi_isdn_linktab;
-}
-
-static void
-i4b_capi_set_linktab(int unit, int channel, drvr_link_t *dlt)
-{
-    capi_softc_t *sc = capi_sc[unit];
-    sc->sc_bchan[channel].capi_drvr_linktab = dlt;
-}
-
-static void
-i4b_capi_bch_config(int unit, int chan, int bprot, int activate)
-{
-    capi_softc_t *sc = capi_sc[unit];
-
-    i4b_Bcleanifq(&sc->sc_bchan[chan].tx_queue);
-    sc->sc_bchan[chan].tx_queue.ifq_maxlen = IFQ_MAXLEN;
-    sc->sc_bchan[chan].txcount = 0;
-
-    /* The telephony drivers use rx_queue for receive. */
-
-    i4b_Bcleanifq(&sc->sc_bchan[chan].rx_queue);
-    sc->sc_bchan[chan].rx_queue.ifq_maxlen = IFQ_MAXLEN;
-    sc->sc_bchan[chan].rxcount = 0;
-
-    /* HDLC frames are put to in_mbuf */
-
-    i4b_Bfreembuf(sc->sc_bchan[chan].in_mbuf);
-    sc->sc_bchan[chan].in_mbuf = NULL;
-
-    /* Because of the difference, we need to remember the protocol. */
-
-    sc->sc_bchan[chan].bprot = bprot;
-    sc->sc_bchan[chan].busy = 0;
-}
-
-static void
-i4b_capi_bch_start_tx(int unit, int chan)
-{
-    capi_softc_t *sc = capi_sc[unit];
-    int s;
-
-    s = SPLI4B();
-
-    if (sc->sc_bchan[chan].state != B_CONNECTED) {
-	splx(s);
-	printf("capi%d: start_tx on unconnected channel\n", sc->sc_unit);
-	return;
-    }
-
-    if (sc->sc_bchan[chan].busy) {
-	splx(s);
-	return;
-    }
-
-    capi_start_tx(sc, chan);
-
-    splx(s);
-}
-
-static void
-i4b_capi_bch_stat(int unit, int chan, bchan_statistics_t *bsp)
-{
-    capi_softc_t *sc = capi_sc[unit];
-    int s = SPLI4B();
-
-    bsp->outbytes = sc->sc_bchan[chan].txcount;
-    bsp->inbytes = sc->sc_bchan[chan].rxcount;
-
-    sc->sc_bchan[chan].txcount = 0;
-    sc->sc_bchan[chan].rxcount = 0;
-
-    splx(s);
-}
-
-int capi_start_tx(capi_softc_t *sc, int chan)
-{
-    struct mbuf *m_b3;
-    int sent = 0;
-
-    _IF_DEQUEUE(&sc->sc_bchan[chan].tx_queue, m_b3);
-    while (m_b3) {
-	struct mbuf *m = m_b3->m_next;
-
-	sc->sc_bchan[chan].txcount += m_b3->m_len;
-	capi_data_b3_req(sc, chan, m_b3);
-	sent++;
-
-	m_b3 = m;
-    }
-
-    if (sc->sc_bchan[chan].capi_drvr_linktab) {
-	/* Notify i4b driver of activity, and if the queue is drained. */
-
-	if (sent)
-	    (*sc->sc_bchan[chan].capi_drvr_linktab->bch_activity)(
-		sc->sc_bchan[chan].capi_drvr_linktab->unit, ACT_TX);
-
-	if (IF_QEMPTY(&sc->sc_bchan[chan].tx_queue))
-	    (*sc->sc_bchan[chan].capi_drvr_linktab->bch_tx_queue_empty)(
-		sc->sc_bchan[chan].capi_drvr_linktab->unit);
-    }
-
-    return sent;
-}
-
-/*
-//  capi_ll_attach
-//      Called by a link layer driver at boot time.
-*/
-
-int
-capi_ll_attach(capi_softc_t *sc)
-{
-    int i;
-
-    if (ncapi == (sizeof(capi_sc) / sizeof(capi_sc[0]))) {
-	printf("capi%d: too many units, increase MAX_CONTROLLERS\n", ncapi);
-	return (ENXIO);
-    }
-
-    /* Unit type and subtype; sc is partly filled by ll driver */
-    
-    ctrl_desc[nctrl].unit = ncapi;
-    ctrl_desc[nctrl].ctrl_type = CTRL_CAPI;
-    ctrl_desc[nctrl].card_type = sc->card_type;
-
-    /* L4 callbacks */
-    
-    ctrl_types[CTRL_CAPI].get_linktab = i4b_capi_ret_linktab;
-    ctrl_types[CTRL_CAPI].set_linktab = i4b_capi_set_linktab;
-
-    ctrl_desc[nctrl].N_CONNECT_REQUEST = n_connect_request;
-    ctrl_desc[nctrl].N_CONNECT_RESPONSE = n_connect_response;
-    ctrl_desc[nctrl].N_DISCONNECT_REQUEST = n_disconnect_request;
-    ctrl_desc[nctrl].N_ALERT_REQUEST = n_alert_request;
-    ctrl_desc[nctrl].N_DOWNLOAD = n_download;
-    ctrl_desc[nctrl].N_DIAGNOSTICS = NULL; /* XXX todo */
-    ctrl_desc[nctrl].N_MGMT_COMMAND = n_mgmt_command;
-
-    /* Unit state */
-
-    sc->sc_enabled = FALSE;
-    sc->sc_state = C_DOWN;
-    sc->sc_msgid = 0;
-
-    ctrl_desc[nctrl].dl_est = DL_DOWN;
-    ctrl_desc[nctrl].nbch = sc->sc_nbch;
-
-    for (i = 0; i < sc->sc_nbch; i++) {
-	ctrl_desc[nctrl].bch_state[i] = BCH_ST_FREE;
-	sc->sc_bchan[i].ncci = INVALID;
-	sc->sc_bchan[i].msgid = 0;
-	sc->sc_bchan[i].busy = 0;
-	sc->sc_bchan[i].state = B_FREE;
-
-	memset(&sc->sc_bchan[i].tx_queue, 0, sizeof(struct ifqueue));
-	memset(&sc->sc_bchan[i].rx_queue, 0, sizeof(struct ifqueue));
-	sc->sc_bchan[i].tx_queue.ifq_maxlen = IFQ_MAXLEN;
-	sc->sc_bchan[i].rx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-	if(!mtx_initialized(&sc->sc_bchan[i].tx_queue.ifq_mtx))
-		mtx_init(&sc->sc_bchan[i].tx_queue.ifq_mtx, "i4b_capi_tx", NULL, MTX_DEF);
-	if(!mtx_initialized(&sc->sc_bchan[i].rx_queue.ifq_mtx))	
-		mtx_init(&sc->sc_bchan[i].rx_queue.ifq_mtx, "i4b_capi_rx", NULL, MTX_DEF);	
-
-	sc->sc_bchan[i].txcount = 0;
-	sc->sc_bchan[i].rxcount = 0;
-
-	sc->sc_bchan[i].cdid = CDID_UNUSED;
-	sc->sc_bchan[i].bprot = BPROT_NONE;
-	sc->sc_bchan[i].in_mbuf = NULL;
-
-	sc->sc_bchan[i].capi_drvr_linktab = NULL;
-
-	sc->sc_bchan[i].capi_isdn_linktab.unit = ncapi;
-	sc->sc_bchan[i].capi_isdn_linktab.channel = i;
-	sc->sc_bchan[i].capi_isdn_linktab.bch_config = i4b_capi_bch_config;
-	sc->sc_bchan[i].capi_isdn_linktab.bch_tx_start = i4b_capi_bch_start_tx;
-	sc->sc_bchan[i].capi_isdn_linktab.bch_stat = i4b_capi_bch_stat;
-	sc->sc_bchan[i].capi_isdn_linktab.tx_queue = &sc->sc_bchan[i].tx_queue;
-	sc->sc_bchan[i].capi_isdn_linktab.rx_queue = &sc->sc_bchan[i].rx_queue;
-	sc->sc_bchan[i].capi_isdn_linktab.rx_mbuf = &sc->sc_bchan[i].in_mbuf;
-    }
-
-    ctrl_desc[nctrl].tei = -1;
-
-    /* Up the controller index and store the softc */
-
-    sc->sc_unit = ncapi;
-    capi_sc[ncapi++] = sc;
-    sc->ctrl_unit = nctrl++;
-
-    printf("capi%d: card type %d attached\n", sc->sc_unit, sc->card_type);
-
-    return(0);
-}
-
-/*
-//  n_mgmt_command
-//      i4b L4 management command.
-*/
-
-static void
-n_mgmt_command(int unit, int op, void *arg)
-{
-    capi_softc_t *sc = capi_sc[unit];
-
-    printf("capi%d: mgmt command %d\n", sc->sc_unit, op);
-
-    switch(op) {
-    case CMR_DOPEN:
-	sc->sc_enabled = TRUE;
-	break;
-
-    case CMR_DCLOSE:
-	sc->sc_enabled = FALSE;
-	break;
-
-    case CMR_SETTRACE:
-	break;
-
-    default:
-	break;
-    }
-}
-
-/*
-//  n_connect_request
-//      i4b L4 wants to connect. We assign a B channel to the call,
-//      send a CAPI_CONNECT_REQ, and set the channel to B_CONNECT_CONF.
-*/
-
-static void
-n_connect_request(u_int cdid)
-{
-    call_desc_t *cd = cd_by_cdid(cdid);
-    capi_softc_t *sc;
-    int bch, s;
-
-    if (!cd) {
-	printf("capi?: invalid cdid %d\n", cdid);
-	return;
-    }
-
-    sc = capi_sc[ctrl_desc[cd->controller].unit];
-    bch = cd->channelid;
-
-    s = SPLI4B();
-
-    if ((bch < 0) || (bch >= sc->sc_nbch))
-	for (bch = 0; bch < sc->sc_nbch; bch++)
-	    if (sc->sc_bchan[bch].state == B_FREE)
-		break;
-
-    if (bch == sc->sc_nbch) {
-	splx(s);
-	printf("capi%d: no free B channel\n", sc->sc_unit);
-	return;
-    }
-
-    cd->channelid = bch;
-
-    capi_connect_req(sc, cd);
-    splx(s);
-}
-
-/*
-//  n_connect_response
-//      i4b L4 answers a call. We send a CONNECT_RESP with the proper
-//      Reject code, and set the channel to B_CONNECT_B3_IND or B_FREE,
-//      depending whether we answer or not.
-*/
-
-static void
-n_connect_response(u_int cdid, int response, int cause)
-{
-    call_desc_t *cd = cd_by_cdid(cdid);
-    capi_softc_t *sc;
-    int bch, s;
-
-    if (!cd) {
-	printf("capi?: invalid cdid %d\n", cdid);
-	return;
-    }
-
-    sc = capi_sc[ctrl_desc[cd->controller].unit];
-    bch = cd->channelid;
-
-    T400_stop(cd);
-	
-    cd->response = response;
-    cd->cause_out = cause;
-
-    s = SPLI4B();
-    capi_connect_resp(sc, cd);
-    splx(s);
-}
-
-/*
-//  n_disconnect_request
-//      i4b L4 wants to disconnect. We send a DISCONNECT_REQ and
-//      set the channel to B_DISCONNECT_CONF.
-*/
-
-static void
-n_disconnect_request(u_int cdid, int cause)
-{
-    call_desc_t *cd = cd_by_cdid(cdid);
-    capi_softc_t *sc;
-    int bch, s;
-
-    if (!cd) {
-	printf("capi?: invalid cdid %d\n", cdid);
-	return;
-    }
-
-    sc = capi_sc[ctrl_desc[cd->controller].unit];
-    bch = cd->channelid;
-
-    cd->cause_out = cause;
-
-    s = SPLI4B();
-    capi_disconnect_req(sc, cd);
-    splx(s);
-}
-
-/*
-//  n_alert_request
-//      i4b L4 wants to alert an incoming call. We send ALERT_REQ.
-*/
-
-static void
-n_alert_request(u_int cdid)
-{
-    call_desc_t *cd = cd_by_cdid(cdid);
-    capi_softc_t *sc;
-    int s;
-
-    if (!cd) {
-	printf("capi?: invalid cdid %d\n", cdid);
-	return;
-    }
-
-    sc = capi_sc[ctrl_desc[cd->controller].unit];
-
-    s = SPLI4B();
-    capi_alert_req(sc, cd);
-    splx(s);
-}
-
-/*
-//  n_download
-//      L4 -> firmware download
-*/
-
-static int
-n_download(int unit, int numprotos, struct isdn_dr_prot *protocols)
-{
-    capi_softc_t *sc = capi_sc[unit];
-
-    if (sc->load) {
-	(*capi_sc[unit]->load)(sc, protocols[0].bytecount,
-			       protocols[0].microcode);
-    }
-
-    return(0);
-}
--- sys/i4b/capi/capi_msgs.h
+++ /dev/null
@@ -1,381 +0,0 @@
-/*-
- * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* capi/capi_msgs.h	The CAPI i4b message and handler declarations.
- *
- * $FreeBSD: src/sys/i4b/capi/capi_msgs.h,v 1.2 2005/01/06 22:18:18 imp Exp $
- */
-
-#ifndef _I4B_CAPI_MSGS_H_
-#define _I4B_CAPI_MSGS_H_
-
-/* CAPI commands */
-
-#define CAPI_ALERT                   0x01
-#define CAPI_CONNECT                 0x02
-#define CAPI_CONNECT_ACTIVE          0x03
-#define CAPI_CONNECT_B3              0x82
-#define CAPI_CONNECT_B3_ACTIVE       0x83
-#define CAPI_CONNECT_B3_T90_ACTIVE   0x88
-#define CAPI_DATA_B3                 0x86
-#define CAPI_DISCONNECT_B3           0x84
-#define CAPI_DISCONNECT              0x04
-#define CAPI_FACILITY                0x80
-#define CAPI_INFO                    0x08
-#define CAPI_LISTEN                  0x05
-#define CAPI_MANUFACTURER            0xff
-#define CAPI_RESET_B3                0x87
-#define CAPI_SELECT_B_PROTOCOL       0x41
-
-/* CAPI subcommands */
-
-#define CAPI_REQ                     0x80
-#define CAPI_CONF                    0x81
-#define CAPI_IND                     0x82
-#define CAPI_RESP                    0x83
-
-/* CAPI combined commands */
-
-#define CAPICMD(cmd,subcmd)          (((subcmd)<<8)|(cmd))
-
-#define CAPI_DISCONNECT_REQ          CAPICMD(CAPI_DISCONNECT,CAPI_REQ)
-#define CAPI_DISCONNECT_CONF         CAPICMD(CAPI_DISCONNECT,CAPI_CONF)
-#define CAPI_DISCONNECT_IND          CAPICMD(CAPI_DISCONNECT,CAPI_IND)
-#define CAPI_DISCONNECT_RESP         CAPICMD(CAPI_DISCONNECT,CAPI_RESP)
-
-#define CAPI_ALERT_REQ               CAPICMD(CAPI_ALERT,CAPI_REQ)
-#define CAPI_ALERT_CONF              CAPICMD(CAPI_ALERT,CAPI_CONF)
-
-#define CAPI_CONNECT_REQ             CAPICMD(CAPI_CONNECT,CAPI_REQ)
-#define CAPI_CONNECT_CONF            CAPICMD(CAPI_CONNECT,CAPI_CONF)
-#define CAPI_CONNECT_IND             CAPICMD(CAPI_CONNECT,CAPI_IND)
-#define CAPI_CONNECT_RESP            CAPICMD(CAPI_CONNECT,CAPI_RESP)
-
-#define CAPI_CONNECT_ACTIVE_REQ      CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_REQ)
-#define CAPI_CONNECT_ACTIVE_CONF     CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_CONF)
-#define CAPI_CONNECT_ACTIVE_IND      CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_IND)
-#define CAPI_CONNECT_ACTIVE_RESP     CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_RESP)
-
-#define CAPI_SELECT_B_PROTOCOL_REQ   CAPICMD(CAPI_SELECT_B_PROTOCOL,CAPI_REQ)
-#define CAPI_SELECT_B_PROTOCOL_CONF  CAPICMD(CAPI_SELECT_B_PROTOCOL,CAPI_CONF)
-
-#define CAPI_CONNECT_B3_REQ          CAPICMD(CAPI_CONNECT_B3,CAPI_REQ)
-#define CAPI_CONNECT_B3_CONF         CAPICMD(CAPI_CONNECT_B3,CAPI_CONF)
-#define CAPI_CONNECT_B3_IND          CAPICMD(CAPI_CONNECT_B3,CAPI_IND)
-#define CAPI_CONNECT_B3_RESP         CAPICMD(CAPI_CONNECT_B3,CAPI_RESP)
-
-#define CAPI_CONNECT_B3_ACTIVE_REQ   CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_REQ)
-#define CAPI_CONNECT_B3_ACTIVE_CONF  CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_CONF)
-#define CAPI_CONNECT_B3_ACTIVE_IND   CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_IND)
-#define CAPI_CONNECT_B3_ACTIVE_RESP  CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_RESP)
-
-#define CAPI_CONNECT_B3_T90_ACTIVE_IND CAPICMD(CAPI_CONNECT_B3_T90_ACTIVE,CAPI_IND)
-#define CAPI_CONNECT_B3_T90_ACTIVE_RESP CAPICMD(CAPI_CONNECT_B3_T90_ACTIVE,CAPI_RESP)
-
-#define CAPI_DATA_B3_REQ             CAPICMD(CAPI_DATA_B3,CAPI_REQ)
-#define CAPI_DATA_B3_CONF            CAPICMD(CAPI_DATA_B3,CAPI_CONF)
-#define CAPI_DATA_B3_IND             CAPICMD(CAPI_DATA_B3,CAPI_IND)
-#define CAPI_DATA_B3_RESP            CAPICMD(CAPI_DATA_B3,CAPI_RESP)
-
-#define CAPI_DISCONNECT_B3_REQ       CAPICMD(CAPI_DISCONNECT_B3,CAPI_REQ)
-#define CAPI_DISCONNECT_B3_CONF      CAPICMD(CAPI_DISCONNECT_B3,CAPI_CONF)
-#define CAPI_DISCONNECT_B3_IND       CAPICMD(CAPI_DISCONNECT_B3,CAPI_IND)
-#define CAPI_DISCONNECT_B3_RESP      CAPICMD(CAPI_DISCONNECT_B3,CAPI_RESP)
-
-#define CAPI_RESET_B3_REQ            CAPICMD(CAPI_RESET_B3,CAPI_REQ)
-#define CAPI_RESET_B3_CONF           CAPICMD(CAPI_RESET_B3,CAPI_CONF)
-#define CAPI_RESET_B3_IND            CAPICMD(CAPI_RESET_B3,CAPI_IND)
-#define CAPI_RESET_B3_RESP           CAPICMD(CAPI_RESET_B3,CAPI_RESP)
-
-#define CAPI_LISTEN_REQ              CAPICMD(CAPI_LISTEN,CAPI_REQ)
-#define CAPI_LISTEN_CONF             CAPICMD(CAPI_LISTEN,CAPI_CONF)
-
-#define CAPI_MANUFACTURER_REQ        CAPICMD(CAPI_MANUFACTURER,CAPI_REQ)
-#define CAPI_MANUFACTURER_CONF       CAPICMD(CAPI_MANUFACTURER,CAPI_CONF)
-#define CAPI_MANUFACTURER_IND        CAPICMD(CAPI_MANUFACTURER,CAPI_IND)
-#define CAPI_MANUFACTURER_RESP       CAPICMD(CAPI_MANUFACTURER,CAPI_RESP)
-
-#define CAPI_FACILITY_REQ            CAPICMD(CAPI_FACILITY,CAPI_REQ)
-#define CAPI_FACILITY_CONF           CAPICMD(CAPI_FACILITY,CAPI_CONF)
-#define CAPI_FACILITY_IND            CAPICMD(CAPI_FACILITY,CAPI_IND)
-#define CAPI_FACILITY_RESP           CAPICMD(CAPI_FACILITY,CAPI_RESP)
-
-#define CAPI_INFO_REQ                CAPICMD(CAPI_INFO,CAPI_REQ)
-#define CAPI_INFO_CONF               CAPICMD(CAPI_INFO,CAPI_CONF)
-#define CAPI_INFO_IND                CAPICMD(CAPI_INFO,CAPI_IND)
-#define CAPI_INFO_RESP               CAPICMD(CAPI_INFO,CAPI_RESP)
-
-/* CAPI message access helpers */
-
-/*
- * CAPI message header:
- * word   Length
- * word   ApplId
- * byte   Command
- * byte   Subcommand
- * word   MsgId
- *
- * Note that in the following, Controller/PLCI/NCCI is coded as follows:
- * bits 0..6 = controller, bit 7 = ext/int, bits 8..15 = PLCI, and
- * bits 16..31 = NCCI value.
- *
- * ALERT_REQ, 01 80:
- * dword  PLCI
- * struct Additional Info
- *
- * ALERT_CONF, 01 81:
- * dword  PLCI
- * word   Info (0 = OK, other = cause)
- *
- * CONNECT_REQ, 02 80:
- * dword  controller
- * word   CIP
- * struct Called party number
- * struct Calling party number
- * struct Called party subaddress
- * struct Calling party subaddress
- * struct Bearer Capability
- * struct Low Layer Compatibility
- * struct High Layer Compatibility
- * struct Additional Info
- *
- * CONNECT_CONF, 02 81:
- * dword  PLCI
- * word   Info (0 = OK, other = cause)
- *
- * CONNECT_IND, 02 82:
- * dword  PLCI
- * word   CIP
- * struct Called party number
- * struct Calling party number
- * struct Called party subaddress
- * struct Calling party subaddress
- * struct Bearer Capability
- * struct Low Layer Compatibility
- * struct High Layer Compatibility
- * struct Additional Info
- * struct Second Calling party number
- *
- * CONNECT_RESP, 02 83:
- * dword  PLCI
- * word   Reject (0 = accept, 1 = ignore, 2 = reject/normal clearing)
- * struct B protocol
- * struct Connected number
- * struct Connected subaddress
- * struct Low Layer Compatibility
- * struct Additional Info
- *
- * CONNECT_ACTIVE_IND, 03 82:
- * dword  PLCI
- * struct Connected number
- * struct Connected subaddress
- * struct Low Layer Compatibility
- *
- * CONNECT_ACTIVE_RESP, 03 83:
- * dword  PLCI
- *
- * CONNECT_B3_REQ, 82 80:
- * dword  PLCI
- * struct NCPI
- *
- * CONNECT_B3_CONF, 82 81:
- * dword  NCCI
- * word   Info (0 = connected, other = cause)
- *
- * CONNECT_B3_IND, 82 82:
- * dword  NCCI
- * struct NCPI
- *
- * CONNECT_B3_RESP, 82 83:
- * dword  NCCI
- * word   Reject (0 = accept, 2 = reject/normal clearing)
- * struct NCPI
- *
- * CONNECT_B3_ACTIVE_IND, 83 82:
- * dword  NCCI
- * struct NCPI
- *
- * CONNECT_B3_ACTIVE_RESP, 83  83:
- * dword  NCCI
- *
- * DATA_B3_REQ, 86 80:
- * dword  NCCI
- * dword  Data pointer
- * word   Data length
- * word   Data handle (packet id)
- * word   Flags (02 = more)
- *
- * DATA_B3_CONF, 86 81:
- * dword  NCCI
- * word   Data handle (packet id)
- * word   Info (0 = OK, other = cause)
- *
- * DATA_B3_IND, 86 82:
- * dword  NCCI
- * dword  Data pointer
- * word   Data length
- * word   Data handle (packet id)
- * word   Flags (02 = more)
- *
- * DATA_B3_RESP, 86 83:
- * dword  NCCI
- * word   Data handle (packet id)
- *
- * DISCONNECT_B3_REQ, 84 80:
- * dword  NCCI
- * struct NCPI
- *
- * DISCONNECT_B3_CONF, 84 81:
- * dword  NCCI
- * word   Info (0 = OK, other = cause)
- *
- * DISCONNECT_B3_IND, 84 82:
- * dword  NCCI
- * word   Reason
- * struct NCPI
- *
- * DISCONNECT_B3_RESP, 84 83:
- * dword  NCCI
- *
- * DISCONNECT_REQ, 04 80:
- * dword  PLCI
- * struct Additional Info
- *
- * DISCONNECT_CONF, 04 81:
- * dword  PLCI
- * word   Info (0 = OK, other = cause)
- *
- * DISCONNECT_IND, 04 82:
- * dword  PLCI
- * word   Reason
- *
- * DISCONNECT_RESP, 04 83:
- * dword  PLCI
- *
- * LISTEN_REQ, 05 80:
- * dword  Controller
- * dword  Info mask (bits 0..9 used)
- * dword  CIP Mask (bit 0 = any match)
- * dword  CIP Mask 2 (bit 0 = any match)
- * struct Calling party number
- * struct Calling party subaddress
- *
- * LISTEN_CONF, 05 81:
- * dword  Controller
- * word   Info (0 = OK, other = cause)
- *
- * INFO_REQ, 08 80:
- * dword  Controller/PLCI
- * struct Called party number
- * struct Additional Info
- *
- * INFO_CONF, 08 81:
- * dword  Controller/PLCI
- * word   Info (0 = OK, other = cause)
- *
- * INFO_IND, 08 82:
- * dword  Controller/PLCI
- * word   Info number
- * struct Info element
- *
- * INFO_RESP, 08 83:
- * dword  Controller/PLCI
- */
-
-#define CAPIMSG_LEN(msg)             (msg[0]|(msg[1]<<8))
-#define CAPIMSG_DATALEN(msg)         (msg[16]|(msg[17]<<8))
-
-static __inline u_int8_t* capimsg_getu8(u_int8_t *msg, u_int8_t *val)
-{
-    *val = *msg;
-    return (msg + 1);
-}
-
-static __inline u_int8_t* capimsg_getu16(u_int8_t *msg, u_int16_t *val)
-{
-    *val = (msg[0]|(msg[1]<<8));
-    return (msg + 2);
-}
-
-static __inline u_int8_t* capimsg_getu32(u_int8_t *msg, u_int32_t *val)
-{
-    *val = (msg[0]|(msg[1]<<8)|(msg[2]<<16)|(msg[3]<<24));
-    return (msg + 4);
-}
-
-static __inline u_int8_t* capimsg_setu8(u_int8_t *msg, u_int8_t val)
-{
-    msg[0] = val;
-    return (msg + 1);
-}
-
-static __inline u_int8_t* capimsg_setu16(u_int8_t *msg, u_int16_t val)
-{
-    msg[0] = (val & 0xff);
-    msg[1] = (val >> 8) & 0xff;
-    return (msg + 2);
-}
-
-static __inline u_int8_t* capimsg_setu32(u_int8_t *msg, u_int32_t val)
-{
-    msg[0] = (val & 0xff);
-    msg[1] = (val >> 8) & 0xff;
-    msg[2] = (val >> 16) & 0xff;
-    msg[3] = (val >> 24) & 0xff;
-    return (msg + 4);
-}
-
-/*
-//  CAPI message handlers called by higher layers
-*/
-
-extern void capi_listen_req(capi_softc_t *sc, u_int32_t CIP);
-extern void capi_alert_req(capi_softc_t *sc, call_desc_t *cd);
-extern void capi_connect_req(capi_softc_t *sc, call_desc_t *cd);
-extern void capi_connect_b3_req(capi_softc_t *sc, call_desc_t *cd);
-extern void capi_connect_resp(capi_softc_t *sc, call_desc_t *cd);
-extern void capi_data_b3_req(capi_softc_t *sc, int chan, struct mbuf *m);
-extern void capi_disconnect_req(capi_softc_t *sc, call_desc_t *cd);
-
-/*
-//  CAPI message handlers called by the receive routine
-*/
-
-extern void capi_listen_conf(capi_softc_t *sc, struct mbuf *m);
-extern void capi_info_ind(capi_softc_t *sc, struct mbuf *m);
-extern void capi_alert_conf(capi_softc_t *sc, struct mbuf *m);
-extern void capi_connect_conf(capi_softc_t *sc, struct mbuf *m);
-extern void capi_connect_active_ind(capi_softc_t *sc, struct mbuf *m);
-extern void capi_connect_b3_conf(capi_softc_t *sc, struct mbuf *m);
-extern void capi_connect_b3_active_ind(capi_softc_t *sc, struct mbuf *m);
-extern void capi_connect_ind(capi_softc_t *sc, struct mbuf *m);
-extern void capi_connect_b3_ind(capi_softc_t *sc, struct mbuf *m);
-extern void capi_data_b3_conf(capi_softc_t *sc, struct mbuf *m);
-extern void capi_data_b3_ind(capi_softc_t *sc, struct mbuf *m);
-extern void capi_disconnect_conf(capi_softc_t *sc, struct mbuf *m);
-extern void capi_disconnect_b3_ind(capi_softc_t *sc, struct mbuf *m);
-extern void capi_disconnect_ind(capi_softc_t *sc, struct mbuf *m);
-
-#endif /* _I4B_CAPI_MSGS_H_ */
--- sys/i4b/capi/capi_msgs.c
+++ /dev/null
@@ -1,950 +0,0 @@
-/*-
- * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* capi/capi_msgs.c	The CAPI i4b message handlers.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/capi/capi_msgs.c,v 1.5 2005/01/06 22:18:18 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-#include <i4b/capi/capi.h>
-#include <i4b/capi/capi_msgs.h>
-
-/*
-//  Administrative messages:
-//  ------------------------
-*/
-
-void capi_listen_req(capi_softc_t *sc, u_int32_t CIP)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 18);
-    u_int8_t *msg;
-    u_int16_t msgid;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for listen_req\n", sc->sc_unit);
-	return;
-    }
-
-    msgid = sc->sc_msgid++;
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, I4BCAPI_APPLID);
-    msg = capimsg_setu16(msg, CAPI_LISTEN_REQ);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, 1); /* Controller */
-    msg = capimsg_setu32(msg, 0); /* Info mask */
-    msg = capimsg_setu32(msg, CIP);
-    msg = capimsg_setu32(msg, 0);
-    msg = capimsg_setu8(msg, 0);
-    msg = capimsg_setu8(msg, 0);
-
-    sc->send(sc, m);
-}
-
-void capi_listen_conf(capi_softc_t *sc, struct mbuf *m_in)
-{
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    u_int16_t Info;
-
-    capimsg_getu16(msg + 12, &Info);
-
-    if (Info == 0) {
-	/* We are now listening. */
-
-	sc->sc_state = C_UP;
-	ctrl_desc[sc->ctrl_unit].dl_est = DL_UP;
-
-	i4b_l4_l12stat(sc->ctrl_unit, 1, 1);
-	i4b_l4_l12stat(sc->ctrl_unit, 2, 1);
-
-    } else {
-	/* XXX sc->sc_state = C_DOWN ? XXX */
-	printf("capi%d: can't listen, info=%04x\n", sc->sc_unit, Info);
-    }
-}
-
-void capi_info_ind(capi_softc_t *sc, struct mbuf *m_in)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 4);
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    u_int16_t applid, msgid;
-    u_int32_t PLCI;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for info_resp\n", sc->sc_unit);
-	return;
-    }
-
-    msg = capimsg_getu16(msg + 2, &applid);
-    msg = capimsg_getu16(msg + 2, &msgid);
-    msg = capimsg_getu32(msg, &PLCI);
-
-    /* i4b_l4_info_ind() */
-    
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, applid);
-    msg = capimsg_setu16(msg, CAPI_INFO_RESP);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, PLCI);
-
-    sc->send(sc, m);
-}
-
-void capi_alert_req(capi_softc_t *sc, call_desc_t *cd)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 5);
-    u_int8_t *msg;
-    u_int16_t msgid;
-    u_int32_t PLCI;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for alert_req\n", sc->sc_unit);
-	return;
-    }
-
-    msgid = sc->sc_bchan[cd->channelid].msgid = sc->sc_msgid++;
-    PLCI = (sc->sc_bchan[cd->channelid].ncci & CAPI_PLCI_MASK);
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, I4BCAPI_APPLID);
-    msg = capimsg_setu16(msg, CAPI_ALERT_REQ);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, PLCI);
-    msg = capimsg_setu8(msg, 0);
-
-    sc->send(sc, m);
-}
-
-void capi_alert_conf(capi_softc_t *sc, struct mbuf *m_in)
-{
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    u_int16_t Info;
-
-    msg = capimsg_getu16(msg + 12, &Info);
-
-    if (Info) {
-	printf("capi%d: can't alert, info=%04x\n", sc->sc_unit, Info);
-    }
-}
-
-/*
-//  Outgoing call setup:
-//  --------------------
-//
-//             CAPI_CONNECT_REQ -->
-//                              <-- CAPI_CONNECT_CONF
-//                       (notify Layer 4)
-//                              <-- CAPI_CONNECT_ACTIVE_IND
-//     CAPI_CONNECT_ACTIVE_RESP -->
-//          CAPI_CONNECT_B3_REQ -->
-//                              <-- CAPI_CONNECT_B3_CONF
-//                              <-- CAPI_CONNECT_B3_ACTIVE_IND
-//  CAPI_CONNECT_B3_ACTIVE_RESP -->
-//                       (notify Layer 4)
-*/
-
-void capi_connect_req(capi_softc_t *sc, call_desc_t *cd)
-{
-    struct mbuf *m;
-    u_int8_t *msg;
-    u_int16_t msgid;
-    int slen = strlen(cd->src_telno);
-    int dlen = strlen(cd->dst_telno);
-
-    m = i4b_Dgetmbuf(8 + 27 + slen + dlen);
-    if (!m) {
-	printf("capi%d: can't get mbuf for connect_req\n", sc->sc_unit);
-	return;
-    }
-
-    cd->crflag = CRF_ORIG;
-
-    sc->sc_bchan[cd->channelid].cdid = cd->cdid;
-    sc->sc_bchan[cd->channelid].bprot = cd->bprot;
-    sc->sc_bchan[cd->channelid].state = B_CONNECT_CONF;
-    msgid = sc->sc_bchan[cd->channelid].msgid = sc->sc_msgid++;
-    ctrl_desc[sc->ctrl_unit].bch_state[cd->channelid] = BCH_ST_RSVD;
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, I4BCAPI_APPLID);
-    msg = capimsg_setu16(msg, CAPI_CONNECT_REQ);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, 1); /* Controller */
-
-    switch (cd->bprot) {
-    case BPROT_NONE:
-	msg = capimsg_setu16(msg, 0x0010); /* Telephony */
-	break;
-
-    case BPROT_RHDLC:
-	msg = capimsg_setu16(msg, 0x0002); /* Unrestricted digital */
-	break;
-
-    default:
-	msg = capimsg_setu16(msg, 0x0002); /* Unrestricted digital */
-    }
-
-    msg = capimsg_setu8(msg, 1 + dlen);
-    msg = capimsg_setu8(msg, 0x80);
-    strncpy(msg, cd->dst_telno, dlen);
-
-    msg = capimsg_setu8(msg + dlen, 2 + slen);
-    msg = capimsg_setu8(msg, 0x00);
-    msg = capimsg_setu8(msg, 0x80); /* Presentation and screening indicator */
-    strncpy(msg, cd->src_telno, slen);
-
-    msg = capimsg_setu8(msg + slen, 0); /* Called & */
-    msg = capimsg_setu8(msg, 0); /* Calling party subaddress */
-    
-    msg = capimsg_setu8(msg, 15); /* B protocol */
-    if (cd->bprot == BPROT_NONE)
-	msg = capimsg_setu16(msg, 1); /* B1 protocol = transparent */
-    else
-	msg = capimsg_setu16(msg, 0); /* B1 protocol = HDLC */
-    msg = capimsg_setu16(msg, 1); /* B2 protocol = transparent */
-    msg = capimsg_setu16(msg, 0); /* B3 protocol = transparent */
-    msg = capimsg_setu8(msg, 0); /* B1 parameters */
-    msg = capimsg_setu8(msg, 0); /* B2 parameters */
-    msg = capimsg_setu8(msg, 0); /* B3 parameters */
-
-    msg = capimsg_setu8(msg, 0); /* Bearer Capability */
-    msg = capimsg_setu8(msg, 0); /* Low Layer Compatibility */
-    msg = capimsg_setu8(msg, 0); /* High Layer Compatibility */
-    msg = capimsg_setu8(msg, 0); /* Additional Info */
-
-    sc->send(sc, m);
-}
-
-void capi_connect_conf(capi_softc_t *sc, struct mbuf *m_in)
-{
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    call_desc_t *cd;
-    u_int16_t msgid;
-    u_int32_t PLCI;
-    u_int16_t Info;
-    int bch;
-
-    msg = capimsg_getu16(msg + 6, &msgid);
-    msg = capimsg_getu32(msg, &PLCI);
-    msg = capimsg_getu16(msg, &Info);
-
-    for (bch = 0; bch < sc->sc_nbch; bch++)
-	if ((sc->sc_bchan[bch].state == B_CONNECT_CONF) &&
-	    (sc->sc_bchan[bch].msgid == msgid))
-	    break;
-
-    if ((bch == sc->sc_nbch) ||
-	(cd = cd_by_cdid(sc->sc_bchan[bch].cdid)) == NULL) {
-	printf("capi%d: can't find channel for connect_conf PLCI %x\n",
-	       sc->sc_unit, PLCI);
-	return;
-    }
-
-    if (Info == 0) {
-	sc->sc_bchan[bch].state = B_CONNECT_ACTIVE_IND;
-	sc->sc_bchan[bch].ncci = PLCI;
-
-	i4b_l4_proceeding_ind(cd);
-
-    } else {
-	SET_CAUSE_TV(cd->cause_out, CAUSET_I4B, CAUSE_I4B_L1ERROR);
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-
-	sc->sc_bchan[bch].state = B_FREE;
-	ctrl_desc[sc->ctrl_unit].bch_state[bch] = BCH_ST_FREE;
-
-	printf("capi%d: can't connect out, info=%04x\n", sc->sc_unit, Info);
-    }
-}
-
-void capi_connect_active_ind(capi_softc_t *sc, struct mbuf *m_in)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 4);
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    call_desc_t *cd;
-    u_int16_t applid, msgid;
-    u_int32_t PLCI;
-    int bch;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for active_ind\n", sc->sc_unit);
-	return;
-    }
-
-    msg = capimsg_getu16(msg + 2, &applid);
-    msg = capimsg_getu16(msg + 2, &msgid);
-    msg = capimsg_getu32(msg, &PLCI);
-
-    for (bch = 0; bch < sc->sc_nbch; bch++)
-	if ((sc->sc_bchan[bch].state == B_CONNECT_ACTIVE_IND) &&
-	    (sc->sc_bchan[bch].ncci == PLCI))
-	    break;
-
-    if ((bch == sc->sc_nbch) ||
-	(cd = cd_by_cdid(sc->sc_bchan[bch].cdid)) == NULL) {
-	printf("capi%d: can't find channel for active_resp, PLCI %x\n",
-	       sc->sc_unit, PLCI);
-	return;
-    }
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, applid);
-    msg = capimsg_setu16(msg, CAPI_CONNECT_ACTIVE_RESP);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, PLCI);
-
-    sc->send(sc, m);
-
-    if (cd->crflag == CRF_ORIG) {
-	capi_connect_b3_req(sc, cd);
-
-    } else {
-	sc->sc_bchan[bch].state = B_CONNECT_B3_IND;
-    }
-}
-
-void capi_connect_b3_req(capi_softc_t *sc, call_desc_t *cd)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 5);
-    u_int8_t *msg;
-    u_int16_t msgid;
-    u_int32_t PLCI;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for connect_b3_req\n", sc->sc_unit);
-	return;
-    }
-
-    sc->sc_bchan[cd->channelid].state = B_CONNECT_B3_CONF;
-    msgid = sc->sc_bchan[cd->channelid].msgid = sc->sc_msgid++;
-    PLCI = (sc->sc_bchan[cd->channelid].ncci & CAPI_PLCI_MASK);
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, I4BCAPI_APPLID);
-    msg = capimsg_setu16(msg, CAPI_CONNECT_B3_REQ);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, PLCI);
-    msg = capimsg_setu8(msg, 0); /* NCPI */
-
-    sc->send(sc, m);
-}
-
-void capi_connect_b3_conf(capi_softc_t *sc, struct mbuf *m_in)
-{
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    call_desc_t *cd;
-    u_int16_t msgid;
-    u_int32_t NCCI;
-    u_int16_t Info;
-    int bch;
-
-    msg = capimsg_getu16(msg + 6, &msgid);
-    msg = capimsg_getu32(msg, &NCCI);
-    msg = capimsg_getu16(msg, &Info);
-
-    for (bch = 0; bch < sc->sc_nbch; bch++)
-	if ((sc->sc_bchan[bch].state == B_CONNECT_B3_CONF) &&
-	    (sc->sc_bchan[bch].ncci == (NCCI & CAPI_PLCI_MASK)))
-	    break;
-
-    if ((bch == sc->sc_nbch) ||
-	(cd = cd_by_cdid(sc->sc_bchan[bch].cdid)) == NULL) {
-	printf("capi%d: can't find channel for connect_b3_conf NCCI %x\n",
-	       sc->sc_unit, NCCI);
-	return;
-    }
-
-    if (Info == 0) {
-	sc->sc_bchan[bch].ncci = NCCI;
-	sc->sc_bchan[bch].state = B_CONNECT_B3_ACTIVE_IND;
-
-    } else {
-	SET_CAUSE_TV(cd->cause_in, CAUSET_I4B, CAUSE_I4B_OOO); /* XXX */
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-
-	ctrl_desc[sc->ctrl_unit].bch_state[bch] = BCH_ST_RSVD;
-
-	printf("capi%d: can't connect_b3 out, info=%04x\n", sc->sc_unit, Info);
-
-	capi_disconnect_req(sc, cd);
-    }
-}
-
-void capi_connect_b3_active_ind(capi_softc_t *sc, struct mbuf *m_in)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 4);
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    call_desc_t *cd;
-    u_int16_t applid, msgid;
-    u_int32_t NCCI;
-    int bch;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for b3_active_ind\n", sc->sc_unit);
-	return;
-    }
-
-    msg = capimsg_getu16(msg + 2, &applid);
-    msg = capimsg_getu16(msg + 2, &msgid);
-    msg = capimsg_getu32(msg, &NCCI);
-
-    for (bch = 0; bch < sc->sc_nbch; bch++)
-	if ((sc->sc_bchan[bch].state == B_CONNECT_B3_ACTIVE_IND) &&
-	    (sc->sc_bchan[bch].ncci == NCCI))
-	    break;
-
-    if ((bch == sc->sc_nbch) ||
-	(cd = cd_by_cdid(sc->sc_bchan[bch].cdid)) == NULL) {
-	printf("capi%d: can't find channel for b3_active_resp NCCI %x\n",
-	       sc->sc_unit, NCCI);
-	return;
-    }
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, I4BCAPI_APPLID);
-    msg = capimsg_setu16(msg, CAPI_CONNECT_B3_ACTIVE_RESP);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, NCCI);
-
-    sc->send(sc, m);
-
-    sc->sc_bchan[bch].state = B_CONNECTED;
-    i4b_l4_connect_active_ind(cd);
-}
-
-/*
-//  Incoming call setup:
-//  --------------------
-//
-//                              <-- CAPI_CONNECT_IND
-//                       (consult Layer 4)
-//            CAPI_CONNECT_RESP -->
-//                              <-- CAPI_CONNECT_ACTIVE_IND
-//     CAPI_CONNECT_ACTIVE_RESP -->
-//                              <-- CAPI_CONNECT_B3_IND
-//         CAPI_CONNECT_B3_RESP -->
-//                              <-- CAPI_CONNECT_B3_ACTIVE_IND
-//  CAPI_CONNECT_B3_ACTIVE_RESP -->
-//                       (notify Layer 4)
-*/
-
-void capi_connect_ind(capi_softc_t *sc, struct mbuf *m_in)
-{
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    call_desc_t *cd;
-    u_int16_t applid, msgid;
-    u_int32_t PLCI;
-    u_int16_t CIP;
-    u_int8_t x, y, z;
-    int bch;
-
-    if ((cd = reserve_cd()) == NULL) {
-	printf("capi%d: can't get cd for connect_ind\n", sc->sc_unit);
-	return;
-    }
-
-    cd->controller = sc->ctrl_unit;
-    cd->channelexcl = FALSE;
-
-    for (bch = 0; bch < sc->sc_nbch; bch++)
-	if (sc->sc_bchan[bch].state == B_FREE) break;
-    sc->sc_bchan[bch].state = B_CONNECT_IND;
-    cd->channelid = bch; /* XXX CHAN_ANY XXX */
-
-    cd->crflag = CRF_DEST;
-    cd->cr = get_rand_cr(sc->sc_unit);
-    cd->scr_ind = SCR_NONE;
-    cd->prs_ind = PRS_NONE;
-    cd->bprot = BPROT_NONE;
-    cd->ilt = NULL;
-    cd->dlt = NULL;
-    cd->display[0] = '\0';
-    cd->datetime[0] = '\0';
-
-    msg = capimsg_getu16(msg + 2, &applid);
-    msg = capimsg_getu16(msg + 2, &msgid);
-    msg = capimsg_getu32(msg, &PLCI);
-    msg = capimsg_getu16(msg, &CIP);
-
-    cd->event = (int) msgid; /* XXX overload */
-    cd->Q931state = (int) PLCI; /* XXX overload */
-
-    switch (CIP) {
-    case 0x0010:
-    case 0x0001: cd->bprot = BPROT_NONE; break;
-    case 0x0002: cd->bprot = BPROT_RHDLC; break;
-    default:
-	NDBGL4(L4_CAPIDBG, "capi%d: unknown CIP = %d", sc->sc_unit, CIP);
-	cd->bprot = BPROT_NONE;
-    }
-
-    msg = capimsg_getu8(msg, &x); /* Called party struct len */
-    if (x) {
-	msg = capimsg_getu8(msg, &y); /* Numbering plan */
-	z = x - 1;
-	if (z >= TELNO_MAX) z = (TELNO_MAX-1);
-	strncpy(cd->dst_telno, msg, z);
-	msg += x;
-	x = z;
-    }
-    cd->dst_telno[x] = '\0';
-
-    msg = capimsg_getu8(msg, &x); /* Calling party struct len */
-    if (x) {
-	msg = capimsg_getu8(msg, &y); /* Numbering plan */
-	msg = capimsg_getu8(msg, &y); /* Screening/Presentation */
-	if ((y & 0x80) == 0) { /* screening used */
-	    cd->scr_ind = (y & 3) + SCR_USR_NOSC;
-	    cd->prs_ind = ((y >> 5) & 3) + PRS_ALLOWED;
-	}
-	z = x - 2;
-	if (z >= TELNO_MAX) z = (TELNO_MAX-1);
-	strncpy(cd->src_telno, msg, z);
-	msg += x;
-	x = z;
-    }
-    cd->src_telno[x] = '\0';
-
-    i4b_l4_connect_ind(cd);
-}
-
-void capi_connect_resp(capi_softc_t *sc, call_desc_t *cd)
-{
-    struct mbuf *m;
-    u_int8_t *msg;
-    u_int16_t msgid;
-    u_int32_t PLCI;
-    int dlen = strlen(cd->dst_telno);
-
-    m = i4b_Dgetmbuf(8 + 21 + dlen);
-    if (!m) {
-	printf("capi%d: can't get mbuf for connect_resp\n", sc->sc_unit);
-	return;
-    }
-
-    msgid = (u_int16_t) cd->event;
-    PLCI = (u_int32_t) cd->Q931state;
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, I4BCAPI_APPLID);
-    msg = capimsg_setu16(msg, CAPI_CONNECT_RESP);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, PLCI);
-
-    switch (cd->response) {
-    case SETUP_RESP_ACCEPT:
-	sc->sc_bchan[cd->channelid].cdid = cd->cdid;
-	sc->sc_bchan[cd->channelid].ncci = PLCI;
-	sc->sc_bchan[cd->channelid].state = B_CONNECT_ACTIVE_IND;
-	ctrl_desc[sc->ctrl_unit].bch_state[cd->channelid] = BCH_ST_USED;
-	msg = capimsg_setu16(msg, 0); /* Accept the call */
-	break;
-
-    case SETUP_RESP_REJECT:
-	sc->sc_bchan[cd->channelid].state = B_FREE;
-	ctrl_desc[sc->ctrl_unit].bch_state[cd->channelid] = BCH_ST_FREE;
-	msg = capimsg_setu16(msg, 2); /* Reject, normal call clearing */
-	break;
-
-    case SETUP_RESP_DNTCRE:
-	sc->sc_bchan[cd->channelid].state = B_FREE;
-	ctrl_desc[sc->ctrl_unit].bch_state[cd->channelid] = BCH_ST_FREE;
-	if (sc->sc_nbch == 30) {
-	    /* With PRI, we can't really ignore calls  -- normal clearing */
-	    msg = capimsg_setu16(msg, (0x3480|CAUSE_Q850_NCCLR));
-	} else {
-	    msg = capimsg_setu16(msg, 1); /* Ignore */
-	}
-	break;
-
-    default:
-	sc->sc_bchan[cd->channelid].state = B_FREE;
-	ctrl_desc[sc->ctrl_unit].bch_state[cd->channelid] = BCH_ST_FREE;
-	msg = capimsg_setu16(msg, (0x3480|CAUSE_Q850_CALLREJ));
-    }
-
-    msg = capimsg_setu8(msg, 15); /* B protocol */
-    if (cd->bprot == BPROT_NONE)
-	msg = capimsg_setu16(msg, 1); /* B1 protocol = transparent */
-    else
-	msg = capimsg_setu16(msg, 0); /* B1 protocol = HDLC */
-    msg = capimsg_setu16(msg, 1); /* B2 protocol = transparent */
-    msg = capimsg_setu16(msg, 0); /* B3 protocol = transparent */
-    msg = capimsg_setu8(msg, 0); /* B1 parameters */
-    msg = capimsg_setu8(msg, 0); /* B2 parameters */
-    msg = capimsg_setu8(msg, 0); /* B3 parameters */
-
-    msg = capimsg_setu8(msg, 1 + dlen);
-    msg = capimsg_setu8(msg, 0x80); /* Numbering plan */
-    strncpy(msg, cd->dst_telno, dlen);
-    msg = capimsg_setu8(msg + dlen, 0); /* Connected subaddress */
-    msg = capimsg_setu8(msg, 0); /* Low Layer Compatibility */
-    msg = capimsg_setu8(msg, 0); /* Additional Info */
-
-    sc->send(sc, m);
-}
-
-void capi_connect_b3_ind(capi_softc_t *sc, struct mbuf *m_in)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 7);
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    u_int16_t applid, msgid;
-    u_int32_t NCCI;
-    int bch;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for connect_b3_resp\n", sc->sc_unit);
-	return;
-    }
-
-    msg = capimsg_getu16(msg + 2, &applid);
-    msg = capimsg_getu16(msg + 2, &msgid);
-    msg = capimsg_getu32(msg, &NCCI);
-
-    for (bch = 0; bch < sc->sc_nbch; bch++)
-	if ((sc->sc_bchan[bch].state == B_CONNECT_B3_IND) &&
-	    (sc->sc_bchan[bch].ncci == (NCCI & CAPI_PLCI_MASK)))
-	    break;
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, applid);
-    msg = capimsg_setu16(msg, CAPI_CONNECT_B3_RESP);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, NCCI);
-
-    if (bch == sc->sc_nbch) {
-	printf("capi%d: can't get cd for connect_b3_resp NCCI %x\n",
-	       sc->sc_unit, NCCI);
-	msg = capimsg_setu16(msg, 8); /* Reject, destination OOO */
-
-    } else {
-	sc->sc_bchan[bch].ncci = NCCI;
-	sc->sc_bchan[bch].state = B_CONNECT_B3_ACTIVE_IND;
-	msg = capimsg_setu16(msg, 0); /* Accept */
-    }
-
-    msg = capimsg_setu8(msg, 0); /* NCPI */
-
-    sc->send(sc, m);
-}
-
-/*
-//  Data transfer:
-//  --------------
-*/
-
-void capi_data_b3_req(capi_softc_t *sc, int chan, struct mbuf *m_b3)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 14);
-    u_int8_t *msg;
-    u_int16_t msgid;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for data_b3_req\n", sc->sc_unit);
-	return;
-    }
-
-    msgid = sc->sc_bchan[chan].msgid = sc->sc_msgid++;
-    sc->sc_bchan[chan].busy = 1;
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, I4BCAPI_APPLID);
-    msg = capimsg_setu16(msg, CAPI_DATA_B3_REQ);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, sc->sc_bchan[chan].ncci);
-    msg = capimsg_setu32(msg, (u_int32_t) m_b3->m_data); /* Pointer */
-    msg = capimsg_setu16(msg, m_b3->m_len);
-    msg = capimsg_setu16(msg, chan);
-    msg = capimsg_setu16(msg, 0); /* Flags */
-
-    m->m_next = m_b3;
-
-    sc->send(sc, m);
-}
-
-void capi_data_b3_conf(capi_softc_t *sc, struct mbuf *m_in)
-{
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    u_int32_t NCCI;
-    u_int16_t handle;
-    u_int16_t Info;
-
-    msg = capimsg_getu32(msg + 8, &NCCI);
-    msg = capimsg_getu16(msg, &handle);
-    msg = capimsg_getu16(msg, &Info);
-
-    if (Info == 0) {
-	sc->sc_bchan[handle].busy = 0;
-	capi_start_tx(sc, handle);
-
-    } else {
-	printf("capi%d: data_b3_conf NCCI %x handle %x info=%04x\n",
-	       sc->sc_unit, NCCI, handle, Info);
-    }
-}
-
-void capi_data_b3_ind(capi_softc_t *sc, struct mbuf *m_in)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 6);
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    u_int16_t applid, msgid;
-    u_int32_t NCCI;
-    u_int16_t handle;
-    int bch;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for data_b3_resp\n", sc->sc_unit);
-	return;
-    }
-
-    msg = capimsg_getu16(msg + 2, &applid);
-    msg = capimsg_getu16(msg + 2, &msgid);
-    msg = capimsg_getu32(msg, &NCCI);
-    msg = capimsg_getu16(msg + 6, &handle);
-
-    for (bch = 0; bch < sc->sc_nbch; bch++)
-	if ((sc->sc_bchan[bch].state == B_CONNECTED) &&
-	    (sc->sc_bchan[bch].ncci == NCCI))
-	    break;
-
-    if (bch == sc->sc_nbch) {
-	printf("capi%d: can't find channel for data_b3_ind NCCI %x\n",
-	       sc->sc_unit, NCCI);
-
-    } else {
-	if (sc->sc_bchan[bch].bprot == BPROT_RHDLC) {
-	    /* HDLC drivers use rx_mbuf */
-
-	    sc->sc_bchan[bch].in_mbuf = m_in->m_next;
-	    sc->sc_bchan[bch].rxcount += m_in->m_next->m_len;
-	    m_in->m_next = NULL; /* driver frees */
-
-	    (*sc->sc_bchan[bch].capi_drvr_linktab->bch_rx_data_ready)(
-		sc->sc_bchan[bch].capi_drvr_linktab->unit);
-
-	} else {
-	    /* Telephony drivers use rx_queue */
-
-	    if (!_IF_QFULL(&sc->sc_bchan[bch].rx_queue)) {
-		_IF_ENQUEUE(&sc->sc_bchan[bch].rx_queue, m_in->m_next);
-		sc->sc_bchan[bch].rxcount += m_in->m_next->m_len;
-		m_in->m_next = NULL; /* driver frees */
-	    }
-
-	    (*sc->sc_bchan[bch].capi_drvr_linktab->bch_rx_data_ready)(
-		sc->sc_bchan[bch].capi_drvr_linktab->unit);
-	}
-    }
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, I4BCAPI_APPLID);
-    msg = capimsg_setu16(msg, CAPI_DATA_B3_RESP);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, NCCI);
-    msg = capimsg_setu16(msg, handle);
-
-    sc->send(sc, m);
-}
-
-/*
-//  Connection teardown:
-//  --------------------
-*/
-
-void capi_disconnect_req(capi_softc_t *sc, call_desc_t *cd)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 5);
-    u_int8_t *msg;
-    u_int16_t msgid;
-    u_int32_t PLCI;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for disconnect_req\n", sc->sc_unit);
-	return;
-    }
-
-    sc->sc_bchan[cd->channelid].state = B_DISCONNECT_CONF;
-    ctrl_desc[sc->ctrl_unit].bch_state[cd->channelid] = BCH_ST_RSVD;
-    msgid = sc->sc_bchan[cd->channelid].msgid = sc->sc_msgid++;
-    PLCI = (sc->sc_bchan[cd->channelid].ncci & CAPI_PLCI_MASK);
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, I4BCAPI_APPLID);
-    msg = capimsg_setu16(msg, CAPI_DISCONNECT_REQ);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, PLCI);
-    msg = capimsg_setu8(msg, 0); /* Additional Info */
-
-    sc->send(sc, m);
-}
-
-void capi_disconnect_conf(capi_softc_t *sc, struct mbuf *m_in)
-{
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    call_desc_t *cd;
-    u_int32_t PLCI;
-    int bch;
-
-    msg = capimsg_getu32(msg + 8, &PLCI);
-
-    for (bch = 0; bch < sc->sc_nbch; bch++)
-	if ((sc->sc_bchan[bch].state == B_DISCONNECT_CONF) &&
-	    ((sc->sc_bchan[bch].ncci & CAPI_PLCI_MASK) == PLCI))
-	    break;
-
-    if (bch == sc->sc_nbch) {
-	printf("capi%d: can't find channel for disconnect_conf PLCI %x\n",
-	       sc->sc_unit, PLCI);
-	return;
-    }
-
-    cd = cd_by_cdid(sc->sc_bchan[bch].cdid);
-    if (!cd) {
-	printf("capi%d: can't find cd for disconnect_conf PLCI %x\n",
-	       sc->sc_unit, PLCI);
-    } else {
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-    }
-
-    sc->sc_bchan[bch].state = B_FREE;
-    ctrl_desc[sc->ctrl_unit].bch_state[bch] = BCH_ST_FREE;
-}
-
-void capi_disconnect_b3_ind(capi_softc_t *sc, struct mbuf *m_in)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 4);
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    u_int16_t applid, msgid;
-    u_int32_t NCCI;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for disconnect_b3_resp\n", sc->sc_unit);
-	return;
-    }
-
-    msg = capimsg_getu16(msg + 2, &applid);
-    msg = capimsg_getu16(msg + 2, &msgid);
-    msg = capimsg_getu32(msg, &NCCI);
-
-    /* XXX update bchan state? XXX */
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, applid);
-    msg = capimsg_setu16(msg, CAPI_DISCONNECT_B3_RESP);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, NCCI);
-
-    sc->send(sc, m);
-}
-
-void capi_disconnect_ind(capi_softc_t *sc, struct mbuf *m_in)
-{
-    struct mbuf *m = i4b_Dgetmbuf(8 + 4);
-    u_int8_t *msg = mtod(m_in, u_int8_t*);
-    call_desc_t *cd;
-    u_int16_t applid, msgid;
-    u_int32_t PLCI;
-    u_int16_t Reason;
-    int bch;
-
-    if (!m) {
-	printf("capi%d: can't get mbuf for disconnect_resp\n", sc->sc_unit);
-	return;
-    }
-
-    msg = capimsg_getu16(msg + 2, &applid);
-    msg = capimsg_getu16(msg + 2, &msgid);
-    msg = capimsg_getu32(msg, &PLCI);
-    msg = capimsg_getu16(msg, &Reason);
-
-    for (bch = 0; bch < sc->sc_nbch; bch++)
-	if ((sc->sc_bchan[bch].state != B_FREE) &&
-	    ((sc->sc_bchan[bch].ncci & CAPI_PLCI_MASK) == PLCI))
-	    break;
-
-    if (bch < sc->sc_nbch) {
-	/* We may not have a bchan assigned if call was ignored. */
-
-	cd = cd_by_cdid(sc->sc_bchan[bch].cdid);
-	sc->sc_bchan[bch].state = B_DISCONNECT_IND;
-    } else cd = NULL;
-
-    if (cd) {
-	if ((Reason & 0xff00) == 0x3400) {
-	    SET_CAUSE_TV(cd->cause_in, CAUSET_Q850, (Reason & 0x7f));
-	} else {
-	    SET_CAUSE_TV(cd->cause_in, CAUSET_I4B, CAUSE_I4B_NORMAL);
-	}
-
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-
-	sc->sc_bchan[bch].state = B_FREE;
-	ctrl_desc[sc->ctrl_unit].bch_state[bch] = BCH_ST_FREE;
-    }
-
-    msg = capimsg_setu16(mtod(m, u_int8_t*), m->m_len);
-    msg = capimsg_setu16(msg, applid);
-    msg = capimsg_setu16(msg, CAPI_DISCONNECT_RESP);
-    msg = capimsg_setu16(msg, msgid);
-
-    msg = capimsg_setu32(msg, PLCI);
-
-    sc->send(sc, m);
-}
--- sys/i4b/capi/capi.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*-
- * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* capi/capi.h		The CAPI device interface.
- *
- * $FreeBSD: src/sys/i4b/capi/capi.h,v 1.2 2005/01/06 22:18:18 imp Exp $
- */
-
-#ifndef _I4B_CAPI_H_
-#define _I4B_CAPI_H_
-
-/*
-//  CAPI driver context: B channels and controller softcs.
-*/
-
-#define INVALID -1
-
-enum capi_b_state {
-    B_FREE,                  /* channel free, ncci invalid */
-    B_CONNECT_CONF,          /* wait for CONNECT_CONF */
-    B_CONNECT_IND,           /* IND got, wait for appl RESP */
-    B_CONNECT_ACTIVE_IND,    /* wait for CONNECT_ACTIVE_IND */
-    B_CONNECT_B3_CONF,       /* wait for CONNECT_B3_CONF */
-    B_CONNECT_B3_IND,        /* wait for CONNECT_B3_IND */
-    B_CONNECT_B3_ACTIVE_IND, /* wait for CONNECT_B3_ACTIVE_IND */
-    B_CONNECTED,             /* channel connected & in use */
-    B_DISCONNECT_CONF,       /* wait for DISCONNECT_CONF */
-    B_DISCONNECT_B3_CONF,    /* wait for DISCONNECT_B3_CONF */
-    B_DISCONNECT_IND,        /* wait for DISCONNECT_IND */
-};
-
-typedef struct capi_bchan
-{
-    /* Channel state */
-
-    int ncci;
-#define CAPI_CTRL_MASK 0x000000ff
-#define CAPI_PLCI_MASK 0x0000ffff
-#define CAPI_NCCI_MASK 0xffff0000
-    u_int16_t msgid;
-    int busy;
-    enum capi_b_state state;
-
-    struct ifqueue tx_queue;
-    struct ifqueue rx_queue;
-    int rxcount;
-    int txcount;
-
-    /* The rest is needed for i4b integration */
-
-    int bprot;
-    int cdid;
-
-    struct mbuf *in_mbuf;
-    isdn_link_t	capi_isdn_linktab;
-    drvr_link_t	*capi_drvr_linktab;
-} capi_bchan_t;
-
-enum capi_c_state {
-    C_DOWN,             /* controller uninitialized */
-    C_READY,            /* controller initialized but not listening */
-    C_UP,               /* controller listening */
-};
-
-typedef struct capi_softc {
-    int sc_unit;        /* index in capi_sc[]                      */
-    int ctrl_unit;      /* index in isdn_ctrl_tab[]                */
-    int card_type;      /* CARD_TYPEC_xxx, filled by ll driver     */
-    int sc_nbch;        /* number of b channels on this controller */
-    int sc_enabled;     /* is daemon connected TRUE/FALSE          */
-    int sc_msgid;       /* next CAPI message id                    */
-    char sc_profile[64];/* CAPI profile data                       */
-    enum capi_c_state sc_state;
-
-    capi_bchan_t sc_bchan[MAX_BCHAN];
-
-    /* Link layer driver context holder and methods */
-
-    void *ctx;
-    
-    int (*load)(struct capi_softc *, int, u_int8_t *);
-    int (*reg_appl)(struct capi_softc *, int, int);
-    int (*rel_appl)(struct capi_softc *, int);
-    int (*send)(struct capi_softc *, struct mbuf *);
-} capi_softc_t;
-
-extern capi_softc_t *capi_sc[];
-extern int ncapi;
-
-/*
-//  CAPI upcalls for the link layer.
-*/
-
-#define I4BCAPI_APPLID 1
-
-extern int capi_ll_attach(capi_softc_t *);
-extern int capi_ll_control(capi_softc_t *, int op, int arg);
-
-#define CAPI_CTRL_READY     0 /* ctrl ready, value=TRUE/FALSE */
-#define CAPI_CTRL_PROFILE   1 /* set CAPI profile             */
-#define CAPI_CTRL_NEW_NCCI  2 /* new ncci value, assign bchan */
-#define CAPI_CTRL_FREE_NCCI 3 /* free ncci value, clear bchan */
-
-extern int capi_ll_receive(capi_softc_t *, struct mbuf *);
-
-extern int capi_start_tx(capi_softc_t *, int bchan);
-
-#endif /* _I4B_CAPI_H_ */
--- sys/i4b/capi/capi_llif.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-
- * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* capi/capi_llif.c	The i4b CAPI link layer interface.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/capi/capi_llif.c,v 1.4 2005/01/06 22:18:18 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-#include <i4b/capi/capi.h>
-#include <i4b/capi/capi_msgs.h>
-
-/*
-//  capi_ll_control
-//      CAPI link layer control routine. Called by a link layer
-//      driver when its state changes.
-*/
-
-int
-capi_ll_control(capi_softc_t *sc, int op, int arg)
-{
-    switch (op) {
-    case CAPI_CTRL_READY:
-	if (arg) {
-	    sc->sc_state = C_READY;
-
-	    /*
-	     *  Register our CAPI ApplId and send CAPI_LISTEN_REQ
-	     *  with CIP Mask value 1 (match all).
-	     */
-
-	    sc->reg_appl(sc, I4BCAPI_APPLID, sc->sc_nbch);
-	    capi_listen_req(sc, 0x10007);
-
-	} else {
-	    sc->sc_state = C_DOWN;
-	    /* XXX go through cds and notify L4 of pdeact? XXX */
-	}
-	break;
-
-    case CAPI_CTRL_PROFILE:
-	bcopy((char*) arg, &sc->sc_profile, sizeof(sc->sc_profile));
-	break;
-
-    case CAPI_CTRL_NEW_NCCI:
-    case CAPI_CTRL_FREE_NCCI:
-	/* We ignore the controller's NCCI notifications. */
-	break;
-
-    default:
-	printf("capi%d: unknown control %d\n", sc->sc_unit, op);
-    }
-
-    return 0;
-}
-
-/*
-//  i4b_capi_handlers
-//      Array of message-handler pairs used to dispatch CAPI
-//      messages sent to I4BCAPI_APPLID.
-*/
-
-static struct capi_cmdtab {
-    u_int16_t cmd;
-    void (*handler)(capi_softc_t *, struct mbuf *);
-} i4b_capi_handlers[] = {
-    { CAPI_LISTEN_CONF,           capi_listen_conf },
-    { CAPI_INFO_IND,              capi_info_ind },
-    { CAPI_ALERT_CONF,            capi_alert_conf },
-    { CAPI_CONNECT_CONF,          capi_connect_conf },
-    { CAPI_CONNECT_IND,           capi_connect_ind },
-    { CAPI_CONNECT_ACTIVE_IND,    capi_connect_active_ind },
-    { CAPI_CONNECT_B3_CONF,       capi_connect_b3_conf },
-    { CAPI_CONNECT_B3_IND,        capi_connect_b3_ind },
-    { CAPI_CONNECT_B3_ACTIVE_IND, capi_connect_b3_active_ind },
-    { CAPI_DATA_B3_CONF,          capi_data_b3_conf },
-    { CAPI_DATA_B3_IND,           capi_data_b3_ind },
-    { CAPI_DISCONNECT_B3_IND,     capi_disconnect_b3_ind },
-    { CAPI_DISCONNECT_CONF,       capi_disconnect_conf },
-    { CAPI_DISCONNECT_IND,        capi_disconnect_ind },
-    { 0, 0 }
-};
-
-/*
-//  capi_ll_receive
-//      CAPI link layer receive upcall. Called by a link layer
-//      driver to dispatch incoming CAPI messages.
-*/
-
-int
-capi_ll_receive(capi_softc_t *sc, struct mbuf *m)
-{
-    u_int8_t *p = mtod(m, u_int8_t*);
-    u_int16_t len, applid, msgid, cmd;
-
-    capimsg_getu16(p + 0, &len);
-    capimsg_getu16(p + 2, &applid);
-    capimsg_getu16(p + 4, &cmd);
-    capimsg_getu16(p + 6, &msgid);
-
-#if 0
-    printf("capi%d: ll_receive hdr %04x %04x %04x %04x\n", sc->sc_unit,
-	   len, applid, cmd, msgid);
-#endif
-
-    if (applid == I4BCAPI_APPLID) {
-	struct capi_cmdtab *e;
-	for (e = i4b_capi_handlers; e->cmd && e->cmd != cmd; e++);
-	if (e->cmd) (*e->handler)(sc, m);
-	else printf("capi%d: unknown message %04x\n", sc->sc_unit, cmd);
-
-    } else {
-	/* XXX we could handle arbitrary ApplIds here XXX */
-	printf("capi%d: message %04x for unknown applid %d\n", sc->sc_unit,
-	       cmd, applid);
-    }
-
-    if (m->m_next) {
-	i4b_Bfreembuf(m->m_next);
-	m->m_next = NULL;
-    }
-    i4b_Dfreembuf(m);
-    return(0);
-}
--- sys/i4b/capi/README
+++ /dev/null
@@ -1,150 +0,0 @@
-$FreeBSD: src/sys/i4b/capi/README,v 1.1 2001/05/25 08:39:31 hm Exp $
-
-Message-ID: <3AF56886.7D92609A at cubical.fi>
-Date: Sun, 06 May 2001 18:06:47 +0300
-From: Juha-Matti Liukkonen <jml at cubical.fi>
-Organization: Cubical Solutions Ltd
-
-Please find the attached diff and tarball for our support software for
-CAPI 2.0 and AVM's active T1 and T1-B (primary rate) and B1 (basic rate)
-ISDN adapters for isdn4bsd. The implementation has been made from
-scratch by us, based on reverse engineering of the Linux driver provided
-by AVM GmbH and available in ftp.avm.de. Cubical Solutions Ltd offers
-this implementation for the BSD community free of charge and assuming
-absolutely no liabilities whatsoever. Feel free to modify the
-implementation any way you see fit, but please retain our one-liner
-copyright statement somewhere in the comment headers in the capi and
-iavc driver modules.
-
-That said, the attached tarball is i4b-00.96.00-beta with our
-modifications integrated, and the diff contains all modifications we
-have made to the original (including the new capi files). Our mods add
-pseudo-device i4bcapi, which attaches to i4b layer 4, and device iavc0,
-which implements a link layer driver for AVM's active B1 and T1 adapters
-for i4bcapi. There are also a couple of related improvements to isdnd,
-and a number of modifications to isdnd and layer 4 to implement support
-for up to 30 channels per adapter (for primary rate use).
-
-We have developed the software explicitly for our telephony application,
-to be used with AVM's T1 adapters, and the implementation has been
-tested primarily with this functionality in mind. There may be
-interesting side effects with eg. the ipr and isppp drivers; we do not
-use them and therefore their testing has been cursory at best. The
-i4btel driver works well with the T1 (our primary use), and the i4brbch
-driver has been verified to work with T1, T1-B and B1 adapters (ftp'd
-some files over a dialup PPP connection with each adapter). Only the PCI
-versions of the adapters (equipped with the AMCC DMA controller) are
-supported, although the basics (PIO mode communication) for the older
-ISA model support is in place, so only the bus attachment modules should
-be required to support the older hardware.
-
-All of the AVM active adapters use downloadable firmware, which is not
-included in the attached package. The firmware files (t1.t4, t1b.t4,
-b1.t4) can be found from ftp.avm.de in adapter specific subdirectories,
-or from the CDs provided with the adapters (in directory
-'cardware/firmware').
-
-Our primary development platform is our own embedded build (we call it
-'ebsd') based on FreeBSD 4.2-RELEASE. The implementation has also been
-tested on standard FreeBSD 4.2-RELEASE system. The implementation should
-not contain any FreeBSD (or even FreeBSD release) specific issues, but
-it has not been tested or even compiled on any other platforms;
-specifically, only the FreeBSD overinstall.sh script is modified to
-install the capi/iavc support in the kernel source tree.
-
-This code is not under active development here since the functionality
-we use (i4btel, T1) has been working since the beginning of March. We
-are also not planning on any further development (no need seen at this
-point), but I am naturally interested on whatever bugs and development
-ideas pop up on the community and will keep a keen eye on the isdn
-mailing list. I personally may be available for consultation, debugging
-and possibly development projects, but with notable reservations on my
-time (the current IT industry recession seems to be pushing even more
-work for us, which tends to keep us pretty busy these days).
-
-Here are some specific technical notes:
-
-* isdnd supports new keyword 'firmware=</path/to/file>' in section
-'controller'. This keyword is supported for all controller types, and
-causes I4B_CTRL_DOWNLOAD ioctl to be invoked with the specified file as
-an argument. In systems equipped with both active and passive adapters,
-and the passive cards being detected first, dummy 'controller' entries
-are required for the passive cards to get the correct firmwares to
-correct adapters. (I hope you did not have other uses for this ioctl in
-mind?)
-
-* isdnd supports new keyword 'clone=<entry name>' in section 'entry'.
-This causes the entry to be copied from the existing named entry. At
-least entry specific 'name' and 'usrdeviceunit' values should be
-specified after a 'clone'. (Makes configuring 30 or 60 entries way much
-easier.)
-
-* a bug in i4btel driver read routine corrected. The conditions in the
-while() clause caused the receive queue to be referenced before checking
-if a channel is connected, leading to kernel panic (do a 'dd
-if=/dev/i4btel0 of=/dev/null' on an unconnected tel device, panic will
-follow). Correction was to reorder the while clause conditions to check
-for connectedness first.
-
-* isdnd and i4b layer 4 support up to CHANNELS_MAX (=30) channels per
-adapter. The msg_ctrl_info_req_t message reports the number of channels
-provided by the adapter, the number is stored in the nbchan field of the
-controller state structure. The fixed stateb1 and stateb2 entries in
-controller state stuctures are replaced with an array, and all fixed
-references there are replaced with loops up to nbchan. Passive stack
-layer 1 and 2 are not modified, layer 3 sets this field to fixed value 2
-for all adapters (but it could be delegated to the layer 1 driver's
-attach request).
-
-* the i4bcapi driver maps i4b channels to logical channels identified
-with PLCI/NCCI values in the CAPI protocol using the sc_bchan[] array.
-The PLCI/NCCI handling is merged in the channel mapping and is greatly
-simplified from the reference state machine model, because in practice
-there can be only one PLCI/NCCI per channel active at any given time.
-
-* the i4bcapi driver does not provide any kind of user level interface
-(such as the /dev/capi20 interface provided by the linux driver), but
-could relatively easily be extended to do so (and if done, interface
-compatibility with the linux implementation would probably be a good
-goal).
-
-* there are some gritty details in the iavc driver, inherited from the
-linux code. Despite us being a legitimate company in the telecom
-business, AVM failed to produce any programming reference material for
-us (at least in a reasonable time frame), so some guesswork remains due
-to classic reverse engineering process (particularly there are a few
-magic numbers in the card initialization sequence whose meaning I do not
-know).
-
-* pseudo-devices i4bq931, i4bq921 and some passive stack layer 1 driver
-(such as iwic) are required to compile, as the required ctrl_desc[]
-array is in layer 3, which requires layer 2, which requires layer 1.
-Some architectural cleanup would come in handy here, but we did not want
-to start making any major changes (and we use iwic in test setups
-anyway, so we simply always compile it in).
-
-To summarize: unpack, overinstall, add the following lines (with the
-usual passive stack configuration including at least one L1 driver) to
-your kernel configuration file:
-
-pseudo-device	"i4bcapi"
-device		iavc0
-
-...and the following to your isdnd.rc:
-
-controller
-firmware = /usr/lib/isdn/b1.t4
-
-...compile your new kernel, make sure the firmware file is in
-/usr/lib/isdn, and your B1 adapter should boot up and Just Work (tm). If
-you have multiple adapters, you need a 'controller' section for each to
-have them loaded and booted on isdnd startup.
-
-Have fun -- and let me know if there are any complications, or if I can
-be of further assistance,
-
-	- Juha
---
-Juha-Matti Liukkonen, Cubical Solutions Ltd
-Phone: +358(0)405280142
-Email: jml at cubical.fi
--- sys/i4b/capi/iavc/iavc_pci.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*-
- * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* capi/iavc/iavc_pci.c
- *		The AVM ISDN controllers' PCI bus attachment handling.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/capi/iavc/iavc_pci.c,v 1.10 2005/01/06 22:18:18 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/clock.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/capi/capi.h>
-
-#include <i4b/capi/iavc/iavc.h>
-
-/* PCI device ids */
-
-#define PCI_AVM_VID   0x1244
-#define PCI_AVMT1_DID 0x1200
-#define PCI_AVMB1_DID 0x0700
-
-/* PCI driver linkage */
-
-static void iavc_pci_intr(iavc_softc_t *sc);
-static int iavc_pci_probe(device_t dev);
-static int iavc_pci_attach(device_t dev);
-
-static device_method_t iavc_pci_methods[] =
-{
-    DEVMETHOD(device_probe,	iavc_pci_probe),
-    DEVMETHOD(device_attach,	iavc_pci_attach),
-    { 0, 0 }
-};
-
-static driver_t iavc_pci_driver =
-{
-    "iavc",
-    iavc_pci_methods,
-    0
-};
-
-static devclass_t iavc_pci_devclass;
-
-DRIVER_MODULE(iavc, pci, iavc_pci_driver, iavc_pci_devclass, 0, 0);
-
-/* Driver soft contexts */
-
-iavc_softc_t iavc_sc[IAVC_MAXUNIT];
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-
-static int
-iavc_pci_probe(device_t dev)
-{
-    u_int16_t did = pci_get_device(dev);
-    u_int16_t vid = pci_get_vendor(dev);
-
-    if ((vid == PCI_AVM_VID) && (did == PCI_AVMT1_DID)) {
-	device_set_desc(dev, "AVM T1 PCI");
-    } else if ((vid == PCI_AVM_VID) && (did == PCI_AVMB1_DID)) {
-	device_set_desc(dev, "AVM B1 PCI");
-    } else {
-	return(ENXIO);
-    }
-
-    return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-
-static int
-iavc_pci_attach(device_t dev)
-{
-    struct iavc_softc *sc;
-    void *ih = 0;
-    u_int16_t did = pci_get_device(dev);
-    int unit = device_get_unit(dev), ret;
-	
-    /* check max unit range */
-	
-    if (unit >= IAVC_MAXUNIT) {
-	printf("iavc%d: too many units\n", unit);
-	return(ENXIO);	
-    }	
-
-    sc = iavc_find_sc(unit);	/* get softc */	
-	
-    sc->sc_unit = unit;
-
-    /* use the i/o mapped base address */
-	
-    sc->sc_resources.io_rid[0] = 0x14;
-	
-    if (!(sc->sc_resources.io_base[0] =
-	 bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-				&sc->sc_resources.io_rid[0], RF_ACTIVE))) {
-	printf("iavc%d: can't allocate io region\n", unit);
-	return(ENXIO);                                       
-    }
-
-    sc->sc_iobase = rman_get_start(sc->sc_resources.io_base[0]);
-    sc->sc_io_bt = rman_get_bustag(sc->sc_resources.io_base[0]);
-    sc->sc_io_bh = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-    /* use the memory mapped DMA controller */
-	
-    sc->sc_resources.mem_rid = 0x10;
-	
-    if (!(sc->sc_resources.mem =
-	 bus_alloc_resource_any(dev, SYS_RES_MEMORY,
-				&sc->sc_resources.mem_rid, RF_ACTIVE))) {
-	printf("iavc%d: can't allocate memory region\n", unit);
-	return(ENXIO);                                       
-    }
-
-    sc->sc_membase = rman_get_start(sc->sc_resources.mem);
-    sc->sc_mem_bt = rman_get_bustag(sc->sc_resources.mem);
-    sc->sc_mem_bh = rman_get_bushandle(sc->sc_resources.mem);
-
-    /* do some detection */
-
-    sc->sc_t1 = FALSE;
-    sc->sc_dma = FALSE;
-    b1dma_reset(sc);
-
-    if (did == PCI_AVMT1_DID) {
-	sc->sc_capi.card_type = CARD_TYPEC_AVM_T1_PCI;
-	sc->sc_capi.sc_nbch = 30;
-	ret = t1_detect(sc);
-	if (ret) {
-	    if (ret < 6) {
-		printf("iavc%d: no card detected?\n", sc->sc_unit);
-	    } else {
-		printf("iavc%d: black box not on\n", sc->sc_unit);
-	    }
-	    return(ENXIO);
-	} else {
-	    sc->sc_dma = TRUE;
-	    sc->sc_t1 = TRUE;
-	}
-
-    } else if (did == PCI_AVMB1_DID) {
-	sc->sc_capi.card_type = CARD_TYPEC_AVM_B1_PCI;
-	sc->sc_capi.sc_nbch = 2;
-	ret = b1dma_detect(sc);
-	if (ret) {
-	    ret = b1_detect(sc);
-	    if (ret) {
-		printf("iavc%d: no card detected?\n", sc->sc_unit);
-		return(ENXIO);
-	    }
-	} else {
-	    sc->sc_dma = TRUE;
-	}
-    }
-
-    if (sc->sc_dma) b1dma_reset(sc);
-#if 0
-    if (sc->sc_t1) t1_reset(sc);
-    else b1_reset(sc);
-#endif
-
-    /* of course we need an interrupt */
-    
-    sc->sc_resources.irq_rid = 0x00;
-	
-    if(!(sc->sc_resources.irq =
-	 bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sc_resources.irq_rid,
-				RF_SHAREABLE|RF_ACTIVE))) {
-	printf("iavc%d: can't allocate irq\n",unit);
-	return(ENXIO);
-    }
-
-    /* finalize our own context */
-
-    memset(&sc->sc_txq, 0, sizeof(struct ifqueue));
-    sc->sc_txq.ifq_maxlen = sc->sc_capi.sc_nbch * 4;
-
-    if(!mtx_initialized(&sc->sc_txq.ifq_mtx))
-	    mtx_init(&sc->sc_txq.ifq_mtx, "i4b_ivac_pci", NULL, MTX_DEF);
-    
-    sc->sc_intr = FALSE;
-    sc->sc_state = IAVC_DOWN;
-    sc->sc_blocked = FALSE;
-
-    /* setup capi link */
-	
-    sc->sc_capi.load = iavc_load;
-    sc->sc_capi.reg_appl = iavc_register;
-    sc->sc_capi.rel_appl = iavc_release;
-    sc->sc_capi.send = iavc_send;
-    sc->sc_capi.ctx = (void*) sc;
-
-    if (capi_ll_attach(&sc->sc_capi)) {
-	printf("iavc%d: capi attach failed\n", unit);
-	return(ENXIO);
-    }
-
-    /* setup the interrupt */
-
-    if(bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET,
-		      (void(*)(void*))iavc_pci_intr,
-		      sc, &ih)) {
-	printf("iavc%d: irq setup failed\n", unit);
-	return(ENXIO);
-    }
-
-    /* the board is now ready to be loaded */
-
-    return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	IRQ handler
- *---------------------------------------------------------------------------*/
-
-static void
-iavc_pci_intr(struct iavc_softc *sc)
-{
-    iavc_handle_intr(sc);
-}
--- sys/i4b/capi/iavc/iavc_card.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/*-
- * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* capi/iavc/iavc_card.c
- *		The AVM ISDN controllers' card specific support routines.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/capi/iavc/iavc_card.c,v 1.5 2005/01/06 22:18:18 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/clock.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/capi/capi.h>
-
-#include <i4b/capi/iavc/iavc.h>
-
-/*
-//  AVM B1 (active BRI, PIO mode)
-*/
-
-int b1_detect(iavc_softc_t *sc)
-{
-    if ((iavc_read_port(sc, B1_INSTAT) & 0xfc) ||
-	(iavc_read_port(sc, B1_OUTSTAT) & 0xfc))
-	return (1);
-
-    b1io_outp(sc, B1_INSTAT, 0x02);
-    b1io_outp(sc, B1_OUTSTAT, 0x02);
-    if ((iavc_read_port(sc, B1_INSTAT) & 0xfe) != 2 ||
-	(iavc_read_port(sc, B1_OUTSTAT) & 0xfe) != 2)
-	return (2);
-
-    b1io_outp(sc, B1_INSTAT, 0x00);
-    b1io_outp(sc, B1_OUTSTAT, 0x00);
-    if ((iavc_read_port(sc, B1_INSTAT) & 0xfe) ||
-	(iavc_read_port(sc, B1_OUTSTAT) & 0xfe))
-	return (3);
-
-    return (0); /* found */
-}
-
-void b1_disable_irq(iavc_softc_t *sc)
-{
-    b1io_outp(sc, B1_INSTAT, 0x00);
-}
-
-void b1_reset(iavc_softc_t *sc)
-{
-    b1io_outp(sc, B1_RESET, 0);
-    DELAY(55*2*1000);
-
-    b1io_outp(sc, B1_RESET, 1);
-    DELAY(55*2*1000);
-
-    b1io_outp(sc, B1_RESET, 0);
-    DELAY(55*2*1000);
-}
-
-/*
-//  Newer PCI-based B1's, and T1's, supports DMA
-*/
-
-int b1dma_detect(iavc_softc_t *sc)
-{
-    AMCC_WRITE(sc, AMCC_MCSR, 0);
-    DELAY(10*1000);
-    AMCC_WRITE(sc, AMCC_MCSR, 0x0f000000);
-    DELAY(10*1000);
-    AMCC_WRITE(sc, AMCC_MCSR, 0);
-    DELAY(42*1000);
-
-    AMCC_WRITE(sc, AMCC_RXLEN, 0);
-    AMCC_WRITE(sc, AMCC_TXLEN, 0);
-    sc->sc_csr = 0;
-    AMCC_WRITE(sc, AMCC_INTCSR, sc->sc_csr);
-
-    if (AMCC_READ(sc, AMCC_INTCSR) != 0)
-	return 1;
-
-    AMCC_WRITE(sc, AMCC_RXPTR, 0xffffffff);
-    AMCC_WRITE(sc, AMCC_TXPTR, 0xffffffff);
-    if ((AMCC_READ(sc, AMCC_RXPTR) != 0xfffffffc) ||
-	(AMCC_READ(sc, AMCC_TXPTR) != 0xfffffffc))
-	return 2;
-
-    AMCC_WRITE(sc, AMCC_RXPTR, 0);
-    AMCC_WRITE(sc, AMCC_TXPTR, 0);
-    if ((AMCC_READ(sc, AMCC_RXPTR) != 0) ||
-	(AMCC_READ(sc, AMCC_TXPTR) != 0))
-	return 3;
-
-    iavc_write_port(sc, 0x10, 0x00);
-    iavc_write_port(sc, 0x07, 0x00);
-
-    iavc_write_port(sc, 0x02, 0x02);
-    iavc_write_port(sc, 0x03, 0x02);
-
-    if (((iavc_read_port(sc, 0x02) & 0xfe) != 0x02) ||
-	(iavc_read_port(sc, 0x03) != 0x03))
-	return 4;
-
-    iavc_write_port(sc, 0x02, 0x00);
-    iavc_write_port(sc, 0x03, 0x00);
-
-    if (((iavc_read_port(sc, 0x02) & 0xfe) != 0x00) ||
-	(iavc_read_port(sc, 0x03) != 0x01))
-	return 5;
-
-    return (0); /* found */
-}
-
-void b1dma_reset(iavc_softc_t *sc)
-{
-    int s = SPLI4B();
-
-    sc->sc_csr = 0;
-    AMCC_WRITE(sc, AMCC_INTCSR, sc->sc_csr);
-    AMCC_WRITE(sc, AMCC_MCSR, 0);
-    AMCC_WRITE(sc, AMCC_RXLEN, 0);
-    AMCC_WRITE(sc, AMCC_TXLEN, 0);
-
-    iavc_write_port(sc, 0x10, 0x00); /* XXX magic numbers from */
-    iavc_write_port(sc, 0x07, 0x00); /* XXX the linux driver */
-
-    splx(s);
-
-    AMCC_WRITE(sc, AMCC_MCSR, 0);
-    DELAY(10 * 1000);
-    AMCC_WRITE(sc, AMCC_MCSR, 0x0f000000);
-    DELAY(10 * 1000);
-    AMCC_WRITE(sc, AMCC_MCSR, 0);
-    DELAY(42 * 1000);
-}
-
-/*
-//  AVM T1 (active PRI)
-*/
-
-/* XXX how do these differ from b1io_{read,write}_reg()? XXX */
-
-static int b1dma_tx_empty(int iobase)
-{ return inb(iobase + 3) & 1; }
-
-static int b1dma_rx_full(int iobase)
-{ return inb(iobase + 2) & 1; }
-
-static int b1dma_tolink(iavc_softc_t *sc, void *buf, int len)
-{
-    volatile int spin;
-    char *s = (char*) buf;
-    while (len--) {
-	spin = 0;
-	while (!b1dma_tx_empty(sc->sc_iobase) && spin < 100000)
-	    spin++;
-	if (!b1dma_tx_empty(sc->sc_iobase))
-	    return -1;
-	t1io_outp(sc, 1, *s++);
-    }
-    return 0;
-}
-
-static int b1dma_fromlink(iavc_softc_t *sc, void *buf, int len)
-{
-    volatile int spin;
-    char *s = (char*) buf;
-    while (len--) {
-	spin = 0;
-	while (!b1dma_rx_full(sc->sc_iobase) && spin < 100000)
-	    spin++;
-	if (!b1dma_rx_full(sc->sc_iobase))
-	    return -1;
-	*s++ = t1io_inp(sc, 0);
-    }
-    return 0;
-}
-
-static int WriteReg(iavc_softc_t *sc, u_int32_t reg, u_int8_t val)
-{
-    u_int8_t cmd = 0;
-    if (b1dma_tolink(sc, &cmd, 1) == 0 &&
-	b1dma_tolink(sc, &reg, 4) == 0) {
-	u_int32_t tmp = val;
-	return b1dma_tolink(sc, &tmp, 4);
-    }
-    return -1;
-}
-
-static u_int8_t ReadReg(iavc_softc_t *sc, u_int32_t reg)
-{
-    u_int8_t cmd = 1;
-    if (b1dma_tolink(sc, &cmd, 1) == 0 &&
-	b1dma_tolink(sc, &reg, 4) == 0) {
-	u_int32_t tmp;
-	if (b1dma_fromlink(sc, &tmp, 4) == 0)
-	    return (u_int8_t) tmp;
-    }
-    return 0xff;
-}
-
-int t1_detect(iavc_softc_t *sc)
-{
-    int ret = b1dma_detect(sc);
-    if (ret) return ret;
-
-    if ((WriteReg(sc, 0x80001000, 0x11) != 0) ||
-	(WriteReg(sc, 0x80101000, 0x22) != 0) ||
-	(WriteReg(sc, 0x80201000, 0x33) != 0) ||
-	(WriteReg(sc, 0x80301000, 0x44) != 0))
-	return 6;
-
-    if ((ReadReg(sc, 0x80001000) != 0x11) ||
-	(ReadReg(sc, 0x80101000) != 0x22) ||
-	(ReadReg(sc, 0x80201000) != 0x33) ||
-	(ReadReg(sc, 0x80301000) != 0x44))
-	return 7;
-
-    if ((WriteReg(sc, 0x80001000, 0x55) != 0) ||
-	(WriteReg(sc, 0x80101000, 0x66) != 0) ||
-	(WriteReg(sc, 0x80201000, 0x77) != 0) ||
-	(WriteReg(sc, 0x80301000, 0x88) != 0))
-	return 8;
-
-    if ((ReadReg(sc, 0x80001000) != 0x55) ||
-	(ReadReg(sc, 0x80101000) != 0x66) ||
-	(ReadReg(sc, 0x80201000) != 0x77) ||
-	(ReadReg(sc, 0x80301000) != 0x88))
-	return 9;
-
-    return 0; /* found */
-}
-
-void t1_disable_irq(iavc_softc_t *sc)
-{
-    iavc_write_port(sc, T1_IRQMASTER, 0x00);
-}
-
-void t1_reset(iavc_softc_t *sc)
-{
-    b1_reset(sc);
-    iavc_write_port(sc, B1_INSTAT, 0x00);
-    iavc_write_port(sc, B1_OUTSTAT, 0x00);
-    iavc_write_port(sc, T1_IRQMASTER, 0x00);
-    iavc_write_port(sc, T1_RESETBOARD, 0x0f);
-}
--- sys/i4b/capi/iavc/iavc_lli.c
+++ /dev/null
@@ -1,987 +0,0 @@
-/*-
- * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* capi/iavc/iavc_lli.c
- *		The AVM ISDN controllers' Low Level Interface.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/capi/iavc/iavc_lli.c,v 1.8 2005/01/06 22:18:18 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/malloc.h>
-#include <net/if.h>
-
-#include <machine/clock.h>
-
-#include <machine/bus.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/capi/capi.h>
-#include <i4b/capi/capi_msgs.h>
-
-#include <i4b/capi/iavc/iavc.h>
-
-/* Forward declarations of local subroutines... */
-
-static int iavc_send_init(iavc_softc_t *);
-
-static void iavc_handle_rx(iavc_softc_t *);
-static void iavc_start_tx(iavc_softc_t *);
-
-/*
-//  Callbacks from the upper (capi) layer:
-//  --------------------------------------
-//
-//  iavc_load
-//      Resets the board and loads the firmware, then initiates
-//      board startup.
-//
-//  iavc_register
-//      Registers a CAPI application id.
-//
-//  iavc_release
-//      Releases a CAPI application id.
-//
-//  iavc_send
-//      Sends a capi message.
-*/
-
-int iavc_load(capi_softc_t *capi_sc, int len, u_int8_t *cp)
-{
-    iavc_softc_t *sc = (iavc_softc_t*) capi_sc->ctx;
-    u_int8_t val;
-
-    if(bootverbose)
-	printf("iavc%d: reset card ....\n", sc->sc_unit);
-
-    if (sc->sc_dma)
-	b1dma_reset(sc);	/* PCI cards */
-    else if (sc->sc_t1)
-	t1_reset(sc);		/* ISA attachment T1 */
-    else
-	b1_reset(sc);		/* ISA attachment B1 */
-
-    DELAY(1000);
-
-    if(bootverbose)
-	    printf("iavc%d: start loading %d bytes firmware ....\n", sc->sc_unit, len);
-    
-    while (len && b1io_save_put_byte(sc, *cp++) == 0)
-	len--;
-
-    if (len) {
-	printf("iavc%d: loading failed, can't write to card, len = %d\n",
-	       sc->sc_unit, len);
-	return (EIO);
-    }
-
-    if(bootverbose)
-    	printf("iavc%d: firmware loaded, wait for ACK ....\n", sc->sc_unit);
-    
-    if(sc->sc_capi.card_type == CARD_TYPEC_AVM_B1_ISA)
-	    iavc_put_byte(sc, SEND_POLL);
-    else
-	    iavc_put_byte(sc, SEND_POLLACK);    	
-    
-    for (len = 0; len < 1000 && !iavc_rx_full(sc); len++)
-	DELAY(100);
-    
-    if (!iavc_rx_full(sc)) {
-	printf("iavc%d: loading failed, no ack\n", sc->sc_unit);
-	return (EIO);
-    }
-    
-    val = iavc_get_byte(sc);
-
-    if ((sc->sc_dma && val != RECEIVE_POLLDWORD) ||
-	(!sc->sc_dma && val != RECEIVE_POLL)) {
-	printf("iavc%d: loading failed, bad ack = %02x\n", sc->sc_unit, val);
-	return (EIO);
-    }
-
-    if(bootverbose)
-	    printf("iavc%d: got ACK = 0x%02x\n", sc->sc_unit, val);    
-
-    if (sc->sc_dma) {
-	/* Start the DMA engine */
-
-	int s = SPLI4B();
-
-	sc->sc_csr = AVM_FLAG;
-	AMCC_WRITE(sc, AMCC_INTCSR, sc->sc_csr);
-	AMCC_WRITE(sc, AMCC_MCSR, (EN_A2P_TRANSFERS|EN_P2A_TRANSFERS|
-				   A2P_HI_PRIORITY|P2A_HI_PRIORITY|
-				   RESET_A2P_FLAGS|RESET_P2A_FLAGS));
-
-	iavc_write_port(sc, 0x07, 0x30); /* XXX magic numbers from */
-	iavc_write_port(sc, 0x10, 0xf0); /* XXX the linux driver */
-
-	sc->sc_recvlen = 0;
-	AMCC_WRITE(sc, AMCC_RXPTR, vtophys(&sc->sc_recvbuf[0]));
-	AMCC_WRITE(sc, AMCC_RXLEN, 4);
-	sc->sc_csr |= EN_RX_TC_INT|EN_TX_TC_INT;
-	AMCC_WRITE(sc, AMCC_INTCSR, sc->sc_csr);
-
-	splx(s);
-    }
-
-    if(sc->sc_capi.card_type == CARD_TYPEC_AVM_B1_ISA)
-	b1isa_setup_irq(sc);
-    
-    iavc_send_init(sc);
-
-    return 0;
-}
-
-int iavc_register(capi_softc_t *capi_sc, int applid, int nchan)
-{
-    iavc_softc_t *sc = (iavc_softc_t*) capi_sc->ctx;
-    struct mbuf *m = i4b_Dgetmbuf(23);
-    u_int8_t *p;
-
-    if (!m) {
-	printf("iavc%d: can't get memory\n", sc->sc_unit);
-	return (ENOMEM);
-    }
-
-    /*
-     * byte  0x12 = SEND_REGISTER
-     * dword ApplId
-     * dword NumMessages
-     * dword NumB3Connections 0..nbch
-     * dword NumB3Blocks
-     * dword B3Size
-     */
-
-    p = amcc_put_byte(mtod(m, u_int8_t*), 0);
-    p = amcc_put_byte(p, 0);
-    p = amcc_put_byte(p, SEND_REGISTER);
-    p = amcc_put_word(p, applid);
-#if 0
-    p = amcc_put_word(p, 1024 + (nchan + 1));
-#else
-    p = amcc_put_word(p, 1024 * (nchan + 1));
-#endif    
-    p = amcc_put_word(p, nchan);
-    p = amcc_put_word(p, 8);
-    p = amcc_put_word(p, 2048);
-
-    _IF_ENQUEUE(&sc->sc_txq, m);
-
-    iavc_start_tx(sc);
-
-    return 0;
-}
-
-int iavc_release(capi_softc_t *capi_sc, int applid)
-{
-    iavc_softc_t *sc = (iavc_softc_t*) capi_sc->ctx;
-    struct mbuf *m = i4b_Dgetmbuf(7);
-    u_int8_t *p;
-
-    if (!m) {
-	printf("iavc%d: can't get memory\n", sc->sc_unit);
-	return (ENOMEM);
-    }
-
-    /*
-     * byte  0x14 = SEND_RELEASE
-     * dword ApplId
-     */
-
-    p = amcc_put_byte(mtod(m, u_int8_t*), 0);
-    p = amcc_put_byte(p, 0);
-    p = amcc_put_byte(p, SEND_RELEASE);
-    p = amcc_put_word(p, applid);
-
-    _IF_ENQUEUE(&sc->sc_txq, m);
-
-    iavc_start_tx(sc);
-    return 0;
-}
-
-int iavc_send(capi_softc_t *capi_sc, struct mbuf *m)
-{
-    iavc_softc_t *sc = (iavc_softc_t*) capi_sc->ctx;
-
-    if (sc->sc_state != IAVC_UP) {
-	printf("iavc%d: attempt to send before device up\n", sc->sc_unit);
-
-	if (m->m_next) i4b_Bfreembuf(m->m_next);
-	i4b_Dfreembuf(m);
-
-	return (ENXIO);
-    }
-
-    if (_IF_QFULL(&sc->sc_txq)) {
-
-	_IF_DROP(&sc->sc_txq);
-
-	printf("iavc%d: tx overflow, message dropped\n", sc->sc_unit);
-
-	if (m->m_next) i4b_Bfreembuf(m->m_next);
-	i4b_Dfreembuf(m);
-
-    } else {
-	_IF_ENQUEUE(&sc->sc_txq, m);
-
-	iavc_start_tx(sc);
-    }
-    
-    return 0;
-}
-
-/*
-//  Functions called by ourself during the initialization sequence:
-//  ---------------------------------------------------------------
-//
-//  iavc_send_init
-//      Sends the system initialization message to a newly loaded
-//      board, and sets state to INIT.
-*/
-
-static int iavc_send_init(iavc_softc_t *sc)
-{
-    struct mbuf *m = i4b_Dgetmbuf(15);
-    u_int8_t *p;
-    int s;
-
-    if (!m) {
-	printf("iavc%d: can't get memory\n", sc->sc_unit);
-	return (ENOMEM);
-    }
-
-    /*
-     * byte  0x11 = SEND_INIT
-     * dword NumApplications
-     * dword NumNCCIs
-     * dword BoardNumber
-     */
-
-    p = amcc_put_byte(mtod(m, u_int8_t*), 0);
-    p = amcc_put_byte(p, 0);
-    p = amcc_put_byte(p, SEND_INIT);
-    p = amcc_put_word(p, 1); /* XXX MaxAppl XXX */
-    p = amcc_put_word(p, sc->sc_capi.sc_nbch);
-    p = amcc_put_word(p, sc->sc_unit);
-
-    s = SPLI4B();
-    _IF_ENQUEUE(&sc->sc_txq, m);
-
-    iavc_start_tx(sc);
-
-    sc->sc_state = IAVC_INIT;
-    splx(s);
-    return 0;
-}
-
-/*
-//  Functions called during normal operation:
-//  -----------------------------------------
-//
-//  iavc_receive_init
-//      Reads the initialization reply and calls capi_ll_control().
-//
-//  iavc_receive_new_ncci
-//      Reads a new NCCI notification and calls capi_ll_control().
-//
-//  iavc_receive_free_ncci
-//      Reads a freed NCCI notification and calls capi_ll_control().
-//
-//  iavc_receive_task_ready
-//      Reads a task ready message -- which should not occur XXX.
-//
-//  iavc_receive_debugmsg
-//      Reads a debug message -- which should not occur XXX.
-//
-//  iavc_receive_start
-//      Reads a START TRANSMIT message and unblocks device.
-//
-//  iavc_receive_stop
-//      Reads a STOP TRANSMIT message and blocks device.
-//
-//  iavc_receive
-//      Reads an incoming message and calls capi_ll_receive().
-*/
-
-static int iavc_receive_init(iavc_softc_t *sc, u_int8_t *dmabuf)
-{
-    u_int32_t Length;
-    u_int8_t *p;
-    u_int8_t *cardtype, *serial, *profile, *version, *caps, *prot;
-
-    if (sc->sc_dma) {
-	p = amcc_get_word(dmabuf, &Length);
-    } else {
-	Length = iavc_get_slice(sc, sc->sc_recvbuf);
-	p = sc->sc_recvbuf;
-    }
-
-#if 0
-    {
-	int len = 0;
-	printf("iavc%d: rx_init: ", sc->sc_unit);
-	    while (len < Length) {
-		printf(" %02x", p[len]);
-		if (len && (len % 16) == 0) printf("\n");
-		len++;
-	    }
-	    if (len % 16) printf("\n");
-    }
-#endif
-
-    version = (p + 1);
-    p += (*p + 1); /* driver version */
-    cardtype = (p + 1);
-    p += (*p + 1); /* card type */
-    p += (*p + 1); /* hardware ID */
-    serial = (p + 1);
-    p += (*p + 1); /* serial number */
-    caps = (p + 1);
-    p += (*p + 1); /* supported options */
-    prot = (p + 1);
-    p += (*p + 1); /* supported protocols */
-    profile = (p + 1);
-
-    if (cardtype && serial && profile) {
-	int nbch = ((profile[3]<<8) | profile[2]);
-
-	printf("iavc%d: AVM %s, s/n %s, %d chans, f/w rev %s, prot %s\n",
-		sc->sc_unit, cardtype, serial, nbch, version, prot);
-
-	if(bootverbose)
-		printf("iavc%d: %s\n", sc->sc_unit, caps);
-
-        capi_ll_control(&sc->sc_capi, CAPI_CTRL_PROFILE, (int) profile);
-
-    } else {
-	printf("iavc%d: no profile data in info response?\n", sc->sc_unit);
-    }
-
-    sc->sc_blocked = TRUE; /* controller will send START when ready */
-    return 0;
-}
-
-static int iavc_receive_start(iavc_softc_t *sc, u_int8_t *dmabuf)
-{
-    struct mbuf *m = i4b_Dgetmbuf(3);
-    u_int8_t *p;
-
-    if (sc->sc_blocked && sc->sc_state == IAVC_UP)
-	printf("iavc%d: receive_start\n", sc->sc_unit);
-
-    if (!m) {
-	printf("iavc%d: can't get memory\n", sc->sc_unit);
-	return (ENOMEM);
-    }
-
-    /*
-     * byte  0x73 = SEND_POLLACK
-     */
-
-    p = amcc_put_byte(mtod(m, u_int8_t*), 0);
-    p = amcc_put_byte(p, 0);
-    p = amcc_put_byte(p, SEND_POLLACK);
-    
-    _IF_PREPEND(&sc->sc_txq, m);
-
-    NDBGL4(L4_IAVCDBG, "iavc%d: blocked = %d, state = %d",
-		sc->sc_unit, sc->sc_blocked, sc->sc_state);
-
-    sc->sc_blocked = FALSE;
-    iavc_start_tx(sc);
-    
-    /* If this was our first START, register our readiness */
-
-    if (sc->sc_state != IAVC_UP) {
-	sc->sc_state = IAVC_UP;
-	capi_ll_control(&sc->sc_capi, CAPI_CTRL_READY, TRUE);
-    }
-
-    return 0;
-}
-
-static int iavc_receive_stop(iavc_softc_t *sc, u_int8_t *dmabuf)
-{
-    printf("iavc%d: receive_stop\n", sc->sc_unit);
-    sc->sc_blocked = TRUE;
-    return 0;
-}
-
-static int iavc_receive_new_ncci(iavc_softc_t *sc, u_int8_t *dmabuf)
-{
-    u_int32_t ApplId, NCCI, WindowSize;
-
-    if (sc->sc_dma) {
-	dmabuf = amcc_get_word(dmabuf, &ApplId);
-	dmabuf = amcc_get_word(dmabuf, &NCCI);
-	dmabuf = amcc_get_word(dmabuf, &WindowSize);
-    } else {
-	ApplId = iavc_get_word(sc);
-	NCCI   = iavc_get_word(sc);
-	WindowSize = iavc_get_word(sc);
-    }
-
-    capi_ll_control(&sc->sc_capi, CAPI_CTRL_NEW_NCCI, NCCI);
-    return 0;
-}
-
-static int iavc_receive_free_ncci(iavc_softc_t *sc, u_int8_t *dmabuf)
-{
-    u_int32_t ApplId, NCCI;
-
-    if (sc->sc_dma) {
-	dmabuf = amcc_get_word(dmabuf, &ApplId);
-	dmabuf = amcc_get_word(dmabuf, &NCCI);
-    } else {
-	ApplId = iavc_get_word(sc);
-	NCCI   = iavc_get_word(sc);
-    }
-
-    capi_ll_control(&sc->sc_capi, CAPI_CTRL_FREE_NCCI, NCCI);
-    return 0;
-}
-
-static int iavc_receive_task_ready(iavc_softc_t *sc, u_int8_t *dmabuf)
-{
-    u_int32_t TaskId, Length;
-    u_int8_t *p;
-    printf("iavc%d: receive_task_ready\n", sc->sc_unit);
-    
-    if (sc->sc_dma) {
-	p = amcc_get_word(dmabuf, &TaskId);
-	p = amcc_get_word(p, &Length);
-    } else {
-	TaskId = iavc_get_word(sc);
-	Length = iavc_get_slice(sc, sc->sc_recvbuf);
-	p = sc->sc_recvbuf;
-    }
-
-    /* XXX could show the message if trace enabled? XXX */
-    return 0;
-}
-
-static int iavc_receive_debugmsg(iavc_softc_t *sc, u_int8_t *dmabuf)
-{
-    u_int32_t Length;
-    u_int8_t *p;
-    printf("iavc%d: receive_debugmsg\n", sc->sc_unit);
-    
-    if (sc->sc_dma) {
-	p = amcc_get_word(dmabuf, &Length);
-    } else {
-	Length = iavc_get_slice(sc, sc->sc_recvbuf);
-	p = sc->sc_recvbuf;
-    }
-
-    /* XXX could show the message if trace enabled? XXX */
-    return 0;
-}
-
-static int iavc_receive(iavc_softc_t *sc, u_int8_t *dmabuf, int b3data)
-{
-    struct mbuf *m;
-    u_int32_t ApplId, Length;
-
-    /*
-     * byte  0x21 = RECEIVE_MESSAGE
-     * dword ApplId
-     * dword length
-     * ...   CAPI msg
-     *
-     * --or--
-     *
-     * byte  0x22 = RECEIVE_DATA_B3_IND
-     * dword ApplId
-     * dword length
-     * ...   CAPI msg
-     * dword datalen
-     * ...   B3 data
-     */
-
-    if (sc->sc_dma) {
-	dmabuf = amcc_get_word(dmabuf, &ApplId);
-	dmabuf = amcc_get_word(dmabuf, &Length);
-    } else {
-	ApplId = iavc_get_word(sc);
-	Length = iavc_get_slice(sc, sc->sc_recvbuf);
-	dmabuf = sc->sc_recvbuf;
-    }
-
-    m = i4b_Dgetmbuf(Length);
-    if (!m) {
-	printf("iavc%d: can't get memory for receive\n", sc->sc_unit);
-	return (ENOMEM);
-    }
-
-    bcopy(dmabuf, mtod(m, u_int8_t*), Length);
-
-#if 0
-	{
-	    u_int8_t *p = mtod(m, u_int8_t*);
-	    int len = 0;
-	    printf("iavc%d: applid=%d, len=%d\n", sc->sc_unit, ApplId, Length);
-	    while (len < m->m_len) {
-		printf(" %02x", p[len]);
-		if (len && (len % 16) == 0) printf("\n");
-		len++;
-	    }
-	    if (len % 16) printf("\n");
-	}
-#endif
-
-    if (b3data) {
-	if (sc->sc_dma) {
-	    dmabuf = amcc_get_word(dmabuf + Length, &Length);
-	} else {
-	    Length = iavc_get_slice(sc, sc->sc_recvbuf);
-	    dmabuf = sc->sc_recvbuf;
-	}
-
-	m->m_next = i4b_Bgetmbuf(Length);
-	if (!m->m_next) {
-	    printf("iavc%d: can't get memory for receive\n", sc->sc_unit);
-	    i4b_Dfreembuf(m);
-	    return (ENOMEM);
-	}
-
-	bcopy(dmabuf, mtod(m->m_next, u_int8_t*), Length);
-    }
-
-    capi_ll_receive(&sc->sc_capi, m);
-    return 0;
-}
-
-/*
-//  iavc_handle_intr
-//      Checks device interrupt status and calls iavc_handle_{rx,tx}()
-//      as necessary.
-//
-//  iavc_handle_rx
-//      Reads in the command byte and calls the subroutines above.
-//
-//  iavc_start_tx
-//      Initiates DMA on the next queued message if possible.
-*/
-
-void iavc_handle_intr(iavc_softc_t *sc)
-{
-    u_int32_t status;
-    u_int32_t newcsr;
-
-    if (!sc->sc_dma) {
-	while (iavc_rx_full(sc))
-	    iavc_handle_rx(sc);
-	return;
-    }
-
-    status = AMCC_READ(sc, AMCC_INTCSR);
-    if ((status & ANY_S5933_INT) == 0)
-	return;
-
-    newcsr = sc->sc_csr | (status & ALL_INT);
-    if (status & TX_TC_INT) newcsr &= ~EN_TX_TC_INT;
-    if (status & RX_TC_INT) newcsr &= ~EN_RX_TC_INT;
-    AMCC_WRITE(sc, AMCC_INTCSR, newcsr);
-    sc->sc_intr = TRUE;
-
-    if (status & RX_TC_INT) {
-	u_int32_t rxlen;
-
-	if (sc->sc_recvlen == 0) {
-	    sc->sc_recvlen = *((u_int32_t*)(&sc->sc_recvbuf[0]));
-	    rxlen = (sc->sc_recvlen + 3) & ~3;
-	    AMCC_WRITE(sc, AMCC_RXPTR, vtophys(&sc->sc_recvbuf[4]));
-	    AMCC_WRITE(sc, AMCC_RXLEN, rxlen);
-	} else {
-	    iavc_handle_rx(sc);
-	    sc->sc_recvlen = 0;
-	    AMCC_WRITE(sc, AMCC_RXPTR, vtophys(&sc->sc_recvbuf[0]));
-	    AMCC_WRITE(sc, AMCC_RXLEN, 4);
-	}
-    }
-
-    if (status & TX_TC_INT) {
-	sc->sc_csr &= ~EN_TX_TC_INT;
-	iavc_start_tx(sc);
-    }
-
-    AMCC_WRITE(sc, AMCC_INTCSR, sc->sc_csr);
-    sc->sc_intr = FALSE;
-}
-
-static void iavc_handle_rx(iavc_softc_t *sc)
-{
-    u_int8_t *dmabuf = 0, cmd;
-
-    if (sc->sc_dma) {
-	dmabuf = amcc_get_byte(&sc->sc_recvbuf[4], &cmd);
-    } else {
-	cmd = iavc_get_byte(sc);
-    }
-
-    NDBGL4(L4_IAVCDBG, "iavc%d: command = 0x%02x", sc->sc_unit, cmd);
-    
-    switch (cmd) {
-    case RECEIVE_DATA_B3_IND:
-	iavc_receive(sc, dmabuf, TRUE);
-	break;
-
-    case RECEIVE_MESSAGE:
-	iavc_receive(sc, dmabuf, FALSE);
-	break;
-
-    case RECEIVE_NEW_NCCI:
-	iavc_receive_new_ncci(sc, dmabuf);
-	break;
-
-    case RECEIVE_FREE_NCCI:
-	iavc_receive_free_ncci(sc, dmabuf);
-	break;
-
-    case RECEIVE_START:
-	iavc_receive_start(sc, dmabuf);
-	break;
-
-    case RECEIVE_STOP:
-	iavc_receive_stop(sc, dmabuf);
-	break;
-
-    case RECEIVE_INIT:
-	iavc_receive_init(sc, dmabuf);
-	break;
-
-    case RECEIVE_TASK_READY:
-	iavc_receive_task_ready(sc, dmabuf);
-	break;
-
-    case RECEIVE_DEBUGMSG:
-	iavc_receive_debugmsg(sc, dmabuf);
-	break;
-
-    default:
-	printf("iavc%d: unknown msg %02x\n", sc->sc_unit, cmd);
-    }
-}
-
-static void iavc_start_tx(iavc_softc_t *sc)
-{
-    struct mbuf *m;
-    u_int8_t *dmabuf;
-    u_int32_t txlen = 0;
-    
-    /* If device has put us on hold, punt. */
-
-    if (sc->sc_blocked) {
-	return;
-    }
-
-    /* If using DMA and transmitter busy, punt. */
-    
-    if (sc->sc_dma && (sc->sc_csr & EN_TX_TC_INT)) {
-	return;
-    }
-
-    /* Else, see if we have messages to send. */
-
-    _IF_DEQUEUE(&sc->sc_txq, m);
-    if (!m) {
-	return;
-    }
-
-    /* Have message, will send. */
-
-    if (CAPIMSG_LEN(m->m_data)) {
-	/* A proper CAPI message, possibly with B3 data */
-
-	if (sc->sc_dma) {
-	    /* Copy message to DMA buffer. */
-
-	    if (m->m_next) {
-		dmabuf = amcc_put_byte(&sc->sc_sendbuf[0], SEND_DATA_B3_REQ);
-	    } else {
-		dmabuf = amcc_put_byte(&sc->sc_sendbuf[0], SEND_MESSAGE);
-	    }
-
-	    dmabuf = amcc_put_word(dmabuf, m->m_len);
-	    bcopy(m->m_data, dmabuf, m->m_len);
-	    dmabuf += m->m_len;
-	    txlen = 5 + m->m_len;
-
-	    if (m->m_next) {
-		dmabuf = amcc_put_word(dmabuf, m->m_next->m_len);
-		bcopy(m->m_next->m_data, dmabuf, m->m_next->m_len);
-		txlen += 4 + m->m_next->m_len;
-	    }
-
-	} else {
-	    /* Use PIO. */
-
-	    if (m->m_next) {
-		iavc_put_byte(sc, SEND_DATA_B3_REQ);
-		NDBGL4(L4_IAVCDBG, "iavc%d: tx SDB3R msg, len = %d", sc->sc_unit, m->m_len);
-	    } else {
-		iavc_put_byte(sc, SEND_MESSAGE);
-		NDBGL4(L4_IAVCDBG, "iavc%d: tx SM msg, len = %d", sc->sc_unit, m->m_len);
-	    }
-#if 0
-    {
-	u_int8_t *p = mtod(m, u_int8_t*);
-	int len;
-	for (len = 0; len < m->m_len; len++) {
-	    printf(" %02x", *p++);
-	    if (len && (len % 16) == 0) printf("\n");
-	}
-	if (len % 16) printf("\n");
-    }
-#endif
-
-	    iavc_put_slice(sc, m->m_data, m->m_len);
-
-	    if (m->m_next) {
-		iavc_put_slice(sc, m->m_next->m_data, m->m_next->m_len);
-	    }
-	}
-
-    } else {
-	/* A board control message to be sent as is */
-
-	if (sc->sc_dma) {
-	    bcopy(m->m_data + 2, &sc->sc_sendbuf[0], m->m_len - 2);
-	    txlen = m->m_len - 2;
-
-	} else {
-#if 0
-    {
-	u_int8_t *p = mtod(m, u_int8_t*) + 2;
-	int len;
-	printf("iavc%d: tx BDC msg, len = %d, msg =", sc->sc_unit, m->m_len-2);
-	for (len = 0; len < m->m_len-2; len++) {
-	    printf(" %02x", *p++);
-	    if (len && (len % 16) == 0) printf("\n");
-	}
-	if (len % 16) printf("\n");
-    }
-#endif
-
-	    txlen = m->m_len - 2;
-	    dmabuf = mtod(m, char*) + 2;
-	    while(txlen--)
-	    	b1io_put_byte(sc, *dmabuf++);
-	}
-    }
-
-    if (m->m_next) {
-	i4b_Bfreembuf(m->m_next);
-	m->m_next = NULL;
-    }
-    i4b_Dfreembuf(m);
-
-    if (sc->sc_dma) {
-	/* Start transmitter */
-
-	txlen = (txlen + 3) & ~3;
-	AMCC_WRITE(sc, AMCC_TXPTR, vtophys(&sc->sc_sendbuf[0]));
-	AMCC_WRITE(sc, AMCC_TXLEN, txlen);
-	sc->sc_csr |= EN_TX_TC_INT;
-
-	if (!sc->sc_intr)
-	    AMCC_WRITE(sc, AMCC_INTCSR, sc->sc_csr);
-    }
-}
-
-int t1io_get_slice(iavc_softc_t *sc, u_int8_t *dp)
-{
-    int len, i;
-    len = i = b1io_get_word(sc);
-    if (t1io_isfastlink(sc)) {
-	int status;
-	while (i) {
-	    status = t1io_fifostatus(sc) & (T1F_IREADY|T1F_IHALF);
-	    if (i >= FIFO_INPBSIZE) status |= T1F_IFULL;
-
-	    switch (status) {
-	    case T1F_IREADY|T1F_IHALF|T1F_IFULL:
-		bus_space_read_multi_1(sc->sc_io_bt, sc->sc_io_bh,
-				       T1_READ, dp, FIFO_INPBSIZE);
-		dp += FIFO_INPBSIZE;
-		i -= FIFO_INPBSIZE;
-		break;
-
-	    case T1F_IREADY|T1F_IHALF:
-		bus_space_read_multi_1(sc->sc_io_bt, sc->sc_io_bh,
-				       T1_READ, dp, i);
-		dp += i;
-		i = 0;
-		break;
-
-	    default:
-		*dp++ = b1io_get_byte(sc);
-		i--;
-	    }
-	}
-    } else { /* not fastlink */
-	if (i--) *dp++ = b1io_get_byte(sc);
-    }
-    return len;
-}
-
-void t1io_put_slice(iavc_softc_t *sc, u_int8_t *dp, int len)
-{
-    int i = len;
-    b1io_put_word(sc, i);
-    if (t1io_isfastlink(sc)) {
-	int status;
-	while (i) {
-	    status = t1io_fifostatus(sc) & (T1F_OREADY|T1F_OHALF);
-	    if (i >= FIFO_OUTBSIZE) status |= T1F_OFULL;
-
-	    switch (status) {
-	    case T1F_OREADY|T1F_OHALF|T1F_OFULL:
-		bus_space_write_multi_1(sc->sc_io_bt, sc->sc_io_bh,
-					T1_WRITE, dp, FIFO_OUTBSIZE);
-		dp += FIFO_OUTBSIZE;
-		i -= FIFO_OUTBSIZE;
-		break;
-
-	    case T1F_OREADY|T1F_OHALF:
-		bus_space_write_multi_1(sc->sc_io_bt, sc->sc_io_bh,
-					T1_WRITE, dp, i);
-		dp += i;
-		i = 0;
-		break;
-
-	    default:
-		b1io_put_byte(sc, *dp++);
-		i--;
-	    }
-	}
-    } else {
-	while (i--) b1io_put_byte(sc, *dp++);
-    }
-}
-
-u_int32_t b1io_get_word(iavc_softc_t *sc)
-{
-    u_int32_t val = 0;
-    val |= b1io_get_byte(sc);
-    val |= (b1io_get_byte(sc) << 8);
-    val |= (b1io_get_byte(sc) << 16);
-    val |= (b1io_get_byte(sc) << 24);
-    return val;
-}
-
-void b1io_put_word(iavc_softc_t *sc, u_int32_t val)
-{
-    b1io_put_byte(sc, (val & 0xff));
-    b1io_put_byte(sc, (val >> 8) & 0xff);
-    b1io_put_byte(sc, (val >> 16) & 0xff);
-    b1io_put_byte(sc, (val >> 24) & 0xff);
-}
-
-int b1io_get_slice(iavc_softc_t *sc, u_int8_t *dp)
-{
-    int len, i;
-    len = i = b1io_get_word(sc);
-    while (i--) *dp++ = b1io_get_byte(sc);
-    return len;
-}
-
-void b1io_put_slice(iavc_softc_t *sc, u_int8_t *dp, int len)
-{
-    b1io_put_word(sc, len);
-    while (len--) b1io_put_byte(sc, *dp++);
-}
-
-u_int32_t b1io_read_reg(iavc_softc_t *sc, int reg)
-{
-    b1io_put_byte(sc, READ_REGISTER);
-    b1io_put_word(sc, reg);
-    return b1io_get_word(sc);
-}
-
-u_int32_t b1io_write_reg(iavc_softc_t *sc, int reg, u_int32_t val)
-{
-    b1io_put_byte(sc, WRITE_REGISTER);
-    b1io_put_word(sc, reg);
-    b1io_put_word(sc, val);
-    return b1io_get_word(sc);
-}
-
-u_int8_t b1io_get_byte(iavc_softc_t *sc)
-{
-    int spin = 0;
-    while (!b1io_rx_full(sc) && spin < B1IO_WAIT_MAX) {
-	spin++; DELAY(B1IO_WAIT_DLY);
-    }
-    if (b1io_rx_full(sc))
-	return bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, B1_READ);
-    printf("iavc%d: rx not completed\n", sc->sc_unit);
-    return 0xff;
-}
-
-int b1io_put_byte(iavc_softc_t *sc, u_int8_t val)
-{
-    int spin = 0;
-    while (!b1io_tx_empty(sc) && spin < B1IO_WAIT_MAX) {
-	spin++; DELAY(B1IO_WAIT_DLY);
-    }
-    if (b1io_tx_empty(sc)) {
-	bus_space_write_1(sc->sc_io_bt, sc->sc_io_bh, B1_WRITE, val);
-	return 0;
-    }
-    printf("iavc%d: tx not emptied\n", sc->sc_unit);
-    return -1;
-}
-
-int b1io_save_put_byte(iavc_softc_t *sc, u_int8_t val)
-{
-    int spin = 0;
-    while (!b1io_tx_empty(sc) && spin < B1IO_WAIT_MAX) {
-	spin++; DELAY(B1IO_WAIT_DLY);
-    }
-    if (b1io_tx_empty(sc)) {
-	b1io_outp(sc, B1_WRITE, val);
-	return 0;
-    }
-    printf("iavc%d: tx not emptied\n", sc->sc_unit);
-    return -1;
-}
--- sys/i4b/capi/iavc/iavc.h
+++ /dev/null
@@ -1,446 +0,0 @@
-/*-
- * Copyright (c) 2001 Cubical Solutions Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* capi/iavc/iavc.h	The AVM ISDN controllers' common declarations.
- *
- * $FreeBSD: src/sys/i4b/capi/iavc/iavc.h,v 1.3 2005/01/06 22:18:18 imp Exp $
- */
-
-#ifndef _CAPI_IAVC_H_
-#define _CAPI_IAVC_H_
-
-/* max 4 units supported per machine */
-
-#define IAVC_MAXUNIT 4
-
-/*
-//  iavc_softc_t
-//      The software context of one AVM T1 controller.
-*/
-
-#define IAVC_IO_BASES 1
-
-typedef struct i4b_info {
-    struct resource * io_base[IAVC_IO_BASES];
-    int               io_rid [IAVC_IO_BASES];
-    struct resource * irq;
-    int               irq_rid;
-    struct resource * mem;
-    int               mem_rid;
-} i4b_info_t;
-
-typedef struct iavc_softc {
-    capi_softc_t        sc_capi;
-    int		        sc_unit;
-    int		        sc_cardtyp;
-
-    u_int32_t           sc_membase;
-    bus_space_handle_t  sc_mem_bh;
-    bus_space_tag_t     sc_mem_bt;
-    u_int32_t	        sc_iobase;
-    bus_space_handle_t  sc_io_bh;
-    bus_space_tag_t     sc_io_bt;
-
-    int                 sc_state;
-#define IAVC_DOWN       0
-#define IAVC_POLL       1
-#define IAVC_INIT       2
-#define IAVC_UP         3
-    int                 sc_blocked;
-    int                 sc_dma;
-    int                 sc_t1;
-    int                 sc_intr;
-
-    u_int32_t           sc_csr;
-
-    char                sc_sendbuf[128+2048];
-    char                sc_recvbuf[128+2048];
-    int                 sc_recvlen;
-
-    struct ifqueue      sc_txq;
-
-    i4b_info_t	        sc_resources;
-} iavc_softc_t;
-
-extern iavc_softc_t iavc_sc[];
-
-#define iavc_find_sc(unit)	(&iavc_sc[(unit)])
-
-/*
-//  {b1,b1dma,t1}_{detect,reset}
-//      Routines to detect and manage the specific type of card.
-*/
-
-extern int      b1_detect(iavc_softc_t *sc);
-extern void     b1_disable_irq(iavc_softc_t *sc);
-extern void     b1_reset(iavc_softc_t *sc);
-
-extern int      b1dma_detect(iavc_softc_t *sc);
-extern void     b1dma_reset(iavc_softc_t *sc);
-
-extern int      t1_detect(iavc_softc_t *sc);
-extern void     t1_disable_irq(iavc_softc_t *sc);
-extern void     t1_reset(iavc_softc_t *sc);
-
-/*
-//  AMCC_{READ,WRITE}
-//      Routines to access the memory mapped registers of the
-//      S5933 DMA controller.
-*/
-
-static __inline u_int32_t AMCC_READ(iavc_softc_t *sc, int off)
-{
-    return bus_space_read_4(sc->sc_mem_bt, sc->sc_mem_bh, off);
-}
-
-static __inline void AMCC_WRITE(iavc_softc_t *sc, int off, u_int32_t value)
-{
-    bus_space_write_4(sc->sc_mem_bt, sc->sc_mem_bh, off, value);
-}
-
-/*
-//  amcc_{put,get}_{byte,word}
-//      Routines to access the DMA buffers byte- or wordwise.
-*/
-
-static __inline u_int8_t* amcc_put_byte(u_int8_t *buf, u_int8_t value)
-{
-    *buf++ = value;
-    return buf;
-}
-
-static __inline u_int8_t* amcc_get_byte(u_int8_t *buf, u_int8_t *value)
-{
-    *value = *buf++;
-    return buf;
-}
-
-static __inline u_int8_t* amcc_put_word(u_int8_t *buf, u_int32_t value)
-{
-    *buf++ = (value & 0xff);
-    *buf++ = (value >> 8) & 0xff;
-    *buf++ = (value >> 16) & 0xff;
-    *buf++ = (value >> 24) & 0xff;
-    return buf;
-}
-
-static __inline u_int8_t* amcc_get_word(u_int8_t *buf, u_int32_t *value)
-{
-    *value = *buf++;
-    *value |= (*buf++ << 8);
-    *value |= (*buf++ << 16);
-    *value |= (*buf++ << 24);
-    return buf;
-}
-
-/*
-//  Controller LLI message numbers.
-*/
-
-#define SEND_POLL           0x72
-#define SEND_INIT           0x11
-#define SEND_REGISTER       0x12
-#define SEND_DATA_B3_REQ    0x13
-#define SEND_RELEASE        0x14
-#define SEND_MESSAGE        0x15
-#define SEND_CONFIG         0x71
-#define SEND_POLLACK        0x73
-
-#define RECEIVE_POLL        0x32
-#define RECEIVE_INIT        0x27
-#define RECEIVE_MESSAGE     0x21
-#define RECEIVE_DATA_B3_IND 0x22
-#define RECEIVE_START       0x23
-#define RECEIVE_STOP        0x24
-#define RECEIVE_NEW_NCCI    0x25
-#define RECEIVE_FREE_NCCI   0x26
-#define RECEIVE_RELEASE     0x26
-#define RECEIVE_TASK_READY  0x31
-#define RECEIVE_DEBUGMSG    0x71
-#define RECEIVE_POLLDWORD   0x75
-
-/* Operation constants */
-
-#define WRITE_REGISTER      0x00
-#define READ_REGISTER       0x01
-
-/* Port offsets in I/O space */
-
-#define B1_READ             0x00
-#define B1_WRITE            0x01
-#define B1_INSTAT           0x02
-#define B1_OUTSTAT          0x03
-#define B1_ANALYSE          0x04
-#define B1_REVISION         0x05
-#define B1_RESET            0x10
-
-#define T1_FASTLINK         0x00
-#define T1_SLOWLINK         0x08
-
-#define T1_READ             B1_READ
-#define T1_WRITE            B1_WRITE
-#define T1_INSTAT           B1_INSTAT
-#define T1_OUTSTAT          B1_OUTSTAT
-#define T1_IRQENABLE        0x05
-#define T1_FIFOSTAT         0x06
-#define T1_RESETLINK        0x10
-#define T1_ANALYSE          0x11
-#define T1_IRQMASTER        0x12
-#define T1_IDENT            0x17
-#define T1_RESETBOARD       0x1f
-
-#define T1F_IREADY          0x01
-#define T1F_IHALF           0x02
-#define T1F_IFULL           0x04
-#define T1F_IEMPTY          0x08
-#define T1F_IFLAGS          0xf0
-
-#define T1F_OREADY          0x10
-#define T1F_OHALF           0x20
-#define T1F_OEMPTY          0x40
-#define T1F_OFULL           0x80
-#define T1F_OFLAGS          0xf0
-
-#define FIFO_OUTBSIZE       256
-#define FIFO_INPBSIZE       512
-
-#define HEMA_VERSION_ID     0
-#define HEMA_PAL_ID         0
-
-/*
-//  S5933 DMA controller register offsets in memory, and bitmasks.
-*/
-
-#define AMCC_RXPTR       0x24
-#define AMCC_RXLEN       0x28
-#define AMCC_TXPTR       0x2c
-#define AMCC_TXLEN       0x30
-
-#define AMCC_INTCSR      0x38
-#define EN_READ_TC_INT   0x00008000
-#define EN_WRITE_TC_INT  0x00004000
-#define EN_TX_TC_INT     EN_READ_TC_INT
-#define EN_RX_TC_INT     EN_WRITE_TC_INT
-#define AVM_FLAG         0x30000000
-
-#define ANY_S5933_INT    0x00800000
-#define READ_TC_INT      0x00080000
-#define WRITE_TC_INT     0x00040000
-#define TX_TC_INT        READ_TC_INT
-#define RX_TC_INT        WRITE_TC_INT
-#define MASTER_ABORT_INT 0x00100000
-#define TARGET_ABORT_INT 0x00200000
-#define BUS_MASTER_INT   0x00200000
-#define ALL_INT          0x000c0000
-
-#define AMCC_MCSR        0x3c
-#define A2P_HI_PRIORITY  0x00000100
-#define EN_A2P_TRANSFERS 0x00000400
-#define P2A_HI_PRIORITY  0x00001000
-#define EN_P2A_TRANSFERS 0x00004000
-#define RESET_A2P_FLAGS  0x04000000
-#define RESET_P2A_FLAGS  0x02000000
-
-/*
-//  (B1IO_WAIT_MAX * B1IO_WAIT_DLY) is the max wait in us for the card
-//  to become ready after an I/O operation. The default is 1 ms.
-*/
-
-#define B1IO_WAIT_MAX    1000
-#define B1IO_WAIT_DLY    1
-
-/*
-//  b1io_outp
-//      Diagnostic output routine, returns the written value via
-//      the device's analysis register.
-//
-//  b1io_rx_full
-//      Returns nonzero if data is readable from the card via the
-//      I/O ports.
-//
-//  b1io_tx_empty
-//      Returns nonzero if data can be written to the card via the
-//      I/O ports.
-*/
-
-static __inline u_int8_t b1io_outp(iavc_softc_t *sc, int off, u_int8_t val)
-{
-    bus_space_write_1(sc->sc_io_bt, sc->sc_io_bh, off, val);
-    DELAY(1);
-    return bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, B1_ANALYSE);
-}
-
-static __inline int b1io_rx_full(iavc_softc_t *sc)
-{
-    u_int8_t val = bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, B1_INSTAT);
-    return (val & 0x01);
-}
-
-static __inline int b1io_tx_empty(iavc_softc_t *sc)
-{
-    u_int8_t val = bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, B1_OUTSTAT);
-    return  (val & 0x01);
-}
-
-/*
-//  b1io_{get,put}_{byte,word}
-//      Routines to read and write the device I/O registers byte- or
-//      wordwise.
-//
-//  b1io_{get,put}_slice
-//      Routines to read and write sequential bytes to the device
-//      I/O registers.
-*/
-
-u_int8_t b1io_get_byte(iavc_softc_t *sc);
-int b1io_put_byte(iavc_softc_t *sc, u_int8_t val);
-
-int b1io_save_put_byte(iavc_softc_t *sc, u_int8_t val);
-
-u_int32_t b1io_get_word(iavc_softc_t *sc);
-void b1io_put_word(iavc_softc_t *sc, u_int32_t val);
-
-int b1io_get_slice(iavc_softc_t *sc, u_int8_t *dp);
-void b1io_put_slice(iavc_softc_t *sc, u_int8_t *dp, int len);
-
-/*
-//  b1io_{read,write}_reg
-//      Routines to read and write the device registers via the I/O
-//      ports.
-*/
-
-u_int32_t b1io_read_reg(iavc_softc_t *sc, int reg);
-u_int32_t b1io_write_reg(iavc_softc_t *sc, int reg, u_int32_t val);
-
-/*
-//  t1io_outp
-//      I/O port write operation for the T1, which does not seem
-//      to have the analysis port.
-*/
-
-static __inline void t1io_outp(iavc_softc_t *sc, int off, u_int8_t val)
-{
-    bus_space_write_1(sc->sc_io_bt, sc->sc_io_bh, off, val);
-}
-
-static __inline u_int8_t t1io_inp(iavc_softc_t *sc, int off)
-{
-    return bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, off);
-}
-
-static __inline int t1io_isfastlink(iavc_softc_t *sc)
-{
-    return ((bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, T1_IDENT) & ~0x82) == 1);
-}
-
-static __inline u_int8_t t1io_fifostatus(iavc_softc_t *sc)
-{
-    return bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, T1_FIFOSTAT);
-}
-
-int t1io_get_slice(iavc_softc_t *sc, u_int8_t *dp);
-void t1io_put_slice(iavc_softc_t *sc, u_int8_t *dp, int len);
-
-/*
-//  An attempt to bring it all together:
-//  ------------------------------------
-//
-//  iavc_{read,write}_reg
-//      Routines to access the device registers via the I/O port.
-//
-//  iavc_{read,write}_port
-//      Routines to access the device I/O ports.
-//
-//  iavc_tx_empty, iavc_rx_full
-//      Routines to check when the device has drained the last written
-//      byte, or produced a full byte to read.
-//
-//  iavc_{get,put}_byte
-//      Routines to read/write byte values to the device via the I/O port.
-//
-//  iavc_{get,put}_word
-//      Routines to read/write 32-bit words to the device via the I/O port.
-//
-//  iavc_{get,put}_slice
-//      Routines to read/write {length, data} pairs to the device via the
-//      ubiquituous I/O port. Uses the HEMA FIFO on a T1.
-*/
-
-#define iavc_read_reg(sc, reg) b1io_read_reg(sc, reg)
-#define iavc_write_reg(sc, reg, val) b1io_write_reg(sc, reg, val)
-
-#define iavc_read_port(sc, port) \
-        bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, (port))
-#define iavc_write_port(sc, port, val) \
-        bus_space_write_1(sc->sc_io_bt, sc->sc_io_bh, (port), (val))
-
-#define iavc_tx_empty(sc)      b1io_tx_empty(sc)
-#define iavc_rx_full(sc)       b1io_rx_full(sc)
-
-#define iavc_get_byte(sc)      b1io_get_byte(sc)
-#define iavc_put_byte(sc, val) b1io_put_byte(sc, val)
-#define iavc_get_word(sc)      b1io_get_word(sc)
-#define iavc_put_word(sc, val) b1io_put_word(sc, val)
-
-static __inline u_int32_t iavc_get_slice(iavc_softc_t *sc, u_int8_t *dp)
-{
-    if (sc->sc_t1) return t1io_get_slice(sc, dp);
-    else return b1io_get_slice(sc, dp);
-}
-
-static __inline void iavc_put_slice(iavc_softc_t *sc, u_int8_t *dp, int len)
-{
-    if (sc->sc_t1) t1io_put_slice(sc, dp, len);
-    else b1io_put_slice(sc, dp, len);
-}
-
-/*
-//  iavc_handle_intr
-//      Interrupt handler, called by the bus specific interrupt routine
-//      in iavc_<bustype>.c module.
-//
-//  iavc_load
-//      CAPI callback. Resets device and loads firmware.
-//
-//  iavc_register
-//      CAPI callback. Registers an application id.
-//
-//  iavc_release
-//      CAPI callback. Releases an application id.
-//
-//  iavc_send
-//      CAPI callback. Sends a CAPI message. A B3_DATA_REQ message has
-//      m_next point to a data mbuf.
-*/
-
-extern void iavc_handle_intr(iavc_softc_t *);
-extern int iavc_load(capi_softc_t *, int, u_int8_t *);
-extern int iavc_register(capi_softc_t *, int, int);
-extern int iavc_release(capi_softc_t *, int);
-extern int iavc_send(capi_softc_t *, struct mbuf *);
-
-extern void b1isa_setup_irq(struct iavc_softc *sc);
-
-#endif /* _CAPI_IAVC_H_ */
--- sys/i4b/capi/iavc/iavc_isa.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/*-
- * Copyright (c) 2001, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/capi/iavc/iavc_isa.c,v 1.9 2005/01/06 22:18:18 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/clock.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <isa/isavar.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/capi/capi.h>
-
-#include <i4b/capi/iavc/iavc.h>
-
-/* ISA driver linkage */
-
-static void iavc_isa_intr(iavc_softc_t *sc);
-static int iavc_isa_probe(device_t dev);
-static int iavc_isa_attach(device_t dev);
-
-static device_method_t iavc_isa_methods[] =
-{
-    DEVMETHOD(device_probe,	iavc_isa_probe),
-    DEVMETHOD(device_attach,	iavc_isa_attach),
-    { 0, 0 }
-};
-
-static driver_t iavc_isa_driver =
-{
-    "iavc",
-    iavc_isa_methods,
-    0
-};
-
-static devclass_t iavc_isa_devclass;
-
-DRIVER_MODULE(iavc, isa, iavc_isa_driver, iavc_isa_devclass, 0, 0);
-
-#define B1_IOLENGTH	0x20
-
-static int b1_irq_table[] =
-{0, 0, 0, 192, 32, 160, 96, 224, 0, 64, 80, 208, 48, 0, 0, 112};
-/*        3    4   5    6   7       9   10  11   12        15 */
-
-/*---------------------------------------------------------------------------*
- *	device probe
- *---------------------------------------------------------------------------*/
-
-static int
-iavc_isa_probe(device_t dev)
-{
-	struct iavc_softc *sc;
-	int ret = ENXIO;
-	int unit = device_get_unit(dev);
-	
-	if(isa_get_vendorid(dev))	/* no PnP probes here */
-		return ENXIO;
-
-	/* check max unit range */
-	
-	if (unit >= IAVC_MAXUNIT)
-	{
-		printf("iavc%d: too many units\n", unit);
-		return(ENXIO);	
-	}
-
-	sc = iavc_find_sc(unit);	/* get softc */	
-	
-	sc->sc_unit = unit;
-
-	if (!(sc->sc_resources.io_base[0] =
-		bus_alloc_resource(dev, SYS_RES_IOPORT,
-			&sc->sc_resources.io_rid[0],
-			0UL, ~0UL, B1_IOLENGTH, RF_ACTIVE)))
-	{
-		printf("iavc%d: can't allocate io region\n", unit);
-		return(ENXIO);                                       
-	}
-
-	sc->sc_iobase = rman_get_start(sc->sc_resources.io_base[0]);
-
-	switch(sc->sc_iobase)
-	{
-		case 0x150:
-		case 0x250:
-		case 0x300:
-		case 0x340:
-			break;
-		default:
-			printf("iavc%d: ERROR, invalid i/o base addr 0x%x configured!\n", sc->sc_unit, sc->sc_iobase);
-			bus_release_resource(dev, SYS_RES_IOPORT,
-					sc->sc_resources.io_rid[0],
-		                        sc->sc_resources.io_base[0]);
-		return(ENXIO);
-	}	
-	
-	sc->sc_io_bt = rman_get_bustag(sc->sc_resources.io_base[0]);
-	sc->sc_io_bh = rman_get_bushandle(sc->sc_resources.io_base[0]);
-
-	/* setup characteristics */
-
-	sc->sc_t1 = FALSE;
-	sc->sc_dma = FALSE;
-
-	sc->sc_capi.card_type = CARD_TYPEC_AVM_B1_ISA;
-	sc->sc_capi.sc_nbch = 2;
-
-	b1_reset(sc);
-	DELAY(100);
-
-	ret = b1_detect(sc);
-
-	if(ret)
-	{
-		printf("iavc%d: no card ? b1_detect returns %0x02x\n",
-			sc->sc_unit, ret);
-		return(ENXIO);
-	}
-
-	DELAY(100);
-
-	b1_reset(sc);
-	
-	DELAY(100);
-
-	if(bootverbose)
-	{
-		printf("iavc%d: class = 0x%02x, rev = 0x%02x\n", sc->sc_unit,
-			iavc_read_port(sc, B1_ANALYSE),
-			iavc_read_port(sc, B1_REVISION));
-	}
-
-	device_set_desc(dev, "AVM B1 ISA");
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	attach
- *---------------------------------------------------------------------------*/
-static int
-iavc_isa_attach(device_t dev)
-{
-	struct iavc_softc *sc;
-	void *ih = 0;
-	int unit = device_get_unit(dev);
-	int irq;
-	
-	sc = iavc_find_sc(unit);	/* get softc */	
-	
-	sc->sc_resources.irq_rid = 0;
-	
-	if(!(sc->sc_resources.irq =
-		bus_alloc_resource_any(dev, SYS_RES_IRQ,
-			&sc->sc_resources.irq_rid, RF_ACTIVE)))
-	{
-		printf("iavc%d: can't allocate irq\n",unit);
-		bus_release_resource(dev, SYS_RES_IOPORT,
-				sc->sc_resources.io_rid[0],
-	                        sc->sc_resources.io_base[0]);
-		return(ENXIO);
-	}
-
-	irq = rman_get_start(sc->sc_resources.irq);
-
-	if(b1_irq_table[irq] == 0)
-	{
-		printf("iavc%d: ERROR, illegal irq %d configured!\n",unit, irq);
-		bus_release_resource(dev, SYS_RES_IOPORT,
-				sc->sc_resources.io_rid[0],
-	                        sc->sc_resources.io_base[0]);
-		bus_release_resource(dev, SYS_RES_IRQ,
-				sc->sc_resources.irq_rid,
-				sc->sc_resources.irq);
-		return(ENXIO);
-	}
-	
-	memset(&sc->sc_txq, 0, sizeof(struct ifqueue));
-	sc->sc_txq.ifq_maxlen = sc->sc_capi.sc_nbch * 4;
-
-        if(!mtx_initialized(&sc->sc_txq.ifq_mtx))
-		mtx_init(&sc->sc_txq.ifq_mtx, "i4b_ivac_isa", NULL, MTX_DEF);
-
-	sc->sc_intr = FALSE;
-	sc->sc_state = IAVC_DOWN;
-	sc->sc_blocked = FALSE;
-
-	/* setup capi link */
-	
-	sc->sc_capi.load = iavc_load;
-	sc->sc_capi.reg_appl = iavc_register;
-	sc->sc_capi.rel_appl = iavc_release;
-	sc->sc_capi.send = iavc_send;
-	sc->sc_capi.ctx = (void*) sc;
-
-	if (capi_ll_attach(&sc->sc_capi))
-	{
-		printf("iavc%d: capi attach failed\n", unit);
-		return(ENXIO);
-	}
-
-	/* setup the interrupt */
-
-	if(bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET,
-		      (void(*)(void*))iavc_isa_intr,
-		      sc, &ih))
-	{
-		printf("iavc%d: irq setup failed\n", unit);
-		bus_release_resource(dev, SYS_RES_IOPORT,
-				sc->sc_resources.io_rid[0],
-	                        sc->sc_resources.io_base[0]);
-		bus_release_resource(dev, SYS_RES_IRQ,
-				sc->sc_resources.irq_rid,
-				sc->sc_resources.irq);
-		return(ENXIO);
-	}
-
-	/* the board is now ready to be loaded */
-
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	setup interrupt
- *---------------------------------------------------------------------------*/
-void
-b1isa_setup_irq(struct iavc_softc *sc)
-{
-	int irq = rman_get_start(sc->sc_resources.irq);
-	
-	if(bootverbose)
-		printf("iavc%d: using irq %d\n", sc->sc_unit, irq);
-
-	/* enable the interrupt */
-
-	b1io_outp(sc, B1_INSTAT, 0x00);
-	b1io_outp(sc, B1_RESET, b1_irq_table[irq]);
-	b1io_outp(sc, B1_INSTAT, 0x02);
-}	
-
-/*---------------------------------------------------------------------------*
- *	IRQ handler
- *---------------------------------------------------------------------------*/
-static void
-iavc_isa_intr(struct iavc_softc *sc)
-{
-	iavc_handle_intr(sc);
-}
--- sys/i4b/layer2/i4b_util.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_util.c - layer 2 utility routines
- *	-------------------------------------
- *      last edit-date: [Sat Mar  9 17:55:03 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_util.c,v 1.16 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l1l2.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer2/i4b_l2.h>
-
-/*---------------------------------------------------------------------------*
- *	routine ESTABLISH DATA LINK (Q.921 03/93 page 83)
- *---------------------------------------------------------------------------*/
-void
-i4b_establish_data_link(l2_softc_t *l2sc)
-{
-	i4b_l1_activate(l2sc);	
-
-	i4b_clear_exception_conditions(l2sc);
-
-	l2sc->RC = 0;
-
-	i4b_tx_sabme(l2sc, P1);
-
-	i4b_T200_restart(l2sc);
-
-	i4b_T203_stop(l2sc);	
-}
-
-/*---------------------------------------------------------------------------*
- *	routine CLEAR EXCEPTION CONDITIONS (Q.921 03/93 page 83)
- *---------------------------------------------------------------------------*/
-void
-i4b_clear_exception_conditions(l2_softc_t *l2sc)
-{
-	CRIT_VAR;
-
-	CRIT_BEG;
-	
-/*XXX -------------------------------------------------------------- */
-/*XXX is this really appropriate here or should it moved elsewhere ? */
-
-	i4b_Dcleanifq(&l2sc->i_queue);
-	
-	if(l2sc->ua_num != UA_EMPTY)
-	{
-		i4b_Dfreembuf(l2sc->ua_frame);
-		l2sc->ua_num = UA_EMPTY;
-	}
-/*XXX -------------------------------------------------------------- */
-
-	l2sc->peer_busy = 0;
-
-	l2sc->rej_excpt = 0;
-
-	l2sc->own_busy = 0;
-
-	l2sc->ack_pend = 0;	
-
-	CRIT_END;	
-}
-
-/*---------------------------------------------------------------------------*
- *	routine TRANSMIT ENQUIRE (Q.921 03/93 page 83)
- *---------------------------------------------------------------------------*/
-void
-i4b_transmit_enquire(l2_softc_t *l2sc)
-{
-	if(l2sc->own_busy)
-		i4b_tx_rnr_command(l2sc, P1);
-	else
-		i4b_tx_rr_command(l2sc, P1);
-
-	l2sc->ack_pend = 0;
-
-	i4b_T200_start(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	routine NR ERROR RECOVERY (Q.921 03/93 page 83)
- *---------------------------------------------------------------------------*/
-void
-i4b_nr_error_recovery(l2_softc_t *l2sc)
-{
-	i4b_mdl_error_ind(l2sc, "i4b_nr_error_recovery", MDL_ERR_J);
-
-	i4b_establish_data_link(l2sc);
-	
-	l2sc->l3initiated = 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	routine ENQUIRY RESPONSE (Q.921 03/93 page 84)
- *---------------------------------------------------------------------------*/
-void
-i4b_enquiry_response(l2_softc_t *l2sc)
-{
-	if(l2sc->own_busy)
-		i4b_tx_rnr_response(l2sc, F1);
-	else
-		i4b_tx_rr_response(l2sc, F1);
-
-	l2sc->ack_pend = 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	routine INVOKE RETRANSMISSION (Q.921 03/93 page 84)
- *---------------------------------------------------------------------------*/
-void
-i4b_invoke_retransmission(l2_softc_t *l2sc, int nr)
-{
-	CRIT_VAR;
-
-	CRIT_BEG;
-
-	NDBGL2(L2_ERROR, "nr = %d", nr );
-	
-	while(l2sc->vs != nr)
-	{
-		NDBGL2(L2_ERROR, "nr(%d) != vs(%d)", nr, l2sc->vs);
-
-		M128DEC(l2sc->vs);
-
-/* XXXXXXXXXXXXXXXXX */
-
-		if((l2sc->ua_num != UA_EMPTY) && (l2sc->vs == l2sc->ua_num))
-		{
-			if(_IF_QFULL(&l2sc->i_queue))
-			{
-				NDBGL2(L2_ERROR, "ERROR, I-queue full!");
-			}
-			else
-			{
-				IF_ENQUEUE(&l2sc->i_queue, l2sc->ua_frame);
-				l2sc->ua_num = UA_EMPTY;
-			}
-		}
-		else
-		{
-			NDBGL2(L2_ERROR, "ERROR, l2sc->vs = %d, l2sc->ua_num = %d ",l2sc->vs, l2sc->ua_num);
-		}
-
-/* XXXXXXXXXXXXXXXXX */
-			
-		i4b_i_frame_queued_up(l2sc);
-	}
-
-	CRIT_END;
-}
-
-/*---------------------------------------------------------------------------*
- *	routine ACKNOWLEDGE PENDING (Q.921 03/93 p 70)
- *---------------------------------------------------------------------------*/
-void
-i4b_acknowledge_pending(l2_softc_t *l2sc)
-{
-	if(l2sc->ack_pend)
-	{
-		l2sc->ack_pend = 0;
-		i4b_tx_rr_response(l2sc, F0);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_print_frame - just print the hex contents of a frame
- *---------------------------------------------------------------------------*/
-void
-i4b_print_frame(int len, u_char *buf)
-{
-#if DO_I4B_DEBUG
-	int i;
-
-	if (!(i4b_l2_debug & L2_ERROR))		/* XXXXXXXXXXXXXXXXXXXXX */
-		return;
-
-	for(i = 0; i < len; i++)
-		printf(" 0x%x", buf[i]);
-	printf("\n");
-#endif
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_print_l2var - print some l2softc vars
- *---------------------------------------------------------------------------*/
-void
-i4b_print_l2var(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_ERROR, "unit%d V(R)=%d, V(S)=%d, V(A)=%d,ACKP=%d,PBSY=%d,OBSY=%d",
-		l2sc->unit,
-		l2sc->vr,
-		l2sc->vs,
-		l2sc->va,
-		l2sc->ack_pend,
-		l2sc->peer_busy,
-		l2sc->own_busy);
-}
-
-/*---------------------------------------------------------------------------*
- *	got s or i frame, check if valid ack for last sent frame
- *---------------------------------------------------------------------------*/
-void
-i4b_rxd_ack(l2_softc_t *l2sc, int nr)
-{
-
-#ifdef NOTDEF
-	NDBGL2(L2_ERROR, "N(R)=%d, UA=%d, V(R)=%d, V(S)=%d, V(A)=%d",
-		nr,
-		l2sc->ua_num,
-		l2sc->vr,
-		l2sc->vs,
-		l2sc->va);
-#endif
-
-	if(l2sc->ua_num != UA_EMPTY)
-	{
-		CRIT_VAR;
-
-		CRIT_BEG;
-		
-		M128DEC(nr);
-
-		if(l2sc->ua_num != nr)
-			NDBGL2(L2_ERROR, "((N(R)-1)=%d) != (UA=%d) !!!", nr, l2sc->ua_num);
-			
-		i4b_Dfreembuf(l2sc->ua_frame);
-		l2sc->ua_num = UA_EMPTY;
-		
-		CRIT_END;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	if not already active, activate layer 1
- *---------------------------------------------------------------------------*/
-void
-i4b_l1_activate(l2_softc_t *l2sc)
-{
-	if(l2sc->ph_active == PH_INACTIVE)
-	{
-		l2sc->ph_active = PH_ACTIVEPEND;
-		PH_Act_Req(l2sc->unit);
-	}
-};
-
-/*---------------------------------------------------------------------------*
- *	check for v(a) <= n(r) <= v(s)
- *	nr = receive sequence frame counter, va = acknowledge sequence frame
- *	counter and vs = transmit sequence frame counter
- *---------------------------------------------------------------------------*/
-int
-i4b_l2_nr_ok(int nr, int va, int vs)
-{
-	if((va > nr) && ((nr != 0) || (va != 127)))
-	{
-		NDBGL2(L2_ERROR, "ERROR, va = %d, nr = %d, vs = %d [1]", va, nr, vs);
-		return 0;	/* fail */
-	}
-
-	if((nr > vs) && ((vs != 0) || (nr != 127)))
-	{
-		NDBGL2(L2_ERROR, "ERROR, va = %d, nr = %d, vs = %d [2]", va, nr, vs);
-		return 0;	/* fail */
-	}
-	return 1;		/* good */
-}
--- sys/i4b/layer2/i4b_uframe.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_uframe.c - routines for handling U-frames
- *	-----------------------------------------------
- *      last edit-date: [Sat Mar  9 17:54:08 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_uframe.c,v 1.15 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_l1l2.h>
-#include <i4b/include/i4b_l2l3.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer2/i4b_l2.h>
-#include <i4b/layer2/i4b_l2fsm.h>
-
-/*---------------------------------------------------------------------------*
- *	process a received U-frame
- *---------------------------------------------------------------------------*/
-void
-i4b_rxd_u_frame(int unit, struct mbuf *m)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-	u_char *ptr = m->m_data;
-
-	int sapi = GETSAPI(*(ptr + OFF_SAPI));
-	int tei = GETTEI(*(ptr + OFF_TEI));	
-	int pfbit = GETUPF(*(ptr + OFF_CNTL));
-	
-	switch(*(ptr + OFF_CNTL) & ~UPFBIT)
-	{
-		/* commands */
-
-		case SABME:
-			if((l2sc->tei_valid == TEI_VALID) &&
-			   (l2sc->tei == GETTEI(*(ptr+OFF_TEI))))
-			{
-				l2sc->stat.rx_sabme++;
-				NDBGL2(L2_U_MSG, "SABME, sapi = %d, tei = %d", sapi, tei);
-				l2sc->rxd_PF = pfbit;
-				i4b_next_l2state(l2sc, EV_RXSABME);
-			}
-			i4b_Dfreembuf(m);
-			break;
-
-		case UI:
-			if(sapi == SAPI_L2M &&
-			   tei == GROUP_TEI &&
-			   *(ptr + OFF_MEI) == MEI)
-			{
-				/* layer 2 management (SAPI = 63) */
-				l2sc->stat.rx_tei++;
-				i4b_tei_rxframe(unit, m);
-			}
-			else if(sapi == SAPI_CCP && tei == GROUP_TEI)
-			{
-				/* call control (SAPI = 0) */
-				l2sc->stat.rx_ui++;
-				/* strip ui header */
-				m_adj(m, UI_HDR_LEN);
-				/* to upper layer */
-				DL_Unit_Data_Ind(unit, m);
-			}
-			else
-			{
-				l2sc->stat.err_rx_badui++;
-				NDBGL2(L2_U_ERR, "unknown UI frame!");
-				i4b_Dfreembuf(m);				
-			}
-			break;
-			
-		case DISC:
-			if((l2sc->tei_valid == TEI_VALID) &&
-			   (l2sc->tei == GETTEI(*(ptr+OFF_TEI))))
-			{		
-				l2sc->stat.rx_disc++;
-				NDBGL2(L2_U_MSG, "DISC, sapi = %d, tei = %d", sapi, tei);
-				l2sc->rxd_PF = pfbit;
-				i4b_next_l2state(l2sc, EV_RXDISC);
-			}
-			i4b_Dfreembuf(m);
-			break;
-
-		case XID:
-			if((l2sc->tei_valid == TEI_VALID) &&
-			   (l2sc->tei == GETTEI(*(ptr+OFF_TEI))))
-			{		
-				l2sc->stat.rx_xid++;
-				NDBGL2(L2_U_MSG, "XID, sapi = %d, tei = %d", sapi, tei);
-			}
-			i4b_Dfreembuf(m);			
-			break;
-			
-		/* responses */
-
-		case DM:
-			if((l2sc->tei_valid == TEI_VALID) &&
-			   (l2sc->tei == GETTEI(*(ptr+OFF_TEI))))
-			{		
-				l2sc->stat.rx_dm++;
-				NDBGL2(L2_U_MSG, "DM, sapi = %d, tei = %d", sapi, tei);
-				i4b_print_frame(m->m_len, m->m_data);
-				l2sc->rxd_PF = pfbit;
-				i4b_next_l2state(l2sc, EV_RXDM);
-			}
-			i4b_Dfreembuf(m);
-			break;
-			
-		case UA:
-			if((l2sc->tei_valid == TEI_VALID) &&
-			   (l2sc->tei == GETTEI(*(ptr+OFF_TEI))))
-			{		
-				l2sc->stat.rx_ua++;
-				NDBGL2(L2_U_MSG, "UA, sapi = %d, tei = %d", sapi, tei);
-				l2sc->rxd_PF = pfbit;
-				i4b_next_l2state(l2sc, EV_RXUA);
-			}
-			i4b_Dfreembuf(m);			
-			break;			
-
-		case FRMR:
-			if((l2sc->tei_valid == TEI_VALID) &&
-			   (l2sc->tei == GETTEI(*(ptr+OFF_TEI))))
-			{
-				l2sc->stat.rx_frmr++;
-				NDBGL2(L2_U_MSG, "FRMR, sapi = %d, tei = %d", sapi, tei);
-				l2sc->rxd_PF = pfbit;
-				i4b_next_l2state(l2sc, EV_RXFRMR);
-			}
-			i4b_Dfreembuf(m);			
-			break;
-
-		default:
-			if((l2sc->tei_valid == TEI_VALID) &&
-			   (l2sc->tei == GETTEI(*(ptr+OFF_TEI))))
-			{		
-				NDBGL2(L2_U_ERR, "UNKNOWN TYPE ERROR, sapi = %d, tei = %d, frame = ", sapi, tei);
-				i4b_print_frame(m->m_len, m->m_data);
-			}
-			else
-			{		
-				NDBGL2(L2_U_ERR, "not mine -  UNKNOWN TYPE ERROR, sapi = %d, tei = %d, frame = ", sapi, tei);
-				i4b_print_frame(m->m_len, m->m_data);
-			}
-			l2sc->stat.err_rx_badui++;			
-			i4b_Dfreembuf(m);			
-			break;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	build U-frame for sending
- *---------------------------------------------------------------------------*/
-struct mbuf *
-i4b_build_u_frame(l2_softc_t *l2sc, crbit_to_nt_t crbit, pbit_t pbit, u_char type)
-{
-	struct mbuf *m;
-	
-	if((m = i4b_Dgetmbuf(U_FRAME_LEN)) == NULL)
-		return(NULL);
-
-	PUTSAPI(SAPI_CCP, crbit, m->m_data[OFF_SAPI]);
-		
-	PUTTEI(l2sc->tei, m->m_data[OFF_TEI]);
-
-	if(pbit)
-		m->m_data[OFF_CNTL] = type | UPBITSET;
-	else
-		m->m_data[OFF_CNTL] = type & ~UPBITSET;
-
-	return(m);
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit SABME command
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_sabme(l2_softc_t *l2sc, pbit_t pbit)
-{
-	struct mbuf *m;
-
-	l2sc->stat.tx_sabme++;
-	NDBGL2(L2_U_MSG, "tx SABME, tei = %d", l2sc->tei);
-	m = i4b_build_u_frame(l2sc, CR_CMD_TO_NT, pbit, SABME);
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit DM response
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_dm(l2_softc_t *l2sc, fbit_t fbit)
-{
-	struct mbuf *m;
-
-	l2sc->stat.tx_dm++;	
-	NDBGL2(L2_U_MSG, "tx DM, tei = %d", l2sc->tei);
-	m = i4b_build_u_frame(l2sc, CR_RSP_TO_NT, fbit, DM);
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit DISC command
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_disc(l2_softc_t *l2sc, pbit_t pbit)
-{
-	struct mbuf *m;
-	
-	l2sc->stat.tx_disc++;
-	NDBGL2(L2_U_MSG, "tx DISC, tei = %d", l2sc->tei);
-	m = i4b_build_u_frame(l2sc, CR_CMD_TO_NT, pbit, DISC);
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit UA response
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_ua(l2_softc_t *l2sc, fbit_t fbit)
-{
-	struct mbuf *m;
-	
-	l2sc->stat.tx_ua++;
-	NDBGL2(L2_U_MSG, "tx UA, tei = %d", l2sc->tei);
-	m = i4b_build_u_frame(l2sc, CR_RSP_TO_NT, fbit, UA);
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit FRMR response
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_frmr(l2_softc_t *l2sc, fbit_t fbit)
-{
-	struct mbuf *m;
-	
-	l2sc->stat.tx_frmr++;
-	NDBGL2(L2_U_MSG, "tx FRMR, tei = %d", l2sc->tei);
-	m = i4b_build_u_frame(l2sc, CR_RSP_TO_NT, fbit, FRMR);
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-}
--- sys/i4b/layer2/i4b_lme.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_lme.c - layer management entity
- *	-------------------------------------
- *      last edit-date: [Sat Mar  9 17:49:42 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_lme.c,v 1.15 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-
-#include <i4b/layer2/i4b_l2.h>
-
-/*---------------------------------------------------------------------------*
- *	mdl assign indication handler
- *---------------------------------------------------------------------------*/
-void
-i4b_mdl_assign_ind(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_PRIM, "unit %d", l2sc->unit);
-	
-	i4b_l1_activate(l2sc);
-	
-	if(l2sc->tei_valid == TEI_VALID)
-	{
-		l2sc->T202func = (void(*)(void*))i4b_tei_verify;
-		l2sc->N202 = N202DEF;
-		i4b_tei_verify(l2sc);
-	}
-	else
-	{
-		l2sc->T202func = (void(*)(void*))i4b_tei_assign;
-		l2sc->N202 = N202DEF;
-		i4b_tei_assign(l2sc);
-	}		
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_mdl_error_ind handler (Q.921 01/94 pp 156)
- *---------------------------------------------------------------------------*/
-void
-i4b_mdl_error_ind(l2_softc_t *l2sc, char *where, int errorcode)
-{
-#if DO_I4B_DEBUG
-	static char *error_text[] = {
-		"MDL_ERR_A: rx'd unsolicited response - supervisory (F=1)",
-		"MDL_ERR_B: rx'd unsolicited response - DM (F=1)",
-		"MDL_ERR_C: rx'd unsolicited response - UA (F=1)",
-		"MDL_ERR_D: rx'd unsolicited response - UA (F=0)",
-		"MDL_ERR_E: rx'd unsolicited response - DM (F=0)",
-		"MDL_ERR_F: peer initiated re-establishment - SABME",
-		"MDL_ERR_G: unsuccessful transmission N200times - SABME",
-		"MDL_ERR_H: unsuccessful transmission N200times - DIS",
-		"MDL_ERR_I: unsuccessful transmission N200times - Status ENQ",
-		"MDL_ERR_J: other error - N(R) error",
-		"MDL_ERR_K: other error - rx'd FRMR response",
-		"MDL_ERR_L: other error - rx'd undefined frame",
-		"MDL_ERR_M: other error - receipt of I field not permitted",
-		"MDL_ERR_N: other error - rx'd frame with wrong size",
-		"MDL_ERR_O: other error - N201 error",
-		"MDL_ERR_MAX: i4b_mdl_error_ind called with wrong parameter!!!"
-	};
-#endif
-
-	if(errorcode > MDL_ERR_MAX)
-		errorcode = MDL_ERR_MAX;
-		
-	NDBGL2(L2_ERROR, "unit = %d, location = %s", l2sc->unit, where);
-	NDBGL2(L2_ERROR, "error = %s", error_text[errorcode]);
-
-	switch(errorcode)
-	{	
-		case MDL_ERR_A:
-		case MDL_ERR_B:
-			break;
-
-		case MDL_ERR_C:
-		case MDL_ERR_D:
-			i4b_tei_verify(l2sc);
-			break;
-
-		case MDL_ERR_E:
-		case MDL_ERR_F:
-			break;
-
-		case MDL_ERR_G:
-		case MDL_ERR_H:
-			i4b_tei_verify(l2sc);
-			break;
-
-		case MDL_ERR_I:
-		case MDL_ERR_J:
-		case MDL_ERR_K:
-		case MDL_ERR_L:
-		case MDL_ERR_M:
-		case MDL_ERR_N:
-		case MDL_ERR_O:
-			break;
-
-		default:
-			break;
-	}
-}
--- sys/i4b/layer2/i4b_l2fsm.c
+++ /dev/null
@@ -1,1578 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l2fsm.c - layer 2 FSM
- *	-------------------------
- *      last edit-date: [Sat Mar  9 16:14:07 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_l2fsm.c,v 1.17 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l2l3.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer2/i4b_l2.h>
-#include <i4b/layer2/i4b_l2fsm.h>
-
-l2_softc_t l2_softc[MAXL1UNITS];
-
-#if DO_I4B_DEBUG
-static char *l2state_text[N_STATES] = {
-	"ST_TEI_UNAS",
-	"ST_ASG_AW_TEI",
-	"ST_EST_AW_TEI",
-	"ST_TEI_ASGD",
-
-	"ST_AW_EST",
-	"ST_AW_REL",
-	"ST_MULTIFR",
-	"ST_TIMREC",
-
-	"ST_SUBSET",
-	"Illegal State"
-};
-
-static char *l2event_text[N_EVENTS] = {
-	"EV_DLESTRQ",
-	"EV_DLUDTRQ",
-	"EV_MDASGRQ",
-	"EV_MDERRRS",
-	"EV_PSDEACT",
-	"EV_MDREMRQ",
-	"EV_RXSABME",
-	"EV_RXDISC",
-	"EV_RXUA",
-	"EV_RXDM",
-	"EV_T200EXP",
-	"EV_DLDATRQ",
-	"EV_DLRELRQ",
-	"EV_T203EXP",
-	"EV_OWNBUSY",
-	"EV_OWNRDY", 
-	"EV_RXRR",
-	"EV_RXREJ",
-	"EV_RXRNR",
-	"EV_RXFRMR",
-	"Illegal Event"
-};
-#endif
-
-static void F_TU01(l2_softc_t *);
-static void F_TU03(l2_softc_t *);
-
-static void F_TA03(l2_softc_t *);
-static void F_TA04(l2_softc_t *);
-static void F_TA05(l2_softc_t *);
-
-static void F_TE03(l2_softc_t *);
-static void F_TE04(l2_softc_t *);
-static void F_TE05(l2_softc_t *);
-
-static void F_T01(l2_softc_t *);
-static void F_T05(l2_softc_t *);
-static void F_T06(l2_softc_t *);
-static void F_T07(l2_softc_t *);
-static void F_T08(l2_softc_t *);
-static void F_T09(l2_softc_t *);
-static void F_T10(l2_softc_t *);
-static void F_T13(l2_softc_t *);
-
-static void F_AE01(l2_softc_t *);
-static void F_AE05(l2_softc_t *);
-static void F_AE06(l2_softc_t *);
-static void F_AE07(l2_softc_t *);
-static void F_AE08(l2_softc_t *);
-static void F_AE09(l2_softc_t *);
-static void F_AE10(l2_softc_t *);
-static void F_AE11(l2_softc_t *);
-static void F_AE12(l2_softc_t *);
-
-static void F_AR05(l2_softc_t *);
-static void F_AR06(l2_softc_t *);
-static void F_AR07(l2_softc_t *);
-static void F_AR08(l2_softc_t *);
-static void F_AR09(l2_softc_t *);
-static void F_AR10(l2_softc_t *);
-static void F_AR11(l2_softc_t *);
-
-static void F_MF01(l2_softc_t *);
-static void F_MF05(l2_softc_t *);
-static void F_MF06(l2_softc_t *);
-static void F_MF07(l2_softc_t *);
-static void F_MF08(l2_softc_t *);
-static void F_MF09(l2_softc_t *);
-static void F_MF10(l2_softc_t *);
-static void F_MF11(l2_softc_t *);
-static void F_MF12(l2_softc_t *);
-static void F_MF13(l2_softc_t *);
-static void F_MF14(l2_softc_t *);
-static void F_MF15(l2_softc_t *);
-static void F_MF16(l2_softc_t *);
-static void F_MF17(l2_softc_t *);
-static void F_MF18(l2_softc_t *);
-static void F_MF19(l2_softc_t *);
-static void F_MF20(l2_softc_t *);
-
-static void F_TR01(l2_softc_t *);
-static void F_TR05(l2_softc_t *);
-static void F_TR06(l2_softc_t *);
-static void F_TR07(l2_softc_t *);
-static void F_TR08(l2_softc_t *);
-static void F_TR09(l2_softc_t *);
-static void F_TR10(l2_softc_t *);
-static void F_TR11(l2_softc_t *);
-static void F_TR12(l2_softc_t *);
-static void F_TR13(l2_softc_t *);
-static void F_TR15(l2_softc_t *);
-static void F_TR16(l2_softc_t *);
-static void F_TR17(l2_softc_t *);
-static void F_TR18(l2_softc_t *);
-static void F_TR19(l2_softc_t *);
-static void F_TR20(l2_softc_t *);
-static void F_ILL(l2_softc_t *);
-static void F_NCNA(l2_softc_t *);
-
-/*---------------------------------------------------------------------------*
- *	FSM illegal state default action
- *---------------------------------------------------------------------------*/	
-static void
-F_ILL(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_ERR, "FSM function F_ILL executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM No change, No action
- *---------------------------------------------------------------------------*/	
-static void
-F_NCNA(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_NCNA executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	layer 2 state transition table
- *---------------------------------------------------------------------------*/	
-struct l2state_tab {
-	void (*func)(l2_softc_t *);	/* function to execute */
-	int newstate;				/* next state */
-} l2state_tab[N_EVENTS][N_STATES] = {
-
-/* STATE:	ST_TEI_UNAS,			ST_ASG_AW_TEI,			ST_EST_AW_TEI,			ST_TEI_ASGD,		ST_AW_EST,		ST_AW_REL,		ST_MULTIFR,		ST_TIMREC,		ST_SUBSET,		ILLEGAL STATE	*/
-/* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*EV_DLESTRQ*/{	{F_TU01, ST_EST_AW_TEI},	{F_NCNA, ST_EST_AW_TEI},	{F_ILL,	ST_ILL},		{F_T01,	ST_AW_EST},     {F_AE01, ST_AW_EST},	{F_ILL,	ST_ILL},	{F_MF01, ST_AW_EST},	{F_TR01, ST_AW_EST},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_DLUDTRQ*/{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_MDASGRQ*/{	{F_TU03, ST_TEI_ASGD},		{F_TA03, ST_TEI_ASGD},		{F_TE03, ST_AW_EST},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_MDERRRS*/{	{F_ILL,	ST_ILL},		{F_TA04, ST_TEI_UNAS},		{F_TE04, ST_TEI_UNAS},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_PSDEACT*/{	{F_ILL,	ST_ILL},		{F_TA05, ST_TEI_UNAS},		{F_TE05, ST_TEI_UNAS},		{F_T05,	ST_TEI_ASGD},	{F_AE05, ST_TEI_ASGD},	{F_AR05, ST_TEI_ASGD},	{F_MF05, ST_TEI_ASGD},	{F_TR05, ST_TEI_ASGD},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_MDREMRQ*/{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_T06,	ST_TEI_UNAS},	{F_AE06, ST_TEI_UNAS},	{F_AR06, ST_TEI_UNAS},	{F_MF06, ST_TEI_UNAS},	{F_TR06, ST_TEI_UNAS},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_RXSABME*/{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_T07,	ST_SUBSET},	{F_AE07, ST_AW_EST},	{F_AR07, ST_AW_REL},	{F_MF07, ST_MULTIFR},	{F_TR07, ST_MULTIFR},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_RXDISC */{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_T08,	ST_TEI_ASGD},	{F_AE08, ST_AW_EST},	{F_AR08, ST_AW_REL},	{F_MF08, ST_TEI_ASGD},	{F_TR08, ST_TEI_ASGD},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_RXUA   */{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_T09,	ST_TEI_ASGD},	{F_AE09, ST_SUBSET},	{F_AR09, ST_SUBSET},	{F_MF09, ST_MULTIFR},	{F_TR09, ST_TIMREC},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_RXDM   */{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_T10,	ST_SUBSET},	{F_AE10, ST_SUBSET},	{F_AR10, ST_SUBSET},	{F_MF10, ST_SUBSET},	{F_TR10, ST_AW_EST},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_T200EXP*/{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_AE11, ST_SUBSET},	{F_AR11, ST_SUBSET},	{F_MF11, ST_TIMREC},	{F_TR11, ST_SUBSET},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_DLDATRQ*/{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_AE12, ST_AW_EST},	{F_ILL,	ST_ILL},	{F_MF12, ST_MULTIFR},	{F_TR12, ST_TIMREC},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_DLRELRQ*/{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_T13,	ST_TEI_ASGD},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_MF13, ST_AW_REL},	{F_TR13, ST_AW_REL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_T203EXP*/{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_MF14, ST_TIMREC},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_OWNBUSY*/{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_MF15, ST_MULTIFR},	{F_TR15, ST_TIMREC},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_OWNRDY */{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_MF16, ST_MULTIFR},	{F_TR16, ST_TIMREC},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_RXRR   */{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_MF17, ST_SUBSET},	{F_TR17, ST_SUBSET},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_RXREJ  */{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_MF18, ST_SUBSET},	{F_TR18, ST_SUBSET},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_RXRNR  */{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_MF19, ST_SUBSET},	{F_TR19, ST_SUBSET},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_RXFRMR */{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_MF20, ST_AW_EST},	{F_TR20, ST_AW_EST},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} },
-/*EV_ILL    */{	{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},		{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL},	{F_ILL,	ST_ILL} }
-};
-
-/*---------------------------------------------------------------------------*
- *	event handler, executes function and sets new state
- *---------------------------------------------------------------------------*/	
-void i4b_next_l2state(l2_softc_t *l2sc, int event)
-{
-	int currstate, newstate;
-	int (*savpostfsmfunc)(int) = NULL;
-
-	/* check event number */
-	if(event >= N_EVENTS)
-		panic("i4b_l2fsm.c: event >= N_EVENTS\n");
-
-	/* get current state and check it */
-	if((currstate = l2sc->Q921_state) >= N_STATES) 	/* failsafe */
-		panic("i4b_l2fsm.c: currstate >= N_STATES\n");	
-
-	/* get new state and check it */
-	if((newstate = l2state_tab[event][currstate].newstate) >= N_STATES)
-		panic("i4b_l2fsm.c: newstate >= N_STATES\n");	
-	
-	
-	if(newstate != ST_SUBSET)
-	{	/* state function does NOT set new state */
-		NDBGL2(L2_F_MSG, "FSM event [%s]: [%s/%d => %s/%d]",
-				l2event_text[event],
-                                l2state_text[currstate], currstate,
-                                l2state_text[newstate], newstate);
-        }
-
-	/* execute state transition function */
-        (*l2state_tab[event][currstate].func)(l2sc);
-
-	if(newstate == ST_SUBSET)
-	{	/* state function DOES set new state */
-		NDBGL2(L2_F_MSG, "FSM S-event [%s]: [%s => %s]", l2event_text[event],
-                                           l2state_text[currstate],
-                                           l2state_text[l2sc->Q921_state]);
-        }
-        
-	/* check for illegal new state */
-
-	if(newstate == ST_ILL)
-	{
-		newstate = currstate;
-		NDBGL2(L2_F_ERR, "FSM illegal state, state = %s, event = %s!",
-                                l2state_text[currstate],
-				l2event_text[event]);
-	}
-
-	/* check if state machine function has to set new state */
-
-	if(newstate != ST_SUBSET)
-		l2sc->Q921_state = newstate;        /* no, we set new state */
-
-	if(l2sc->postfsmfunc != NULL)
-	{
-		NDBGL2(L2_F_MSG, "FSM executing postfsmfunc!");
-		/* try to avoid an endless loop */
-		savpostfsmfunc = l2sc->postfsmfunc;
-		l2sc->postfsmfunc = NULL;
-        	(*savpostfsmfunc)(l2sc->postfsmarg);
-        }
-}
-
-#if DO_I4B_DEBUG
-/*---------------------------------------------------------------------------*
- *	return pointer to current state description
- *---------------------------------------------------------------------------*/	
-char *i4b_print_l2state(l2_softc_t *l2sc)
-{
-	return((char *) l2state_text[l2sc->Q921_state]);
-}
-#endif
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_UNAS event dl establish request
- *---------------------------------------------------------------------------*/	
-static void
-F_TU01(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TU01 executing");
-	i4b_mdl_assign_ind(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_UNAS event mdl assign request
- *---------------------------------------------------------------------------*/	
-static void
-F_TU03(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TU03 executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_ASG_AW_TEI event mdl assign request
- *---------------------------------------------------------------------------*/	
-static void
-F_TA03(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TA03 executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_ASG_AW_TEI event mdl error response
- *---------------------------------------------------------------------------*/	
-static void
-F_TA04(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TA04 executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_ASG_AW_TEI event persistent deactivation
- *---------------------------------------------------------------------------*/	
-static void
-F_TA05(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TA05 executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_EST_AW_TEI event mdl assign request
- *---------------------------------------------------------------------------*/	
-static void
-F_TE03(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TE03 executing");
-	i4b_establish_data_link(l2sc);
-	l2sc->l3initiated = 1;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_EST_AW_TEI event mdl error response
- *---------------------------------------------------------------------------*/	
-static void
-F_TE04(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TE04 executing");
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_EST_AW_TEI event persistent deactivation
- *---------------------------------------------------------------------------*/	
-static void
-F_TE05(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TE05 executing");
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_ASGD event dl establish request
- *---------------------------------------------------------------------------*/	
-static void
-F_T01(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_T01 executing");
-	i4b_establish_data_link(l2sc);
-	l2sc->l3initiated = 1;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_ASGD event persistent deactivation
- *---------------------------------------------------------------------------*/	
-static void
-F_T05(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_T05 executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_ASGD event mdl remove request
- *---------------------------------------------------------------------------*/	
-static void
-F_T06(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_T06 executing");
-/*XXX*/	i4b_mdl_assign_ind(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_ASGD event rx'd SABME
- *---------------------------------------------------------------------------*/	
-static void
-F_T07(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_T07 executing");
-
-/* XXX */
-#ifdef NOTDEF
-	if(NOT able to establish)
-	{
-		i4b_tx_dm(l2sc, l2sc->rxd_PF);
-		l2sc->Q921_state = ST_TEI_ASGD;
-		return;
-	}
-#endif
-
-	i4b_clear_exception_conditions(l2sc);
-
-	MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
-	
-	i4b_tx_ua(l2sc, l2sc->rxd_PF);
-
-	l2sc->vs = 0;
-	l2sc->va = 0;
-	l2sc->vr = 0;	
-
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Est_Ind_A;
-
-	i4b_T203_start(l2sc);	
-
-	l2sc->Q921_state = ST_MULTIFR;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_ASGD event rx'd DISC
- *---------------------------------------------------------------------------*/	
-static void
-F_T08(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_T08 executing");
-	MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
-	i4b_tx_ua(l2sc, l2sc->rxd_PF);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_ASGD event rx'd UA
- *---------------------------------------------------------------------------*/	
-static void
-F_T09(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_T09 executing");
-	i4b_mdl_error_ind(l2sc, "F_T09", MDL_ERR_C);
-	i4b_mdl_error_ind(l2sc, "F_T09", MDL_ERR_D);	
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_ASGD event rx'd DM
- *---------------------------------------------------------------------------*/	
-static void
-F_T10(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_T10 executing");
-
-	if(l2sc->rxd_PF)
-	{
-		l2sc->Q921_state = ST_TEI_ASGD;
-	}
-	else
-	{
-#ifdef NOTDEF
-		if(NOT able_to_etablish)
-		{
-			l2sc->Q921_state = ST_TEI_ASGD;
-			return;
-		}
-#endif
-		i4b_establish_data_link(l2sc);
-
-		l2sc->l3initiated = 1;
-
-		l2sc->Q921_state = ST_AW_EST;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TEI_ASGD event dl release request
- *---------------------------------------------------------------------------*/	
-static void
-F_T13(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_T13 executing");
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Cnf_A;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_EST event dl establish request
- *---------------------------------------------------------------------------*/	
-static void
-F_AE01(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AE01 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);
-	
-	l2sc->l3initiated = 1;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_EST event persistent deactivation
- *---------------------------------------------------------------------------*/	
-static void
-F_AE05(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AE05 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);	
-
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-
-	i4b_T200_stop(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_EST event mdl remove request
- *---------------------------------------------------------------------------*/	
-static void
-F_AE06(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AE06 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);	
-
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-
-	i4b_T200_stop(l2sc);
-
-/*XXX*/	i4b_mdl_assign_ind(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_EST event rx'd SABME
- *---------------------------------------------------------------------------*/	
-static void
-F_AE07(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AE07 executing");
-	MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
-	i4b_tx_ua(l2sc, l2sc->rxd_PF);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_EST event rx'd DISC
- *---------------------------------------------------------------------------*/	
-static void
-F_AE08(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AE08 executing");
-	i4b_tx_dm(l2sc, l2sc->rxd_PF);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_EST event rx'd UA
- *---------------------------------------------------------------------------*/	
-static void
-F_AE09(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AE09 executing");
-
-	if(l2sc->rxd_PF == 0)
-	{
-		i4b_mdl_error_ind(l2sc, "F_AE09", MDL_ERR_D);
-		l2sc->Q921_state = ST_AW_EST;
-	}
-	else
-	{
-		if(l2sc->l3initiated)
-		{
-			l2sc->l3initiated = 0;
-			l2sc->vr = 0;
-			l2sc->postfsmarg = l2sc->unit;
-			l2sc->postfsmfunc = DL_Est_Cnf_A;
-		}
-		else
-		{
-			if(l2sc->vs != l2sc->va)
-			{
-				i4b_Dcleanifq(&l2sc->i_queue);
-				l2sc->postfsmarg = l2sc->unit;
-				l2sc->postfsmfunc = DL_Est_Ind_A;
-			}
-		}
-
-		MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
-		
-		i4b_T200_stop(l2sc);
-		i4b_T203_start(l2sc);
-
-		l2sc->vs = 0;
-		l2sc->va = 0;
-
-		l2sc->Q921_state = ST_MULTIFR;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_EST event rx'd DM
- *---------------------------------------------------------------------------*/	
-static void
-F_AE10(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AE10 executing");
-
-	if(l2sc->rxd_PF == 0)
-	{
-		l2sc->Q921_state = ST_AW_EST;
-	}
-	else
-	{
-		i4b_Dcleanifq(&l2sc->i_queue);
-
-		l2sc->postfsmarg = l2sc->unit;
-		l2sc->postfsmfunc = DL_Rel_Ind_A;
-
-		i4b_T200_stop(l2sc);
-
-		l2sc->Q921_state = ST_TEI_ASGD;		
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_EST event T200 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_AE11(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AE11 executing");
-
-	if(l2sc->RC >= N200)
-	{
-		i4b_Dcleanifq(&l2sc->i_queue);
-
-		i4b_mdl_error_ind(l2sc, "F_AE11", MDL_ERR_G);
-
-		l2sc->postfsmarg = l2sc->unit;
-		l2sc->postfsmfunc = DL_Rel_Ind_A;
-
-		l2sc->Q921_state = ST_TEI_ASGD;
-	}
-	else
-	{
-		l2sc->RC++;
-
-		i4b_tx_sabme(l2sc, P1);
-
-		i4b_T200_start(l2sc);
-
-		l2sc->Q921_state = ST_AW_EST;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_EST event dl data request
- *---------------------------------------------------------------------------*/	
-static void
-F_AE12(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AE12 executing");
-
-	if(l2sc->l3initiated == 0)
-	{
-		i4b_i_frame_queued_up(l2sc);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_REL event persistent deactivation
- *---------------------------------------------------------------------------*/	
-static void
-F_AR05(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AR05 executing");
-
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Cnf_A;
-
-	i4b_T200_stop(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_REL event mdl remove request
- *---------------------------------------------------------------------------*/	
-static void
-F_AR06(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AR06 executing");
-
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Cnf_A;
-
-	i4b_T200_stop(l2sc);
-
-/*XXX*/	i4b_mdl_assign_ind(l2sc);	
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_REL event rx'd SABME
- *---------------------------------------------------------------------------*/	
-static void
-F_AR07(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AR07 executing");	
-	i4b_tx_dm(l2sc, l2sc->rxd_PF);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_REL event rx'd DISC
- *---------------------------------------------------------------------------*/	
-static void
-F_AR08(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AR08 executing");
-	MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
-	i4b_tx_ua(l2sc, l2sc->rxd_PF);	
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_REL event rx'd UA
- *---------------------------------------------------------------------------*/	
-static void
-F_AR09(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AR09 executing");
-
-	if(l2sc->rxd_PF)
-	{
-		l2sc->postfsmarg = l2sc->unit;
-		l2sc->postfsmfunc = DL_Rel_Cnf_A;
-
-		i4b_T200_stop(l2sc);
-
-		l2sc->Q921_state = ST_TEI_ASGD;
-	}
-	else
-	{
-		i4b_mdl_error_ind(l2sc, "F_AR09", MDL_ERR_D);
-		
-		l2sc->Q921_state = ST_AW_REL;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_REL event rx'd DM
- *---------------------------------------------------------------------------*/	
-static void
-F_AR10(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AR10 executing");
-
-	if(l2sc->rxd_PF)
-	{
-		l2sc->postfsmarg = l2sc->unit;
-		l2sc->postfsmfunc = DL_Rel_Cnf_A;
-
-		i4b_T200_stop(l2sc);
-
-		l2sc->Q921_state = ST_TEI_ASGD;
-	}
-	else
-	{
-		l2sc->Q921_state = ST_AW_REL;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_AW_REL event T200 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_AR11(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_AR11 executing");
-
-	if(l2sc->RC >= N200)
-	{
-		i4b_mdl_error_ind(l2sc, "F_AR11", MDL_ERR_H);
-
-		l2sc->postfsmarg = l2sc->unit;
-		l2sc->postfsmfunc = DL_Rel_Cnf_A;
-
-		l2sc->Q921_state = ST_TEI_ASGD;
-	}
-	else
-	{
-		l2sc->RC++;
-
-		i4b_tx_disc(l2sc, P1);
-
-		i4b_T200_start(l2sc);
-
-		l2sc->Q921_state = ST_AW_REL;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event dl establish request
- *---------------------------------------------------------------------------*/	
-static void
-F_MF01(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF01 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);
-
-	i4b_establish_data_link(l2sc);
-	
-	l2sc->l3initiated = 1;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event persistent deactivation
- *---------------------------------------------------------------------------*/	
-static void
-F_MF05(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF05 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);
-	
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-	
-	i4b_T200_stop(l2sc);
-	i4b_T203_stop(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event mdl remove request
- *---------------------------------------------------------------------------*/	
-static void
-F_MF06(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF06 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);
-	
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-	
-	i4b_T200_stop(l2sc);
-	i4b_T203_stop(l2sc);
-
-/*XXX*/	i4b_mdl_assign_ind(l2sc);	
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event rx'd SABME
- *---------------------------------------------------------------------------*/	
-static void
-F_MF07(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF07 executing");
-
-	i4b_clear_exception_conditions(l2sc);
-
-	MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);	
-
-	i4b_tx_ua(l2sc, l2sc->rxd_PF);
-
-	i4b_mdl_error_ind(l2sc, "F_MF07", MDL_ERR_F);
-
-	if(l2sc->vs != l2sc->va)
-	{
-		i4b_Dcleanifq(&l2sc->i_queue);
-	
-		l2sc->postfsmarg = l2sc->unit;
-		l2sc->postfsmfunc = DL_Est_Ind_A;
-	}
-
-	i4b_T200_stop(l2sc);
-	i4b_T203_start(l2sc);
-
-	l2sc->vs = 0;
-	l2sc->va = 0;
-	l2sc->vr = 0;	
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event rx'd DISC
- *---------------------------------------------------------------------------*/	
-static void
-F_MF08(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF08 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);
-	MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
-	i4b_tx_ua(l2sc, l2sc->rxd_PF);
-	
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-
-	i4b_T200_stop(l2sc);
-	i4b_T203_stop(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event rx'd UA
- *---------------------------------------------------------------------------*/	
-static void
-F_MF09(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF09 executing");
-	if(l2sc->rxd_PF)
-		i4b_mdl_error_ind(l2sc, "F_MF09", MDL_ERR_C);
-	else
-		i4b_mdl_error_ind(l2sc, "F_MF09", MDL_ERR_D);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event rx'd DM
- *---------------------------------------------------------------------------*/	
-static void
-F_MF10(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF10 executing");
-
-	if(l2sc->rxd_PF)
-	{
-		i4b_mdl_error_ind(l2sc, "F_MF10", MDL_ERR_B);
-		
-		l2sc->Q921_state = ST_MULTIFR;
-	}
-	else
-	{
-		i4b_mdl_error_ind(l2sc, "F_MF10", MDL_ERR_E);
-		
-		i4b_establish_data_link(l2sc);
-
-		l2sc->l3initiated = 0;
-		
-		l2sc->Q921_state = ST_AW_EST;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event T200 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_MF11(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF11 executing");
-
-	l2sc->RC = 0;
-
-	i4b_transmit_enquire(l2sc);
-
-	l2sc->RC++;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event dl data request
- *---------------------------------------------------------------------------*/	
-static void
-F_MF12(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF12 executing");
-
-	i4b_i_frame_queued_up(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event dl release request
- *---------------------------------------------------------------------------*/	
-static void
-F_MF13(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF13 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);
-
-	l2sc->RC = 0;
-
-	i4b_tx_disc(l2sc, P1);
-	
-	i4b_T203_stop(l2sc);
-	i4b_T200_restart(l2sc);	
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event T203 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_MF14(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF14 executing");
-
-	i4b_transmit_enquire(l2sc);
-
-	l2sc->RC = 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event set own rx busy
- *---------------------------------------------------------------------------*/	
-static void
-F_MF15(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF15 executing");
-
-	if(l2sc->own_busy == 0)
-	{
-		l2sc->own_busy = 1;
-
-		i4b_tx_rnr_response(l2sc, F0); /* wrong in Q.921 03/93 p 64 */
-
-		l2sc->ack_pend = 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event clear own rx busy
- *---------------------------------------------------------------------------*/	
-static void
-F_MF16(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF16 executing");
-
-	if(l2sc->own_busy != 0)
-	{
-		l2sc->own_busy = 0;
-
-		i4b_tx_rr_response(l2sc, F0); /* wrong in Q.921 03/93 p 64 */
-
-		l2sc->ack_pend = 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event rx'd RR
- *---------------------------------------------------------------------------*/	
-static void
-F_MF17(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF17 executing");
-
-	l2sc->peer_busy = 0;
-
-	if(l2sc->rxd_CR == CR_CMD_FROM_NT)
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			i4b_enquiry_response(l2sc);
-		}
-	}
-	else
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			i4b_mdl_error_ind(l2sc, "F_MF17", MDL_ERR_A);
-		}
-	}
-
-	if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
-	{
-		if(l2sc->rxd_NR == l2sc->vs)
-		{
-			l2sc->va = l2sc->rxd_NR;
-			i4b_T200_stop(l2sc);
-			i4b_T203_restart(l2sc);
-		}
-		else if(l2sc->rxd_NR != l2sc->va)
-		{
-			l2sc->va = l2sc->rxd_NR;
-			i4b_T200_restart(l2sc);
-		}
-		l2sc->Q921_state = ST_MULTIFR;
-	}
-	else
-	{
-		i4b_nr_error_recovery(l2sc);
-		l2sc->Q921_state = ST_AW_EST;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event rx'd REJ
- *---------------------------------------------------------------------------*/	
-static void
-F_MF18(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF18 executing");
-
-	l2sc->peer_busy = 0;
-
-	if(l2sc->rxd_CR == CR_CMD_FROM_NT)
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			i4b_enquiry_response(l2sc);
-		}
-	}
-	else
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			i4b_mdl_error_ind(l2sc, "F_MF18", MDL_ERR_A);
-		}
-	}
-
-	if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
-	{
-		l2sc->va = l2sc->rxd_NR;
-		i4b_T200_stop(l2sc);
-		i4b_T203_start(l2sc);
-		i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
-		l2sc->Q921_state = ST_MULTIFR;
-	}
-	else
-	{
-		i4b_nr_error_recovery(l2sc);
-		l2sc->Q921_state = ST_AW_EST;		
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event rx'd RNR
- *---------------------------------------------------------------------------*/	
-static void
-F_MF19(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF19 executing");
-
-	l2sc->peer_busy = 1;
-
-	if(l2sc->rxd_CR == CR_CMD_FROM_NT)
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			i4b_enquiry_response(l2sc);
-		}
-	}
-	else
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			i4b_mdl_error_ind(l2sc, "F_MF19", MDL_ERR_A);
-                }
-        }
-
-	if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
-        {
-                l2sc->va = l2sc->rxd_NR;
-                i4b_T203_stop(l2sc);
-                i4b_T200_restart(l2sc);
-		l2sc->Q921_state = ST_MULTIFR;
-        }
-        else
-        {
-                i4b_nr_error_recovery(l2sc);
-		l2sc->Q921_state = ST_AW_EST;                
-        }
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_MULTIFR event rx'd FRMR
- *---------------------------------------------------------------------------*/	
-static void
-F_MF20(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_MF20 executing");
-
-	i4b_mdl_error_ind(l2sc, "F_MF20", MDL_ERR_K);
-
-	i4b_establish_data_link(l2sc);
-
-	l2sc->l3initiated = 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event dl establish request
- *---------------------------------------------------------------------------*/	
-static void
-F_TR01(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR01 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);
-
-	i4b_establish_data_link(l2sc);
-
-	l2sc->l3initiated = 1;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event persistent deactivation
- *---------------------------------------------------------------------------*/	
-static void
-F_TR05(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR05 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);	
-
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-
-	i4b_T200_stop(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event mdl remove request
- *---------------------------------------------------------------------------*/	
-static void
-F_TR06(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR06 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);
-
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-
-	i4b_T200_stop(l2sc);
-
-/*XXX*/	i4b_mdl_assign_ind(l2sc);	
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event rx'd SABME
- *---------------------------------------------------------------------------*/	
-static void
-F_TR07(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR07 executing");
-
-	i4b_clear_exception_conditions(l2sc);
-
-	MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
-	
-	i4b_tx_ua(l2sc, l2sc->rxd_PF);
-
-	i4b_mdl_error_ind(l2sc, "F_TR07", MDL_ERR_F);
-
-	if(l2sc->vs != l2sc->va)
-	{
-		i4b_Dcleanifq(&l2sc->i_queue);		
-
-		l2sc->postfsmarg = l2sc->unit;
-		l2sc->postfsmfunc = DL_Est_Ind_A;
-	}
-
-	i4b_T200_stop(l2sc);
-	i4b_T203_start(l2sc);
-	
-	l2sc->vs = 0;
-	l2sc->va = 0;
-	l2sc->vr = 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event rx'd DISC
- *---------------------------------------------------------------------------*/	
-static void
-F_TR08(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR08 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);		
-	MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
-	i4b_tx_ua(l2sc, l2sc->rxd_PF);
-
-	l2sc->postfsmarg = l2sc->unit;
-	l2sc->postfsmfunc = DL_Rel_Ind_A;
-
-	i4b_T200_stop(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event rx'd UA
- *---------------------------------------------------------------------------*/	
-static void
-F_TR09(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR09 executing");
-	if(l2sc->rxd_PF)
-		i4b_mdl_error_ind(l2sc, "F_TR09", MDL_ERR_C);
-	else
-		i4b_mdl_error_ind(l2sc, "F_TR09", MDL_ERR_D);	
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event rx'd DM
- *---------------------------------------------------------------------------*/	
-static void
-F_TR10(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR10 executing");
-
-	if(l2sc->rxd_PF)
-	{
-		i4b_mdl_error_ind(l2sc, "F_TR10", MDL_ERR_B);
-	}
-	else
-	{
-		i4b_mdl_error_ind(l2sc, "F_TR10", MDL_ERR_E);
-	}
-
-	i4b_establish_data_link(l2sc);
-
-	l2sc->l3initiated = 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event T200 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_TR11(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR11 executing");
-
-	if(l2sc->RC >= N200)
-	{
-		i4b_mdl_error_ind(l2sc, "F_TR11", MDL_ERR_I);
-
-		i4b_establish_data_link(l2sc);
-
-		l2sc->l3initiated = 0;
-
-		l2sc->Q921_state = ST_AW_EST;
-	}
-	else
-	{
-		i4b_transmit_enquire(l2sc);
-
-		l2sc->RC++;
-
-		l2sc->Q921_state = ST_TIMREC;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event dl data request
- *---------------------------------------------------------------------------*/	
-static void
-F_TR12(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR12 executing");
-
-	i4b_i_frame_queued_up(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event dl release request
- *---------------------------------------------------------------------------*/	
-static void
-F_TR13(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR13 executing");
-
-	i4b_Dcleanifq(&l2sc->i_queue);			
-
-	l2sc->RC = 0;
-
-	i4b_tx_disc(l2sc, P1);
-
-	i4b_T200_restart(l2sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event set own rx busy
- *---------------------------------------------------------------------------*/	
-static void
-F_TR15(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR15 executing");
-
-	if(l2sc->own_busy == 0)
-	{
-		l2sc->own_busy = 1;
-
-		i4b_tx_rnr_response(l2sc, F0);
-
-		l2sc->ack_pend = 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event clear own rx busy
- *---------------------------------------------------------------------------*/	
-static void
-F_TR16(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR16 executing");
-
-	if(l2sc->own_busy != 0)
-	{
-		l2sc->own_busy = 0;
-
-		i4b_tx_rr_response(l2sc, F0);	/* this is wrong	 */
-						/* in Q.921 03/93 p 74 ! */
-		l2sc->ack_pend = 0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event rx'd RR
- *---------------------------------------------------------------------------*/	
-static void
-F_TR17(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR17 executing");
-
-	l2sc->peer_busy = 0;
-
-	if(l2sc->rxd_CR == CR_CMD_FROM_NT)
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			i4b_enquiry_response(l2sc);
-		}
-	}
-	else
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
-			{
-				l2sc->va = l2sc->rxd_NR;
-				i4b_T200_stop(l2sc);
-				i4b_T203_start(l2sc);
-				i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
-				l2sc->Q921_state = ST_MULTIFR;
-				return;
-			}
-			else
-			{
-				i4b_nr_error_recovery(l2sc);
-				l2sc->Q921_state = ST_AW_EST;
-				return;
-			}
-		}
-	}
-
-	if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
-	{
-		l2sc->va = l2sc->rxd_NR;
-		l2sc->Q921_state = ST_TIMREC;
-	}
-	else
-	{
-		i4b_nr_error_recovery(l2sc);
-		l2sc->Q921_state = ST_AW_EST;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event 
- *---------------------------------------------------------------------------*/	
-static void
-F_TR18(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR18 executing");
-
-	l2sc->peer_busy = 0;
-
-	if(l2sc->rxd_CR == CR_CMD_FROM_NT)
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			i4b_enquiry_response(l2sc);
-		}
-	}
-	else
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
-			{
-				l2sc->va = l2sc->rxd_NR;
-				i4b_T200_stop(l2sc);
-				i4b_T203_start(l2sc);
-				i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
-				l2sc->Q921_state = ST_MULTIFR;
-				return;
-			}
-			else
-			{
-				i4b_nr_error_recovery(l2sc);
-				l2sc->Q921_state = ST_AW_EST;
-				return;
-			}
-		}
-	}
-
-	if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
-	{
-		l2sc->va = l2sc->rxd_NR;
-		l2sc->Q921_state = ST_TIMREC;
-	}
-	else
-	{
-		i4b_nr_error_recovery(l2sc);
-		l2sc->Q921_state = ST_AW_EST;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event rx'd RNR
- *---------------------------------------------------------------------------*/	
-static void
-F_TR19(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR19 executing");
-
-	l2sc->peer_busy = 0;
-
-	if(l2sc->rxd_CR == CR_CMD_FROM_NT)
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			i4b_enquiry_response(l2sc);
-		}
-	}
-	else
-	{
-		if(l2sc->rxd_PF == 1)
-		{
-			if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
-			{
-				l2sc->va = l2sc->rxd_NR;
-				i4b_T200_restart(l2sc);
-				i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
-				l2sc->Q921_state = ST_MULTIFR;
-				return;
-			}
-			else
-			{
-				i4b_nr_error_recovery(l2sc);
-				l2sc->Q921_state = ST_AW_EST;
-				return;
-			}
-		}
-	}
-
-	if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
-	{
-		l2sc->va = l2sc->rxd_NR;
-		l2sc->Q921_state = ST_TIMREC;
-	}
-	else
-	{
-		i4b_nr_error_recovery(l2sc);
-		l2sc->Q921_state = ST_AW_EST;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM state ST_TIMREC event rx'd FRMR
- *---------------------------------------------------------------------------*/	
-static void
-F_TR20(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_F_MSG, "FSM function F_TR20 executing");
-
-	i4b_mdl_error_ind(l2sc, "F_TR20", MDL_ERR_K);
-
-	i4b_establish_data_link(l2sc);
-
-	l2sc->l3initiated = 0;
-}
--- sys/i4b/layer2/i4b_tei.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_tei.c - tei handling procedures
- *	-----------------------------------
- *      last edit-date: [Sat Mar  9 17:53:27 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_tei.c,v 1.16 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/syslog.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l1l2.h>
-#include <i4b/include/i4b_l2l3.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer2/i4b_l2.h>
-#include <i4b/layer2/i4b_l2fsm.h>
-
-/*---------------------------------------------------------------------------*
- *	handle a received TEI management frame
- *---------------------------------------------------------------------------*/
-void
-i4b_tei_rxframe(int unit, struct mbuf *m)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-	u_char *ptr = m->m_data;
-	
-	switch(*(ptr + OFF_MT))
-	{
-		case MT_ID_ASSIGN:
-			if( (*(ptr + OFF_RIL) == l2sc->last_ril) &&
-			    (*(ptr + OFF_RIH) == l2sc->last_rih))
-			{
-				l2sc->tei = GET_TEIFROMAI(*(ptr+OFF_AI));
-				l2sc->tei_valid = TEI_VALID;
-
-				if(l2sc->T202 == TIMER_ACTIVE)
-					i4b_T202_stop(l2sc);
-
-				MDL_Status_Ind(l2sc->unit, STI_TEIASG, l2sc->tei);
-
-				log(LOG_INFO, "i4b: unit %d, assigned TEI = %d = 0x%02x\n", l2sc->unit, l2sc->tei, l2sc->tei);
-
-				NDBGL2(L2_TEI_MSG, "TEI ID Assign - TEI = %d", l2sc->tei);
-
-				i4b_next_l2state(l2sc, EV_MDASGRQ);
-			}
-			break;
-			
-		case MT_ID_DENY:
-			if( (*(ptr + OFF_RIL) == l2sc->last_ril) &&
-			    (*(ptr + OFF_RIH) == l2sc->last_rih))
-			{
-				l2sc->tei_valid = TEI_INVALID;
-				l2sc->tei = GET_TEIFROMAI(*(ptr+OFF_AI));
-
-				if(l2sc->tei == GROUP_TEI)
-				{
-					log(LOG_WARNING, "i4b: unit %d, denied TEI, no TEI values available from exchange!\n", l2sc->unit);
-					NDBGL2(L2_TEI_ERR, "TEI ID Denied, No TEI values available from exchange!");
-				}
-				else
-				{
-					log(LOG_WARNING, "i4b: unit %d, denied TEI = %d = 0x%02x\n", l2sc->unit, l2sc->tei, l2sc->tei);
-					NDBGL2(L2_TEI_ERR, "TEI ID Denied - TEI = %d", l2sc->tei);
-				}					
-				MDL_Status_Ind(l2sc->unit, STI_TEIASG, -1);
-				i4b_next_l2state(l2sc, EV_MDERRRS);
-			}
-			break;
-			
-		case MT_ID_CHK_REQ:
-			if( (l2sc->tei_valid == TEI_VALID) &&
-			    ( (l2sc->tei == GET_TEIFROMAI(*(ptr+OFF_AI))) ||
-			      (GROUP_TEI == GET_TEIFROMAI(*(ptr+OFF_AI))) ))
-			{
-				static int lasttei = -1;
-
-				if(l2sc->tei != lasttei)
-				{
-					NDBGL2(L2_TEI_MSG, "TEI ID Check Req - TEI = %d", l2sc->tei);
-					lasttei = l2sc->tei;
-				}
-				
-				if(l2sc->T202 == TIMER_ACTIVE)
-					i4b_T202_stop(l2sc);
-				i4b_tei_chkresp(l2sc);
-			}
-			break;
-			
-		case MT_ID_REMOVE:
-			if( (l2sc->tei_valid == TEI_VALID) &&
-			    ( (l2sc->tei == GET_TEIFROMAI(*(ptr+OFF_AI))) ||
-			      (l2sc->tei == GET_TEIFROMAI(*(ptr+OFF_AI)))))
-			{
-				l2sc->tei_valid = TEI_INVALID;
-				l2sc->tei = GET_TEIFROMAI(*(ptr+OFF_AI));
-
-				log(LOG_INFO, "i4b: unit %d, removed TEI = %d = 0x%02x\n", l2sc->unit, l2sc->tei, l2sc->tei);
-				NDBGL2(L2_TEI_MSG, "TEI ID Remove - TEI = %d", l2sc->tei);
-				MDL_Status_Ind(l2sc->unit, STI_TEIASG, -1);
-				i4b_next_l2state(l2sc, EV_MDREMRQ);
-			}
-			break;
-			
-		default:
-			NDBGL2(L2_TEI_ERR, "UNKNOWN TEI MGMT Frame, type = 0x%x", *(ptr + OFF_MT));
-			i4b_print_frame(m->m_len, m->m_data);
-			break;
-	}
-	i4b_Dfreembuf(m);
-}
-
-/*---------------------------------------------------------------------------*
- *	allocate and fill up a TEI management frame for sending
- *---------------------------------------------------------------------------*/
-static struct mbuf *
-build_tei_mgmt_frame(l2_softc_t *l2sc, unsigned char type)
-{
-	struct mbuf *m;
-	
-	if((m = i4b_Dgetmbuf(TEI_MGMT_FRM_LEN)) == NULL)
-		return(NULL);
-
-	m->m_data[TEIM_SAPIO] = 0xfc;	/* SAPI = 63, CR = 0, EA = 0 */
-	m->m_data[TEIM_TEIO]  = 0xff;	/* TEI = 127, EA = 1 */
-	m->m_data[TEIM_UIO]   = UI;	/* UI */
-	m->m_data[TEIM_MEIO]  = MEI;	/* MEI */
-	m->m_data[TEIM_MTO]   = type;	/* message type */
-	
-	switch(type)
-	{
-		case MT_ID_REQEST:
-			i4b_make_rand_ri(l2sc);
-			m->m_data[TEIM_RILO] = l2sc->last_ril;
-			m->m_data[TEIM_RIHO] = l2sc->last_rih;
-			m->m_data[TEIM_AIO] = (GROUP_TEI << 1) | 0x01;
-			break;
-
-		case MT_ID_CHK_RSP:
-			i4b_make_rand_ri(l2sc);
-			m->m_data[TEIM_RILO] = l2sc->last_ril;
-			m->m_data[TEIM_RIHO] = l2sc->last_rih;
-			m->m_data[TEIM_AIO] = (l2sc->tei << 1) | 0x01;
-			break;
-			
-		case MT_ID_VERIFY:
-			m->m_data[TEIM_RILO] = 0;
-			m->m_data[TEIM_RIHO] = 0;
-			m->m_data[TEIM_AIO] = (l2sc->tei << 1) | 0x01;
-			break;
-
-		default:
-			i4b_Dfreembuf(m);
-			panic("build_tei_mgmt_frame: invalid type");
-			break;
-	}
-	l2sc->stat.tx_tei++;
-	return(m);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_tei_assign - TEI assignment procedure (Q.921, 5.3.2, pp 24)
- *	T202func and N202 _MUST_ be set prior to calling this function !
- *---------------------------------------------------------------------------*/
-void
-i4b_tei_assign(l2_softc_t *l2sc)
-{
-	struct mbuf *m;
-
-	NDBGL2(L2_TEI_MSG, "tx TEI ID_Request");
-	
-	m = build_tei_mgmt_frame(l2sc, MT_ID_REQEST);
-
-	if(m == NULL)
-		panic("i4b_tei_assign: no mbuf");		
-
-	i4b_T202_start(l2sc);
-	
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_tei_assign - TEI verify procedure (Q.921, 5.3.5, pp 29)
- *	T202func and N202 _MUST_ be set prior to calling this function !
- *---------------------------------------------------------------------------*/
-void
-i4b_tei_verify(l2_softc_t *l2sc)
-{
-	struct mbuf *m;
-
-	NDBGL2(L2_TEI_MSG, "tx TEI ID_Verify");
-
-	m = build_tei_mgmt_frame(l2sc, MT_ID_VERIFY);
-
-	if(m == NULL)
-		panic("i4b_tei_verify: no mbuf");		
-
-	i4b_T202_start(l2sc);
-	
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_tei_chkresp - TEI check response procedure (Q.921, 5.3.5, pp 29)
- *---------------------------------------------------------------------------*/
-void
-i4b_tei_chkresp(l2_softc_t *l2sc)
-{
-	struct mbuf *m;
-	static int lasttei = 0;
-
-	if(l2sc->tei != lasttei)
-	{
-		lasttei = l2sc->tei;
-		NDBGL2(L2_TEI_MSG, "tx TEI ID_Check_Response");
-	}
-
-	m = build_tei_mgmt_frame(l2sc, MT_ID_CHK_RSP);
-
-	if(m == NULL)
-		panic("i4b_tei_chkresp: no mbuf");		
-
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-}
-
-/*---------------------------------------------------------------------------*
- *	generate some 16 bit "random" number used for TEI mgmt Ri field
- *---------------------------------------------------------------------------*/
-void
-i4b_make_rand_ri(l2_softc_t *l2sc)
-{
-	u_short val;
-
-#ifdef RANDOMDEV
-        read_random((char *)&val, sizeof(val));
-#else
-	val = (u_short)random();
-#endif /* RANDOMDEV */ 
-
-	l2sc->last_rih = (val >> 8) & 0x00ff;
-	l2sc->last_ril = val & 0x00ff;
-}
--- sys/i4b/layer2/i4b_l2.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_l2.c - ISDN layer 2 (Q.921)
- *	-------------------------------
- *      last edit-date: [Sat Mar  9 16:11:14 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_l2.c,v 1.20 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_l1l2.h>
-#include <i4b/include/i4b_l2l3.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer2/i4b_l2.h>
-#include <i4b/layer2/i4b_l2fsm.h>
-
-int i4b_dl_establish_ind(int);
-int i4b_dl_establish_cnf(int);
-int i4b_dl_release_ind(int);
-int i4b_dl_release_cnf(int);
-int i4b_dl_data_ind(int, struct mbuf *);
-int i4b_dl_unit_data_ind(int, struct mbuf *);
-
-static int i4b_mdl_command_req(int, int, void *);
-
-/* from layer 2 */
-
-extern int i4b_mdl_status_ind(int, int, int);
-
-/* this layers debug level */
-
-unsigned int i4b_l2_debug = L2_DEBUG_DEFAULT;
-
-struct i4b_l2l3_func i4b_l2l3_func = {
-
-	/* Layer 2 --> Layer 3 */
-	
-	(int (*)(int))				i4b_dl_establish_ind,
-	(int (*)(int)) 				i4b_dl_establish_cnf,
-	(int (*)(int))				i4b_dl_release_ind,
-	(int (*)(int))				i4b_dl_release_cnf,
-	(int (*)(int, struct mbuf *))		i4b_dl_data_ind,
-	(int (*)(int, struct mbuf *))		i4b_dl_unit_data_ind,
-
-	/* Layer 3 --> Layer 2 */
-
-	(int (*)(int))				i4b_dl_establish_req,
-	(int (*)(int))				i4b_dl_release_req,
-	(int (*)(int, struct mbuf *))		i4b_dl_data_req,
-	(int (*)(int, struct mbuf *))		i4b_dl_unit_data_req,
-
-	/* Layer 2 --> Layer 3 management */
-	
-	(int (*)(int, int, int))		i4b_mdl_status_ind,
-
-	/* Layer 3  --> Layer 2 management */
-	
-	(int (*)(int, int, void *))		i4b_mdl_command_req	
-};
-
-/*---------------------------------------------------------------------------*
- *	DL_ESTABLISH_REQ from layer 3
- *---------------------------------------------------------------------------*/
-int i4b_dl_establish_req(int unit)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-	
-	NDBGL2(L2_PRIM, "unit %d",unit);
-	i4b_l1_activate(l2sc);
-	i4b_next_l2state(l2sc, EV_DLESTRQ);
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	DL_RELEASE_REQ from layer 3
- *---------------------------------------------------------------------------*/
-int i4b_dl_release_req(int unit)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-
-	NDBGL2(L2_PRIM, "unit %d",unit);	
-	i4b_next_l2state(l2sc, EV_DLRELRQ);
-	return(0);	
-}
-
-/*---------------------------------------------------------------------------*
- *	DL UNIT DATA REQUEST from Layer 3
- *---------------------------------------------------------------------------*/
-int i4b_dl_unit_data_req(int unit, struct mbuf *m)
-{
-#ifdef NOTDEF
-	NDBGL2(L2_PRIM, "unit %d",unit);
-#endif
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	DL DATA REQUEST from Layer 3
- *---------------------------------------------------------------------------*/
-int i4b_dl_data_req(int unit, struct mbuf *m)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-
-#ifdef NOTDEF
-	NDBGL2(L2_PRIM, "unit %d",unit);
-#endif
-	switch(l2sc->Q921_state)
-	{
-		case ST_AW_EST:
-		case ST_MULTIFR:
-		case ST_TIMREC:
-		
-		        if(_IF_QFULL(&l2sc->i_queue))
-		        {
-		        	NDBGL2(L2_ERROR, "i_queue full!!");
-		        	i4b_Dfreembuf(m);
-		        }
-		        else
-		        {
-		        	CRIT_VAR;
-
-		        	CRIT_BEG;
-				IF_ENQUEUE(&l2sc->i_queue, m);
-				CRIT_END;
-
-				i4b_i_frame_queued_up(l2sc);
-			}
-			break;
-			
-		default:
-			NDBGL2(L2_ERROR, "unit %d ERROR in state [%s], freeing mbuf", unit, i4b_print_l2state(l2sc));
-			i4b_Dfreembuf(m);
-			break;
-	}		
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_ph_activate_ind - link activation indication from layer 1
- *---------------------------------------------------------------------------*/
-int
-i4b_ph_activate_ind(int unit)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-
-	NDBGL1(L1_PRIM, "unit %d",unit);
-	l2sc->ph_active = PH_ACTIVE;
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_ph_deactivate_ind - link deactivation indication from layer 1
- *---------------------------------------------------------------------------*/
-int
-i4b_ph_deactivate_ind(int unit)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-
-	NDBGL1(L1_PRIM, "unit %d",unit);
-	l2sc->ph_active = PH_INACTIVE;
-	return(0);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	i4b_l2_unit_init - place layer 2 unit into known state
- *---------------------------------------------------------------------------*/
-static void
-i4b_l2_unit_init(int unit)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-	CRIT_VAR;
-
-	CRIT_BEG;
-	l2sc->Q921_state = ST_TEI_UNAS;
-	l2sc->tei_valid = TEI_INVALID;
-	l2sc->vr = 0;
-	l2sc->vs = 0;
-	l2sc->va = 0;
-	l2sc->ack_pend = 0;
-	l2sc->rej_excpt = 0;
-	l2sc->peer_busy = 0;
-	l2sc->own_busy = 0;
-	l2sc->l3initiated = 0;
-
-	l2sc->rxd_CR = 0;
-	l2sc->rxd_PF = 0;
-	l2sc->rxd_NR = 0;
-	l2sc->RC = 0;
-	l2sc->iframe_sent = 0;
-		
-	l2sc->postfsmfunc = NULL;
-
-	if(l2sc->ua_num != UA_EMPTY)
-	{
-		i4b_Dfreembuf(l2sc->ua_frame);
-		l2sc->ua_num = UA_EMPTY;
-		l2sc->ua_frame = NULL;
-	}
-
-	i4b_T200_stop(l2sc);
-	i4b_T202_stop(l2sc);
-	i4b_T203_stop(l2sc);
-
-	CRIT_END;	
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_mph_status_ind - status indication upward
- *---------------------------------------------------------------------------*/
-int
-i4b_mph_status_ind(int unit, int status, int parm)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-	CRIT_VAR;
-	int sendup = 1;
-	
-	CRIT_BEG;
-
-	NDBGL1(L1_PRIM, "unit %d, status=%d, parm=%d", unit, status, parm);
-
-	switch(status)
-	{
-		case STI_ATTACH:
-			l2sc->unit = unit;
-			l2sc->i_queue.ifq_maxlen = IQUEUE_MAXLEN;
-
-			if(!mtx_initialized(&l2sc->i_queue.ifq_mtx))
-				mtx_init(&l2sc->i_queue.ifq_mtx, "i4b_l2sc", NULL, MTX_DEF);
-
-			l2sc->ua_frame = NULL;
-			bzero(&l2sc->stat, sizeof(lapdstat_t));			
-			i4b_l2_unit_init(unit);
-			
-			/* initialize the callout handles for timeout routines */
-			callout_handle_init(&l2sc->T200_callout);
-			callout_handle_init(&l2sc->T202_callout);
-			callout_handle_init(&l2sc->T203_callout);
-			callout_handle_init(&l2sc->IFQU_callout);
-			break;
-
-		case STI_L1STAT:	/* state of layer 1 */
-			break;
-		
-		case STI_PDEACT:	/* Timer 4 expired */
-/*XXX*/			if((l2sc->Q921_state >= ST_AW_EST) &&
-			   (l2sc->Q921_state <= ST_TIMREC))
-			{
-				NDBGL2(L2_ERROR, "unit %d, persistent deactivation!", unit);
-				i4b_l2_unit_init(unit);
-			}
-			else
-			{
-				sendup = 0;
-			}
-			break;
-
-		case STI_NOL1ACC:
-			i4b_l2_unit_init(unit);
-			NDBGL2(L2_ERROR, "unit %d, cannot access S0 bus!", unit);
-			break;
-			
-		default:
-			NDBGL2(L2_ERROR, "ERROR, unit %d, unknown status message!", unit);
-			break;
-	}
-	
-	if(sendup)
-		MDL_Status_Ind(unit, status, parm);  /* send up to layer 3 */
-
-	CRIT_END;
-	
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	MDL_COMMAND_REQ from layer 3
- *---------------------------------------------------------------------------*/
-static int
-i4b_mdl_command_req(int unit, int command, void * parm)
-{
-	NDBGL2(L2_PRIM, "unit %d, command=%d, parm=%d", unit, command, (unsigned int)parm);
-
-	switch(command)
-	{
-		case CMR_DOPEN:
-			i4b_l2_unit_init(unit);
-			break;
-	}		
-
-	MPH_Command_Req(unit, command, parm);
-	
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_ph_data_ind - process a rx'd frame got from layer 1
- *---------------------------------------------------------------------------*/
-int
-i4b_ph_data_ind(int unit, struct mbuf *m)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-#ifdef NOTDEF
-	NDBGL1(L1_PRIM, "unit %d", unit);
-#endif
-	u_char *ptr = m->m_data;
-
-	if ( (*(ptr + OFF_CNTL) & 0x01) == 0 )
-	{
-		if(m->m_len < 4)	/* 6 oct - 2 chksum oct */
-		{
-			l2sc->stat.err_rx_len++;
-			NDBGL2(L2_ERROR, "ERROR, I-frame < 6 octetts!");
-			i4b_Dfreembuf(m);
-			return(0);
-		}
-		i4b_rxd_i_frame(unit, m);
-	}
-	else if ( (*(ptr + OFF_CNTL) & 0x03) == 0x01 )
-	{
-		if(m->m_len < 4)	/* 6 oct - 2 chksum oct */
-		{
-			l2sc->stat.err_rx_len++;
-			NDBGL2(L2_ERROR, "ERROR, S-frame < 6 octetts!");
-			i4b_Dfreembuf(m);
-			return(0);
-		}
-		i4b_rxd_s_frame(unit, m);
-	}
-	else if ( (*(ptr + OFF_CNTL) & 0x03) == 0x03 )
-	{
-		if(m->m_len < 3)	/* 5 oct - 2 chksum oct */
-		{
-			l2sc->stat.err_rx_len++;
-			NDBGL2(L2_ERROR, "ERROR, U-frame < 5 octetts!");
-			i4b_Dfreembuf(m);
-			return(0);
-		}
-		i4b_rxd_u_frame(unit, m);
-	}
-	else
-	{
-		l2sc->stat.err_rx_badf++;
-		NDBGL2(L2_ERROR, "ERROR, bad frame rx'd - ");
-		i4b_print_frame(m->m_len, m->m_data);
-		i4b_Dfreembuf(m);
-	}
-	return(0);
-}
--- sys/i4b/layer2/i4b_sframe.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_sframe.c - s frame handling routines
- *	----------------------------------------
- *      last edit-date: [Sat Mar  9 17:52:06 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_sframe.c,v 1.15 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_l1l2.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer2/i4b_l2.h>
-#include <i4b/layer2/i4b_l2fsm.h>
-
-/*---------------------------------------------------------------------------*
- *	process s frame
- *---------------------------------------------------------------------------*/
-void
-i4b_rxd_s_frame(int unit, struct mbuf *m)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-	u_char *ptr = m->m_data;
-	
-	if(!((l2sc->tei_valid == TEI_VALID) &&
-	     (l2sc->tei == GETTEI(*(ptr+OFF_TEI)))))
-	{
-		i4b_Dfreembuf(m);
-		return;
-	}
-
-	l2sc->rxd_CR = GETCR(*(ptr + OFF_SAPI));
-	l2sc->rxd_PF = GETSPF(*(ptr + OFF_SNR));
-	l2sc->rxd_NR = GETSNR(*(ptr + OFF_SNR));
-
-	i4b_rxd_ack(l2sc, l2sc->rxd_NR);
-	
-	switch(*(ptr + OFF_SRCR))
-	{
-		case RR:
-			l2sc->stat.rx_rr++; /* update statistics */
-			NDBGL2(L2_S_MSG, "rx'd RR, N(R) = %d", l2sc->rxd_NR);
-			i4b_next_l2state(l2sc, EV_RXRR);
-			break;
-
-		case RNR:
-			l2sc->stat.rx_rnr++; /* update statistics */
-			NDBGL2(L2_S_MSG, "rx'd RNR, N(R) = %d", l2sc->rxd_NR);
-			i4b_next_l2state(l2sc, EV_RXRNR);
-			break;
-
-		case REJ:
-			l2sc->stat.rx_rej++; /* update statistics */
-			NDBGL2(L2_S_MSG, "rx'd REJ, N(R) = %d", l2sc->rxd_NR);
-			i4b_next_l2state(l2sc, EV_RXREJ);
-			break;
-
-		default:
-			l2sc->stat.err_rx_bads++; /* update statistics */
-			NDBGL2(L2_S_ERR, "ERROR, unknown code, frame = ");
-			i4b_print_frame(m->m_len, m->m_data);
-			break;
-	}
-	i4b_Dfreembuf(m);	
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit RR command
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_rr_command(l2_softc_t *l2sc, pbit_t pbit)
-{
-	struct mbuf *m;
-
-	NDBGL2(L2_S_MSG, "tx RR, unit = %d", l2sc->unit);
-
-	m = i4b_build_s_frame(l2sc, CR_CMD_TO_NT, pbit, RR);
-
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-
-	l2sc->stat.tx_rr++; /* update statistics */
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit RR response
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_rr_response(l2_softc_t *l2sc, fbit_t fbit)
-{
-	struct mbuf *m;
-
-	NDBGL2(L2_S_MSG, "tx RR, unit = %d", l2sc->unit);
-
-	m = i4b_build_s_frame(l2sc, CR_RSP_TO_NT, fbit, RR);	
-
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-
-	l2sc->stat.tx_rr++; /* update statistics */
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit RNR command
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_rnr_command(l2_softc_t *l2sc, pbit_t pbit)
-{
-	struct mbuf *m;
-
-	NDBGL2(L2_S_MSG, "tx RNR, unit = %d", l2sc->unit);
-
-	m = i4b_build_s_frame(l2sc, CR_CMD_TO_NT, pbit, RNR);	
-
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-
-	l2sc->stat.tx_rnr++; /* update statistics */
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit RNR response
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_rnr_response(l2_softc_t *l2sc, fbit_t fbit)
-{
-	struct mbuf *m;
-
-	NDBGL2(L2_S_MSG, "tx RNR, unit = %d", l2sc->unit);
-
-	m = i4b_build_s_frame(l2sc, CR_RSP_TO_NT, fbit, RNR);
-
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-
-	l2sc->stat.tx_rnr++; /* update statistics */
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit REJ response
- *---------------------------------------------------------------------------*/
-void
-i4b_tx_rej_response(l2_softc_t *l2sc, fbit_t fbit)
-{
-	struct mbuf *m;
-
-	NDBGL2(L2_S_MSG, "tx REJ, unit = %d", l2sc->unit);
-
-	m = i4b_build_s_frame(l2sc, CR_RSP_TO_NT, fbit, REJ);
-
-	PH_Data_Req(l2sc->unit, m, MBUF_FREE);
-
-	l2sc->stat.tx_rej++; /* update statistics */	
-}
-
-/*---------------------------------------------------------------------------*
- *	build S-frame for sending
- *---------------------------------------------------------------------------*/
-struct mbuf *
-i4b_build_s_frame(l2_softc_t *l2sc, crbit_to_nt_t crbit, pbit_t pbit, u_char type)
-{
-	struct mbuf *m;
-	
-	if((m = i4b_Dgetmbuf(S_FRAME_LEN)) == NULL)
-		return(NULL);
-
-	PUTSAPI(SAPI_CCP, crbit, m->m_data[OFF_SAPI]);
-		
-	PUTTEI(l2sc->tei, m->m_data[OFF_TEI]);
-
-	m->m_data[OFF_SRCR] = type;
-
-	m->m_data[OFF_SNR] = (l2sc->vr << 1) | (pbit & 0x01);
-
-	return(m);
-}
--- sys/i4b/layer2/i4b_mbuf.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b - mbuf handling support routines
- *	------------------------------------
- *      last edit-date: [Sat Mar  9 17:51:22 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_mbuf.c,v 1.17 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <i4b/include/i4b_mbuf.h>
-
-#define I4B_MBUF_DEBUG
-#undef I4B_MBUF_TYPE_DEBUG
-
-#ifdef I4B_MBUF_TYPE_DEBUG
-
-#define MT_DCHAN	42
-#define MT_BCHAN	43
-
-#define MT_I4B_D	MT_DCHAN
-#define MT_I4B_B	MT_BCHAN
-
-#else /* ! I4B_MBUF_TYPE_DEBUG */
-
-#define MT_I4B_D	MT_DATA
-#define MT_I4B_B	MT_DATA
-
-#endif /* I4B_MBUF_TYPE_DEBUG */
-
-/*---------------------------------------------------------------------------*
- *	allocate D-channel mbuf space
- *---------------------------------------------------------------------------*/
-struct mbuf*
-i4b_Dgetmbuf(int len)
-{
-	struct mbuf *m;
-
-	if(len > MCLBYTES)	/* if length > max extension size */
-	{
-
-#ifdef I4B_MBUF_DEBUG
-		printf("i4b_getmbuf: error - len(%d) > MCLBYTES(%d)\n",
-					len, MCLBYTES);
-#endif
-		
-		return(NULL);
-	}
-
-	MGETHDR(m, M_DONTWAIT, MT_I4B_D);	/* get mbuf with pkthdr */
-
-	/* did we actually get the mbuf ? */
-
-	if(!m)	
-	{
-
-#ifdef I4B_MBUF_DEBUG
-		printf("i4b_getbuf: error - MGETHDR failed!\n");
-#endif
-
-		return(NULL);
-	}
-
-	if(len >= MHLEN)
-	{
-		MCLGET(m, M_DONTWAIT);
-
-		if(!(m->m_flags & M_EXT))
-		{
-			m_freem(m);
-
-#ifdef I4B_MBUF_DEBUG
-			printf("i4b_getbuf: error - MCLGET failed, len(%d)\n", len);
-#endif
-			
-			return (NULL);
-		}
-	}
-
-	m->m_len = len;
-
-	return(m);
-}
-
-/*---------------------------------------------------------------------------*
- *	free a D-channel mbuf
- *---------------------------------------------------------------------------*/
-void
-i4b_Dfreembuf(struct mbuf *m)
-{
-	if(m)
-		m_freem(m);
-}
-
-/*---------------------------------------------------------------------------*
- *	clear a D-channel ifqueue from data
- *---------------------------------------------------------------------------*/
-void
-i4b_Dcleanifq(struct ifqueue *ifq)
-{
-	int x = splimp();
-
-	IF_DRAIN(ifq);
-
-	splx(x);
-}
-
-/*---------------------------------------------------------------------------*
- *	allocate B-channel mbuf space
- *---------------------------------------------------------------------------*/
-struct mbuf*
-i4b_Bgetmbuf(int len)
-{
-	struct mbuf *m;
-
-	if(len > MCLBYTES)	/* if length > max extension size */
-	{
-
-#ifdef I4B_MBUF_DEBUG
-		printf("i4b_getmbuf: error - len(%d) > MCLBYTES(%d)\n",
-					len, MCLBYTES);
-#endif
-		
-		return(NULL);
-	}
-
-	MGETHDR(m, M_DONTWAIT, MT_I4B_B);	/* get mbuf with pkthdr */
-
-	/* did we actually get the mbuf ? */
-
-	if(!m)	
-	{
-
-#ifdef I4B_MBUF_DEBUG
-		printf("i4b_getbuf: error - MGETHDR failed!\n");
-#endif
-
-		return(NULL);
-	}
-
-	if(len >= MHLEN)
-	{
-		MCLGET(m, M_DONTWAIT);
-
-		if(!(m->m_flags & M_EXT))
-		{
-			m_freem(m);
-
-#ifdef I4B_MBUF_DEBUG
-			printf("i4b_getbuf: error - MCLGET failed, len(%d)\n", len);
-#endif
-			
-			return (NULL);
-		}
-	}
-
-	m->m_len = len;
-
-	return(m);
-}
-
-/*---------------------------------------------------------------------------*
- *	free a B-channel mbuf
- *---------------------------------------------------------------------------*/
-void
-i4b_Bfreembuf(struct mbuf *m)
-{
-	if(m)
-		m_freem(m);
-}
-
-/*---------------------------------------------------------------------------*
- *	clear a B-channel ifqueue from data
- *---------------------------------------------------------------------------*/
-void
-i4b_Bcleanifq(struct ifqueue *ifq)
-{
-	int x = splimp();
-	
-	IF_DRAIN(ifq);
-
-	splx(x);
-}
-
-/* EOF */
--- sys/i4b/layer2/i4b_l2timer.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l2timer.c - layer 2 timer handling
- *	--------------------------------------
- *      last edit-date: [Sat Mar  9 17:48:58 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_l2timer.c,v 1.14 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer2/i4b_l2.h>
-#include <i4b/layer2/i4b_l2fsm.h>
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T200 timeout function
- *---------------------------------------------------------------------------*/
-static void
-i4b_T200_timeout(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_T_ERR, "unit %d, RC = %d", l2sc->unit, l2sc->RC);
-	i4b_next_l2state(l2sc, EV_T200EXP);
-}
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T200 start
- *---------------------------------------------------------------------------*/
-void
-i4b_T200_start(l2_softc_t *l2sc)
-{
-	if(l2sc->T200 == TIMER_ACTIVE)
-		return;
-		
-	NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
-	l2sc->T200 = TIMER_ACTIVE;
-
-	START_TIMER(l2sc->T200_callout, i4b_T200_timeout, l2sc, T200DEF);
-}
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T200 stop
- *---------------------------------------------------------------------------*/
-void
-i4b_T200_stop(l2_softc_t *l2sc)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-	if(l2sc->T200 != TIMER_IDLE)
-	{
-		STOP_TIMER(l2sc->T200_callout, i4b_T200_timeout, l2sc);
-		l2sc->T200 = TIMER_IDLE;
-	}
-	CRIT_END;
-	NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
-}
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T200 restart
- *---------------------------------------------------------------------------*/
-void
-i4b_T200_restart(l2_softc_t *l2sc)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-	if(l2sc->T200 != TIMER_IDLE)
-	{
-		STOP_TIMER(l2sc->T200_callout, i4b_T200_timeout, l2sc);
-	}
-	else
-	{
-		l2sc->T200 = TIMER_ACTIVE;
-	}
-
-	START_TIMER(l2sc->T200_callout, i4b_T200_timeout, l2sc, T200DEF);
-	CRIT_END;
-	NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
-}
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T202 timeout function
- *---------------------------------------------------------------------------*/
-static void
-i4b_T202_timeout(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_T_ERR, "unit %d, N202 = %d", l2sc->unit, l2sc->N202);
-	
-	if(--(l2sc->N202))
-	{
-		(*l2sc->T202func)(l2sc);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T202 start
- *---------------------------------------------------------------------------*/
-void
-i4b_T202_start(l2_softc_t *l2sc)
-{
-	if (l2sc->N202 == TIMER_ACTIVE)
-		return;
-
-	NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
-	l2sc->N202 = N202DEF;	
-	l2sc->T202 = TIMER_ACTIVE;
-
-	START_TIMER(l2sc->T202_callout, i4b_T202_timeout, l2sc, T202DEF);
-}
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T202 stop
- *---------------------------------------------------------------------------*/
-void
-i4b_T202_stop(l2_softc_t *l2sc)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-	if(l2sc->T202 != TIMER_IDLE)
-	{
-		STOP_TIMER(l2sc->T202_callout, i4b_T202_timeout, l2sc);
-		l2sc->T202 = TIMER_IDLE;
-	}
-	CRIT_END;
-	NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
-}
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T203 timeout function
- *---------------------------------------------------------------------------*/
-#if I4B_T203_ACTIVE
-static void
-i4b_T203_timeout(l2_softc_t *l2sc)
-{
-	NDBGL2(L2_T_ERR, "unit %d", l2sc->unit);
-	i4b_next_l2state(l2sc, EV_T203EXP);
-}
-#endif
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T203 start
- *---------------------------------------------------------------------------*/
-void
-i4b_T203_start(l2_softc_t *l2sc)
-{
-#if I4B_T203_ACTIVE
-	if (l2sc->T203 == TIMER_ACTIVE)
-		return;
-		
-	NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
-	l2sc->T203 = TIMER_ACTIVE;
-
-	START_TIMER(l2sc->T203_callout, i4b_T203_timeout, l2sc, T203DEF);
-#endif
-}
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T203 stop
- *---------------------------------------------------------------------------*/
-void
-i4b_T203_stop(l2_softc_t *l2sc)
-{
-#if I4B_T203_ACTIVE
-	CRIT_VAR;
-	CRIT_BEG;
-	if(l2sc->T203 != TIMER_IDLE)
-	{
-		STOP_TIMER(l2sc->T203_callout, i4b_T203_timeout, l2sc);
-		l2sc->T203 = TIMER_IDLE;
-	}
-	CRIT_END;
-	NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
-#endif
-}
-
-/*---------------------------------------------------------------------------*
- *	Q.921 timer T203 restart
- *---------------------------------------------------------------------------*/
-void
-i4b_T203_restart(l2_softc_t *l2sc)
-{
-#if I4B_T203_ACTIVE
-	CRIT_VAR;
-	CRIT_BEG;
-
-	if(l2sc->T203 != TIMER_IDLE)
-	{
-		STOP_TIMER(l2sc->T203_callout, i4b_T203_timerout, l2sc);
-	}
-	else
-	{
-		l2sc->T203 = TIMER_ACTIVE;
-	}
-
-	START_TIMER(l2sc->T203_callout, i4b_T203_timerout, l2sc, T203DEF);	
-	CRIT_END;
-	NDBGL2(L2_T_MSG, "unit %d", l2sc->unit);
-#endif
-}
--- sys/i4b/layer2/i4b_l2fsm.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_l2fsm.h - layer 2 FSM
- *      -------------------------
- *
- * $FreeBSD: src/sys/i4b/layer2/i4b_l2fsm.h,v 1.9 2005/01/06 22:18:21 imp Exp $
- *
- *      last edit-date: [Sat Mar  9 17:47:53 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L2FSM_H_
-#define _I4B_L2FSM_H_
-
-enum Q921_states {
-	ST_TEI_UNAS,	/* TEI unassigned */
-	ST_ASG_AW_TEI,	/* assign awaiting TEI */
-	ST_EST_AW_TEI,	/* establish awaiting TEI */
-	ST_TEI_ASGD,	/* TEI assigned */
-
-	ST_AW_EST,	/* awaiting establishment */
-	ST_AW_REL,	/* awaiting release */
-	ST_MULTIFR,	/* multiple frame established */
-	ST_TIMREC,	/* timer recovery */
-
-	ST_SUBSET,	/* SUBroutine SETs new state */
-	ST_ILL,		/* illegal state */
-	N_STATES	/* number of states */
-};
-
-enum Q921_events {
-	EV_DLESTRQ,	/* dl establish req */
-	EV_DLUDTRQ,	/* dl unit data req */
-	EV_MDASGRQ,	/* mdl assign req */
-	EV_MDERRRS,	/* mdl error response */
-	EV_PSDEACT,	/* persistent deactivation */
-	EV_MDREMRQ,	/* mdl remove req */
-	EV_RXSABME,	/* rx'd SABME */
-	EV_RXDISC,	/* rx'd DISC */
-	EV_RXUA,	/* rx'd UA */
-	EV_RXDM,	/* rx'd DM */
-	EV_T200EXP,	/* T200 expired */
-	EV_DLDATRQ,	/* dl data req */
-	EV_DLRELRQ,	/* dl release req */
-	EV_T203EXP,	/* T203 expired */
-	EV_OWNBUSY,	/* set own rx busy */
-	EV_OWNRDY,	/* clear own rx busy */
-	EV_RXRR,	/* rx'd RR */
-	EV_RXREJ,	/* rx'd REJ */
-	EV_RXRNR,	/* rx'd RNR */
-	EV_RXFRMR,	/* rx'd FRMR */
-
-	EV_ILL,		/* Illegal */
-	N_EVENTS
-};
-	
-#endif /* _I4B_L2FSM_H_ */
--- sys/i4b/layer2/i4b_iframe.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_iframe.c - i frame handling routines
- *	------------------------------------------
- *      last edit-date: [Sat Mar  9 16:07:21 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer2/i4b_iframe.c,v 1.14 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l1l2.h>
-#include <i4b/include/i4b_l2l3.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer2/i4b_l2.h>
-#include <i4b/layer2/i4b_l2fsm.h>
-
-/*---------------------------------------------------------------------------*
- *	process i frame
- *	implements the routine "I COMMAND" Q.921 03/93 pp 68 and pp 77
- *---------------------------------------------------------------------------*/
-void
-i4b_rxd_i_frame(int unit, struct mbuf *m)
-{
-	l2_softc_t *l2sc = &l2_softc[unit];
-	u_char *ptr = m->m_data;
-	int nr;
-	int ns;
-	int p;
-	CRIT_VAR;
-	
-	if(!((l2sc->tei_valid == TEI_VALID) &&
-	     (l2sc->tei == GETTEI(*(ptr+OFF_TEI)))))
-	{
-		i4b_Dfreembuf(m);
-		return;
-	}
-
-	if((l2sc->Q921_state != ST_MULTIFR) && (l2sc->Q921_state != ST_TIMREC))
-	{
-		i4b_Dfreembuf(m);
-		NDBGL2(L2_I_ERR, "ERROR, state != (MF || TR)!");
-		return;
-	}
-
-	CRIT_BEG;
-
-	l2sc->stat.rx_i++;		/* update frame count */
-	
-	nr = GETINR(*(ptr + OFF_INR));
-	ns = GETINS(*(ptr + OFF_INS));
-	p = GETIP(*(ptr + OFF_INR));
-	
-	i4b_rxd_ack(l2sc, nr);		/* last packet ack */
-
-	if(l2sc->own_busy)		/* own receiver busy ? */
-	{	
-		i4b_Dfreembuf(m);	/* yes, discard information */
-
-		if(p == 1)		/* P bit == 1 ? */
-		{
-			i4b_tx_rnr_response(l2sc, p); /* yes, tx RNR */
-			l2sc->ack_pend = 0;	/* clear ACK pending */
-		}
-	}
-	else	/* own receiver ready */
-	{
-		if(ns == l2sc->vr)	/* expected sequence number ? */
-		{
-			M128INC(l2sc->vr);	/* yes, update */
-			
-			l2sc->rej_excpt = 0;	/* clr reject exception */
-
-			m_adj(m, I_HDR_LEN);	/* strip i frame header */
-
-			l2sc->iframe_sent = 0;	/* reset i acked already */
-
-			DL_Data_Ind(l2sc->unit, m);	/* pass data up */
-
-			if(!l2sc->iframe_sent)
-			{
-				i4b_tx_rr_response(l2sc, p); /* yes, tx RR */
-				l2sc->ack_pend = 0;	/* clr ACK pending */
-			}
-		}
-		else	/* ERROR, sequence number NOT expected */
-		{
-			i4b_Dfreembuf(m);	/* discard information */
-
-			if(l2sc->rej_excpt == 1)  /* already exception ? */
-			{
-				if(p == 1)	/* immediate response ? */
-				{
-					i4b_tx_rr_response(l2sc, p); /* yes, tx RR */
-					l2sc->ack_pend = 0; /* clr ack pend */
-				}
-			}
-			else	/* not in exception cond */
-			{
-				l2sc->rej_excpt = 1;	/* set exception */
-				i4b_tx_rej_response(l2sc, p);	/* tx REJ */
-				l2sc->ack_pend = 0;	/* clr ack pending */
-			}
-		}
-	}
-
-	/* sequence number ranges as expected ? */
-	
-	if(i4b_l2_nr_ok(nr, l2sc->va, l2sc->vs))
-	{
-		if(l2sc->Q921_state == ST_TIMREC)
-		{
-			l2sc->va = nr;
-
-			CRIT_END;
-
-			return;
-		}
-
-		if(l2sc->peer_busy)	/* yes, other side busy ? */
-		{
-			l2sc->va = nr;	/* yes, update ack count */
-		}
-		else	/* other side ready */
-		{
-			if(nr == l2sc->vs)	/* count expected ? */
-			{
-				l2sc->va = nr;	/* update ack */
-				i4b_T200_stop(l2sc);
-				i4b_T203_restart(l2sc);
-			}
-			else
-			{
-				if(nr != l2sc->va)
-				{
-					l2sc->va = nr;
-					i4b_T200_restart(l2sc);
-				}
-			}
-		}
-	}
-	else
-	{
-		i4b_nr_error_recovery(l2sc);	/* sequence error */
-		l2sc->Q921_state = ST_AW_EST; 
-	}
-
-	CRIT_END;
-}
-
-/*---------------------------------------------------------------------------*
- *	internal I FRAME QUEUED UP routine (Q.921 03/93 p 61)
- *---------------------------------------------------------------------------*/
-void
-i4b_i_frame_queued_up(l2_softc_t *l2sc)
-{
-	struct mbuf *m;
-	u_char *ptr;
-	CRIT_VAR;
-
-	CRIT_BEG;
-	
-	if((l2sc->peer_busy) || (l2sc->vs == ((l2sc->va + MAX_K_VALUE) & 127)))
-	{
-		if(l2sc->peer_busy)
-		{
-			NDBGL2(L2_I_MSG, "regen IFQUP, cause: peer busy!");
-		}
-
-		if(l2sc->vs == ((l2sc->va + MAX_K_VALUE) & 127))
-		{
-			NDBGL2(L2_I_MSG, "regen IFQUP, cause: vs=va+k!");
-		}	
-
-		/*
-		 * XXX see: Q.921, page 36, 5.6.1 ".. may retransmit an I
-		 * frame ...", shall we retransmit the last i frame ?
-		 */
-
-		if(!(IF_QEMPTY(&l2sc->i_queue)))
-		{
-			NDBGL2(L2_I_MSG, "re-scheduling IFQU call!");
-			START_TIMER(l2sc->IFQU_callout, i4b_i_frame_queued_up, l2sc, IFQU_DLY);
-		}
-		CRIT_END;
-		return;
-	}
-
-	IF_DEQUEUE(&l2sc->i_queue, m);    /* fetch next frame to tx */
-
-	if(!m)
-	{
-		NDBGL2(L2_I_ERR, "ERROR, mbuf NULL after IF_DEQUEUE");
-		CRIT_END;
-		return;
-	}
-
-	ptr = m->m_data;
-	
-	PUTSAPI(SAPI_CCP, CR_CMD_TO_NT, *(ptr + OFF_SAPI));
-	PUTTEI(l2sc->tei, *(ptr + OFF_TEI));
-
-	*(ptr + OFF_INS) = (l2sc->vs << 1) & 0xfe; /* bit 0 = 0 */
-	*(ptr + OFF_INR) = (l2sc->vr << 1) & 0xfe; /* P bit = 0 */
-
-	l2sc->stat.tx_i++;	/* update frame counter */
-	
-	PH_Data_Req(l2sc->unit, m, MBUF_DONTFREE); /* free'd when ack'd ! */
-
-	l2sc->iframe_sent = 1;		/* in case we ack an I frame with another I frame */
-	
-	if(l2sc->ua_num != UA_EMPTY)	/* failsafe */
-	{
-		NDBGL2(L2_I_ERR, "ERROR, l2sc->ua_num: %d != UA_EMPTY", l2sc->ua_num);
-		i4b_print_l2var(l2sc);
-		i4b_Dfreembuf(l2sc->ua_frame);
-	}
-
-	l2sc->ua_frame = m;		/* save unacked frame */
-	l2sc->ua_num = l2sc->vs;	/* save frame number */
-
-	M128INC(l2sc->vs);
-	
-	l2sc->ack_pend = 0;
-
-	CRIT_END;
-
-	if(l2sc->T200 == TIMER_IDLE)
-	{
-		i4b_T203_stop(l2sc);
-		i4b_T200_start(l2sc);
-	}
-}
--- sys/i4b/layer2/i4b_l2.h
+++ /dev/null
@@ -1,351 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l2.h - ISDN layer 2 (Q.921) definitions
- *	---------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer2/i4b_l2.h,v 1.9 2005/01/06 22:18:21 imp Exp $
- *
- *      last edit-date: [Sat Mar  9 16:12:20 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L2_H_
-#define _I4B_L2_H_
-
-typedef struct {
-	int	unit;		/* unit number this entry is for */
-
-	int	Q921_state;	/* state according to Q.921 */
-
-	u_char	last_ril;	/* last reference number from TEI management */
-	u_char	last_rih;
-
-	int	tei_valid;	/* tei is valid flag */
-#define TEI_INVALID	0
-#define TEI_VALID	1	
-	int	tei;		/* tei, if tei flag valid */
-
-	int	ph_active;	/* Layer 1 active flag */
-#define PH_INACTIVE	0	/* layer 1 inactive */
-#define PH_ACTIVEPEND	1	/* already tried to activate */
-#define PH_ACTIVE	2	/* layer 1 active */
-
-	int	T200;		/* Multiframe timeout timer */
-	int	T201;		/* min time between TEI ID check */
-	int	T202;		/* min time between TEI ID Req messages */
-	int	N202;		/* TEI ID Req tx counter */
-	void(*T202func)(void *);/* function to be called when T202 expires */
-	int	T203;		/* max line idle time */
-
-	struct	callout_handle T200_callout;
-	struct	callout_handle T202_callout;
-	struct	callout_handle T203_callout;
-	struct	callout_handle IFQU_callout;	
-
-/*
- * i4b_iframe.c, i4b_i_frame_queued_up(): value of IFQU_DLY
- * some experimentation Gary did showed a minimal value of (hz/20) was
- * possible to let this work, Gary suggested using (hz/10) but i settled
- * down to using (hz/5) for now (-hm).
- */
-#define IFQU_DLY (hz/5)		/* reschedule I-FRAME-QUEUED-UP 0.2 sec */
-
-	int	vr;		/* receive sequence frame counter */
-	int	vs;		/* transmit sequence frame counter */
-	int	va;		/* acknowledge sequence frame counter */
-
-	int	ack_pend;	/* acknowledge pending */
-	int	rej_excpt;	/* reject exception */
-	int	peer_busy;	/* peer receiver busy */
-	int	own_busy;	/* own receiver busy */
-	int	l3initiated;	/* layer 3 initiated */
-
-	struct ifqueue i_queue;	/* queue of outgoing i frames */
-#define IQUEUE_MAXLEN	20
-
-	/* this implementation only supports a k-value of 1 !!! */
-	struct mbuf *ua_frame;	/* last unacked frame */
-	int	ua_num;		/* last unacked frame number */
-#define UA_EMPTY (-1)		/* ua_frame is unused	*/	
-
-	int	rxd_CR;		/* received Command Response bit */
-	int	rxd_PF;		/* received Poll/Final bit */
-	int	rxd_NR;		/* received N(R) field */
-	int	RC;		/* Retry Counter */
-
-	int	iframe_sent;	/* check if i frame acked by another i frame */
-	
-	int (*postfsmfunc)(int);/* function to be called at fsm exit */
-	int	postfsmarg;	/* argument for above function */
-
-	/* statistics */
-
-	lapdstat_t	stat;	/* lapd protocol statistics */
-
-} l2_softc_t;
-
-extern l2_softc_t l2_softc[];
-
-/* Q.912 system parameters (Q.921 03/93 pp 43) */
-
-#define MAX_K_VALUE	1	/* BRI - # of outstanding frames 	*/
-
-#define N200	3		/* max no of retransmissions */
-#define N201DEF	260		/* max no of octetts in information field */
-#define N202DEF	3		/* max no of TEI ID Request message transmissions */
-
-#define T200DEF	(hz*1)		/* default T200 timer value = 1 second	*/
-#define T201DEF	T200DEF		/* default T201 timer value = T200DEF	*/
-#define T202DEF (hz*2)		/* default T202 timer value = 2 seconds */
-#define T203DEF (hz*10)		/* default T203 timer value = 10 seconds*/
-
-/* modulo 128 operations */
-
-#define M128INC(v) 	(v)++;		\
-			if((v)>127)	\
-			{		\
-				v = 0;	\
-			}
-			
-#define M128DEC(v) 	(v)--;		\
-			if((v)<0)	\
-			{		\
-				v = 127;\
-			}
-			
-/* P-bit values */
-
-typedef enum {
-	P0,
-	P1
-} pbit_t;
-
-/* F-bit values */
-
-typedef enum {
-	F0,
-	F1
-} fbit_t;
-
-/* CR-bit values to NT */
-
-typedef enum {
-	CR_CMD_TO_NT,
-	CR_RSP_TO_NT
-} crbit_to_nt_t;
-
-/* CR-bit values from NT */
-
-typedef enum {
-	CR_RSP_FROM_NT,
-	CR_CMD_FROM_NT
-} crbit_from_nt_t;
-
-/* address field - octett 2 */
-
-#define OFF_SAPI	0	/* SAPI offset, HDLC flag is eaten by L1 */
-#define SAPI_CCP	0	/* SAPI = 0 - call control procedures */
-#define SAPI_X25	16	/* SAPI = 16 - X.25 packet procedures */
-#define SAPI_L2M	63	/* SAPI = 63 - Layer 2 management procedures */
-
-/* extract and insert macros for SAPI octett */
-
-#define GETSAPI(octett)		(((octett) >> 2) & 0x3f)
-#define PUTSAPI(sapi,cr,octett)	((octett) = (((sapi << 2) & 0xfc) | ((cr & 0x01) << 1)))
-#define GETCR(octett)		(((octett) >> 1) & 0x01)
-#define GETEA(octett)		((octett) & 0x01)
-
-/* address field - octett 3 */
-
-#define OFF_TEI		1	/* TEI offset */
-#define GETTEI(octett) (((octett) >> 1) & 0x7f)
-#define PUTTEI(tei, octett) ((octett) = ((((tei) << 1) & 0xfe)) | 0x01) 
-#define GROUP_TEI	127	/* broadcast TEI for LME */
-
-/* control field - octett 4 */
-
-#define OFF_CNTL	2	/* 1st byte of control field */
-
-/* S frames */
-
-#define S_FRAME_LEN	4	/* lenght of a U-frame */
-#define OFF_SRCR	2	/* 1st byte of control field,	*/
-				/* R-commands and R-responses	*/
-#define OFF_SNR		3	/* 2nd byte of control field, N(R) and PF */
-#define SPFBIT		0x01	/* poll/final bit mask */
-#define SPBITSET	SPFBIT
-#define SFBITSET	SPFBIT
-#define GETSNR(octett) (((octett) >> 1) & 0x7f)
-#define GETSPF(octett) ((octett) & SPFBIT)
-#define RR		0x01	/* RR and bit 0 set */
-#define RNR		0x05	/* RNR and bit 0 set */
-#define REJ		0x09	/* REJ and bit 0 set */
-
-/* U frames */
-
-#define UI_HDR_LEN	3	/* length of UI header in front of L3 frame */
-#define U_FRAME_LEN	3	/* lenght of a U-frame */
-#define UPFBIT		0x10	/* poll/final bit mask */
-#define UPBITSET	UPFBIT
-#define UFBITSET	UPFBIT
-#define GETUPF(octett) (((octett) >> 4) & 0x01)
-
-/* commands/responses with pf bit set to 0 */
-
-#define SABME		0x6f
-#define	DM		0x0f
-#define UI		0x03
-#define DISC		0x43
-#define UA		0x63
-#define FRMR		0x87
-#define XID		0xaf
-
-/* control field - octett 3 */
-
-#define OFF_MEI		3	/* 2nd byte of control field */
-
-/* control field - octett 4,5 */
-
-#define OFF_RIL		4	/* Ri low byte */
-#define OFF_RIH		5	/* Ri high byte */
-
-/* control field - octett 6 */
-
-#define OFF_MT		6	/* Message Type */
-#define OFF_AI		7	/* Action Indicator  */
-#define GET_TEIFROMAI(octett) (((octett) >> 1) & 0x7f)
-
-/* I frame */
-
-#define I_HDR_LEN	4	/* length of I header in front of L3 frame */
-#define OFF_INS		2	/* transmit sequence number */
-#define OFF_INR		3	/* receive sequence number */
-#define IPFBIT		0x01	/* poll/final bit mask */
-#define IPBITSET	0x01
-#define GETINR(octett)	(((octett) >> 1) & 0x7f)
-#define GETINS(octett)	(((octett) >> 1) & 0x7f)
-#define GETIP(octett)	((octett) & IPFBIT)
-
-/* structure of a TEI management frame */
-
-#define TEI_MGMT_FRM_LEN   8		/* frame length */
-#define TEIM_SAPIO	0x00		/* SAPI, CR, EA */
-#define TEIM_TEIO	0x01		/* TEI, EA */
-#define TEIM_UIO	0x02		/* frame type = UI = 0x03 */
-#define TEIM_MEIO	0x03		/* management entity id = 0x0f */
-#define 	MEI	0x0f	
-#define TEIM_RILO	0x04		/* reference number, low  */
-#define TEIM_RIHO	0x05		/* reference number, high */
-#define TEIM_MTO	0x06		/* message type */
-#define 	MT_ID_REQEST	0x01
-#define 	MT_ID_ASSIGN	0x02
-#define 	MT_ID_DENY	0x03
-#define 	MT_ID_CHK_REQ	0x04
-#define 	MT_ID_CHK_RSP	0x05
-#define 	MT_ID_REMOVE	0x06
-#define 	MT_ID_VERIFY	0x07
-#define TEIM_AIO	0x07		/* action indicator */
-
-/* i4b_mdl_error_ind codes */
-
-enum MDL_ERROR_CODES {
-	MDL_ERR_A,
-	MDL_ERR_B,
-	MDL_ERR_C,
-	MDL_ERR_D,
-	MDL_ERR_E,
-	MDL_ERR_F,
-	MDL_ERR_G,
-	MDL_ERR_H,
-	MDL_ERR_I,
-	MDL_ERR_J,
-	MDL_ERR_K,
-	MDL_ERR_L,
-	MDL_ERR_M,
-	MDL_ERR_N,
-	MDL_ERR_O,
-	MDL_ERR_MAX	
-};
-
-/* forward decl */
-
-extern void i4b_acknowledge_pending ( l2_softc_t *l2sc );
-extern struct mbuf * i4b_build_s_frame ( l2_softc_t *l2sc, crbit_to_nt_t crbit, pbit_t pbit, u_char type );
-extern struct mbuf * i4b_build_u_frame ( l2_softc_t *l2sc, crbit_to_nt_t crbit, pbit_t pbit, u_char type );
-extern void i4b_clear_exception_conditions ( l2_softc_t *l2sc );
-extern int i4b_dl_data_req ( int unit, struct mbuf *m );
-extern int i4b_dl_establish_req ( int unit );
-extern int i4b_dl_release_req ( int unit );
-extern int i4b_dl_unit_data_req ( int unit, struct mbuf *m );
-extern void i4b_enquiry_response ( l2_softc_t *l2sc );
-extern void i4b_establish_data_link ( l2_softc_t *l2sc );
-extern void i4b_invoke_retransmission ( l2_softc_t *l2sc, int nr );
-extern void i4b_i_frame_queued_up ( l2_softc_t *l2sc );
-extern void i4b_l1_activate ( l2_softc_t *l2sc );
-extern int i4b_l2_nr_ok ( int nr, int va, int vs );
-extern void i4b_make_rand_ri ( l2_softc_t *l2sc );
-extern void i4b_mdl_assign_ind ( l2_softc_t *l2sc );
-extern void i4b_mdl_error_ind ( l2_softc_t *l2sc, char *where, int errorcode );
-extern int i4b_mph_status_ind ( int unit, int status, int parm );
-extern void i4b_next_l2state ( l2_softc_t *l2sc, int event );
-extern void i4b_nr_error_recovery ( l2_softc_t *l2sc );
-extern int i4b_ph_activate_ind ( int unit );
-extern int i4b_ph_deactivate_ind ( int unit );
-extern int i4b_ph_data_ind ( int unit, struct mbuf *m );
-extern void i4b_print_frame ( int len, u_char *buf );
-extern char *i4b_print_l2state ( l2_softc_t *l2sc );
-extern void i4b_print_l2var ( l2_softc_t *l2sc );
-extern void i4b_rxd_ack(l2_softc_t *l2sc, int nr);
-extern void i4b_rxd_i_frame ( int unit, struct mbuf *m );
-extern void i4b_rxd_s_frame ( int unit, struct mbuf *m );
-extern void i4b_rxd_u_frame ( int unit, struct mbuf *m );
-extern void i4b_T200_restart ( l2_softc_t *l2sc );
-extern void i4b_T200_start ( l2_softc_t *l2sc );
-extern void i4b_T200_stop ( l2_softc_t *l2sc );
-extern void i4b_T202_start ( l2_softc_t *l2sc );
-extern void i4b_T202_stop ( l2_softc_t *l2sc );
-extern void i4b_T203_restart ( l2_softc_t *l2sc );
-extern void i4b_T203_start ( l2_softc_t *l2sc );
-extern void i4b_T203_stop ( l2_softc_t *l2sc );
-extern void i4b_tei_assign ( l2_softc_t *l2sc );
-extern void i4b_tei_chkresp ( l2_softc_t *l2sc );
-extern void i4b_tei_rxframe ( int unit, struct mbuf *m );
-extern void i4b_tei_verify ( l2_softc_t *l2sc );
-extern void i4b_transmit_enquire ( l2_softc_t *l2sc );
-extern void i4b_tx_disc ( l2_softc_t *l2sc, pbit_t pbit );
-extern void i4b_tx_dm ( l2_softc_t *l2sc, fbit_t fbit );
-extern void i4b_tx_frmr ( l2_softc_t *l2sc, fbit_t fbit );
-extern void i4b_tx_rej_response ( l2_softc_t *l2sc, fbit_t fbit );
-extern void i4b_tx_rnr_command ( l2_softc_t *l2sc, pbit_t pbit );
-extern void i4b_tx_rnr_response ( l2_softc_t *l2sc, fbit_t fbit );
-extern void i4b_tx_rr_command ( l2_softc_t *l2sc, pbit_t pbit );
-extern void i4b_tx_rr_response ( l2_softc_t *l2sc, fbit_t fbit );
-extern void i4b_tx_sabme ( l2_softc_t *l2sc, pbit_t pbit );
-extern void i4b_tx_ua ( l2_softc_t *l2sc, fbit_t fbit );
-
-#endif /* _I4B_L2_H_ */
--- sys/i4b/layer1/iwic/i4b_iwic_pci.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 Dave Boyce. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_iwic - isdn4bsd Winbond W6692 driver
- *      ----------------------------------------
- *      last edit-date: [Tue Jan 16 10:53:03 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/iwic/i4b_iwic_pci.c,v 1.14 2005/03/19 03:00:22 murray Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/iwic/i4b_iwic.h>
-#include <i4b/layer1/iwic/i4b_w6692.h>
-
-extern struct i4b_l1mux_func iwic_l1mux_func;
-
-/* Winbond PCI Configuration Space */
-
-#define BADDR0 PCIR_BAR(0)
-#define BADDR1 PCIR_BAR(1)
-
-
-static void iwic_pci_intr(struct iwic_softc *sc);
-static int iwic_pci_probe(device_t dev);
-static int iwic_pci_attach(device_t dev);
-
-static device_method_t iwic_pci_methods[] =
-{
-	DEVMETHOD(device_probe,		iwic_pci_probe),
-	DEVMETHOD(device_attach,	iwic_pci_attach),
-	{ 0, 0 }
-};
-
-static driver_t iwic_pci_driver =
-{
-	"iwic",
-	iwic_pci_methods,
-	0
-};
-
-static devclass_t iwic_pci_devclass;
-
-DRIVER_MODULE(iwic, pci, iwic_pci_driver, iwic_pci_devclass, 0, 0);
-
-#define IWIC_MAXUNIT 4
-
-struct iwic_softc iwic_sc[IWIC_MAXUNIT];
-
-/*---------------------------------------------------------------------------*
- * PCI ID list for ASUSCOM card got from Asuscom in March 2000:
- *
- * Vendor ID: 0675 Device ID: 1702
- * Vendor ID: 0675 Device ID: 1703
- * Vendor ID: 0675 Device ID: 1707
- * Vendor ID: 10CF Device ID: 105E
- * Vendor ID: 1043 Device ID: 0675 SubVendor: 144F SubDevice ID: 2000
- * Vendor ID: 1043 Device ID: 0675 SubVendor: 144F SubDevice ID: 1702
- * Vendor ID: 1043 Device ID: 0675 SubVendor: 144F SubDevice ID: 1707
- * Vendor ID: 1043 Device ID: 0675 SubVendor: 1043 SubDevice ID: 1702
- * Vendor ID: 1043 Device ID: 0675 SubVendor: 1043 SubDevice ID: 1707
- * Vendor ID: 1050 Device ID: 6692 SubVendor: 0675 SubDevice ID: 1702
- * Vendor ID: 1043 Device ID: 0675 SubVendor: 0675 SubDevice ID: 1704
- *---------------------------------------------------------------------------*/
-
-static struct winids {
-	u_int32_t type;
-	int sv;	
-	int sd;	
-	const char *desc;
-} win_ids[] = {
- { 0x66921050, -1, -1,		"Generic Winbond W6692 ISDN PCI (0x66921050)"      },
- { 0x06751043, 0x0675, 0x1704,	"Planet PCI ISDN Adapter (IA128P-STD) ASUS-HCF675" },
- { 0x66921050, 0x144F, 0x1707,	"Planet PCI ISDN Adapter (Model IA128P-STDV)"      },
- { 0x17020675, -1, -1,		"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x17020675)" },
- { 0x17030675, -1, -1,		"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x17030675)" },
- { 0x17070675, -1, -1,		"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x17070675)" },
- { 0x105e10cf, -1, -1,		"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x105e10cf)" },
- { 0x06751043, 0x144F, 0x2000,	"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x06751043)" },
- { 0x06751043, 0x144F, 0x1702,	"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x06751043)" },
- { 0x06751043, 0x144F, 0x1707,	"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x06751043)" },
- { 0x06751043, 0x1443, 0x1702,	"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x06751043)" },
- { 0x06751043, 0x1443, 0x1707,	"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x06751043)" },
- { 0x06751043, 0x144F, 0x2000,	"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x06751043)" },
- { 0x06751043, 0x144F, 0x2000,	"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x06751043)" },
- { 0x06751043, 0x144F, 0x2000,	"ASUSCOM P-IN100-ST-D (Winbond W6692, 0x06751043)" },
- { 0x00000000, 0, 0, NULL }
-};
-
-/*---------------------------------------------------------------------------*
- *	iwic PCI probe
- *---------------------------------------------------------------------------*/
-static int
-iwic_pci_probe(device_t dev)
-{
-	u_int32_t type = pci_get_devid(dev);
-	u_int32_t sv = pci_get_subvendor(dev);
-	u_int32_t sd = pci_get_subdevice(dev);
-	
-	struct winids *wip = win_ids;
-
-	while(wip->type)
-	{
-		if(wip->type == type)
-		{
-			if(((wip->sv == -1) && (wip->sd == -1)) ||
-			   ((wip->sv == sv) && (wip->sd == sd)))
-				break;
-		}
-		++wip;
-	}
-
-	if(wip->desc)
-	{
-		if(bootverbose)
-		{
-			printf("iwic_pci_probe: vendor = 0x%x, device = 0x%x\n", pci_get_vendor(dev), pci_get_device(dev));
-			printf("iwic_pci_probe: subvendor = 0x%x, subdevice = 0x%x\n", sv, sd);
-		}
-		device_set_desc(dev, wip->desc);
-		return(0);
-	}
-	else
-	{
-		return(ENXIO);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	PCI attach
- *---------------------------------------------------------------------------*/
-static int
-iwic_pci_attach(device_t dev)
-{
-	unsigned short iobase;
-	struct iwic_softc *sc;
-	void *ih = 0;
-	int unit = device_get_unit(dev);
-	struct iwic_bchan *bchan;
-	
-	/* check max unit range */
-	
-	if(unit >= IWIC_MAXUNIT)
-	{
-		printf("iwic%d: Error, unit %d >= IWIC_MAXUNIT!\n", unit, unit);
-		return(ENXIO);	
-	}	
-
-	sc = iwic_find_sc(unit);	/* get softc */	
-	
-	sc->sc_unit = unit;
-
-	/* use the i/o mapped base address */
-	
-	sc->sc_resources.io_rid[0] = BADDR1;
-	
-	if(!(sc->sc_resources.io_base[0] =
-			bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-					       &sc->sc_resources.io_rid[0],
-					       RF_ACTIVE)))
-	{
-		printf("iwic%d: Couldn't alloc io port!\n", unit);
-		return(ENXIO);                                       
-	}
-
-	iobase = rman_get_start(sc->sc_resources.io_base[0]);
-
-	if(!(sc->sc_resources.irq =
-			bus_alloc_resource_any(dev, SYS_RES_IRQ,
-					       &sc->sc_resources.irq_rid,
-					       RF_SHAREABLE|RF_ACTIVE)))
-	{
-		printf("iwic%d: Couldn't alloc irq!\n",unit);
-		return(ENXIO);                                       
-	}
-	
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_WINB6692;
-	sc->sc_iobase = (u_int32_t) iobase;
-	sc->sc_trace = TRACE_OFF;
-	sc->sc_I430state = ST_F3N;	/* Deactivated */
-	sc->enabled = FALSE;
-	
-	if(bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET,
-				(void(*)(void*))iwic_pci_intr,
-				sc, &ih))
-	{
-		printf("iwic%d: Couldn't set up irq!\n", unit);
-		return(ENXIO);
-	}
-
-	/* disable interrupts */
-	IWIC_WRITE(sc, IMASK, 0xff);
-
-	iwic_dchan_init(sc);
-
-	bchan = &sc->sc_bchan[IWIC_BCH_A];
-	bchan->unit = unit;
-	bchan->offset = B1_CHAN_OFFSET;
-	bchan->channel = IWIC_BCH_A;
-	bchan->state = ST_IDLE;
-		
-	iwic_bchannel_setup(unit, IWIC_BCH_A, BPROT_NONE, 0);
-
-	bchan = &sc->sc_bchan[IWIC_BCH_B];
-	bchan->unit = unit;
-	bchan->offset = B2_CHAN_OFFSET;
-	bchan->channel = IWIC_BCH_B;
-	bchan->state = ST_IDLE;
-	
-	iwic_bchannel_setup(unit, IWIC_BCH_B, BPROT_NONE, 0);
-
-	iwic_init_linktab(sc);
-	
-	if(bootverbose)
-	{
-		int ver = IWIC_READ(sc, D_RBCH);
-		printf("iwic%d: W6692 chip version = %d\n", unit, D_RBCH_VN(ver));
-	}
-
-	i4b_l1_mph_status_ind(L0IWICUNIT(sc->sc_unit), STI_ATTACH, sc->sc_cardtyp, &iwic_l1mux_func);
-
-	IWIC_READ(sc, ISTA);
-
-	/* Enable interrupts */
-	IWIC_WRITE(sc, IMASK, IMASK_XINT0 | IMASK_XINT1);
-
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	IRQ handler
- *---------------------------------------------------------------------------*/
-static void
-iwic_pci_intr(struct iwic_softc *sc)
-{
-	while (1)
-	{
-		int irq_stat = IWIC_READ(sc, ISTA);
-
-		if (irq_stat == 0)
-			break;
-
-		if (irq_stat & (ISTA_D_RME | ISTA_D_RMR | ISTA_D_XFR))
-		{
-			iwic_dchan_xfer_irq(sc, irq_stat);
-		}
-		if (irq_stat & ISTA_D_EXI)
-		{
-			iwic_dchan_xirq(sc);
-		}
-		if (irq_stat & ISTA_B1_EXI)
-		{
-			iwic_bchan_xirq(sc, 0);
-		}
-		if (irq_stat & ISTA_B2_EXI)
-		{
-			iwic_bchan_xirq(sc, 1);
-		}
-	}
-}
--- sys/i4b/layer1/iwic/i4b_iwic_ext.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_iwic - isdn4bsd Winbond W6692 driver
- *      ----------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/iwic/i4b_iwic_ext.h,v 1.3 2005/01/06 22:18:21 imp Exp $
- *
- *      last edit-date: [Sun Jan 21 11:09:14 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_IWIC_EXT_H_
-#define _I4B_IWIC_EXT_H_
-
-#include <i4b/include/i4b_l3l4.h>
-
-void iwic_set_linktab(int unit, int channel, drvr_link_t * dlt);
-isdn_link_t *iwic_ret_linktab(int unit, int channel);
-
-int iwic_ph_data_req(int unit, struct mbuf *m, int freeflag);
-int iwic_ph_activate_req(int unit);
-int iwic_mph_command_req(int unit, int command, void *parm);
-
-#endif /* _I4B_IWIC_EXT_H_ */
--- sys/i4b/layer1/iwic/i4b_w6692.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 Dave Boyce. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_iwic - isdn4bsd Winbond W6692 driver
- *      ----------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/iwic/i4b_w6692.h,v 1.3 2005/01/06 22:18:21 imp Exp $
- *
- *      last edit-date: [Sun Jan 21 11:09:46 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_W6692_H_
-#define _I4B_W6692_H_
-
-#define IWIC_BCH_A       0       /* channel A */
-#define IWIC_BCH_B       1       /* channel B */
-
-/*---------------------------------------------------------------------------*
- *	FIFO depths
- *---------------------------------------------------------------------------*/
-#define IWIC_DCHAN_FIFO_LEN	64
-#define IWIC_BCHAN_FIFO_LEN	64
-
-/*---------------------------------------------------------------------------*
- *	D-Channel register offsets
- *---------------------------------------------------------------------------*/
-#define D_RFIFO		0x00	/* D channel receive FIFO */
-#define D_XFIFO		0x04	/* D channel transmit FIFO */
-#define D_CMDR		0x08	/* D channel command register */
-#define D_MODE		0x0c	/* D channel mode control */
-#define D_TIMR		0x10	/* D channel timer control */
-#define D_EXIR		0x1c	/* D channel extended interrupt */
-#define D_EXIM		0x20	/* D channel extended interrupt mask */
-#define D_STAR		0x24	/* D channel status register */
-#define D_RSTA		0x28	/* D channel receive status */
-#define D_SAM		0x2c	/* D channel address mask 1 */
-#define D_SAP1		0x30	/* D channel individual SAPI 1 */
-#define D_SAP2		0x34	/* D channel individual SAPI 2 */
-#define D_TAM		0x38	/* D channel address mask 2 */
-#define D_TEI1		0x3c	/* D channel individual TEI 1 */
-#define D_TEI2		0x40	/* D channel individual TEI 2 */
-#define D_RBCH		0x44	/* D channel receive frame byte count high */
-#define D_RBCL		0x48	/* D channel receive frame byte count low */
-#define D_CTL		0x54	/* D channel control register */
-
-/*---------------------------------------------------------------------------*
- *	B-channel base offsets
- *---------------------------------------------------------------------------*/
-#define B1_CHAN_OFFSET	0x80	/* B1 channel offset */
-#define B2_CHAN_OFFSET	0xc0	/* B2 channel offset */
-
-/*---------------------------------------------------------------------------*
- *	B-channel register offsets, from base
- *---------------------------------------------------------------------------*/
-#define B_RFIFO		0x00	/* B channel receive FIFO */
-#define B_XFIFO		0x04	/* B channel transmit FIFO */
-#define B_CMDR		0x08	/* B channel command register */
-#define B_MODE		0x0c	/* B channel mode control */
-#define B_EXIR		0x10	/* B channel extended interrupt */
-#define B_EXIM		0x14	/* B channel extended interrupt mask */
-#define B_STAR		0x18	/* B channel status register */
-#define B_ADM1		0x1c	/* B channel address mask 1 */
-#define B_ADM2		0x20	/* B channel address mask 2 */
-#define B_ADR1		0x24	/* B channel address 1 */
-#define B_ADR2		0x28	/* B channel address 2 */
-#define B_RBCL		0x2c	/* B channel receive frame byte count high */
-#define B_RBCH		0x30	/* B channel receive frame byte count low */
-
-/*---------------------------------------------------------------------------*
- * 	Remaining control register offsets.
- *---------------------------------------------------------------------------*/
-#define ISTA		0x14	/* Interrupt status register */
-#define IMASK		0x18	/* Interrupt mask register */
-#define TIMR2		0x4c	/* Timer 2 */
-#define L1_RC		0x50	/* GCI layer 1 ready code */
-#define CIR		0x58	/* Command/Indication receive */
-#define CIX		0x5c	/* Command/Indication transmit */
-#define SQR		0x60	/* S/Q channel receive register */
-#define SQX		0x64	/* S/Q channel transmit register */
-#define PCTL		0x68	/* Peripheral control register */
-#define MOR		0x6c	/* Monitor receive channel */
-#define MOX		0x70	/* Monitor transmit channel */
-#define MOSR		0x74	/* Monitor channel status register */
-#define MOCR		0x78	/* Monitor channel control register */
-#define GCR		0x7c	/* GCI mode control register */
-#define XADDR		0xf4	/* Peripheral address register */
-#define XDATA		0xf8	/* Peripheral data register */
-#define EPCTL		0xfc	/* Serial EEPROM control */
-
-/*---------------------------------------------------------------------------*
- *	register bits
- *---------------------------------------------------------------------------*/
-#define D_CMDR_RACK	0x80
-#define D_CMDR_RRST	0x40
-#define D_CMDR_STT	0x10
-#define D_CMDR_XMS	0x08
-#define D_CMDR_XME	0x02
-#define D_CMDR_XRST	0x01
-
-#define D_MODE_MMS	0x80
-#define D_MODE_RACT	0x40
-#define D_MODE_TMS	0x10
-#define D_MODE_TEE	0x08
-#define D_MODE_MFD	0x04
-#define D_MODE_DLP	0x02
-#define D_MODE_RLP	0x01
-
-#define D_TIMR_CNT(i)	(((i) >> 5) & 0x07)
-#define D_TIMR_VAL(i)   ((i) & 0x1f)
-
-#define ISTA_D_RMR	0x80
-#define ISTA_D_RME	0x40
-#define ISTA_D_XFR	0x20
-#define ISTA_XINT1	0x10
-#define ISTA_XINT0	0x08
-#define ISTA_D_EXI	0x04
-#define ISTA_B1_EXI	0x02
-#define ISTA_B2_EXI	0x01
-
-#define IMASK_D_RMR	0x80
-#define IMASK_D_RME	0x40
-#define IMASK_D_XFR	0x20
-#define IMASK_XINT1	0x10
-#define IMASK_XINT0	0x08
-#define IMASK_D_EXI	0x04
-#define IMASK_B1_EXI	0x02
-#define IMASK_B2_EXI	0x01
-
-#define D_EXIR_RDOV	0x80
-#define D_EXIR_XDUN	0x40
-#define D_EXIR_XCOL	0x20
-#define D_EXIR_TIN2	0x10
-#define D_EXIR_MOC	0x08
-#define D_EXIR_ISC	0x04
-#define D_EXIR_TEXP	0x02
-#define D_EXIR_WEXP	0x01
-
-#define D_EXIM_RDOV	0x80
-#define D_EXIM_XDUN	0x40
-#define D_EXIM_XCOL	0x20
-#define D_EXIM_TIM2	0x10
-#define D_EXIM_MOC	0x08
-#define D_EXIM_ISC	0x04
-#define D_EXIM_TEXP	0x02
-#define D_EXIM_WEXP	0x01
-
-#define D_STAR_XDOW	0x80
-#define D_STAR_XBZ	0x20
-#define D_STAR_DRDY	0x10
-
-#define D_RSTA_RDOV	0x40
-#define D_RSTA_CRCE	0x20
-#define D_RSTA_RMB	0x10
-
-#define D_RBCH_VN(i)	(((i) >> 6) & 0x03)
-#define D_RBCH_LOV	0x20
-#define D_RBC(h,l)      (((((h) & 0x1f)) << 8) + (l))
-
-#define D_TIMR2_TMD	0x80
-#define D_TIMR2_TBCN(i)	((i) & 0x3f)
-
-#define L1_RC_RC(i)	((i) & 0x0f)
-
-#define D_CTL_WTT(i)	(((i) > 6) & 0x03)
-#define D_CTL_SRST	0x20
-#define D_CTL_TPS	0x04
-#define D_CTL_OPS(i)	((i) & 0x03)
-
-#define CIR_SCC		0x80
-#define CIR_ICC		0x40
-#define CIR_CODR(i)	((i) & 0x0f)
-
-#define CIX_ECK		0x00
-#define CIX_RST		0x01
-#define CIX_SCP		0x04
-#define CIX_SSP		0x02
-#define CIX_AR8		0x08
-#define CIX_AR10       	0x09
-#define CIX_EAL		0x0a
-#define CIX_DRC		0x0f
-
-#define CIR_CE		0x07
-#define CIR_DRD		0x00
-#define CIR_LD		0x04
-#define CIR_ARD		0x08
-#define CIR_TI		0x0a
-#define CIR_ATI		0x0b
-#define CIR_AI8		0x0c
-#define CIR_AI10	0x0d
-#define CIR_CD		0x0f
-
-#define SQR_XIND1	0x80
-#define SQR_XIND0	0x40
-#define SQR_MSYN	0x20
-#define SQR_SCIE	0x10
-#define SQR_S(i)	((i) & 0x0f)
-
-#define SQX_SCIE	0x10
-#define SQX_Q(i)	((i) & 0x0f)
-
-
-#define B_CMDR_RACK	0x80
-#define B_CMDR_RRST	0x40
-#define B_CMDR_RACT	0x20
-#define B_CMDR_XMS 	0x04
-#define B_CMDR_XME 	0x02
-#define B_CMDR_XRST	0x01
-
-#define B_MODE_MMS	0x80
-#define B_MODE_ITF	0x40
-#define B_MODE_EPCM	0x20
-#define B_MODE_BSW1	0x10
-#define B_MODE_BSW0	0x08
-#define B_MODE_SW56	0x04
-#define B_MODE_FTS1	0x02
-#define B_MODE_FTS0	0x01
-
-#define B_EXIR_RMR	0x40
-#define B_EXIR_RME	0x20
-#define B_EXIR_RDOV	0x10
-#define B_EXIR_XFR	0x02
-#define B_EXIR_XDUN	0x01
-
-#define B_EXIM_RMR	0x40
-#define B_EXIM_RME	0x20
-#define B_EXIM_RDOV	0x10
-#define B_EXIM_XFR	0x02
-#define B_EXIM_XDUN	0x01
-
-#define B_STAR_RDOV	0x40
-#define B_STAR_CRCE	0x20
-#define B_STAR_RMB	0x10
-#define B_STAR_XDOW	0x04
-#define B_STAR_XBZ	0x01
-
-#define B_RBC(h,l)      (((((h) & 0x1f)) << 8) + (l))
-
-#endif /* _I4B_W6692_H_ */
--- sys/i4b/layer1/iwic/i4b_iwic.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 Dave Boyce. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_iwic - isdn4bsd Winbond W6692 driver
- *      ----------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/iwic/i4b_iwic.h,v 1.3 2005/01/06 22:18:20 imp Exp $
- *
- *      last edit-date: [Sun Jan 21 11:08:44 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_IWIC_H_
-#define _I4B_IWIC_H_
-
-#include <i4b/layer1/iwic/i4b_iwic_ext.h>
-
-/*---------------------------------------------------------------------------*
- *	PCI resources used
- *---------------------------------------------------------------------------*/
-
-#define INFO_IO_BASES	2
-
-struct i4b_info {
-	struct resource * io_base[INFO_IO_BASES];
-	int               io_rid [INFO_IO_BASES];
-	struct resource * irq;
-	int               irq_rid;
-	struct resource * mem;
-	int               mem_rid;
-};
-
-/*---------------------------------------------------------------------------*
- *	state of a B channel 
- *---------------------------------------------------------------------------*/
-struct iwic_bchan
-{
-	int unit;			/* unit number		*/
-	int channel;			/* channel number	*/
-	int offset;			/* offset from iobase	*/
-	int bprot;			/* b channel protocol used */
-	int state;			/* transceiver state:	*/
-#define ST_IDLE		0x00		/* channel idle		*/
-#define ST_TX_ACTIVE	0x01    	/* tx running		*/
-
-	int sc_trace_bcount;
-	
-        /* receive data from ISDN */
-
-	struct ifqueue	rx_queue;	/* receiver queue	*/
-	int		rxcount;	/* rx statistics counter*/
-	struct mbuf	*in_mbuf;	/* rx input buffer	*/
-	u_char		*in_cbptr;	/* curr buffer pointer	*/
-	int		in_len;		/* rx input buffer len	*/
-
-	/* transmit data to ISDN */
-
-	struct ifqueue	tx_queue;	/* transmitter queue		*/
-	int		txcount;	/* tx statistics counter	*/
-	struct mbuf	*out_mbuf_head;	/* first mbuf in possible chain */
-	struct mbuf	*out_mbuf_cur;	/* current mbuf in possbl chain */
-	unsigned char	*out_mbuf_cur_ptr; /* data pointer into mbuf    */
-	int		out_mbuf_cur_len; /* remaining bytes in mbuf    */
-	
-	/* linktab */
-	
-	isdn_link_t	iwic_isdn_linktab;
-	drvr_link_t	*iwic_drvr_linktab;
-};
-
-/*---------------------------------------------------------------------------*
- *	state of a D channel
- *---------------------------------------------------------------------------*/
-struct iwic_dchan
-{
-	int		enabled;
-	int		trace_count;
-	struct mbuf	*ibuf;
-	u_char		*ibuf_ptr;	/* Input buffer pointer */
-	int		ibuf_len;	/* Current length of input buffer */
-	int		ibuf_max_len;	/* Max length in input buffer */
-	int		rx_count;
-
-	int		tx_ready;	/* Can send next 64 bytes of data. */
-	int		tx_count;
-
-	struct mbuf	*obuf;
-	int		free_obuf;
-	u_char		*obuf_ptr;
-	int		obuf_len;
-
-	struct mbuf	*obuf2;
-	int		free_obuf2;
-};
-
-/*---------------------------------------------------------------------------*
- *	state of one iwic unit
- *---------------------------------------------------------------------------*/
-struct iwic_softc
-{
-	int		sc_unit;
-	u_int32_t	sc_iobase;
-	int		sc_trace;
-	int		sc_cardtyp;
-
-	int		sc_I430state;
-	int		sc_I430T3;
-
-	int		enabled;
-
-	struct iwic_dchan sc_dchan;
-	struct iwic_bchan sc_bchan[2];
-
-	struct i4b_info	sc_resources;
-};
-
-/*---------------------------------------------------------------------------*
- *	rd/wr register/fifo macros
- *---------------------------------------------------------------------------*/
-#define IWIC_READ(sc,reg)	(inb   ((sc)->sc_iobase + (u_int32_t)(reg)))
-#define IWIC_WRITE(sc,reg,val)	(outb  ((sc)->sc_iobase + (u_int32_t)(reg), (val)))
-#define IWIC_WRDFIFO(sc,p,l)    (outsb ((sc)->sc_iobase + D_XFIFO, (p), (l)))
-#define IWIC_RDDFIFO(sc,p,l)    (insb  ((sc)->sc_iobase + D_RFIFO, (p), (l)))
-#define IWIC_WRBFIFO(sc,b,p,l)  (outsb (((sc)->sc_iobase + (b)->offset + B_XFIFO), (p), (l)))
-#define IWIC_RDBFIFO(sc,b,p,l)  (insb  (((sc)->sc_iobase + (b)->offset + B_RFIFO), (p), (l)))
-
-/*---------------------------------------------------------------------------*
- *	possible I.430 states
- *---------------------------------------------------------------------------*/
-enum I430states
-{
-	ST_F3N,			/* F3 Deactivated, no clock	*/
-	ST_F3,			/* F3 Deactivated		*/
-	ST_F4,			/* F4 Awaiting Signal		*/
-	ST_F5,			/* F5 Identifying Input		*/
-	ST_F6,			/* F6 Synchronized		*/
-	ST_F7,			/* F7 Activated			*/
-	ST_F8,			/* F8 Lost Framing		*/
-	ST_ILL,			/* Illegal State		*/
-	N_STATES
-};
-
-/*---------------------------------------------------------------------------*
- *	possible I.430 events
- *---------------------------------------------------------------------------*/
-enum I430events
-{
-	EV_PHAR,		/* PH ACTIVATE REQUEST          */
-	EV_CE,			/* Clock enabled                */
-	EV_T3,			/* Timer 3 expired              */
-	EV_INFO0,		/* receiving INFO0              */
-	EV_RSY,			/* receiving any signal         */
-	EV_INFO2,		/* receiving INFO2              */
-	EV_INFO48,		/* receiving INFO4 pri 8/9      */
-	EV_INFO410,		/* receiving INFO4 pri 10/11    */
-	EV_DR,			/* Deactivate Request           */
-	EV_PU,			/* Power UP                     */
-	EV_DIS,			/* Disconnected (only 2085)     */
-	EV_EI,			/* Error Indication             */
-	EV_ILL,			/* Illegal Event                */
-	N_EVENTS
-};
-
-/*---------------------------------------------------------------------------*
- *	available commands
- *---------------------------------------------------------------------------*/
-enum I430commands
-{
-	CMD_ECK,		/* Enable clock			*/
-	CMD_TIM,		/* Timing			*/
-	CMD_RT,			/* Reset			*/
-	CMD_AR8,		/* Activation request pri 8	*/
-	CMD_AR10,		/* Activation request pri 10	*/
-	CMD_DIU,		/* Deactivate Indication Upstream */
-	CMD_ILL			/* Illegal command		*/
-};
-
-
-extern struct iwic_softc iwic_sc[];
-
-#define iwic_find_sc(unit)	(&iwic_sc[(unit)])
-
-extern void iwic_init(struct iwic_softc *);
-extern void iwic_next_state(struct iwic_softc *, int);
-
-extern void iwic_dchan_init(struct iwic_softc *);
-extern void iwic_dchan_xirq(struct iwic_softc *);
-extern void iwic_dchan_xfer_irq(struct iwic_softc *, int);
-extern void iwic_dchan_disable(struct iwic_softc *sc);
-extern int iwic_dchan_data_req(struct iwic_softc *sc, struct mbuf *m, int freeflag);
-extern void iwic_dchan_transmit(struct iwic_softc *sc);
-
-char *iwic_printstate(struct iwic_softc *sc);
-
-void iwic_init_linktab(struct iwic_softc *sc);
-void iwic_bchan_xirq(struct iwic_softc *, int);
-void iwic_bchannel_setup(int unit, int h_chan, int bprot, int activate);
-
-#endif /* _I4B_IWIC_H_ */
--- sys/i4b/layer1/iwic/i4b_iwic_dchan.c
+++ /dev/null
@@ -1,467 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 Dave Boyce. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_iwic - isdn4bsd Winbond W6692 driver
- *      ----------------------------------------
- *      last edit-date: [Tue Jan 16 13:20:14 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/iwic/i4b_iwic_dchan.c,v 1.8 2005/01/06 22:18:21 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer1/iwic/i4b_iwic.h>
-#include <i4b/layer1/iwic/i4b_w6692.h>
-
-#define MAX_DFRAME_LEN	264
-
-static void dchan_receive(struct iwic_softc *sc, int ista);
-
-/*---------------------------------------------------------------------------*
- *	initialize D-channel variables and registers
- *---------------------------------------------------------------------------*/
-void
-iwic_dchan_init(struct iwic_softc *sc)
-{
-	sc->sc_dchan.ibuf = NULL;
-	sc->sc_dchan.rx_count = 0;
-
-	sc->sc_dchan.obuf = NULL;
-	sc->sc_dchan.obuf2 = NULL;
-	sc->sc_dchan.tx_count = 0;
-	sc->sc_dchan.tx_ready = 0;
-
-	IWIC_WRITE(sc, D_CTL, D_CTL_SRST);
-
-	DELAY(5000);
-
-	IWIC_WRITE(sc, D_CTL, 0);
-
-	IWIC_WRITE(sc, SQX, SQX_SCIE);
-
-	IWIC_WRITE(sc, PCTL, 0x00);
-	IWIC_WRITE(sc, MOCR, 0x00);
-	IWIC_WRITE(sc, GCR, 0x00);
-
-	IWIC_WRITE(sc, D_CMDR, D_CMDR_RRST | D_CMDR_XRST);
-	IWIC_WRITE(sc, D_MODE, D_MODE_RACT);
-
-	IWIC_WRITE(sc, D_SAM, 0xff);
-	IWIC_WRITE(sc, D_TAM, 0xff);
-
-	IWIC_WRITE(sc, D_EXIM, 0x00);
-}
-
-/*---------------------------------------------------------------------------*
- *	Extended IRQ handler for the D-channel
- *---------------------------------------------------------------------------*/
-void
-iwic_dchan_xirq(struct iwic_softc *sc)
-{
-	int irq_stat;
-	int stat;
-
-	irq_stat = IWIC_READ(sc, D_EXIR);
-
-	if (irq_stat & D_EXIR_RDOV)
-	{
-		NDBGL1(L1_I_ERR, "RDOV in state %s", iwic_printstate(sc));
-		IWIC_WRITE(sc, D_CMDR, D_CMDR_RRST);
-	}
-	if (irq_stat & D_EXIR_XDUN)
-	{
-		NDBGL1(L1_I_ERR, "XDUN in state %s", iwic_printstate(sc));
-		sc->sc_dchan.tx_ready = 0;
-	}
-	if (irq_stat & D_EXIR_XCOL)
-	{
-		NDBGL1(L1_I_ERR, "XCOL in state %s", iwic_printstate(sc));
-		IWIC_WRITE(sc, D_CMDR, D_CMDR_XRST);
-		sc->sc_dchan.tx_ready = 0;
-	}
-	if (irq_stat & D_EXIR_TIN2)
-	{
-		NDBGL1(L1_I_ERR, "TIN2 in state %s", iwic_printstate(sc));
-	}
-	if (irq_stat & D_EXIR_MOC)
-	{
-		stat = IWIC_READ(sc, MOR);
-		NDBGL1(L1_I_ERR, "MOC in state %s, byte = 0x%x", iwic_printstate(sc), stat);
-	}
-
-	if (irq_stat & D_EXIR_ISC)
-	{
-		stat = (IWIC_READ(sc, CIR)) & 0x0f;
-
-		switch (stat)
-		{
-			case CIR_CE:
-				NDBGL1(L1_I_CICO, "rx CE in state %s", iwic_printstate(sc));
-				iwic_next_state(sc, EV_CE);
-				break;
-			case CIR_DRD:
-				NDBGL1(L1_I_CICO, "rx DRD in state %s", iwic_printstate(sc));
-				iwic_next_state(sc, EV_INFO0);
-				i4b_l1_mph_status_ind(L0IWICUNIT(sc->sc_unit), STI_L1STAT, LAYER_IDLE, NULL);
-				break;
-			case CIR_LD:
-				NDBGL1(L1_I_CICO, "rx LD in state %s", iwic_printstate(sc));
-				iwic_next_state(sc, EV_RSY);
-				break;
-			case CIR_ARD:
-				NDBGL1(L1_I_CICO, "rx ARD in state %s", iwic_printstate(sc));
-				iwic_next_state(sc, EV_INFO2);
-				break;
-			case CIR_TI:
-				NDBGL1(L1_I_CICO, "rx TI in state %s", iwic_printstate(sc));
-				iwic_next_state(sc, EV_INFO0);
-				break;
-			case CIR_ATI:
-				NDBGL1(L1_I_CICO, "rx ATI in state %s", iwic_printstate(sc));
-				iwic_next_state(sc, EV_INFO0);
-				break;
-			case CIR_AI8:
-				NDBGL1(L1_I_CICO, "rx AI8 in state %s", iwic_printstate(sc));
-				i4b_l1_mph_status_ind(L0IWICUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-				iwic_next_state(sc, EV_INFO48);
-				break;
-			case CIR_AI10:
-				NDBGL1(L1_I_CICO, "rx AI10 in state %s", iwic_printstate(sc));
-				i4b_l1_mph_status_ind(L0IWICUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-				iwic_next_state(sc, EV_INFO410);
-				break;
-			case CIR_CD:
-				NDBGL1(L1_I_CICO, "rx DIS in state %s", iwic_printstate(sc));
-				iwic_next_state(sc, EV_DIS);
-				break;
-			default:
-				NDBGL1(L1_I_ERR, "ERROR, unknown indication 0x%x in state %s", stat, iwic_printstate(sc));
-				iwic_next_state(sc, EV_INFO0);
-				break;
-		}
-	}
-
-	if (irq_stat & D_EXIR_TEXP)
-	{
-		NDBGL1(L1_I_ERR, "TEXP in state %s", iwic_printstate(sc));
-	}
-
-	if (irq_stat & D_EXIR_WEXP)
-	{
-		NDBGL1(L1_I_ERR, "WEXP in state %s", iwic_printstate(sc));
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	All receiving and transmitting takes place here.
- *---------------------------------------------------------------------------*/
-void
-iwic_dchan_xfer_irq(struct iwic_softc *sc, int ista)
-{
-	NDBGL1(L1_I_MSG, "ISTA = 0x%x", ista);
-
-	if (ista & (ISTA_D_RMR | ISTA_D_RME))
-	{
-		/* Receive message ready */
-		dchan_receive(sc, ista);
-	}
-	if (ista & ISTA_D_XFR)
-	{
-		/* Transmitter ready */
-		sc->sc_dchan.tx_ready = 1;
-
-		iwic_dchan_transmit(sc);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	disable D-channel
- *---------------------------------------------------------------------------*/
-void
-iwic_dchan_disable(struct iwic_softc *sc)
-{
-	int s;
-
-	s = SPLI4B();
-
-	if (sc->sc_dchan.obuf)
-	{
-		if (sc->sc_dchan.free_obuf)
-			i4b_Dfreembuf(sc->sc_dchan.obuf);
-		sc->sc_dchan.obuf = NULL;
-	}
-
-	if (sc->sc_dchan.obuf2)
-	{
-		if (sc->sc_dchan.free_obuf2)
-			i4b_Dfreembuf(sc->sc_dchan.obuf2);
-		sc->sc_dchan.obuf2 = NULL;
-	}
-
-	splx(s);
-
-	IWIC_WRITE(sc, CIX, CIX_DRC);
-}
-
-/*---------------------------------------------------------------------------*
- *	queue D-channel message for transmission
- *---------------------------------------------------------------------------*/
-int
-iwic_dchan_data_req(struct iwic_softc *sc, struct mbuf *m, int freeflag)
-{
-	int s;
-
-	if (!m)
-		return 0;
-
-	s = SPLI4B();
-
-	/* Queue message */
-
-	if (sc->sc_dchan.obuf)
-	{
-		if (sc->sc_dchan.obuf2)
-		{
-			NDBGL1(L1_I_ERR, "no buffer space!");
-		}
-		else
-		{
-			sc->sc_dchan.obuf2 = m;
-			sc->sc_dchan.free_obuf2 = freeflag;
-		}
-	}
-	else
-	{
-		sc->sc_dchan.obuf = m;
-		sc->sc_dchan.obuf_ptr = m->m_data;
-		sc->sc_dchan.obuf_len = m->m_len;
-		sc->sc_dchan.free_obuf = freeflag;
-	}
-
-	iwic_dchan_transmit(sc);
-
-	splx(s);
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------------*
- *	allocate an mbuf
- *---------------------------------------------------------------------------*/
-static void
-dchan_get_mbuf(struct iwic_softc *sc, int len)
-{
-	sc->sc_dchan.ibuf = i4b_Dgetmbuf(len);
-
-	if (!sc->sc_dchan.ibuf)
-		panic("dchan_get_mbuf: unable to allocate %d bytes for mbuf!\n", len);
-		
-	sc->sc_dchan.ibuf_ptr = sc->sc_dchan.ibuf->m_data;
-	sc->sc_dchan.ibuf_max_len = sc->sc_dchan.ibuf->m_len;
-	sc->sc_dchan.ibuf_len = 0;
-}
-
-/*---------------------------------------------------------------------------*
- *	D-channel receive data interrupt
- *---------------------------------------------------------------------------*/
-static void
-dchan_receive(struct iwic_softc *sc, int ista)
-{
-	int command = D_CMDR_RACK;
-	
-	if (ista & ISTA_D_RMR)
-	{
-		/* Got 64 bytes in FIFO */
-
-		if (!sc->sc_dchan.ibuf)
-		{
-			dchan_get_mbuf(sc, MAX_DFRAME_LEN);
-
-		}
-		else if ((sc->sc_dchan.ibuf_len + MAX_DFRAME_LEN) >
-			 sc->sc_dchan.ibuf_max_len)
-		{
-			panic("dchan_receive: not enough space in buffer!\n");
-		}
-
-		IWIC_RDDFIFO(sc, sc->sc_dchan.ibuf_ptr, 64);
-
-		sc->sc_dchan.ibuf_ptr += 64;
-		sc->sc_dchan.ibuf_len += 64;
-		sc->sc_dchan.rx_count += 64;
-	}
-	if (ista & ISTA_D_RME)
-	{
-		/* Got end of frame */
-		int status;
-
-		status = IWIC_READ(sc, D_RSTA);
-
-		if (status & (D_RSTA_RDOV | D_RSTA_CRCE | D_RSTA_RMB))
-		{
-			if (status & D_RSTA_RDOV)
-				NDBGL1(L1_I_ERR, "iwic%d: D-channel Receive Data Overflow", sc->sc_unit);
-			if (status & D_RSTA_CRCE)
-				NDBGL1(L1_I_ERR, "iwic%d: D-channel CRC Error", sc->sc_unit);
-			if (status & D_RSTA_RMB)
-				NDBGL1(L1_I_ERR, "iwic%d: D-channel Receive Message Aborted", sc->sc_unit);
-			command |= D_CMDR_RRST;
-		}
-		else
-		{
-			int hi, lo;
-			int total_frame_len;
-	
-			lo = IWIC_READ(sc, D_RBCL);
-			hi = IWIC_READ(sc, D_RBCH);
-			total_frame_len = D_RBC(hi, lo);
-			lo = lo & 0x3f;
-	
-			if (lo == 0)
-				lo = IWIC_DCHAN_FIFO_LEN;
-	
-			if (!sc->sc_dchan.ibuf)
-			{
-				dchan_get_mbuf(sc, lo);
-			}
-			else if ((sc->sc_dchan.ibuf_len + lo) >
-				 sc->sc_dchan.ibuf_max_len)
-			{
-				panic("dchan_receive: buffer not long enough");
-			}
-	
-			IWIC_RDDFIFO(sc, sc->sc_dchan.ibuf_ptr, lo);
-			sc->sc_dchan.ibuf_len += lo;
-			sc->sc_dchan.rx_count += lo;
-	
-			sc->sc_dchan.ibuf->m_len = sc->sc_dchan.ibuf_len;
-	
-			if(sc->sc_trace & TRACE_D_RX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0IWICUNIT(sc->sc_unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_NT;
-				hdr.count = ++sc->sc_dchan.trace_count;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, sc->sc_dchan.ibuf->m_len, sc->sc_dchan.ibuf->m_data);
-			}
-			i4b_l1_ph_data_ind(L0IWICUNIT(sc->sc_unit), sc->sc_dchan.ibuf);
-			
-			sc->sc_dchan.ibuf = NULL;
-		}
-	}
-	IWIC_WRITE(sc, D_CMDR, command);
-}
-
-/*---------------------------------------------------------------------------*
- *	transmit D-channel frame
- *---------------------------------------------------------------------------*/
-void
-iwic_dchan_transmit(struct iwic_softc *sc)
-{
-	int cmd;
-	u_char *ptr;
-	int len;
-
-	if (!sc->sc_dchan.tx_ready)
-		return;
-
-	if (!sc->sc_dchan.obuf)
-		return;
-
-	if (sc->sc_I430state != ST_F7)
-		return;
-
-	ptr = sc->sc_dchan.obuf_ptr;
-	len = min(sc->sc_dchan.obuf_len, IWIC_DCHAN_FIFO_LEN);
-
-	if(sc->sc_trace & TRACE_D_TX)
-	{
-		i4b_trace_hdr_t hdr;	
-		hdr.unit = L0IWICUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_D;
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_dchan.trace_count;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, len, ptr);
-	}
-
-	IWIC_WRDFIFO(sc, ptr, len);
-
-	sc->sc_dchan.tx_count += len;
-
-	if (len < sc->sc_dchan.obuf_len)
-	{
-		sc->sc_dchan.obuf_ptr += len;
-		sc->sc_dchan.obuf_len -= len;
-
-		cmd = D_CMDR_XMS;
-
-	}
-	else
-	{
-		if (sc->sc_dchan.free_obuf)
-			i4b_Dfreembuf(sc->sc_dchan.obuf);
-
-		sc->sc_dchan.obuf = NULL;
-		sc->sc_dchan.obuf_ptr = NULL;
-		sc->sc_dchan.obuf_len = 0;
-
-		if (sc->sc_dchan.obuf2)
-		{
-			sc->sc_dchan.obuf = sc->sc_dchan.obuf2;
-			sc->sc_dchan.obuf_ptr = sc->sc_dchan.obuf->m_data;
-			sc->sc_dchan.obuf_len = sc->sc_dchan.obuf->m_len;
-			sc->sc_dchan.free_obuf = sc->sc_dchan.free_obuf2;
-
-			sc->sc_dchan.obuf2 = NULL;
-		}
-		cmd = D_CMDR_XMS | D_CMDR_XME;
-	}
-	sc->sc_dchan.tx_ready = 0;
-	IWIC_WRITE(sc, D_CMDR, cmd);
-}
--- sys/i4b/layer1/iwic/i4b_iwic_bchan.c
+++ /dev/null
@@ -1,767 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 Dave Boyce. 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_iwic - isdn4bsd Winbond W6692 driver
- *      ----------------------------------------
- *      last edit-date: [Tue Jan 16 13:21:24 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/iwic/i4b_iwic_bchan.c,v 1.14 2005/01/06 22:18:21 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/iwic/i4b_iwic.h>
-#include <i4b/layer1/iwic/i4b_w6692.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-static void iwic_bchan_init(struct iwic_softc *sc, int chan_no, int activate);
-
-/*---------------------------------------------------------------------------*
- *	B-channel interrupt handler
- *---------------------------------------------------------------------------*/
-void
-iwic_bchan_xirq(struct iwic_softc *sc, int chan_no)
-{
-	int irq_stat;
-	struct iwic_bchan *chan;
-	int cmd = 0;
-	int activity = 0;
-
-	chan = &sc->sc_bchan[chan_no];
-
-	irq_stat = IWIC_READ(sc, chan->offset + B_EXIR);
-
-	NDBGL1(L1_H_IRQ, "irq_stat = 0x%x", irq_stat);
-	
-	if((irq_stat & (B_EXIR_RMR | B_EXIR_RME | B_EXIR_RDOV | B_EXIR_XFR | B_EXIR_XDUN)) == 0)
-	{
-		NDBGL1(L1_H_XFRERR, "spurious IRQ!");
-		return;
-	}
-
-	if (irq_stat & B_EXIR_RDOV)
-	{
-		NDBGL1(L1_H_XFRERR, "iwic%d: EXIR B-channel Receive Data Overflow", sc->sc_unit);
-	}
-
-	if (irq_stat & B_EXIR_XDUN)
-	{
-		NDBGL1(L1_H_XFRERR, "iwic%d: EXIR B-channel Transmit Data Underrun", sc->sc_unit);
-		cmd |= (B_CMDR_XRST);	/*XXX must retransmit frame ! */
-	}
-
-/* RX message end interrupt */
-	
-	if(irq_stat & B_EXIR_RME)
-	{
-		int error;
-
-		NDBGL1(L1_H_IRQ, "B_EXIR_RME");
-
-		error = (IWIC_READ(sc,chan->offset+B_STAR) &
-			 (B_STAR_RDOV | B_STAR_CRCE | B_STAR_RMB));
-
-		if(error)
-		{
-			if(error & B_STAR_RDOV)
-				NDBGL1(L1_H_XFRERR, "iwic%d: B-channel Receive Data Overflow", sc->sc_unit);
-			if(error & B_STAR_CRCE)
-				NDBGL1(L1_H_XFRERR, "iwic%d: B-channel CRC Error", sc->sc_unit);
-			if(error & B_STAR_RMB)
-				NDBGL1(L1_H_XFRERR, "iwic%d: B-channel Receive Message Aborted", sc->sc_unit);
-		}
-
-		/* all error conditions checked, now decide and take action */
-		
-		if(error == 0)
-		{
-			register int fifo_data_len;
-			fifo_data_len = ((IWIC_READ(sc,chan->offset+B_RBCL)) &
-					((IWIC_BCHAN_FIFO_LEN)-1));
-		
-			if(fifo_data_len == 0)
-				fifo_data_len = IWIC_BCHAN_FIFO_LEN;
-
-
-			if(chan->in_mbuf == NULL)
-			{
-				if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-					panic("L1 iwic_bchan_irq: RME, cannot allocate mbuf!\n");
-				chan->in_cbptr = chan->in_mbuf->m_data;
-				chan->in_len = 0;
-			}
-
-			if((chan->in_len + fifo_data_len) <= BCH_MAX_DATALEN)
-			{
-				/* read data from fifo */
-	
-				NDBGL1(L1_H_IRQ, "B_EXIR_RME, rd fifo, len = %d", fifo_data_len);
-
-				IWIC_RDBFIFO(sc, chan, chan->in_cbptr, fifo_data_len);
-
-				cmd |= (B_CMDR_RACK | B_CMDR_RACT);
-				IWIC_WRITE(sc, chan->offset + B_CMDR, cmd);
-				cmd = 0;
-				
-		                chan->in_len += fifo_data_len;
-				chan->rxcount += fifo_data_len;
-
-				/* setup mbuf data length */
-					
-				chan->in_mbuf->m_len = chan->in_len;
-				chan->in_mbuf->m_pkthdr.len = chan->in_len;
-
-				if(sc->sc_trace & TRACE_B_RX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IWICUNIT(sc->sc_unit);
-					hdr.type = (chan_no == IWIC_BCH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_NT;
-					hdr.count = ++sc->sc_bchan[chan_no].sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-				}
-
-				(*chan->iwic_drvr_linktab->bch_rx_data_ready)(chan->iwic_drvr_linktab->unit);
-
-				activity = ACT_RX;
-				
-				/* mark buffer ptr as unused */
-					
-				chan->in_mbuf = NULL;
-				chan->in_cbptr = NULL;
-				chan->in_len = 0;
-			}
-			else
-			{
-				NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RME, in_len=%d, fifolen=%d", chan->in_len, fifo_data_len);
-				chan->in_cbptr = chan->in_mbuf->m_data;
-				chan->in_len = 0;
-				cmd |= (B_CMDR_RRST | B_CMDR_RACK);
-			}
-		}
-		else
-		{
-			if (chan->in_mbuf != NULL)
-			{
-				i4b_Bfreembuf(chan->in_mbuf);
-				chan->in_mbuf = NULL;
-				chan->in_cbptr = NULL;
-				chan->in_len = 0;
-			}
-			cmd |= (B_CMDR_RRST | B_CMDR_RACK);
-		}
-	}
-
-/* RX fifo full interrupt */
-
-	if(irq_stat & B_EXIR_RMR)
-	{
-		NDBGL1(L1_H_IRQ, "B_EXIR_RMR");
-
-		if(chan->in_mbuf == NULL)
-		{
-			if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-				panic("L1 iwic_bchan_irq: RMR, cannot allocate mbuf!\n");
-			chan->in_cbptr = chan->in_mbuf->m_data;
-			chan->in_len = 0;
-		}
-
-		chan->rxcount += IWIC_BCHAN_FIFO_LEN;
-		
-		if((chan->in_len + IWIC_BCHAN_FIFO_LEN) <= BCH_MAX_DATALEN)
-		{
-			/* read data from fifo */
-
-			NDBGL1(L1_H_IRQ, "B_EXIR_RMR, rd fifo, len = max (64)");
-			
-			IWIC_RDBFIFO(sc, chan, chan->in_cbptr, IWIC_BCHAN_FIFO_LEN);
-
-			chan->in_cbptr += IWIC_BCHAN_FIFO_LEN;
-	                chan->in_len += IWIC_BCHAN_FIFO_LEN;
-		}
-		else
-		{
-			if(chan->bprot == BPROT_NONE)
-			{
-				/* setup mbuf data length */
-				
-				chan->in_mbuf->m_len = chan->in_len;
-				chan->in_mbuf->m_pkthdr.len = chan->in_len;
-
-				if(sc->sc_trace & TRACE_B_RX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IWICUNIT(sc->sc_unit);
-					hdr.type = (chan_no == IWIC_BCH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_NT;
-					hdr.count = ++sc->sc_bchan[chan_no].sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
-				}
-
-				/* silence detection */
-				
-				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);
-				
-				/* alloc new buffer */
-				
-				if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-					panic("L1 iwic_bchan_irq: RMR, cannot allocate new mbuf!\n");
-	
-				/* setup new data ptr */
-				
-				chan->in_cbptr = chan->in_mbuf->m_data;
-	
-				/* read data from fifo */
-	
-				NDBGL1(L1_H_IRQ, "B_EXIR_RMR, rd fifo1, len = max (64)");
-				
-				IWIC_RDBFIFO(sc, chan, chan->in_cbptr, IWIC_BCHAN_FIFO_LEN);
-
-				chan->in_cbptr += IWIC_BCHAN_FIFO_LEN;
-				chan->in_len = IWIC_BCHAN_FIFO_LEN;
-
-				chan->rxcount += IWIC_BCHAN_FIFO_LEN;
-			}
-			else
-			{
-				NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RPF, in_len=%d", chan->in_len);
-				chan->in_cbptr = chan->in_mbuf->m_data;
-				chan->in_len = 0;
-				cmd |= (B_CMDR_RRST | B_CMDR_RACK);
-			}
-		}
-		
-		/* command to release fifo space */
-		
-		cmd |= B_CMDR_RACK;
-	}
-
-/* TX interrupt */
-	
-	if (irq_stat & B_EXIR_XFR)
-	{			
-		/* transmit fifo empty, new data can be written to fifo */
-
-		int activity = -1;
-		int len;
-		int nextlen;
-
-		NDBGL1(L1_H_IRQ, "B_EXIR_XFR");
-		
-		if(chan->out_mbuf_cur == NULL) 	/* last frame is transmitted */
-		{
-			IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-
-			if(chan->out_mbuf_head == NULL)
-			{
-				chan->state &= ~ST_TX_ACTIVE;
-				(*chan->iwic_drvr_linktab->bch_tx_queue_empty)(chan->iwic_drvr_linktab->unit);
-			}
-			else
-			{
-				chan->state |= ST_TX_ACTIVE;
-				chan->out_mbuf_cur = chan->out_mbuf_head;
-				chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-				chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-
-				if(sc->sc_trace & TRACE_B_TX)
-				{
-					i4b_trace_hdr_t hdr;
-					hdr.unit = L0IWICUNIT(sc->sc_unit);
-					hdr.type = (chan_no == IWIC_BCH_A ? TRC_CH_B1 : TRC_CH_B2);
-					hdr.dir = FROM_TE;
-					hdr.count = ++sc->sc_bchan[chan_no].sc_trace_bcount;
-					MICROTIME(hdr.time);
-					i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-				}
-
-				if(chan->bprot == BPROT_NONE)
-				{
-					if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-						activity = ACT_TX;
-				}
-				else
-				{
-					activity = ACT_TX;
-				}
-			}
-		}
-			
-		len = 0;
-
-		while(chan->out_mbuf_cur && len != IWIC_BCHAN_FIFO_LEN)
-		{
-			nextlen = min(chan->out_mbuf_cur_len, IWIC_BCHAN_FIFO_LEN - len);
-
-			NDBGL1(L1_H_IRQ, "B_EXIR_XFR, wr fifo, len = %d", nextlen);
-			
-			IWIC_WRBFIFO(sc, chan, chan->out_mbuf_cur_ptr, nextlen);
-
-			cmd |= B_CMDR_XMS;
-	
-			len += nextlen;
-			chan->txcount += nextlen;
-	
-			chan->out_mbuf_cur_ptr += nextlen;
-			chan->out_mbuf_cur_len -= nextlen;
-			
-			if(chan->out_mbuf_cur_len == 0) 
-			{
-				if((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL)
-				{
-					chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-					chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-
-					if(sc->sc_trace & TRACE_B_TX)
-					{
-						i4b_trace_hdr_t hdr;
-						hdr.unit = L0IWICUNIT(sc->sc_unit);
-						hdr.type = (chan_no == IWIC_BCH_A ? TRC_CH_B1 : TRC_CH_B2);
-						hdr.dir = FROM_TE;
-						hdr.count = ++sc->sc_bchan[chan_no].sc_trace_bcount;
-						MICROTIME(hdr.time);
-						i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-					}
-				}
-				else
-				{
-					if (chan->bprot != BPROT_NONE)
-						cmd |= B_CMDR_XME;
-					i4b_Bfreembuf(chan->out_mbuf_head);
-					chan->out_mbuf_head = NULL;
-				}
-			}
-		}
-	}
-	if(cmd)
-	{
-		cmd |= B_CMDR_RACT;
-		IWIC_WRITE(sc, chan->offset + B_CMDR, cmd);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	initialize one B channels rx/tx data structures
- *---------------------------------------------------------------------------*/
-void
-iwic_bchannel_setup(int unit, int chan_no, int bprot, int activate)
-{
-	struct iwic_softc *sc = &iwic_sc[unit];
-	struct iwic_bchan *chan = &sc->sc_bchan[chan_no];
-
-	int s = SPLI4B();
-	
-	NDBGL1(L1_BCHAN, "unit %d, chan %d, bprot %d, activate %d", unit, chan_no, bprot, activate);
-
-	/* general part */
-
-	chan->bprot = bprot;		/* B channel protocol */
-	chan->state = ST_IDLE;		/* B channel state */
-
-	if(activate == 0)
-	{
-		/* deactivation */
-		iwic_bchan_init(sc, chan_no, activate);
-	}
-		
-	/* receiver part */
-
-	chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-#if defined (__FreeBSD__) && __FreeBSD__ > 4
-	if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
-		mtx_init(&chan->rx_queue.ifq_mtx, "i4b_iwic_rx", NULL, MTX_DEF);
-#endif
-
-	i4b_Bcleanifq(&chan->rx_queue);	/* clean rx queue */
-
-	chan->rxcount = 0;		/* reset rx counter */
-	
-	i4b_Bfreembuf(chan->in_mbuf);	/* clean rx mbuf */
-
-	chan->in_mbuf = NULL;		/* reset mbuf ptr */
-	chan->in_cbptr = NULL;		/* reset mbuf curr ptr */
-	chan->in_len = 0;		/* reset mbuf data len */
-	
-	/* transmitter part */
-
-	chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-#if defined (__FreeBSD__) && __FreeBSD__ > 4	
-	if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
-		mtx_init(&chan->tx_queue.ifq_mtx, "i4b_iwic_tx", NULL, MTX_DEF);
-#endif
-
-	i4b_Bcleanifq(&chan->tx_queue);	/* clean tx queue */
-	
-	chan->txcount = 0;		/* reset tx counter */
-	
-	i4b_Bfreembuf(chan->out_mbuf_head);	/* clean tx mbuf */
-
-	chan->out_mbuf_head = NULL;	/* reset head mbuf ptr */
-	chan->out_mbuf_cur = NULL;	/* reset current mbuf ptr */	
-	chan->out_mbuf_cur_ptr = NULL;	/* reset current mbuf data ptr */
-	chan->out_mbuf_cur_len = 0;	/* reset current mbuf data cnt */
-	
-	if(activate != 0)
-	{
-		/* activation */
-		iwic_bchan_init(sc, chan_no, activate);
-	}
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	initalize / deinitialize B-channel hardware
- *---------------------------------------------------------------------------*/
-static void
-iwic_bchan_init(struct iwic_softc *sc, int chan_no, int activate)
-{
-	struct iwic_bchan *bchan = &sc->sc_bchan[chan_no];
-
-	NDBGL1(L1_BCHAN, "chan %d, activate %d", chan_no, activate);
-
-	if(activate)
-	{
-		if(bchan->bprot == BPROT_NONE)
-		{
-			/* Extended transparent mode */
-			IWIC_WRITE(sc, bchan->offset + B_MODE, B_MODE_MMS);
-		}
-		else
-		{
-			/* Transparent mode */
-			IWIC_WRITE(sc, bchan->offset + B_MODE, 0);
-			/* disable address comparation */
-			IWIC_WRITE (sc, bchan->offset+B_ADM1, 0xff);
-			IWIC_WRITE (sc, bchan->offset+B_ADM2, 0xff);
-		}
-
-		/* reset & start receiver */
-		IWIC_WRITE(sc, bchan->offset + B_CMDR, B_CMDR_RRST|B_CMDR_RACT);
-
-		/* clear irq mask */
-		IWIC_WRITE(sc, bchan->offset + B_EXIM, 0);
-	}
-	else
-	{
-		/* mask all irqs */		
-		IWIC_WRITE(sc, bchan->offset + B_EXIM, 0xff);
-
-		/* reset mode */
-		IWIC_WRITE(sc, bchan->offset + B_MODE, 0);
-		
-		/* Bring interface down */
-		IWIC_WRITE(sc, bchan->offset + B_CMDR, B_CMDR_RRST | B_CMDR_XRST);
-
-		/* Flush pending interrupts */
-		IWIC_READ(sc, bchan->offset + B_EXIR);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	start transmission on a b channel
- *---------------------------------------------------------------------------*/
-static void
-iwic_bchannel_start(int unit, int chan_no)
-{
-	struct iwic_softc *sc = &iwic_sc[unit];
-	register struct iwic_bchan *chan = &sc->sc_bchan[chan_no];
-	register int next_len;
-	register int len;
-
-	int s;
-	int activity = -1;
-	int cmd = 0;
-
-	s = SPLI4B();				/* enter critical section */
-
-	NDBGL1(L1_BCHAN, "unit %d, channel %d", unit, chan_no);
-
-	if(chan->state & ST_TX_ACTIVE)		/* already running ? */
-	{
-		splx(s);
-		return;				/* yes, leave */
-	}
-
-	/* get next mbuf from queue */
-	
-	IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
-	
-	if(chan->out_mbuf_head == NULL)		/* queue empty ? */
-	{
-		splx(s);			/* leave critical section */
-		return;				/* yes, exit */
-	}
-
-	/* init current mbuf values */
-	
-	chan->out_mbuf_cur = chan->out_mbuf_head;
-	chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-	chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;	
-	
-	/* activity indicator for timeout handling */
-
-	if(chan->bprot == BPROT_NONE)
-	{
-		if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
-			activity = ACT_TX;
-	}
-	else
-	{
-		activity = ACT_TX;
-	}
-
-	chan->state |= ST_TX_ACTIVE;		/* we start transmitting */
-
-	if(sc->sc_trace & TRACE_B_TX)	/* if trace, send mbuf to trace dev */
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0IWICUNIT(unit);
-		hdr.type = (chan_no == IWIC_BCH_A ? TRC_CH_B1 : TRC_CH_B2);
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_bchan[chan_no].sc_trace_bcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-	}			
-
-	len = 0;	/* # of chars put into tx fifo this time */
-
-	/*
-	 * fill the tx fifo with data from the current mbuf. if
-	 * current mbuf holds less data than fifo length, try to
-	 * get the next mbuf from (a possible) mbuf chain. if there is
-	 * not enough data in a single mbuf or in a chain, then this
-	 * is the last mbuf and we tell the chip that it has to send
-	 * CRC and closing flag
-	 */
-	 
-	while((len < IWIC_BCHAN_FIFO_LEN) && chan->out_mbuf_cur)
-	{
-		/*
-		 * put as much data into the fifo as is
-		 * available from the current mbuf
-		 */
-		 
-		if((len + chan->out_mbuf_cur_len) >= IWIC_BCHAN_FIFO_LEN)
-			next_len = IWIC_BCHAN_FIFO_LEN - len;
-		else
-			next_len = chan->out_mbuf_cur_len;
-
-		/* write what we have from current mbuf to fifo */
-
-		IWIC_WRBFIFO(sc, chan, chan->out_mbuf_cur_ptr, next_len);
-		
-		len += next_len;		/* update # of bytes written */
-		chan->txcount += next_len;	/* statistics */
-		chan->out_mbuf_cur_ptr += next_len;	/* data ptr */
-		chan->out_mbuf_cur_len -= next_len;	/* data len */
-
-		/*
-		 * in case the current mbuf (of a possible chain) data
-		 * has been put into the fifo, check if there is a next
-		 * mbuf in the chain. If there is one, get ptr to it
-		 * and update the data ptr and the length
-		 */
-		 
-		if((chan->out_mbuf_cur_len <= 0)	&&
-		  ((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL))
-		{
-			chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
-			chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
-
-			if(sc->sc_trace & TRACE_B_TX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0IWICUNIT(unit);
-				hdr.type = (chan_no == IWIC_BCH_A ? TRC_CH_B1 : TRC_CH_B2);
-				hdr.dir = FROM_TE;
-				hdr.count = ++sc->sc_bchan[chan_no].sc_trace_bcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
-			}
-		}
-	}
-
-	/*
-	 * if there is either still data in the current mbuf and/or
-	 * there is a successor on the chain available issue just
-	 * a XTF (transmit) command to the chip. if there is no more
-	 * data available from the current mbuf (-chain), issue
-	 * an XTF and an XME (message end) command which will then
-	 * send the CRC and the closing HDLC flag sequence
-	 */
-	 
-	if(chan->out_mbuf_cur && (chan->out_mbuf_cur_len > 0))
-	{
-		/*
-		 * more data available, send current fifo out.
-		 * next xfer to tx fifo is done in the
-		 * interrupt routine.
-		 */
-		 
-		cmd |= B_CMDR_XMS;
-	}
-	else
-	{
-		/* end of mbuf chain */
-	
-		if(chan->bprot == BPROT_NONE)
-			cmd |= B_CMDR_XMS;
-		else
-			cmd |= (B_CMDR_XMS | B_CMDR_XME);
-		
-		i4b_Bfreembuf(chan->out_mbuf_head);	/* free mbuf chain */
-		
-		chan->out_mbuf_head = NULL;
-		chan->out_mbuf_cur = NULL;			
-		chan->out_mbuf_cur_ptr = NULL;
-		chan->out_mbuf_cur_len = 0;
-	}
-
-	/* call timeout handling routine */
-	
-	if(activity == ACT_RX || activity == ACT_TX)
-		(*chan->iwic_drvr_linktab->bch_activity)(chan->iwic_drvr_linktab->unit, activity);
-
-	if(cmd)
-	{
-		cmd |= B_CMDR_RACT;
-		IWIC_WRITE(sc, chan->offset + B_CMDR, cmd);
-	}
-		
-	splx(s);	
-}
-
-/*---------------------------------------------------------------------------*
- *	return B-channel statistics
- *---------------------------------------------------------------------------*/
-static void
-iwic_bchannel_stat(int unit, int chan_no, bchan_statistics_t *bsp)
-{
-	struct iwic_softc *sc = iwic_find_sc(unit);
-	struct iwic_bchan *bchan = &sc->sc_bchan[chan_no];
-
-	int s = SPLI4B();
-
-	bsp->outbytes = bchan->txcount;
-	bsp->inbytes = bchan->rxcount;
-
-	bchan->txcount = 0;
-	bchan->rxcount = 0;
-
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	initialize our local linktab
- *---------------------------------------------------------------------------*/
-void
-iwic_init_linktab(struct iwic_softc *sc)
-{
-	struct iwic_bchan *chan;
-	isdn_link_t *lt;
-
-	/* make sure the hardware driver is known to layer 4 */
-	ctrl_types[CTRL_PASSIVE].set_linktab = i4b_l1_set_linktab;
-	ctrl_types[CTRL_PASSIVE].get_linktab = i4b_l1_ret_linktab;
-
-	/* channel A */
-	
-	chan = &sc->sc_bchan[IWIC_BCH_A];
-	lt = &chan->iwic_isdn_linktab;
-	
-	lt->unit = sc->sc_unit;
-	lt->channel = IWIC_BCH_A;
-	lt->bch_config = iwic_bchannel_setup;
-	lt->bch_tx_start = iwic_bchannel_start;
-	lt->bch_stat = iwic_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-                                                
-	/* channel B */
-	
-	chan = &sc->sc_bchan[IWIC_BCH_B];
-	lt = &chan->iwic_isdn_linktab;
-	
-	lt->unit = sc->sc_unit;
-	lt->channel = IWIC_BCH_B;
-	lt->bch_config = iwic_bchannel_setup;
-	lt->bch_tx_start = iwic_bchannel_start;
-	lt->bch_stat = iwic_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-}
--- sys/i4b/layer1/iwic/i4b_iwic_fsm.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 Dave Boyce. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_iwic - isdn4bsd Winbond W6692 driver
- *      ----------------------------------------
- *      last edit-date: [Sun Jan 21 11:09:24 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/iwic/i4b_iwic_fsm.c,v 1.8 2005/01/06 22:18:21 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer1/iwic/i4b_iwic.h>
-#include <i4b/layer1/iwic/i4b_w6692.h>
-
-#if DO_I4B_DEBUG
-static char *state_names[] = {
-	"F3N",
-	"F3",
-	"F4",
-	"F5",
-	"F6",
-	"F7",
-	"F8",
-	"ILLEGAL",
-};
-
-static char *event_names[] = {
-	"PHAR",
-	"CE",
-	"T3",
-	"INFO0",
-	"RSY",
-	"INFO2",
-	"INFO48",
-	"INFO410",
-	"DR",
-	"PU",
-	"DIS",
-	"EI",
-	"ILLEGAL"
-};
-#endif
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_NULL(struct iwic_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_NULL executing");
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_AR(struct iwic_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_AR executing");
-	IWIC_WRITE(sc, CIX, CIX_ECK);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_AR3(struct iwic_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_AR3 executing");
-	IWIC_WRITE(sc, CIX, CIX_AR8);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_I0I(struct iwic_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_IOI executing");
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_I0A(struct iwic_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_IOA executing");
-	iwic_dchan_disable(sc);
-	i4b_l1_ph_deactivate_ind(L0IWICUNIT(sc->sc_unit));
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_AI8(struct iwic_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_AI8 executing");
-	iwic_dchan_transmit(sc);
-	i4b_l1_ph_activate_ind(L0IWICUNIT(sc->sc_unit));
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static void
-F_AI10(struct iwic_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_AI10 executing");
-	iwic_dchan_transmit(sc);
-	i4b_l1_ph_activate_ind(L0IWICUNIT(sc->sc_unit));
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-struct iwic_state_tab {
-	void (*func) (struct iwic_softc *sc);	/* function to execute */
-	int newstate;				/* next state */
-} iwic_state_tab[N_EVENTS][N_STATES] = {
-
-/* STATE:       F3N                  F3                  F4                  F5                  F6                  F7                  F8                  ILLEGAL STATE        */
-/* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ */
-/* EV_PHAR   */ {{F_AR,   ST_F3  },  {F_AR3,  ST_F4  },  {F_NULL, ST_F4  },  {F_NULL, ST_F5  },  {F_NULL, ST_F6  },  {F_NULL, ST_F7  },  {F_NULL, ST_F8  },  {F_NULL, ST_ILL }},
-/* EV_CE     */ {{F_NULL, ST_F3  },  {F_AR3,  ST_F4  },  {F_NULL, ST_F4  },  {F_NULL, ST_F4  },  {F_NULL, ST_F4  },  {F_NULL, ST_F4  },  {F_NULL, ST_F4  },  {F_NULL, ST_ILL }},
-/* EV_T3     */ {{F_NULL, ST_F3N },  {F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F7  },  {F_NULL, ST_F8  },  {F_NULL, ST_ILL }},
-/* EV_INFO0  */ {{F_I0I,  ST_F3  },  {F_I0I,  ST_F3  },  {F_I0I,  ST_F3  },  {F_I0I,  ST_F3  },  {F_I0A,  ST_F3  },  {F_I0A,  ST_F3  },  {F_I0A,  ST_F3  },  {F_NULL, ST_ILL }},
-/* EV_RSY    */ {{F_NULL, ST_F3  },  {F_NULL, ST_F5  },  {F_NULL, ST_F5  },  {F_NULL, ST_F5  },  {F_NULL, ST_F8  },  {F_NULL, ST_F8  },  {F_NULL, ST_F8  },  {F_NULL, ST_ILL }},
-/* EV_INFO2  */ {{F_NULL, ST_F6  },  {F_NULL, ST_F6  },  {F_NULL, ST_F6  },  {F_NULL, ST_F6  },  {F_NULL, ST_F6  },  {F_NULL, ST_F6  },  {F_NULL, ST_F6  },  {F_NULL, ST_ILL }},
-/* EV_INFO48 */ {{F_AI8 , ST_F7  },  {F_AI8,  ST_F7  },  {F_AI8,  ST_F7  },  {F_AI8,  ST_F7  },  {F_AI8,  ST_F7  },  {F_AI8,  ST_F7  },  {F_AI8,  ST_F7  },  {F_NULL, ST_ILL }},
-/* EV_INFO410*/ {{F_AI10, ST_F7  },  {F_AI10, ST_F7  },  {F_AI10, ST_F7  },  {F_AI10, ST_F7  },  {F_AI10, ST_F7  },  {F_AI10, ST_F7  },  {F_AI10, ST_F7  },  {F_NULL, ST_ILL }},
-/* EV_DR     */ {{F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F4  },  {F_NULL, ST_F5  },  {F_NULL, ST_F6  },  {F_NULL, ST_F7  },  {F_NULL, ST_F8  },  {F_NULL, ST_ILL }},
-/* EV_PU     */ {{F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F4  },  {F_NULL, ST_F5  },  {F_NULL, ST_F6  },  {F_NULL, ST_F7  },  {F_NULL, ST_F8  },  {F_NULL, ST_ILL }},
-/* EV_DIS    */ {{F_NULL, ST_F3N },  {F_NULL, ST_F3N },  {F_NULL, ST_F3N },  {F_NULL, ST_F3N },  {F_NULL, ST_F3N },  {F_I0A,  ST_F3N },  {F_I0A,  ST_F3N },  {F_NULL, ST_ILL }},
-/* EV_EI     */ {{F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_F3  },  {F_NULL, ST_ILL }},
-/* EV_ILL    */ {{F_NULL, ST_ILL },  {F_NULL, ST_ILL },  {F_NULL, ST_ILL },  {F_NULL, ST_ILL },  {F_NULL, ST_ILL },  {F_NULL, ST_ILL },  {F_NULL, ST_ILL },  {F_NULL, ST_ILL }},
-};
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-void
-iwic_next_state(struct iwic_softc *sc, int event)
-{
-	int currstate, newstate;
-
-	NDBGL1(L1_F_MSG, "event %s", event_names[event]);
-
-	if (event >= N_EVENTS)
-	{
-		printf("iwic_next_state: event >= N_EVENTS\n");
-		return;
-	}
-
-	currstate = sc->sc_I430state;
-
-	newstate = iwic_state_tab[event][currstate].newstate;
-	if (newstate >= N_STATES)
-	{
-		printf("iwic_next_state: newstate >= N_STATES\n");
-		return;
-	}
-
-	NDBGL1(L1_F_MSG, "state %s -> %s",
-		state_names[currstate], state_names[newstate]);
-
-	sc->sc_I430state = newstate;
-
-	(*iwic_state_tab[event][currstate].func) (sc);
-}
-
-#if DO_I4B_DEBUG
-/*---------------------------------------------------------------------------*
- *      return pointer to current state description
- *---------------------------------------------------------------------------*/
-char *
-iwic_printstate(struct iwic_softc *sc)
-{
-	return((char *)state_names[sc->sc_I430state]);
-}
-#endif
--- sys/i4b/layer1/iwic/i4b_iwic_l1if.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 Dave Boyce. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_iwic - isdn4bsd Winbond W6692 driver
- *      ----------------------------------------
- *      last edit-date: [Sun Jan 21 11:09:33 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/iwic/i4b_iwic_l1if.c,v 1.9 2005/01/06 22:18:21 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/iwic/i4b_iwic.h>
-#include <i4b/layer1/iwic/i4b_iwic_ext.h>
-
-/* jump table for multiplex routines */
-
-struct i4b_l1mux_func iwic_l1mux_func = {
-	iwic_ret_linktab,
-	iwic_set_linktab,
-	iwic_mph_command_req,
-	iwic_ph_data_req,
-	iwic_ph_activate_req,
-};
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-int
-iwic_ph_data_req(int unit, struct mbuf *m, int freeflag)
-{
-	struct iwic_softc *sc = iwic_find_sc(unit);
-
-	return iwic_dchan_data_req(sc, m, freeflag);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-int
-iwic_ph_activate_req(int unit)
-{
-	struct iwic_softc *sc = iwic_find_sc(unit);
-
-	iwic_next_state(sc, EV_PHAR);
-
-	return 0;
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-int
-iwic_mph_command_req(int unit, int command, void *parm)
-{
-	struct iwic_softc *sc = iwic_find_sc(unit);
-
-	switch (command)
-	{
-		case CMR_DOPEN:	/* Daemon running */
-			NDBGL1(L1_PRIM, "CMR_DOPEN");
-			sc->enabled = TRUE;
-			break;
-
-		case CMR_DCLOSE:	/* Daemon not running */
-			NDBGL1(L1_PRIM, "CMR_DCLOSE");
-			sc->enabled = FALSE;
-			break;
-
-		case CMR_SETTRACE:
-			NDBGL1(L1_PRIM, "CMR_SETTRACE, parm = %d", (unsigned int)parm);
-			sc->sc_trace = (unsigned int)parm;
-			break;
-
-		default:
-			NDBGL1(L1_PRIM, "unknown command = %d", command);
-			break;
-	}
-
-	return 0;
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-isdn_link_t *
-iwic_ret_linktab(int unit, int channel)
-{
-	struct iwic_softc *sc = iwic_find_sc(unit);
-	struct iwic_bchan *bchan = &sc->sc_bchan[channel];
-
-	return &bchan->iwic_isdn_linktab;
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-void
-iwic_set_linktab (int unit, int channel, drvr_link_t *dlt)
-{
-	struct iwic_softc *sc = iwic_find_sc(unit);
-	struct iwic_bchan *bchan = &sc->sc_bchan[channel];
-
-	bchan->iwic_drvr_linktab = dlt;
-}
--- sys/i4b/layer3/i4b_q932fac.c
+++ /dev/null
@@ -1,541 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_q932fac.c - Q932 facility handling
- *	--------------------------------------
- *      last edit-date: [Sat Mar  9 19:37:29 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer3/i4b_q932fac.c,v 1.14 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer3/i4b_l3.h>
-#include <i4b/layer3/i4b_q932fac.h>
-
-static int do_component(int length);
-static void next_state(int class, int form, int code, int val);
-
-static int byte_len;
-static unsigned char *byte_buf;
-static int state;
-
-static int units;
-static int operation_value;
-
-/*---------------------------------------------------------------------------*
- *	decode Q.931/Q.932 facility info element
- *---------------------------------------------------------------------------*/
-int
-i4b_aoc(unsigned char *buf, call_desc_t *cd)
-{
-	int len;
-
-	cd->units_type = CHARGE_INVALID;
-	cd->units = -1;			
-	
-	buf++;		/* length */
-
-	len = *buf;
-
-	buf++;		/* protocol profile */
-
-	switch(*buf & 0x1f)
-	{
-		case FAC_PROTO_ROP:
-			break;
-
-		case FAC_PROTO_CMIP:
-			NDBGL3(L3_A_MSG, "CMIP Protocol (Q.941), UNSUPPORTED");
-			return(-1);
-			break;
-
-		case FAC_PROTO_ACSE:
-			NDBGL3(L3_A_MSG, "ACSE Protocol (X.217/X.227), UNSUPPORTED!");
-			return(-1);
-			break;
-
-		default:
-			NDBGL3(L3_A_ERR, "Unknown Protocol, UNSUPPORTED!");
-			return(-1);
-			break;
-	}
-
-	NDBGL3(L3_A_MSG, "Remote Operations Protocol");
-
-	/* next byte */
-	
-	buf++;
-	len--;
-
-	/* initialize variables for do_component */
-	
-	byte_len = 0;
-	byte_buf = buf;
-	state = ST_EXP_COMP_TYP;	
-
-	/* decode facility */
-	
-	do_component(len);
-
-	switch(operation_value)
-	{
-		case FAC_OPVAL_AOC_D_CUR:
-			cd->units_type = CHARGE_AOCD;
-			cd->units = 0;
-			return(0);
-			break;
-			
-		case FAC_OPVAL_AOC_D_UNIT:
-			cd->units_type = CHARGE_AOCD;
-			cd->units = units;
-			return(0);
-			break;
-			
-		case FAC_OPVAL_AOC_E_CUR:
-			cd->units_type = CHARGE_AOCE;
-			cd->units = 0;
-			return(0);
-			break;
-			
-		case FAC_OPVAL_AOC_E_UNIT:
-			cd->units_type = CHARGE_AOCE;
-			cd->units = units;
-			return(0);
-			break;
-
-		default:
-			cd->units_type = CHARGE_INVALID;
-			cd->units = -1;
-			return(-1);
-			break;
-	}
-	return(-1);	
-}
-
-/*---------------------------------------------------------------------------*
- *	handle a component recursively
- *---------------------------------------------------------------------------*/
-static int
-do_component(int length)
-{
-	int comp_tag_class;	/* component tag class */
-	int comp_tag_form;	/* component form: constructor or primitive */
-	int comp_tag_code;	/* component code depending on class */
-	int comp_length = 0;	/* component length */
-
-again:
-
-	/*----------------------------------------*/
-	/* first component element: component tag */
-	/*----------------------------------------*/
-	
-	/* tag class bits */
-
-	comp_tag_class = (*byte_buf & 0xc0) >> 6;
-	
-	switch(comp_tag_class)
-	{
-		case FAC_TAGCLASS_UNI:
-			break;
-		case FAC_TAGCLASS_APW:
-			break;
-		case FAC_TAGCLASS_COS:
-			break;
-		case FAC_TAGCLASS_PRU:
-			break;
-	}
-
-	/* tag form bit */
-
-	comp_tag_form = (*byte_buf & 0x20) > 5;
-	
-	/* tag code bits */
-
-	comp_tag_code = *byte_buf & 0x1f;
-	
-	if(comp_tag_code == 0x1f)
-	{
-		comp_tag_code = 0;
-		
-		byte_buf++;
-		byte_len++;
-
-		while(*byte_buf & 0x80)
-		{
-			comp_tag_code += (*byte_buf & 0x7f);
-			byte_buf++;
-			byte_len++;
-		}
-		comp_tag_code += (*byte_buf & 0x7f);
-	}
-	else
-	{
-		comp_tag_code = (*byte_buf & 0x1f);
-	}
-
-	byte_buf++;
-	byte_len++;
-	
-	/*--------------------------------------------*/
-	/* second component element: component length */
-	/*--------------------------------------------*/
-	
-	comp_length = 0;
-	
-	if(*byte_buf & 0x80)
-	{
-		int i = *byte_buf & 0x7f;
-
-		byte_len += i;
-		
-		for(;i > 0;i++)
-		{
-			byte_buf++;
-			comp_length += (*byte_buf * (i*256));
-		}	
-	}
-	else
-	{
-		comp_length = *byte_buf & 0x7f;
-	}
-
-	next_state(comp_tag_class, comp_tag_form, comp_tag_code, -1);
-	
-	byte_len++;
-	byte_buf++;
-	
-	/*---------------------------------------------*/
-	/* third component element: component contents */
-	/*---------------------------------------------*/
-
-	if(comp_tag_form)	/* == constructor */
-	{
-		do_component(comp_length);
-	}
-	else 
-	{
-		int val = 0;		
-		if(comp_tag_class == FAC_TAGCLASS_UNI)
-		{
-			switch(comp_tag_code)
-			{
-				case FAC_CODEUNI_INT:
-				case FAC_CODEUNI_ENUM:
-				case FAC_CODEUNI_BOOL:				
-					if(comp_length)
-					{
-						int i;
-				
-						for(i = comp_length-1; i >= 0; i--)
-						{
-							val += (*byte_buf + (i*255));
-							byte_buf++;
-							byte_len++;
-						}
-					}
-					break;
-				default:	
-					if(comp_length)
-					{
-						int i;
-				
-						for(i = comp_length-1; i >= 0; i--)
-						{
-							byte_buf++;
-							byte_len++;
-						}
-					}
-					break;
-			}
-		}
-
-		else	/* comp_tag_class != FAC_TAGCLASS_UNI */
-		{
-			if(comp_length)
-			{
-				int i;
-		
-				for(i = comp_length-1; i >= 0; i--)
-				{
-					val += (*byte_buf + (i*255)); 
-					byte_buf++;
-					byte_len++;
-				}
-			}
-		}
-		next_state(comp_tag_class, comp_tag_form, comp_tag_code, val);
-	}
-
-	if(byte_len < length)
-		goto again;
-
-	return(byte_len);
-}
-
-/*---------------------------------------------------------------------------*
- *	invoke component
- *---------------------------------------------------------------------------*/
-static void
-F_1_1(int val)
-{
-	if(val == -1)
-	{
-		state = ST_EXP_INV_ID;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	return result
- *---------------------------------------------------------------------------*/
-static void
-F_1_2(int val)
-{
-	if(val == -1)
-		state = ST_EXP_NIX;
-}
-/*---------------------------------------------------------------------------*
- *	return error
- *---------------------------------------------------------------------------*/
-static void
-F_1_3(int val)
-{
-	if(val == -1)
-		state = ST_EXP_NIX;
-}
-/*---------------------------------------------------------------------------*
- *	reject
- *---------------------------------------------------------------------------*/
-static void
-F_1_4(int val)
-{
-	if(val == -1)
-		state = ST_EXP_NIX;
-}
-
-/*---------------------------------------------------------------------------*
- *	invoke id
- *---------------------------------------------------------------------------*/
-static void
-F_2(int val)
-{
-	if(val != -1)
-	{
-		NDBGL3(L3_A_MSG, "Invoke ID = %d", val);
-		state = ST_EXP_OP_VAL;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	operation value
- *---------------------------------------------------------------------------*/
-static void
-F_3(int val)
-{
-	if(val != -1)
-	{
-		NDBGL3(L3_A_MSG, "Operation Value = %d", val);
-	
-		operation_value = val;
-		
-		if((val == FAC_OPVAL_AOC_D_UNIT) || (val == FAC_OPVAL_AOC_E_UNIT))
-		{
-			units = 0;
-			state = ST_EXP_INFO;
-		}
-		else
-		{
-			state = ST_EXP_NIX;
-		}
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	specific charging units
- *---------------------------------------------------------------------------*/
-static void
-F_4(int val)
-{
-	if(val == -1)
-		state = ST_EXP_RUL;
-}
-
-/*---------------------------------------------------------------------------*
- *	free of charge
- *---------------------------------------------------------------------------*/
-static void
-F_4_1(int val)
-{
-	if(val == -1)
-	{
-		NDBGL3(L3_A_MSG, "Free of Charge");
-		/* units = 0; XXXX */
-		state = ST_EXP_NIX;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	charge not available
- *---------------------------------------------------------------------------*/
-static void
-F_4_2(int val)
-{
-	if(val == -1)
-	{
-		NDBGL3(L3_A_MSG, "Charge not available");
-		/* units = -1; 	XXXXXX ??? */
-		state = ST_EXP_NIX;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	recorded units list
- *---------------------------------------------------------------------------*/
-static void
-F_5(int val)
-{
-	if(val == -1)
-		state = ST_EXP_RU;
-}
-
-/*---------------------------------------------------------------------------*
- *	recorded units
- *---------------------------------------------------------------------------*/
-static void
-F_6(int val)
-{
-	if(val == -1)
-		state = ST_EXP_RNOU;
-}
-
-/*---------------------------------------------------------------------------*
- *	number of units
- *---------------------------------------------------------------------------*/
-static void
-F_7(int val)
-{
-	if(val != -1)
-	{
-		NDBGL3(L3_A_MSG, "Number of Units = %d", val);
-		units = val;
-		state = ST_EXP_TOCI;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	subtotal/total
- *---------------------------------------------------------------------------*/
-static void
-F_8(int val)
-{
-	if(val != -1)
-	{
-		NDBGL3(L3_A_MSG, "Subtotal/Total = %d", val);
-		/* type_of_charge = val; */
-		state = ST_EXP_DBID;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	billing_id
- *---------------------------------------------------------------------------*/
-static void
-F_9(int val)
-{
-	if(val != -1)
-	{
-		NDBGL3(L3_A_MSG, "Billing ID = %d", val);
-		/* billing_id = val; */
-		state = ST_EXP_NIX;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------------*/
-static struct statetab {
-	int currstate;		/* input: current state we are in */
-	int form;		/* input: current tag form */
-	int class;		/* input: current tag class */
-	int code;		/* input: current tag code */
-	void (*func)(int);	/* output: func to exec */
-} statetab[] = {
-
-/*	 current state		tag form		tag class		tag code		function	*/
-/*	 ---------------------  ----------------------  ----------------------  ---------------------- 	----------------*/
-	{ST_EXP_COMP_TYP,	FAC_TAGFORM_CON,	FAC_TAGCLASS_COS,	1,			F_1_1		},
-	{ST_EXP_COMP_TYP,	FAC_TAGFORM_CON,	FAC_TAGCLASS_COS,	2,			F_1_2		},
-	{ST_EXP_COMP_TYP,	FAC_TAGFORM_CON,	FAC_TAGCLASS_COS,	3,			F_1_3		},
-	{ST_EXP_COMP_TYP,	FAC_TAGFORM_CON,	FAC_TAGCLASS_COS,	4,			F_1_4		},
-	{ST_EXP_INV_ID,		FAC_TAGFORM_PRI,	FAC_TAGCLASS_UNI,	FAC_CODEUNI_INT,	F_2		},
-	{ST_EXP_OP_VAL,		FAC_TAGFORM_PRI,	FAC_TAGCLASS_UNI,	FAC_CODEUNI_INT,	F_3		},
-	{ST_EXP_INFO,		FAC_TAGFORM_CON,	FAC_TAGCLASS_UNI,	FAC_CODEUNI_SEQ,	F_4		},
-	{ST_EXP_INFO,		FAC_TAGFORM_PRI,	FAC_TAGCLASS_UNI,	FAC_CODEUNI_NULL,	F_4_1		},
-	{ST_EXP_INFO,		FAC_TAGFORM_PRI,	FAC_TAGCLASS_COS,	1,			F_4_2		},
-	{ST_EXP_RUL,		FAC_TAGFORM_CON,	FAC_TAGCLASS_COS,	1,			F_5		},
-	{ST_EXP_RU,		FAC_TAGFORM_CON,	FAC_TAGCLASS_UNI,	FAC_CODEUNI_SEQ,	F_6		},
-	{ST_EXP_RNOU,		FAC_TAGFORM_PRI,	FAC_TAGCLASS_UNI,	FAC_CODEUNI_INT,	F_7		},
-	{ST_EXP_TOCI,		FAC_TAGFORM_PRI,	FAC_TAGCLASS_COS,	2,			F_8		},
-	{ST_EXP_DBID,		FAC_TAGFORM_PRI,	FAC_TAGCLASS_COS,	3,			F_9		},
-	{-1,			-1,			-1,			-1,			NULL		}
-};	
-	
-/*---------------------------------------------------------------------------*
- *	state decode for do_component
- *---------------------------------------------------------------------------*/
-static void
-next_state(int class, int form, int code, int val)
-{
-	int i;
-
-	for(i=0; ; i++)
-	{
-		if((statetab[i].currstate > state) ||
-		   (statetab[i].currstate == -1))
-		{
-			break;
-		}
-
-		if((statetab[i].currstate == state) 	&&
-		   (statetab[i].form == form)		&&
-		   (statetab[i].class == class)		&&
-		   (statetab[i].code == code))
-		{
-			(*statetab[i].func)(val);
-			break;
-		}
-	}
-}
--- sys/i4b/layer3/i4b_l2if.c
+++ /dev/null
@@ -1,680 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l2if.c - Layer 3 interface to Layer 2
- *	-------------------------------------------
- *      last edit-date: [Sun Aug 11 12:48:41 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer3/i4b_l2if.c,v 1.16 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include <i4b/include/i4b_isdnq931.h>
-#include <i4b/include/i4b_l2l3.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer3/i4b_l3.h>
-#include <i4b/layer3/i4b_l3fsm.h>
-#include <i4b/layer3/i4b_q931.h>
-
-
-static unsigned char make_q931_cause(cause_t cause);
-
-/*---------------------------------------------------------------------------*
- * this converts our internal state (number) to the number specified
- * in Q.931 and is used for reporting our state in STATUS messages.
- *---------------------------------------------------------------------------*/
-int i4b_status_tab[] = {
-	0,	/*	ST_U0,	*/
-	1,	/*	ST_U1,	*/
-	3,	/*	ST_U3,	*/
-	4,	/*	ST_U4,	*/
-	6,	/*	ST_U6,	*/
-	7,	/*	ST_U7,	*/
-	8,	/*	ST_U8,	*/
-	9,	/*	ST_U9,	*/
-	10,	/*	ST_U10,	*/
-	11,	/*	ST_U11,	*/
-	12,	/*	ST_U12,	*/
-	19,	/*	ST_U19,	*/
-	6,	/*	ST_IWA,	*/
-	6,	/*	ST_IWR,	*/
-	1,	/*	ST_OW,	*/
-	6,	/*	ST_IWL,	*/	
-};
-
-/*---------------------------------------------------------------------------*
- *	return a valid q.931/q.850 cause from any of the internal causes
- *---------------------------------------------------------------------------*/
-static unsigned char
-make_q931_cause(cause_t cause)
-{
-	register unsigned char ret;
-	
-	switch(GET_CAUSE_TYPE(cause))
-	{
-		case CAUSET_Q850:
-			ret = GET_CAUSE_VAL(cause);
-			break;
-		case CAUSET_I4B:
-			ret = cause_tab_q931[GET_CAUSE_VAL(cause)];
-			break;
-		default:
-			panic("make_q931_cause: unknown cause type!");
-			break;
-	}
-	ret |= EXT_LAST;
-	return(ret);
-}
-
-/*---------------------------------------------------------------------------*
- *	return status of data link
- *---------------------------------------------------------------------------*/
-int
-i4b_get_dl_stat(call_desc_t *cd)
-{
-	return(ctrl_desc[cd->controller].dl_est);
-}
-
-/*---------------------------------------------------------------------------*
- *	DL ESTABLISH INDICATION from Layer 2
- *---------------------------------------------------------------------------*/
-int
-i4b_dl_establish_ind(int unit)
-{
-	int i;
-	int found = 0;
-	
-	NDBGL2(L2_PRIM, "DL-ESTABLISH-IND unit %d",unit);
-
-	/* first set DL up in controller descriptor */
-	
-	for(i=0; i < nctrl; i++)
-	{
-		if((ctrl_desc[i].ctrl_type == CTRL_PASSIVE) &&
-		   (ctrl_desc[i].unit == unit))
-                {
-                 	NDBGL3(L3_MSG, "unit=%d DL established!",unit);
-			ctrl_desc[i].dl_est = DL_UP;
-			found = 1;
-		}
-	}
-
-	if(found == 0)
-	{
-	       	NDBGL3(L3_ERR, "ERROR, controller not found for unit=%d!",unit);
-		return(-1);	       	
-	}
-
-	found = 0;
-
-	/* second, inform all (!) active call of the event */
-	
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		if( (call_desc[i].cdid != 0) &&
-		    (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
-		    (ctrl_desc[call_desc[i].controller].unit == unit))
-                {
-                 	NDBGL3(L3_MSG, "unit=%d, index=%d cdid=%u cr=%d",
-					unit, i, call_desc[i].cdid, call_desc[i].cr);
-			next_l3state(&call_desc[i], EV_DLESTIN);
-			found++;
-		}
-	}
-	
-	if(found == 0)
-	{
-		NDBGL3(L3_ERR, "ERROR, no cdid for unit %d found!", unit);
-		return(-1);
-	}
-	else
-	{
-		return(0);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	DL ESTABLISH CONFIRM from Layer 2
- *---------------------------------------------------------------------------*/
-int
-i4b_dl_establish_cnf(int unit)
-{
-	int i;
-	int found = 0;
-
-	NDBGL2(L2_PRIM, "DL-ESTABLISH-CONF unit %d",unit);
-	
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		if( (call_desc[i].cdid != 0) &&
-		    (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
-		    (ctrl_desc[call_desc[i].controller].unit == unit))
-                {
-			ctrl_desc[call_desc[i].controller].dl_est = DL_UP;
-
-                 	NDBGL3(L3_MSG, "unit=%d, index=%d cdid=%u cr=%d",
-					unit, i, call_desc[i].cdid, call_desc[i].cr);
-
-			next_l3state(&call_desc[i], EV_DLESTCF);
-			found++;
-		}
-	}
-	
-	if(found == 0)
-	{
-		NDBGL3(L3_ERR, "ERROR, no cdid for unit %d found!", unit);
-		return(-1);
-	}
-	else
-	{
-		return(0);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	DL RELEASE INDICATION from Layer 2
- *---------------------------------------------------------------------------*/
-int
-i4b_dl_release_ind(int unit)
-{
-	int i;
-	int found = 0;
-
-	NDBGL2(L2_PRIM, "DL-RELEASE-IND unit %d",unit);
-	
-	/* first set controller to down */
-	
-	for(i=0; i < nctrl; i++)
-	{
-		if((ctrl_desc[i].ctrl_type == CTRL_PASSIVE) &&
-		   (ctrl_desc[i].unit == unit))
-                {
-                 	NDBGL3(L3_MSG, "unit=%d DL released!",unit);
-			ctrl_desc[i].dl_est = DL_DOWN;
-			found = 1;
-		}
-	}
-
-	if(found == 0)
-	{
-	       	NDBGL3(L3_ERR, "ERROR, controller not found for unit=%d!",unit);
-		return(-1);
-	}
-	
-	found = 0;
-
-	/* second, inform all (!) active calls of the event */
-	
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		if( (call_desc[i].cdid != 0) &&
-		    (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
-		    (ctrl_desc[call_desc[i].controller].unit == unit))
-                {
-                 	NDBGL3(L3_MSG, "unit=%d, index=%d cdid=%u cr=%d",
-					unit, i, call_desc[i].cdid, call_desc[i].cr);
-			next_l3state(&call_desc[i], EV_DLRELIN);
-			found++;
-		}
-	}
-	
-	if(found == 0)
-	{
-		/* this is not an error since it might be a normal call end */
-		NDBGL3(L3_MSG, "no cdid for unit %d found", unit);
-	}
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	DL RELEASE CONFIRM from Layer 2
- *---------------------------------------------------------------------------*/
-int
-i4b_dl_release_cnf(int unit)
-{
-	int i;
-	
-	NDBGL2(L2_PRIM, "DL-RELEASE-CONF unit %d",unit);
-	
-	for(i=0; i < nctrl; i++)
-	{
-		if((ctrl_desc[i].ctrl_type == CTRL_PASSIVE) &&
-		   (ctrl_desc[i].unit == unit))
-                {
-                 	NDBGL3(L3_MSG, "unit=%d DL released!",unit);
-			ctrl_desc[i].dl_est = DL_DOWN;
-			return(0);
-		}
-	}
-       	NDBGL3(L3_ERR, "ERROR, controller not found for unit=%d!",unit);
-	return(-1);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4b_dl_data_ind - process a rx'd I-frame got from layer 2
- *---------------------------------------------------------------------------*/
-int
-i4b_dl_data_ind(int unit, struct mbuf *m)
-{
-#ifdef NOTDEF
-	NDBGL2(L2_PRIM, "DL-DATA-IND unit %d",unit);
-#endif
-	i4b_decode_q931(unit, m->m_len, m->m_data);
-	i4b_Dfreembuf(m);
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	dl_unit_data_ind - process a rx'd U-frame got from layer 2
- *---------------------------------------------------------------------------*/
-int
-i4b_dl_unit_data_ind(int unit, struct mbuf *m)
-{
-#ifdef NOTDEF
-	NDBGL2(L2_PRIM, "DL-UNIT-DATA-IND unit %d",unit);
-#endif
-	i4b_decode_q931(unit, m->m_len, m->m_data);
-	i4b_Dfreembuf(m);
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	send CONNECT message
- *---------------------------------------------------------------------------*/
-void
-i4b_l3_tx_connect(call_desc_t *cd)
-{
-	struct mbuf *m;
-	u_char *ptr;
-
-	NDBGL3(L3_PRIM, "unit %d, cr = 0x%02x", ctrl_desc[cd->controller].unit, cd->cr);
-	
-	if((m = i4b_Dgetmbuf(I_FRAME_HDRLEN + MSG_CONNECT_LEN)) == NULL)
-		panic("i4b_l3_tx_connect: can't allocate mbuf\n");
-
-	ptr = m->m_data + I_FRAME_HDRLEN;
-	
-	*ptr++ = PD_Q931;		/* protocol discriminator */
-	*ptr++ = 0x01;			/* call reference length */
-	*ptr++ = setup_cr(cd, cd->cr);	/* call reference value */
-	*ptr++ = CONNECT;		/* message type = connect */
-	
-	DL_Data_Req(ctrl_desc[cd->controller].unit, m);
-}
-
-/*---------------------------------------------------------------------------*
- *	send RELEASE COMPLETE message
- *---------------------------------------------------------------------------*/
-void
-i4b_l3_tx_release_complete(call_desc_t *cd, int send_cause_flag)
-{
-	struct mbuf *m;
-	u_char *ptr;
-	int len = I_FRAME_HDRLEN + MSG_RELEASE_COMPLETE_LEN;
-	
-	if(send_cause_flag == 0)
-	{
-		len -= 4;
-		NDBGL3(L3_PRIM, "unit %d, cr = 0x%02x",
-			ctrl_desc[cd->controller].unit, cd->cr);
-	}
-	else
-	{
-		NDBGL3(L3_PRIM, "unit=%d, cr=0x%02x, cause=0x%x",
-			ctrl_desc[cd->controller].unit, cd->cr, cd->cause_out);
-	}
-		
-	if((m = i4b_Dgetmbuf(len)) == NULL)
-		panic("i4b_l3_tx_release_complete: can't allocate mbuf\n");
-
-	ptr = m->m_data + I_FRAME_HDRLEN;
-	
-	*ptr++ = PD_Q931;		/* protocol discriminator */
-	*ptr++ = 0x01;			/* call reference length */
-	*ptr++ = setup_cr(cd, cd->cr);	/* call reference value */
-	*ptr++ = RELEASE_COMPLETE;	/* message type = release complete */
-
-	if(send_cause_flag)
-	{		
-		*ptr++ = IEI_CAUSE;		/* cause ie */
-		*ptr++ = CAUSE_LEN;
-		*ptr++ = CAUSE_STD_LOC_OUT;
-		*ptr++ = make_q931_cause(cd->cause_out);
-	}
-
-	DL_Data_Req(ctrl_desc[cd->controller].unit, m);
-}
-
-/*---------------------------------------------------------------------------*
- *	send DISCONNECT message
- *---------------------------------------------------------------------------*/
-void
-i4b_l3_tx_disconnect(call_desc_t *cd)
-{
-	struct mbuf *m;
-	u_char *ptr;
-
-	NDBGL3(L3_PRIM, "unit %d, cr = 0x%02x", ctrl_desc[cd->controller].unit, cd->cr);
-	
-	if((m = i4b_Dgetmbuf(I_FRAME_HDRLEN + MSG_DISCONNECT_LEN)) == NULL)
-		panic("i4b_l3_tx_disconnect: can't allocate mbuf\n");
-
-	ptr = m->m_data + I_FRAME_HDRLEN;
-	
-	*ptr++ = PD_Q931;		/* protocol discriminator */
-	*ptr++ = 0x01;			/* call ref length */
-	*ptr++ = setup_cr(cd, cd->cr);	/* call reference value */
-	*ptr++ = DISCONNECT;		/* message type = disconnect */
-
-	*ptr++ = IEI_CAUSE;		/* cause ie */
-	*ptr++ = CAUSE_LEN;
-	*ptr++ = CAUSE_STD_LOC_OUT;
-	*ptr++ = make_q931_cause(cd->cause_out);
-
-	DL_Data_Req(ctrl_desc[cd->controller].unit, m);
-}
-
-/*---------------------------------------------------------------------------*
- *	send SETUP message
- *---------------------------------------------------------------------------*/
-void
-i4b_l3_tx_setup(call_desc_t *cd)
-{
-	struct mbuf *m;
-	u_char *ptr;
-	int len;
-	int slen = strlen(cd->src_telno);
-	int sslen = strlen(cd->src_subaddr);
-	int dlen = strlen(cd->dst_telno);
-	int dslen = strlen(cd->dst_subaddr);
-	int klen = strlen(cd->keypad);	
-
-	/*
-	 * there is one additional octet if cd->bprot == BPROT_NONE
-	 * NOTE: the selection of a bearer capability by a B L1
-	 *       protocol is highly questionable and a better
-	 *       mechanism should be used in future. (-hm)
-	 */
-
-	NDBGL3(L3_PRIM, "unit %d, cr = 0x%02x", ctrl_desc[cd->controller].unit, cd->cr);
-	
-	len = 	I_FRAME_HDRLEN		+
-		MSG_SETUP_LEN		+
-		(slen ? (3+slen) : 0)	+
-		(sslen ? (3+sslen) : 0)	+
-		(dlen ? (3+dlen) : 0)	+
-		(dslen ? (3+dslen) : 0)	+
-		(klen ? (2+klen) : 0)	+
-		(cd->bprot == BPROT_NONE ? 1 : 0);
-
-	if((m = i4b_Dgetmbuf(len)) == NULL)
-	{
-		panic("i4b_l3_tx_setup: can't allocate mbuf\n");
-	}
-
-	cd->crflag = CRF_ORIG;		/* we are the originating side */
-	
-	ptr = m->m_data + I_FRAME_HDRLEN;
-	
-	*ptr++ = PD_Q931;		/* protocol discriminator */
-	*ptr++ = 0x01;			/* call ref length */
-	*ptr++ = setup_cr(cd, cd->cr);	/* call reference value */
-	*ptr++ = SETUP;			/* message type = setup */
-
-	*ptr++ = IEI_SENDCOMPL;		/* sending complete */	
-	
-	*ptr++ = IEI_BEARERCAP;		/* bearer capability */
-
-	/* XXX
-	 * currently i have no idea if this should be switched by
-	 * the choosen B channel protocol or if there should be a
-	 * separate configuration item for the bearer capability.
-	 * For now, it is switched by the choosen b protocol (-hm)
-	 */
-	 
-	switch(cd->bprot)
-	{
-		case BPROT_NONE:	/* telephony */
-			*ptr++ = IEI_BEARERCAP_LEN+1;
-			*ptr++ = IT_CAP_SPEECH;
-			*ptr++ = IT_RATE_64K;
-			*ptr++ = IT_UL1_G711A;
-			break;
-
-		case BPROT_RHDLC:	/* raw HDLC */
-			if (cd->bcap == BCAP_DOV) /* Data over Voice */
-			{
-				*ptr++ = IEI_BEARERCAP_LEN+1;
-				*ptr++ = IT_CAP_SPEECH;
-				*ptr++ = IT_RATE_64K;
-				*ptr++ = IT_UL1_G711A;
-			}
-			else
-			{
-				*ptr++ = IEI_BEARERCAP_LEN;
-				*ptr++ = IT_CAP_UNR_DIG_INFO;
-				*ptr++ = IT_RATE_64K;
-			}
-			break;
-
-		default:
-			*ptr++ = IEI_BEARERCAP_LEN;
-			*ptr++ = IT_CAP_UNR_DIG_INFO;
-			*ptr++ = IT_RATE_64K;
-			break;
-	}
-
-	*ptr++ = IEI_CHANNELID;		/* channel id */
-	*ptr++ = IEI_CHANNELID_LEN;	/* channel id length */
-
-	switch(cd->channelid)
-	{
-		case CHAN_B1:
-			*ptr++ = CHANNELID_B1;
-			break;
-		case CHAN_B2:
-			*ptr++ = CHANNELID_B2;
-			break;
-		default:
-			*ptr++ = CHANNELID_ANY;
-			break;
-	}
-
-	if(klen)
-	{
-		*ptr++ = IEI_KEYPAD;		/* keypad facility */
-		*ptr++ = klen;			/* keypad facility length */
-		strncpy(ptr, cd->keypad, klen);
-		ptr += klen;
-	}
-	
-	if(slen)
-	{
-		*ptr++ = IEI_CALLINGPN;		/* calling party no */
-		*ptr++ = IEI_CALLINGPN_LEN+slen;/* calling party no length */
-		*ptr++ = NUMBER_TYPEPLAN;	/* type of number, number plan id */
-		strncpy(ptr, cd->src_telno, slen);
-		ptr += slen;
-	}
-
-	if(sslen)
-	{
-		*ptr++ = IEI_CALLINGPS;		/* calling subaddr */
-		*ptr++ = IEI_CALLINGPS_LEN+sslen; /* calling subaddr len */
-		*ptr++ = SUBADDR_TYPE_NSAP;	/* type = NSAP */
-		strncpy(ptr, cd->src_subaddr, sslen);
-		ptr += sslen;
-	}
-
-	if(dlen)
-	{
-		*ptr++ = IEI_CALLEDPN;		/* called party no */
-		*ptr++ = IEI_CALLEDPN_LEN+dlen;	/* called party no length */
-		*ptr++ = NUMBER_TYPEPLAN;	/* type of number, number plan id */
-		strncpy(ptr, cd->dst_telno, dlen);
-		ptr += dlen;
-	}
-
-	if(dslen)
-	{	
-		*ptr++ = IEI_CALLEDPS;		/* calling party subaddr */
-		*ptr++ = IEI_CALLEDPS_LEN+dslen;/* calling party subaddr len */
-		*ptr++ = SUBADDR_TYPE_NSAP;	/* type = NSAP */
-		strncpy(ptr, cd->dst_subaddr, dslen);
-		ptr += dslen;
-	}
-	
-	DL_Data_Req(ctrl_desc[cd->controller].unit, m);
-}
-
-/*---------------------------------------------------------------------------*
- *	send CONNECT ACKNOWLEDGE message
- *---------------------------------------------------------------------------*/
-void
-i4b_l3_tx_connect_ack(call_desc_t *cd)
-{
-	struct mbuf *m;
-	u_char *ptr;
-
-	NDBGL3(L3_PRIM, "unit %d, cr = 0x%02x", ctrl_desc[cd->controller].unit, cd->cr);
-	
-	if((m = i4b_Dgetmbuf(I_FRAME_HDRLEN + MSG_CONNECT_ACK_LEN)) == NULL)
-		panic("i4b_l3_tx_connect_ack: can't allocate mbuf\n");
-
-	ptr = m->m_data + I_FRAME_HDRLEN;
-	
-	*ptr++ = PD_Q931;		/* protocol discriminator */
-	*ptr++ = 0x01;			/* call reference length */
-	*ptr++ = setup_cr(cd, cd->cr);	/* call reference value */
-	*ptr++ = CONNECT_ACKNOWLEDGE;	/* message type = connect ack */
-
-	DL_Data_Req(ctrl_desc[cd->controller].unit, m);
-}
-
-/*---------------------------------------------------------------------------*
- *	send STATUS message
- *---------------------------------------------------------------------------*/
-void
-i4b_l3_tx_status(call_desc_t *cd, u_char q850cause)
-{
-	struct mbuf *m;
-	u_char *ptr;
-
-	NDBGL3(L3_PRIM, "unit %d, cr = 0x%02x", ctrl_desc[cd->controller].unit, cd->cr);
-	
-	if((m = i4b_Dgetmbuf(I_FRAME_HDRLEN + MSG_STATUS_LEN)) == NULL)
-		panic("i4b_l3_tx_status: can't allocate mbuf\n");
-
-	ptr = m->m_data + I_FRAME_HDRLEN;
-	
-	*ptr++ = PD_Q931;		/* protocol discriminator */
-	*ptr++ = 0x01;			/* call reference length */
-	*ptr++ = setup_cr(cd, cd->cr);	/* call reference value */
-	*ptr++ = STATUS;	/* message type = connect ack */
-
-	*ptr++ = IEI_CAUSE;		/* cause ie */
-	*ptr++ = CAUSE_LEN;
-	*ptr++ = CAUSE_STD_LOC_OUT;
-	*ptr++ = q850cause | EXT_LAST;
-
-	*ptr++ = IEI_CALLSTATE;		/* call state ie */
-	*ptr++ = CALLSTATE_LEN;
-	*ptr++ = i4b_status_tab[cd->Q931state];
-		
-	DL_Data_Req(ctrl_desc[cd->controller].unit, m);
-}
-
-/*---------------------------------------------------------------------------*
- *	send RELEASE message
- *---------------------------------------------------------------------------*/
-void
-i4b_l3_tx_release(call_desc_t *cd, int send_cause_flag)
-{
-	struct mbuf *m;
-	u_char *ptr;
-	int len = I_FRAME_HDRLEN + MSG_RELEASE_LEN;
-
-	NDBGL3(L3_PRIM, "unit %d, cr = 0x%02x", ctrl_desc[cd->controller].unit, cd->cr);
-	
-	if(send_cause_flag == 0)
-		len -= 4;
-
-	if((m = i4b_Dgetmbuf(len)) == NULL)
-		panic("i4b_l3_tx_release: can't allocate mbuf\n");
-
-	ptr = m->m_data + I_FRAME_HDRLEN;
-	
-	*ptr++ = PD_Q931;		/* protocol discriminator */
-	*ptr++ = 0x01;			/* call reference length */
-	*ptr++ = setup_cr(cd, cd->cr);	/* call reference value */
-	*ptr++ = RELEASE;		/* message type = release complete */
-
-	if(send_cause_flag)
-	{
-		*ptr++ = IEI_CAUSE;		/* cause ie */
-		*ptr++ = CAUSE_LEN;
-		*ptr++ = CAUSE_STD_LOC_OUT;
-		*ptr++ = make_q931_cause(cd->cause_out);
-	}
-
-	DL_Data_Req(ctrl_desc[cd->controller].unit, m);
-}
-
-/*---------------------------------------------------------------------------*
- *	send ALERTING message
- *---------------------------------------------------------------------------*/
-void
-i4b_l3_tx_alert(call_desc_t *cd)
-{
-	struct mbuf *m;
-	u_char *ptr;
-
-	if((m = i4b_Dgetmbuf(I_FRAME_HDRLEN + MSG_ALERT_LEN)) == NULL)
-		panic("i4b_l3_tx_alert: can't allocate mbuf\n");
-
-	NDBGL3(L3_PRIM, "unit %d, cr = 0x%02x", ctrl_desc[cd->controller].unit, cd->cr);
-	
-	ptr = m->m_data + I_FRAME_HDRLEN;
-	
-	*ptr++ = PD_Q931;		/* protocol discriminator */
-	*ptr++ = 0x01;			/* call reference length */
-	*ptr++ = setup_cr(cd, cd->cr);	/* call reference value */
-	*ptr++ = ALERT;			/* message type = alert */
-
-	DL_Data_Req(ctrl_desc[cd->controller].unit, m);
-}
--- sys/i4b/layer3/i4b_q931.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_q931.h - Q931 handling header file
- *	--------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer3/i4b_q931.h,v 1.11 2005/01/06 22:18:21 imp Exp $
- *
- *      last edit-date: [Tue Mar 26 15:04:33 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_Q931_H_
-#define _I4B_Q931_H_
-
-/* extension bit */
-
-#define EXT_LAST		0x80	/* last octett */
-
-/* reserve space in mbuf */
-
-#define I_FRAME_HDRLEN		4	/* to be added by layer 2 */
-
-/* SHIFT */
-
-#define CODESET_MASK		0x07
-#define UNSHIFTED		0
-#define SHIFTED			1
-#define CRLENGTH_MASK		0x0f
-
-/* CONNECT */
-
-#define MSG_CONNECT_LEN		4	/* length of a connect message */
-
-/* DISCONNECT */
-
-#define MSG_DISCONNECT_LEN	8	/* length of a disconnect message */
-
-/* RELEASE COMPLETE */
-
-#define MSG_RELEASE_COMPLETE_LEN 8	/* length of release complete msg */
-
-/* for outgoing causes */
-
-#define CAUSE_LEN		2
-#define CAUSE_STD_LOC_OUT	0x80	/* std = CCITT, loc = user */
-
-/* SETUP */
-
-#define MSG_SETUP_LEN		12	/* without called party,	*/
-					/*	calling party and	*/
-					/*	keypad facility !	*/
-
-#define IEI_BEARERCAP_LEN	2	/* 2 octetts length */
-
-#define IT_CAP_SPEECH		0x80	/* BC: information xfer capability */
-#define IT_CAP_UNR_DIG_INFO	0x88	/* BC: information xfer capability */
-
-#define	IT_RATE_64K		0x90	/* BC: information xfer rate	*/
-#define	IT_UL1_G711A		0xa3	/* layer1 proto G.711 A-law	*/
-
-#define IEI_CHANNELID_LEN	0x01    /* length of channel id		*/
-#define	CHANNELID_B1		0x81	/* channel = B1 (outgoing)	*/
-#define	CHANNELID_B2		0x82	/* channel = B2 (outgoing) 	*/
-#define	CHANNELID_ANY		0x83	/* channel = any channel (outgoing) */
-
-#define IE_CHAN_ID_NO		0x00	/* no channel (incoming)	*/
-#define IE_CHAN_ID_B1		0x01	/* B1 channel (incoming)	*/
-#define IE_CHAN_ID_B2		0x02	/* B2 channel (incoming)	*/
-#define IE_CHAN_ID_ANY		0x03	/* ANY channel (incoming)	*/
-
-#define	NUMBER_TYPEPLAN		0x81    /* type of number/numbering plan */
-
-#define IEI_CALLINGPN_LEN	1	/* without number string !	*/
-#define IEI_CALLEDPN_LEN	1	/* without number string !	*/
-
-#define IEI_CALLINGPS_LEN	1
-#define IEI_CALLEDPS_LEN	1
-
-#define	SUBADDR_TYPE_NSAP	0x80	/* subaddr: type=NSAP		*/
-
-/* CONNECT_ACK */
-
-#define MSG_CONNECT_ACK_LEN	4	/* length of a connect ack message */
-
-/* STATUS */
-
-#define MSG_STATUS_LEN		11
-#define CALLSTATE_LEN		1
-
-/* RELEASE */
-
-#define MSG_RELEASE_LEN		8	/* length of release msg */
-
-/* ALERT */
-
-#define MSG_ALERT_LEN		4	/* length of an alert message */
-
-#endif /* _I4B_Q931_H_ */
-
-/* EOF */
--- sys/i4b/layer3/i4b_l3timer.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l3timer.c - timer and timeout handling for layer 3
- *	------------------------------------------------------
- *      last edit-date: [Sat Mar  9 19:35:31 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer3/i4b_l3timer.c,v 1.13 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer3/i4b_l3.h>
-#include <i4b/layer3/i4b_l3fsm.h>
-
-/*---------------------------------------------------------------------------*
- *	stop all layer 3 timers
- *---------------------------------------------------------------------------*/
-void i4b_l3_stop_all_timers(call_desc_t *cd)
-{
-	T303_stop(cd);
-	T305_stop(cd);
-	T308_stop(cd);
-	T309_stop(cd);
-	T310_stop(cd);
-	T313_stop(cd);	
-}
-	
-/*---------------------------------------------------------------------------*
- *	timer T303 timeout function
- *---------------------------------------------------------------------------*/
-static void
-T303_timeout(call_desc_t *cd)
-{
-	NDBGL3(L3_T_ERR, "SETUP not answered, cr = %d", cd->cr);
-	next_l3state(cd, EV_T303EXP);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T303 start
- *---------------------------------------------------------------------------*/
-void
-T303_start(call_desc_t *cd)
-{
-	if (cd->T303 == TIMER_ACTIVE)
-		return;
-		
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-	cd->T303 = TIMER_ACTIVE;
-
-	START_TIMER(cd->T303_callout, T303_timeout, cd, T303VAL);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T303 stop
- *---------------------------------------------------------------------------*/
-void
-T303_stop(call_desc_t *cd)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-	
-	if(cd->T303 != TIMER_IDLE)
-	{
-		STOP_TIMER(cd->T303_callout, T303_timeout, cd);
-		cd->T303 = TIMER_IDLE;
-	}
-	CRIT_END;
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T305 timeout function
- *---------------------------------------------------------------------------*/
-static void
-T305_timeout(call_desc_t *cd)
-{
-	NDBGL3(L3_T_ERR, "DISC not answered, cr = %d", cd->cr);
-	next_l3state(cd, EV_T305EXP);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T305 start
- *---------------------------------------------------------------------------*/
-void
-T305_start(call_desc_t *cd)
-{
-	if (cd->T305 == TIMER_ACTIVE)
-		return;
-		
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-	cd->T305 = TIMER_ACTIVE;
-
-	START_TIMER(cd->T305_callout, T305_timeout, cd, T305VAL);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T305 stop
- *---------------------------------------------------------------------------*/
-void
-T305_stop(call_desc_t *cd)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-	
-	if(cd->T305 != TIMER_IDLE)
-	{
-		STOP_TIMER(cd->T305_callout, T305_timeout, cd);
-		cd->T305 = TIMER_IDLE;
-	}
-	CRIT_END;
-	
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T308 timeout function
- *---------------------------------------------------------------------------*/
-static void
-T308_timeout(call_desc_t *cd)
-{
-	NDBGL3(L3_T_ERR, "REL not answered, cr = %d", cd->cr);
-	next_l3state(cd, EV_T308EXP);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T308 start
- *---------------------------------------------------------------------------*/
-void
-T308_start(call_desc_t *cd)
-{
-	if(cd->T308 == TIMER_ACTIVE)
-		return;
-		
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-	cd->T308 = TIMER_ACTIVE;
-
-	START_TIMER(cd->T308_callout, T308_timeout, cd, T308VAL);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T308 stop
- *---------------------------------------------------------------------------*/
-void
-T308_stop(call_desc_t *cd)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-	
-	if(cd->T308 != TIMER_IDLE)
-	{
-		STOP_TIMER(cd->T308_callout, T308_timeout, cd);
-		cd->T308 = TIMER_IDLE;
-	}
-	CRIT_END;
-	
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T309 timeout function
- *---------------------------------------------------------------------------*/
-static void
-T309_timeout(call_desc_t *cd)
-{
-	NDBGL3(L3_T_ERR, "datalink not reconnected, cr = %d", cd->cr);
-	next_l3state(cd, EV_T309EXP);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T309 start
- *---------------------------------------------------------------------------*/
-void
-T309_start(call_desc_t *cd)
-{
-	if (cd->T309 == TIMER_ACTIVE)
-		return;
-
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-	cd->T309 = TIMER_ACTIVE;
-
-	START_TIMER(cd->T309_callout, T309_timeout, cd, T309VAL);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T309 stop
- *---------------------------------------------------------------------------*/
-void
-T309_stop(call_desc_t *cd)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-	
-	if(cd->T309 != TIMER_IDLE)
-	{
-		STOP_TIMER(cd->T309_callout, T309_timeout, cd);
-		cd->T309 = TIMER_IDLE;
-	}
-	CRIT_END;
-	
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T310 timeout function
- *---------------------------------------------------------------------------*/
-static void
-T310_timeout(call_desc_t *cd)
-{
-	NDBGL3(L3_T_ERR, "CALL PROC timeout, cr = %d", cd->cr);
-	next_l3state(cd, EV_T310EXP);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T310 start
- *---------------------------------------------------------------------------*/
-void
-T310_start(call_desc_t *cd)
-{
-	if (cd->T310 == TIMER_ACTIVE)
-		return;
-		
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-	cd->T310 = TIMER_ACTIVE;
-
-	START_TIMER(cd->T310_callout, T310_timeout, cd, T310VAL);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T310 stop
- *---------------------------------------------------------------------------*/
-void
-T310_stop(call_desc_t *cd)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-	
-	if(cd->T310 != TIMER_IDLE)
-	{
-		STOP_TIMER(cd->T310_callout, T310_timeout, cd);
-		cd->T310 = TIMER_IDLE;
-	}
-	CRIT_END;
-
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T313 timeout function
- *---------------------------------------------------------------------------*/
-static void
-T313_timeout(call_desc_t *cd)
-{
-	NDBGL3(L3_T_ERR, "CONN ACK not received, cr = %d", cd->cr);
-	next_l3state(cd, EV_T313EXP);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T313 start
- *---------------------------------------------------------------------------*/
-void
-T313_start(call_desc_t *cd)
-{
-	if (cd->T313 == TIMER_ACTIVE)
-		return;
-		
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-	cd->T313 = TIMER_ACTIVE;
-
-	START_TIMER(cd->T313_callout, T313_timeout, cd, T313VAL);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T313 stop
- *---------------------------------------------------------------------------*/
-void
-T313_stop(call_desc_t *cd)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-	
-	if(cd->T313 != TIMER_IDLE)
-	{
-		cd->T313 = TIMER_IDLE;
-		STOP_TIMER(cd->T313_callout, T313_timeout, cd);
-	}
-	CRIT_END;
-	
-	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
-}
--- sys/i4b/layer3/i4b_l3.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l3.h - layer 3 header file
- *	------------------------------
- *
- *	$Id: i4b_l3.h,v 1.11 2000/04/27 09:25:21 hm Exp $ 
- *
- * $FreeBSD: src/sys/i4b/layer3/i4b_l3.h,v 1.8 2005/01/06 22:18:21 imp Exp $
- *
- *      last edit-date: [Thu Apr 27 11:07:01 2000]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L3_H_
-#define _I4B_L3_H_
-
-extern int utoc_tab[];
-extern unsigned char cause_tab_q931[];
-
-extern int i4b_aoc ( unsigned char *, call_desc_t *cd );
-extern void i4b_decode_q931 ( int unit, int msg_len, u_char *msg_ptr );
-extern int i4b_decode_q931_cs0_ie ( int unit, call_desc_t *cd, int msg_len, u_char *msg_ptr );
-extern void i4b_decode_q931_message ( int unit, call_desc_t *cd, u_char message_type );
-extern void i4b_l3_stop_all_timers ( call_desc_t *cd );
-extern void i4b_l3_tx_alert ( call_desc_t *cd );
-extern void i4b_l3_tx_connect ( call_desc_t *cd );
-extern void i4b_l3_tx_connect_ack ( call_desc_t *cd );
-extern void i4b_l3_tx_disconnect ( call_desc_t *cd );
-extern void i4b_l3_tx_release ( call_desc_t *cd, int send_cause_flag );
-extern void i4b_l3_tx_release_complete ( call_desc_t *cd, int send_cause_flag );
-extern void i4b_l3_tx_setup ( call_desc_t *cd );
-extern void i4b_l3_tx_status ( call_desc_t *cd, u_char q850cause );
-extern int i4b_dl_data_ind ( int unit, struct mbuf *m );
-extern int i4b_dl_establish_cnf ( int unit );
-extern int i4b_dl_establish_ind ( int unit );
-extern int i4b_dl_release_cnf ( int unit );
-extern int i4b_dl_release_ind ( int unit );
-extern int i4b_dl_unit_data_ind ( int unit, struct mbuf *m );
-extern int i4b_get_dl_stat( call_desc_t *cd );
-extern int i4b_mdl_status_ind ( int unit, int status, int parm);
-extern void i4b_print_frame ( int len, u_char *buf );
-extern void next_l3state ( call_desc_t *cd, int event );
-extern char *print_l3state ( call_desc_t *cd );
-extern unsigned char setup_cr ( call_desc_t *cd, unsigned char cr );
-extern void T303_start ( call_desc_t *cd );
-extern void T303_stop ( call_desc_t *cd );
-extern void T305_start ( call_desc_t *cd );
-extern void T305_stop ( call_desc_t *cd );
-extern void T308_start ( call_desc_t *cd );
-extern void T308_stop ( call_desc_t *cd );
-extern void T309_start ( call_desc_t *cd );
-extern void T309_stop ( call_desc_t *cd );
-extern void T310_start ( call_desc_t *cd );
-extern void T310_stop ( call_desc_t *cd );
-extern void T313_start ( call_desc_t *cd );
-extern void T313_stop ( call_desc_t *cd );
-
-#endif /* _I4B_L3_H_ */
--- sys/i4b/layer3/i4b_q932fac.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_q932fac.h - Q932 facility handling header file
- *	--------------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer3/i4b_q932fac.h,v 1.9 2005/01/06 22:18:21 imp Exp $
- *
- *      last edit-date: [Sat Mar  9 19:37:46 2002]
- *
- *---------------------------------------------------------------------------
- *
- *	- Q.932 (03/93) Generic Procedures for the Control of
- *		ISDN Supplementaty Services
- *	- Q.950 (03/93) Supplementary Services Protocols, Structure and
- *		General Principles
- *	- ETS 300 179 (10/92) Advice Of Charge: charging information during
- *		the call (AOC-D) supplementary service Service description
- *	- ETS 300 180 (10/92) Advice Of Charge: charging information at the
- *		end of call (AOC-E) supplementary service Service description
- *	- ETS 300 181 (04/93) Advice Of Charge (AOC) supplementary service
- *		Functional capabilities and information flows
- *	- ETS 300 182 (04/93) Advice Of Charge (AOC) supplementary service
- *		Digital Subscriber Signalling System No. one (DSS1) protocol
- *	- X.208 Specification of Abstract Syntax Notation One (ASN.1)
- *	- X.209 Specification of Basic Encoding Rules for
- *		Abstract Syntax Notation One (ASN.1) 
- *	- "ASN.1 Abstract Syntax Notation One", Walter Gora, DATACOM-Verlag
- *		1992, 3rd Edition (ISBN 3-89238-062-7) (german !)
- *
- *---------------------------------------------------------------------------*/
-
-/* protocols */
-#define FAC_PROTO_ROP		0x11
-#define FAC_PROTO_CMIP		0x12
-#define FAC_PROTO_ACSE		0x13
-
-/* tag classes */
-#define FAC_TAGCLASS_UNI	0x00
-#define FAC_TAGCLASS_APW	0x01
-#define FAC_TAGCLASS_COS	0x02
-#define FAC_TAGCLASS_PRU	0x03
-
-/* tag forms */
-#define FAC_TAGFORM_PRI		0x00
-#define FAC_TAGFORM_CON		0x01
-
-/* class UNIVERSAL values */
-#define FAC_CODEUNI_BOOL	1
-#define FAC_CODEUNI_INT		2
-#define FAC_CODEUNI_BITS	3
-#define FAC_CODEUNI_OCTS	4
-#define FAC_CODEUNI_NULL	5
-#define FAC_CODEUNI_OBJI	6
-#define FAC_CODEUNI_OBJD	7
-#define FAC_CODEUNI_EXT		8
-#define FAC_CODEUNI_REAL	9
-#define FAC_CODEUNI_ENUM	10
-#define FAC_CODEUNI_R11		11
-#define FAC_CODEUNI_R12		12
-#define FAC_CODEUNI_R13		13
-#define FAC_CODEUNI_R14		14
-#define FAC_CODEUNI_R15		15
-#define FAC_CODEUNI_SEQ		16
-#define FAC_CODEUNI_SET		17
-#define FAC_CODEUNI_NSTR	18
-#define FAC_CODEUNI_PSTR	19
-#define FAC_CODEUNI_TSTR	20
-#define FAC_CODEUNI_VSTR	21
-#define FAC_CODEUNI_ISTR	22
-#define FAC_CODEUNI_UTIME	23
-#define FAC_CODEUNI_GTIME	24
-#define FAC_CODEUNI_GSTR	25
-#define FAC_CODEUNI_VISTR	26
-#define FAC_CODEUNI_GNSTR	27
-
-/* operation values */
-#define FAC_OPVAL_UUS		1
-#define FAC_OPVAL_CUG		2
-#define FAC_OPVAL_MCID		3
-#define FAC_OPVAL_BTPY		4
-#define FAC_OPVAL_ETPY		5
-#define FAC_OPVAL_ECT		6
-
-#define FAC_OPVAL_DIV_ACT	7
-#define FAC_OPVAL_DIV_DEACT	8
-#define FAC_OPVAL_DIV_ACTSN	9
-#define FAC_OPVAL_DIV_DEACTSN	10
-#define FAC_OPVAL_DIV_INTER	11
-#define FAC_OPVAL_DIV_INFO	12
-#define FAC_OPVAL_DIV_CALLDEF	13
-#define FAC_OPVAL_DIV_CALLRER	14
-#define FAC_OPVAL_DIV_LINF2	15
-#define FAC_OPVAL_DIV_INVS	16
-#define FAC_OPVAL_DIV_INTER1	17
-#define FAC_OPVAL_DIV_LINF1	18
-#define FAC_OPVAL_DIV_LINF3	19
-
-#define FAC_OPVAL_ER_CRCO	20
-#define FAC_OPVAL_ER_MGMT	21
-#define FAC_OPVAL_ER_CANC	22
-
-#define FAC_OPVAL_MLPP_QUERY	24
-#define FAC_OPVAL_MLPP_CALLR	25
-#define FAC_OPVAL_MLPP_CALLP	26
-
-#define FAC_OPVAL_AOC_REQ	30
-#define FAC_OPVAL_AOC_S_CUR	31
-#define FAC_OPVAL_AOC_S_SPC	32
-#define FAC_OPVAL_AOC_D_CUR	33
-#define FAC_OPVAL_AOC_D_UNIT	34
-#define FAC_OPVAL_AOC_E_CUR	35
-#define FAC_OPVAL_AOC_E_UNIT	36
-#define FAC_OPVAL_AOC_IDOFCRG	37
-
-#define FAC_OPVAL_CONF_BEG	40
-#define FAC_OPVAL_CONF_ADD	41
-#define FAC_OPVAL_CONF_SPLIT	42
-#define FAC_OPVAL_CONF_DROP	43
-#define FAC_OPVAL_CONF_ISOLATE	44
-#define FAC_OPVAL_CONF_REATT	45
-#define FAC_OPVAL_CONF_PDISC	46
-#define FAC_OPVAL_CONF_FCONF	47
-#define FAC_OPVAL_CONF_END	48
-#define FAC_OPVAL_CONF_IDCFE	49
-
-#define FAC_OPVAL_REVC_REQ	60
-
-enum states {
-	ST_EXP_COMP_TYP,
-	ST_EXP_INV_ID,
-	ST_EXP_OP_VAL,
-	ST_EXP_INFO,
-	ST_EXP_RUL,
-	ST_EXP_RU,
-	ST_EXP_RNOU,
-	ST_EXP_TOCI,
-	ST_EXP_DBID,	
-	
-	ST_EXP_NIX	
-};
-
-/* EOF */
-
--- sys/i4b/layer3/i4b_l4if.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l4if.c - Layer 3 interface to Layer 4
- *	-------------------------------------------
- *      last edit-date: [Sat Mar  9 19:36:08 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer3/i4b_l4if.c,v 1.15 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include <i4b/include/i4b_l2l3.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer3/i4b_l3.h>
-#include <i4b/layer3/i4b_l3fsm.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-extern void isic_settrace(int unit, int val);		/*XXX*/
-extern int isic_gettrace(int unit);			/*XXX*/
-
-static void n_connect_request(u_int cdid);
-static void n_connect_response(u_int cdid, int response, int cause);
-static void n_disconnect_request(u_int cdid, int cause);
-static void n_alert_request(u_int cdid);
-static void n_mgmt_command(int unit, int cmd, void *parm);
-
-/*---------------------------------------------------------------------------*
- *	i4b_mdl_status_ind - status indication from lower layers
- *---------------------------------------------------------------------------*/
-int
-i4b_mdl_status_ind(int unit, int status, int parm)
-{
-	int sendup;
-	int i;
-	
-	NDBGL3(L3_MSG, "unit = %d, status = %d, parm = %d", unit, status, parm);
-
-	switch(status)
-	{
-		case STI_ATTACH:
-			NDBGL3(L3_MSG, "STI_ATTACH: attaching unit %d to controller %d", unit, nctrl);
-		
-			/* init function pointers */
-			
-			ctrl_desc[nctrl].N_CONNECT_REQUEST = n_connect_request;
-			ctrl_desc[nctrl].N_CONNECT_RESPONSE = n_connect_response;
-			ctrl_desc[nctrl].N_DISCONNECT_REQUEST = n_disconnect_request;
-			ctrl_desc[nctrl].N_ALERT_REQUEST = n_alert_request;	
-			ctrl_desc[nctrl].N_DOWNLOAD = NULL;	/* only used by active cards */
-			ctrl_desc[nctrl].N_DIAGNOSTICS = NULL;	/* only used by active cards */
-			ctrl_desc[nctrl].N_MGMT_COMMAND = n_mgmt_command;
-		
-			/* init type and unit */
-			
-			ctrl_desc[nctrl].unit = unit;
-			ctrl_desc[nctrl].ctrl_type = CTRL_PASSIVE;
-			ctrl_desc[nctrl].card_type = parm;
-		
-			/* state fields */
-		
-			ctrl_desc[nctrl].dl_est = DL_DOWN;
-			ctrl_desc[nctrl].nbch = 2; /* XXX extra param? */
-			for (i = 0; i < ctrl_desc[nctrl].nbch; i++)
-			    ctrl_desc[nctrl].bch_state[i] = BCH_ST_FREE;
-
-			ctrl_desc[nctrl].tei = -1;
-			
-			/* init unit to controller table */
-			
-			utoc_tab[unit] = nctrl;
-			
-			/* increment no. of controllers */
-			
-			nctrl++;
-
-			break;
-			
-		case STI_L1STAT:
-			i4b_l4_l12stat(unit, 1, parm);
-			NDBGL3(L3_MSG, "STI_L1STAT: unit %d layer 1 = %s", unit, status ? "up" : "down");
-			break;
-			
-		case STI_L2STAT:
-			i4b_l4_l12stat(unit, 2, parm);
-			NDBGL3(L3_MSG, "STI_L2STAT: unit %d layer 2 = %s", unit, status ? "up" : "down");
-			break;
-
-		case STI_TEIASG:
-			ctrl_desc[unit].tei = parm;
-			i4b_l4_teiasg(unit, parm);
-			NDBGL3(L3_MSG, "STI_TEIASG: unit %d TEI = %d = 0x%02x", unit, parm, parm);
-			break;
-
-		case STI_PDEACT:	/* L1 T4 timeout */
-			NDBGL3(L3_ERR, "STI_PDEACT: unit %d TEI = %d = 0x%02x", unit, parm, parm);
-
-			sendup = 0;
-
-			for(i=0; i < N_CALL_DESC; i++)
-			{
-				if( (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
-				    (ctrl_desc[call_desc[i].controller].unit == unit))
-                		{
-					i4b_l3_stop_all_timers(&(call_desc[i]));
-					if(call_desc[i].cdid != CDID_UNUSED)
-						sendup++;
-				}
-			}
-
-			ctrl_desc[utoc_tab[unit]].dl_est = DL_DOWN;
-			for (i = 0; i < ctrl_desc[utoc_tab[unit]].nbch; i++)
-			    ctrl_desc[utoc_tab[unit]].bch_state[i] = BCH_ST_FREE;
-			ctrl_desc[utoc_tab[unit]].tei = -1;
-
-			if(sendup)
-			{
-				i4b_l4_pdeact(unit, sendup);
-				call_desc[i].cdid = CDID_UNUSED;
-			}
-			break;
-
-		case STI_NOL1ACC:	/* no outgoing access to S0 */
-			NDBGL3(L3_ERR, "STI_NOL1ACC: unit %d no outgoing access to S0", unit);
-
-			for(i=0; i < N_CALL_DESC; i++)
-			{
-				if( (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
-				    (ctrl_desc[call_desc[i].controller].unit == unit))
-                		{
-					if(call_desc[i].cdid != CDID_UNUSED)
-					{
-						SET_CAUSE_TYPE(call_desc[i].cause_in, CAUSET_I4B);
-						SET_CAUSE_VAL(call_desc[i].cause_in, CAUSE_I4B_L1ERROR);
-						i4b_l4_disconnect_ind(&(call_desc[i]));
-					}
-				}
-			}
-
-			ctrl_desc[utoc_tab[unit]].dl_est = DL_DOWN;
-			for (i = 0; i < ctrl_desc[utoc_tab[unit]].nbch; i++)
-			    ctrl_desc[utoc_tab[unit]].bch_state[i] = BCH_ST_FREE;
-			ctrl_desc[utoc_tab[unit]].tei = -1;
-			break;
-
-		default:
-			NDBGL3(L3_ERR, "ERROR, unit %d, unknown status value %d!", unit, status);
-			break;
-	}		
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	send command to the lower layers
- *---------------------------------------------------------------------------*/
-static void
-n_mgmt_command(int unit, int cmd, void *parm)
-{
-	int i;
-
-	switch(cmd)
-	{
-		case CMR_DOPEN:
-			NDBGL3(L3_MSG, "CMR_DOPEN for unit %d", unit);
-			
-			for(i=0; i < N_CALL_DESC; i++)
-			{
-				if( (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
-				    (ctrl_desc[call_desc[i].controller].unit == unit))
-                		{
-                			call_desc[i].cdid = CDID_UNUSED;
-				}
-			}
-
-			ctrl_desc[utoc_tab[unit]].dl_est = DL_DOWN;
-			for (i = 0; i < ctrl_desc[utoc_tab[unit]].nbch; i++)
-			    ctrl_desc[utoc_tab[unit]].bch_state[i] = BCH_ST_FREE;
-			ctrl_desc[utoc_tab[unit]].tei = -1;
-			break;
-
-		case CMR_DCLOSE:
-			NDBGL3(L3_MSG, "CMR_DCLOSE for unit %d", unit);
-			break;
-			
-		case CMR_SETTRACE:
-			NDBGL3(L3_MSG, "CMR_SETTRACE for unit %d", unit);
-			break;
-			
-		default:
-			NDBGL3(L3_MSG, "unknown cmd %d for unit %d", cmd, unit);
-			break;
-	}
-
-	MDL_Command_Req(unit, cmd, parm);
-	
-}
-
-/*---------------------------------------------------------------------------*
- *	handle connect request message from userland
- *---------------------------------------------------------------------------*/
-static void
-n_connect_request(u_int cdid)
-{
-	call_desc_t *cd;
-
-	cd = cd_by_cdid(cdid);
-
-	next_l3state(cd, EV_SETUPRQ);	
-}
-
-/*---------------------------------------------------------------------------*
- *	handle setup response message from userland
- *---------------------------------------------------------------------------*/
-static void
-n_connect_response(u_int cdid, int response, int cause)
-{
-	call_desc_t *cd;
-	int chstate;
-
-	cd = cd_by_cdid(cdid);
-
-	T400_stop(cd);
-	
-	cd->response = response;
-	cd->cause_out = cause;
-
-	switch(response)
-	{
-		case SETUP_RESP_ACCEPT:
-			next_l3state(cd, EV_SETACRS);
-			chstate = BCH_ST_USED;
-			break;
-		
-		case SETUP_RESP_REJECT:
-			next_l3state(cd, EV_SETRJRS);
-			chstate = BCH_ST_FREE;
-			break;
-			
-		case SETUP_RESP_DNTCRE:
-			next_l3state(cd, EV_SETDCRS);
-			chstate = BCH_ST_FREE;
-			break;
-
-		default:	/* failsafe */
-			next_l3state(cd, EV_SETDCRS);
-			chstate = BCH_ST_FREE;
-			NDBGL3(L3_ERR, "unknown response, doing SETUP_RESP_DNTCRE");
-			break;
-	}
-
-	if((cd->channelid >= 0) && (cd->channelid < ctrl_desc[cd->controller].nbch))
-	{
-		ctrl_desc[cd->controller].bch_state[cd->channelid] = chstate;
-	}
-	else
-	{
-		NDBGL3(L3_MSG, "Warning, invalid channelid %d, response = %d\n", cd->channelid, response);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	handle disconnect request message from userland
- *---------------------------------------------------------------------------*/
-static void
-n_disconnect_request(u_int cdid, int cause)
-{
-	call_desc_t *cd;
-
-	cd = cd_by_cdid(cdid);
-
-	cd->cause_out = cause;
-
-	next_l3state(cd, EV_DISCRQ);
-}
-
-/*---------------------------------------------------------------------------*
- *	handle alert request message from userland
- *---------------------------------------------------------------------------*/
-static void
-n_alert_request(u_int cdid)
-{
-	call_desc_t *cd;
-
-	cd = cd_by_cdid(cdid);
-
-	next_l3state(cd, EV_ALERTRQ);
-}
--- sys/i4b/layer3/i4b_l3fsm.c
+++ /dev/null
@@ -1,1037 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l3fsm.c - layer 3 FSM
- *	-------------------------
- *      last edit-date: [Sat Mar  9 19:34:39 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer3/i4b_l3fsm.c,v 1.18 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include <i4b/include/i4b_l2l3.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer3/i4b_l3.h>
-#include <i4b/layer3/i4b_l3fsm.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-static void F_00A(call_desc_t *cd), F_00H(call_desc_t *cd), F_00I(call_desc_t *cd);
-static void F_00J(call_desc_t *cd);
-
-static void F_01B(call_desc_t *cd), F_01K(call_desc_t *cd), F_01L(call_desc_t *cd);
-static void F_01M(call_desc_t *cd), F_01N(call_desc_t *cd), F_01U(call_desc_t *cd);
-static void F_01O(call_desc_t *cd);
-
-static void F_03C(call_desc_t *cd), F_03N(call_desc_t *cd), F_03O(call_desc_t *cd);
-static void F_03P(call_desc_t *cd), F_03Y(call_desc_t *cd);
-
-static void F_04O(call_desc_t *cd);
-
-static void F_06D(call_desc_t *cd), F_06E(call_desc_t *cd), F_06F(call_desc_t *cd);
-static void F_06G(call_desc_t *cd), F_06J(call_desc_t *cd), F_06Q(call_desc_t *cd);
-
-static void F_07E(call_desc_t *cd), F_07F(call_desc_t *cd), F_07G(call_desc_t *cd);
-
-static void F_08R(call_desc_t *cd), F_08Z(call_desc_t *cd);
-
-static void F_09D(call_desc_t *cd), F_09E(call_desc_t *cd), F_09F(call_desc_t *cd);
-static void F_09G(call_desc_t *cd);
-
-static void F_11J(call_desc_t *cd), F_11Q(call_desc_t *cd), F_11V(call_desc_t *cd);
-
-static void F_12C(call_desc_t *cd), F_12J(call_desc_t *cd);
-
-static void F_19I(call_desc_t *cd), F_19J(call_desc_t *cd), F_19K(call_desc_t *cd);
-static void F_19W(call_desc_t *cd);
-
-static void F_NCNA(call_desc_t *cd), F_STENQ(call_desc_t *cd), F_STAT(call_desc_t *cd);
-static void F_INFO(call_desc_t *cd), F_RELCP(call_desc_t *cd), F_REL(call_desc_t *cd);
-static void F_DISC(call_desc_t *cd), F_DCRQ(call_desc_t *cd), F_UEM(call_desc_t *cd);
-static void F_SIGN(call_desc_t *cd), F_DLEI(call_desc_t *cd), F_ILL(call_desc_t *cd);
-static void F_309TO(call_desc_t *cd), F_DECF(call_desc_t *cd), F_FCTY(call_desc_t *cd);
-static void F_DECF1(call_desc_t *cd), F_DECF2(call_desc_t *cd), F_DECF3(call_desc_t *cd);
-static void F_DLRI(call_desc_t *cd), F_DLRIA(call_desc_t *cd), F_DECF4(call_desc_t *cd);
-
-static void F_308TO(call_desc_t *cd);
-
-#if DO_I4B_DEBUG
-static char *l3state_text[N_STATES] = {
-	 "ST_U0 - Null",
-	 "ST_U1 - Out Init",
-	 "ST_U3 - Out Proc",
-	 "ST_U4 - Out Delv",
-	 "ST_U6 - In Pres",
-	 "ST_U7 - In Rxd",
-	 "ST_U8 - In ConReq",
-	 "ST_U9 - In Proc",
-	"ST_U10 - Active",
-	"ST_U11 - Disc Req",
-	"ST_U12 - Disc Ind",
-	"ST_U19 - Rel Req",
-
-	"ST_IWA - In Wait EST-Accept",
-	"ST_IWR - In Wait EST-Reject",
-	"ST_OW - Out Wait EST",
-	"ST_IWL - In Wait EST-Alert",	
-
-	"ST_SUSE - Subroutine sets state",	
-
-	"Illegal State"
-};
-
-static char *l3event_text[N_EVENTS] = {
-	"EV_SETUPRQ - L4 SETUP REQ",	/* setup request from L4		*/
-	"EV_DISCRQ - L4 DISC REQ",	/* disconnect request from L4		*/
-	"EV_RELRQ - L4 REL REQ",	/* release request from L4		*/
-	"EV_ALERTRQ - L4 ALERT REQ",	/* alerting request from L4		*/
-	"EV_SETACRS - L4 accept RSP",	/* setup response accept from l4	*/
-	"EV_SETRJRS - L4 reject RSP",	/* setup response reject from l4	*/
-	"EV_SETDCRS - L4 ignore RSP",	/* setup response dontcare from l4	*/
-	
-	"EV_SETUP - rxd SETUP",		/* incoming SETUP message from L2	*/
-	"EV_STATUS - rxd STATUS",	/* incoming STATUS message from L2	*/
-	"EV_RELEASE - rxd REL",		/* incoming RELEASE message from L2	*/
-	"EV_RELCOMP - rxd REL COMPL",	/* incoming RELEASE COMPLETE from L2	*/
-	"EV_SETUPAK - rxd SETUP ACK",	/* incoming SETUP ACK message from L2	*/
-	"EV_CALLPRC - rxd CALL PROC",	/* incoming CALL PROCEEDING from L2	*/
-	"EV_ALERT - rxd ALERT",		/* incoming ALERT message from L2	*/
-	"EV_CONNECT - rxd CONNECT",	/* incoming CONNECT message from L2	*/	
-	"EV_PROGIND - rxd PROG IND",	/* incoming Progress IND from L2	*/
-	"EV_DISCONN - rxd DISC",	/* incoming DISCONNECT message from L2	*/
-	"EV_CONACK - rxd CONN ACK",	/* incoming CONNECT ACK message from L2	*/
-	"EV_STATENQ - rxd STAT ENQ",	/* incoming STATUS ENQ message from L2	*/
-	"EV_INFO - rxd INFO",		/* incoming INFO message from L2	*/
-	"EV_FACILITY - rxd FACILITY",	/* incoming FACILITY message 		*/
-	
-	"EV_T303EXP - T303 timeout",	/* Timer T303 expired			*/	
-	"EV_T305EXP - T305 timeout",	/* Timer T305 expired			*/
-	"EV_T308EXP - T308 timeout",	/* Timer T308 expired			*/	
-	"EV_T309EXP - T309 timeout",	/* Timer T309 expired			*/	
-	"EV_T310EXP - T310 timeout",	/* Timer T310 expired			*/	
-	"EV_T313EXP - T313 timeout",	/* Timer T313 expired			*/	
-	
-	"EV_DLESTIN - L2 DL_Est_Ind",	/* dl establish indication from l2	*/
-	"EV_DLRELIN - L2 DL_Rel_Ind",	/* dl release indication from l2	*/
-	"EV_DLESTCF - L2 DL_Est_Cnf",	/* dl establish confirm from l2		*/
-	"EV_DLRELCF - L2 DL_Rel_Cnf",	/* dl release confirm from l2		*/	
-
-	"EV_ILL - Illegal event!!" 	/* Illegal */
-};
-#endif
-
-/*---------------------------------------------------------------------------*
- *	layer 3 state transition table
- *---------------------------------------------------------------------------*/	
-struct l3state_tab {
-	void (*func) (call_desc_t *);	/* function to execute */
-	int newstate;				/* next state */
-} l3state_tab[N_EVENTS][N_STATES] = {
-
-/* STATE:	ST_U0			ST_U1			ST_U3			ST_U4			ST_U6			ST_U7			ST_U8			ST_U9			ST_U10			ST_U11			ST_U12			ST_U19			ST_IWA			ST_IWR			ST_OW			ST_IWL			ST_SUBSET		ST_ILL	      */
-/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*EV_SETUPRQ*/	{{F_00A,  ST_SUSE},	{F_ILL,	 ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL, ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_DISCRQ */	{{F_ILL,  ST_ILL},	{F_01B,	 ST_U11},	{F_DCRQ, ST_U11},	{F_DCRQ, ST_U11},	{F_ILL,  ST_ILL},	{F_DCRQ, ST_U11},	{F_DCRQ, ST_U11},	{F_DCRQ, ST_U11},	{F_DCRQ, ST_U11},	{F_ILL,	 ST_ILL},	{F_NCNA, ST_U12},	{F_ILL,	 ST_ILL},	{F_DCRQ, ST_U11},	{F_DCRQ, ST_U11},	{F_DCRQ, ST_U11},	{F_DCRQ, ST_U11},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_RELRQ  */	{{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_03C,  ST_U19},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_12C,	 ST_U19},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_ALERTRQ*/	{{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_06D,  ST_SUSE},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_09D,	 ST_U7},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_SETACRS*/	{{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_06E,  ST_SUSE},	{F_07E,	 ST_U8},	{F_ILL,	 ST_ILL},	{F_09E,	 ST_U8},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_SETRJRS*/	{{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_06F,  ST_SUSE},	{F_07F,	 ST_U0},	{F_ILL,	 ST_ILL},	{F_09F,	 ST_U0},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_SETDCRS*/	{{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_06G,  ST_U0},	{F_07G,	 ST_U0},	{F_ILL,	 ST_ILL},	{F_09G,	 ST_U0},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/* STATE:	ST_U0			ST_U1			ST_U3			ST_U4			ST_U6			ST_U7			ST_U8			ST_U9			ST_U10			ST_U11			ST_U12			ST_U19			ST_IWA			ST_IWR			ST_OW			ST_IWL			ST_SUBSET		ST_ILL	      */
-/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*EV_SETUP  */	{{F_00H,  ST_U6},	{F_SIGN, ST_U1},	{F_SIGN, ST_U3},	{F_SIGN, ST_U4},	{F_SIGN, ST_U6},	{F_SIGN, ST_U7},	{F_SIGN, ST_U8},	{F_SIGN, ST_U9},	{F_SIGN, ST_U10},	{F_SIGN, ST_U11},	{F_SIGN, ST_U12},	{F_SIGN, ST_U19},	{F_SIGN, ST_IWA},	{F_SIGN, ST_IWR},	{F_SIGN, ST_OW},	{F_SIGN, ST_IWL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_STATUS */	{{F_00I,  ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_19I,	 ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_STAT, ST_SUSE},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_RELEASE*/	{{F_00J,  ST_U0},	{F_UEM,	 ST_SUSE},	{F_REL,  ST_U0},	{F_REL,  ST_U0},	{F_06J,	 ST_U0},	{F_REL,	 ST_U0},	{F_REL,	 ST_U0},	{F_REL,	 ST_U0},	{F_REL,	 ST_U0},	{F_11J,	 ST_U0},	{F_12J,	 ST_U0},	{F_19J,	 ST_U0},	{F_REL,	 ST_U0},	{F_REL,	 ST_U0},	{F_REL,	 ST_U0},	{F_REL,  ST_U0},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_RELCOMP*/	{{F_NCNA, ST_U0},	{F_01K,	 ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_19K,	 ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_RELCP,ST_U0},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_SETUPAK*/	{{F_UEM,  ST_SUSE},	{F_01L,	 ST_U3},	{F_UEM,  ST_SUSE},	{F_UEM,  ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,  ST_SUSE},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_CALLPRC*/	{{F_UEM,  ST_SUSE},	{F_01M,	 ST_U3},	{F_NCNA, ST_U3},	{F_UEM,  ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,  ST_SUSE},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_ALERT  */	{{F_UEM,  ST_SUSE},	{F_01N,	 ST_U4},	{F_03N,  ST_U4},	{F_UEM,  ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,  ST_SUSE},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_CONNECT*/	{{F_UEM,  ST_SUSE},	{F_01O,	 ST_U10},	{F_03O,  ST_U10},	{F_04O,  ST_U10},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,  ST_SUSE},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_PROGIND*/	{{F_UEM,  ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_03P,  ST_U3},	{F_UEM,  ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,  ST_SUSE},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_DISCONN*/	{{F_UEM,  ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_DISC, ST_U12},	{F_DISC, ST_U12},	{F_06Q,	 ST_U12},	{F_DISC, ST_U12},	{F_DISC, ST_U12},	{F_DISC, ST_U12},	{F_DISC, ST_U12},	{F_11Q,	 ST_U19},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_DISC, ST_U12},	{F_DISC, ST_U12},	{F_DISC, ST_U12},	{F_DISC, ST_U12},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_CONACK */	{{F_UEM,  ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,  ST_SUSE},	{F_UEM,  ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_08R,	 ST_U10},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,	 ST_SUSE},	{F_UEM,  ST_SUSE},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_STATENQ*/	{{F_STENQ,ST_U0},	{F_STENQ,ST_U1},	{F_STENQ,ST_U3},	{F_STENQ,ST_U4},	{F_STENQ,ST_U6},	{F_STENQ,ST_U7},	{F_STENQ,ST_U8},	{F_STENQ,ST_U9},	{F_STENQ,ST_U10},	{F_STENQ,ST_U11},	{F_STENQ,ST_U12},	{F_STENQ,ST_U19},	{F_STENQ,ST_IWA},	{F_STENQ,ST_IWR},	{F_STENQ,ST_OW},	{F_STENQ,ST_OW},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_INFO   */	{{F_UEM,  ST_SUSE},	{F_UEM,  ST_SUSE},	{F_INFO, ST_U3},	{F_INFO, ST_U4},	{F_UEM,	 ST_SUSE},	{F_INFO, ST_U7},	{F_INFO, ST_U8},	{F_INFO, ST_U9},	{F_INFO, ST_U10},	{F_INFO, ST_U11},	{F_INFO, ST_U12},	{F_UEM,  ST_SUSE},	{F_INFO, ST_IWA},	{F_INFO, ST_IWR},	{F_INFO, ST_OW},	{F_INFO, ST_OW},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_FACILITY*/	{{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_FCTY, ST_SUSE},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/* STATE:	ST_U0			ST_U1			ST_U3			ST_U4			ST_U6			ST_U7			ST_U8			ST_U9			ST_U10			ST_U11			ST_U12			ST_U19			ST_IWA			ST_IWR			ST_OW			ST_IWL			ST_SUBSET		ST_ILL	      */
-/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*EV_T303EXP*/	{{F_ILL,  ST_ILL},	{F_01U,	 ST_SUSE},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_T305EXP*/	{{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_11V,	 ST_U19},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_T308EXP*/	{{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_308TO,ST_ILL},	{F_19W,	 ST_SUSE},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_T309EXP*/	{{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_309TO,ST_U0},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_T310EXP*/	{{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_03Y,  ST_U11},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_T313EXP*/	{{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_08Z,	 ST_U11},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/* STATE:	ST_U0			ST_U1			ST_U3			ST_U4			ST_U6			ST_U7			ST_U8			ST_U9			ST_U10			ST_U11			ST_U12			ST_U19			ST_IWA			ST_IWR			ST_OW			ST_IWL			ST_SUBSET		ST_ILL	      */
-/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*EV_DLESTIN*/	{{F_ILL,  ST_ILL},	{F_DLEI, ST_U1},	{F_DLEI, ST_U3},	{F_DLEI, ST_U4},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_DLEI, ST_U1},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_DLRELIN*/	{{F_NCNA, ST_U0},	{F_DLRIA, ST_OW},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRIA,ST_U10},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_DLRI, ST_U0},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_DLESTCF*/	{{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF, ST_SUSE},	{F_DECF2,ST_U8},	{F_DECF3,ST_U0},	{F_DECF1,ST_U1},	{F_DECF4,ST_U7},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_DLRELCF*/	{{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}},
-/*EV_ILL    */	{{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,  ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	 ST_ILL},	{F_ILL,	ST_ILL},        {F_ILL, ST_ILL}}
-};
-
-/*---------------------------------------------------------------------------*
- *	event handler
- *---------------------------------------------------------------------------*/	
-void next_l3state(call_desc_t *cd, int event)
-{
-	int currstate, newstate;
-
-	if(event >= N_EVENTS)
-		panic("i4b_l3fsm.c: event >= N_EVENTS\n");
-
-	currstate = cd->Q931state;
-
-	if(currstate >= N_STATES)
-		panic("i4b_l3fsm.c: currstate >= N_STATES\n");	
-
-	newstate = l3state_tab[event][currstate].newstate;
-
-	if(newstate > N_STATES)
-		panic("i4b_l3fsm.c: newstate > N_STATES\n");	
-	
-	NDBGL3(L3_F_MSG, "L3 FSM event [%s]: [%s => %s]",
-				l3event_text[event],
-                                l3state_text[currstate],
-                                l3state_text[newstate]);
-
-	/* execute function */
-	
-        (*l3state_tab[event][currstate].func)(cd);
-
-	if(newstate == ST_ILL)
-	{
-		newstate = currstate;
-		NDBGL3(L3_F_ERR, "FSM illegal state, state = %s, event = %s!",
-				l3state_text[newstate],
-				l3event_text[event]);
-	}
-
-	if(newstate != ST_SUSE)	
-		cd->Q931state = newstate;        
-}
-
-#if DO_I4B_DEBUG
-/*---------------------------------------------------------------------------*
- *	return pointer to current state description
- *---------------------------------------------------------------------------*/	
-char *print_l3state(call_desc_t *cd)
-{
-	return((char *) l3state_text[cd->Q931state]);
-}
-#endif
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U0 event L4 setup req
- *---------------------------------------------------------------------------*/	
-static void F_00A(call_desc_t *cd)
-{
-	int s;
-	NDBGL3(L3_F_MSG, "FSM function F_00A executing");
-
-	cd->T303_first_to = 1;
-	T303_start(cd);
-
-	s = SPLI4B();
-	if(i4b_get_dl_stat(cd) == DL_DOWN)
-	{
-		splx(s);
-		DL_Est_Req(ctrl_desc[cd->controller].unit);
-		cd->Q931state = ST_OW;
-	}
-	else
-	{
-		cd->Q931state = ST_U1;
-		splx(s);
-		i4b_l3_tx_setup(cd);
-	}		
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U0 event SETUP from L2
- *---------------------------------------------------------------------------*/	
-static void F_00H(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_00H executing");
-	i4b_l4_connect_ind(cd);	/* tell l4 we have an incoming setup */	
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U0 event STATUS from L2
- *---------------------------------------------------------------------------*/	
-static void F_00I(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_00I executing");
-
-	if(cd->call_state != 0)
-	{
-		cd->cause_out = 101;
-		i4b_l3_tx_release_complete(cd, 1);	/* 1 = send cause */
-	}
-	cd->Q931state = ST_U0;
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U0 event RELEASE from L2
- *---------------------------------------------------------------------------*/	
-static void F_00J(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_00J executing");
-	i4b_l3_tx_release_complete(cd, 0);	/* 0 = don't send cause */	
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U1 event disconnect req from L4
- *---------------------------------------------------------------------------*/	
-static void F_01B(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_01B executing");
-	/* cause from L4 */
-	i4b_l3_tx_disconnect(cd);
-	T303_stop(cd);
-	T305_start(cd);	
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U1 event RELEASE COMPLETE from L2
- *---------------------------------------------------------------------------*/	
-static void F_01K(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_01K executing");
-	T303_stop(cd);
-	i4b_l4_disconnect_ind(cd);	/* tell l4 we were rejected */
-	freecd_by_cd(cd);	
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U1 event SETUP ACK from L2
- *---------------------------------------------------------------------------*/	
-static void F_01L(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_01L executing");
-	T303_stop(cd);
-
-	/*
-	 * since this implementation does NOT support overlap sending,
-	 * we react here as if we received a CALL PROCEEDING because
-	 * several PBX's react with a SETUP ACK even if the called
-	 * number is complete AND we sent a SENDING COMPLETE in the
-	 * preceding SETUP message. (-hm)
-	 */
-
-	T310_start(cd);
-	i4b_l4_proceeding_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U1 event CALL PROCEEDING from L2
- *---------------------------------------------------------------------------*/	
-static void F_01M(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_01M executing");
-	T303_stop(cd);
-	T310_start(cd);
-	i4b_l4_proceeding_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U1 event ALERT from L2  (XXX !)
- *---------------------------------------------------------------------------*/	
-static void F_01N(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_01N executing");
-	T303_stop(cd);
-	i4b_l4_alert_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U1 event CONNECT from L2 (XXX !)
- *---------------------------------------------------------------------------*/	
-static void F_01O(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_01O executing");
-	T303_stop(cd);
-	i4b_l3_tx_connect_ack(cd);
-	i4b_l4_connect_active_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U1 event T303 timeout
- *---------------------------------------------------------------------------*/	
-static void F_01U(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_01U executing");
-	if(cd->T303_first_to == 1)
-	{
-		cd->T303_first_to = 0;
-		i4b_l3_tx_setup(cd);
-		T303_start(cd);
-		cd->Q931state = ST_U1;
-	}
-	else
-	{
-		i4b_l4_disconnect_ind(cd);
-		freecd_by_cd(cd);
-		cd->Q931state = ST_U0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U3 event release req from L4
- *---------------------------------------------------------------------------*/	
-static void F_03C(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_03C executing");
-	T310_stop(cd);
-	cd->cause_out = 6;
-	i4b_l3_tx_release(cd, 1);	/* 0 = don't send cause */	
-	cd->T308_first_to = 1;
-	T308_start(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U3 event ALERT from L2
- *---------------------------------------------------------------------------*/	
-static void F_03N(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_03N executing");
-	T310_stop(cd);
-	i4b_l4_alert_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U3 event CONNECT from L2
- *---------------------------------------------------------------------------*/	
-static void F_03O(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_03O executing");
-	T310_stop(cd);
-	i4b_l3_tx_connect_ack(cd);	/* CONNECT ACK to network */
-	i4b_l4_connect_active_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U3 event PROGESS IND from L2
- *---------------------------------------------------------------------------*/	
-static void F_03P(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_03P executing");
-	T310_stop(cd);
-#ifdef NOTDEF
-	i4b_l4_progress_ind(cd);
-#endif	
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U3 event T310 timeout
- *---------------------------------------------------------------------------*/	
-static void F_03Y(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_03Y executing");
-	cd->cause_out = 102;	/* recovery on timer expiry */
-	i4b_l3_tx_disconnect(cd);
-	T305_start(cd);
-	i4b_l4_disconnect_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U4 event CONNECT from L2
- *---------------------------------------------------------------------------*/	
-static void F_04O(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_04O executing");
-	i4b_l3_tx_connect_ack(cd);	/* CONNECT ACK to network */		
-	i4b_l4_connect_active_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U6 event alert req from L4
- *---------------------------------------------------------------------------*/	
-static void F_06D(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_06D executing");
-
-	if(i4b_get_dl_stat(cd) == DL_DOWN)
-	{	
-		DL_Est_Req(ctrl_desc[cd->controller].unit);
-		cd->Q931state = ST_IWL;
-	}
-	else
-	{
-		i4b_l3_tx_alert(cd);
-		cd->Q931state = ST_U7;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U6 event incoming setup accept from L4
- *---------------------------------------------------------------------------*/	
-static void F_06E(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_06E executing");
-
-	if(i4b_get_dl_stat(cd) == DL_DOWN)
-	{	
-		DL_Est_Req(ctrl_desc[cd->controller].unit);
-		cd->Q931state = ST_IWA;		
-	}
-	else
-	{
-		i4b_l3_tx_connect(cd);
-		cd->Q931state = ST_U8;
-	}
-	T313_start(cd);		
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U6 event incoming setup reject from L4
- *---------------------------------------------------------------------------*/	
-static void F_06F(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_06F executing");
-
-	if(i4b_get_dl_stat(cd) == DL_DOWN)
-	{	
-		DL_Est_Req(ctrl_desc[cd->controller].unit);
-		cd->Q931state = ST_IWR;		
-	}
-	else
-	{
-		int s = SPLI4B();
-		i4b_l3_tx_release_complete(cd, 1);
-		cd->Q931state = ST_U0;
-		freecd_by_cd(cd);
-		splx(s);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U6 event incoming setup ignore from L4
- *---------------------------------------------------------------------------*/	
-static void F_06G(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_06G executing");
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U6 event RELEASE from L2
- *---------------------------------------------------------------------------*/	
-static void F_06J(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_06J executing");
-	i4b_l3_tx_release_complete(cd, 0);
-	i4b_l4_disconnect_ind(cd);	
-	freecd_by_cd(cd);	
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U6 event DISCONNECT from L2
- *---------------------------------------------------------------------------*/	
-static void F_06Q(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_06Q executing");
-	i4b_l4_disconnect_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U7 event setup response accept from L4
- *---------------------------------------------------------------------------*/	
-static void F_07E(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_07E executing");
-	i4b_l3_tx_connect(cd);
-	T313_start(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U7 event setup response reject from L4
- *---------------------------------------------------------------------------*/	
-static void F_07F(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_07F executing");
-	i4b_l3_tx_release_complete(cd, 1);
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U7 event setup response ignore from L4
- *---------------------------------------------------------------------------*/	
-static void F_07G(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_07G executing");
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U8 event CONNECT ACK from L2
- *---------------------------------------------------------------------------*/	
-static void F_08R(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_08R executing");
-	T313_stop(cd);
-	i4b_l4_connect_active_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U8 event T313 timeout
- *---------------------------------------------------------------------------*/	
-static void F_08Z(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_08Z executing");
-	cd->cause_out = 102;	/* recovery on timer expiry */
-	i4b_l3_tx_disconnect(cd);
-	T305_start(cd);
-	i4b_l4_disconnect_ind(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U9 event alert req from L4
- *---------------------------------------------------------------------------*/	
-static void F_09D(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_09D executing");
-	i4b_l3_tx_alert(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U9 event setup response accept from L4
- *---------------------------------------------------------------------------*/	
-static void F_09E(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_09E executing");
-	i4b_l3_tx_connect(cd);
-	T313_start(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U9 event setup response reject from L4
- *---------------------------------------------------------------------------*/	
-static void F_09F(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_09F executing");
-	i4b_l3_tx_release_complete(cd, 1);
-	freecd_by_cd(cd);
-}
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U9 event setup response ignore from L4
- *---------------------------------------------------------------------------*/	
-static void F_09G(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_09G executing");
-	freecd_by_cd(cd);	
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U11 event RELEASE from L2
- *---------------------------------------------------------------------------*/	
-static void F_11J(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_11J executing");
-	T305_stop(cd);
-	i4b_l3_tx_release_complete(cd, 0);
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U11 event DISCONNECT from L2
- *---------------------------------------------------------------------------*/	
-static void F_11Q(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_11Q executing");
-	T305_stop(cd);
-	i4b_l3_tx_release(cd, 0);
-	cd->T308_first_to = 1;
-	T308_start(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U11 event T305 timeout
- *---------------------------------------------------------------------------*/	
-static void F_11V(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_11V executing");
-	cd->cause_out = 102;
-	i4b_l3_tx_release(cd, 1);
-	cd->T308_first_to = 1;
-	T308_start(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U12 event release req from L4
- *---------------------------------------------------------------------------*/	
-static void F_12C(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_12C executing");
-	i4b_l3_tx_release(cd, 1);
-	cd->T308_first_to = 1;
-	T308_start(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U12 event RELEASE from L2
- *---------------------------------------------------------------------------*/	
-static void F_12J(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_12J executing");
-	i4b_l3_tx_release_complete(cd, 0);
-	i4b_l4_disconnect_ind(cd);	
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U19 event STATUS from L2
- *---------------------------------------------------------------------------*/	
-static void F_19I(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_19I executing");
-
-	if(cd->call_state == 0)
-	{
-		i4b_l4_status_ind(cd);
-		freecd_by_cd(cd);
-		cd->Q931state = ST_U0;
-	}
-	else
-	{
-		cd->Q931state = ST_U19;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U19 event RELEASE from L2
- *---------------------------------------------------------------------------*/	
-static void F_19J(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_19J executing");
-	T308_stop(cd);
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U19 event RELEASE COMPLETE from L2
- *---------------------------------------------------------------------------*/	
-static void F_19K(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_19K executing");
-	T308_stop(cd);
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U19 event T308 timeout
- *---------------------------------------------------------------------------*/	
-static void F_19W(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_19W executing");
-	if(cd->T308_first_to == 0)
-	{
-		cd->T308_first_to = 1;
-		i4b_l3_tx_release(cd, 0);
-		T308_start(cd);
-		cd->Q931state = ST_U19;
-	}
-	else
-	{
-		cd->T308_first_to = 0;
-		i4b_l4_disconnect_ind(cd);
-		freecd_by_cd(cd);
-		cd->Q931state = ST_U0;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM routine no change no action
- *---------------------------------------------------------------------------*/	
-static void F_NCNA(call_desc_t *cd)
-{
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM any state event STATUS ENQ from L2
- *---------------------------------------------------------------------------*/	
-static void F_STENQ(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_STENQ executing");
-	i4b_l3_tx_status(cd, CAUSE_Q850_STENQRSP); /* 30, resonse to stat enq */
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM any state except 0 & 19 event STATUS from L2
- *---------------------------------------------------------------------------*/	
-static void F_STAT(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_STAT executing");
-	if(cd->call_state == 0)
-	{
-		i4b_l4_status_ind(cd);
-		cd->Q931state = ST_U0;		
-		freecd_by_cd(cd);
-	}
-	else
-	{
-		/* XXX !!!!!!!!!!!!!!!!!! */
-		
-		i4b_l4_status_ind(cd);
-		cd->cause_out = 101;	/* message not compatible with call state */
-		i4b_l3_tx_disconnect(cd);
-		T305_start(cd);
-		cd->Q931state = ST_U11;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM some states event INFORMATION from L2
- *---------------------------------------------------------------------------*/	
-static void F_INFO(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_INFO executing");
-	i4b_l4_info_ind(cd);
-	/* remain in current state */
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM T308 timeout while expecting RELEASE COMPLETE
- *---------------------------------------------------------------------------*/	
-static void F_308TO(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_308TO executing");
-	i4b_l3_stop_all_timers(cd);
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM some states event RELEASE COMPLETE from L2
- *---------------------------------------------------------------------------*/	
-static void F_RELCP(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_RELCP executing");
-	i4b_l3_stop_all_timers(cd);
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM some states event RELEASE from L2
- *---------------------------------------------------------------------------*/	
-static void F_REL(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_REL executing");
-	i4b_l3_stop_all_timers(cd);
-	i4b_l3_tx_release_complete(cd, 0);
-	i4b_l4_disconnect_ind(cd);	
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM some states event DISCONNECT from L2
- *---------------------------------------------------------------------------*/	
-static void F_DISC(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DISC executing");
-	i4b_l3_stop_all_timers(cd);
-
-	/*
-	 * no disconnect ind to L4, no jump to state U12
-	 * instead we issue a RELEASE and jump to U19
-	 */
-
-	i4b_l3_tx_release(cd, 0);
-	cd->T308_first_to = 1;	
-	T308_start(cd);
-	cd->Q931state = ST_U19;
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM some states event disconnect request from L4
- *---------------------------------------------------------------------------*/	
-static void F_DCRQ(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DCRQ executing");
-
-	/* stop T310 in case this is the result of an incoming call for a */
-	/* calledback connection */
-
-	if(cd->T310 == TIMER_ACTIVE)
-		T310_stop(cd);
-		
-	/* cause from L4 */
-	i4b_l3_tx_disconnect(cd);
-	T305_start(cd);
-	cd->Q931state = ST_U11;	
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM any state except 0 event unexpected message from L2
- *---------------------------------------------------------------------------*/	
-static void F_UEM(call_desc_t *cd)
-{
-	NDBGL3(L3_F_ERR, "FSM function F_UEM executing, state = %s", print_l3state(cd));
-	i4b_l3_tx_status(cd, CAUSE_Q850_MSGNCWCS); /* 101, message not compatible with call state */
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM any state except 0 event SETUP from L2
- *---------------------------------------------------------------------------*/	
-static void F_SIGN(call_desc_t *cd)
-{
-	NDBGL3(L3_F_ERR, "FSM function F_SIGN executing");
-
-/* XXX */ /* freecd_by_cd(cd); ?????????? XXX */
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM relevant states event DL ESTABLISH IND from L2
- *---------------------------------------------------------------------------*/	
-static void F_DLEI(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DLEI executing");
-
-/* XXX */
-
-	/* remain in current state */
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM any state event illegal event occured
- *---------------------------------------------------------------------------*/	
-static void F_ILL(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_ILL executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM any state event T309 timeout
- *---------------------------------------------------------------------------*/	
-static void F_309TO(call_desc_t *cd)
-{
-	NDBGL3(L3_F_ERR, "FSM function F_309TO executing");
-
-/* XXX */
-
-#ifdef NOTDEF
-	i4b_l4_dl_fail_ind(cd);
-#endif	
-
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM any state event FACILITY message received
- *---------------------------------------------------------------------------*/	
-static void F_FCTY(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_FCTY executing");
-	/* ST_SUSE, no change in state ! */
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state ST_OW event DL ESTABLISH CONF from L2
- *---------------------------------------------------------------------------*/	
-static void F_DECF1(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DECF1 executing");
-	i4b_l3_tx_setup(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state ST_IWA event DL ESTABLISH CONF from L2
- *---------------------------------------------------------------------------*/	
-static void F_DECF2(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DECF2 executing");
-	i4b_l3_tx_connect(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state ST_IWR event DL ESTABLISH CONF from L2
- *---------------------------------------------------------------------------*/	
-static void F_DECF3(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DECF3 executing");
-	i4b_l3_tx_release_complete(cd, 1);
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state ST_IWL event DL ESTABLISH CONF from L2
- *---------------------------------------------------------------------------*/	
-static void F_DECF4(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DECF4 executing");
-	i4b_l3_tx_alert(cd);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM any state event DL ESTABLISH CONF from L2
- *---------------------------------------------------------------------------*/	
-static void F_DECF(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DECF executing");
-	T309_stop(cd);
-	i4b_l3_tx_status(cd, CAUSE_Q850_NORMUNSP); /* 31, normal unspecified */
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM any state except U10 event DL RELEASE IND from L2
- *---------------------------------------------------------------------------*/	
-static void F_DLRI(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DLRI executing");
-	i4b_l3_stop_all_timers(cd);
-	i4b_l4_disconnect_ind(cd);
-	freecd_by_cd(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L3 FSM state U10 event DL RELEASE IND from L2
- *---------------------------------------------------------------------------*/	
-static void F_DLRIA(call_desc_t *cd)
-{
-	NDBGL3(L3_F_MSG, "FSM function F_DLRIA executing");
-
-	if(cd->T309 == TIMER_IDLE)
-		T309_start(cd);
-
-	DL_Est_Req(ctrl_desc[cd->controller].unit);
-}
--- sys/i4b/layer3/i4b_l3fsm.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_l3fsm.c - layer 3 FSM
- *      -------------------------
- * 
- * $FreeBSD: src/sys/i4b/layer3/i4b_l3fsm.h,v 1.9 2005/01/06 22:18:21 imp Exp $
- *
- *      last edit-date: [Sat Mar  9 19:34:51 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L3FSM_H_
-#define _I4B_L3FSM_H_
-
-enum Q931_states {
-	ST_U0,
-	ST_U1,
-	ST_U3,
-	ST_U4,
-	ST_U6,
-	ST_U7,
-	ST_U8,
-	ST_U9,
-	ST_U10,
-	ST_U11,
-	ST_U12,
-	ST_U19,
-
-	ST_IWA,		/* incoming call, wait establish, then accept */
-	ST_IWR,		/* incoming call, wait establish, then reject */
-	ST_OW,		/* outgoing call, wait establish */
-	ST_IWL,		/* incoming call, wait establish, then alert */
-	
-	ST_SUSE,	/* SUBroutine SETs new state on exit */
-	ST_ILL,		/* Illegal */
-	
-	N_STATES	/* number of states */
-};
-
-enum Q931_events {
-
-	EV_SETUPRQ,	/* setup request from L4		*/
-	EV_DISCRQ,	/* disconnect request from L4		*/
-	EV_RELRQ,	/* release request from L4		*/
-	EV_ALERTRQ,	/* alerting request from L4		*/
-	EV_SETACRS,	/* setup response accept from l4	*/
-	EV_SETRJRS,	/* setup response reject from l4	*/
-	EV_SETDCRS,	/* setup response dontcare from l4	*/
-	
-	EV_SETUP,	/* incoming SETUP message from L2	*/
-	EV_STATUS,	/* incoming STATUS message from L2	*/
-	EV_RELEASE,	/* incoming RELEASE message from L2	*/
-	EV_RELCOMP,	/* incoming RELEASE COMPLETE from L2	*/
-	EV_SETUPAK,	/* incoming SETUP ACK message from L2	*/
-	EV_CALLPRC,	/* incoming CALL PROCEEDING from L2	*/
-	EV_ALERT,	/* incoming ALERT message from L2	*/
-	EV_CONNECT,	/* incoming CONNECT message from L2	*/	
-	EV_PROGIND,	/* incoming Progress IND from L2	*/
-	EV_DISCONN,	/* incoming DISCONNECT message from L2	*/
-	EV_CONACK,	/* incoming CONNECT ACK message from L2	*/
-	EV_STATENQ,	/* incoming STATUS ENQ message from L2	*/
-	EV_INFO,	/* incoming INFO message from L2	*/
-	EV_FACILITY,	/* FACILITY message			*/
-	
-	EV_T303EXP,	/* Timer T303 expired			*/	
-	EV_T305EXP,	/* Timer T305 expired			*/
-	EV_T308EXP,	/* Timer T308 expired			*/	
-	EV_T309EXP,	/* Timer T309 expired			*/	
-	EV_T310EXP,	/* Timer T310 expired			*/	
-	EV_T313EXP,	/* Timer T313 expired			*/	
-	
-	EV_DLESTIN,	/* dl establish indication from l2	*/
-	EV_DLRELIN,	/* dl release indication from l2	*/
-	EV_DLESTCF,	/* dl establish confirm from l2		*/
-	EV_DLRELCF,	/* dl release indication from l2	*/
-	
-	EV_ILL,		/* Illegal */	
-	N_EVENTS
-};
-	
-#endif /* _I4B_L3FSM_H_ */
--- sys/i4b/layer3/i4b_q931.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_q931.c - Q931 received messages handling
- *	--------------------------------------------
- *      last edit-date: [Sun Aug 11 19:18:08 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer3/i4b_q931.c,v 1.18 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include <i4b/include/i4b_isdnq931.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer3/i4b_l3.h>
-#include <i4b/layer3/i4b_l3fsm.h>
-#include <i4b/layer3/i4b_q931.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-unsigned int i4b_l3_debug = L3_DEBUG_DEFAULT;
-
-ctrl_desc_t ctrl_desc[MAX_CONTROLLERS];	/* controller description array */
-int utoc_tab[MAX_CONTROLLERS];		/* unit to controller conversion */
-
-/* protocol independent causes -> Q.931 causes */
-
-unsigned char cause_tab_q931[CAUSE_I4B_MAX] = {
-	CAUSE_Q850_NCCLR, 	/* CAUSE_I4B_NORMAL -> normal call clearing */
-	CAUSE_Q850_USRBSY,	/* CAUSE_I4B_BUSY -> user busy */
-	CAUSE_Q850_NOCAVAIL,	/* CAUSE_I4B_NOCHAN -> no circuit/channel available*/
-	CAUSE_Q850_INCDEST,	/* CAUSE_I4B_INCOMP -> incompatible destination */
-	CAUSE_Q850_CALLREJ,	/* CAUSE_I4B_REJECT -> call rejected */
-	CAUSE_Q850_DSTOOORDR,	/* CAUSE_I4B_OOO -> destination out of order */
-	CAUSE_Q850_TMPFAIL,	/* CAUSE_I4B_TMPFAIL -> temporary failure */
-	CAUSE_Q850_USRBSY,	/* CAUSE_I4B_L1ERROR -> L1 error / persistent deact XXX */
-	CAUSE_Q850_USRBSY,	/* CAUSE_I4B_LLDIAL -> no dialout on leased line XXX */
-};	
-
-/*---------------------------------------------------------------------------*
- *	setup cr ref flag according to direction
- *---------------------------------------------------------------------------*/
-unsigned char
-setup_cr(call_desc_t *cd, unsigned char cr)
-{
-	if(cd->crflag == CRF_ORIG)
-		return(cr & 0x7f);	/* clear cr ref flag */
-	else if(cd->crflag == CRF_DEST)
-		return(cr | 0x80);	/* set cr ref flag */
-	else
-		panic("setup_cr: invalid crflag!\n"); 
-}
-
-/*---------------------------------------------------------------------------*
- *	decode and process a Q.931 message
- *---------------------------------------------------------------------------*/
-void
-i4b_decode_q931(int unit, int msg_len, u_char *msg_ptr)
-{
-	call_desc_t *cd;
-	int codeset = CODESET_0;
-	int old_codeset = CODESET_0;
-	int shift_flag = UNSHIFTED;
-	int crlen = 0;
-	int crval = 0;
-	int crflag = 0;
-	int i;	
-	int offset;
-	int s;
-	
-	/* check protocol discriminator */
-	
-	if(*msg_ptr != PD_Q931)
-	{
-		static int protoflag = -1;	/* print only once .. */
-
-		if(*msg_ptr != protoflag)
-		{
-			NDBGL3(L3_P_ERR, "unknown protocol discriminator 0x%x!", *msg_ptr);
-			protoflag = *msg_ptr;
-		}			
-		return;
-	}
-
-	msg_ptr++;
-	msg_len--;
-
-	s = SPLI4B();		/* this has to be protected ! */
-	
-	/* extract call reference */
-
-	crlen = *msg_ptr & CRLENGTH_MASK;
-	msg_ptr++;
-	msg_len--;
-	
-	if(crlen != 0)
-	{
-		crval += *msg_ptr & 0x7f;
-		crflag = (*msg_ptr >> 7) & 0x01;
-		msg_ptr++;
-		msg_len--;
-		
-		for(i=1; i < crlen; i++)
-		{
-			crval += *msg_ptr;
-			msg_ptr++;
-			msg_len--;			
-		}
-	}
-	else
-	{
-		crval = 0;
-		crflag = 0;
-	}
-			
-	NDBGL3(L3_P_MSG, "Call Ref, len %d, val %d, flag %d", crlen, crval, crflag);
-
-	/* find or allocate calldescriptor */
-
-	if((cd = cd_by_unitcr(unit, crval,
-			crflag == CRF_DEST ? CRF_ORIG : CRF_DEST)) == NULL)
-	{
-		if(*msg_ptr == SETUP)
-		{
-			/* get and init new calldescriptor */
-
-			cd = reserve_cd();	/* cdid filled in */
-			cd->controller = utoc_tab[unit];
-			cd->cr = crval;		
-			cd->crflag = CRF_DEST;	/* we are the dest side */
-			cd->ilt = NULL;		/* reset link tab ptrs */
-			cd->dlt = NULL;
-		}
-		else
-		{
-/*XXX*/			if(crval != 0)	/* ignore global call references */
-			{
-				NDBGL3(L3_P_ERR, "cannot find calldescriptor for cr = 0x%x, crflag = 0x%x, msg = 0x%x, frame = ", crval, crflag, *msg_ptr);
-				i4b_print_frame(msg_len, msg_ptr);
-			}
-			splx(s);
-			return;
-		}
-	}
-
-	splx(s);
-
-	/* decode and handle message type */
-	
-	i4b_decode_q931_message(unit, cd, *msg_ptr);
-	msg_ptr++;
-	msg_len--;
-	
-	/* process information elements */
-
-	while(msg_len > 0)
-	{
-		/* check for shift codeset IE */
-		
-		if((*msg_ptr & 0x80) && ((*msg_ptr & 0xf0) == SOIE_SHIFT))
-		{
-			if(!(*msg_ptr & SHIFT_LOCK))
-				shift_flag = SHIFTED;
-
-			old_codeset = codeset;
-			codeset = *msg_ptr & CODESET_MASK;
-
-			if((shift_flag != SHIFTED) &&
-			   (codeset <= old_codeset))
-			{
-				NDBGL3(L3_P_ERR, "Q.931 lockingshift proc violation, shift %d -> %d", old_codeset, codeset);
-				codeset = old_codeset;
-			}
-			msg_len--;
-			msg_ptr++;
-		}
-
-		/* process one IE for selected codeset */
-		
-		switch(codeset)
-		{
-			case CODESET_0:
-				offset = i4b_decode_q931_cs0_ie(unit, cd, msg_len, msg_ptr);
-				msg_len -= offset;
-				msg_ptr += offset;
-				break;
-				
-			default:
-				NDBGL3(L3_P_ERR, "unknown codeset %d, ", codeset);
-				i4b_print_frame(msg_len, msg_ptr);
-				msg_len = 0;
-				break;
-		}
-
-		/* check for non-locking shifts */
-		
-		if(shift_flag == SHIFTED)
-		{
-			shift_flag = UNSHIFTED;
-			codeset = old_codeset;
-		}
-	}
-	next_l3state(cd, cd->event);
-}
-
-/*---------------------------------------------------------------------------*
- *	decode and process one Q.931 codeset 0 information element
- *---------------------------------------------------------------------------*/
-int
-i4b_decode_q931_cs0_ie(int unit, call_desc_t *cd, int msg_len, u_char *msg_ptr)
-{
-	int i, j;
-	char *p;
-	
-	switch(*msg_ptr)
-	{
-
-/*********/
-/* Q.931 */
-/*********/
-		/* single byte IE's */
-		
-		case IEI_SENDCOMPL:
-			NDBGL3(L3_P_MSG, "IEI_SENDCOMPL");
-			return(1);
-			break;
-
-		/* multi byte IE's */
-		
-		case IEI_SEGMMSG:	/* segmented message */
-			NDBGL3(L3_P_MSG, "IEI_SEGMENTED_MESSAGE");
-			break;
-			
-		case IEI_BEARERCAP:	/* bearer capability */
-			switch(msg_ptr[2])
-			{
-				case 0x80:	/* speech */
-				case 0x89:	/* restricted digital info */
-				case 0x90:	/* 3.1KHz audio */
-/* XXX */				cd->bprot = BPROT_NONE;
-					NDBGL3(L3_P_MSG, "IEI_BEARERCAP - Telephony");
-					break;
-
-				case 0x88:	/* unrestricted digital info */
-/* XXX */				cd->bprot = BPROT_RHDLC;
-					NDBGL3(L3_P_MSG, "IEI_BEARERCAP - Raw HDLC");
-					break;
-
-				default:
-/* XXX */				cd->bprot = BPROT_NONE;
-					NDBGL3(L3_P_ERR, "IEI_BEARERCAP - Unsupported B-Protocol 0x%x", msg_ptr[2]);
-					break;
-			}
-			break;
-	
-		case IEI_CAUSE:		/* cause */
-			if(msg_ptr[2] & 0x80)
-			{
-				cd->cause_in = msg_ptr[3] & 0x7f;
-				NDBGL3(L3_P_MSG, "IEI_CAUSE = %d", msg_ptr[3] & 0x7f);
-			}
-			else
-			{
-				cd->cause_in = msg_ptr[4] & 0x7f;
-				NDBGL3(L3_P_MSG, "IEI_CAUSE = %d", msg_ptr[4] & 0x7f);
-			}
-			break;
-	
-		case IEI_CALLID:	/* call identity */
-			NDBGL3(L3_P_MSG, "IEI_CALL_IDENTITY");
-			break;
-
-		case IEI_CALLSTATE:	/* call state		*/
-			cd->call_state = msg_ptr[2] & 0x3f;		
-			NDBGL3(L3_P_MSG, "IEI_CALLSTATE = %d", cd->call_state);
-			break;
-			
-		case IEI_CHANNELID:	/* channel id */
-			if((msg_ptr[2] & 0xf4) != 0x80)
-			{
-				cd->channelid = CHAN_NO;
-				NDBGL3(L3_P_ERR, "IEI_CHANNELID, unsupported value 0x%x", msg_ptr[2]);
-			}
-			else
-			{
-				switch(msg_ptr[2] & 0x03)
-				{
-					case IE_CHAN_ID_NO:
-						cd->channelid = CHAN_NO;
-						break;
-					case IE_CHAN_ID_B1:
-						cd->channelid = CHAN_B1;
-						break;
-					case IE_CHAN_ID_B2:
-						cd->channelid = CHAN_B2;
-						break;
-					case IE_CHAN_ID_ANY:
-						cd->channelid = CHAN_ANY;
-						break;
-				}
-				cd->channelexcl = (msg_ptr[2] & 0x08) >> 3;
-
-				NDBGL3(L3_P_MSG, "IEI_CHANNELID - channel %d, exclusive = %d", cd->channelid, cd->channelexcl);
-
-				/* if this is a setup message, reserve channel */
-				
-				if(cd->event == EV_SETUP)
-				{
-					if((cd->channelid == CHAN_B1) || (cd->channelid == CHAN_B2))
-					{
-						if(ctrl_desc[cd->controller].bch_state[cd->channelid] == BCH_ST_FREE)
-							ctrl_desc[cd->controller].bch_state[cd->channelid] = BCH_ST_RSVD;
-						else
-							NDBGL3(L3_P_ERR, "IE ChannelID, Channel NOT free!!");
-					}
-					else if(cd->channelid == CHAN_NO)
-					{
-						NDBGL3(L3_P_MSG, "IE ChannelID, SETUP with channel = No channel (CW)");
-					}
-					else /* cd->channelid == CHAN_ANY */
-					{
-						NDBGL3(L3_P_ERR, "ERROR: IE ChannelID, SETUP with channel = Any channel!");
-					}
-				}
-			}
-			break;				
-	
-		case IEI_PROGRESSI:	/* progress indicator	*/
-			NDBGL3(L3_P_MSG, "IEI_PROGRESSINDICATOR");
-			break;
-			
-		case IEI_NETSPCFAC:	/* network specific fac */
-			NDBGL3(L3_P_MSG, "IEI_NETSPCFAC");
-			break;
-			
-		case IEI_NOTIFIND:	/* notification indicator */
-			NDBGL3(L3_P_MSG, "IEI_NOTIFICATION_INDICATOR");
-			break;
-			
-		case IEI_DISPLAY:	/* display		*/
-			memcpy(cd->display, &msg_ptr[2], min(DISPLAY_MAX, msg_ptr[1]));
-			cd->display[min(DISPLAY_MAX, msg_ptr[1])] = '\0';
-			NDBGL3(L3_P_MSG, "IEI_DISPLAY = %s", cd->display);
-  			break;
-			
-		case IEI_DATETIME:	/* date/time		*/
-			i = 2;
-			j = msg_ptr[1];
-			p = &(cd->datetime[0]);
-			*p = '\0';
-			
-			for(j = msg_ptr[1]; j > 0; j--, i++)
-				sprintf(p+strlen(p), "%02d", msg_ptr[i]);
-			
-			NDBGL3(L3_P_MSG, "IEI_DATETIME = %s", cd->datetime);
-			break;
-			
-		case IEI_KEYPAD:	/* keypad facility */
-			NDBGL3(L3_P_MSG, "IEI_KEYPAD_FACILITY");
-			break;
-			
-		case IEI_SIGNAL:	/* signal type */
-			NDBGL3(L3_P_MSG, "IEI_SIGNAL = %d", msg_ptr[2]);
-			break;
-
-		case IEI_INFRATE:	/* information rate */
-			NDBGL3(L3_P_MSG, "IEI_INFORMATION_RATE");
-			break;
-
-		case IEI_ETETDEL:	/* end to end transit delay */
-			NDBGL3(L3_P_MSG, "IEI_END_TO_END_TRANSIT_DELAY");
-			break;
-
-		case IEI_CUG:		/* closed user group */
-			NDBGL3(L3_P_MSG, "IEI_CLOSED_USER_GROUP");
-			break;
-
-		case IEI_CALLINGPN:	/* calling party no */
-			if(msg_ptr[2] & 0x80) /* no presentation/screening indicator ? */
-			{
-				memcpy(cd->src_telno, &msg_ptr[3], min(TELNO_MAX, msg_ptr[1]-1));
-				cd->src_telno[min(TELNO_MAX, msg_ptr[1] - 1)] = '\0';
-				cd->scr_ind = SCR_NONE;
-				cd->prs_ind = PRS_NONE;				
-			}
-			else
-			{
-				memcpy(cd->src_telno, &msg_ptr[4], min(TELNO_MAX, msg_ptr[1]-2));
-				cd->src_telno[min(TELNO_MAX, msg_ptr[1] - 2)] = '\0';
-				cd->scr_ind = (msg_ptr[3] & 0x03) + SCR_USR_NOSC;
-				cd->prs_ind = ((msg_ptr[3] >> 5) & 0x03) + PRS_ALLOWED;
-			}
-
-			/* type of number (source) */
-			switch ((msg_ptr[2] & 0x70) >> 4)
-			{
-				case 1:	
-					cd->src_ton = TON_INTERNAT;
-					break;
-				case 2:
-					cd->src_ton = TON_NATIONAL;
-					break;
-				default:
-					cd->src_ton = TON_OTHER;
-					break;
-			}
-			NDBGL3(L3_P_MSG, "IEI_CALLINGPN = %s", cd->src_telno);
-			break;
-	
-		case IEI_CALLINGPS:	/* calling party subaddress */
-			memcpy(cd->src_subaddr, &msg_ptr[3], min(SUBADDR_MAX, msg_ptr[1]-1));
-			cd->src_subaddr[min(SUBADDR_MAX, msg_ptr[1] - 1)] = '\0';
-			NDBGL3(L3_P_MSG, "IEI_CALLINGPS = %s", cd->src_subaddr);
-			break;
-			
-		case IEI_CALLEDPN:	/* called party number */
-			memcpy(cd->dst_telno, &msg_ptr[3], min(TELNO_MAX, msg_ptr[1]-1));
-			cd->dst_telno[min(TELNO_MAX, msg_ptr[1] - 1)] = '\0';
-
-			/* type of number (destination) */
-			switch ((msg_ptr[2] & 0x70) >> 4)
-			{
-				case 1:	
-					cd->dst_ton = TON_INTERNAT;
-					break;
-				case 2:
-					cd->dst_ton = TON_NATIONAL;
-					break;
-				default:
-					cd->dst_ton = TON_OTHER;
-					break;
-			}
-
-			NDBGL3(L3_P_MSG, "IEI_CALLED = %s", cd->dst_telno); 
-			break;
-	
-		case IEI_CALLEDPS:	/* called party subaddress */
-			memcpy(cd->dst_subaddr, &msg_ptr[3], min(SUBADDR_MAX, msg_ptr[1]-1));
-			cd->dst_subaddr[min(SUBADDR_MAX, msg_ptr[1] - 1)] = '\0';
-			NDBGL3(L3_P_MSG, "IEI_CALLEDPS = %s", cd->dst_subaddr);
-			break;
-
-		case IEI_REDIRNO:	/* redirecting number */
-			NDBGL3(L3_P_MSG, "IEI_REDIRECTING_NUMBER");
-			break;
-
-		case IEI_TRNSEL:	/* transit network selection */
-			NDBGL3(L3_P_MSG, "IEI_TRANSIT_NETWORK_SELECTION");
-			break;
-
-		case IEI_RESTARTI:	/* restart indicator */
-			NDBGL3(L3_P_MSG, "IEI_RESTART_INDICATOR");
-			break;
-
-		case IEI_LLCOMPAT:	/* low layer compat */
-			NDBGL3(L3_P_MSG, "IEI_LLCOMPAT");
-			break;
-			
-		case IEI_HLCOMPAT:	/* high layer compat	*/
-			NDBGL3(L3_P_MSG, "IEI_HLCOMPAT");
-			break;
-			
-		case IEI_USERUSER:	/* user-user */
-			NDBGL3(L3_P_MSG, "IEI_USER_USER");
-			break;
-			
-		case IEI_ESCAPE:	/* escape for extension */
-			NDBGL3(L3_P_MSG, "IEI_ESCAPE");
-			break;
-			
-/*********/
-/* Q.932 */
-/*********/
-		case IEI_FACILITY:	/* facility		*/
-			NDBGL3(L3_P_MSG, "IEI_FACILITY");
-			if(i4b_aoc(msg_ptr, cd) > -1)
-				i4b_l4_charging_ind(cd);
-			break;
-			
-/*********/
-/* Q.95x */
-/*********/
-		case IEI_CONCTDNO:	/* connected number	*/
-			NDBGL3(L3_P_MSG, "IEI_CONCTDNO");
-			break;
-			
-			
-		default:
-			NDBGL3(L3_P_ERR, "Unknown IE %d - ", *msg_ptr);
-			i4b_print_frame(msg_ptr[1]+2, msg_ptr);
-			break;
-	}
-	return(msg_ptr[1] + 2);
-}
-
-/*---------------------------------------------------------------------------*
- *	decode and process one Q.931 codeset 0 information element
- *---------------------------------------------------------------------------*/
-void
-i4b_decode_q931_message(int unit, call_desc_t *cd, u_char message_type)
-{
-	char *m = NULL;
-	
-	cd->event = EV_ILL;
-
-	switch(message_type)
-	{
-		/* call establishment */
-
-		case ALERT:
-			cd->event = EV_ALERT;			
-			m = "ALERT";
-			break;
-			
-		case CALL_PROCEEDING:
-			cd->event = EV_CALLPRC;
-			m = "CALL_PROCEEDING";
-			break;
-			
-		case PROGRESS:
-			cd->event = EV_PROGIND;
-			m = "PROGRESS";
-			break;
-			
-		case SETUP:
-			m = "SETUP";
-			cd->bprot = BPROT_NONE;
-			cd->cause_in = 0;
-			cd->cause_out = 0;			
-			cd->dst_telno[0] = '\0';
-			cd->src_telno[0] = '\0';
-			cd->channelid = CHAN_NO;
-			cd->channelexcl = 0;
-			cd->display[0] = '\0';
-			cd->datetime[0] = '\0';			
-			cd->event = EV_SETUP;
-			break;
-			
-		case CONNECT:
-			m = "CONNECT";
-			cd->datetime[0] = '\0';		
-			cd->event = EV_CONNECT;			
-			break;
-			
-		case SETUP_ACKNOWLEDGE:
-			m = "SETUP_ACKNOWLEDGE";
-			cd->event = EV_SETUPAK;
-			break;
-			
-		case CONNECT_ACKNOWLEDGE:
-			m = "CONNECT_ACKNOWLEDGE";
-			cd->event = EV_CONACK;
-			break;
-			
-		/* call information */
-
-		case USER_INFORMATION:
-			m = "USER_INFORMATION";
-			break;
-	
-		case SUSPEND_REJECT:
-			m = "SUSPEND_REJECT";
-			break;
-			
-		case RESUME_REJECT:
-			m = "RESUME_REJECT";
-			break;
-			
-		case HOLD:
-			m = "HOLD";
-			break;
-			
-		case SUSPEND:
-			m = "SUSPEND";
-			break;
-			
-		case RESUME:
-			m = "RESUME";
-			break;
-			
-		case HOLD_ACKNOWLEDGE:
-			m = "HOLD_ACKNOWLEDGE";
-			break;
-			
-		case SUSPEND_ACKNOWLEDGE:
-			m = "SUSPEND_ACKNOWLEDGE";
-			break;
-			
-		case RESUME_ACKNOWLEDGE:
-			m = "RESUME_ACKNOWLEDGE";
-			break;
-			
-		case HOLD_REJECT:
-			m = "HOLD_REJECT";
-			break;
-			
-		case RETRIEVE:
-			m = "RETRIEVE";
-			break;
-			
-		case RETRIEVE_ACKNOWLEDGE:
-			m = "RETRIEVE_ACKNOWLEDGE";
-			break;
-			
-		case RETRIEVE_REJECT:
-			m = "RETRIEVE_REJECT";
-			break;
-			
-		/* call clearing */
-
-		case DISCONNECT:
-			m = "DISCONNECT";
-			cd->event = EV_DISCONN;
-			break;
-	
-		case RESTART:
-			m = "RESTART";
-			break;
-			
-		case RELEASE:
-			m = "RELEASE";
-			cd->event = EV_RELEASE;
-			break;
-			
-		case RESTART_ACKNOWLEDGE:
-			m = "RESTART_ACKNOWLEDGE";
-			break;
-			
-		case RELEASE_COMPLETE:
-			m = "RELEASE_COMPLETE";
-			cd->event = EV_RELCOMP;		
-			break;
-			
-		/* misc messages */
-
-		case SEGMENT:
-			m = "SEGMENT";
-			break;
-	
-		case FACILITY:
-			m = "FACILITY";
-			cd->event = EV_FACILITY;		
-			break;
-			
-		case REGISTER:
-			m = "REGISTER";
-			break;
-			
-		case NOTIFY:
-			m = "NOTIFY";
-			break;
-			
-		case STATUS_ENQUIRY:
-			m = "STATUS_ENQUIRY";
-			cd->event = EV_STATENQ;		
-			break;
-			
-		case CONGESTION_CONTROL:
-			m = "CONGESTION_CONTROL";
-			break;
-			
-		case INFORMATION:
-			m = "INFORMATION";
-			cd->event = EV_INFO;		
-			break;
-			
-		case STATUS:
-			m = "STATUS";
-			cd->event = EV_STATUS;		
-			break;
-			
-		default:
-			NDBGL3(L3_P_ERR, "unit %d, cr = 0x%02x, msg = 0x%02x", unit, cd->cr, message_type);
-			break;
-	}
-	if(m)
-	{
-		NDBGL3(L3_PRIM, "%s: unit %d, cr = 0x%02x\n", m, unit, cd->cr);
-	}
-}
--- sys/i4b/layer1/itjc/i4b_itjc_pci.c
+++ /dev/null
@@ -1,2143 +0,0 @@
-/*-
- *   Copyright (c) 2000, 2001 Sergio Prallon. All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *   3. Neither the name of the author nor the names of any co-contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *   4. Altered versions must be plainly marked as such, and must not be
- *      misrepresented as being the original software and/or documentation.
- *   
- *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *   SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_itjc_pci.c: NetJet-S hardware driver
- *	----------------------------------------
- *      last edit-date: [Thu Jan 11 11:29:38 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/itjc/i4b_itjc_pci.c,v 1.15 2005/05/29 04:42:28 nyan Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/clock.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-
-#include <sys/socket.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/itjc/i4b_hdlc.h>	/* XXXXXXXXXXXXXXXXXXXXXXXX */
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-
-#include <i4b/layer1/itjc/i4b_itjc_ext.h>
-
-#define PCI_TJNET_VID (0xe159)
-#define PCI_TJ300_DID (0x0001)
-
-
-/*
- * Function prototypes
- */
-
-static int  itjc_probe(device_t dev);
-static int  itjc_attach(device_t dev);
-static void itjc_shutdown(device_t dev);
-static void itjc_intr(void *xsc);
-static int  itjc_dma_start(struct l1_softc *sc);
-static void itjc_dma_stop(struct l1_softc *sc);
-static void itjc_isac_intr(struct l1_softc *sc);
-static void itjc_init_linktab(struct l1_softc *sc);
-static void itjc_bchannel_setup(int unit, int h_chan, int bprot, 
-	int activate);
-static void itjc_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp);
-
-
-/*
- * Shorter names to bus resource manager routines.
- */
-
-#define itjc_bus_setup(sc)						\
-	bus_space_handle_t h =						\
-		rman_get_bushandle((sc)->sc_resources.io_base[0]);	\
-	bus_space_tag_t    t =						\
-		rman_get_bustag((sc)->sc_resources.io_base[0]);
-
-#define itjc_read_1(port)	(bus_space_read_1(t, h, (port)))
-#define itjc_read_4(port)	(bus_space_read_4(t, h, (port)))
-#define itjc_write_1(port, data) (bus_space_write_1(t, h, (port), (data)))
-#define itjc_write_4(port, data) (bus_space_write_4(t, h, (port), (data)))
-#define itjc_read_multi_1(port, buf, size)				\
-	(bus_space_read_multi_1(t, h, (port), (buf), (size)))
-#define itjc_write_multi_1(port, buf, size)				\
-	(bus_space_write_multi_1(t, h, (port), (buf), (size)))
-
-
-/*---------------------------------------------------------------------------*
- *	Glue data to register ourselves as a PCI device driver.
- *---------------------------------------------------------------------------*/
-
-static device_method_t itjc_pci_methods[] =
-{
-	/* Device interface */
-	DEVMETHOD(device_probe,		itjc_probe),
-	DEVMETHOD(device_attach,	itjc_attach),
-	DEVMETHOD(device_shutdown,	itjc_shutdown),
-
-	/* bus interface */
-	DEVMETHOD(bus_print_child,	bus_generic_print_child),
-	DEVMETHOD(bus_driver_added,	bus_generic_driver_added),
-
-	{ 0, 0 }
-};
-
-static driver_t itjc_pci_driver =
-{
-	"itjc",
-	itjc_pci_methods,
-	sizeof(struct l1_softc)
-};
-
-static devclass_t itjc_pci_devclass;
-
-DRIVER_MODULE(netjet, pci, itjc_pci_driver, itjc_pci_devclass, 0, 0);
-
-/*
- * Jump table for multiplex routines.
- */
-
-struct i4b_l1mux_func itjc_l1mux_func =
-{
-	itjc_ret_linktab,
-	itjc_set_linktab,
-	itjc_mph_command_req,
-	itjc_ph_data_req,
-	itjc_ph_activate_req,
-};
-
-struct l1_softc *itjc_scp[ITJC_MAXUNIT];
-
-
-/*---------------------------------------------------------------------------*
- *	Tiger300/320 PCI ASIC registers.
- *---------------------------------------------------------------------------*/
-
-/*
- *	Register offsets from i/o base.
- */
-enum tiger_regs
-{
-	TIGER_RESET_PIB_CL_TIME	= 0x00,
-	TIGER_DMA_OPER		= 0x01,
-	TIGER_AUX_PORT_CNTL	= 0x02,
-	TIGER_AUX_PORT_DATA	= 0x03,
-	TIGER_INT0_MASK		= 0x04,
-	TIGER_INT1_MASK		= 0x05,
-	TIGER_INT0_STATUS	= 0x06,
-	TIGER_INT1_STATUS	= 0x07,
-	TIGER_DMA_WR_START_ADDR	= 0x08,
-	TIGER_DMA_WR_INT_ADDR	= 0x0C,
-	TIGER_DMA_WR_END_ADDR	= 0x10,
-	TIGER_DMA_WR_CURR_ADDR	= 0x14,
-	TIGER_DMA_RD_START_ADDR	= 0x18,
-	TIGER_DMA_RD_INT_ADDR	= 0x1C,
-	TIGER_DMA_RD_END_ADDR	= 0x20,
-	TIGER_DMA_RD_CURR_ADDR	= 0x24,
-	TIGER_PULSE_COUNTER	= 0x28,
-};
-
-/*
- * Bits on the above registers.
- */
-
-enum tiger_reg_bits
-{
-/* Reset and PIB Cycle Timing */
-
-	TIGER_DMA_OP_MODE_MASK		= 0x80,
-		TIGER_SELF_ADDR_DMA	= 0x00,	/* Wrap around ending addr */
-		TIGER_NORMAL_DMA	= 0x80,	/* Stop at ending addr */
-
-	TIGER_DMA_INT_MODE_MASK		= 0x40,
-		TIGER_DONT_LATCH_DMA_INT= 0x00,	/* Bits on int0 status will be
-						   set only while curr addr
-						   equals int or end addr */
-		TIGER_LATCH_DMA_INT	= 0x40,	/* Bits on int0 status remain
-						   set until cleared by CPU */
-
-	TIGER_PIB_CYCLE_TIMING_MASK	= 0x30,
-		TIGER_PIB_3_CYCLES	= 0x00,
-		TIGER_PIB_5_CYCLES	= 0x01,
-		TIGER_PIB_12_CYCLES	= 0x10,
-
-	TIGER_RESET_MASK		= 0x0F,
-		TIGER_RESET_PULSE_COUNT	= 0x08,
-		TIGER_RESET_SERIAL_PORT	= 0x04,
-		TIGER_RESET_DMA_LOGIC	= 0x02,
-		TIGER_RESET_EXTERNAL	= 0x01,
-		TIGER_RESET_ALL		= 0x0F,
-	
-/* DMA Operation */
-	TIGER_DMA_RESTART_MASK		= 0x02,
-		TIGER_HOLD_DMA		= 0x00,
-		TIGER_RESTART_DMA	= 0x00,
-
-	TIGER_DMA_ENABLE_MASK		= 0x01,
-		TIGER_ENABLE_DMA	= 0x01,
-		TIGER_DISABLE_DMA	= 0x00,
-
-/* AUX Port Control & Data plus Interrupt 1 Mask & Status  */
-	TIGER_AUX_7_MASK		= 0x80,
-	TIGER_AUX_6_MASK		= 0x40,
-	TIGER_AUX_5_MASK		= 0x20,
-	TIGER_AUX_4_MASK		= 0x10,
-	TIGER_ISAC_INT_MASK		= 0x10,
-	TIGER_AUX_3_MASK		= 0x08,
-	TIGER_AUX_2_MASK		= 0x04,
-	TIGER_AUX_1_MASK		= 0x02,
-	TIGER_AUX_0_MASK		= 0x01,
-
-/* AUX Port Control */
-		TIGER_AUX_7_IS_INPUT	= 0x00,
-		TIGER_AUX_7_IS_OUTPUT	= 0x80,
-		TIGER_AUX_6_IS_INPUT	= 0x00,
-		TIGER_AUX_6_IS_OUTPUT	= 0x40,
-		TIGER_AUX_5_IS_INPUT	= 0x00,
-		TIGER_AUX_5_IS_OUTPUT	= 0x20,
-		TIGER_AUX_4_IS_INPUT	= 0x00,
-		TIGER_AUX_4_IS_OUTPUT	= 0x10,
-		TIGER_AUX_3_IS_INPUT	= 0x00,
-		TIGER_AUX_3_IS_OUTPUT	= 0x80,
-		TIGER_AUX_2_IS_INPUT	= 0x00,
-		TIGER_AUX_2_IS_OUTPUT	= 0x40,
-		TIGER_AUX_1_IS_INPUT	= 0x00,
-		TIGER_AUX_1_IS_OUTPUT	= 0x20,
-		TIGER_AUX_0_IS_INPUT	= 0x00,
-		TIGER_AUX_0_IS_OUTPUT	= 0x10,
-		TIGER_AUX_NJ_DEFAULT	= 0xEF, /* All but ISAC int is output */
-
-/* Interrupt 0 Mask & Status */
-	TIGER_PCI_TARGET_ABORT_INT_MASK	= 0x20,
-		TIGER_NO_TGT_ABORT_INT	= 0x00,
-		TIGER_TARGET_ABORT_INT	= 0x20,
-	TIGER_PCI_MASTER_ABORT_INT_MASK	= 0x10,
-		TIGER_NO_MST_ABORT_INT	= 0x00,
-		TIGER_MASTER_ABORT_INT	= 0x10,
-	TIGER_DMA_RD_END_INT_MASK	= 0x08,
-		TIGER_NO_RD_END_INT	= 0x00,
-		TIGER_RD_END_INT	= 0x08,
-	TIGER_DMA_RD_INT_INT_MASK	= 0x04,
-		TIGER_NO_RD_INT_INT	= 0x00,
-		TIGER_RD_INT_INT	= 0x04,
-	TIGER_DMA_WR_END_INT_MASK	= 0x02,
-		TIGER_NO_WR_END_INT	= 0x00,
-		TIGER_WR_END_INT	= 0x02,
-	TIGER_DMA_WR_INT_INT_MASK	= 0x01,
-		TIGER_NO_WR_INT_INT	= 0x00,
-		TIGER_WR_INT_INT	= 0x01,
-
-/* Interrupt 1 Mask & Status */
-		TIGER_NO_AUX_7_INT	= 0x00,
-		TIGER_AUX_7_INT		= 0x80,
-		TIGER_NO_AUX_6_INT	= 0x00,
-		TIGER_AUX_6_INT		= 0x40,
-		TIGER_NO_AUX_5_INT	= 0x00,
-		TIGER_AUX_5_INT		= 0x20,
-		TIGER_NO_AUX_4_INT	= 0x00,
-		TIGER_AUX_4_INT		= 0x10,
-		TIGER_NO_ISAC_INT	= 0x00,
-		TIGER_ISAC_INT		= 0x10,
-		TIGER_NO_AUX_3_INT	= 0x00,
-		TIGER_AUX_3_INT		= 0x08,
-		TIGER_NO_AUX_2_INT	= 0x00,
-		TIGER_AUX_2_INT		= 0x04,
-		TIGER_NO_AUX_1_INT	= 0x00,
-		TIGER_AUX_1_INT		= 0x02,
-		TIGER_NO_AUX_0_INT	= 0x00,
-		TIGER_AUX_0_INT		= 0x01
-};
-
-/*
- * Peripheral Interface Bus definitions. This is an ISA like bus
- * created by the Tiger ASIC to keep ISA chips like the ISAC happy
- * on a PCI environment.
- *
- * Since the PIB only supplies 4 addressing lines, the 2 higher bits
- * (A4 & A5) of the ISAC register addresses are wired on the 2 lower
- * AUX lines. Another restriction is that all I/O to the PIB (8bit
- * wide) is mapped on the PCI side as 32bit data. So the PCI address
- * of a given ISAC register has to be multiplied by 4 before being
- * added to the PIB base offset.
- */
-enum tiger_pib_regs_defs
-{
-	/* Offset from the I/O base to the ISAC registers. */
-	PIB_OFFSET		= 0xC0,
-	PIB_LO_ADDR_MASK	= 0x0F,		
-	PIB_HI_ADDR_MASK	= 0x30,
-	PIB_LO_ADDR_SHIFT	= 2,	/* Align on dword boundary */
-	PIB_HI_ADDR_SHIFT	= 4	/* Right shift to AUX_1 & AUX_0 */
-};
-
-
-#define	itjc_set_pib_addr_msb(a)					\
-(									\
-	itjc_write_1(TIGER_AUX_PORT_DATA,				\
-		((a) & PIB_HI_ADDR_MASK) >> PIB_HI_ADDR_SHIFT)		\
-)
-
-#define	itjc_pib_2_pci(a)						\
-(									\
-	(((a) & PIB_LO_ADDR_MASK) << PIB_LO_ADDR_SHIFT) + PIB_OFFSET	\
-)
-
-#define itjc_get_dma_offset(ctx,reg)					\
-(									\
-	(u_int16_t)((bus_addr_t)itjc_read_4((reg)) - (ctx)->bus_addr)	\
-)
-
-
-/*
- * IOM-2 serial channel 0 DMA data ring buffers.
- *
- * The Tiger300/320 ASIC do not nothing more than transfer via DMA the
- * first 32 bits of every IOM-2 frame on the serial interface to the
- * ISAC. So we have no framing/deframing facilities like we would have
- * with an HSCX, having to do the job with CPU cycles. On the plus side
- * we are able to specify large rings which can limit the occurrence of
- * over/underruns.
- */
-
-enum
-{
-	ITJC_RING_SLOT_WORDS	= 64,
-	ITJC_RING_WORDS		= 3 * ITJC_RING_SLOT_WORDS,
-	ITJC_RING_SLOT_BYTES	= 4 * ITJC_RING_SLOT_WORDS,
-	ITJC_RING_BYTES		= 4 * ITJC_RING_WORDS,
-	ITJC_DMA_POOL_WORDS	= 2 * ITJC_RING_WORDS,
-	ITJC_DMA_POOL_BYTES	= 4 * ITJC_DMA_POOL_WORDS
-};
-
-#define	itjc_ring_add(x, d)	(((x) + 4 * (d)) % ITJC_RING_BYTES)
-#define itjc_ring_sub(x, d)	(((x) + ITJC_RING_BYTES - 4 * (d))	\
-					% ITJC_RING_BYTES)
-
-
-enum
-{
-	TIGER_CH_A		= 0,
-	TIGER_CH_B		= 1,
-
-	HSCX_CH_A		= 0,	/* For compatibility reasons. */
-	HSCX_CH_B		= 1,
-};
-
-enum
-{
-	ITJC_TEL_SILENCE_BYTE	= 0x00,
-	ITJC_HDLC_FLAG_BYTE	= 0x7E,
-	ITJC_HDLC_ABORT_BYTE	= 0xFF
-};
-
-/*
- * Hardware DMA control block (one per card).
- */
-typedef enum
-{
-	ITJC_DS_LOAD_FAILED	= -1,
-	ITJC_DS_FREE		=  0,
-	ITJC_DS_LOADING,
-	ITJC_DS_STOPPED,
-	ITJC_DS_RUNNING
-}
-	dma_state_t;
-
-typedef struct
-{
-	dma_state_t	state;
-	u_int8_t	*pool;
-	bus_addr_t	bus_addr;
-	bus_dma_tag_t	tag;
-	bus_dmamap_t	map;
-	int		error;
-}
-	dma_context_t;
-
-dma_context_t
-	dma_context	[ ITJC_MAXUNIT ];
-
-/*
- * B-channel DMA control blocks (4 per card -- 1 RX & 1 TX per channel).
- */
-typedef enum
-{
-	ITJC_RS_IDLE	= 0,
-	ITJC_RS_ACTIVE
-}
-	dma_rx_state_t;
-
-typedef enum
-{
-	ITJC_TS_IDLE	= 0,
-	ITJC_TS_ACTIVE,
-	ITJC_TS_AFTER_XDU
-}
-	dma_tx_state_t;
-
-typedef struct
-{
-	u_int8_t	*ring;
-	bus_addr_t	bus_addr;
-	u_int16_t	next_read;
-	u_int16_t	hdlc_len;
-	u_int16_t	hdlc_tmp;
-	u_int16_t	hdlc_crc;
-	u_int16_t	hdlc_ib;
-	u_int8_t	hdlc_blevel;
-	u_int8_t	hdlc_flag;
-	dma_rx_state_t	state;
-}
-	dma_rx_context_t;
-
-typedef struct
-{
-	u_int8_t	*ring;
-	bus_addr_t	bus_addr;
-	u_int16_t	next_write;
-	u_int32_t	hdlc_tmp;
-	u_int16_t	hdlc_blevel;
-	u_int16_t	hdlc_crc;
-	u_int16_t	hdlc_ib;
-	u_int16_t	next_frame;
-	u_int16_t	filled;
-	u_int8_t	hdlc_flag;
-	dma_tx_state_t	state;
-}
-	dma_tx_context_t;
-
-dma_rx_context_t
-	dma_rx_context	[ ITJC_MAXUNIT ] [ 2 ];
-
-dma_tx_context_t
-	dma_tx_context	[ ITJC_MAXUNIT ] [ 2 ];
-
-/*
- * Used by the mbuf handling functions.
- */
-typedef enum
-{
-	ITJC_MB_CURR = 0,
-	ITJC_MB_NEXT = 1,
-	ITJC_MB_NEW  = 2
-}
-	which_mb_t;
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_map_callback - get DMA bus address from resource mgr.
- *---------------------------------------------------------------------------*/
-static void
-itjc_map_callback(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
-	dma_context_t		*ctx = (dma_context_t *)arg;
-
-	if (error)
-	{
-		ctx->error = error;
-		ctx->state = ITJC_DS_LOAD_FAILED;
-		return;
-	}
-
-        ctx->bus_addr = segs->ds_addr;
-	ctx->state = ITJC_DS_STOPPED;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_dma_start - Complete DMA setup & start the Tiger DMA engine.
- *---------------------------------------------------------------------------*/
-static int
-itjc_dma_start(struct l1_softc *sc)
-{
-	int			unit	= sc->sc_unit;
-	dma_context_t		*ctx	= &dma_context[unit];
-	dma_rx_context_t	*rxc	= &dma_rx_context[unit][0];
-	dma_tx_context_t	*txc	= &dma_tx_context[unit][0];
-	bus_addr_t		ba;
-	u_int8_t		i;
-	u_int32_t		*pool_end,
-				*ip;
-
-	itjc_bus_setup(sc);
-
-	/* See if it is already running. */
-
-	if (ctx->state == ITJC_DS_RUNNING)
-		return 0;
-
-	if (ctx->state == ITJC_DS_LOAD_FAILED)
-	{
-		NDBGL1(L1_ERROR, "itjc%d: dma_start: DMA map loading "
-			"failed (error=%d).\n", unit, ctx->error);
-		return 1;
-	}
-
-	if (ctx->state != ITJC_DS_STOPPED)
-	{
-		NDBGL1(L1_ERROR, "itjc%d: dma_start: Unexpected DMA "
-			"state (%d).\n", unit, ctx->state);
-		return 1;
-	}
-
-	/*
-	 * Initialize the DMA control structures (hardware & B-channel).
-	 */
-	ba = ctx->bus_addr;
-
-	txc->ring = ctx->pool + TIGER_CH_A;
-	rxc->ring = ctx->pool + TIGER_CH_A + ITJC_RING_BYTES;
-
-	txc->bus_addr = ba;
-	rxc->bus_addr = ba + ITJC_RING_BYTES;
-
-	++rxc; ++txc;
-
-	txc->ring = ctx->pool + TIGER_CH_B;
-	rxc->ring = ctx->pool + TIGER_CH_B + ITJC_RING_BYTES;
-
-	txc->bus_addr = ba;
-	rxc->bus_addr = ba + ITJC_RING_BYTES;
-
-	/*
-	 * Fill the DMA ring buffers with IOM-2 channel 0 frames made of
-	 * idle/abort sequences for the B & D channels and NOP for IOM-2
-	 * cmd/ind, monitor handshake & data.
-	 */
-	pool_end = (u_int32_t *)ctx->pool + ITJC_DMA_POOL_WORDS;
-	for (ip = (u_int32_t *)ctx->pool; ip < pool_end; ++ip)
-		*ip = 0xFFFFFFFF;
-
-	/*
-	 * Program the Tiger DMA gears.
-	 */
-
-	itjc_write_4(TIGER_DMA_WR_START_ADDR, ba);
-	itjc_write_4(TIGER_DMA_WR_INT_ADDR, ba + ITJC_RING_SLOT_BYTES - 4);
-	itjc_write_4(TIGER_DMA_WR_END_ADDR, ba + ITJC_RING_BYTES - 4);
-
-	ba += ITJC_RING_BYTES;
-
-	itjc_write_4(TIGER_DMA_RD_START_ADDR, ba);
-	itjc_write_4(TIGER_DMA_RD_INT_ADDR, ba + ITJC_RING_SLOT_BYTES * 2 - 4);
-	itjc_write_4(TIGER_DMA_RD_END_ADDR, ba + ITJC_RING_BYTES - 4);
-
-	itjc_write_1(TIGER_INT0_MASK, 
-		TIGER_WR_END_INT | TIGER_WR_INT_INT | TIGER_RD_INT_INT);
-
-	itjc_write_1(TIGER_DMA_OPER, TIGER_ENABLE_DMA);
-
-	/*
-	 * See if it really started.
-	 */
-	ba = itjc_read_4(TIGER_DMA_RD_CURR_ADDR);
-	for (i = 0; i < 10; ++i)
-	{
-		DELAY(SEC_DELAY/1000);
-		if (ba != itjc_read_4(TIGER_DMA_RD_CURR_ADDR))
-		{
-			ctx->state = ITJC_DS_RUNNING;
-			return 0;
-		}
-	}
-
-	NDBGL1(L1_ERROR, "itjc%d: dma_start: DMA start failed.\n ", unit);
-	return 1;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_dma_stop - Stop the Tiger DMA engine.
- *---------------------------------------------------------------------------*/
-static void
-itjc_dma_stop(struct l1_softc *sc)
-{
-	dma_context_t		*ctx	= &dma_context[sc->sc_unit];
-
-	itjc_bus_setup(sc);
-
-	/* Only stop the DMA if it is running. */
-
-	if (ctx->state != ITJC_DS_RUNNING)
-		return;
-
-	itjc_write_1(TIGER_DMA_OPER, TIGER_DISABLE_DMA);
-	DELAY(SEC_DELAY/1000);
-
-	ctx->state = ITJC_DS_STOPPED;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_bchannel_dma_setup - The DMA side of itjc_bchannel_setup.
- *---------------------------------------------------------------------------*/
-static void
-itjc_bchannel_dma_setup(struct l1_softc *sc, int h_chan, int activate)
-{
-	dma_rx_context_t	*rxc  = &dma_rx_context[sc->sc_unit][h_chan];
-	dma_tx_context_t	*txc  = &dma_tx_context[sc->sc_unit][h_chan];
-
-	l1_bchan_state_t	*chan = &sc->sc_chan[h_chan];
-
-	u_int8_t		fill_byte,
-				*ring_end,
-				*cp;
-
-	int			s = SPLI4B();
-
-	itjc_bus_setup(sc);
-
-	if (activate)
-	{
-		/*
-		 * Get the DMA engine going if it's not running already.
-		 */
-		itjc_dma_start(sc);
-
-		rxc->hdlc_len	= rxc->hdlc_tmp    = rxc->hdlc_crc  = 0;
-		rxc->hdlc_ib	= rxc->hdlc_blevel = rxc->hdlc_flag = 0;
-
-		txc->hdlc_tmp	= txc->hdlc_blevel = txc->hdlc_crc  = 0;
-		txc->hdlc_ib	= 0;
-		txc->hdlc_flag	= 2;
-		txc->filled	= 0;
-
-		if (chan->bprot == BPROT_NONE)
-			fill_byte = ITJC_TEL_SILENCE_BYTE;
-		else
-			fill_byte = ITJC_HDLC_ABORT_BYTE;
-
-		ring_end = rxc->ring + ITJC_RING_BYTES;
-		for (cp = rxc->ring; cp < ring_end; cp += 4)
-			*cp = fill_byte;
-
-		ring_end = txc->ring + ITJC_RING_BYTES;
-		for (cp = txc->ring; cp < ring_end; cp += 4)
-			*cp = fill_byte;
-
-		rxc->next_read  =
-			itjc_get_dma_offset(rxc, TIGER_DMA_RD_CURR_ADDR);
-
-		txc->next_frame = txc->next_write =
-			itjc_get_dma_offset(txc, TIGER_DMA_WR_CURR_ADDR);
-
-		rxc->state	= ITJC_RS_ACTIVE;
-		txc->state	= ITJC_TS_AFTER_XDU;
-	}
-	else
-	{
-		dma_rx_context_t	*rxc2;
-
-		txc->state	= ITJC_TS_IDLE;
-		rxc->state	= ITJC_RS_IDLE;
-
-		rxc2 = &dma_rx_context[sc->sc_unit][0];
-
-		if (rxc2->state == ITJC_RS_IDLE 
-		&& rxc2[1].state == ITJC_RS_IDLE)
-			itjc_dma_stop(sc);
-	}
-
-	splx(s);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	Mbuf & if_queues management routines.
- *---------------------------------------------------------------------------*/
-
-static u_int8_t *
-itjc_get_rx_mbuf(l1_bchan_state_t *chan, u_int8_t **dst_end_p,
-which_mb_t which)
-{
-	struct mbuf	*mbuf = chan->in_mbuf;
-
-	if (mbuf == NULL && which == ITJC_MB_NEW)
-	{
-		if ((mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
-			panic("itjc_get_rx_mbuf: cannot allocate mbuf!");
-
-		chan->in_mbuf  = mbuf;
-		chan->in_cbptr = (u_int8_t *)mbuf->m_data;
-		chan->in_len   = 0;
-	}
-
-	if (dst_end_p != NULL)
-	{
-		if (mbuf != NULL)
-			*dst_end_p = (u_int8_t *)(mbuf->m_data)
-				+ BCH_MAX_DATALEN;
-		else
-			*dst_end_p = NULL;
-	}
-
-	return chan->in_cbptr;
-}
-
-
-static void
-itjc_save_rx_mbuf(l1_bchan_state_t *chan, u_int8_t * dst)
-{
-	struct mbuf	*mbuf = chan->in_mbuf;
-
-	if (dst != NULL && mbuf != NULL)
-	{
-		chan->in_cbptr = dst;
-		chan->in_len   = dst - (u_int8_t *)mbuf->m_data;
-	}
-	else if (dst == NULL && mbuf == NULL)
-	{
-		chan->in_cbptr = NULL;
-		chan->in_len   = 0;
-	}
-	else
-		panic("itjc_save_rx_mbuf: stale pointer dst=%p mbuf=%p "
-			"in_cbptr=%p in_len=%d", dst, mbuf, 
-			chan->in_cbptr, chan->in_len);
-}
-
-
-static void
-itjc_free_rx_mbuf(l1_bchan_state_t *chan)
-{
-	struct mbuf	*mbuf = chan->in_mbuf;
-
-	if (mbuf != NULL)
-		i4b_Bfreembuf(mbuf);
-
-	chan->in_mbuf  = NULL;
-	chan->in_cbptr = NULL;
-	chan->in_len   = 0;
-}
-
-
-static void
-itjc_put_rx_mbuf(struct l1_softc *sc, l1_bchan_state_t *chan, u_int16_t len)
-{
-	i4b_trace_hdr_t	hdr;
-	struct mbuf	*mbuf	 = chan->in_mbuf;
-	u_int8_t	*data	 = mbuf->m_data;
-	int		activity = 1;
-
-	mbuf->m_pkthdr.len = mbuf->m_len = len;
-
-	if (sc->sc_trace & TRACE_B_RX)
-	{
-		hdr.unit = L0ITJCUNIT(sc->sc_unit);
-		hdr.type = (chan->channel == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-		hdr.dir = FROM_NT;
-		hdr.count = ++sc->sc_trace_bcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, len, data);
-	}
-
-	if (chan->bprot == BPROT_NONE)
-	{
-		activity = ! i4b_l1_bchan_tel_silence(data, len);
-				
-		/* move rx'd data to rx queue */
-
-		if (! _IF_QFULL(&chan->rx_queue))
-		{
-			IF_ENQUEUE(&chan->rx_queue, mbuf);
-		}
-		else
-		{
-			i4b_Bfreembuf(mbuf);
-			len = 0;
-		}
-	}
-
-	if (len != 0)
-	{
-		chan->rxcount += len;
-
-		(*chan->isic_drvr_linktab->bch_rx_data_ready)
-			(chan->isic_drvr_linktab->unit);
-	}
-				
-	if (activity)
-		(*chan->isic_drvr_linktab->bch_activity)
-			(chan->isic_drvr_linktab->unit, ACT_RX);
-
-	chan->in_mbuf  = NULL;
-	chan->in_cbptr = NULL;
-	chan->in_len   = 0;
-}
-
-
-#define itjc_free_tx_mbufs(chan)					\
-{									\
-	i4b_Bfreembuf((chan)->out_mbuf_head);				\
-	(chan)->out_mbuf_cur = (chan)->out_mbuf_head = NULL;		\
-	(chan)->out_mbuf_cur_ptr = NULL;				\
-	(chan)->out_mbuf_cur_len = 0;					\
-}
-
-
-static u_int16_t
-itjc_get_tx_mbuf(struct l1_softc *sc, l1_bchan_state_t *chan,
-	u_int8_t **src_p, which_mb_t which)
-{
-	i4b_trace_hdr_t	hdr;
-	struct mbuf	*mbuf = chan->out_mbuf_cur;
-	u_int8_t	activity = 1;
-	u_int16_t	len;
-	void		*data;
-
-	switch (which)
-	{
-	case ITJC_MB_CURR:
-		if (mbuf != NULL)
-		{
-			*src_p = chan->out_mbuf_cur_ptr;
-			return   chan->out_mbuf_cur_len;
-		}
-
-		break;
-
-	case ITJC_MB_NEXT:
-		if (mbuf != NULL)
-		{
-			chan->txcount += mbuf->m_len;
-
-			mbuf = mbuf->m_next;
-
-			if (mbuf != NULL)
-				goto new_mbuf;
-		}
-
-		chan->out_mbuf_cur_ptr = *src_p = NULL;
-		chan->out_mbuf_cur_len = 0;
-
-		if (chan->out_mbuf_head != NULL)
-		{
-			i4b_Bfreembuf(chan->out_mbuf_head);
-			chan->out_mbuf_head = NULL;
-		}
-
-		return 0;
-
-	case ITJC_MB_NEW:
-		if (mbuf != NULL)
-			chan->txcount += mbuf->m_len;
-	}
-
-	if (chan->out_mbuf_head != NULL)
-		i4b_Bfreembuf(chan->out_mbuf_head);
-
-	IF_DEQUEUE(&chan->tx_queue, mbuf);
-
-	if (mbuf == NULL)
-	{
-		chan->out_mbuf_cur = chan->out_mbuf_head = NULL;
-		chan->out_mbuf_cur_ptr = *src_p = NULL;
-		chan->out_mbuf_cur_len = 0;
-
-		chan->state &= ~(HSCX_TX_ACTIVE);
-
-		(*chan->isic_drvr_linktab->bch_tx_queue_empty)
-			(chan->isic_drvr_linktab->unit);
-
-		return 0;
-	}
-
-	chan->out_mbuf_head = mbuf;
-
-new_mbuf:
-	chan->out_mbuf_cur	= mbuf;
-	chan->out_mbuf_cur_ptr	= data = mbuf->m_data;
-	chan->out_mbuf_cur_len	= len  = mbuf->m_len;
-
-	chan->state |= HSCX_TX_ACTIVE;
-
-	if (sc->sc_trace & TRACE_B_TX)
-	{
-		hdr.unit = L0ITJCUNIT(sc->sc_unit);
-		hdr.type = (chan->channel == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_bcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, len, data);
-	}
-
-	if (chan->bprot == BPROT_NONE)
-		activity = ! i4b_l1_bchan_tel_silence(data, len);
-
-	if (activity)
-		(*chan->isic_drvr_linktab->bch_activity)
-			(chan->isic_drvr_linktab->unit, ACT_TX);
-
-	*src_p = data;
-	return len;
-}
-
-
-#define itjc_save_tx_mbuf(chan, src, dst)				\
-(									\
-	(chan)->out_mbuf_cur != NULL ?					\
-	(								\
-		(chan)->out_mbuf_cur_ptr = (src),			\
-		(chan)->out_mbuf_cur_len = (len)			\
-	)								\
-	:								\
-		0							\
-)
-
-
-/*---------------------------------------------------------------------------*
- *	B-channel interrupt service routines.
- *---------------------------------------------------------------------------*/
-
-/*
- * Since the Tiger ASIC doesn't produce a XMIT underflow indication,
- * we need to deduce it ourselves. This is somewhat tricky because we
- * are dealing with modulo m arithmetic. The idea here is to have a
- * "XDU zone" ahead of the writing pointer sized 1/3 of total ring
- * length (a ring slot). If the hardware DMA pointer is found there we
- * consider that a XDU has occurred. To complete the scheme, we never
- * let the ring have more than 2 slots of (unsent) data and adjust the
- * interrupt registers to cause an interrupt at every slot.
- */
-static u_int8_t
-itjc_xdu(struct l1_softc *sc, l1_bchan_state_t *chan, dma_tx_context_t *ctx,
-u_int16_t *dst_p, u_int16_t *dst_end_p, u_int8_t tx_restart)
-{
-	u_int8_t	xdu;
-
-	u_int16_t	dst_end,
-			dst,
-			dma,
-			dma_l,
-			dma_h,
-			xdu_l,
-			xdu_h;
-
-	itjc_bus_setup(sc);
-
-	/*
-	 * Since the hardware is running, be conservative and assume
-	 * the pointer location has a `fuzy' error factor.
-	 */
-	dma   = itjc_get_dma_offset(ctx, TIGER_DMA_WR_CURR_ADDR);
-	dma_l = dma;
-	dma_h = itjc_ring_add(dma, 1);
-
-	dst_end = itjc_ring_sub(dma_l, ITJC_RING_SLOT_WORDS);
-
-	if (ctx->state != ITJC_TS_ACTIVE)
-	{
-		xdu = (ctx->state == ITJC_TS_AFTER_XDU);
-		dst = itjc_ring_add(dma_h, 4);
-		goto done;
-	}
-
-	/*
-	 * Check for xmit underruns.
-	 */
-	xdu_l = dst = ctx->next_write; 
-	xdu_h = itjc_ring_add(dst, ITJC_RING_SLOT_WORDS);
-
-	if (xdu_l < xdu_h)
-		xdu =	   (xdu_l <= dma_l && dma_l < xdu_h)
-			|| (xdu_l <= dma_h && dma_h < xdu_h);
-	else
-		xdu =	   (xdu_l <= dma_l || dma_l < xdu_h)
-			|| (xdu_l <= dma_h || dma_h < xdu_h);
-
-	if (xdu)
-	{
-		ctx->state = ITJC_TS_AFTER_XDU;
-
-		dst = itjc_ring_add(dma_h, 4);
-	}
-	else if (tx_restart)
-	{
-		/*
-		 * See if we still can restart from immediately
-		 * after the last frame sent. It's a XDU test but
-		 * using the real data end on the comparsions. We
-		 * don't consider XDU an error here because we were
-		 * just trying to avoid send a filling gap between
-		 * frames. If it's already sent no harm is done.
-		 */
-		xdu_l = dst = ctx->next_frame; 
-		xdu_h = itjc_ring_add(dst, ITJC_RING_SLOT_WORDS);
-
-		if (xdu_l < xdu_h)
-			xdu =	   (xdu_l <= dma_l && dma_l < xdu_h)
-				|| (xdu_l <= dma_h && dma_h < xdu_h);
-		else
-			xdu =	   (xdu_l <= dma_l || dma_l < xdu_h)
-				|| (xdu_l <= dma_h || dma_h < xdu_h);
-
-		if (xdu)
-			dst = itjc_ring_add(dma_h, 4);
-
-		xdu = 0;
-	}
-
-done:
-	if (dst_p != NULL)
-		*dst_p = dst;
-	
-	if (dst_end_p != NULL)
-		*dst_end_p = dst_end;
-
-	ctx->next_write = dst_end;
-
-	return xdu;
-}
-
-
-#define itjc_rotate_hdlc_flag(blevel)					\
-	((u_int8_t)(0x7E7E >> (8 - (u_int8_t)((blevel) >> 8))))
-
-
-static void
-itjc_dma_rx_intr(struct l1_softc *sc, l1_bchan_state_t *chan,
-dma_rx_context_t *ctx)
-{
-	u_int8_t	*ring,
-			*dst,
-			*dst_end,
-			flag,
-			blevel;
-
-	u_int16_t	dma,
-			src,
-			tmp2,
-			tmp,
-			len,
-			crc,
-			ib;
-	
-	itjc_bus_setup(sc);
-
-
-	if (ctx->state == ITJC_RS_IDLE)
-		return;
-
-	ring = ctx->ring;
-	dma = itjc_get_dma_offset(ctx, TIGER_DMA_RD_CURR_ADDR);
-	dma = itjc_ring_sub(dma, 1);
-	src = ctx->next_read;
-
-	if (chan->bprot == BPROT_NONE)
-	{
-		dst = itjc_get_rx_mbuf(chan, &dst_end, ITJC_MB_CURR);
-
-		while (src != dma)
-		{
-			if (dst == NULL)
-				dst = itjc_get_rx_mbuf(chan, &dst_end, 
-					ITJC_MB_NEW);
-
-			*dst++ = ring[src];
-			src = itjc_ring_add(src, 1);
-
-			if (dst >= dst_end)
-			{
-				itjc_put_rx_mbuf(sc, chan, BCH_MAX_DATALEN);
-				dst = dst_end = NULL;
-			}
-		}
-		ctx->next_read = src;
-		itjc_save_rx_mbuf(chan, dst);
-		return;
-	}
-
-	blevel = ctx->hdlc_blevel;
-	flag   = ctx->hdlc_flag;
-	len    = ctx->hdlc_len;
-	tmp    = ctx->hdlc_tmp;
-	crc    = ctx->hdlc_crc;
-	ib     = ctx->hdlc_ib;
-
-	dst = itjc_get_rx_mbuf(chan, NULL, ITJC_MB_CURR);
-
-	while (src != dma)
-	{
-		HDLC_DECODE(*dst++, len, tmp, tmp2, blevel, ib, crc, flag,
-		{/* rdd */
-			tmp2 = ring[src];
-			src = itjc_ring_add(src, 1);
-		},
-		{/* nfr */
-			if (dst != NULL)
-				panic("itjc_dma_rx_intr: nfrcmd with "
-					"valid current frame");
-
-			dst = itjc_get_rx_mbuf(chan, &dst_end, ITJC_MB_NEW);
-			len = dst_end - dst;
-		},
-		{/* cfr */
-			len = BCH_MAX_DATALEN - len;
-
-			if ((!len) || (len > BCH_MAX_DATALEN))
-			{
-				/*
-				 * NOTE: frames without any data, only crc
-				 * field, should be silently discared.
-				 */
-				NDBGL1(L1_S_MSG, "itjc_dma_rx_intr: "
-					"bad frame (len=%d, unit=%d)",
-					len, sc->sc_unit);
-
-				itjc_free_rx_mbuf(chan);
-
-				goto s0;
-			}
-
-			if (crc)
-			{
-				NDBGL1(L1_S_ERR,
-					"CRC (crc=0x%04x, len=%d, unit=%d)",
-					crc, len, sc->sc_unit);
-
-				itjc_free_rx_mbuf(chan);
-
-				goto s0;
-			}
-
-			itjc_put_rx_mbuf(sc, chan, len);
-
-		s0:
-			dst = NULL;
-			len = 0;
-		},
-		{/* rab */
-			NDBGL1(L1_S_ERR, "Read Abort (unit=%d)", sc->sc_unit);
-
-			itjc_free_rx_mbuf(chan);
-			dst = NULL;
-			len = 0;
-		},
-		{/* rdo */
-			NDBGL1(L1_S_ERR, "RDO (unit=%d) dma=%d src=%d",
-				sc->sc_unit, dma, src);
-
-			itjc_free_rx_mbuf(chan);
-			dst = NULL;
-			len = 0;
-		},
-		continue,
-		d);
-	}
-
-	itjc_save_rx_mbuf(chan, dst);
-
-	ctx->next_read	= src;
-	ctx->hdlc_blevel= blevel;
-	ctx->hdlc_flag	= flag;
-	ctx->hdlc_len	= len;
-	ctx->hdlc_tmp	= tmp;
-	ctx->hdlc_crc	= crc;
-	ctx->hdlc_ib	= ib;
-}
-
-
-/*
- * The HDLC side of itjc_dma_tx_intr. We made a separate function
- * to improve readability and (perhaps) help the compiler with
- * register allocation.
- */
-static void
-itjc_hdlc_encode(struct l1_softc *sc, l1_bchan_state_t *chan,
-dma_tx_context_t * ctx)
-{
-	u_int8_t	*ring,
-			*src,
-			xdu,
-			flag,
-			flag_byte,
-			tx_restart;
-
-	u_int16_t	saved_len,
-			dst_end,
-			dst_end1,
-			dst,
-			filled,
-			blevel,
-			tmp2,
-			len,
-			crc,
-			ib;
-
-	u_int32_t	tmp;
-
-
-	saved_len = len = itjc_get_tx_mbuf(sc, chan, &src, ITJC_MB_CURR);
-
-	filled = ctx->filled;
-	flag   = ctx->hdlc_flag;
-
-	if (src == NULL && flag == 2 && filled >= ITJC_RING_WORDS)
-		return;
-
-	tx_restart = (flag == 2 && src != NULL);
-	xdu = itjc_xdu(sc, chan, ctx, &dst, &dst_end, tx_restart);
-
-	ring   = ctx->ring;
-
-	ib     = ctx->hdlc_ib;
-	crc    = ctx->hdlc_crc;
-	tmp    = ctx->hdlc_tmp;
-	blevel = ctx->hdlc_blevel;
-
-	if (xdu)
-	{
-		if (flag != 2)
-		{
-			NDBGL1(L1_H_XFRERR, "XDU");
-			++chan->stat_XDU;
-
-			/*
-			 * Abort the current frame and 
-			 * prepare for a full restart.
-			 */
-			itjc_free_tx_mbufs(chan);
-			saved_len = len = filled = 0;
-			flag = (u_int8_t)-2;
-		}
-		else if (filled < ITJC_RING_SLOT_WORDS)
-		{
-			/*
-			 * A little garbage may have been retransmitted.
-			 * Send an abort before any new data.
-			 */
-			filled = 0;
-			flag = (u_int8_t)-2;
-		}
-	}
-
-	if (flag != 3)
-		len = 0;
-
-	while (dst != dst_end)
-	{
-		HDLC_ENCODE(
-		*src++, len, tmp, tmp2, blevel, ib, crc, flag,
-		{/* gfr */
-			if ((len = saved_len) == 0)
-				len = itjc_get_tx_mbuf(sc, chan, &src,
-					ITJC_MB_NEW);
-
-			if (len == 0)
-			{
-				ctx->next_frame = dst;
-
-				flag_byte = itjc_rotate_hdlc_flag(blevel);
-
-				for (dst_end1 = itjc_ring_sub(dst_end, 1);
-				dst != dst_end1;
-				dst = itjc_ring_add(dst, 1))
-				{
-					ring[dst] = flag_byte;
-					++filled;
-				}
-			}
-			else
-				filled = 0;
-
-			ctx->state = ITJC_TS_ACTIVE;
-		},
-		{/* nmb */
-			saved_len = 0;
-			len = itjc_get_tx_mbuf(sc, chan, &src, ITJC_MB_NEXT);
-		},
-		{/* wrd */
-			ring[dst] = (u_int8_t)tmp;
-			dst = itjc_ring_add(dst, 1);
-		},
-		d1);
-	}
-
-	ctx->hdlc_blevel = blevel;
-	ctx->hdlc_flag   = flag;
-	ctx->hdlc_tmp    = tmp;
-	ctx->hdlc_crc    = crc;
-	ctx->hdlc_ib     = ib;
-
-	ctx->filled = filled;
-	ctx->next_write = dst;
-
-	itjc_save_tx_mbuf(chan, src, len);
-}
-
-
-static void
-itjc_dma_tx_intr(struct l1_softc *sc, l1_bchan_state_t *chan,
-dma_tx_context_t * ctx)
-{
-	u_int8_t	*data_end,
-			*ring,
-			*src,
-			xdu;
-
-	u_int16_t	dst,
-			dst_end,
-			filled,
-			len;
-
-
-	if (ctx->state == ITJC_TS_IDLE)
-		goto done;
-
-	if (chan->bprot != BPROT_NONE)
-	{
-		itjc_hdlc_encode(sc, chan, ctx);
-		goto done;
-	}
-
-	ring   = ctx->ring;
-	filled = ctx->filled;
-
-	len = itjc_get_tx_mbuf(sc, chan, &src, ITJC_MB_CURR);
-
-	if (len == 0 && filled >= ITJC_RING_WORDS)
-		goto done;
-
-	xdu = itjc_xdu(sc, chan, ctx, &dst, &dst_end, len != 0);
-
-	if (xdu && filled < ITJC_RING_WORDS)
-	{
-		NDBGL1(L1_H_XFRERR, "XDU");
-		++chan->stat_XDU;
-		filled = 0;
-	}
-
-	if (len == 0)
-		goto fill_ring;
-
-	ctx->state = ITJC_TS_ACTIVE;
-
-	data_end = src + len;
-	while (dst != dst_end)
-	{
-		ring[dst] = *src++; --len;
-
-		dst = itjc_ring_add(dst, 1);
-
-		if (src >= data_end)
-		{
-			len = itjc_get_tx_mbuf(sc, chan, &src, ITJC_MB_NEXT);
-			if (len == 0)
-				len = itjc_get_tx_mbuf(sc, chan,
-					 &src, ITJC_MB_NEW);
-
-			if (len == 0)
-			{
-				data_end = NULL;
-				break;
-			}
-			data_end = src + len;
-		}
-	}
-
-	itjc_save_tx_mbuf(chan, src, len);
-
-	filled = 0;
-
-fill_ring:
-	ctx->next_frame = dst;
-
-	for (; dst != dst_end; dst = itjc_ring_add(dst, 1))
-	{
-		ring[dst] = ITJC_TEL_SILENCE_BYTE;
-		++filled;
-	}
-
-	ctx->next_write = dst;
-	ctx->filled = filled;
-
-done:
-	return;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	NetJet fifo read/write routines.
- *---------------------------------------------------------------------------*/
-
-static void
-itjc_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	itjc_bus_setup(sc);
-
-	if (what != ISIC_WHAT_ISAC)
-		panic("itjc_write_fifo: Trying to read from HSCX fifo.\n");
-
-	itjc_set_pib_addr_msb(0);
-	itjc_read_multi_1(PIB_OFFSET, buf, size);
-}
-
-
-static void
-itjc_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
-{
-	itjc_bus_setup(sc);
-
-	if (what != ISIC_WHAT_ISAC)
-		panic("itjc_write_fifo: Trying to write to HSCX fifo.\n");
-
-	itjc_set_pib_addr_msb(0);
-	itjc_write_multi_1(PIB_OFFSET, buf, size);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	Read an ISAC register.
- *---------------------------------------------------------------------------*/
-static u_int8_t
-itjc_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
-{
-	itjc_bus_setup(sc);
-
-	if (what != ISIC_WHAT_ISAC)
-	{
-		panic("itjc_read_reg: what(%d) != ISIC_WHAT_ISAC\n",
-			what);
-		return 0;
-	}
-
-	itjc_set_pib_addr_msb(offs);
-	return itjc_read_1(itjc_pib_2_pci(offs));
-}
-
-
-/*---------------------------------------------------------------------------*
- *	Write an ISAC register.
- *---------------------------------------------------------------------------*/
-static void
-itjc_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
-{
-	itjc_bus_setup(sc);
-
-	if (what != ISIC_WHAT_ISAC)
-	{
-		panic("itjc_write_reg: what(%d) != ISIC_WHAT_ISAC\n",
-			what);
-		return;
-	}
-
-	itjc_set_pib_addr_msb(offs);
-	itjc_write_1(itjc_pib_2_pci(offs), data);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_probe - probe for a card.
- *---------------------------------------------------------------------------*/
-static int itjc_probe(device_t dev)
-{
-	u_int16_t	vid = pci_get_vendor(dev),
-			did = pci_get_device(dev);
-
-	if ((vid == PCI_TJNET_VID) && (did == PCI_TJ300_DID))
-	{
-		device_set_desc(dev, "NetJet-S");
-		return 0;
-	}
-
-	return ENXIO;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_attach - attach a (previously probed) card.
- *---------------------------------------------------------------------------*/
-static int
-itjc_attach(device_t dev)
-{
-	bus_space_handle_t	h;
-	bus_space_tag_t		t; 
-
-	struct l1_softc		*sc = device_get_softc(dev);
-
-	u_int16_t		vid = pci_get_vendor(dev),
-				did = pci_get_device(dev);
-
-	int			unit = device_get_unit(dev),
-				s = splimp(),
-				res_init_level = 0,
-				error = 0;
-
-	void			*ih = 0;
-
-	dma_context_t		*ctx = &dma_context[unit];
-	l1_bchan_state_t	*chan;
-
-	bzero(sc, sizeof(struct l1_softc));
-
-	/* Probably not really required. */
-	if (unit >= ITJC_MAXUNIT)
-	{
-		printf("itjc%d: Error, unit >= ITJC_MAXUNIT!\n", unit);
-		splx(s);
-		return ENXIO;
-	}
-
-	if (!(vid == PCI_TJNET_VID && did == PCI_TJ300_DID))
-	{
-		printf("itjc%d: unknown device (%04X,%04X)!\n", unit, vid, did);
-		goto fail;
-	}
-
-	itjc_scp[unit] = sc;
-
-	sc->sc_resources.io_rid[0] = PCIR_BAR(0);
-	sc->sc_resources.io_base[0] = bus_alloc_resource_any(dev, 
-		SYS_RES_IOPORT, &sc->sc_resources.io_rid[0], RF_ACTIVE);
-
-	if (sc->sc_resources.io_base[0] == NULL)
-	{
-		printf("itjc%d: couldn't map IO port\n", unit);
-		error = ENXIO;
-		goto fail;
-	}
-
-	h = rman_get_bushandle(sc->sc_resources.io_base[0]);
-	t = rman_get_bustag(sc->sc_resources.io_base[0]); 
-
-	++res_init_level;
-
-	/* Allocate interrupt. */
-	sc->sc_resources.irq_rid = 0;
-	sc->sc_resources.irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
-		&sc->sc_resources.irq_rid, RF_SHAREABLE | RF_ACTIVE);
-
-	if (sc->sc_resources.irq == NULL)
-	{
-		printf("itjc%d: couldn't map interrupt\n", unit);
-		error = ENXIO;
-		goto fail;
-	}
-
-	++res_init_level;
-
-	error = bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET,
-			 itjc_intr, sc, &ih);
-
-	if (error)
-	{
-		printf("itjc%d: couldn't set up irq handler\n", unit);
-		error = ENXIO;
-		goto fail;
-	}
-
-	/*
-	 * Reset the ASIC & the ISAC.
-	 */
-	itjc_write_1(TIGER_RESET_PIB_CL_TIME, TIGER_RESET_ALL);
-
-	DELAY(SEC_DELAY/100); /* Give it 10 ms to reset ...*/
-
-	itjc_write_1(TIGER_RESET_PIB_CL_TIME,
-		TIGER_SELF_ADDR_DMA | TIGER_PIB_3_CYCLES);
-
-	DELAY(SEC_DELAY/100); /* ... and more 10 to recover. */
-
-	/*
-	 * First part of DMA initialization. Create & map the memory
-	 * pool that will be used to bear the rx & tx ring buffers.
-	 */
-	ctx->state = ITJC_DS_LOADING;
-
-	error = bus_dma_tag_create(
-		NULL,					/* parent */
-		4,					/* alignment*/
-		0,					/* boundary*/
-		BUS_SPACE_MAXADDR_32BIT,		/* lowaddr*/	
-		BUS_SPACE_MAXADDR,			/* highaddr*/
-		NULL,					/* filter*/
-		NULL,					/* filterarg*/
-		ITJC_DMA_POOL_BYTES,			/* maxsize*/
-		1,					/* nsegments*/
-		ITJC_DMA_POOL_BYTES,			/* maxsegsz*/
-		BUS_DMA_ALLOCNOW | BUS_DMA_COHERENT,	/* flags*/
-		NULL, NULL,				/* lockfuunc, lockarg */
-		&ctx->tag);
-
-	if (error)
-	{
-		printf("itjc%d: couldn't create bus DMA tag.\n", unit);
-		goto fail;
-	}
-
-	++res_init_level;
-
-        error = bus_dmamem_alloc(
-		ctx->tag, 				/* DMA tag */
-		(void **)&ctx->pool,	/* KV addr of the allocated memory */
-		BUS_DMA_NOWAIT | BUS_DMA_COHERENT,	/* flags */
-		&ctx->map);				/* KV <-> PCI map */
-
-	if (error)
-                goto fail;
-
-        /*
-	 * Load the KV <-> PCI map so the device sees the same
-	 * memory segment as pointed by pool. Note: since the
-	 * load may happen assyncronously (completion indicated by
-	 * the execution of the callback function) we have to
-	 * delay the initialization of the DMA engine to a moment we
-	 * actually have the proper bus addresses to feed the Tiger
-	 * and our DMA control blocks. This will be done in
-	 * itjc_bchannel_setup via a call to itjc_dma_start.
-	 */
-        bus_dmamap_load(
-		ctx->tag,		/* DMA tag */
-		ctx->map,		/* DMA map */
-		ctx->pool,		/* KV addr of buffer */
-		ITJC_DMA_POOL_BYTES,	/* buffer size */
-		itjc_map_callback, 	/* this receive the bus addr/error */
-		ctx, 			/* callback aux arg */
-		0);			/* flags */
-
-	++res_init_level;
-
-	/*
-	 * Setup the AUX port so we can talk to the ISAC.
-	 */
-	itjc_write_1(TIGER_AUX_PORT_CNTL, TIGER_AUX_NJ_DEFAULT);
-	itjc_write_1(TIGER_INT1_MASK, TIGER_ISAC_INT);
-
-	/*
-	 * From now on, almost like a `normal' ISIC driver.
-	 */
-
-	sc->sc_unit = unit;
-
-	ISAC_BASE = (caddr_t)ISIC_WHAT_ISAC;
-
-	HSCX_A_BASE = (caddr_t)ISIC_WHAT_HSCXA;
-	HSCX_B_BASE = (caddr_t)ISIC_WHAT_HSCXB;
-
-	/* setup access routines */
-
-	sc->clearirq = NULL;
-	sc->readreg = itjc_read_reg;
-	sc->writereg = itjc_write_reg;
-
-	sc->readfifo = itjc_read_fifo;
-	sc->writefifo = itjc_write_fifo;
-
-	/* setup card type */
-	
-	sc->sc_cardtyp = CARD_TYPEP_NETJET_S;
-
-	/* setup IOM bus type */
-	
-	sc->sc_bustyp = BUS_TYPE_IOM2;
-
-	/* set up some other miscellaneous things */
-	sc->sc_ipac = 0;
-	sc->sc_bfifolen = 2 * ITJC_RING_SLOT_WORDS;
-
-	printf("itjc%d: ISAC 2186 Version 1.1 (IOM-2)\n", unit);
-
-	/* init the ISAC */
-	itjc_isac_init(sc);
-
-	chan = &sc->sc_chan[HSCX_CH_A];
-	if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
-		mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp_rx", NULL, MTX_DEF);
-	if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
-		mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp_tx", NULL, MTX_DEF);
-	chan = &sc->sc_chan[HSCX_CH_B];
-	if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
-		mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp_rx", NULL, MTX_DEF);
-	if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
-		mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp_tx", NULL, MTX_DEF);
-
-	/* init the "HSCX" */
-	itjc_bchannel_setup(sc->sc_unit, HSCX_CH_A, BPROT_NONE, 0);
-	
-	itjc_bchannel_setup(sc->sc_unit, HSCX_CH_B, BPROT_NONE, 0);
-
-	/* can't use the normal B-Channel stuff */
-	itjc_init_linktab(sc);
-
-	/* set trace level */
-
-	sc->sc_trace = TRACE_OFF;
-
-	sc->sc_state = ISAC_IDLE;
-
-	sc->sc_ibuf = NULL;
-	sc->sc_ib = NULL;
-	sc->sc_ilen = 0;
-
-	sc->sc_obuf = NULL;
-	sc->sc_op = NULL;
-	sc->sc_ol = 0;
-	sc->sc_freeflag = 0;
-
-	sc->sc_obuf2 = NULL;
-	sc->sc_freeflag2 = 0;
-
-#if defined(__FreeBSD__) && __FreeBSD__ >=3
-	callout_handle_init(&sc->sc_T3_callout);
-	callout_handle_init(&sc->sc_T4_callout);	
-#endif
-	
-	/* init higher protocol layers */
-	
-	i4b_l1_mph_status_ind(L0ITJCUNIT(sc->sc_unit), STI_ATTACH, 
-		sc->sc_cardtyp, &itjc_l1mux_func);
-
-	splx(s);
-	return 0;
-
-  fail:
-	switch (res_init_level)
-	{
-	case 5:
-		bus_dmamap_unload(ctx->tag, ctx->map);
-		/* FALL TRHU */
-
-	case 4:
-		bus_dmamem_free(ctx->tag, ctx->pool, ctx->map);
-		bus_dmamap_destroy(ctx->tag, ctx->map);
-		/* FALL TRHU */
-
-	case 3:
-		bus_dma_tag_destroy(ctx->tag);
-		/* FALL TRHU */
-
-	case 2:
-		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_resources.irq);
-		/* FALL TRHU */
-
-	case 1:
-		bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(0),
-			sc->sc_resources.io_base[0]);
-		/* FALL TRHU */
-
-	case 0:
-		break;
-	}
-
-	itjc_scp[unit] = NULL;
-
-	splx(s);
-	return error;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_intr - main interrupt service routine.
- *---------------------------------------------------------------------------*/
-static void
-itjc_intr(void *xsc)
-{
-	struct l1_softc		*sc	= xsc;
-	l1_bchan_state_t	*chan	= &sc->sc_chan[0];
-	dma_context_t		*dma	= &dma_context[sc->sc_unit];
-	dma_rx_context_t	*rxc	= &dma_rx_context[sc->sc_unit][0];
-	dma_tx_context_t	*txc	= &dma_tx_context[sc->sc_unit][0];
-
-	itjc_bus_setup(sc);
-
-	/* Honor interrupts from successfully configured cards only. */
-	if (dma->state < ITJC_DS_STOPPED)
-		return;
-
-	/* First, we check the ISAC... */
-	if (! (itjc_read_1(TIGER_AUX_PORT_DATA) & TIGER_ISAC_INT_MASK))
-	{
-		itjc_write_1(TIGER_INT1_STATUS, TIGER_ISAC_INT);
-		NDBGL1(L1_H_IRQ, "ISAC");
-		itjc_isac_intr(sc);
-	}
-
-	/* ... after what we always have a look at the DMA rings. */
-
-	NDBGL1(L1_H_IRQ, "Tiger");
-
-	itjc_read_1(TIGER_INT0_STATUS);
-	itjc_write_1(TIGER_INT0_STATUS, TIGER_TARGET_ABORT_INT
-		| TIGER_MASTER_ABORT_INT | TIGER_RD_END_INT
-		| TIGER_RD_INT_INT	 | TIGER_WR_END_INT | TIGER_WR_INT_INT);
-
-	itjc_dma_rx_intr(sc, chan, rxc);
-	itjc_dma_tx_intr(sc, chan, txc);
-
-	++chan; ++rxc; ++txc;
-
-	itjc_dma_rx_intr(sc, chan, rxc);
-	itjc_dma_tx_intr(sc, chan, txc);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_bchannel_setup - (Re)initialize and start/stop a Bchannel.
- *---------------------------------------------------------------------------*/
-static void
-itjc_bchannel_setup(int unit, int h_chan, int bprot, int activate)
-{
-#ifdef __FreeBSD__
-	struct l1_softc		*sc	= itjc_scp[unit];
-#else
-	struct l1_softc		*sc	= isic_find_sc(unit);
-#endif
-	l1_bchan_state_t	*chan	= &sc->sc_chan[h_chan];
-	int			s	= SPLI4B();
-		
-	NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
-		unit, h_chan, activate ? "activate" : "deactivate");
-
-	/*
-	 * If we are deactivating the channel, we have to stop
-	 * the DMA before we reset the channel control structures.
-	 */
-	if (! activate)
-		itjc_bchannel_dma_setup(sc, h_chan, activate); 
-
-	/* general part */
-
-	chan->state = HSCX_IDLE;
-
-	chan->unit = sc->sc_unit;	/* unit number */
-	chan->channel = h_chan;		/* B channel */
-	chan->bprot = bprot;		/* B channel protocol */
-
-	/* receiver part */
-
-	i4b_Bcleanifq(&chan->rx_queue);	/* clean rx queue */
-
-	chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
-
-	chan->rxcount = 0;		/* reset rx counter */
-	
-	i4b_Bfreembuf(chan->in_mbuf);	/* clean rx mbuf */
-
-	chan->in_mbuf = NULL;		/* reset mbuf ptr */
-	chan->in_cbptr = NULL;		/* reset mbuf curr ptr */
-	chan->in_len = 0;		/* reset mbuf data len */
-	
-	/* transmitter part */
-
-	i4b_Bcleanifq(&chan->tx_queue);	/* clean tx queue */
-
-	chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
-	
-	chan->txcount = 0;		/* reset tx counter */
-	
-	i4b_Bfreembuf(chan->out_mbuf_head);	/* clean tx mbuf */
-
-	chan->out_mbuf_head = NULL;	/* reset head mbuf ptr */
-	chan->out_mbuf_cur = NULL;	/* reset current mbuf ptr */	
-	chan->out_mbuf_cur_ptr = NULL;	/* reset current mbuf data ptr */
-	chan->out_mbuf_cur_len = 0;	/* reset current mbuf data cnt */
-
-	/*
-	 * Only setup & start the DMA after all other channel
-	 * control structures are in place.
-	 */
-	if (activate)
-		itjc_bchannel_dma_setup(sc, h_chan, activate); 
-
-	splx(s);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_bchannel_start - Signal us we have more data to send.
- *---------------------------------------------------------------------------*/
-static void
-itjc_bchannel_start(int unit, int h_chan)
-{
-#if Buggy_code
-	/*
-	 * I disabled this routine because it was causing crashes when
-	 * this driver was used with the ISP (kernel SPPP) protocol driver.
-	 * The scenario is reproductible:
-	 *	Use the -link1 (dial on demand) ifconfig option.
-	 *	Start an interactive  TCP connection to somewhere.
-	 *	Wait until the PPP connection times out and is dropped.
-	 *	Try to send something on the TCP connection.
-	 *	The machine will print some garbage and halt or reboot
-	 *	(no panic messages).
-	 *
-	 * I've nailed down the problem to the fact that this routine
-	 * was being called before the B channel had been setup again.
-	 *
-	 * For now, I don't have a good solution other than this one.
-	 * But, don't despair. The impact of it is unnoticeable.
-	 */
-
-#ifdef __FreeBSD__
-	struct l1_softc  *sc	= itjc_scp[unit];
-#else
-	struct l1_softc	 *sc	= isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan	= &sc->sc_chan[h_chan];
-
-	int		 s	= SPLI4B();
-
-	dma_tx_context_t *txc	= &dma_tx_context[unit][h_chan];
-
-	if (chan->state & HSCX_TX_ACTIVE)
-	{
-		splx(s);
-		return;
-	}
-
-	itjc_dma_tx_intr(sc, chan, txc);
-
-	splx(s);
-#endif
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_shutdown - Stop the driver and reset the card.
- *---------------------------------------------------------------------------*/
-static void
-itjc_shutdown(device_t dev)
-{
-	struct l1_softc *sc = device_get_softc(dev);
-
-	itjc_bus_setup(sc);
-
-	/*
-	 * Stop the DMA the nice and easy way.
-	 */
-	itjc_bchannel_setup(sc->sc_unit, 0, BPROT_NONE, 0);
-	itjc_bchannel_setup(sc->sc_unit, 1, BPROT_NONE, 0);
-
-	/*
-	 * Reset the card.
-	 */
-	itjc_write_1(TIGER_RESET_PIB_CL_TIME, TIGER_RESET_ALL);
-
-	DELAY(SEC_DELAY/100); /* Give it 10 ms to reset ...*/
-
-	itjc_write_1(TIGER_RESET_PIB_CL_TIME,
-		TIGER_SELF_ADDR_DMA | TIGER_LATCH_DMA_INT | TIGER_PIB_3_CYCLES);
-
-	DELAY(SEC_DELAY/100); /* ... and more 10 to recover */
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_ret_linktab - Return the address of itjc drivers linktab.
- *---------------------------------------------------------------------------*/
-isdn_link_t *
-itjc_ret_linktab(int unit, int channel)
-{
-#ifdef __FreeBSD__
-	struct l1_softc		*sc = itjc_scp[unit];
-#else
-	struct l1_softc		*sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t	*chan = &sc->sc_chan[channel];
-
-	return(&chan->isic_isdn_linktab);
-}
- 
-/*---------------------------------------------------------------------------*
- *	itjc_set_linktab - Set the driver linktab in the b channel softc.
- *---------------------------------------------------------------------------*/
-void
-itjc_set_linktab(int unit, int channel, drvr_link_t *dlt)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc	= itjc_scp[unit];
-#else
-	struct l1_softc *sc	= isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan	= &sc->sc_chan[channel];
-
-	chan->isic_drvr_linktab = dlt;
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_init_linktab - Initialize our local linktab.
- *---------------------------------------------------------------------------*/
-static void
-itjc_init_linktab(struct l1_softc *sc)
-{
-	l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A];
-	isdn_link_t *lt = &chan->isic_isdn_linktab;
-
-	/* make sure the hardware driver is known to layer 4 */
-	/* avoid overwriting if already set */
-	if (ctrl_types[CTRL_PASSIVE].set_linktab == NULL)
-	{
-		ctrl_types[CTRL_PASSIVE].set_linktab = itjc_set_linktab;
-		ctrl_types[CTRL_PASSIVE].get_linktab = itjc_ret_linktab;
-	}
-
-	/* local setup */
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_A;
-	lt->bch_config = itjc_bchannel_setup;
-	lt->bch_tx_start = itjc_bchannel_start;
-	lt->bch_stat = itjc_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-                                                
-	chan = &sc->sc_chan[HSCX_CH_B];
-	lt = &chan->isic_isdn_linktab;
-
-	lt->unit = sc->sc_unit;
-	lt->channel = HSCX_CH_B;
-	lt->bch_config = itjc_bchannel_setup;
-	lt->bch_tx_start = itjc_bchannel_start;
-	lt->bch_stat = itjc_bchannel_stat;
-	lt->tx_queue = &chan->tx_queue;
-
-	/* used by non-HDLC data transfers, i.e. telephony drivers */
-	lt->rx_queue = &chan->rx_queue;
-
-	/* used by HDLC data transfers, i.e. ipr and isp drivers */	
-	lt->rx_mbuf = &chan->in_mbuf;	
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_bchannel_stat - Collect link statistics for a given B channel.
- *---------------------------------------------------------------------------*/
-static void
-itjc_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp)
-{
-#ifdef __FreeBSD__
-	struct l1_softc *sc = itjc_scp[unit];
-#else
-	struct l1_softc *sc = isic_find_sc(unit);
-#endif
-	l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
-	int s;
-
-	s = SPLI4B();
-	
-	bsp->outbytes = chan->txcount;
-	bsp->inbytes = chan->rxcount;
-
-	chan->txcount = 0;
-	chan->rxcount = 0;
-
-	splx(s);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	Netjet - ISAC interrupt routine.
- *---------------------------------------------------------------------------*/
-static void
-itjc_isac_intr(struct l1_softc *sc)
-{
-	register u_char irq_stat;
-
-	do
-	{
-		/* get isac irq status */
-		irq_stat = ISAC_READ(I_ISTA);
-
-		if(irq_stat)
-			itjc_isac_irq(sc, irq_stat); /* isac handler */
-	}
-	while(irq_stat);
-
-	ISAC_WRITE(I_MASK, 0xff);
-
-	DELAY(100);
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	itjc_recover - Try to recover from ISAC irq lockup.
- *---------------------------------------------------------------------------*/
-void
-itjc_recover(struct l1_softc *sc)
-{
-	u_char byte;
-	
-	/* get isac irq status */
-
-	byte = ISAC_READ(I_ISTA);
-
-	NDBGL1(L1_ERROR, "  ISAC: ISTA = 0x%x", byte);
-	
-	if(byte & ISAC_ISTA_EXI)
-		NDBGL1(L1_ERROR, "  ISAC: EXIR = 0x%x", (u_char)ISAC_READ(I_EXIR));
-
-	if(byte & ISAC_ISTA_CISQ)
-	{
-		byte = ISAC_READ(I_CIRR);
-	
-		NDBGL1(L1_ERROR, "  ISAC: CISQ = 0x%x", byte);
-		
-		if(byte & ISAC_CIRR_SQC)
-			NDBGL1(L1_ERROR, "  ISAC: SQRR = 0x%x", (u_char)ISAC_READ(I_SQRR));
-	}
-
-	NDBGL1(L1_ERROR, "  ISAC: IMASK = 0x%x", ISAC_IMASK);
-
-	ISAC_WRITE(I_MASK, 0xff);	
-	DELAY(100);
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-}
--- sys/i4b/layer1/itjc/i4b_itjc_l1.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_itjc_l1.c - NetJet-S layer 1 handler
- *	---------------------------------------------
- *      last edit-date: [Wed Jan 10 17:16:19 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/itjc/i4b_itjc_l1.c,v 1.5 2005/01/06 22:18:20 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <machine/stdarg.h>
-#include <machine/clock.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-
-#include <i4b/layer1/itjc/i4b_itjc_ext.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-DATA-REQUEST
- *	=========================
- *
- *	parms:
- *		unit		physical interface unit number
- *		m		mbuf containing L2 frame to be sent out
- *		freeflag	MBUF_FREE: free mbuf here after having sent
- *						it out
- *				MBUF_DONTFREE: mbuf is freed by Layer 2
- *	returns:
- *		==0	fail, nothing sent out
- *		!=0	ok, frame sent out
- *
- *---------------------------------------------------------------------------*/
-int
-itjc_ph_data_req(int unit, struct mbuf *m, int freeflag)
-{
-	u_char cmd;
-	int s;
-	struct l1_softc *sc = itjc_scp[unit];
-
-	NDBGL1(L1_PRIM, "PH-DATA-REQ, unit %d, freeflag=%d", unit, freeflag);
-
-	if(m == NULL)			/* failsafe */
-		return (0);
-
-	s = SPLI4B();
-
-	if(sc->sc_I430state == ST_F3)	/* layer 1 not running ? */
-	{
-		NDBGL1(L1_I_ERR, "still in state F3!");
-		itjc_ph_activate_req(unit);
-	}
-
-	if(sc->sc_state & ISAC_TX_ACTIVE)
-	{
-		if(sc->sc_obuf2 == NULL)
-		{
-			sc->sc_obuf2 = m;		/* save mbuf ptr */
-
-			if(freeflag)
-				sc->sc_freeflag2 = 1;	/* IRQ must mfree */
-			else
-				sc->sc_freeflag2 = 0;	/* IRQ must not mfree */
-
-			NDBGL1(L1_I_MSG, "using 2nd ISAC TX buffer, state = %s", itjc_printstate(sc));
-
-			if(sc->sc_trace & TRACE_D_TX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0ITJCUNIT(unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_TE;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-			}
-			splx(s);
-			return(1);
-		}
-
-		NDBGL1(L1_I_ERR, "No Space in TX FIFO, state = %s", itjc_printstate(sc));
-	
-		if(freeflag == MBUF_FREE)
-			i4b_Dfreembuf(m);			
-	
-		splx(s);
-		return (0);
-	}
-
-	if(sc->sc_trace & TRACE_D_TX)
-	{
-		i4b_trace_hdr_t hdr;
-		hdr.unit = L0ITJCUNIT(unit);
-		hdr.type = TRC_CH_D;
-		hdr.dir = FROM_TE;
-		hdr.count = ++sc->sc_trace_dcount;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, m->m_len, m->m_data);
-	}
-	
-	sc->sc_state |= ISAC_TX_ACTIVE;	/* set transmitter busy flag */
-
-	NDBGL1(L1_I_MSG, "ISAC_TX_ACTIVE set");
-
-	sc->sc_freeflag = 0;		/* IRQ must NOT mfree */
-	
-	ISAC_WRFIFO(m->m_data, min(m->m_len, ISAC_FIFO_LEN)); /* output to TX fifo */
-
-	if(m->m_len > ISAC_FIFO_LEN)	/* message > 32 bytes ? */
-	{
-		sc->sc_obuf = m;	/* save mbuf ptr */
-		sc->sc_op = m->m_data + ISAC_FIFO_LEN; 	/* ptr for irq hdl */
-		sc->sc_ol = m->m_len - ISAC_FIFO_LEN;	/* length for irq hdl */
-
-		if(freeflag)
-			sc->sc_freeflag = 1;	/* IRQ must mfree */
-		
-		cmd = ISAC_CMDR_XTF;
-	}
-	else
-	{
-		sc->sc_obuf = NULL;
-		sc->sc_op = NULL;
-		sc->sc_ol = 0;
-
-		if(freeflag)
-			i4b_Dfreembuf(m);
-
-		cmd = ISAC_CMDR_XTF | ISAC_CMDR_XME;
-  	}
-
-	ISAC_WRITE(I_CMDR, cmd);
-	ISACCMDRWRDELAY();
-
-	splx(s);
-	
-	return(1);
-}
-
-/*---------------------------------------------------------------------------*
- *
- *	L2 -> L1: PH-ACTIVATE-REQUEST
- *	=============================
- *
- *	parms:
- *		unit	physical interface unit number
- *
- *	returns:
- *		==0	
- *		!=0	
- *
- *---------------------------------------------------------------------------*/
-int
-itjc_ph_activate_req(int unit)
-{
-	struct l1_softc *sc = itjc_scp[unit];
-	NDBGL1(L1_PRIM, "PH-ACTIVATE-REQ, unit %d", unit);
-	itjc_next_state(sc, EV_PHAR);
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	command from the upper layers
- *---------------------------------------------------------------------------*/
-int
-itjc_mph_command_req(int unit, int command, void *parm)
-{
-	struct l1_softc *sc = itjc_scp[unit];
-
-	switch(command)
-	{
-		case CMR_DOPEN:		/* daemon running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DOPEN", unit);
-			sc->sc_enabled = 1;			
-			break;
-			
-		case CMR_DCLOSE:	/* daemon not running */
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_DCLOSE", unit);
-			sc->sc_enabled = 0;
-			break;
-
-		case CMR_SETTRACE:
-			NDBGL1(L1_PRIM, "unit %d, command = CMR_SETTRACE, parm = %d", unit, (unsigned int)parm);
-			sc->sc_trace = (unsigned int)parm;
-			break;
-		
-		default:
-			NDBGL1(L1_ERROR, "ERROR, unknown command = %d, unit = %d, parm = %d", command, unit, (unsigned int)parm);
-			break;
-	}
-
-	return(0);
-}
--- sys/i4b/layer1/itjc/i4b_itjc_isac.c
+++ /dev/null
@@ -1,546 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_itjc_isac.c - i4b NetJet-S ISAC handler
- *	--------------------------------------------
- *      last edit-date: [Wed Jan 10 17:15:54 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/itjc/i4b_itjc_isac.c,v 1.5 2005/01/06 22:18:20 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <machine/stdarg.h>
-#include <machine/clock.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-
-#include <i4b/layer1/itjc/i4b_itjc_ext.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_mbuf.h>
-
-static u_char itjc_isac_exir_hdlr(register struct l1_softc *sc, u_char exir);
-static void itjc_isac_ind_hdlr(register struct l1_softc *sc, int ind);
-
-/*---------------------------------------------------------------------------*
- *	ISAC interrupt service routine
- *---------------------------------------------------------------------------*/
-void
-itjc_isac_irq(struct l1_softc *sc, int ista)
-{
-	register u_char c = 0;
-	NDBGL1(L1_F_MSG, "unit %d: ista = 0x%02x", sc->sc_unit, ista);
-
-	if(ista & ISAC_ISTA_EXI)	/* extended interrupt */
-	{
-		c |= itjc_isac_exir_hdlr(sc, ISAC_READ(I_EXIR));
-	}
-	
-	if(ista & ISAC_ISTA_RME)	/* receive message end */
-	{
-		register int rest;
-		u_char rsta;
-
-		/* get rx status register */
-		
-		rsta = ISAC_READ(I_RSTA);
-
-		if((rsta & ISAC_RSTA_MASK) != 0x20)
-		{
-			int error = 0;
-			
-			if(!(rsta & ISAC_RSTA_CRC))	/* CRC error */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: CRC error", sc->sc_unit);
-			}
-	
-			if(rsta & ISAC_RSTA_RDO)	/* ReceiveDataOverflow */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Data Overrun error", sc->sc_unit);
-			}
-	
-			if(rsta & ISAC_RSTA_RAB)	/* ReceiveABorted */
-			{
-				error++;
-				NDBGL1(L1_I_ERR, "unit %d: Receive Aborted error", sc->sc_unit);
-			}
-
-			if(error == 0)			
-				NDBGL1(L1_I_ERR, "unit %d: RME unknown error, RSTA = 0x%02x!", sc->sc_unit, rsta);
-
-			i4b_Dfreembuf(sc->sc_ibuf);
-
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-
-			ISAC_WRITE(I_CMDR, ISAC_CMDR_RMC|ISAC_CMDR_RRES);
-			ISACCMDRWRDELAY();
-
-			return;
-		}
-
-		rest = (ISAC_READ(I_RBCL) & (ISAC_FIFO_LEN-1));
-
-		if(rest == 0)
-			rest = ISAC_FIFO_LEN;
-
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(rest)) != NULL)
-				sc->sc_ib = sc->sc_ibuf->m_data;
-			else
-				panic("itjc_isac_irq: RME, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - rest))
-		{
-			ISAC_RDFIFO(sc->sc_ib, rest);
-			sc->sc_ilen += rest;
-			
-			sc->sc_ibuf->m_pkthdr.len =
-				sc->sc_ibuf->m_len = sc->sc_ilen;
-
-			if(sc->sc_trace & TRACE_D_RX)
-			{
-				i4b_trace_hdr_t hdr;
-				hdr.unit = L0ITJCUNIT(sc->sc_unit);
-				hdr.type = TRC_CH_D;
-				hdr.dir = FROM_NT;
-				hdr.count = ++sc->sc_trace_dcount;
-				MICROTIME(hdr.time);
-				i4b_l1_trace_ind(&hdr, sc->sc_ibuf->m_len, sc->sc_ibuf->m_data);
-			}
-
-			c |= ISAC_CMDR_RMC;
-
-			if(sc->sc_enabled &&
-			   (ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S))
-			{
-				i4b_l1_ph_data_ind(L0ITJCUNIT(sc->sc_unit), sc->sc_ibuf);
-			}
-			else
-			{
-				i4b_Dfreembuf(sc->sc_ibuf);
-			}
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RME, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-		}
-
-		sc->sc_ibuf = NULL;
-		sc->sc_ib = NULL;
-		sc->sc_ilen = 0;
-	}
-
-	if(ista & ISAC_ISTA_RPF)	/* receive fifo full */
-	{
-		if(sc->sc_ibuf == NULL)
-		{
-			if((sc->sc_ibuf = i4b_Dgetmbuf(MAX_DFRAME_LEN)) != NULL)
-				sc->sc_ib= sc->sc_ibuf->m_data;
-			else
-				panic("itjc_isac_irq: RPF, i4b_Dgetmbuf returns NULL!\n");
-			sc->sc_ilen = 0;
-		}
-
-		if(sc->sc_ilen <= (MAX_DFRAME_LEN - ISAC_FIFO_LEN))
-		{
-			ISAC_RDFIFO(sc->sc_ib, ISAC_FIFO_LEN);
-			sc->sc_ilen += ISAC_FIFO_LEN;			
-			sc->sc_ib += ISAC_FIFO_LEN;
-			c |= ISAC_CMDR_RMC;
-		}
-		else
-		{
-			NDBGL1(L1_I_ERR, "RPF, input buffer overflow!");
-			i4b_Dfreembuf(sc->sc_ibuf);
-			sc->sc_ibuf = NULL;
-			sc->sc_ib = NULL;
-			sc->sc_ilen = 0;
-			c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;			
-		}
-	}
-
-	if(ista & ISAC_ISTA_XPR)	/* transmit fifo empty (XPR bit set) */
-	{
-		if((sc->sc_obuf2 != NULL) && (sc->sc_obuf == NULL))
-		{
-			sc->sc_freeflag = sc->sc_freeflag2;
-			sc->sc_obuf = sc->sc_obuf2;
-			sc->sc_op = sc->sc_obuf->m_data;
-			sc->sc_ol = sc->sc_obuf->m_len;
-			sc->sc_obuf2 = NULL;
-		}
-		
-		if(sc->sc_obuf)
-		{			
-			ISAC_WRFIFO(sc->sc_op, min(sc->sc_ol, ISAC_FIFO_LEN));
-	
-			if(sc->sc_ol > ISAC_FIFO_LEN)	/* length > 32 ? */
-			{
-				sc->sc_op += ISAC_FIFO_LEN; /* bufferptr+32 */
-				sc->sc_ol -= ISAC_FIFO_LEN; /* length - 32 */
-				c |= ISAC_CMDR_XTF;	    /* set XTF bit */
-			}
-			else
-			{
-				if(sc->sc_freeflag)
-				{
-					i4b_Dfreembuf(sc->sc_obuf);
-					sc->sc_freeflag = 0;
-				}
-				sc->sc_obuf = NULL;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-	
-				c |= ISAC_CMDR_XTF | ISAC_CMDR_XME;
-			}
-		}
-		else
-		{
-			sc->sc_state &= ~ISAC_TX_ACTIVE;
-		}
-	}
-	
-	if(ista & ISAC_ISTA_CISQ)	/* channel status change CISQ */
-	{
-		register u_char ci;
-	
-		/* get command/indication rx register*/
-	
-		ci = ISAC_READ(I_CIRR);
-
-		/* if S/Q IRQ, read SQC reg to clr SQC IRQ */
-	
-		if(ci & ISAC_CIRR_SQC)
-			(void) ISAC_READ(I_SQRR);
-
-		/* C/I code change IRQ (flag already cleared by CIRR read) */
-	
-		if(ci & ISAC_CIRR_CIC0)
-			itjc_isac_ind_hdlr(sc, (ci >> 2) & 0xf);
-	}
-	
-	if(c)
-	{
-		ISAC_WRITE(I_CMDR, c);
-		ISACCMDRWRDELAY();
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	ISAC L1 Extended IRQ handler
- *---------------------------------------------------------------------------*/
-static u_char
-itjc_isac_exir_hdlr(register struct l1_softc *sc, u_char exir)
-{
-	u_char c = 0;
-	
-	if(exir & ISAC_EXIR_XMR)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Message Repeat");
-
-		c |= ISAC_CMDR_XRES;
-	}
-	
-	if(exir & ISAC_EXIR_XDU)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Tx Data Underrun");
-
-		c |= ISAC_CMDR_XRES;
-	}
-
-	if(exir & ISAC_EXIR_PCE)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Protocol Error");
-	}
-
-	if(exir & ISAC_EXIR_RFO)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Rx Frame Overflow");
-
-		c |= ISAC_CMDR_RMC|ISAC_CMDR_RRES;
-	}
-
-	if(exir & ISAC_EXIR_SOV)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Sync Xfer Overflow");
-	}
-
-	if(exir & ISAC_EXIR_MOS)
-	{
-		NDBGL1(L1_I_ERR, "EXIRQ Monitor Status");
-	}
-
-	if(exir & ISAC_EXIR_SAW)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-		
-		NDBGL1(L1_I_ERR, "EXIRQ Subscriber Awake");
-	}
-
-	if(exir & ISAC_EXIR_WOV)
-	{
-		/* cannot happen, STCR:TSF is set to 0 */
-
-		NDBGL1(L1_I_ERR, "EXIRQ Watchdog Timer Overflow");
-	}
-
-	return(c);
-}
-
-/*---------------------------------------------------------------------------*
- *	ISAC L1 Indication handler
- *---------------------------------------------------------------------------*/
-static void
-itjc_isac_ind_hdlr(register struct l1_softc *sc, int ind)
-{
-	register int event;
-	
-	switch(ind)
-	{
-		case ISAC_CIRR_IAI8:
-			NDBGL1(L1_I_CICO, "rx AI8 in state %s", itjc_printstate(sc));
-			itjc_isac_l1_cmd(sc, CMD_AR8);
-			event = EV_INFO48;
-			i4b_l1_mph_status_ind(L0ITJCUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-			
-		case ISAC_CIRR_IAI10:
-			NDBGL1(L1_I_CICO, "rx AI10 in state %s", itjc_printstate(sc));
-			itjc_isac_l1_cmd(sc, CMD_AR10);
-			event = EV_INFO410;
-			i4b_l1_mph_status_ind(L0ITJCUNIT(sc->sc_unit), STI_L1STAT, LAYER_ACTIVE, NULL);
-			break;
-
-		case ISAC_CIRR_IRSY:
-			NDBGL1(L1_I_CICO, "rx RSY in state %s", itjc_printstate(sc));
-			event = EV_RSY;
-			break;
-
-		case ISAC_CIRR_IPU:
-			NDBGL1(L1_I_CICO, "rx PU in state %s", itjc_printstate(sc));
-			event = EV_PU;
-			break;
-
-		case ISAC_CIRR_IDR:
-			NDBGL1(L1_I_CICO, "rx DR in state %s", itjc_printstate(sc));
-			itjc_isac_l1_cmd(sc, CMD_DIU);
-			event = EV_DR;			
-			break;
-			
-		case ISAC_CIRR_IDID:
-			NDBGL1(L1_I_CICO, "rx DID in state %s", itjc_printstate(sc));
-			event = EV_INFO0;
-			i4b_l1_mph_status_ind(L0ITJCUNIT(sc->sc_unit), STI_L1STAT, LAYER_IDLE, NULL);
-			break;
-
-		case ISAC_CIRR_IDIS:
-			NDBGL1(L1_I_CICO, "rx DIS in state %s", itjc_printstate(sc));
-			event = EV_DIS;
-			break;
-
-		case ISAC_CIRR_IEI:
-			NDBGL1(L1_I_CICO, "rx EI in state %s", itjc_printstate(sc));
-			itjc_isac_l1_cmd(sc, CMD_DIU);
-			event = EV_EI;
-			break;
-
-		case ISAC_CIRR_IARD:
-			NDBGL1(L1_I_CICO, "rx ARD in state %s", itjc_printstate(sc));
-			event = EV_INFO2;
-			break;
-
-		case ISAC_CIRR_ITI:
-			NDBGL1(L1_I_CICO, "rx TI in state %s", itjc_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISAC_CIRR_IATI:
-			NDBGL1(L1_I_CICO, "rx ATI in state %s", itjc_printstate(sc));
-			event = EV_INFO0;
-			break;
-
-		case ISAC_CIRR_ISD:
-			NDBGL1(L1_I_CICO, "rx SD in state %s", itjc_printstate(sc));
-			event = EV_INFO0;
-			break;
-		
-		default:
-			NDBGL1(L1_I_ERR, "UNKNOWN Indication 0x%x in state %s", ind, itjc_printstate(sc));
-			event = EV_INFO0;
-			break;
-	}
-	itjc_next_state(sc, event);
-}
-
-/*---------------------------------------------------------------------------*
- *	execute a layer 1 command
- *---------------------------------------------------------------------------*/	
-void
-itjc_isac_l1_cmd(struct l1_softc *sc, int command)
-{
-	u_char cmd;
-
-	if(command < 0 || command > CMD_ILL)
-	{
-		NDBGL1(L1_I_ERR, "illegal cmd 0x%x in state %s", command, itjc_printstate(sc));
-		return;
-	}
-                                           
-	cmd = ISAC_CIX0_LOW;
-
-	switch(command)
-	{
-		case CMD_TIM:
-			NDBGL1(L1_I_CICO, "tx TIM in state %s", itjc_printstate(sc));
-			cmd |= (ISAC_CIXR_CTIM << 2);
-			break;
-
-		case CMD_RS:
-			NDBGL1(L1_I_CICO, "tx RS in state %s", itjc_printstate(sc));
-			cmd |= (ISAC_CIXR_CRS << 2);
-			break;
-
-		case CMD_AR8:
-			NDBGL1(L1_I_CICO, "tx AR8 in state %s", itjc_printstate(sc));
-			cmd |= (ISAC_CIXR_CAR8 << 2);
-			break;
-
-		case CMD_AR10:
-			NDBGL1(L1_I_CICO, "tx AR10 in state %s", itjc_printstate(sc));
-			cmd |= (ISAC_CIXR_CAR10 << 2);
-			break;
-
-		case CMD_DIU:
-			NDBGL1(L1_I_CICO, "tx DIU in state %s", itjc_printstate(sc));
-			cmd |= (ISAC_CIXR_CDIU << 2);
-			break;
-	}
-	ISAC_WRITE(I_CIXR, cmd);
-}
-
-/*---------------------------------------------------------------------------*
- *	L1 ISAC initialization
- *---------------------------------------------------------------------------*/
-int
-itjc_isac_init(struct l1_softc *sc)
-{
-	ISAC_IMASK = 0xff;		/* disable all irqs */
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	NDBGL1(L1_I_SETUP, "configuring for IOM-2 mode");
-
-	/* ADF2: Select mode IOM-2 */		
-	ISAC_WRITE(I_ADF2, ISAC_ADF2_IMS);
-
-	/* SPCR: serial port control register:
-	 *	SPU - software power up = 0
-	 *	SPM - timing mode 0
-	 *	TLP - test loop = 0
-	 *	C1C, C2C - B1 + C1 and B2 + IC2 monitoring
-	 */
-	ISAC_WRITE(I_SPCR, 0x00);
-
-	/* SQXR: S/Q channel xmit register:
-	 *	IDC  - IOM direction = 0 (master)
-	 *	CFS  - Config Select = 0 (clock always active)
-	 *	CI1E - C/I channel 1 IRQ enable = 0
-                 *	SQIE - S/Q IRQ enable = 0
-	 *	SQX1-4 - Fa bits = 1
-	 */
-	ISAC_WRITE(I_SQXR, ISAC_SQXR_SQX1|ISAC_SQXR_SQX2|ISAC_SQXR_SQX3|ISAC_SQXR_SQX4);
-
-	/* ADF1: additional feature reg 1:
-	 *	WTC - watchdog = 0
-	 *	TEM - test mode = 0
-	 *	PFS - pre-filter = 0
-	 *	IOF - IOM i/f off = 0
-	 *	ITF - interframe fill = idle
-	 */	
-	ISAC_WRITE(I_ADF1, 0x00);
-
-	/* STCR: sync transfer control reg:
-	 *	TSF - terminal secific functions = 0
-	 *	TBA - TIC bus address = 7
-	 *	STx/SCx = 0
-	 */
-	ISAC_WRITE(I_STCR, ISAC_STCR_TBA2|ISAC_STCR_TBA1|ISAC_STCR_TBA0);
-
-	/* MODE: Mode Register:
-	 *	MDSx - transparent mode 2
-	 *	TMD  - timer mode = external
-	 *	RAC  - Receiver enabled
-	 *	DIMx - digital i/f mode
-	 */
-	ISAC_WRITE(I_MODE, ISAC_MODE_MDS2|ISAC_MODE_MDS1|ISAC_MODE_RAC|ISAC_MODE_DIM0);
-
-	/* enabled interrupts:
-	 * ===================
-	 * RME  - receive message end
-	 * RPF  - receive pool full
-	 * XPR  - transmit pool ready
-	 * CISQ - CI or S/Q channel change
-	 * EXI  - extended interrupt
-	 */
-
-	ISAC_IMASK = ISAC_MASK_RSC |	/* auto mode only	*/
-		     ISAC_MASK_TIN | 	/* timer irq		*/
-		     ISAC_MASK_SIN;	/* sync xfer irq	*/
-
-	ISAC_WRITE(I_MASK, ISAC_IMASK);
-
-	return(0);
-}
--- sys/i4b/layer1/itjc/i4b_hdlc.h
+++ /dev/null
@@ -1,319 +0,0 @@
-/*-
- * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_hdlc.h - software-HDLC header file
- *	--------------------------------------
- *
- *	$Id: i4b_hdlc.h,v 1.5 2000/08/28 07:41:19 hm Exp $
- *
- * $FreeBSD: src/sys/i4b/layer1/itjc/i4b_hdlc.h,v 1.3 2005/01/06 22:18:20 imp Exp $
- *
- *	last edit-date: [Thu Jan 11 11:31:01 2001]
- *
- *	Please conform "ihfc/i4b_ihfc_drv.c" (ihfc_hdlc_Bxxxx)
- *	for correct usage! (-hp)
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_HDLC_H_
-#define _I4B_HDLC_H_
-
-extern const u_short HDLC_FCS_TAB[256];
-extern const u_short HDLC_BIT_TAB[256];
-
-/*---------------------------------------------------------------------------*
- *	HDLC_DECODE
- *	===========
- *
- *	u_char:  flag, blevel
- *	u_short: crc, ib, tmp, tmp2, len
- *
- *	next: 'continue' or 'goto xxx'
- *
- *	cfr: complete frame
- *	nfr: new frame
- *	     NOTE: must setup 'len' and 'dst', so that 'dst' may be written
- *		   at most 'len' times.
- *
- *	rab: abort
- *	rdd: read data (read byte is stored in 'tmp2')
- *	rdo: overflow
- *
- *	d: dummy
- *
- *	NOTE: setting flag to '0' and len to '0' => recover from rdu
- *	NOTE: bits[8 .. ] of tmp2 may be used to store custom data/flags
- *	NOTE: these variables have to be 'suspended' / 'resumed' somehow:
- *		flag, blevel, crc, ib, tmp, len
- *	NOTE: zero is default value for all variables.
- *	NOTE: each time 'dst' is written, 'len' is decreased by one.
- *---------------------------------------------------------------------------*/
-
-#define HDLC_DECODE(dst, len, tmp, tmp2, blevel, ib, crc, flag,	rddcmd, nfrcmd,	\
-		 cfrcmd, rabcmd, rdocmd, nextcmd, d) 				\
-										\
-	rddcmd;									\
-										\
-	ib  += HDLC_BIT_TAB[(u_char)tmp2];					\
-										\
-	if ((u_char)ib >= 5)							\
-	{									\
-		if (ib & 0x20)		/* de-stuff (msb) */			\
-		{								\
-			if ((u_char)tmp2 == 0x7e) goto j0##d;			\
-			tmp2 += tmp2 & 0x7f;					\
-			blevel--;						\
-										\
-			if ((ib += 0x100) & 0xc) tmp2 |= 1; /* */		\
-		}								\
-										\
-		ib &= ~0xe0;							\
-										\
-		if ((u_char)ib == 6)	/* flag seq (lsb) */			\
-		{								\
-		 j0##d:	if (flag >= 2)						\
-			{							\
-				len += (4 - flag) & 3;	/* remove CRC bytes */	\
-				crc ^= 0xf0b8;					\
-				cfrcmd;						\
-				len = 0;					\
-			}							\
-										\
-			flag   = 1;						\
-										\
-			blevel = (ib >> 8) & 0xf;				\
-			tmp    = ((u_char)tmp2) >> blevel;			\
-			blevel = 8 - blevel;					\
-										\
-			ib >>= 12;						\
-										\
-			nextcmd;						\
-		}								\
-		if ((u_char)ib >= 7)	/* abort (msb & lsb) */			\
-		{								\
-			if (flag >= 2)						\
-			{							\
-				rabcmd;						\
-				len = 0;					\
-			}							\
-										\
-			flag = 0;						\
-										\
-			ib >>= 12;						\
-										\
-			nextcmd;						\
-		}								\
-		if ((u_char)ib == 5)	/* de-stuff (lsb) */			\
-		{								\
-			tmp2 = (tmp2 | (tmp2 + 1)) & ~0x1;			\
-			blevel--;						\
-		}								\
-		if (blevel > 7)		/* EO - bits */				\
-		{								\
-			tmp |= (u_char)tmp2 >> (8 - (blevel &= 7));		\
-										\
-			ib >>= 12;						\
-										\
-			nextcmd;						\
-		}								\
-	}									\
-										\
-	tmp |= (u_char)tmp2 << blevel;						\
-										\
-	if (!len--)								\
-	{									\
-		len++;								\
-										\
-		if (!flag++) { flag--; goto j5##d;} /* hunt mode */		\
-										\
-		switch (flag)							\
-		{   case 2: 		/* new frame */				\
-			nfrcmd;							\
-			crc = -1;						\
-			if (!len--) { len++; flag++; goto j4##d; }		\
-			goto j3##d;						\
-		    case 3:		/* CRC (lsb's) */			\
-		    case 4:		/* CRC (msb's) */			\
-			goto j4##d;						\
-		    case 5:		/* RDO */				\
-			rdocmd;							\
-			flag = 0;						\
-			break;							\
-		}								\
-	}									\
-	else									\
-	{ 									\
-	 j3##d:	dst = (u_char)tmp;						\
-	 j4##d: crc = (HDLC_FCS_TAB[(u_char)(tmp ^ crc)] ^ (u_char)(crc >> 8));	\
-	}									\
-										\
- j5##d:	ib >>= 12;								\
-	tmp >>= 8;								\
-
-/*------ end of HDLC_DECODE -------------------------------------------------*/
-
-
-/*---------------------------------------------------------------------------*
- *	HDLC_ENCODE
- *	===========
- *
- *	u_char:  flag, src
- *	u_short: tmp2, blevel, ib, crc, len
- *	u_int:   tmp
- *
- *	gfr: This is the place where you free the last [mbuf] chain, and get
- *	     the next one. If a mbuf is available the code should setup 'len'
- *	     and 'src' so that 'src' may be read 'len' times. If no mbuf is
- *	     available leave 'len' and 'src' untouched.
- *
- *	nmb: If your implementation accept/use chained mbufs, this is the
- *	     place where you update 'len' and 'src' to the next mbuf of
- *	     the chain that makes up a frame. If no further mbuf is
- *	     available leave 'len' and 'src' untouched. This is not the
- *	     place where you free the mbuf. Leave the block empty if your
- *	     implementation does not accept/use chained mbufs.
- *
- *	wrd: write data (output = (u_char)tmp)
- *
- *	d: dummy
- *
- *	NOTE: setting flag to '-2' and len to '0' => abort bytes will be sent
- *	NOTE: these variables have to be 'suspended' / 'resumed' somehow:
- *		flag, blevel, crc, ib, tmp, len
- *	NOTE: zero is default value for all variables.
- *	NOTE: each time 'src' is read, 'len' is decreased by one.
- *	NOTE: neither cmd's should exit through 'goto' or 'break' statements.
- *---------------------------------------------------------------------------*/
-
-#define HDLC_ENCODE(src, len, tmp, tmp2, blevel, ib, crc, flag, gfrcmd, nmbcmd, wrdcmd, d) \
-										\
-	if (blevel >= 0x800) { blevel -= 0x800; goto j4##d; }			\
-										\
-	if (!len--)								\
-	{									\
-		len++;								\
-										\
-		switch(++flag)							\
-		{ default:			/* abort */			\
-			tmp  = blevel = 0;	/* zero is default */		\
-			tmp2 = 0xff;						\
-			goto j3##d;						\
-		  case 1:			/* 1st time FS */		\
-		  case 2:			/* 2nd time FS */		\
-			tmp2 = 0x7e;						\
-			goto j3##d;						\
-		  case 3:							\
-			gfrcmd;			/* get new frame */		\
-			if (!len--)						\
-			{							\
-				len++;						\
-				flag--;		/* don't proceed */		\
-				tmp2 = 0x7e;					\
-				goto j3##d;	/* final FS */			\
-			}							\
-			else							\
-			{							\
-				crc = -1;					\
-				ib  = 0;					\
-				goto j1##d; 	/* first byte */		\
-			}							\
-		  case 4:							\
-			nmbcmd;			/* get next mbuf in chain */	\
-			if (!len--)						\
-			{							\
-				len++;						\
-				crc ^= -1;					\
-				tmp2 = (u_char)crc;				\
-				goto j2##d;	/* CRC (lsb's) */		\
-			}							\
-			else							\
-			{							\
-				flag--;						\
-				goto j1##d;	/* proceed with the frame */	\
-			}							\
-		  case 5:							\
-			tmp2  = (u_char)(crc >> 8);				\
-			flag  = 1;						\
-			goto j2##d;		/* CRC (msb's) */		\
-		}								\
-	}									\
- 	else									\
-  	{ j1##d	:								\
-		tmp2 = (u_char)src;						\
-		crc =(HDLC_FCS_TAB[(u_char)(crc ^ tmp2)] ^ (u_char)(crc >> 8));	\
-	  j2##d:								\
-										\
-		ib >>= 12;							\
-		ib  += HDLC_BIT_TAB[(u_char)tmp2];				\
-										\
-		if ((u_char)ib >= 5)	/* stuffing */				\
-		{								\
-			blevel &= ~0xff;					\
-										\
-			if (ib & 0xc0)		/* bit stuff (msb) */		\
-			{							\
-				tmp2 += tmp2 & (0xff * (ib & 0xc0));		\
-				ib %= 0x5000;					\
-				blevel++;					\
-			}							\
-										\
-			ib &= ~0xf0;						\
-										\
-			if ((u_char)ib >= 5)	/* bit stuff (lsb) */		\
-			{							\
-				tmp2 += tmp2 & ~0x1f >> ((ib - (ib >> 8) + 1)	\
-								& 7);		\
-				blevel++;					\
-										\
-				if ((u_char)ib >= 10)	/* bit stuff (msb) */	\
-				{						\
-					tmp2 += tmp2 & ~0x7ff >> ((ib - 	\
-							(ib >> 8) + 1) & 7);	\
-					blevel++;				\
-				}						\
-				if (ib & 0x8000)	/* bit walk */		\
-				{						\
-					ib = ((u_char)ib % 5) << 12;		\
-				}						\
-			}							\
-										\
-			tmp    |= tmp2 << (u_char)(blevel >> 8);		\
-			blevel += (u_char)blevel << 8;				\
-		}								\
-		else		/* no stuffing */				\
-		{								\
-		  j3##d:tmp    |= tmp2 << (u_char)(blevel >> 8);		\
-		}								\
-	}									\
-										\
- j4##d:	wrdcmd;									\
-	tmp >>= 8;								\
-
-/*------ end of HDLC_ENCODE -------------------------------------------------*/
-
-
-#endif /* _I4B_HDLC_H_ */
--- sys/i4b/layer1/itjc/i4b_itjc_ext.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * Copyright (c) 2000, 2001 Sergio Prallon. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *      i4b_itjc - NetJet PCI for split layers
- *      ------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer1/itjc/i4b_itjc_ext.h,v 1.2 2005/01/06 22:18:20 imp Exp $
- *
- *      last edit-date: [Wed Jan 10 17:15:31 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_ITJC_EXT_H_
-#define _I4B_ITJC_EXT_H_
-
-#include <i4b/include/i4b_l3l4.h>
-
-void itjc_set_linktab(int unit, int channel, drvr_link_t * dlt);
-isdn_link_t *itjc_ret_linktab(int unit, int channel);
-
-int itjc_ph_data_req(int unit, struct mbuf *m, int freeflag);
-int itjc_ph_activate_req(int unit);
-int itjc_mph_command_req(int unit, int command, void *parm);
-
-void itjc_isac_irq(struct l1_softc *sc, int ista);
-void itjc_isac_l1_cmd(struct l1_softc *sc, int command);
-int itjc_isac_init(struct l1_softc *sc);
-
-void itjc_recover(struct l1_softc *sc);
-char * itjc_printstate(struct l1_softc *sc);
-void itjc_next_state(struct l1_softc *sc, int event);
-
-#define ITJC_MAXUNIT 4
-extern struct l1_softc *itjc_scp[ITJC_MAXUNIT];
-
-#endif /* _I4B_ITJC_EXT_H_ */
--- sys/i4b/layer1/itjc/i4b_itjc_l1fsm.c
+++ /dev/null
@@ -1,514 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_itjc_l1fsm.c - NetJet-S layer 1 I.430 state machine
- *	------------------------------------------------------------
- *      last edit-date: [Wed Jan 10 17:16:33 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer1/itjc/i4b_itjc_l1fsm.c,v 1.5 2005/01/06 22:18:20 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <machine/stdarg.h>
-#include <machine/clock.h>
-
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_trace.h>
-
-#include <i4b/layer1/isic/i4b_isic.h>
-#include <i4b/layer1/isic/i4b_isac.h>
-#include <i4b/layer1/isic/i4b_hscx.h>
-
-#include <i4b/layer1/i4b_l1.h>
-
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/include/i4b_mbuf.h>
-
-#include <i4b/layer1/itjc/i4b_itjc_ext.h>
-
-#if DO_I4B_DEBUG
-static char *state_text[N_STATES] = {
-	"F3 Deactivated",
-	"F4 Awaiting Signal",
-	"F5 Identifying Input",
-	"F6 Synchronized",
-	"F7 Activated",
-	"F8 Lost Framing",
-	"Illegal State"	
-};
-
-static char *event_text[N_EVENTS] = {
-	"EV_PHAR PH_ACT_REQ",
-	"EV_T3 Timer 3 expired",
-	"EV_INFO0 INFO0 received",
-	"EV_RSY Level Detected",
-	"EV_INFO2 INFO2 received",
-	"EV_INFO48 INFO4 received",
-	"EV_INFO410 INFO4 received",
-	"EV_DR Deactivate Req",
-	"EV_PU Power UP",
-	"EV_DIS Disconnected",
-	"EV_EI Error Ind",
-	"Illegal Event"
-};
-#endif
-
-/* Function prototypes */
-
-static void timer3_expired (struct l1_softc *sc);
-static void T3_start (struct l1_softc *sc);
-static void T3_stop (struct l1_softc *sc);
-static void F_T3ex (struct l1_softc *sc);
-static void timer4_expired (struct l1_softc *sc);
-static void T4_start (struct l1_softc *sc);
-static void T4_stop (struct l1_softc *sc);
-static void F_AI8 (struct l1_softc *sc);
-static void F_AI10 (struct l1_softc *sc);
-static void F_I01 (struct l1_softc *sc);
-static void F_I02 (struct l1_softc *sc);
-static void F_I03 (struct l1_softc *sc);
-static void F_I2 (struct l1_softc *sc);
-static void F_ill (struct l1_softc *sc);
-static void F_NULL (struct l1_softc *sc);
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer3_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T3)
-	{
-		NDBGL1(L1_T_ERR, "state = %s", itjc_printstate(sc));
-		sc->sc_I430T3 = 0;
-
-		/* XXX try some recovery here XXX */
-
-		itjc_recover(sc);
-
-		sc->sc_init_tries++;	/* increment retry count */
-
-/*XXX*/		if(sc->sc_init_tries > 4)
-		{
-			int s = SPLI4B();
-
-			sc->sc_init_tries = 0;
-			
-			if(sc->sc_obuf2 != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf2);
-				sc->sc_obuf2 = NULL;
-			}
-			if(sc->sc_obuf != NULL)
-			{
-				i4b_Dfreembuf(sc->sc_obuf);
-				sc->sc_obuf = NULL;
-				sc->sc_freeflag = 0;
-				sc->sc_op = NULL;
-				sc->sc_ol = 0;
-			}
-
-			splx(s);
-
-			i4b_l1_mph_status_ind(L0ITJCUNIT(sc->sc_unit), STI_NOL1ACC, 0, NULL);
-		}
-		
-		itjc_next_state(sc, EV_T3);		
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 start
- *---------------------------------------------------------------------------*/	
-static void
-T3_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", itjc_printstate(sc));
-	sc->sc_I430T3 = 1;
-	sc->sc_T3_callout = timeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, 2*hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 stop
- *---------------------------------------------------------------------------*/	
-static void
-T3_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", itjc_printstate(sc));
-
-	sc->sc_init_tries = 0;	/* init connect retry count */
-	
-	if(sc->sc_I430T3)
-	{
-		sc->sc_I430T3 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, sc->sc_T3_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	I.430 Timer T3 expiry
- *---------------------------------------------------------------------------*/	
-static void
-F_T3ex(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_T3ex executing");
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0ITJCUNIT(sc->sc_unit));
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 expire function
- *---------------------------------------------------------------------------*/	
-static void
-timer4_expired(struct l1_softc *sc)
-{
-	if(sc->sc_I430T4)
-	{
-		NDBGL1(L1_T_MSG, "state = %s", itjc_printstate(sc));
-		sc->sc_I430T4 = 0;
-		i4b_l1_mph_status_ind(L0ITJCUNIT(sc->sc_unit), STI_PDEACT, 0, NULL);
-	}
-	else
-	{
-		NDBGL1(L1_T_ERR, "expired without starting it ....");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 start
- *---------------------------------------------------------------------------*/	
-static void
-T4_start(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", itjc_printstate(sc));
-	sc->sc_I430T4 = 1;
-	sc->sc_T4_callout = timeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, hz);
-}
-
-/*---------------------------------------------------------------------------*
- *	Timer T4 stop
- *---------------------------------------------------------------------------*/	
-static void
-T4_stop(struct l1_softc *sc)
-{
-	NDBGL1(L1_T_MSG, "state = %s", itjc_printstate(sc));
-
-	if(sc->sc_I430T4)
-	{
-		sc->sc_I430T4 = 0;
-		untimeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, sc->sc_T4_callout);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI8
- *---------------------------------------------------------------------------*/	
-static void
-F_AI8(struct l1_softc *sc)
-{
-	T4_stop(sc);
-
-	NDBGL1(L1_F_MSG, "FSM function F_AI8 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0ITJCUNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_8;
-		
-		hdr.unit = L0ITJCUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received AI10
- *---------------------------------------------------------------------------*/	
-static void
-F_AI10(struct l1_softc *sc)
-{
-	T4_stop(sc);
-	
-	NDBGL1(L1_F_MSG, "FSM function F_AI10 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_activate_ind(L0ITJCUNIT(sc->sc_unit));
-
-	T3_stop(sc);
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO4_10;
-		
-		hdr.unit = L0ITJCUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in states F3 .. F5
- *---------------------------------------------------------------------------*/	
-static void
-F_I01(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I01 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0ITJCUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F6
- *---------------------------------------------------------------------------*/	
-static void
-F_I02(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I02 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0ITJCUNIT(sc->sc_unit));
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0ITJCUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO 0 in state F7 or F8
- *---------------------------------------------------------------------------*/	
-static void
-F_I03(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I03 executing");
-
-	if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)
-		i4b_l1_ph_deactivate_ind(L0ITJCUNIT(sc->sc_unit));
-
-	T4_start(sc);
-	
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO0;
-		
-		hdr.unit = L0ITJCUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: activate request
- *---------------------------------------------------------------------------*/	
-static void
-F_AR(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_AR executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO1_8;
-		
-		hdr.unit = L0ITJCUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_TE;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}
-
-	itjc_isac_l1_cmd(sc, CMD_AR8);
-
-	T3_start(sc);
-}
-
-/*---------------------------------------------------------------------------*
- *	FSM function: received INFO2
- *---------------------------------------------------------------------------*/	
-static void
-F_I2(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_I2 executing");
-
-	if(sc->sc_trace & TRACE_I)
-	{
-		i4b_trace_hdr_t hdr;
-		char info = INFO2;
-		
-		hdr.unit = L0ITJCUNIT(sc->sc_unit);
-		hdr.type = TRC_CH_I;
-		hdr.dir = FROM_NT;
-		hdr.count = 0;
-		MICROTIME(hdr.time);
-		i4b_l1_trace_ind(&hdr, 1, &info);
-	}		
-
-}
-
-/*---------------------------------------------------------------------------*
- *	illegal state default action
- *---------------------------------------------------------------------------*/	
-static void
-F_ill(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_ERR, "FSM function F_ill executing");
-}
-
-/*---------------------------------------------------------------------------*
- *	No action
- *---------------------------------------------------------------------------*/	
-static void
-F_NULL(struct l1_softc *sc)
-{
-	NDBGL1(L1_F_MSG, "FSM function F_NULL executing");
-}
-
-
-/*---------------------------------------------------------------------------*
- *	layer 1 state transition table
- *---------------------------------------------------------------------------*/	
-struct itjc_state_tab {
-	void (*func) (struct l1_softc *sc);	/* function to execute */
-	int newstate;				/* next state */
-} itjc_state_tab[N_EVENTS][N_STATES] = {
-
-/* STATE:	F3			F4			F5			F6			F7			F8			ILLEGAL STATE     */
-/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/* EV_PHAR x*/	{{F_AR,   ST_F4},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_ill,  ST_ILL},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_T3   x*/	{{F_NULL, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_T3ex, ST_F3},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO0 */	{{F_I01,  ST_F3},	{F_I01,  ST_F4},	{F_I01,  ST_F5},	{F_I02,  ST_F3},	{F_I03,  ST_F3},	{F_I03,  ST_F3},	{F_ill, ST_ILL}},
-/* EV_RSY  x*/	{{F_NULL, ST_F3},	{F_NULL, ST_F5},	{F_NULL, ST_F5}, 	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_INFO2 */	{{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_I2,   ST_F6},	{F_ill, ST_ILL}},
-/* EV_INFO48*/	{{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_AI8,  ST_F7},	{F_NULL, ST_F7},	{F_AI8,  ST_F7},	{F_ill, ST_ILL}},
-/* EV_INFO41*/	{{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_AI10, ST_F7},	{F_NULL, ST_F7},	{F_AI10, ST_F7},	{F_ill, ST_ILL}},
-/* EV_DR    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_PU    */	{{F_NULL, ST_F3},	{F_NULL, ST_F4},	{F_NULL, ST_F5},	{F_NULL, ST_F6},	{F_NULL, ST_F7},	{F_NULL, ST_F8},	{F_ill, ST_ILL}},
-/* EV_DIS   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}},
-/* EV_EI    */	{{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_NULL, ST_F3},	{F_ill, ST_ILL}},
-/* EV_ILL   */	{{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill,  ST_ILL},	{F_ill, ST_ILL}}
-};
-
-/*---------------------------------------------------------------------------*
- *	event handler
- *---------------------------------------------------------------------------*/	
-void
-itjc_next_state(struct l1_softc *sc, int event)
-{
-	int currstate, newstate;
-
-	if(event >= N_EVENTS)
-		panic("i4b_l1fsm.c: event >= N_EVENTS\n");
-
-	currstate = sc->sc_I430state;
-
-	if(currstate >= N_STATES)
-		panic("i4b_l1fsm.c: currstate >= N_STATES\n");	
-
-	newstate = itjc_state_tab[event][currstate].newstate;
-
-	if(newstate >= N_STATES)
-		panic("i4b_l1fsm.c: newstate >= N_STATES\n");	
-	
-	NDBGL1(L1_F_MSG, "FSM event [%s]: [%s => %s]", event_text[event],
-                                           state_text[currstate],
-                                           state_text[newstate]);
-
-        (*itjc_state_tab[event][currstate].func)(sc);
-
-	if(newstate == ST_ILL)
-	{
-		newstate = ST_F3;
-		NDBGL1(L1_F_ERR, "FSM Illegal State ERROR, oldstate = %s, newstate = %s, event = %s!",
-					state_text[currstate],
-					state_text[newstate],
-					event_text[event]);
-	}
-
-	sc->sc_I430state = newstate;
-}
-
-#if DO_I4B_DEBUG
-/*---------------------------------------------------------------------------*
- *	return pointer to current state description
- *---------------------------------------------------------------------------*/	
-char *
-itjc_printstate(struct l1_softc *sc)
-{
-	return((char *) state_text[sc->sc_I430state]);
-}
-#endif
--- sys/i4b/layer4/i4b_l4mgmt.c
+++ /dev/null
@@ -1,432 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l4mgmt.c - layer 4 calldescriptor management utilites
- *	-----------------------------------------------------------
- *      last edit-date: [Sun Aug 11 12:42:01 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer4/i4b_l4mgmt.c,v 1.17 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-call_desc_t call_desc[N_CALL_DESC];	/* call descriptor array */
-
-static unsigned int get_cdid(void);
-
-int nctrl;				/* number of attached controllers */
-
-void i4b_init_callout(call_desc_t *);
-
-/*---------------------------------------------------------------------------*
- *      return a new unique call descriptor id
- *	--------------------------------------
- *	returns a new calldescriptor id which is used to uniquely identyfy
- *	a single call in the communication between kernel and userland.
- *	this cdid is then used to associate a calldescriptor with an id.
- *---------------------------------------------------------------------------*/
-static unsigned int
-get_cdid(void)
-{
-	static unsigned int cdid_count = 0;
-	int i;
-	int x;
-
-	x = SPLI4B();
-
-	/* get next id */
-
-	cdid_count++;
-
-again:
-	if(cdid_count == CDID_UNUSED)		/* zero is invalid */
-		cdid_count++;
-	else if(cdid_count > CDID_MAX)		/* wraparound ? */
-		cdid_count = 1;
-
-	/* check if id already in use */
-
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		if(call_desc[i].cdid == cdid_count)
-		{
-			cdid_count++;
-			goto again;
-		}
-	}
-
-	splx(x);
-
-	return(cdid_count);
-}
-
-/*---------------------------------------------------------------------------*
- *      reserve a calldescriptor for later usage
- *      ----------------------------------------
- *      searches the calldescriptor array until an unused
- *      descriptor is found, gets a new calldescriptor id
- *      and reserves it by putting the id into the cdid field.
- *      returns pointer to the calldescriptor.
- *---------------------------------------------------------------------------*/
-call_desc_t *
-reserve_cd(void)
-{
-	call_desc_t *cd;
-	int x;
-	int i;
-
-	x = SPLI4B();
-
-	cd = NULL;
-
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		if(call_desc[i].cdid == CDID_UNUSED)
-		{
-			bzero(&call_desc[i], sizeof(call_desc_t)); /* clear it */
-			call_desc[i].cdid = get_cdid();	/* fill in new cdid */
-			cd = &(call_desc[i]);	/* get pointer to descriptor */
-			NDBGL4(L4_MSG, "found free cd - index=%d cdid=%u",
-				 i, call_desc[i].cdid);
-			break;
-		}
-	}
-
-	splx(x);
-
-	if(cd == NULL)
-		panic("reserve_cd: no free call descriptor available!");
-
-	i4b_init_callout(cd);
-
-	return(cd);
-}
-
-/*---------------------------------------------------------------------------*
- *      free a calldescriptor
- *      ---------------------
- *      free an unused calldescriptor by giving address of calldescriptor
- *      and writing a 0 into the cdid field marking it as unused.
- *---------------------------------------------------------------------------*/
-void
-freecd_by_cd(call_desc_t *cd)
-{
-	int i;
-	int x = SPLI4B();
-
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		if( (call_desc[i].cdid != CDID_UNUSED) &&
-		    (&(call_desc[i]) == cd) )
-		{
-			NDBGL4(L4_MSG, "releasing cd - index=%d cdid=%u cr=%d",
-				i, call_desc[i].cdid, cd->cr);
-			call_desc[i].cdid = CDID_UNUSED;
-			break;
-		}
-	}
-
-	if(i == N_CALL_DESC)
-		panic("freecd_by_cd: ERROR, cd not found, cr = %d\n", cd->cr);
-
-	splx(x);
-}
-
-/*---------------------------------------------------------------------------*
- *      return pointer to calldescriptor by giving the calldescriptor id
- *      ----------------------------------------------------------------
- *      lookup a calldescriptor in the calldescriptor array by looking
- *      at the cdid field. return pointer to calldescriptor if found,
- *      else return NULL if not found.
- *---------------------------------------------------------------------------*/
-call_desc_t *
-cd_by_cdid(unsigned int cdid)
-{
-	int i;
-
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		if(call_desc[i].cdid == cdid)
-		{
-			NDBGL4(L4_MSG, "found cdid - index=%d cdid=%u cr=%d",
-					i, call_desc[i].cdid, call_desc[i].cr);
-
-			i4b_init_callout(&call_desc[i]);
-
-			return(&(call_desc[i]));
-		}
-	}
-	return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- *      search calldescriptor
- *      ---------------------
- *      This routine searches for the calldescriptor for a passive controller
- *      given by unit number, callreference and callreference flag.
- *	It returns a pointer to the calldescriptor if found, else a NULL.
- *---------------------------------------------------------------------------*/
-call_desc_t *
-cd_by_unitcr(int unit, int cr, int crf)
-{
-	int i;
-
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-	  if((call_desc[i].cdid != CDID_UNUSED)                                       &&
-	     (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
-	     (ctrl_desc[call_desc[i].controller].unit == unit)              &&
-	     (call_desc[i].cr == cr)                                        &&
-	     (call_desc[i].crflag == crf) )
-	  {
-	    NDBGL4(L4_MSG, "found cd, index=%d cdid=%u cr=%d",
-			i, call_desc[i].cdid, call_desc[i].cr);
-
-	    i4b_init_callout(&call_desc[i]);
-
-	    return(&(call_desc[i]));
-	  }
-	}
-	return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- *	generate 7 bit "random" number used for outgoing Call Reference
- *---------------------------------------------------------------------------*/
-unsigned char
-get_rand_cr(int unit)
-{
-	register int i, j;
-	static u_char val, retval;
-	static int called = 42;
-
-	val += ++called;
-
-	for(i=0; i < 50 ; i++, val++)
-	{
-		int found = 1;
-
-#ifdef RANDOMDEV
-		read_random((char *)&val, sizeof(val));
-#else
-		val = (u_char)random();
-#endif /* RANDOMDEV */
-
-		retval = val & 0x7f;
-
-		if(retval == 0 || retval == 0x7f)
-			continue;
-
-		for(j=0; j < N_CALL_DESC; j++)
-		{
-			if( (call_desc[j].cdid != CDID_UNUSED) &&
-			    (call_desc[j].cr == retval) )
-			{
-				found = 0;
-				break;
-			}
-		}
-
-		if(found)
-			return(retval);
-	}
-	return(0);	/* XXX */
-}
-
-/*---------------------------------------------------------------------------*
- *	initialize the callout handles for FreeBSD
- *---------------------------------------------------------------------------*/
-void
-i4b_init_callout(call_desc_t *cd)
-{
-	if(cd->callouts_inited == 0)
-	{
-		callout_handle_init(&cd->idle_timeout_handle);
-		callout_handle_init(&cd->T303_callout);
-		callout_handle_init(&cd->T305_callout);
-		callout_handle_init(&cd->T308_callout);
-		callout_handle_init(&cd->T309_callout);
-		callout_handle_init(&cd->T310_callout);
-		callout_handle_init(&cd->T313_callout);
-		callout_handle_init(&cd->T400_callout);
-		cd->callouts_inited = 1;
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *      daemon is attached
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_daemon_attached(void)
-{
-	int i;
-
-	int x = SPLI4B();
-
-	for(i=0; i < nctrl; i++)
-	{
-/*XXX*/		if(ctrl_desc[i].ctrl_type == CTRL_PASSIVE)
-		{
-			NDBGL4(L4_MSG, "CMR_DOPEN sent to unit %d", ctrl_desc[i].unit);
-			(*ctrl_desc[i].N_MGMT_COMMAND)(ctrl_desc[i].unit, CMR_DOPEN, 0);
-		}
-	}
-	splx(x);
-}
-
-/*---------------------------------------------------------------------------*
- *      daemon is detached
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_daemon_detached(void)
-{
-	int i;
-
-	int x = SPLI4B();
-
-	for(i=0; i < nctrl; i++)
-	{
-/*XXX*/		if(ctrl_desc[i].ctrl_type == CTRL_PASSIVE)
-		{
-			NDBGL4(L4_MSG, "CMR_DCLOSE sent to unit %d", ctrl_desc[i].unit);
-			(*ctrl_desc[i].N_MGMT_COMMAND)(ctrl_desc[i].unit, CMR_DCLOSE, 0);
-		}
-	}
-	splx(x);
-}
-
-#ifdef I4B_CD_DEBUG_PRINT
-
-extern char *print_l3state(call_desc_t *cd);
-
-void i4b_print_cdp(call_desc_t *cdp);
-void i4b_print_cdx(int index);
-void i4b_print_cda(void);
-void i4b_print_cdaa(void);
-
-/*---------------------------------------------------------------------------*
- *	print a call descriptor by cd-pointer
- *---------------------------------------------------------------------------*/
-void
-i4b_print_cdp(call_desc_t *cdp)
-{
-	if((cdp > &(call_desc[N_CALL_DESC])) || (cdp < &(call_desc[0])))
-	{
-		printf("i4b_print_cd: cdp out of range!\n");
-		return;
-	}
-
-	printf("i4b_print_cd: printing call descriptor %d at 0x%lx:\n", cdp - (&(call_desc[0])), (unsigned long)cdp);
-
-	printf("         cdid = %d\n", cdp->cdid);
-	printf("   controller = %d (u=%d, dl=%d, b1=%d, b2=%d)\n",
-			cdp->controller,
-			ctrl_desc[cdp->controller].unit,
-			ctrl_desc[cdp->controller].dl_est,
-			ctrl_desc[cdp->controller].bch_state[CHAN_B1],
-			ctrl_desc[cdp->controller].bch_state[CHAN_B2]);
-	printf("           cr = 0x%02x\n", cdp->cr);
-	printf("       crflag = %d\n", cdp->crflag);
-	printf("    channelid = %d\n", cdp->channelid);
-	printf("        bprot = %d\n", cdp->bprot);
-	printf("         bcap = %d\n", cdp->bcap);
-	printf("       driver = %d\n", cdp->driver);
-	printf("  driver_unit = %d\n", cdp->driver_unit);
-	printf("   call_state = %d\n", cdp->call_state);
-	printf("    Q931state = %s\n", print_l3state(cdp));
-	printf("        event = %d\n", cdp->event);
-	printf("     response = %d\n", cdp->response);
-	printf("         T303 = %d\n", cdp->T303);
-	printf("T303_first_to = %d\n", cdp->T303_first_to);
-	printf("         T305 = %d\n", cdp->T305);
-	printf("         T308 = %d\n", cdp->T308);
-	printf("T308_first_to = %d\n", cdp->T308_first_to);
-	printf("         T309 = %d\n", cdp->T309);
-	printf("         T310 = %d\n", cdp->T310);
-	printf("         T313 = %d\n", cdp->T313);
-	printf("         T400 = %d\n", cdp->T400);
-	printf("          dir = %s\n", cdp->dir == DIR_OUTGOING ? "out" : "in");
-}
-
-/*---------------------------------------------------------------------------*
- *	print a call descriptor by index
- *---------------------------------------------------------------------------*/
-void
-i4b_print_cdx(int index)
-{
-	if(index >= N_CALL_DESC)
-	{
-		printf("i4b_print_cdx: index %d >= N_CALL_DESC %d\n", index, N_CALL_DESC);
-		return;
-	}
-	i4b_print_cdp(&(call_desc[index]));
-}
-
-/*---------------------------------------------------------------------------*
- *	print all call descriptors
- *---------------------------------------------------------------------------*/
-void
-i4b_print_cda(void)
-{
-	int i;
-
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		i4b_print_cdp(&(call_desc[i]));
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	print all active call descriptors
- *---------------------------------------------------------------------------*/
-void
-i4b_print_cdaa(void)
-{
-	int i;
-
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		if(call_desc[i].cdid != CDID_UNUSED)
-		{
-			i4b_print_cdp(&(call_desc[i]));
-		}
-	}
-}
-
-#endif /* I4B_CD_DEBUG_PRINT */
--- sys/i4b/layer4/i4b_l4timer.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *---------------------------------------------------------------------------
- *
- *	i4b_l4timer.c - timer and timeout handling for layer 4
- *	--------------------------------------------------------
- *      last edit-date: [Sat Mar  9 19:49:13 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer4/i4b_l4timer.c,v 1.13 2005/01/06 22:18:21 imp Exp $");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-/*---------------------------------------------------------------------------*
- *	timer T400 timeout function
- *---------------------------------------------------------------------------*/
-static void
-T400_timeout(call_desc_t *cd)
-{
-	NDBGL4(L4_ERR, "cr = %d", cd->cr);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T400 start
- *---------------------------------------------------------------------------*/
-void
-T400_start(call_desc_t *cd)
-{
-	if (cd->T400 == TIMER_ACTIVE)
-		return;
-		
-	NDBGL4(L4_MSG, "cr = %d", cd->cr);
-	cd->T400 = TIMER_ACTIVE;
-
-	START_TIMER(cd->T400_callout, T400_timeout, cd, T400DEF);
-}
-
-/*---------------------------------------------------------------------------*
- *	timer T400 stop
- *---------------------------------------------------------------------------*/
-void
-T400_stop(call_desc_t *cd)
-{
-	CRIT_VAR;
-	CRIT_BEG;
-
-	if(cd->T400 == TIMER_ACTIVE)
-	{
-		STOP_TIMER(cd->T400_callout, T400_timeout, cd);
-		cd->T400 = TIMER_IDLE;
-	}
-	CRIT_END;
-	NDBGL4(L4_MSG, "cr = %d", cd->cr);
-}
--- sys/i4b/layer4/i4b_l4.c
+++ /dev/null
@@ -1,1097 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l4.c - kernel interface to userland
- *	-----------------------------------------
- *      last edit-date: [Sun Aug 11 12:43:14 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer4/i4b_l4.c,v 1.19 2005/01/06 22:18:21 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/layer4/i4b_l4.h>
-
-unsigned int i4b_l4_debug = L4_DEBUG_DEFAULT;
-
-struct ctrl_type_desc ctrl_types[CTRL_NUMTYPES] = { { NULL, NULL} };
-
-static int i4b_link_bchandrvr(call_desc_t *cd);
-static void i4b_unlink_bchandrvr(call_desc_t *cd);
-static void i4b_l4_setup_timeout(call_desc_t *cd);
-static void i4b_idle_check_fix_unit(call_desc_t *cd);
-static void i4b_idle_check_var_unit(call_desc_t *cd);
-static void i4b_l4_setup_timeout_fix_unit(call_desc_t *cd);
-static void i4b_l4_setup_timeout_var_unit(call_desc_t *cd);
-static time_t i4b_get_idletime(call_desc_t *cd);
-
-#if NI4BISPPP > 0
-extern time_t i4bisppp_idletime(int);
-#endif
-
-/*---------------------------------------------------------------------------*
- *	send MSG_PDEACT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_pdeact(int controller, int numactive)
-{
-	struct mbuf *m;
-	int i;
-	call_desc_t *cd;
-	
-	for(i=0; i < N_CALL_DESC; i++)
-	{
-		if((call_desc[i].cdid != CDID_UNUSED)				  &&
-		   (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
-		   (ctrl_desc[call_desc[i].controller].unit == controller))
-		{
-			cd = &call_desc[i];
-			
-			if(cd->timeout_active)
-			{
-				STOP_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd);
-			}
-			
-			if(cd->dlt != NULL)
-			{
-				(*cd->dlt->line_disconnected)(cd->driver_unit, (void *)cd);
-				i4b_unlink_bchandrvr(cd);
-			}
-		
-			if((cd->channelid >= 0) & (cd->channelid < ctrl_desc[cd->controller].nbch))
-			{
-				ctrl_desc[cd->controller].bch_state[cd->channelid] = BCH_ST_FREE;
-			}
-
-			cd->cdid = CDID_UNUSED;
-		}
-	}
-	
-	if((m = i4b_Dgetmbuf(sizeof(msg_pdeact_ind_t))) != NULL)
-	{
-		msg_pdeact_ind_t *md = (msg_pdeact_ind_t *)m->m_data;
-
-		md->header.type = MSG_PDEACT_IND;
-		md->header.cdid = -1;
-
-		md->controller = controller;
-		md->numactive = numactive;
-
-		i4bputqueue_hipri(m);		/* URGENT !!! */
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_L12STAT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_l12stat(int controller, int layer, int state)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_l12stat_ind_t))) != NULL)
-	{
-		msg_l12stat_ind_t *md = (msg_l12stat_ind_t *)m->m_data;
-
-		md->header.type = MSG_L12STAT_IND;
-		md->header.cdid = -1;
-
-		md->controller = controller;
-		md->layer = layer;
-		md->state = state;
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_TEIASG_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_teiasg(int controller, int tei)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_teiasg_ind_t))) != NULL)
-	{
-		msg_teiasg_ind_t *md = (msg_teiasg_ind_t *)m->m_data;
-
-		md->header.type = MSG_TEIASG_IND;
-		md->header.cdid = -1;
-
-		md->controller = controller;
-		md->tei = ctrl_desc[controller].tei;
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_DIALOUT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_dialout(int driver, int driver_unit)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_dialout_ind_t))) != NULL)
-	{
-		msg_dialout_ind_t *md = (msg_dialout_ind_t *)m->m_data;
-
-		md->header.type = MSG_DIALOUT_IND;
-		md->header.cdid = -1;
-
-		md->driver = driver;
-		md->driver_unit = driver_unit;	
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_DIALOUTNUMBER_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_dialoutnumber(int driver, int driver_unit, int cmdlen, char *cmd)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_dialoutnumber_ind_t))) != NULL)
-	{
-		msg_dialoutnumber_ind_t *md = (msg_dialoutnumber_ind_t *)m->m_data;
-		int i;
-
-		md->header.type = MSG_DIALOUTNUMBER_IND;
-		md->header.cdid = -1;
-
-		md->driver = driver;
-		md->driver_unit = driver_unit;
-
-		for (i = 0; i < cmdlen; i++)
-			if (cmd[i] == '*')
-				break;
-
-		/* XXX: TELNO_MAX is _with_ tailing '\0', so max is actually TELNO_MAX - 1 */
-		md->cmdlen = (i < TELNO_MAX  - 1 ? i : TELNO_MAX - 1);
-		/* skip the (first) '*' */
-		md->subaddrlen = (cmdlen - i - 1 < SUBADDR_MAX - 1 ? cmdlen - i - 1 : SUBADDR_MAX - 1);
-
-		bcopy(cmd, md->cmd, md->cmdlen);
-		if (md->subaddrlen != -1)
-			bcopy(cmd+i+1, md->subaddr, md->subaddrlen); 
-
-		NDBGL4(L4_TIMO, "cmd[%d]=%s, subaddr[%d]=%s", md->cmdlen, md->cmd, md->subaddrlen, md->subaddr);
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_KEYPAD_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_keypad(int driver, int driver_unit, int cmdlen, char *cmd)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_keypad_ind_t))) != NULL)
-	{
-		msg_keypad_ind_t *md = (msg_keypad_ind_t *)m->m_data;
-
-		md->header.type = MSG_KEYPAD_IND;
-		md->header.cdid = -1;
-
-		md->driver = driver;
-		md->driver_unit = driver_unit;
-
-		if(cmdlen > KEYPAD_MAX)
-			cmdlen = KEYPAD_MAX;
-
-		md->cmdlen = cmdlen;
-		bcopy(cmd, md->cmd, cmdlen);
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_NEGOTIATION_COMPL message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_negcomplete(call_desc_t *cd)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_negcomplete_ind_t))) != NULL)
-	{
-		msg_negcomplete_ind_t *md = (msg_negcomplete_ind_t *)m->m_data;
-
-		md->header.type = MSG_NEGCOMP_IND;
-		md->header.cdid = cd->cdid;
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_IFSTATE_CHANGED_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_ifstate_changed(call_desc_t *cd, int new_state)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_ifstatechg_ind_t))) != NULL)
-	{
-		msg_ifstatechg_ind_t *md = (msg_ifstatechg_ind_t *)m->m_data;
-
-		md->header.type = MSG_IFSTATE_CHANGED_IND;
-		md->header.cdid = cd->cdid;
-		md->state = new_state;
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_DRVRDISC_REQ message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_drvrdisc(int driver, int driver_unit)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_drvrdisc_req_t))) != NULL)
-	{
-		msg_drvrdisc_req_t *md = (msg_drvrdisc_req_t *)m->m_data;
-
-		md->header.type = MSG_DRVRDISC_REQ;
-		md->header.cdid = -1;
-
-		md->driver = driver;
-		md->driver_unit = driver_unit;	
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_ACCT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_accounting(int driver, int driver_unit, int accttype, int ioutbytes,
-		int iinbytes, int ro, int ri, int outbytes, int inbytes)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_accounting_ind_t))) != NULL)
-	{
-		msg_accounting_ind_t *md = (msg_accounting_ind_t *)m->m_data;
-
-		md->header.type = MSG_ACCT_IND;
-		md->header.cdid = -1;
-
-		md->driver = driver;
-		md->driver_unit = driver_unit;	
-
-		md->accttype = accttype;
-		md->ioutbytes = ioutbytes;
-		md->iinbytes = iinbytes;
-		md->outbps = ro;
-		md->inbps = ri;
-		md->outbytes = outbytes;
-		md->inbytes = inbytes;
-		
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_CONNECT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_connect_ind(call_desc_t *cd)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_connect_ind_t))) != NULL)
-	{
-		msg_connect_ind_t *mp = (msg_connect_ind_t *)m->m_data;
-
-		mp->header.type = MSG_CONNECT_IND;
-		mp->header.cdid = cd->cdid;
-
-		mp->controller = cd->controller;
-		mp->channel = cd->channelid;
-		mp->bprot = cd->bprot;
-		mp->bcap = cd->bcap;		
-
-		cd->dir = DIR_INCOMING;
-
-		if(strlen(cd->dst_telno) > 0)
-			strcpy(mp->dst_telno, cd->dst_telno);
-		else
-			strcpy(mp->dst_telno, TELNO_EMPTY);
-
-		if(strlen(cd->dst_subaddr) > 0)
-			strcpy(mp->dst_subaddr, cd->dst_subaddr);
-		else
-			strcpy(mp->dst_subaddr, TELNO_EMPTY);
-
-		if(strlen(cd->src_telno) > 0)
-			strcpy(mp->src_telno, cd->src_telno);
-		else
-			strcpy(mp->src_telno, TELNO_EMPTY);
-			
-		if(strlen(cd->src_subaddr) > 0)
-			strcpy(mp->src_subaddr, cd->src_subaddr);
-		else
-			strcpy(mp->src_subaddr, TELNO_EMPTY);
-
-		mp->src_ton = cd->src_ton;
-		mp->dst_ton = cd->dst_ton;
-
-		strcpy(mp->display, cd->display);
-
-		mp->scr_ind = cd->scr_ind;
-		mp->prs_ind = cd->prs_ind;		
-		
-		T400_start(cd);
-		
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_CONNECT_ACTIVE_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_connect_active_ind(call_desc_t *cd)
-{
-	int s;
-	struct mbuf *m;
-
-	s = SPLI4B();
-
-	cd->last_active_time = cd->connect_time = SECOND;
-
-	NDBGL4(L4_TIMO, "last_active/connect_time=%ld", (long)cd->connect_time);
-	
-	i4b_link_bchandrvr(cd);
-
-	(*cd->dlt->line_connected)(cd->driver_unit, (void *)cd);
-
-	i4b_l4_setup_timeout(cd);
-	
-	splx(s);	
-	
-	if((m = i4b_Dgetmbuf(sizeof(msg_connect_active_ind_t))) != NULL)
-	{
-		msg_connect_active_ind_t *mp = (msg_connect_active_ind_t *)m->m_data;
-
-		mp->header.type = MSG_CONNECT_ACTIVE_IND;
-		mp->header.cdid = cd->cdid;
-		mp->controller = cd->controller;
-		mp->channel = cd->channelid;
-		if(cd->datetime[0] != '\0')
-			strcpy(mp->datetime, cd->datetime);
-		else
-			mp->datetime[0] = '\0';
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_DISCONNECT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_disconnect_ind(call_desc_t *cd)
-{
-	struct mbuf *m;
-
-	if(cd->timeout_active)
-		STOP_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd);
-
-	if(cd->dlt != NULL)
-	{
-		(*cd->dlt->line_disconnected)(cd->driver_unit, (void *)cd);
-		i4b_unlink_bchandrvr(cd);
-	}
-
-	if((cd->channelid >= 0) && (cd->channelid < ctrl_desc[cd->controller].nbch))
-	{
-		ctrl_desc[cd->controller].bch_state[cd->channelid] = BCH_ST_FREE;
-	}
-	else
-	{
-		/* no error, might be hunting call for callback */
-		NDBGL4(L4_MSG, "channel free not valid but %d!", cd->channelid);
-	}
-	
-	if((m = i4b_Dgetmbuf(sizeof(msg_disconnect_ind_t))) != NULL)
-	{
-		msg_disconnect_ind_t *mp = (msg_disconnect_ind_t *)m->m_data;
-
-		mp->header.type = MSG_DISCONNECT_IND;
-		mp->header.cdid = cd->cdid;
-		mp->cause = cd->cause_in;
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_IDLE_TIMEOUT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_idle_timeout_ind(call_desc_t *cd)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_idle_timeout_ind_t))) != NULL)
-	{
-		msg_idle_timeout_ind_t *mp = (msg_idle_timeout_ind_t *)m->m_data;
-
-		mp->header.type = MSG_IDLE_TIMEOUT_IND;
-		mp->header.cdid = cd->cdid;
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_CHARGING_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_charging_ind(call_desc_t *cd)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_charging_ind_t))) != NULL)
-	{
-		msg_charging_ind_t *mp = (msg_charging_ind_t *)m->m_data;
-
-		mp->header.type = MSG_CHARGING_IND;
-		mp->header.cdid = cd->cdid;
-		mp->units_type = cd->units_type;
-
-/*XXX*/		if(mp->units_type == CHARGE_CALC)
-			mp->units = cd->cunits;
-		else
-			mp->units = cd->units;
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_STATUS_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_status_ind(call_desc_t *cd)
-{
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_ALERT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_alert_ind(call_desc_t *cd)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_alert_ind_t))) != NULL)
-	{
-		msg_alert_ind_t *mp = (msg_alert_ind_t *)m->m_data;
-
-		mp->header.type = MSG_ALERT_IND;
-		mp->header.cdid = cd->cdid;
-
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_INFO_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_info_ind(call_desc_t *cd)
-{
-}
-
-/*---------------------------------------------------------------------------*
- *	send MSG_INFO_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_proceeding_ind(call_desc_t *cd)
-{
-	struct mbuf *m;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_proceeding_ind_t))) != NULL)
-	{
-		msg_proceeding_ind_t *mp = (msg_proceeding_ind_t *)m->m_data;
-
-		mp->header.type = MSG_PROCEEDING_IND;
-		mp->header.cdid = cd->cdid;
-		mp->controller = cd->controller;
-		mp->channel = cd->channelid;
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *    send MSG_PACKET_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_packet_ind(int driver, int driver_unit, int dir, struct mbuf *pkt)
-{
-	struct mbuf *m;
-	int len = pkt->m_pkthdr.len;
-	unsigned char *ip = pkt->m_data;
-
-	if((m = i4b_Dgetmbuf(sizeof(msg_packet_ind_t))) != NULL)
-	{
-		msg_packet_ind_t *mp = (msg_packet_ind_t *)m->m_data;
-
-		mp->header.type = MSG_PACKET_IND;
-		mp->header.cdid = -1;
-		mp->driver = driver;
-		mp->driver_unit = driver_unit;
-		mp->direction = dir;
-		memcpy(mp->pktdata, ip,
-			len <MAX_PACKET_LOG ? len : MAX_PACKET_LOG);
-		i4bputqueue(m);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	link a driver(unit) to a B-channel(controller,unit,channel)
- *---------------------------------------------------------------------------*/
-static int
-i4b_link_bchandrvr(call_desc_t *cd)
-{
-	int t = ctrl_desc[cd->controller].ctrl_type;
-	
-	if(t < 0 || t >= CTRL_NUMTYPES || ctrl_types[t].get_linktab == NULL)
-	{
-			cd->ilt = NULL;
-	}
-	else
-	{
-		cd->ilt = ctrl_types[t].get_linktab(
-			ctrl_desc[cd->controller].unit,
-			cd->channelid);
-	}
-
-	switch(cd->driver)
-	{
-#if NI4BRBCH > 0
-		case BDRV_RBCH:
-			cd->dlt = rbch_ret_linktab(cd->driver_unit);
-			break;
-#endif
-		
-#if NI4BTEL > 0
-		case BDRV_TEL:
-			cd->dlt = tel_ret_linktab(cd->driver_unit);
-			break;
-#endif
-
-#if NI4BIPR > 0
-		case BDRV_IPR:
-			cd->dlt = ipr_ret_linktab(cd->driver_unit);
-			break;
-#endif
-
-#if NI4BISPPP > 0
-		case BDRV_ISPPP:
-			cd->dlt = i4bisppp_ret_linktab(cd->driver_unit);
-			break;
-#endif
-
-#if NIBC > 0
-		case BDRV_IBC:
-			cd->dlt = ibc_ret_linktab(cd->driver_unit);
-			break;
-#endif
-
-#if NI4BING > 0
-		case BDRV_ING:
-			cd->dlt = ing_ret_linktab(cd->driver_unit);
-			break;
-#endif
-
-		default:
-			cd->dlt = NULL;
-			break;
-	}
-
-	if(cd->dlt == NULL || cd->ilt == NULL)
-		return(-1);
-
-	if(t >= 0 && t < CTRL_NUMTYPES && ctrl_types[t].set_linktab != NULL)
-	{
-		ctrl_types[t].set_linktab(
-				ctrl_desc[cd->controller].unit,
-				cd->channelid,
-				cd->dlt);
-	}
-
-	switch(cd->driver)
-	{
-#if NI4BRBCH > 0
-		case BDRV_RBCH:
-			rbch_set_linktab(cd->driver_unit, cd->ilt);
-			break;
-#endif
-
-#if NI4BTEL > 0
-		case BDRV_TEL:
-			tel_set_linktab(cd->driver_unit, cd->ilt);
-			break;
-#endif
-
-#if NI4BIPR > 0
-		case BDRV_IPR:
-			ipr_set_linktab(cd->driver_unit, cd->ilt);
-			break;
-#endif
-
-#if NI4BISPPP > 0
-		case BDRV_ISPPP:
-			i4bisppp_set_linktab(cd->driver_unit, cd->ilt);
-			break;
-#endif
-
-#if NIBC > 0
-		case BDRV_IBC:
-			ibc_set_linktab(cd->driver_unit, cd->ilt);
-			break;
-#endif
-
-#if NI4BING > 0
-		case BDRV_ING:
-			ing_set_linktab(cd->driver_unit, cd->ilt);
-			break;
-#endif
-
-		default:
-			return(0);
-			break;
-	}
-
-	/* activate B channel */
-		
-	(*cd->ilt->bch_config)(cd->ilt->unit, cd->ilt->channel, cd->bprot, 1);
-
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	unlink a driver(unit) from a B-channel(controller,unit,channel)
- *---------------------------------------------------------------------------*/
-static void
-i4b_unlink_bchandrvr(call_desc_t *cd)
-{
-	int t = ctrl_desc[cd->controller].ctrl_type;
-
-	if(t < 0 || t >= CTRL_NUMTYPES || ctrl_types[t].get_linktab == NULL)
-	{
-		cd->ilt = NULL;
-		return;
-	}
-	else
-	{
-		cd->ilt = ctrl_types[t].get_linktab(
-				ctrl_desc[cd->controller].unit,
-				cd->channelid);
-	}
-	
-	/* deactivate B channel */
-		
-	(*cd->ilt->bch_config)(cd->ilt->unit, cd->ilt->channel, cd->bprot, 0);
-} 
-
-/*---------------------------------------------------------------------------
-
-	How shorthold mode works for OUTGOING connections
-	=================================================
-
-	|<---- unchecked-window ------->|<-checkwindow->|<-safetywindow>|
-
-idletime_state:      IST_NONCHK             IST_CHECK       IST_SAFE	
-	
-	|				|		|		|
-  time>>+-------------------------------+---------------+---------------+-...
-	|				|		|		|
-	|				|<--idle_time-->|<--earlyhup--->|
-	|<-----------------------unitlen------------------------------->|
-
-	
-	  unitlen - specifies the time a charging unit lasts
-	idle_time - specifies the thime the line must be idle at the
-		    end of the unit to be elected for hangup
-	 earlyhup - is the beginning of a timing safety zone before the
-		    next charging unit starts
-
-	The algorithm works as follows: lets assume the unitlen is 100
-	secons, idle_time is 40 seconds and earlyhup is 10 seconds.
-	The line then must be idle 50 seconds after the begin of the
-	current unit and it must then be quiet for 40 seconds. if it
-	has been quiet for this 40 seconds, the line is closed 10
-	seconds before the next charging unit starts. In case there was
-	any traffic within the idle_time, the line is not closed.
-	It does not matter whether there was any traffic between second
-	0 and second 50 or not.
-
-
-	How shorthold mode works for INCOMING connections
-	=================================================
-
-	it is just possible to specify a maximum idle time for incoming
-	connections, after this time of no activity on the line the line
-	is closed.
-	
----------------------------------------------------------------------------*/	
-
-static time_t
-i4b_get_idletime(call_desc_t *cd)
-{
-	switch (cd->driver) {
-#if NI4BISPPP > 0
-		case BDRV_ISPPP:
-			return i4bisppp_idletime(cd->driver_unit);
-		break;
-#endif
-		default:
-			return cd->last_active_time;
-		break;
-	}
-}
-/*---------------------------------------------------------------------------*
- *	B channel idle check timeout setup
- *---------------------------------------------------------------------------*/ 
-static void
-i4b_l4_setup_timeout(call_desc_t *cd)
-{
-	NDBGL4(L4_TIMO, "%ld: direction %d, shorthold algorithm %d",
-		(long)SECOND, cd->dir, cd->shorthold_data.shorthold_algorithm);
-	
-	cd->timeout_active = 0;
-	cd->idletime_state = IST_IDLE;
-	
-	if((cd->dir == DIR_INCOMING) && (cd->max_idle_time > 0))
-	{
-		/* incoming call: simple max idletime check */
-	
-		START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2);
-		cd->timeout_active = 1;
-		NDBGL4(L4_TIMO, "%ld: incoming-call, setup max_idle_time to %ld", (long)SECOND, (long)cd->max_idle_time);
-	}
-	else if((cd->dir == DIR_OUTGOING) && (cd->shorthold_data.idle_time > 0))
-	{
-		switch( cd->shorthold_data.shorthold_algorithm )
-		{
-			default:	/* fall into the old fix algorithm */
-			case SHA_FIXU:
-				i4b_l4_setup_timeout_fix_unit( cd );
-				break;
-				
-			case SHA_VARU:
-				i4b_l4_setup_timeout_var_unit( cd );
-				break;
-		}
-	}
-	else
-	{
-		NDBGL4(L4_TIMO, "no idle_timeout configured");
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	fixed unit algorithm B channel idle check timeout setup
- *---------------------------------------------------------------------------*/
-static void
-i4b_l4_setup_timeout_fix_unit(call_desc_t *cd)
-{
-	/* outgoing call */
-	
-	if((cd->shorthold_data.idle_time > 0) && (cd->shorthold_data.unitlen_time == 0))
-	{
-		/* outgoing call: simple max idletime check */
-		
-		START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2);
-		cd->timeout_active = 1;
-		NDBGL4(L4_TIMO, "%ld: outgoing-call, setup idle_time to %ld",
-			(long)SECOND, (long)cd->shorthold_data.idle_time);
-	}
-	else if((cd->shorthold_data.unitlen_time > 0) && (cd->shorthold_data.unitlen_time > (cd->shorthold_data.idle_time + cd->shorthold_data.earlyhup_time)))
-	{
-		/* outgoing call: full shorthold mode check */
-		
-		START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz*(cd->shorthold_data.unitlen_time - (cd->shorthold_data.idle_time + cd->shorthold_data.earlyhup_time)));
-		cd->timeout_active = 1;
-		cd->idletime_state = IST_NONCHK;
-		NDBGL4(L4_TIMO, "%ld: outgoing-call, start %ld sec nocheck window", 
-			(long)SECOND, (long)(cd->shorthold_data.unitlen_time - (cd->shorthold_data.idle_time + cd->shorthold_data.earlyhup_time)));
-
-		if(cd->aocd_flag == 0)
-		{
-			cd->units_type = CHARGE_CALC;
-			cd->cunits++;
-			i4b_l4_charging_ind(cd);
-		}
-	}
-	else
-	{
-		/* parms somehow got wrong .. */
-		
-		NDBGL4(L4_ERR, "%ld: ERROR: idletime[%ld]+earlyhup[%ld] > unitlength[%ld]!",
-			(long)SECOND, (long)cd->shorthold_data.idle_time, (long)cd->shorthold_data.earlyhup_time, (long)cd->shorthold_data.unitlen_time);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	variable unit algorithm B channel idle check timeout setup
- *---------------------------------------------------------------------------*/
-static void
-i4b_l4_setup_timeout_var_unit(call_desc_t *cd)
-{
-	/* outgoing call: variable unit idletime check */
-		
-	/*
-	 * start checking for an idle connect one second before the end of the unit.
-	 * The one second takes into account of rounding due to the driver only
-	 * using the seconds and not the uSeconds of the current time
-	 */
-	cd->idletime_state = IST_CHECK;	/* move directly to the checking state */
-
-	START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz * (cd->shorthold_data.unitlen_time - 1) );
-	cd->timeout_active = 1;
-	NDBGL4(L4_TIMO, "%ld: outgoing-call, var idle time - setup to %ld",
-		(long)SECOND, (long)cd->shorthold_data.unitlen_time);
-}
-
-
-/*---------------------------------------------------------------------------*
- *	B channel idle check timeout function
- *---------------------------------------------------------------------------*/ 
-void
-i4b_idle_check(call_desc_t *cd)
-{
-	int s;
-
-	if(cd->cdid == CDID_UNUSED)
-		return;
-	
-	s = SPLI4B();
-
-	/* failsafe */
-
-	if(cd->timeout_active == 0)
-	{
-		NDBGL4(L4_ERR, "ERROR: timeout_active == 0 !!!");
-	}
-	else
-	{	
-		cd->timeout_active = 0;
-	}
-	
-	/* incoming connections, simple idletime check */
-
-	if(cd->dir == DIR_INCOMING)
-	{
-		if((i4b_get_idletime(cd) + cd->max_idle_time) <= SECOND)
-		{
-			NDBGL4(L4_TIMO, "%ld: incoming-call, line idle timeout, disconnecting!", (long)SECOND);
-			(*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(cd->cdid,
-					(CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
-			i4b_l4_idle_timeout_ind(cd);
-		}
-		else
-		{
-			NDBGL4(L4_TIMO, "%ld: incoming-call, activity, last_active=%ld, max_idle=%ld", (long)SECOND, (long)i4b_get_idletime(cd), (long)cd->max_idle_time);
-
-			START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2);
-			cd->timeout_active = 1;
-		}
-	}
-
-	/* outgoing connections */
-
-	else if(cd->dir == DIR_OUTGOING)
-	{
-		switch( cd->shorthold_data.shorthold_algorithm )
-		{
-			case SHA_FIXU:
-				i4b_idle_check_fix_unit( cd );
-				break;
-			case SHA_VARU:
-				i4b_idle_check_var_unit( cd );
-				break;
-			default:
-				NDBGL4(L4_TIMO, "%ld: bad value for shorthold_algorithm of %d",
-					(long)SECOND, cd->shorthold_data.shorthold_algorithm);
-				i4b_idle_check_fix_unit( cd );
-				break;
-		}
-	}
-	splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- *	fixed unit algorithm B channel idle check timeout function
- *---------------------------------------------------------------------------*/
-static void
-i4b_idle_check_fix_unit(call_desc_t *cd)
-{
-
-	/* simple idletime calculation */
-
-	if((cd->shorthold_data.idle_time > 0) && (cd->shorthold_data.unitlen_time == 0))
-	{
-		if((i4b_get_idletime(cd) + cd->shorthold_data.idle_time) <= SECOND)
-		{
-			NDBGL4(L4_TIMO, "%ld: outgoing-call-st, idle timeout, disconnecting!", (long)SECOND);
-			(*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(cd->cdid, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
-			i4b_l4_idle_timeout_ind(cd);
-		}
-		else
-		{
-			NDBGL4(L4_TIMO, "%ld: outgoing-call-st, activity, last_active=%ld, max_idle=%ld",
-					(long)SECOND, (long)i4b_get_idletime(cd), (long)cd->shorthold_data.idle_time);
-			START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2);
-			cd->timeout_active = 1;
-		}
-	}
-
-	/* full shorthold mode calculation */
-
-	else if((cd->shorthold_data.unitlen_time > 0)
-	         && (cd->shorthold_data.unitlen_time > (cd->shorthold_data.idle_time + cd->shorthold_data.earlyhup_time)))
-	{
-		switch(cd->idletime_state)
-		{
-
-		case IST_NONCHK:	/* end of non-check time */
-
-			START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz*(cd->shorthold_data.idle_time));
-			cd->idletimechk_start = SECOND;
-			cd->idletime_state = IST_CHECK;
-			cd->timeout_active = 1;
-			NDBGL4(L4_TIMO, "%ld: outgoing-call, idletime check window reached!", (long)SECOND);
-			break;
-
-		case IST_CHECK:		/* end of idletime chk */
-			if((i4b_get_idletime(cd) > cd->idletimechk_start) &&
-			   (i4b_get_idletime(cd) <= SECOND))
-			{	/* activity detected */
-				START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz*(cd->shorthold_data.earlyhup_time));
-				cd->timeout_active = 1;
-				cd->idletime_state = IST_SAFE;
-				NDBGL4(L4_TIMO, "%ld: outgoing-call, activity at %ld, wait earlyhup-end", (long)SECOND, (long)i4b_get_idletime(cd));
-			}
-			else
-			{	/* no activity, hangup */
-				NDBGL4(L4_TIMO, "%ld: outgoing-call, idle timeout, last activity at %ld", (long)SECOND, (long)i4b_get_idletime(cd));
-				(*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(cd->cdid, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
-				i4b_l4_idle_timeout_ind(cd);
-				cd->idletime_state = IST_IDLE;
-			}
-			break;
-
-		case IST_SAFE:	/* end of earlyhup time */
-
-			START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz*(cd->shorthold_data.unitlen_time - (cd->shorthold_data.idle_time+cd->shorthold_data.earlyhup_time)));
-			cd->timeout_active = 1;
-			cd->idletime_state = IST_NONCHK;
-
-			if(cd->aocd_flag == 0)
-			{
-				cd->units_type = CHARGE_CALC;
-				cd->cunits++;
-				i4b_l4_charging_ind(cd);
-			}
-			
-			NDBGL4(L4_TIMO, "%ld: outgoing-call, earlyhup end, wait for idletime start", (long)SECOND);
-			break;
-
-		default:
-			NDBGL4(L4_ERR, "outgoing-call: invalid idletime_state value!");
-			cd->idletime_state = IST_IDLE;
-			break;
-		}
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	variable unit algorithm B channel idle check timeout function
- *---------------------------------------------------------------------------*/
-static void
-i4b_idle_check_var_unit(call_desc_t *cd)
-{
-	switch(cd->idletime_state)
-	{
-
-	/* see if there has been any activity within the last idle_time seconds */
-	case IST_CHECK:
-		if( i4b_get_idletime(cd) > (SECOND - cd->shorthold_data.idle_time))
-		{	/* activity detected */
-			/* check again in one second */		
-			cd->idle_timeout_handle =
-				START_TIMER (cd->idle_timeout_handle, i4b_idle_check, cd, hz);
-			cd->timeout_active = 1;
-			cd->idletime_state = IST_CHECK;
-			NDBGL4(L4_TIMO, "%ld: outgoing-call, var idle timeout - activity at %ld, continuing", (long)SECOND, (long)i4b_get_idletime(cd));
-		}
-		else
-		{	/* no activity, hangup */
-			NDBGL4(L4_TIMO, "%ld: outgoing-call, var idle timeout - last activity at %ld", (long)SECOND, (long)i4b_get_idletime(cd));
-			(*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(cd->cdid, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
-			i4b_l4_idle_timeout_ind(cd);
-			cd->idletime_state = IST_IDLE;
-		}
-		break;
-
-	default:
-		NDBGL4(L4_ERR, "outgoing-call: var idle timeout invalid idletime_state value!");
-		cd->idletime_state = IST_IDLE;
-		break;
-	}
-}
--- sys/i4b/layer4/i4b_l4.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_l4.h - kernel interface to userland header file
- *	---------------------------------------------------
- *
- * $FreeBSD: src/sys/i4b/layer4/i4b_l4.h,v 1.9 2005/01/06 22:18:21 imp Exp $
- *
- *      last edit-date: [Thu Oct 18 10:11:51 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L4_H_
-#define _I4B_L4_H_
-
-extern void i4bputqueue ( struct mbuf *m );
-extern void i4bputqueue_hipri(struct mbuf *m);
-extern void i4b_l4_accounting(int, int, int, int, int, int, int, int, int);
-extern void i4b_l4_alert_ind ( call_desc_t *cd );
-extern void i4b_l4_charging_ind( call_desc_t *cd );
-extern void i4b_l4_connect_active_ind ( call_desc_t *cd );
-extern void i4b_l4_connect_ind ( call_desc_t *cd );
-extern void i4b_l4_daemon_attached(void);
-extern void i4b_l4_daemon_detached(void);
-extern void i4b_l4_dialout( int driver, int driver_unit );
-extern void i4b_l4_dialoutnumber(int driver, int driver_unit, int cmdlen, char *cmd);
-extern void i4b_l4_keypad(int driver, int driver_unit, int cmdlen, char *cmd);
-extern void i4b_l4_disconnect_ind ( call_desc_t *cd );
-extern void i4b_l4_drvrdisc (int driver, int driver_unit );
-extern void i4b_l4_negcomplete( call_desc_t *cd );
-extern void i4b_l4_ifstate_changed( call_desc_t *cd, int new_state );
-extern void i4b_l4_idle_timeout_ind( call_desc_t *cd );
-extern void i4b_l4_info_ind ( call_desc_t *cd );
-extern void i4b_l4_packet_ind(int, int, int, struct mbuf *pkt);
-extern void i4b_l4_l12stat(int controller, int layer, int state);
-extern void i4b_l4_pdeact(int controller, int numactive);
-extern void i4b_l4_teiasg(int controller, int tei);
-extern void i4b_l4_status_ind ( call_desc_t *cd );
-extern void i4b_l4_proceeding_ind ( call_desc_t *cd );
-extern void i4b_idle_check(call_desc_t *cdp);
-extern call_desc_t * cd_by_cdid ( unsigned int cdid );
-extern call_desc_t * cd_by_unitcr ( int unit, int cr, int crf );
-extern void freecd_by_cd ( call_desc_t *cd );
-extern unsigned char get_rand_cr ( int unit );
-extern call_desc_t * reserve_cd ( void );
-extern void T400_start ( call_desc_t *cd );
-extern void T400_stop ( call_desc_t *cd );
-
-#endif /* _I4B_L4_H_ */
--- sys/i4b/layer4/i4b_i4bdrv.c
+++ /dev/null
@@ -1,865 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*---------------------------------------------------------------------------
- *
- *	i4b_i4bdrv.c - i4b userland interface driver
- *	--------------------------------------------
- *      last edit-date: [Sun Aug 11 12:42:46 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i4b/layer4/i4b_i4bdrv.c,v 1.43 2005/01/06 22:18:21 imp Exp $");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/ioccom.h>
-#include <sys/malloc.h>
-#include <sys/uio.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/selinfo.h>
-#include <net/if.h>
-
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#include <machine/i4b_cause.h>
-
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-#include <sys/poll.h>
-
-struct selinfo select_rd_info;
-
-static struct ifqueue i4b_rdqueue;
-static int openflag = 0;
-static int selflag = 0;
-static int readflag = 0;
-
-static	d_open_t	i4bopen;
-static	d_close_t	i4bclose;
-static	d_read_t	i4bread;
-static	d_ioctl_t	i4bioctl;
-static	d_poll_t	i4bpoll;
-
-
-static struct cdevsw i4b_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
-	.d_open =	i4bopen,
-	.d_close =	i4bclose,
-	.d_read =	i4bread,
-	.d_ioctl =	i4bioctl,
-	.d_poll =	i4bpoll,
-	.d_name =	"i4b",
-};
-
-static void i4battach(void *);
-PSEUDO_SET(i4battach, i4b_i4bdrv);
-
-/*---------------------------------------------------------------------------*
- *	interface attach routine
- *---------------------------------------------------------------------------*/
-static void
-i4battach(void *dummy)
-{
-	printf("i4b: ISDN call control device attached\n");
-
-	i4b_rdqueue.ifq_maxlen = IFQ_MAXLEN;
-
-	if(!mtx_initialized(&i4b_rdqueue.ifq_mtx))
-		mtx_init(&i4b_rdqueue.ifq_mtx, "i4b_rdqueue", NULL, MTX_DEF);
-
-	make_dev(&i4b_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "i4b");
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bopen - device driver open routine
- *---------------------------------------------------------------------------*/
-static int
-i4bopen(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	int x;
-	
-	if(minor(dev))
-		return(ENXIO);
-
-	if(openflag)
-		return(EBUSY);
-	
-	x = splimp();
-	openflag = 1;
-	i4b_l4_daemon_attached();
-	splx(x);
-	
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bclose - device driver close routine
- *---------------------------------------------------------------------------*/
-static int
-i4bclose(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
-	int x = splimp();	
-	openflag = 0;
-	i4b_l4_daemon_detached();
-	i4b_Dcleanifq(&i4b_rdqueue);
-	splx(x);
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bread - device driver read routine
- *---------------------------------------------------------------------------*/
-static int
-i4bread(struct cdev *dev, struct uio *uio, int ioflag)
-{
-	struct mbuf *m;
-	int x;
-	int error = 0;
-
-	if(minor(dev))
-		return(ENODEV);
-
-	x = splimp();
-	IF_LOCK(&i4b_rdqueue);
-	while(IF_QEMPTY(&i4b_rdqueue))
-	{
-		readflag = 1;
-
-		error = msleep( &i4b_rdqueue, &i4b_rdqueue.ifq_mtx,
-			(PZERO + 1) | PCATCH, "bird", 0);
-
-		if (error != 0) {
-			IF_UNLOCK(&i4b_rdqueue);
-			splx(x);
-			return error;
-		}
-	}
-
-	_IF_DEQUEUE(&i4b_rdqueue, m);
-	IF_UNLOCK(&i4b_rdqueue);
-
-	splx(x);
-		
-	if(m && m->m_len)
-		error = uiomove(m->m_data, m->m_len, uio);
-	else
-		error = EIO;
-		
-	if(m)
-		i4b_Dfreembuf(m);
-
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bioctl - device driver ioctl routine
- *---------------------------------------------------------------------------*/
-static int
-i4bioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
-{
-	call_desc_t *cd;
-	int error = 0;
-	
-	if(minor(dev))
-		return(ENODEV);
-
-	switch(cmd)
-	{
-		/* cdid request, reserve cd and return cdid */
-
-		case I4B_CDID_REQ:
-		{
-			msg_cdid_req_t *mir;
-			mir = (msg_cdid_req_t *)data;
-			cd = reserve_cd();
-			mir->cdid = cd->cdid;
-			break;
-		}
-		
-		/* connect request, dial out to remote */
-		
-		case I4B_CONNECT_REQ:
-		{
-			msg_connect_req_t *mcr;
-			mcr = (msg_connect_req_t *)data;	/* setup ptr */
-
-			if((cd = cd_by_cdid(mcr->cdid)) == NULL)/* get cd */
-			{
-				NDBGL4(L4_ERR, "I4B_CONNECT_REQ ioctl, cdid not found!"); 
-				error = EINVAL;
-				break;
-			}
-
-			/* prevent dialling on leased lines */
-			if(ctrl_desc[mcr->controller].protocol == PROTOCOL_D64S)
-			{
-				SET_CAUSE_TYPE(cd->cause_in, CAUSET_I4B);
-				SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_LLDIAL);
-				i4b_l4_disconnect_ind(cd);
-				freecd_by_cd(cd);
-				break;
-			}
-
-			cd->controller = mcr->controller;	/* fill cd */
-			cd->bprot = mcr->bprot;
-			cd->bcap = mcr->bcap;			
-			cd->driver = mcr->driver;
-			cd->driver_unit = mcr->driver_unit;
-			cd->cr = get_rand_cr(ctrl_desc[cd->controller].unit);
-
-			cd->shorthold_data.shorthold_algorithm = mcr->shorthold_data.shorthold_algorithm;
-			cd->shorthold_data.unitlen_time  = mcr->shorthold_data.unitlen_time;
-			cd->shorthold_data.idle_time     = mcr->shorthold_data.idle_time;
-			cd->shorthold_data.earlyhup_time = mcr->shorthold_data.earlyhup_time;
-
-			cd->last_aocd_time = 0;
-			if(mcr->unitlen_method == ULEN_METHOD_DYNAMIC)
-				cd->aocd_flag = 1;
-			else
-				cd->aocd_flag = 0;
-				
-			cd->cunits = 0;
-
-			cd->max_idle_time = 0;	/* this is outgoing */
-
-			cd->dir = DIR_OUTGOING;
-			
-			NDBGL4(L4_TIMO, "I4B_CONNECT_REQ times, algorithm=%ld unitlen=%ld idle=%ld earlyhup=%ld",
-					(long)cd->shorthold_data.shorthold_algorithm, (long)cd->shorthold_data.unitlen_time,
-					(long)cd->shorthold_data.idle_time, (long)cd->shorthold_data.earlyhup_time);
-
-			strcpy(cd->dst_telno, mcr->dst_telno);
-			strcpy(cd->src_telno, mcr->src_telno);
-
-			strcpy(cd->dst_subaddr, mcr->dst_subaddr);
-			strcpy(cd->src_subaddr, mcr->src_subaddr);
-
-			if(mcr->keypad[0] != '\0')
-				strcpy(cd->keypad, mcr->keypad);
-			else
-				cd->keypad[0] = '\0';
-				
-			cd->display[0] = '\0';
-
-			SET_CAUSE_TYPE(cd->cause_in, CAUSET_I4B);
-			SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NORMAL);
-			
-			switch(mcr->channel)
-			{
-				case CHAN_B1:
-				case CHAN_B2:
-					if(ctrl_desc[mcr->controller].bch_state[mcr->channel] != BCH_ST_FREE)
-						SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
-					break;
-
-				case CHAN_ANY:
-				{
-				    int i;
-				    for (i = 0;
-					 i < ctrl_desc[mcr->controller].nbch &&
-					 ctrl_desc[mcr->controller].bch_state[i] != BCH_ST_FREE;
-					 i++);
-				    if (i == ctrl_desc[mcr->controller].nbch)
-						SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
-				    /* else mcr->channel = i; XXX */
-				}
-					break;
-
-				default:
-					SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
-					break;
-			}
-
-			cd->channelid = mcr->channel;
-
-			cd->isdntxdelay = mcr->txdelay;
-			
-			/* check whether we have a pointer. Seems like */
-			/* this should be adequate. GJ 19.09.97 */
-			if(ctrl_desc[cd->controller].N_CONNECT_REQUEST == NULL)
-/*XXX*/				SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
-
-			if((GET_CAUSE_VAL(cd->cause_in)) != CAUSE_I4B_NORMAL)
-			{
-				i4b_l4_disconnect_ind(cd);
-				freecd_by_cd(cd);
-			}
-			else
-			{
-				(*ctrl_desc[cd->controller].N_CONNECT_REQUEST)(mcr->cdid);
-			}
-			break;
-		}
-		
-		/* connect response, accept/reject/ignore incoming call */
-		
-		case I4B_CONNECT_RESP:
-		{
-			msg_connect_resp_t *mcrsp;
-			
-			mcrsp = (msg_connect_resp_t *)data;
-
-			if((cd = cd_by_cdid(mcrsp->cdid)) == NULL)/* get cd */
-			{
-				NDBGL4(L4_ERR, "I4B_CONNECT_RESP ioctl, cdid not found!"); 
-				error = EINVAL;
-				break;
-			}
-
-			T400_stop(cd);
-
-			cd->driver = mcrsp->driver;
-			cd->driver_unit = mcrsp->driver_unit;
-			cd->max_idle_time = mcrsp->max_idle_time;
-
-			cd->shorthold_data.shorthold_algorithm = SHA_FIXU;
-			cd->shorthold_data.unitlen_time = 0;	/* this is incoming */
-			cd->shorthold_data.idle_time = 0;
-			cd->shorthold_data.earlyhup_time = 0;
-
-			cd->isdntxdelay = mcrsp->txdelay;			
-			
-			NDBGL4(L4_TIMO, "I4B_CONNECT_RESP max_idle_time set to %ld seconds", (long)cd->max_idle_time);
-
-			(*ctrl_desc[cd->controller].N_CONNECT_RESPONSE)(mcrsp->cdid, mcrsp->response, mcrsp->cause);
-			break;
-		}
-		
-		/* disconnect request, actively terminate connection */
-		
-		case I4B_DISCONNECT_REQ:
-		{
-			msg_discon_req_t *mdr;
-			
-			mdr = (msg_discon_req_t *)data;
-
-			if((cd = cd_by_cdid(mdr->cdid)) == NULL)/* get cd */
-			{
-				NDBGL4(L4_ERR, "I4B_DISCONNECT_REQ ioctl, cdid not found!"); 
-				error = EINVAL;
-				break;
-			}
-
-			/* preset causes with our cause */
-			cd->cause_in = cd->cause_out = mdr->cause;
-			
-			(*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(mdr->cdid, mdr->cause);
-			break;
-		}
-		
-		/* controller info request */
-
-		case I4B_CTRL_INFO_REQ:
-		{
-			msg_ctrl_info_req_t *mcir;
-			
-			mcir = (msg_ctrl_info_req_t *)data;
-			mcir->ncontroller = nctrl;
-
-			if(mcir->controller > nctrl)
-			{
-				mcir->ctrl_type = -1;
-				mcir->card_type = -1;
-			}
-			else
-			{
-				mcir->ctrl_type = 
-					ctrl_desc[mcir->controller].ctrl_type;
-				mcir->card_type = 
-					ctrl_desc[mcir->controller].card_type;
-				mcir->nbch =
-					ctrl_desc[mcir->controller].nbch;
-
-				if(ctrl_desc[mcir->controller].ctrl_type == CTRL_PASSIVE)
-					mcir->tei = ctrl_desc[mcir->controller].tei;
-				else
-					mcir->tei = -1;
-			}
-			break;
-		}
-		
-		/* dial response */
-		
-		case I4B_DIALOUT_RESP:
-		{
-			drvr_link_t *dlt = NULL;
-			msg_dialout_resp_t *mdrsp;
-			
-			mdrsp = (msg_dialout_resp_t *)data;
-
-			switch(mdrsp->driver)
-			{
-#if NI4BIPR > 0
-				case BDRV_IPR:
-					dlt = ipr_ret_linktab(mdrsp->driver_unit);
-					break;
-#endif					
-
-#if NI4BISPPP > 0
-				case BDRV_ISPPP:
-					dlt = i4bisppp_ret_linktab(mdrsp->driver_unit);
-					break;
-#endif
-
-#if NI4BTEL > 0
-				case BDRV_TEL:
-					dlt = tel_ret_linktab(mdrsp->driver_unit);
-					break;
-#endif
-
-#if NIBC > 0
-				case BDRV_IBC:
-					dlt = ibc_ret_linktab(mdrsp->driver_unit);
-					break;
-#endif
-
-#if NI4BING > 0
-				case BDRV_ING:
-					dlt = ing_ret_linktab(mdrsp->driver_unit);
-					break;
-#endif					
-			}
-
-			if(dlt != NULL)		
-				(*dlt->dial_response)(mdrsp->driver_unit, mdrsp->stat, mdrsp->cause);
-			break;
-		}
-		
-		/* update timeout value */
-		
-		case I4B_TIMEOUT_UPD:
-		{
-			msg_timeout_upd_t *mtu;
-			int x;
-			
-			mtu = (msg_timeout_upd_t *)data;
-
-			NDBGL4(L4_TIMO, "I4B_TIMEOUT_UPD ioctl, alg %d, unit %d, idle %d, early %d!",
-					mtu->shorthold_data.shorthold_algorithm, mtu->shorthold_data.unitlen_time,
-					mtu->shorthold_data.idle_time, mtu->shorthold_data.earlyhup_time); 
-
-			if((cd = cd_by_cdid(mtu->cdid)) == NULL)/* get cd */
-			{
-				NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, cdid not found!"); 
-				error = EINVAL;
-				break;
-			}
-
-			switch( mtu->shorthold_data.shorthold_algorithm )
-			{
-				case SHA_FIXU:
-					/*
-					 * For this algorithm unitlen_time,
-					 * idle_time and earlyhup_time are used.
-					 */
-
-					if(!(mtu->shorthold_data.unitlen_time >= 0 &&
-					     mtu->shorthold_data.idle_time >= 0    &&
-					     mtu->shorthold_data.earlyhup_time >= 0))
-					{
-						NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid args for fix unit algorithm!"); 
-						error = EINVAL;
-					}
-					break;
-	
-				case SHA_VARU:
-					/*
-					 * For this algorithm unitlen_time and
-					 * idle_time are used. both must be
-					 * positive integers. earlyhup_time is
-					 * not used and must be 0.
-					 */
-
-					if(!(mtu->shorthold_data.unitlen_time > 0 &&
-					     mtu->shorthold_data.idle_time >= 0   &&
-					     mtu->shorthold_data.earlyhup_time == 0))
-					{
-						NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid args for var unit algorithm!"); 
-						error = EINVAL;
-					}
-					break;
-	
-				default:
-					NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid algorithm!"); 
-					error = EINVAL;
-					break;
-			}
-
-			/*
-			 * any error set above requires us to break
-			 * out of the outer switch
-			 */
-			if(error != 0)
-				break;
-
-			x = SPLI4B();
-			cd->shorthold_data.shorthold_algorithm = mtu->shorthold_data.shorthold_algorithm;
-			cd->shorthold_data.unitlen_time = mtu->shorthold_data.unitlen_time;
-			cd->shorthold_data.idle_time = mtu->shorthold_data.idle_time;
-			cd->shorthold_data.earlyhup_time = mtu->shorthold_data.earlyhup_time;
-			splx(x);
-			break;
-		}
-			
-		/* soft enable/disable interface */
-		
-		case I4B_UPDOWN_IND:
-		{
-			msg_updown_ind_t *mui;
-			
-			mui = (msg_updown_ind_t *)data;
-
-#if NI4BIPR > 0
-			if(mui->driver == BDRV_IPR)
-			{
-				drvr_link_t *dlt;
-				dlt = ipr_ret_linktab(mui->driver_unit);
-				(*dlt->updown_ind)(mui->driver_unit, mui->updown);
-			}
-#endif
-			break;
-		}
-		
-		/* send ALERT request */
-		
-		case I4B_ALERT_REQ:
-		{
-			msg_alert_req_t *mar;
-			
-			mar = (msg_alert_req_t *)data;
-
-			if((cd = cd_by_cdid(mar->cdid)) == NULL)
-			{
-				NDBGL4(L4_ERR, "I4B_ALERT_REQ ioctl, cdid not found!"); 
-				error = EINVAL;
-				break;
-			}
-
-			T400_stop(cd);
-			
-			(*ctrl_desc[cd->controller].N_ALERT_REQUEST)(mar->cdid);
-
-			break;
-		}
-
-		/* version/release number request */
-		
-		case I4B_VR_REQ:
-                {
-			msg_vr_req_t *mvr;
-
-			mvr = (msg_vr_req_t *)data;
-
-			mvr->version = VERSION;
-			mvr->release = REL;
-			mvr->step = STEP;			
-			break;
-		}
-
-		/* set D-channel protocol for a controller */
-		
-		case I4B_PROT_IND:
-		{
-			msg_prot_ind_t *mpi;
-			
-			mpi = (msg_prot_ind_t *)data;
-
-			ctrl_desc[mpi->controller].protocol = mpi->protocol;
-			
-			break;
-		}
-		
-		/* Download request */
-
-		case I4B_CTRL_DOWNLOAD:
-		{
-			struct isdn_dr_prot *prots = NULL, *prots2 = NULL;
-			struct isdn_download_request *r =
-				(struct isdn_download_request*)data;
-			int i;
-
-			if (r->controller < 0 || r->controller >= nctrl)
-			{
-				error = ENODEV;
-				goto download_done;
-			}
-
-			if(!ctrl_desc[r->controller].N_DOWNLOAD)
-			{
-				error = ENODEV;
-				goto download_done;
-			}
-
-			prots = malloc(r->numprotos * sizeof(struct isdn_dr_prot),
-					M_DEVBUF, M_WAITOK);
-
-			prots2 = malloc(r->numprotos * sizeof(struct isdn_dr_prot),
-					M_DEVBUF, M_WAITOK);
-
-			if(!prots || !prots2)
-			{
-				error = ENOMEM;
-				goto download_done;
-			}
-
-			copyin(r->protocols, prots, r->numprotos * sizeof(struct isdn_dr_prot));
-
-			for(i = 0; i < r->numprotos; i++)
-			{
-				prots2[i].microcode = malloc(prots[i].bytecount, M_DEVBUF, M_WAITOK);
-				copyin(prots[i].microcode, prots2[i].microcode, prots[i].bytecount);
-				prots2[i].bytecount = prots[i].bytecount; 
-			}
-
-			error = ctrl_desc[r->controller].N_DOWNLOAD(
-						ctrl_desc[r->controller].unit,
-						r->numprotos, prots2);
-
-download_done:
-			if(prots2)
-			{
-				for(i = 0; i < r->numprotos; i++)
-				{
-					if(prots2[i].microcode)
-					{
-						free(prots2[i].microcode, M_DEVBUF);
-					}
-				}
-				free(prots2, M_DEVBUF);
-			}
-
-			if(prots)
-			{
-				free(prots, M_DEVBUF);
-			}
-			break;
-		}
-
-		/* Diagnostic request */
-
-		case I4B_ACTIVE_DIAGNOSTIC:
-		{
-			struct isdn_diagnostic_request req, *r =
-				(struct isdn_diagnostic_request*)data;
-
-			req.in_param = req.out_param = NULL;
-			if (r->controller < 0 || r->controller >= nctrl)
-			{
-				error = ENODEV;
-				goto diag_done;
-			}
-
-			if(!ctrl_desc[r->controller].N_DIAGNOSTICS)
-			{
-				error = ENODEV;
-				goto diag_done;
-			}
-
-			memcpy(&req, r, sizeof(req));
-
-			if(req.in_param_len)
-			{
-				/* XXX arbitrary limit */
-				if (req.in_param_len >
-				    I4B_ACTIVE_DIAGNOSTIC_MAXPARAMLEN) {
-				    	error = EINVAL;
-				    	goto diag_done;
-				}	
-
-				req.in_param = malloc(r->in_param_len, M_DEVBUF, M_WAITOK);
-
-				if(!req.in_param)
-				{
-					error = ENOMEM;
-					goto diag_done;
-				}
-				error = copyin(r->in_param, req.in_param, req.in_param_len);
-				if (error)
-					goto diag_done;
-			}
-
-			if(req.out_param_len)
-			{
-				req.out_param = malloc(r->out_param_len, M_DEVBUF, M_WAITOK);
-
-				if(!req.out_param)
-				{
-					error = ENOMEM;
-					goto diag_done;
-				}
-			}
-			
-			error = ctrl_desc[r->controller].N_DIAGNOSTICS(r->controller, &req);
-
-			if(!error && req.out_param_len)
-				error = copyout(req.out_param, r->out_param, req.out_param_len);
-
-diag_done:
-			if(req.in_param)
-				free(req.in_param, M_DEVBUF);
-				
-			if(req.out_param)
-				free(req.out_param, M_DEVBUF);
-
-			break;
-		}
-
-		/* default */
-		
-		default:
-			error = ENOTTY;
-			break;
-	}
-	
-	return(error);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bpoll - device driver poll routine
- *---------------------------------------------------------------------------*/
-static int
-i4bpoll(struct cdev *dev, int events, struct thread *td)
-{
-	int x;
-	
-	if(minor(dev))
-		return(ENODEV);
-
-	if((events & POLLIN) || (events & POLLRDNORM))
-	{
-		if(!IF_QEMPTY(&i4b_rdqueue))
-			return(1);
-
-		x = splimp();
-		selrecord(td, &select_rd_info);
-		selflag = 1;
-		splx(x);
-		return(0);
-	}
-	else if((events & POLLOUT) || (events & POLLWRNORM))
-	{
-		return(1);
-	}
-
-	return(0);
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bputqueue - put message into queue to userland
- *---------------------------------------------------------------------------*/
-void
-i4bputqueue(struct mbuf *m)
-{
-	int x;
-	
-	if(!openflag)
-	{
-		i4b_Dfreembuf(m);
-		return;
-	}
-
-	x = splimp();
-	
-	IF_LOCK(&i4b_rdqueue);
-	if(_IF_QFULL(&i4b_rdqueue))
-	{
-		struct mbuf *m1;
-		_IF_DEQUEUE(&i4b_rdqueue, m1);
-		i4b_Dfreembuf(m1);
-		NDBGL4(L4_ERR, "ERROR, queue full, removing entry!");
-	}
-
-	_IF_ENQUEUE(&i4b_rdqueue, m);
-	IF_UNLOCK(&i4b_rdqueue);
-
-	splx(x);	
-
-	if(readflag)
-	{
-		readflag = 0;
-		wakeup( &i4b_rdqueue);
-	}
-
-	if(selflag)
-	{
-		selflag = 0;
-		selwakeuppri(&select_rd_info, I4BPRI);
-	}
-}
-
-/*---------------------------------------------------------------------------*
- *	i4bputqueue_hipri - put message into front of queue to userland
- *---------------------------------------------------------------------------*/
-void
-i4bputqueue_hipri(struct mbuf *m)
-{
-	int x;
-	
-	if(!openflag)
-	{
-		i4b_Dfreembuf(m);
-		return;
-	}
-
-	x = splimp();
-	
-	IF_LOCK(&i4b_rdqueue);
-	if(_IF_QFULL(&i4b_rdqueue))
-	{
-		struct mbuf *m1;
-		_IF_DEQUEUE(&i4b_rdqueue, m1);
-		i4b_Dfreembuf(m1);
-		NDBGL4(L4_ERR, "ERROR, queue full, removing entry!");
-	}
-
-	_IF_PREPEND(&i4b_rdqueue, m);
-	IF_UNLOCK(&i4b_rdqueue);
-
-	splx(x);	
-
-	if(readflag)
-	{
-		readflag = 0;
-		wakeup( &i4b_rdqueue);
-	}
-
-	if(selflag)
-	{
-		selflag = 0;
-		selwakeuppri(&select_rd_info, I4BPRI);
-	}
-}


More information about the Midnightbsd-cvs mailing list