Home | History | Annotate | Line # | Download | only in dev
if_le.c revision 1.9.4.1
      1  1.9.4.1     chuck /*	$NetBSD: if_le.c,v 1.9.4.1 1996/05/29 05:16:23 chuck Exp $	*/
      2      1.1     chuck 
      3      1.1     chuck /*-
      4      1.2   mycroft  * Copyright (c) 1995 Charles M. Hannum.  All rights reserved.
      5      1.2   mycroft  * Copyright (c) 1992, 1993
      6      1.1     chuck  *	The Regents of the University of California.  All rights reserved.
      7      1.1     chuck  *
      8      1.2   mycroft  * This code is derived from software contributed to Berkeley by
      9      1.2   mycroft  * Ralph Campbell and Rick Macklem.
     10      1.2   mycroft  *
     11      1.1     chuck  * Redistribution and use in source and binary forms, with or without
     12      1.1     chuck  * modification, are permitted provided that the following conditions
     13      1.1     chuck  * are met:
     14      1.1     chuck  * 1. Redistributions of source code must retain the above copyright
     15      1.1     chuck  *    notice, this list of conditions and the following disclaimer.
     16      1.1     chuck  * 2. Redistributions in binary form must reproduce the above copyright
     17      1.1     chuck  *    notice, this list of conditions and the following disclaimer in the
     18      1.1     chuck  *    documentation and/or other materials provided with the distribution.
     19      1.1     chuck  * 3. All advertising materials mentioning features or use of this software
     20      1.1     chuck  *    must display the following acknowledgement:
     21      1.1     chuck  *	This product includes software developed by the University of
     22      1.1     chuck  *	California, Berkeley and its contributors.
     23      1.1     chuck  * 4. Neither the name of the University nor the names of its contributors
     24      1.1     chuck  *    may be used to endorse or promote products derived from this software
     25      1.1     chuck  *    without specific prior written permission.
     26      1.1     chuck  *
     27      1.1     chuck  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28      1.1     chuck  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29      1.1     chuck  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30      1.1     chuck  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31      1.1     chuck  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32      1.1     chuck  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33      1.1     chuck  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34      1.1     chuck  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35      1.1     chuck  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36      1.1     chuck  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37      1.1     chuck  * SUCH DAMAGE.
     38      1.1     chuck  *
     39      1.2   mycroft  *	@(#)if_le.c	8.2 (Berkeley) 11/16/93
     40      1.1     chuck  */
     41      1.1     chuck 
     42      1.1     chuck #include "bpfilter.h"
     43      1.1     chuck 
     44      1.1     chuck #include <sys/param.h>
     45      1.1     chuck #include <sys/systm.h>
     46      1.1     chuck #include <sys/mbuf.h>
     47      1.2   mycroft #include <sys/syslog.h>
     48      1.1     chuck #include <sys/socket.h>
     49      1.2   mycroft #include <sys/device.h>
     50      1.1     chuck 
     51      1.1     chuck #include <net/if.h>
     52      1.1     chuck 
     53      1.1     chuck #ifdef INET
     54      1.1     chuck #include <netinet/in.h>
     55      1.1     chuck #include <netinet/if_ether.h>
     56      1.1     chuck #endif
     57      1.1     chuck 
     58      1.2   mycroft #include <vm/vm.h>
     59      1.1     chuck 
     60  1.9.4.1     chuck #include <machine/autoconf.h>
     61      1.1     chuck #include <machine/cpu.h>
     62      1.1     chuck #include <machine/pmap.h>
     63      1.1     chuck 
     64      1.2   mycroft #include <mvme68k/dev/pccreg.h>
     65      1.7     chuck #include <mvme68k/dev/pccvar.h>
     66      1.7     chuck 
     67      1.2   mycroft #include <dev/ic/am7990reg.h>
     68      1.2   mycroft #include <dev/ic/am7990var.h>
     69      1.2   mycroft 
     70      1.8   thorpej #include <mvme68k/dev/if_lereg.h>
     71      1.8   thorpej #include <mvme68k/dev/if_levar.h>
     72      1.2   mycroft 
     73      1.7     chuck int	le_pcc_match __P((struct device *, void *, void *));
     74      1.7     chuck void	le_pcc_attach __P((struct device *, struct device *, void *));
     75      1.1     chuck 
     76      1.7     chuck struct cfattach le_pcc_ca = {
     77      1.7     chuck 	sizeof(struct le_softc), le_pcc_match, le_pcc_attach
     78      1.4   thorpej };
     79      1.4   thorpej 
     80      1.8   thorpej hide void le_pcc_wrcsr __P((struct am7990_softc *, u_int16_t, u_int16_t));
     81      1.8   thorpej hide u_int16_t le_pcc_rdcsr __P((struct am7990_softc *, u_int16_t));
     82      1.1     chuck 
     83      1.1     chuck void *ledatabuf; /* XXXCDC hack from pmap bootstrap */
     84      1.6  christos 
     85      1.8   thorpej hide void
     86      1.8   thorpej le_pcc_wrcsr(sc, port, val)
     87      1.8   thorpej 	struct am7990_softc *sc;
     88      1.2   mycroft 	u_int16_t port, val;
     89      1.1     chuck {
     90      1.8   thorpej 	register struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
     91      1.1     chuck 
     92      1.2   mycroft 	ler1->ler1_rap = port;
     93      1.2   mycroft 	ler1->ler1_rdp = val;
     94      1.1     chuck }
     95      1.1     chuck 
     96      1.8   thorpej hide u_int16_t
     97      1.8   thorpej le_pcc_rdcsr(sc, port)
     98      1.8   thorpej 	struct am7990_softc *sc;
     99      1.2   mycroft 	u_int16_t port;
    100      1.1     chuck {
    101      1.8   thorpej 	register struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
    102      1.2   mycroft 	u_int16_t val;
    103      1.1     chuck 
    104      1.2   mycroft 	ler1->ler1_rap = port;
    105      1.2   mycroft 	val = ler1->ler1_rdp;
    106      1.2   mycroft 	return (val);
    107      1.1     chuck }
    108      1.1     chuck 
    109      1.1     chuck int
    110      1.7     chuck le_pcc_match(parent, match, aux)
    111      1.2   mycroft 	struct device *parent;
    112      1.2   mycroft 	void *match, *aux;
    113      1.1     chuck {
    114      1.2   mycroft 	struct cfdata *cf = match;
    115      1.7     chuck 	struct pcc_attach_args *pa = aux;
    116      1.7     chuck 
    117      1.7     chuck 	if (strcmp(pa->pa_name, le_cd.cd_name))
    118      1.7     chuck 		return (0);
    119      1.1     chuck 
    120      1.7     chuck 	pa->pa_ipl = cf->pcccf_ipl;
    121      1.7     chuck 	return (1);
    122      1.1     chuck }
    123      1.1     chuck 
    124      1.1     chuck void
    125      1.7     chuck le_pcc_attach(parent, self, aux)
    126      1.2   mycroft 	struct device *parent, *self;
    127      1.2   mycroft 	void *aux;
    128      1.2   mycroft {
    129      1.8   thorpej 	struct le_softc *lesc = (void *)self;
    130      1.8   thorpej 	struct am7990_softc *sc = &lesc->sc_am7990;
    131      1.7     chuck 	struct pcc_attach_args *pa = aux;
    132      1.1     chuck 
    133      1.2   mycroft 	/* XXX the following declarations should be elsewhere */
    134      1.2   mycroft 	extern void myetheraddr __P((u_char *));
    135      1.1     chuck 
    136      1.7     chuck 	/* Map control registers. */
    137      1.8   thorpej 	lesc->sc_r1 = (struct lereg1 *)PCC_VADDR(pa->pa_offset);
    138      1.1     chuck 
    139      1.2   mycroft 	sc->sc_mem = ledatabuf;		/* XXX */
    140      1.2   mycroft 	sc->sc_conf3 = LE_C3_BSWP;
    141      1.2   mycroft 	sc->sc_addr = (u_long)sc->sc_mem;
    142      1.2   mycroft 	sc->sc_memsize = 4 * NBPG;	/* XXX */
    143      1.2   mycroft 
    144      1.2   mycroft 	myetheraddr(sc->sc_arpcom.ac_enaddr);
    145      1.2   mycroft 
    146      1.5       cgd 	sc->sc_copytodesc = am7990_copytobuf_contig;
    147      1.5       cgd 	sc->sc_copyfromdesc = am7990_copyfrombuf_contig;
    148      1.5       cgd 	sc->sc_copytobuf = am7990_copytobuf_contig;
    149      1.5       cgd 	sc->sc_copyfrombuf = am7990_copyfrombuf_contig;
    150      1.5       cgd 	sc->sc_zerobuf = am7990_zerobuf_contig;
    151      1.1     chuck 
    152      1.8   thorpej 	sc->sc_rdcsr = le_pcc_rdcsr;
    153      1.8   thorpej 	sc->sc_wrcsr = le_pcc_wrcsr;
    154      1.8   thorpej 	sc->sc_hwinit = NULL;
    155      1.1     chuck 
    156      1.8   thorpej 	am7990_config(sc);
    157  1.9.4.1     chuck 
    158  1.9.4.1     chuck 	/* Are we the boot device? */
    159  1.9.4.1     chuck 	if (PCC_PADDR(pa->pa_offset) == bootaddr)
    160  1.9.4.1     chuck 		bootdv = self;
    161      1.8   thorpej 
    162      1.8   thorpej 	pccintr_establish(PCCV_LE, am7990_intr, pa->pa_ipl, sc);
    163      1.7     chuck 	sys_pcc->le_int = pa->pa_ipl | PCC_IENABLE;
    164      1.1     chuck }
    165