diff -u --recursive --exclude-from=diff-excludes --new-file linux-0.9.13/config.in linux-lance-0.9.13/config.in
--- linux-0.9.13/config.in	Wed Oct 18 17:19:09 1995
+++ linux-lance-0.9.13/config.in	Wed Oct 18 17:51:52 1995
@@ -102,6 +102,7 @@
 bool 'Ariadne support' CONFIG_ARIADNE n
 bool 'A2065 support' CONFIG_A2065 n
 bool 'Hydra support' CONFIG_HYDRA n
+bool 'Atari Lance support' CONFIG_ATARILANCE y
 bool '3c501 support' CONFIG_EL1 n
 bool '3c503 support' CONFIG_EL2 n
 fi
diff -u --recursive --exclude-from=diff-excludes --new-file linux-0.9.13/drivers/net/Makefile linux-lance-0.9.13/drivers/net/Makefile
--- linux-0.9.13/drivers/net/Makefile	Sat Sep  2 16:37:14 1995
+++ linux-lance-0.9.13/drivers/net/Makefile	Wed Oct 18 17:21:55 1995
@@ -81,6 +81,10 @@
 NETDRV_OBJS := $(NETDRV_OBJS) hydra.o
 endif
 
+ifdef CONFIG_ATARILANCE
+NETDRV_OBJS := $(NETDRV_OBJS) atarilance.o
+endif
+
 ifdef CONFIG_PLIP
 NETDRV_OBJS := $(NETDRV_OBJS) plip.o
 endif
diff -u --recursive --exclude-from=diff-excludes --new-file linux-0.9.13/drivers/net/Space.c linux-lance-0.9.13/drivers/net/Space.c
--- linux-0.9.13/drivers/net/Space.c	Sat Sep  2 16:37:14 1995
+++ linux-lance-0.9.13/drivers/net/Space.c	Wed Oct 18 17:23:42 1995
@@ -61,6 +61,7 @@
 extern int ariadne_probe(struct device *);
 extern int a2065_probe(struct device *);
 extern int hydra_probe(struct device *);
+extern int atarilance_probe(struct device *);
 extern int ni52_probe(struct device *);
 extern int ni65_probe(struct device *);
 extern int SK_init(struct device *);
@@ -150,6 +151,9 @@
 #endif
 #ifdef CONFIG_HYDRA             /* Hydra Systems Amiganet ethernet board */
         && hydra_probe(dev)
+#endif
+#ifdef CONFIG_ATARILANCE	/* Lance-based Atari ethernet boards */
+	&& atarilance_probe(dev)
 #endif
 #ifdef CONFIG_DE600		/* D-Link DE-600 adapter */
 	&& de600_probe(dev)
