elink.c revision 28752
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 *
2928752Sbde *	$Id: elink.c,v 1.8 1997/07/20 14:09:54 bde Exp $
302268Sats */
312268Sats
322268Sats/*
332268Sats * Common code for dealing with 3COM ethernet cards.
342268Sats */
352268Sats
362268Sats#include <sys/types.h>
376734Sbde
386734Sbde#include <machine/cpufunc.h>
396734Sbde
402268Sats#include <i386/isa/elink.h>
412268Sats
422268Sats/*
432268Sats * Issue a `global reset' to all cards.  We have to be careful to do this only
442268Sats * once during autoconfig, to prevent resetting boards that have already been
452268Sats * configured.
462268Sats */
472268Satsvoid
482268Satselink_reset()
498876Srgrimes{
502268Sats	static int x = 0;
512268Sats
522268Sats	if (x == 0) {
532268Sats		x = 1;
542268Sats		outb(ELINK_ID_PORT, ELINK_RESET);
552268Sats	}
562268Sats}
572268Sats
582268Sats/*
592268Sats * The `ID sequence' is really just snapshots of an 8-bit CRC register as 0
602268Sats * bits are shifted in.  Different board types use different polynomials.
612268Sats */
622268Satsvoid
6328752Sbdeelink_idseq(u_char p)
642268Sats{
652268Sats	register int i;
662268Sats	register u_char c;
672268Sats
682268Sats	c = 0xff;
692268Sats	for (i = 255; i; i--) {
702268Sats		outb(ELINK_ID_PORT, c);
712268Sats		if (c & 0x80) {
722268Sats			c <<= 1;
732268Sats			c ^= p;
742268Sats		} else
752268Sats			c <<= 1;
762268Sats	}
772268Sats}
78