Date: Sat, 11 Apr 1998 01:13:05 +0200 (MET DST) From: Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE> To: FreeBSD-ISDN@FreeBSD.ORG (FreeBSD ISDN mailinglist) Subject: layer 1 rework Message-ID: <199804102313.BAA00432@rvc1.informatik.ba-stuttgart.de>
next in thread | raw e-mail | index | archive | help
Hi, This is a rework of layer 1: - layer 1 is not any more activated during boot time, instead it is activated when needed -- i. e. its activated, when a data request is issued by layer 2. - a deactivate request from the S-interface (NT) is respected now. - the routine isic_isac_enable_clk() is not needed anymore and hence deleted. - in ph_data_req() more code is proteced from interrupts, and a bogus check (sc->sc_obuf != NULL) is removed. - mph_deactivate_req() is ready to be called from layer 2, to deactivate layer 1 if a disconnection happened. After mph_deactivate_req() is called, the net may deactivate layer 1, (if the S0-bus is not needed for other connections) mph_deactivate_req() is not called from layer 2. This is a diff against i4b_00.51 . It won't apply cleanly against an already patched version of i4b_00.51, i. e. the one which made it compile under FreeBSD-current. Wolfgang --- /home/helbig/src/i4b/layer1/i4b_l1fsm.c Thu Mar 19 20:36:55 1998 +++ layer1/i4b_l1fsm.c Fri Apr 10 23:06:05 1998 @@ -221,6 +221,8 @@ PH_Act_Ind(sc->sc_unit); MPH_Act_Ind(sc->sc_unit); + + isic_isac_l1_cmd(sc, CMD_AR8); /* activate request needed by ISAC */ T3_stop(sc); } @@ -238,6 +240,8 @@ MPH_Act_Ind(sc->sc_unit); MPH_Error_Ind(sc->sc_unit, 2); + + isic_isac_l1_cmd(sc, CMD_AR8); /* activate request needed by ISAC */ T3_stop(sc); } @@ -254,6 +258,8 @@ MPH_Act_Ind(sc->sc_unit); + isic_isac_l1_cmd(sc, CMD_AR10); /* activate request needed by ISAC */ + T3_stop(sc); } @@ -270,6 +276,8 @@ MPH_Act_Ind(sc->sc_unit); MPH_Error_Ind(sc->sc_unit, 2); + + isic_isac_l1_cmd(sc, CMD_AR10); /* activate request needed by ISAC */ T3_stop(sc); } @@ -290,8 +298,6 @@ F_PU2(struct isic_softc *sc) { DBGL1(L1_F_MSG, "F_PU", ("FSM function F_PU executing\n")) - - isic_isac_l1_cmd(sc, CMD_AR8); /* activate layer 1 */ } /*---------------------------------------------------------------------------* @@ -302,7 +308,7 @@ { DBGL1(L1_F_MSG, "F_DR", ("FSM function F_DR executing\n")) - isic_isac_l1_cmd(sc, CMD_TIM); /* activate layer 1 */ + isic_isac_l1_cmd(sc, CMD_DIU); /* power down ISAC */ MPH_Deact_Ind(sc->sc_unit); --- /home/helbig/src/i4b/layer1/i4b_l1.c Tue Mar 31 11:41:35 1998 +++ layer1/i4b_l1.c Fri Apr 10 23:13:49 1998 @@ -175,43 +175,33 @@ if(m == NULL) /* failsafe */ return (0); + s = SPLI4B(); + if(sc->sc_I430state != ST_F7) /* layer 1 running ? */ { DBGL1(L1_I_ERR, "ph_data_req", ("Not in ST_F7, sc->sc_I430state = %s\n", isic_printstate(sc))) /* timer T3 start !!! */ - if(isic_isac_enable_clk(sc) == 0) - isic_isac_l1_cmd(sc, CMD_AR8); +#if 0 if(freeflag == MBUF_FREE) i4b_Dfreembuf(m); return(0); - } - - if(sc->sc_obuf != NULL) /* transmitter currently busy ? */ - { - - DBGL1(L1_I_ERR, "ph_data_req", ("sc->sc_obuf != NULL, sc->sc_I430state = %s\n", isic_printstate(sc))) - - if(freeflag == MBUF_FREE) - i4b_Dfreembuf(m); - - return (0); +#endif + isic_isac_l1_cmd(sc, CMD_AR8); } if(sc->sc_state & ISAC_TX_ACTIVE) { if(sc->sc_obuf2 == NULL) { - s = SPLI4B(); sc->sc_obuf2 = m; /* save mbuf ptr */ if(freeflag) sc->sc_freeflag2 = 1; /* IRQ must mfree */ else sc->sc_freeflag2 = 0; /* IRQ must not mfree */ - splx(s); DBGL1(L1_I_MSG, "ph_data_req", ("using 2nd ISAC TX buffer, state = %s\n", isic_printstate(sc))) @@ -222,9 +212,14 @@ hdr.type = TRC_CH_D; hdr.dir = FROM_TE; hdr.count = ++sc->sc_trace_dcount; +#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + getmicrotime(&hdr.time); +#else hdr.time = time; +#endif MPH_Trace_Ind(&hdr, m->m_len, m->m_data); } + splx(s); return(1); } @@ -233,6 +228,7 @@ if(freeflag == MBUF_FREE) i4b_Dfreembuf(m); + splx(s); return (0); } @@ -243,11 +239,14 @@ hdr.type = TRC_CH_D; hdr.dir = FROM_TE; hdr.count = ++sc->sc_trace_dcount; +#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + getmicrotime(&hdr.time); +#else hdr.time = time; +#endif MPH_Trace_Ind(&hdr, m->m_len, m->m_data); } - s = SPLI4B(); sc->sc_state |= ISAC_TX_ACTIVE; /* set transmitter busy flag */ @@ -315,8 +314,7 @@ { /* timer T3 start !!! */ - if(isic_isac_enable_clk(sc) == 0) - isic_isac_l1_cmd(sc, CMD_AR8); + isic_isac_l1_cmd(sc, CMD_AR8); } return(1); } @@ -327,6 +325,14 @@ static int mph_deactivate_req(int unit) { +#ifdef __FreeBSD__ + struct isic_softc *sc = &isic_sc[unit]; +#else + struct isic_softc *sc = isic_find_sc(unit); +#endif + + isic_isac_l1_cmd(sc, CMD_DIU); + return(0); } --- /home/helbig/src/i4b/layer1/i4b_isac.c Tue Mar 31 12:00:45 1998 +++ layer1/i4b_isac.c Fri Apr 10 23:16:38 1998 @@ -100,6 +100,7 @@ isic_isac_irq(struct isic_softc *sc, int ista) { register u_char c = 0; + DBGL1(L1_F_MSG, "isic_isac_irq", ("ista =%#x\n", ista)) if(ista & ISAC_ISTA_EXI) /* extended interrupt */ { @@ -183,7 +184,11 @@ hdr.type = TRC_CH_D; hdr.dir = FROM_NT; hdr.count = ++sc->sc_trace_dcount; +#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + getmicrotime(&hdr.time); +#else hdr.time = time; +#endif MPH_Trace_Ind(&hdr, sc->sc_ibuf->m_len, sc->sc_ibuf->m_data); } @@ -442,77 +447,6 @@ } /*---------------------------------------------------------------------------* - * L1 ISAC enable clocks - *---------------------------------------------------------------------------*/ -int -isic_isac_enable_clk(struct isic_softc *sc) -{ - u_char bitset; - u_char spcr; - - int count; - int i; - - bitset = (ISAC_READ(I_STAR)) & ISAC_STAR_BVS; - - count = 0; - - for(i=0; i < 500; i++) - { - if(((ISAC_READ(I_STAR)) & ISAC_STAR_BVS) != bitset) - { - if(++count > 6) - { - DBGL1(L1_I_SETUP, "isic_isac_enable_clk", ("clocks already running, return (i=%d,count=%d)\n",i,count)) - return(0); /* clocks were running */ - } - - i = 0; - - bitset = (ISAC_READ(I_STAR)) & ISAC_STAR_BVS; - } - } - - DBGL1(L1_I_SETUP, "isic_isac_enable_clk", ("clocks not running, starting clocks\n")) - - if(sc->sc_isac_version != ISAC_VA) - { - DBGL1(L1_I_SETUP, "isic_isac_enable_clk", ("ISAC version B, set IDC bit\n")) - - ISAC_WRITE(I_SQXR, ISAC_SQXR_IDC); - } - - spcr = ISAC_READ(I_SPCR); - - DBGL1(L1_I_SETUP, "isic_isac_enable_clk", ("SPCR = 0x%x\n", spcr)) - - ISAC_WRITE(I_SPCR, spcr | ISAC_SPCR_SPU); - - isic_isac_l1_cmd(sc, CMD_TIM); - - while((((ISAC_READ(I_CIRR)) >> 2) & 0x0f) != ISAC_CIRR_IPU) - { - if(++i > 1000) - break; - } - - if(i < 1000) - isic_next_state(sc, EV_PU); - - DBGL1(L1_I_SETUP, "isic_isac_enable_clk", ("PU loop left, i = %d\n", i)) - - ISAC_WRITE(I_SPCR, spcr); - - if(sc->sc_isac_version != ISAC_VA) - { - DBGL1(L1_I_SETUP, "isic_isac_enable_clk", ("ISAC version B, clear IDC bit\n")) - - ISAC_WRITE(I_SQXR, 0x00); - } - return(1); /* clocks were not running */ -} - -/*---------------------------------------------------------------------------* * L1 ISAC register setup *---------------------------------------------------------------------------*/ static void @@ -669,13 +603,6 @@ isic_isac_init(struct isic_softc *sc) { isic_isac_setup(sc); /* setup registers */ - - DELAY(SEC_DELAY / 5); - - /* activate Layer 1 */ - - if(isic_isac_enable_clk(sc) == 0) - isic_isac_l1_cmd(sc, CMD_AR8); return(0); } --- /home/helbig/src/i4b/layer1/i4b_l1.h Wed Apr 1 13:48:30 1998 +++ layer1/i4b_l1.h Fri Apr 10 23:43:01 1998 @@ -352,7 +352,6 @@ 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_enable_clk ( 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 ); @@ -387,7 +386,6 @@ 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_enable_clk __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)); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-isdn" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804102313.BAA00432>