Home | History | Annotate | Line # | Download | only in dev
if_ie_sebuf.c revision 1.3
      1 /*	$NetBSD: if_ie_sebuf.c,v 1.3 1997/10/25 18:04:21 gwr Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Gordon W. Ross.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * Machine-dependent glue for the Intel Ethernet (ie) driver,
     41  * as found on the Sun3/E SCSI/Ethernet board.
     42  */
     43 
     44 #include <sys/param.h>
     45 #include <sys/systm.h>
     46 #include <sys/device.h>
     47 #include <sys/protosw.h>
     48 #include <sys/socket.h>
     49 #include <net/if.h>
     50 #include <net/if_ether.h>
     51 
     52 #ifdef INET
     53 #include <netinet/in.h>
     54 #include <netinet/in_systm.h>
     55 #include <netinet/in_var.h>
     56 #include <netinet/ip.h>
     57 #include <netinet/if_inarp.h>
     58 #endif
     59 
     60 #include <machine/autoconf.h>
     61 #include <machine/cpu.h>
     62 #include <machine/dvma.h>
     63 #include <machine/idprom.h>
     64 #include <machine/vmparam.h>
     65 
     66 #include "i82586.h"
     67 #include "if_iereg.h"
     68 #include "if_ievar.h"
     69 #include "sereg.h"
     70 #include "sevar.h"
     71 
     72 static void ie_sebuf_reset __P((struct ie_softc *));
     73 static void ie_sebuf_attend __P((struct ie_softc *));
     74 static void ie_sebuf_run __P((struct ie_softc *));
     75 
     76 /*
     77  * New-style autoconfig attachment
     78  */
     79 
     80 static int  ie_sebuf_match __P((struct device *, struct cfdata *, void *));
     81 static void ie_sebuf_attach __P((struct device *, struct device *, void *));
     82 
     83 struct cfattach ie_sebuf_ca = {
     84 	sizeof(struct ie_softc), ie_sebuf_match, ie_sebuf_attach
     85 };
     86 
     87 
     88 static int
     89 ie_sebuf_match(parent, cf, args)
     90 	struct device *parent;
     91 	struct cfdata *cf;
     92 	void *args;
     93 {
     94 	struct sebuf_attach_args *aa = args;
     95 
     96 	/* Match by name. */
     97 	if (strcmp(aa->name, "ie"))
     98 		return (0);
     99 
    100 	/* Anyting else to check? */
    101 
    102 	return (1);
    103 }
    104 
    105 static void
    106 ie_sebuf_attach(parent, self, args)
    107 	struct device *parent;
    108 	struct device *self;
    109 	void *args;
    110 {
    111 	struct ie_softc *sc = (void *) self;
    112 	struct sebuf_attach_args *aa = args;
    113 	volatile struct ie_regs *regs;
    114 	int     off;
    115 
    116 	sc->hard_type = IE_VME3E;
    117 	sc->reset_586 = ie_sebuf_reset;
    118 	sc->chan_attn = ie_sebuf_attend;
    119 	sc->run_586   = ie_sebuf_run;
    120 	sc->sc_bcopy = bcopy;
    121 	sc->sc_bzero = bzero;
    122 
    123 	/*
    124 	 * There is 128K of memory for the i82586 on
    125 	 * the Sun3/E SCSI/Ethernet board, and the
    126 	 * "sebuf" driver has mapped it in for us.
    127 	 * (Fixed in hardware; NOT configurable!)
    128 	 */
    129 	if (aa->blen < SE_IEBUFSIZE)
    130 		panic("ie_sebuf: bad size");
    131 	sc->sc_msize = SE_IEBUFSIZE;
    132 	sc->sc_maddr = aa->buf;
    133 	sc->sc_reg = aa->regs;
    134 	regs = (volatile struct ie_regs *) sc->sc_reg;
    135 
    136 	/*
    137 	 * On this hardware, the i82586 address is just
    138 	 * masked to 17 bits, so sc_iobase == sc_maddr
    139 	 */
    140 	sc->sc_iobase = sc->sc_maddr;
    141 
    142 	/* Clear the memory. */
    143 	(sc->sc_bzero)(sc->sc_maddr, sc->sc_msize);
    144 
    145 	/*
    146 	 * Set the System Configuration Pointer (SCP).
    147 	 * Its location is system-dependent because the
    148 	 * i82586 reads it from a fixed physical address.
    149 	 * On this hardware, the i82586 address is just
    150 	 * masked down to 17 bits, so the SCP is found
    151 	 * at the end of the RAM on the VME board.
    152 	 */
    153 	off = IE_SCP_ADDR & (SE_IEBUFSIZE-1);
    154 	sc->scp = (volatile void *) (sc->sc_iobase + off);
    155 
    156 	/*
    157 	 * The rest of ram is used for buffers, etc.
    158 	 */
    159 	sc->buf_area = sc->sc_maddr;
    160 	sc->buf_area_sz = off;
    161 
    162 	/* Set the ethernet address. */
    163 	idprom_etheraddr(sc->sc_addr);
    164 
    165 	/* Install interrupt handler. */
    166 	regs->ie_ivec = aa->ca.ca_intvec;
    167 	isr_add_vectored(ie_intr, (void *)sc,
    168 		aa->ca.ca_intpri, aa->ca.ca_intvec);
    169 
    170 	/* Do machine-independent parts of attach. */
    171 	ie_attach(sc);
    172 
    173 }
    174 
    175 
    176 /*
    177  * MULTIBUS/VME support
    178  */
    179 void
    180 ie_sebuf_reset(sc)
    181 	struct ie_softc *sc;
    182 {
    183 	volatile struct ie_regs *regs = (struct ie_regs *) sc->sc_reg;
    184 	regs->ie_csr = IE_CSR_RESET;
    185 	delay(10);
    186 	regs->ie_csr = 0;
    187 }
    188 
    189 void
    190 ie_sebuf_attend(sc)
    191 	struct ie_softc *sc;
    192 {
    193 	volatile struct ie_regs *regs = (struct ie_regs *) sc->sc_reg;
    194 
    195 	regs->ie_csr |= IE_CSR_ATTEN;	/* flag! */
    196 	regs->ie_csr &= ~IE_CSR_ATTEN;	/* down. */
    197 }
    198 
    199 void
    200 ie_sebuf_run(sc)
    201 	struct ie_softc *sc;
    202 {
    203 	volatile struct ie_regs *regs = (struct ie_regs *) sc->sc_reg;
    204 
    205 	regs->ie_csr |= IE_CSR_IENAB;
    206 }
    207