FreeBSD/sys/dev/wl/if_wl.c
/*
 * wlconfig:
 *
 *	This routine does a standard config of the WaveLAN board.
 *
 */
This routine does a standard config of the WaveLAN board.
This routine does a standard config of the WaveLAN board .
static int
wlconfig(struct wl_softc *sc)
{
    configure_t	configure;
#if	MULTICAST
    struct ifmultiaddr *ifma;
    u_char *addrp;
    int cnt = 0;
#endif	
#ifdef WLDEBUG
    if (sc->ifp->if_flags & IFF_DEBUG)
	if_printf(sc->ifp, "entered wlconfig()\n");
#endif
    WL_WRITE_2(sc, PIOR0, OFFSET_SCB);
    if (WL_READ_2(sc, PIOP0) & SCB_SW_INT) {
    }
    wlack(sc);
    WL_WRITE_2(sc, PIOR1, OFFSET_CU);
    WL_WRITE_2(sc, PIOP1, 0);				
    WL_WRITE_2(sc, PIOP1, AC_CONFIGURE|AC_CW_EL);	
    configure.fifolim_bytecnt 	= 0x080c;
    configure.addrlen_mode  	= 0x0600;
    configure.linprio_interframe	= 0x2060;
    configure.slot_time      	= 0xf200;
    configure.hardware	     	= 0x0008;	
    configure.min_frame_len   	= 0x0040;
#if 0
    configure.fifolim_bytecnt 	= 0x040c;
    configure.addrlen_mode  	= 0x0600;
    configure.linprio_interframe	= 0x2060;
    configure.slot_time      	= 0xf000;
    configure.hardware	     	= 0x0008;	
    configure.min_frame_len   	= 0x0040;
#else
    configure.fifolim_bytecnt 	= 0x080c;
    configure.addrlen_mode  	= 0x2600;
    configure.linprio_interframe	= 0x7820;	
    configure.slot_time      	= 0xf00c;	
    configure.hardware	     	= 0x0008;	
    configure.min_frame_len   	= 0x0040;
#endif
    if (sc->mode & (MOD_PROM | MOD_ENAL))
	configure.hardware |= 1;
    WL_WRITE_2(sc, PIOR1, OFFSET_CU + 6);
    WL_WRITE_MULTI_2(sc, PIOP1, &configure, sizeof(configure_t)/2);
    if (wlcmd(sc, "config()-configure") == 0)
	return 0;
#if	MULTICAST
    WL_WRITE_2(sc, PIOR1, OFFSET_CU);
    WL_WRITE_2(sc, PIOP1, 0);				
    WL_WRITE_2(sc, PIOP1, AC_MCSETUP|AC_CW_EL);		
    WL_WRITE_2(sc, PIOR1, OFFSET_CU + 8);
    if_maddr_rlock(sc->ifp);
    TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
	if (ifma->ifma_addr->sa_family != AF_LINK)
	    continue;
	addrp = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
        WL_WRITE_2(sc, PIOP1, addrp[0] + (addrp[1] << 8));
        WL_WRITE_2(sc, PIOP1, addrp[2] + (addrp[3] << 8));
        WL_WRITE_2(sc, PIOP1, addrp[4] + (addrp[5] << 8));
        ++cnt;
    }
    if_maddr_runlock(sc->ifp);
    WL_WRITE_2(sc, PIOR1, OFFSET_CU + 6);		
    WL_WRITE_2(sc, PIOP1, cnt * WAVELAN_ADDR_SIZE);
    if (wlcmd(sc, "config()-mcaddress") == 0)
	return 0;
