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