elink.c revision 8876
12268Sats/* 22268Sats * Copyright (c) 1994 Charles Hannum. All rights reserved. 32268Sats * 42268Sats * Redistribution and use in source and binary forms, with or without 52268Sats * modification, are permitted provided that the following conditions 62268Sats * are met: 72268Sats * 1. Redistributions of source code must retain the above copyright 82268Sats * notice, this list of conditions and the following disclaimer. 92268Sats * 2. Redistributions in binary form must reproduce the above copyright 102268Sats * notice, this list of conditions and the following disclaimer in the 112268Sats * documentation and/or other materials provided with the distribution. 122268Sats * 3. All advertising materials mentioning features or use of this software 132268Sats * must display the following acknowledgement: 142268Sats * This product includes software developed by Charles Hannum. 152268Sats * 4. The name of the author may not be used to endorse or promote products 162268Sats * derived from this software without specific prior written permission. 172268Sats * 182268Sats * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 192268Sats * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 202268Sats * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 212268Sats * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 222268Sats * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 232268Sats * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242268Sats * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252268Sats * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262268Sats * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 272268Sats * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282268Sats * 298876Srgrimes * $Id: elink.c,v 1.4 1995/02/26 05:14:46 bde Exp $ 302268Sats */ 312268Sats 322268Sats/* 332268Sats * Common code for dealing with 3COM ethernet cards. 342268Sats */ 352268Sats 362268Sats#include <sys/types.h> 372268Sats#include <sys/cdefs.h> 386734Sbde 396734Sbde#include <machine/cpufunc.h> 406734Sbde 412268Sats#include <i386/isa/elink.h> 422268Sats 432268Sats/* 442268Sats * Issue a `global reset' to all cards. We have to be careful to do this only 452268Sats * once during autoconfig, to prevent resetting boards that have already been 462268Sats * configured. 472268Sats */ 482268Satsvoid 492268Satselink_reset() 508876Srgrimes{ 512268Sats static int x = 0; 522268Sats 532268Sats if (x == 0) { 542268Sats x = 1; 552268Sats outb(ELINK_ID_PORT, ELINK_RESET); 562268Sats } 572268Sats} 582268Sats 592268Sats/* 602268Sats * The `ID sequence' is really just snapshots of an 8-bit CRC register as 0 612268Sats * bits are shifted in. Different board types use different polynomials. 622268Sats */ 632268Satsvoid 642268Satselink_idseq(p) 652268Sats register u_char p; 662268Sats{ 672268Sats register int i; 682268Sats register u_char c; 692268Sats 702268Sats c = 0xff; 712268Sats for (i = 255; i; i--) { 722268Sats outb(ELINK_ID_PORT, c); 732268Sats if (c & 0x80) { 742268Sats c <<= 1; 752268Sats c ^= p; 762268Sats } else 772268Sats c <<= 1; 782268Sats } 792268Sats} 80