Home | History | Annotate | Line # | Download | only in if
if_ze.c revision 1.9
      1  1.9  thorpej /*      $NetBSD: if_ze.c,v 1.9 2002/10/02 16:02:32 thorpej Exp $ */
      2  1.1    ragge /*
      3  1.1    ragge  * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
      4  1.1    ragge  *
      5  1.1    ragge  * Redistribution and use in source and binary forms, with or without
      6  1.1    ragge  * modification, are permitted provided that the following conditions
      7  1.1    ragge  * are met:
      8  1.1    ragge  * 1. Redistributions of source code must retain the above copyright
      9  1.1    ragge  *    notice, this list of conditions and the following disclaimer.
     10  1.1    ragge  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1    ragge  *    notice, this list of conditions and the following disclaimer in the
     12  1.1    ragge  *    documentation and/or other materials provided with the distribution.
     13  1.1    ragge  * 3. All advertising materials mentioning features or use of this software
     14  1.1    ragge  *    must display the following acknowledgement:
     15  1.1    ragge  *      This product includes software developed at Ludd, University of
     16  1.1    ragge  *      Lule}, Sweden and its contributors.
     17  1.1    ragge  * 4. The name of the author may not be used to endorse or promote products
     18  1.1    ragge  *    derived from this software without specific prior written permission
     19  1.1    ragge  *
     20  1.1    ragge  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.1    ragge  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.1    ragge  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.1    ragge  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.1    ragge  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.1    ragge  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.1    ragge  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.1    ragge  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.1    ragge  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.1    ragge  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  1.1    ragge  */
     31  1.1    ragge 
     32  1.6    ragge #include "opt_cputype.h"
     33  1.6    ragge 
     34  1.1    ragge #include <sys/param.h>
     35  1.1    ragge #include <sys/socket.h>
     36  1.1    ragge #include <sys/device.h>
     37  1.1    ragge #include <sys/systm.h>
     38  1.1    ragge #include <sys/sockio.h>
     39  1.1    ragge 
     40  1.1    ragge #include <net/if.h>
     41  1.1    ragge #include <net/if_ether.h>
     42  1.1    ragge #include <net/if_dl.h>
     43  1.1    ragge 
     44  1.1    ragge #include <netinet/in.h>
     45  1.1    ragge #include <netinet/if_inarp.h>
     46  1.1    ragge 
     47  1.1    ragge #if NBPFILTER > 0
     48  1.1    ragge #include <net/bpf.h>
     49  1.1    ragge #include <net/bpfdesc.h>
     50  1.1    ragge #endif
     51  1.1    ragge 
     52  1.1    ragge #include <machine/bus.h>
     53  1.1    ragge #include <machine/nexus.h>
     54  1.1    ragge #include <machine/cpu.h>
     55  1.1    ragge #include <machine/scb.h>
     56  1.4    ragge #include <machine/sid.h>
     57  1.1    ragge 
     58  1.1    ragge #include <dev/ic/sgecreg.h>
     59  1.1    ragge #include <dev/ic/sgecvar.h>
     60  1.1    ragge 
     61  1.1    ragge #include "ioconf.h"
     62  1.1    ragge /*
     63  1.1    ragge  * Adresses.
     64  1.1    ragge  */
     65  1.1    ragge #define SGECADDR        0x20008000
     66  1.1    ragge #define NISA_ROM        0x20084000
     67  1.6    ragge #define NISA_ROM_VXT    0x200c4000
     68  1.1    ragge #define	SGECVEC		0x108
     69  1.1    ragge 
     70  1.1    ragge static	int	zematch __P((struct device *, struct cfdata *, void *));
     71  1.1    ragge static	void	zeattach __P((struct device *, struct device *, void *));
     72  1.1    ragge 
     73  1.8  thorpej CFATTACH_DECL(ze_ibus, sizeof(struct ze_softc),
     74  1.9  thorpej     zematch, zeattach, NULL, NULL);
     75  1.1    ragge 
     76  1.1    ragge /*
     77  1.1    ragge  * Check for present SGEC.
     78  1.1    ragge  */
     79  1.1    ragge int
     80  1.1    ragge zematch(parent, cf, aux)
     81  1.1    ragge 	struct	device *parent;
     82  1.1    ragge 	struct	cfdata *cf;
     83  1.1    ragge 	void	*aux;
     84  1.1    ragge {
     85  1.1    ragge 	struct bp_conf *bp = aux;
     86  1.1    ragge 
     87  1.1    ragge 	/*
     88  1.1    ragge 	 * Should some more intelligent checking be done???
     89  1.1    ragge 	 */
     90  1.1    ragge 	if (strcmp(bp->type, "sgec") == 0)
     91  1.1    ragge 		return 1;
     92  1.1    ragge 	return 0;
     93  1.1    ragge }
     94  1.1    ragge 
     95  1.1    ragge /*
     96  1.1    ragge  * Interface exists: make available by filling in network interface
     97  1.1    ragge  * record.  System will initialize the interface when it is ready
     98  1.1    ragge  * to accept packets.
     99  1.1    ragge  */
    100  1.1    ragge void
    101  1.1    ragge zeattach(parent, self, aux)
    102  1.1    ragge 	struct	device *parent, *self;
    103  1.1    ragge 	void	*aux;
    104  1.1    ragge {
    105  1.1    ragge 	extern struct vax_bus_dma_tag vax_bus_dma_tag;
    106  1.1    ragge 	struct	ze_softc *sc = (struct ze_softc *)self;
    107  1.6    ragge 	paddr_t nisarom;
    108  1.1    ragge 	int *ea, i;
    109  1.1    ragge 
    110  1.1    ragge 	/*
    111  1.1    ragge 	 * Map in SGEC registers.
    112  1.1    ragge 	 */
    113  1.1    ragge 	sc->sc_ioh = vax_map_physmem(SGECADDR, 1);
    114  1.1    ragge 	sc->sc_iot = 0; /* :-) */
    115  1.1    ragge 	sc->sc_dmat = &vax_bus_dma_tag;
    116  1.1    ragge 
    117  1.1    ragge 	sc->sc_intvec = SGECVEC;
    118  1.1    ragge 
    119  1.1    ragge 	/*
    120  1.1    ragge 	 * Map in, read and release ethernet rom address.
    121  1.1    ragge 	 */
    122  1.6    ragge 	nisarom = (vax_boardtype == VAX_BTYP_VXT ? NISA_ROM_VXT : NISA_ROM);
    123  1.6    ragge 	ea = (int *)vax_map_physmem(nisarom, 1);
    124  1.6    ragge 	for (i = 0; i < ETHER_ADDR_LEN; i++) {
    125  1.4    ragge 		if (vax_boardtype == VAX_BTYP_660)
    126  1.4    ragge 			sc->sc_enaddr[i] = (ea[i] >> 24) & 0377;
    127  1.6    ragge #if VXT2000 || VAXANY
    128  1.6    ragge 		else if (vax_boardtype == VAX_BTYP_VXT)
    129  1.6    ragge 			sc->sc_enaddr[i] = ea[i] & 0377;
    130  1.6    ragge #endif
    131  1.4    ragge 		else
    132  1.4    ragge 			sc->sc_enaddr[i] = (ea[i] >> 8) & 0377;
    133  1.6    ragge 	}
    134  1.1    ragge 	vax_unmap_physmem((vaddr_t)ea, 1);
    135  1.1    ragge 
    136  1.6    ragge #if VXT2000 || VAXANY
    137  1.6    ragge 	if (vax_boardtype == VAX_BTYP_VXT)
    138  1.6    ragge 		scb_vecalloc(0x200, (void (*)(void *)) sgec_intr, sc,
    139  1.6    ragge 		    SCB_ISTACK, &sc->sc_intrcnt);
    140  1.6    ragge 	else
    141  1.6    ragge #endif
    142  1.6    ragge 		scb_vecalloc(SGECVEC, (void (*)(void *)) sgec_intr, sc,
    143  1.6    ragge 		    SCB_ISTACK, &sc->sc_intrcnt);
    144  1.1    ragge 
    145  1.1    ragge 	sgec_attach(sc);
    146  1.1    ragge }
    147