Home | History | Annotate | Line # | Download | only in if
if_ze.c revision 1.1
      1  1.1  ragge /*      $NetBSD: if_ze.c,v 1.1 1999/08/08 11:45:02 ragge 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.1  ragge #include <sys/param.h>
     33  1.1  ragge #include <sys/socket.h>
     34  1.1  ragge #include <sys/device.h>
     35  1.1  ragge #include <sys/systm.h>
     36  1.1  ragge #include <sys/sockio.h>
     37  1.1  ragge 
     38  1.1  ragge #include <net/if.h>
     39  1.1  ragge #include <net/if_ether.h>
     40  1.1  ragge #include <net/if_dl.h>
     41  1.1  ragge 
     42  1.1  ragge #include <netinet/in.h>
     43  1.1  ragge #include <netinet/if_inarp.h>
     44  1.1  ragge 
     45  1.1  ragge #if NBPFILTER > 0
     46  1.1  ragge #include <net/bpf.h>
     47  1.1  ragge #include <net/bpfdesc.h>
     48  1.1  ragge #endif
     49  1.1  ragge 
     50  1.1  ragge #include <machine/bus.h>
     51  1.1  ragge #include <machine/nexus.h>
     52  1.1  ragge #include <machine/cpu.h>
     53  1.1  ragge #include <machine/scb.h>
     54  1.1  ragge 
     55  1.1  ragge #include <dev/ic/sgecreg.h>
     56  1.1  ragge #include <dev/ic/sgecvar.h>
     57  1.1  ragge 
     58  1.1  ragge #include "ioconf.h"
     59  1.1  ragge /*
     60  1.1  ragge  * Adresses.
     61  1.1  ragge  */
     62  1.1  ragge #define SGECADDR        0x20008000
     63  1.1  ragge #define NISA_ROM        0x20084000
     64  1.1  ragge #define	SGECVEC		0x108
     65  1.1  ragge 
     66  1.1  ragge static	int	zematch __P((struct device *, struct cfdata *, void *));
     67  1.1  ragge static	void	zeattach __P((struct device *, struct device *, void *));
     68  1.1  ragge static	void	zeintr __P((int));
     69  1.1  ragge 
     70  1.1  ragge struct	cfattach ze_ca = {
     71  1.1  ragge 	sizeof(struct ze_softc), zematch, zeattach
     72  1.1  ragge };
     73  1.1  ragge 
     74  1.1  ragge /*
     75  1.1  ragge  * Check for present SGEC.
     76  1.1  ragge  */
     77  1.1  ragge int
     78  1.1  ragge zematch(parent, cf, aux)
     79  1.1  ragge 	struct	device *parent;
     80  1.1  ragge 	struct	cfdata *cf;
     81  1.1  ragge 	void	*aux;
     82  1.1  ragge {
     83  1.1  ragge 	struct bp_conf *bp = aux;
     84  1.1  ragge 
     85  1.1  ragge 	/*
     86  1.1  ragge 	 * Should some more intelligent checking be done???
     87  1.1  ragge 	 */
     88  1.1  ragge 	if (strcmp(bp->type, "sgec") == 0)
     89  1.1  ragge 		return 1;
     90  1.1  ragge 	return 0;
     91  1.1  ragge }
     92  1.1  ragge 
     93  1.1  ragge /*
     94  1.1  ragge  * Interface exists: make available by filling in network interface
     95  1.1  ragge  * record.  System will initialize the interface when it is ready
     96  1.1  ragge  * to accept packets.
     97  1.1  ragge  */
     98  1.1  ragge void
     99  1.1  ragge zeattach(parent, self, aux)
    100  1.1  ragge 	struct	device *parent, *self;
    101  1.1  ragge 	void	*aux;
    102  1.1  ragge {
    103  1.1  ragge 	extern struct vax_bus_dma_tag vax_bus_dma_tag;
    104  1.1  ragge 	struct	ze_softc *sc = (struct ze_softc *)self;
    105  1.1  ragge 	int *ea, i;
    106  1.1  ragge 
    107  1.1  ragge 	/*
    108  1.1  ragge 	 * Map in SGEC registers.
    109  1.1  ragge 	 */
    110  1.1  ragge 	sc->sc_ioh = vax_map_physmem(SGECADDR, 1);
    111  1.1  ragge 	sc->sc_iot = 0; /* :-) */
    112  1.1  ragge 	sc->sc_dmat = &vax_bus_dma_tag;
    113  1.1  ragge 
    114  1.1  ragge 	sc->sc_intvec = SGECVEC;
    115  1.1  ragge 
    116  1.1  ragge 	/*
    117  1.1  ragge 	 * Map in, read and release ethernet rom address.
    118  1.1  ragge 	 */
    119  1.1  ragge 	ea = (int *)vax_map_physmem(NISA_ROM, 1);
    120  1.1  ragge 	for (i = 0; i < ETHER_ADDR_LEN; i++)
    121  1.1  ragge 		sc->sc_enaddr[i] = (ea[i] >> 8) & 0377;
    122  1.1  ragge 	vax_unmap_physmem((vaddr_t)ea, 1);
    123  1.1  ragge 
    124  1.1  ragge 	scb_vecalloc(SGECVEC, zeintr, sc->sc_dev.dv_unit, SCB_ISTACK);
    125  1.1  ragge 
    126  1.1  ragge 	sgec_attach(sc);
    127  1.1  ragge }
    128  1.1  ragge 
    129  1.1  ragge void
    130  1.1  ragge zeintr(unit)
    131  1.1  ragge 	int	unit;
    132  1.1  ragge {
    133  1.1  ragge 	struct ze_softc *sc = ze_cd.cd_devs[unit];
    134  1.1  ragge 
    135  1.1  ragge 	sgec_intr(sc);
    136  1.1  ragge }
    137