#endif	
    WL_WRITE_2(sc, PIOR1, OFFSET_CU);
    WL_WRITE_2(sc, PIOP1, 0);				
    WL_WRITE_2(sc, PIOP1, AC_IASETUP|AC_CW_EL);		
    WL_WRITE_2(sc, PIOR1, OFFSET_CU + 6);
    WL_WRITE_MULTI_2(sc, PIOP1, IF_LLADDR(sc->ifp), WAVELAN_ADDR_SIZE/2);
    if (wlcmd(sc, "config()-address") == 0)
	return(0);
    wlinitmmc(sc);
    return(1);
}
static int wlconfig ( struct wl_softc * sc ) { configure_t configure ; #if MULTICAST struct ifmultiaddr * ifma ; u_char * addrp ; int cnt = 0 ; #endif #ifdef WLDEBUG if ( sc -> ifp -> if_flags & IFF_DEBUG ) if_printf ( sc -> ifp , " \n " ) ; #endif WL_WRITE_2 ( sc , PIOR0 , OFFSET_SCB ) ; if ( WL_READ_2 ( sc , PIOP0 ) & SCB_SW_INT ) { } wlack ( sc ) ; WL_WRITE_2 ( sc , PIOR1 , OFFSET_CU ) ; WL_WRITE_2 ( sc , PIOP1 , 0 ) ; WL_WRITE_2 ( sc , PIOP1 , AC_CONFIGURE | AC_CW_EL ) ; configure . fifolim_bytecnt = 0x080c ; configure . addrlen_mode = 0x0600 ; configure . linprio_interframe = 0x2060 ; configure . slot_time = 0xf200 ; configure . hardware = 0x0008 ; configure . min_frame_len = 0x0040 ; #if 0 configure . fifolim_bytecnt = 0x040c ; configure . addrlen_mode = 0x0600 ; configure . linprio_interframe = 0x2060 ; configure . slot_time = 0xf000 ; configure . hardware = 0x0008 ; configure . min_frame_len = 0x0040 ; #else configure . fifolim_bytecnt = 0x080c ; configure . addrlen_mode = 0x2600 ; configure . linprio_interframe = 0x7820 ; configure . slot_time = 0xf00c ; configure . hardware = 0x0008 ; configure . min_frame_len = 0x0040 ; #endif if ( sc -> mode & ( MOD_PROM | MOD_ENAL ) ) configure . hardware |= 1 ; WL_WRITE_2 ( sc , PIOR1 , OFFSET_CU + 6 ) ; WL_WRITE_MULTI_2 ( sc , PIOP1 , & configure , sizeof ( configure_t ) / 2 ) ; if ( wlcmd ( sc , " " ) == 0 ) return 0 ; #if MULTICAST WL_WRITE_2 ( sc , PIOR1 , OFFSET_CU ) ; WL_WRITE_2 ( sc , PIOP1 , 0 ) ; WL_WRITE_2 ( sc , PIOP1 , AC_MCSETUP | AC_CW_EL ) ; WL_WRITE_2 ( sc , PIOR1 , OFFSET_CU + 8 ) ; if_maddr_rlock ( sc -> ifp ) ; TAILQ_FOREACH ( ifma , & sc -> ifp -> if_multiaddrs , ifma_link ) { if ( ifma -> ifma_addr -> sa_family != AF_LINK ) continue ; addrp = LLADDR ( ( struct sockaddr_dl * ) ifma -> ifma_addr ) ; WL_WRITE_2 ( sc , PIOP1 , addrp [ 0 ] + ( addrp [ 1 ] << 8 ) ) ; WL_WRITE_2 ( sc , PIOP1 , addrp [ 2 ] + ( addrp [ 3 ] << 8 ) ) ; WL_WRITE_2 ( sc , PIOP1 , addrp [ 4 ] + ( addrp [ 5 ] << 8 ) ) ; ++ cnt ; } if_maddr_runlock ( sc -> ifp ) ; WL_WRITE_2 ( sc , PIOR1 , OFFSET_CU + 6 ) ; WL_WRITE_2 ( sc , PIOP1 , cnt * WAVELAN_ADDR_SIZE ) ; if ( wlcmd ( sc , " " ) == 0 ) return 0 ; #endif WL_WRITE_2 ( sc , PIOR1 , OFFSET_CU ) ; WL_WRITE_2 ( sc , PIOP1 , 0 ) ; WL_WRITE_2 ( sc , PIOP1 , AC_IASETUP | AC_CW_EL ) ; WL_WRITE_2 ( sc , PIOR1 , OFFSET_CU + 6 ) ; WL_WRITE_MULTI_2 ( sc , PIOP1 , IF_LLADDR ( sc -> ifp ) , WAVELAN_ADDR_SIZE / 2 ) ; if ( wlcmd ( sc , " " ) == 0 ) return ( 0 ) ; wlinitmmc ( sc ) ; return ( 1 ) ; }
wlconfig:
      This routine does a standard config of the WaveLAN board.
wlconfig : This routine does a standard config of the WaveLAN board .
/* MULTICAST */ /*
	  if_printf(sc->ifp, "config(): unexpected initial state %x\n",
	      WL_READ_2(sc, PIOP0));
	  */ /* ac_status */ /* ac_command */ /* jrb hack */ /* tx even w/o CD */ /* This is the configuration block suggested by Marc Meertens
     * <mmeerten@obelix.utrecht.NCR.COM> in an e-mail message to John
     * Ioannidis on 10 Nov 92.
     */ /* tx even w/o CD */ /*
     * below is the default board configuration from p2-28 from 586 book
     */ /* IFS=120, ACS=2 */ /* slottime=12    */ /* tx even w/o CD */ /* ac_status */ /* ac_command */ /* mc-cnt */ /* MULTICAST */ /* ac_status */ /* ac_command */