Update the ihfc driver with a patch from the author. He writes: This patch
enables the driver to work on current (I have not tested the isa part fully, but I suppose it should work). The patching from jlemon caused a crash at probe time. This is probably my fault not having added a comment for "RESET_SOFT" saying: "this resets all!". Submitted by: Hans Petter Selasky <hselasky@c2i.net>
This commit is contained in:
parent
5ed4160254
commit
2fd9d69993
@ -31,12 +31,7 @@
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
* last edit-date: [Thu Oct 26 08:29:06 2000]
|
||||
*
|
||||
* NOTE:
|
||||
* - October 19th: made minor changes to HDLC_ENCODE macro
|
||||
* Please conform "ihfc/i4b_ihfc_drv.c" (ihfc_hdlc_Bwrite)
|
||||
* for correct usage! (-hp)
|
||||
* last edit-date: [Wed Jul 19 09:41:13 2000]
|
||||
*
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -95,7 +90,7 @@ const u_short HDLC_FCS_TAB[256] = { 0x0000,
|
||||
*
|
||||
* bits[4..7]: Special bytes like 0x7e, 0x7d, 0xfd ... are flagged here
|
||||
* NOTE: Special bytes also means 'abort' bytes (7 or more
|
||||
* continious set bits)
|
||||
* continuous set bits)
|
||||
*
|
||||
* bits[8..11]: A copy of bits[0..3] but only incremented by one.
|
||||
* NOTE: 0x7e has value '8' instead of '0'. Internal reasons.
|
||||
@ -149,7 +144,7 @@ const u_short HDLC_BIT_TAB[256] = { 0x0100,
|
||||
*
|
||||
* next: 'continue' or 'goto xxx'
|
||||
*
|
||||
* cfr: complet frame
|
||||
* cfr: complete frame
|
||||
* nfr: new frame
|
||||
* NOTE: must setup 'len' and 'dst', so that 'dst' may be written
|
||||
* at most 'len' times.
|
||||
@ -165,7 +160,7 @@ const u_short HDLC_BIT_TAB[256] = { 0x0100,
|
||||
* NOTE: these variables have to be 'suspended' / 'resumed' somehow:
|
||||
* flag, blevel, crc, ib, tmp, len
|
||||
* NOTE: zero is default value for all variables.
|
||||
* NOTE: each time 'dst' is written, 'len' is decremented by one.
|
||||
* NOTE: each time 'dst' is written, 'len' is decreased by one.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define HDLC_DECODE(dst, len, tmp, tmp2, blevel, ib, crc, flag, rddcmd, nfrcmd, \
|
||||
@ -280,20 +275,21 @@ const u_short HDLC_BIT_TAB[256] = { 0x0100,
|
||||
* u_short: tmp2, blevel, ib, crc, len
|
||||
* u_int: tmp
|
||||
*
|
||||
* gfr: get new frame, free old, and exit if no frame
|
||||
* NOTE: must setup 'len' and 'src', so that 'src' can be read
|
||||
* 'len' times.
|
||||
* gfr: This is the place where you free the last [mbuf] chain, and get
|
||||
* the next one. If a mbuf is available the code should setup 'len'
|
||||
* and 'src' so that 'src' may be read 'len' times. If no mbuf is
|
||||
* available leave 'len' and 'src' untouched.
|
||||
*
|
||||
* wrd: write data (output = (u_char)tmp)
|
||||
*
|
||||
* d: dummy
|
||||
*
|
||||
* NOTE: setting flag to '-1' and len to '0' => abort byte will be sent
|
||||
* NOTE: setting flag to '-2' and len to '0' => abort bytes will be sent
|
||||
* NOTE: these variables have to be 'suspended' / 'resumed' somehow:
|
||||
* flag, blevel, crc, ib, tmp, len
|
||||
* NOTE: zero is default value for all variables.
|
||||
* NOTE: each time 'src' is read, 'len' is decremented by one.
|
||||
* NOTE: gfr must setup 'len'.
|
||||
* NOTE: each time 'src' is read, 'len' is decreased by one.
|
||||
* NOTE: neither cmd's should exit through 'goto' or 'break' statements.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define HDLC_ENCODE(src, len, tmp, tmp2, blevel, ib, crc, flag, gfrcmd, wrdcmd, d) \
|
||||
@ -305,7 +301,7 @@ const u_short HDLC_BIT_TAB[256] = { 0x0100,
|
||||
len++; \
|
||||
\
|
||||
switch(++flag) \
|
||||
{ case 0: /* abort */ \
|
||||
{ default: /* abort */ \
|
||||
tmp = blevel = 0; /* zero is default */ \
|
||||
tmp2 = 0xff; \
|
||||
goto j3##d; \
|
||||
@ -313,8 +309,8 @@ const u_short HDLC_BIT_TAB[256] = { 0x0100,
|
||||
case 2: /* 2nd time FS */ \
|
||||
tmp2 = 0x7e; \
|
||||
goto j3##d; \
|
||||
case 3: /* get new frame */ \
|
||||
gfrcmd; \
|
||||
case 3: \
|
||||
gfrcmd; /* get new frame */ \
|
||||
if (!len--) \
|
||||
{ \
|
||||
len++; \
|
||||
@ -328,15 +324,14 @@ const u_short HDLC_BIT_TAB[256] = { 0x0100,
|
||||
ib = 0; \
|
||||
goto j1##d; /* first byte */ \
|
||||
} \
|
||||
case 4: /* CRC (lsb's) */ \
|
||||
crc ^= -1; \
|
||||
tmp2 = (u_char)crc; \
|
||||
crc >>= 8; \
|
||||
goto j2##d; \
|
||||
case 5: /* CRC (msb's) */ \
|
||||
tmp2 = (u_char)crc; \
|
||||
case 4: \
|
||||
crc ^= -1; \
|
||||
tmp2 = (u_char)crc; \
|
||||
goto j2##d; /* CRC (lsb's) */ \
|
||||
case 5: \
|
||||
tmp2 = (u_char)(crc >> 8); \
|
||||
flag = 1; \
|
||||
goto j2##d; /* CRC stuff */ \
|
||||
goto j2##d; /* CRC (msb's) */ \
|
||||
} \
|
||||
} \
|
||||
else \
|
||||
@ -395,3 +390,4 @@ const u_short HDLC_BIT_TAB[256] = { 0x0100,
|
||||
|
||||
|
||||
#endif /* _I4B_HDLC_H_ */
|
||||
|
||||
|
@ -323,6 +323,9 @@ ihfc_control(ihfc_sc_t *sc, int flag)
|
||||
|
||||
S_SQXR |= 0x40; /* power down */
|
||||
|
||||
S_INT_M2 &= ~0x01;
|
||||
S_MASK |= 0x02;
|
||||
|
||||
S_SPCR &= ~0x0f; /* send 1's only */
|
||||
S_SCTRL &= ~0x83; /* send 1's only + enable oscillator */
|
||||
|
||||
@ -351,14 +354,14 @@ ihfc_init (ihfc_sc_t *sc, u_char chan, int prot, int activate)
|
||||
do
|
||||
{ if (chan < 2) /* D-Channel */
|
||||
{
|
||||
S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
|
||||
mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
|
||||
|
||||
i4b_Dfreembuf(S_MBUF);
|
||||
i4b_Dcleanifq(&S_IFQUEUE);
|
||||
if (!IF_QEMPTY(&S_IFQUEUE)) i4b_Dcleanifq(&S_IFQUEUE);
|
||||
|
||||
RESET_SOFT_CHAN(sc, chan);
|
||||
|
||||
S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
|
||||
mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
|
||||
|
||||
if (!activate) continue;
|
||||
|
||||
if (S_HFC & HFC_1)
|
||||
@ -374,14 +377,14 @@ ihfc_init (ihfc_sc_t *sc, u_char chan, int prot, int activate)
|
||||
}
|
||||
else /* B-Channel */
|
||||
{
|
||||
S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
|
||||
mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
|
||||
|
||||
i4b_Bfreembuf(S_MBUF);
|
||||
i4b_Bcleanifq(&S_IFQUEUE);
|
||||
if (!IF_QEMPTY(&S_IFQUEUE)) i4b_Bcleanifq(&S_IFQUEUE);
|
||||
|
||||
RESET_SOFT_CHAN(sc, chan);
|
||||
|
||||
S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
|
||||
mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
|
||||
|
||||
S_PROT = prot;
|
||||
|
||||
if (!activate) continue;
|
||||
@ -711,6 +714,10 @@ ihfc_intr1 (ihfc_sc_t *sc)
|
||||
{
|
||||
if (chan == 1) break;
|
||||
if (S_FILTER) S_FILTER(sc, chan);
|
||||
|
||||
HFC_END;
|
||||
DELAY(10);
|
||||
HFC_BEG;
|
||||
}
|
||||
}
|
||||
|
||||
@ -766,6 +773,10 @@ ihfc_intr2 (ihfc_sc_t *sc)
|
||||
{
|
||||
if (chan == 1) continue;
|
||||
if (S_FILTER) S_FILTER(sc, chan);
|
||||
|
||||
HFC_END;
|
||||
DELAY(10);
|
||||
HFC_BEG;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1408,7 +1419,7 @@ ihfc_hdlc_Bwrite (ihfc_sc_t *sc, u_char chan)
|
||||
{
|
||||
/* XDU */
|
||||
|
||||
flag = -1;
|
||||
flag = -2;
|
||||
len = 0;
|
||||
|
||||
NDBGL1(L1_S_ERR, "XDU (unit=%d)", S_UNIT);
|
||||
@ -1588,7 +1599,7 @@ ihfc_test_Bwrite (ihfc_sc_t *sc, u_char chan)
|
||||
|
||||
j0:
|
||||
|
||||
sendlen = (u_short)ihfc_Bsel_fifo(sc, chan, 0);
|
||||
sendlen = /* (u_short)ihfc_Bsel_fifo(sc, chan, 0); */ 0;
|
||||
|
||||
if (sendlen == 0x5ff) printf("(send empty)");
|
||||
|
||||
@ -1649,7 +1660,7 @@ ihfc_test_Bread (ihfc_sc_t *sc, u_char chan)
|
||||
|
||||
if (S_UNIT != 0) return;
|
||||
|
||||
reclen = (u_short)ihfc_Bsel_fifo(sc, chan, 0);
|
||||
reclen = /* (u_short)ihfc_Bsel_fifo(sc, chan, 0); */ 0;
|
||||
|
||||
S_BYTES += reclen;
|
||||
|
||||
|
@ -136,7 +136,10 @@ ihfc_ph_data_req(int unit, struct mbuf *m, int freeflag)
|
||||
else
|
||||
{
|
||||
NDBGL1(L1_ERROR, "No frame out (unit = %d)", unit);
|
||||
i4b_Dfreembuf(m);
|
||||
if (m) i4b_Dfreembuf(m);
|
||||
|
||||
HFC_END;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (S_INTR_ACTIVE) S_INT_S1 |= 0x04;
|
||||
|
@ -28,7 +28,7 @@
|
||||
* -------------------------------------------------
|
||||
*
|
||||
* - Everything which has got anything to to with "PnP" bus setup has
|
||||
* been put here.
|
||||
* been put here, except the chip spesific "PnP" setup.
|
||||
*
|
||||
*
|
||||
* last edit-date: [Wed Jul 19 09:41:07 2000]
|
||||
@ -91,9 +91,9 @@ const struct ihfc_pnp_ids
|
||||
}
|
||||
ihfc_pnp_ids[] =
|
||||
{
|
||||
{ 0x10262750, FLAG_TELES_S0_163C, HFC_S , 2, 0x200 , 0xd},
|
||||
{ 0x20262750, FLAG_TELES_S0_163C, HFC_SP, 0, 0x000 , 0xf},
|
||||
{ 0x1411d805, FLAG_ACER_P10 , HFC_S , 1, 0x300 , 0xe},
|
||||
{ 0x10262750, FLAG_TELES_S0_163C, HFC_S , 2, 0x200 , 0x2d},
|
||||
{ 0x20262750, FLAG_TELES_S0_163C, HFC_SP, 0, 0x000 , 0x0f},
|
||||
{ 0x1411d805, FLAG_ACER_P10 , HFC_S , 1, 0x300 , 0x0e},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -149,6 +149,8 @@ ihfc_pnp_probe(device_t dev)
|
||||
u_int32_t vid = isa_get_vendorid(dev); /* vendor id */
|
||||
ihfc_id_t *ids = &ihfc_pnp_ids[0]; /* ids ptr */
|
||||
ihfc_sc_t *sc = &ihfc_softc[unit]; /* softc */
|
||||
u_char flag = 0; /* flag */
|
||||
void *dummy = 0; /* a dummy */
|
||||
|
||||
HFC_VAR;
|
||||
|
||||
@ -161,12 +163,18 @@ ihfc_pnp_probe(device_t dev)
|
||||
if (!vid) return ihfc_isa_probe(dev);
|
||||
|
||||
HFC_BEG;
|
||||
|
||||
|
||||
for ( ;(ids->vid); ids++)
|
||||
{
|
||||
if (ids->vid == vid)
|
||||
{
|
||||
bzero(sc, sizeof(ihfc_sc_t)); /* reset data structure */
|
||||
flag = 0;
|
||||
|
||||
bzero(sc, sizeof(ihfc_sc_t)); /* reset data structure.*
|
||||
* Zero is default for *
|
||||
* most, so calling the *
|
||||
* int. handler now will*
|
||||
* not be a problem. */
|
||||
|
||||
S_IOBASE[0] = bus_alloc_resource(
|
||||
dev, SYS_RES_IOPORT, &S_IORID[0],
|
||||
@ -201,6 +209,14 @@ ihfc_pnp_probe(device_t dev)
|
||||
S_IIRQ = IIRQ3[rman_get_start(S_IRQ) & 0xf];
|
||||
}
|
||||
|
||||
/* setup interrupt routine now to avvoid stray *
|
||||
* interrupts. */
|
||||
|
||||
bus_setup_intr(dev, S_IRQ, INTR_TYPE_NET, (void(*)(void*))
|
||||
HFC_INTR, sc, &dummy);
|
||||
|
||||
flag = 1;
|
||||
|
||||
if (!HFC_CONTROL(sc, 1))
|
||||
{
|
||||
HFC_END;
|
||||
@ -214,7 +230,7 @@ ihfc_pnp_probe(device_t dev)
|
||||
}
|
||||
}
|
||||
|
||||
ihfc_pnp_detach(dev, 0);
|
||||
ihfc_pnp_detach(dev, flag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,6 +248,8 @@ ihfc_isa_probe(device_t dev)
|
||||
ihfc_sc_t *sc = &ihfc_softc[unit]; /* softc */
|
||||
const u_char *irq = &IRQ0[0]; /* irq's to try */
|
||||
const u_long *iobase = &IO0[0]; /* iobases to try */
|
||||
u_char flag = 0; /* flag */
|
||||
void *dummy = 0; /* a dummy */
|
||||
|
||||
HFC_VAR;
|
||||
|
||||
@ -266,6 +284,8 @@ ihfc_isa_probe(device_t dev)
|
||||
iobase++;
|
||||
}
|
||||
|
||||
flag = 0;
|
||||
|
||||
if (*irq && *iobase) /* we got our resources, now test chip */
|
||||
{
|
||||
S_DLP = IHFC_DLP; /* set D-priority */
|
||||
@ -281,6 +301,14 @@ ihfc_isa_probe(device_t dev)
|
||||
S_IIRQ = IIRQ0[*irq]; /* set internal irq */
|
||||
S_IIO = *iobase; /* set internal iobase */
|
||||
|
||||
/* setup interrupt routine now to avvoid stray *
|
||||
* interrupts. */
|
||||
|
||||
bus_setup_intr(dev, S_IRQ, INTR_TYPE_NET, (void(*)(void*))
|
||||
HFC_INTR, sc, &dummy);
|
||||
|
||||
flag = 1;
|
||||
|
||||
if (!HFC_CONTROL(sc, 1))
|
||||
{
|
||||
device_set_desc(dev, "TELEINT ISDN SPEED No. 1");
|
||||
@ -290,7 +318,7 @@ ihfc_isa_probe(device_t dev)
|
||||
}
|
||||
}
|
||||
|
||||
ihfc_pnp_detach(dev, 0);
|
||||
ihfc_pnp_detach(dev, flag);
|
||||
|
||||
if (*irq && *++iobase) goto j0; /* try again */
|
||||
|
||||
@ -310,7 +338,6 @@ ihfc_pnp_attach(device_t dev)
|
||||
{
|
||||
u_int unit = device_get_unit(dev); /* get unit */
|
||||
ihfc_sc_t *sc = &ihfc_softc[unit]; /* softc */
|
||||
void *dummy = 0; /* a dummy */
|
||||
HFC_VAR;
|
||||
|
||||
HFC_BEG;
|
||||
@ -324,9 +351,6 @@ ihfc_pnp_attach(device_t dev)
|
||||
HFC_INIT(sc, 2, 0, 0); /* Init B1 - Channel */
|
||||
HFC_INIT(sc, 4, 0, 0); /* Init B2 - Channel */
|
||||
|
||||
bus_setup_intr(dev, S_IRQ, INTR_TYPE_NET, (void(*)(void*))
|
||||
HFC_INTR, sc, &dummy);
|
||||
|
||||
HFC_END;
|
||||
return 0; /* success */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user