/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Gordon W. Ross.
*
* 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.
*
* 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 FOUNDATION 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.
*/
/*
* Machine-dependent glue for the Intel Ethernet (ie) driver.
*/
/*
* zero/copy functions: OBIO can use the normal functions, but VME
* must do only byte or half-word (16 bit) accesses...
*/
static void *wmemcpy(void *, const void *, size_t);
static void *wmemset(void *, int, size_t);
/*
* *note*: we don't detect the difference between a VME3E and
* a multibus/vme card. if you want to use a 3E you'll have
* to fix this.
*/
void
ie_vme_attach(device_t parent, device_t self, void *args)
{
struct ie_softc *sc = device_private(self);
struct confargs *ca = args;
volatile struct ievme *iev;
u_long rampaddr;
int lcv, off;
/*
* There is 64K of memory on the VME board.
* (determined by hardware - NOT configurable!)
*/
sc->sc_msize = 0x10000; /* MEMSIZE 64K */
/* Map in the board control regs. */
sc->sc_reg = bus_mapin(ca->ca_bustype, ca->ca_paddr,
sizeof(struct ievme));
iev = (volatile struct ievme *) sc->sc_reg;
/*
* Find and map in the board memory.
*/
/* top 12 bits */
rampaddr = ca->ca_paddr & 0xfff00000;
/* 4 more */
rampaddr |= ((iev->status & IEVME_HADDR) << 16);
sc->sc_maddr = bus_mapin(ca->ca_bustype, rampaddr, sc->sc_msize);
/*
* On this hardware, the i82586 address is just
* masked to 16 bits, so sc_iobase == sc_maddr
*/
sc->sc_iobase = sc->sc_maddr;
/*
* Set up on-board mapping registers for linear map.
*/
iev->pectrl |= IEVME_PARACK; /* clear to start */
for (lcv = 0; lcv < IEVME_MAPSZ; lcv++)
iev->pgmap[lcv] = IEVME_SBORDR | IEVME_OBMEM | lcv;
(sc->sc_memset)(sc->sc_maddr, 0, sc->sc_msize);
/*
* 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 is just
* masked down to 16 bits, so the SCP is found
* at the end of the RAM on the VME board.
*/
off = IE_SCP_ADDR & 0xFFFF;
sc->scp = (volatile void *)((char *)sc->sc_maddr + off);
/*
* The rest of ram is used for buffers, etc.
*/
sc->buf_area = sc->sc_maddr;
sc->buf_area_sz = off;
/* Set the ethernet address. */
idprom_etheraddr(sc->sc_addr);
/* Do machine-independent parts of attach. */
ie_attach(sc);
/*
* wmemcpy/wmemset - like memcpy/memset but largest access is 16-bits,
* and also does byte swaps...
* XXX - Would be nice to have asm versions in some library...
*/