Date: Wed, 15 Jul 1998 22:42:32 +0100
From: Richard Hirst <richard@sleepie.demon.co.uk>
To: Jes Sorensen <Jes.Sorensen@cern.ch>, linux-m68k@lists.linux-m68k.org
Subject: Re: L68K: 2.1.108
References: <199807101625.SAA26767@valhall.cern.ch>
In-Reply-To: <199807101625.SAA26767@valhall.cern.ch>; from Jes Sorensen on Fri, Jul 10, 1998 at 06:25:09PM +0200
Sender: owner-linux-m68k@phil.uni-sb.de

On Fri, Jul 10, 1998 at 06:25:09PM +0200, Jes Sorensen wrote:
> Hi
> 
> 2.1.108 is out, may you have a lot of fun with it.
> 
> Its mainly a `i've been away for almost 3 weeks, lets get something out
> the door to get in sync release', thus some patches are probably
> missing.

The fixes for the 53c710 driver are missing.  They are included in the
attached patch, which also removes apricot.c and replaces it with 82596.c,
an ethernet driver for Intel 82596 on Intel and 68k hardware.

Richard.


diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/arch/m68k/config.in linuxvme-2.1.108/arch/m68k/config.in
--- linux68k-2.1.108+Geert/arch/m68k/config.in	Wed Jul 15 21:16:11 1998
+++ linuxvme-2.1.108/arch/m68k/config.in	Tue Jul 14 08:38:56 1998
@@ -60,10 +61,13 @@
     bool 'Use 68060 specific optimizations' CONFIG_OPTIMIZE_060
   fi
 fi
+if [ "$CONFIG_VME" = "y" -a "$CONFIG_M68060" = "y" ]; then
+  define_bool CONFIG_060_WRITETHROUGH y
+fi
 bool 'Advanced processor options' CONFIG_ADVANCED_CPU
 if [ "$CONFIG_ADVANCED_CPU" = "y" ]; then
   bool 'Use read-modify-write instructions' CONFIG_RMW_INSNS
-  if [ "$CONFIG_M68060" = "y" ]; then
+  if [ "$CONFIG_M68060" = "y" -a "$CONFIG_VME" = "n" ]; then
     bool 'Use write-through caching for 68060 supervisor accesses' CONFIG_060_WRITETHROUGH
   fi
 fi
@@ -227,10 +231,10 @@
   bool 'Mac NS 8390 based ethernet cards' CONFIG_DAYNAPORT
 fi
 if [ "$CONFIG_VME" = "y" -a "$CONFIG_MVME16x" = "y" ]; then
-  bool 'MVME16x Ethernet support' CONFIG_APRICOT
+  bool 'MVME16x Ethernet support' CONFIG_MVME16x_NET
 fi
 if [ "$CONFIG_VME" = "y" -a "$CONFIG_BVME6000" = "y" ]; then
-  bool 'BVME6000 Ethernet support' CONFIG_APRICOT
+  bool 'BVME6000 Ethernet support' CONFIG_BVME6000_NET
 fi
 fi
 endmenu
@@ -330,7 +334,11 @@
   bool '   Disable watchdog shutdown on close' CONFIG_WATCHDOG_NOWAYOUT
   bool '   Software Watchdog' CONFIG_SOFT_WATCHDOG
 fi
-bool 'Support for user misc device modules' CONFIG_UMISC
+if [ "$CONFIG_VME" = "y" ]; then
+  define_bool CONFIG_UMISC y
+else
+  bool 'Support for user misc device modules' CONFIG_UMISC
+fi
 if [ "$CONFIG_ATARI" = "y" ]; then
   bool 'Enhanced Real Time Clock Support' CONFIG_RTC
 fi
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/arch/m68k/kernel/setup.c linuxvme-2.1.108/arch/m68k/kernel/setup.c
--- linux68k-2.1.108+Geert/arch/m68k/kernel/setup.c	Wed Jul 15 21:16:11 1998
+++ linuxvme-2.1.108/arch/m68k/kernel/setup.c	Tue Jul 14 08:38:56 1998
@@ -104,7 +104,7 @@
 extern void config_sun3(void);
 extern void config_apollo(void);
 extern void config_mvme16x(void);
-extern void config_bmve6000(void);
+extern void config_bvme6000(void);
 extern void config_hp300(void);
 
 #define MASK_256K 0xfffc0000
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/net/82596.c linuxvme-2.1.108/drivers/net/82596.c
--- linux68k-2.1.108+Geert/drivers/net/82596.c	Thu Jan  1 00:00:00 1970
+++ linuxvme-2.1.108/drivers/net/82596.c	Wed Jul 15 21:04:52 1998
@@ -0,0 +1,1419 @@
+/* apricot.c: An Apricot 82596 ethernet driver for linux. */
+/*
+    Apricot
+    	Written 1994 by Mark Evans.
+	This driver is for the Apricot 82596 bus-master interface
+
+        Modularised 12/94 Mark Evans
+
+
+	Modified to support the 82596 ethernet chips on 680x0 VME boards.
+	by Richard Hirst <richard@sleepie.demon.co.uk>
+	Renamed to be 82596.c
+
+	*** Untested on Apricot hardware, and may require some hacking
+	*** to make it work.  The old apricot.c reported hasn't worked
+	*** since 1.3.xx anyway.  I have been unable to find any users
+	*** of Apricot hardware to test this on.
+
+	Most of my modifications relate to the braindead big-endian
+	implementation by Intel.  When the i596 is operating in
+	'big-endian' mode, it thinks a 32 bit value of 0x12345678
+	should be stored as 0x56781234.  This is a real pain, when
+	you have linked lists which are shared by the 680x0 and the
+	i596.
+
+    Driver skeleton
+	Written 1993 by Donald Becker.
+	Copyright 1993 United States Government as represented by the Director,
+	National Security Agency. This software may only be used and distributed
+	according to the terms of the GNU Public License as modified by SRC,
+	incorporated herein by reference.
+
+	The author may be reached as becker@super.org or
+	C/O Supercomputing Research Ctr., 17100 Science Dr., Bowie MD 20715
+
+*/
+
+static const char *version = "82596.c:v1.0 15/07/98\n";
+
+#include <linux/config.h>
+#include <linux/module.h>
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/ptrace.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/malloc.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/init.h>
+
+#include <asm/setup.h>
+#include <asm/bitops.h>
+#include <asm/io.h>
+#include <asm/dma.h>
+#include <asm/pgtable.h>	/*??*/
+
+#ifdef CONFIG_MVME16x_NET
+#include <asm/mvme16xhw.h>
+#endif
+#ifdef CONFIG_BVME6000_NET
+#include <asm/bvme6000hw.h>
+#endif
+
+/*
+ * Define various macros for Channel Attention, word swapping etc., dependant
+ * on architecture.  MVME and BVME are 680x0 based, otherwise it is Intel.
+ */
+
+#ifdef __mc68000__
+#define WSWAPrfd(x)  ((struct i596_rfd *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
+#define WSWAPrbd(x)  ((struct i596_rbd *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
+#define WSWAPiscp(x) ((struct i596_iscp *)(((u32)(x)<<16) | ((((u32)(x)))>>16)))
+#define WSWAPscb(x)  ((struct i596_scb *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
+#define WSWAPcmd(x)  ((struct i596_cmd *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
+#define WSWAPtbd(x)  ((struct i596_tbd *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
+#define WSWAPchar(x) ((char *)            (((u32)(x)<<16) | ((((u32)(x)))>>16)))
+#define ISCP_BUSY	0x00010000
+#define MACH_IS_APRICOT	0
+#else
+#define WSWAPrfd(x)	x
+#define WSWAPiscp(x)	((struct i596_iscp *)(x))
+#define WSWAPscb(x)	((struct i596_scb *)(x))
+#define WSWAPcmd(x)	x
+#define WSWAPtbd(x)	x
+#define WSWAPchar(x)	x
+#define ISCP_BUSY	0x0001
+#define MACH_IS_APRICOT	1
+#endif
+
+/*
+ * The MPU_PORT command allows direct access to the 82596. With PORT access
+ * the following commands are available (p5-18). The 32-bit port command
+ * must be word-swapped with the most significant word written first.
+ * This only applies to VME boards.
+ */
+#define PORT_RESET		0x00	/* reset 82596 */
+#define PORT_SELFTEST		0x01	/* selftest */
+#define PORT_ALTSCP		0x02	/* alternate SCB address */
+#define PORT_ALTDUMP		0x03	/* Alternate DUMP address */
+
+#ifndef HAVE_PORTRESERVE
+#define check_region(addr, size)	0
+#define request_region(addr, size,name)	do ; while(0)
+#endif
+
+#ifndef HAVE_ALLOC_SKB
+#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
+#define kfree_skbmem(buff, size) kfree_s(buff,size)
+#endif
+
+#define APRICOT_DEBUG 2
+
+#ifdef APRICOT_DEBUG
+int i596_debug = APRICOT_DEBUG;
+#else
+int i596_debug = 1;
+#endif
+
+#define I596_TOTAL_SIZE 17
+
+#define I596_NULL -1
+
+#define CMD_EOL		0x8000	/* The last command of the list, stop. */
+#define CMD_SUSP	0x4000	/* Suspend after doing cmd. */
+#define CMD_INTR	0x2000	/* Interrupt after doing cmd. */
+
+#define CMD_FLEX	0x0008	/* Enable flexible memory model */
+
+enum commands {
+	CmdNOp = 0, CmdSASetup = 1, CmdConfigure = 2, CmdMulticastList = 3,
+	CmdTx = 4, CmdTDR = 5, CmdDump = 6, CmdDiagnose = 7};
+
+#define STAT_C		0x8000	/* Set to 0 after execution */
+#define STAT_B		0x4000	/* Command being executed */
+#define STAT_OK		0x2000	/* Command executed ok */
+#define STAT_A		0x1000	/* Command aborted */
+
+#define	 CUC_START	0x0100
+#define	 CUC_RESUME	0x0200
+#define	 CUC_SUSPEND    0x0300
+#define	 CUC_ABORT	0x0400
+#define	 RX_START	0x0010
+#define	 RX_RESUME	0x0020
+#define	 RX_SUSPEND	0x0030
+#define	 RX_ABORT	0x0040
+
+struct i596_reg {
+    unsigned short porthi;
+    unsigned short portlo;
+    unsigned long  ca;
+};
+
+struct i596_cmd {
+    unsigned short status;
+    unsigned short command;
+    struct i596_cmd *next;
+};
+
+#define EOF		0x8000
+#define SIZE_MASK	0x3fff
+
+struct i596_tbd {
+    unsigned short size;
+    unsigned short pad;
+    struct i596_tbd *next;
+    char *data;
+};
+
+struct tx_cmd {
+    struct i596_cmd cmd;
+    struct i596_tbd *tbd;
+    unsigned short size;
+    unsigned short pad;
+    struct sk_buff *skb;	/* So we can free it after tx */
+};
+
+struct i596_rfd {
+    unsigned short stat;
+    unsigned short cmd;
+    struct i596_rfd *next;
+    long rbd;
+    unsigned short count;
+    unsigned short size;
+    char data[1532];
+};
+
+#define RX_RING_SIZE 16
+
+struct i596_scb {
+    unsigned short status;
+    unsigned short command;
+    struct i596_cmd *cmd;
+    struct i596_rfd *rfd;
+    unsigned long crc_err;
+    unsigned long align_err;
+    unsigned long resource_err;
+    unsigned long over_err;
+    unsigned long rcvdt_err;
+    unsigned long short_err;
+    unsigned short t_on;
+    unsigned short t_off;
+};
+
+struct i596_iscp {
+    unsigned long stat;
+    struct i596_scb *scb;
+};
+
+struct i596_scp {
+    unsigned long sysbus;
+    unsigned long pad;
+    struct i596_iscp *iscp;
+};
+
+struct i596_private {
+    volatile struct i596_scp scp;
+    volatile struct i596_iscp iscp;
+    volatile struct i596_scb scb;
+    struct i596_cmd set_add;
+    char eth_addr[8];
+    struct i596_cmd set_conf;
+    char i596_config[16];
+    struct i596_cmd tdr;
+    unsigned long stat;
+    int last_restart __attribute__ ((aligned (4)));
+    struct i596_rfd *rx_tail;
+    struct i596_cmd *cmd_tail;
+    struct i596_cmd *cmd_head;
+    int cmd_backlog;
+    unsigned long last_cmd;
+    struct net_device_stats stats;
+};
+
+char init_setup[] = {
+	0x8E,	/* length, prefetch on */
+	0xC8,	/* fifo to 8, monitor off */
+#ifdef CONFIG_VME
+	0xc0,	/* don't save bad frames */
+#else
+	0x80,	/* don't save bad frames */
+#endif
+	0x2E,	/* No source address insertion, 8 byte preamble */
+	0x00,	/* priority and backoff defaults */
+	0x60,	/* interframe spacing */
+	0x00,	/* slot time LSB */
+	0xf2,	/* slot time and retries */
+	0x00,	/* promiscuous mode */
+	0x00,	/* collision detect */
+	0x40,	/* minimum frame length */
+	0xff,
+	0x00,
+	0x7f	/*  *multi IA */ };
+
+static int i596_open(struct device *dev);
+static int i596_start_xmit(struct sk_buff *skb, struct device *dev);
+static void i596_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static int i596_close(struct device *dev);
+static struct net_device_stats *i596_get_stats(struct device *dev);
+static void i596_add_cmd(struct device *dev, struct i596_cmd *cmd);
+static void print_eth(char *);
+static void set_multicast_list(struct device *dev);
+
+static int ticks_limit  = 25;
+static int max_cmd_backlog = 16;
+
+
+static inline void CA(struct device *dev)
+{
+#ifdef CONFIG_MVME16x_NET
+	if (MACH_IS_MVME16x)
+        {
+		((struct i596_reg *)dev->base_addr)->ca = 1;
+        }
+#endif
+#ifdef CONFIG_BVME6000_NET
+	if (MACH_IS_BVME6000)
+	{
+		volatile u32 i = *(volatile u32 *)(dev->base_addr);
+	}
+#endif
+#ifdef CONFIG_APRICOT_i596
+        if (MACH_IS_APRICOT)
+	{
+		outw(0, (short)(dev->base_addr)+4);
+	}
+#endif
+}
+
+
+static inline void MPU_PORT(struct device *dev, int c, volatile void *x)
+{
+#ifdef CONFIG_MVME16x_NET
+	if (MACH_IS_MVME16x)
+	{
+		struct i596_reg *p = (struct i596_reg *)(dev->base_addr);
+		p->porthi = ((c) | (u32)(x)) & 0xffff; 
+		p->portlo = ((c) | (u32)(x)) >> 16;
+	}
+#endif
+#ifdef CONFIG_BVME6000_NET
+	if (MACH_IS_BVME6000)
+	{
+		u32 v = (u32)(c) | (u32)(x);
+		v = ((u32)(v)<<16) | ((u32)(v)>>16);
+		*(volatile u32 *)dev->base_addr = v;
+		udelay(1);
+		*(volatile u32 *)dev->base_addr = v;
+	}
+#endif
+}
+
+
+#if defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET)
+static void i596_error(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct device *dev = dev_id;
+	struct i596_cmd *cmd;
+
+	struct i596_private *lp = (struct i596_private *)dev->priv;
+	printk ("i596_error: lp = 0x%08x\n", (u32)lp);
+	printk ("scp at %08x, .sysbus = %08x, .iscp = %08x\n",
+			(u32)&lp->scp, (u32)lp->scp.sysbus, (u32)lp->scp.iscp);
+	printk ("iscp at %08x, .stat = %08x, .scb = %08x\n",
+			(u32)&lp->iscp, (u32)lp->iscp.stat, (u32)lp->iscp.scb);
+	printk ("scb at %08x, .status = %04x, .command = %04x\n",
+			(u32)&lp->scb, lp->scb.status, lp->scb.command);
+	printk ("   .cmd = %08x, .rfd = %08x\n", (u32)lp->scb.cmd,
+			(u32)lp->scb.rfd);
+	cmd = WSWAPcmd(lp->scb.cmd);
+	while (cmd && (u32)cmd < 0x1000000)
+	{
+	  printk ("cmd at %08x, .status = %04x, .command = %04x, .next = %08x\n",
+		(u32)cmd, cmd->status, cmd->command, (u32)cmd->next);
+	  cmd  = WSWAPcmd(cmd->next);
+	}
+	while (1)
+		;
+}
+#endif
+
+static inline int
+init_rx_bufs(struct device *dev, int num)
+{
+    struct i596_private *lp = (struct i596_private *)dev->priv;
+    int i;
+    struct i596_rfd *rfd;
+
+    lp->scb.rfd = (struct i596_rfd *)I596_NULL;
+
+    if (i596_debug > 1) printk ("%s: init_rx_bufs %d.\n", dev->name, num);
+
+    for (i = 0; i < num; i++)
+    {
+	if (!(rfd = (struct i596_rfd *)kmalloc(sizeof(struct i596_rfd), GFP_KERNEL)))
+            break;
+
+	rfd->stat = 0x0000;
+	rfd->rbd = I596_NULL;
+	rfd->count = 0;
+	rfd->size = 1532;
+        if (i == 0)
+        {
+	    rfd->cmd = CMD_EOL;
+            lp->rx_tail = rfd;
+        }
+        else
+	    rfd->cmd = 0x0000;
+
+        rfd->next = lp->scb.rfd;
+        lp->scb.rfd = WSWAPrfd(rfd);
+    }
+
+    if (i != 0)
+      lp->rx_tail->next = lp->scb.rfd;
+
+    return (i);
+}
+
+static inline void
+remove_rx_bufs(struct device *dev)
+{
+    struct i596_private *lp = (struct i596_private *)dev->priv;
+    struct i596_rfd *rfd = WSWAPrfd(lp->scb.rfd);
+
+    lp->rx_tail->next = (struct i596_rfd *)I596_NULL;
+
+    do
+    {
+        lp->scb.rfd = rfd->next;
+        kfree(rfd);
+        rfd = WSWAPrfd(lp->scb.rfd);
+    }
+    while (rfd != lp->rx_tail);
+}
+
+static inline void
+init_i596_mem(struct device *dev)
+{
+    struct i596_private *lp = (struct i596_private *)dev->priv;
+#if !defined(CONFIG_MVME16x_NET) && !defined(CONFIG_BVME6000_NET)
+    short ioaddr = dev->base_addr;
+#endif
+    int boguscnt = 100000;
+    unsigned long flags;
+
+#if defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET)
+#ifdef CONFIG_MVME16x_NET
+    if (MACH_IS_MVME16x)
+    {
+        volatile unsigned char *pcc2 = (unsigned char *)0xfff42000;
+
+        /* Disable all ints for now */
+        pcc2[0x28] = 1;
+        pcc2[0x2a] = 0x40;
+        pcc2[0x2b] = 0x40;	/* Set snooping bits now! */
+    }
+#endif
+#ifdef CONFIG_BVME6000_NET
+    if (MACH_IS_BVME6000)
+    {
+        volatile unsigned char *ethirq = (unsigned char *)BVME_ETHIRQ_REG;
+
+        *ethirq = 1;
+    }
+#endif
+
+    MPU_PORT(dev, PORT_RESET, 0);
+
+    udelay (100);	/* Wait 100us - seems to help */
+
+    /* change the scp address */
+
+    MPU_PORT(dev, PORT_ALTSCP, &lp->scp);
+
+#else
+
+    /* change the scp address */
+    outw(0, ioaddr);
+    outw(0, ioaddr);
+    outb(4, ioaddr+0xf);
+    outw(((((int)&lp->scp) & 0xffff) | 2), ioaddr);
+    outw((((int)&lp->scp)>>16) & 0xffff, ioaddr);
+#endif
+
+    lp->last_cmd = jiffies;
+
+#ifdef CONFIG_MVME16x_NET
+    if (MACH_IS_MVME16x)
+        lp->scp.sysbus = 0x00000054;
+#endif
+#ifdef CONFIG_BVME6000_NET
+    if (MACH_IS_BVME6000)
+	lp->scp.sysbus = 0x0000004c;
+#endif
+#ifdef CONFIG_APRICOT_i596
+    if (MACH_IS_APRICOT)
+	lp->scp.sysbus = 0x00440000;
+#endif
+
+    lp->scp.iscp = WSWAPiscp(&(lp->iscp));
+    lp->iscp.scb = WSWAPscb(&(lp->scb));
+    lp->iscp.stat = ISCP_BUSY;
+    lp->cmd_backlog = 0;
+
+    lp->cmd_head = lp->scb.cmd = (struct i596_cmd *) I596_NULL;
+
+    if (i596_debug > 1) printk("%s: starting i82596.\n", dev->name);
+
+#if !defined(CONFIG_MVME16x_NET) && !defined(CONFIG_BVME6000_NET)
+    (void) inb (ioaddr+0x10);
+    outb(4, ioaddr+0xf);
+#endif
+    CA(dev);
+
+    while (lp->iscp.stat)
+	if (--boguscnt == 0)
+	{
+	    printk("%s: i82596 initialization timed out with status %4.4x, cmd %4.4x.\n",
+		   dev->name, lp->scb.status, lp->scb.command);
+	    break;
+    	}
+
+    lp->scb.command = 0;
+
+#ifdef CONFIG_MVME16x_NET
+    if (MACH_IS_MVME16x)
+    {
+        volatile unsigned char *pcc2 = (unsigned char *)0xfff42000;
+
+        /* Enable ints, etc. now */
+        pcc2[0x2a] = 0x08;
+        pcc2[0x2a] = 0x55;	/* Edge sensitive */
+        pcc2[0x2b] = 0x55;
+    }
+#endif
+#ifdef CONFIG_BVME6000_NET
+    if (MACH_IS_BVME6000)
+    {
+        volatile unsigned char *ethirq = (unsigned char *)BVME_ETHIRQ_REG;
+
+        *ethirq = 3;
+    }
+#endif
+
+    memcpy (lp->i596_config, init_setup, 14);
+    lp->set_conf.command = CmdConfigure;
+    i596_add_cmd(dev, &lp->set_conf);
+
+    memcpy (lp->eth_addr, dev->dev_addr, 6);
+    lp->set_add.command = CmdSASetup;
+    i596_add_cmd(dev, &lp->set_add);
+
+    lp->tdr.command = CmdTDR;
+    i596_add_cmd(dev, &lp->tdr);
+
+    boguscnt = 200000;
+
+    save_flags(flags);
+    cli();
+
+    while (lp->scb.command)
+	if (--boguscnt == 0)
+	{
+	    printk("%s: receive unit start timed out with status %4.4x, cmd %4.4x.\n",
+		   dev->name, lp->scb.status, lp->scb.command);
+	    break;
+    	}
+
+    lp->scb.command = RX_START;
+    CA(dev);
+
+    restore_flags(flags);
+
+    boguscnt = 2000;
+    while (lp->scb.command)
+        if (--boguscnt == 0)
+	{
+	    printk("i82596 init timed out with status %4.4x, cmd %4.4x.\n",
+		lp->scb.status, lp->scb.command);
+	    break;
+	}
+    return;
+}
+
+static inline int
+i596_rx(struct device *dev)
+{
+    struct i596_private *lp = (struct i596_private *)dev->priv;
+    struct i596_rfd *rfd;
+    int frames = 0;
+
+    if (i596_debug > 3) printk ("i596_rx()\n");
+
+    rfd = WSWAPrfd(lp->scb.rfd);	/* Reference next frame descriptor to check */
+
+    while ((rfd->stat) & STAT_C)	/* Loop while we have complete frames */
+    {
+        if (i596_debug >2) print_eth(rfd->data);
+
+	if ((rfd->stat) & STAT_OK)
+	{
+	    /* a good frame */
+	    int pkt_len = rfd->count & 0x3fff;
+	    struct sk_buff *skb = dev_alloc_skb(pkt_len);
+
+	    frames++;
+
+	    if (skb == NULL)
+	    {
+		printk ("%s: i596_rx Memory squeeze, dropping packet.\n", dev->name);
+		lp->stats.rx_dropped++;
+	    }
+	    else
+	    {
+		skb->dev = dev;
+		memcpy(skb_put(skb,pkt_len), rfd->data, pkt_len);
+		skb->protocol=eth_type_trans(skb,dev);
+		netif_rx(skb);
+		lp->stats.rx_packets++;
+		lp->stats.rx_bytes+=pkt_len;
+	    }
+	}
+	else
+	{
+	    lp->stats.rx_errors++;
+	    if ((rfd->stat) & 0x0001) lp->stats.collisions++;
+	    if ((rfd->stat) & 0x0080) lp->stats.rx_length_errors++;
+	    if ((rfd->stat) & 0x0100) lp->stats.rx_over_errors++;
+	    if ((rfd->stat) & 0x0200) lp->stats.rx_fifo_errors++;
+	    if ((rfd->stat) & 0x0400) lp->stats.rx_frame_errors++;
+	    if ((rfd->stat) & 0x0800) lp->stats.rx_crc_errors++;
+	    if ((rfd->stat) & 0x1000) lp->stats.rx_length_errors++;
+	}
+
+	/* Clear the buffer descriptor count and EOF + F flags */
+
+	rfd->stat = 0;
+	rfd->count = 0;
+	rfd->cmd = CMD_EOL;
+	lp->rx_tail->cmd = 0;
+	lp->rx_tail = rfd;
+	lp->scb.rfd = rfd->next;
+        rfd = WSWAPrfd(lp->scb.rfd);	/* Next frame descriptor to check */
+    }
+
+    if (i596_debug > 3) printk ("frames %d\n", frames);
+
+    return 0;
+}
+
+static inline void
+i596_cleanup_cmd(struct i596_private *lp)
+{
+    struct i596_cmd *ptr;
+    int boguscnt = 1000;
+
+    if (i596_debug > 4) printk ("i596_cleanup_cmd\n");
+
+    while (lp->cmd_head != (struct i596_cmd *) I596_NULL)
+    {
+	ptr = lp->cmd_head;
+
+	lp->cmd_head = WSWAPcmd(lp->cmd_head->next);
+	lp->cmd_backlog--;
+
+	switch ((ptr->command) & 0x7)
+	{
+	    case CmdTx:
+	    {
+		struct tx_cmd *tx_cmd = (struct tx_cmd *) ptr;
+		struct sk_buff *skb = tx_cmd->skb;
+
+		dev_kfree_skb(skb);
+
+		lp->stats.tx_errors++;
+		lp->stats.tx_aborted_errors++;
+
+		ptr->next = (struct i596_cmd * ) I596_NULL;
+		kfree(tx_cmd);
+		break;
+	    }
+	    case CmdMulticastList:
+	    {
+		ptr->next = (struct i596_cmd * ) I596_NULL;
+		kfree(ptr);
+		break;
+	    }
+	    default:
+		ptr->next = (struct i596_cmd * ) I596_NULL;
+	}
+    }
+
+    while (lp->scb.command)
+	if (--boguscnt == 0)
+	{
+	    printk("i596_cleanup_cmd timed out with status %4.4x, cmd %4.4x.\n",
+		lp->scb.status, lp->scb.command);
+	    break;
+    	}
+
+    lp->scb.cmd = WSWAPcmd(lp->cmd_head);
+}
+
+static inline void
+i596_reset(struct device *dev, struct i596_private *lp, int ioaddr)
+{
+    int boguscnt = 1000;
+    unsigned long flags;
+
+    if (i596_debug > 1) printk ("i596_reset\n");
+
+    save_flags(flags);
+    cli();
+
+    while (lp->scb.command)
+        if (--boguscnt == 0)
+	{
+	    printk("i596_reset timed out with status %4.4x, cmd %4.4x.\n",
+		lp->scb.status, lp->scb.command);
+	    break;
+	}
+
+    dev->start = 0;
+    dev->tbusy = 1;
+
+    lp->scb.command = CUC_ABORT|RX_ABORT;
+    CA(dev);
+
+    /* wait for shutdown */
+    boguscnt = 4000;
+
+    while (lp->scb.command)
+        if (--boguscnt == 0)
+	{
+	    printk("i596_reset 2 timed out with status %4.4x, cmd %4.4x.\n",
+		lp->scb.status, lp->scb.command);
+	    break;
+	}
+
+    restore_flags(flags);
+
+    i596_cleanup_cmd(lp);
+    i596_rx(dev);
+
+    dev->start = 1;
+    dev->tbusy = 0;
+    dev->interrupt = 0;
+    init_i596_mem(dev);
+}
+
+static void i596_add_cmd(struct device *dev, struct i596_cmd *cmd)
+{
+    struct i596_private *lp = (struct i596_private *)dev->priv;
+    int ioaddr = dev->base_addr;
+    unsigned long flags;
+    int boguscnt = 1000;
+
+    if (i596_debug > 4) printk ("i596_add_cmd\n");
+
+    cmd->status = 0;
+    cmd->command |= (CMD_EOL|CMD_INTR);
+    cmd->next = (struct i596_cmd *) I596_NULL;
+    save_flags(flags);
+    cli();
+
+    /*
+     * RGH  300597:  Looks to me like there could be a race condition
+     * here.  Just because we havn't picked up all the command items
+     * yet, doesn't mean that the 82596 hasn't finished processing
+     * them.  So, we may need to do a CUC_START anyway.
+     * Maybe not.  If it interrupts saying the CU is idle when there
+     * is still something in the cmd queue, the int handler with restart
+     * the CU.
+     */
+
+    if (lp->cmd_head != (struct i596_cmd *) I596_NULL)
+    {
+	lp->cmd_tail->next = WSWAPcmd(cmd);
+    }
+    else 
+    {
+	lp->cmd_head = cmd;
+	while (lp->scb.command)
+	    if (--boguscnt == 0)
+	    {
+		printk("i596_add_cmd timed out with status %4.4x, cmd %4.4x.\n",
+		   lp->scb.status, lp->scb.command);
+		break;
+    	    }
+
+	lp->scb.cmd = WSWAPcmd(cmd);
+	lp->scb.command = CUC_START;
+        CA(dev);
+    }
+    lp->cmd_tail = cmd;
+    lp->cmd_backlog++;
+
+    lp->cmd_head = WSWAPcmd(lp->scb.cmd);	/* Is this redundant?  RGH 300597 */
+    restore_flags(flags);
+
+    if (lp->cmd_backlog > max_cmd_backlog)
+    {
+	unsigned long tickssofar = jiffies - lp->last_cmd;
+
+	if (tickssofar < ticks_limit) return;
+
+	printk("%s: command unit timed out, status resetting.\n", dev->name);
+
+	i596_reset(dev, lp, ioaddr);
+    }
+}
+
+static int
+i596_open(struct device *dev)
+{
+    int i;
+
+    if (i596_debug > 1)
+	printk("%s: i596_open() irq %d.\n", dev->name, dev->irq);
+
+    if (request_irq(dev->irq, &i596_interrupt, 0, "apricot", dev))
+	return -EAGAIN;
+#ifdef CONFIG_MVME16x_NET
+    if (MACH_IS_MVME16x)
+    {
+        if (request_irq(0x56, &i596_error, 0, "apricot_error", dev))
+	    return -EAGAIN;
+    }
+#endif
+    if ((i = init_rx_bufs(dev, RX_RING_SIZE)) < RX_RING_SIZE)
+        printk("%s: only able to allocate %d receive buffers\n", dev->name, i);
+
+    if (i < 4)
+    {
+        free_irq(dev->irq, dev);
+        return -EAGAIN;
+    }
+
+    dev->tbusy = 0;
+    dev->interrupt = 0;
+    dev->start = 1;
+    MOD_INC_USE_COUNT;
+
+    /* Initialize the 82596 memory */
+    init_i596_mem(dev);
+
+    return 0;			/* Always succeed */
+}
+
+static int
+i596_start_xmit(struct sk_buff *skb, struct device *dev)
+{
+    struct i596_private *lp = (struct i596_private *)dev->priv;
+    int ioaddr = dev->base_addr;
+    struct tx_cmd *tx_cmd;
+
+    if (i596_debug > 2) printk ("%s: Apricot start xmit\n", dev->name);
+
+    /* Transmitter timeout, serious problems. */
+    if (dev->tbusy) {
+	int tickssofar = jiffies - dev->trans_start;
+	if (tickssofar < 5)
+	    return 1;
+	printk("%s: transmit timed out, status resetting.\n",
+	       dev->name);
+	lp->stats.tx_errors++;
+	/* Try to restart the adaptor */
+	if (lp->last_restart == lp->stats.tx_packets) {
+	    if (i596_debug > 1) printk ("Resetting board.\n");
+
+	    /* Shutdown and restart */
+            i596_reset(dev,lp, ioaddr);
+	} else {
+	    /* Issue a channel attention signal */
+	    if (i596_debug > 1) printk ("Kicking board.\n");
+	    lp->scb.command = CUC_START|RX_START;
+	    CA(dev);
+	    lp->last_restart = lp->stats.tx_packets;
+	}
+	dev->tbusy = 0;
+	dev->trans_start = jiffies;
+    }
+
+    if (i596_debug > 3) printk("%s: i596_start_xmit() called\n", dev->name);
+
+    /* 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 (test_and_set_bit(0, (void*)&dev->tbusy) != 0)
+	printk("%s: Transmitter access conflict.\n", dev->name);
+    else
+    {
+	short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
+	dev->trans_start = jiffies;
+
+	tx_cmd = (struct tx_cmd *) kmalloc ((sizeof (struct tx_cmd) + sizeof (struct i596_tbd)), GFP_ATOMIC);
+	if (tx_cmd == NULL)
+	{
+	    printk ("%s: i596_xmit Memory squeeze, dropping packet.\n", dev->name);
+	    lp->stats.tx_dropped++;
+
+	    dev_kfree_skb(skb);
+	}
+	else
+	{
+	    struct i596_tbd *tbd = (struct i596_tbd *) (tx_cmd + 1);
+	    tx_cmd->tbd = WSWAPtbd(tbd);
+	    tbd->next = (struct i596_tbd *) I596_NULL;
+
+	    tx_cmd->cmd.command = CMD_FLEX|CmdTx;
+	    tx_cmd->skb = skb;
+
+	    tx_cmd->pad = 0;
+	    tx_cmd->size = 0;
+	    tbd->pad = 0;
+	    tbd->size = EOF | length;
+
+	    tbd->data = WSWAPchar(skb->data);
+
+	    if (i596_debug > 3) print_eth(skb->data);
+	    i596_add_cmd(dev, (struct i596_cmd *)tx_cmd);
+
+	    lp->stats.tx_packets++;
+	    lp->stats.tx_bytes+=length;
+	}
+    }
+
+    dev->tbusy = 0;
+
+    return 0;
+}
+
+
+static void print_eth(char *add)
+{
+    int i;
+
+    printk ("print_eth(%08x)\n", (unsigned int)add);
+    printk ("Dest  ");
+    for (i = 0; i < 6; i++)
+	printk(" %2.2X", (unsigned char)add[i]);
+    printk ("\n");
+
+    printk ("Source");
+    for (i = 0; i < 6; i++)
+	printk(" %2.2X", (unsigned char)add[i+6]);
+    printk ("\n");
+    printk ("type %2.2X%2.2X\n", (unsigned char)add[12], (unsigned char)add[13]);
+}
+
+__initfunc(int i82596_probe(struct device *dev))
+{
+    int i;
+    struct i596_private *lp;
+    char eth_addr[6];
+
+#ifdef CONFIG_MVME16x_NET
+    if (MACH_IS_MVME16x)
+    {
+        static int probed = 0;
+
+        if (mvme16x_config & MVME16x_CONFIG_NO_ETHERNET) {
+	    printk ("Ethernet probe disabled - chip not present\n");
+	    return ENODEV;
+        }
+        if (probed)
+	    return ENODEV;
+        probed++;
+        memcpy (eth_addr, (void *)0xfffc1f2c, 6); /* YUCK! Get addr from NOVRAM */
+        dev->base_addr = MVME_I596_BASE;
+        dev->irq = (unsigned)MVME16x_IRQ_I596;
+    }
+#endif
+#ifdef CONFIG_BVME6000_NET
+    if (MACH_IS_BVME6000)
+    {
+	volatile unsigned char *rtc = (unsigned char *)BVME_RTC_BASE;
+	unsigned char msr = rtc[3];
+	int i;
+
+	rtc[3] |= 0x80;
+	for (i = 0; i < 6; i++)
+	    eth_addr[i] = rtc[i*4+7];	/* Stored in RTC RAM at offset 1 */
+	rtc[3] = msr;
+        dev->base_addr = BVME_I596_BASE;
+        dev->irq = (unsigned)BVME_IRQ_I596;
+    }
+#endif
+#ifdef CONFIG_APRICOT_INTEL
+    int checksum = 0;
+    int ioaddr = 0x300;
+
+    /* this is easy the ethernet interface can only be at 0x300 */
+    /* first check nothing is already registered here */
+
+    if (check_region(ioaddr, APRICOT_TOTAL_SIZE))
+	return ENODEV;
+
+    for (i = 0; i < 8; i++)
+    {
+    	eth_addr[i] = inb(ioaddr+8+i);
+	checksum += eth_addr[i];
+     }
+
+    /* checksum is a multiple of 0x100, got this wrong first time
+       some machines have 0x100, some 0x200. The DOS driver doesn't
+       even bother with the checksum */
+
+    if (checksum % 0x100) return ENODEV;
+
+    /* Some other boards trip the checksum.. but then appear as ether
+       address 0. Trap these - AC */
+
+    if(memcmp(eth_addr,"\x00\x00\x49",3)!= 0)
+    	return ENODEV;
+
+    request_region(ioaddr, APRICOT_TOTAL_SIZE, "i596");
+
+    dev->base_addr = ioaddr;
+    dev->irq = 10;
+#endif
+    ether_setup(dev);
+    printk("%s: Apricot 82596 at %#3lx,", dev->name, dev->base_addr);
+
+    for (i = 0; i < 6; i++)
+	printk(" %2.2X", dev->dev_addr[i] = eth_addr[i]);
+
+    printk(" IRQ %d.\n", dev->irq);
+
+    if (i596_debug > 0) printk(version);
+
+    /* The APRICOT-specific entries in the device structure. */
+    dev->open = &i596_open;
+    dev->stop = &i596_close;
+    dev->hard_start_xmit = &i596_start_xmit;
+    dev->get_stats = &i596_get_stats;
+    dev->set_multicast_list = &set_multicast_list;
+
+    dev->mem_start = (int)kmalloc(sizeof(struct i596_private)+ 0x0f, GFP_KERNEL);
+    /* align for scp */
+    dev->priv = (void *)((dev->mem_start + 0xf) & 0xfffffff0);
+
+    lp = (struct i596_private *)dev->priv;
+    if (i596_debug) printk ("%s: lp at 0x%08lx, lp->scb at 0x%08lx\n"
+             ,dev->name, (unsigned long)lp, (unsigned long)&lp->scb);
+    memset((void *)lp, 0, sizeof(struct i596_private));
+    lp->scb.command = 0;
+    lp->scb.cmd = (struct i596_cmd *) I596_NULL;
+    lp->scb.rfd = (struct i596_rfd *)I596_NULL;
+
+    return 0;
+}
+
+static void
+i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+    struct device *dev = dev_id;
+    struct i596_private *lp;
+    short ioaddr;
+    int boguscnt = 2000;
+    unsigned short status, ack_cmd = 0;
+
+#ifdef CONFIG_BVME6000_NET
+    if (MACH_IS_BVME6000)
+    {
+        if (*(char *)BVME_LOCAL_IRQ_STAT & BVME_ETHERR)
+        {
+	    i596_error(BVME_IRQ_I596, NULL, NULL);
+            return;
+        }
+    }
+#endif
+    if (dev == NULL) {
+	printk ("i596_interrupt(): irq %d for unknown device.\n", irq);
+	return;
+    }
+
+    if (i596_debug > 3) printk ("%s: i596_interrupt(): irq %d\n",dev->name, irq);
+
+    if (dev->interrupt)
+	printk("%s: Re-entering the interrupt handler.\n", dev->name);
+
+    dev->interrupt = 1;
+
+    ioaddr = dev->base_addr;
+
+    lp = (struct i596_private *)dev->priv;
+
+    while (lp->scb.command)
+	if (--boguscnt == 0)
+	    {
+		printk("%s: i596 interrupt, timeout status %4.4x command %4.4x.\n", dev->name, lp->scb.status, lp->scb.command);
+		break;
+	    }
+    status = lp->scb.status;
+
+    if (i596_debug > 4)
+	printk("%s: i596 interrupt, status %4.4x.\n", dev->name, status);
+
+    ack_cmd = status & 0xf000;
+
+    if ((status & 0x8000) || (status & 0x2000))
+    {
+	struct i596_cmd *ptr;
+
+	if ((i596_debug > 4) && (status & 0x8000))
+	    printk("%s: i596 interrupt completed command.\n", dev->name);
+	if ((i596_debug > 4) && (status & 0x2000))
+	    printk("%s: i596 interrupt command unit inactive %x.\n", dev->name, status & 0x0700);
+
+	while ((lp->cmd_head != (struct i596_cmd *) I596_NULL) && (lp->cmd_head->status & STAT_C))
+	{
+	    ptr = lp->cmd_head;
+
+	    if (i596_debug > 2)
+		printk ("cmd_head->status = %04x, ->command = %04x\n",
+			lp->cmd_head->status, lp->cmd_head->command);
+	    lp->cmd_head = WSWAPcmd(lp->cmd_head->next);
+	    lp->cmd_backlog--;
+
+	    switch ((ptr->command) & 0x7)
+	    {
+		case CmdTx:
+		{
+		    struct tx_cmd *tx_cmd = (struct tx_cmd *) ptr;
+		    struct sk_buff *skb = tx_cmd->skb;
+
+		    if ((ptr->status) & STAT_OK)
+		    {
+	    		if (i596_debug >2) print_eth(skb->data);
+		    }
+		    else
+		    {
+			lp->stats.tx_errors++;
+			if ((ptr->status) & 0x0020) lp->stats.collisions++;
+			if (!((ptr->status) & 0x0040)) lp->stats.tx_heartbeat_errors++;
+			if ((ptr->status) & 0x0400) lp->stats.tx_carrier_errors++;
+			if ((ptr->status) & 0x0800) lp->stats.collisions++;
+			if ((ptr->status) & 0x1000) lp->stats.tx_aborted_errors++;
+		    }
+
+		    dev_kfree_skb(skb);
+
+		    ptr->next = (struct i596_cmd * ) I596_NULL;
+		    kfree(tx_cmd);
+		    break;
+		}
+		case CmdMulticastList:
+		{
+		    ptr->next = (struct i596_cmd * ) I596_NULL;
+		    kfree(ptr);
+		    break;
+		}
+		case CmdTDR:
+		{
+		    unsigned long status = *((unsigned long *) (ptr + 1));
+
+		    if (status & 0x8000)
+		    {
+			if (i596_debug > 3)
+	    		    printk("%s: link ok.\n", dev->name);
+		    }
+		    else
+		    {
+			if (status & 0x4000)
+	    		    printk("%s: Transceiver problem.\n", dev->name);
+			if (status & 0x2000)
+	    		    printk("%s: Termination problem.\n", dev->name);
+			if (status & 0x1000)
+	    		    printk("%s: Short circuit.\n", dev->name);
+
+			if (i596_debug > 1)
+	    		    printk("%s: Time %ld.\n", dev->name, status & 0x07ff);
+		    }
+		    break;
+		}
+		case CmdConfigure:
+		{
+		    ptr->next = (struct i596_cmd * ) I596_NULL;
+		    /* Zap command so set_multicast_list() knows it is free */
+		    ptr->command = 0;
+		    break;
+		}
+		default:
+		    ptr->next = (struct i596_cmd * ) I596_NULL;
+ 	    }
+	    lp->last_cmd = jiffies;
+	}
+
+	ptr = lp->cmd_head;
+	while ((ptr != (struct i596_cmd *) I596_NULL) && (ptr != lp->cmd_tail))
+	{
+	    ptr->command &= 0x1fff;
+	    ptr = WSWAPcmd(ptr->next);
+	}
+
+	if ((lp->cmd_head != (struct i596_cmd *) I596_NULL) && (dev->start))
+	    ack_cmd |= CUC_START;
+	lp->scb.cmd = WSWAPcmd(lp->cmd_head);
+    }
+
+    if ((status & 0x1000) || (status & 0x4000))
+    {
+	if ((i596_debug > 4) && (status & 0x4000))
+	    printk("%s: i596 interrupt received a frame.\n", dev->name);
+	/* Only RX_START if stopped - RGH 07-07-96 */
+	if (status & 0x1000)
+	{
+	    if (dev->start) ack_cmd |= RX_START;
+	    if (i596_debug > 1)
+		printk("%s: i596 interrupt receive unit inactive %x.\n", dev->name, status & 0x00f0);
+	}
+	i596_rx(dev);
+    }
+
+    /* acknowledge the interrupt */
+
+/*	COMMENTED OUT <<<<<
+    if ((lp->scb.cmd != (struct i596_cmd *) I596_NULL) && (dev->start))
+	ack_cmd |= CUC_START;
+*/
+    boguscnt = 1000;
+    while (lp->scb.command)
+	if (--boguscnt == 0)
+	    {
+		printk("%s: i596 interrupt, timeout status %4.4x command %4.4x.\n", dev->name, lp->scb.status, lp->scb.command);
+		break;
+	    }
+    lp->scb.command = ack_cmd;
+
+#ifdef CONFIG_MVME16x_NET
+    if (MACH_IS_MVME16x)
+    {
+      /* Ack the interrupt */
+
+      volatile unsigned char *pcc2 = (unsigned char *)0xfff42000;
+
+      pcc2[0x2a] |= 0x08;
+    }
+#endif
+#ifdef CONFIG_BVME6000_NET
+    if (MACH_IS_BVME6000)
+    {
+      volatile unsigned char *ethirq = (unsigned char *)BVME_ETHIRQ_REG;
+
+      *ethirq = 1;
+      *ethirq = 3;
+    }
+#endif
+#ifdef CONFIG_APRICOT_INTEL
+    (void) inb (ioaddr+0x10);
+    outb (4, ioaddr+0xf);
+#endif
+    CA(dev);
+
+    if (i596_debug > 4)
+	printk("%s: exiting interrupt.\n", dev->name);
+
+    dev->interrupt = 0;
+    return;
+}
+
+static int
+i596_close(struct device *dev)
+{
+    struct i596_private *lp = (struct i596_private *)dev->priv;
+    int boguscnt = 2000;
+    unsigned long flags;
+
+    dev->start = 0;
+    dev->tbusy = 1;
+
+    if (i596_debug > 1)
+	printk("%s: Shutting down ethercard, status was %4.4x.\n",
+	       dev->name, lp->scb.status);
+
+    save_flags(flags);
+    cli();
+
+    while (lp->scb.command)
+	if (--boguscnt == 0)
+	{
+	    printk("%s: close1 timed timed out with status %4.4x, cmd %4.4x.\n",
+		   dev->name, lp->scb.status, lp->scb.command);
+	    break;
+    	}
+
+    lp->scb.command = CUC_ABORT|RX_ABORT;
+    CA(dev);
+
+    boguscnt = 2000;
+
+    while (lp->scb.command)
+	if (--boguscnt == 0)
+	{
+	    printk("%s: close2 timed timed out with status %4.4x, cmd %4.4x.\n",
+		   dev->name, lp->scb.status, lp->scb.command);
+	    break;
+    	}
+
+    restore_flags(flags);
+
+    i596_cleanup_cmd(lp);
+
+#ifdef CONFIG_MVME16x_NET
+    if (MACH_IS_MVME16x)
+    {
+	volatile unsigned char *pcc2 = (unsigned char *)0xfff42000;
+
+	/* Disable all ints */
+	pcc2[0x28] = 1;
+	pcc2[0x2a] = 0x40;
+	pcc2[0x2b] = 0x40;  /* Set snooping bits now! */
+    }
+#endif
+#ifdef CONFIG_BVME6000_NET
+    if (MACH_IS_BVME6000)
+    {
+	volatile unsigned char *ethirq = (unsigned char *)BVME_ETHIRQ_REG;
+
+	*ethirq = 1;
+    }
+#endif
+
+    free_irq(dev->irq, dev);
+    remove_rx_bufs(dev);
+    MOD_DEC_USE_COUNT;
+
+    return 0;
+}
+
+static struct net_device_stats *
+i596_get_stats(struct device *dev)
+{
+    struct i596_private *lp = (struct i596_private *)dev->priv;
+
+    return &lp->stats;
+}
+
+/*
+ *	Set or clear the multicast filter for this adaptor.
+ */
+ 
+static void set_multicast_list(struct device *dev)
+{
+	struct i596_private *lp = (struct i596_private *)dev->priv;
+	struct i596_cmd *cmd;
+	int config = 0;
+
+	if (i596_debug > 1)
+		printk ("%s: set multicast list, %d entries, promisc %s, allmulti %s\n", dev->name, dev->mc_count, dev->flags & IFF_PROMISC ? "ON" : "OFF", dev->flags & IFF_ALLMULTI ? "ON" : "OFF");
+
+	if ((dev->flags & IFF_PROMISC) && !(lp->i596_config[8] & 0x01))
+	{
+		lp->i596_config[8] |= 0x01;
+		config = 1;
+	}
+	if (!(dev->flags & IFF_PROMISC) && (lp->i596_config[8] & 0x01))
+	{
+		lp->i596_config[8] &= ~0x01;
+		config = 1;
+	}
+	if ((dev->flags & IFF_ALLMULTI) && (lp->i596_config[11] & 0x20))
+	{
+		lp->i596_config[11] &= ~0x20;
+		config = 1;
+	}
+	if (!(dev->flags & IFF_ALLMULTI) && !(lp->i596_config[11] & 0x20))
+	{
+		lp->i596_config[11] |= 0x20;
+		config = 1;
+	}
+	if (config)
+	{
+		if (lp->set_conf.command)
+			printk ("%s: config change request already queued\n",
+				dev->name);
+		else
+		{
+    			lp->set_conf.command = CmdConfigure;
+			i596_add_cmd(dev, &lp->set_conf);
+		}
+	}
+		
+	if (dev->mc_count > 0)
+	{
+		struct dev_mc_list *dmi;
+		unsigned char *cp;
+		cmd = (struct i596_cmd *) kmalloc(sizeof(struct i596_cmd)+2+dev->mc_count*6, GFP_ATOMIC);
+		if (cmd == NULL)
+		{
+			printk ("%s: set_multicast Memory squeeze.\n", dev->name);
+			return;
+		}
+		cmd->command = CmdMulticastList;
+		*((unsigned short *) (cmd + 1)) = dev->mc_count * 6;
+		cp=((unsigned char *)(cmd + 1))+2;
+		for(dmi=dev->mc_list;dmi!=NULL;dmi=dmi->next)
+		{
+			memcpy(cp, dmi->dmi_addr, 6);
+			if (i596_debug > 1)
+				printk ("%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, *(cp+0), *(cp+1), *(cp+2), *(cp+3), *(cp+4), *(cp+5));
+			cp+=6;
+		}
+		if (i596_debug >2) print_eth (((char *)(cmd + 1)) + 2);
+		i596_add_cmd(dev, cmd);
+	}
+}
+
+#ifdef HAVE_DEVLIST
+static unsigned int i596_portlist[] __initdata = {0x300, 0};
+struct netdev_entry i596_drv =
+{"apricot", i82596_probe, APRICOT_TOTAL_SIZE, apricot_portlist};
+#endif
+
+#ifdef MODULE
+static char devicename[9] = { 0, };
+static struct device dev_apricot = {
+  devicename, /* device name inserted by /linux/drivers/net/net_init.c */
+  0, 0, 0, 0,
+  0x300, 10,
+  0, 0, 0, NULL, i82596_probe };
+
+static int io = 0x300;
+static int irq = 10;
+MODULE_PARM(irq, "i");
+
+int
+init_module(void)
+{
+  dev_apricot.base_addr = io;
+  dev_apricot.irq       = irq;
+  if (register_netdev(&dev_apricot) != 0)
+    return -EIO;
+  return 0;
+}
+
+void
+cleanup_module(void)
+{
+    unregister_netdev(&dev_apricot);
+    kfree((void*)dev_apricot.mem_start);
+    dev_apricot.priv = NULL;
+
+    /* If we don't do this, we can't re-insmod it later. */
+    release_region(dev_apricot.base_addr, APRICOT_TOTAL_SIZE);
+}
+#endif /* MODULE */
+
+/*
+ * Local variables:
+ *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c apricot.c"
+ * End:
+ */
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/net/Makefile linuxvme-2.1.108/drivers/net/Makefile
--- linux68k-2.1.108+Geert/drivers/net/Makefile	Wed Jul 15 21:16:17 1998
+++ linuxvme-2.1.108/drivers/net/Makefile	Tue Jul 14 08:39:03 1998
@@ -22,6 +22,8 @@
 CONFIG_PPPDEF_MODULE  :=
 CONFIG_7990_BUILTIN :=
 CONFIG_7990_MODULE :=
+CONFIG_82596_BUILTIN :=
+CONFIG_82596_MODULE :=
 
 ifeq ($(CONFIG_ISDN),y)
   ifeq ($(CONFIG_ISDN_PPP),y)
@@ -591,10 +593,26 @@
 endif
 
 ifeq ($(CONFIG_APRICOT),y)
-L_OBJS += apricot.o
+CONFIG_82596_BUILTIN = y
 else
   ifeq ($(CONFIG_APRICOT),m)
-  M_OBJS += apricot.o
+  CONFIG_82596_MODULE = y
+  endif
+endif
+
+ifeq ($(CONFIG_MVME16x_NET),y)
+CONFIG_82596_BUILTIN = y
+else
+  ifeq ($(CONFIG_MVME16x_NET),m)
+  CONFIG_82596_MODULE = y
+  endif
+endif
+
+ifeq ($(CONFIG_BVME6000_NET),y)
+CONFIG_82596_BUILTIN = y
+else
+  ifeq ($(CONFIG_BVME6000_NET),m)
+  CONFIG_82596_MODULE = y
   endif
 endif
 
@@ -709,6 +727,16 @@
 else
   ifdef CONFIG_7990_MODULE
   M_OBJS += 7990.o
+  endif
+endif
+
+# If anything built-in uses the 82596, then build it into the kernel also.
+# If not, but a module uses it, build as a module.
+ifdef CONFIG_82596_BUILTIN
+L_OBJS += 82596.o
+else
+  ifdef CONFIG_82596_MODULE
+  M_OBJS += 82596.o
   endif
 endif
 
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/net/Space.c linuxvme-2.1.108/drivers/net/Space.c
--- linux68k-2.1.108+Geert/drivers/net/Space.c	Wed Jul 15 21:16:17 1998
+++ linuxvme-2.1.108/drivers/net/Space.c	Wed Jul 15 20:50:59 1998
@@ -62,7 +62,7 @@
 extern int fmv18x_probe(struct device *);
 extern int eth16i_probe(struct device *);
 extern int depca_probe(struct device *);
-extern int apricot_probe(struct device *);
+extern int i82596_probe(struct device *);
 extern int ewrk3_probe(struct device *);
 extern int de4x5_probe(struct device *);
 extern int el1_probe(struct device *);
@@ -234,8 +234,8 @@
 #ifdef CONFIG_DE4X5             /* DEC DE425, DE434, DE435 adapters */
         && de4x5_probe(dev)
 #endif
-#ifdef CONFIG_APRICOT		/* Apricot I82596 */
-	&& apricot_probe(dev)
+#if defined(CONFIG_APRICOT) || defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET)		/* Apricot I82596 */
+	&& i82596_probe(dev)
 #endif
 #ifdef CONFIG_EL1		/* 3c501 */
 	&& el1_probe(dev)
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/net/apricot.c linuxvme-2.1.108/drivers/net/apricot.c
--- linux68k-2.1.108+Geert/drivers/net/apricot.c	Tue Feb 17 13:57:45 1998
+++ linuxvme-2.1.108/drivers/net/apricot.c	Thu Jan  1 00:00:00 1970
@@ -1,1031 +0,0 @@
-/* apricot.c: An Apricot 82596 ethernet driver for linux. */
-/*
-    Apricot
-    	Written 1994 by Mark Evans.
-	This driver is for the Apricot 82596 bus-master interface
-
-        Modularised 12/94 Mark Evans
-
-    Driver skeleton
-	Written 1993 by Donald Becker.
-	Copyright 1993 United States Government as represented by the Director,
-	National Security Agency.  This software may only be used and distributed
-	according to the terms of the GNU Public License as modified by SRC,
-	incorporated herein by reference.
-
-	The author may be reached as becker@super.org or
-	C/O Supercomputing Research Ctr., 17100 Science Dr., Bowie MD 20715
-
-
-*/
-
-static const char *version = "apricot.c:v0.2 05/12/94\n";
-
-#include <linux/module.h>
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/ptrace.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/malloc.h>
-#include <linux/interrupt.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/init.h>
-
-#include <asm/bitops.h>
-#include <asm/io.h>
-#include <asm/dma.h>
-
-#ifndef HAVE_PORTRESERVE
-#define check_region(addr, size)	0
-#define request_region(addr, size,name)	do ; while(0)
-#endif
-
-#ifndef HAVE_ALLOC_SKB
-#define alloc_skb(size, priority) (struct sk_buff *) kmalloc(size,priority)
-#define kfree_skbmem(buff, size) kfree_s(buff,size)
-#endif
-
-#define APRICOT_DEBUG 1
-
-#ifdef APRICOT_DEBUG
-int i596_debug = APRICOT_DEBUG;
-#else
-int i596_debug = 1;
-#endif
-
-#define APRICOT_TOTAL_SIZE 17
-
-#define I596_NULL -1
-
-#define CMD_EOL		0x8000	/* The last command of the list, stop. */
-#define CMD_SUSP	0x4000	/* Suspend after doing cmd. */
-#define CMD_INTR	0x2000	/* Interrupt after doing cmd. */
-
-#define CMD_FLEX	0x0008	/* Enable flexible memory model */
-
-enum commands {
-	CmdNOp = 0, CmdSASetup = 1, CmdConfigure = 2, CmdMulticastList = 3,
-	CmdTx = 4, CmdTDR = 5, CmdDump = 6, CmdDiagnose = 7};
-
-#define STAT_C		0x8000	/* Set to 0 after execution */
-#define STAT_B		0x4000	/* Command being executed */
-#define STAT_OK		0x2000	/* Command executed ok */
-#define STAT_A		0x1000	/* Command aborted */
-
-#define	 CUC_START	0x0100
-#define	 CUC_RESUME	0x0200
-#define	 CUC_SUSPEND    0x0300
-#define	 CUC_ABORT	0x0400
-#define	 RX_START	0x0010
-#define	 RX_RESUME	0x0020
-#define	 RX_SUSPEND	0x0030
-#define	 RX_ABORT	0x0040
-
-struct i596_cmd {
-    unsigned short status;
-    unsigned short command;
-    struct i596_cmd *next;
-};
-
-#define EOF		0x8000
-#define SIZE_MASK	0x3fff
-
-struct i596_tbd {
-    unsigned short size;
-    unsigned short pad;
-    struct i596_tbd *next;
-    char *data;
-};
-
-struct tx_cmd {
-    struct i596_cmd cmd;
-    struct i596_tbd *tbd;
-    unsigned short size;
-    unsigned short pad;
-};
-
-struct i596_rfd {
-    unsigned short stat;
-    unsigned short cmd;
-    struct i596_rfd *next;
-    long rbd;
-    unsigned short count;
-    unsigned short size;
-    char data[1532];
-};
-
-#define RX_RING_SIZE 8
-
-struct i596_scb {
-    unsigned short status;
-    unsigned short command;
-    struct i596_cmd *cmd;
-    struct i596_rfd *rfd;
-    unsigned long crc_err;
-    unsigned long align_err;
-    unsigned long resource_err;
-    unsigned long over_err;
-    unsigned long rcvdt_err;
-    unsigned long short_err;
-    unsigned short t_on;
-    unsigned short t_off;
-};
-
-struct i596_iscp {
-    unsigned long stat;
-    struct i596_scb *scb;
-};
-
-struct i596_scp {
-    unsigned long sysbus;
-    unsigned long pad;
-    struct i596_iscp *iscp;
-};
-
-struct i596_private {
-    struct i596_scp scp;
-    struct i596_iscp iscp;
-    struct i596_scb scb;
-    struct i596_cmd set_add;
-    char eth_addr[8];
-    struct i596_cmd set_conf;
-    char i596_config[16];
-    struct i596_cmd tdr;
-    unsigned long stat;
-    int last_restart;
-    struct i596_rfd *rx_tail;
-    struct i596_cmd *cmd_tail;
-    struct i596_cmd *cmd_head;
-    int cmd_backlog;
-    unsigned long last_cmd;
-    struct net_device_stats stats;
-};
-
-char init_setup[] = {
-	0x8E,	/* length, prefetch on */
-	0xC8,	/* fifo to 8, monitor off */
-	0x80,	/* don't save bad frames */
-	0x2E,	/* No source address insertion, 8 byte preamble */
-	0x00,	/* priority and backoff defaults */
-	0x60,	/* interframe spacing */
-	0x00,	/* slot time LSB */
-	0xf2,	/* slot time and retries */
-	0x00,	/* promiscuous mode */
-	0x00,	/* collision detect */
-	0x40,	/* minimum frame length */
-	0xff,
-	0x00,
-	0x7f	/*  *multi IA */ };
-
-static int i596_open(struct device *dev);
-static int i596_start_xmit(struct sk_buff *skb, struct device *dev);
-static void i596_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-static int i596_close(struct device *dev);
-static struct net_device_stats *i596_get_stats(struct device *dev);
-static void i596_add_cmd(struct device *dev, struct i596_cmd *cmd);
-static void print_eth(char *);
-static void set_multicast_list(struct device *dev);
-
-
-static inline int
-init_rx_bufs(struct device *dev, int num)
-{
-    struct i596_private *lp = (struct i596_private *)dev->priv;
-    int i;
-    struct i596_rfd *rfd;
-
-    lp->scb.rfd = (struct i596_rfd *)I596_NULL;
-
-    if (i596_debug > 1) printk ("%s: init_rx_bufs %d.\n", dev->name, num);
-
-    for (i = 0; i < num; i++)
-    {
-	if (!(rfd = (struct i596_rfd *)kmalloc(sizeof(struct i596_rfd), GFP_KERNEL)))
-            break;
-
-	rfd->stat = 0x0000;
-	rfd->rbd = I596_NULL;
-	rfd->count = 0;
-	rfd->size = 1532;
-        if (i == 0)
-        {
-	    rfd->cmd = CMD_EOL;
-            lp->rx_tail = rfd;
-        }
-        else
-	    rfd->cmd = 0x0000;
-
-        rfd->next = lp->scb.rfd;
-        lp->scb.rfd = rfd;
-    }
-
-    if (i != 0)
-      lp->rx_tail->next = lp->scb.rfd;
-
-    return (i);
-}
-
-static inline void
-remove_rx_bufs(struct device *dev)
-{
-    struct i596_private *lp = (struct i596_private *)dev->priv;
-    struct i596_rfd *rfd = lp->scb.rfd;
-
-    lp->rx_tail->next = (struct i596_rfd *)I596_NULL;
-
-    do
-    {
-        lp->scb.rfd = rfd->next;
-        kfree(rfd);
-        rfd = lp->scb.rfd;
-    }
-    while (rfd != lp->rx_tail);
-}
-
-static inline void
-init_i596_mem(struct device *dev)
-{
-    struct i596_private *lp = (struct i596_private *)dev->priv;
-    short ioaddr = dev->base_addr;
-    int boguscnt = 100;
-
-    /* change the scp address */
-    outw(0, ioaddr);
-    outw(0, ioaddr);
-    outb(4, ioaddr+0xf);
-    outw(((((int)&lp->scp) & 0xffff) | 2), ioaddr);
-    outw((((int)&lp->scp)>>16) & 0xffff, ioaddr);
-
-    lp->last_cmd = jiffies;
-
-    lp->scp.sysbus = 0x00440000;
-    lp->scp.iscp = &(lp->iscp);
-    lp->iscp.scb = &(lp->scb);
-    lp->iscp.stat = 0x0001;
-    lp->cmd_backlog = 0;
-
-    lp->cmd_head = lp->scb.cmd = (struct i596_cmd *) I596_NULL;
-
-    if (i596_debug > 2) printk("%s: starting i82596.\n", dev->name);
-
-    (void) inb (ioaddr+0x10);
-    outb(4, ioaddr+0xf);
-    outw(0, ioaddr+4);
-
-    while (lp->iscp.stat)
-	if (--boguscnt == 0)
-	{
-	    printk("%s: i82596 initialization timed out with status %4.4x, cmd %4.4x.\n",
-		   dev->name, lp->scb.status, lp->scb.command);
-	    break;
-    	}
-
-    lp->scb.command = 0;
-
-    memcpy (lp->i596_config, init_setup, 14);
-    lp->set_conf.command = CmdConfigure;
-    i596_add_cmd(dev, &lp->set_conf);
-
-    memcpy (lp->eth_addr, dev->dev_addr, 6);
-    lp->set_add.command = CmdSASetup;
-    i596_add_cmd(dev, &lp->set_add);
-
-    lp->tdr.command = CmdTDR;
-    i596_add_cmd(dev, &lp->tdr);
-
-    boguscnt = 200;
-    while (lp->scb.command)
-	if (--boguscnt == 0)
-	{
-	    printk("%s: receive unit start timed out with status %4.4x, cmd %4.4x.\n",
-		   dev->name, lp->scb.status, lp->scb.command);
-	    break;
-    	}
-
-    lp->scb.command = RX_START;
-    outw(0, ioaddr+4);
-
-    boguscnt = 200;
-    while (lp->scb.command)
-        if (--boguscnt == 0)
-	{
-	    printk("i82596 init timed out with status %4.4x, cmd %4.4x.\n",
-		lp->scb.status, lp->scb.command);
-	    break;
-	}
-
-    return;
-}
-
-static inline int
-i596_rx(struct device *dev)
-{
-    struct i596_private *lp = (struct i596_private *)dev->priv;
-    int frames = 0;
-
-    if (i596_debug > 3) printk ("i596_rx()\n");
-
-    while ((lp->scb.rfd->stat) & STAT_C)
-    {
-        if (i596_debug >2) print_eth(lp->scb.rfd->data);
-
-	if ((lp->scb.rfd->stat) & STAT_OK)
-	{
-	    /* a good frame */
-	    int pkt_len = lp->scb.rfd->count & 0x3fff;
-	    struct sk_buff *skb = dev_alloc_skb(pkt_len);
-
-	    frames++;
-
-	    if (skb == NULL)
-	    {
-		printk ("%s: i596_rx Memory squeeze, dropping packet.\n", dev->name);
-		lp->stats.rx_dropped++;
-		break;
-	    }
-
-  	    skb->dev = dev;
-	    memcpy(skb_put(skb,pkt_len), lp->scb.rfd->data, pkt_len);
-
-	    skb->protocol=eth_type_trans(skb,dev);
-	    netif_rx(skb);
-	    lp->stats.rx_packets++;
-	    lp->stats.rx_bytes+=pkt_len;
-
-	    if (i596_debug > 4) print_eth(skb->data);
-	}
-	else
-	{
-	    lp->stats.rx_errors++;
-	    if ((lp->scb.rfd->stat) & 0x0001) lp->stats.collisions++;
-	    if ((lp->scb.rfd->stat) & 0x0080) lp->stats.rx_length_errors++;
-	    if ((lp->scb.rfd->stat) & 0x0100) lp->stats.rx_over_errors++;
-	    if ((lp->scb.rfd->stat) & 0x0200) lp->stats.rx_fifo_errors++;
-	    if ((lp->scb.rfd->stat) & 0x0400) lp->stats.rx_frame_errors++;
-	    if ((lp->scb.rfd->stat) & 0x0800) lp->stats.rx_crc_errors++;
-	    if ((lp->scb.rfd->stat) & 0x1000) lp->stats.rx_length_errors++;
-	}
-
-	lp->scb.rfd->stat = 0;
-	lp->rx_tail->cmd = 0;
-	lp->rx_tail = lp->scb.rfd;
-	lp->scb.rfd = lp->scb.rfd->next;
-	lp->rx_tail->count = 0;
-	lp->rx_tail->cmd = CMD_EOL;
-
-    }
-
-    if (i596_debug > 3) printk ("frames %d\n", frames);
-
-    return 0;
-}
-
-static inline void
-i596_cleanup_cmd(struct i596_private *lp)
-{
-    struct i596_cmd *ptr;
-    int boguscnt = 100;
-
-    if (i596_debug > 4) printk ("i596_cleanup_cmd\n");
-
-    while (lp->cmd_head != (struct i596_cmd *) I596_NULL)
-    {
-	ptr = lp->cmd_head;
-
-	lp->cmd_head = lp->cmd_head->next;
-	lp->cmd_backlog--;
-
-	switch ((ptr->command) & 0x7)
-	{
-	    case CmdTx:
-	    {
-		struct tx_cmd *tx_cmd = (struct tx_cmd *) ptr;
-		struct sk_buff *skb = ((struct sk_buff *)(tx_cmd->tbd->data)) -1;
-
-		dev_kfree_skb(skb);
-
-		lp->stats.tx_errors++;
-		lp->stats.tx_aborted_errors++;
-
-		ptr->next = (struct i596_cmd * ) I596_NULL;
-		kfree(tx_cmd);
-		break;
-	    }
-	    case CmdMulticastList:
-	    {
-		ptr->next = (struct i596_cmd * ) I596_NULL;
-		kfree(ptr);
-		break;
-	    }
-	    default:
-		ptr->next = (struct i596_cmd * ) I596_NULL;
-	}
-    }
-
-    while (lp->scb.command)
-	if (--boguscnt == 0)
-	{
-	    printk("i596_cleanup_cmd timed out with status %4.4x, cmd %4.4x.\n",
-		lp->scb.status, lp->scb.command);
-	    break;
-    	}
-
-    lp->scb.cmd = lp->cmd_head;
-}
-
-static inline void
-i596_reset(struct device *dev, struct i596_private *lp, int ioaddr)
-{
-    int boguscnt = 100;
-
-    if (i596_debug > 4) printk ("i596_reset\n");
-
-    while (lp->scb.command)
-        if (--boguscnt == 0)
-	{
-	    printk("i596_reset timed out with status %4.4x, cmd %4.4x.\n",
-		lp->scb.status, lp->scb.command);
-	    break;
-	}
-
-    dev->start = 0;
-    dev->tbusy = 1;
-
-    lp->scb.command = CUC_ABORT|RX_ABORT;
-    outw(0, ioaddr+4);
-
-    /* wait for shutdown */
-    boguscnt = 400;
-
-    while (lp->scb.command)
-        if (--boguscnt == 0)
-	{
-	    printk("i596_reset 2 timed out with status %4.4x, cmd %4.4x.\n",
-		lp->scb.status, lp->scb.command);
-	    break;
-	}
-
-    i596_cleanup_cmd(lp);
-    i596_rx(dev);
-
-    dev->start = 1;
-    dev->tbusy = 0;
-    dev->interrupt = 0;
-    init_i596_mem(dev);
-}
-
-static void i596_add_cmd(struct device *dev, struct i596_cmd *cmd)
-{
-    struct i596_private *lp = (struct i596_private *)dev->priv;
-    int ioaddr = dev->base_addr;
-    unsigned long flags;
-    int boguscnt = 100;
-
-    if (i596_debug > 4) printk ("i596_add_cmd\n");
-
-    cmd->status = 0;
-    cmd->command |= (CMD_EOL|CMD_INTR);
-    cmd->next = (struct i596_cmd *) I596_NULL;
-
-    save_flags(flags);
-    cli();
-    if (lp->cmd_head != (struct i596_cmd *) I596_NULL)
-	lp->cmd_tail->next = cmd;
-    else
-    {
-	lp->cmd_head = cmd;
-	while (lp->scb.command)
-	    if (--boguscnt == 0)
-	    {
-		printk("i596_add_cmd timed out with status %4.4x, cmd %4.4x.\n",
-		   lp->scb.status, lp->scb.command);
-		break;
-    	    }
-
-	lp->scb.cmd = cmd;
-	lp->scb.command = CUC_START;
-        outw (0, ioaddr+4);
-    }
-    lp->cmd_tail = cmd;
-    lp->cmd_backlog++;
-
-    lp->cmd_head = lp->scb.cmd;
-    restore_flags(flags);
-
-    if (lp->cmd_backlog > 16)
-    {
-	int tickssofar = jiffies - lp->last_cmd;
-
-	if (tickssofar < 25) return;
-
-	printk("%s: command unit timed out, status resetting.\n", dev->name);
-
-	i596_reset(dev, lp, ioaddr);
-    }
-}
-
-static int
-i596_open(struct device *dev)
-{
-    int i;
-
-    if (i596_debug > 1)
-	printk("%s: i596_open() irq %d.\n", dev->name, dev->irq);
-
-    if (request_irq(dev->irq, &i596_interrupt, 0, "apricot", dev))
-	return -EAGAIN;
-
-    i = init_rx_bufs(dev, RX_RING_SIZE);
-
-    if ((i = init_rx_bufs(dev, RX_RING_SIZE)) < RX_RING_SIZE)
-        printk("%s: only able to allocate %d receive buffers\n", dev->name, i);
-
-    if (i < 4)
-    {
-        free_irq(dev->irq, dev);
-        return -EAGAIN;
-    }
-
-    dev->tbusy = 0;
-    dev->interrupt = 0;
-    dev->start = 1;
-    MOD_INC_USE_COUNT;
-
-    /* Initialize the 82596 memory */
-    init_i596_mem(dev);
-
-    return 0;			/* Always succeed */
-}
-
-static int
-i596_start_xmit(struct sk_buff *skb, struct device *dev)
-{
-    struct i596_private *lp = (struct i596_private *)dev->priv;
-    int ioaddr = dev->base_addr;
-    struct tx_cmd *tx_cmd;
-
-    if (i596_debug > 2) printk ("%s: Apricot start xmit\n", dev->name);
-
-    /* Transmitter timeout, serious problems. */
-    if (dev->tbusy) {
-	int tickssofar = jiffies - dev->trans_start;
-	if (tickssofar < 5)
-	    return 1;
-	printk("%s: transmit timed out, status resetting.\n",
-	       dev->name);
-	lp->stats.tx_errors++;
-	/* Try to restart the adaptor */
-	if (lp->last_restart == lp->stats.tx_packets) {
-	    if (i596_debug > 1) printk ("Resetting board.\n");
-
-	    /* Shutdown and restart */
-            i596_reset(dev,lp, ioaddr);
-	} else {
-	    /* Issue a channel attention signal */
-	    if (i596_debug > 1) printk ("Kicking board.\n");
-
-	    lp->scb.command = CUC_START|RX_START;
-	    outw(0, ioaddr+4);
-
-	    lp->last_restart = lp->stats.tx_packets;
-	}
-	dev->tbusy = 0;
-	dev->trans_start = jiffies;
-    }
-
-    if (i596_debug > 3) printk("%s: i596_start_xmit() called\n", dev->name);
-
-    /* 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 (test_and_set_bit(0, (void*)&dev->tbusy) != 0)
-	printk("%s: Transmitter access conflict.\n", dev->name);
-    else
-    {
-	short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
-	dev->trans_start = jiffies;
-
-	tx_cmd = (struct tx_cmd *) kmalloc ((sizeof (struct tx_cmd) + sizeof (struct i596_tbd)), GFP_ATOMIC);
-	if (tx_cmd == NULL)
-	{
-	    printk ("%s: i596_xmit Memory squeeze, dropping packet.\n", dev->name);
-	    lp->stats.tx_dropped++;
-
-	    dev_kfree_skb(skb);
-	}
-	else
-	{
-	    tx_cmd->tbd = (struct i596_tbd *) (tx_cmd + 1);
-	    tx_cmd->tbd->next = (struct i596_tbd *) I596_NULL;
-
-	    tx_cmd->cmd.command = CMD_FLEX|CmdTx;
-
-	    tx_cmd->pad = 0;
-	    tx_cmd->size = 0;
-	    tx_cmd->tbd->pad = 0;
-	    tx_cmd->tbd->size = EOF | length;
-
-	    tx_cmd->tbd->data = skb->data;
-
-	    if (i596_debug > 3) print_eth(skb->data);
-
-	    i596_add_cmd(dev, (struct i596_cmd *)tx_cmd);
-
-	    lp->stats.tx_packets++;
-	    lp->stats.tx_bytes+=length;
-	}
-    }
-
-    dev->tbusy = 0;
-
-    return 0;
-}
-
-
-static void print_eth(char *add)
-{
-    int i;
-
-    printk ("Dest  ");
-    for (i = 0; i < 6; i++)
-	printk(" %2.2X", (unsigned char)add[i]);
-    printk ("\n");
-
-    printk ("Source");
-    for (i = 0; i < 6; i++)
-	printk(" %2.2X", (unsigned char)add[i+6]);
-    printk ("\n");
-    printk ("type %2.2X%2.2X\n", (unsigned char)add[12], (unsigned char)add[13]);
-}
-
-__initfunc(int apricot_probe(struct device *dev))
-{
-    int i;
-    struct i596_private *lp;
-    int checksum = 0;
-    int ioaddr = 0x300;
-    char eth_addr[6];
-
-    /* this is easy the ethernet interface can only be at 0x300 */
-    /* first check nothing is already registered here */
-
-    if (check_region(ioaddr, APRICOT_TOTAL_SIZE))
-	return ENODEV;
-
-    for (i = 0; i < 8; i++)
-    {
-    	eth_addr[i] = inb(ioaddr+8+i);
-	checksum += eth_addr[i];
-     }
-
-    /* checksum is a multiple of 0x100, got this wrong first time
-       some machines have 0x100, some 0x200. The DOS driver doesn't
-       even bother with the checksum */
-
-    if (checksum % 0x100) return ENODEV;
-
-    /* Some other boards trip the checksum.. but then appear as ether
-       address 0. Trap these - AC */
-
-    if(memcmp(eth_addr,"\x00\x00\x49",3)!= 0)
-    	return ENODEV;
-
-    request_region(ioaddr, APRICOT_TOTAL_SIZE, "apricot");
-
-    dev->base_addr = ioaddr;
-    ether_setup(dev);
-    printk("%s: Apricot 82596 at %#3x,", dev->name, ioaddr);
-
-    for (i = 0; i < 6; i++)
-	printk(" %2.2X", dev->dev_addr[i] = eth_addr[i]);
-
-    dev->base_addr = ioaddr;
-    dev->irq = 10;
-    printk(" IRQ %d.\n", dev->irq);
-
-    if (i596_debug > 0) printk(version);
-
-    /* The APRICOT-specific entries in the device structure. */
-    dev->open = &i596_open;
-    dev->stop = &i596_close;
-    dev->hard_start_xmit = &i596_start_xmit;
-    dev->get_stats = &i596_get_stats;
-    dev->set_multicast_list = &set_multicast_list;
-
-    dev->mem_start = (int)kmalloc(sizeof(struct i596_private)+ 0x0f, GFP_KERNEL);
-    /* align for scp */
-    dev->priv = (void *)((dev->mem_start + 0xf) & 0xfffffff0);
-
-    lp = (struct i596_private *)dev->priv;
-    memset((void *)lp, 0, sizeof(struct i596_private));
-    lp->scb.command = 0;
-    lp->scb.cmd = (struct i596_cmd *) I596_NULL;
-    lp->scb.rfd = (struct i596_rfd *)I596_NULL;
-
-    return 0;
-}
-
-static void
-i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-    struct device *dev = dev_id;
-    struct i596_private *lp;
-    short ioaddr;
-    int boguscnt = 200;
-    unsigned short status, ack_cmd = 0;
-
-    if (dev == NULL) {
-	printk ("i596_interrupt(): irq %d for unknown device.\n", irq);
-	return;
-    }
-
-    if (i596_debug > 3) printk ("%s: i596_interrupt(): irq %d\n",dev->name, irq);
-
-    if (dev->interrupt)
-	printk("%s: Re-entering the interrupt handler.\n", dev->name);
-
-    dev->interrupt = 1;
-
-    ioaddr = dev->base_addr;
-
-    lp = (struct i596_private *)dev->priv;
-
-    while (lp->scb.command)
-	if (--boguscnt == 0)
-	    {
-		printk("%s: i596 interrupt, timeout status %4.4x command %4.4x.\n", dev->name, lp->scb.status, lp->scb.command);
-		break;
-	    }
-    status = lp->scb.status;
-
-    if (i596_debug > 4)
-	printk("%s: i596 interrupt, status %4.4x.\n", dev->name, status);
-
-    ack_cmd = status & 0xf000;
-
-    if ((status & 0x8000) || (status & 0x2000))
-    {
-	struct i596_cmd *ptr;
-
-	if ((i596_debug > 4) && (status & 0x8000))
-	    printk("%s: i596 interrupt completed command.\n", dev->name);
-	if ((i596_debug > 4) && (status & 0x2000))
-	    printk("%s: i596 interrupt command unit inactive %x.\n", dev->name, status & 0x0700);
-
-	while ((lp->cmd_head != (struct i596_cmd *) I596_NULL) && (lp->cmd_head->status & STAT_C))
-	{
-	    ptr = lp->cmd_head;
-
-	    lp->cmd_head = lp->cmd_head->next;
-	    lp->cmd_backlog--;
-
-	    switch ((ptr->command) & 0x7)
-	    {
-		case CmdTx:
-		{
-		    struct tx_cmd *tx_cmd = (struct tx_cmd *) ptr;
-		    struct sk_buff *skb = ((struct sk_buff *)(tx_cmd->tbd->data)) -1;
-
-		    dev_kfree_skb(skb);
-
-		    if ((ptr->status) & STAT_OK)
-		    {
-	    		if (i596_debug >2) print_eth(skb->data);
-		    }
-		    else
-		    {
-			lp->stats.tx_errors++;
-			if ((ptr->status) & 0x0020) lp->stats.collisions++;
-			if (!((ptr->status) & 0x0040)) lp->stats.tx_heartbeat_errors++;
-			if ((ptr->status) & 0x0400) lp->stats.tx_carrier_errors++;
-			if ((ptr->status) & 0x0800) lp->stats.collisions++;
-			if ((ptr->status) & 0x1000) lp->stats.tx_aborted_errors++;
-		    }
-
-
-		    ptr->next = (struct i596_cmd * ) I596_NULL;
-		    kfree(tx_cmd);
-		    break;
-		}
-		case CmdMulticastList:
-		{
-		    ptr->next = (struct i596_cmd * ) I596_NULL;
-		    kfree(ptr);
-		    break;
-		}
-		case CmdTDR:
-		{
-		    unsigned long status = *((unsigned long *) (ptr + 1));
-
-		    if (status & 0x8000)
-		    {
-			if (i596_debug > 3)
-	    		    printk("%s: link ok.\n", dev->name);
-		    }
-		    else
-		    {
-			if (status & 0x4000)
-	    		    printk("%s: Transceiver problem.\n", dev->name);
-			if (status & 0x2000)
-	    		    printk("%s: Termination problem.\n", dev->name);
-			if (status & 0x1000)
-	    		    printk("%s: Short circuit.\n", dev->name);
-
-	    		printk("%s: Time %ld.\n", dev->name, status & 0x07ff);
-		    }
-		}
-		default:
-		    ptr->next = (struct i596_cmd * ) I596_NULL;
-
-		lp->last_cmd = jiffies;
- 	    }
-	}
-
-	ptr = lp->cmd_head;
-	while ((ptr != (struct i596_cmd *) I596_NULL) && (ptr != lp->cmd_tail))
-	{
-	    ptr->command &= 0x1fff;
-	    ptr = ptr->next;
-	}
-
-	if ((lp->cmd_head != (struct i596_cmd *) I596_NULL) && (dev->start)) ack_cmd |= CUC_START;
-	lp->scb.cmd = lp->cmd_head;
-    }
-
-    if ((status & 0x1000) || (status & 0x4000))
-    {
-	if ((i596_debug > 4) && (status & 0x4000))
-	    printk("%s: i596 interrupt received a frame.\n", dev->name);
-	if ((i596_debug > 4) && (status & 0x1000))
-	    printk("%s: i596 interrupt receive unit inactive %x.\n", dev->name, status & 0x0070);
-
-	i596_rx(dev);
-
-	if (dev->start) ack_cmd |= RX_START;
-    }
-
-    /* acknowledge the interrupt */
-
-/*
-    if ((lp->scb.cmd != (struct i596_cmd *) I596_NULL) && (dev->start)) ack_cmd | = CUC_START;
-*/
-    boguscnt = 100;
-    while (lp->scb.command)
-	if (--boguscnt == 0)
-	    {
-		printk("%s: i596 interrupt, timeout status %4.4x command %4.4x.\n", dev->name, lp->scb.status, lp->scb.command);
-		break;
-	    }
-    lp->scb.command = ack_cmd;
-
-    (void) inb (ioaddr+0x10);
-    outb (4, ioaddr+0xf);
-    outw (0, ioaddr+4);
-
-    if (i596_debug > 4)
-	printk("%s: exiting interrupt.\n", dev->name);
-
-    dev->interrupt = 0;
-    return;
-}
-
-static int
-i596_close(struct device *dev)
-{
-    int ioaddr = dev->base_addr;
-    struct i596_private *lp = (struct i596_private *)dev->priv;
-    int boguscnt = 200;
-
-    dev->start = 0;
-    dev->tbusy = 1;
-
-    if (i596_debug > 1)
-	printk("%s: Shutting down ethercard, status was %4.4x.\n",
-	       dev->name, lp->scb.status);
-
-    lp->scb.command = CUC_ABORT|RX_ABORT;
-    outw(0, ioaddr+4);
-
-    i596_cleanup_cmd(lp);
-
-    while (lp->scb.command)
-	if (--boguscnt == 0)
-	{
-	    printk("%s: close timed timed out with status %4.4x, cmd %4.4x.\n",
-		   dev->name, lp->scb.status, lp->scb.command);
-	    break;
-    	}
-    free_irq(dev->irq, dev);
-    remove_rx_bufs(dev);
-    MOD_DEC_USE_COUNT;
-
-    return 0;
-}
-
-static struct net_device_stats *
-i596_get_stats(struct device *dev)
-{
-    struct i596_private *lp = (struct i596_private *)dev->priv;
-
-    return &lp->stats;
-}
-
-/*
- *	Set or clear the multicast filter for this adaptor.
- */
-
-static void set_multicast_list(struct device *dev)
-{
-	struct i596_private *lp = (struct i596_private *)dev->priv;
-	struct i596_cmd *cmd;
-
-	if (i596_debug > 1)
-		printk ("%s: set multicast list %d\n", dev->name, dev->mc_count);
-
-	if (dev->mc_count > 0)
-	{
-		struct dev_mc_list *dmi;
-		char *cp;
-		cmd = (struct i596_cmd *) kmalloc(sizeof(struct i596_cmd)+2+dev->mc_count*6, GFP_ATOMIC);
-		if (cmd == NULL)
-		{
-			printk ("%s: set_multicast Memory squeeze.\n", dev->name);
-			return;
-		}
-		cmd->command = CmdMulticastList;
-		*((unsigned short *) (cmd + 1)) = dev->mc_count * 6;
-		cp=((char *)(cmd + 1))+2;
-		for(dmi=dev->mc_list;dmi!=NULL;dmi=dmi->next)
-		{
-			memcpy(cp, dmi,6);
-			cp+=6;
-		}
-		print_eth (((char *)(cmd + 1)) + 2);
-		i596_add_cmd(dev, cmd);
-	}
-	else
-	{
-		if (lp->set_conf.next != (struct i596_cmd * ) I596_NULL)
-			return;
-		if (dev->mc_count == 0 && !(dev->flags&(IFF_PROMISC|IFF_ALLMULTI)))
-		{
-			if(dev->flags&IFF_ALLMULTI)
-				dev->flags|=IFF_PROMISC;
-			lp->i596_config[8] &= ~0x01;
-		}
-		else
-			lp->i596_config[8] |= 0x01;
-
-		i596_add_cmd(dev, &lp->set_conf);
-	}
-}
-
-#ifdef HAVE_DEVLIST
-static unsigned int apricot_portlist[] __initdata = {0x300, 0};
-struct netdev_entry apricot_drv =
-{"apricot", apricot_probe, APRICOT_TOTAL_SIZE, apricot_portlist};
-#endif
-
-#ifdef MODULE
-static char devicename[9] = { 0, };
-static struct device dev_apricot = {
-  devicename, /* device name inserted by /linux/drivers/net/net_init.c */
-  0, 0, 0, 0,
-  0x300, 10,
-  0, 0, 0, NULL, apricot_probe };
-
-static int io = 0x300;
-static int irq = 10;
-MODULE_PARM(irq, "i");
-
-int
-init_module(void)
-{
-  dev_apricot.base_addr = io;
-  dev_apricot.irq       = irq;
-  if (register_netdev(&dev_apricot) != 0)
-    return -EIO;
-  return 0;
-}
-
-void
-cleanup_module(void)
-{
-    unregister_netdev(&dev_apricot);
-    kfree((void*)dev_apricot.mem_start);
-    dev_apricot.priv = NULL;
-
-    /* If we don't do this, we can't re-insmod it later. */
-    release_region(dev_apricot.base_addr, APRICOT_TOTAL_SIZE);
-}
-#endif /* MODULE */
-
-/*
- * Local variables:
- *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c apricot.c"
- * End:
- */
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/scsi/53c7xx.c linuxvme-2.1.108/drivers/scsi/53c7xx.c
--- linux68k-2.1.108+Geert/drivers/scsi/53c7xx.c	Wed Jul 15 21:13:02 1998
+++ linuxvme-2.1.108/drivers/scsi/53c7xx.c	Wed Jul 15 20:59:53 1998
@@ -40,7 +40,8 @@
  *
  * Options for the NCR7xx driver
  *
- * nosync:0		-	disables synchronous negotiation
+ * noasync:0		-	disables sync and asynchronous negotiation
+ * nosync:0		-	disables synchronous negotiation (does async)
  * nodisconnect:0	-	disables disconnection
  * validids:0x??	-	Bitmask field that disallows certain ID's.
  *			-	e.g.	0x03	allows ID 0,1
@@ -355,7 +356,6 @@
 #ifdef FORCE_DSA_ALIGNMENT
 int CmdPageStart = (0 - Ent_dsa_zero - sizeof(struct NCR53c7x0_cmd)) & 0xff;
 #endif
-int flushsize;
 
 static char *setup_strings[] =
 	{"","","","","","","",""};
@@ -713,7 +713,7 @@
 	    h->max_id);
 	return -1;
     }
-    hostdata = (struct NCR53c7x0_hostdata *)h->hostdata;
+    hostdata = (struct NCR53c7x0_hostdata *)h->hostdata[0];
 
     save_flags(flags);
     cli();
@@ -746,7 +746,7 @@
     struct NCR53c7x0_hostdata *hostdata;
     if (!(h = find_host (host)))
 	return -1;
-    hostdata = (struct NCR53c7x0_hostdata *) h->hostdata;
+    hostdata = (struct NCR53c7x0_hostdata *) h->hostdata[0];
     if (on_or_off) 
 	hostdata->options |= OPTION_DISCONNECT;
     else
@@ -767,7 +767,7 @@
 static void 
 NCR53c7x0_driver_init (struct Scsi_Host *host) {
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     int i, j;
     u32 *ncrcurrent;
 
@@ -799,9 +799,6 @@
     	hostdata->initiate_sdtr = 0;
     hostdata->talked_to = 0;
     hostdata->idle = 1;
-
-    if (!MACH_IS_MVME16x && !MACH_IS_BVME6000)
-	cache_push(virt_to_bus(hostdata->script), flushsize);
 }
 
 /* 
@@ -849,7 +846,7 @@
     int i, ccf;
     unsigned char revision;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     struct Scsi_Host *search;
     /* 
      * There are some things which we need to know about in order to provide
@@ -872,12 +869,17 @@
 	hostdata->valid_ids[i] = 1;	/* Default all ID's to scan */
 
     /* Parse commandline flags */
-    if (check_setup_strings("nosync",&flags,&val,buf))
+    if (check_setup_strings("noasync",&flags,&val,buf))
     {
 	hostdata->options |= OPTION_NO_ASYNC;
 	hostdata->options &= ~(OPTION_SYNCHRONOUS | OPTION_ALWAYS_SYNCHRONOUS);
     }
 
+    if (check_setup_strings("nosync",&flags,&val,buf))
+    {
+	hostdata->options &= ~(OPTION_SYNCHRONOUS | OPTION_ALWAYS_SYNCHRONOUS);
+    }
+
     if (check_setup_strings("nodisconnect",&flags,&val,buf))
 	hostdata->options &= ~OPTION_DISCONNECT;
 
@@ -1075,40 +1077,13 @@
      * with another board.
      */
 
-#ifdef CONFIG_MVME16x
-    if (MACH_IS_MVME16x)
-    {
-        if (request_irq(MVME16x_IRQ_SCSI, NCR53c7x0_intr, 0, "SCSI-script", NULL))
-	    panic ("Couldn't get SCSI IRQ");
-#ifdef MVME16x_INTFLY
-        else if (request_irq(MVME16x_IRQ_FLY, NCR53c7x0_intr, 0, "SCSI-intfly", NULL))
-	    panic ("Couldn't get INT_FLY IRQ");
-#endif
-    }
-#endif
-#ifdef CONFIG_BVME6000
-    if (MACH_IS_BVME6000)
-    {
-        if (request_irq(BVME_IRQ_SCSI, NCR53c7x0_intr, 0, "SCSI-script", NULL))
-            panic ("Couldn't get SCSI IRQ");
-    }
-#endif
-#ifndef CONFIG_VME
     for (search = first_host; search && !(search->hostt == the_template &&
 	search->irq == host->irq && search != host); search=search->next);
 
     if (!search) {
-#ifdef CONFIG_AMIGA
-	if (request_irq(IRQ_AMIGA_PORTS, NCR53c7x0_intr, 0, "53c7xx", NCR53c7x0_intr))
-#else
-	if (request_irq(host->irq, NCR53c7x0_intr, SA_INTERRUPT, "53c7xx", NULL))
-#endif
+	if (request_irq(host->irq, NCR53c7x0_intr, 0, "53c7xx", NCR53c7x0_intr))
 	{
-	    printk("scsi%d : IRQ%d not free, detaching\n"
-	           "         You have either a configuration problem, or a\n"
-                   "         broken BIOS.  You may wish to manually assign\n"
-	           "         an interrupt to the NCR board rather than using\n"
-                   "         an automatic setting.\n", 
+	    printk("scsi%d : IRQ%d not free, detaching\n",
 		host->host_no, host->irq);
 	    scsi_unregister (host);
 	    return -1;
@@ -1117,7 +1092,6 @@
 	printk("scsi%d : using interrupt handler previously installed for scsi%d\n",
 	    host->host_no, search->host_no);
     }
-#endif
 
     if ((hostdata->run_tests && hostdata->run_tests(host) == -1) ||
         (hostdata->options & OPTION_DEBUG_TESTS_ONLY)) {
@@ -1236,20 +1210,27 @@
     */
     size += 256;
 #endif
-	flushsize = size;
-    instance = scsi_register (tpnt, size);
+    /* Size should be < 8K, so we can fit it in two pages. */
+    if (size > 8192)
+      panic("53c7xx: hostdata > 8K");
+    instance = scsi_register (tpnt, 4);
     if (!instance)
 	return -1;
+    instance->hostdata[0] = __get_free_pages(GFP_ATOMIC, 1);
+    if (instance->hostdata[0] == 0)
+        panic ("53c7xx: Couldn't get hostdata memory");
+    memset((void *)instance->hostdata[0], 0, 8192);
+    cache_push(virt_to_phys((void *)(instance->hostdata[0])), 8192);
+    cache_clear(virt_to_phys((void *)(instance->hostdata[0])), 8192);
+    kernel_set_cachemode(instance->hostdata[0], 8192, KERNELMAP_NOCACHE_SER);
 
     /* FIXME : if we ever support an ISA NCR53c7xx based board, we
        need to check if the chip is running in a 16 bit mode, and if so 
        unregister it if it is past the 16M (0x1000000) mark */
 
-    hostdata = (struct NCR53c7x0_hostdata *) 
-    	instance->hostdata;
+    hostdata = (struct NCR53c7x0_hostdata *)instance->hostdata[0];
     hostdata->size = size;
     hostdata->script_count = script_len / sizeof(u32);
-    hostdata = (struct NCR53c7x0_hostdata *) instance->hostdata;
     hostdata->board = board;
     hostdata->chip = chip;
 
@@ -1309,10 +1290,12 @@
 	    t = (void *)((u32)t + 255);
 	t = (void *)(((u32)t & ~0xff) + CmdPageStart);
         hostdata->free = t;
+#if 0
 	printk ("scsi: Registered size increased by 256 to %d\n", size);
 	printk ("scsi: CmdPageStart = 0x%02x\n", CmdPageStart);
 	printk ("scsi: tmp = 0x%08x, hostdata->free set to 0x%08x\n",
 			(u32)tmp, (u32)t);
+#endif
     }
 #else
     hostdata->free = ROUNDUP(tmp, void *);
@@ -1367,7 +1350,7 @@
 NCR53c7x0_init_fixup (struct Scsi_Host *host) {
     NCR53c7x0_local_declare();
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     unsigned char tmp;
     int i, ncr_to_memory, memory_to_ncr;
     u32 base;
@@ -1574,9 +1557,6 @@
 
     printk("scsi%d : NCR code relocated to 0x%lx (virt 0x%p)\n", host->host_no,
 	virt_to_bus(hostdata->script), hostdata->script);
-
-    if (!MACH_IS_MVME16x && !MACH_IS_BVME6000)
-	cache_push(virt_to_bus(hostdata->script), flushsize);
 }
 
 /*
@@ -1598,7 +1578,7 @@
 NCR53c7xx_run_tests (struct Scsi_Host *host) {
     NCR53c7x0_local_declare();
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     unsigned long timeout;
     u32 start;
     int failed, i;
@@ -1630,8 +1610,6 @@
 	start = virt_to_bus (hostdata->script) + hostdata->E_test_1;
     	hostdata->state = STATE_RUNNING;
 	printk ("scsi%d : test 1", host->host_no);
-	if (!MACH_IS_MVME16x && !MACH_IS_BVME6000)
-	    cache_push(virt_to_bus(hostdata->script), flushsize);
 	NCR53c7x0_write32 (DSP_REG, start);
 	if (hostdata->options & OPTION_DEBUG_TRACE)
 	    NCR53c7x0_write8 (DCNTL_REG, hostdata->saved_dcntl | DCNTL_SSM |
@@ -1725,8 +1703,6 @@
 	    hostdata->test_completed = -1;
 	    start = virt_to_bus(hostdata->script) + hostdata->E_test_2;
 	    hostdata->state = STATE_RUNNING;
-	    if(!MACH_IS_MVME16x && !MACH_IS_BVME6000)
-		cache_clear(virt_to_bus(hostdata->script), flushsize);
 	    NCR53c7x0_write32 (DSA_REG, virt_to_bus(dsa));
 	    NCR53c7x0_write32 (DSP_REG, start);
 	    if (hostdata->options & OPTION_DEBUG_TRACE)
@@ -1785,7 +1761,7 @@
     Scsi_Cmnd *c = cmd->cmd;
     struct Scsi_Host *host = c->host;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-    	host->hostdata;
+    	host->hostdata[0];
     int i;
 
     memcpy (cmd->dsa, hostdata->script + (hostdata->E_dsa_code_template / 4),
@@ -1832,11 +1808,6 @@
 
     patch_abs_32 (cmd->dsa, Ent_dsa_code_template / sizeof(u32),
 	dsa_temp_addr_dsa_value, virt_to_bus(&cmd->dsa_addr));
-
-    if (!MACH_IS_MVME16x && !MACH_IS_BVME6000) {
-	cache_push(virt_to_bus(hostdata->script), flushsize);
-    	cache_push(virt_to_bus(cmd->dsa), flushsize);
-    }
 }
 
 /* 
@@ -1888,7 +1859,7 @@
     Scsi_Cmnd *c = cmd->cmd;
     struct Scsi_Host *host = c->host;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-    	host->hostdata;
+    	host->hostdata[0];
     unsigned long flags;
     int left, found;
     volatile struct NCR53c7x0_cmd * linux_search;
@@ -2008,7 +1979,7 @@
 #endif
     u32 *dsp;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;		
+	host->hostdata[0];		
     unsigned long flags;
     NCR53c7x0_local_setup(host);
 
@@ -2088,7 +2059,7 @@
     int now_connected) {
     NCR53c7x0_local_declare();
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *) 
-	host->hostdata;
+	host->hostdata[0];
     u32 *script;
     NCR53c7x0_local_setup(host);
 
@@ -2163,7 +2134,7 @@
 asynchronous (struct Scsi_Host *host, int target) {
     NCR53c7x0_local_declare();
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     NCR53c7x0_local_setup(host);
     set_synchronous (host, target, /* no offset */ 0, hostdata->saved_scntl3,
 	1);
@@ -2222,7 +2193,7 @@
 static void 
 synchronous (struct Scsi_Host *host, int target, char *msg) {
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     int desire, divisor, i, limit;
     unsigned char scntl3, sxfer;
 /* The diagnostic message fits on one line, even with max. width integers */
@@ -2284,7 +2255,7 @@
     int print;
     Scsi_Cmnd *c = cmd ? cmd->cmd : NULL;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;		
+	host->hostdata[0];		
     u32 dsps,*dsp;	/* Argument of the INT instruction */
 
     NCR53c7x0_local_setup(host);
@@ -2297,7 +2268,7 @@
     /* RGH 200597:  Need to disable for BVME6000, as it gets Check Conditions
      * and then dies.  Seems to handle Check Condition at startup, but
      * not mid kernel build. */
-    if (dsps == A_int_norm_emulateintfly && c && c->result == 2)
+    if (dsps == A_int_norm_emulateintfly && cmd && cmd->result == 2)
         dsps = A_int_err_check_condition;
 #endif
 
@@ -2476,12 +2447,23 @@
 
     	patch_dsa_32 (cmd->dsa, dsa_cmdout, 0, 6);
 
-	c->cmnd[0] = REQUEST_SENSE;
-	c->cmnd[1] &= 0xe0;	/* Zero all but LUN */
-	c->cmnd[2] = 0;
-	c->cmnd[3] = 0;
-	c->cmnd[4] = sizeof(c->sense_buffer);
-	c->cmnd[5] = 0; 
+        /*
+         * The CDB is now mirrored in our local non-cached
+         * structure, but keep the old structure up to date as well,
+         * just in case anyone looks at it.
+         */
+
+	/*
+	 * XXX Need to worry about data buffer alignment/cache state
+	 * XXX here, but currently never get A_int_err_check_condition,
+	 * XXX so ignore problem for now.
+         */
+	cmd->cmnd[0] = c->cmnd[0] = REQUEST_SENSE;
+	cmd->cmnd[0] = c->cmnd[1] &= 0xe0;	/* Zero all but LUN */
+	cmd->cmnd[0] = c->cmnd[2] = 0;
+	cmd->cmnd[0] = c->cmnd[3] = 0;
+	cmd->cmnd[0] = c->cmnd[4] = sizeof(c->sense_buffer);
+	cmd->cmnd[0] = c->cmnd[5] = 0; 
 
 	/*
 	 * Disable dataout phase, and program datain to transfer to the 
@@ -2509,7 +2491,7 @@
 	 * status, etc are used.
     	 */
 
-	cmd->cmd->result = 0xffff;		
+	cmd->result = cmd->cmd->result = 0xffff;		
 
 	/* 
 	 * Restart command as a REQUEST SENSE.
@@ -2905,9 +2887,6 @@
 	    host->host_no, (unsigned) dsps);
 	return SPECIFIC_INT_PANIC;
     }
-
-    if (!MACH_IS_MVME16x && !MACH_IS_BVME6000)
-	flush_cache_all();
 }
 
 /* 
@@ -2946,7 +2925,7 @@
     NCR53c7x0_local_declare();
     unsigned long flags;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     NCR53c7x0_local_setup(host);
 
     save_flags(flags);
@@ -3063,7 +3042,7 @@
  *
  * Side effects : If we haven't yet scheduled allocation of NCR53c7x0_cmd
  *	structures for this device, do so.  Attempt to complete all scheduled
- *	allocations using kmalloc(), putting NCR53c7x0_cmd structures on
+ *	allocations using get_free_page(), putting NCR53c7x0_cmd structures on
  *	the free list.  Teach programmers not to drink and hack.
  *
  * Inputs : cmd - SCSI command
@@ -3072,12 +3051,22 @@
  *	NULL on failure.
  */
 
+static void
+my_free_page (void *addr, int dummy)
+{
+    /* XXX This assumes default cache mode to be KERNELMAP_FULL_CACHING, which
+     * XXX may be invalid (CONFIG_060_WRITETHROUGH)
+     */
+    kernel_set_cachemode((u32)addr, 4096, KERNELMAP_FULL_CACHING);
+    free_page ((u32)addr);
+}
+
 static struct NCR53c7x0_cmd *
 allocate_cmd (Scsi_Cmnd *cmd) {
     struct Scsi_Host *host = cmd->host;
     struct NCR53c7x0_hostdata *hostdata = 
-	(struct NCR53c7x0_hostdata *) host->hostdata;
-    void *real;			/* Real address */
+	(struct NCR53c7x0_hostdata *) host->hostdata[0];
+    u32 real;			/* Real address */
     int size;			/* Size of *tmp */
     struct NCR53c7x0_cmd *tmp;
     unsigned long flags;
@@ -3115,28 +3104,31 @@
 	size += 256;
 #endif
 /* FIXME: for ISA bus '7xx chips, we need to or GFP_DMA in here */
-	real = kmalloc (size, GFP_ATOMIC);
-	if (!real) {
-	    if (hostdata->options & OPTION_DEBUG_ALLOCATION)
-		printk ("scsi%d : kmalloc(%d) failed\n",
-		    host->host_no, size);
-	    break;
-	}
+
+        if (size > 4096)
+            panic ("53c7xx: allocate_cmd size > 4K");
+        real = get_free_page(GFP_ATOMIC);
+        if (real == 0)
+            panic ("53c7xx: Couldn't get memory for allocate_cmd");
+        memset((void *)real, 0, 4096);
+        cache_push(virt_to_phys((void *)real), 4096);
+        cache_clear(virt_to_phys((void *)real), 4096);
+        kernel_set_cachemode(real, 4096, KERNELMAP_NOCACHE_SER);
 	tmp = ROUNDUP(real, void *);
 #ifdef FORCE_DSA_ALIGNMENT
 	{
 	    if (((u32)tmp & 0xff) > CmdPageStart)
 		tmp = (struct NCR53c7x0_cmd *)((u32)tmp + 255);
 	    tmp = (struct NCR53c7x0_cmd *)(((u32)tmp & ~0xff) + CmdPageStart);
-#ifdef DEBUG
+#if 0
 	    printk ("scsi: size = %d, real = 0x%08x, tmp set to 0x%08x\n",
-			size, (u32)real, (u32)tmp);
+			size, real, (u32)tmp);
 #endif
 	}
 #endif
-	tmp->real = real;
+	tmp->real = (void *)real;
 	tmp->size = size;			
-	tmp->free = ((void (*)(void *, int)) kfree);
+	tmp->free = ((void (*)(void *, int)) my_free_page);
 	save_flags (flags);
 	cli();
 	tmp->next = hostdata->free;
@@ -3174,7 +3166,7 @@
     NCR53c7x0_local_declare();
     struct Scsi_Host *host = cmd->host;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-        host->hostdata;	
+        host->hostdata[0];	
     struct NCR53c7x0_cmd *tmp; 	/* NCR53c7x0_cmd structure for this command */
     int datain,  		/* Number of instructions per phase */
 	dataout;
@@ -3193,6 +3185,14 @@
     if (!(tmp = allocate_cmd (cmd)))
 	return NULL;
 
+    /*
+     * Copy CDB and initialised result fields from Scsi_Cmnd to NCR53c7x0_cmd.
+     * We do this because NCR53c7x0_cmd may have a special cache mode
+     * selected to cope with lack of bus snooping, etc.
+     */
+
+    memcpy(tmp->cmnd, cmd->cmnd, 12);
+    tmp->result = cmd->result;
 
     /*
      * Decide whether we need to generate commands for DATA IN,
@@ -3207,6 +3207,8 @@
     case READ_10:
     case READ_CAPACITY:
     case REQUEST_SENSE:
+    case READ_BLOCK_LIMITS:
+    case READ_TOC:
 	datain = 2 * (cmd->use_sg ? cmd->use_sg : 1) + 3;
     	dataout = 0;
 	break;
@@ -3234,13 +3236,17 @@
      * interrupt if a data phase is attempted on them.
      */
     case TEST_UNIT_READY:
+    case ALLOW_MEDIUM_REMOVAL:
     	datain = dataout = 0;
 	break;
     /*
      * We don't know about these commands, so generate code to handle
-     * both DATA IN and DATA OUT phases.
+     * both DATA IN and DATA OUT phases.  More efficient to identify them
+     * and add them to the above cases.
      */
     default:
+	printk("scsi%d : datain+dataout for command ", host->host_no);
+	print_command(cmd->cmnd);
 	datain = dataout = 2 * (cmd->use_sg ? cmd->use_sg : 1) + 3;
     }
 
@@ -3322,6 +3328,10 @@
     	hostdata->dsa_fixup(tmp);
 
     patch_dsa_32(tmp->dsa, dsa_next, 0, 0);
+    /*
+     * XXX is this giving 53c710 access to the Scsi_Cmnd in some way?
+     * Do we need to change it for caching reasons?
+     */
     patch_dsa_32(tmp->dsa, dsa_cmnd, 0, virt_to_bus(cmd));
 
     if (hostdata->options & OPTION_DEBUG_SYNCHRONOUS) {
@@ -3383,7 +3393,7 @@
 	IDENTIFY (1, cmd->lun) : IDENTIFY (0, cmd->lun);
     patch_dsa_32(tmp->dsa, dsa_msgout, 1, virt_to_bus(tmp->select));
     patch_dsa_32(tmp->dsa, dsa_cmdout, 0, cmd->cmd_len);
-    patch_dsa_32(tmp->dsa, dsa_cmdout, 1, virt_to_bus(cmd->cmnd));
+    patch_dsa_32(tmp->dsa, dsa_cmdout, 1, virt_to_bus(tmp->cmnd));
     patch_dsa_32(tmp->dsa, dsa_dataout, 0, cmd_dataout ? 
     	    virt_to_bus (cmd_dataout)
 	: virt_to_bus (hostdata->script) + hostdata->E_other_transfer);
@@ -3401,13 +3411,13 @@
  *	structure, and assign them to cmd->result when we're done.
  */
 #ifdef BIG_ENDIAN
-    patch_dsa_32(tmp->dsa, dsa_msgin, 1, virt_to_bus(&cmd->result) + 2);
+    patch_dsa_32(tmp->dsa, dsa_msgin, 1, virt_to_bus(&tmp->result) + 2);
     patch_dsa_32(tmp->dsa, dsa_status, 0, 1);
-    patch_dsa_32(tmp->dsa, dsa_status, 1, virt_to_bus(&cmd->result) + 3);
+    patch_dsa_32(tmp->dsa, dsa_status, 1, virt_to_bus(&tmp->result) + 3);
 #else
-    patch_dsa_32(tmp->dsa, dsa_msgin, 1, virt_to_bus(&cmd->result) + 1);
+    patch_dsa_32(tmp->dsa, dsa_msgin, 1, virt_to_bus(&tmp->result) + 1);
     patch_dsa_32(tmp->dsa, dsa_status, 0, 1);
-    patch_dsa_32(tmp->dsa, dsa_status, 1, virt_to_bus(&cmd->result));
+    patch_dsa_32(tmp->dsa, dsa_status, 1, virt_to_bus(&tmp->result));
 #endif
     patch_dsa_32(tmp->dsa, dsa_msgout_other, 0, 1);
     patch_dsa_32(tmp->dsa, dsa_msgout_other, 1, 
@@ -3451,16 +3461,58 @@
  * Not bad, not good. We'll see.
  */
 
+    tmp->bounce.len = 0;	/* Assume aligned buffer */
+
     for (i = 0; cmd->use_sg ? (i < cmd->use_sg) : !i; cmd_datain += 4, 
 	cmd_dataout += 4, ++i) {
-	u32 buf = cmd->use_sg ? 
-	    virt_to_bus(((struct scatterlist *)cmd->buffer)[i].address) :
-	    virt_to_bus(cmd->request_buffer);
+	u32 vbuf = cmd->use_sg ? 
+	    (u32)(((struct scatterlist *)cmd->buffer)[i].address) :
+	    (u32)(cmd->request_buffer);
+	u32 bbuf = virt_to_bus((void *)vbuf);
 	u32 count = cmd->use_sg ?
 	    ((struct scatterlist *)cmd->buffer)[i].length :
 	    cmd->request_bufflen;
 
+	/*
+	 * If we have buffers which are not aligned with 16 byte cache
+	 * lines, then we just hope nothing accesses the other parts of
+	 * those cache lines while the transfer is in progress.  That would
+	 * fill the cache, and subsequent reads of the dma data would pick
+	 * up the wrong thing.
+	 * XXX We need a bounce buffer to handle that correctly.
+	 */
+
+	if (((bbuf & 15) || (count & 15)) && (datain || dataout))
+	{
+	    /* Bounce buffer needed */
+	    if (cmd->use_sg)
+		printk ("53c7xx: Non-aligned buffer with use_sg\n");
+	    else if (datain && dataout)
+                printk ("53c7xx: Non-aligned buffer with datain && dataout\n");
+            else if (count > 256)
+		printk ("53c7xx: Non-aligned transfer > 256 bytes\n");
+	    else
+	    {
+		    if (datain)
+		    {
+			tmp->bounce.len = count;
+			tmp->bounce.addr = vbuf;
+			bbuf = virt_to_bus(tmp->bounce.buf);
+			tmp->bounce.buf[0] = 0xff;
+			tmp->bounce.buf[1] = 0xfe;
+			tmp->bounce.buf[2] = 0xfd;
+			tmp->bounce.buf[3] = 0xfc;
+	    	    }
+	    	    if (dataout)
+	    	    {
+			memcpy ((void *)tmp->bounce.buf, (void *)vbuf, count);
+			bbuf = virt_to_bus(tmp->bounce.buf);
+		    }
+	    }
+	}
+
 	if (datain) {
+            cache_clear(virt_to_phys((void *)vbuf), count);
 	    /* CALL other_in, WHEN NOT DATA_IN */  
 	    cmd_datain[0] = ((DCMD_TYPE_TCI | DCMD_TCI_OP_CALL | 
 		DCMD_TCI_IO) << 24) | 
@@ -3470,13 +3522,14 @@
 	    /* MOVE count, buf, WHEN DATA_IN */
 	    cmd_datain[2] = ((DCMD_TYPE_BMI | DCMD_BMI_OP_MOVE_I | DCMD_BMI_IO) 
     	    	<< 24) | count;
-	    cmd_datain[3] = buf;
+	    cmd_datain[3] = bbuf;
 #if 0
 	    print_insn (host, cmd_datain, "dynamic ", 1);
 	    print_insn (host, cmd_datain + 2, "dynamic ", 1);
 #endif
 	}
 	if (dataout) {
+            cache_push(virt_to_phys((void *)vbuf), count);
 	    /* CALL other_out, WHEN NOT DATA_OUT */
 	    cmd_dataout[0] = ((DCMD_TYPE_TCI | DCMD_TCI_OP_CALL) << 24) | 
 		DBC_TCI_WAIT_FOR_VALID | DBC_TCI_COMPARE_PHASE;
@@ -3485,7 +3538,7 @@
 	    /* MOVE count, buf, WHEN DATA+OUT */
 	    cmd_dataout[2] = ((DCMD_TYPE_BMI | DCMD_BMI_OP_MOVE_I) << 24) 
 		| count;
-	    cmd_dataout[3] = buf;
+	    cmd_dataout[3] = bbuf;
 #if 0
 	    print_insn (host, cmd_dataout, "dynamic ", 1);
 	    print_insn (host, cmd_dataout + 2, "dynamic ", 1);
@@ -3555,7 +3608,7 @@
 NCR53c7xx_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) {
     struct Scsi_Host *host = cmd->host;
     struct NCR53c7x0_hostdata *hostdata = 
-	(struct NCR53c7x0_hostdata *) host->hostdata;
+	(struct NCR53c7x0_hostdata *) host->hostdata[0];
     unsigned long flags;
     Scsi_Cmnd *tmp;
 
@@ -3733,9 +3786,6 @@
      * soon as it is idle.
      */
 
-    if (!MACH_IS_MVME16x && !MACH_IS_BVME6000)
-	flush_cache_all();
-
     if (hostdata->idle) {
 	hostdata->idle = 0;
 	hostdata->state = STATE_RUNNING;
@@ -3809,7 +3859,7 @@
 	done = 1;
 	for (host = first_host; host && host->hostt == the_template;
 	    host = host->next) {
-	    hostdata = (struct NCR53c7x0_hostdata *) host->hostdata;
+	    hostdata = (struct NCR53c7x0_hostdata *) host->hostdata[0];
 	    cli();
 	    if (hostdata->issue_queue) {
 	    	if (hostdata->state == STATE_DISABLED) {
@@ -3881,7 +3931,7 @@
 intr_scsi (struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd) {
     NCR53c7x0_local_declare();
     struct NCR53c7x0_hostdata *hostdata = 
-    	(struct NCR53c7x0_hostdata *) host->hostdata;
+    	(struct NCR53c7x0_hostdata *) host->hostdata[0];
     unsigned char sstat0_sist0, sist1, 		/* Registers */
 	    fatal; 				/* Did a fatal interrupt 
 						   occur ? */
@@ -4072,7 +4122,7 @@
 	struct Scsi_Host *host = first_host;
 
 	while (cnt < 4096) {
-		printk ("%08x (+%6x): ", insn_log[i], (insn_log[i] - (u32)&(((struct NCR53c7x0_hostdata *)host->hostdata)->script))/4);
+		printk ("%08x (+%6x): ", insn_log[i], (insn_log[i] - (u32)&(((struct NCR53c7x0_hostdata *)host->hostdata[0])->script))/4);
 		if (++i == 4096)
 			i = 0;
 		cnt++;
@@ -4110,7 +4160,7 @@
     NCR53c7x0_local_declare();
     struct Scsi_Host *host;			/* Host we are looking at */
     unsigned char istat; 			/* Values of interrupt regs */
-    struct NCR53c7x0_hostdata *hostdata;	/* host->hostdata */
+    struct NCR53c7x0_hostdata *hostdata;	/* host->hostdata[0] */
     struct NCR53c7x0_cmd *cmd,			/* command which halted */
 	**cmd_prev_ptr;
     u32 *dsa;					/* DSA */
@@ -4145,7 +4195,7 @@
 							) {
     	    NCR53c7x0_local_setup(host);
 
-	    hostdata = (struct NCR53c7x0_hostdata *) host->hostdata;
+	    hostdata = (struct NCR53c7x0_hostdata *) host->hostdata[0];
 	    hostdata->dsp_changed = 0;
 	    interrupted = 0;
 	    have_intfly = 0;
@@ -4207,6 +4257,11 @@
 				host->host_no);
 				continue;
 			}
+                        /* Copy the result over now; may not be complete,
+			 * but subsequent tests may as well be done on
+                         * cached memory.
+                         */
+                        tmp->result = cmd->result;
 #if 0
 			printk ("scsi%d : looking at result of 0x%x\n",
 			    host->host_no, cmd->cmd->result);
@@ -4218,6 +4273,10 @@
 
 			search_found = 1;
 
+			if (cmd->bounce.len)
+			    memcpy ((void *)cmd->bounce.addr,
+				(void *)cmd->bounce.buf, cmd->bounce.len);
+
 			/* Important - remove from list _before_ done is called */
 			if (cmd_prev_ptr)
 			    *cmd_prev_ptr = (struct NCR53c7x0_cmd *) cmd->next;
@@ -4348,8 +4407,6 @@
 #endif
 		
 		hostdata->state = STATE_RUNNING;
-		if (!MACH_IS_MVME16x && !MACH_IS_BVME6000)
-		    flush_cache_all();
 		NCR53c7x0_write32 (DSP_REG, virt_to_bus(hostdata->dsp));
 		if (hostdata->options & OPTION_DEBUG_TRACE) {
 #ifdef CYCLIC_TRACE
@@ -4387,7 +4444,7 @@
     NCR53c7x0_local_declare();
 #endif
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
 /* FIXME : this probably should change for production kernels; at the 
    least, counter should move to a per-host structure. */
     static int counter = 5;
@@ -4564,7 +4621,7 @@
     u32 dbc_dcmd, *dsp, *dsp_next;
     unsigned char dcmd, sbcl;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-    	host->hostdata;
+    	host->hostdata[0];
     int residual;
     enum {ACTION_ABORT, ACTION_ABORT_PRINT, ACTION_CONTINUE} action = 
 	ACTION_ABORT_PRINT;
@@ -4758,9 +4815,6 @@
 	print_insn (host, hostdata->dsp, "", 1);
     }
 #endif
-
-    if (!MACH_IS_MVME16x && !MACH_IS_BVME6000)
-	cache_push(virt_to_bus(hostdata->script), flushsize);
 }
 
 /*
@@ -4834,7 +4888,7 @@
      */
 
     if (retry == NEVER) {
-    	printk(KERN_ALERT "          mail ricahrd@sleepie.demon.co.uk\n");
+    	printk(KERN_ALERT "          mail richard@sleepie.demon.co.uk\n");
     	FATAL (host);
     }
 }
@@ -4854,7 +4908,7 @@
 intr_dma (struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd) {
     NCR53c7x0_local_declare();
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     unsigned char dstat;	/* DSTAT */	
     u32 *dsp,
 	*next_dsp,		/* Current dsp */
@@ -5113,7 +5167,7 @@
 	/* Remove virtual addresses to reduce output, as they are the same */
 	sprintf(buf, "%s0x%x (+%x) : 0x%08x 0x%08x", 
 	    (prefix ? prefix : ""), (u32)insn, ((u32)insn -
-		(u32)&(((struct NCR53c7x0_hostdata *)host->hostdata)->script))/4, 
+		(u32)&(((struct NCR53c7x0_hostdata *)host->hostdata[0])->script))/4, 
 	    insn[0], insn[1]);
 #endif
 	tmp = buf + strlen(buf);
@@ -5160,7 +5214,7 @@
     NCR53c7x0_local_declare();
     struct Scsi_Host *host = cmd->host;
     struct NCR53c7x0_hostdata *hostdata = host ? (struct NCR53c7x0_hostdata *) 
-	host->hostdata : NULL;
+	host->hostdata[0] : NULL;
     unsigned long flags;
     struct NCR53c7x0_cmd *curr, **prev;
     Scsi_Cmnd *me, **last;
@@ -5251,7 +5305,8 @@
          &(curr->next), curr = (struct NCR53c7x0_cmd *) curr->next);
 
     if (curr) {
-	if ((cmd->result & 0xff) != 0xff && (cmd->result & 0xff00) != 0xff00) {
+	if ((curr->result & 0xff) != 0xff && (curr->result & 0xff00) != 0xff00) {
+            cmd->result = curr->result;
 	    if (prev)
 		*prev = (struct NCR53c7x0_cmd *) curr->next;
 	    curr->next = (struct NCR53c7x0_cmd *) hostdata->free;
@@ -5282,13 +5337,14 @@
 	cmd->host_scribble = NULL;
     }
 
-    if (((cmd->result & 0xff00) == 0xff00) ||
-	((cmd->result & 0xff) == 0xff)) {
+    if (curr == NULL || ((curr->result & 0xff00) == 0xff00) ||
+		((curr->result & 0xff) == 0xff)) {
 	printk ("scsi%d : did this command ever run?\n", host->host_no);
-	cmd->result = DID_ABORT << 16;
+	    cmd->result = DID_ABORT << 16;
     } else {
 	printk ("scsi%d : probably lost INTFLY, normal completion\n", 
 	    host->host_no);
+        cmd->result = curr->result;
 /* 
  * FIXME : We need to add an additional flag which indicates if a 
  * command was ever counted as BUSY, so if we end up here we can
@@ -5341,7 +5397,7 @@
     Scsi_Cmnd *nuke_list = NULL;
     struct Scsi_Host *host = cmd->host;
     struct NCR53c7x0_hostdata *hostdata = 
-    	(struct NCR53c7x0_hostdata *) host->hostdata;
+    	(struct NCR53c7x0_hostdata *) host->hostdata[0];
 
     NCR53c7x0_local_setup(host);
     save_flags(flags);
@@ -5410,7 +5466,7 @@
 static int 
 insn_to_offset (Scsi_Cmnd *cmd, u32 *insn) {
     struct NCR53c7x0_hostdata *hostdata = 
-	(struct NCR53c7x0_hostdata *) cmd->host->hostdata;
+	(struct NCR53c7x0_hostdata *) cmd->host->hostdata[0];
     struct NCR53c7x0_cmd *ncmd = 
 	(struct NCR53c7x0_cmd *) cmd->host_scribble;
     int offset = 0, buffers;
@@ -5479,6 +5535,16 @@
     char *where;
     u32 *ptr;
     NCR53c7x0_local_setup (cmd->host);
+
+    if (check_address ((unsigned long) ncmd,sizeof (struct NCR53c7x0_cmd)) == 0)
+    {
+	printk("\nNCR53c7x0_cmd fields:\n");
+	printk("  bounce.len=0x%x, addr=0x%0x, buf[]=0x%02x %02x %02x %02x\n",
+	    ncmd->bounce.len, ncmd->bounce.addr, ncmd->bounce.buf[0],
+	    ncmd->bounce.buf[1], ncmd->bounce.buf[2], ncmd->bounce.buf[3]);
+	printk("  result=%04x, cdb[0]=0x%02x\n", ncmd->result, ncmd->cmnd[0]);
+    }
+
     for (i = 0; i < 2; ++i) {
 	if (check_address ((unsigned long) ncmd, 
 	    sizeof (struct NCR53c7x0_cmd)) == -1) 
@@ -5516,7 +5582,7 @@
 static void 
 print_dsa (struct Scsi_Host *host, u32 *dsa, const char *prefix) {
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     int i, len;
     char *ptr;
     Scsi_Cmnd *cmd;
@@ -5558,6 +5624,7 @@
     cmd = (Scsi_Cmnd *) bus_to_virt(dsa[hostdata->dsa_cmnd / sizeof(u32)]);
     printk("        + %d : dsa_cmnd = 0x%x ", hostdata->dsa_cmnd,
 	   (u32) virt_to_bus(cmd));
+    /* XXX Maybe we should access cmd->host_scribble->result here. RGH */
     if (cmd) {
 	printk("               result = 0x%x, target = %d, lun = %d, cmd = ",
 	    cmd->result, cmd->target, cmd->lun);
@@ -5590,7 +5657,7 @@
 static void 
 print_queues (struct Scsi_Host *host) {
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     u32 *dsa, *next_dsa;
     volatile u32 *ncrcurrent;
     int left;
@@ -5673,7 +5740,7 @@
 print_lots (struct Scsi_Host *host) {
     NCR53c7x0_local_declare();
     struct NCR53c7x0_hostdata *hostdata = 
-	(struct NCR53c7x0_hostdata *) host->hostdata;
+	(struct NCR53c7x0_hostdata *) host->hostdata[0];
     u32 *dsp_next, *dsp, *dsa, dbc_dcmd;
     unsigned char dcmd, sbcl;
     int i, size;
@@ -5695,7 +5762,7 @@
 	        "         DSPS=0x%x, TEMP=0x%x (virt 0x%p), DMODE=0x%x\n"
 		"         SXFER=0x%x, SCNTL3=0x%x\n"
 		"         %s%s%sphase=%s, %d bytes in SCSI FIFO\n"
-		"         STEST0=0x%x\n",
+		"         SCRATCH=0x%x, saved2_dsa=0x%0lx\n",
 	    host->host_no, dbc_dcmd, NCR53c7x0_read32(DNAD_REG),
 		bus_to_virt(NCR53c7x0_read32(DNAD_REG)),
 	    virt_to_bus(dsa), dsa,
@@ -5712,8 +5779,9 @@
 	    	SSTAT1_REG : SSTAT2_REG)),
 	    (NCR53c7x0_read8 ((hostdata->chip / 100) == 8 ? 
 		SSTAT1_REG : SSTAT2_REG) & SSTAT2_FF_MASK) >> SSTAT2_FF_SHIFT,
-	    ((hostdata->chip / 100) == 8) ?
-		NCR53c7x0_read8 (STEST0_REG_800) : 0);
+	    ((hostdata->chip / 100) == 8) ? NCR53c7x0_read8 (STEST0_REG_800) :
+		NCR53c7x0_read32(SCRATCHA_REG_800),
+	    hostdata->saved2_dsa);
 	printk ("scsi%d : DSP 0x%lx (virt 0x%p) ->\n", host->host_no, 
 	    virt_to_bus(dsp), dsp);
     	for (i = 6; i > 0; --i, dsp += size)
@@ -5748,7 +5816,7 @@
     NCR53c7x0_local_declare();
     unsigned long flags;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     NCR53c7x0_local_setup(host);
     save_flags (flags);
     cli();
@@ -5789,7 +5857,7 @@
 static void 
 hard_reset (struct Scsi_Host *host) {
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     unsigned long flags;
     save_flags (flags);
     cli();
@@ -5824,7 +5892,7 @@
 static Scsi_Cmnd *
 return_outstanding_commands (struct Scsi_Host *host, int free, int issue) {
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     struct NCR53c7x0_cmd *c;
     int i;
     u32 *ncrcurrent;
@@ -5890,7 +5958,7 @@
 static int 
 disable (struct Scsi_Host *host) {
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     unsigned long flags;
     Scsi_Cmnd *nuke_list, *tmp;
     save_flags(flags);
@@ -5929,7 +5997,7 @@
     unsigned long flags;
     unsigned char istat, tmp;
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     int stage;
     NCR53c7x0_local_setup(host);
 
@@ -6007,7 +6075,7 @@
 static void
 dump_events (struct Scsi_Host *host, int count) {
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
-	host->hostdata;
+	host->hostdata[0];
     struct NCR53c7x0_event event;
     int i;
     unsigned long flags;
@@ -6071,7 +6139,7 @@
 int 
 NCR53c7x0_release(struct Scsi_Host *host) {
     struct NCR53c7x0_hostdata *hostdata = 
-	(struct NCR53c7x0_hostdata *) host->hostdata;
+	(struct NCR53c7x0_hostdata *) host->hostdata[0];
     struct NCR53c7x0_cmd *cmd, *tmp;
     shutdown (host);
     if (host->irq != IRQ_NONE)
@@ -6105,6 +6173,12 @@
 	    host->host_no, hostdata->num_cmds);
     if (hostdata->events) 
 	vfree ((void *)hostdata->events);
+
+    /* XXX This assumes default cache mode to be KERNELMAP_FULL_CACHING, which
+     * XXX may be invalid (CONFIG_060_WRITETHROUGH)
+     */
+    kernel_set_cachemode((u32)hostdata, 8192, KERNELMAP_FULL_CACHING);
+    free_pages ((u32)hostdata, 1);
     return 1;
 }
 Scsi_Host_Template driver_template = NCR53c7xx;
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/scsi/53c7xx.h linuxvme-2.1.108/drivers/scsi/53c7xx.h
--- linux68k-2.1.108+Geert/drivers/scsi/53c7xx.h	Wed Jul 15 21:13:02 1998
+++ linuxvme-2.1.108/drivers/scsi/53c7xx.h	Tue Jul 14 09:12:03 1998
@@ -1125,6 +1125,15 @@
 
     int flags;				/* CMD_* flags */
 
+    unsigned char      cmnd[12];	/* CDB, copied from Scsi_Cmnd */
+    int                result;		/* Copy to Scsi_Cmnd when done */
+
+    struct {				/* Private non-cached bounce buffer */
+        unsigned char buf[256];
+	u32	      addr;
+        u32           len;
+    } bounce;
+
 /*
  * SDTR and WIDE messages are an either/or affair
  * in this message, since we will go into message out and send
@@ -1547,7 +1556,7 @@
     NCR53c7x0_address_memory = (void *) (host)->base;			\
     NCR53c7x0_address_io = (unsigned int) (host)->io_port;		\
     NCR53c7x0_memory_mapped = ((struct NCR53c7x0_hostdata *) 		\
-	host->hostdata)-> options & OPTION_MEMORY_MAPPED 
+	host->hostdata[0])-> options & OPTION_MEMORY_MAPPED 
 
 #ifdef BIG_ENDIAN
 /* These could be more efficient, given that we are always memory mapped,
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/scsi/amiga7xx.h linuxvme-2.1.108/drivers/scsi/amiga7xx.h
--- linux68k-2.1.108+Geert/drivers/scsi/amiga7xx.h	Wed Jan  7 17:09:45 1998
+++ linuxvme-2.1.108/drivers/scsi/amiga7xx.h	Mon Jul 13 21:45:30 1998
@@ -35,7 +35,7 @@
 		       bios_param:          scsicam_bios_param,   \
 		       can_queue:           24,       \
 		       this_id:             7,               \
-		       sg_tablesize:        127,          \
+		       sg_tablesize:        63,          \
 		       cmd_per_lun:	    3,     \
 		       use_clustering:      DISABLE_CLUSTERING }
 #endif
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/scsi/bvme6000.h linuxvme-2.1.108/drivers/scsi/bvme6000.h
--- linux68k-2.1.108+Geert/drivers/scsi/bvme6000.h	Wed Jul 15 21:13:11 1998
+++ linuxvme-2.1.108/drivers/scsi/bvme6000.h	Mon Jul 13 21:45:30 1998
@@ -36,7 +36,7 @@
 		       bios_param:          scsicam_bios_param,   \
 		       can_queue:           24,       \
 		       this_id:             7,               \
-		       sg_tablesize:        127,          \
+		       sg_tablesize:        63,          \
 		       cmd_per_lun:	    3,     \
 		       use_clustering:      DISABLE_CLUSTERING }
 #endif
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/scsi/mvme16x.c linuxvme-2.1.108/drivers/scsi/mvme16x.c
--- linux68k-2.1.108+Geert/drivers/scsi/mvme16x.c	Wed Jul 15 21:13:15 1998
+++ linuxvme-2.1.108/drivers/scsi/mvme16x.c	Mon Jul 13 20:41:53 1998
@@ -53,7 +53,7 @@
     clock = 66000000;	/* 66MHz SCSI Clock */
 
     ncr53c7xx_init(tpnt, 0, 710, (u32)0xfff47000,
-			0, 0x55, DMA_NONE,
+			0, MVME16x_IRQ_SCSI, DMA_NONE,
 			options, clock);
     called = 1;
     return 1;
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/drivers/scsi/mvme16x.h linuxvme-2.1.108/drivers/scsi/mvme16x.h
--- linux68k-2.1.108+Geert/drivers/scsi/mvme16x.h	Wed Jul 15 21:13:15 1998
+++ linuxvme-2.1.108/drivers/scsi/mvme16x.h	Mon Jul 13 21:45:30 1998
@@ -36,7 +36,7 @@
 		       bios_param:          scsicam_bios_param,   \
 		       can_queue:           24,       \
 		       this_id:             7,               \
-		       sg_tablesize:        127,          \
+		       sg_tablesize:        63,          \
 		       cmd_per_lun:	    3,     \
 		       use_clustering:      DISABLE_CLUSTERING }
 #endif
diff -ur -X dodiffs-exclude --new-file linux68k-2.1.108+Geert/fs/partitions/Config.in linuxvme-2.1.108/fs/partitions/Config.in
--- linux68k-2.1.108+Geert/fs/partitions/Config.in	Wed Jul 15 21:16:21 1998
+++ linuxvme-2.1.108/fs/partitions/Config.in	Tue Jul 14 08:48:14 1998
@@ -20,6 +20,9 @@
   if [ "$CONFIG_MAC" = "y" ]; then
     define_bool CONFIG_MAC_PARTITION y
   fi
+  if [ "$CONFIG_VME" = "y" ]; then
+    define_bool CONFIG_MSDOS_PARTITION y
+  fi
 fi
 if [ "$ARCH" = "sparc" -o "$ARCH" = "sparc64" ]; then
   define_bool CONFIG_SUN_PARTITION y
