Home | History | Annotate | Line # | Download | only in dev
if_le.c revision 1.41.74.1
      1  1.41.74.1       mjf /*	$NetBSD: if_le.c,v 1.41.74.1 2008/06/02 13:21:50 mjf Exp $ */
      2        1.7       cgd 
      3       1.15    chopps /*-
      4       1.31   mycroft  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
      5       1.27   thorpej  * All rights reserved.
      6       1.27   thorpej  *
      7       1.27   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8       1.31   mycroft  * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
      9       1.31   mycroft  * Simulation Facility, NASA Ames Research Center.
     10       1.27   thorpej  *
     11       1.27   thorpej  * Redistribution and use in source and binary forms, with or without
     12       1.27   thorpej  * modification, are permitted provided that the following conditions
     13       1.27   thorpej  * are met:
     14       1.27   thorpej  * 1. Redistributions of source code must retain the above copyright
     15       1.27   thorpej  *    notice, this list of conditions and the following disclaimer.
     16       1.27   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.27   thorpej  *    notice, this list of conditions and the following disclaimer in the
     18       1.27   thorpej  *    documentation and/or other materials provided with the distribution.
     19       1.27   thorpej  *
     20       1.27   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21       1.27   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22       1.27   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23       1.27   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24       1.27   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25       1.27   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26       1.27   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27       1.27   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28       1.27   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29       1.27   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30       1.27   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     31       1.27   thorpej  */
     32       1.27   thorpej 
     33       1.27   thorpej /*-
     34       1.27   thorpej  * Copyright (c) 1997 Bernd Ernesti.  All rights reserved.
     35       1.15    chopps  * Copyright (c) 1992, 1993
     36       1.15    chopps  *	The Regents of the University of California.  All rights reserved.
     37       1.15    chopps  *
     38       1.15    chopps  * This code is derived from software contributed to Berkeley by
     39       1.15    chopps  * Ralph Campbell and Rick Macklem.
     40        1.1        mw  *
     41        1.1        mw  * Redistribution and use in source and binary forms, with or without
     42        1.1        mw  * modification, are permitted provided that the following conditions
     43        1.1        mw  * are met:
     44        1.1        mw  * 1. Redistributions of source code must retain the above copyright
     45        1.1        mw  *    notice, this list of conditions and the following disclaimer.
     46        1.1        mw  * 2. Redistributions in binary form must reproduce the above copyright
     47        1.1        mw  *    notice, this list of conditions and the following disclaimer in the
     48        1.1        mw  *    documentation and/or other materials provided with the distribution.
     49        1.1        mw  * 3. All advertising materials mentioning features or use of this software
     50        1.1        mw  *    must display the following acknowledgement:
     51       1.26     veego  *	This product includes software developed for the NetBSD Project
     52       1.27   thorpej  *	by Bernd Ernesti.
     53        1.1        mw  *	This product includes software developed by the University of
     54        1.1        mw  *	California, Berkeley and its contributors.
     55        1.1        mw  * 4. Neither the name of the University nor the names of its contributors
     56        1.1        mw  *    may be used to endorse or promote products derived from this software
     57        1.1        mw  *    without specific prior written permission.
     58        1.1        mw  *
     59        1.1        mw  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     60        1.1        mw  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     61        1.1        mw  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     62        1.1        mw  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     63        1.1        mw  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     64        1.1        mw  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     65        1.1        mw  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     66        1.1        mw  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     67        1.1        mw  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     68        1.1        mw  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     69        1.1        mw  * SUCH DAMAGE.
     70        1.1        mw  *
     71       1.15    chopps  *	@(#)if_le.c	8.2 (Berkeley) 11/16/93
     72        1.1        mw  */
     73        1.1        mw 
     74       1.29  jonathan #include "opt_inet.h"
     75       1.36   aymeric 
     76       1.36   aymeric #include <sys/cdefs.h>
     77  1.41.74.1       mjf __KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.41.74.1 2008/06/02 13:21:50 mjf Exp $");
     78       1.36   aymeric 
     79        1.1        mw #include "bpfilter.h"
     80        1.1        mw 
     81        1.5    chopps #include <sys/param.h>
     82        1.5    chopps #include <sys/systm.h>
     83        1.5    chopps #include <sys/mbuf.h>
     84       1.15    chopps #include <sys/syslog.h>
     85        1.5    chopps #include <sys/socket.h>
     86        1.6    chopps #include <sys/device.h>
     87        1.5    chopps 
     88        1.5    chopps #include <net/if.h>
     89       1.23        is #include <net/if_ether.h>
     90       1.24   thorpej #include <net/if_media.h>
     91        1.1        mw 
     92        1.1        mw #ifdef INET
     93        1.5    chopps #include <netinet/in.h>
     94       1.23        is #include <netinet/if_inarp.h>
     95        1.1        mw #endif
     96        1.1        mw 
     97        1.5    chopps #include <machine/cpu.h>
     98        1.5    chopps #include <machine/mtpr.h>
     99       1.15    chopps 
    100        1.6    chopps #include <amiga/amiga/device.h>
    101       1.10    chopps #include <amiga/amiga/isr.h>
    102       1.21   thorpej 
    103       1.30  drochner #include <dev/ic/lancereg.h>
    104       1.30  drochner #include <dev/ic/lancevar.h>
    105       1.21   thorpej #include <dev/ic/am7990reg.h>
    106       1.21   thorpej #include <dev/ic/am7990var.h>
    107       1.21   thorpej 
    108        1.9    chopps #include <amiga/dev/zbusvar.h>
    109       1.15    chopps #include <amiga/dev/if_levar.h>
    110        1.6    chopps 
    111  1.41.74.1       mjf int le_zbus_match(device_t, cfdata_t, void *);
    112  1.41.74.1       mjf void le_zbus_attach(device_t, device_t, void *);
    113        1.6    chopps 
    114  1.41.74.1       mjf CFATTACH_DECL_NEW(le_zbus, sizeof(struct le_softc),
    115       1.38   thorpej     le_zbus_match, le_zbus_attach, NULL, NULL);
    116       1.17   thorpej 
    117       1.33       mrg #if defined(_KERNEL_OPT)
    118       1.30  drochner #include "opt_ddb.h"
    119       1.30  drochner #endif
    120       1.30  drochner 
    121       1.30  drochner #ifdef DDB
    122       1.30  drochner #define	integrate
    123       1.30  drochner #define hide
    124       1.30  drochner #else
    125       1.41     perry #define	integrate	static inline
    126       1.30  drochner #define hide		static
    127       1.30  drochner #endif
    128       1.30  drochner 
    129       1.35   aymeric hide void lepcnet_reset(struct lance_softc *);
    130       1.35   aymeric hide void lewrcsr(struct lance_softc *, u_int16_t, u_int16_t);
    131       1.35   aymeric hide u_int16_t lerdcsr(struct lance_softc *, u_int16_t);
    132       1.35   aymeric 
    133       1.35   aymeric hide u_int16_t ariadne_swapreg(u_int16_t);
    134       1.35   aymeric hide void ariadne_wrcsr(struct lance_softc *, u_int16_t, u_int16_t);
    135       1.35   aymeric hide u_int16_t ariadne_rdcsr(struct lance_softc *, u_int16_t);
    136       1.35   aymeric hide void ariadne_wribcr(struct lance_softc *, u_int16_t, u_int16_t);
    137       1.35   aymeric integrate void ariadne_copytodesc_word(struct lance_softc *, void *, int, int);
    138       1.35   aymeric integrate void ariadne_copyfromdesc_word(struct lance_softc *, void *,
    139       1.35   aymeric 				int, int);
    140       1.35   aymeric integrate void ariadne_copytobuf_word(struct lance_softc *, void *, int, int);
    141       1.35   aymeric integrate void ariadne_copyfrombuf_word(struct lance_softc *, void *, int, int);
    142       1.35   aymeric integrate void ariadne_zerobuf_word(struct lance_softc *, int, int);
    143       1.35   aymeric void ariadne_autoselect(struct lance_softc *, int);
    144       1.35   aymeric int ariadne_mediachange(struct lance_softc *);
    145       1.35   aymeric void ariadne_hwinit(struct lance_softc *);
    146       1.26     veego 
    147       1.35   aymeric /*
    148       1.26     veego  * Media types supported by the Ariadne.
    149       1.26     veego  */
    150       1.26     veego int lemedia_ariadne[] = {
    151       1.26     veego 	IFM_ETHER | IFM_10_T,
    152       1.26     veego 	IFM_ETHER | IFM_10_2,
    153       1.26     veego 	IFM_ETHER | IFM_AUTO,
    154       1.26     veego };
    155  1.41.74.1       mjf #define NLEMEDIA_ARIADNE __arraycount(lemedia_ariadne)
    156       1.26     veego 
    157       1.26     veego 
    158       1.26     veego hide u_int16_t
    159       1.35   aymeric ariadne_swapreg(u_int16_t val)
    160       1.26     veego {
    161       1.26     veego 
    162       1.26     veego 	return (((val & 0xff) << 8 ) | (( val >> 8) & 0xff));
    163       1.26     veego }
    164       1.26     veego 
    165       1.26     veego hide void
    166       1.35   aymeric ariadne_wrcsr(struct lance_softc *sc, u_int16_t port, u_int16_t val)
    167       1.26     veego {
    168       1.26     veego 	struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
    169       1.26     veego 
    170       1.26     veego 	ler1->ler1_rap = ariadne_swapreg(port);
    171       1.26     veego 	ler1->ler1_rdp = ariadne_swapreg(val);
    172       1.26     veego }
    173       1.26     veego 
    174       1.26     veego hide u_int16_t
    175       1.35   aymeric ariadne_rdcsr(struct lance_softc *sc, u_int16_t port)
    176       1.26     veego {
    177       1.26     veego 	struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
    178       1.26     veego 	u_int16_t val;
    179       1.26     veego 
    180       1.26     veego 	ler1->ler1_rap = ariadne_swapreg(port);
    181       1.26     veego 	val = ariadne_swapreg(ler1->ler1_rdp);
    182       1.26     veego 	return (val);
    183       1.26     veego }
    184       1.26     veego 
    185       1.26     veego hide void
    186       1.35   aymeric ariadne_wribcr(struct lance_softc *sc, u_int16_t port, u_int16_t val)
    187       1.26     veego {
    188       1.26     veego 	struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
    189       1.26     veego 
    190       1.26     veego 	ler1->ler1_rap = ariadne_swapreg(port);
    191       1.26     veego 	ler1->ler1_idp = ariadne_swapreg(val);
    192       1.26     veego }
    193       1.26     veego 
    194       1.21   thorpej hide void
    195       1.35   aymeric lewrcsr(struct lance_softc *sc, u_int16_t port, u_int16_t val)
    196       1.15    chopps {
    197       1.21   thorpej 	struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
    198        1.6    chopps 
    199       1.15    chopps 	ler1->ler1_rap = port;
    200       1.15    chopps 	ler1->ler1_rdp = val;
    201       1.15    chopps }
    202        1.6    chopps 
    203       1.21   thorpej hide u_int16_t
    204       1.35   aymeric lerdcsr(struct lance_softc *sc, u_int16_t port)
    205        1.6    chopps {
    206       1.21   thorpej 	struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
    207       1.15    chopps 	u_int16_t val;
    208        1.6    chopps 
    209       1.15    chopps 	ler1->ler1_rap = port;
    210       1.15    chopps 	val = ler1->ler1_rdp;
    211       1.15    chopps 	return (val);
    212       1.15    chopps }
    213        1.6    chopps 
    214       1.26     veego hide void
    215       1.35   aymeric lepcnet_reset(struct lance_softc *sc)
    216       1.26     veego {
    217       1.26     veego 	struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
    218       1.26     veego 	volatile int dummy;
    219       1.26     veego 
    220       1.26     veego 	dummy = ler1->ler1_reset;	/* Reset PCNet-ISA */
    221       1.26     veego }
    222       1.26     veego 
    223       1.26     veego void
    224       1.35   aymeric ariadne_autoselect(struct lance_softc *sc, int on)
    225       1.26     veego {
    226       1.26     veego 
    227       1.26     veego 	/*
    228       1.26     veego 	 * on = 0: autoselect disabled
    229       1.26     veego 	 * on = 1: autoselect enabled
    230       1.26     veego 	 */
    231       1.26     veego 	if (on == 0)
    232       1.26     veego 		ariadne_wribcr(sc, LE_BCR_MC, 0x0000);
    233       1.26     veego 	else
    234       1.26     veego 		ariadne_wribcr(sc, LE_BCR_MC, LE_MC_ASEL);
    235       1.26     veego }
    236       1.26     veego 
    237       1.26     veego int
    238       1.35   aymeric ariadne_mediachange(struct lance_softc *sc)
    239       1.26     veego {
    240       1.26     veego 	struct ifmedia *ifm = &sc->sc_media;
    241       1.26     veego 
    242       1.26     veego 	if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
    243       1.26     veego 		return (EINVAL);
    244       1.26     veego 
    245       1.26     veego 	/*
    246       1.26     veego 	 * Switch to the selected media.  If autoselect is
    247       1.26     veego 	 * set, switch it on otherwise disable it.  We'll
    248       1.26     veego 	 * switch to the other media when we detect loss of
    249       1.26     veego 	 * carrier.
    250       1.26     veego 	 */
    251       1.26     veego 	switch (IFM_SUBTYPE(ifm->ifm_media)) {
    252       1.26     veego 	    case IFM_10_T:
    253       1.26     veego 		sc->sc_initmodemedia = 1;
    254       1.34  jdolecek 		lance_init(&sc->sc_ethercom.ec_if);
    255       1.26     veego 		break;
    256       1.26     veego 
    257       1.26     veego 	    case IFM_10_2:
    258       1.26     veego 		sc->sc_initmodemedia = 0;
    259       1.34  jdolecek 		lance_init(&sc->sc_ethercom.ec_if);
    260       1.26     veego 		break;
    261       1.26     veego 
    262       1.26     veego 	    case IFM_AUTO:
    263       1.26     veego 		sc->sc_initmodemedia = 2;
    264       1.26     veego 		ariadne_hwinit(sc);
    265       1.26     veego 		break;
    266       1.26     veego 
    267       1.26     veego 	    default:
    268       1.26     veego 		return (EINVAL);
    269       1.26     veego 	}
    270       1.26     veego 
    271       1.26     veego 	return (0);
    272       1.26     veego }
    273       1.26     veego 
    274       1.26     veego void
    275       1.35   aymeric ariadne_hwinit(struct lance_softc *sc)
    276       1.26     veego {
    277       1.26     veego 
    278       1.26     veego 	/*
    279       1.26     veego 	 * Re-program LEDs to match meaning used on the Ariadne board.
    280       1.26     veego          */
    281       1.26     veego 	ariadne_wribcr(sc, LE_BCR_LED1, 0x0090);
    282       1.26     veego 	ariadne_wribcr(sc, LE_BCR_LED2, 0x0081);
    283       1.26     veego 	ariadne_wribcr(sc, LE_BCR_LED3, 0x0084);
    284       1.26     veego 
    285       1.26     veego 	/*
    286       1.35   aymeric 	 * Enabel/Disable auto selection
    287       1.26     veego 	 */
    288       1.26     veego 	if (sc->sc_initmodemedia == 2)
    289       1.26     veego 		ariadne_autoselect(sc, 1);
    290       1.26     veego 	else
    291       1.26     veego 		ariadne_autoselect(sc, 0);
    292       1.26     veego }
    293       1.26     veego 
    294       1.15    chopps int
    295  1.41.74.1       mjf le_zbus_match(device_t parent, cfdata_t cfp, void *aux)
    296       1.15    chopps {
    297       1.15    chopps 	struct zbus_args *zap = aux;
    298        1.6    chopps 
    299        1.6    chopps 	/* Commodore ethernet card */
    300       1.15    chopps 	if (zap->manid == 514 && zap->prodid == 112)
    301       1.15    chopps 		return (1);
    302        1.6    chopps 
    303        1.6    chopps 	/* Ameristar ethernet card */
    304       1.15    chopps 	if (zap->manid == 1053 && zap->prodid == 1)
    305       1.15    chopps 		return (1);
    306        1.6    chopps 
    307       1.26     veego 	/* Ariadne ethernet card */
    308       1.26     veego 	if (zap->manid == 2167 && zap->prodid == 201)
    309       1.26     veego 		return (1);
    310       1.26     veego 
    311        1.6    chopps 	return (0);
    312        1.6    chopps }
    313        1.1        mw 
    314        1.6    chopps void
    315  1.41.74.1       mjf le_zbus_attach(device_t parent, device_t self, void *aux)
    316        1.1        mw {
    317  1.41.74.1       mjf 	struct le_softc *lesc = device_private(self);
    318       1.30  drochner 	struct lance_softc *sc = &lesc->sc_am7990.lsc;
    319       1.15    chopps 	struct zbus_args *zap = aux;
    320       1.15    chopps 	u_long ser;
    321        1.1        mw 
    322  1.41.74.1       mjf 	sc->sc_dev = self;
    323  1.41.74.1       mjf 
    324       1.26     veego 	/* This has no effect on PCnet-ISA LANCE chips */
    325       1.15    chopps 	sc->sc_conf3 = LE_C3_BSWP;
    326        1.6    chopps 
    327        1.6    chopps 	/*
    328        1.6    chopps 	 * Manufacturer decides the 3 first bytes, i.e. ethernet vendor ID.
    329        1.6    chopps 	 */
    330       1.15    chopps 	switch (zap->manid) {
    331       1.26     veego 	    case 514:
    332       1.15    chopps 		/* Commodore */
    333       1.15    chopps 		sc->sc_memsize = 32768;
    334       1.23        is 		sc->sc_enaddr[0] = 0x00;
    335       1.23        is 		sc->sc_enaddr[1] = 0x80;
    336       1.23        is 		sc->sc_enaddr[2] = 0x10;
    337       1.26     veego 		lesc->sc_r1 = (struct lereg1 *)(0x4000 + (int)zap->va);
    338       1.26     veego 		sc->sc_mem = (void *)(0x8000 + (int)zap->va);
    339       1.26     veego 		sc->sc_addr = 0x8000;
    340       1.30  drochner 		sc->sc_copytodesc = lance_copytobuf_contig;
    341       1.30  drochner 		sc->sc_copyfromdesc = lance_copyfrombuf_contig;
    342       1.30  drochner 		sc->sc_copytobuf = lance_copytobuf_contig;
    343       1.30  drochner 		sc->sc_copyfrombuf = lance_copyfrombuf_contig;
    344       1.30  drochner 		sc->sc_zerobuf = lance_zerobuf_contig;
    345       1.26     veego 		sc->sc_rdcsr = lerdcsr;
    346       1.26     veego 		sc->sc_wrcsr = lewrcsr;
    347       1.26     veego 		sc->sc_hwreset = NULL;
    348       1.26     veego 		sc->sc_hwinit = NULL;
    349       1.15    chopps 		break;
    350        1.6    chopps 
    351       1.26     veego 	    case 1053:
    352       1.15    chopps 		/* Ameristar */
    353       1.15    chopps 		sc->sc_memsize = 32768;
    354       1.23        is 		sc->sc_enaddr[0] = 0x00;
    355       1.23        is 		sc->sc_enaddr[1] = 0x00;
    356       1.23        is 		sc->sc_enaddr[2] = 0x9f;
    357       1.26     veego 		lesc->sc_r1 = (struct lereg1 *)(0x4000 + (int)zap->va);
    358       1.26     veego 		sc->sc_mem = (void *)(0x8000 + (int)zap->va);
    359       1.26     veego 		sc->sc_addr = 0x8000;
    360       1.30  drochner 		sc->sc_copytodesc = lance_copytobuf_contig;
    361       1.30  drochner 		sc->sc_copyfromdesc = lance_copyfrombuf_contig;
    362       1.30  drochner 		sc->sc_copytobuf = lance_copytobuf_contig;
    363       1.30  drochner 		sc->sc_copyfrombuf = lance_copyfrombuf_contig;
    364       1.30  drochner 		sc->sc_zerobuf = lance_zerobuf_contig;
    365       1.26     veego 		sc->sc_rdcsr = lerdcsr;
    366       1.26     veego 		sc->sc_wrcsr = lewrcsr;
    367       1.26     veego 		sc->sc_hwreset = NULL;
    368       1.26     veego 		sc->sc_hwinit = NULL;
    369       1.15    chopps 		break;
    370        1.6    chopps 
    371       1.26     veego 	    case 2167:
    372       1.26     veego 		/* Village Tronic */
    373       1.26     veego 		sc->sc_memsize = 32768;
    374       1.26     veego 		sc->sc_enaddr[0] = 0x00;
    375       1.26     veego 		sc->sc_enaddr[1] = 0x60;
    376       1.26     veego 		sc->sc_enaddr[2] = 0x30;
    377       1.26     veego 		lesc->sc_r1 = (struct lereg1 *)(0x0370 + (int)zap->va);
    378       1.26     veego 		sc->sc_mem = (void *)(0x8000 + (int)zap->va);
    379       1.26     veego 		sc->sc_addr = 0x8000;
    380       1.26     veego 		sc->sc_copytodesc = ariadne_copytodesc_word;
    381       1.26     veego 		sc->sc_copyfromdesc = ariadne_copyfromdesc_word;
    382       1.26     veego 		sc->sc_copytobuf = ariadne_copytobuf_word;
    383       1.26     veego 		sc->sc_copyfrombuf = ariadne_copyfrombuf_word;
    384       1.26     veego 		sc->sc_zerobuf = ariadne_zerobuf_word;
    385       1.26     veego 		sc->sc_rdcsr = ariadne_rdcsr;
    386       1.26     veego 		sc->sc_wrcsr = ariadne_wrcsr;
    387       1.26     veego 		sc->sc_hwreset = lepcnet_reset;
    388       1.26     veego 		sc->sc_hwinit = ariadne_hwinit;
    389       1.26     veego 		sc->sc_mediachange = ariadne_mediachange;
    390       1.26     veego 		sc->sc_supmedia = lemedia_ariadne;
    391       1.26     veego 		sc->sc_nsupmedia = NLEMEDIA_ARIADNE;
    392       1.26     veego 		sc->sc_defaultmedia = IFM_ETHER | IFM_AUTO;
    393       1.26     veego 		sc->sc_initmodemedia = 2;
    394       1.26     veego 		break;
    395       1.26     veego 
    396       1.26     veego 	    default:
    397       1.21   thorpej 		panic("le_zbus_attach: bad manid");
    398        1.1        mw 	}
    399        1.6    chopps 
    400        1.6    chopps 	/*
    401       1.15    chopps 	 * Serial number for board is used as host ID.
    402        1.6    chopps 	 */
    403       1.15    chopps 	ser = (u_long)zap->serno;
    404       1.23        is 	sc->sc_enaddr[3] = (ser >> 16) & 0xff;
    405       1.23        is 	sc->sc_enaddr[4] = (ser >>  8) & 0xff;
    406       1.23        is 	sc->sc_enaddr[5] = (ser      ) & 0xff;
    407        1.1        mw 
    408       1.30  drochner 	am7990_config(&lesc->sc_am7990);
    409        1.6    chopps 
    410       1.21   thorpej 	lesc->sc_isr.isr_intr = am7990_intr;
    411       1.21   thorpej 	lesc->sc_isr.isr_arg = sc;
    412       1.21   thorpej 	lesc->sc_isr.isr_ipl = 2;
    413       1.21   thorpej 	add_isr(&lesc->sc_isr);
    414       1.26     veego }
    415       1.26     veego 
    416       1.26     veego 
    417       1.26     veego integrate void
    418       1.35   aymeric ariadne_copytodesc_word(struct lance_softc *sc, void *from, int boff, int len)
    419       1.26     veego {
    420       1.26     veego 	u_short *b1 = from;
    421       1.32      tron 	volatile u_short *b2 = (u_short *)((u_char *)sc->sc_mem + boff);
    422       1.26     veego 
    423       1.26     veego 	for (len >>= 1; len > 0; len--)
    424       1.26     veego 		*b2++ = ariadne_swapreg(*b1++);
    425       1.26     veego }
    426       1.26     veego 
    427       1.26     veego integrate void
    428       1.35   aymeric ariadne_copyfromdesc_word(struct lance_softc *sc, void *to, int boff, int len)
    429       1.26     veego {
    430       1.32      tron 	volatile u_short *b1 = (u_short *)((u_char *)sc->sc_mem + boff);
    431       1.26     veego 	u_short *b2 = to;
    432       1.26     veego 
    433       1.26     veego 	for (len >>= 1; len > 0; len--)
    434       1.26     veego 		*b2++ = ariadne_swapreg(*b1++);
    435       1.26     veego }
    436       1.26     veego 
    437       1.26     veego #define	isodd(n)	((n) & 1)
    438       1.26     veego 
    439       1.26     veego integrate void
    440       1.35   aymeric ariadne_copytobuf_word(struct lance_softc *sc, void *from, int boff, int len)
    441       1.26     veego {
    442       1.26     veego 	u_char *a1 = from;
    443       1.32      tron 	volatile u_char *a2 = (u_char *)sc->sc_mem + boff;
    444       1.26     veego 	u_short *b1;
    445       1.26     veego 	volatile u_short *b2;
    446       1.26     veego 	int i;
    447       1.26     veego 
    448       1.26     veego 	if (len > 0 && isodd(boff)) {
    449       1.28        is 		/* adjust source pointer */
    450       1.26     veego 		b1 = (u_short *)(a1 + 1);
    451       1.28        is 		/* compute aligned destination pointer */
    452       1.39       jmc 		b2 = (volatile u_short *)(a2 + 1);
    453       1.28        is 		/* copy first unaligned byte to buf */
    454       1.28        is 		b2[-1] = (b2[-1] & 0xff00) | *a1;
    455       1.26     veego 		--len;
    456       1.26     veego 	} else {
    457       1.28        is 		/* destination is aligned or length is zero */
    458       1.26     veego 		b1 = (u_short *)a1;
    459       1.39       jmc 		b2 = (volatile u_short *)a2;
    460       1.26     veego 	}
    461       1.26     veego 
    462       1.28        is 	/* copy full words with aligned destination */
    463       1.26     veego 	for (i = len >> 1; i > 0; i--)
    464       1.26     veego 		*b2++ = *b1++;
    465       1.26     veego 
    466       1.28        is 	/* copy remaining byte */
    467       1.26     veego 	if (isodd(len))
    468       1.28        is 		*b2 = (*b2 & 0x00ff) | (*(u_char *)b1) << 8;
    469       1.26     veego }
    470       1.26     veego 
    471       1.26     veego integrate void
    472       1.35   aymeric ariadne_copyfrombuf_word(struct lance_softc *sc, void *to, int boff, int len)
    473       1.26     veego {
    474       1.32      tron 	volatile u_char *a1 = (u_char *)sc->sc_mem + boff;
    475       1.26     veego 	u_char *a2 = to;
    476       1.26     veego 	volatile u_short *b1;
    477       1.26     veego 	u_short *b2;
    478       1.26     veego 	int i;
    479       1.26     veego 
    480       1.26     veego 	if (len > 0 && isodd(boff)) {
    481       1.28        is 		/* compute aligned source pointer */
    482       1.39       jmc 		b1  = (volatile u_short *)(a1 + 1);
    483       1.28        is 		/* adjust destination pointer (possibly unaligned) */
    484       1.28        is 		b2  = (u_short *)(a2 + 1);
    485       1.28        is 		/* copy first unaligned byte from buf */
    486       1.28        is 		*a2 = b1[-1];
    487       1.26     veego 		--len;
    488       1.26     veego 	} else {
    489       1.28        is 		/* source is aligned or length is zero */
    490       1.39       jmc 		b1 = (volatile u_short *)a1;
    491       1.26     veego 		b2 = (u_short *)a2;
    492       1.26     veego 	}
    493       1.26     veego 
    494       1.28        is 	/* copy full words with aligned source */
    495       1.26     veego 	for (i = len >> 1; i > 0; i--)
    496       1.26     veego 		*b2++ = *b1++;
    497       1.26     veego 
    498       1.28        is 	/* copy remaining byte */
    499       1.26     veego 	if (isodd(len))
    500       1.28        is 		*(u_char *)b2 = *b1 >> 8;
    501       1.26     veego }
    502       1.26     veego 
    503       1.26     veego integrate void
    504       1.35   aymeric ariadne_zerobuf_word(struct lance_softc *sc, int boff, int len)
    505       1.26     veego {
    506       1.32      tron 	volatile u_char *a1 = (u_char *)sc->sc_mem + boff;
    507       1.26     veego 	volatile u_short *b1;
    508       1.26     veego 	int i;
    509       1.26     veego 
    510       1.26     veego 	if (len > 0 && isodd(boff)) {
    511       1.39       jmc 		b1 = (volatile u_short *)(a1 + 1);
    512       1.26     veego 		b1[-1] &= 0xff00;
    513       1.26     veego 		--len;
    514       1.26     veego 	} else {
    515       1.39       jmc 		b1 = (volatile u_short *)a1;
    516       1.26     veego 	}
    517       1.35   aymeric 
    518       1.26     veego 	for (i = len >> 1; i > 0; i--)
    519       1.26     veego 		*b1++ = 0;
    520       1.26     veego 
    521       1.26     veego 	if (isodd(len))
    522       1.26     veego 		*b1 &= 0x00ff;
    523        1.1        mw }
    524