Home | History | Annotate | Line # | Download | only in nubus
if_ae_nubus.c revision 1.23
      1  1.23   briggs /*	$NetBSD: if_ae_nubus.c,v 1.23 1997/10/17 00:24:47 briggs Exp $	*/
      2   1.1   scottr 
      3   1.1   scottr /*
      4   1.1   scottr  * Copyright (C) 1997 Scott Reynolds
      5   1.1   scottr  * All rights reserved.
      6   1.1   scottr  *
      7   1.1   scottr  * Redistribution and use in source and binary forms, with or without
      8   1.1   scottr  * modification, are permitted provided that the following conditions
      9   1.1   scottr  * are met:
     10   1.1   scottr  * 1. Redistributions of source code must retain the above copyright
     11   1.1   scottr  *    notice, this list of conditions and the following disclaimer.
     12   1.1   scottr  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1   scottr  *    notice, this list of conditions and the following disclaimer in the
     14   1.1   scottr  *    documentation and/or other materials provided with the distribution.
     15  1.21   scottr  * 3. The name of the author may not be used to endorse or promote products
     16   1.1   scottr  *    derived from this software without specific prior written permission.
     17   1.1   scottr  *
     18   1.1   scottr  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19   1.1   scottr  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20   1.1   scottr  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21   1.1   scottr  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22   1.1   scottr  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23   1.1   scottr  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24   1.1   scottr  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25   1.1   scottr  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26   1.1   scottr  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27   1.1   scottr  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28   1.1   scottr  */
     29  1.11   scottr /*
     30  1.11   scottr  * Some parts are derived from code adapted for MacBSD by Brad Parker
     31  1.11   scottr  * <brad (at) fcr.com>.
     32  1.11   scottr  *
     33  1.11   scottr  * Currently supports:
     34  1.11   scottr  *	Apple NB Ethernet Card
     35  1.11   scottr  *	Apple NB Ethernet Card II
     36  1.11   scottr  *	Interlan A310 NuBus Ethernet card
     37  1.11   scottr  *	Cayman Systems GatorCard
     38  1.11   scottr  *	Asante MacCon II/E
     39  1.11   scottr  *	Kinetics EtherPort SE/30
     40  1.11   scottr  */
     41   1.1   scottr 
     42   1.1   scottr #include <sys/param.h>
     43   1.1   scottr #include <sys/device.h>
     44   1.1   scottr #include <sys/errno.h>
     45   1.1   scottr #include <sys/ioctl.h>
     46  1.14   scottr #include <sys/malloc.h>
     47   1.1   scottr #include <sys/socket.h>
     48   1.4   scottr #include <sys/syslog.h>
     49   1.1   scottr #include <sys/systm.h>
     50   1.1   scottr 
     51   1.1   scottr #include <net/if.h>
     52   1.7       is #include <net/if_ether.h>
     53   1.1   scottr 
     54   1.1   scottr #include <machine/bus.h>
     55   1.1   scottr #include <machine/viareg.h>
     56   1.1   scottr 
     57   1.1   scottr #include <dev/ic/dp8390reg.h>
     58  1.14   scottr #include <dev/ic/dp8390var.h>
     59  1.19   scottr #include <mac68k/dev/nubus.h>
     60  1.19   scottr #include <mac68k/dev/if_aevar.h>
     61  1.19   scottr #include <mac68k/dev/if_aereg.h>
     62   1.1   scottr 
     63   1.1   scottr static int	ae_nubus_match __P((struct device *, struct cfdata *, void *));
     64   1.1   scottr static void	ae_nubus_attach __P((struct device *, struct device *, void *));
     65  1.18   scottr static int	ae_nb_card_vendor __P((bus_space_tag_t, bus_space_handle_t,
     66  1.18   scottr 		    struct nubus_attach_args *));
     67  1.18   scottr static int	ae_nb_get_enaddr __P((bus_space_tag_t, bus_space_handle_t,
     68  1.18   scottr 		    struct nubus_attach_args *, u_int8_t *));
     69  1.11   scottr #ifdef DEBUG
     70   1.4   scottr static void	ae_nb_watchdog __P((struct ifnet *));
     71  1.11   scottr #endif
     72   1.1   scottr 
     73  1.22  thorpej void		ae_nubus_intr __P((void *, int));
     74  1.22  thorpej 
     75   1.1   scottr struct cfattach ae_nubus_ca = {
     76  1.14   scottr 	sizeof(struct dp8390_softc), ae_nubus_match, ae_nubus_attach
     77   1.1   scottr };
     78   1.1   scottr 
     79   1.1   scottr static int
     80   1.1   scottr ae_nubus_match(parent, cf, aux)
     81   1.1   scottr 	struct device *parent;
     82   1.1   scottr 	struct cfdata *cf;
     83   1.1   scottr 	void *aux;
     84   1.1   scottr {
     85  1.14   scottr 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
     86   1.1   scottr 	bus_space_handle_t bsh;
     87   1.1   scottr 	int rv;
     88   1.1   scottr 
     89   1.1   scottr 	if (bus_space_map(na->na_tag, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
     90   1.1   scottr 	    0, &bsh))
     91   1.1   scottr 		return (0);
     92   1.1   scottr 
     93   1.1   scottr 	rv = 0;
     94   1.1   scottr 
     95   1.1   scottr 	if (na->category == NUBUS_CATEGORY_NETWORK &&
     96   1.1   scottr 	    na->type == NUBUS_TYPE_ETHERNET) {
     97  1.18   scottr 		switch (ae_nb_card_vendor(na->na_tag, bsh, na)) {
     98  1.14   scottr 		case DP8390_VENDOR_APPLE:
     99  1.14   scottr 		case DP8390_VENDOR_ASANTE:
    100  1.14   scottr 		case DP8390_VENDOR_FARALLON:
    101  1.14   scottr 		case DP8390_VENDOR_INTERLAN:
    102  1.14   scottr 		case DP8390_VENDOR_KINETICS:
    103   1.1   scottr 			rv = 1;
    104   1.1   scottr 			break;
    105  1.14   scottr 		case DP8390_VENDOR_DAYNA:
    106  1.14   scottr 		case DP8390_VENDOR_FOCUS:
    107   1.1   scottr 			rv = UNSUPP;
    108   1.1   scottr 			break;
    109   1.1   scottr 		default:
    110   1.1   scottr 			break;
    111   1.1   scottr 		}
    112   1.1   scottr 	}
    113   1.1   scottr 
    114   1.1   scottr 	bus_space_unmap(na->na_tag, bsh, NBMEMSIZE);
    115   1.1   scottr 
    116   1.1   scottr 	return rv;
    117   1.1   scottr }
    118   1.1   scottr 
    119   1.1   scottr /*
    120   1.1   scottr  * Install interface into kernel networking data structures
    121   1.1   scottr  */
    122   1.1   scottr static void
    123   1.1   scottr ae_nubus_attach(parent, self, aux)
    124   1.1   scottr 	struct device *parent, *self;
    125   1.1   scottr 	void   *aux;
    126   1.1   scottr {
    127  1.14   scottr 	struct dp8390_softc *sc = (struct dp8390_softc *)self;
    128  1.14   scottr 	struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
    129  1.11   scottr #ifdef DEBUG
    130   1.7       is 	struct ifnet *ifp = &sc->sc_ec.ec_if;
    131  1.11   scottr #endif
    132   1.1   scottr 	bus_space_tag_t bst;
    133   1.1   scottr 	bus_space_handle_t bsh;
    134  1.11   scottr 	int i, success;
    135  1.14   scottr 	char *cardtype;
    136   1.1   scottr 
    137   1.1   scottr 	bst = na->na_tag;
    138   1.1   scottr 	if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
    139   1.1   scottr 	    0, &bsh)) {
    140   1.1   scottr 		printf(": can't map memory space\n");
    141   1.1   scottr 		return;
    142   1.1   scottr 	}
    143   1.1   scottr 
    144   1.4   scottr 	sc->sc_regt = sc->sc_buft = bst;
    145   1.3   scottr 	sc->sc_flags = self->dv_cfdata->cf_flags;
    146  1.14   scottr 
    147  1.18   scottr 	cardtype = nubus_get_card_name(bst, bsh, na->fmt);
    148  1.14   scottr 
    149  1.14   scottr 	sc->is790 = 0;
    150  1.14   scottr 
    151  1.14   scottr 	sc->mem_start = 0;
    152   1.1   scottr 	sc->mem_size = 0;
    153   1.1   scottr 
    154   1.1   scottr 	success = 0;
    155   1.1   scottr 
    156  1.23   briggs 	switch (ae_nb_card_vendor(bst, bsh, na)) {
    157  1.14   scottr 	case DP8390_VENDOR_APPLE:	/* Apple-compatible cards */
    158  1.14   scottr 	case DP8390_VENDOR_ASANTE:
    159  1.11   scottr 		/* Map register offsets */
    160  1.11   scottr 		for (i = 0; i < 16; i++) /* reverse order, longword aligned */
    161  1.11   scottr 			sc->sc_reg_map[i] = (15 - i) << 2;
    162  1.11   scottr 
    163  1.16   scottr 		sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
    164   1.1   scottr 		if (bus_space_subregion(bst, bsh,
    165   1.4   scottr 		    AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
    166   1.1   scottr 			printf(": failed to map register space\n");
    167   1.1   scottr 			break;
    168   1.1   scottr 		}
    169   1.1   scottr 		if ((sc->mem_size = ae_size_card_memory(bst, bsh,
    170   1.1   scottr 		    AE_DATA_OFFSET)) == 0) {
    171   1.1   scottr 			printf(": failed to determine size of RAM.\n");
    172   1.1   scottr 			break;
    173   1.1   scottr 		}
    174   1.1   scottr 		if (bus_space_subregion(bst, bsh,
    175   1.4   scottr 		    AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
    176   1.1   scottr 			printf(": failed to map register space\n");
    177   1.1   scottr 			break;
    178   1.1   scottr 		}
    179   1.3   scottr #ifdef AE_OLD_GET_ENADDR
    180   1.1   scottr 		/* Get station address from on-board ROM */
    181   1.1   scottr 		for (i = 0; i < ETHER_ADDR_LEN; ++i)
    182  1.14   scottr 			sc->sc_enaddr[i] =
    183   1.1   scottr 			    bus_space_read_1(bst, bsh, (AE_ROM_OFFSET + i * 2));
    184   1.3   scottr #else
    185  1.18   scottr 		if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
    186   1.3   scottr 			printf(": can't find MAC address\n");
    187   1.3   scottr 			break;
    188   1.3   scottr 		}
    189   1.3   scottr #endif
    190   1.1   scottr 
    191   1.1   scottr 		success = 1;
    192   1.1   scottr 		break;
    193   1.1   scottr 
    194  1.14   scottr 	case DP8390_VENDOR_DAYNA:
    195  1.11   scottr 		/* Map register offsets */
    196  1.11   scottr 		for (i = 0; i < 16; i++) /* normal order, longword aligned */
    197  1.11   scottr 			sc->sc_reg_map[i] = i << 2;
    198  1.11   scottr 
    199  1.16   scottr 		sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
    200   1.1   scottr 		if (bus_space_subregion(bst, bsh,
    201   1.4   scottr 		    DP_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
    202   1.1   scottr 			printf(": failed to map register space\n");
    203   1.1   scottr 			break;
    204   1.1   scottr 		}
    205   1.1   scottr 		sc->mem_size = 8192;
    206   1.1   scottr 		if (bus_space_subregion(bst, bsh,
    207   1.4   scottr 		    DP_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
    208   1.1   scottr 			printf(": failed to map register space\n");
    209   1.1   scottr 			break;
    210   1.1   scottr 		}
    211   1.3   scottr #ifdef AE_OLD_GET_ENADDR
    212   1.1   scottr 		/* Get station address from on-board ROM */
    213   1.1   scottr 		for (i = 0; i < ETHER_ADDR_LEN; ++i)
    214  1.14   scottr 			sc->sc_enaddr[i] =
    215   1.1   scottr 			    bus_space_read_1(bst, bsh, (DP_ROM_OFFSET + i * 2));
    216   1.3   scottr #else
    217  1.18   scottr 		if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
    218   1.3   scottr 			printf(": can't find MAC address\n");
    219   1.3   scottr 			break;
    220   1.3   scottr 		}
    221   1.3   scottr #endif
    222   1.1   scottr 
    223   1.1   scottr 		printf(": unsupported Dayna hardware\n");
    224   1.1   scottr 		break;
    225   1.1   scottr 
    226  1.14   scottr 	case DP8390_VENDOR_FARALLON:
    227  1.11   scottr 		/* Map register offsets */
    228  1.11   scottr 		for (i = 0; i < 16; i++) /* reverse order, longword aligned */
    229  1.11   scottr 			sc->sc_reg_map[i] = (15 - i) << 2;
    230  1.11   scottr 
    231  1.16   scottr 		sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
    232   1.1   scottr 		if (bus_space_subregion(bst, bsh,
    233   1.4   scottr 		    AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
    234   1.1   scottr 			printf(": failed to map register space\n");
    235   1.1   scottr 			break;
    236   1.1   scottr 		}
    237   1.1   scottr 		if ((sc->mem_size = ae_size_card_memory(bst, bsh,
    238   1.1   scottr 		    AE_DATA_OFFSET)) == 0) {
    239   1.1   scottr 			printf(": failed to determine size of RAM.\n");
    240   1.1   scottr 			break;
    241   1.1   scottr 		}
    242   1.1   scottr 		if (bus_space_subregion(bst, bsh,
    243   1.4   scottr 		    AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
    244   1.1   scottr 			printf(": failed to map register space\n");
    245   1.1   scottr 			break;
    246   1.1   scottr 		}
    247   1.3   scottr #ifdef AE_OLD_GET_ENADDR
    248   1.1   scottr 		/* Get station address from on-board ROM */
    249   1.1   scottr 		for (i = 0; i < ETHER_ADDR_LEN; ++i)
    250  1.14   scottr 			sc->sc_enaddr[i] =
    251   1.1   scottr 			    bus_space_read_1(bst, bsh, (FE_ROM_OFFSET + i));
    252   1.6   scottr #else
    253  1.18   scottr 		if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
    254   1.6   scottr 			printf(": can't find MAC address\n");
    255   1.6   scottr 			break;
    256   1.6   scottr 		}
    257   1.3   scottr #endif
    258   1.1   scottr 
    259   1.1   scottr 		success = 1;
    260   1.1   scottr 		break;
    261   1.1   scottr 
    262  1.14   scottr 	case DP8390_VENDOR_FOCUS:
    263   1.1   scottr 		printf(": unsupported Focus hardware\n");
    264   1.1   scottr 		break;
    265   1.1   scottr 
    266  1.14   scottr 	case DP8390_VENDOR_INTERLAN:
    267  1.11   scottr 		/* Map register offsets */
    268  1.11   scottr 		for (i = 0; i < 16; i++) /* normal order, longword aligned */
    269  1.11   scottr 			sc->sc_reg_map[i] = i << 2;
    270  1.11   scottr 
    271  1.16   scottr 		sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
    272   1.2   scottr 		if (bus_space_subregion(bst, bsh,
    273   1.4   scottr 		    GC_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
    274   1.2   scottr 			printf(": failed to map register space\n");
    275   1.2   scottr 			break;
    276   1.2   scottr 		}
    277   1.2   scottr 		if ((sc->mem_size = ae_size_card_memory(bst, bsh,
    278   1.3   scottr 		    GC_DATA_OFFSET)) == 0) {
    279   1.2   scottr 			printf(": failed to determine size of RAM.\n");
    280   1.2   scottr 			break;
    281   1.2   scottr 		}
    282   1.2   scottr 		if (bus_space_subregion(bst, bsh,
    283   1.4   scottr 		    GC_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
    284   1.2   scottr 			printf(": failed to map register space\n");
    285   1.2   scottr 			break;
    286   1.2   scottr 		}
    287   1.2   scottr 
    288   1.3   scottr 		/* reset the NIC chip */
    289   1.3   scottr 		bus_space_write_1(bst, bsh, GC_RESET_OFFSET, 0);
    290   1.3   scottr 
    291  1.18   scottr 		if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
    292   1.9   scottr 			/* Fall back to snarf directly from ROM.  Ick. */
    293   1.9   scottr 			for (i = 0; i < ETHER_ADDR_LEN; ++i)
    294  1.14   scottr 				sc->sc_enaddr[i] =
    295   1.9   scottr 				    bus_space_read_1(bst, bsh,
    296   1.9   scottr 				    (GC_ROM_OFFSET + i * 4));
    297   1.2   scottr 		}
    298   1.2   scottr 
    299   1.2   scottr 		success = 1;
    300   1.2   scottr 		break;
    301   1.2   scottr 
    302  1.14   scottr 	case DP8390_VENDOR_KINETICS:
    303  1.11   scottr 		/* Map register offsets */
    304  1.11   scottr 		for (i = 0; i < 16; i++) /* normal order, longword aligned */
    305  1.11   scottr 			sc->sc_reg_map[i] = i << 2;
    306  1.11   scottr 
    307   1.3   scottr 		if (bus_space_subregion(bst, bsh,
    308   1.4   scottr 		    KE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
    309   1.3   scottr 			printf(": failed to map register space\n");
    310   1.3   scottr 			break;
    311   1.3   scottr 		}
    312   1.3   scottr 		if ((sc->mem_size = ae_size_card_memory(bst, bsh,
    313   1.3   scottr 		    KE_DATA_OFFSET)) == 0) {
    314   1.3   scottr 			printf(": failed to determine size of RAM.\n");
    315   1.3   scottr 			break;
    316   1.3   scottr 		}
    317   1.3   scottr 		if (bus_space_subregion(bst, bsh,
    318   1.4   scottr 		    KE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
    319   1.3   scottr 			printf(": failed to map register space\n");
    320   1.3   scottr 			break;
    321   1.3   scottr 		}
    322  1.18   scottr 		if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_enaddr)) {
    323   1.3   scottr 			printf(": can't find MAC address\n");
    324   1.3   scottr 			break;
    325   1.3   scottr 		}
    326   1.3   scottr 
    327   1.3   scottr 		success = 1;
    328   1.3   scottr 		break;
    329   1.3   scottr 
    330   1.1   scottr 	default:
    331   1.1   scottr 		break;
    332   1.1   scottr 	}
    333   1.1   scottr 
    334   1.1   scottr 	if (!success) {
    335   1.1   scottr 		bus_space_unmap(bst, bsh, NBMEMSIZE);
    336   1.1   scottr 		return;
    337   1.1   scottr 	}
    338   1.1   scottr 
    339  1.14   scottr 	/*
    340  1.14   scottr 	 * Override test_mem and write_mbuf functions; other defaults
    341  1.14   scottr 	 * already work properly.
    342  1.14   scottr 	 */
    343  1.14   scottr 	sc->test_mem = ae_test_mem;
    344  1.14   scottr 	sc->write_mbuf = ae_write_mbuf;
    345  1.11   scottr #ifdef DEBUG
    346   1.4   scottr 	ifp->if_watchdog = ae_nb_watchdog;	/* Override watchdog */
    347  1.11   scottr #endif
    348  1.14   scottr 
    349  1.22  thorpej 	/* Interface is always enabled. */
    350  1.22  thorpej 	sc->sc_enabled = 1;
    351  1.22  thorpej 
    352  1.23   briggs 	printf(": %s, %dKB memory\n", cardtype, sc->mem_size / 1024);
    353  1.22  thorpej 
    354  1.14   scottr 	if (dp8390_config(sc)) {
    355   1.5   scottr 		bus_space_unmap(bst, bsh, NBMEMSIZE);
    356   1.5   scottr 		return;
    357   1.5   scottr 	}
    358   1.1   scottr 
    359  1.22  thorpej 	/* make sure interrupts are vectored to us */
    360  1.22  thorpej 	add_nubus_intr(na->slot, ae_nubus_intr, sc);
    361  1.22  thorpej }
    362  1.22  thorpej 
    363  1.22  thorpej /* ARGSUSED */
    364  1.22  thorpej void
    365  1.22  thorpej ae_nubus_intr(arg, slot)
    366  1.22  thorpej 	void *arg;
    367  1.22  thorpej 	int slot;
    368  1.22  thorpej {
    369  1.23   briggs 	struct dp8390_softc *sc = (struct dp8390_softc *)arg;
    370  1.23   briggs 
    371  1.22  thorpej 	(void) dp8390_intr(sc);
    372   1.1   scottr }
    373   1.1   scottr 
    374   1.1   scottr static int
    375  1.18   scottr ae_nb_card_vendor(bst, bsh, na)
    376  1.18   scottr 	bus_space_tag_t bst;
    377  1.18   scottr 	bus_space_handle_t bsh;
    378   1.1   scottr 	struct nubus_attach_args *na;
    379   1.1   scottr {
    380   1.1   scottr 	int vendor;
    381   1.1   scottr 
    382   1.1   scottr 	switch (na->drsw) {
    383   1.1   scottr 	case NUBUS_DRSW_3COM:
    384  1.12   briggs 		switch (na->drhw) {
    385  1.12   briggs 		case NUBUS_DRHW_APPLE_SN:
    386  1.17   briggs 		case NUBUS_DRHW_APPLE_SNT:
    387  1.14   scottr 			vendor = DP8390_VENDOR_UNKNOWN;
    388  1.12   briggs 			break;
    389  1.12   briggs 		default:
    390  1.14   scottr 			vendor = DP8390_VENDOR_APPLE;
    391  1.12   briggs 			break;
    392  1.12   briggs 		}
    393  1.12   briggs 		break;
    394   1.1   scottr 	case NUBUS_DRSW_APPLE:
    395  1.20   briggs 	case NUBUS_DRSW_DAYNA2:
    396   1.1   scottr 	case NUBUS_DRSW_TECHWORKS:
    397  1.14   scottr 		vendor = DP8390_VENDOR_APPLE;
    398   1.1   scottr 		break;
    399   1.1   scottr 	case NUBUS_DRSW_ASANTE:
    400  1.14   scottr 		vendor = DP8390_VENDOR_ASANTE;
    401   1.1   scottr 		break;
    402   1.1   scottr 	case NUBUS_DRSW_FARALLON:
    403  1.14   scottr 		vendor = DP8390_VENDOR_FARALLON;
    404   1.1   scottr 		break;
    405   1.1   scottr 	case NUBUS_DRSW_FOCUS:
    406  1.14   scottr 		vendor = DP8390_VENDOR_FOCUS;
    407   1.1   scottr 		break;
    408   1.1   scottr 	case NUBUS_DRSW_GATOR:
    409   1.1   scottr 		switch (na->drhw) {
    410   1.1   scottr 		default:
    411   1.1   scottr 		case NUBUS_DRHW_INTERLAN:
    412  1.14   scottr 			vendor = DP8390_VENDOR_INTERLAN;
    413   1.1   scottr 			break;
    414   1.1   scottr 		case NUBUS_DRHW_KINETICS:
    415  1.18   scottr 			if (strncmp(nubus_get_card_name(bst, bsh, na->fmt),
    416  1.18   scottr 			    "EtherPort", 9) == 0)
    417  1.14   scottr 				vendor = DP8390_VENDOR_KINETICS;
    418   1.2   scottr 			else
    419  1.14   scottr 				vendor = DP8390_VENDOR_DAYNA;
    420   1.1   scottr 			break;
    421   1.1   scottr 		}
    422   1.1   scottr 		break;
    423   1.1   scottr 	default:
    424  1.14   scottr 		vendor = DP8390_VENDOR_UNKNOWN;
    425   1.1   scottr 	}
    426   1.1   scottr 	return vendor;
    427   1.3   scottr }
    428   1.3   scottr 
    429   1.3   scottr static int
    430  1.18   scottr ae_nb_get_enaddr(bst, bsh, na, ep)
    431  1.18   scottr 	bus_space_tag_t bst;
    432  1.18   scottr 	bus_space_handle_t bsh;
    433   1.3   scottr 	struct nubus_attach_args *na;
    434   1.3   scottr 	u_int8_t *ep;
    435   1.3   scottr {
    436   1.3   scottr 	nubus_dir dir;
    437   1.3   scottr 	nubus_dirent dirent;
    438   1.3   scottr 
    439   1.3   scottr 	/*
    440   1.3   scottr 	 * XXX - note hardwired resource IDs here (0x80); these are
    441   1.3   scottr 	 * assumed to be used by all cards, but should be fixed when
    442   1.3   scottr 	 * we find out more about Ethernet card resources.
    443   1.3   scottr 	 */
    444   1.3   scottr 	nubus_get_main_dir(na->fmt, &dir);
    445  1.18   scottr 	if (nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x80, &dirent) <= 0)
    446   1.3   scottr 		return 1;
    447   1.3   scottr 	nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir);
    448  1.18   scottr 	if (nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x80, &dirent) <= 0)
    449   1.3   scottr 		return 1;
    450  1.18   scottr 	if (nubus_get_ind_data(bst, bsh,
    451  1.18   scottr 	    na->fmt, &dirent, ep, ETHER_ADDR_LEN) <= 0)
    452   1.3   scottr 		return 1;
    453   1.3   scottr 
    454   1.3   scottr 	return 0;
    455   1.4   scottr }
    456   1.4   scottr 
    457  1.11   scottr #ifdef DEBUG
    458   1.4   scottr static void
    459   1.4   scottr ae_nb_watchdog(ifp)
    460   1.4   scottr 	struct ifnet *ifp;
    461   1.4   scottr {
    462  1.14   scottr 	struct dp8390_softc *sc = ifp->if_softc;
    463   1.4   scottr 
    464   1.4   scottr /*
    465   1.4   scottr  * This is a kludge!  The via code seems to miss slot interrupts
    466   1.4   scottr  * sometimes.  This kludges around that by calling the handler
    467   1.4   scottr  * by hand if the watchdog is activated. -- XXX (akb)
    468   1.4   scottr  */
    469   1.4   scottr 	(*via2itab[1])((void *) 1);
    470   1.4   scottr 
    471   1.4   scottr 	log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
    472   1.7       is 	++ifp->if_oerrors;
    473   1.4   scottr 
    474  1.14   scottr 	dp8390_reset(sc);
    475   1.1   scottr }
    476  1.11   scottr #endif
    477