elink.c revision 112789
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 * 2950477Speter * $FreeBSD: head/sys/i386/isa/elink.c 112789 2003-03-29 13:18:20Z mdodd $ 302268Sats */ 312268Sats 322268Sats/* 332268Sats * Common code for dealing with 3COM ethernet cards. 342268Sats */ 352268Sats 36112789Smdodd#include <sys/param.h> 37112789Smdodd#include <sys/systm.h> 38112789Smdodd#include <sys/kernel.h> 39112789Smdodd#include <sys/module.h> 406734Sbde 416734Sbde#include <machine/cpufunc.h> 426734Sbde 432268Sats#include <i386/isa/elink.h> 442268Sats 452268Sats/* 462268Sats * Issue a `global reset' to all cards. We have to be careful to do this only 472268Sats * once during autoconfig, to prevent resetting boards that have already been 482268Sats * configured. 492268Sats */ 502268Satsvoid 512268Satselink_reset() 528876Srgrimes{ 532268Sats static int x = 0; 542268Sats 552268Sats if (x == 0) { 562268Sats x = 1; 572268Sats outb(ELINK_ID_PORT, ELINK_RESET); 582268Sats } 59112789Smdodd outb(ELINK_ID_PORT, 0); 60112789Smdodd outb(ELINK_ID_PORT, 0); 61112789Smdodd 62112789Smdodd return; 632268Sats} 642268Sats 652268Sats/* 662268Sats * The `ID sequence' is really just snapshots of an 8-bit CRC register as 0 672268Sats * bits are shifted in. Different board types use different polynomials. 682268Sats */ 692268Satsvoid 7028752Sbdeelink_idseq(u_char p) 712268Sats{ 722268Sats register int i; 732268Sats register u_char c; 742268Sats 752268Sats c = 0xff; 762268Sats for (i = 255; i; i--) { 772268Sats outb(ELINK_ID_PORT, c); 782268Sats if (c & 0x80) { 792268Sats c <<= 1; 802268Sats c ^= p; 812268Sats } else 822268Sats c <<= 1; 832268Sats } 842268Sats} 85112789Smdodd 86112789Smdoddstatic moduledata_t elink_mod = { 87112789Smdodd "elink",/* module name */ 88112789Smdodd NULL, /* event handler */ 89112789Smdodd 0 /* extra data */ 90112789Smdodd}; 91112789Smdodd 92112789SmdoddDECLARE_MODULE(elink, elink_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); 93112789SmdoddMODULE_VERSION(elink, 1); 94