From 57bc8b41244c53f38345080f7e4b02bed8685f82 Mon Sep 17 00:00:00 2001 From: hm Date: Tue, 14 Dec 1999 20:48:35 +0000 Subject: update to isdn4bsd beta release 0.90 --- sys/i4b/driver/i4b_bsdi_ibc.c | 4 +- sys/i4b/driver/i4b_ctl.c | 75 +++- sys/i4b/driver/i4b_ipr.c | 29 +- sys/i4b/driver/i4b_isppp.c | 4 +- sys/i4b/driver/i4b_rbch.c | 382 +++++++++++----- sys/i4b/driver/i4b_tel.c | 71 ++- sys/i4b/driver/i4b_trace.c | 75 +++- sys/i4b/include/i4b_global.h | 10 +- sys/i4b/include/i4b_isdnq931.h | 4 +- sys/i4b/include/i4b_l1l2.h | 4 +- sys/i4b/include/i4b_l2l3.h | 4 +- sys/i4b/include/i4b_l3l4.h | 13 +- sys/i4b/include/i4b_mbuf.h | 4 +- sys/i4b/layer1/i4b_asuscom_ipac.c | 461 +++++--------------- sys/i4b/layer1/i4b_avm_a1.c | 451 ++++++++----------- sys/i4b/layer1/i4b_avm_fritz_pci.c | 865 ++++++++++++------------------------- sys/i4b/layer1/i4b_bchan.c | 77 +--- sys/i4b/layer1/i4b_ctx_s0P.c | 370 ++++++---------- sys/i4b/layer1/i4b_drn_ngo.c | 492 +++++---------------- sys/i4b/layer1/i4b_elsa_pcc16.c | 392 +++++++++++++++++ sys/i4b/layer1/i4b_elsa_qs1i.c | 335 ++------------ sys/i4b/layer1/i4b_elsa_qs1p.c | 393 +++++++---------- sys/i4b/layer1/i4b_hscx.c | 45 +- sys/i4b/layer1/i4b_hscx.h | 10 +- sys/i4b/layer1/i4b_ipac.h | 4 +- sys/i4b/layer1/i4b_isac.c | 59 +-- sys/i4b/layer1/i4b_isac.h | 9 +- sys/i4b/layer1/i4b_isic.c | 391 +++++++++++------ sys/i4b/layer1/i4b_isic_isa.c | 674 +++-------------------------- sys/i4b/layer1/i4b_isic_pci.c | 477 -------------------- sys/i4b/layer1/i4b_isic_pnp.c | 364 +++++++--------- sys/i4b/layer1/i4b_l1.c | 57 +-- sys/i4b/layer1/i4b_l1.h | 327 ++++---------- sys/i4b/layer1/i4b_l1fsm.c | 141 +++--- sys/i4b/layer1/i4b_siemens_isurf.c | 250 ++++------- sys/i4b/layer1/i4b_sws.c | 287 +++--------- sys/i4b/layer1/i4b_tel_s016.c | 406 +++++++---------- sys/i4b/layer1/i4b_tel_s0163.c | 579 ++++++++----------------- sys/i4b/layer1/i4b_tel_s08.c | 367 +++++++--------- sys/i4b/layer1/i4b_tel_s0P.c | 374 ---------------- sys/i4b/layer2/i4b_iframe.c | 13 +- sys/i4b/layer2/i4b_l2.c | 14 +- sys/i4b/layer2/i4b_l2.h | 8 +- sys/i4b/layer2/i4b_l2fsm.c | 10 +- sys/i4b/layer2/i4b_l2fsm.h | 6 +- sys/i4b/layer2/i4b_l2timer.c | 29 +- sys/i4b/layer2/i4b_lme.c | 10 +- sys/i4b/layer2/i4b_mbuf.c | 10 +- sys/i4b/layer2/i4b_sframe.c | 10 +- sys/i4b/layer2/i4b_tei.c | 14 +- sys/i4b/layer2/i4b_uframe.c | 10 +- sys/i4b/layer2/i4b_util.c | 10 +- sys/i4b/layer3/i4b_l2if.c | 10 +- sys/i4b/layer3/i4b_l3.h | 6 +- sys/i4b/layer3/i4b_l3fsm.c | 11 +- sys/i4b/layer3/i4b_l3fsm.h | 6 +- sys/i4b/layer3/i4b_l3timer.c | 34 +- sys/i4b/layer3/i4b_l4if.c | 14 +- sys/i4b/layer3/i4b_q931.c | 10 +- sys/i4b/layer3/i4b_q931.h | 8 +- sys/i4b/layer3/i4b_q932fac.c | 10 +- sys/i4b/layer3/i4b_q932fac.h | 6 +- sys/i4b/layer4/i4b_i4bdrv.c | 96 +++- sys/i4b/layer4/i4b_l4.c | 39 +- sys/i4b/layer4/i4b_l4.h | 7 +- sys/i4b/layer4/i4b_l4mgmt.c | 31 +- sys/i4b/layer4/i4b_l4timer.c | 14 +- 67 files changed, 3516 insertions(+), 6266 deletions(-) create mode 100644 sys/i4b/layer1/i4b_elsa_pcc16.c delete mode 100644 sys/i4b/layer1/i4b_isic_pci.c delete mode 100644 sys/i4b/layer1/i4b_tel_s0P.c (limited to 'sys') diff --git a/sys/i4b/driver/i4b_bsdi_ibc.c b/sys/i4b/driver/i4b_bsdi_ibc.c index 17d90c2..2134997 100644 --- a/sys/i4b/driver/i4b_bsdi_ibc.c +++ b/sys/i4b/driver/i4b_bsdi_ibc.c @@ -30,9 +30,11 @@ * i4b_bsdi_ibc.c - isdn4bsd kernel BSD/OS point to point driver * ------------------------------------------------------------- * + * $Id: i4b_bsdi_ibc.c,v 1.1 1999/04/23 08:35:07 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Fri Apr 23 10:27:57 1999] + * last edit-date: [Tue Dec 14 21:55:37 1999] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/driver/i4b_ctl.c b/sys/i4b/driver/i4b_ctl.c index 21d5d76..a8d50cc 100644 --- a/sys/i4b/driver/i4b_ctl.c +++ b/sys/i4b/driver/i4b_ctl.c @@ -27,9 +27,11 @@ * i4b_ctl.c - i4b system control port driver * ------------------------------------------ * + * $Id: i4b_ctl.c,v 1.30 1999/12/13 21:25:23 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Tue Jun 8 09:27:15 1999] + * last edit-date: [Mon Dec 13 21:38:15 1999] * *---------------------------------------------------------------------------*/ @@ -60,6 +62,18 @@ #include #ifdef __FreeBSD__ + +#if defined(__FreeBSD__) && __FreeBSD__ == 3 +#include "opt_devfs.h" +#endif + +#ifdef DEVFS +#include +#endif + +#endif /* __FreeBSD__ */ + +#ifdef __FreeBSD__ #include #include #elif defined(__bsdi__) @@ -93,22 +107,22 @@ static d_poll_t i4bctlpoll; #define CDEV_MAJOR 55 -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 static struct cdevsw i4bctl_cdevsw = { - /* open */ i4bctlopen, - /* close */ i4bctlclose, - /* read */ noread, - /* write */ nowrite, - /* ioctl */ i4bctlioctl, - /* poll */ POLLFIELD, - /* mmap */ nommap, - /* strategy */ nostrategy, - /* name */ "i4bctl", - /* maj */ CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ 0, - /* bmaj */ -1 + /* open */ i4bctlopen, + /* close */ i4bctlclose, + /* read */ noread, + /* write */ nowrite, + /* ioctl */ i4bctlioctl, + /* poll */ POLLFIELD, + /* mmap */ nommap, + /* strategy */ nostrategy, + /* name */ "i4bctl", + /* maj */ CDEV_MAJOR, + /* dump */ nodump, + /* psize */ nopsize, + /* flags */ 0, + /* bmaj */ -1 }; #else static struct cdevsw i4bctl_cdevsw = @@ -123,6 +137,12 @@ PSEUDO_SET(i4bctlattach, i4b_i4bctldrv); #define PDEVSTATIC static #endif /* __FreeBSD__ */ +#if defined(__FreeBSD__) && __FreeBSD__ == 3 +#ifdef DEVFS +static void *devfs_token; +#endif +#endif + #ifndef __FreeBSD__ #define PDEVSTATIC /* */ void i4bctlattach __P((void)); @@ -142,7 +162,7 @@ int i4bctlioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) static void i4bctlinit(void *unused) { -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 cdevsw_add(&i4bctl_cdevsw); #else dev_t dev = makedev(CDEV_MAJOR, 0); @@ -195,7 +215,20 @@ i4bctlattach() #ifndef HACK_NO_PSEUDO_ATTACH_MSG printf("i4bctl: ISDN system control port attached\n"); #endif + +#if defined(__FreeBSD__) +#if __FreeBSD__ == 3 + +#ifdef DEVFS + devfs_token = devfs_add_devswf(&i4bctl_cdevsw, 0, DV_CHR, + UID_ROOT, GID_WHEEL, 0600, + "i4bctl"); +#endif + +#else make_dev(&i4bctl_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "i4bctl"); +#endif +#endif } /*---------------------------------------------------------------------------* @@ -267,7 +300,7 @@ i4bctlioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case I4B_CTL_GET_HSCXSTAT: { hscxstat_t *hst; - struct isic_softc *sc; + struct l1_softc *sc; hst = (hscxstat_t *)data; if( hst->unit < 0 || @@ -282,7 +315,7 @@ i4bctlioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) #ifndef __FreeBSD__ sc = isic_find_sc(hst->unit); #else - sc = &isic_sc[hst->unit]; + sc = &l1_sc[hst->unit]; #endif hst->vfr = sc->sc_chan[hst->chan].stat_VFR; hst->rdo = sc->sc_chan[hst->chan].stat_RDO; @@ -296,7 +329,7 @@ i4bctlioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case I4B_CTL_CLR_HSCXSTAT: { hscxstat_t *hst; - struct isic_softc *sc; + struct l1_softc *sc; hst = (hscxstat_t *)data; if( hst->unit < 0 || @@ -311,7 +344,7 @@ i4bctlioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) #ifndef __FreeBSD__ sc = isic_find_sc(hst->unit); #else - sc = &isic_sc[hst->unit]; + sc = &l1_sc[hst->unit]; #endif sc->sc_chan[hst->chan].stat_VFR = 0; diff --git a/sys/i4b/driver/i4b_ipr.c b/sys/i4b/driver/i4b_ipr.c index b594451..e807412 100644 --- a/sys/i4b/driver/i4b_ipr.c +++ b/sys/i4b/driver/i4b_ipr.c @@ -27,9 +27,11 @@ * i4b_ipr.c - isdn4bsd IP over raw HDLC ISDN network driver * --------------------------------------------------------- * + * $Id: i4b_ipr.c,v 1.55 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Thu Jul 22 19:46:53 1999] + * last edit-date: [Mon Dec 13 21:38:51 1999] * *---------------------------------------------------------------------------* * @@ -194,6 +196,9 @@ struct ipr_softc { #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 */ @@ -330,6 +335,9 @@ i4biprattach() sc->sc_loutb = 0; sc->sc_fn = 1; #endif +#if IPR_LOG + sc->sc_log_first = IPR_LOG; +#endif #ifdef IPR_VJ #ifdef __FreeBSD__ @@ -456,6 +464,14 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, 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_if.if_lastchange); @@ -801,6 +817,10 @@ ipr_disconnect(int unit, void *cdp) #if I4BIPRACCT sc->sc_if.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); @@ -997,6 +1017,13 @@ error: /* 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 NBPFILTER > 0 || NBPF > 0 if(sc->sc_if.if_bpf) diff --git a/sys/i4b/driver/i4b_isppp.c b/sys/i4b/driver/i4b_isppp.c index e3dcac4..ea81bb6 100644 --- a/sys/i4b/driver/i4b_isppp.c +++ b/sys/i4b/driver/i4b_isppp.c @@ -34,9 +34,11 @@ * the "cx" driver for Cronyx's HDLC-in-hardware device). This driver * is only the glue between sppp and i4b. * + * $Id: i4b_isppp.c,v 1.35 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Sat Jul 24 15:23:04 1999] + * last edit-date: [Mon Dec 13 21:39:06 1999] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/driver/i4b_rbch.c b/sys/i4b/driver/i4b_rbch.c index 0822569..855f413 100644 --- a/sys/i4b/driver/i4b_rbch.c +++ b/sys/i4b/driver/i4b_rbch.c @@ -27,9 +27,11 @@ * i4b_rbch.c - device driver for raw B channel data * --------------------------------------------------- * + * $Id: i4b_rbch.c,v 1.48 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Fri Jul 9 09:37:02 1999] + * last edit-date: [Mon Dec 13 21:39:15 1999] * *---------------------------------------------------------------------------*/ @@ -54,6 +56,18 @@ extern cc_t ttydefchars; #define termioschars(t) memcpy((t)->c_cc, &ttydefchars, sizeof((t)->c_cc)) #endif +#ifdef __FreeBSD__ + +#if defined(__FreeBSD__) && __FreeBSD__ == 3 +#include "opt_devfs.h" +#endif + +#ifdef DEVFS +#include +#endif + +#endif /* __FreeBSD__ */ + #ifdef __NetBSD__ #include #define bootverbose 0 @@ -74,7 +88,6 @@ extern cc_t ttydefchars; #include #include -/* initialized by L4 */ #ifdef __bsdi__ #include @@ -90,15 +103,20 @@ int bootverbose = 0; #include #endif -#if (defined(__FreeBSD_version) && __FreeBSD_version >= 300001) +#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include #endif - 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 @@ -109,13 +127,31 @@ static struct rbch_softc { int sc_bprot; /* B-ch protocol used */ - call_desc_t *cd; /* Call Descriptor */ + 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 defined(__FreeBSD__) && __FreeBSD__ == 3 +#ifdef DEVFS + void *devfs_token; /* device filesystem */ +#endif +#endif + +#if I4BRBCHACCT +#if defined(__FreeBSD__) + struct callout_handle sc_callout; +#endif + int sc_iinb; /* isdn driver # of inbytes */ + int sc_ioutb; /* isdn driver # of outbytes */ + int sc_linb; /* last # of bytes rx'd */ + 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); @@ -143,11 +179,7 @@ PDEVSTATIC int i4brbchselect __P((dev_t dev, int rw, struct proc *p)); #if BSD > 199306 && defined(__FreeBSD__) #define PDEVSTATIC static -#if !defined(__FreeBSD_version) || __FreeBSD_version < 300003 -#define IOCTL_CMD_T int -#else #define IOCTL_CMD_T u_long -#endif PDEVSTATIC d_open_t i4brbchopen; PDEVSTATIC d_close_t i4brbchclose; @@ -165,22 +197,22 @@ PDEVSTATIC d_select_t i4brbchselect; #define CDEV_MAJOR 57 -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 static struct cdevsw i4brbch_cdevsw = { - /* open */ i4brbchopen, - /* close */ i4brbchclose, - /* read */ i4brbchread, - /* write */ i4brbchwrite, - /* ioctl */ i4brbchioctl, - /* poll */ POLLFIELD, - /* mmap */ nommap, - /* strategy */ nostrategy, - /* name */ "i4brbch", - /* maj */ CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ 0, - /* bmaj */ -1 + /* open */ i4brbchopen, + /* close */ i4brbchclose, + /* read */ i4brbchread, + /* write */ i4brbchwrite, + /* ioctl */ i4brbchioctl, + /* poll */ POLLFIELD, + /* mmap */ nommap, + /* strategy */ nostrategy, + /* name */ "i4brbch", + /* maj */ CDEV_MAJOR, + /* dump */ nodump, + /* psize */ nopsize, + /* flags */ 0, + /* bmaj */ -1 }; #else static struct cdevsw i4brbch_cdevsw = { @@ -203,7 +235,7 @@ PSEUDO_SET(i4brbchattach, i4b_rbch); static void i4brbchinit(void *unused) { -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 cdevsw_add(&i4brbch_cdevsw); #else dev_t dev = makedev(CDEV_MAJOR, 0); @@ -263,8 +295,29 @@ i4brbchattach() for(i=0; i < NI4BRBCH; i++) { +#if defined(__FreeBSD__) +#if __FreeBSD__ == 3 + +#ifdef DEVFS + rbch_softc[i].devfs_token = + devfs_add_devswf(&i4brbch_cdevsw, i, DV_CHR, + UID_ROOT, GID_WHEEL, 0600, + "i4brbch%d", i); +#endif + +#else make_dev(&i4brbch_cdevsw, i, UID_ROOT, GID_WHEEL, 0600, "i4brbch%d", i); +#endif +#endif + +#if I4BRBCHACCT +#if defined(__FreeBSD__) + callout_handle_init(&rbch_softc[i].sc_callout); +#endif + 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; rbch_softc[i].it_in.c_ispeed = rbch_softc[i].it_in.c_ospeed = 64000; @@ -287,7 +340,9 @@ i4brbchopen(dev_t dev, int flag, int fmt, struct proc *p) if(rbch_softc[unit].sc_devstate & ST_ISOPEN) return(EBUSY); +#if 0 rbch_clrq(unit); +#endif rbch_softc[unit].sc_devstate |= ST_ISOPEN; @@ -303,16 +358,16 @@ PDEVSTATIC int i4brbchclose(dev_t dev, int flag, int fmt, struct proc *p) { int unit = minor(dev); - - if (rbch_softc[unit].cd) { + struct rbch_softc *sc = &rbch_softc[unit]; + + if(sc->sc_devstate & ST_CONNECTED) i4b_l4_drvrdisc(BDRV_RBCH, unit); - rbch_softc[unit].cd = NULL; - } - rbch_softc[unit].sc_devstate &= ~ST_ISOPEN; + + sc->sc_devstate &= ~ST_ISOPEN; rbch_clrq(unit); - DBGL4(L4_RBCHDBG, "i4brbclose", ("unit %d, close\n", unit)); + DBGL4(L4_RBCHDBG, "i4brbclose", ("unit %d, closed\n", unit)); return(0); } @@ -324,32 +379,37 @@ PDEVSTATIC int i4brbchread(dev_t dev, struct uio *uio, int ioflag) { struct mbuf *m; - int s; int error = 0; int unit = minor(dev); struct ifqueue *iqp; + struct rbch_softc *sc = &rbch_softc[unit]; + + CRIT_VAR; DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, enter read\n", unit)); - if(!(rbch_softc[unit].sc_devstate & ST_ISOPEN)) + if(!(sc->sc_devstate & ST_ISOPEN)) { DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, read while not open\n", unit)); return(EIO); } - if((rbch_softc[unit].sc_devstate & ST_NOBLOCK)) { - if(!(rbch_softc[unit].sc_devstate & ST_CONNECTED)) + if((sc->sc_devstate & ST_NOBLOCK)) + { + if(!(sc->sc_devstate & ST_CONNECTED)) return(EWOULDBLOCK); - if(rbch_softc[unit].sc_bprot == BPROT_RHDLC) - iqp = &rbch_softc[unit].sc_hdlcq; + if(sc->sc_bprot == BPROT_RHDLC) + iqp = &sc->sc_hdlcq; else iqp = isdn_linktab[unit]->rx_queue; - if(IF_QEMPTY(iqp) && (rbch_softc[unit].sc_devstate & ST_ISOPEN)) + if(IF_QEMPTY(iqp) && (sc->sc_devstate & ST_ISOPEN)) return(EWOULDBLOCK); - } else { - while(!(rbch_softc[unit].sc_devstate & ST_CONNECTED)) + } + else + { + while(!(sc->sc_devstate & ST_CONNECTED)) { DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, wait read init\n", unit)); @@ -362,16 +422,16 @@ i4brbchread(dev_t dev, struct uio *uio, int ioflag) } } - if(rbch_softc[unit].sc_bprot == BPROT_RHDLC) - iqp = &rbch_softc[unit].sc_hdlcq; + if(sc->sc_bprot == BPROT_RHDLC) + iqp = &sc->sc_hdlcq; else iqp = isdn_linktab[unit]->rx_queue; - while(IF_QEMPTY(iqp) && (rbch_softc[unit].sc_devstate & ST_ISOPEN)) + while(IF_QEMPTY(iqp) && (sc->sc_devstate & ST_ISOPEN)) { - s = splimp(); - rbch_softc[unit].sc_devstate |= ST_RDWAITDATA; - splx(s); + CRIT_BEG; + sc->sc_devstate |= ST_RDWAITDATA; + CRIT_END; DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, wait read data\n", unit)); @@ -380,13 +440,13 @@ i4brbchread(dev_t dev, struct uio *uio, int ioflag) "rrbch", 0 )) != 0) { DBGL4(L4_RBCHDBG, "i4brbchread", ("unit %d, error %d tsleep read\n", unit, error)); - rbch_softc[unit].sc_devstate &= ~ST_RDWAITDATA; + sc->sc_devstate &= ~ST_RDWAITDATA; return(error); } } } - s = splimp(); + CRIT_BEG; IF_DEQUEUE(iqp, m); @@ -405,7 +465,7 @@ i4brbchread(dev_t dev, struct uio *uio, int ioflag) if(m) i4b_Bfreembuf(m); - splx(s); + CRIT_END; return(error); } @@ -417,25 +477,30 @@ PDEVSTATIC int i4brbchwrite(dev_t dev, struct uio * uio, int ioflag) { struct mbuf *m; - int s; int error = 0; int unit = minor(dev); + struct rbch_softc *sc = &rbch_softc[unit]; + CRIT_VAR; + DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, write\n", unit)); - if(!(rbch_softc[unit].sc_devstate & ST_ISOPEN)) + if(!(sc->sc_devstate & ST_ISOPEN)) { DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, write while not open\n", unit)); return(EIO); } - if((rbch_softc[unit].sc_devstate & ST_NOBLOCK)) { - if(!(rbch_softc[unit].sc_devstate & ST_CONNECTED)) + if((sc->sc_devstate & ST_NOBLOCK)) + { + if(!(sc->sc_devstate & ST_CONNECTED)) return(EWOULDBLOCK); - if(IF_QFULL(isdn_linktab[unit]->tx_queue) && (rbch_softc[unit].sc_devstate & ST_ISOPEN)) + if(IF_QFULL(isdn_linktab[unit]->tx_queue) && (sc->sc_devstate & ST_ISOPEN)) return(EWOULDBLOCK); - } else { - while(!(rbch_softc[unit].sc_devstate & ST_CONNECTED)) + } + else + { + while(!(sc->sc_devstate & ST_CONNECTED)) { DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, write wait init\n", unit)); @@ -444,48 +509,55 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag) "wrrbch", 0 ); if(error == ERESTART) return (ERESTART); - else if(error == EINTR) { - printf("\n ========= i4brbchwrite, EINTR during wait init ======== \n"); + else if(error == EINTR) + { + DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, EINTR during wait init\n", unit)); return(EINTR); - } else if(error) { + } + else if(error) + { DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, error %d tsleep init\n", unit, error)); return(error); } -/*XXX*/ tsleep((caddr_t) &rbch_softc[unit], TTIPRI | PCATCH, "xrbch", (hz*1)); + tsleep((caddr_t) &rbch_softc[unit], TTIPRI | PCATCH, "xrbch", (hz*1)); } - while(IF_QFULL(isdn_linktab[unit]->tx_queue) && (rbch_softc[unit].sc_devstate & ST_ISOPEN)) + while(IF_QFULL(isdn_linktab[unit]->tx_queue) && (sc->sc_devstate & ST_ISOPEN)) { - s = splimp(); - rbch_softc[unit].sc_devstate |= ST_WRWAITEMPTY; - splx(s); + CRIT_BEG; + sc->sc_devstate |= ST_WRWAITEMPTY; + CRIT_END; DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, write queue full\n", unit)); if ((error = tsleep((caddr_t) &isdn_linktab[unit]->tx_queue, TTIPRI | PCATCH, "wrbch", 0)) != 0) { - rbch_softc[unit].sc_devstate &= ~ST_WRWAITEMPTY; - if(error == ERESTART) { + sc->sc_devstate &= ~ST_WRWAITEMPTY; + if(error == ERESTART) + { return(ERESTART); - } else if(error == EINTR) { - printf("\n ========= i4brbchwrite, EINTR during wait write ======== \n"); + } + else if(error == EINTR) + { + DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, EINTR during wait write\n", unit)); return(error); - } else if(error) { - DBGL4(L4_RBCHDBG, "i4brbchwrite", - ("unit %d, error %d tsleep write\n", unit, error)); + } + else if(error) + { + DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, error %d tsleep write\n", unit, error)); return(error); } } } } - s = splimp(); + CRIT_BEG; - if(!(rbch_softc[unit].sc_devstate & ST_ISOPEN)) + if(!(sc->sc_devstate & ST_ISOPEN)) { DBGL4(L4_RBCHDBG, "i4brbchwrite", ("unit %d, not open anymore\n", unit)); - splx(s); + CRIT_END; return(EIO); } @@ -509,7 +581,7 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag) (*isdn_linktab[unit]->bch_tx_start)(isdn_linktab[unit]->unit, isdn_linktab[unit]->channel); } - splx(s); + CRIT_END; return(error); } @@ -518,11 +590,12 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag) * rbch device ioctl handlibg *---------------------------------------------------------------------------*/ PDEVSTATIC int -i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc* p) +i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc *p) { int error = 0; int unit = minor(dev); - + struct rbch_softc *sc = &rbch_softc[unit]; + switch(cmd) { case FIOASYNC: /* Set async mode */ @@ -540,17 +613,17 @@ i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc* p) if (*(int *)data) { DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, setting non-blocking mode\n", unit)); - rbch_softc[unit].sc_devstate |= ST_NOBLOCK; + sc->sc_devstate |= ST_NOBLOCK; } else { DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, clearing non-blocking mode\n", unit)); - rbch_softc[unit].sc_devstate &= ~ST_NOBLOCK; + sc->sc_devstate &= ~ST_NOBLOCK; } break; case TIOCCDTR: /* Clear DTR */ - if(rbch_softc[unit].sc_devstate & ST_CONNECTED) + if(sc->sc_devstate & ST_CONNECTED) { DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, disconnecting for DTR down\n", unit)); i4b_l4_drvrdisc(BDRV_RBCH, unit); @@ -581,12 +654,12 @@ i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc* p) break; case TIOCGETA: /* Get termios struct */ - *(struct termios *)data = rbch_softc[unit].it_in; + *(struct termios *)data = sc->it_in; break; case TIOCMGET: *(int *)data = TIOCM_LE|TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR; - if (rbch_softc[unit].sc_devstate & ST_CONNECTED) + if (sc->sc_devstate & ST_CONNECTED) *(int *)data |= TIOCM_CD; break; @@ -621,12 +694,13 @@ i4brbchpoll(dev_t dev, int events, struct proc *p) 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(!(rbch_softc[unit].sc_devstate & ST_ISOPEN)) + if(!(sc->sc_devstate & ST_ISOPEN)) { splx(s); return(POLLNVAL); @@ -638,7 +712,7 @@ i4brbchpoll(dev_t dev, int events, struct proc *p) */ if((events & (POLLOUT|POLLWRNORM)) && - (rbch_softc[unit].sc_devstate & ST_CONNECTED) && + (sc->sc_devstate & ST_CONNECTED) && !IF_QFULL(isdn_linktab[unit]->tx_queue)) { revents |= (events & (POLLOUT|POLLWRNORM)); @@ -647,12 +721,12 @@ i4brbchpoll(dev_t dev, int events, struct proc *p) /* ... while reads are OK if we have any data */ if((events & (POLLIN|POLLRDNORM)) && - (rbch_softc[unit].sc_devstate & ST_CONNECTED)) + (sc->sc_devstate & ST_CONNECTED)) { struct ifqueue *iqp; - if(rbch_softc[unit].sc_bprot == BPROT_RHDLC) - iqp = &rbch_softc[unit].sc_hdlcq; + if(sc->sc_bprot == BPROT_RHDLC) + iqp = &sc->sc_hdlcq; else iqp = isdn_linktab[unit]->rx_queue; @@ -661,7 +735,7 @@ i4brbchpoll(dev_t dev, int events, struct proc *p) } if(revents == 0) - selrecord(p, &rbch_softc[unit].selp); + selrecord(p, &sc->selp); splx(s); return(revents); @@ -676,26 +750,27 @@ PDEVSTATIC int i4brbchselect(dev_t dev, int rw, struct proc *p) { int unit = minor(dev); + struct rbch_softc *sc = &rbch_softc[unit]; int s; s = splhigh(); - if(!(rbch_softc[unit].sc_devstate & ST_ISOPEN)) + if(!(sc->sc_devstate & ST_ISOPEN)) { splx(s); DBGL4(L4_RBCHDBG, "i4brbchselect", ("unit %d, not open anymore\n", unit)); return(1); } - if(rbch_softc[unit].sc_devstate & ST_CONNECTED) + if(sc->sc_devstate & ST_CONNECTED) { struct ifqueue *iqp; switch(rw) { case FREAD: - if(rbch_softc[unit].sc_bprot == BPROT_RHDLC) - iqp = &rbch_softc[unit].sc_hdlcq; + if(sc->sc_bprot == BPROT_RHDLC) + iqp = &sc->sc_hdlcq; else iqp = isdn_linktab[unit]->rx_queue; @@ -719,13 +794,55 @@ i4brbchselect(dev_t dev, int rw, struct proc *p) return 0; } } - selrecord(p, &rbch_softc[unit].selp); + selrecord(p, &sc->selp); splx(s); return(0); } #endif /* OS_USES_POLL */ +#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); + } +#if defined(__FreeBSD__) + sc->sc_callout = +#endif + timeout((TIMEOUT_FUNC_T)rbch_timeout, + (void *)sc, I4BRBCHACCTINTVL*hz); +} +#endif /* I4BRBCHACCT */ + /*===========================================================================* * ISDN INTERFACE ROUTINES *===========================================================================*/ @@ -737,15 +854,31 @@ static void rbch_connect(int unit, void *cdp) { call_desc_t *cd = (call_desc_t *)cdp; + struct rbch_softc *sc = &rbch_softc[unit]; - rbch_softc[unit].sc_bprot = cd->bprot; - - if(!(rbch_softc[unit].sc_devstate & ST_CONNECTED)) + 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; + +#if defined(__FreeBSD__) + sc->sc_callout = +#endif + timeout((TIMEOUT_FUNC_T)rbch_timeout, + (void *)sc, I4BRBCHACCTINTVL*hz); + } +#endif + if(!(sc->sc_devstate & ST_CONNECTED)) { DBGL4(L4_RBCHDBG, "rbch_connect", ("unit %d, wakeup\n", unit)); - rbch_softc[unit].sc_devstate |= ST_CONNECTED; - rbch_softc[unit].cd = cdp; - wakeup((caddr_t) &rbch_softc[unit]); + sc->sc_devstate |= ST_CONNECTED; + sc->sc_cd = cdp; + wakeup((caddr_t)sc); } } @@ -755,11 +888,39 @@ rbch_connect(int unit, void *cdp) static void rbch_disconnect(int unit, void *cdp) { - /* call_desc_t *cd = (call_desc_t *)cdp; */ + call_desc_t *cd = (call_desc_t *)cdp; + struct rbch_softc *sc = &rbch_softc[unit]; + + CRIT_VAR; + + if(cd != sc->sc_cd) + { + DBGL4(L4_RBCHDBG, "rbch_disconnect", ("rbch%d: channel %d not active\n", + cd->driver_unit, cd->channelid)); + return; + } - DBGL4(L4_RBCHDBG, "rbch_disconnect", ("unit %d, deinit\n", unit)); - rbch_softc[unit].sc_devstate &= ~ST_CONNECTED; - rbch_softc[unit].cd = NULL; + CRIT_BEG; + + DBGL4(L4_RBCHDBG, "rbch_disconnect", ("unit %d, disconnect\n", 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); + +#if defined(__FreeBSD__) + untimeout((TIMEOUT_FUNC_T)rbch_timeout, + (void *)sc, sc->sc_callout); +#else + untimeout((TIMEOUT_FUNC_T)rbch_timeout, (void *)sc); +#endif + +#endif + CRIT_END; } /*---------------------------------------------------------------------------* @@ -847,8 +1008,8 @@ rbch_tx_queue_empty(int unit) static void rbch_activity(int unit, int rxtx) { - if (rbch_softc[unit].cd) - rbch_softc[unit].cd->last_active_time = SECOND; + if (rbch_softc[unit].sc_cd) + rbch_softc[unit].sc_cd->last_active_time = SECOND; selwakeup(&rbch_softc[unit].selp); } @@ -858,14 +1019,15 @@ rbch_activity(int unit, int rxtx) static void rbch_clrq(int unit) { - int x; struct mbuf *m; - + CRIT_VAR; + for(;;) { - x = splimp(); + CRIT_BEG; IF_DEQUEUE(&rbch_softc[unit].sc_hdlcq, m); - splx(x); + CRIT_END; + if(m) m_freem(m); else diff --git a/sys/i4b/driver/i4b_tel.c b/sys/i4b/driver/i4b_tel.c index 4c9bf84..4cd1667 100644 --- a/sys/i4b/driver/i4b_tel.c +++ b/sys/i4b/driver/i4b_tel.c @@ -27,9 +27,11 @@ * i4b_tel.c - device driver for ISDN telephony * -------------------------------------------- * + * $Id: i4b_tel.c,v 1.47 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Sat Aug 28 22:28:25 1999] + * last edit-date: [Mon Dec 13 21:39:26 1999] * *---------------------------------------------------------------------------*/ @@ -42,7 +44,7 @@ #include #include -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 || defined(__NetBSD__) +#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__) #include #include #else @@ -59,6 +61,18 @@ #include #include +#ifdef __FreeBSD__ + +#if defined(__FreeBSD__) && __FreeBSD__ == 3 +#include "opt_devfs.h" +#endif + +#ifdef DEVFS +#include +#endif + +#endif /* __FreeBSD__ */ + #ifdef __bsdi__ #include #endif @@ -122,6 +136,13 @@ typedef struct { #define ST_WRWAITEMPTY 0x08 /* userland write waiting */ struct selinfo selp; /* select / poll */ + +#if defined(__FreeBSD__) && __FreeBSD__ == 3 +#ifdef DEVFS + void *devfs_token; /* token for DEVFS */ +#endif +#endif + } tel_sc_t; static tel_sc_t tel_sc[NI4BTEL][NOFUNCS]; @@ -182,22 +203,22 @@ PDEVSTATIC d_select_t i4btelsel; #define CDEV_MAJOR 56 -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 static struct cdevsw i4btel_cdevsw = { - /* open */ i4btelopen, - /* close */ i4btelclose, - /* read */ i4btelread, - /* write */ i4btelwrite, - /* ioctl */ i4btelioctl, - /* poll */ POLLFIELD, - /* mmap */ nommap, - /* strategy */ nostrategy, - /* name */ "i4btel", - /* maj */ CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ 0, - /* bmaj */ -1 + /* open */ i4btelopen, + /* close */ i4btelclose, + /* read */ i4btelread, + /* write */ i4btelwrite, + /* ioctl */ i4btelioctl, + /* poll */ POLLFIELD, + /* mmap */ nommap, + /* strategy */ nostrategy, + /* name */ "i4btel", + /* maj */ CDEV_MAJOR, + /* dump */ nodump, + /* psize */ nopsize, + /* flags */ 0, + /* bmaj */ -1 }; #else static struct cdevsw i4btel_cdevsw = { @@ -222,7 +243,7 @@ PSEUDO_SET(i4btelattach, i4b_tel); PDEVSTATIC void i4btelinit(void *unused) { -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 cdevsw_add(&i4btel_cdevsw); #else dev_t dev = makedev(CDEV_MAJOR, 0); @@ -294,6 +315,18 @@ i4btelattach() tel_sc[i][j].wcvttab = 0; tel_sc[i][j].result = 0; +#if defined(__FreeBSD__) +#if __FreeBSD__ == 3 + +#ifdef DEVFS + +/* XXX */ tel_sc[i][j].devfs_token + = devfs_add_devswf(&i4btel_cdevsw, i, DV_CHR, + UID_ROOT, GID_WHEEL, 0600, + "i4btel%d", i); +#endif + +#else switch(j) { case FUNCTEL: /* normal i4btel device */ @@ -308,6 +341,8 @@ i4btelattach() 0600, "i4bteld%d", i); break; } +#endif +#endif } tel_init_linktab(i); } diff --git a/sys/i4b/driver/i4b_trace.c b/sys/i4b/driver/i4b_trace.c index d931fab..6324dbe 100644 --- a/sys/i4b/driver/i4b_trace.c +++ b/sys/i4b/driver/i4b_trace.c @@ -27,9 +27,11 @@ * i4btrc - device driver for trace data read device * --------------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_trace.c,v 1.24 1999/12/13 21:25:24 hm Exp $ + * + * last edit-date: [Mon Dec 13 21:39:35 1999] * - * last edit-date: [Tue Jun 1 12:15:40 1999] + * $FreeBSD$ * * NOTE: the code assumes that SPLI4B >= splimp ! * @@ -69,43 +71,60 @@ #include #ifdef __FreeBSD__ + +#ifdef DEVFS +#include +#endif + #include #include + #else + #include #include -#endif -#ifndef __FreeBSD__ -#define memcpy(d,s,l) bcopy(s,d,l) #endif #include #include #include +#ifndef __FreeBSD__ +#define memcpy(d,s,l) bcopy(s,d,l) +#endif + static struct ifqueue trace_queue[NI4BTRC]; static int device_state[NI4BTRC]; #define ST_IDLE 0x00 #define ST_ISOPEN 0x01 #define ST_WAITDATA 0x02 +#if defined(__FreeBSD__) && __FreeBSD__ == 3 +#ifdef DEVFS +static void *devfs_token[NI4BTRC]; +#endif +#endif + static int analyzemode = 0; static int rxunit = -1; static int txunit = -1; static int outunit = -1; #ifndef __FreeBSD__ + #define PDEVSTATIC /* - not static - */ void i4btrcattach __P((void)); int i4btrcopen __P((dev_t dev, int flag, int fmt, struct proc *p)); int i4btrcclose __P((dev_t dev, int flag, int fmt, struct proc *p)); int i4btrcread __P((dev_t dev, struct uio * uio, int ioflag)); + #ifdef __bsdi__ int i4btrcioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)); #else int i4btrcioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)); #endif + #endif #if BSD > 199306 && defined(__FreeBSD__) @@ -124,22 +143,22 @@ static d_poll_t i4btrcpoll; #define CDEV_MAJOR 59 -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 static struct cdevsw i4btrc_cdevsw = { - /* open */ i4btrcopen, - /* close */ i4btrcclose, - /* read */ i4btrcread, - /* write */ nowrite, - /* ioctl */ i4btrcioctl, - /* poll */ POLLFIELD, - /* mmap */ nommap, - /* strategy */ nostrategy, - /* name */ "i4btrc", - /* maj */ CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ 0, - /* bmaj */ -1 + /* open */ i4btrcopen, + /* close */ i4btrcclose, + /* read */ i4btrcread, + /* write */ nowrite, + /* ioctl */ i4btrcioctl, + /* poll */ POLLFIELD, + /* mmap */ nommap, + /* strategy */ nostrategy, + /* name */ "i4btrc", + /* maj */ CDEV_MAJOR, + /* dump */ nodump, + /* psize */ nopsize, + /* flags */ 0, + /* bmaj */ -1 }; #else static struct cdevsw i4btrc_cdevsw = { @@ -155,7 +174,7 @@ static struct cdevsw i4btrc_cdevsw = { static void i4btrcinit(void *unused) { -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 cdevsw_add(&i4btrc_cdevsw); #else dev_t dev = makedev(CDEV_MAJOR, 0); @@ -221,8 +240,22 @@ i4btrcattach() for(i=0; i < NI4BTRC; i++) { + +#if defined(__FreeBSD__) +#if __FreeBSD__ < 4 + +#ifdef DEVFS + devfs_token[i] + = devfs_add_devswf(&i4btrc_cdevsw, i, DV_CHR, + UID_ROOT, GID_WHEEL, 0600, + "i4btrc%d", i); +#endif + +#else make_dev(&i4btrc_cdevsw, i, UID_ROOT, GID_WHEEL, 0600, "i4btrc%d", i); +#endif +#endif trace_queue[i].ifq_maxlen = IFQ_MAXLEN; device_state[i] = ST_IDLE; } diff --git a/sys/i4b/include/i4b_global.h b/sys/i4b/include/i4b_global.h index c5c852d..4b8bfb6 100644 --- a/sys/i4b/include/i4b_global.h +++ b/sys/i4b/include/i4b_global.h @@ -27,9 +27,11 @@ * i4b_global.h - i4b global include file * -------------------------------------- * + * $Id: i4b_global.h,v 1.23 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Mon Apr 26 11:10:26 1999] + * last edit-date: [Mon Dec 13 21:44:17 1999] * *---------------------------------------------------------------------------*/ @@ -46,6 +48,12 @@ #ifdef __FreeBSD__ #include + +#if defined(__FreeBSD_version) && __FreeBSD_version >= 400000 && __FreeBSD_version < 400011 +#error "Unsupported FreeBSD-current version," +#error "you need a FreeBSD-current >= 400011" +#endif + #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 #define TIMEOUT_FUNC_T timeout_t * diff --git a/sys/i4b/include/i4b_isdnq931.h b/sys/i4b/include/i4b_isdnq931.h index 0a85a70..76c84f1 100644 --- a/sys/i4b/include/i4b_isdnq931.h +++ b/sys/i4b/include/i4b_isdnq931.h @@ -27,9 +27,11 @@ * i4b_isdnq931.h - DSS1 layer 3 message types * ------------------------------------------- * + * $Id: i4b_isdnq931.h,v 1.6 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Sun Feb 14 10:04:01 1999] + * last edit-date: [Mon Dec 13 21:44:28 1999] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/include/i4b_l1l2.h b/sys/i4b/include/i4b_l1l2.h index 4386b7b..704fc5d 100644 --- a/sys/i4b/include/i4b_l1l2.h +++ b/sys/i4b/include/i4b_l1l2.h @@ -27,9 +27,11 @@ * i4b_l1l2.h - i4b layer 1 / layer 2 interactions * --------------------------------------------------- * + * $Id: i4b_l1l2.h,v 1.9 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Sun Feb 14 10:04:07 1999] + * last edit-date: [Mon Dec 13 21:44:39 1999] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/include/i4b_l2l3.h b/sys/i4b/include/i4b_l2l3.h index 6dee953..d25bc7b 100644 --- a/sys/i4b/include/i4b_l2l3.h +++ b/sys/i4b/include/i4b_l2l3.h @@ -27,9 +27,11 @@ * i4b_l2l3.h - i4b layer 2 / layer 3 interactions * ----------------------------------------------- * + * $Id: i4b_l2l3.h,v 1.7 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Sun Feb 14 10:04:13 1999] + * last edit-date: [Mon Dec 13 21:44:47 1999] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/include/i4b_l3l4.h b/sys/i4b/include/i4b_l3l4.h index 9a09838..622baf2 100644 --- a/sys/i4b/include/i4b_l3l4.h +++ b/sys/i4b/include/i4b_l3l4.h @@ -27,9 +27,11 @@ * i4b_l3l4.h - layer 3 / layer 4 interface * ------------------------------------------ * + * $Id: i4b_l3l4.h,v 1.27 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Wed Mar 17 16:16:40 1999] + * last edit-date: [Mon Dec 13 21:44:56 1999] * *---------------------------------------------------------------------------*/ @@ -112,6 +114,13 @@ void tel_set_linktab(int unit, isdn_link_t *ilt); drvr_link_t *i4bisppp_ret_linktab(int unit); void i4bisppp_set_linktab(int unit, isdn_link_t *ilt); +#ifdef __bsdi__ +/* global linktab functions for IBC userland driver */ + +drvr_link_t *ibc_ret_linktab(int unit); +void ibc_set_linktab(int unit, isdn_link_t *ilt); +#endif + /*---------------------------------------------------------------------------* * this structure describes one call/connection on one B-channel * and all its parameters @@ -229,6 +238,8 @@ typedef struct 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 diff --git a/sys/i4b/include/i4b_mbuf.h b/sys/i4b/include/i4b_mbuf.h index 0604c33..b7d8984 100644 --- a/sys/i4b/include/i4b_mbuf.h +++ b/sys/i4b/include/i4b_mbuf.h @@ -27,9 +27,11 @@ * i4b - mbuf handling support routines * -------------------------------------- * + * $Id: i4b_mbuf.h,v 1.8 1999/12/13 21:25:24 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Sun Feb 14 10:04:26 1999] + * last edit-date: [Mon Dec 13 21:45:05 1999] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/layer1/i4b_asuscom_ipac.c b/sys/i4b/layer1/i4b_asuscom_ipac.c index 670e217..73639b5 100644 --- a/sys/i4b/layer1/i4b_asuscom_ipac.c +++ b/sys/i4b/layer1/i4b_asuscom_ipac.c @@ -39,63 +39,41 @@ * code is modeled after Linux i4l driver written by Karsten * Keil. * + * $Id: i4b_asuscom_ipac.c,v 1.4 1999/12/13 21:25:26 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Mon May 31 20:53:17 EEST 1999] + * last edit-date: [Mon Dec 13 21:58:27 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) #include "isic.h" #include "opt_i4b.h" -#else -#define NISIC 1 -#endif -#define NPNP 1 -#if (NISIC > 0) && (NPNP > 0) && defined(ASUSCOM_IPAC) +#if (NISIC > 0) && defined (ASUSCOM_IPAC) #include +#include #include #include #include #include -#include -#ifdef __FreeBSD__ -#if __FreeBSD__ >= 3 -#include -#else -#include -#endif #include -#include -#include -#else -#include -#include -#endif -#ifdef __FreeBSD__ +#include + #include #include -#else -#include -#include -#endif #include #include #include #include +#include #include #include -#include - -#ifndef __FreeBSD__ -#include -#endif /* masks for register encoded in base addr */ @@ -115,259 +93,124 @@ #define ASI_OFF_RW 0x01 /*---------------------------------------------------------------------------* - * Asuscom ISDNlink 128K PnP ISAC get fifo routine + * Asuscom ISDNlink 128K ISAC get fifo routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -asi_read_fifo(void *buf, const void *base, size_t len) +static void +asi_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size) { - u_int asus_base; - - asus_base = ((u_int) base) & ASI_BASE_MASK; - switch (((u_int) base) & ASI_OFF_MASK) { - case ASI_IDHSCXB: - outb(asus_base + ASI_OFF_ALE, IPAC_HSCXB_OFF); - insb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len); - break; - case ASI_IDHSCXA: - outb(asus_base + ASI_OFF_ALE, IPAC_HSCXA_OFF); - insb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len); - break; - case ASI_IDISAC: - outb(asus_base + ASI_OFF_ALE, IPAC_ISAC_OFF); - insb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len); - break; - } -} - -#else + 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]); -static void -asi_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; - 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; + 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; } } -#endif - /*---------------------------------------------------------------------------* - * Asuscom ISDNlink 128K PnP ISAC put fifo routine + * Asuscom ISDNlink 128K ISAC put fifo routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -asi_write_fifo(void *base, const void *buf, size_t len) +static void +asi_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size) { - u_int asus_base; + 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]); - asus_base = ((u_int) base) & ASI_BASE_MASK; - switch (((u_int) base) & ASI_OFF_MASK) { - case ASI_IDHSCXB: - outb(asus_base + ASI_OFF_ALE, IPAC_HSCXB_OFF); - outsb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len); - break; - case ASI_IDHSCXA: - outb(asus_base + ASI_OFF_ALE, IPAC_HSCXA_OFF); - outsb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len); - break; - case ASI_IDISAC: - outb(asus_base + ASI_OFF_ALE, IPAC_ISAC_OFF); - outsb(asus_base + ASI_OFF_RW, (u_char *)buf, (u_int)len); - break; - } -} - -#else - -static void -asi_write_fifo(struct isic_softc *sc, - int what, const void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; - 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, (u_int8_t*)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, (u_int8_t*)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, (u_int8_t*)buf,size); - break; + 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; } } -#endif /*---------------------------------------------------------------------------* - * Asuscom ISDNlink 128K PnP ISAC put register routine + * Asuscom ISDNlink 128K ISAC put register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - static void -asi_write_reg(u_char *base, u_int offset, u_int v) +asi_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data) { - u_int asus_base; - - asus_base = ((u_int) base) & ASI_BASE_MASK; - switch (((u_int) base) & ASI_OFF_MASK) { - case ASI_IDHSCXB: - outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF)); - outb(asus_base + ASI_OFF_RW, (u_char)v); - break; - case ASI_IDHSCXA: - outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF)); - outb(asus_base + ASI_OFF_RW, (u_char)v); - break; - case ASI_IDISAC: - outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF)); - outb(asus_base + ASI_OFF_RW, (u_char)v); - break; - case ASI_IDIPAC: - outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF)); - outb(asus_base + ASI_OFF_RW, (u_char)v); - break; - } -} - -#else + 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]); -static void -asi_write_reg(struct isic_softc *sc, - int what, bus_size_t offs, u_int8_t data) -{ - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; - switch (what) { - case ISIC_WHAT_ISAC: - bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_ISAC_OFF+offs); - bus_space_write_1(t, h, ASI_OFF_RW, data); - break; - case ISIC_WHAT_HSCXA: - bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXA_OFF+offs); - bus_space_write_1(t, h, ASI_OFF_RW, data); - break; - case ISIC_WHAT_HSCXB: - bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXB_OFF+offs); - bus_space_write_1(t, h, ASI_OFF_RW, data); - break; - case ISIC_WHAT_IPAC: - bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_IPAC_OFF+offs); - bus_space_write_1(t, h, ASI_OFF_RW, data); - break; + 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; } } -#endif /*---------------------------------------------------------------------------* - * Asuscom ISDNlink 128K PnP ISAC get register routine + * Asuscom ISDNlink 128K ISAC get register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static u_char -asi_read_reg(u_char *base, u_int offset) -{ - u_int asus_base; - - asus_base = ((u_int) base) & ASI_BASE_MASK; - switch (((u_int) base) & ASI_OFF_MASK) { - case ASI_IDHSCXB: - outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF)); - return(inb(asus_base + ASI_OFF_RW)); - case ASI_IDHSCXA: - outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF)); - return(inb(asus_base + ASI_OFF_RW)); - case ASI_IDISAC: - outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF)); - return(inb(asus_base + ASI_OFF_RW)); - case ASI_IDIPAC: - outb(asus_base + ASI_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF)); - return(inb(asus_base + ASI_OFF_RW)); - } - - return 0; /* NOTREACHED */ -} - -#else - static u_int8_t -asi_read_reg(struct isic_softc *sc, int what, bus_size_t offs) +asi_read_reg(struct l1_softc *sc,int what,bus_size_t reg) { - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; - switch (what) { - case ISIC_WHAT_ISAC: - bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_ISAC_OFF+offs); - return bus_space_read_1(t, h, ASI_OFF_RW); - case ISIC_WHAT_HSCXA: - bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXA_OFF+offs); - return bus_space_read_1(t, h, ASI_OFF_RW); - case ISIC_WHAT_HSCXB: - bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_HSCXB_OFF+offs); - return bus_space_read_1(t, h, ASI_OFF_RW); - case ISIC_WHAT_IPAC: - bus_space_write_1(t, h, ASI_OFF_ALE, IPAC_IPAC_OFF+offs); - return bus_space_read_1(t, h, ASI_OFF_RW); - } + 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]); - return 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; + } } -#endif - /*---------------------------------------------------------------------------* - * isic_attach_asi - attach for Asuscom ISDNlink 128K PnP + * isic_attach_siemens_isurf - attach for Asuscom ISDNlink 128K *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ int -isic_probe_asi(struct isa_device *dev, unsigned int iobase2) +isic_attach_asi(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; - - /* check max unit range */ + int unit = device_get_unit(dev); + struct l1_softc *sc = &l1_sc[unit]; - if(dev->id_unit >= ISIC_MAXUNIT) - { - printf("isic%d: Error, unit %d >= ISIC_MAXUNIT " - "for Asuscom ISDNlink 128K PnP!\n", - dev->id_unit, dev->id_unit); - - return(0); - } - sc->sc_unit = dev->id_unit; - - /* setup iobase */ - - if((dev->id_iobase <= 0) || (dev->id_iobase > 0xffff)) - { - printf("isic%d: Error, invalid iobase 0x%x specified " - "for Asuscom ISDNlink 128K PnP\n", - dev->id_unit, iobase2); - - return(0); - } - - sc->sc_port = dev->id_iobase; - /* setup access routines */ sc->clearirq = NULL; @@ -389,121 +232,17 @@ isic_probe_asi(struct isa_device *dev, unsigned int iobase2) sc->sc_ipac = 1; sc->sc_bfifolen = IPAC_BFIFO_LEN; - - /* setup ISAC and HSCX base addr */ - - ISAC_BASE = (caddr_t) ((u_int)dev->id_iobase | ASI_IDISAC); - HSCX_A_BASE = (caddr_t) ((u_int)dev->id_iobase | ASI_IDHSCXA); - HSCX_B_BASE = (caddr_t) ((u_int)dev->id_iobase | ASI_IDHSCXB); - IPAC_BASE = (caddr_t) ((u_int)dev->id_iobase | ASI_IDIPAC); - return (1); -} - -int -isic_attach_asi(struct isa_device *dev, unsigned int iobase2) -{ - struct isic_softc *sc = &isic_sc[dev->id_unit]; /* enable hscx/isac irq's */ -#if 0 -/* - * This is for ELSA driver - */ - 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 */ - - outb(dev->id_iobase + 0x4c, 0x41); /* enable card interrupt */ -#endif /* * This has been taken from Linux driver. - * XXX Figure out bits to use defines as original driver did. - */ - IPAC_WRITE (IPAC_CONF, 0x0); - IPAC_WRITE (IPAC_ACFG, 0xff); - IPAC_WRITE (IPAC_AOE, 0x0); - IPAC_WRITE (IPAC_MASK, 0xc0); - IPAC_WRITE (IPAC_PCFG, 0x12); - - return (1); -} - -#else /* !FreeBSD */ - -void -isic_attach_asi(psc, pa) - struct pci_isic_softc *psc; - struct pci_attach_args *pa; -{ - struct isic_softc *sc = &psc->sc_isic; - - /* setup io mappings */ - sc->sc_num_mappings = 2; - MALLOC_MAPS(sc); - sc->sc_maps[0].size = 0; - if (pci_mapreg_map(pa, ASI_PORT0_MAPOFF, PCI_MAPREG_TYPE_IO, 0, - &sc->sc_maps[0].t, &sc->sc_maps[0].h, NULL, NULL)) { - printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname); - return; - } - sc->sc_maps[1].size = 0; - if (pci_mapreg_map(pa, ASI_PORT1_MAPOFF, PCI_MAPREG_TYPE_IO, 0, - &sc->sc_maps[1].t, &sc->sc_maps[1].h, NULL, NULL)) { - printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname); - return; - } - - /* 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; - -#if 0 -/* - * This for ELSA card in original driver. + * (Removed initialization that was not applicaple to + * this board or was already register default setting.) */ - /* 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 */ + 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)); - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, 0x4c, 0x41); /* enable card interrupt */ -#endif -/* - * This has been taken from Linux driver. - * XXX Figure out bits to use defines as original driver did. - */ - IPAC_WRITE (IPAC_CONF, 0x0); - IPAC_WRITE (IPAC_ACFG, 0xff); - IPAC_WRITE (IPAC_AOE, 0x0); - IPAC_WRITE (IPAC_MASK, 0xc0); - IPAC_WRITE (IPAC_PCFG, 0x12); + return(0); } - - -#endif - -#endif /* (NISIC > 0) && defined(ASUSCOM_IPAC) */ +#endif /* (NISIC > 0) && defined (ASUSCOM_IPAC) */ diff --git a/sys/i4b/layer1/i4b_avm_a1.c b/sys/i4b/layer1/i4b_avm_a1.c index 8cb1ec1..af6b74f 100644 --- a/sys/i4b/layer1/i4b_avm_a1.c +++ b/sys/i4b/layer1/i4b_avm_a1.c @@ -35,48 +35,32 @@ * i4b_avm_a1.c - AVM A1/Fritz passive card driver for isdn4bsd * ------------------------------------------------------------ * - * $FreeBSD$ + * $Id: i4b_avm_a1.c,v 1.2 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Sun Feb 14 10:25:11 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 21:58:36 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) #include "isic.h" #include "opt_i4b.h" -#else -#define NISIC 1 -#endif + #if NISIC > 0 && defined(AVM_A1) #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include - -#ifdef __FreeBSD__ -#include -#include -#else -#include -#include -#endif - #include + #include -#ifdef __FreeBSD__ +#include + #include #include -#else -#include -#include -#endif #include @@ -84,13 +68,6 @@ #include #include -#ifndef __FreeBSD__ -static u_int8_t avma1_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs)); -static void avma1_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)); -static void avma1_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size)); -static void avma1_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size)); -#endif - /*---------------------------------------------------------------------------* * AVM A1 and AVM Fritz! Card special registers *---------------------------------------------------------------------------*/ @@ -111,106 +88,189 @@ static void avma1_write_fifo __P((struct isic_softc *sc, int what, const void *d #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 routines + * AVM read fifo routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -static void -avma1_read_fifo(void *buf, const void *base, size_t len) -{ - insb((int)base - 0x3e0, (u_char *)buf, (u_int)len); -} -#else static void -avma1_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) +avma1_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - bus_space_tag_t t = sc->sc_maps[what+4].t; - bus_space_handle_t h = sc->sc_maps[what+4].h; + 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); } -#endif /*---------------------------------------------------------------------------* - * AVM write fifo routines + * AVM write fifo routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ static void -avma1_write_fifo(void *base, const void *buf, size_t len) +avma1_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - outsb((int)base - 0x3e0, (u_char *)buf, (u_int)len); -} -#else -static void -avma1_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[what+4].t; - bus_space_handle_t h = sc->sc_maps[what+4].h; + 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); } -#endif /*---------------------------------------------------------------------------* - * AVM write register routines + * AVM write register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -static void -avma1_write_reg(u_char *base, u_int offset, u_int v) -{ - outb((int)base + offset, (u_char)v); -} -#else static void -avma1_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) +avma1_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data) { - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; + 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); } -#endif /*---------------------------------------------------------------------------* - * AVM read register routines + * AVM read register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -static u_char -avma1_read_reg(u_char *base, u_int offset) -{ - return (inb((int)base + offset)); -} -#else static u_int8_t -avma1_read_reg(struct isic_softc *sc, int what, bus_size_t offs) +avma1_read_reg(struct l1_softc *sc, int what, bus_size_t offs) { - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; + 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); } -#endif + +/*---------------------------------------------------------------------------* + * 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(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[rid], + 0ul, ~0ul, 1, 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 *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ int -isic_probe_avma1(struct isa_device *dev) +isic_probe_avma1(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; + 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(dev->id_unit >= ISIC_MAXUNIT) + + if(unit >= ISIC_MAXUNIT) { printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for AVM A1/Fritz!\n", - dev->id_unit, dev->id_unit); - return(0); - } - sc->sc_unit = dev->id_unit; + unit, unit); + return(ENXIO); + } - /* check IRQ validity */ + sc = &l1_sc[unit]; /* get pointer to softc */ + sc->sc_unit = unit; /* set unit */ + sc->sc_flags = FLAG_AVM_A1; /* set flags */ + + /* see if an io base was supplied */ - switch(ffs(dev->id_irq)-1) + if(!(sc->sc_resources.io_base[0] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[0], + 0ul, ~0ul, 1, 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(dev, SYS_RES_IRQ, + &sc->sc_resources.irq_rid, + 0ul, ~0ul, 1, 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: @@ -228,40 +288,11 @@ isic_probe_avma1(struct isa_device *dev) default: printf("isic%d: Error, invalid IRQ [%d] specified for AVM A1/Fritz!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); + unit, sc->sc_irq); + isic_detach_common(dev); + return(ENXIO); break; } - sc->sc_irq = dev->id_irq; - - /* check if memory addr specified */ - - if(dev->id_maddr) - { - printf("isic%d: Error, mem addr 0x%lx specified for AVM A1/Fritz!\n", - dev->id_unit, (u_long)dev->id_maddr); - return(0); - } - - dev->id_msize = 0; - - /* check if we got an iobase */ - - switch(dev->id_iobase) - { - case 0x200: - case 0x240: - case 0x300: - case 0x340: - break; - - default: - printf("isic%d: Error, invalid iobase 0x%x specified for AVM A1/Fritz!\n", - dev->id_unit, dev->id_iobase); - return(0); - break; - } - sc->sc_port = dev->id_iobase; sc->clearirq = NULL; sc->readreg = avma1_read_reg; @@ -281,13 +312,6 @@ isic_probe_avma1(struct isa_device *dev) sc->sc_ipac = 0; sc->sc_bfifolen = HSCX_FIFO_LEN; - /* setup ISAC and HSCX base addr */ - - ISAC_BASE = (caddr_t)dev->id_iobase + 0x1400 - 0x20; - - HSCX_A_BASE = (caddr_t)dev->id_iobase + 0x400 - 0x20; - HSCX_B_BASE = (caddr_t)dev->id_iobase + 0xc00 - 0x20; - /* * Read HSCX A/B VSTR. * Expected value for AVM A1 is 0x04 or 0x05 and for the @@ -300,12 +324,12 @@ isic_probe_avma1(struct isa_device *dev) ((HSCX_READ(1, H_VSTR) & 0xf) != 0x4)) ) { printf("isic%d: HSCX VSTR test failed for AVM A1/Fritz\n", - dev->id_unit); + unit); printf("isic%d: HSC0: VSTR: %#x\n", - dev->id_unit, HSCX_READ(0, H_VSTR)); + unit, HSCX_READ(0, H_VSTR)); printf("isic%d: HSC1: VSTR: %#x\n", - dev->id_unit, HSCX_READ(1, H_VSTR)); - return (0); + unit, HSCX_READ(1, H_VSTR)); + return(ENXIO); } /* AVM A1 or Fritz! control register bits: */ @@ -323,164 +347,54 @@ isic_probe_avma1(struct isa_device *dev) * fails, we write back the saved byte ..... */ - savebyte = inb(dev->id_iobase + AVM_CONF_REG); + 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 */ - outb(dev->id_iobase + AVM_CONF_REG, 0x00); + bus_space_write_1(t, h, 0, 0x00); /* test bit and next higher and lower bit must be 0 */ - if((byte = inb(dev->id_iobase + AVM_CONF_REG) & 0x38) != 0x00) + 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", - dev->id_unit, byte); - outb(dev->id_iobase + AVM_CONF_REG, savebyte); - return (0); + unit, byte); + bus_space_write_1(t, h, 0, savebyte); + return(ENXIO); } /* write high to test bit */ - outb(dev->id_iobase + AVM_CONF_REG, 0x10); + bus_space_write_1(t, h, 0, 0x10); /* test bit must be high, next higher and lower bit must be 0 */ - if((byte = inb(dev->id_iobase + AVM_CONF_REG) & 0x38) != 0x10) + 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", - dev->id_unit, byte); - outb(dev->id_iobase + AVM_CONF_REG, savebyte); - return (0); - } - - return (1); -} - -#else - -int -isic_probe_avma1(struct isic_attach_args *ia) -{ - u_int8_t savebyte, v1, v2; - - /* - * 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. - */ - - v1 = bus_space_read_1(ia->ia_maps[ISIC_WHAT_HSCXA+1].t, ia->ia_maps[ISIC_WHAT_HSCXA+1].h, H_VSTR) & 0x0f; - v2 = bus_space_read_1(ia->ia_maps[ISIC_WHAT_HSCXB+1].t, ia->ia_maps[ISIC_WHAT_HSCXB+1].h, H_VSTR) & 0x0f; - if (v1 != v2 || (v1 != 0x05 && v1 != 0x04)) - return 0; - - /* 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 ..... - */ - - savebyte = bus_space_read_1(ia->ia_maps[0].t, ia->ia_maps[0].h, 0); - - /* write low to test bit */ - - bus_space_write_1(ia->ia_maps[0].t, ia->ia_maps[0].h, 0, 0); - - /* test bit and next higher and lower bit must be 0 */ - - if((bus_space_read_1(ia->ia_maps[0].t, ia->ia_maps[0].h, 0) & 0x38) != 0x00) - { - bus_space_write_1(ia->ia_maps[0].t, ia->ia_maps[0].h, 0, savebyte); - return 0; - } - - /* write high to test bit */ - - bus_space_write_1(ia->ia_maps[0].t, ia->ia_maps[0].h, 0, 0x10); - - /* test bit must be high, next higher and lower bit must be 0 */ - - if((bus_space_read_1(ia->ia_maps[0].t, ia->ia_maps[0].h, 0) & 0x38) != 0x10) - { - bus_space_write_1(ia->ia_maps[0].t, ia->ia_maps[0].h, 0, savebyte); - return 0; + unit, byte); + bus_space_write_1(t, h, 0, savebyte); + return(ENXIO); } - - return (1); + return(0); } -#endif /*---------------------------------------------------------------------------* * isic_attach_avma1 - attach AVM A1 and compatibles *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -int -isic_attach_avma1(struct isa_device *dev) -{ - struct isic_softc *sc = &isic_sc[dev->id_unit]; - - /* reset the HSCX and ISAC chips */ - - outb(dev->id_iobase + AVM_CONF_REG, 0x00); - DELAY(SEC_DELAY / 10); - - outb(dev->id_iobase + AVM_CONF_REG, AVM_CONF_WR_RESET); - DELAY(SEC_DELAY / 10); - - outb(dev->id_iobase + AVM_CONF_REG, 0x00); - DELAY(SEC_DELAY / 10); - - /* setup IRQ */ - - outb(dev->id_iobase + AVM_CONF_IRQ, (ffs(sc->sc_irq)) - 1); - DELAY(SEC_DELAY / 10); - - /* enable IRQ, disable counter IRQ */ - - outb(dev->id_iobase + AVM_CONF_REG, AVM_CONF_WR_IRQEN | - AVM_CONF_WR_CCH | AVM_CONF_WR_CCL); - DELAY(SEC_DELAY / 10); - - return (1); -} - -#else - int -isic_attach_avma1(struct isic_softc *sc) +isic_attach_avma1(device_t dev) { - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - - sc->clearirq = NULL; - sc->readreg = avma1_read_reg; - sc->writereg = avma1_write_reg; - - sc->readfifo = avma1_read_fifo; - sc->writefifo = avma1_write_fifo; + 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]); - /* setup card type */ - - sc->sc_cardtyp = CARD_TYPEP_AVMA1; + /* reset ISAC/HSCX */ - /* setup IOM bus type */ - - sc->sc_bustyp = BUS_TYPE_IOM2; - - sc->sc_ipac = 0; - sc->sc_bfifolen = HSCX_FIFO_LEN; - - /* reset the HSCX and ISAC chips */ - bus_space_write_1(t, h, 0, 0x00); DELAY(SEC_DELAY / 10); @@ -498,11 +412,10 @@ isic_attach_avma1(struct isic_softc *sc) /* enable IRQ, disable counter IRQ */ bus_space_write_1(t, h, 0, AVM_CONF_WR_IRQEN | - AVM_CONF_WR_CCH | AVM_CONF_WR_CCL); + AVM_CONF_WR_CCH | AVM_CONF_WR_CCL); DELAY(SEC_DELAY / 10); - return (1); + return(0); } -#endif -#endif /* ISIC > 0 */ +#endif /* NISIC > 0 && defined(AVM_A1) */ diff --git a/sys/i4b/layer1/i4b_avm_fritz_pci.c b/sys/i4b/layer1/i4b_avm_fritz_pci.c index 0b41c7b..b964cf5 100644 --- a/sys/i4b/layer1/i4b_avm_fritz_pci.c +++ b/sys/i4b/layer1/i4b_avm_fritz_pci.c @@ -35,57 +35,42 @@ * Fritz!Card PCI specific routines for isic driver * ------------------------------------------------ * + * New-bus'ified by Gary Jennejohn - 15 Nov 99. + * + * $Id: i4b_avm_fritz_pci.c,v 1.3 1999/12/13 21:25:26 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Tue Jun 1 14:08:01 1999] + * last edit-date: [Mon Dec 13 21:59:04 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) #include "isic.h" #include "opt_i4b.h" -#else -#define NISIC 1 -#endif #if NISIC > 0 && defined(AVM_A1_PCI) #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include -#ifdef __FreeBSD__ -#include -#include -#include /* for pcici_t */ -#if __FreeBSD__ < 3 -#include -#include -#endif /* __FreeBSD__ < 3 */ -#else +#include /* for DELAY */ +#include /* this device uses port accesses only */ #include -#include -#endif +#include +#include +#include + +#include +#include #include #include -#ifdef __FreeBSD__ #include #include -#else -#include -#include -#include -#include -#include -#endif #include #include @@ -95,58 +80,65 @@ #include #include -#ifndef __FreeBSD__ - -#include - -/* PCI config map to use (only one in this driver) */ -#define FRITZPCI_PORT0_MAPOFF PCI_MAPREG_START+4 - -#endif +#define PCI_AVMA1_VID 0x1244 +#define PCI_AVMA1_DID 0x0a00 /* prototypes */ -static void avma1pp_disable(struct isic_softc *); - -#ifdef __FreeBSD__ - -static void avma1pp_intr(struct isic_softc *); -static void avma1pp_disable(struct isic_softc *); -void avma1pp_map_int(pcici_t , void *, unsigned *); -static void hscx_write_reg(int, u_int, u_int, struct isic_softc *); -static u_char hscx_read_reg(int, u_int, struct isic_softc *); -static u_int hscx_read_reg_int(int, u_int, struct isic_softc *); -static void hscx_read_fifo(int, void *, size_t, struct isic_softc *); -static void hscx_write_fifo(int, const void *, size_t, struct isic_softc *); -static void avma1pp_hscx_int_handler(struct isic_softc *); -static void avma1pp_hscx_intr(int, u_int, struct isic_softc *); -static void avma1pp_init_linktab(struct isic_softc *); +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 isic_softc *, 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); -int isic_attach_avma1pp(int, u_int, u_int); -extern void isicintr_sc(struct isic_softc *); +static int avma1pp_pci_probe(device_t); +int isic_attach_avma1pp(device_t); -#else +static device_method_t avma1pp_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, avma1pp_pci_probe), + DEVMETHOD(device_attach, isic_attach_avma1pp), + DEVMETHOD(device_shutdown, avma1pp_disable), -static int avma1pp_intr(void*); -static void avma1pp_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size); -static void avma1pp_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size); -static void avma1pp_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data); -static u_int8_t avma1pp_read_reg(struct isic_softc *sc, int what, bus_size_t offs); -static void hscx_write_fifo(int chan, const void *buf, size_t len, struct isic_softc *sc); -static void hscx_read_fifo(int chan, void *buf, size_t len, struct isic_softc *sc); -static void hscx_write_reg(int chan, u_int off, u_int val, struct isic_softc *sc); -static u_char hscx_read_reg(int chan, u_int off, struct isic_softc *sc); -static u_int hscx_read_reg_int(int chan, u_int off, struct isic_softc *sc); -static void avma1pp_fifo(isic_Bchan_t *chan, struct isic_softc *sc); -static void avma1pp_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp); -static void avma1pp_map_int(struct pci_isic_softc *sc, struct pci_attach_args *pa); -static void avma1pp_bchannel_setup(int unit, int h_chan, int bprot, int activate); -static void avma1pp_init_linktab(struct isic_softc *); -#endif + /* bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + + { 0, 0 } +}; + +/* 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; + u_int8_t avma1pp_unit; /* interface number */ + /* pointer to l1_sc */ + struct l1_softc *avma1pp_isc; +}; + +static driver_t avma1pp_pci_driver = { + "isic", + avma1pp_pci_methods, + sizeof(struct avma1pp_softc) +}; + +static devclass_t avma1pp_pci_devclass; + +DRIVER_MODULE(avma1pp, pci, avma1pp_pci_driver, avma1pp_pci_devclass, 0, 0); /*---------------------------------------------------------------------------* * AVM PCI Fritz!Card special registers @@ -252,23 +244,13 @@ static void avma1pp_init_linktab(struct isic_softc *); * txl = transmit length * cmd = the command to be executed * - * The fields are defined as u_char in struct isic_softc. + * 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)) -#ifdef __FreeBSD__ - -/* "fake" addresses for the non-existent HSCX */ -/* note: the unit number is in the lower byte for both the ISAC and "HSCX" */ -#define HSCX0FAKE 0xfa000 /* read: fake0 */ -#define HSCX1FAKE 0xfa100 /* read: fake1 */ -#define IS_HSCX_MASK 0xfff00 - -#endif /* __FreeBSD__ */ - /* * 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 @@ -281,59 +263,15 @@ static void avma1pp_init_linktab(struct isic_softc *); * AVM read fifo routines *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -static void -avma1pp_read_fifo(void *buf, const void *base, size_t len) -{ - int unit; - struct isic_softc *sc; - - unit = (int)base & 0xff; - sc = &isic_sc[unit]; - - /* check whether the target is an HSCX */ - if (((int)base & IS_HSCX_MASK) == HSCX0FAKE) - { - hscx_read_fifo(0, buf, len, sc); - return; - } - if (((int)base & IS_HSCX_MASK) == HSCX1FAKE) - { - hscx_read_fifo(1, buf, len, sc); - return; - } - /* tell the board to access the ISAC fifo */ - outb(sc->sc_port + ADDR_REG_OFFSET, ISAC_FIFO); - insb(sc->sc_port + ISAC_REG_OFFSET, (u_char *)buf, len); -} - static void -hscx_read_fifo(int chan, void *buf, size_t len, struct isic_softc *sc) +avma1pp_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - u_int *ip; - size_t cnt; - - outl(sc->sc_port + ADDR_REG_OFFSET, chan); - ip = (u_int *)buf; - cnt = 0; - /* what if len isn't a multiple of sizeof(int) and buf is */ - /* too small ???? */ - while (cnt < len) - { - *ip++ = inl(sc->sc_port + ISAC_REG_OFFSET); - cnt += 4; - } -} - -#else + struct avma1pp_softc *asc = (struct avma1pp_softc *)sc->sc_ipacbase; -static void -avma1pp_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) -{ switch (what) { case ISIC_WHAT_ISAC: - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ADDR_REG_OFFSET, ISAC_FIFO); - bus_space_read_multi_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET, buf, size); + bus_space_write_1(asc->avma1pp_btag, asc->avma1pp_bhandle, ADDR_REG_OFFSET, ISAC_FIFO); + bus_space_read_multi_1(asc->avma1pp_btag, asc->avma1pp_bhandle, ISAC_REG_OFFSET, buf, size); break; case ISIC_WHAT_HSCXA: hscx_read_fifo(0, buf, size, sc); @@ -345,93 +283,37 @@ avma1pp_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) } static void -hscx_read_fifo(int chan, void *buf, size_t len, struct isic_softc *sc) +hscx_read_fifo(int chan, void *buf, size_t len, struct l1_softc *sc) { u_int32_t *ip; size_t cnt; + struct avma1pp_softc *asc = (struct avma1pp_softc *)sc->sc_ipacbase; - bus_space_write_4(sc->sc_maps[0].t, sc->sc_maps[0].h, ADDR_REG_OFFSET, chan); + + bus_space_write_4(asc->avma1pp_btag, asc->avma1pp_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(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET); + *ip++ = bus_space_read_4(asc->avma1pp_btag, asc->avma1pp_bhandle, ISAC_REG_OFFSET); cnt += 4; } } -#endif - /*---------------------------------------------------------------------------* * AVM write fifo routines *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ static void -avma1pp_write_fifo(void *base, const void *buf, size_t len) +avma1pp_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - int unit; - struct isic_softc *sc; - - unit = (int)base & 0xff; - sc = &isic_sc[unit]; + struct avma1pp_softc *asc = (struct avma1pp_softc *)sc->sc_ipacbase; - /* check whether the target is an HSCX */ - if (((int)base & IS_HSCX_MASK) == HSCX0FAKE) - { - hscx_write_fifo(0, buf, len, sc); - return; - } - if (((int)base & IS_HSCX_MASK) == HSCX1FAKE) - { - hscx_write_fifo(1, buf, len, sc); - return; - } - /* tell the board to use the ISAC fifo */ - outb(sc->sc_port + ADDR_REG_OFFSET, ISAC_FIFO); - outsb(sc->sc_port + ISAC_REG_OFFSET, (const u_char *)buf, len); -} - -static void -hscx_write_fifo(int chan, const void *buf, size_t len, struct isic_softc *sc) -{ - register const u_int *ip; - register size_t cnt; - isic_Bchan_t *Bchan = &sc->sc_chan[chan]; - - 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 = (const u_int *)buf; - cnt = 0; - while (cnt < len) - { - outl(sc->sc_port + ISAC_REG_OFFSET, *ip++); - cnt += 4; - } -} - -#else - -static void -avma1pp_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) -{ switch (what) { case ISIC_WHAT_ISAC: - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ADDR_REG_OFFSET, ISAC_FIFO); - bus_space_write_multi_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET, (u_int8_t*)buf, size); + bus_space_write_1(asc->avma1pp_btag, asc->avma1pp_bhandle, ADDR_REG_OFFSET, ISAC_FIFO); + bus_space_write_multi_1(asc->avma1pp_btag, asc->avma1pp_bhandle, ISAC_REG_OFFSET, (u_int8_t*)buf, size); break; case ISIC_WHAT_HSCXA: hscx_write_fifo(0, buf, size, sc); @@ -443,11 +325,13 @@ avma1pp_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size } static void -hscx_write_fifo(int chan, const void *buf, size_t len, struct isic_softc *sc) +hscx_write_fifo(int chan, void *buf, size_t len, struct l1_softc *sc) { u_int32_t *ip; size_t cnt; - isic_Bchan_t *Bchan = &sc->sc_chan[chan]; + l1_bchan_state_t *Bchan = &sc->sc_chan[chan]; + struct avma1pp_softc *asc = (struct avma1pp_softc *)sc->sc_ipacbase; + sc->avma1pp_cmd &= ~HSCX_CMD_XME; sc->avma1pp_txl = 0; @@ -467,65 +351,22 @@ hscx_write_fifo(int chan, const void *buf, size_t len, struct isic_softc *sc) cnt = 0; while (cnt < len) { - bus_space_write_4(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET, *ip); + bus_space_write_4(asc->avma1pp_btag, asc->avma1pp_bhandle, ISAC_REG_OFFSET, *ip); ip++; cnt += 4; } } -#endif /*---------------------------------------------------------------------------* * AVM write register routines *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -static void -avma1pp_write_reg(u_char *base, u_int offset, u_int v) -{ - int unit; - struct isic_softc *sc; - u_char reg_bank; - - unit = (int)base & 0xff; - sc = &isic_sc[unit]; - - /* check whether the target is an HSCX */ - if (((int)base & IS_HSCX_MASK) == HSCX0FAKE) - { - hscx_write_reg(0, offset, v, sc); - return; - } - if (((int)base & IS_HSCX_MASK) == HSCX1FAKE) - { - hscx_write_reg(1, offset, v, sc); - return; - } - /* must be the ISAC */ - reg_bank = (offset > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET; -#ifdef AVMA1PCI_DEBUG - printf("write_reg bank %d off %d.. ", reg_bank, offset); -#endif - /* set the register bank */ - outb(sc->sc_port + ADDR_REG_OFFSET, reg_bank); - outb(sc->sc_port + ISAC_REG_OFFSET + (offset & ISAC_REGSET_MASK), v); -} - -static void -hscx_write_reg(int chan, u_int off, u_int val, struct isic_softc *sc) -{ - /* HACK */ - if (off == H_MASK) - return; - /* point at the correct channel */ - outl(sc->sc_port + ADDR_REG_OFFSET, chan); - outl(sc->sc_port + ISAC_REG_OFFSET + off, val); -} - -#else static void -avma1pp_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) +avma1pp_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data) { u_char reg_bank; + struct avma1pp_softc *asc = (struct avma1pp_softc *)sc->sc_ipacbase; + switch (what) { case ISIC_WHAT_ISAC: reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET; @@ -533,8 +374,8 @@ avma1pp_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t dat printf("write_reg bank %d off %ld.. ", (int)reg_bank, (long)offs); #endif /* set the register bank */ - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ADDR_REG_OFFSET, reg_bank); - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET + (offs & ISAC_REGSET_MASK), data); + bus_space_write_1(asc->avma1pp_btag, asc->avma1pp_bhandle, ADDR_REG_OFFSET, reg_bank); + bus_space_write_1(asc->avma1pp_btag, asc->avma1pp_bhandle, ISAC_REG_OFFSET + (offs & ISAC_REGSET_MASK), data); break; case ISIC_WHAT_HSCXA: hscx_write_reg(0, offs, data, sc); @@ -546,53 +387,27 @@ avma1pp_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t dat } static void -hscx_write_reg(int chan, u_int off, u_int val, struct isic_softc *sc) +hscx_write_reg(int chan, u_int off, u_int val, struct l1_softc *sc) { + struct avma1pp_softc *asc = (struct avma1pp_softc *)sc->sc_ipacbase; + /* HACK */ if (off == H_MASK) return; /* point at the correct channel */ - bus_space_write_4(sc->sc_maps[0].t, sc->sc_maps[0].h, ADDR_REG_OFFSET, chan); - bus_space_write_4(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET + off, val); + bus_space_write_4(asc->avma1pp_btag, asc->avma1pp_bhandle, ADDR_REG_OFFSET, chan); + bus_space_write_4(asc->avma1pp_btag, asc->avma1pp_bhandle, ISAC_REG_OFFSET + off, val); } -#endif - /*---------------------------------------------------------------------------* * AVM read register routines *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static u_char -avma1pp_read_reg(u_char *base, u_int offset) -{ - int unit; - struct isic_softc *sc; - u_char reg_bank; - - unit = (int)base & 0xff; - sc = &isic_sc[unit]; - - /* check whether the target is an HSCX */ - if (((int)base & IS_HSCX_MASK) == HSCX0FAKE) - return(hscx_read_reg(0, offset, sc)); - if (((int)base & IS_HSCX_MASK) == HSCX1FAKE) - return(hscx_read_reg(1, offset, sc)); - /* must be the ISAC */ - reg_bank = (offset > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET; -#ifdef AVMA1PCI_DEBUG - printf("read_reg bank %d off %d.. ", reg_bank, offset); -#endif - /* set the register bank */ - outb(sc->sc_port + ADDR_REG_OFFSET, reg_bank); - return(inb(sc->sc_port + ISAC_REG_OFFSET + - (offset & ISAC_REGSET_MASK))); -} -#else static u_int8_t -avma1pp_read_reg(struct isic_softc *sc, int what, bus_size_t offs) +avma1pp_read_reg(struct l1_softc *sc, int what, bus_size_t offs) { u_char reg_bank; + struct avma1pp_softc *asc = (struct avma1pp_softc *)sc->sc_ipacbase; + switch (what) { case ISIC_WHAT_ISAC: reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET; @@ -600,8 +415,8 @@ avma1pp_read_reg(struct isic_softc *sc, int what, bus_size_t offs) printf("read_reg bank %d off %ld.. ", (int)reg_bank, (long)offs); #endif /* set the register bank */ - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ADDR_REG_OFFSET, reg_bank); - return(bus_space_read_1(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET + + bus_space_write_1(asc->avma1pp_btag, asc->avma1pp_bhandle, ADDR_REG_OFFSET, reg_bank); + return(bus_space_read_1(asc->avma1pp_btag, asc->avma1pp_bhandle, ISAC_REG_OFFSET + (offs & ISAC_REGSET_MASK))); case ISIC_WHAT_HSCXA: return hscx_read_reg(0, offs, sc); @@ -610,10 +425,9 @@ avma1pp_read_reg(struct isic_softc *sc, int what, bus_size_t offs) } return 0; } -#endif static u_char -hscx_read_reg(int chan, u_int off, struct isic_softc *sc) +hscx_read_reg(int chan, u_int off, struct l1_softc *sc) { return(hscx_read_reg_int(chan, off, sc) & 0xff); } @@ -623,201 +437,121 @@ hscx_read_reg(int chan, u_int off, struct isic_softc *sc) * byte. */ static u_int -hscx_read_reg_int(int chan, u_int off, struct isic_softc *sc) +hscx_read_reg_int(int chan, u_int off, struct l1_softc *sc) { + struct avma1pp_softc *asc = (struct avma1pp_softc *)sc->sc_ipacbase; + /* HACK */ if (off == H_ISTA) return(0); /* point at the correct channel */ -#ifdef __FreeBSD__ - outl(sc->sc_port + ADDR_REG_OFFSET, chan); - return(inl(sc->sc_port + ISAC_REG_OFFSET + off)); -#else - bus_space_write_4(sc->sc_maps[0].t, sc->sc_maps[0].h, ADDR_REG_OFFSET, chan); - return(bus_space_read_4(sc->sc_maps[0].t, sc->sc_maps[0].h, ISAC_REG_OFFSET + off)); -#endif + bus_space_write_4(asc->avma1pp_btag, asc->avma1pp_bhandle, ADDR_REG_OFFSET, chan); + return(bus_space_read_4(asc->avma1pp_btag, asc->avma1pp_bhandle, ISAC_REG_OFFSET + off)); } /*---------------------------------------------------------------------------* - * isic_attach_avma1pp - attach Fritz!Card PCI + * avma1pp_probe - probe for a card *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -int -isic_attach_avma1pp(int unit, u_int iobase1, u_int iobase2) +static int +avma1pp_pci_probe(dev) + device_t dev; { - struct isic_softc *sc = &isic_sc[unit]; - u_int v; + u_int16_t did, vid; - /* check max unit range */ - - if(unit >= ISIC_MAXUNIT) - { - printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for AVM FRITZ/PCI!\n", - unit, unit); - return(0); - } - sc->sc_unit = unit; - - /* setup iobase */ + vid = pci_get_vendor(dev); + did = pci_get_device(dev); - if((iobase1 <= 0) || (iobase1 > 0xffff)) - { - printf("isic%d: Error, invalid iobase 0x%x specified for AVM FRITZ/PCI!\n", - unit, iobase1); + if ((vid == PCI_AVMA1_VID) && (did == PCI_AVMA1_DID)) { + device_set_desc(dev, "AVM Fritz!Card PCI"); return(0); } - sc->sc_port = iobase1; - - /* the ISAC lives at offset 0x10, but we can't use that. */ - /* instead, put the unit number into the lower byte - HACK */ - sc->sc_isac = (caddr_t)((int)(iobase1 & ~0xff) + unit); - - /* this thing doesn't have an HSCX, so fake the base addresses */ - /* put the unit number into the lower byte - HACK */ - HSCX_A_BASE = (caddr_t)(HSCX0FAKE + unit); - HSCX_B_BASE = (caddr_t)(HSCX1FAKE + unit); - - /* 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; + return(ENXIO); +} - /* setup card type */ - - sc->sc_cardtyp = CARD_TYPEP_AVMA1PCI; +/*---------------------------------------------------------------------------* + * isic_attach_avma1pp - attach Fritz!Card PCI + *---------------------------------------------------------------------------*/ +int +isic_attach_avma1pp(device_t dev) +{ + struct l1_softc *sc; + u_int v; + /* start of new-bus stuff */ + struct avma1pp_softc *asc; + int unit, error = 0, rid; + int s; + u_int16_t did, vid; - /* setup IOM bus type */ - - sc->sc_bustyp = BUS_TYPE_IOM2; + s = splimp(); - /* set up some other miscellaneous things */ - sc->sc_ipac = 0; - sc->sc_bfifolen = HSCX_FIFO_LEN; + vid = pci_get_vendor(dev); + did = pci_get_device(dev); + asc = device_get_softc(dev); + unit = device_get_unit(dev); + bzero(asc, sizeof(struct avma1pp_softc)); - /* 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 + if(unit > ISIC_MAXUNIT) { + printf("avma1pp%d: Error, unit > ISIC_MAXUNIT!\n", unit); + splx(s); + return(ENXIO); } - 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 - - outb(sc->sc_port + STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE); - DELAY(SEC_DELAY/100); /* 10 ms */ - outb(sc->sc_port + STAT0_OFFSET, ASL_TIMERRESET|ASL_ENABLE_INT|ASL_TIMERDISABLE); - DELAY(SEC_DELAY/100); /* 10 ms */ -#ifdef AVMA1PCI_DEBUG - outb(sc->sc_port + STAT1_OFFSET, ASL1_ENABLE_IOM|sc->sc_irq); - DELAY(SEC_DELAY/100); /* 10 ms */ - printf("after reset: S1 %#x\n", inb(sc->sc_port + STAT1_OFFSET)); - - v = inl(sc->sc_port); - printf("isic_attach_avma1pp: v %#x\n", v); -#endif - - /* from here to the end would normally be done in isic_pciattach */ - - printf("isic%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 */ - isic_isac_init(sc); - - /* 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); + if ((vid != PCI_AVMA1_VID) && (did != PCI_AVMA1_DID)) { + printf("avma1pp%d: unknown device!?\n", unit); + goto fail; + } - /* set trace level */ + asc->avma1pp_unit = unit; - sc->sc_trace = TRACE_OFF; + rid = PCI_MAP_REG_START+4; + asc->avma1pp_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, + 0, ~0, 1, RF_ACTIVE); - sc->sc_state = ISAC_IDLE; + if (asc->avma1pp_res == NULL) { + printf("avma1pp%d: couldn't map IO port\n", unit); + error = ENXIO; + goto fail; + } - sc->sc_ibuf = NULL; - sc->sc_ib = NULL; - sc->sc_ilen = 0; + asc->avma1pp_btag = rman_get_bustag(asc->avma1pp_res); + asc->avma1pp_bhandle = rman_get_bushandle(asc->avma1pp_res); - sc->sc_obuf = NULL; - sc->sc_op = NULL; - sc->sc_ol = 0; - sc->sc_freeflag = 0; + /* Allocate interrupt */ + rid = 0; + asc->avma1pp_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, + RF_SHAREABLE | RF_ACTIVE); - sc->sc_obuf2 = NULL; - sc->sc_freeflag2 = 0; + if (asc->avma1pp_irq == NULL) { + bus_release_resource(dev, SYS_RES_IOPORT, PCI_MAP_REG_START+4, asc->avma1pp_res); + printf("avma1pp%d: couldn't map interrupt\n", unit); + error = ENXIO; + goto fail; + } -#if defined(__FreeBSD__) && __FreeBSD__ >=3 - callout_handle_init(&sc->sc_T3_callout); - callout_handle_init(&sc->sc_T4_callout); -#endif - - /* init higher protocol layers */ - - MPH_Status_Ind(sc->sc_unit, STI_ATTACH, sc->sc_cardtyp); + error = bus_setup_intr(dev, asc->avma1pp_irq, INTR_TYPE_NET, avma1pp_intr, asc, &asc->avma1pp_intrhand); - return(1); -} + if (error) { + bus_release_resource(dev, SYS_RES_IRQ, 0, asc->avma1pp_res); + bus_release_resource(dev, SYS_RES_IOPORT, PCI_MAP_REG_START+4, asc->avma1pp_res); + printf("avma1pp%d: couldn't set up irq\n", unit); + goto fail; + } -#else + sc = asc->avma1pp_isc = &l1_sc[unit]; + sc->sc_unit = unit; -void -isic_attach_fritzPci(struct pci_isic_softc *psc, struct pci_attach_args *pa) -{ - struct isic_softc *sc = &psc->sc_isic; - u_int v; + /* mis-use sc_ipacbase to point at avma1pp_softc */ + IPAC_BASE = (caddr_t)asc; + /* end of new-bus stuff */ - isic_sc[sc->sc_unit] = sc; /* XXX - hack! */ + /* the ISAC lives at offset 0x10, but we can't use that. */ + /* instead, put the unit number into the lower byte - HACK */ + ISAC_BASE = (caddr_t)ISIC_WHAT_ISAC; - /* setup io mappings */ - sc->sc_num_mappings = 1; - MALLOC_MAPS(sc); - sc->sc_maps[0].size = 0; - if (pci_mapreg_map(pa, FRITZPCI_PORT0_MAPOFF, PCI_MAPREG_TYPE_IO, 0, - &sc->sc_maps[0].t, &sc->sc_maps[0].h, NULL, NULL)) { - printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname); - return; - } + /* this thing doesn't have an HSCX, so fake the base addresses */ + HSCX_A_BASE = (caddr_t)ISIC_WHAT_HSCXA; + HSCX_B_BASE = (caddr_t)ISIC_WHAT_HSCXB; /* setup access routines */ @@ -828,7 +562,6 @@ isic_attach_fritzPci(struct pci_isic_softc *psc, struct pci_attach_args *pa) sc->readfifo = avma1pp_read_fifo; sc->writefifo = avma1pp_write_fifo; - /* setup card type */ sc->sc_cardtyp = CARD_TYPEP_AVMA1PCI; @@ -837,13 +570,12 @@ isic_attach_fritzPci(struct pci_isic_softc *psc, struct pci_attach_args *pa) sc->sc_bustyp = BUS_TYPE_IOM2; - /* this is no IPAC based card */ + /* set up some other miscellaneous things */ sc->sc_ipac = 0; sc->sc_bfifolen = HSCX_FIFO_LEN; - - /* init the card */ + + /* reset the card */ /* the Linux driver does this to clear any pending ISAC interrupts */ - /* see if it helps any - XXXX */ v = 0; v = ISAC_READ(I_STAR); #ifdef AVMA1PCI_DEBUG @@ -883,24 +615,23 @@ isic_attach_fritzPci(struct pci_isic_softc *psc, struct pci_attach_args *pa) printf("avma1pp_attach: 1 HSCX_STAT %x\n", v); #endif - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE); + bus_space_write_1(asc->avma1pp_btag, asc->avma1pp_bhandle, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE); DELAY(SEC_DELAY/100); /* 10 ms */ - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, STAT0_OFFSET, ASL_TIMERRESET|ASL_ENABLE_INT|ASL_TIMERDISABLE); + bus_space_write_1(asc->avma1pp_btag, asc->avma1pp_bhandle, STAT0_OFFSET, ASL_TIMERRESET|ASL_ENABLE_INT|ASL_TIMERDISABLE); DELAY(SEC_DELAY/100); /* 10 ms */ #ifdef AVMA1PCI_DEBUG - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, STAT1_OFFSET, ASL1_ENABLE_IOM|sc->sc_irq); + bus_space_write_1(asc->avma1pp_btag, asc->avma1pp_bhandle, STAT1_OFFSET, ASL1_ENABLE_IOM|sc->sc_irq); DELAY(SEC_DELAY/100); /* 10 ms */ - v = bus_space_read_1(sc->sc_maps[0].t, sc->sc_maps[0].h, STAT1_OFFSET); + v = bus_space_read_1(asc->avma1pp_btag, asc->avma1pp_bhandle, STAT1_OFFSET); printf("after reset: S1 %#x\n", v); - v = bus_space_read_4(sc->sc_maps[0].t, sc->sc_maps[0].h, 0); + v = bus_space_read_4(asc->avma1pp_btag, asc->avma1pp_bhandle, 0); printf("isic_attach_avma1pp: v %#x\n", v); #endif - /* setup i4b infrastructure (have to roll our own here) */ + /* from here to the end would normally be done in isic_pciattach */ - /* sc->sc_isac_version = ((ISAC_READ(I_RBCH)) >> 5) & 0x03; */ - printf("%s: ISAC %s (IOM-%c)\n", sc->sc_dev.dv_xname, + printf("isic%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'); @@ -933,23 +664,35 @@ isic_attach_fritzPci(struct pci_isic_softc *psc, struct pci_attach_args *pa) sc->sc_obuf2 = NULL; sc->sc_freeflag2 = 0; +#ifdef USENEWFIELDS + /* new fields */ + sc->recover = isic_recover; + sc->next_state = isic_next_state; + sc->ph_data_req = isic_isac_ph_data_req; + sc->l1_cmd = isic_isac_l1_cmd; +#endif + +#if defined(__FreeBSD__) && __FreeBSD__ >=3 + callout_handle_init(&sc->sc_T3_callout); + callout_handle_init(&sc->sc_T4_callout); +#endif + /* init higher protocol layers */ MPH_Status_Ind(sc->sc_unit, STI_ATTACH, sc->sc_cardtyp); - /* setup interrupt mapping */ - avma1pp_map_int(psc, pa); + fail: + splx(s); + return(error); } -#endif - /* * this is the real interrupt routine */ static void -avma1pp_hscx_intr(int h_chan, u_int stat, struct isic_softc *sc) +avma1pp_hscx_intr(int h_chan, u_int stat, struct l1_softc *sc) { - register isic_Bchan_t *chan = &sc->sc_chan[h_chan]; + register l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; int activity = -1; u_int param = 0; @@ -1002,7 +745,26 @@ avma1pp_hscx_intr(int h_chan, u_int stat, struct isic_softc *sc) DBGL1(L1_H_XFRERR, "avma1pp_hscx_intr", ("receive data overflow\n")); 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) + { + DBGL1(L1_H_XFRERR, "avma1pp_hscx_intr", ("toss data from %d\n", h_chan)); + error++; + } + fifo_data_len = ((stat & HSCX_STAT_RML_MASK) >> 8); if(fifo_data_len == 0) @@ -1095,15 +857,23 @@ avma1pp_hscx_intr(int h_chan, u_int stat, struct isic_softc *sc) MPH_Trace_Ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data); } + if(!(isic_hscx_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len))) + activity = ACT_RX; + /* move rx'd data to rx queue */ - IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf); - + if (!(IF_QFULL(&chan->rx_queue))) + { + IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf); + } + else + { + i4b_Bfreembuf(chan->in_mbuf); + } + + /* signal upper layer that data are available */ (*chan->drvr_linktab->bch_rx_data_ready)(chan->drvr_linktab->unit); - if(!(isic_hscx_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len))) - activity = ACT_RX; - /* alloc new buffer */ if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL) @@ -1214,7 +984,7 @@ avma1pp_hscx_intr(int h_chan, u_int stat, struct isic_softc *sc) * the real interrupt routine as appropriate */ static void -avma1pp_hscx_int_handler(struct isic_softc *sc) +avma1pp_hscx_int_handler(struct l1_softc *sc) { u_int stat; @@ -1228,45 +998,29 @@ avma1pp_hscx_int_handler(struct isic_softc *sc) } static void -avma1pp_disable(struct isic_softc *sc) +avma1pp_disable(device_t dev) { -#ifdef __FreeBSD__ - outb(sc->sc_port + STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE); -#else - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE); -#endif + struct avma1pp_softc *asc = device_get_softc(dev); + + bus_space_write_1(asc->avma1pp_btag, asc->avma1pp_bhandle, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE); } -#ifdef __FreeBSD__ static void -avma1pp_intr(struct isic_softc *sc) -{ -#define OURS /* no return value accumulated */ -#define ISICINTR(sc) isicintr_sc(sc) -#else -static int -avma1pp_intr(void * parm) +avma1pp_intr(void *xsc) { - struct isic_softc *sc = parm; - int ret = 0; -#define OURS ret = 1 #define ISICINTR(sc) isicintr(sc) -#endif u_char stat; + struct avma1pp_softc *asc; + struct l1_softc *sc; -#ifdef __FreeBSD__ - stat = inb(sc->sc_port + STAT0_OFFSET); -#else - stat = bus_space_read_1(sc->sc_maps[0].t, sc->sc_maps[0].h, STAT0_OFFSET); -#endif + asc = xsc; + sc = asc->avma1pp_isc; + + stat = bus_space_read_1(asc->avma1pp_btag, asc->avma1pp_bhandle, STAT0_OFFSET); DBGL1(L1_H_IRQ, "avma1pp_intr", ("stat %x\n", stat)); /* was there an interrupt from this card ? */ if ((stat & ASL_IRQ_Pending) == ASL_IRQ_Pending) -#ifdef __FreeBSD__ return; /* no */ -#else - return 0; /* no */ -#endif /* interrupts are low active */ if (!(stat & ASL_IRQ_TIMER)) DBGL1(L1_H_IRQ, "avma1pp_intr", ("timer interrupt ???\n")); @@ -1274,85 +1028,18 @@ avma1pp_intr(void * parm) { DBGL1(L1_H_IRQ, "avma1pp_intr", ("HSCX\n")); avma1pp_hscx_int_handler(sc); - OURS; } if (!(stat & ASL_IRQ_ISAC)) { DBGL1(L1_H_IRQ, "avma1pp_intr", ("ISAC\n")); ISICINTR(sc); - OURS; - } -#ifndef __FreeBSD__ - return ret; -#endif -} - -#ifdef __FreeBSD__ -void -avma1pp_map_int(pcici_t config_id, void *pisc, unsigned *net_imask) -{ - struct isic_softc *sc = (struct isic_softc *)pisc; - -#ifdef AVMA1PCI_DEBUG - /* may need the irq later */ -#if __FreeBSD__ < 3 - /* I'd like to call getirq here, but it is static */ - sc->sc_irq = PCI_INTERRUPT_LINE_EXTRACT( - pci_conf_read (config_id, PCI_INTERRUPT_REG)); - - if (sc->sc_irq == 0 || sc->sc_irq == 0xff) - printf ("avma1pp_map_int:int line register not set by bios\n"); - - if (sc->sc_irq >= PCI_MAX_IRQ) - printf ("avma1pp_map_int:irq %d out of bounds (must be < %d)\n", - sc->sc_irq, PCI_MAX_IRQ); -#else - sc->sc_irq = config_id->intline; -#endif -#endif /* AVMA1PCI_DEBUG */ - - if(!(pci_map_int(config_id, (void *)avma1pp_intr, sc, net_imask))) - { - printf("Failed to map interrupt for AVM Fritz!Card PCI\n"); - /* disable the card */ - avma1pp_disable(sc); } } -#else -static void -avma1pp_map_int(struct pci_isic_softc *psc, struct pci_attach_args *pa) -{ - struct isic_softc *sc = &psc->sc_isic; - pci_chipset_tag_t pc = pa->pa_pc; - pci_intr_handle_t ih; - const char *intrstr; - - /* Map and establish the interrupt. */ - if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin, - pa->pa_intrline, &ih)) { - printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname); - avma1pp_disable(sc); - return; - } - intrstr = pci_intr_string(pc, ih); - psc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, avma1pp_intr, sc); - if (psc->sc_ih == NULL) { - printf("%s: couldn't establish interrupt", - sc->sc_dev.dv_xname); - if (intrstr != NULL) - printf(" at %s", intrstr); - printf("\n"); - avma1pp_disable(sc); - return; - } - printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr); -} -#endif static void -avma1pp_hscx_init(struct isic_softc *sc, int h_chan, int activate) +avma1pp_hscx_init(struct l1_softc *sc, int h_chan, int activate) { - isic_Bchan_t *chan = &sc->sc_chan[h_chan]; + l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; u_int param = 0; DBGL1(L1_BCHAN, "avma1pp_hscx_init", ("unit=%d, channel=%d, %s\n", @@ -1406,18 +1093,18 @@ static void avma1pp_bchannel_setup(int unit, int h_chan, int bprot, int activate) { #ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; + struct l1_softc *sc = &l1_sc[unit]; #else - struct isic_softc *sc = isic_find_sc(unit); + struct l1_softc *sc = isic_find_sc(unit); #endif - isic_Bchan_t *chan = &sc->sc_chan[h_chan]; + l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; int s = SPLI4B(); if(activate == 0) { /* deactivation */ - chan->state &= ~HSCX_AVMA1PP_ACTIVE; + chan->state = HSCX_IDLE; avma1pp_hscx_init(sc, h_chan, activate); } @@ -1474,11 +1161,11 @@ static void avma1pp_bchannel_start(int unit, int h_chan) { #ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; + struct l1_softc *sc = &l1_sc[unit]; #else - struct isic_softc *sc = isic_find_sc(unit); + struct l1_softc *sc = isic_find_sc(unit); #endif - register isic_Bchan_t *chan = &sc->sc_chan[h_chan]; + register l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; int s; int activity = -1; @@ -1547,11 +1234,11 @@ static isdn_link_t * avma1pp_ret_linktab(int unit, int channel) { #ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; + struct l1_softc *sc = &l1_sc[unit]; #else - struct isic_softc *sc = isic_find_sc(unit); + struct l1_softc *sc = isic_find_sc(unit); #endif - isic_Bchan_t *chan = &sc->sc_chan[channel]; + l1_bchan_state_t *chan = &sc->sc_chan[channel]; return(&chan->isdn_linktab); } @@ -1563,11 +1250,11 @@ static void avma1pp_set_linktab(int unit, int channel, drvr_link_t *dlt) { #ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; + struct l1_softc *sc = &l1_sc[unit]; #else - struct isic_softc *sc = isic_find_sc(unit); + struct l1_softc *sc = isic_find_sc(unit); #endif - isic_Bchan_t *chan = &sc->sc_chan[channel]; + l1_bchan_state_t *chan = &sc->sc_chan[channel]; chan->drvr_linktab = dlt; } @@ -1577,9 +1264,9 @@ avma1pp_set_linktab(int unit, int channel, drvr_link_t *dlt) * initialize our local linktab *---------------------------------------------------------------------------*/ static void -avma1pp_init_linktab(struct isic_softc *sc) +avma1pp_init_linktab(struct l1_softc *sc) { - isic_Bchan_t *chan = &sc->sc_chan[HSCX_CH_A]; + l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A]; isdn_link_t *lt = &chan->isdn_linktab; /* make sure the hardware driver is known to layer 4 */ @@ -1628,11 +1315,11 @@ static void avma1pp_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp) { #ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; + struct l1_softc *sc = &l1_sc[unit]; #else - struct isic_softc *sc = isic_find_sc(unit); + struct l1_softc *sc = isic_find_sc(unit); #endif - isic_Bchan_t *chan = &sc->sc_chan[h_chan]; + l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; int s; s = SPLI4B(); @@ -1650,13 +1337,13 @@ avma1pp_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp) * fill HSCX fifo with data from the current mbuf * Put this here until it can go into i4b_hscx.c *---------------------------------------------------------------------------*/ -static int -isic_hscx_fifo(isic_Bchan_t *chan, struct isic_softc *sc) +int +isic_hscx_fifo(l1_bchan_state_t *chan, struct l1_softc *sc) { int len; int nextlen; int i; - int cmd; + int cmd = 0; /* using a scratch buffer simplifies writing to the FIFO */ u_char scrbuf[HSCX_FIFO_LEN]; diff --git a/sys/i4b/layer1/i4b_bchan.c b/sys/i4b/layer1/i4b_bchan.c index 24f0aec..8dd6252 100644 --- a/sys/i4b/layer1/i4b_bchan.c +++ b/sys/i4b/layer1/i4b_bchan.c @@ -27,53 +27,33 @@ * i4b_bchan.c - B channel handling L1 procedures * ---------------------------------------------- * + * $Id: i4b_bchan.c,v 1.2 1999/12/13 21:25:26 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Sun Feb 14 10:25:27 1999] + * last edit-date: [Mon Dec 13 21:59:11 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) #include "isic.h" -#else -#define NISIC 1 -#endif #if NISIC > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include #include -#ifdef __FreeBSD__ #include -#include -#else -#ifndef __bsdi__ -#include -#endif -#include -#endif #include #include -#ifdef __FreeBSD__ #include #include #include -#else -#include -#include -#include -#endif #include #include @@ -83,14 +63,8 @@ #include #include -#ifdef __FreeBSD__ static void isic_bchannel_start(int unit, int h_chan); static void isic_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp); -#else -static void isic_bchannel_start __P((int unit, int h_chan)); -static void isic_bchannel_stat __P((int unit, int h_chan, bchan_statistics_t *bsp)); -#endif - static void isic_set_linktab(int unit, int channel, drvr_link_t *dlt); static isdn_link_t *isic_ret_linktab(int unit, int channel); @@ -100,12 +74,8 @@ static isdn_link_t *isic_ret_linktab(int unit, int channel); void isic_bchannel_setup(int unit, int h_chan, int bprot, int activate) { -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif - isic_Bchan_t *chan = &sc->sc_chan[h_chan]; + struct l1_softc *sc = &l1_sc[unit]; + l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; int s = SPLI4B(); @@ -169,13 +139,8 @@ isic_bchannel_setup(int unit, int h_chan, int bprot, int activate) static void isic_bchannel_start(int unit, int h_chan) { -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif - - register isic_Bchan_t *chan = &sc->sc_chan[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; @@ -356,12 +321,8 @@ isic_bchannel_start(int unit, int h_chan) static void isic_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp) { -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif - isic_Bchan_t *chan = &sc->sc_chan[h_chan]; + struct l1_softc *sc = &l1_sc[unit]; + l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; int s; s = SPLI4B(); @@ -381,12 +342,8 @@ isic_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp) static isdn_link_t * isic_ret_linktab(int unit, int channel) { -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif - isic_Bchan_t *chan = &sc->sc_chan[channel]; + struct l1_softc *sc = &l1_sc[unit]; + l1_bchan_state_t *chan = &sc->sc_chan[channel]; return(&chan->isdn_linktab); } @@ -397,12 +354,8 @@ isic_ret_linktab(int unit, int channel) static void isic_set_linktab(int unit, int channel, drvr_link_t *dlt) { -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif - isic_Bchan_t *chan = &sc->sc_chan[channel]; + struct l1_softc *sc = &l1_sc[unit]; + l1_bchan_state_t *chan = &sc->sc_chan[channel]; chan->drvr_linktab = dlt; } @@ -411,9 +364,9 @@ isic_set_linktab(int unit, int channel, drvr_link_t *dlt) * initialize our local linktab *---------------------------------------------------------------------------*/ void -isic_init_linktab(struct isic_softc *sc) +isic_init_linktab(struct l1_softc *sc) { - isic_Bchan_t *chan = &sc->sc_chan[HSCX_CH_A]; + l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A]; isdn_link_t *lt = &chan->isdn_linktab; /* make sure the hardware driver is known to layer 4 */ diff --git a/sys/i4b/layer1/i4b_ctx_s0P.c b/sys/i4b/layer1/i4b_ctx_s0P.c index 5a9eb32..d3fefae 100644 --- a/sys/i4b/layer1/i4b_ctx_s0P.c +++ b/sys/i4b/layer1/i4b_ctx_s0P.c @@ -24,60 +24,42 @@ * *--------------------------------------------------------------------------- * - * isic - I4B Siemens ISDN Chipset Driver for Creatix PnP cards + * isic - I4B Siemens ISDN Chipset Driver for Creatix/Teles PnP * ============================================================ * - * $FreeBSD$ + * $Id: i4b_ctx_s0P.c,v 1.4 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Sun Feb 14 10:25:33 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 21:59:23 1999] + * + * 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. * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - #include "isic.h" #include "opt_i4b.h" -#else - -#define NISIC 1 - -#endif - -#define NPNP 1 - -#if (NISIC > 0) && (NPNP > 0) && defined(CRTX_S0_P) +#if (NISIC > 0) && (defined(CRTX_S0_P) || defined(TEL_S0_16_3_P)) #include - -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif - #include #include #include +#include -#ifdef __FreeBSD__ #include -#include -#else -#include -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include -#else -#include -#include -#endif #include @@ -88,186 +70,156 @@ #include #include -#ifndef __FreeBSD__ -static u_int8_t ctxs0P_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs)); -static void ctxs0P_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)); -static void ctxs0P_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size)); -static void ctxs0P_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size)); -void isic_attach_Cs0P(struct isic_softc *sc); -#endif - -#ifdef __FreeBSD__ -/* #include */ -extern void isicintr ( int unit ); -#endif - /*---------------------------------------------------------------------------* - * Creatix ISDN-S0 P&P ISAC get fifo routine + * Creatix / Teles PnP ISAC get fifo routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -ctxs0P_read_fifo(void *buf, const void *base, size_t len) -{ - insb((int)base + 0x3e, (u_char *)buf, (u_int)len); -} - -#else - static void -ctxs0P_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) +ctxs0P_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - bus_space_read_multi_1(t, h, o + 0x3e, buf, 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); } -#endif - /*---------------------------------------------------------------------------* - * Creatix ISDN-S0 P&P ISAC put fifo routine + * Creatix / Teles PnP ISAC put fifo routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -ctxs0P_write_fifo(void *base, const void *buf, size_t len) -{ - outsb((int)base + 0x3e, (u_char *)buf, (u_int)len); -} - -#else - static void -ctxs0P_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) +ctxs0P_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - bus_space_write_multi_1(t, h, o + 0x3e, (u_int8_t*)buf, 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); } -#endif /*---------------------------------------------------------------------------* - * Creatix ISDN-S0 P&P ISAC put register routine + * Creatix / Teles PnP ISAC put register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -ctxs0P_write_reg(u_char *base, u_int offset, u_int v) -{ - outb((int)base + offset, (u_char)v); -} - -#else - static void -ctxs0P_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) +ctxs0P_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data) { - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - bus_space_write_1(t, h, o + offs, 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); } -#endif /*---------------------------------------------------------------------------* - * Creatix ISDN-S0 P&P ISAC get register routine + * Creatix / Teles PnP ISAC get register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static u_char -ctxs0P_read_reg(u_char *base, u_int offset) -{ - return (inb((int)base + offset)); -} - -#else - static u_int8_t -ctxs0P_read_reg(struct isic_softc *sc, int what, bus_size_t offs) +ctxs0P_read_reg(struct l1_softc *sc, int what, bus_size_t offs) { - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - return bus_space_read_1(t, h, o + 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); } -#endif - -#ifdef __FreeBSD__ - /*---------------------------------------------------------------------------* - * isic_probe_Cs0P - probe for Creatix ISDN-S0 P&P and compatibles + * isic_attach_Cs0P - attach Creatix / Teles PnP *---------------------------------------------------------------------------*/ int -isic_probe_Cs0P(struct isa_device *dev, unsigned int iobase2) +isic_attach_Cs0P(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; - - /* check max unit range */ + u_int32_t iobase1; + u_int32_t iobase2; + 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(dev->id_unit >= ISIC_MAXUNIT) + if(!(sc->sc_resources.io_base[1] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[1], + 0UL, ~0UL, 1, RF_ACTIVE))) { - printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Creatix ISDN-S0 P&P!\n", - dev->id_unit, dev->id_unit); - return(0); - } - sc->sc_unit = dev->id_unit; - - /* check IRQ validity */ + printf("isic%d: Could not get io area 1 for Creatix / Teles PnP!\n", unit); + isic_detach_common(dev); + return ENXIO; + } - switch(ffs(dev->id_irq) - 1) + /* remember the io base addresses */ + + iobase1 = rman_get_start(sc->sc_resources.io_base[0]); + iobase2 = rman_get_start(sc->sc_resources.io_base[1]); + + /* + * because overlapping resources are invalid, + * release the first io port resource + */ + + bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_resources.io_rid[0], + sc->sc_resources.io_base[0]); + + /* 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(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[2], + 0ul, ~0ul, 1, RF_ACTIVE))) { - case 3: - case 5: - case 7: - case 10: - case 11: - case 12: - break; - - default: - printf("isic%d: Error, invalid IRQ [%d] specified for Creatix ISDN-S0 P&P!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); - break; + printf("isic%d: Could not get io area 2 for Creatix / Teles PnP!\n", unit); + isic_detach_common(dev); + return ENXIO; } - sc->sc_irq = dev->id_irq; - /* check if memory addr specified */ + /* + * because overlapping resources are invalid, + * release the second io port resource + */ - if(dev->id_maddr) - { - printf("isic%d: Error, mem addr 0x%lx specified for Creatix ISDN-S0 P&P!\n", - dev->id_unit, (u_long)dev->id_maddr); - return(0); - } - dev->id_msize = 0; + bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_resources.io_rid[1], + sc->sc_resources.io_base[1]); + + /* set and allocate a resource for the HSCX channel A */ - if(iobase2 == 0) - { - printf("isic%d: Error, iobase2 is 0 for Creatix ISDN-S0 P&P!\n", - dev->id_unit); - return(0); - } + 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. + */ - /* check if we got an iobase */ + bus_set_resource(dev, SYS_RES_IOPORT, 3, iobase2-0x20, 0x20); - switch(dev->id_iobase) + if(!(sc->sc_resources.io_base[3] = + bus_alloc_resource(dev,SYS_RES_IOPORT, + &sc->sc_resources.io_rid[3], + 0ul,~0ul, 1, RF_ACTIVE))) { - case 0x120: - case 0x180: -/*XXX*/ break; - - default: - printf("isic%d: Error, invalid iobase 0x%x specified for Creatix ISDN-S0 P&P!\n", - dev->id_unit, dev->id_iobase); - return(0); - break; + printf("isic%d: Could not get io area 3 for Creatix / Teles PnP!\n", unit); + isic_detach_common(dev); + return ENXIO; } - sc->sc_port = dev->id_iobase; + /* 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(dev,SYS_RES_IOPORT, + &sc->sc_resources.io_rid[4], + 0ul, ~0ul, 1, RF_ACTIVE))) + { + printf("isic%d: Could not get io area 4 for Creatix / Teles PnP!\n", unit); + isic_detach_common(dev); + return ENXIO; + } + /* setup access routines */ sc->clearirq = NULL; @@ -287,80 +239,20 @@ isic_probe_Cs0P(struct isa_device *dev, unsigned int iobase2) sc->sc_ipac = 0; sc->sc_bfifolen = HSCX_FIFO_LEN; + + /* enable the card */ - /* setup ISAC and HSCX base addr */ + t = rman_get_bustag(sc->sc_resources.io_base[2]); + h = rman_get_bushandle(sc->sc_resources.io_base[2]); - ISAC_BASE = (caddr_t) dev->id_iobase - 0x20; - HSCX_A_BASE = (caddr_t) iobase2 - 0x20; - HSCX_B_BASE = (caddr_t) iobase2; - - /* - * Read HSCX A/B VSTR. Expected value for the Creatix 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 Creatix PnP\n", - dev->id_unit); - printf("isic%d: HSC0: VSTR: %#x\n", - dev->id_unit, HSCX_READ(0, H_VSTR)); - printf("isic%d: HSC1: VSTR: %#x\n", - dev->id_unit, HSCX_READ(1, H_VSTR)); - return (0); - } - - return (1); -} - -/*---------------------------------------------------------------------------* - * isic_attach_s0163P - attach Creatix ISDN-S0 P&P - *---------------------------------------------------------------------------*/ -int -isic_attach_Cs0P(struct isa_device *dev, unsigned int iobase2) -{ - outb((dev->id_iobase) + 0x1c, 0); - DELAY(SEC_DELAY / 10); - outb((dev->id_iobase) + 0x1c, 1); + bus_space_write_1(t, h, 0x3c, 0); DELAY(SEC_DELAY / 10); - return(1); -} -#else /* !__FreeBSD__ */ - -void -isic_attach_Cs0P(struct isic_softc *sc) -{ - /* init card */ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - bus_space_write_1(t, h, 0x1c, 0); - DELAY(SEC_DELAY / 10); - bus_space_write_1(t, h, 0x1c, 1); + bus_space_write_1(t, h, 0x3c, 1); DELAY(SEC_DELAY / 10); - /* 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 */ - - 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; + return 0; } -#endif -#endif /* (NISIC > 0) && (NPNP > 0) && defined(CRTX_S0_P) */ +#endif /* (NISIC > 0) && (defined(CRTX_S0_P) || defined(TEL_S0_16_3_P)) */ diff --git a/sys/i4b/layer1/i4b_drn_ngo.c b/sys/i4b/layer1/i4b_drn_ngo.c index 0e5346e..9457069 100644 --- a/sys/i4b/layer1/i4b_drn_ngo.c +++ b/sys/i4b/layer1/i4b_drn_ngo.c @@ -27,55 +27,32 @@ * i4b_drn_ngo.c - Dr. Neuhaus Niccy GO@ and SAGEM Cybermod * -------------------------------------------------------- * + * $Id: i4b_drn_ngo.c,v 1.3 1999/12/13 21:25:26 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Sun Feb 14 10:25:39 1999] + * last edit-date: [Mon Dec 13 21:59:30 1999] * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - #include "isic.h" #include "opt_i4b.h" -#else - -#define NISIC 1 - -#endif - -#define NPNP 1 - -#if (NISIC > 0) && (NPNP > 0) && defined(DRN_NGO) +#if (NISIC > 0) && defined(DRN_NGO) #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include +#include -#ifdef __FreeBSD__ #include -#include -#else -#include -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include -#else -#include -#include -#endif #include @@ -112,7 +89,7 @@ #define HSCX_BOFF 0x40 -#define ADDR_OFF 2 /* address register range offset XXX */ +#define ADDR_OFF 2 /* address register range offset */ #define ISAC_DATA 0 #define HSCX_DATA 1 @@ -120,286 +97,155 @@ #define ISAC_ADDR 0 #define HSCX_ADDR 1 -#ifdef __FreeBSD__ - -#if 0 -#define HSCXADEBUG -#define HSCXBDEBUG -#define ISACDEBUG -#else -#undef HSCXADEBUG -#undef HSCXBDEBUG -#undef ISACDEBUG -#endif - /*---------------------------------------------------------------------------* * Dr. Neuhaus Niccy GO@ read fifo routine *---------------------------------------------------------------------------*/ -static void -drnngo_read_fifo(void *buf, const void *base, size_t len) +static void +drnngo_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - register int offset; - register u_int data; - - int x = SPLI4B(); + bus_space_tag_t tdata, tadr; + bus_space_handle_t hdata, hadr; - if((u_int)base & HSCX_ABIT) - { - (u_int)base &= ~HSCX_ABIT; - (u_int)data = ((u_int)base + HSCX_DATA); - (u_int)base += (ADDR_OFF + HSCX_ADDR); - offset = 0; -#ifdef HSCXADEBUG -printf("GO/A/frd: base=0x%x, data=0x%x, len=%d\n", base, data, len); -#endif - } - else if((u_int)base & HSCX_BBIT) - { - (u_int)base &= ~HSCX_BBIT; - (u_int)data = ((u_int)base + HSCX_DATA); - (u_int)base += (ADDR_OFF + HSCX_ADDR); - offset = HSCX_BOFF; -#ifdef HSCXBDEBUG -printf("GO/B/frd: base=0x%x, data=0x%x, len=%d\n", base, data, len); -#endif - } - else - { - (u_int)data = ((u_int)base + ISAC_DATA); - (u_int)base += (ADDR_OFF + ISAC_ADDR); - offset = 0; -#ifdef ISACDEBUG -printf("GO/I/frd: base=0x%x, data=0x%x, len=%d\n", base, data, len); -#endif - } + 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]); - for(;len > 0; len--, offset++) + switch(what) { - outb((int)base, (u_char)offset); - *((u_char *)buf + offset) = inb((int)data); + 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; } - - splx(x); } /*---------------------------------------------------------------------------* * Dr. Neuhaus Niccy GO@ write fifo routine *---------------------------------------------------------------------------*/ static void -drnngo_write_fifo(void *base, const void *buf, size_t len) +drnngo_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - register int offset; - register u_int data; + bus_space_tag_t tdata, tadr; + bus_space_handle_t hdata, hadr; - int x = SPLI4B(); - - if((u_int)base & HSCX_ABIT) - { - (u_int)base &= ~HSCX_ABIT; - (u_int)data = ((u_int)base + HSCX_DATA); - (u_int)base += (ADDR_OFF + HSCX_ADDR); - offset = 0; -#ifdef HSCXADEBUG -printf("GO/A/fwr: base=0x%x, data=0x%x, len=%d\n", base, data, len); -#endif - } - else if((u_int)base & HSCX_BBIT) - { - (u_int)base &= ~HSCX_BBIT; - (u_int)data = ((u_int)base + HSCX_DATA); - (u_int)base += (ADDR_OFF + HSCX_ADDR); - offset = HSCX_BOFF; -#ifdef HSCXBDEBUG -printf("GO/B/fwr: base=0x%x, data=0x%x, len=%d\n", base, data, len); -#endif - } - else - { - (u_int)data = ((u_int)base + ISAC_DATA); - (u_int)base += (ADDR_OFF + ISAC_ADDR); - offset = 0; -#ifdef ISACDEBUG -printf("GO/I/fwr: base=0x%x, data=0x%x, len=%d\n", base, data, len); -#endif - } - - for(;len > 0; len--, offset++) + 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) { - outb((int)base, (u_char)offset); - outb((int)data, *((u_char *)buf + offset)); + 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; } - - splx(x); } /*---------------------------------------------------------------------------* * Dr. Neuhaus Niccy GO@ write register routine *---------------------------------------------------------------------------*/ -static void -drnngo_write_reg(u_char *base, u_int offset, u_int v) +static void +drnngo_write_reg(struct l1_softc *sc, int what, bus_size_t reg, u_int8_t data) { - int x = SPLI4B(); - if((u_int)base & HSCX_ABIT) - { - (u_int)base &= ~HSCX_ABIT; - outb((int)base + ADDR_OFF + HSCX_ADDR, (u_char)offset); - outb((int)base + HSCX_DATA, (u_char)v); -#ifdef HSCXADEBUG -printf("GO/A/rwr: base=0x%x, addr=0x%x, offset=0x%x, val=0x%x\n", - (int)base + ADDR_OFF + HSCX_ADDR, (int)base + HSCX_DATA, - (u_char)offset, (u_char)v); -#endif - } - else if((u_int)base & HSCX_BBIT) - { - (u_int)base &= ~HSCX_BBIT; - outb((int)base + ADDR_OFF + HSCX_ADDR, (u_char)(offset + HSCX_BOFF)); - outb((int)base + HSCX_DATA, (u_char)v); -#ifdef HSCXBDEBUG -printf("GO/B/rwr: base=0x%x, addr=0x%x, offset=0x%x, val=0x%x\n", - (int)base + ADDR_OFF + HSCX_ADDR, (int)base + HSCX_DATA, - (u_char)(offset + HSCX_BOFF), (u_char)v); -#endif - } - else + 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) { - outb((int)base + ADDR_OFF + ISAC_ADDR, (u_char)offset); - outb((int)base + ISAC_DATA, (u_char)v); -#ifdef ISACDEBUG -printf("GO/I/rwr: base=0x%x, addr=0x%x, offset=0x%x, val=0x%x\n", - (int)base + ADDR_OFF + ISAC_ADDR, (int)base + ISAC_DATA, - (u_char)offset, (u_char)v); -#endif + 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; } - splx(x); } /*---------------------------------------------------------------------------* * Dr. Neuhaus Niccy GO@ read register routine *---------------------------------------------------------------------------*/ -static u_char -drnngo_read_reg(u_char *base, u_int offset) +static u_int8_t +drnngo_read_reg(struct l1_softc *sc, int what, bus_size_t reg) { - u_char val; - int x = SPLI4B(); - - if((u_int)base & HSCX_ABIT) - { - (u_int)base &= ~HSCX_ABIT; - outb((int)base + ADDR_OFF + HSCX_ADDR, (u_char)offset); - val = inb((int)base + HSCX_DATA); -#ifdef HSCXADEBUG -printf("GO/A/rrd: base=0x%x, addr=0x%x, offset=0x%x, val=0x%x\n", - (int)base + ADDR_OFF + HSCX_ADDR, (int)base + HSCX_DATA, - (u_char)offset, (u_char)val); -#endif - } - else if((u_int)base & HSCX_BBIT) + 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) { - (u_int)base &= ~HSCX_BBIT; - outb((int)base + ADDR_OFF + HSCX_ADDR, (u_char)(offset + HSCX_BOFF)); - val = inb((int)base + HSCX_DATA); -#ifdef HSCXBDEBUG -printf("GO/B/rrd: base=0x%x, addr=0x%x, offset=0x%x, val=0x%x\n", - (int)base + ADDR_OFF + HSCX_ADDR, (int)base + HSCX_DATA, - (u_char)(offset + HSCX_BOFF), (u_char)val); -#endif + 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; } - else - { - outb((int)base + ADDR_OFF + ISAC_ADDR, (u_char)offset); - val = inb((int)base + ISAC_DATA); -#ifdef ISACDEBUG -printf("GO/I/rrd: base=0x%x, addr=0x%x, offset=0x%x, val=0x%x\n", - (int)base + ADDR_OFF + ISAC_ADDR, (int)base + ISAC_DATA, - (u_char)offset, (u_char)val); -#endif - } - splx(x); - return(val); } /*---------------------------------------------------------------------------* - * isic_probe_drnngo - probe for Dr. Neuhaus Niccy GO@ + * probe for ISA PnP cards *---------------------------------------------------------------------------*/ int -isic_probe_drnngo(struct isa_device *dev, unsigned int iobase2) +isic_attach_drnngo(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; - - /* check max unit range */ - - if(dev->id_unit >= ISIC_MAXUNIT) - { - printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Dr. Neuhaus Niccy GO@!\n", - dev->id_unit, dev->id_unit); - return(0); - } - sc->sc_unit = dev->id_unit; - - /* check IRQ validity */ - - switch(ffs(dev->id_irq)-1) - { - case 3: - case 4: - case 5: - case 9: - case 10: - case 11: - case 12: - case 15: - break; - - default: - printf("isic%d: Error, invalid IRQ [%d] specified for Dr. Neuhaus Niccy GO@!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); - break; - } - sc->sc_irq = dev->id_irq; - - /* check if memory addr specified */ - - if(dev->id_maddr) - { - printf("isic%d: Error, mem addr 0x%lx specified for Dr. Neuhaus Niccy GO@!\n", - dev->id_unit, (u_long)dev->id_maddr); - return(0); - } - dev->id_msize = 0; - - /* check if we got an iobase */ + int unit = device_get_unit(dev); + struct l1_softc *sc = &l1_sc[unit]; - if(dev->id_iobase < NICCY_PORT_MIN || dev->id_iobase > NICCY_PORT_MAX) - { - printf("isic%d: Error, invalid iobase 0x%x specified for Dr. Neuhaus Niccy GO@!\n", - dev->id_unit, dev->id_iobase); - return(0); - } - sc->sc_port = dev->id_iobase; + sc->sc_resources.io_rid[1] = 1; - if(iobase2 == 0) - { - printf("isic%d: Error, iobase2 is 0 for Dr. Neuhaus Niccy GO@!\n", - dev->id_unit); - return(0); - } + /* + * this card needs a second io_base, + * free resources if we don't get it + */ - if(iobase2 < NICCY_PORT_MIN || iobase2 > NICCY_PORT_MAX) + if(!(sc->sc_resources.io_base[1] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[1], + 0UL, ~0UL, 1, RF_ACTIVE))) { - printf("isic%d: Error, invalid port1 0x%x specified for Dr. Neuhaus Niccy GO@!\n", - dev->id_unit, iobase2); - return(0); + printf("isic%d: Failed to get second io base.\n", unit); + isic_detach_common(dev); + return ENXIO; } -/*XXX*/ if((dev->id_iobase + 2) != iobase2) - { - printf("isic%d: Error, port1 must be (port0+2) for Dr.Neuhaus Niccy GO@!\n", - dev->id_unit); - return(0); - } - /* setup ISAC access routines */ sc->clearirq = NULL; @@ -420,123 +266,7 @@ isic_probe_drnngo(struct isa_device *dev, unsigned int iobase2) sc->sc_ipac = 0; sc->sc_bfifolen = HSCX_FIFO_LEN; - /* setup ISAC and HSCX base addr */ - - ISAC_BASE = (caddr_t)dev->id_iobase; - HSCX_A_BASE = (caddr_t)(((u_int)dev->id_iobase) | HSCX_ABIT); - HSCX_B_BASE = (caddr_t)(((u_int)dev->id_iobase) | HSCX_BBIT); - - /* - * Read HSCX A/B VSTR. Expected value for Dr. Neuhaus Niccy GO@ 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 Dr. Neuhaus Niccy GO@\n", - dev->id_unit); - printf("isic%d: HSC0: VSTR: %#x\n", - dev->id_unit, HSCX_READ(0, H_VSTR)); - printf("isic%d: HSC1: VSTR: %#x\n", - dev->id_unit, HSCX_READ(1, H_VSTR)); - return (0); - } - - return (1); -} - -/*---------------------------------------------------------------------------* - * isic_attach_drnngo - attach Dr. Neuhaus Niccy GO@ - *---------------------------------------------------------------------------*/ -int -isic_attach_drnngo(struct isa_device *dev, unsigned int iobase2) -{ - return (1); -} - -#else - -static u_int8_t drnngo_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs)); -static void drnngo_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)); -static void drnngo_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size)); -static void drnngo_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size)); -void isic_attach_drnngo __P((struct isic_softc *sc)); - -/* - * Mapping from "what" parameter to offsets into the io map - */ -static struct { - bus_size_t oa, /* address register offset */ - od, /* data register offset */ - or; /* additional chip register offset */ -} offset[] = -{ - { ISAC_ADDR, ISAC_DATA, 0 }, /* ISAC access */ - { HSCX_ADDR, HSCX_DATA, 0 }, /* HSCX A access */ - { HSCX_ADDR, HSCX_DATA, HSCX_BOFF } /* HSCX B access */ -}; - -static void -drnngo_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t hd = sc->sc_maps[0].h, ha = sc->sc_maps[1].h; - bus_space_write_1(t, ha, offset[what].oa, offset[what].or); - bus_space_read_multi_1(t, hd, offset[what].od, buf, size); + return (0); } -static void -drnngo_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t hd = sc->sc_maps[0].h, ha = sc->sc_maps[1].h; - bus_space_write_1(t, ha, offset[what].oa, offset[what].or); - bus_space_write_multi_1(t, hd, offset[what].od, (u_int8_t*)buf, size); -} - -static void -drnngo_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t hd = sc->sc_maps[0].h, ha = sc->sc_maps[1].h; - bus_space_write_1(t, ha, offset[what].oa, offs+offset[what].or); - bus_space_write_1(t, hd, offset[what].od, data); -} - -static u_int8_t -drnngo_read_reg(struct isic_softc *sc, int what, bus_size_t offs) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t hd = sc->sc_maps[0].h, ha = sc->sc_maps[1].h; - bus_space_write_1(t, ha, offset[what].oa, offs+offset[what].or); - return bus_space_read_1(t, hd, offset[what].od); -} - -void -isic_attach_drnngo(struct isic_softc *sc) -{ - /* setup 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; -} - -#endif - -#endif /* (NISIC > 0) && (NPNP > 0) && defined(DRN_NGO) */ +#endif /* (NISIC > 0) && defined(DRN_NGO) */ diff --git a/sys/i4b/layer1/i4b_elsa_pcc16.c b/sys/i4b/layer1/i4b_elsa_pcc16.c new file mode 100644 index 0000000..84910e8 --- /dev/null +++ b/sys/i4b/layer1/i4b_elsa_pcc16.c @@ -0,0 +1,392 @@ +/* + * Copyright (c) 1999 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/PCC-16 + * ===================================================================== + * + * $Id: i4b_elsa_pcc16.c,v 1.2 1999/12/13 21:25:26 hm Exp $ + * + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 21:59:36 1999] + * + *---------------------------------------------------------------------------*/ + +#include "isic.h" +#include "opt_i4b.h" + +#if (NISIC > 0) && defined(ELSA_PCC16) + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +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 */ + + sc->sc_flags = FLAG_ELSA_PCC16; /* set flags */ + + /* see if an io base was supplied */ + + if(!(sc->sc_resources.io_base[0] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[0], + 0ul, ~0ul, 1, 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_ELSAQS1ISA; + + /* 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) ) + { + printf("isic%d: HSCX VSTR test failed for ELSA MicroLink ISDN/PCC-16\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_Epcc16(dev); + return (ENXIO); + } + + /* get our irq */ + + if(!(sc->sc_resources.irq = + bus_alloc_resource(dev, SYS_RES_IRQ, + &sc->sc_resources.irq_rid, + 0ul, ~0ul, 1, 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 /* (NISIC > 0) && defined(ELSA_PCC16) */ diff --git a/sys/i4b/layer1/i4b_elsa_qs1i.c b/sys/i4b/layer1/i4b_elsa_qs1i.c index 88bb6a7..5746c1f 100644 --- a/sys/i4b/layer1/i4b_elsa_qs1i.c +++ b/sys/i4b/layer1/i4b_elsa_qs1i.c @@ -27,30 +27,18 @@ * isic - I4B Siemens ISDN Chipset Driver for ELSA Quickstep 1000pro ISA * ===================================================================== * + * $Id: i4b_elsa_qs1i.c,v 1.3 1999/12/13 21:25:26 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Tue Mar 16 15:42:10 1999] + * last edit-date: [Mon Dec 13 21:59:44 1999] * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - #include "isic.h" #include "opt_i4b.h" -#else - -#define NISIC 1 - -#endif - -#define NPNP 1 - -/* - * this driver works for both the ELSA QuickStep 1000 PNP and the ELSA - * PCC-16 - */ -#if (NISIC > 0) && (((NPNP > 0) && defined(ELSA_QS1ISA)) || defined(ELSA_PCC16)) +#if (NISIC > 0) && defined(ELSA_QS1ISA) #include #include @@ -59,27 +47,11 @@ #include #include -#ifdef __FreeBSD__ -#if __FreeBSD__ >= 3 #include -#else -#include -#endif #include -#include -/* #include */ -#else -#include -#include -#endif - -#ifdef __FreeBSD__ + #include #include -#else -#include -#include -#endif #include #include @@ -89,12 +61,7 @@ #include #include -#ifdef __FreeBSD__ -static void i4b_eq1i_clrirq(void* base); -#else -static void i4b_eq1i_clrirq(struct isic_softc *sc); -void isic_attach_Eqs1pi __P((struct isic_softc *sc)); -#endif +static void i4b_eq1i_clrirq(struct l1_softc *sc); /* masks for register encoded in base addr */ @@ -128,55 +95,23 @@ void isic_attach_Eqs1pi __P((struct isic_softc *sc)); /*---------------------------------------------------------------------------* * ELSA QuickStep 1000pro/ISA clear IRQ routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -static void -i4b_eq1i_clrirq(void* base) -{ - outb((u_int)base + ELSA_OFF_IRQ, 0); -} - -#else static void -i4b_eq1i_clrirq(struct isic_softc *sc) +i4b_eq1i_clrirq(struct l1_softc *sc) { - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; + 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); } -#endif /*---------------------------------------------------------------------------* * ELSA QuickStep 1000pro/ISA ISAC get fifo routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -eqs1pi_read_fifo(void *buf, const void *base, size_t len) -{ - if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXB) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, 0x40); - insb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_HSCX), (u_char *)buf, (u_int)len); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXA) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, 0); - insb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_HSCX), (u_char *)buf, (u_int)len); - } - else /* if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDISAC) */ - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, 0); - insb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ISAC), (u_char *)buf, (u_int)len); - } -} - -#else - static void -eqs1pi_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) +eqs1pi_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; + 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); @@ -193,89 +128,40 @@ eqs1pi_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) } } -#endif - /*---------------------------------------------------------------------------* * ELSA QuickStep 1000pro/ISA ISAC put fifo routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - static void -eqs1pi_write_fifo(void *base, const void *buf, size_t len) +eqs1pi_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXB) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, 0x40); - outsb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_HSCX), (u_char *)buf, (u_int)len); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXA) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, 0); - outsb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_HSCX), (u_char *)buf, (u_int)len); - } - else /* if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDISAC) */ - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, 0); - outsb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ISAC), (u_char *)buf, (u_int)len); - } -} - -#else + 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]); -static void -eqs1pi_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; 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, (u_int8_t*)buf, size); + 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, (u_int8_t*)buf, size); + 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, (u_int8_t*)buf, size); + bus_space_write_multi_1(t, h, ELSA_OFF_HSCX, buf, size); break; } } -#endif /*---------------------------------------------------------------------------* * ELSA QuickStep 1000pro/ISA ISAC put register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - static void -eqs1pi_write_reg(u_char *base, u_int offset, u_int v) +eqs1pi_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data) { - if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXB) - { - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, (u_char)(offset+0x40)); - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_HSCX, (u_char)v); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXA) - { - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, (u_char)offset); - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_HSCX, (u_char)v); - } - else /* if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDISAC) */ - { - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, (u_char)offset); - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ISAC, (u_char)v); - } -} - -#else + 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]); -static void -eqs1pi_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; switch (what) { case ISIC_WHAT_ISAC: bus_space_write_1(t, h, ELSA_OFF_OFF, offs); @@ -291,40 +177,16 @@ eqs1pi_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data break; } } -#endif /*---------------------------------------------------------------------------* * ELSA QuickStep 1000pro/ISA ISAC get register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static u_char -eqs1pi_read_reg(u_char *base, u_int offset) -{ - if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXB) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, (u_char)(offset+0x40)); - return(inb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_HSCX)); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXA) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, (u_char)offset); - return(inb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_HSCX)); - } - else /* if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDISAC) */ - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_OFF, (u_char)offset); - return(inb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ISAC)); - } -} - -#else - static u_int8_t -eqs1pi_read_reg(struct isic_softc *sc, int what, bus_size_t offs) +eqs1pi_read_reg(struct l1_softc *sc, int what, bus_size_t offs) { - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; + 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); @@ -339,69 +201,18 @@ eqs1pi_read_reg(struct isic_softc *sc, int what, bus_size_t offs) return 0; } -#endif - -#ifdef __FreeBSD__ - /*---------------------------------------------------------------------------* - * isic_probe_Eqs1pi - probe for ELSA QuickStep 1000pro/ISA and compatibles + * isic_attach_Eqs1pi - attach for ELSA QuickStep 1000pro/ISA *---------------------------------------------------------------------------*/ int -isic_probe_Eqs1pi(struct isa_device *dev, unsigned int iobase2) +isic_attach_Eqs1pi(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; - - /* check max unit range */ - - if(dev->id_unit >= ISIC_MAXUNIT) - { - printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for ELSA QuickStep 1000pro/ISA!\n", - dev->id_unit, dev->id_unit); - return(0); - } - sc->sc_unit = dev->id_unit; - - /* check IRQ validity */ - - switch(ffs(dev->id_irq) - 1) - { - case 3: - case 4: - case 5: - case 7: - case 10: - case 11: - case 12: - case 15: - break; - - default: - printf("isic%d: Error, invalid IRQ [%d] specified for ELSA QuickStep 1000pro/ISA!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); - break; - } - sc->sc_irq = dev->id_irq; + 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]); - /* check if memory addr specified */ - - if(dev->id_maddr) - { - printf("isic%d: Error, mem addr 0x%lx specified for ELSA QuickStep 1000pro/ISA!\n", - dev->id_unit, (u_long)dev->id_maddr); - return(0); - } - dev->id_msize = 0; - - /* check if we got an iobase */ - - if(!((dev->id_iobase >= 0x160) && (dev->id_iobase <= 0x360))) - { - printf("isic%d: Error, invalid iobase 0x%x specified for ELSA QuickStep 1000pro/ISA!\n", - dev->id_unit, dev->id_iobase); - return(0); - } - sc->sc_port = dev->id_iobase; + u_char byte = ELSA_CTRL_SECRET; /* setup access routines */ @@ -423,61 +234,8 @@ isic_probe_Eqs1pi(struct isa_device *dev, unsigned int iobase2) sc->sc_ipac = 0; sc->sc_bfifolen = HSCX_FIFO_LEN; - /* setup ISAC and HSCX base addr */ + /* enable the card */ - ISAC_BASE = (caddr_t) ((u_int)dev->id_iobase | ELSA_IDISAC); - HSCX_A_BASE = (caddr_t) ((u_int)dev->id_iobase | ELSA_IDHSCXA); - HSCX_B_BASE = (caddr_t) ((u_int)dev->id_iobase | ELSA_IDHSCXB); - - /* - * Read HSCX A/B VSTR. Expected value for the ELSA QuickStep 1000pro - * ISA 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 ELSA QuickStep 1000pro/ISA\n", - dev->id_unit); - printf("isic%d: HSC0: VSTR: %#x\n", - dev->id_unit, HSCX_READ(0, H_VSTR)); - printf("isic%d: HSC1: VSTR: %#x\n", - dev->id_unit, HSCX_READ(1, H_VSTR)); - return (0); - } - - return (1); -} - -/*---------------------------------------------------------------------------* - * isic_attach_s0163P - attach ELSA QuickStep 1000pro/ISA - *---------------------------------------------------------------------------*/ -int -isic_attach_Eqs1pi(struct isa_device *dev, unsigned int iobase2) -{ - u_char byte = ELSA_CTRL_SECRET; - - byte &= ~ELSA_CTRL_RESET; - outb(dev->id_iobase + ELSA_OFF_CTRL, byte); - DELAY(20); - byte |= ELSA_CTRL_RESET; - outb(dev->id_iobase + ELSA_OFF_CTRL, byte); - - DELAY(20); - outb(dev->id_iobase + ELSA_OFF_IRQ, 0xff); - - return(1); -} - -#else /* !__FreeBSD__ */ - -void -isic_attach_Eqs1pi(struct isic_softc *sc) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - u_char byte = ELSA_CTRL_SECRET; - byte &= ~ELSA_CTRL_RESET; bus_space_write_1(t, h, ELSA_OFF_CTRL, byte); DELAY(20); @@ -487,27 +245,6 @@ isic_attach_Eqs1pi(struct isic_softc *sc) DELAY(20); bus_space_write_1(t, h, ELSA_OFF_IRQ, 0xff); - /* 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; + return 0; } - -#endif - -#endif /* (NISIC > 0) && (NPNP > 0) && defined(ELSA_QS1ISA) */ +#endif /* (NISIC > 0) && defined(ELSA_QS1ISA) */ diff --git a/sys/i4b/layer1/i4b_elsa_qs1p.c b/sys/i4b/layer1/i4b_elsa_qs1p.c index 3c80e68..d407263 100644 --- a/sys/i4b/layer1/i4b_elsa_qs1p.c +++ b/sys/i4b/layer1/i4b_elsa_qs1p.c @@ -24,24 +24,24 @@ * *--------------------------------------------------------------------------- * - * isic - I4B Siemens ISDN Chipset Driver for ELSA Quickstep 1000pro PCI - * ===================================================================== + * isic - I4B Siemens ISDN Chipset Driver for ELSA MicroLink ISDN/PCI + * ================================================================== + * + * $Id: i4b_elsa_qs1p.c,v 1.2 1999/12/13 21:25:26 hm Exp $ * * $FreeBSD$ * - * last edit-date: [Wed Mar 10 07:24:32 1999] + * last edit-date: [Mon Dec 13 21:59:51 1999] + * + * Note: ELSA Quickstep 1000pro PCI = ELSA MicroLink ISDN/PCI * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) #include "isic.h" #include "opt_i4b.h" #include "pci.h" -#else -#define NISIC 1 -#endif -#if (NISIC > 0) && /* (NPCI > 0) && */ defined(ELSA_QS1PCI) +#if (NISIC > 0) && (NPCI > 0) && defined(ELSA_QS1PCI) #include #include @@ -50,31 +50,19 @@ #include #include -#ifdef __FreeBSD__ -#if __FreeBSD__ >= 3 #include -#else -#include -#endif #include -#include -#else + #include -#include -#endif +#include +#include +#include + +#include +#include -#ifdef __FreeBSD__ #include #include -#else - -#include -#include -#include - -#include -#include -#endif #include #include @@ -85,9 +73,15 @@ #include #include -#ifndef __FreeBSD__ -#include -#endif +#define MEM0_MAPOFF 0 +#define PORT0_MAPOFF 4 +#define PORT1_MAPOFF 12 + +#define ELSA_PORT0_MAPOFF (PCI_MAP_REG_START+PORT0_MAPOFF) +#define ELSA_PORT1_MAPOFF (PCI_MAP_REG_START+PORT1_MAPOFF) + +#define PCI_QS1000_DID 0x1000 +#define PCI_QS1000_VID 0x1048 /* masks for register encoded in base addr */ @@ -106,42 +100,38 @@ #define ELSA_OFF_ALE 0x00 #define ELSA_OFF_RW 0x01 -#define ELSA_PORT0_MAPOFF PCI_MAPREG_START+4 -#define ELSA_PORT1_MAPOFF PCI_MAPREG_START+12 -/*---------------------------------------------------------------------------* - * ELSA QuickStep 1000pro/PCI ISAC get fifo routine - *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ +static int eqs1p_pci_probe(device_t dev); +static int eqs1p_pci_attach(device_t dev); -static void -eqs1pp_read_fifo(void *buf, const void *base, size_t len) -{ - if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXB) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, IPAC_HSCXB_OFF); - insb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW), (u_char *)buf, (u_int)len); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXA) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, IPAC_HSCXA_OFF); - insb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW), (u_char *)buf, (u_int)len); - } - else /* if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDISAC) */ - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, IPAC_ISAC_OFF); - insb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW), (u_char *)buf, (u_int)len); - } -} +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 +}; -#else +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 isic_softc *sc, int what, void *buf, size_t size) +eqs1pp_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; - switch (what) { + 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); @@ -157,41 +147,17 @@ eqs1pp_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) } } -#endif - /*---------------------------------------------------------------------------* - * ELSA QuickStep 1000pro/PCI ISAC put fifo routine + * ELSA MicroLink ISDN/PCI fifo write routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - static void -eqs1pp_write_fifo(void *base, const void *buf, size_t len) +eqs1pp_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXB) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, IPAC_HSCXB_OFF); - outsb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW), (u_char *)buf, (u_int)len); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXA) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, IPAC_HSCXA_OFF); - outsb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW), (u_char *)buf, (u_int)len); - } - else /* if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDISAC) */ - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, IPAC_ISAC_OFF); - outsb((((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW), (u_char *)buf, (u_int)len); - } -} + 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]); -#else - -static void -eqs1pp_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; - switch (what) { + 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); @@ -206,46 +172,18 @@ eqs1pp_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) break; } } -#endif /*---------------------------------------------------------------------------* - * ELSA QuickStep 1000pro/PCI ISAC put register routine + * ELSA MicroLink ISDN/PCI register write routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - static void -eqs1pp_write_reg(u_char *base, u_int offset, u_int v) +eqs1pp_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data) { - if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXB) - { - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF)); - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW, (u_char)v); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXA) - { - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF)); - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW, (u_char)v); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDISAC) - { - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF)); - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW, (u_char)v); - } - else /* IPAC */ - { - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF)); - outb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW, (u_char)v); - } -} + 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]); -#else - -static void -eqs1pp_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) -{ - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; - switch (what) { + 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); @@ -264,46 +202,18 @@ eqs1pp_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data break; } } -#endif /*---------------------------------------------------------------------------* - * ELSA QuickStep 1000pro/PCI ISAC get register routine + * ELSA MicroLink ISDN/PCI register read routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static u_char -eqs1pp_read_reg(u_char *base, u_int offset) -{ - if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXB) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF)); - return(inb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW)); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDHSCXA) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF)); - return(inb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW)); - } - else if(((u_int)base & ELSA_OFF_MASK) == ELSA_IDISAC) - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF)); - return(inb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW)); - } - else /* IPAC */ - { - outb((u_int)((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF)); - return(inb(((u_int)base & ELSA_BASE_MASK) + ELSA_OFF_RW)); - } -} - -#else - static u_int8_t -eqs1pp_read_reg(struct isic_softc *sc, int what, bus_size_t offs) +eqs1pp_read_reg(struct l1_softc *sc, int what, bus_size_t offs) { - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; - switch (what) { + 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); @@ -314,112 +224,90 @@ eqs1pp_read_reg(struct isic_softc *sc, int what, bus_size_t offs) 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; } -#endif +/*---------------------------------------------------------------------------* + * 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 QuickStep 1000pro/PCI + * isic_attach_Eqs1pp - attach for ELSA MicroLink ISDN/PCI *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -int -isic_attach_Eqs1pp(int unit, unsigned int iobase1, unsigned int iobase2) +static int +eqs1p_pci_attach(device_t dev) { - struct isic_softc *sc = &isic_sc[unit]; + 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 QuickStep 1000pro/PCI!\n", + printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for ELSA MicroLink ISDN/PCI!\n", unit, unit); - return(0); + return(ENXIO); } + + sc = &l1_sc[unit]; /* get softc */ + sc->sc_unit = unit; - /* setup iobase */ + /* get io_base */ - if((iobase2 <= 0) || (iobase2 > 0xffff)) + sc->sc_resources.io_rid[0] = ELSA_PORT0_MAPOFF; + + if(!(sc->sc_resources.io_base[0] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[0], + 0UL, ~0UL, 1, RF_ACTIVE))) { - printf("isic%d: Error, invalid iobase 0x%x specified for ELSA QuickStep 1000pro/PCI!\n", - unit, iobase2); - return(0); + printf("isic%d: Couldn't get first iobase for ELSA MicroLink ISDN/PCI!\n", unit); + return(ENXIO); } - sc->sc_port = iobase2; - - /* 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; - - /* setup ISAC and HSCX base addr */ + sc->sc_resources.io_rid[1] = ELSA_PORT1_MAPOFF; - ISAC_BASE = (caddr_t) ((u_int)iobase2 | ELSA_IDISAC); - HSCX_A_BASE = (caddr_t) ((u_int)iobase2 | ELSA_IDHSCXA); - HSCX_B_BASE = (caddr_t) ((u_int)iobase2 | ELSA_IDHSCXB); - IPAC_BASE = (caddr_t) ((u_int)iobase2 | ELSA_IDIPAC); - - /* 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 */ - - outb(iobase1 + 0x4c, 0x41); /* enable card interrupt */ - - return (1); -} + if(!(sc->sc_resources.io_base[1] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[1], + 0UL, ~0UL, 1, RF_ACTIVE))) + { + printf("isic%d: Couldn't get second iobase for ELSA MicroLink ISDN/PCI!\n", unit); + isic_detach_common(dev); + return(ENXIO); + } -#else /* !FreeBSD */ + sc->sc_port = rman_get_start(sc->sc_resources.io_base[1]); -void -isic_attach_Eqs1pp(psc, pa) - struct pci_isic_softc *psc; - struct pci_attach_args *pa; -{ - struct isic_softc *sc = &psc->sc_isic; - - /* setup io mappings */ - sc->sc_num_mappings = 2; - MALLOC_MAPS(sc); - sc->sc_maps[0].size = 0; - if (pci_mapreg_map(pa, ELSA_PORT0_MAPOFF, PCI_MAPREG_TYPE_IO, 0, - &sc->sc_maps[0].t, &sc->sc_maps[0].h, NULL, NULL)) { - printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname); - return; - } - sc->sc_maps[1].size = 0; - if (pci_mapreg_map(pa, ELSA_PORT1_MAPOFF, PCI_MAPREG_TYPE_IO, 0, - &sc->sc_maps[1].t, &sc->sc_maps[1].h, NULL, NULL)) { - printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname); - return; + if(!(sc->sc_resources.irq = + bus_alloc_resource(dev, SYS_RES_IRQ, + &sc->sc_resources.irq_rid, + 0UL, ~0UL, 1, RF_ACTIVE))) + { + 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 */ @@ -442,8 +330,24 @@ isic_attach_Eqs1pp(psc, pa) 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 */ @@ -451,9 +355,12 @@ isic_attach_Eqs1pp(psc, pa) (IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2)); IPAC_WRITE(IPAC_ATX, 0xff); /* set all output lines high */ - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, 0x4c, 0x41); /* enable card interrupt */ + 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 - -#endif /* (NISIC > 0) && defined(ELSA_QS1PCI) */ +#endif /* (NISIC > 0) && (NPCI > 0) && defined(ELSA_QS1PCI) */ diff --git a/sys/i4b/layer1/i4b_hscx.c b/sys/i4b/layer1/i4b_hscx.c index efa1e7b..36aef24 100644 --- a/sys/i4b/layer1/i4b_hscx.c +++ b/sys/i4b/layer1/i4b_hscx.c @@ -27,52 +27,33 @@ * i4b - Siemens HSCX chip (B-channel) handling * -------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_hscx.c,v 1.2 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Wed Mar 17 11:59:05 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 21:59:58 1999] * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ #include "isic.h" -#else -#define NISIC 1 /* doesn't matter in non-FreeBSD, config(8) d.t.r.t. */ -#endif + #if NISIC > 0 #include -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 #include -#else -#include -#endif #include #include #include -#include +#include -#ifdef __FreeBSD__ +#include #include -#include -#else -#ifndef __bsdi__ -#include -#endif -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include #include -#else -#include -#include -#include -#endif #include #include @@ -86,9 +67,9 @@ * HSCX IRQ Handler *---------------------------------------------------------------------------*/ void -isic_hscx_irq(register struct isic_softc *sc, u_char ista, int h_chan, u_char ex_irq) +isic_hscx_irq(register struct l1_softc *sc, u_char ista, int h_chan, u_char ex_irq) { - register isic_Bchan_t *chan = &sc->sc_chan[h_chan]; + register l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; u_char exir = 0; int activity = -1; u_char cmd = 0; @@ -467,9 +448,9 @@ isic_hscx_irq(register struct isic_softc *sc, u_char ista, int h_chan, u_char ex * for raw hdlc: transparent mode 0 *---------------------------------------------------------------------------*/ void -isic_hscx_init(struct isic_softc *sc, int h_chan, int activate) +isic_hscx_init(struct l1_softc *sc, int h_chan, int activate) { - isic_Bchan_t *chan = &sc->sc_chan[h_chan]; + l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; HSCX_WRITE(h_chan, H_MASK, 0xff); /* mask irq's */ @@ -634,7 +615,7 @@ isic_hscx_init(struct isic_softc *sc, int h_chan, int activate) * write command to HSCX command register *---------------------------------------------------------------------------*/ void -isic_hscx_cmd(struct isic_softc *sc, int h_chan, unsigned char cmd) +isic_hscx_cmd(struct l1_softc *sc, int h_chan, unsigned char cmd) { int timeout = 20; @@ -656,7 +637,7 @@ isic_hscx_cmd(struct isic_softc *sc, int h_chan, unsigned char cmd) * wait for HSCX transmit FIFO write enable *---------------------------------------------------------------------------*/ void -isic_hscx_waitxfw(struct isic_softc *sc, int h_chan) +isic_hscx_waitxfw(struct l1_softc *sc, int h_chan) { #define WAITVAL 50 #define WAITTO 200 diff --git a/sys/i4b/layer1/i4b_hscx.h b/sys/i4b/layer1/i4b_hscx.h index ed4208a..e642698 100644 --- a/sys/i4b/layer1/i4b_hscx.h +++ b/sys/i4b/layer1/i4b_hscx.h @@ -30,15 +30,13 @@ * *--------------------------------------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_hscx.h,v 1.2 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Sun Feb 14 10:26:56 1999] + * $FreeBSD$ * - * -hm added AVM config register defs - * -hm split up for rewrite of Siemens chipset driver + * last edit-date: [Mon Dec 13 22:00:49 1999] * - *--------------------------------------------------------------------------- - */ + *---------------------------------------------------------------------------*/ #ifndef I4B_HSCX_H_ #define I4B_HSCX_H_ diff --git a/sys/i4b/layer1/i4b_ipac.h b/sys/i4b/layer1/i4b_ipac.h index 4c2483e..73683d3 100644 --- a/sys/i4b/layer1/i4b_ipac.h +++ b/sys/i4b/layer1/i4b_ipac.h @@ -27,9 +27,11 @@ * i4b_ipac.h - definitions for the Siemens IPAC PSB2115 chip * ========================================================== * + * $Id: i4b_ipac.h,v 1.2 1999/12/13 21:25:26 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Tue Jun 8 09:53:26 1999] + * last edit-date: [Mon Dec 13 22:00:58 1999] * *--------------------------------------------------------------------------- */ diff --git a/sys/i4b/layer1/i4b_isac.c b/sys/i4b/layer1/i4b_isac.c index 64d20e7..1171463 100644 --- a/sys/i4b/layer1/i4b_isac.c +++ b/sys/i4b/layer1/i4b_isac.c @@ -27,55 +27,35 @@ * i4b_isac.c - i4b siemens isdn chipset driver ISAC handler * --------------------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_isac.c,v 1.2 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Sun Feb 14 10:27:09 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:01:05 1999] * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ #include "isic.h" -#else -#define NISIC 1 /* non-FreeBSD handles this via config(8) */ -#endif + #if NISIC > 0 -#ifdef __FreeBSD__ #include "opt_i4b.h" -#endif + #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include -#include +#include -#ifdef __FreeBSD__ +#include #include -#include -#else -#ifndef __bsdi__ -#include -#endif -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include #include -#else -#include -#include -#include -#endif #include #include @@ -85,14 +65,14 @@ #include #include -static u_char isic_isac_exir_hdlr(register struct isic_softc *sc, u_char exir); -static void isic_isac_ind_hdlr(register struct isic_softc *sc, int ind); +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 isic_softc *sc, int ista) +isic_isac_irq(struct l1_softc *sc, int ista) { register u_char c = 0; DBGL1(L1_F_MSG, "isic_isac_irq", ("unit %d: ista = 0x%02x\n", sc->sc_unit, ista)); @@ -185,10 +165,15 @@ isic_isac_irq(struct isic_softc *sc, int ista) c |= ISAC_CMDR_RMC; - if(sc->sc_enabled) + if(sc->sc_enabled && + (ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S)) + { PH_Data_Ind(sc->sc_unit, sc->sc_ibuf); + } else - i4b_Dfreembuf(sc->sc_ibuf); + { + i4b_Dfreembuf(sc->sc_ibuf); + } } else { @@ -319,7 +304,7 @@ isic_isac_irq(struct isic_softc *sc, int ista) * ISAC L1 Extended IRQ handler *---------------------------------------------------------------------------*/ static u_char -isic_isac_exir_hdlr(register struct isic_softc *sc, u_char exir) +isic_isac_exir_hdlr(register struct l1_softc *sc, u_char exir) { u_char c = 0; @@ -380,7 +365,7 @@ isic_isac_exir_hdlr(register struct isic_softc *sc, u_char exir) * ISAC L1 Indication handler *---------------------------------------------------------------------------*/ static void -isic_isac_ind_hdlr(register struct isic_softc *sc, int ind) +isic_isac_ind_hdlr(register struct l1_softc *sc, int ind) { register int event; @@ -467,7 +452,7 @@ isic_isac_ind_hdlr(register struct isic_softc *sc, int ind) * execute a layer 1 command *---------------------------------------------------------------------------*/ void -isic_isac_l1_cmd(struct isic_softc *sc, int command) +isic_isac_l1_cmd(struct l1_softc *sc, int command) { u_char cmd; @@ -541,7 +526,7 @@ isic_isac_l1_cmd(struct isic_softc *sc, int command) * L1 ISAC initialization *---------------------------------------------------------------------------*/ int -isic_isac_init(struct isic_softc *sc) +isic_isac_init(struct l1_softc *sc) { ISAC_IMASK = 0xff; /* disable all irqs */ diff --git a/sys/i4b/layer1/i4b_isac.h b/sys/i4b/layer1/i4b_isac.h index 82fb523..83fa1db 100644 --- a/sys/i4b/layer1/i4b_isac.h +++ b/sys/i4b/layer1/i4b_isac.h @@ -30,14 +30,13 @@ * *--------------------------------------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_isac.h,v 1.2 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Sun Feb 14 10:27:13 1999] + * $FreeBSD$ * - * -hm split up for rewrite of Siemens chipset driver + * last edit-date: [Mon Dec 13 22:01:25 1999] * - *--------------------------------------------------------------------------- - */ + *---------------------------------------------------------------------------*/ #ifndef I4B_ISAC_H_ #define I4B_ISAC_H_ diff --git a/sys/i4b/layer1/i4b_isic.c b/sys/i4b/layer1/i4b_isic.c index b1a141e..b6db86a 100644 --- a/sys/i4b/layer1/i4b_isic.c +++ b/sys/i4b/layer1/i4b_isic.c @@ -27,55 +27,32 @@ * i4b_isic.c - global isic stuff * ============================== * - * $FreeBSD$ + * $Id: i4b_isic.c,v 1.3 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Mon Jul 26 10:59:56 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:01:33 1999] * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ #include "isic.h" #include "opt_i4b.h" -#else -#define NISIC 1 -#endif + #if NISIC > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include #include #include -#ifdef __FreeBSD__ #include -#include -#else -#include -#if defined(__NetBSD__) && defined(amiga) -#include -#else -#ifndef __bsdi__ -#include -#endif -#endif -#endif -#ifdef __FreeBSD__ #include #include #include -#else -#include -#include -#include -#endif #include #include @@ -89,80 +66,30 @@ void isic_settrace(int unit, int val); int isic_gettrace(int unit); -#ifdef __bsdi__ -static int isicmatch(struct device *parent, struct cfdata *cf, void *aux); -static void isicattach(struct device *parent, struct device *self, void *aux); -struct cfdriver isiccd = - { NULL, "isic", isicmatch, isicattach, DV_IFNET, - sizeof(struct isic_softc) }; - -int isa_isicmatch(struct device *parent, struct cfdata *cf, struct isa_attach_args *); -int isapnp_isicmatch(struct device *parent, struct cfdata *cf, struct isa_attach_args *); -int isa_isicattach(struct device *parent, struct device *self, struct isa_attach_args *ia); - -static int -isicmatch(struct device *parent, struct cfdata *cf, void *aux) -{ - struct isa_attach_args *ia = (struct isa_attach_args *) aux; - if (ia->ia_bustype == BUS_PCMCIA) { - ia->ia_irq = IRQNONE; - /* return 1; Not yet */ - return 0; /* for now */ - } - if (ia->ia_bustype == BUS_PNP) { - return isapnp_isicmatch(parent, cf, ia); - } - return isa_isicmatch(parent, cf, ia); -} - -static void -isicattach(struct device *parent, struct device *self, void *aux) -{ - struct isa_attach_args *ia = (struct isa_attach_args *) aux; - struct isic_softc *sc = (struct isic_softc *)self; - - sc->sc_flags = sc->sc_dev.dv_flags; - isa_isicattach(parent, self, ia); - isa_establish(&sc->sc_id, &sc->sc_dev); - sc->sc_ih.ih_fun = isicintr; - sc->sc_ih.ih_arg = (void *)sc; - intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET); - /* Could add a shutdown hook here... */ -} -#endif - -#ifdef __FreeBSD__ -void isicintr_sc(struct isic_softc *sc); -#if !(defined(__FreeBSD_version)) || (defined(__FreeBSD_version) && __FreeBSD_version >= 300006) -void isicintr(int unit); -#endif -#else -/* XXX - hack, going away soon! */ -struct isic_softc *isic_sc[ISIC_MAXUNIT]; -#endif +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" +}; /*---------------------------------------------------------------------------* * isic - device driver interrupt routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -void -isicintr_sc(struct isic_softc *sc) -{ - isicintr(sc->sc_unit); -} - void -isicintr(int unit) -{ - register struct isic_softc *sc = &isic_sc[unit]; -#else -int -isicintr(void *arg) +isicintr(struct l1_softc *sc) { - struct isic_softc *sc = arg; -#endif - if(sc->sc_ipac == 0) /* HSCX/ISAC interupt routine */ { u_char was_hscx_irq = 0; @@ -210,22 +137,6 @@ isicintr(void *arg) } } -#ifdef NOTDEF - -#if !defined(amiga) && !defined(atari) /* XXX should be: #if INTS_ARE_SHARED */ -#ifdef ELSA_QS1ISA - if(sc->sc_cardtyp != CARD_TYPEP_ELSAQS1ISA) - { -#endif - if((was_hscx_irq == 0) && (was_isac_irq == 0)) - DBGL1(L1_ERROR, "isicintr", ("WARNING: unit %d, No IRQ from HSCX/ISAC!\n", sc->sc_unit)); -#ifdef ELSA_QS1ISA - } -#endif -#endif /* !AMIGA && !ATARI */ - -#endif /* NOTDEF */ - HSCX_WRITE(0, H_MASK, 0xff); ISAC_WRITE(I_MASK, 0xff); HSCX_WRITE(1, H_MASK, 0xff); @@ -233,8 +144,7 @@ isicintr(void *arg) #ifdef ELSA_QS1ISA DELAY(80); - if(sc->sc_cardtyp == CARD_TYPEP_ELSAQS1ISA) - if (sc->clearirq) + if((sc->sc_cardtyp == CARD_TYPEP_ELSAQS1ISA) && (sc->clearirq)) { sc->clearirq(sc); } @@ -245,9 +155,6 @@ isicintr(void *arg) HSCX_WRITE(0, H_MASK, HSCX_A_IMASK); ISAC_WRITE(I_MASK, ISAC_IMASK); HSCX_WRITE(1, H_MASK, HSCX_B_IMASK); -#ifndef __FreeBSD__ - return(was_hscx_irq || was_isac_irq); -#endif } else /* IPAC interrupt routine */ { @@ -295,17 +202,10 @@ isicintr(void *arg) if(!ipac_irq_stat) break; } -#ifdef NOTDEF - if(was_ipac_irq == 0) - DBGL1(L1_ERROR, "isicintr", ("WARNING: unit %d, No IRQ from IPAC!\n", sc->sc_unit)); -#endif + IPAC_WRITE(IPAC_MASK, 0xff); DELAY(50); IPAC_WRITE(IPAC_MASK, 0xc0); - -#ifndef __FreeBSD__ - return(was_ipac_irq); -#endif } } @@ -315,11 +215,7 @@ isicintr(void *arg) void isic_settrace(int unit, int val) { -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif + struct l1_softc *sc = &l1_sc[unit]; sc->sc_trace = val; } @@ -329,19 +225,15 @@ isic_settrace(int unit, int val) int isic_gettrace(int unit) { -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif + struct l1_softc *sc = &l1_sc[unit]; return(sc->sc_trace); } /*---------------------------------------------------------------------------* - * isic_recovery - try to recover from irq lockup + * isic_recover - try to recover from irq lockup *---------------------------------------------------------------------------*/ void -isic_recover(struct isic_softc *sc) +isic_recover(struct l1_softc *sc) { u_char byte; @@ -396,5 +288,230 @@ isic_recover(struct isic_softc *sc) ISAC_WRITE(I_MASK, ISAC_IMASK); } +/*---------------------------------------------------------------------------* + * isic_attach_common - common attach routine for all busses + *---------------------------------------------------------------------------*/ +int +isic_attach_common(device_t dev) +{ + int ret; + 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) + { + ret = IPAC_READ(IPAC_ID); + + switch(ret) + { + case 0x01: + break; + + default: + printf("isic%d: Error, IPAC version %d unknown!\n", + unit, ret); + return ENXIO; + 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 */ + + MPH_Status_Ind(sc->sc_unit, STI_ATTACH, sc->sc_cardtyp); + + /* announce manufacturer and card type for ISA cards */ + + switch(sc->sc_flags) + { + case FLAG_TELES_S0_8: + drvid = "Teles S0/8 (or compatible)"; + break; + + case FLAG_TELES_S0_16: + drvid = "Teles S0/16 (or compatible)"; + break; + + case FLAG_TELES_S0_163: + drvid = "Teles S0/16.3"; + break; + + case FLAG_AVM_A1: + drvid = "AVM A1 or Fritz!Card Classic"; + break; + + case FLAG_AVM_A1_PCMCIA: + drvid = "AVM Fritz!Card PCMCIA"; + break; + + case FLAG_USR_ISDN_TA_INT: + drvid = "USRobotics Sportster ISDN TA intern"; + break; + + case FLAG_ITK_IX1: + drvid = "ITK ix1 micro"; + break; + + case FLAG_ELSA_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) + { + printf("isic%d: IPAC PSB2115 Version 1.1\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_flags = 0; + + /* 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; + } + } +} + #endif /* NISIC > 0 */ diff --git a/sys/i4b/layer1/i4b_isic_isa.c b/sys/i4b/layer1/i4b_isic_isa.c index c240a80..b3cf2a2 100644 --- a/sys/i4b/layer1/i4b_isic_isa.c +++ b/sys/i4b/layer1/i4b_isic_isa.c @@ -27,58 +27,32 @@ * i4b_isic_isa.c - ISA bus interface * ================================== * - * $FreeBSD$ + * $Id: i4b_isic_isa.c,v 1.4 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Mon Jul 26 10:59:51 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:01:39 1999] * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ #include "isic.h" #include "opt_i4b.h" -#elif defined(__bsdi__) -#include "isic.h" -#else -#define NISIC 1 -#endif + #if NISIC > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include #include #include -#ifdef __FreeBSD__ #include -#include -#elif defined(__bsdi__) -#include -#include -#else -#include -#if defined(__NetBSD__) && defined(amiga) -#include -#else -#include -#endif -#endif -#ifdef __FreeBSD__ #include #include #include -#else -#include -#include -#include -#endif #include #include @@ -89,687 +63,163 @@ #include #include -#ifdef __FreeBSD__ +#include +#include +#include -#if !(defined(__FreeBSD_version)) || (defined(__FreeBSD_version) && __FreeBSD_version >= 300006) -void isicintr ( int unit ); -#endif +struct l1_softc l1_sc[ISIC_MAXUNIT]; -void isicintr_sc(struct isic_softc *sc); +static int isic_isa_probe(device_t dev); +static int isic_isa_attach(device_t dev); -static int isicprobe(struct isa_device *dev); -int isicattach(struct isa_device *dev); +static device_method_t isic_methods[] = { + DEVMETHOD(device_probe, isic_isa_probe), + DEVMETHOD(device_attach, isic_isa_attach), + { 0, 0 } +}; -struct isa_driver isicdriver = { - isicprobe, - isicattach, +static driver_t isic_driver = { "isic", + isic_methods, 0 }; -int next_isic_unit = 0; -struct isic_softc isic_sc[ISIC_MAXUNIT]; - -#elif defined(__bsdi__) - /* XXX */ -#else - -#ifdef NetBSD1_3 -#if NetBSD1_3 < 2 -struct cfdriver isic_cd = { - NULL, "isic", DV_DULL -}; -#endif -#endif - -#if defined (__OpenBSD__) -struct cfdriver isic_cd = { - NULL, "isic", DV_DULL -}; -#endif - -#endif +static devclass_t isic_devclass; -/* parameter and format for message producing e.g. "isic0: " */ - -#ifdef __FreeBSD__ -#define ISIC_FMT "isic%d: " -#define ISIC_PARM dev->id_unit -#define TERMFMT " " -#else -#define ISIC_FMT "%s: " -#define ISIC_PARM sc->sc_dev.dv_xname -#define TERMFMT "\n" -#endif +DRIVER_MODULE(isic, isa, isic_driver, isic_devclass, 0, 0); -extern void isic_settrace(int unit, int val); /*XXX*/ -extern int isic_gettrace(int unit); /*XXX*/ - -#ifdef __FreeBSD__ /*---------------------------------------------------------------------------* - * isic - non-pnp device driver probe routine + * probe for ISA non-PnP cards *---------------------------------------------------------------------------*/ static int -isicprobe(struct isa_device *dev) +isic_isa_probe(device_t dev) { - int ret = 0; + int ret = ENXIO; - if(dev->id_unit != next_isic_unit) - { - printf("isicprobe: Error: new unit (%d) != next_isic_unit (%d)!\n", dev->id_unit, next_isic_unit); - return(0); - } - - switch(dev->id_flags) - { -#ifdef TEL_S0_8 - case FLAG_TELES_S0_8: - ret = isic_probe_s08(dev); - break; -#endif + if(isa_get_vendorid(dev)) /* no PnP probes here */ + return ENXIO; + switch(device_get_flags(dev)) + { #ifdef TEL_S0_16 case FLAG_TELES_S0_16: ret = isic_probe_s016(dev); break; #endif -#ifdef TEL_S0_16_3 - case FLAG_TELES_S0_163: - ret = isic_probe_s0163(dev); - break; -#endif - -#ifdef AVM_A1 - case FLAG_AVM_A1: - ret = isic_probe_avma1(dev); - break; -#endif - -#ifdef USR_STI - case FLAG_USR_ISDN_TA_INT: - ret = isic_probe_usrtai(dev); - break; -#endif - -#ifdef ITKIX1 - case FLAG_ITK_IX1: - ret = isic_probe_itkix1(dev); - break; -#endif - -#ifdef ELSA_PCC16 - case FLAG_ELSA_PCC16: - ret = isic_probe_Eqs1pi(dev, 0); - break; -#endif - - default: - break; - } - return(ret); -} -#elif defined(__bsdi__) -/*---------------------------------------------------------------------------* - * isic - pnp device driver probe routine - *---------------------------------------------------------------------------*/ -int -isapnp_isicmatch(struct device *parent, struct cfdata *cf, struct isa_attach_args *ia) -{ -#ifdef DYNALINK - if (isapnp_match_dynalink(parent, cf, ia)) - return 1; -#endif - return 0; -} -/*---------------------------------------------------------------------------* - * isic - non-pnp device driver probe routine - *---------------------------------------------------------------------------*/ -int -isa_isicmatch(struct device *parent, struct cfdata *cf, struct isa_attach_args *ia) -{ - int ret = 0; - - switch(cf->cf_flags) - { #ifdef TEL_S0_8 case FLAG_TELES_S0_8: - ret = isic_probe_s08(parent, cf, ia); + ret = isic_probe_s08(dev); break; #endif -#ifdef TEL_S0_16 - case FLAG_TELES_S0_16: - ret = isic_probe_s016(parent, cf, ia); +#ifdef ELSA_PCC16 + case FLAG_ELSA_PCC16: + ret = isic_probe_Epcc16(dev); break; #endif #ifdef TEL_S0_16_3 case FLAG_TELES_S0_163: - ret = isic_probe_s0163(parent, cf, ia); + ret = isic_probe_s0163(dev); break; #endif #ifdef AVM_A1 case FLAG_AVM_A1: - ret = isic_probe_avma1(parent, cf, ia); + ret = isic_probe_avma1(dev); break; #endif #ifdef USR_STI case FLAG_USR_ISDN_TA_INT: - ret = isic_probe_usrtai(parent, cf, ia); + ret = isic_probe_usrtai(dev); break; #endif #ifdef ITKIX1 case FLAG_ITK_IX1: - ret = isic_probe_itkix1(parent, cf, ia); - break; -#endif - -#ifdef ELSA_PCC16 - case FLAG_ELSA_PCC16: - ret = isic_probe_Eqs1pi(dev, 0); + 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); } -#else - -/*---------------------------------------------------------------------------* - * isic - device driver probe routine, dummy for NetBSD/OpenBSD - *---------------------------------------------------------------------------*/ -int -isicprobe(struct isic_attach_args *args) -{ - return 1; -} - -#endif /* __FreeBSD__ */ - -#ifdef __FreeBSD__ - -/*---------------------------------------------------------------------------* - * isic - non-pnp device driver attach routine - *---------------------------------------------------------------------------*/ -int -isicattach(struct isa_device *dev) -{ - return(isic_realattach(dev, 0)); -} - /*---------------------------------------------------------------------------* - * isic - non-pnp and pnp device driver attach routine + * attach for ISA non-PnP cards *---------------------------------------------------------------------------*/ -int -isic_realattach(struct isa_device *dev, unsigned int iobase2) - -#elif defined(__bsdi__) - -/*---------------------------------------------------------------------------* - * isic - non-pnp device driver attach routine - *---------------------------------------------------------------------------*/ -int -isa_isicattach(struct device *parent, struct device *self, struct isa_attach_args *ia) - -#else /* ! __FreeBSD__ */ - -int -isicattach(int flags, struct isic_softc *sc) - -#endif /* __FreeBSD__ */ +static int +isic_isa_attach(device_t dev) { - int ret = 0; - char *drvid; - -#ifdef __FreeBSD__ - - struct isic_softc *sc = &isic_sc[dev->id_unit]; -#define PARM dev -#define PARM2 dev, iobase2 -#define FLAGS dev->id_flags - -#elif defined(__bsdi__) - - struct isic_softc *sc = (struct isic_softc *)self; -#define PARM parent, self, ia -#define PARM2 parent, self, ia -#define FLAGS sc->sc_flags - -#else - -#define PARM sc -#define PARM2 sc -#define FLAGS flags + int ret = ENXIO; -#endif /* __FreeBSD__ */ + struct l1_softc *sc = &l1_sc[device_get_unit(dev)]; - 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" - }; - - /* done in bus specific attach code for other OS */ - -#ifdef __FreeBSD__ - if(dev->id_unit != next_isic_unit) - { -/*XXX*/ printf("isicattach: Error: new unit (%d) != next_isic_unit (%d)!\n", dev->id_unit, next_isic_unit); - return(0); - } - - sc->sc_unit = dev->id_unit; -#else - isic_sc[sc->sc_unit] = sc; -#endif + sc->sc_unit = device_get_unit(dev); /* card dependent setup */ - switch(FLAGS) + + switch(sc->sc_flags) { -#ifdef DYNALINK - case FLAG_DYNALINK: - ret = isic_attach_Dyn(PARM2); +#ifdef TEL_S0_16 + case FLAG_TELES_S0_16: + ret = isic_attach_s016(dev); break; #endif #ifdef TEL_S0_8 case FLAG_TELES_S0_8: - ret = isic_attach_s08(PARM); + ret = isic_attach_s08(dev); break; #endif -#ifdef TEL_S0_16 - case FLAG_TELES_S0_16: - ret = isic_attach_s016(PARM); +#ifdef ELSA_PCC16 + case FLAG_ELSA_PCC16: + ret = isic_attach_Epcc16(dev); break; #endif #ifdef TEL_S0_16_3 case FLAG_TELES_S0_163: - ret = isic_attach_s0163(PARM); + ret = isic_attach_s0163(dev); break; #endif #ifdef AVM_A1 case FLAG_AVM_A1: - ret = isic_attach_avma1(PARM); + ret = isic_attach_avma1(dev); break; #endif #ifdef USR_STI case FLAG_USR_ISDN_TA_INT: - ret = isic_attach_usrtai(PARM); + ret = isic_attach_usrtai(dev); break; #endif #ifdef ITKIX1 case FLAG_ITK_IX1: - ret = isic_attach_itkix1(PARM); - break; -#endif - -#ifdef ELSA_PCC16 - case FLAG_ELSA_PCC16: - ret = isic_attach_Eqs1pi(dev, 0); - break; -#endif - -#ifdef amiga - case FLAG_BLMASTER: - ret = 1; /* full detection was done in caller */ - break; -#endif - -/* ====================================================================== - * Only P&P cards follow below!!! - */ - -#ifdef __FreeBSD__ /* we've already splitted all non-ISA stuff - out of this ISA specific part for the other - OS */ - -#ifdef AVM_A1_PCMCIA - case FLAG_AVM_A1_PCMCIA: - ret = isic_attach_fritzpcmcia(PARM); - break; -#endif - -#ifdef TEL_S0_16_3_P - case FLAG_TELES_S0_163_PnP: - ret = isic_attach_s0163P(PARM2); - break; -#endif - -#ifdef CRTX_S0_P - case FLAG_CREATIX_S0_PnP: - ret = isic_attach_Cs0P(PARM2); + ret = isic_attach_itkix1(dev); break; #endif -#ifdef DRN_NGO - case FLAG_DRN_NGO: - ret = isic_attach_drnngo(PARM2); - break; -#endif - -#ifdef SEDLBAUER - case FLAG_SWS: - ret = isic_attach_sws(PARM); - break; -#endif - -#ifdef ELSA_QS1ISA - case FLAG_ELSA_QS1P_ISA: - ret = isic_attach_Eqs1pi(PARM2); - break; -#endif - -#ifdef AVM_PNP - case FLAG_AVM_PNP: - ret = isic_attach_avm_pnp(PARM2); - ret = 0; - break; -#endif - -#ifdef SIEMENS_ISURF2 - case FLAG_SIEMENS_ISURF2: - ret = isic_attach_siemens_isurf(PARM2); - break; -#endif - -#ifdef ASUSCOM_IPAC - case FLAG_ASUSCOM_IPAC: - ret = isic_attach_asi(PARM2); - break; -#endif - -#endif /* __FreeBSD__ / P&P specific part */ - default: + printf("isic%d: attach, unknown flag: %d\n", + device_get_unit(dev), device_get_flags(dev)); break; } - if(ret == 0) - return(0); + if(ret) + return(ret); - if(sc->sc_ipac) - { - ret = IPAC_READ(IPAC_ID); - - if(ret != IPAC_V11) - { - printf("isic%d: Error, IPAC version %d unknown!\n", - sc->sc_unit, ret); - return(0); - } - } - else - { - - sc->sc_isac_version = 0; - sc->sc_hscx_version = 0; - - if(sc->sc_ipac) - { - ret = IPAC_READ(IPAC_ID); - - switch(ret) - { - case 0x01: - printf("isic%d: IPAC PSB2115 Version 1.1\n", sc->sc_unit); - break; - - default: - printf("isic%d: Error, IPAC version %d unknown!\n", - sc->sc_unit, ret); - 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_FMT "Error, ISAC version %d unknown!\n", - ISIC_PARM, sc->sc_isac_version); - return(0); - 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_FMT "Error, HSCX version %d unknown!\n", - ISIC_PARM, sc->sc_hscx_version); - return(0); - break; - } - } - - } - - /* ISAC setup */ - - isic_isac_init(sc); + ret = isic_attach_common(dev); - /* 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); - - /* setup linktab */ - - isic_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 */ - - MPH_Status_Ind(sc->sc_unit, STI_ATTACH, sc->sc_cardtyp); - - /* announce manufacturer and card type */ - - switch(FLAGS) - { - case FLAG_TELES_S0_8: - drvid = "Teles S0/8 or Niccy 1008"; - break; - - case FLAG_TELES_S0_16: - drvid = "Teles S0/16, Creatix ISDN S0-16 or Niccy 1016"; - break; - - case FLAG_TELES_S0_163: - drvid = "Teles S0/16.3"; - break; - - case FLAG_AVM_A1: - drvid = "AVM A1 or AVM Fritz!Card"; - break; - - case FLAG_AVM_A1_PCMCIA: - drvid = "AVM PCMCIA Fritz!Card"; - break; - - case FLAG_TELES_S0_163_PnP: - drvid = "Teles S0/PnP"; - break; - - case FLAG_CREATIX_S0_PnP: - drvid = "Creatix ISDN S0-16 P&P"; - break; - - case FLAG_USR_ISDN_TA_INT: - drvid = "USRobotics Sportster ISDN TA intern"; - break; - - case FLAG_DRN_NGO: - drvid = "Dr. Neuhaus NICCY Go@"; - break; - - case FLAG_DYNALINK: - drvid = "Dynalink IS64PH"; - break; - - case FLAG_SWS: - drvid = "Sedlbauer WinSpeed"; - break; - - case FLAG_BLMASTER: - /* board announcement was done by caller */ - drvid = (char *)0; - break; - - case FLAG_ELSA_QS1P_ISA: - drvid = "ELSA QuickStep 1000pro (ISA)"; - break; - - case FLAG_ITK_IX1: - drvid = "ITK ix1 micro"; - break; - - case FLAG_ELSA_PCC16: - drvid = "ELSA PCC-16"; - break; - - case FLAG_ASUSCOM_IPAC: - drvid = "Asuscom ISDNlink 128K PnP"; - break; - - case FLAG_SIEMENS_ISURF2: - drvid = "Siemens I-Surf 2.0"; - break; - - default: - drvid = "ERROR, unknown flag used"; - break; - } -#ifndef __FreeBSD__ - printf("\n"); -#endif - if (drvid) - printf(ISIC_FMT "%s\n", ISIC_PARM, drvid); - - /* announce chip versions */ - - if(sc->sc_ipac) - { - printf(ISIC_FMT "IPAC PSB2115 Version 1.1\n", ISIC_PARM); - } - else - { - if(sc->sc_isac_version >= ISAC_UNKN) - { - printf(ISIC_FMT "ISAC Version UNKNOWN (VN=0x%x)" TERMFMT, - ISIC_PARM, - sc->sc_isac_version); - sc->sc_isac_version = ISAC_UNKN; - } - else - { - printf(ISIC_FMT "ISAC %s (IOM-%c)" TERMFMT, - ISIC_PARM, - ISACversion[sc->sc_isac_version], - sc->sc_bustyp == BUS_TYPE_IOM1 ? '1' : '2'); - } - -#ifdef __FreeBSD__ - printf("(Addr=0x%lx)\n", (u_long)ISAC_BASE); -#endif - - if(sc->sc_hscx_version >= HSCX_UNKN) - { - printf(ISIC_FMT "HSCX Version UNKNOWN (VN=0x%x)" TERMFMT, - ISIC_PARM, - sc->sc_hscx_version); - sc->sc_hscx_version = HSCX_UNKN; - } - else - { - printf(ISIC_FMT "HSCX %s" TERMFMT, - ISIC_PARM, - HSCXversion[sc->sc_hscx_version]); - } - -#ifdef __FreeBSD__ - printf("(AddrA=0x%lx, AddrB=0x%lx)\n", (u_long)HSCX_A_BASE, (u_long)HSCX_B_BASE); - -#endif /* __FreeBSD__ */ - } - -#ifdef __FreeBSD__ - next_isic_unit++; - -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300003 - - /* set the interrupt handler - no need to change isa_device.h */ - dev->id_intr = (inthand2_t *)isicintr; - -#endif - -#endif /* __FreeBSD__ */ - - return(1); -#undef PARM -#undef FLAGS + return(ret); } - #endif /* NISIC > 0 */ diff --git a/sys/i4b/layer1/i4b_isic_pci.c b/sys/i4b/layer1/i4b_isic_pci.c deleted file mode 100644 index 59ef6d7..0000000 --- a/sys/i4b/layer1/i4b_isic_pci.c +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright (c) 1997, 1999 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_pci.c - PCI bus interface - * ================================== - * - * $FreeBSD$ - * - * last edit-date: [Wed Apr 21 09:57:37 1999] - * - *---------------------------------------------------------------------------*/ - -#include "isic.h" - -#if defined(__FreeBSD__) -#include "opt_i4b.h" -#include "pci.h" -#endif - -#if (NISIC > 0) && (NPCI > 0) - -#include -#include -#include -#include -#include -#include - -#ifdef __FreeBSD__ -#if __FreeBSD__ >= 3 -#include -#else -#include -#endif -#include -#include -#include -#include -#else -#include -#include -#endif - -#ifdef __FreeBSD__ -#include -#include -#else -#include -#include -#endif - -#include -#include -#include - -#include -#include -#include -#include - -#define PCI_QS1000_ID 0x10001048 -#define PCI_AVMA1_ID 0x0a001244 - -#define MEM0_MAPOFF 0 -#define PORT0_MAPOFF 4 -#define PORT1_MAPOFF 12 - -static const char *i4b_pci_probe(pcici_t tag, pcidi_t type); -static void i4b_pci_attach(pcici_t config_id, int unit); -static int isic_pciattach(int unit, u_long type, u_int iobase1, u_int iobase2); - -static u_long i4b_pci_count = 0; - -static struct pci_device i4b_pci_driver = { - "isic", - i4b_pci_probe, - i4b_pci_attach, - &i4b_pci_count, - NULL -}; - -#if defined(__FreeBSD_version) && __FreeBSD_version >= 400004 -#ifndef COMPAT_PCI_DRIVER -DATA_SET (pcidevice_set, i4b_pci_driver); -#else -COMPAT_PCI_DRIVER (isic_pci, i4b_pci_driver); -#endif /* COMPAT_PCI_DRIVER */ -#else /* __FreeBSD_version >= 400004 */ -DATA_SET (pcidevice_set, i4b_pci_driver); -#endif /* __FreeBSD_version >= 400004 */ - -static void isic_pci_intr_sc(struct isic_softc *sc); - -#ifdef AVM_A1_PCI -extern void avma1pp_map_int(pcici_t, void *, unsigned *); -#endif - - -/*---------------------------------------------------------------------------* - * PCI probe routine - *---------------------------------------------------------------------------*/ -static const char * -i4b_pci_probe(pcici_t tag, pcidi_t type) -{ - switch(type) - { - case PCI_QS1000_ID: - return("ELSA QuickStep 1000pro PCI ISDN adapter"); - - case PCI_AVMA1_ID: - return("AVM Fritz!Card PCI ISDN adapter"); - - default: - if(bootverbose) - printf("i4b_pci_probe: unknown PCI type %ul!\n", (u_int)type); - return(NULL); - } - return(NULL); -} - -/*---------------------------------------------------------------------------* - * PCI attach routine - *---------------------------------------------------------------------------*/ -static void -i4b_pci_attach(pcici_t config_id, int unit) -{ - unsigned short iobase1; - unsigned short iobase2; - unsigned long type; - struct isic_softc *sc = &isic_sc[unit]; - u_long reg1, reg2; - - if(unit != next_isic_unit) - { - printf("i4b_pci_attach: Error: new unit (%d) != next_isic_unit (%d)!\n", unit, next_isic_unit); - return; - } - - /* IMHO all the following should be done in the low-level driver - GJ */ - type = pci_conf_read(config_id, PCI_ID_REG); - - /* not all cards have their ports at the same location !!! */ - switch(type) - { - case PCI_QS1000_ID: - reg1 = PCI_MAP_REG_START+PORT0_MAPOFF; - reg2 = PCI_MAP_REG_START+PORT1_MAPOFF; - break; - - case PCI_AVMA1_ID: - reg1 = PCI_MAP_REG_START+PORT0_MAPOFF; - reg2 = 0; - break; - - default: - reg1 = PCI_MAP_REG_START+PORT0_MAPOFF; - reg2 = PCI_MAP_REG_START+PORT1_MAPOFF; - break; - } - - if(reg1 && !(pci_map_port(config_id, reg1, &iobase1))) - { - printf("i4b_pci_attach: pci_map_port 1 failed!\n"); - return; - } - - if(reg2 && !(pci_map_port(config_id, reg2, &iobase2))) - { - printf("i4b_pci_attach: pci_map_port 2 failed!\n"); - return; - } - - if(bootverbose) - printf("i4b_pci_attach: unit %d, port0 0x%x, port1 0x%x\n", unit, iobase1, iobase2); - - if((isic_pciattach(unit, type, iobase1, iobase2)) == 0) - return; - -#ifdef AVM_A1_PCI - /* the AVM FRTIZ!PCI needs to handle its own interrupts */ - if (type == PCI_AVMA1_ID) - { - avma1pp_map_int(config_id, (void *)sc, &net_imask); - return; - } -#endif - - /* seems like this should be done before the attach in case it fails */ - if(!(pci_map_int(config_id, (void *)isic_pci_intr_sc, (void *)sc, &net_imask))) - return; -} - -/*---------------------------------------------------------------------------* - * isic - pci device driver attach routine - *---------------------------------------------------------------------------*/ -static int -isic_pciattach(int unit, u_long type, u_int iobase1, u_int iobase2) -{ - int ret = 0; - struct isic_softc *sc = &isic_sc[unit]; - - 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" - }; - - switch(type) - { -#ifdef ELSA_QS1PCI - case PCI_QS1000_ID: - ret = isic_attach_Eqs1pp(unit, iobase1, iobase2); - break; -#endif -#ifdef AVM_A1_PCI - case PCI_AVMA1_ID: - ret = isic_attach_avma1pp(unit, iobase1, iobase2); - if (ret) - next_isic_unit++; - return(ret); -#endif - default: - break; - } - - if(ret == 0) - return(ret); - - sc->sc_isac_version = 0; - sc->sc_hscx_version = 0; - - sc->sc_unit = unit; - - if(sc->sc_ipac) - { - ret = IPAC_READ(IPAC_ID); - - switch(ret) - { - case 0x01: - printf("isic%d: IPAC PSB2115 Version 1.1\n", unit); - break; - - default: - printf("isic%d: Error, IPAC version %d unknown!\n", - unit, ret); - 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: - printf("isic%d: ISAC %s (IOM-%c)\n", - unit, - ISACversion[sc->sc_isac_version], - sc->sc_bustyp == BUS_TYPE_IOM1 ? '1' : '2'); - break; - - default: - printf("isic%d: Error, ISAC version %d unknown!\n", - unit, sc->sc_isac_version); - return(0); - 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: - printf("isic%d: HSCX %s\n", - unit, - HSCXversion[sc->sc_hscx_version]); - break; - - default: - printf("isic%d: Error, HSCX version %d unknown!\n", - unit, sc->sc_hscx_version); - return(0); - break; - } - } - - /* ISAC setup */ - - isic_isac_init(sc); - - /* 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); - - /* setup linktab */ - - isic_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 */ - - MPH_Status_Ind(sc->sc_unit, STI_ATTACH, sc->sc_cardtyp); - - next_isic_unit++; - - return(1); -} - -/*---------------------------------------------------------------------------* - * isic - PCI device driver interrupt routine - *---------------------------------------------------------------------------*/ -static void -isic_pci_intr_sc(struct isic_softc *sc) -{ - if(sc->sc_ipac == 0) /* HSCX/ISAC interupt routine */ - { - 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); - } - - 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); - } - - if(isac_irq_stat) - { /* isac handler */ - isic_isac_irq(sc, isac_irq_stat); - } - } - - HSCX_WRITE(0, H_MASK, 0xff); - ISAC_WRITE(I_MASK, 0xff); - HSCX_WRITE(1, H_MASK, 0xff); - - DELAY(100); - - 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; - - for(;;) - { - /* get global irq status */ - - ipac_irq_stat = (IPAC_READ(IPAC_ISTA)) & 0x3f; - - /* do as long as there are pending irqs in the chip */ - if(!ipac_irq_stat) - break; - - /* 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); - } - 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); - } - if(ipac_irq_stat & (IPAC_ISTA_ICD | IPAC_ISTA_EXD)) - { - /* ISAC interrupt */ - isic_isac_irq(sc, ISAC_READ(I_ISTA)); - } - } - - IPAC_WRITE(IPAC_MASK, 0xff); - DELAY(50); - IPAC_WRITE(IPAC_MASK, 0xc0); - } -} - -#endif /* (NISIC > 0) && (NPCI > 0) */ - diff --git a/sys/i4b/layer1/i4b_isic_pnp.c b/sys/i4b/layer1/i4b_isic_pnp.c index 5153105..70d0812 100644 --- a/sys/i4b/layer1/i4b_isic_pnp.c +++ b/sys/i4b/layer1/i4b_isic_pnp.c @@ -1,7 +1,7 @@ /* * Copyright (c) 1998 Eivind Eklund. All rights reserved. * - * Copyright (c) 1998 German Tischler. All rights reserved. + * Copyright (c) 1998, 1999 German Tischler. All rights reserved. * * Copyright (c) 1998, 1999 Hellmuth Michaelis. All rights reserved. * @@ -37,24 +37,18 @@ * i4b_isic_pnp.c - i4b pnp support * -------------------------------- * + * $Id: i4b_isic_pnp.c,v 1.5 1999/12/13 21:25:26 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Mon Jul 5 15:57:01 1999] + * last edit-date: [Mon Dec 13 22:01:48 1999] * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -#define NPNP 1 #include "isic.h" #include "opt_i4b.h" -#if NPNP > 0 -#warning "Fix i4b pnp!" -#undef NPNP -#endif - -#if (NISIC > 0) && (NPNP > 0) +#if (NISIC > 0) #include #include @@ -62,25 +56,14 @@ #include #include -#if defined(__FreeBSD__) && __FreeBSD__ < 3 -#include "ioconf.h" -extern void isicintr(int unit); /* XXX this gives a compiler warning */ - /* on one 2.2.7 machine but no */ - /* warning on another one !? (-hm) */ -#endif - -#if (defined(__FreeBSD_version) && __FreeBSD_version >= 300006) -extern void isicintr(int unit); -#endif - #include -#include -/* #include */ #include #include #include +#include + #define VID_TEL163PNP 0x10212750 /* Teles 16.3 PnP */ #define VID_CREATIXPP 0x0000980e /* Creatix S0/16 P+P */ #define VID_DYNALINK 0x88167506 /* Dynalink */ @@ -92,53 +75,73 @@ extern void isicintr(int unit); #define VID_SIESURF2 0x2000254d /* Siemens I-Surf 2.0 PnP*/ #define VID_ASUSCOM_IPAC 0x90167506 /* Asuscom (with IPAC) */ -static struct i4b_pnp_ids { +static struct isic_pnp_ids { u_long vend_id; char *id_str; -} i4b_pnp_ids[] = { - { VID_TEL163PNP, "Teles 16.3 PnP" }, - { VID_CREATIXPP, "Creatix S0/16 P+P" }, +} isic_pnp_ids[] = { +#if defined(TEL_S0_16_3_P) || defined(CRTX_S0_P) + { VID_TEL163PNP, "Teles S0/16.3 PnP" }, + { VID_CREATIXPP, "Creatix S0/16 PnP" }, +#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" }, - { 0 } +#endif + { 0, 0 } }; -extern struct isa_driver isicdriver; - -static int isic_pnpprobe(struct isa_device *dev, unsigned int iobase2); -static char *i4b_pnp_probe(u_long csn, u_long vend_id); -static void i4b_pnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev); +static int isic_pnp_probe(device_t dev); +static int isic_pnp_attach(device_t dev); -static u_long ni4b_pnp = 0; - -static struct pnp_device i4b_pnp = { - "i4b_pnp", - i4b_pnp_probe, - i4b_pnp_attach, - &ni4b_pnp, - &net_imask +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, }; -DATA_SET(pnpdevice_set, i4b_pnp); +static devclass_t isic_devclass; + +DRIVER_MODULE(isicpnp, isa, isic_pnp_driver, isic_devclass, 0, 0); /*---------------------------------------------------------------------------* - * PnP probe routine + * probe for ISA PnP cards *---------------------------------------------------------------------------*/ -static char * -i4b_pnp_probe(u_long csn, u_long vend_id) +int +isic_pnp_probe(device_t dev) { - struct i4b_pnp_ids *ids; - char *string = NULL; + 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 = i4b_pnp_ids; ids->vend_id != 0; ids++) + for(ids = isic_pnp_ids; ids->vend_id != 0; ids++) { if(vend_id == ids->vend_id) { @@ -146,204 +149,169 @@ i4b_pnp_probe(u_long csn, u_long vend_id) break; } } - - if(string) + + if(string) /* set name if we have one */ { - struct pnp_cinfo spci; - - read_pnp_parms(&spci, 0); - - if((spci.enable == 0) || (spci.flags & 0x01)) - { - printf("CSN %d (%s) is disabled.\n", (int)csn, string); - return (NULL); - } + device_set_desc(dev, string); /* set description */ + return 0; + } + else + { + return ENXIO; } - return(string); } /*---------------------------------------------------------------------------* - * PnP attach routine + * attach for ISA PnP cards *---------------------------------------------------------------------------*/ -static void -i4b_pnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev) +int +isic_pnp_attach(device_t dev) { - struct pnp_cinfo spci; -#if !((defined(__FreeBSD_version) && __FreeBSD_version >= 400004)) - struct isa_device *isa_devp; -#endif - - if(dev->id_unit != next_isic_unit) + 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("i4b_pnp_attach: Error: new unit (%d) != next_isic_unit (%d)!\n", dev->id_unit, next_isic_unit); - return; + printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for %s\n", unit, unit, name); + return ENXIO; } - if(dev->id_unit >= ISIC_MAXUNIT) - { - printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for %s\n", - dev->id_unit, dev->id_unit, name); - return; - } + /* get information structure for this unit */ - if(read_pnp_parms(&spci, 0) == 0) - { - printf("isic%d: read_pnp_parms error for %s\n", - dev->id_unit, name); - return; - } + sc = &l1_sc[unit]; - if(bootverbose) + /* get io_base */ + if(!(sc->sc_resources.io_base[0] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[0], + 0UL, ~0UL, 1, RF_ACTIVE ) )) { - printf("isic%d: vendorid = 0x%08x port0 = 0x%04x, port1 = 0x%04x, irq = %d\n", - dev->id_unit, spci.vendor_id, spci.port[0], spci.port[1], spci.irq[0]); + printf("isic_pnp_attach: Couldn't get my io_base.\n"); + return ENXIO; } - dev->id_iobase = spci.port[0]; - dev->id_irq = (1 << spci.irq[0]); - dev->id_intr = (inthand2_t *) isicintr; - dev->id_drq = -1; + /* will not be used for pnp devices */ -/* XXX add dev->id_alive init here ! ?? */ + sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]); - switch(spci.vendor_id) - { - case VID_TEL163PNP: - dev->id_flags = FLAG_TELES_S0_163_PnP; - break; - case VID_CREATIXPP: - dev->id_flags = FLAG_CREATIX_S0_PnP; - break; - case VID_DYNALINK: - dev->id_flags = FLAG_DYNALINK; - break; - case VID_SEDLBAUER: - dev->id_flags = FLAG_SWS; - break; - case VID_NICCYGO: - dev->id_flags = FLAG_DRN_NGO; - break; - case VID_ELSAQS1P: - dev->id_flags = FLAG_ELSA_QS1P_ISA; - break; - case VID_ITK0025: - dev->id_flags = FLAG_ITK_IX1; - break; - case VID_AVMPNP: - dev->id_flags = FLAG_AVM_PNP; - break; - case VID_SIESURF2: - dev->id_flags = FLAG_SIEMENS_ISURF2; - break; - case VID_ASUSCOM_IPAC: - dev->id_flags = FLAG_ASUSCOM_IPAC; - break; - } + /* get irq, release io_base if we don't get it */ - write_pnp_parms(&spci, 0); - enable_pnp_card(); - - if(dev->id_driver == NULL) + if(!(sc->sc_resources.irq = + bus_alloc_resource(dev, SYS_RES_IRQ, + &sc->sc_resources.irq_rid, + 0UL, ~0UL, 1, RF_ACTIVE))) { - dev->id_driver = &isicdriver; -#if(defined(__FreeBSD_version) && __FreeBSD_version >= 400004) - dev->id_id = isa_compat_nextid(); -#else - isa_devp = find_isadev(isa_devtab_net, &isicdriver, 0); - - if(isa_devp != NULL) - { - dev->id_id = isa_devp->id_id; - } -#endif + 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); - if((dev->id_alive = isic_pnpprobe(dev, spci.port[1])) != 0) - { -/* XXX dev->id_alive is the size of the port area used ! */ - isic_realattach(dev, spci.port[1]); - } - else - { - printf("isic%d: probe failed!\n", dev->id_unit); - } -} -/*---------------------------------------------------------------------------* - * isic - pnp device driver probe routine - *---------------------------------------------------------------------------*/ -static int -isic_pnpprobe(struct isa_device *dev, unsigned int iobase2) -{ - int ret = 0; + /* set flag so we know what this card is */ - switch(dev->id_flags) + ret = ENXIO; + + switch(vend_id) { -#ifdef TEL_S0_16_3_P - case FLAG_TELES_S0_163_PnP: - ret = isic_probe_s0163P(dev, iobase2); +#if defined(TEL_S0_16_3_P) || defined(CRTX_S0_P) + case VID_TEL163PNP: + sc->sc_flags = FLAG_TELES_S0_163_PnP; + ret = isic_attach_Cs0P(dev); break; -#endif -#ifdef CRTX_S0_P - case FLAG_CREATIX_S0_PnP: - ret = isic_probe_Cs0P(dev, iobase2); + case VID_CREATIXPP: + sc->sc_flags = FLAG_CREATIX_S0_PnP; + ret = isic_attach_Cs0P(dev); break; #endif - -#ifdef DRN_NGO - case FLAG_DRN_NGO: - ret = isic_probe_drnngo(dev, iobase2); +#ifdef DYNALINK + case VID_DYNALINK: + sc->sc_flags = FLAG_DYNALINK; + ret = isic_attach_Dyn(dev); break; #endif - #ifdef SEDLBAUER - case FLAG_SWS: - ret = 8; /* pnp only, nothing to probe */ + case VID_SEDLBAUER: + sc->sc_flags = FLAG_SWS; + ret = isic_attach_sws(dev); break; #endif - -#ifdef DYNALINK - case FLAG_DYNALINK: - ret = isic_probe_Dyn(dev, iobase2); +#ifdef DRN_NGO + case VID_NICCYGO: + sc->sc_flags = FLAG_DRN_NGO; + ret = isic_attach_drnngo(dev); break; #endif - #ifdef ELSA_QS1ISA - case FLAG_ELSA_QS1P_ISA: - ret = isic_probe_Eqs1pi(dev, iobase2); + case VID_ELSAQS1P: + sc->sc_flags = FLAG_ELSA_QS1P_ISA; + ret = isic_attach_Eqs1pi(dev); break; #endif - #ifdef ITKIX1 - case FLAG_ITK_IX1: - ret = isic_probe_itkix1(dev); + case VID_ITK0025: + sc->sc_flags = FLAG_ITK_IX1; + ret = isic_attach_itkix1(dev); break; -#endif - +#endif #ifdef AVM_PNP - case FLAG_AVM_PNP: - ret = isic_probe_avm_pnp(dev, iobase2); + case VID_AVMPNP: + sc->sc_flags = FLAG_AVM_PNP; + ret = isic_attach_avm_pnp(dev); break; #endif - #ifdef SIEMENS_ISURF2 - case FLAG_SIEMENS_ISURF2: - ret = isic_probe_siemens_isurf(dev, iobase2); + case VID_SIESURF2: + sc->sc_flags = FLAG_SIEMENS_ISURF2; + ret = isic_attach_siemens_isurf(dev); break; #endif - #ifdef ASUSCOM_IPAC - case FLAG_ASUSCOM_IPAC: - ret = isic_probe_asi(dev, iobase2); + case VID_ASUSCOM_IPAC: + sc->sc_flags = FLAG_ASUSCOM_IPAC; + ret = isic_attach_asi(dev); break; #endif - default: - break; + printf("isic%d: Error, no driver for %s\n", unit, name); + ret = ENXIO; + break; } - return(ret); -} -#endif /* (NISIC > 0) && (NPNP > 0) */ -#endif /* __FreeBSD__ */ + if(ret) + { + isic_detach_common(dev); + return ENXIO; + } + + if(isic_attach_common(dev)) + { + /* unset flag */ + sc->sc_flags = 0; + + /* 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; + } +} +#endif /* (NISIC > 0) */ diff --git a/sys/i4b/layer1/i4b_l1.c b/sys/i4b/layer1/i4b_l1.c index 847bb4f..cdb2b01 100644 --- a/sys/i4b/layer1/i4b_l1.c +++ b/sys/i4b/layer1/i4b_l1.c @@ -27,52 +27,33 @@ * i4b_l1.c - isdn4bsd layer 1 handler * ----------------------------------- * - * $FreeBSD$ + * $Id: i4b_l1.c,v 1.2 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Sun Feb 14 10:28:10 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:01:55 1999] * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ #include "isic.h" -#else -#define NISIC 1 /* don't bother */ -#endif + #if NISIC > 0 #include -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 #include -#else -#include -#endif #include #include #include -#include +#include -#ifdef __FreeBSD__ +#include #include -#include -#else -#ifndef __bsdi__ -#include -#endif -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include #include -#else -#include -#include -#include -#endif #include #include @@ -145,12 +126,7 @@ ph_data_req(int unit, struct mbuf *m, int freeflag) { u_char cmd; int s; - -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif + struct l1_softc *sc = &l1_sc[unit]; #ifdef NOTDEF DBGL1(L1_PRIM, "PH-DATA-REQ", ("unit %d, freeflag=%d\n", unit, freeflag)); @@ -269,13 +245,7 @@ ph_data_req(int unit, struct mbuf *m, int freeflag) static int ph_activate_req(int unit) { - -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif - + struct l1_softc *sc = &l1_sc[unit]; DBGL1(L1_PRIM, "PH-ACTIVATE-REQ", ("unit %d\n", unit)); isic_next_state(sc, EV_PHAR); return(0); @@ -287,12 +257,8 @@ ph_activate_req(int unit) static int i4b_mph_command_req(int unit, int command, int parm) { -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[unit]; -#else - struct isic_softc *sc = isic_find_sc(unit); -#endif - + struct l1_softc *sc = &l1_sc[unit]; + switch(command) { case CMR_DOPEN: /* daemon running */ @@ -314,4 +280,3 @@ i4b_mph_command_req(int unit, int command, int parm) } #endif /* NISIC > 0 */ - diff --git a/sys/i4b/layer1/i4b_l1.h b/sys/i4b/layer1/i4b_l1.h index 3bf196f..8ee9868 100644 --- a/sys/i4b/layer1/i4b_l1.h +++ b/sys/i4b/layer1/i4b_l1.h @@ -27,21 +27,22 @@ * i4b_l1.h - isdn4bsd layer 1 header file * --------------------------------------- * - * $FreeBSD$ + * $Id: i4b_l1.h,v 1.3 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Mon Jul 5 15:32:02 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:02:07 1999] * *---------------------------------------------------------------------------*/ #ifndef I4B_L1_H_ #define I4B_L1_H_ -#ifdef __bsdi__ -#include /* XXX */ -#ifndef ISA_NPORT_CHECK /* Double yuck XXX */ -#include /* XXX */ -#endif -#endif +#include +#include +#include +#include +#include #include @@ -76,56 +77,29 @@ #define MAX_DFRAME_LEN 264 /* max length of a D frame */ -#ifndef __bsdi__ #define min(a,b) ((a)<(b)?(a):(b)) -#endif - -#if !defined(__FreeBSD__) && !defined(__bsdi__) -/* We try to map as few as possible as small as possible io and/or - memory regions. Each card defines its own interpretation of this - mapping array. At probe time we have a fixed size array, later - (when the card type is known) we allocate a minimal array - dynamically. */ - -#define ISIC_MAX_IO_MAPS 49 /* no cardtype needs more yet */ - -/* one entry in mapping array */ -struct isic_io_map { - bus_space_tag_t t; /* which bus-space is this? */ - bus_space_handle_t h; /* handle of mapped bus space region */ - bus_size_t offset; /* offset into region */ - bus_size_t size; /* size of region, zero if not ours - (i.e.: don't ever unmap it!) */ -}; -/* this is passed around at probe time (no struct isic_softc yet) */ -struct isic_attach_args { - int ia_flags; /* flags from config file */ - int ia_num_mappings; /* number of io mappings provided */ - struct isic_io_map ia_maps[ISIC_MAX_IO_MAPS]; -}; -#endif +#define INFO_IO_BASES 50 /* 49 needed for USR */ -#ifdef __FreeBSD__ -extern int next_isic_unit; -#endif +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; +}; /*---------------------------------------------------------------------------* - * isic_Bchan: the state of one B channel + * l1_bchan_state: the state of one B channel *---------------------------------------------------------------------------*/ typedef struct { int unit; /* cards unit number */ int channel; /* which channel is this*/ - -#if defined(__FreeBSD__) || defined(__bsdi__) caddr_t hscx; /* HSCX address */ -#endif - 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 */ @@ -170,39 +144,19 @@ typedef struct int stat_XDU; /* HSCX EXIR tx data underrun */ int stat_RFO; /* HSCX EXIR rx frame overflow */ -} isic_Bchan_t; +} l1_bchan_state_t; /*---------------------------------------------------------------------------* - * isic_softc: the state of the layer 1 of the D channel + * l1_softc: the state of the layer 1 of the D channel *---------------------------------------------------------------------------*/ -struct isic_softc +struct l1_softc { -#if !defined(__FreeBSD__) - /* We are inherited from this class. All drivers must have this - as their first entry in struct softc. */ - struct device sc_dev; -#endif - int sc_unit; /* unit number */ int sc_irq; /* interrupt vector */ + struct i4b_info sc_resources; + int sc_flags; -#ifdef __FreeBSD__ int sc_port; /* port base address */ -#elif defined(__bsdi__) - struct isadev sc_id; /* ISA/PCI device */ - struct intrhand sc_ih; /* interrupt vectoring */ - int sc_flags; - int sc_port; - caddr_t sc_maddr; - int sc_abustype; /* PCI, ISA etcetera */ -#else - u_int sc_maddr; /* "memory address" for card config register */ - int sc_num_mappings; /* number of io mappings provided */ - struct isic_io_map *sc_maps; - -#define MALLOC_MAPS(sc) \ - (sc)->sc_maps = (struct isic_io_map*)malloc(sizeof((sc)->sc_maps[0])*(sc)->sc_num_mappings, M_DEVBUF, 0) -#endif int sc_cardtyp; /* CARD_TYPEP_xxxx */ @@ -220,19 +174,17 @@ struct isic_softc int sc_init_tries; /* no of out tries to access S0 */ -#if defined(__FreeBSD__) || defined(__bsdi__) 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) -#endif u_char sc_isac_mask; /* ISAC IRQ mask */ #define ISAC_IMASK (sc->sc_isac_mask) - isic_Bchan_t sc_chan[2]; /* B-channel state */ + 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) @@ -256,15 +208,12 @@ struct isic_softc int sc_I430state; /* I.430 state F3 .... F8 */ int sc_I430T3; /* I.430 Timer T3 running */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 + struct callout_handle sc_T3_callout; -#endif - + int sc_I430T4; /* Timer T4 running */ -#if defined(__FreeBSD__) && __FreeBSD__ >=3 struct callout_handle sc_T4_callout; -#endif /* * byte fields for the AVM Fritz!Card PCI. These are packed into @@ -278,40 +227,17 @@ struct isic_softc int sc_ipac; /* flag, running on ipac */ int sc_bfifolen; /* length of b channel fifos */ - -#if defined(__FreeBSD__) || defined(__bsdi__) - - u_char (*readreg)(u_char *, u_int); - void (*writereg)(u_char *, u_int, u_int); - void (*readfifo)(void *, const void *, size_t); - void (*writefifo)(void *, const void *, size_t); - void (*clearirq)(void *); - -#define ISAC_READ(r) (*sc->readreg)(ISAC_BASE, (r)) -#define ISAC_WRITE(r,v) (*sc->writereg)(ISAC_BASE, (r), (v)); -#define ISAC_RDFIFO(b,s) (*sc->readfifo)((b), ISAC_BASE, (s)) -#define ISAC_WRFIFO(b,s) (*sc->writefifo)(ISAC_BASE, (b), (s)) - -#define HSCX_READ(n,r) (*sc->readreg)(sc->sc_chan[(n)].hscx, (r)) -#define HSCX_WRITE(n,r,v) (*sc->writereg)(sc->sc_chan[(n)].hscx, (r), (v)) -#define HSCX_RDFIFO(n,b,s) (*sc->readfifo)((b), sc->sc_chan[(n)].hscx, (s)) -#define HSCX_WRFIFO(n,b,s) (*sc->writefifo)(sc->sc_chan[(n)].hscx, (b), (s)) - -#define IPAC_READ(r) (*sc->readreg)(IPAC_BASE, (r)) -#define IPAC_WRITE(r,v) (*sc->writereg)(IPAC_BASE, (r), (v)); - -#else /* ! __FreeBSD__ */ #define ISIC_WHAT_ISAC 0 #define ISIC_WHAT_HSCXA 1 #define ISIC_WHAT_HSCXB 2 #define ISIC_WHAT_IPAC 3 - u_int8_t (*readreg) __P((struct isic_softc *sc, int what, bus_size_t offs)); - void (*writereg) __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)); - void (*readfifo) __P((struct isic_softc *sc, int what, void *buf, size_t size)); - void (*writefifo) __P((struct isic_softc *sc, int what, const void *data, size_t size)); - void (*clearirq) __P((struct isic_softc *sc)); + 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)) @@ -325,8 +251,6 @@ struct isic_softc #define IPAC_READ(r) (*sc->readreg)(sc, ISIC_WHAT_IPAC, (r)) #define IPAC_WRITE(r, v) (*sc->writereg)(sc, ISIC_WHAT_IPAC, (r), (v)) - -#endif /* __FreeBSD__ */ }; /*---------------------------------------------------------------------------* @@ -373,148 +297,51 @@ enum I430commands { #define N_COMMANDS CMD_ILL -#ifdef __FreeBSD__ - -extern struct isic_softc isic_sc[]; - -extern void isic_recover(struct isic_softc *sc); -extern int isic_realattach(struct isa_device *dev, unsigned int iobase2); -extern int isic_attach_avma1 ( struct isa_device *dev ); -extern int isic_attach_fritzpcmcia ( struct isa_device *dev ); -extern int isic_attach_Cs0P ( struct isa_device *dev, unsigned int iobase2); -extern int isic_attach_Dyn ( struct isa_device *dev, unsigned int iobase2); -extern int isic_attach_s016 ( struct isa_device *dev ); -extern int isic_attach_s0163 ( struct isa_device *dev ); -extern int isic_attach_s0163P ( struct isa_device *dev, unsigned int iobase2); -extern int isic_attach_s08 ( struct isa_device *dev ); -extern int isic_attach_usrtai ( struct isa_device *dev ); -extern int isic_attach_itkix1 ( struct isa_device *dev ); -extern int isic_attach_drnngo ( struct isa_device *dev, unsigned int iobase2); -extern int isic_attach_sws ( struct isa_device *dev ); -extern int isic_attach_Eqs1pi(struct isa_device *dev, unsigned int iobase2); -extern int isic_attach_avm_pnp(struct isa_device *dev, unsigned int iobase2); -extern int isic_attach_siemens_isurf(struct isa_device *dev, unsigned int iobase2); -extern int isic_attach_Eqs1pp(int unit, unsigned int iobase1, unsigned int iobase2); -extern int isic_attach_asi(struct isa_device *dev, unsigned int iobase2); + +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 int isic_hscx_fifo(isic_Bchan_t *, struct isic_softc *); -extern void isic_hscx_init ( struct isic_softc *sc, int hscx_channel, int activate ); -extern void isic_hscx_irq ( struct isic_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 isic_softc *sc, int h_chan, unsigned char cmd ); -extern void isic_hscx_waitxfw( struct isic_softc *sc, int h_chan ); -extern void isic_init_linktab ( struct isic_softc *sc ); -extern int isic_isac_init ( struct isic_softc *sc ); -extern void isic_isac_irq ( struct isic_softc *sc, int r ); -extern void isic_isac_l1_cmd ( struct isic_softc *sc, int command ); -extern void isic_next_state ( struct isic_softc *sc, int event ); -extern char *isic_printstate ( struct isic_softc *sc ); -extern int isic_probe_avma1 ( struct isa_device *dev ); -extern int isic_probe_avma1_pcmcia ( struct isa_device *dev ); -extern int isic_probe_avm_pnp ( struct isa_device *dev, unsigned int iobase2); -extern int isic_probe_siemens_isurf ( struct isa_device *dev, unsigned int iobase2); -extern int isic_probe_Cs0P ( struct isa_device *dev, unsigned int iobase2); -extern int isic_probe_Dyn ( struct isa_device *dev, unsigned int iobase2); -extern int isic_probe_s016 ( struct isa_device *dev ); -extern int isic_probe_s0163 ( struct isa_device *dev ); -extern int isic_probe_s0163P ( struct isa_device *dev, unsigned int iobase2); -extern int isic_probe_s08 ( struct isa_device *dev ); -extern int isic_probe_usrtai ( struct isa_device *dev ); -extern int isic_probe_itkix1 ( struct isa_device *dev ); -extern int isic_probe_drnngo ( struct isa_device *dev, unsigned int iobase2); -extern int isic_probe_sws ( struct isa_device *dev ); -extern int isic_probe_Eqs1pi(struct isa_device *dev, unsigned int iobase2); -extern int isic_probe_asi(struct isa_device *dev, unsigned int iobase2); - -#elif defined(__bsdi__) - -extern struct isic_softc *isic_sc[]; -#define isic_find_sc(unit) (isic_sc[(unit)]) - -#define ATTACHARGS struct device *, struct device *, struct isa_attach_args * -#define MATCHARGS struct device *, struct cfdata *, struct isa_attach_args * -extern int isa_isicmatch(MATCHARGS); -extern int isa_isicattach(ATTACHARGS); -extern int isicintr(void *); -extern void isic_recover(struct isic_softc *sc); -extern int isic_realattach(ATTACHARGS); -extern int isic_attach_avma1(ATTACHARGS); -extern int isic_attach_fritzpcmcia(ATTACHARGS); -extern int isic_attach_Cs0P(ATTACHARGS); -extern int isic_attach_Dyn(ATTACHARGS); -extern int isic_attach_s016(ATTACHARGS); -extern int isic_attach_s0163(ATTACHARGS); -extern int isic_attach_s0163P(ATTACHARGS); -extern int isic_attach_s08(ATTACHARGS); -extern int isic_attach_usrtai(ATTACHARGS); -extern int isic_attach_itkix1(ATTACHARGS); -extern int isic_attach_drnngo(ATTACHARGS); -extern int isic_attach_sws(ATTACHARGS); -extern int isic_attach_Eqs1pi(ATTACHARGS); -extern int isic_attach_Eqs1pp(ATTACHARGS); -extern void isic_bchannel_setup(int unit, int hscx_channel, int bprot, int activate ); -extern void isic_hscx_init(struct isic_softc *sc, int hscx_channel, int activate ); -extern void isic_hscx_irq(struct isic_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 isic_softc *sc, int h_chan, unsigned char cmd ); -extern void isic_hscx_waitxfw(struct isic_softc *sc, int h_chan ); -extern void isic_init_linktab(struct isic_softc *sc ); -extern int isic_isac_init(struct isic_softc *sc ); -extern void isic_isac_irq(struct isic_softc *sc, int r ); -extern void isic_isac_l1_cmd(struct isic_softc *sc, int command ); -extern void isic_next_state(struct isic_softc *sc, int event ); -extern char *isic_printstate(struct isic_softc *sc ); -extern int isic_probe_avma1(MATCHARGS); -extern int isic_probe_avma1_pcmcia(MATCHARGS); -extern int isic_probe_Cs0P(MATCHARGS); -extern int isic_probe_Dyn(MATCHARGS); -extern int isic_probe_s016(MATCHARGS); -extern int isic_probe_s0163(MATCHARGS); -extern int isic_probe_s0163P(MATCHARGS); -extern int isic_probe_s08(MATCHARGS); -extern int isic_probe_usrtai(MATCHARGS); -extern int isic_probe_itkix1(MATCHARGS); -extern int isic_probe_drnngo(MATCHARGS); -extern int isic_probe_sws(MATCHARGS); -extern int isic_probe_Eqs1pi(MATCHARGS); - -#undef MATCHARGS -#undef ATTACHARGS -#else /* not FreeBSD/__bsdi__ */ - -extern void isic_recover __P((struct isic_softc *sc)); -extern int isicattach __P((int flags, struct isic_softc *sc)); -extern int isicintr __P((void *)); -extern int isicprobe __P((struct isic_attach_args *ia)); -extern int isic_attach_avma1 __P((struct isic_softc *sc)); -extern int isic_attach_s016 __P((struct isic_softc *sc)); -extern int isic_attach_s0163 __P((struct isic_softc *sc)); -extern int isic_attach_s08 __P((struct isic_softc *sc)); -extern int isic_attach_usrtai __P((struct isic_softc *sc)); -extern int isic_attach_itkix1 __P((struct isic_softc *sc)); -extern void isic_bchannel_setup __P((int unit, int hscx_channel, int bprot, int activate)); -extern void isic_hscx_init __P((struct isic_softc *sc, int hscx_channel, int activate)); -extern void isic_hscx_irq __P((struct isic_softc *sc, u_char ista, int hscx_channel, u_char ex_irq)); -extern int isic_hscx_silence __P(( unsigned char *data, int len )); -extern void isic_hscx_cmd __P(( struct isic_softc *sc, int h_chan, unsigned char cmd )); -extern void isic_hscx_waitxfw __P(( struct isic_softc *sc, int h_chan )); -extern void isic_init_linktab __P((struct isic_softc *sc)); -extern int isic_isac_init __P((struct isic_softc *sc)); -extern void isic_isac_irq __P((struct isic_softc *sc, int r)); -extern void isic_isac_l1_cmd __P((struct isic_softc *sc, int command)); -extern void isic_next_state __P((struct isic_softc *sc, int event)); -extern char * isic_printstate __P((struct isic_softc *sc)); -extern int isic_probe_avma1 __P((struct isic_attach_args *ia)); -extern int isic_probe_s016 __P((struct isic_attach_args *ia)); -extern int isic_probe_s0163 __P((struct isic_attach_args *ia)); -extern int isic_probe_s08 __P((struct isic_attach_args *ia)); -extern int isic_probe_usrtai __P((struct isic_attach_args *ia)); -extern int isic_probe_itkix1 __P((struct isic_attach_args *ia)); - -extern struct isic_softc *isic_sc[]; - -#define isic_find_sc(unit) (isic_sc[(unit)]) - -#endif /* __FreeBSD__ */ + +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_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); + #endif /* I4B_L1_H_ */ diff --git a/sys/i4b/layer1/i4b_l1fsm.c b/sys/i4b/layer1/i4b_l1fsm.c index 142cff3..3107db0 100644 --- a/sys/i4b/layer1/i4b_l1fsm.c +++ b/sys/i4b/layer1/i4b_l1fsm.c @@ -27,52 +27,32 @@ * i4b_l1fsm.c - isdn4bsd layer 1 I.430 state machine * -------------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_l1fsm.c,v 1.2 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Sun Feb 14 10:28:26 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:02:16 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) || defined(__bsdi__) #include "isic.h" -#else -#define NISIC 1 -#endif #if NISIC > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include +#include #include - -#ifdef __FreeBSD__ #include -#include -#else -#ifndef __bsdi__ -#include -#endif -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include -#else -#include -#include -#endif #include #include @@ -110,27 +90,27 @@ static char *event_text[N_EVENTS] = { /* Function prototypes */ -static void timer3_expired (struct isic_softc *sc); -static void T3_start (struct isic_softc *sc); -static void T3_stop (struct isic_softc *sc); -static void F_T3ex (struct isic_softc *sc); -static void timer4_expired (struct isic_softc *sc); -static void T4_start (struct isic_softc *sc); -static void T4_stop (struct isic_softc *sc); -static void F_AI8 (struct isic_softc *sc); -static void F_AI10 (struct isic_softc *sc); -static void F_I01 (struct isic_softc *sc); -static void F_I02 (struct isic_softc *sc); -static void F_I03 (struct isic_softc *sc); -static void F_I2 (struct isic_softc *sc); -static void F_ill (struct isic_softc *sc); -static void F_NULL (struct isic_softc *sc); +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 isic_softc *sc) +timer3_expired(struct l1_softc *sc) { if(sc->sc_I430T3) { @@ -180,23 +160,18 @@ timer3_expired(struct isic_softc *sc) * I.430 Timer T3 start *---------------------------------------------------------------------------*/ static void -T3_start(struct isic_softc *sc) +T3_start(struct l1_softc *sc) { DBGL1(L1_T_MSG, "T3_start", ("state = %s\n", isic_printstate(sc))); sc->sc_I430T3 = 1; - -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - sc->sc_T3_callout = timeout((TIMEOUT_FUNC_T)timer3_expired,(struct isic_softc *)sc, 2*hz); -#else - timeout((TIMEOUT_FUNC_T)timer3_expired,(struct isic_softc *)sc, 2*hz); -#endif + 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 isic_softc *sc) +T3_stop(struct l1_softc *sc) { DBGL1(L1_T_MSG, "T3_stop", ("state = %s\n", isic_printstate(sc))); @@ -205,11 +180,7 @@ T3_stop(struct isic_softc *sc) if(sc->sc_I430T3) { sc->sc_I430T3 = 0; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - untimeout((TIMEOUT_FUNC_T)timer3_expired,(struct isic_softc *)sc, sc->sc_T3_callout); -#else - untimeout((TIMEOUT_FUNC_T)timer3_expired,(struct isic_softc *)sc); -#endif + untimeout((TIMEOUT_FUNC_T)timer3_expired,(struct l1_softc *)sc, sc->sc_T3_callout); } } @@ -217,21 +188,22 @@ T3_stop(struct isic_softc *sc) * I.430 Timer T3 expiry *---------------------------------------------------------------------------*/ static void -F_T3ex(struct isic_softc *sc) +F_T3ex(struct l1_softc *sc) { DBGL1(L1_F_MSG, "F_T3ex", ("FSM function F_T3ex executing\n")); - PH_Deact_Ind(sc->sc_unit); + if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S) + PH_Deact_Ind(sc->sc_unit); } /*---------------------------------------------------------------------------* * Timer T4 expire function *---------------------------------------------------------------------------*/ static void -timer4_expired(struct isic_softc *sc) +timer4_expired(struct l1_softc *sc) { if(sc->sc_I430T4) { - DBGL1(L1_T_ERR, "timer4_expired", ("state = %s\n", isic_printstate(sc))); + DBGL1(L1_T_MSG, "timer4_expired", ("state = %s\n", isic_printstate(sc))); sc->sc_I430T4 = 0; MPH_Status_Ind(sc->sc_unit, STI_PDEACT, 0); } @@ -245,34 +217,25 @@ timer4_expired(struct isic_softc *sc) * Timer T4 start *---------------------------------------------------------------------------*/ static void -T4_start(struct isic_softc *sc) +T4_start(struct l1_softc *sc) { DBGL1(L1_T_MSG, "T4_start", ("state = %s\n", isic_printstate(sc))); sc->sc_I430T4 = 1; - -#if defined(__FreeBSD__) && __FreeBSD__ >=3 - sc->sc_T4_callout = timeout((TIMEOUT_FUNC_T)timer4_expired,(struct isic_softc *)sc, hz); -#else - timeout((TIMEOUT_FUNC_T)timer4_expired,(struct isic_softc *)sc, hz); -#endif + sc->sc_T4_callout = timeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, hz); } /*---------------------------------------------------------------------------* * Timer T4 stop *---------------------------------------------------------------------------*/ static void -T4_stop(struct isic_softc *sc) +T4_stop(struct l1_softc *sc) { DBGL1(L1_T_MSG, "T4_stop", ("state = %s\n", isic_printstate(sc))); if(sc->sc_I430T4) { sc->sc_I430T4 = 0; -#if defined(__FreeBSD__) && __FreeBSD__ >=3 - untimeout((TIMEOUT_FUNC_T)timer4_expired,(struct isic_softc *)sc, sc->sc_T4_callout); -#else - untimeout((TIMEOUT_FUNC_T)timer4_expired,(struct isic_softc *)sc); -#endif + untimeout((TIMEOUT_FUNC_T)timer4_expired,(struct l1_softc *)sc, sc->sc_T4_callout); } } @@ -280,13 +243,14 @@ T4_stop(struct isic_softc *sc) * FSM function: received AI8 *---------------------------------------------------------------------------*/ static void -F_AI8(struct isic_softc *sc) +F_AI8(struct l1_softc *sc) { T4_stop(sc); DBGL1(L1_F_MSG, "F_AI8", ("FSM function F_AI8 executing\n")); - PH_Act_Ind(sc->sc_unit); + if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S) + PH_Act_Ind(sc->sc_unit); T3_stop(sc); @@ -308,13 +272,14 @@ F_AI8(struct isic_softc *sc) * FSM function: received AI10 *---------------------------------------------------------------------------*/ static void -F_AI10(struct isic_softc *sc) +F_AI10(struct l1_softc *sc) { T4_stop(sc); DBGL1(L1_F_MSG, "F_AI10", ("FSM function F_AI10 executing\n")); - PH_Act_Ind(sc->sc_unit); + if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S) + PH_Act_Ind(sc->sc_unit); T3_stop(sc); @@ -336,7 +301,7 @@ F_AI10(struct isic_softc *sc) * FSM function: received INFO 0 in states F3 .. F5 *---------------------------------------------------------------------------*/ static void -F_I01(struct isic_softc *sc) +F_I01(struct l1_softc *sc) { DBGL1(L1_F_MSG, "F_I01", ("FSM function F_I01 executing\n")); @@ -358,11 +323,12 @@ F_I01(struct isic_softc *sc) * FSM function: received INFO 0 in state F6 *---------------------------------------------------------------------------*/ static void -F_I02(struct isic_softc *sc) +F_I02(struct l1_softc *sc) { DBGL1(L1_F_MSG, "F_I02", ("FSM function F_I02 executing\n")); - PH_Deact_Ind(sc->sc_unit); + if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S) + PH_Deact_Ind(sc->sc_unit); if(sc->sc_trace & TRACE_I) { @@ -382,11 +348,12 @@ F_I02(struct isic_softc *sc) * FSM function: received INFO 0 in state F7 or F8 *---------------------------------------------------------------------------*/ static void -F_I03(struct isic_softc *sc) +F_I03(struct l1_softc *sc) { DBGL1(L1_F_MSG, "F_I03", ("FSM function F_I03 executing\n")); - PH_Deact_Ind(sc->sc_unit); + if(ctrl_desc[sc->sc_unit].protocol != PROTOCOL_D64S) + PH_Deact_Ind(sc->sc_unit); T4_start(sc); @@ -408,7 +375,7 @@ F_I03(struct isic_softc *sc) * FSM function: activate request *---------------------------------------------------------------------------*/ static void -F_AR(struct isic_softc *sc) +F_AR(struct l1_softc *sc) { DBGL1(L1_F_MSG, "F_AR", ("FSM function F_AR executing\n")); @@ -434,7 +401,7 @@ F_AR(struct isic_softc *sc) * FSM function: received INFO2 *---------------------------------------------------------------------------*/ static void -F_I2(struct isic_softc *sc) +F_I2(struct l1_softc *sc) { DBGL1(L1_F_MSG, "F_I2", ("FSM function F_I2 executing\n")); @@ -457,7 +424,7 @@ F_I2(struct isic_softc *sc) * illegal state default action *---------------------------------------------------------------------------*/ static void -F_ill(struct isic_softc *sc) +F_ill(struct l1_softc *sc) { DBGL1(L1_F_ERR, "F_ill", ("FSM function F_ill executing\n")); } @@ -466,7 +433,7 @@ F_ill(struct isic_softc *sc) * No action *---------------------------------------------------------------------------*/ static void -F_NULL(struct isic_softc *sc) +F_NULL(struct l1_softc *sc) { DBGL1(L1_F_MSG, "F_NULL", ("FSM function F_NULL executing\n")); } @@ -476,7 +443,7 @@ F_NULL(struct isic_softc *sc) * layer 1 state transition table *---------------------------------------------------------------------------*/ struct isic_state_tab { - void (*func) (struct isic_softc *sc); /* function to execute */ + void (*func) (struct l1_softc *sc); /* function to execute */ int newstate; /* next state */ } isic_state_tab[N_EVENTS][N_STATES] = { @@ -500,7 +467,7 @@ struct isic_state_tab { * event handler *---------------------------------------------------------------------------*/ void -isic_next_state(struct isic_softc *sc, int event) +isic_next_state(struct l1_softc *sc, int event) { int currstate, newstate; @@ -539,7 +506,7 @@ isic_next_state(struct isic_softc *sc, int event) * return pointer to current state description *---------------------------------------------------------------------------*/ char * -isic_printstate(struct isic_softc *sc) +isic_printstate(struct l1_softc *sc) { return((char *) state_text[sc->sc_I430state]); } diff --git a/sys/i4b/layer1/i4b_siemens_isurf.c b/sys/i4b/layer1/i4b_siemens_isurf.c index ed48a66..29730aa 100644 --- a/sys/i4b/layer1/i4b_siemens_isurf.c +++ b/sys/i4b/layer1/i4b_siemens_isurf.c @@ -37,32 +37,28 @@ * Siemens I-Surf 2.0 PnP specific routines for isic driver * -------------------------------------------------------- * + * $Id: i4b_siemens_isurf.c,v 1.2 1999/12/13 21:25:26 hm Exp $ + * * $FreeBSD$ * - * last edit-date: [Mon 14 Jun 16:46:27 CEST 1999] + * last edit-date: [Mon Dec 13 22:02:28 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) #include "isic.h" #include "opt_i4b.h" #if NISIC > 0 && defined(SIEMENS_ISURF2) #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include +#include #include -#include -#include #include #include @@ -97,171 +93,122 @@ /*---------------------------------------------------------------------------* * Siemens I-Surf 2.0 PnP ISAC get fifo routine *---------------------------------------------------------------------------*/ - -static void -siemens_isurf_read_fifo(void *buf, const void *base, size_t len) +static void +siemens_isurf_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size) { - if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXB) + 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 ) { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_HSCXB_OFF); - insb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (u_char *)buf, (u_int)len); + 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; } - else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXA) - { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_HSCXA_OFF); - insb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (u_char *)buf, (u_int)len); - } - else /* if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDISAC) */ - { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_ISAC_OFF); - insb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (u_char *)buf, (u_int)len); - } } /*---------------------------------------------------------------------------* * Siemens I-Surf 2.0 PnP ISAC put fifo routine *---------------------------------------------------------------------------*/ - -static void -siemens_isurf_write_fifo(void *base, const void *buf, size_t len) +static void +siemens_isurf_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size) { - if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXB) - { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_HSCXB_OFF); - outsb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (const u_char *)buf, (u_int)len); - } - else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXA) - { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_HSCXA_OFF); - outsb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (const u_char *)buf, (u_int)len); - } - else /* if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDISAC) */ + 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 ) { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, IPAC_ISAC_OFF); - outsb((((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW), (const u_char *)buf, (u_int)len); + 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(u_char *base, u_int offset, u_int v) +siemens_isurf_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data) { - if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXB) - { - outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF)); - outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW, (u_char)v); - } - else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXA) - { - outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF)); - outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW, (u_char)v); - } - else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDISAC) - { - outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF)); - outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW, (u_char)v); - } - else /* IPAC */ + 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 ) { - outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF)); - outb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW, (u_char)v); - } + 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_char -siemens_isurf_read_reg(u_char *base, u_int offset) +static u_int8_t +siemens_isurf_read_reg(struct l1_softc *sc,int what,bus_size_t reg) { - if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXB) - { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_HSCXB_OFF)); - return(inb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW)); + 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; } - else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDHSCXA) - { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_HSCXA_OFF)); - return(inb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW)); - } - else if(((u_int)base & SIE_ISURF_OFF_MASK) == SIE_ISURF_IDISAC) - { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_ISAC_OFF)); - return(inb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW)); - } - else /* IPAC */ - { - outb((u_int)((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_ALE, (u_char)(offset+IPAC_IPAC_OFF)); - return(inb(((u_int)base & SIE_ISURF_BASE_MASK) + SIE_ISURF_OFF_RW)); - } } /*---------------------------------------------------------------------------* - * isic_probe_siemens_isurf - probe for Siemens I-Surf 2.0 PnP + * isic_attach_siemens_isurf - attach for Siemens I-Surf 2.0 PnP *---------------------------------------------------------------------------*/ - int -isic_probe_siemens_isurf(struct isa_device *dev, unsigned int iobase2) +isic_attach_siemens_isurf(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; - - /* check max unit range */ - - if(dev->id_unit >= ISIC_MAXUNIT) - { - printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Siemens I-Surf 2.0 PnP\n", - dev->id_unit, dev->id_unit); - return(0); - } - sc->sc_unit = dev->id_unit; - - /* check IRQ validity */ - - switch(ffs(dev->id_irq) - 1) - { - case 3: - case 4: - case 5: - case 7: - case 10: - case 11: - case 12: - case 15: - break; - - default: - printf("isic%d: Error, invalid IRQ [%d] specified for Siemens I-Surf 2.0 PnP!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); - break; - } - sc->sc_irq = dev->id_irq; - - /* check if memory addr specified */ - - if(dev->id_maddr) - { - printf("isic%d: Error, mem addr 0x%lx specified for Siemens I-Surf 2.0 PnP!\n", - dev->id_unit, (u_long)dev->id_maddr); - return(0); - } - dev->id_msize = 0; + int unit = device_get_unit(dev); + struct l1_softc *sc = &l1_sc[unit]; - /* check if we got an iobase */ - - if(!((dev->id_iobase >= 0x100) && (dev->id_iobase <= 0xff0))) - { - printf("isic%d: Error, invalid iobase 0x%x specified for Siemens I-Surf 2.0 PnP!\n", - dev->id_unit, dev->id_iobase); - return(0); - } - sc->sc_port = dev->id_iobase; - - /* setup access routines */ sc->clearirq = NULL; @@ -283,27 +230,9 @@ isic_probe_siemens_isurf(struct isa_device *dev, unsigned int iobase2) sc->sc_ipac = 1; sc->sc_bfifolen = IPAC_BFIFO_LEN; - - - return (1); -} - -/*---------------------------------------------------------------------------* - * isic_attach_siemens_isurf - attach for Siemens I-Surf 2.0 PnP - *---------------------------------------------------------------------------*/ -int -isic_attach_siemens_isurf(struct isa_device *dev, unsigned int iobase2) -{ - struct isic_softc *sc = &isic_sc[dev->id_unit]; - - /* setup ISAC and HSCX base addr */ - - ISAC_BASE = (caddr_t) ((u_int)sc->sc_port | SIE_ISURF_IDISAC); - HSCX_A_BASE = (caddr_t) ((u_int)sc->sc_port | SIE_ISURF_IDHSCXA); - HSCX_B_BASE = (caddr_t) ((u_int)sc->sc_port | SIE_ISURF_IDHSCXB); - IPAC_BASE = (caddr_t) ((u_int)sc->sc_port | SIE_ISURF_IDIPAC); /* enable hscx/isac irq's */ + IPAC_WRITE(IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0)); IPAC_WRITE(IPAC_ACFG, 0); /* outputs are open drain */ @@ -311,7 +240,6 @@ isic_attach_siemens_isurf(struct isa_device *dev, unsigned int iobase2) (IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2)); IPAC_WRITE(IPAC_ATX, 0xff); /* set all output lines high */ - return(1); + return(0); } #endif /* NISIC > 0 && defined(SIEMENS_ISURF2) */ -#endif /* FreeBSD */ diff --git a/sys/i4b/layer1/i4b_sws.c b/sys/i4b/layer1/i4b_sws.c index 4759762..d6dd4db 100644 --- a/sys/i4b/layer1/i4b_sws.c +++ b/sys/i4b/layer1/i4b_sws.c @@ -44,29 +44,17 @@ * isic - I4B Siemens ISDN Chipset Driver for SWS cards * ==================================================== * - * EXPERIMENTAL !!!! - * ================= + * $Id: i4b_sws.c,v 1.2 1999/12/13 21:25:26 hm Exp $ * * $FreeBSD$ * - * last edit-date: [Sun Feb 14 10:28:31 1999] - * - * -hm adding driver to i4b - * -hm adjustments for FreeBSD < 2.2.6, no PnP support yet + * last edit-date: [Mon Dec 13 22:02:39 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) - #include "isic.h" #include "opt_i4b.h" -#else - -#define NISIC 1 - -#endif - #if defined (SEDLBAUER) && NISIC > 0 #define SWS_RESON 0 /* reset on */ @@ -79,40 +67,19 @@ #define SWS_REGS 8 /* we use an area of 8 bytes for io */ -#define SWS_BASE(X) ((unsigned int)X&~(SWS_REGS-1)) -#define SWS_PART(X) ((unsigned int)X& (SWS_REGS-1)) -#define SWS_ADDR(X) ((SWS_PART(X) == SWS_ISAC) ? (SWS_BASE(X)+SWS_ISAC) : (SWS_BASE(X)+SWS_HSCX0) ) -#define SWS_REG(X,Y) ((SWS_PART(X) != SWS_HSCX1) ? Y : (Y+0x40) ) -#define SWS_IDO(X) (SWS_BASE(X)+SWS_RW) - #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include +#include -#ifdef __FreeBSD__ #include -#include -#else -#include -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include -#else -#include -#include -#endif #include #include @@ -122,191 +89,113 @@ #include #include -#ifndef __FreeBSD__ -static u_int8_t sws_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs)); -static void sws_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)); -static void sws_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size)); -static void sws_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size)); -void isic_attach_sws __P((struct isic_softc *sc)); -#endif - /*---------------------------------------------------------------------------* * SWS P&P ISAC get fifo routine *---------------------------------------------------------------------------*/ - -#ifdef __FreeBSD__ - static void -sws_read_fifo(void *buf, const void *base, size_t len) -{ - outb(SWS_IDO(base),SWS_REG(base,0)); - insb(SWS_ADDR(base),buf,len); -} - -#else +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]); -static void -sws_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - switch (what) { + switch ( what ) { case ISIC_WHAT_ISAC: - bus_space_write_1(t, h, SWS_RW, 0); - bus_space_read_multi_1(t, h, SWS_ISAC, buf, size); + 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, 0); - bus_space_read_multi_1(t, h, SWS_HSCX0, buf, size); + 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, 0x40); - bus_space_read_multi_1(t, h, SWS_HSCX0, buf, size); + bus_space_write_1(t,h,SWS_RW,0x0+0x40); + bus_space_read_multi_1(t,h,SWS_HSCX0,buf,size); break; } } -#endif - -/*---------------------------------------------------------------------------* - * SWS P&P ISAC put fifo routine - *---------------------------------------------------------------------------*/ - -#ifdef __FreeBSD__ - static void -sws_write_fifo(void *base, const void *buf, size_t len) -{ - outb (SWS_IDO(base),SWS_REG(base,0)); - outsb(SWS_ADDR(base),buf,len); -} +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]); -#else - -static void -sws_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - switch (what) { + switch ( what ) { case ISIC_WHAT_ISAC: - bus_space_write_1(t, h, SWS_RW, 0); - bus_space_write_multi_1(t, h, SWS_ISAC, (u_int8_t*)buf, size); + 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, 0); - bus_space_write_multi_1(t, h, SWS_HSCX0, (u_int8_t*)buf, size); + 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, 0x40); - bus_space_write_multi_1(t, h, SWS_HSCX0, (u_int8_t*)buf, size); + bus_space_write_1(t,h,SWS_RW,0x0+0x40); + bus_space_write_multi_1(t,h,SWS_HSCX0,buf,size); break; } } -#endif - -/*---------------------------------------------------------------------------* - * SWS P&P ISAC put register routine - *---------------------------------------------------------------------------*/ - -#ifdef __FreeBSD__ - static void -sws_write_reg(u_char *base, u_int offset, u_int v) -{ - outb(SWS_IDO(base),SWS_REG(base,offset)); - outb(SWS_ADDR(base),v); -} +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]); -#else - -static void -sws_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - switch (what) { + switch ( what ) { case ISIC_WHAT_ISAC: - bus_space_write_1(t, h, SWS_RW, offs); - bus_space_write_1(t, h, SWS_ISAC, data); + 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, offs); - bus_space_write_1(t, h, SWS_HSCX0, data); + 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, 0x40+offs); - bus_space_write_1(t, h, SWS_HSCX0, data); + bus_space_write_1(t,h,SWS_RW,reg+0x40); + bus_space_write_1(t,h,SWS_HSCX0,data); break; } } -#endif - -/*---------------------------------------------------------------------------* - * SWS P&P ISAC get register routine - *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - static u_char -sws_read_reg(u_char *base, u_int offset) -{ - outb(SWS_IDO(base),SWS_REG(base,offset)); - return inb(SWS_ADDR(base)); -} +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]); -#else - -static u_int8_t -sws_read_reg(struct isic_softc *sc, int what, bus_size_t offs) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - switch (what) { + switch ( what ) { case ISIC_WHAT_ISAC: - bus_space_write_1(t, h, SWS_RW, offs); - return bus_space_read_1(t, h, SWS_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, offs); - return bus_space_read_1(t, h, SWS_HSCX0); + 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, 0x40+offs); - return bus_space_read_1(t, h, SWS_HSCX0); + bus_space_write_1(t,h,SWS_RW,reg+0x40); + return bus_space_read_1(t,h,SWS_HSCX0); + default: + return 0; } - return 0; } -#endif - -#ifdef __FreeBSD__ - /* attach callback routine */ - int -isic_attach_sws(struct isa_device *dev) +isic_attach_sws(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; - - /* fill in isic_softc structure */ + 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_unit = dev->id_unit; - sc->sc_irq = dev->id_irq; - sc->sc_port = dev->id_iobase; sc->sc_cardtyp = CARD_TYPEP_SWS; sc->sc_bustyp = BUS_TYPE_IOM2; sc->sc_ipac = 0; sc->sc_bfifolen = HSCX_FIFO_LEN; - dev->id_msize = 0; - - ISAC_BASE = (caddr_t) (((u_int) sc->sc_port) + SWS_ISAC); - HSCX_A_BASE = (caddr_t) (((u_int) sc->sc_port) + SWS_HSCX0); - HSCX_B_BASE = (caddr_t) (((u_int) sc->sc_port) + SWS_HSCX1); /* * Read HSCX A/B VSTR. Expected value for the SWS PnP card is @@ -317,76 +206,20 @@ isic_attach_sws(struct isa_device *dev) ((HSCX_READ(1, H_VSTR) & 0xf) != 0x5) ) { printf("isic%d: HSCX VSTR test failed for SWS PnP\n", - dev->id_unit); + sc->sc_unit); printf("isic%d: HSC0: VSTR: %#x\n", - dev->id_unit, HSCX_READ(0, H_VSTR)); + sc->sc_unit, HSCX_READ(0, H_VSTR)); printf("isic%d: HSC1: VSTR: %#x\n", - dev->id_unit, HSCX_READ(1, H_VSTR)); - return (0); + sc->sc_unit, HSCX_READ(1, H_VSTR)); + return (ENXIO); } /* reset card */ - - outb( ((u_int) sc->sc_port) + SWS_RESON , 0x3); + bus_space_write_1(t,h,SWS_RESON,0x3); DELAY(SEC_DELAY / 5); - outb( ((u_int) sc->sc_port) + SWS_RESOFF, 0); + bus_space_write_1(t,h,SWS_RESOFF,0x0); DELAY(SEC_DELAY / 5); - - return(1); -} - -#else /* !__FreeBSD__ */ - -void -isic_attach_sws(struct isic_softc *sc) -{ - /* setup access routines */ - - sc->readreg = sws_read_reg; - sc->writereg = sws_write_reg; - - sc->readfifo = sws_read_fifo; - sc->writefifo = sws_write_fifo; - - /* setup card type */ - - sc->sc_cardtyp = CARD_TYPEP_SWS; - - /* 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 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("%s: HSCX VSTR test failed for SWS PnP\n", - sc->sc_dev.dv_xname); - printf("%s: HSC0: VSTR: %#x\n", - sc->sc_dev.dv_xname, HSCX_READ(0, H_VSTR)); - printf("%s: HSC1: VSTR: %#x\n", - sc->sc_dev.dv_xname, HSCX_READ(1, H_VSTR)); - return; - } - - /* reset card */ - { - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - bus_space_write_1(t, h, SWS_RESON, 0x3); - DELAY(SEC_DELAY / 5); - bus_space_write_1(t, h, SWS_RESOFF, 0); - DELAY(SEC_DELAY / 5); - } + return(0); } - -#endif /* !__FreeBSD__ */ - #endif /* defined(SEDLBAUER) && NISIC > 0 */ diff --git a/sys/i4b/layer1/i4b_tel_s016.c b/sys/i4b/layer1/i4b_tel_s016.c index 3a84249..d3879b1 100644 --- a/sys/i4b/layer1/i4b_tel_s016.c +++ b/sys/i4b/layer1/i4b_tel_s016.c @@ -37,55 +37,33 @@ * isic - I4B Siemens ISDN Chipset Driver for Teles S0/16 and clones * ================================================================= * - * $FreeBSD$ + * $Id: i4b_tel_s016.c,v 1.3 1999/12/13 21:25:26 hm Exp $ * - * last edit-date: [Sun Feb 14 10:28:38 1999] + * $FreeBSD$ * - * -hm clean up - * -hm checked with a Creatix ISDN-S0 (PCB version: mp 130.1) - * -hm more cleanup - * -hm NetBSD patches from Martin - * -hm converting asm -> C + * last edit-date: [Mon Dec 13 22:02:47 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) #include "isic.h" #include "opt_i4b.h" -#else -#define NISIC 1 -#endif + #if NISIC > 0 && defined(TEL_S0_16) #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include +#include -#ifdef __FreeBSD__ #include #include -#include -#else -#include -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include -#else -#include -#include -#endif #include #include @@ -95,66 +73,36 @@ #include #include -static u_char intr_no[] = { 1, 1, 0, 2, 4, 6, 1, 1, 1, 0, 8, 10, 12, 1, 1, 14 }; +#define TELES_S016_MEMSIZE 0x1000 -#ifndef __FreeBSD__ -static u_int8_t tels016_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs)); -static void tels016_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)); -static void tels016_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size)); -static void tels016_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size)); -#endif +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 *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - static void -tels016_write_reg(u_char *base, u_int i, u_int v) +tels016_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data) { - if(i & 0x01) - i |= 0x200; - base[i] = v; -} - -#else - -static const bus_size_t offset[] = { 0x100, 0x180, 0x1c0 }; - -static void -tels016_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) -{ - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; + 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); } -#endif /*---------------------------------------------------------------------------* * Teles S0/16 read register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static u_char -tels016_read_reg(u_char *base, u_int i) -{ - if(i & 0x1) - i |= 0x200; - return(base[i]); -} - -#else - static u_int8_t -tels016_read_reg(struct isic_softc *sc, int what, bus_size_t offs) +tels016_read_reg(struct l1_softc *sc, int what, bus_size_t offs) { - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; + 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]; @@ -163,72 +111,75 @@ tels016_read_reg(struct isic_softc *sc, int what, bus_size_t offs) return bus_space_read_1(t, h, offs); } -#endif /*---------------------------------------------------------------------------* - * Teles S0/16 fifo read/write routines + * Teles S0/16 fifo write routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -tels016_memcpyb(void *to, const void *from, size_t len) -{ - for(;len > 0; len--) - *((unsigned char *)to)++ = *((unsigned char *)from)++; -} - -#else - static void -tels016_write_fifo(struct isic_softc *sc, int what, const void *data, size_t size) +tels016_write_fifo(struct l1_softc *sc, int what, void *data, size_t size) { - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; + 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 isic_softc *sc, int what, void *buf, size_t size) +tels016_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - bus_space_tag_t t = sc->sc_maps[1].t; - bus_space_handle_t h = sc->sc_maps[1].h; + 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); } -#endif /*---------------------------------------------------------------------------* * isic_probe_s016 - probe for Teles S0/16 and compatibles *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ int -isic_probe_s016(struct isa_device *dev) +isic_probe_s016(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; - u_char byte; + 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(dev->id_unit >= ISIC_MAXUNIT) + + if(unit >= ISIC_MAXUNIT) { printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Teles S0/16!\n", - dev->id_unit, dev->id_unit); - return(0); - } - sc->sc_unit = dev->id_unit; + unit, unit); + return(ENXIO); + } - /* check IRQ validity */ + sc = &l1_sc[unit]; /* get pointer to softc */ + + sc->sc_unit = unit; /* set unit */ + + sc->sc_flags = FLAG_TELES_S0_16; /* set flags */ + + /* see if an io base was supplied */ - if((intr_no[ffs(dev->id_irq) - 1]) == 1) + if(!(sc->sc_resources.io_base[0] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[0], + 0ul, ~0ul, 1, RF_ACTIVE))) { - printf("isic%d: Error, invalid IRQ [%d] specified for Teles S0/16!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); + printf("isic%d: Could not allocate i/o port for Teles S0/16.\n", unit); + return(ENXIO); } - sc->sc_irq = dev->id_irq; - /* check if we got an iobase */ + sc->sc_port = rman_get_start(sc->sc_resources.io_base[0]); + + /* + * check if the provided io port is valid + */ - switch(dev->id_iobase) + switch(sc->sc_port) { case 0xd80: case 0xe80: @@ -237,15 +188,34 @@ isic_probe_s016(struct isa_device *dev) default: printf("isic%d: Error, invalid iobase 0x%x specified for Teles S0/16!\n", - dev->id_unit, dev->id_iobase); - return(0); + unit, sc->sc_port); + isic_detach_common(dev); + return(ENXIO); break; } - sc->sc_port = dev->id_iobase; - - /* check if valid memory addr */ - switch((unsigned int)kvtop(dev->id_maddr)) + /* 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: @@ -266,51 +236,25 @@ isic_probe_s016(struct isa_device *dev) break; default: - printf("isic%d: Error, invalid mem addr 0x%lx for Teles S0/16!\n", - dev->id_unit, kvtop(dev->id_maddr)); - return(0); + printf("isic%d: Error, invalid memory address 0x%lx for Teles S0/16!\n", + unit, kvtop(sc->sc_vmem_addr)); + isic_detach_common(dev); + return(ENXIO); break; } - sc->sc_vmem_addr = (caddr_t) dev->id_maddr; - dev->id_msize = 0x1000; - - /* check card signature */ - - if((byte = inb(sc->sc_port)) != 0x51) - { - printf("isic%d: Error, signature 1 0x%x != 0x51 for Teles S0/16!\n", - dev->id_unit, byte); - return(0); - } - - if((byte = inb(sc->sc_port + 1)) != 0x93) - { - printf("isic%d: Error, signature 2 0x%x != 0x93 for Teles S0/16!\n", - dev->id_unit, byte); - return(0); - } - byte = inb(sc->sc_port + 2); - - if((byte != 0x1e) && (byte != 0x1f)) - { - printf("isic%d: Error, signature 3 0x%x != 0x1e or 0x1f for Teles S0/16!\n", - dev->id_unit, byte); - return(0); - } - - /* setup access routines */ + /* setup ISAC access routines */ sc->clearirq = NULL; + sc->readreg = tels016_read_reg; sc->writereg = tels016_write_reg; - sc->readfifo = tels016_memcpyb; - sc->writefifo = tels016_memcpyb; + sc->readfifo = tels016_read_fifo; + sc->writefifo = tels016_write_fifo; /* setup card type */ - - sc->sc_cardtyp= CARD_TYPEP_16; + sc->sc_cardtyp = CARD_TYPEP_16; /* setup IOM bus type */ @@ -318,138 +262,124 @@ isic_probe_s016(struct isa_device *dev) sc->sc_ipac = 0; sc->sc_bfifolen = HSCX_FIFO_LEN; + + /* setup ISAC base addr, though we don't really need it */ - /* setup ISAC base addr */ - - ISAC_BASE = (caddr_t) ((dev->id_maddr) + 0x100); + ISAC_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x100); /* setup HSCX base addr */ - HSCX_A_BASE = (caddr_t) ((dev->id_maddr) + 0x180); - HSCX_B_BASE = (caddr_t) ((dev->id_maddr) + 0x1c0); - - return (1); -} - -#else + HSCX_A_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x180); + HSCX_B_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x1c0); -int -isic_probe_s016(struct isic_attach_args *ia) -{ - bus_space_tag_t t = ia->ia_maps[0].t; - bus_space_handle_t h = ia->ia_maps[0].h; - u_int8_t b0, b1, b2; + 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); - if (b0 == 0x51 && b1 == 0x93 && (b2 == 0x1e || b2 == 0x1f)) - return 1; - - return 0; -} -#endif - -/*---------------------------------------------------------------------------* - * isic_attach_s016 - attach Teles S0/16 and compatibles - *---------------------------------------------------------------------------*/ -int -#ifdef __FreeBSD__ -isic_attach_s016(struct isa_device *dev) -#else -isic_attach_s016(struct isic_softc *sc) -#endif -{ - -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[dev->id_unit]; -#endif - - u_long irq; - -#ifndef __FreeBSD__ - /* setup 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 */ + /* 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); + } - sc->sc_cardtyp= CARD_TYPEP_16; - - /* setup IOM bus type */ + 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); + } - sc->sc_bustyp = BUS_TYPE_IOM1; - - sc->sc_ipac = 0; - sc->sc_bfifolen = HSCX_FIFO_LEN; + 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); + } -#endif + /* get our irq */ -#ifdef __FreeBSD__ - if((irq = intr_no[ffs(dev->id_irq) - 1]) == 1) + if(!(sc->sc_resources.irq = + bus_alloc_resource(dev, SYS_RES_IRQ, + &sc->sc_resources.irq_rid, + 0ul, ~0ul, 1, RF_ACTIVE))) { - printf("isic%d: Attach error, invalid IRQ [%d] specified for Teles S0/16!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); + printf("isic%d: Could not allocate irq for Teles S0/16.\n", unit); + isic_detach_common(dev); + return ENXIO; } -#else - irq = intr_no[sc->sc_irq]; -#endif - /* configure IRQ */ + /* register interupt routine */ -#ifdef __FreeBSD__ - irq |= ((u_long) sc->sc_vmem_addr) >> 9; + bus_setup_intr(dev, sc->sc_resources.irq, + INTR_TYPE_NET, + (void(*)(void *))(isicintr), + sc, &ih); - DELAY(SEC_DELAY / 10); - outb(sc->sc_port + 4, irq); + /* get the irq number */ + + sc->sc_irq = rman_get_start(sc->sc_resources.irq); - DELAY(SEC_DELAY / 10); - outb(sc->sc_port + 4, irq | 0x01); + /* check IRQ validity */ - DELAY(SEC_DELAY / 5); + 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); +} - /* set card bit off */ +/*---------------------------------------------------------------------------* + * 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; - sc->sc_vmem_addr[0x80] = 0; - DELAY(SEC_DELAY / 5); + 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]); - /* set card bit on */ - - sc->sc_vmem_addr[0x80] = 1; - DELAY(SEC_DELAY / 5); + /* is this right for FreeBSD or off by one ? */ + irq = intr_no[sc->sc_irq]; -#else + /* configure IRQ */ - irq |= ((sc->sc_maddr >> 9) & 0x000000f0); + irq |= ((u_long) sc->sc_vmem_addr) >> 9; DELAY(SEC_DELAY / 10); - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, 4, irq); + bus_space_write_1(tb, hb, 4, irq); DELAY(SEC_DELAY / 10); - bus_space_write_1(sc->sc_maps[0].t, sc->sc_maps[0].h, 4, irq | 0x01); + bus_space_write_1(tb, hb, 4, irq | 0x01); DELAY(SEC_DELAY / 5); /* set card bit off */ - bus_space_write_1(sc->sc_maps[1].t, sc->sc_maps[1].h, 0x80, 0); + bus_space_write_1(ta, ha, 0x80, 0); DELAY(SEC_DELAY / 5); /* set card bit on */ - bus_space_write_1(sc->sc_maps[1].t, sc->sc_maps[1].h, 0x80, 1); + bus_space_write_1(ta, ha, 0x80, 1); DELAY(SEC_DELAY / 5); -#endif - return (1); + return 0; } - #endif /* ISIC > 0 */ - diff --git a/sys/i4b/layer1/i4b_tel_s0163.c b/sys/i4b/layer1/i4b_tel_s0163.c index 0d36135..9b4f06e 100644 --- a/sys/i4b/layer1/i4b_tel_s0163.c +++ b/sys/i4b/layer1/i4b_tel_s0163.c @@ -37,55 +37,32 @@ * isic - I4B Siemens ISDN Chipset Driver for Teles S0/16.3 * ======================================================== * - * $FreeBSD$ + * $Id: i4b_tel_s0163.c,v 1.2 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Mon Jul 26 10:59:38 1999] + * $FreeBSD$ * - * -hm clean up - * -hm more cleanup - * -hm NetBSD patches from Martin - * -hm VSTR detection for older 16.3 cards + * last edit-date: [Mon Dec 13 22:02:55 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) #include "isic.h" #include "opt_i4b.h" -#else -#define NISIC 1 -#endif + #if NISIC > 0 && defined(TEL_S0_16_3) #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include +#include -#ifdef __FreeBSD__ #include -#include -#elif defined(__bsdi__) - /* XXX */ -#else -#include -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include -#else -#include -#include -#endif #include #include @@ -97,184 +74,167 @@ static u_char intr_no[] = { 1, 1, 0, 2, 4, 6, 1, 1, 1, 0, 8, 10, 12, 1, 1, 14 }; -#if !defined(__FreeBSD__) && !defined(__bsdi__) -static u_int8_t tels0163_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs)); -static void tels0163_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)); -static void tels0163_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size)); -static void tels0163_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size)); -#endif +#define ISAC_OFFS 0x420 +#define HSCXA_OFFS 0xc20 +#define HSCXB_OFFS 0x820 /*---------------------------------------------------------------------------* * Teles S0/16.3 read fifo routine *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) || defined(__bsdi__) - -static void -tels0163_read_fifo(void *buf, const void *base, size_t len) -{ - insb((int)base + 0x3e, (u_char *)buf, (u_int)len); -} - -#else - static void -tels0163_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) +tels0163_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - bus_space_read_multi_1(t, h, o + 0x1e, buf, 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,0x3e,buf,size); } -#endif - /*---------------------------------------------------------------------------* * Teles S0/16.3 write fifo routine *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) || defined(__bsdi__) - static void -tels0163_write_fifo(void *base, const void *buf, size_t len) +tels0163_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - outsb((int)base + 0x3e, (u_char *)buf, (u_int)len); + 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,0x3e,buf,size); } -#else - -static void -tels0163_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - bus_space_write_multi_1(t, h, o + 0x1e, (u_int8_t*)buf, size); -} -#endif - /*---------------------------------------------------------------------------* * Teles S0/16.3 ISAC put register routine *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) || defined(__bsdi__) - -static void -tels0163_write_reg(u_char *base, u_int offset, u_int v) -{ - outb((int)base + offset, (u_char)v); -} - -#else - static void -tels0163_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) +tels0163_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data) { - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - bus_space_write_1(t, h, o + offs - 0x20, 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); } -#endif /*---------------------------------------------------------------------------* * Teles S0/16.3 ISAC get register routine *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) || defined(__bsdi__) - -static u_char -tels0163_read_reg(u_char *base, u_int offset) -{ - return (inb((int)base + offset)); -} - -#else - static u_int8_t -tels0163_read_reg(struct isic_softc *sc, int what, bus_size_t offs) +tels0163_read_reg(struct l1_softc *sc, int what, bus_size_t offs) { - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - return bus_space_read_1(t, h, o + offs - 0x20); + 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); } -#endif - /*---------------------------------------------------------------------------* - * isic_probe_s0163 - probe for Teles S0/16.3 and compatibles + * isic_probe_s0163 - probe routine for Teles S0/16.3 *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ int -isic_probe_s0163(struct isa_device *dev) +isic_probe_s0163(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; - u_char byte; - - /* check max unit range */ - - if(dev->id_unit >= ISIC_MAXUNIT) - { - printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Teles S0/16.3!\n", - dev->id_unit, dev->id_unit); - return(0); - } - sc->sc_unit = dev->id_unit; + 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 IRQ validity */ + /* check max unit range */ - if((intr_no[ffs(dev->id_irq) - 1]) == 1) + if(unit >= ISIC_MAXUNIT) { - printf("isic%d: Error, invalid IRQ [%d] specified for Teles S0/16.3!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); + printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Teles 16.3!\n", + unit, unit); + return(ENXIO); } - sc->sc_irq = dev->id_irq; - /* check if memory addr specified */ + sc = &l1_sc[unit]; /* get pointer to softc */ + sc->sc_unit = unit; /* set unit */ + sc->sc_flags = FLAG_TELES_S0_163; /* set flags */ - if(dev->id_maddr) + /* see if an io base was supplied */ + + if(!(sc->sc_resources.io_base[0] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[0], + 0ul, ~0ul, 1, RF_ACTIVE))) { - printf("isic%d: Error, mem addr 0x%lx specified for Teles S0/16.3!\n", - dev->id_unit, (u_long)dev->id_maddr); - return(0); + printf("isic%d: Could not get iobase for Teles S0/16.3.\n", + unit); + return(ENXIO); } - - dev->id_msize = 0; - - /* check if we got an iobase */ - switch(dev->id_iobase) + /* set io base */ + + sc->sc_port = rman_get_start(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", - dev->id_unit, dev->id_iobase); - return(0); + unit, sc->sc_port); + isic_detach_common(dev); + return(ENXIO); break; } - sc->sc_port = dev->id_iobase; - if(((byte = inb(sc->sc_port)) != 0x51) && (byte != 0x10)) + /* set io port resources */ + + sc->sc_resources.io_rid[1] = 1; + bus_set_resource(dev, SYS_RES_IOPORT, 1, + sc->sc_port-ISAC_OFFS, 0x40); + sc->sc_resources.io_base[1] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[1], + 0ul, ~0ul, 1, RF_ACTIVE); + if(!sc->sc_resources.io_base[1]) { - printf("isic%d: Error, signature 1 0x%x != 0x51 or 0x10 for Teles S0/16.3!\n", - dev->id_unit, byte); - return(0); + 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; } - if((byte = inb(sc->sc_port + 1)) != 0x93) + sc->sc_resources.io_rid[2] = 2; + bus_set_resource(dev, SYS_RES_IOPORT, 2, + sc->sc_port-HSCXA_OFFS, 0x40); + sc->sc_resources.io_base[2] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[2], + 0ul, ~0ul, 1, RF_ACTIVE); + if(!sc->sc_resources.io_base[2]) { - printf("isic%d: Error, signature 2 0x%x != 0x93 for Teles S0/16.3!\n", - dev->id_unit, byte); - return(0); + 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; } - if((byte = inb(sc->sc_port + 2)) != 0x1c) + sc->sc_resources.io_rid[3] = 3; + bus_set_resource(dev, SYS_RES_IOPORT, 3, + sc->sc_port-HSCXB_OFFS, 0x40); + sc->sc_resources.io_base[3] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[3], + 0ul, ~0ul, 1, RF_ACTIVE); + if(!sc->sc_resources.io_base[3]) { - printf("isic%d: Error, signature 3 0x%x != 0x1c for Teles S0/16.3!\n", - dev->id_unit, byte); - return(0); + 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 */ @@ -295,309 +255,118 @@ isic_probe_s0163(struct isa_device *dev) sc->sc_bustyp = BUS_TYPE_IOM2; sc->sc_ipac = 0; - sc->sc_bfifolen = HSCX_FIFO_LEN; - - /* setup ISAC and HSCX base addr */ - - switch(dev->id_iobase) - { - case 0xd80: - ISAC_BASE = (caddr_t) 0x960; - HSCX_A_BASE = (caddr_t) 0x160; - HSCX_B_BASE = (caddr_t) 0x560; - break; - - case 0xe80: - ISAC_BASE = (caddr_t) 0xa60; - HSCX_A_BASE = (caddr_t) 0x260; - HSCX_B_BASE = (caddr_t) 0x660; - break; - - case 0xf80: - ISAC_BASE = (caddr_t) 0xb60; - HSCX_A_BASE = (caddr_t) 0x360; - HSCX_B_BASE = (caddr_t) 0x760; - break; - } - - /* - * 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", - dev->id_unit); - printf("isic%d: HSC0: VSTR: %#x\n", - dev->id_unit, HSCX_READ(0, H_VSTR)); - printf("isic%d: HSC1: VSTR: %#x\n", - dev->id_unit, HSCX_READ(1, H_VSTR)); - return (0); - } - - return (1); -} - -#elif defined(__bsdi__) - -static int -set_softc(struct isic_softc *sc, struct isa_attach_args *ia, int unit) -{ - sc->sc_irq = ia->ia_irq; - - /* check if we got an iobase */ - - switch(ia->ia_iobase) - { - case 0xd80: - case 0xe80: - case 0xf80: - break; - - default: - printf("isic%d: Error, invalid iobase 0x%x specified for Teles S0/16.3!\n", - unit, ia->ia_iobase); - return(0); - break; - } - sc->sc_port = ia->ia_iobase; - - /* 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; - - /* setup ISAC and HSCX base addr */ - - switch(ia->ia_iobase) - { - case 0xd80: - ISAC_BASE = (caddr_t) 0x960; - HSCX_A_BASE = (caddr_t) 0x160; - HSCX_B_BASE = (caddr_t) 0x560; - break; - - case 0xe80: - ISAC_BASE = (caddr_t) 0xa60; - HSCX_A_BASE = (caddr_t) 0x260; - HSCX_B_BASE = (caddr_t) 0x660; - break; - - case 0xf80: - ISAC_BASE = (caddr_t) 0xb60; - HSCX_A_BASE = (caddr_t) 0x360; - HSCX_B_BASE = (caddr_t) 0x760; - break; - } - return 1; -} - -int -isic_probe_s0163(struct device *dev, struct cfdata *cf, - struct isa_attach_args *ia) -{ - u_char byte; - struct isic_softc dummysc, *sc = &dummysc; - - if((intr_no[ffs(ia->ia_irq) - 1]) == 1) - { - printf("isic%d: Error, invalid IRQ [%d] specified for Teles S0/16.3!\n", - cf->cf_unit, ffs(ia->ia_irq)-1); - return(0); - } - - /* check if memory addr specified */ - - if(ia->ia_maddr) - { - printf("isic%d: Error, mem addr 0x%lx specified for Teles S0/16.3!\n", - cf->cf_unit, (u_long)ia->ia_maddr); - return 0; - } + sc->sc_bfifolen = HSCX_FIFO_LEN; - /* Set up a temporary softc for the probe */ + t = rman_get_bustag(sc->sc_resources.io_base[0]); + h = rman_get_bushandle(sc->sc_resources.io_base[0]); - if (set_softc(sc, ia, cf->cf_unit) == 0) - return 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((byte = inb(sc->sc_port)) != 0x51) - { - printf("isic%d: Error, signature 1 0x%x != 0x51 for Teles S0/16.3!\n", - cf->cf_unit, byte); - return(0); + 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((byte = inb(sc->sc_port + 1)) != 0x93) - { + if ( b1 != 0x93 ) { printf("isic%d: Error, signature 2 0x%x != 0x93 for Teles S0/16.3!\n", - cf->cf_unit, byte); - return(0); + unit, b1); + isic_detach_common(dev); + return ENXIO; } - - if((byte = inb(sc->sc_port + 2)) != 0x1c) - { + if ( b2 != 0x1c ) { printf("isic%d: Error, signature 3 0x%x != 0x1c for Teles S0/16.3!\n", - cf->cf_unit, byte); - return(0); + 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", - cf->cf_unit); + unit); printf("isic%d: HSC0: VSTR: %#x\n", - cf->cf_unit, HSCX_READ(0, H_VSTR)); + unit, HSCX_READ(0, H_VSTR)); printf("isic%d: HSC1: VSTR: %#x\n", - cf->cf_unit, HSCX_READ(1, H_VSTR)); - return (0); + unit, HSCX_READ(1, H_VSTR)); + isic_detach_common(dev); + return (ENXIO); } - return (1); -} + /* get our irq */ + if(!(sc->sc_resources.irq = + bus_alloc_resource(dev, SYS_RES_IRQ, + &sc->sc_resources.irq_rid, + 0ul, ~0ul, 1, RF_ACTIVE))) + { + printf("isic%d: Could not get IRQ for Teles S0/16.3.\n",unit); + isic_detach_common(dev); + return ENXIO; + } -#else + /* get the irq number */ + sc->sc_irq = rman_get_start(sc->sc_resources.irq); -int -isic_probe_s0163(struct isic_attach_args *ia) -{ - bus_space_tag_t t = ia->ia_maps[0].t; - bus_space_handle_t h = ia->ia_maps[0].h; - u_int8_t b0, b1, b2; + switch(sc->sc_irq) + { + case 2: + case 9: + case 5: + case 10: + case 12: + case 15: + break; - b0 = bus_space_read_1(t, h, 0); - b1 = bus_space_read_1(t, h, 1); - b2 = bus_space_read_1(t, h, 2); + 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; + } - if (b0 == 0x51 && b1 == 0x93 && b2 == 0x1c) - return 1; + /* register interupt routine */ + bus_setup_intr(dev, sc->sc_resources.irq, + INTR_TYPE_NET, + (void(*)(void *))(isicintr), + sc, &ih); - return 0; + return (0); } -#endif /*---------------------------------------------------------------------------* * isic_attach_s0163 - attach Teles S0/16.3 and compatibles *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ int -isic_attach_s0163(struct isa_device *dev) +isic_attach_s0163(device_t dev) { - u_char irq; - - if((irq = intr_no[ffs(dev->id_irq) - 1]) == 1) - { - printf("isic%d: Attach error, invalid IRQ [%d] specified for Teles S0/16.3!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); - } + 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); - outb(dev->id_iobase + 4, irq); + bus_space_write_1(t, h, 4, intr_no[sc->sc_irq]); DELAY(SEC_DELAY / 10); - outb(dev->id_iobase + 4, irq | 0x01); - - return (1); -} - -#elif defined(__bsdi__) - -extern int -isic_attach_s0163(struct device *parent, struct device *self, struct isa_attach_args *ia) -{ - u_char irq; - struct isic_softc *sc = (struct isic_softc *)self; - int unit = sc->sc_dev.dv_unit; - - /* Commit the probed attachement values */ - - if (set_softc(sc, ia, unit) == 0) - panic("isic_attach_s0163: set_softc"); - - if (((unsigned)sc->sc_unit) >= NISIC) - panic("attach isic%d; NISIC=%d", sc->sc_unit, NISIC); - isic_sc[sc->sc_unit] = sc; - irq = intr_no[ffs(sc->sc_irq) - 1]; - /* configure IRQ */ - - DELAY(SEC_DELAY / 10); - outb(sc->sc_port + 4, irq); - - DELAY(SEC_DELAY / 10); - outb(sc->sc_port + 4, irq | 0x01); - - return 1; -} -#else - -int -isic_attach_s0163(struct isic_softc *sc) -{ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - u_int8_t irq = intr_no[sc->sc_irq]; - - /* configure IRQ */ - - DELAY(SEC_DELAY / 10); - bus_space_write_1(t, h, 4, irq); - - DELAY(SEC_DELAY / 10); - bus_space_write_1(t, h, 4, irq | 0x01); - - /* 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; + bus_space_write_1(t, h, 4, intr_no[sc->sc_irq] | 0x01); - return (1); + return (0); } -#endif #endif /* ISIC > 0 */ diff --git a/sys/i4b/layer1/i4b_tel_s08.c b/sys/i4b/layer1/i4b_tel_s08.c index 7fb53e6..a7c835d 100644 --- a/sys/i4b/layer1/i4b_tel_s08.c +++ b/sys/i4b/layer1/i4b_tel_s08.c @@ -37,55 +37,33 @@ * isic - I4B Siemens ISDN Chipset Driver for Teles S0/8 and clones * ================================================================ * - * $FreeBSD$ + * $Id: i4b_tel_s08.c,v 1.2 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Sun Feb 14 10:28:53 1999] + * $FreeBSD$ * - * -hm clean up - * -hm more cleanup - * -hm NetBSD patches from Martin - * -hm making it finally work (checked with board revision 1.2) - * -hm converting asm -> C + * last edit-date: [Mon Dec 13 22:03:06 1999] * *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) #include "isic.h" #include "opt_i4b.h" -#else -#define NISIC 1 -#endif + #if NISIC > 0 && defined(TEL_S0_8) #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 #include -#else -#include -#endif #include #include #include +#include -#ifdef __FreeBSD__ #include #include -#include -#else -#include -#include -#endif -#include #include -#ifdef __FreeBSD__ #include #include -#else -#include -#include -#endif #include #include @@ -95,35 +73,18 @@ #include #include -#ifndef __FreeBSD__ -static u_int8_t tels08_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs)); -static void tels08_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)); -static void tels08_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size)); -static void tels08_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size)); -#endif +#define TELES_S08_MEMSIZE 0x1000 + +static const bus_size_t offset[] = { 0x100, 0x180, 0x1c0 }; /*---------------------------------------------------------------------------* * Teles S0/8 write register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -tels08_write_reg(u_char *base, u_int i, u_int v) -{ - if(i & 0x01) - i |= 0x200; - base[i] = v; -} - -#else - -static const bus_size_t offset[] = { 0x100, 0x180, 0x1c0 }; - static void -tels08_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) +tels08_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data) { - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; + 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]; @@ -132,28 +93,15 @@ tels08_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data bus_space_write_1(t, h, offs, data); } -#endif /*---------------------------------------------------------------------------* * Teles S0/8 read register routine *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static u_char -tels08_read_reg(u_char *base, u_int i) -{ - if(i & 0x1) - i |= 0x200; - return(base[i]); -} - -#else - static u_int8_t -tels08_read_reg(struct isic_softc *sc, int what, bus_size_t offs) +tels08_read_reg(struct l1_softc *sc, int what, bus_size_t offs) { - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; + 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]; @@ -162,228 +110,209 @@ tels08_read_reg(struct isic_softc *sc, int what, bus_size_t offs) return bus_space_read_1(t, h, offs); } -#endif /*---------------------------------------------------------------------------* - * Teles S0/8 fifo read/write access + * Teles S0/8 fifo write access *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -tels08_memcpyb(void *to, const void *from, size_t len) -{ - for(;len > 0; len--) - *((unsigned char *)to)++ = *((unsigned char *)from)++; -} - -#else - static void -tels08_write_fifo(struct isic_softc *sc, int what, const void *data, size_t size) +tels08_write_fifo(struct l1_softc *sc, int what, void *data, size_t size) { - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; + 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 isic_softc *sc, int what, void *buf, size_t size) +tels08_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size) { - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; + 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); } -#endif /*---------------------------------------------------------------------------* * isic_probe_s08 - probe for Teles S0/8 and compatibles *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - int -isic_probe_s08(struct isa_device *dev) +isic_probe_s08(device_t dev) { - struct isic_softc *sc = &isic_sc[dev->id_unit]; + 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(dev->id_unit >= ISIC_MAXUNIT) + + if(unit >= ISIC_MAXUNIT) { printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Teles S0/8!\n", - dev->id_unit, dev->id_unit); - return(0); - } - sc->sc_unit = dev->id_unit; + unit, unit); + return(ENXIO); + } - /* check IRQ validity */ - - switch(ffs(dev->id_irq)-1) + sc = &l1_sc[unit]; /* get pointer to softc */ + + sc->sc_unit = unit; /* set unit */ + + sc->sc_flags = FLAG_TELES_S0_8; /* set flags */ + + /* see if an io base was supplied */ + + if((sc->sc_resources.io_base[0] = + bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->sc_resources.io_rid[0], + 0ul, ~0ul, 1, RF_ACTIVE))) { - 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", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); - break; - } - sc->sc_irq = dev->id_irq; - - /* check if we got an iobase */ + /* 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(dev->id_iobase > 0) + 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: Error, iobase specified for Teles S0/8!\n", - dev->id_unit); - return(0); + 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(dev->id_maddr) < 0xa0000) || - (kvtop(dev->id_maddr) > 0xdf000) ) + + if((kvtop(sc->sc_vmem_addr) < 0xa0000) || + (kvtop(sc->sc_vmem_addr) > 0xdf000)) { printf("isic%d: Error, mem addr 0x%lx outside 0xA0000-0xDF000 for Teles S0/8!\n", - dev->id_unit, kvtop(dev->id_maddr)); - return(0); + 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); } - - sc->sc_vmem_addr = (caddr_t) dev->id_maddr; - dev->id_msize = 0x1000; /* setup ISAC access routines */ sc->clearirq = NULL; + sc->readreg = tels08_read_reg; sc->writereg = tels08_write_reg; - sc->readfifo = tels08_memcpyb; - sc->writefifo = tels08_memcpyb; - - /* setup card type */ - - sc->sc_cardtyp = CARD_TYPEP_8; + sc->readfifo = tels08_read_fifo; + sc->writefifo = tels08_write_fifo; - /* setup IOM bus type */ + sc->sc_cardtyp = CARD_TYPEP_8; /* setup card type */ - sc->sc_bustyp = BUS_TYPE_IOM1; + sc->sc_bustyp = BUS_TYPE_IOM1; /* setup IOM bus type */ sc->sc_ipac = 0; sc->sc_bfifolen = HSCX_FIFO_LEN; - /* setup ISAC base addr */ + /* setup ISAC base addr, though we don't really need it */ - ISAC_BASE = (caddr_t)((dev->id_maddr) + 0x100); + ISAC_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x100); /* setup HSCX base addr */ - HSCX_A_BASE = (caddr_t)((dev->id_maddr) + 0x180); - HSCX_B_BASE = (caddr_t)((dev->id_maddr) + 0x1c0); - - return (1); -} + HSCX_A_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x180); + HSCX_B_BASE = (caddr_t)((sc->sc_vmem_addr) + 0x1c0); -#else + /* allocate our irq */ -int -isic_probe_s08(struct isic_attach_args *ia) -{ - /* no real sensible probe is easy - write to fifo memory - and read back to verify there is memory doesn't work, - because you talk to tx fifo and rcv fifo. So, just check - HSCX version, which at least fails if no card present - at the given location. */ - bus_space_tag_t t = ia->ia_maps[0].t; - bus_space_handle_t h = ia->ia_maps[0].h; - u_int8_t v1, v2; - - /* HSCX A VSTR */ - v1 = bus_space_read_1(t, h, offset[1] + H_VSTR) & 0x0f; - if (v1 != HSCX_VA1 && v1 != HSCX_VA2 && v1 != HSCX_VA3 && v1 != HSCX_V21) - return 0; - - /* HSCX B VSTR */ - v2 = bus_space_read_1(t, h, offset[2] + H_VSTR) & 0x0f; - if (v2 != HSCX_VA1 && v2 != HSCX_VA2 && v2 != HSCX_VA3 && v2 != HSCX_V21) - return 0; - - /* both HSCX channels should have the same version... */ - if (v1 != v2) - return 0; - - return 1; + if(!(sc->sc_resources.irq = + bus_alloc_resource(dev, SYS_RES_IRQ, + &sc->sc_resources.irq_rid, + 0ul, ~0ul, 1, 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); } -#endif /*---------------------------------------------------------------------------* * isic_attach_s08 - attach Teles S0/8 and compatibles *---------------------------------------------------------------------------*/ int -#ifdef __FreeBSD__ -isic_attach_s08(struct isa_device *dev) -#else -isic_attach_s08(struct isic_softc *sc) -#endif +isic_attach_s08(device_t dev) { -#ifdef __FreeBSD__ - struct isic_softc *sc = &isic_sc[dev->id_unit]; -#else - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; -#endif + 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 */ -#ifdef __FreeBSD__ - sc->sc_vmem_addr[0x80] = 0; -#else bus_space_write_1(t, h, 0x80, 0); -#endif DELAY(SEC_DELAY / 5); /* set card on */ -#ifdef __FreeBSD__ - sc->sc_vmem_addr[0x80] = 1; -#else bus_space_write_1(t, h, 0x80, 1); -#endif DELAY(SEC_DELAY / 5); -#ifndef __FreeBSD__ - - /* 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; - - /* setup card type */ - - sc->sc_cardtyp = CARD_TYPEP_8; - - /* setup IOM bus type */ - - sc->sc_bustyp = BUS_TYPE_IOM1; - - sc->sc_ipac = 0; - sc->sc_bfifolen = HSCX_FIFO_LEN; - -#endif - - return (1); + return 0; } - #endif /* ISIC > 0 */ - diff --git a/sys/i4b/layer1/i4b_tel_s0P.c b/sys/i4b/layer1/i4b_tel_s0P.c deleted file mode 100644 index afbc6a5..0000000 --- a/sys/i4b/layer1/i4b_tel_s0P.c +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (c) 1997 Andrew Gordon. All rights reserved. - * - * Copyright (c) 1997, 1999 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 PnP - * ======================================================= - * - * EXPERIMENTAL !!! - * ================ - * - * $FreeBSD$ - * - * last edit-date: [Tue Mar 16 10:39:14 1999] - * - *---------------------------------------------------------------------------*/ - -#if defined(__FreeBSD__) -#include "isic.h" -#include "opt_i4b.h" -#else -#define NISIC 1 -#endif -#if NISIC > 0 && defined(TEL_S0_16_3_P) - -#include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 -#include -#else -#include -#endif -#include -#include -#include - -#ifdef __FreeBSD__ -#include -#include -#else -#include -#include -#endif - -#include -#include - -#ifdef __FreeBSD__ -#include -#include -#else -#include -#include -#endif - -#include -#include -#include - -#include -#include -#include - -#ifndef __FreeBSD__ -static u_int8_t tels0163P_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs)); -static void tels0163P_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)); -static void tels0163P_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size)); -static void tels0163P_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size)); -void isic_attach_s0163P __P((struct isic_softc *sc)); -#endif - - -/*---------------------------------------------------------------------------* - * Teles S0/16.3 PnP read fifo routine - *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -tels0163P_read_fifo(void *buf, const void *base, size_t len) -{ - insb((int)base + 0x3e, (u_char *)buf, (u_int)len); -} - -#else - -static void -tels0163P_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - bus_space_read_multi_1(t, h, o + 0x3e, buf, size); -} - -#endif - -/*---------------------------------------------------------------------------* - * Teles S0/16.3 PnP write fifo routine - *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -tels0163P_write_fifo(void *base, const void *buf, size_t len) -{ - outsb((int)base + 0x3e, (u_char *)buf, (u_int)len); -} - -#else - -static void -tels0163P_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size) -{ - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - bus_space_write_multi_1(t, h, o + 0x3e, (u_int8_t*)buf, size); -} -#endif - -/*---------------------------------------------------------------------------* - * Teles S0/16.3 PnP write register routine - *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static void -tels0163P_write_reg(u_char *base, u_int offset, u_int v) -{ - outb((int)base + offset, (u_char)v); -} - -#else - -static void -tels0163P_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data) -{ - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - bus_space_write_1(t, h, o + offs, data); -} -#endif - -/*---------------------------------------------------------------------------* - * Teles S0/16.3 PnP read register routine - *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ - -static u_char -tels0163P_read_reg(u_char *base, u_int offset) -{ - return (inb((int)base + offset)); -} - -#else - -static u_int8_t -tels0163P_read_reg(struct isic_softc *sc, int what, bus_size_t offs) -{ - bus_space_tag_t t = sc->sc_maps[what+1].t; - bus_space_handle_t h = sc->sc_maps[what+1].h; - bus_size_t o = sc->sc_maps[what+1].offset; - return bus_space_read_1(t, h, o + offs); -} -#endif - -/*---------------------------------------------------------------------------* - * isic_probe_s0163P - probe for Teles S0/16.3 PnP and compatibles - *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -int -isic_probe_s0163P(struct isa_device *dev, unsigned int iobase2) -{ - struct isic_softc *sc = &isic_sc[dev->id_unit]; - - /* check max unit range */ - - if(dev->id_unit >= ISIC_MAXUNIT) - { - printf("isic%d: Error, unit %d >= ISIC_MAXUNIT for Teles S0/16.3 PnP!\n", - dev->id_unit, dev->id_unit); - return(0); - } - sc->sc_unit = dev->id_unit; - - /* check IRQ validity */ - - switch(ffs(dev->id_irq) - 1) - { - case 3: - case 5: - case 7: - case 10: - case 11: - case 12: - break; - - default: - printf("isic%d: Error, invalid IRQ [%d] specified for Teles S0/16.3 PnP!\n", - dev->id_unit, ffs(dev->id_irq)-1); - return(0); - break; - } - sc->sc_irq = dev->id_irq; - - /* check if memory addr specified */ - - if(dev->id_maddr) - { - printf("isic%d: Error, mem addr 0x%lx specified for Teles S0/16.3 PnP!\n", - dev->id_unit, (u_long)dev->id_maddr); - return(0); - } - dev->id_msize = 0; - - /* check if we got an iobase */ - - switch(dev->id_iobase) - { - case 0x580: - case 0x500: - case 0x680: - break; - - default: - printf("isic%d: Error, invalid iobase 0x%x specified for Teles S0/16.3 PnP!\n", - dev->id_unit, dev->id_iobase); - return(0); - break; - } - sc->sc_port = dev->id_iobase; - - /* setup access routines */ - - sc->clearirq = NULL; - sc->readreg = tels0163P_read_reg; - sc->writereg = tels0163P_write_reg; - - sc->readfifo = tels0163P_read_fifo; - sc->writefifo = tels0163P_write_fifo; - - /* setup card type */ - - sc->sc_cardtyp = CARD_TYPEP_163P; - - /* 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 */ - - switch(dev->id_iobase) - { - case 0x580: - ISAC_BASE = (caddr_t) 0x580 - 0x20; - HSCX_A_BASE = (caddr_t) 0x180 - 0x20; - HSCX_B_BASE = (caddr_t) 0x180; - break; - - case 0x500: - ISAC_BASE = (caddr_t) 0x500 - 0x20; - HSCX_A_BASE = (caddr_t) 0x100 - 0x20; - HSCX_B_BASE = (caddr_t) 0x100; - break; - - case 0x680: - ISAC_BASE = (caddr_t) 0x680 - 0x20; - HSCX_A_BASE = (caddr_t) 0x280 - 0x20; - HSCX_B_BASE = (caddr_t) 0x280; - break; - } - - /* - * Read HSCX A/B VSTR. Expected value for the S0/16.3 PnP card 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 Teles S0/16.3 PnP\n", - dev->id_unit); - printf("isic%d: HSC0: VSTR: %#x\n", - dev->id_unit, HSCX_READ(0, H_VSTR)); - printf("isic%d: HSC1: VSTR: %#x\n", - dev->id_unit, HSCX_READ(1, H_VSTR)); - return (0); - } - - return (1); -} -#endif - -/*---------------------------------------------------------------------------* - * isic_attach_s0163P - attach Teles S0/16.3 PnP and compatibles - *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -int -isic_attach_s0163P(struct isa_device *dev, unsigned int iobase2) -{ - outb((dev->id_iobase) + 0x1c, 0); - DELAY(SEC_DELAY / 10); - outb((dev->id_iobase) + 0x1c, 1); - DELAY(SEC_DELAY / 10); - return(1); -} - -#else - -void -isic_attach_s0163P(struct isic_softc *sc) -{ - /* init card */ - bus_space_tag_t t = sc->sc_maps[0].t; - bus_space_handle_t h = sc->sc_maps[0].h; - bus_space_write_1(t, h, 0x1c, 0); - DELAY(SEC_DELAY / 10); - bus_space_write_1(t, h, 0x1c, 1); - DELAY(SEC_DELAY / 10); - - /* setup access routines */ - - sc->clearirq = NULL; - sc->readreg = tels0163P_read_reg; - sc->writereg = tels0163P_write_reg; - - sc->readfifo = tels0163P_read_fifo; - sc->writefifo = tels0163P_write_fifo; - - /* setup card type */ - - sc->sc_cardtyp = CARD_TYPEP_163P; - - /* setup IOM bus type */ - - sc->sc_bustyp = BUS_TYPE_IOM2; - - sc->sc_ipac = 0; - sc->sc_bfifolen = HSCX_FIFO_LEN; -} -#endif - -#endif /* ISIC > 0 */ - diff --git a/sys/i4b/layer2/i4b_iframe.c b/sys/i4b/layer2/i4b_iframe.c index a043d85..ea7350d7 100644 --- a/sys/i4b/layer2/i4b_iframe.c +++ b/sys/i4b/layer2/i4b_iframe.c @@ -27,9 +27,11 @@ * i4b_iframe.c - i frame handling routines * ------------------------------------------ * - * $FreeBSD$ + * $Id: i4b_iframe.c,v 1.22 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Fri May 28 15:52:41 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:03:16 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ921 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include @@ -236,7 +240,8 @@ i4b_i_frame_queued_up(l2_softc_t *l2sc) if(!(IF_QEMPTY(&l2sc->i_queue))) { DBGL2(L2_I_MSG, "i4b_i_frame_queued_up", ("re-scheduling IFQU call!\n")); -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 + +#if defined(__FreeBSD__) l2sc->IFQU_callout = timeout((TIMEOUT_FUNC_T)i4b_i_frame_queued_up, (void *)l2sc, IFQU_DLY); #else timeout((TIMEOUT_FUNC_T)i4b_i_frame_queued_up, (void *)l2sc, IFQU_DLY); diff --git a/sys/i4b/layer2/i4b_l2.c b/sys/i4b/layer2/i4b_l2.c index cee25ab..3bd9863 100644 --- a/sys/i4b/layer2/i4b_l2.c +++ b/sys/i4b/layer2/i4b_l2.c @@ -27,9 +27,11 @@ * i4b_l2.c - ISDN layer 2 (Q.921) * ------------------------------- * - * $FreeBSD$ + * $Id: i4b_l2.c,v 1.30 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Fri May 28 16:15:39 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:03:23 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ921 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include @@ -284,7 +288,7 @@ i4b_mph_status_ind(int unit, int status, int parm) bzero(&l2sc->stat, sizeof(lapdstat_t)); i4b_l2_unit_init(unit); -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) /* initialize the callout handles for timeout routines */ callout_handle_init(&l2sc->T200_callout); callout_handle_init(&l2sc->T202_callout); @@ -297,7 +301,7 @@ i4b_mph_status_ind(int unit, int status, int parm) break; case STI_PDEACT: /* Timer 4 expired */ - if((l2sc->Q921_state >= ST_AW_EST) && +/*XXX*/ if((l2sc->Q921_state >= ST_AW_EST) && (l2sc->Q921_state <= ST_TIMREC)) { DBGL2(L2_ERROR, "i4b_mph_status_ind", ("unit %d, persistent deactivation!\n", unit)); diff --git a/sys/i4b/layer2/i4b_l2.h b/sys/i4b/layer2/i4b_l2.h index 0b838b0..b00c386 100644 --- a/sys/i4b/layer2/i4b_l2.h +++ b/sys/i4b/layer2/i4b_l2.h @@ -27,9 +27,11 @@ * i4b_l2.h - ISDN layer 2 (Q.921) definitions * --------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_l2.h,v 1.20 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Fri May 28 15:51:17 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:03:29 1999] * *---------------------------------------------------------------------------*/ @@ -61,7 +63,7 @@ typedef struct { void(*T202func)(void *);/* function to be called when T202 expires */ int T203; /* max line idle time */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) struct callout_handle T200_callout; struct callout_handle T202_callout; struct callout_handle T203_callout; diff --git a/sys/i4b/layer2/i4b_l2fsm.c b/sys/i4b/layer2/i4b_l2fsm.c index 051c5b2..333650c 100644 --- a/sys/i4b/layer2/i4b_l2fsm.c +++ b/sys/i4b/layer2/i4b_l2fsm.c @@ -27,9 +27,11 @@ * i4b_l2fsm.c - layer 2 FSM * ------------------------- * - * $FreeBSD$ + * $Id: i4b_l2fsm.c,v 1.17 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Tue Mar 16 16:27:12 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:03:36 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ921 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer2/i4b_l2fsm.h b/sys/i4b/layer2/i4b_l2fsm.h index ae3f6de..56a11ff 100644 --- a/sys/i4b/layer2/i4b_l2fsm.h +++ b/sys/i4b/layer2/i4b_l2fsm.h @@ -27,9 +27,11 @@ * i4b_l2fsm.h - layer 2 FSM * ------------------------- * - * $FreeBSD$ + * $Id: i4b_l2fsm.h,v 1.5 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Sun Feb 14 10:31:43 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:03:48 1999] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/layer2/i4b_l2timer.c b/sys/i4b/layer2/i4b_l2timer.c index 50ace65..468c2a4 100644 --- a/sys/i4b/layer2/i4b_l2timer.c +++ b/sys/i4b/layer2/i4b_l2timer.c @@ -27,9 +27,11 @@ * i4b_l2timer.c - layer 2 timer handling * -------------------------------------- * - * $FreeBSD$ + * $Id: i4b_l2timer.c,v 1.17 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Wed Apr 21 09:17:58 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:03:56 1999] * *---------------------------------------------------------------------------*/ @@ -41,7 +43,8 @@ #if NI4BQ921 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include @@ -91,7 +94,7 @@ i4b_T200_start(l2_softc_t *l2sc) DBGL2(L2_T_MSG, "i4b_T200_start", ("unit %d\n", l2sc->unit)); l2sc->T200 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) l2sc->T200_callout = timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF); #else timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF); @@ -108,7 +111,7 @@ i4b_T200_stop(l2_softc_t *l2sc) CRIT_BEG; if(l2sc->T200 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, l2sc->T200_callout); #else untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc); @@ -129,7 +132,7 @@ i4b_T200_restart(l2_softc_t *l2sc) CRIT_BEG; if(l2sc->T200 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, l2sc->T200_callout); #else untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc); @@ -140,7 +143,7 @@ i4b_T200_restart(l2_softc_t *l2sc) l2sc->T200 = TIMER_ACTIVE; } -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) l2sc->T200_callout = timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF); #else timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF); @@ -176,7 +179,7 @@ i4b_T202_start(l2_softc_t *l2sc) l2sc->N202 = N202DEF; l2sc->T202 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) l2sc->T202_callout = timeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, T202DEF); #else timeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, T202DEF); @@ -193,7 +196,7 @@ i4b_T202_stop(l2_softc_t *l2sc) CRIT_BEG; if(l2sc->T202 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, l2sc->T202_callout); #else untimeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc); @@ -229,7 +232,7 @@ i4b_T203_start(l2_softc_t *l2sc) DBGL2(L2_T_MSG, "i4b_T203_start", ("unit %d\n", l2sc->unit)); l2sc->T203 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) l2sc->T203_callout = timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF); #else timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF); @@ -248,7 +251,7 @@ i4b_T203_stop(l2_softc_t *l2sc) CRIT_BEG; if(l2sc->T203 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, l2sc->T203_callout); #else untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc); @@ -272,7 +275,7 @@ i4b_T203_restart(l2_softc_t *l2sc) if(l2sc->T203 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, l2sc->T203_callout); #else untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc); @@ -283,7 +286,7 @@ i4b_T203_restart(l2_softc_t *l2sc) l2sc->T203 = TIMER_ACTIVE; } -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) l2sc->T203_callout = timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF); #else timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF); diff --git a/sys/i4b/layer2/i4b_lme.c b/sys/i4b/layer2/i4b_lme.c index cdfddee..a3690b9 100644 --- a/sys/i4b/layer2/i4b_lme.c +++ b/sys/i4b/layer2/i4b_lme.c @@ -27,9 +27,11 @@ * i4b_lme.c - layer management entity * ------------------------------------- * - * $FreeBSD$ + * $Id: i4b_lme.c,v 1.11 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Sun Feb 14 10:31:55 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:04:03 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ921 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer2/i4b_mbuf.c b/sys/i4b/layer2/i4b_mbuf.c index 21b12bb..4fb0fb6 100644 --- a/sys/i4b/layer2/i4b_mbuf.c +++ b/sys/i4b/layer2/i4b_mbuf.c @@ -27,20 +27,24 @@ * i4b - mbuf handling support routines * ------------------------------------ * - * $FreeBSD$ + * $Id: i4b_mbuf.c,v 1.13 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Sun Feb 14 10:32:00 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:04:10 1999] * *---------------------------------------------------------------------------*/ #include #include #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer2/i4b_sframe.c b/sys/i4b/layer2/i4b_sframe.c index 309d952..f0c6702 100644 --- a/sys/i4b/layer2/i4b_sframe.c +++ b/sys/i4b/layer2/i4b_sframe.c @@ -27,9 +27,11 @@ * i4b_sframe.c - s frame handling routines * ---------------------------------------- * - * $FreeBSD$ + * $Id: i4b_sframe.c,v 1.12 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Fri May 28 16:14:04 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:04:17 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ921 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer2/i4b_tei.c b/sys/i4b/layer2/i4b_tei.c index 1ca81aa..fd813c8 100644 --- a/sys/i4b/layer2/i4b_tei.c +++ b/sys/i4b/layer2/i4b_tei.c @@ -27,9 +27,11 @@ * i4b_tei.c - tei handling procedures * ----------------------------------- * - * $FreeBSD$ + * $Id: i4b_tei.c,v 1.17 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Fri May 28 16:14:14 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:04:24 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ921 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include @@ -61,7 +65,7 @@ #include #endif -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 +#if defined(__FreeBSD__) #include #endif @@ -289,7 +293,7 @@ void i4b_make_rand_ri(l2_softc_t *l2sc) { -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 +#if defined(__FreeBSD__) u_short val; read_random((char *)&val, sizeof(val)); diff --git a/sys/i4b/layer2/i4b_uframe.c b/sys/i4b/layer2/i4b_uframe.c index 127bb30..7de4965 100644 --- a/sys/i4b/layer2/i4b_uframe.c +++ b/sys/i4b/layer2/i4b_uframe.c @@ -27,9 +27,11 @@ * i4b_uframe.c - routines for handling U-frames * ----------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_uframe.c,v 1.10 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Fri May 28 16:14:32 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:04:30 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ921 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer2/i4b_util.c b/sys/i4b/layer2/i4b_util.c index 3266667..4356a8c 100644 --- a/sys/i4b/layer2/i4b_util.c +++ b/sys/i4b/layer2/i4b_util.c @@ -27,9 +27,11 @@ * i4b_util.c - layer 2 utility routines * ------------------------------------- * - * $FreeBSD$ + * $Id: i4b_util.c,v 1.22 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Thu Apr 15 10:47:52 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:04:37 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ921 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer3/i4b_l2if.c b/sys/i4b/layer3/i4b_l2if.c index f5e3d32..dfebbca 100644 --- a/sys/i4b/layer3/i4b_l2if.c +++ b/sys/i4b/layer3/i4b_l2if.c @@ -27,9 +27,11 @@ * i4b_l2if.c - Layer 3 interface to Layer 2 * ------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_l2if.c,v 1.18 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Tue May 25 11:55:15 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:04:48 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ931 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer3/i4b_l3.h b/sys/i4b/layer3/i4b_l3.h index 32e6d80..3badbd8 100644 --- a/sys/i4b/layer3/i4b_l3.h +++ b/sys/i4b/layer3/i4b_l3.h @@ -27,9 +27,11 @@ * i4b_l3.h - layer 3 header file * ------------------------------ * - * $FreeBSD$ + * $Id: i4b_l3.h,v 1.10 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Sun Feb 14 10:33:19 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:04:55 1999] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/layer3/i4b_l3fsm.c b/sys/i4b/layer3/i4b_l3fsm.c index 6bc0e67..92de1ad 100644 --- a/sys/i4b/layer3/i4b_l3fsm.c +++ b/sys/i4b/layer3/i4b_l3fsm.c @@ -27,9 +27,11 @@ * i4b_l3fsm.c - layer 3 FSM * ------------------------- * - * $FreeBSD$ + * $Id: i4b_l3fsm.c,v 1.18 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Wed Apr 21 09:42:26 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:05:02 1999] * *---------------------------------------------------------------------------*/ @@ -39,12 +41,15 @@ #define NI4BQ931 1 #endif #if NI4BQ931 > 0 + #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer3/i4b_l3fsm.h b/sys/i4b/layer3/i4b_l3fsm.h index 3b46875..1980ae0 100644 --- a/sys/i4b/layer3/i4b_l3fsm.h +++ b/sys/i4b/layer3/i4b_l3fsm.h @@ -27,9 +27,11 @@ * i4b_l3fsm.c - layer 3 FSM * ------------------------- * - * $FreeBSD$ + * $Id: i4b_l3fsm.h,v 1.7 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Sun Feb 14 10:33:31 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:05:09 1999] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/layer3/i4b_l3timer.c b/sys/i4b/layer3/i4b_l3timer.c index 70c916d..495d9f6 100644 --- a/sys/i4b/layer3/i4b_l3timer.c +++ b/sys/i4b/layer3/i4b_l3timer.c @@ -27,9 +27,11 @@ * i4b_l3timer.c - timer and timeout handling for layer 3 * ------------------------------------------------------ * - * $FreeBSD$ + * $Id: i4b_l3timer.c,v 1.14 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Wed Apr 21 09:46:59 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:05:18 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ931 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include @@ -107,7 +111,7 @@ T303_start(call_desc_t *cd) DBGL3(L3_T_MSG, "T303_start", ("cr = %d\n", cd->cr)); cd->T303 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) cd->T303_callout = timeout((TIMEOUT_FUNC_T)T303_timeout, (void *)cd, T303VAL); #else timeout((TIMEOUT_FUNC_T)T303_timeout, (void *)cd, T303VAL); @@ -125,7 +129,7 @@ T303_stop(call_desc_t *cd) if(cd->T303 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)T303_timeout, (void *)cd, cd->T303_callout); #else untimeout((TIMEOUT_FUNC_T)T303_timeout, (void *)cd); @@ -158,7 +162,7 @@ T305_start(call_desc_t *cd) DBGL3(L3_T_MSG, "T305_start", ("cr = %d\n", cd->cr)); cd->T305 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) cd->T305_callout = timeout((TIMEOUT_FUNC_T)T305_timeout, (void *)cd, T305VAL); #else timeout((TIMEOUT_FUNC_T)T305_timeout, (void *)cd, T305VAL); @@ -176,7 +180,7 @@ T305_stop(call_desc_t *cd) if(cd->T305 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)T305_timeout, (void *)cd, cd->T305_callout); #else untimeout((TIMEOUT_FUNC_T)T305_timeout, (void *)cd); @@ -210,7 +214,7 @@ T308_start(call_desc_t *cd) DBGL3(L3_T_MSG, "T308_start", ("cr = %d\n", cd->cr)); cd->T308 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) cd->T308_callout = timeout((TIMEOUT_FUNC_T)T308_timeout, (void *)cd, T308VAL); #else timeout((TIMEOUT_FUNC_T)T308_timeout, (void *)cd, T308VAL); @@ -228,7 +232,7 @@ T308_stop(call_desc_t *cd) if(cd->T308 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)T308_timeout, (void *)cd, cd->T308_callout); #else untimeout((TIMEOUT_FUNC_T)T308_timeout, (void *)cd); @@ -262,7 +266,7 @@ T309_start(call_desc_t *cd) DBGL3(L3_T_MSG, "T309_start", ("cr = %d\n", cd->cr)); cd->T309 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) cd->T309_callout = timeout((TIMEOUT_FUNC_T)T309_timeout, (void *)cd, T309VAL); #else timeout((TIMEOUT_FUNC_T)T309_timeout, (void *)cd, T309VAL); @@ -280,7 +284,7 @@ T309_stop(call_desc_t *cd) if(cd->T309 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)T309_timeout, (void *)cd, cd->T309_callout); #else untimeout((TIMEOUT_FUNC_T)T309_timeout, (void *)cd); @@ -314,7 +318,7 @@ T310_start(call_desc_t *cd) DBGL3(L3_T_MSG, "T310_start", ("cr = %d\n", cd->cr)); cd->T310 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) cd->T310_callout = timeout((TIMEOUT_FUNC_T)T310_timeout, (void *)cd, T310VAL); #else timeout((TIMEOUT_FUNC_T)T310_timeout, (void *)cd, T310VAL); @@ -332,7 +336,7 @@ T310_stop(call_desc_t *cd) if(cd->T310 != TIMER_IDLE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)T310_timeout, (void *)cd, cd->T310_callout); #else untimeout((TIMEOUT_FUNC_T)T310_timeout, (void *)cd); @@ -366,7 +370,7 @@ T313_start(call_desc_t *cd) DBGL3(L3_T_MSG, "T313_start", ("cr = %d\n", cd->cr)); cd->T313 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) cd->T313_callout = timeout((TIMEOUT_FUNC_T)T313_timeout, (void *)cd, T313VAL); #else timeout((TIMEOUT_FUNC_T)T313_timeout, (void *)cd, T313VAL); @@ -385,7 +389,7 @@ T313_stop(call_desc_t *cd) if(cd->T313 != TIMER_IDLE) { cd->T313 = TIMER_IDLE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)T313_timeout, (void *)cd, cd->T313_callout); #else untimeout((TIMEOUT_FUNC_T)T313_timeout, (void *)cd); diff --git a/sys/i4b/layer3/i4b_l4if.c b/sys/i4b/layer3/i4b_l4if.c index fa6ea16..da11b63 100644 --- a/sys/i4b/layer3/i4b_l4if.c +++ b/sys/i4b/layer3/i4b_l4if.c @@ -27,9 +27,11 @@ * i4b_l4if.c - Layer 3 interface to Layer 4 * ------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_l4if.c,v 1.22 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Tue Apr 27 16:46:51 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:05:25 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ931 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include @@ -160,6 +164,7 @@ i4b_mdl_status_ind(int unit, int status, int parm) 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++; } @@ -171,7 +176,10 @@ i4b_mdl_status_ind(int unit, int status, int parm) 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 */ diff --git a/sys/i4b/layer3/i4b_q931.c b/sys/i4b/layer3/i4b_q931.c index cc6d904..e2fa689 100644 --- a/sys/i4b/layer3/i4b_q931.c +++ b/sys/i4b/layer3/i4b_q931.c @@ -27,9 +27,11 @@ * i4b_q931.c - Q931 received messages handling * -------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_q931.c,v 1.23 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Tue Apr 27 12:04:35 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:05:33 1999] * *---------------------------------------------------------------------------*/ @@ -42,11 +44,13 @@ #if NI4BQ931 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer3/i4b_q931.h b/sys/i4b/layer3/i4b_q931.h index 376d5ff..bbfc9b6 100644 --- a/sys/i4b/layer3/i4b_q931.h +++ b/sys/i4b/layer3/i4b_q931.h @@ -27,9 +27,11 @@ * i4b_q931.h - Q931 handling header file * -------------------------------------- * - * $FreeBSD$ + * $Id: i4b_q931.h,v 1.8 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Sun Feb 14 10:33:56 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:05:44 1999] * *---------------------------------------------------------------------------*/ @@ -114,3 +116,5 @@ #define MSG_ALERT_LEN 4 /* length of a alert message */ #endif /* _I4B_Q931_H_ */ + +/* EOF */ diff --git a/sys/i4b/layer3/i4b_q932fac.c b/sys/i4b/layer3/i4b_q932fac.c index e180b9d..1162144 100644 --- a/sys/i4b/layer3/i4b_q932fac.c +++ b/sys/i4b/layer3/i4b_q932fac.c @@ -27,9 +27,11 @@ * i4b_q932fac.c - Q932 facility handling * -------------------------------------- * - * $FreeBSD$ + * $Id: i4b_q932fac.c,v 1.8 1999/12/13 21:25:27 hm Exp $ * - * last edit-date: [Sun Feb 14 10:34:02 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:05:51 1999] * *---------------------------------------------------------------------------*/ @@ -41,11 +43,13 @@ #if NI4BQ931 > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include diff --git a/sys/i4b/layer3/i4b_q932fac.h b/sys/i4b/layer3/i4b_q932fac.h index 4e745ea..d878c2e 100644 --- a/sys/i4b/layer3/i4b_q932fac.h +++ b/sys/i4b/layer3/i4b_q932fac.h @@ -27,9 +27,11 @@ * i4b_q932fac.h - Q932 facility handling header file * -------------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_q932fac.h,v 1.7 1999/12/13 21:25:28 hm Exp $ * - * last edit-date: [Sun Feb 14 10:34:08 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:06:00 1999] * *--------------------------------------------------------------------------- * diff --git a/sys/i4b/layer4/i4b_i4bdrv.c b/sys/i4b/layer4/i4b_i4bdrv.c index f45897b..1a07b95 100644 --- a/sys/i4b/layer4/i4b_i4bdrv.c +++ b/sys/i4b/layer4/i4b_i4bdrv.c @@ -27,9 +27,11 @@ * i4b_i4bdrv.c - i4b userland interface driver * -------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_i4bdrv.c,v 1.52 1999/12/13 21:25:28 hm Exp $ * - * last edit-date: [Tue Jun 8 19:48:16 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:06:11 1999] * *---------------------------------------------------------------------------*/ @@ -51,7 +53,7 @@ #include -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) #include #include #include @@ -70,6 +72,18 @@ #include #ifdef __FreeBSD__ + +#if defined(__FreeBSD__) && __FreeBSD__ == 3 +#include "opt_devfs.h" +#endif + +#ifdef DEVFS +#include +#endif + +#endif /* __FreeBSD__*/ + +#ifdef __FreeBSD__ #include #include #include @@ -96,6 +110,12 @@ static int openflag = 0; static int selflag = 0; static int readflag = 0; +#if defined(__FreeBSD__) && __FreeBSD__ == 3 +#ifdef DEVFS +static void *devfs_token; +#endif +#endif + #ifndef __FreeBSD__ #define PDEVSTATIC /* - not static - */ @@ -137,22 +157,22 @@ PDEVSTATIC d_select_t i4bselect; #define CDEV_MAJOR 60 -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 static struct cdevsw i4b_cdevsw = { - /* open */ i4bopen, - /* close */ i4bclose, - /* read */ i4bread, - /* write */ nowrite, - /* ioctl */ i4bioctl, - /* poll */ POLLFIELD, - /* mmap */ nommap, - /* strategy */ nostrategy, - /* name */ "i4b", - /* maj */ CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ 0, - /* bmaj */ -1 + /* open */ i4bopen, + /* close */ i4bclose, + /* read */ i4bread, + /* write */ nowrite, + /* ioctl */ i4bioctl, + /* poll */ POLLFIELD, + /* mmap */ nommap, + /* strategy */ nostrategy, + /* name */ "i4b", + /* maj */ CDEV_MAJOR, + /* dump */ nodump, + /* psize */ nopsize, + /* flags */ 0, + /* bmaj */ -1 }; #else static struct cdevsw i4b_cdevsw = { @@ -168,7 +188,7 @@ PSEUDO_SET(i4battach, i4b_i4bdrv); static void i4b_drvinit(void *unused) { -#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006 +#if defined(__FreeBSD__) && __FreeBSD__ >= 4 cdevsw_add(&i4b_cdevsw); #else static int i4b_devsw_installed = 0; @@ -231,7 +251,20 @@ i4battach() printf("i4b: ISDN call control device attached\n"); #endif i4b_rdqueue.ifq_maxlen = IFQ_MAXLEN; + +#if defined(__FreeBSD__) +#if __FreeBSD__ == 3 + +#ifdef DEVFS + devfs_token = devfs_add_devswf(&i4b_cdevsw, 0, DV_CHR, + UID_ROOT, GID_WHEEL, 0600, + "i4b"); +#endif + +#else make_dev(&i4b_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "i4b"); +#endif +#endif } /*---------------------------------------------------------------------------* @@ -332,7 +365,7 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case I4B_CDID_REQ: { - msg_cdid_req_t *mir; + msg_cdid_req_t *mir; mir = (msg_cdid_req_t *)data; cd = reserve_cd(); mir->cdid = cd->cdid; @@ -353,6 +386,16 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) 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->driver = mcr->driver; @@ -683,6 +726,19 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) 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 */ diff --git a/sys/i4b/layer4/i4b_l4.c b/sys/i4b/layer4/i4b_l4.c index 60cf4dc..920772c 100644 --- a/sys/i4b/layer4/i4b_l4.c +++ b/sys/i4b/layer4/i4b_l4.c @@ -27,9 +27,11 @@ * i4b_l4.c - kernel interface to userland * ----------------------------------------- * - * $FreeBSD$ + * $Id: i4b_l4.c,v 1.45 1999/12/13 21:25:28 hm Exp $ * - * last edit-date: [Thu Apr 8 17:31:52 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:06:17 1999] * *---------------------------------------------------------------------------*/ @@ -47,7 +49,7 @@ #if NI4B > 0 #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 +#if defined(__FreeBSD__) #include #else #include @@ -77,6 +79,10 @@ #include #include +#if !defined(__FreeBSD__) && !defined(__NetBSD__) +#define memcpy(dst, src, len) bcopy((src), (dst), (len)) +#endif + unsigned int i4b_l4_debug = L4_DEBUG_DEFAULT; struct ctrl_type_desc ctrl_types[CTRL_NUMTYPES] = { { NULL, NULL} }; @@ -109,7 +115,7 @@ i4b_l4_pdeact(int controller, int numactive) if(cd->timeout_active) { -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, cd->idle_timeout_handle); #else untimeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd); @@ -554,6 +560,31 @@ i4b_l4_proceeding_ind(call_desc_t *cd) } /*---------------------------------------------------------------------------* + * 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 0 #include -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include @@ -50,11 +54,12 @@ #include #ifdef __FreeBSD__ -#include -#include -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 #include #endif + +#ifdef __FreeBSD__ +#include +#include #else #include #include @@ -74,7 +79,7 @@ static unsigned int get_cdid(void); int nctrl; /* number of attached controllers */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) void init_callout(call_desc_t *); #endif @@ -157,7 +162,7 @@ reserve_cd(void) if(cd == NULL) panic("reserve_cd: no free call descriptor available!"); -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) init_callout(cd); #endif @@ -212,7 +217,7 @@ cd_by_cdid(unsigned int cdid) { DBGL4(L4_MSG, "cd_by_cdid", ("found cdid - index=%d cdid=%u cr=%d\n", i, call_desc[i].cdid, call_desc[i].cr)); -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) init_callout(&call_desc[i]); #endif return(&(call_desc[i])); @@ -243,7 +248,7 @@ cd_by_unitcr(int unit, int cr, int crf) { DBGL4(L4_MSG, "cd_by_unitcr", ("found cd, index=%d cdid=%u cr=%d\n", i, call_desc[i].cdid, call_desc[i].cr)); -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) init_callout(&call_desc[i]); #endif return(&(call_desc[i])); @@ -268,7 +273,7 @@ get_rand_cr(int unit) { int found = 1; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) read_random((char *)&val, sizeof(val)); #else val |= unit+i; @@ -300,9 +305,9 @@ get_rand_cr(int unit) } /*---------------------------------------------------------------------------* - * initialize the callout handles for FreeBSD-current 3.0 + * initialize the callout handles for FreeBSD *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) void init_callout(call_desc_t *cd) { diff --git a/sys/i4b/layer4/i4b_l4timer.c b/sys/i4b/layer4/i4b_l4timer.c index fefb25d..21855e2 100644 --- a/sys/i4b/layer4/i4b_l4timer.c +++ b/sys/i4b/layer4/i4b_l4timer.c @@ -27,9 +27,11 @@ * i4b_l4timer.c - timer and timeout handling for layer 4 * -------------------------------------------------------- * - * $FreeBSD$ + * $Id: i4b_l4timer.c,v 1.15 1999/12/13 21:25:28 hm Exp $ * - * last edit-date: [Wed Apr 21 09:49:08 1999] + * $FreeBSD$ + * + * last edit-date: [Mon Dec 13 22:06:39 1999] * *---------------------------------------------------------------------------*/ @@ -38,11 +40,13 @@ #if NI4B > 0 #include -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 + +#if defined(__FreeBSD__) #include #else #include #endif + #include #include #include @@ -84,7 +88,7 @@ T400_start(call_desc_t *cd) DBGL4(L4_MSG, "T400_start", ("cr = %d\n", cd->cr)); cd->T400 = TIMER_ACTIVE; -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) cd->T400_callout = timeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd, T400DEF); #else timeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd, T400DEF); @@ -102,7 +106,7 @@ T400_stop(call_desc_t *cd) if(cd->T400 == TIMER_ACTIVE) { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 +#if defined(__FreeBSD__) untimeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd, cd->T400_callout); #else untimeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd); -- cgit v1.1