/*
* Copyright (c) 2009 Stephen M. Rumble
* All rights reserved.
*
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Ethernet software status per interface.
* The real stuff is in dev/ic/am7990var.h
* The really real stuff is in dev/ic/lancevar.h
*
* Lance is somewhat nasty MI code. We basically get:
* struct le_softc {
* struct am7990_softc {
* struct lance_softc {
* device_t sc_dev;
* ...
* }
* }
*
* bus_space_tag ...
* }
*
* So, we can cast any three to any other three, plus
* device_private(sc_dev) points back at the top (i.e. to le_softc,
* am7990_softc and lance_softc). Bloody hell!
*/
struct le_softc {
struct am7990_softc sc_am7990; /* glue to MI code */
/* Allocate a contiguous chunk of physical memory for the le buffer. */
error = uvm_pglistalloc(OIOC_LANCE_NPAGES * PAGE_SIZE,
pmap_limits.avail_start, pmap_limits.avail_end, PAGE_SIZE, 0,
&mlist, 1, 0);
if (error) {
aprint_error(": failed to allocate ioc<->lance buffer space, "
"error = %d\n", error);
goto fail_3;
}
/* Use IOC to map the physical memory into the Ethernet chip's space. */
for (i = 0; i < OIOC_LANCE_NPAGES; i++) {
bus_space_write_2(lesc->sc_st,lesc->sc_maph,
OIOC_ENET_PGMAP_OFF(i),
(VM_PAGE_TO_PHYS(mlist.tqh_first) >> PAGE_SHIFT) + i);
}