/*
* Copyright (c) 1995 Theo de Raadt
*
* 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 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.
*
* Copyright (c) 1993 Adam Glass
* 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. 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:
* This product includes software developed by Adam Glass.
* 4. 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 Adam Glass ``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.
*/
int
le_match(struct netif *nif, void *machdep_hint)
{
char *name;
int i, val = 0;
if (bugargs.cputyp != CPU_147)
return 0;
name = machdep_hint;
if (name && !memcmp(le_driver.netif_bname, name, 2))
val += 10;
for (i = 0; i < nle_config; i++) {
if (le_config[i].used)
continue;
if (le_debug)
printf("le%d: le_match --> %d\n", i, val + 1);
le_config[i].used++;
return val + 1;
}
if (le_debug)
printf("le%d: le_match --> 0\n", i);
return 0;
}
int
le_probe(struct netif *nif, void *machdep_hint)
{
/* the set unit is the current unit */
if (le_debug)
printf("le%d: le_probe called\n", nif->nif_unit);
if (bugargs.cputyp == CPU_147)
return 0;
return 1;
}
/* ler1->ler1_rap = LE_CSRO done in caller */
if (ler1->ler1_rdp & LE_C0_BABL)
panic("le%d: been babbling, found by '%s'", nif->nif_unit, str);
if (ler1->ler1_rdp & LE_C0_CERR) {
le_stats.collision_error++;
ler1->ler1_rdp = LE_C0_CERR;
}
if (ler1->ler1_rdp & LE_C0_MISS) {
le_stats.missed++;
ler1->ler1_rdp = LE_C0_MISS;
}
if (ler1->ler1_rdp & LE_C0_MERR) {
printf("le%d: memory error in '%s'\n", nif->nif_unit, str);
panic("memory error");
}
}
void
le_reset(struct netif *nif, u_char *myea)
{
struct lereg1 *ler1 = le_softc.sc_r1;
struct lereg2 *ler2 = le_softc.sc_r2;
unsigned int a;
int timo = 100000, stat = 0, i;
if (le_debug)
printf("le%d: le_reset called\n", nif->nif_unit);
ler1->ler1_rap = LE_CSR0;
ler1->ler1_rdp = LE_C0_STOP; /* do nothing until we are finished */