|
|
| version 1.2, 2003/06/17 04:28:39 | version 1.3, 2004/04/16 15:40:21 |
|---|---|
| Line 24 | Line 24 |
| * | * |
| * capi/iavc/iavc.h The AVM ISDN controllers' common declarations. | * capi/iavc/iavc.h The AVM ISDN controllers' common declarations. |
| * | * |
| * $FreeBSD: src/sys/i4b/capi/iavc/iavc.h,v 1.1.2.1 2001/08/10 14:08:34 obrien Exp $ | * $FreeBSD: src/sys/i4b/capi/iavc/iavc.h,v 1.2 2003/07/23 17:58:41 phk Exp $ |
| * $DragonFly: src/sys/i4b/capi/iavc/iavc.h,v 1.1 2003/06/16 06:22:17 dillon Exp $ | * $DragonFly$ |
| */ | */ |
| #ifndef _CAPI_IAVC_H_ | #ifndef _CAPI_IAVC_H_ |
| Line 314 static __inline int b1io_tx_empty(iavc_s | Line 314 static __inline int b1io_tx_empty(iavc_s |
| // I/O registers. | // I/O registers. |
| */ | */ |
| static __inline u_int8_t b1io_get_byte(iavc_softc_t *sc) | u_int8_t b1io_get_byte(iavc_softc_t *sc); |
| { | int b1io_put_byte(iavc_softc_t *sc, u_int8_t val); |
| int spin = 0; | |
| while (!b1io_rx_full(sc) && spin < B1IO_WAIT_MAX) { | |
| spin++; DELAY(B1IO_WAIT_DLY); | |
| } | |
| if (b1io_rx_full(sc)) | |
| return bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, B1_READ); | |
| printf("iavc%d: rx not completed\n", sc->sc_unit); | |
| return 0xff; | |
| } | |
| static __inline int b1io_put_byte(iavc_softc_t *sc, u_int8_t val) | |
| { | |
| int spin = 0; | |
| while (!b1io_tx_empty(sc) && spin < B1IO_WAIT_MAX) { | |
| spin++; DELAY(B1IO_WAIT_DLY); | |
| } | |
| if (b1io_tx_empty(sc)) { | |
| bus_space_write_1(sc->sc_io_bt, sc->sc_io_bh, B1_WRITE, val); | |
| return 0; | |
| } | |
| printf("iavc%d: tx not emptied\n", sc->sc_unit); | |
| return -1; | |
| } | |
| static __inline int b1io_save_put_byte(iavc_softc_t *sc, u_int8_t val) | |
| { | |
| int spin = 0; | |
| while (!b1io_tx_empty(sc) && spin < B1IO_WAIT_MAX) { | |
| spin++; DELAY(B1IO_WAIT_DLY); | |
| } | |
| if (b1io_tx_empty(sc)) { | |
| b1io_outp(sc, B1_WRITE, val); | |
| return 0; | |
| } | |
| printf("iavc%d: tx not emptied\n", sc->sc_unit); | |
| return -1; | |
| } | |
| static __inline u_int32_t b1io_get_word(iavc_softc_t *sc) | |
| { | |
| u_int32_t val = 0; | |
| val |= b1io_get_byte(sc); | |
| val |= (b1io_get_byte(sc) << 8); | |
| val |= (b1io_get_byte(sc) << 16); | |
| val |= (b1io_get_byte(sc) << 24); | |
| return val; | |
| } | |
| static __inline void b1io_put_word(iavc_softc_t *sc, u_int32_t val) | int b1io_save_put_byte(iavc_softc_t *sc, u_int8_t val); |
| { | |
| b1io_put_byte(sc, (val & 0xff)); | |
| b1io_put_byte(sc, (val >> 8) & 0xff); | |
| b1io_put_byte(sc, (val >> 16) & 0xff); | |
| b1io_put_byte(sc, (val >> 24) & 0xff); | |
| } | |
| static __inline int b1io_get_slice(iavc_softc_t *sc, u_int8_t *dp) | u_int32_t b1io_get_word(iavc_softc_t *sc); |
| { | void b1io_put_word(iavc_softc_t *sc, u_int32_t val); |
| int len, i; | |
| len = i = b1io_get_word(sc); | |
| while (i--) *dp++ = b1io_get_byte(sc); | |
| return len; | |
| } | |
| static __inline void b1io_put_slice(iavc_softc_t *sc, u_int8_t *dp, int len) | int b1io_get_slice(iavc_softc_t *sc, u_int8_t *dp); |
| { | void b1io_put_slice(iavc_softc_t *sc, u_int8_t *dp, int len); |
| b1io_put_word(sc, len); | |
| while (len--) b1io_put_byte(sc, *dp++); | |
| } | |
| /* | /* |
| // b1io_{read,write}_reg | // b1io_{read,write}_reg |
| Line 392 static __inline void b1io_put_slice(iavc | Line 331 static __inline void b1io_put_slice(iavc |
| // ports. | // ports. |
| */ | */ |
| static __inline u_int32_t b1io_read_reg(iavc_softc_t *sc, int reg) | u_int32_t b1io_read_reg(iavc_softc_t *sc, int reg); |
| { | u_int32_t b1io_write_reg(iavc_softc_t *sc, int reg, u_int32_t val); |
| b1io_put_byte(sc, READ_REGISTER); | |
| b1io_put_word(sc, reg); | |
| return b1io_get_word(sc); | |
| } | |
| static __inline u_int32_t b1io_write_reg(iavc_softc_t *sc, int reg, u_int32_t val) | |
| { | |
| b1io_put_byte(sc, WRITE_REGISTER); | |
| b1io_put_word(sc, reg); | |
| b1io_put_word(sc, val); | |
| return b1io_get_word(sc); | |
| } | |
| /* | /* |
| // t1io_outp | // t1io_outp |
| Line 433 static __inline u_int8_t t1io_fifostatus | Line 360 static __inline u_int8_t t1io_fifostatus |
| return bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, T1_FIFOSTAT); | return bus_space_read_1(sc->sc_io_bt, sc->sc_io_bh, T1_FIFOSTAT); |
| } | } |
| static __inline int t1io_get_slice(iavc_softc_t *sc, u_int8_t *dp) | int t1io_get_slice(iavc_softc_t *sc, u_int8_t *dp); |
| { | void t1io_put_slice(iavc_softc_t *sc, u_int8_t *dp, int len); |
| int len, i; | |
| len = i = b1io_get_word(sc); | |
| if (t1io_isfastlink(sc)) { | |
| int status; | |
| while (i) { | |
| status = t1io_fifostatus(sc) & (T1F_IREADY|T1F_IHALF); | |
| if (i >= FIFO_INPBSIZE) status |= T1F_IFULL; | |
| switch (status) { | |
| case T1F_IREADY|T1F_IHALF|T1F_IFULL: | |
| bus_space_read_multi_1(sc->sc_io_bt, sc->sc_io_bh, | |
| T1_READ, dp, FIFO_INPBSIZE); | |
| dp += FIFO_INPBSIZE; | |
| i -= FIFO_INPBSIZE; | |
| break; | |
| case T1F_IREADY|T1F_IHALF: | |
| bus_space_read_multi_1(sc->sc_io_bt, sc->sc_io_bh, | |
| T1_READ, dp, i); | |
| dp += i; | |
| i = 0; | |
| break; | |
| default: | |
| *dp++ = b1io_get_byte(sc); | |
| i--; | |
| } | |
| } | |
| } else { /* not fastlink */ | |
| if (i--) *dp++ = b1io_get_byte(sc); | |
| } | |
| return len; | |
| } | |
| static __inline void t1io_put_slice(iavc_softc_t *sc, u_int8_t *dp, int len) | |
| { | |
| int i = len; | |
| b1io_put_word(sc, i); | |
| if (t1io_isfastlink(sc)) { | |
| int status; | |
| while (i) { | |
| status = t1io_fifostatus(sc) & (T1F_OREADY|T1F_OHALF); | |
| if (i >= FIFO_OUTBSIZE) status |= T1F_OFULL; | |
| switch (status) { | |
| case T1F_OREADY|T1F_OHALF|T1F_OFULL: | |
| bus_space_write_multi_1(sc->sc_io_bt, sc->sc_io_bh, | |
| T1_WRITE, dp, FIFO_OUTBSIZE); | |
| dp += FIFO_OUTBSIZE; | |
| i -= FIFO_OUTBSIZE; | |
| break; | |
| case T1F_OREADY|T1F_OHALF: | |
| bus_space_write_multi_1(sc->sc_io_bt, sc->sc_io_bh, | |
| T1_WRITE, dp, i); | |
| dp += i; | |
| i = 0; | |
| break; | |
| default: | |
| b1io_put_byte(sc, *dp++); | |
| i--; | |
| } | |
| } | |
| } else { | |
| while (i--) b1io_put_byte(sc, *dp++); | |
| } | |
| } | |
| /* | /* |
| // An attempt to bring it all together: | // An attempt to bring it all together: |