/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
* Simulation Facility, NASA Ames Research Center.
*
* 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.
*/
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell and Rick Macklem.
*
* 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
*
* @(#)if_le.c 8.2 (Berkeley) 11/16/93
*/
mem = 0;
sc->lsc.sc_initaddr = mem;
mem += sizeof(struct leinit);
sc->lsc.sc_rmdaddr = mem;
mem += sizeof(struct lermd) * sc->lsc.sc_nrbuf;
sc->lsc.sc_tmdaddr = mem;
mem += sizeof(struct letmd) * sc->lsc.sc_ntbuf;
for (i = 0; i < sc->lsc.sc_nrbuf; i++, mem += LEBLEN)
sc->lsc.sc_rbufaddr[i] = mem;
for (i = 0; i < sc->lsc.sc_ntbuf; i++, mem += LEBLEN)
sc->lsc.sc_tbufaddr[i] = mem;
#ifdef notyet
if (mem > ...)
panic(...);
#endif
}
/*
* Set up the initialization block and the descriptor rings.
*/
static void
am7990_meminit(struct lance_softc *sc)
{
u_long a;
int bix;
struct leinit init;
struct lermd rmd;
struct letmd tmd;
uint8_t *myaddr;
if (ifp->if_flags & IFF_PROMISC)
init.init_mode = LE_MODE_NORMAL | LE_MODE_PROM;
else
init.init_mode = LE_MODE_NORMAL;
if (sc->sc_initmodemedia == 1)
init.init_mode |= LE_MODE_PSEL0;
/*
* Update our private copy of the Ethernet address.
* We NEED the copy so we can ensure its alignment!
*/
memcpy(sc->sc_enaddr, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN);
myaddr = sc->sc_enaddr;
/*
* Pretend we have carrier; if we don't this will be cleared
* shortly.
*/
const int ocarrier = sc->sc_havecarrier;
sc->sc_havecarrier = 1;
if (isr & LE_C0_RINT)
am7990_rint(sc);
if (isr & LE_C0_TINT)
am7990_tint(sc);
if (sc->sc_havecarrier != ocarrier)
if_link_state_change(ifp,
sc->sc_havecarrier ? LINK_STATE_UP : LINK_STATE_DOWN);
rnd_add_uint32(&sc->rnd_source, isr);
return (1);
}
#undef ifp
/*
* Setup output on interface.
* Get another datagram to send off of the interface queue, and map it to the
* interface before starting the output.
* Called only at splnet or interrupt level.
*/
static void
am7990_start(struct ifnet *ifp)
{
struct lance_softc *sc = ifp->if_softc;
int bix;
struct mbuf *m;
struct letmd tmd;
int rp;
int len;
if ((ifp->if_flags & IFF_RUNNING) != IFF_RUNNING)
return;
bix = sc->sc_last_td;
while (sc->sc_no_td < sc->sc_ntbuf) {
rp = LE_TMDADDR(sc, bix);
(*sc->sc_copyfromdesc)(sc, &tmd, rp, sizeof(tmd));