diff -u --recursive --exclude-from=diff-excludes --new-file linux-0.9.13/drivers/net/atarilance.c linux-lance-0.9.13/drivers/net/atarilance.c
--- linux-0.9.13/drivers/net/atarilance.c	Thu Jan  1 01:00:00 1970
+++ linux-lance-0.9.13/drivers/net/atarilance.c	Tue Oct 24 22:46:13 1995
@@ -0,0 +1,1062 @@
+/* atarilance.c: Ethernet driver for VME Lance cards on the Atari */
+/*
+	Written 1995 by Roman Hodek (rnhodek@cip.informatik.uni-erlangen.de)
+
+	This software may be used and distributed according to the terms
+	of the GNU Public License, incorporated herein by reference.
+
+	This drivers was written with the following sources of reference:
+	 - The driver for the Riebl Lance card by the TU Vienna.
+	 - The modified TUW driver for PAM's VME cards
+	 - The PC-Linux driver for Lance cards (but this is for bus master
+       cards, not the shared memory ones)
+	 - The Amiga Ariadne driver
+
+    To do:
+	 - Is it possible (and how) to set multicast lists with the Atari boards
+	   (Riebl, RAM)
+	 - Are there some races left??
+	 
+*/
+
+static char *version = "atarilance.c: v1.0 10/18/95 "
+					   "Roman.Hodek@informatik.uni-erlangen.de\n";
+
+#include <linux/config.h>
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/ptrace.h>
+#include <linux/errno.h>
+#include <linux/malloc.h>
+#include <linux/interrupt.h>
+#include <linux/atariints.h>
+#include <asm/bitops.h>
+#include <asm/io.h>
+
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+
+struct device *init_etherdev( struct device *dev, int sizeof_private,
+							  unsigned long *mem_startp );
+
+/* Debug level:
+ *  0 = silent, print only serious errors
+ *  1 = normal, print error messages
+ *  2 = debug, print debug infos
+ *  3 = debug, print even more debug infos (packet data)
+ */
+
+#define	LANCE_DEBUG	1
+
+#ifdef LANCE_DEBUG
+int lance_debug = LANCE_DEBUG;
+#else
+int lance_debug = 1;
+#endif
+
+/* Print debug messages on probing? */
+#undef LANCE_DEBUG_PROBE
+
+/* Int at vector #0 ? This happens currently with my board... It doesn't hurt
+ * if this is turned on and the int is at vector #0x50 as it should be. */
+#undef	LANCE_0_INT
+
+
+#define	DPRINTK(n,a)							\
+	do {										\
+		if (lance_debug >= n)					\
+			printk a;							\
+	} while( 0 )
+
+#ifdef LANCE_DEBUG_PROBE
+# define PROBE_PRINT(a)	printk a
+#else
+# define PROBE_PRINT(a)	
+#endif
+
+/* These define the number of Rx and Tx buffers as log2. (Only powers
+ * of two are valid)
+ * Much more rx buffers (32) are reserved than tx buffers (4), since receiving
+ * is more time critical then sending and packets may have to remain in the
+ * board's memory when memory is low.
+ */
+
+#define TX_LOG_RING_SIZE			2
+#define RX_LOG_RING_SIZE			5
+
+/* These are the derived values */
+
+#define TX_RING_SIZE			(1 << TX_LOG_RING_SIZE)
+#define TX_RING_LEN_BITS		(TX_LOG_RING_SIZE << 5)
+#define	TX_RING_MOD_MASK		(TX_RING_SIZE - 1)
+
+#define RX_RING_SIZE			(1 << RX_LOG_RING_SIZE)
+#define RX_RING_LEN_BITS		(RX_LOG_RING_SIZE << 5)
+#define	RX_RING_MOD_MASK		(RX_RING_SIZE - 1)
+
+#define PKT_BUF_SZ		1544
+
+
+/* The LANCE Rx and Tx ring descriptors. */
+struct lance_rx_head {
+	unsigned short			base;		/* Low word of base addr */
+	volatile unsigned char	flag;
+	unsigned char			base_hi;	/* High word of base addr (unused) */
+	short					buf_length;	/* This length is 2s complement! */
+	short					msg_length;	/* This length is "normal". */
+};
+
+struct lance_tx_head {
+	unsigned short			base;		/* Low word of base addr */
+	volatile unsigned char	flag;
+	unsigned char			base_hi;	/* High word of base addr (unused) */
+	short					length;		/* Length is 2s complement! */
+	volatile short			misc;
+};
+
+struct ringdesc {
+	unsigned short	adr_lo;		/* Low 16 bits of address */
+	unsigned char	len;		/* Length bits */
+	unsigned char	adr_hi;		/* High 8 bits of address (unused) */
+};
+
+struct lance_packet {
+	volatile unsigned char	data[PKT_BUF_SZ];
+};
+
+/* The LANCE initialization block, described in databook. */
+struct lance_init_block {
+	unsigned short	mode;		/* Pre-set mode */
+	unsigned char	hwaddr[6];	/* Physical ethernet address */
+	unsigned		filter[2];	/* Multicast filter (unused). */
+	/* Receive and transmit ring base, along with length bits. */
+	struct ringdesc	rx_ring;
+	struct ringdesc	tx_ring;
+};
+
+/* The whole layout of the Lance shared memory */
+struct lance_memory {
+	struct lance_init_block	init;
+	struct lance_tx_head	tx_head[TX_RING_SIZE];
+	struct lance_rx_head	rx_head[RX_RING_SIZE];
+	struct lance_packet		tx_packet[TX_RING_SIZE];
+	struct lance_packet		rx_packet[TX_RING_SIZE];
+};
+
+#define RIEBL_MAGIC			0x09051990
+#define RIEBL_MAGIC_ADDR	((unsigned long *)(((char *)MEM) + 0xee8a))
+#define RIEBL_HWADDR_ADDR	((unsigned char *)(((char *)MEM) + 0xee8e))
+#define RIEBL_IVEC_ADDR		((unsigned short *)(((char *)MEM) + 0xfffe))
+
+struct lance_ioreg {
+/* base+0x0 */	volatile unsigned short	data;
+/* base+0x2 */	volatile unsigned short	addr;
+				unsigned char			_dummy1[3];
+/* base+0x7 */	volatile unsigned char	ivec;
+				unsigned char			_dummy2[5];
+/* base+0xd */	volatile unsigned char	eeprom;
+				unsigned char			_dummy3;
+/* base+0xf */	volatile unsigned char	mem;
+};
+
+enum lance_type {
+	OLD_RIEBL,		/* old Riebl card without battery */
+	NEW_RIEBL,		/* new Riebl card with battery */
+	PAM_CARD		/* PAM card with EEPROM */
+};
+
+char *lance_names[] = {
+	"Riebl-Card (without battery)",
+	"Riebl-Card (with battery)",
+	"PAM intern card"
+};
+
+/* This is a default address for the old RieblCards without a battery
+ * that have no ethernet address at boot time. 00:00:36:04 is the
+ * prefix for Riebl cards, the 00:00 at the end is arbitrary.
+ */
+
+unsigned char OldRieblDefHwaddr[6] = {
+	0x00, 0x00, 0x36, 0x04, 0x00, 0x00
+};
+
+struct lance_private {
+	enum lance_type		cardtype;
+	struct lance_ioreg	*iobase;
+	struct lance_memory	*mem;
+	int					cur_rx, cur_tx;	/* The next free ring entry */
+	int					dirty_tx;		/* Ring entries to be freeed. */
+	struct enet_statistics stats;
+	char				tx_full;
+	char				lock;
+};
+
+#define	MEM		lp->mem
+#define	IO		lp->iobase
+#define	DREG	IO->data
+#define	AREG	IO->addr
+#define	REGA(a)	( AREG = (a), DREG )
+
+/* Possible addresses */
+
+unsigned long lance_memaddr_list[] = {
+	0xfe010000,		/* Rieblcard VME in TT */
+	0xfec10000,		/* Rieblcard VME in MegaSTE (highest byte stripped) */
+	0xfee00000,		/* Rieblcard in ST (highest byte stripped) */
+	0xfecf0000		/* PAM card VME in TT and MSTE (highest byte stripped) */
+};
+
+unsigned long lance_ioport_list[] = {
+	0xfe00fff0,		/* Rieblcard VME in TT */
+	0xfec0fff0,		/* Rieblcard VME in MegaSTE (highest byte stripped) */
+	0xfeff7000,		/* Rieblcard in ST (highest byte stripped) */
+	0xfecffff0		/* PAM card VME in TT and MSTE (highest byte stripped) */
+};
+
+#define	N_LANCE_ADDR	(sizeof(lance_ioport_list)/sizeof(*lance_ioport_list))
+
+struct {
+	enum lance_type	type;
+	char			*name;
+} chip_table[] = {
+	{ OLD_RIEBL,	"old Rieblcard (without battery)" },
+	{ NEW_RIEBL,	"new Rieblcard (with battery)" },
+	{ PAM_CARD,		"PAM intern" },
+};
+
+
+/* Definitions for the Lance */
+
+/* tx_head flags */
+#define	TMD1_ENP		0x01
+#define TMD1_STP		0x02
+#define	TMD1_DEF		0x04
+#define TMD1_ONE		0x08
+#define	TMD1_MORE		0x10
+#define	TMD1_ERR		0x40
+#define TMD1_OWN 		0x80
+
+#define TMD1_OWN_CHIP	TMD1_OWN
+#define TMD1_OWN_HOST	0
+
+/* tx_head misc field */
+#define TMD3_TDR		0x03FF
+#define TMD3_RTRY		0x0400
+#define TMD3_LCAR		0x0800
+#define TMD3_LCOL		0x1000
+#define TMD3_UFLO		0x4000
+#define TMD3_BUFF3		0x8000
+
+/* rx_head flags */
+#define	RMD1_ENP		0x01
+#define RMD1_STP		0x02
+#define RMD1_BUFF		0x04
+#define RMD1_CRC		0x08
+#define RMD1_OFLO		0x10
+#define RMD1_FRAM		0x20
+#define	RMD1_ERR		0x40
+#define RMD1_OWN 		0x80
+
+#define RMD1_OWN_CHIP	RMD1_OWN
+#define RMD1_OWN_HOST	0
+
+/* register names */
+#define CSR0	0
+#define CSR1	1
+#define CSR2	2
+#define CSR3	3
+
+/* CSR0 */
+#define CSR0_INIT	0x0001		/* initialize */
+#define CSR0_STRT	0x0002		/* start */
+#define CSR0_STOP	0x0004		/* stop */
+#define CSR0_TDMD	0x0008		/* transmit demand */
+#define CSR0_TXON	0x0010		/* transmitter on */
+#define CSR0_RXON	0x0020		/* receiver on */
+#define CSR0_INEA	0x0040		/* interrupt enable */
+#define CSR0_INTR	0x0080		/* interrupt active */
+#define CSR0_IDON	0x0100		/* initialization done */
+#define CSR0_TINT	0x0200		/* transmitter interrupt */
+#define CSR0_RINT	0x0400		/* receiver interrupt */
+#define CSR0_MERR	0x0800		/* memory error */
+#define CSR0_MISS	0x1000		/* missed frame */
+#define CSR0_CERR	0x2000		/* carrier error (no heartbeat :-) */
+#define CSR0_BABL	0x4000		/* babble: tx-ed too many bits */
+#define CSR0_ERR	0x8000		/* error */
+
+/* CSR3 */
+#define CSR3_BCON	0x0001
+#define CSR3_ACON	0x0002
+#define CSR3_BSWP	0x0004
+
+
+
+/***************************** Prototypes *****************************/
+
+static int addr_readable( volatile void *regp, int wordflag );
+static unsigned long lance_probe1( struct device *dev, volatile unsigned
+                                   short *memaddr, volatile unsigned short
+                                   *ioaddr );
+static int lance_open( struct device *dev );
+static void lance_init_ring( struct device *dev );
+static int lance_start_xmit( struct sk_buff *skb, struct device *dev );
+static void lance_interrupt( struct intframe *fp, struct device *dev );
+static int lance_rx( struct device *dev );
+static int lance_close( struct device *dev );
+static struct enet_statistics *lance_get_stats( struct device *dev );
+static void set_multicast_list( struct device *dev, int num_addrs, void
+                                *addrs );
+static int lance_set_mac_address( struct device *dev, void *addr );
+
+/************************* End of Prototypes **************************/
+
+
+
+
+
+static __inline__ void memcpyw( u_short *dest, u_short *src, int len )
+
+{
+	if (len <= 0)
+		return;
+	
+    __asm__ __volatile__
+		("1: movew %1@+,%0@+	\n\t"
+		 "   dbra  %2,1b"
+	  : "=a" (dest), "=a" (src), "=g" (len)
+	  : "0" (dest), "1" (src), "2" (((len+1)/2)-1) );
+}
+
+
+unsigned long atarilance_probe( struct device *dev )
+
+{	int		i;
+
+	for( i = 0; i < N_LANCE_ADDR; ++i ) {
+		if (lance_probe1( dev,
+						  (unsigned short *)lance_memaddr_list[i],
+						  (unsigned short *)lance_ioport_list[i] ))
+			return( 0 );
+	}
+
+	return( ENODEV );
+}
+
+
+/* Derived from hwreg_present() in atari/config.c: */
+
+static int addr_readable( volatile void *regp, int wordflag )
+
+{	int		ret;
+	long	flags;
+	long	*vbr, save_berr;
+
+	save_flags(flags);
+	cli();
+
+	__asm__ __volatile__ ( "movec	vbr,%0" : "=r" (vbr) : );
+	save_berr = vbr[2];
+	
+	__asm__ __volatile__
+	(	"movel	sp,d1\n\t"
+		"movel	#Lberr,%2@\n\t"
+		"moveq	#0,%0\n\t"
+		"tstl   %3\n\t"
+		"bne	1f\n\t"
+		"tstb	%1@\n\t"
+		"bra	2f\n"
+"1:		 tstw	%1@\n"
+"2:		 moveq	#1,%0\n"
+"Lberr:	 movel	d1,sp"
+		: "=&d" (ret)
+		: "a" (regp), "a" (&vbr[2]), "rm" (wordflag)
+		: "d1", "memory"
+	);
+
+	vbr[2] = save_berr;
+	restore_flags(flags);
+	
+	return( ret );
+}
+
+#ifdef LANCE_0_INT
+
+static int int0_cnt = 0;
+static int int0_printed = 0;
+
+__asm__
+("	.text\n\t"
+ "_atalance_inthandler:\n\t"
+ "	movel	d0,sp@-\n\t"
+ "	movew	sp@(10),d0\n\t"
+ "	andw	#0xf000,d0\n\t"
+ "	orw		#4*0x50,d0\n\t"
+ "	movew	d0,sp@(10)\n\t"
+ "	addql	#1,_int0_cnt\n\t"
+ "	movel	sp@+,d0\n\t"
+ "	jmp		_inthandler\n"
+);
+
+extern void atalance_inthandler( void );
+
+#endif
+
+
+static unsigned long lance_probe1( struct device *dev,
+								   volatile unsigned short *memaddr,
+								   volatile unsigned short *ioaddr )
+
+{	struct lance_private	*lp;
+	int 					i;
+	static int 				did_version = 0;
+	
+	PROBE_PRINT(( "Probing for Lance card at mem %#lx io %#lx\n",
+				  (long)memaddr, (long)ioaddr ));
+
+	/* Test whether memory readable */
+	PROBE_PRINT(( "lance_probe1: testing memory to be readable\n" ));
+	if (!addr_readable( memaddr, 1 )) goto probe_fail;
+
+	/* Written values should come back... */
+	PROBE_PRINT(( "lance_probe1: testing memory to be writable (1)\n" ));
+	*memaddr = 0x0001;
+	if (*memaddr != 0x0001) goto probe_fail;
+	PROBE_PRINT(( "lance_probe1: testing memory to be writable (2)\n" ));
+	*memaddr = 0x0000;
+	if (*memaddr != 0x0000) goto probe_fail;
+
+	/* First port should be readable */
+	PROBE_PRINT(( "lance_probe1: testing ioport to be readable\n" ));
+	if (!addr_readable( ioaddr, 1 )) goto probe_fail;
+
+	/* and written values should be readable */
+	PROBE_PRINT(( "lance_probe1: testing ioport to be writeable\n" ));
+	*(unsigned short *)ioaddr = 0x0001;
+	if (*(unsigned short *)ioaddr != 0x0001) goto probe_fail;
+
+	/* CSR0_STOP should not be readable */
+	PROBE_PRINT(( "lance_probe1: testing CSR0 register function (1)\n" ));
+	ioaddr[1] = CSR0;
+	ioaddr[0] = CSR0_INIT | CSR0_STOP;
+	if (ioaddr[0] != CSR0_STOP) goto probe_fail;
+	PROBE_PRINT(( "lance_probe1: testing CSR0 register function (2)\n" ));
+	ioaddr[0] = CSR0_STOP;
+	if (ioaddr[0] != CSR0_STOP) goto probe_fail;
+
+	/* Now ok... */
+	PROBE_PRINT(( "lance_probe1: Lance card detected\n" ));
+	goto probe_ok;
+
+  probe_fail:
+	return( 0 );
+	
+  probe_ok:
+	init_etherdev( dev, sizeof(struct lance_private), NULL );
+	dev->priv = kmalloc(sizeof(struct lance_private), GFP_KERNEL);
+	lp = (struct lance_private *)dev->priv;
+	MEM = (struct lance_memory *)memaddr;
+	IO = (struct lance_ioreg *)ioaddr;
+	dev->base_addr = (unsigned long)ioaddr; /* informational only */
+
+	REGA( CSR0 ) = CSR0_STOP;
+
+	/* Now test for type: If the eeprom I/O port is readable, it is a
+	 * PAM card */
+	if (addr_readable( &(IO->eeprom), 0 )) {
+		/* Switch back to Ram */
+		i = IO->mem;
+		lp->cardtype = PAM_CARD;
+	}
+	else if (*RIEBL_MAGIC_ADDR == RIEBL_MAGIC) {
+		lp->cardtype = NEW_RIEBL;
+	}
+	else
+		lp->cardtype = OLD_RIEBL;
+		
+	printk("%s: %s at io %#lx, mem %#lx, hwaddr ",
+		   dev->name, lance_names[lp->cardtype],
+		   (unsigned long)ioaddr,
+		   (unsigned long)memaddr );
+
+	/* Get the ethernet address */
+	switch( lp->cardtype ) {
+	  case OLD_RIEBL:
+		/* No ethernet address! (Set some default address) */
+		memcpy( dev->dev_addr, OldRieblDefHwaddr, 6 );
+		break;
+	  case NEW_RIEBL:
+		memcpy( dev->dev_addr, RIEBL_HWADDR_ADDR, 6 );
+		break;
+	  case PAM_CARD:
+		i = IO->eeprom;
+		for( i = 0; i < 6; ++i )
+			dev->dev_addr[i] = 
+				((((unsigned short *)MEM)[i*2] & 0x0f) << 4) |
+				((((unsigned short *)MEM)[i*2+1] & 0x0f));
+		i = IO->mem;
+		break;
+	}
+	for( i = 0; i < 6; ++i )
+		printk( "%02x%s", dev->dev_addr[i], (i < 5) ? ":" : "\n" );
+	if (lp->cardtype == OLD_RIEBL) {
+		printk( "%s: Warning: This is a default ethernet address!\n",
+				dev->name );
+		printk( "      Use \"ifconfig hw ether ...\" to set the address.\n" );
+	}
+	
+	MEM->init.mode = 0x0000;		/* Disable Rx and Tx. */
+	for( i = 0; i < 6; i++ )
+		MEM->init.hwaddr[i] = dev->dev_addr[i^1]; /* <- 16 bit swap! */
+	MEM->init.filter[0] = 0x00000000;
+	MEM->init.filter[1] = 0x00000000;
+	MEM->init.rx_ring.adr_lo = offsetof( struct lance_memory, rx_head );
+	MEM->init.rx_ring.adr_hi = 0;
+	MEM->init.rx_ring.len    = RX_RING_LEN_BITS;
+	MEM->init.tx_ring.adr_lo = offsetof( struct lance_memory, tx_head );
+	MEM->init.tx_ring.adr_hi = 0;
+	MEM->init.tx_ring.len    = TX_RING_LEN_BITS;
+
+	if (lp->cardtype == PAM_CARD ||
+		memaddr == (unsigned short *)0xffe00000) {
+		/* PAMs card and Riebl on ST use level 5 autovector */
+		add_isr( IRQ5, (isrfunc)lance_interrupt, 0, dev );
+		dev->irq = 29;
+	}
+	else {
+		/* RieblCards on VME use vector 0x50, which is the same as the
+		 * IO0 bit of the TT MFP */
+		add_isr( IRQ_TT_MFP_IO0, (isrfunc)lance_interrupt, 0, dev );
+		dev->irq = 0x50;
+#ifdef LANCE_0_INT
+		{	long	*vbr;
+			__asm__ __volatile__ ( "movec	vbr,%0" : "=r" (vbr) : );
+			vbr[0] = (long)atalance_inthandler;
+		}
+#endif
+	}
+
+	if (lp->cardtype == PAM_CARD)
+		IO->ivec = dev->irq;
+	else
+		*RIEBL_IVEC_ADDR = dev->irq;
+	
+	if (did_version++ == 0)
+		DPRINTK( 1, ( version ));
+
+	/* The LANCE-specific entries in the device structure. */
+	dev->open = &lance_open;
+	dev->hard_start_xmit = &lance_start_xmit;
+	dev->stop = &lance_close;
+	dev->get_stats = &lance_get_stats;
+	dev->set_multicast_list = &set_multicast_list;
+	dev->set_mac_address = &lance_set_mac_address;
+	dev->start = 0;
+	
+	return( 1 );
+}
+
+
+static int lance_open( struct device *dev )
+
+{	struct lance_private *lp = (struct lance_private *)dev->priv;
+	int i;
+
+	DPRINTK( 2, ( "%s: lance_open()\n", dev->name ));
+
+	lance_init_ring(dev);
+	/* Re-initialize the LANCE, and start it when done. */
+
+	REGA( CSR3 ) = CSR3_BSWP | (lp->cardtype == PAM_CARD ? CSR3_ACON : 0); 
+	REGA( CSR2 ) = 0;
+	REGA( CSR1 ) = 0;
+	REGA( CSR0 ) = CSR0_INIT | CSR0_STRT;
+
+	i = 1000000;
+	while (i-- > 0)
+		if (DREG & CSR0_IDON)
+			break;
+	if (i < 0 || (DREG & CSR0_ERR)) {
+		DPRINTK( 2, ( "lance_open(): opening %s failed, i=%d, csr0=%04x\n",
+					  dev->name, i, DREG ));
+		DREG = CSR0_STOP;
+		return( -EIO );
+	}
+	DREG = CSR0_IDON;
+	DREG = CSR0_INEA;
+	
+	dev->tbusy = 0;
+	dev->interrupt = 0;
+	dev->start = 1;
+
+	DPRINTK( 2, ( "%s: LANCE is open, csr0 %04x\n", dev->name, DREG ));
+
+	return( 0 );
+}
+
+
+/* Initialize the LANCE Rx and Tx rings. */
+
+static void lance_init_ring( struct device *dev )
+
+{	struct lance_private *lp = (struct lance_private *)dev->priv;
+	int i;
+
+	lp->lock = 0;
+	lp->tx_full = 0;
+	lp->cur_rx = lp->cur_tx = 0;
+	lp->dirty_tx = 0;
+
+	for (i = 0; i < TX_RING_SIZE; i++) {
+		MEM->tx_head[i].base = offsetof( struct lance_memory, tx_packet[i] );
+		MEM->tx_head[i].flag = TMD1_OWN_HOST;
+ 		MEM->tx_head[i].base_hi = 0;
+		MEM->tx_head[i].length = 0;
+		MEM->tx_head[i].misc = 0;
+	}
+
+	for (i = 0; i < RX_RING_SIZE; i++) {
+		MEM->rx_head[i].base = offsetof( struct lance_memory, rx_packet[i] );
+		MEM->rx_head[i].flag = TMD1_OWN_CHIP;
+		MEM->rx_head[i].base_hi = 0;
+		MEM->rx_head[i].buf_length = -PKT_BUF_SZ;
+		MEM->rx_head[i].msg_length = 0;
+	}
+}
+
+
+static int lance_start_xmit( struct sk_buff *skb, struct device *dev )
+
+{	struct lance_private *lp = (struct lance_private *)dev->priv;
+	int entry, len;
+	unsigned long flags;
+	
+	/* Transmitter timeout, serious problems. */
+	if (dev->tbusy) {
+		int tickssofar = jiffies - dev->trans_start;
+		if (tickssofar < 20)
+			return( 1 );
+		AREG = CSR0;
+		DPRINTK( 1, ( "%s: transmit timed out, status %04x, resetting.\n",
+					  dev->name, DREG ));
+		DREG = CSR0_STOP;
+		lp->stats.tx_errors++;
+#ifndef final_version
+		{	int i;
+			DPRINTK( 2, ( "Ring data: dirty_tx %d cur_tx %d%s cur_rx %d\n",
+						  lp->dirty_tx, lp->cur_tx,
+						  lp->tx_full ? " (full)" : "",
+						  lp->cur_rx ));
+			for( i = 0 ; i < RX_RING_SIZE; i++ )
+				DPRINTK( 2, ( "rx #%d: base=%04x blen=%04x mlen=%04x\n",
+							  i, MEM->rx_head[i].base,
+							  -MEM->rx_head[i].buf_length,
+							  MEM->rx_head[i].msg_length ));
+			for( i = 0 ; i < TX_RING_SIZE; i++ )
+				DPRINTK( 2, ( "tx #%d: base=%04x len=%04x misc=%04x\n",
+							  i, MEM->tx_head[i].base,
+							  -MEM->tx_head[i].length,
+							  MEM->tx_head[i].misc ));
+		}
+#endif
+		lance_init_ring(dev);
+		DREG = CSR0_INEA | CSR0_INIT | CSR0_STRT;
+
+		dev->tbusy = 0;
+		dev->trans_start = jiffies;
+
+		return( 0 );
+	}
+
+	if (skb == NULL) {
+		dev_tint( dev );
+		return( 0 );
+	}
+
+	if (skb->len <= 0)
+		return( 0 );
+
+	DPRINTK( 2, ( "%s: lance_start_xmit() called, csr0 %4.4x.\n",
+				  dev->name, REGA( CSR0 ) ));
+
+	/* Block a timer-based transmit from overlapping.  This could better be
+	   done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
+	if (set_bit( 0, (void*)&dev->tbusy ) != 0) {
+		DPRINTK( 0, ( "%s: Transmitter access conflict.\n", dev->name ));
+		return 1;
+	}
+
+	if (set_bit( 0, (void*)&lp->lock ) != 0) {
+		DPRINTK( 0, ( "%s: tx queue lock!.\n", dev->name ));
+		/* don't clear dev->tbusy flag. */
+		return 1;
+	}
+
+	/* Fill in a Tx ring entry */
+	if (lance_debug >= 3) {
+		u_char *p;
+		int i;
+		printk( "%s: TX pkt type 0x%04x from ", dev->name,
+				((u_short *)skb->data)[6]);
+		for( p = &((u_char *)skb->data)[6], i = 0; i < 6; i++ )
+			printk("%02x%s", *p++, i != 5 ? ":" : "" );
+		printk(" to ");
+		for( p = (u_char *)skb->data, i = 0; i < 6; i++ )
+			printk("%02x%s", *p++, i != 5 ? ":" : "" );
+		printk(" data at 0x%08x len %d\n", (int)skb->data,
+			   (int)skb->len );
+	}
+
+	/* Mask to ring buffer boundary. */
+	entry = lp->cur_tx & TX_RING_MOD_MASK;
+
+	/* Caution: the write order is important here, set the "ownership" bits
+	 * last.
+	 */
+
+	/* The old LANCE chips doesn't automatically pad buffers to min. size. */
+	len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
+	/* PAM-Card has a bug: Can only send packets with even number of bytes! */
+	if (lp->cardtype == PAM_CARD && (len & 1))
+		++len;
+	MEM->tx_head[entry].length = -len;
+	MEM->tx_head[entry].misc = 0;
+	memcpyw( (u_short *)MEM->tx_packet[entry].data,
+			 (u_short *)skb->data,
+			 skb->len );
+	MEM->tx_head[entry].base = offsetof(struct lance_memory, tx_packet[entry]);
+	MEM->tx_head[entry].base_hi = 0;
+	MEM->tx_head[entry].flag = TMD1_OWN_CHIP | TMD1_ENP | TMD1_STP;
+	dev_kfree_skb( skb, FREE_WRITE );
+	lp->cur_tx++;
+	while( lp->cur_tx >= TX_RING_SIZE && lp->dirty_tx >= TX_RING_SIZE ) {
+		lp->cur_tx -= TX_RING_SIZE;
+		lp->dirty_tx -= TX_RING_SIZE;
+	}
+
+	/* Trigger an immediate send poll. */
+	REGA( CSR0 ) = CSR0_INEA | CSR0_TDMD;
+	dev->trans_start = jiffies;
+
+	save_flags(flags);
+	cli();
+	lp->lock = 0;
+	if ((MEM->tx_head[(entry+1) & TX_RING_MOD_MASK].flag & TMD1_OWN) ==
+		TMD1_OWN_HOST)
+		dev->tbusy = 0;
+	else
+		lp->tx_full = 1;
+	restore_flags(flags);
+
+	return 0;
+}
+
+/* The LANCE interrupt handler. */
+
+static void lance_interrupt( struct intframe *fp, struct device *dev )
+
+{	struct lance_private *lp;
+	int csr0, boguscnt = 10;
+
+#ifdef LANCE_0_INT
+	if (int0_cnt > 0) {
+		if (lance_debug >= 2 || int0_printed < 10)
+			printk( "%s: seen %d #0 ints\n", dev->name, int0_cnt );
+		int0_cnt = 0;
+		int0_printed++;
+	}
+#endif
+	
+	if (dev == NULL) {
+		DPRINTK( 1, ( "lance_interrupt(): interrupt for unknown device.\n" ));
+		return;
+	}
+
+	lp = (struct lance_private *)dev->priv;
+	AREG = CSR0;
+
+	if (dev->interrupt)
+		DPRINTK( 2, ( "%s: Re-entering the interrupt handler.\n", dev->name ));
+	dev->interrupt = 1;
+
+	while( ((csr0 = DREG) & (CSR0_ERR | CSR0_TINT | CSR0_RINT)) &&
+		   --boguscnt >= 0) {
+		/* Acknowledge all of the current interrupt sources ASAP. */
+		DREG = csr0 & ~(CSR0_INIT | CSR0_STRT | CSR0_STOP |
+									CSR0_TDMD | CSR0_INEA);
+
+		DPRINTK( 2, ( "%s: interrupt  csr0=%04x new csr=%04x.\n",
+					  dev->name, csr0, DREG ));
+
+		if (csr0 & CSR0_RINT)			/* Rx interrupt */
+			lance_rx( dev );
+
+		if (csr0 & CSR0_TINT) {			/* Tx-done interrupt */
+			int dirty_tx = lp->dirty_tx;
+
+			while( dirty_tx < lp->cur_tx) {
+				int entry = dirty_tx & TX_RING_MOD_MASK;
+				int status = MEM->tx_head[entry].flag;
+			
+				if (status & TMD1_OWN_CHIP)
+					break;			/* It still hasn't been Txed */
+
+				MEM->tx_head[entry].flag = 0;
+
+				if (status & TMD1_ERR) {
+					/* There was an major error, log it. */
+					int err_status = MEM->tx_head[entry].misc;
+					lp->stats.tx_errors++;
+					if (err_status & TMD3_RTRY) lp->stats.tx_aborted_errors++;
+					if (err_status & TMD3_LCAR) lp->stats.tx_carrier_errors++;
+					if (err_status & TMD3_LCOL) lp->stats.tx_window_errors++;
+					if (err_status & TMD3_UFLO) {
+						/* Ackk!  On FIFO errors the Tx unit is turned off! */
+						lp->stats.tx_fifo_errors++;
+						/* Remove this verbosity later! */
+						DPRINTK( 1, ( "%s: Tx FIFO error! Status %04x\n",
+									  dev->name, csr0 ));
+						/* Restart the chip. */
+						DREG = CSR0_STRT;
+					}
+				} else {
+					if (status & (TMD1_MORE | TMD1_ONE | TMD1_DEF))
+						lp->stats.collisions++;
+					lp->stats.tx_packets++;
+				}
+				dirty_tx++;
+			}
+
+#ifndef final_version
+			if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) {
+				DPRINTK( 0, ( "out-of-sync dirty pointer,"
+							  " %d vs. %d, full=%d.\n",
+							  dirty_tx, lp->cur_tx, lp->tx_full ));
+				dirty_tx += TX_RING_SIZE;
+			}
+#endif
+
+			if (lp->tx_full && dev->tbusy
+				&& dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) {
+				/* The ring is no longer full, clear tbusy. */
+				lp->tx_full = 0;
+				dev->tbusy = 0;
+				mark_bh( NET_BH );
+			}
+
+			lp->dirty_tx = dirty_tx;
+		}
+
+		/* Log misc errors. */
+		if (csr0 & CSR0_BABL) lp->stats.tx_errors++; /* Tx babble. */
+		if (csr0 & CSR0_MISS) lp->stats.rx_errors++; /* Missed a Rx frame. */
+		if (csr0 & CSR0_MERR) {
+			DPRINTK( 1, ( "%s: Bus master arbitration failure (?!?), "
+						  "status %04x.\n", dev->name, csr0 ));
+			/* Restart the chip. */
+			DREG = CSR0_STRT;
+		}
+	}
+
+    /* Clear any other interrupt, and set interrupt enable. */
+	REGA( CSR0 ) = CSR0_BABL | CSR0_CERR | CSR0_MISS | CSR0_MERR |
+				   CSR0_IDON | CSR0_INEA;
+
+	DPRINTK( 2, ( "%s: exiting interrupt, csr0=%#04x.\n",
+				  dev->name, DREG ));
+	dev->interrupt = 0;
+	return;
+}
+
+
+static int lance_rx( struct device *dev )
+
+{	struct lance_private *lp = (struct lance_private *)dev->priv;
+	int entry = lp->cur_rx & RX_RING_MOD_MASK;
+	int i;
+
+	DPRINTK( 2, ( "%s: rx int, flag=%04x\n", dev->name,
+				  MEM->rx_head[entry].flag ));
+	
+	/* If we own the next entry, it's a new packet. Send it up. */
+	while( (MEM->rx_head[entry].flag & RMD1_OWN) == RMD1_OWN_HOST ) {
+		int status = MEM->rx_head[entry].flag;
+
+		if (status != (RMD1_ENP|RMD1_STP)) {		/* There was an error. */
+			/* There is a tricky error noted by John Murphy,
+			   <murf@perftech.com> to Russ Nelson: Even with full-sized
+			   buffers it's possible for a jabber packet to use two
+			   buffers, with only the last correctly noting the error. */
+			if (status & RMD1_ENP)	/* Only count a general error at the */
+				lp->stats.rx_errors++; /* end of a packet.*/
+			if (status & RMD1_FRAM) lp->stats.rx_frame_errors++;
+			if (status & RMD1_OFLO) lp->stats.rx_over_errors++;
+			if (status & RMD1_CRC) lp->stats.rx_crc_errors++;
+			if (status & RMD1_BUFF) lp->stats.rx_fifo_errors++;
+			MEM->rx_head[entry].flag &= (RMD1_ENP|RMD1_STP);
+		} else {
+			/* Malloc up new buffer, compatible with net-2e. */
+			short pkt_len = MEM->rx_head[entry].msg_length & 0xfff;
+			struct sk_buff *skb;
+
+			skb = alloc_skb( pkt_len, GFP_ATOMIC );
+			if (skb == NULL) {
+				DPRINTK( 1, ( "%s: Memory squeeze, deferring packet.\n",
+							  dev->name ));
+				for( i = 0; i < RX_RING_SIZE; i++ )
+				  if (MEM->rx_head[(entry+i) & RX_RING_MOD_MASK].flag &
+					  RMD1_OWN_CHIP)
+					break;
+
+				if (i > RX_RING_SIZE - 2) {
+				  lp->stats.rx_dropped++;
+				  MEM->rx_head[entry].flag |= RMD1_OWN_CHIP;
+				  lp->cur_rx++;
+				}
+				break;
+			}
+			skb->len = pkt_len;
+			skb->dev = dev;
+			memcpyw( (u_short *)skb->data,
+					 (u_short *)MEM->rx_packet[entry].data,
+					 pkt_len );
+
+			if (lance_debug >= 3) {
+				u_char *p;
+				printk( "%s: RX pkt type 0x%04x from ", dev->name,
+						((u_short *)skb->data)[6]);
+				for( p = &((u_char *)skb->data)[6], i = 0; i < 6; i++ )
+					printk("%02x%s", *p++, i != 5 ? ":" : "" );
+				printk(" to ");
+				for( p = (u_char *)skb->data, i = 0; i < 6; i++ )
+					printk("%02x%s", *p++, i != 5 ? ":" : "" );
+				printk(" data at 0x%08x len %d\n", (int)skb->data,
+					   (int)skb->len );
+			}
+
+			netif_rx( skb );
+			lp->stats.rx_packets++;
+		}
+
+		/* The docs say that the buffer length isn't touched, but Andrew Boyd
+		   of QNX reports that some revs of the 79C965 clear it. */
+		MEM->rx_head[entry].buf_length = -PKT_BUF_SZ;
+		MEM->rx_head[entry].flag |= RMD1_OWN_CHIP;
+		entry = (++lp->cur_rx) & RX_RING_MOD_MASK;
+	}
+	lp->cur_rx &= RX_RING_MOD_MASK;
+
+	/* We should check that at least two ring entries are free.	 If not,
+	   we should free one and mark stats->rx_dropped++. */
+
+	return 0;
+}
+
+
+static int lance_close( struct device *dev )
+
+{	struct lance_private *lp = (struct lance_private *)dev->priv;
+
+	dev->start = 0;
+	dev->tbusy = 1;
+
+	AREG = CSR0;
+
+	DPRINTK( 2, ( "%s: Shutting down ethercard, status was %2.2x.\n",
+				  dev->name, DREG ));
+
+	/* We stop the LANCE here -- it occasionally polls
+	   memory if we don't. */
+	DREG = CSR0_STOP;
+
+	return 0;
+}
+
+
+static struct enet_statistics *lance_get_stats( struct device *dev )
+
+{	struct lance_private *lp = (struct lance_private *)dev->priv;
+
+	return &lp->stats;
+}
+
+
+/* Set or clear the multicast filter for this adaptor.
+   num_addrs == -1		Promiscuous mode, receive all packets
+   num_addrs == 0		Normal mode, clear multicast list
+   num_addrs > 0		Multicast mode, receive normal and MC packets, and do
+						best-effort filtering.
+ */
+
+static void set_multicast_list( struct device *dev, int num_addrs,
+								void *addrs )
+
+{
+
+/* Don't know if that works with the Atari cards... */
+#if 0
+	struct lance_private *lp = (struct lance_private *)dev->priv;
+	
+	/* We take the simple way out and always enable promiscuous mode. */
+	REGA( CSR0 ) = CSR0_STOP; /* Temporarily stop the lance. */
+
+	AREG = 15;
+	if (num_addrs >= 0) {
+		short multicast_table[4];
+		int i;
+		/* We don't use the multicast table, but rely on upper-layer filtering. */
+		memset( multicast_table, (num_addrs == 0) ? 0 : -1,
+				sizeof(multicast_table) );
+		for( i = 0; i < 4; i++ ) {
+			AREG = 8 + i;
+			DREG = multicast_table[i];
+		}
+		DREG = 0; /* Unset promiscuous mode */
+	} else {
+		/* Log any net taps. */
+		DPRINTK( 0, ( "%s: Promiscuous mode enabled.\n", dev->name ));
+		DREG = 0x8000; /* Set promiscuous mode */
+	}
+
+	/* Resume normal operation. */
+	REGA( CSR0 ) = CSR0_IDON | CSR0_INEA | CSR0_STRT;
+#endif
+}
+
+
+/* This is needed for old RieblCards and possible for new RieblCards */
+
+static int lance_set_mac_address( struct device *dev, void *addr )
+
+{	struct lance_private *lp = (struct lance_private *)dev->priv;
+	int i;
+	
+	if (lp->cardtype != OLD_RIEBL && lp->cardtype != NEW_RIEBL)
+		return( -EOPNOTSUPP );
+
+	if (dev->start) {
+		/* Only possible while card isn't started */
+		DPRINTK( 1, ( "%s: hwaddr can be set only while card isn't open.\n",
+					  dev->name ));
+		return( -EIO );
+	}
+
+	memcpy( dev->dev_addr, addr, 6 );
+	for( i = 0; i < 6; i++ )
+		MEM->init.hwaddr[i] = dev->dev_addr[i^1]; /* <- 16 bit swap! */
+	memcpy( RIEBL_HWADDR_ADDR, dev->dev_addr, 6 );
+	/* set also the magic for future sessions */
+	*RIEBL_MAGIC_ADDR = RIEBL_MAGIC;
+	
+	return( 0 );
+}
+
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  tab-width: 4
+ * End:
+ */
