⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tlan.c

📁 i386的bootloader源码grub
💻 C
📖 第 1 页 / 共 5 页
字号:
{	/* if probe_addrs is 0, then routine can use a hardwired default */	/* if board found */	{		/* point to NIC specific routines */		nic->reset = skel_reset;		nic->poll = skel_poll;		nic->transmit = skel_transmit;		nic->disable = skel_disable;		return nic;	}	/* else */	return 0;}#if	0#ifndef TLAN_H#define TLAN_H/******************************************************************** * *  Linux ThunderLAN Driver * *  tlan.h *  by James Banks * *  (C) 1997-1998 Caldera, Inc. *  (C) 1999-2001 Torben Mathiasen *  *  This software may be used and distributed according to the terms *  of the GNU General Public License, incorporated herein by reference. * ** This file is best viewed/edited with tabstop=4, colums>=132 * *   *  Dec 10, 1999	Torben Mathiasen <torben.mathiasen@compaq.com> *			New Maintainer * ********************************************************************/#include <asm/io.h>#include <asm/types.h>#include <linux/netdevice.h>#define FALSE			0#define TRUE			1#define TX_TIMEOUT		(10*HZ)	 /* We need time for auto-neg */typedef struct tlan_adapter_entry {	u16	vendorId;	u16	deviceId;	char	*deviceLabel;	u32	flags;	u16	addrOfs;} TLanAdapterEntry;	/*****************************************************************	 * EISA Definitions	 *	 ****************************************************************/#define EISA_ID      0xc80   /* EISA ID Registers */ #define EISA_ID0     0xc80   /* EISA ID Register 0 */ #define EISA_ID1     0xc81   /* EISA ID Register 1 */ #define EISA_ID2     0xc82   /* EISA ID Register 2 */ #define EISA_ID3     0xc83   /* EISA ID Register 3 */ #define EISA_CR      0xc84   /* EISA Control Register */#define EISA_REG0    0xc88   /* EISA Configuration Register 0 */#define EISA_REG1    0xc89   /* EISA Configuration Register 1 */#define EISA_REG2    0xc8a   /* EISA Configuration Register 2 */#define EISA_REG3    0xc8f   /* EISA Configuration Register 3 */#define EISA_APROM   0xc90   /* Ethernet Address PROM */	/*****************************************************************	 * Rx/Tx List Definitions	 *	 ****************************************************************/typedef struct tlan_buffer_ref_tag {	u32	count;	u32	address;} TLanBufferRef;typedef struct tlan_list_tag {	u32		forward;	u16		cStat;	u16		frameSize;	TLanBufferRef	buffer[TLAN_BUFFERS_PER_LIST];} TLanList;typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];	/*****************************************************************	 * TLAN Private Information Structure	 *	 ****************************************************************/typedef struct tlan_private_tag {	struct net_device       *nextDevice;	void			*dmaStorage;	u8			*padBuffer;	TLanList                *rxList;	u8			*rxBuffer;	u32                     rxHead;	u32                     rxTail;	u32			rxEocCount;	TLanList                *txList;	u8			*txBuffer;	u32                     txHead;	u32                     txInProgress;	u32                     txTail;	u32			txBusyCount;	u32                     phyOnline;	u32			timerSetAt;	u32			timerType;	struct timer_list	timer;	struct net_device_stats	stats;	struct board		*adapter;	u32			adapterRev;	u32			aui;	u32			debug;	u32			duplex;	u32			phy[2];	u32			phyNum;	u32			speed;	u8			tlanRev;	u8			tlanFullDuplex;	char                    devName[8];	spinlock_t		lock;	u8			link;	u8			is_eisa;	struct tq_struct	tlan_tqueue;	u8			neg_be_verbose;} TLanPrivateInfo;#define 	TLAN_HC_GO		0x80000000#define		TLAN_HC_STOP		0x40000000#define		TLAN_HC_ACK		0x20000000#define		TLAN_HC_CS_MASK		0x1FE00000#define		TLAN_HC_EOC		0x00100000#define		TLAN_HC_RT		0x00080000#define		TLAN_HC_NES		0x00040000#define		TLAN_HC_AD_RST		0x00008000#define		TLAN_HC_LD_TMR		0x00004000#define		TLAN_HC_LD_THR		0x00002000#define		TLAN_HC_REQ_INT		0x00001000#define		TLAN_HC_INT_OFF		0x00000800#define		TLAN_HC_INT_ON		0x00000400#define		TLAN_HC_AC_MASK		0x000000FF#define		TLAN_DA_ADR_INC		0x8000#define		TLAN_DA_RAM_ADR		0x4000#define		TLAN_HI_IV_MASK		0x1FE0#define		TLAN_HI_IT_MASK		0x001C#define		TLAN_NET_CMD_NRESET	0x80#define		TLAN_NET_CMD_NWRAP	0x40#define		TLAN_NET_CMD_CSF	0x20#define		TLAN_NET_CMD_CAF	0x10#define		TLAN_NET_CMD_NOBRX	0x08#define		TLAN_NET_CMD_DUPLEX	0x04#define		TLAN_NET_CMD_TRFRAM	0x02#define		TLAN_NET_CMD_TXPACE	0x01#define 	TLAN_NET_SIO_MINTEN	0x80#define		TLAN_NET_SIO_ECLOK	0x40#define		TLAN_NET_SIO_ETXEN	0x20#define		TLAN_NET_SIO_EDATA	0x10#define		TLAN_NET_SIO_NMRST	0x08#define		TLAN_NET_SIO_MCLK	0x04#define		TLAN_NET_SIO_MTXEN	0x02#define		TLAN_NET_SIO_MDATA	0x01#define		TLAN_NET_STS_MIRQ	0x80#define		TLAN_NET_STS_HBEAT	0x40#define		TLAN_NET_STS_TXSTOP	0x20#define		TLAN_NET_STS_RXSTOP	0x10#define		TLAN_NET_STS_RSRVD	0x0F#define		TLAN_NET_MASK_MASK7	0x80#define		TLAN_NET_MASK_MASK6	0x40#define		TLAN_NET_MASK_MASK5	0x20#define		TLAN_NET_MASK_MASK4	0x10#define		TLAN_NET_MASK_RSRVD	0x0F#define 	TLAN_NET_CFG_RCLK	0x8000#define		TLAN_NET_CFG_TCLK	0x4000#define		TLAN_NET_CFG_BIT	0x2000#define		TLAN_NET_CFG_RXCRC	0x1000#define		TLAN_NET_CFG_PEF	0x0800#define		TLAN_NET_CFG_1FRAG	0x0400#define		TLAN_NET_CFG_1CHAN	0x0200#define		TLAN_NET_CFG_MTEST	0x0100#define		TLAN_NET_CFG_PHY_EN	0x0080#define		TLAN_NET_CFG_MSMASK	0x007F#define		TLAN_LED_ACT		0x10#define		TLAN_LED_LINK		0x01#define		TLAN_ID_TX_EOC		0x04#define		TLAN_ID_RX_EOF		0x02#define		TLAN_ID_RX_EOC		0x01#define CIRC_INC( a, b ) if ( ++a >= b ) a = 0#ifdef I_LIKE_A_FAST_HASH_FUNCTION/* given 6 bytes, view them as 8 6-bit numbers and return the XOR of those *//* the code below is about seven times as fast as the original code */inline u32 TLan_HashFunc( u8 *a ){        u8     hash;        hash = (a[0]^a[3]);             /* & 077 */        hash ^= ((a[0]^a[3])>>6);       /* & 003 */        hash ^= ((a[1]^a[4])<<2);       /* & 074 */        hash ^= ((a[1]^a[4])>>4);       /* & 017 */        hash ^= ((a[2]^a[5])<<4);       /* & 060 */        hash ^= ((a[2]^a[5])>>2);       /* & 077 */        return (hash & 077);}#else /* original code */inline	u32	xor( u32 a, u32 b ){	return ( ( a && ! b ) || ( ! a && b ) );}#define XOR8( a, b, c, d, e, f, g, h )	xor( a, xor( b, xor( c, xor( d, xor( e, xor( f, xor( g, h ) ) ) ) ) ) )#define DA( a, bit )					( ( (u8) a[bit/8] ) & ( (u8) ( 1 << bit%8 ) ) )inline u32 TLan_HashFunc( u8 *a ){	u32	hash;	hash  = XOR8( DA(a,0), DA(a, 6), DA(a,12), DA(a,18), DA(a,24), DA(a,30), DA(a,36), DA(a,42) );	hash |= XOR8( DA(a,1), DA(a, 7), DA(a,13), DA(a,19), DA(a,25), DA(a,31), DA(a,37), DA(a,43) ) << 1;	hash |= XOR8( DA(a,2), DA(a, 8), DA(a,14), DA(a,20), DA(a,26), DA(a,32), DA(a,38), DA(a,44) ) << 2;	hash |= XOR8( DA(a,3), DA(a, 9), DA(a,15), DA(a,21), DA(a,27), DA(a,33), DA(a,39), DA(a,45) ) << 3;	hash |= XOR8( DA(a,4), DA(a,10), DA(a,16), DA(a,22), DA(a,28), DA(a,34), DA(a,40), DA(a,46) ) << 4;	hash |= XOR8( DA(a,5), DA(a,11), DA(a,17), DA(a,23), DA(a,29), DA(a,35), DA(a,41), DA(a,47) ) << 5;	return hash;} #endif /* I_LIKE_A_FAST_HASH_FUNCTION */#endif/******************************************************************************* * *  Linux ThunderLAN Driver * *  tlan.c *  by James Banks * *  (C) 1997-1998 Caldera, Inc. *  (C) 1998 James Banks *  (C) 1999-2001 Torben Mathiasen * *  This software may be used and distributed according to the terms *  of the GNU General Public License, incorporated herein by reference. * ** This file is best viewed/edited with columns>=132. * ** Useful (if not required) reading: * *		Texas Instruments, ThunderLAN Programmer's Guide, *			TI Literature Number SPWU013A *			available in PDF format from www.ti.com *		Level One, LXT901 and LXT970 Data Sheets *			available in PDF format from www.level1.com *		National Semiconductor, DP83840A Data Sheet *			available in PDF format from www.national.com *		Microchip Technology, 24C01A/02A/04A Data Sheet *			available in PDF format from www.microchip.com * * Change History * *	Tigran Aivazian <tigran@sco.com>:	TLan_PciProbe() now uses *						new PCI BIOS interface. *	Alan Cox	<alan@redhat.com>:	Fixed the out of memory *						handling. *       *	Torben Mathiasen <torben.mathiasen@compaq.com> New Maintainer! * *	v1.1 Dec 20, 1999    - Removed linux version checking *			       Patch from Tigran Aivazian.  *			     - v1.1 includes Alan's SMP updates. *			     - We still have problems on SMP though, *			       but I'm looking into that.  *			 *	v1.2 Jan 02, 2000    - Hopefully fixed the SMP deadlock. *			     - Removed dependency of HZ being 100. *			     - We now allow higher priority timers to  *			       overwrite timers like TLAN_TIMER_ACTIVITY *			       Patch from John Cagle <john.cagle@compaq.com>. *			     - Fixed a few compiler warnings. * *	v1.3 Feb 04, 2000    - Fixed the remaining HZ issues. *			     - Removed call to pci_present().  *			     - Removed SA_INTERRUPT flag from irq handler. *			     - Added __init and __initdata to reduce resisdent  *			       code size. *			     - Driver now uses module_init/module_exit. *			     - Rewrote init_module and tlan_probe to *			       share a lot more code. We now use tlan_probe *			       with builtin and module driver. *			     - Driver ported to new net API.  *			     - tlan.txt has been reworked to reflect current  *			       driver (almost) *			     - Other minor stuff * *	v1.4 Feb 10, 2000    - Updated with more changes required after Dave's *	                       network cleanup in 2.3.43pre7 (Tigran & myself) *	                     - Minor stuff. * *	v1.5 March 22, 2000  - Fixed another timer bug that would hang the driver *			       if no cable/link were present. *			     - Cosmetic changes. *			     - TODO: Port completely to new PCI/DMA API *			     	     Auto-Neg fallback. * * 	v1.6 April 04, 2000  - Fixed driver support for kernel-parameters. Haven't * 			       tested it though, as the kernel support is currently  * 			       broken (2.3.99p4p3). * 			     - Updated tlan.txt accordingly. * 			     - Adjusted minimum/maximum frame length. * 			     - There is now a TLAN website up at  * 			       http://tlan.kernel.dk * * 	v1.7 April 07, 2000  - Started to implement custom ioctls. Driver now * 			       reports PHY information when used with Donald * 			       Beckers userspace MII diagnostics utility. * * 	v1.8 April 23, 2000  - Fixed support for forced speed/duplex settings. * 			     - Added link information to Auto-Neg and forced * 			       modes. When NIC operates with auto-neg the driver * 			       will report Link speed & duplex modes as well as * 			       link partner abilities. When forced link is used, * 			       the driver will report status of the established * 			       link. * 			       Please read tlan.txt for additional information.  * 			     - Removed call to check_region(), and used  * 			       return value of request_region() instead. *	 *	v1.8a May 28, 2000   - Minor updates. * *	v1.9 July 25, 2000   - Fixed a few remaining Full-Duplex issues. *	                     - Updated with timer fixes from Andrew Morton. *	                     - Fixed module race in TLan_Open. *	                     - Added routine to monitor PHY status. *	                     - Added activity led support for Proliant devices. * *	v1.10 Aug 30, 2000   - Added support for EISA based tlan controllers  *			       like the Compaq NetFlex3/E.  *			     - Rewrote tlan_probe to better handle multiple *			       bus probes. Probing and device setup is now *			       done through TLan_Probe and TLan_init_one. Actual *			       hardware probe is done with kernel API and  *			       TLan_EisaProbe. *			     - Adjusted debug information for probing. *			     - Fixed bug that would cause general debug information  *			       to be printed after driver removal.  *			     - Added transmit timeout handling. *			     - Fixed OOM return values in tlan_probe.  *			     - Fixed possible mem leak in tlan_exit  *			       (now tlan_remove_one). *			     - Fixed timer bug in TLan_phyMonitor. *			     - This driver version is alpha quality, please *			       send me any bug issues you may encounter. * *	v1.11 Aug 31, 2000   - Do not try to register irq 0 if no irq line was  *			       set for EISA cards. *			     - Added support for NetFlex3/E with nibble-rate *			       10Base-T PHY. This is untestet as I haven't got *			       one of these cards. *			     - Fixed timer being added twice. *			     - Disabled PhyMonitoring by default as this is *			       work in progress. Define MONITOR to enable it. *			     - Now we don't display link info with PHYs that *			       doesn't support it (level1). *			     - Incresed tx_timeout beacuse of auto-neg. *			     - Adjusted timers for forced speeds. * *	v1.12 Oct 12, 2000   - Minor fixes (memleak, init, etc.) * * 	v1.13 Nov 28, 2000   - Stop flooding console with auto-neg issues * 			       when link can't be established. *			     - Added the bbuf option as a kernel parameter. *			     - Fixed ioaddr probe bug. *			     - Fixed stupid deadlock with MII interrupts. *			     - Added support for speed/duplex selection with  *			       multiple nics. *			     - Added partly fix for TX Channel lockup with *			       TLAN v1.0 silicon. This needs to be investigated *			       further. * * 	v1.14 Dec 16, 2000   - Added support for servicing multiple frames per. * 			       interrupt. Thanks goes to * 			       Adam Keys <adam@ti.com> * 			       Denis Beaudoin <dbeaudoin@ti.com> * 			       for providing the patch. * 			     - Fixed auto-neg output when using multiple * 			       adapters. * 			     - Converted to use new taskq interface. * * 	v1.14a Jan 6, 2001   - Minor adjustments (spinlocks, etc.) * *******************************************************************************/                                                                                #include <linux/module.h>#include "tlan.h"#include <linux/init.h>#include <linux/ioport.h>#include <linux/pci.h>#include <linux/etherdevice.h>#include <linux/delay.h>#include <linux/spinlock.h>#include <linux/mii.h>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -