1996-12-18 00:10:35 +03:00
|
|
|
/* $NetBSD: if_ie_obio.c,v 1.7 1996/12/17 21:10:45 gwr Exp $ */
|
1996-03-26 17:38:29 +03:00
|
|
|
|
1996-11-20 21:56:49 +03:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
1996-03-26 17:38:29 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1996-11-20 21:56:49 +03:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Gordon W. Ross.
|
|
|
|
*
|
1996-03-26 17:38:29 +03:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1996-11-20 21:56:49 +03:00
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
1996-03-26 17:38:29 +03:00
|
|
|
*
|
1996-11-20 21:56:49 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
1996-03-26 17:38:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Machine-dependent glue for the Intel Ethernet (ie) driver.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <machine/autoconf.h>
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/dvma.h>
|
|
|
|
#include <machine/obio.h>
|
|
|
|
#include <machine/idprom.h>
|
|
|
|
#include <machine/vmparam.h>
|
|
|
|
|
|
|
|
#include "i82586.h"
|
1996-03-27 01:04:14 +03:00
|
|
|
#include "if_iereg.h"
|
|
|
|
#include "if_ievar.h"
|
1996-03-26 17:38:29 +03:00
|
|
|
|
|
|
|
static void ie_obreset __P((struct ie_softc *));
|
|
|
|
static void ie_obattend __P((struct ie_softc *));
|
|
|
|
static void ie_obrun __P((struct ie_softc *));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* New-style autoconfig attachment
|
|
|
|
*/
|
|
|
|
|
1996-12-18 00:10:35 +03:00
|
|
|
static int ie_obio_match __P((struct device *, struct cfdata *, void *));
|
1996-03-26 17:38:29 +03:00
|
|
|
static void ie_obio_attach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct cfattach ie_obio_ca = {
|
|
|
|
sizeof(struct ie_softc), ie_obio_match, ie_obio_attach
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
1996-12-18 00:10:35 +03:00
|
|
|
ie_obio_match(parent, cf, args)
|
1996-03-26 17:38:29 +03:00
|
|
|
struct device *parent;
|
1996-12-18 00:10:35 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *args;
|
1996-03-26 17:38:29 +03:00
|
|
|
{
|
|
|
|
struct confargs *ca = args;
|
|
|
|
|
1996-10-30 03:24:32 +03:00
|
|
|
/* Make sure there is something there... */
|
|
|
|
if (bus_peek(ca->ca_bustype, ca->ca_paddr, 1) == -1)
|
1996-03-26 17:38:29 +03:00
|
|
|
return (0);
|
|
|
|
|
1996-10-30 03:24:32 +03:00
|
|
|
/* Default interrupt priority. */
|
|
|
|
if (ca->ca_intpri == -1)
|
|
|
|
ca->ca_intpri = 3;
|
1996-03-26 17:38:29 +03:00
|
|
|
|
1996-10-30 03:24:32 +03:00
|
|
|
return (1);
|
1996-03-26 17:38:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ie_obio_attach(parent, self, args)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *args;
|
|
|
|
{
|
|
|
|
struct ie_softc *sc = (void *) self;
|
|
|
|
struct confargs *ca = args;
|
|
|
|
|
|
|
|
sc->hard_type = IE_OBIO;
|
|
|
|
sc->reset_586 = ie_obreset;
|
|
|
|
sc->chan_attn = ie_obattend;
|
|
|
|
sc->run_586 = ie_obrun;
|
|
|
|
sc->sc_bcopy = bcopy;
|
|
|
|
sc->sc_bzero = bzero;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The on-board "ie" just uses main memory, so
|
|
|
|
* we can choose how much memory to give it.
|
|
|
|
* XXX: Would like to use less than 64K...
|
|
|
|
*/
|
|
|
|
sc->sc_msize = 0x8000; /* MEMSIZE 32K */
|
|
|
|
|
|
|
|
/* Map in the control registers. */
|
|
|
|
sc->sc_reg = obio_alloc(ca->ca_paddr, OBIO_INTEL_ETHER_SIZE);
|
|
|
|
|
|
|
|
/* Allocate "shared" memory (in DVMA space). */
|
|
|
|
sc->sc_maddr = dvma_malloc(sc->sc_msize);
|
|
|
|
if (sc->sc_maddr == NULL)
|
|
|
|
panic(": not enough dvma space");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The on-board "ie" is wired-up such that its
|
|
|
|
* memory access goes to the high 16 megabytes
|
|
|
|
* of the on-board memory space (on-board DVMA).
|
|
|
|
*/
|
|
|
|
sc->sc_iobase = (caddr_t)DVMA_OBIO_SLAVE_BASE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the System Configuration Pointer (SCP).
|
|
|
|
* Its location is system-dependent because the
|
|
|
|
* i82586 reads it from a fixed physical address.
|
|
|
|
* On this hardware, the i82586 address maps to
|
|
|
|
* a 24-bit offset in on-board DVMA space. The
|
|
|
|
* SCP happens to fall in a page used by the
|
|
|
|
* PROM monitor, which the PROM knows about.
|
|
|
|
*/
|
|
|
|
sc->scp = (volatile void *) (sc->sc_iobase + IE_SCP_ADDR);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The rest of ram is used for buffers.
|
|
|
|
*/
|
|
|
|
sc->buf_area = sc->sc_maddr;
|
|
|
|
sc->buf_area_sz = sc->sc_msize;
|
|
|
|
|
|
|
|
/* Set the ethernet address. */
|
|
|
|
idprom_etheraddr(sc->sc_addr);
|
|
|
|
|
|
|
|
/* Do machine-independent parts of attach. */
|
|
|
|
ie_attach(sc);
|
|
|
|
|
|
|
|
/* Install interrupt handler. */
|
1996-10-30 03:24:32 +03:00
|
|
|
isr_add_autovect(ie_intr, (void *)sc, ca->ca_intpri);
|
1996-03-26 17:38:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* onboard ie support
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ie_obreset(sc)
|
|
|
|
struct ie_softc *sc;
|
|
|
|
{
|
|
|
|
volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
|
|
|
|
ieo->obctrl = 0;
|
|
|
|
delay(100); /* XXX could be shorter? */
|
|
|
|
ieo->obctrl = IEOB_NORSET;
|
|
|
|
}
|
|
|
|
void
|
|
|
|
ie_obattend(sc)
|
|
|
|
struct ie_softc *sc;
|
|
|
|
{
|
|
|
|
volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
|
|
|
|
|
|
|
|
ieo->obctrl |= IEOB_ATTEN; /* flag! */
|
|
|
|
ieo->obctrl &= ~IEOB_ATTEN; /* down. */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ie_obrun(sc)
|
|
|
|
struct ie_softc *sc;
|
|
|
|
{
|
|
|
|
volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
|
|
|
|
|
|
|
|
ieo->obctrl |= (IEOB_ONAIR|IEOB_IENAB|IEOB_NORSET);
|
|
|
|
}
|
|
|
|
|