home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / kernel-s / v1.2 / patch-1.007 / patch-1.2.6
Text File  |  1995-04-23  |  104KB  |  3,497 lines

  1. diff -u --recursive --new-file v1.2.5/linux/CREDITS linux/CREDITS
  2. --- v1.2.5/linux/CREDITS    Wed Mar 29 06:52:56 1995
  3. +++ linux/CREDITS    Sun Apr 16 08:12:01 1995
  4. @@ -683,6 +683,10 @@
  5.  D: CDROM driver "sonycd535" (Sony CDU-535/531)
  6.  S: 
  7.  
  8. +N: Frederic Potter 
  9. +E: Frederic.Potter@masi.ibp.fr 
  10. +D: Some PCI kernel support
  11. +
  12.  N: Stefan Probst
  13.  E: snprobst@immd4.informatik.uni-erlangen.de
  14.  D: The Linux Support Team Erlangen
  15. diff -u --recursive --new-file v1.2.5/linux/Makefile linux/Makefile
  16. --- v1.2.5/linux/Makefile    Fri Apr 14 12:02:41 1995
  17. +++ linux/Makefile    Fri Apr 14 12:05:10 1995
  18. @@ -1,6 +1,6 @@
  19.  VERSION = 1
  20.  PATCHLEVEL = 2
  21. -SUBLEVEL = 5
  22. +SUBLEVEL = 6
  23.  
  24.  ARCH = i386
  25.  
  26. diff -u --recursive --new-file v1.2.5/linux/arch/i386/config.in linux/arch/i386/config.in
  27. --- v1.2.5/linux/arch/i386/config.in    Wed Feb 15 10:50:55 1995
  28. +++ linux/arch/i386/config.in    Mon Apr 17 13:47:56 1995
  29. @@ -74,6 +74,10 @@
  30.  bool 'Scsi CDROM support' CONFIG_BLK_DEV_SR n
  31.  bool 'Scsi generic support' CONFIG_CHR_DEV_SG n
  32.  
  33. +comment 'Some SCSI devices (e.g. CD jukebox) support multiple LUNs'
  34. +
  35. +bool 'Probe all LUNs on each SCSI device' CONFIG_SCSI_MULTI_LUN n
  36. +
  37.  comment 'SCSI low-level drivers'
  38.  
  39.  bool 'Adaptec AHA152X support' CONFIG_SCSI_AHA152X n
  40. diff -u --recursive --new-file v1.2.5/linux/drivers/char/ChangeLog linux/drivers/char/ChangeLog
  41. --- v1.2.5/linux/drivers/char/ChangeLog    Fri Apr 14 12:02:41 1995
  42. +++ linux/drivers/char/ChangeLog    Fri Apr 14 12:01:41 1995
  43. @@ -4,7 +4,7 @@
  44.          rs_init):  Hangups are now scheduled via a separate tqueue
  45.          structure in the async_struct structure, tqueue_hangup.
  46.          This task is pushed on to the tq_schedule queue, so that
  47. -        it is processed syncronously by the scheduler.
  48. +        it is processed synchronously by the scheduler.
  49.  
  50.  Sat Feb 18 12:13:51 1995  Theodore Y. Ts'o  (tytso@rt-11)
  51.  
  52. diff -u --recursive --new-file v1.2.5/linux/drivers/char/serial.c linux/drivers/char/serial.c
  53. --- v1.2.5/linux/drivers/char/serial.c    Fri Apr 14 12:02:41 1995
  54. +++ linux/drivers/char/serial.c    Fri Apr 14 12:01:40 1995
  55. @@ -733,7 +733,7 @@
  56.  
  57.  /*
  58.   * This routine is called from the scheduler tqueue when the interrupt
  59. - * routine has signalled that a hangup has occured.  The path of
  60. + * routine has signalled that a hangup has occurred.  The path of
  61.   * hangup processing is:
  62.   *
  63.   *     serial interrupt routine -> (scheduler tqueue) ->
  64. diff -u --recursive --new-file v1.2.5/linux/drivers/net/lance.c linux/drivers/net/lance.c
  65. --- v1.2.5/linux/drivers/net/lance.c    Fri Apr 14 12:02:41 1995
  66. +++ linux/drivers/net/lance.c    Fri Apr 14 12:01:40 1995
  67. @@ -15,7 +15,7 @@
  68.         Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771
  69.  */
  70.  
  71. -static char *version = "lance.c:v1.07 1/18/95 becker@cesdis.gsfc.nasa.gov\n";
  72. +static char *version = "lance.c:v1.08 4/10/95 dplatt@3do.com\n";
  73.  
  74.  #include <linux/config.h>
  75.  #include <linux/kernel.h>
  76. @@ -203,12 +203,18 @@
  77.      int dirty_rx, dirty_tx;        /* The ring entries to be free()ed. */
  78.      int dma;
  79.      struct enet_statistics stats;
  80. -    char chip_version;            /* See lance_chip_type. */
  81. +    unsigned char chip_version;            /* See lance_chip_type. */
  82.      char tx_full;
  83.      char lock;
  84.      int pad0, pad1;                /* Used for 8-byte alignment */
  85.  };
  86.  
  87. +#define LANCE_MUST_PAD          0x00000001
  88. +#define LANCE_ENABLE_AUTOSELECT 0x00000002
  89. +#define LANCE_MUST_REINIT_RING  0x00000004
  90. +#define LANCE_MUST_UNRESET      0x00000008
  91. +#define LANCE_HAS_MISSED_FRAME  0x00000010
  92. +
  93.  /* A mapping from the chip ID number to the part number and features.
  94.     These are from the datasheets -- in real life the '970 version
  95.     reportedly has the same ID as the '965. */
  96. @@ -217,14 +223,25 @@
  97.      char *name;
  98.      int flags;
  99.  } chip_table[] = {
  100. -    {0x0000, "LANCE 7990", 0},            /* Ancient lance chip.  */
  101. -    {0x0003, "PCnet/ISA 79C960", 0},    /* 79C960 PCnet/ISA.  */
  102. -    {0x2260, "PCnet/ISA+ 79C961", 0},    /* 79C961 PCnet/ISA+, Plug-n-Play.  */
  103. -    {0x2420, "PCnet/PCI 79C970", 0},    /* 79C970 or 79C974 PCnet-SCSI, PCI. */
  104. +    {0x0000, "LANCE 7990",                /* Ancient lance chip.  */
  105. +        LANCE_MUST_PAD + LANCE_MUST_UNRESET},
  106. +    {0x0003, "PCnet/ISA 79C960",        /* 79C960 PCnet/ISA.  */
  107. +        LANCE_ENABLE_AUTOSELECT + LANCE_MUST_REINIT_RING +
  108. +            LANCE_HAS_MISSED_FRAME},
  109. +    {0x2260, "PCnet/ISA+ 79C961",        /* 79C961 PCnet/ISA+, Plug-n-Play.  */
  110. +        LANCE_ENABLE_AUTOSELECT + LANCE_MUST_REINIT_RING +
  111. +            LANCE_HAS_MISSED_FRAME},
  112. +    {0x2420, "PCnet/PCI 79C970",        /* 79C970 or 79C974 PCnet-SCSI, PCI. */
  113. +        LANCE_ENABLE_AUTOSELECT + LANCE_MUST_REINIT_RING +
  114. +            LANCE_HAS_MISSED_FRAME},
  115.      /* Bug: the PCnet/PCI actually uses the PCnet/VLB ID number, so just call
  116.          it the PCnet32. */
  117. -    {0x2430, "PCnet32", 0},                /* 79C965 PCnet for VL bus. */
  118. -    {0x0,      "PCnet (unknown)", 0},
  119. +    {0x2430, "PCnet32",                    /* 79C965 PCnet for VL bus. */
  120. +        LANCE_ENABLE_AUTOSELECT + LANCE_MUST_REINIT_RING +
  121. +            LANCE_HAS_MISSED_FRAME},
  122. +    {0x0,      "PCnet (unknown)",
  123. +        LANCE_ENABLE_AUTOSELECT + LANCE_MUST_REINIT_RING +
  124. +            LANCE_HAS_MISSED_FRAME},
  125.  };
  126.  
  127.  enum {OLD_LANCE = 0, PCNET_ISA=1, PCNET_ISAP=2, PCNET_PCI=3, PCNET_VLB=4, LANCE_UNKNOWN=5};
  128. @@ -256,8 +273,6 @@
  129.      int *port;
  130.  
  131.  #if defined(CONFIG_PCI)
  132. -#define AMD_VENDOR_ID 0x1022
  133. -#define AMD_DEVICE_ID 0x2000
  134.      if (pcibios_present()) {
  135.          int pci_index;
  136.          printk("lance.c: PCI bios is present, checking for devices...\n");
  137. @@ -266,7 +281,8 @@
  138.              unsigned long pci_ioaddr;
  139.              unsigned short pci_command;
  140.  
  141. -            if (pcibios_find_device (AMD_VENDOR_ID, AMD_DEVICE_ID, pci_index,
  142. +            if (pcibios_find_device (PCI_VENDOR_ID_AMD,
  143. +                                     PCI_DEVICE_ID_AMD_LANCE, pci_index,
  144.                                       &pci_bus, &pci_device_fn) != 0)
  145.                  break;
  146.              pcibios_read_config_byte(pci_bus, pci_device_fn,
  147. @@ -522,7 +538,7 @@
  148.          }
  149.      }
  150.  
  151. -    if (lp->chip_version !=  OLD_LANCE) {
  152. +    if (chip_table[lp->chip_version].flags & LANCE_ENABLE_AUTOSELECT) {
  153.          /* Turn on auto-select of media (10baseT or BNC) so that the user
  154.             can watch the LEDs even if the board isn't opened. */
  155.          outw(0x0002, ioaddr+LANCE_ADDR);
  156. @@ -570,10 +586,10 @@
  157.      }
  158.  
  159.      /* Un-Reset the LANCE, needed only for the NE2100. */
  160. -    if (lp->chip_version == OLD_LANCE)
  161. +    if (chip_table[lp->chip_version].flags & LANCE_MUST_UNRESET)
  162.          outw(0, ioaddr+LANCE_RESET);
  163.  
  164. -    if (lp->chip_version != OLD_LANCE) {
  165. +    if (chip_table[lp->chip_version].flags & LANCE_ENABLE_AUTOSELECT) {
  166.          /* This is 79C960-specific: Turn on auto-select of media (AUI, BNC). */
  167.          outw(0x0002, ioaddr+LANCE_ADDR);
  168.          outw(0x0002, ioaddr+LANCE_BUS_IF);
  169. @@ -617,6 +633,33 @@
  170.      return 0;                    /* Always succeed */
  171.  }
  172.  
  173. +/* The LANCE has been halted for one reason or another (busmaster memory
  174. +   arbitration error, Tx FIFO underflow, driver stopped it to reconfigure,
  175. +   etc.).  Modern LANCE variants always reload their ring-buffer
  176. +   configuration when restarted, so we must reinitialize our ring
  177. +   context before restarting.  As part of this reinitialization,
  178. +   find all packets still on the Tx ring and pretend that they had been
  179. +   sent (in effect, drop the packets on the floor) - the higher-level
  180. +   protocols will time out and retransmit.  It'd be better to shuffle
  181. +   these skbs to a temp list and then actually re-Tx them after
  182. +   restarting the chip, but I'm too lazy to do so right now.  dplatt@3do.com
  183. +*/
  184. +
  185. +static void 
  186. +lance_purge_tx_ring(struct device *dev)
  187. +{
  188. +    struct lance_private *lp = (struct lance_private *)dev->priv;
  189. +    int i;
  190. +
  191. +    for (i = 0; i < TX_RING_SIZE; i++) {
  192. +        if (lp->tx_skbuff[i]) {
  193. +            dev_kfree_skb(lp->tx_skbuff[i],FREE_WRITE);
  194. +            lp->tx_skbuff[i] = NULL;
  195. +        }
  196. +    }
  197. +}
  198. +
  199. +
  200.  /* Initialize the LANCE Rx and Tx rings. */
  201.  static void
  202.  lance_init_ring(struct device *dev)
  203. @@ -647,12 +690,27 @@
  204.      lp->init_block.tx_ring = (int)lp->tx_ring | TX_RING_LEN_BITS;
  205.  }
  206.  
  207. +static void
  208. +lance_restart(struct device *dev, unsigned int csr0_bits, int must_reinit)
  209. +{
  210. +    struct lance_private *lp = (struct lance_private *)dev->priv;
  211. +
  212. +    if (must_reinit ||
  213. +        (chip_table[lp->chip_version].flags & LANCE_MUST_REINIT_RING)) {
  214. +        lance_purge_tx_ring(dev);
  215. +        lance_init_ring(dev);
  216. +    }
  217. +    outw(0x0000,    dev->base_addr + LANCE_ADDR);
  218. +    outw(csr0_bits, dev->base_addr + LANCE_DATA);
  219. +}
  220. +
  221.  static int
  222.  lance_start_xmit(struct sk_buff *skb, struct device *dev)
  223.  {
  224.      struct lance_private *lp = (struct lance_private *)dev->priv;
  225.      int ioaddr = dev->base_addr;
  226.      int entry;
  227. +    unsigned long flags;
  228.  
  229.      /* Transmitter timeout, serious problems. */
  230.      if (dev->tbusy) {
  231. @@ -681,8 +739,7 @@
  232.              printk("\n");
  233.          }
  234.  #endif
  235. -        lance_init_ring(dev);
  236. -        outw(0x0043, ioaddr+LANCE_DATA);
  237. +        lance_restart(dev, 0x0043, 1);
  238.  
  239.          dev->tbusy=0;
  240.          dev->trans_start = jiffies;
  241. @@ -728,7 +785,7 @@
  242.         with the "ownership" bits last. */
  243.  
  244.      /* The old LANCE chips doesn't automatically pad buffers to min. size. */
  245. -    if (lp->chip_version == OLD_LANCE) {
  246. +    if (chip_table[lp->chip_version].flags & LANCE_MUST_PAD) {
  247.          lp->tx_ring[entry].length =
  248.              -(ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN);
  249.      } else
  250. @@ -758,13 +815,14 @@
  251.  
  252.      dev->trans_start = jiffies;
  253.  
  254. +    save_flags(flags);
  255.      cli();
  256.      lp->lock = 0;
  257.      if (lp->tx_ring[(entry+1) & TX_RING_MOD_MASK].base == 0)
  258.          dev->tbusy=0;
  259.      else
  260.          lp->tx_full = 1;
  261. -    sti();
  262. +    restore_flags(flags);
  263.  
  264.      return 0;
  265.  }
  266. @@ -776,6 +834,7 @@
  267.      struct device *dev = (struct device *)(irq2dev_map[irq]);
  268.      struct lance_private *lp;
  269.      int csr0, ioaddr, boguscnt=10;
  270. +    int must_restart;
  271.  
  272.      if (dev == NULL) {
  273.          printk ("lance_interrupt(): irq %d for unknown device.\n", irq);
  274. @@ -795,6 +854,8 @@
  275.          /* Acknowledge all of the current interrupt sources ASAP. */
  276.          outw(csr0 & ~0x004f, dev->base_addr + LANCE_DATA);
  277.  
  278. +        must_restart = 0;
  279. +
  280.          if (lance_debug > 5)
  281.              printk("%s: interrupt  csr0=%#2.2x new csr=%#2.2x.\n",
  282.                     dev->name, csr0, inw(dev->base_addr + LANCE_DATA));
  283. @@ -828,7 +889,7 @@
  284.                          printk("%s: Tx FIFO error! Status %4.4x.\n",
  285.                                 dev->name, csr0);
  286.                          /* Restart the chip. */
  287. -                        outw(0x0002, dev->base_addr + LANCE_DATA);
  288. +                        must_restart = 1;
  289.                      }
  290.                  } else {
  291.                      if (status & 0x18000000)
  292. @@ -871,7 +932,14 @@
  293.              printk("%s: Bus master arbitration failure, status %4.4x.\n",
  294.                     dev->name, csr0);
  295.              /* Restart the chip. */
  296. -            outw(0x0002, dev->base_addr + LANCE_DATA);
  297. +            must_restart = 1;
  298. +        }
  299. +
  300. +        if (must_restart) {
  301. +            /* stop the chip to clear the error condition, then restart */
  302. +            outw(0x0000, dev->base_addr + LANCE_ADDR);
  303. +            outw(0x0004, dev->base_addr + LANCE_DATA);
  304. +            lance_restart(dev, 0x0002, 0);
  305.          }
  306.      }
  307.  
  308. @@ -961,7 +1029,7 @@
  309.      dev->start = 0;
  310.      dev->tbusy = 1;
  311.  
  312. -    if (lp->chip_version != OLD_LANCE) {
  313. +    if (chip_table[lp->chip_version].flags & LANCE_HAS_MISSED_FRAME) {
  314.          outw(112, ioaddr+LANCE_ADDR);
  315.          lp->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA);
  316.      }
  317. @@ -991,14 +1059,16 @@
  318.      struct lance_private *lp = (struct lance_private *)dev->priv;
  319.      short ioaddr = dev->base_addr;
  320.      short saved_addr;
  321. +    unsigned long flags;
  322.  
  323. -    if (lp->chip_version != OLD_LANCE) {
  324. +    if (chip_table[lp->chip_version].flags & LANCE_HAS_MISSED_FRAME) {
  325. +        save_flags(flags);
  326.          cli();
  327.          saved_addr = inw(ioaddr+LANCE_ADDR);
  328.          outw(112, ioaddr+LANCE_ADDR);
  329.          lp->stats.rx_missed_errors = inw(ioaddr+LANCE_DATA);
  330.          outw(saved_addr, ioaddr+LANCE_ADDR);
  331. -        sti();
  332. +        restore_flags(flags);
  333.      }
  334.  
  335.      return &lp->stats;
  336. @@ -1015,11 +1085,9 @@
  337.  {
  338.      short ioaddr = dev->base_addr;
  339.  
  340. -    /* We take the simple way out and always enable promiscuous mode. */
  341.      outw(0, ioaddr+LANCE_ADDR);
  342.      outw(0x0004, ioaddr+LANCE_DATA); /* Temporarily stop the lance.     */
  343.  
  344. -    outw(15, ioaddr+LANCE_ADDR);
  345.      if (num_addrs >= 0) {
  346.          short multicast_table[4];
  347.          int i;
  348. @@ -1029,15 +1097,17 @@
  349.              outw(8 + i, ioaddr+LANCE_ADDR);
  350.              outw(multicast_table[i], ioaddr+LANCE_DATA);
  351.          }
  352. +        outw(15, ioaddr+LANCE_ADDR);
  353.          outw(0x0000, ioaddr+LANCE_DATA); /* Unset promiscuous mode */
  354.      } else {
  355.          /* Log any net taps. */
  356.          printk("%s: Promiscuous mode enabled.\n", dev->name);
  357. +        outw(15, ioaddr+LANCE_ADDR);
  358.          outw(0x8000, ioaddr+LANCE_DATA); /* Set promiscuous mode */
  359.      }
  360.  
  361. -    outw(0, ioaddr+LANCE_ADDR);
  362. -    outw(0x0142, ioaddr+LANCE_DATA); /* Resume normal operation. */
  363. +    lance_restart(dev, 0x0142, 0); /*  Resume normal operation */
  364. +
  365.  }
  366.  
  367.  
  368. diff -u --recursive --new-file v1.2.5/linux/drivers/net/ne.c linux/drivers/net/ne.c
  369. --- v1.2.5/linux/drivers/net/ne.c    Fri Apr 14 12:02:41 1995
  370. +++ linux/drivers/net/ne.c    Thu Apr 20 11:24:55 1995
  371. @@ -376,7 +376,6 @@
  372.  {
  373.      int retries = 0;
  374.      int nic_base = NE_BASE;
  375. -    unsigned long flags;
  376.  
  377.      /* Round the count up for word writes.  Do we need to do this?
  378.         What effect will an odd byte count have on the 8390?
  379. @@ -412,19 +411,7 @@
  380.      SLOW_DOWN_IO;
  381.  #endif  /* rw_bugfix */
  382.  
  383. -   /*
  384. -        Now the normal output. I believe that if we don't lock this, a
  385. -    race condition will munge the remote byte count values, and then
  386. -    the ne2k will hang the machine by holding I/O CH RDY because it
  387. -    expects more data. Hopefully fixes the lockups. -- Paul Gortmaker.
  388. -
  389. -    Use save_flags/cli/restore_flags rather than cli/sti to avoid risk
  390. -    of accidentally enabling interrupts which were disabled when we
  391. -    were entered.   Dave Platt <dplatt@3do.com>
  392. -    */
  393. -
  394. -    save_flags(flags);
  395. -    cli();
  396. +   /* Now the normal output. */
  397.      outb_p(count & 0xff, nic_base + EN0_RCNTLO);
  398.      outb_p(count >> 8,   nic_base + EN0_RCNTHI);
  399.      outb_p(0x00, nic_base + EN0_RSARLO);
  400. @@ -436,7 +423,6 @@
  401.      } else {
  402.      outsb(NE_BASE + NE_DATAPORT, buf, count);
  403.      }
  404. -    restore_flags(flags);
  405.  
  406.  #ifdef CONFIG_NE_SANITY
  407.      /* This was for the ALPHA version only, but enough people have
  408. diff -u --recursive --new-file v1.2.5/linux/drivers/net/plip.c linux/drivers/net/plip.c
  409. --- v1.2.5/linux/drivers/net/plip.c    Mon Feb 20 08:59:52 1995
  410. +++ linux/drivers/net/plip.c    Mon Apr 17 13:47:56 1995
  411. @@ -98,6 +98,7 @@
  412.  #include <linux/ioport.h>
  413.  #include <asm/bitops.h>
  414.  #include <asm/irq.h>
  415. +#include <asm/byteorder.h>
  416.  
  417.  /* Use 0 for production, 1 for verification, >2 for debug */
  418.  #ifndef NET_DEBUG
  419. @@ -165,26 +166,14 @@
  420.      enum plip_nibble_state nibble;
  421.      union {
  422.          struct {
  423. -#if defined(__i386__)
  424. +#if defined(LITTLE_ENDIAN)
  425.              unsigned char lsb;
  426.              unsigned char msb;
  427. -#elif defined(__mc68000__)
  428. +#elif defined(BIG_ENDIAN)
  429.              unsigned char msb;
  430.              unsigned char lsb;
  431. -#elif defined(__sparc__)
  432. -            unsigned char msb;
  433. -            unsigned char lsb;
  434. -#elif defined(__MIPSEL__)
  435. -            unsigned char lsb;
  436. -            unsigned char msb;
  437. -#elif defined(__MIPSEB__)
  438. -            unsigned char msb;
  439. -            unsigned char lsb;
  440. -#elif defined(__alpha__)
  441. -            unsigned char lsb;
  442. -            unsigned char msb;
  443.  #else
  444. -#error    "Adjust this structure to match your CPU"
  445. +#error    "Please fix the endianness defines in <asm/byteorder.h>"
  446.  #endif                        
  447.          } b;
  448.          unsigned short h;
  449. diff -u --recursive --new-file v1.2.5/linux/drivers/scsi/53c7,8xx.c linux/drivers/scsi/53c7,8xx.c
  450. --- v1.2.5/linux/drivers/scsi/53c7,8xx.c    Sun Feb 19 11:22:43 1995
  451. +++ linux/drivers/scsi/53c7,8xx.c    Mon Apr 17 13:47:57 1995
  452. @@ -5,8 +5,8 @@
  453.   *      weed out brain damaged main boards.
  454.   */
  455.  
  456. -#define PERM_OPTIONS (OPTION_IO_MAPPED|OPTION_DEBUG_TEST1)
  457.  
  458. +#define PERM_OPTIONS (OPTION_IO_MAPPED|OPTION_DEBUG_TEST1)
  459.  /*
  460.   * Define SCSI_MALLOC to use scsi_malloc instead of kmalloc.  Other than
  461.   * preventing deadlock, I'm not sure why we'd want to do this.
  462. @@ -20,7 +20,7 @@
  463.   *    Hannover, Germany
  464.   *    hm@ix.de
  465.   *
  466. - * Copyright 1993, 1994 Drew Eckhardt
  467. + * Copyright 1993, 1994, 1995 Drew Eckhardt
  468.   *      Visionary Computing 
  469.   *      (Unix and Linux consulting and custom programming)
  470.   *      drew@Colorado.EDU
  471. @@ -28,8 +28,6 @@
  472.   *
  473.   * TolerANT and SCSI SCRIPTS are registered trademarks of NCR Corporation.
  474.   * 
  475. - * PRE-ALPHA
  476. - *
  477.   * For more information, please consult 
  478.   *
  479.   *
  480. @@ -156,6 +154,11 @@
  481.   *
  482.   */
  483.  
  484. +#ifdef MODULE
  485. +#include <linux/module.h>
  486. +#endif
  487. +
  488. +#include <asm/dma.h>
  489.  #include <asm/io.h>
  490.  #include <asm/system.h>
  491.  #include <linux/delay.h>
  492. @@ -176,7 +179,9 @@
  493.  static void abnormal_finished (struct NCR53c7x0_cmd *cmd, int result);
  494.  static int NCR53c8xx_run_tests (struct Scsi_Host *host);
  495.  static int NCR53c8xx_script_len;
  496. +static int NCR53c8xx_dsa_len;
  497.  static void NCR53c7x0_intr(int irq, struct pt_regs * regs);
  498. +static int halt (struct Scsi_Host *host);
  499.  static void intr_phase_mismatch (struct Scsi_Host *host, struct NCR53c7x0_cmd 
  500.      *cmd);
  501.  static void intr_dma (struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd);
  502. @@ -190,40 +195,11 @@
  503.      NCR53c7x0_cmd *cmd);
  504.  static void NCR53c8x0_soft_reset (struct Scsi_Host *host);
  505.  
  506. +static int perm_options = PERM_OPTIONS;
  507. +
  508.  static struct Scsi_Host *first_host = NULL;    /* Head of list of NCR boards */
  509.  static Scsi_Host_Template *the_template = NULL;    
  510.  
  511. -/* Allocate storage space for constant messages, etc. */
  512. -
  513. -static long NCR53c7xx_zero = 0;            
  514. -static long NCR53c7xx_sink;
  515. -static char NCR53c7xx_msg_reject = MESSAGE_REJECT;
  516. -static char NCR53c7xx_msg_abort = ABORT;
  517. -static char NCR53c7xx_msg_nop = NOP;
  518. -
  519. -/* Buffer for commands run before *malloc() works */
  520. -/* 
  521. - * XXX - if need be, replace this with normal wait.
  522. - */
  523. -static int scan_scsis_buf_busy = 0;
  524. -static char scan_scsis_buf[512];
  525. -
  526. -
  527. -/*
  528. - * Spl-levels are evil. We shouldn't emulate braindamage.
  529. - *        Linus
  530. - */
  531. -static int splx (int new_level)
  532. -{
  533. -    register int old_level, tmp;
  534. -    save_flags(tmp);
  535. -    old_level = (tmp & 0x200) ? 7 : 0;
  536. -    if (new_level)
  537. -    sti();
  538. -    else 
  539. -    cli();
  540. -    return old_level;
  541. -}
  542.  
  543.  /*
  544.   * TODO : 
  545. @@ -285,8 +261,7 @@
  546.   *
  547.   * For the very similar chips, we should probably hack the fixup code
  548.   * and interrupt code so that it works everywhere, but I suspect the 
  549. - * NCR53c700 is going
  550. - * to need it's own fixup routine.
  551. + * NCR53c700 is going to need it's own fixup routine.
  552.   */
  553.  
  554.  /*
  555. @@ -420,7 +395,8 @@
  556.   *     field of the hostdata structure MUST have been set.
  557.   */
  558.  
  559. -static int NCR53c7x0_init (struct Scsi_Host *host) {
  560. +static int 
  561. +NCR53c7x0_init (struct Scsi_Host *host) {
  562.      NCR53c7x0_local_declare();
  563.      /* unsigned char tmp; */
  564.      int i, j, ccf;
  565. @@ -450,13 +426,19 @@
  566.      return -1;
  567.      }
  568.  
  569. +    /* Assign constants accessed by NCR */
  570. +    hostdata->NCR53c7xx_zero = 0;            
  571. +    hostdata->NCR53c7xx_msg_reject = MESSAGE_REJECT;
  572. +    hostdata->NCR53c7xx_msg_abort = ABORT;
  573. +    hostdata->NCR53c7xx_msg_nop = NOP;
  574. +
  575.      /*
  576.       * Set up an interrupt handler if we aren't already sharing an IRQ
  577.       * with another board.
  578.       */
  579.  
  580. -    for (search = first_host; search && (search->hostt == the_template) &&
  581. -    (search->irq != host->irq); search=search->next);
  582. +    for (search = first_host; search && ((search->hostt != the_template) ||
  583. +    (search->irq != host->irq)); search=search->next);
  584.  
  585.      if (!search) {
  586.      if (request_irq(host->irq, NCR53c7x0_intr, SA_INTERRUPT, "53c7,8xx")) {
  587. @@ -479,6 +461,10 @@
  588.      hostdata->istat = ((hostdata->chip / 100) == 8) ? 
  589.          ISTAT_REG_800 : ISTAT_REG_700;
  590.  
  591. +/* Only the ISTAT register is readable when the NCR is running, so make 
  592. +   sure it's halted. */
  593. +    halt(host);
  594. +
  595.  /* 
  596.   * XXX - the NCR53c700 uses bitfielded registers for SCID, SDID, etc,
  597.   *    as does the 710 with one bit per SCSI ID.  Conversely, the NCR
  598. @@ -523,9 +509,9 @@
  599.      hostdata->saved_dcntl = NCR53c7x0_read8(DCNTL_REG);
  600.      
  601.      if ((hostdata->chip / 100) == 8)
  602. -    printk ("scsi%d : using %s interrupts.\n", host->host_no,
  603. -        (hostdata->saved_dcntl & DCNTL_800_IRQM) ? "level active" : 
  604. -        "edge triggered");
  605. +    printk ("scsi%d : using %s interrupts\n", host->host_no,
  606. +        (hostdata->saved_dcntl & DCNTL_800_IRQM) ? "edge triggered" :
  607. +        "level active");
  608.  
  609.      /*
  610.       * DMODE controls DMA burst length, and on 700 series chips,
  611. @@ -547,8 +533,9 @@
  612.          case DMODE_BL_4: i = 4; break;
  613.          case DMODE_BL_8: i = 8; break;
  614.          case DMODE_BL_16: i = 16; break;
  615. +            default: i = 0;
  616.          }
  617. -        printk ("scsi%d ; burst length %d\n", host->host_no, i);
  618. +        printk ("scsi%d : burst length %d\n", host->host_no, i);
  619.      }
  620.      }
  621.  
  622. @@ -592,6 +579,7 @@
  623.       */
  624.  
  625.      for (i = 0; i < 8; ++i) {
  626. +        hostdata->cmd_allocated[i] = 0;
  627.          for (j = 0; j < 8; ++j)
  628.          hostdata->busy[i][j] = 0;
  629.      /* 
  630. @@ -620,8 +608,8 @@
  631.  
  632.      hostdata->issue_queue = hostdata->running_list = 
  633.          hostdata->finished_queue = NULL;
  634. -    hostdata->issue_dsa_head = 
  635. -    hostdata->issue_dsa_tail = NULL;
  636. +    hostdata->issue_dsa_head = NULL;
  637. +    hostdata->issue_dsa_tail = NULL;
  638.  
  639.      if (hostdata->init_save_regs)
  640.          hostdata->init_save_regs (host);
  641. @@ -688,11 +676,11 @@
  642.      struct Scsi_Host *instance;
  643.      struct NCR53c7x0_hostdata *hostdata;
  644.      char chip_str[80];
  645. -    int script_len = 0, size = 0;
  646. +    int script_len = 0, dsa_len = 0, size = 0, max_cmd_size = 0;
  647.      int ok = 0;
  648.  
  649.      
  650. -    options |= PERM_OPTIONS;
  651. +    options |= perm_options;
  652.  
  653.      switch (chip) {
  654.      case 825:
  655. @@ -700,6 +688,7 @@
  656.      case 815:
  657.      case 810:
  658.      script_len = NCR53c8xx_script_len;
  659. +        dsa_len = NCR53c8xx_dsa_len;
  660.          options |= OPTION_INTFLY;
  661.          sprintf (chip_str, "NCR53c%d", chip);
  662.          break;
  663. @@ -718,7 +707,7 @@
  664.      if ((chip / 100 == 8) && !pci_valid) 
  665.      printk ("scsi-ncr53c7,8xx : for better reliability and performance, please use the\n" 
  666.          "        PCI override instead.\n"
  667. -        "     Syntax : ncr53c8{10,20,25}=pci,<bus>,<device>,<function>\n"
  668. +        "     Syntax : ncr53c8{10,15,20,25}=pci,<bus>,<device>,<function>\n"
  669.          "              <bus> and <device> are usually 0.\n");
  670.  
  671.      if (options & OPTION_DEBUG_PROBE_ONLY) {
  672. @@ -726,9 +715,50 @@
  673.          return -1;
  674.      }
  675.  
  676. -    size = sizeof(struct NCR53c7x0_hostdata) + script_len;
  677. +    max_cmd_size = sizeof(struct NCR53c7x0_cmd) + dsa_len +
  678. +        /* Size of dynamic part of command structure : */
  679. +    2 * /* Worst case : we don't know if we need DATA IN or DATA out */
  680. +        ( 2 * /* Current instructions per scatter/gather segment */ 
  681. +              tpnt->sg_tablesize + 
  682. +                  3 /* Current startup / termination required per phase */
  683. +        ) *
  684. +    8 /* Each instruction is eight bytes */;
  685. +    /* Note that alignment will be guaranteed, since we put the command
  686. +       allocated at probe time after the fixed-up SCSI script, which 
  687. +       consists of 32 bit words, aligned on a 32 bit boundary. */ 
  688. +
  689. +    /* Allocate fixed part of hostdata, dynamic part to hold appropriate
  690. +       SCSI SCRIPT(tm) plus a single, maximum-sized NCR53c7x0_cmd structure.
  691. +
  692. +       We need a NCR53c7x0_cmd structure for scan_scsis() when we are 
  693. +       not loaded as a module, and when we're loaded as a module, we 
  694. +       can't use a non-dynamically allocated structure because modules
  695. +       are vmalloc()'d, which can allow structures to cross page 
  696. +       boundaries and breaks our physical/virtual address assumptions
  697. +       for DMA.
  698. +
  699. +       So, we stick it past the end of our hostdata structure.
  700. +
  701. +       ASSUMPTION : 
  702. +            Irregardless of how many simultaenous SCSI commands we allow,
  703. +         the probe code only executes a _single_ instruction at a time,
  704. +     so we only need one here, and don't need to allocate NCR53c7x0_cmd
  705. +     structures for each target until we are no longer in scan_scsis
  706. +     and kmalloc() has become functional (memory_init() happens 
  707. +     after all device driver initialization).
  708. +    */
  709. +
  710. +    size = sizeof(struct NCR53c7x0_hostdata) + script_len + max_cmd_size;
  711.  
  712.      instance = scsi_register (tpnt, size);
  713. +    if (!instance)
  714. +    return -1;
  715. +
  716. +
  717. +    /* FIXME : if we ever support an ISA NCR53c7xx based board, we
  718. +       need to check if the chip is running in a 16 bit mode, and if so 
  719. +       unregister it if it is past the 16M (0x1000000) mark */
  720. +       
  721.      hostdata = (struct NCR53c7x0_hostdata *) 
  722.          instance->hostdata;
  723.      hostdata->size = size;
  724. @@ -784,7 +814,18 @@
  725.      instance->dma_channel = dma;
  726.  
  727.      hostdata->options = options;
  728. -    
  729. +    hostdata->dsa_size = dsa_len;
  730. +    hostdata->max_cmd_size = max_cmd_size;
  731. +    hostdata->num_cmds = 1;
  732. +    /* Initialize single command */
  733. +    hostdata->free = (struct NCR53c7x0_cmd *) 
  734. +    (hostdata->script + hostdata->script_count);
  735. +    hostdata->free->real = (void *) hostdata->free;
  736. +    hostdata->free->size = max_cmd_size;
  737. +    hostdata->free->free = NULL;
  738. +    hostdata->free->next = NULL;
  739. +
  740. +
  741.      return NCR53c7x0_init(instance);
  742.  }
  743.  
  744. @@ -796,7 +837,7 @@
  745.   * Purpose : initializes a NCR53c800 family based on the PCI
  746.   *    bus, device, and function location of it.  Allows 
  747.   *     reprogramming of latency timer and determining addresses
  748. - *    and weather bus mastering, etc. are OK.
  749. + *    and whether bus mastering, etc. are OK.
  750.   *    
  751.   *    Useful where a new NCR chip is backwards compatible with
  752.   *    a supported chip, but the DEVICE ID has changed so it 
  753. @@ -815,7 +856,8 @@
  754.      unsigned short vendor_id, device_id, command;
  755.      unsigned long base, io_port; 
  756.      unsigned char irq, revision;
  757. -    int error, expected_chip, expected_id, max_revision, min_revision;
  758. +    int error, expected_chip;
  759. +    int expected_id = -1, max_revision = -1, min_revision = -1;
  760.      int i;
  761.  
  762.      printk("scsi-ncr53c7,8xx : at PCI bus %d, device %d,  function %d\n",
  763. @@ -870,6 +912,8 @@
  764.          io_port = 0;
  765.      } else
  766.          io_port &= PCI_BASE_ADDRESS_IO_MASK;
  767. +    } else {
  768. +        io_port = 0;
  769.      }
  770.  
  771.      if (command & PCI_COMMAND_MEMORY) {
  772. @@ -879,6 +923,8 @@
  773.          base = 0;
  774.      } else 
  775.          base &= PCI_BASE_ADDRESS_MEM_MASK;
  776. +    } else {
  777. +        base = 0;
  778.      }
  779.      
  780.      if (!io_port && !base) {
  781. @@ -932,7 +978,6 @@
  782.   */
  783.  
  784.  int NCR53c7xx_detect(Scsi_Host_Template *tpnt) {
  785. -    short current_chip;
  786.      int i;
  787.      int current_override;
  788.      int count;            /* Number of boards detected */
  789. @@ -979,6 +1024,7 @@
  790.  
  791.  #include "53c8xx_d.h"
  792.  static int NCR53c8xx_script_len = sizeof (SCRIPT);
  793. +static int NCR53c8xx_dsa_len = A_dsa_end + Ent_dsa_zero - Ent_dsa_code_template;
  794.  
  795.  /* 
  796.   * Function : static void NCR53c8x0_init_fixup (struct Scsi_Host *host)
  797. @@ -989,7 +1035,8 @@
  798.   *
  799.   */
  800.  
  801. -static void NCR53c8x0_init_fixup (struct Scsi_Host *host) {
  802. +static void 
  803. +NCR53c8x0_init_fixup (struct Scsi_Host *host) {
  804.      NCR53c7x0_local_declare();
  805.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  806.      host->hostdata;
  807. @@ -1008,6 +1055,16 @@
  808.      for (i = 0; i < PATCHES; ++i) 
  809.      hostdata->script[LABELPATCHES[i]] += 
  810.              (unsigned long) hostdata->script;
  811. +    /* Fixup addresses of constants that used to be EXTERNAL */
  812. +    
  813. +    patch_abs_32 (hostdata->script, 0, NCR53c7xx_msg_abort, 
  814. +        (long) &(hostdata->NCR53c7xx_msg_abort));
  815. +    patch_abs_32 (hostdata->script, 0, NCR53c7xx_msg_reject, 
  816. +        (long) &(hostdata->NCR53c7xx_msg_reject));
  817. +    patch_abs_32 (hostdata->script, 0, NCR53c7xx_zero, 
  818. +        (long) &(hostdata->NCR53c7xx_zero));
  819. +    patch_abs_32 (hostdata->script, 0, NCR53c7xx_sink, 
  820. +        (long) &(hostdata->NCR53c7xx_sink));
  821.  
  822.      /* 
  823.       * Fixup absolutes set at boot-time.
  824. @@ -1037,10 +1094,6 @@
  825.          ncr_to_ncr = memory_to_ncr = ncr_to_memory = tmp;
  826.      }
  827.  
  828. -    printk ("scsi%d : m_to_n = 0x%x, n_to_m = 0x%x, n_to_n = 0x%x\n",
  829. -        (int) host->host_no, (int) memory_to_ncr, (int) 
  830. -        ncr_to_memory, ncr_to_ncr);
  831. -
  832.      patch_abs_32 (hostdata->script, 0, addr_scratch, base + SCRATCHA_REG_800);
  833.      patch_abs_32 (hostdata->script, 0, addr_sfbr, base + SFBR_REG);
  834.      patch_abs_32 (hostdata->script, 0, addr_temp, base + TEMP_REG);
  835. @@ -1059,11 +1112,15 @@
  836.      patch_abs_rwri_data (hostdata->script, 0, dmode_ncr_to_memory, ncr_to_memory);
  837.      patch_abs_rwri_data (hostdata->script, 0, dmode_ncr_to_ncr, ncr_to_ncr);
  838.  
  839. -    patch_abs_32 (hostdata->script, 0, issue_dsa_head, (long) &(hostdata->issue_dsa_head));
  840. +    patch_abs_32 (hostdata->script, 0, issue_dsa_head, 
  841. +        (long) &(hostdata->issue_dsa_head));
  842.      patch_abs_32 (hostdata->script, 0, msg_buf, (long) &(hostdata->msg_buf));
  843. -    patch_abs_32 (hostdata->script, 0, reconnect_dsa_head, (long) &(hostdata->reconnect_dsa_head));
  844. -    patch_abs_32 (hostdata->script, 0, reselected_identify, (long) &(hostdata->reselected_identify));
  845. -    patch_abs_32 (hostdata->script, 0, reselected_tag, (long) &(hostdata->reselected_tag));
  846. +    patch_abs_32 (hostdata->script, 0, reconnect_dsa_head, 
  847. +        (long) &(hostdata->reconnect_dsa_head));
  848. +    patch_abs_32 (hostdata->script, 0, reselected_identify, 
  849. +        (long) &(hostdata->reselected_identify));
  850. +    patch_abs_32 (hostdata->script, 0, reselected_tag, 
  851. +        (long) &(hostdata->reselected_tag));
  852.  
  853.      patch_abs_32 (hostdata->script, 0, test_dest, (long) &(hostdata->test_dest));
  854.      patch_abs_32 (hostdata->script, 0, test_src, (long) &(hostdata->test_source));
  855. @@ -1145,17 +1202,18 @@
  856.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  857.      host->hostdata;
  858.      unsigned long timeout, start;
  859. -    int old_level, failed, i;
  860. +    int failed, i;
  861. +    unsigned long flags;
  862. +    
  863.      NCR53c7x0_local_setup(host);
  864.  
  865. -    printk("scsi%d : testing\n", host->host_no);
  866. -
  867.      /* The NCR chip _must_ be idle to run the test scripts */
  868.  
  869. -    old_level = splx(0);
  870. +    save_flags(flags);
  871. +    cli();
  872.      if (!hostdata->idle) {
  873.      printk ("scsi%d : chip not idle, aborting tests\n", host->host_no);
  874. -    splx(old_level);
  875. +    restore_flags(flags);
  876.      return -1;
  877.      }
  878.  
  879. @@ -1181,7 +1239,7 @@
  880.      printk ("scsi%d : test 1", host->host_no);
  881.      NCR53c7x0_write32 (DSP_REG, start);
  882.      printk (" started\n");
  883. -    splx(7);
  884. +    sti();
  885.  
  886.      timeout = jiffies + 50;    /* arbitrary */
  887.      while ((hostdata->test_completed == -1) && jiffies < timeout);
  888. @@ -1217,7 +1275,7 @@
  889.          (unsigned long) hostdata->script, start);
  890.          printk ("scsi%d : DSPS = 0x%lx\n", host->host_no,
  891.          (unsigned long) NCR53c7x0_read32(DSPS_REG));
  892. -        splx(old_level);
  893. +        restore_flags(flags);
  894.          return -1;
  895.      }
  896.          hostdata->test_running = 0;
  897. @@ -1253,10 +1311,10 @@
  898.          dsa[11] = (unsigned long) &msg;
  899.  
  900.      for (i = 0; i < 3; ++i) {
  901. -        splx(0);
  902. +            cli();
  903.          if (!hostdata->idle) {
  904.          printk ("scsi%d : chip not idle, aborting tests\n", host->host_no);
  905. -        splx(old_level);
  906. +        restore_flags(flags);
  907.          return -1;
  908.          }
  909.  
  910. @@ -1269,7 +1327,7 @@
  911.          hostdata->state = STATE_RUNNING;
  912.          NCR53c7x0_write32 (DSA_REG, (unsigned long) dsa);
  913.          NCR53c7x0_write32 (DSP_REG, start);
  914. -        splx(7);
  915. +        sti();
  916.  
  917.          timeout = jiffies + 500;    /* arbitrary */
  918.          while ((hostdata->test_completed == -1) && jiffies < timeout);
  919. @@ -1289,12 +1347,12 @@
  920.              host->host_no, i);
  921.          if (!hostdata->idle) {
  922.              printk("scsi%d : not idle\n", host->host_no);
  923. -            splx(old_level);
  924. +            restore_flags(flags);
  925.              return -1;
  926.          }
  927.          } else if (hostdata->test_completed == -1) {
  928.          printk ("scsi%d : test 2 timed out\n", host->host_no);
  929. -        splx(old_level);
  930. +        restore_flags(flags);
  931.          return -1;
  932.          } 
  933.          hostdata->test_running = 0;
  934. @@ -1305,9 +1363,8 @@
  935.      }
  936.      }
  937.      }
  938. -    printk ("scsi%d : tests complete.\n", host->host_no);
  939.  
  940. -    splx(old_level);
  941. +    restore_flags(flags);
  942.      return 0;
  943.  }
  944.  
  945. @@ -1364,11 +1421,12 @@
  946.      struct Scsi_Host *host = c->host;
  947.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  948.          host->hostdata;
  949. -    int old_level;
  950. +    unsigned long flags;
  951.      char **prev, *search;
  952.      int i;
  953.  
  954. -    old_level = splx(0);
  955. +    save_flags(flags);
  956. +    cli();
  957.      for (i = 0; i < 2; ++i) {
  958.          for (search = (char *) (i ? hostdata->issue_dsa_head : 
  959.                  hostdata->reconnect_dsa_head), prev = (char **) (i ? 
  960. @@ -1390,21 +1448,14 @@
  961.      if (hostdata->running_list == cmd)
  962.          hostdata->running_list = cmd->next;
  963.  
  964. -    if (!scan_scsis_buf_busy) {
  965. -#ifdef SCSI_MALLOC
  966. -    scsi_free ((void *) cmd->real, cmd->size);
  967. -#else
  968. -    kfree_s (cmd->real, cmd->size);
  969. -#endif
  970. -    } else {
  971. -    scan_scsis_buf_busy = 0;
  972. -    }
  973. +    cmd->next = hostdata->free;
  974. +    hostdata->free = cmd;
  975.  
  976.      c->host_scribble = NULL;
  977.      c->result = result;
  978.      c->scsi_done(c);
  979.  
  980. -    splx(old_level);
  981. +    restore_flags(flags);
  982.  }
  983.  
  984.  /* 
  985. @@ -1429,7 +1480,7 @@
  986.      unsigned long *dsp;
  987.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  988.      host->hostdata;        
  989. -    int old_level;
  990. +    unsigned long flags;
  991.      NCR53c7x0_local_setup(host);
  992.  
  993.      /*
  994. @@ -1437,8 +1488,8 @@
  995.       * dump the appropriate debugging information to standard 
  996.       * output.  
  997.       */
  998. -
  999. -    old_level = splx(0);
  1000. +    save_flags(flags);
  1001. +    cli();
  1002.      dsp = (unsigned long *) NCR53c7x0_read32(DSP_REG);
  1003.      for (bp = hostdata->breakpoints; bp && bp->address != dsp; 
  1004.          bp = bp->next);
  1005. @@ -1460,7 +1511,7 @@
  1006.       * instruction in bytes.
  1007.       */
  1008.  
  1009. -    splx(old_level);
  1010. +    restore_flags(flags);
  1011.  }
  1012.  
  1013.  /*
  1014. @@ -1575,7 +1626,7 @@
  1015.      hostdata->sync[target].select_indirect = (scntl3 << 24) | (target << 16) | 
  1016.          (sxfer << 8);
  1017.  
  1018. -    script = hostdata->sync[target].script;
  1019. +    script = (long *) hostdata->sync[target].script;
  1020.  
  1021.      /* XXX - add NCR53c7x0 code to reprogram SCF bits if we want to */
  1022.      if ((hostdata->chip / 100) == 8) {
  1023. @@ -1630,7 +1681,7 @@
  1024.      printk ("scsi%d : message", host->host_no);
  1025.      if (cmd) 
  1026.          printk (" from target %d lun %d", c->target, c->lun);
  1027. -    print_msg (hostdata->msg_buf);
  1028. +    print_msg ((unsigned char *) hostdata->msg_buf);
  1029.      printk("\n");
  1030.      switch (hostdata->msg_buf[0]) {
  1031.      /* 
  1032. @@ -1665,7 +1716,8 @@
  1033.          */
  1034.          if (cmd->flags & CMD_FLAG_SDTR) {
  1035.          cmd->flags &= ~CMD_FLAG_SDTR; 
  1036. -        synchronous (host, c->target, hostdata->msg_buf);
  1037. +        synchronous (host, c->target, (unsigned char *) 
  1038. +            hostdata->msg_buf);
  1039.          hostdata->dsp = hostdata->script + hostdata->E_accept_message /
  1040.              sizeof(long);
  1041.          hostdata->dsp_changed = 1;
  1042. @@ -1673,7 +1725,8 @@
  1043.          } else {
  1044.          if (hostdata->options & OPTION_SYNCHRONOUS)  {
  1045.              cmd->flags |= CMD_FLAG_DID_SDTR;
  1046. -            synchronous (host, c->target, hostdata->msg_buf);
  1047. +            synchronous (host, c->target, (unsigned char *)
  1048. +                hostdata->msg_buf);
  1049.          } else {
  1050.              hostdata->msg_buf[4] = 0;        /* 0 offset = async */
  1051.          }
  1052. @@ -1948,15 +2001,16 @@
  1053.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1054.      instance->hostdata;
  1055.      struct NCR53c7x0_break *bp, **prev;
  1056. -    int old_level;
  1057. -    old_level = splx(0);
  1058. +    unsigned long flags;
  1059. +    save_flags(flags);
  1060. +    cli();
  1061.      for (bp = (struct NCR53c7x0_break *) instance->breakpoints,
  1062.          prev = (struct NCR53c7x0_break **) &instance->breakpoints;
  1063.          bp; prev = (struct NCR53c7x0_break **) &(bp->next),
  1064.          bp = (struct NCR53c7x0_break *) bp->next);
  1065.  
  1066.      if (!bp) {
  1067. -    splx(old_level);
  1068. +    restore_flags(flags);
  1069.      return -EIO;
  1070.      }
  1071.  
  1072. @@ -1969,7 +2023,7 @@
  1073.      if (prev)
  1074.      *prev = bp->next;
  1075.  
  1076. -    splx(old_level);
  1077. +    restore_flags(flags);
  1078.      return 0;
  1079.  }
  1080.  
  1081. @@ -1981,7 +2035,7 @@
  1082.      struct NCR53c7x0_break *bp;
  1083.      char buf[80];
  1084.      size_t len;
  1085. -    int old_level;
  1086. +    unsigned long flags;
  1087.      /* 
  1088.       * XXX - we need to insure that the processor is halted 
  1089.       * here in order to prevent a race condition.  So, if the 
  1090. @@ -1992,7 +2046,8 @@
  1091.      host->host_no);
  1092.      debugger_kernel_write (host, buf, strlen(buf));
  1093.  
  1094. -    old_level=splx(0);
  1095. +    save_flags(flags);
  1096. +    cli();
  1097.      for (bp = (struct NCR53c7x0_break *) host->breakpoints;
  1098.          bp; bp = (struct NCR53c7x0_break *) bp->next); {
  1099.          sprintf (buf, "scsi%d : bp : success : at %08x, replaces %08x %08x",
  1100. @@ -2007,7 +2062,7 @@
  1101.          len = strlen(buf);
  1102.          debugger_kernel_write (host, buf, len);
  1103.      }
  1104. -    splx(old_level);
  1105. +    restore_flags(flags);
  1106.      return 0;
  1107.  }
  1108.  
  1109. @@ -2018,20 +2073,21 @@
  1110.      struct NCR53c7x0_break *bp;
  1111.      char buf[80];
  1112.      size_t len;
  1113. -    int old_level;
  1114. -    old_level=splx(0);
  1115. +    unsigned long flags;
  1116. +    save_flags(flags);
  1117. +    cli();
  1118.  
  1119.      if (hostdata->state != STATE_HALTED) {
  1120.      sprintf (buf, "scsi%d : bs : failure : NCR not halted\n", host->host_no);
  1121.      debugger_kernel_write (host, buf, strlen(buf));
  1122. -    splx(old_level);
  1123. +    restore_flags(flags);
  1124.      return -1;
  1125.      }
  1126.  
  1127.      if (!(bp = kmalloc (sizeof (struct NCR53c7x0_break)))) {
  1128.      printk ("scsi%d : kmalloc(%d) of breakpoint structure failed, try again\n",
  1129.          host->host_no, sizeof(struct NCR53c7x0_break));
  1130. -    splx(old_level);
  1131. +    restore_flags(flags);
  1132.      return -1;
  1133.      }
  1134.  
  1135. @@ -2043,7 +2099,7 @@
  1136.      hostdata->breakpoints = bp->next;
  1137.      memcpy ((void *) bp->address, (void *) hostdata->E_debug_break, 8);
  1138.      
  1139. -    splx(old_level);
  1140. +    restore_flags(flags);
  1141.      return 0;
  1142.  }
  1143.  
  1144. @@ -2132,9 +2188,10 @@
  1145.      buflen) {
  1146.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1147.      host->hostdata;
  1148. -    int copy, left, old_level;
  1149. -    
  1150. -    old_level = splx(0);
  1151. +    int copy, left;
  1152. +    unsigned long flags;
  1153. +    save_flags(flags);
  1154. +    cli();
  1155.      while (buflen) {
  1156.      left = (hostdata->debug_buf + hostdata->debug_size - 1) -
  1157.          hostdata->debug_write;
  1158. @@ -2147,7 +2204,7 @@
  1159.          (hostdata->debug_buf + hostdata->debug_size))
  1160.          hosdata->debug_write = hostdata->debug_buf;
  1161.      }
  1162. -    (void) splx(old_level);
  1163. +    restore_flags(flags);
  1164.  }
  1165.  
  1166.  #endif /* def NCRDEBUG */
  1167. @@ -2164,7 +2221,8 @@
  1168.   * 
  1169.   */
  1170.  
  1171. -static void NCR53c8x0_soft_reset (struct Scsi_Host *host) {
  1172. +static void 
  1173. +NCR53c8x0_soft_reset (struct Scsi_Host *host) {
  1174.      NCR53c7x0_local_declare();
  1175.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1176.      host->hostdata;
  1177. @@ -2187,14 +2245,18 @@
  1178.  
  1179.  
  1180.      /* 
  1181. -     * Respond to selection and reselection by targets and 
  1182. -     * use our _initiator_ SCSI ID for arbitration. 
  1183. +     * Respond to reselection by targets and use our _initiator_ SCSI ID 
  1184. +     * for arbitration. If notyet, also respond to SCSI selection.
  1185.       *
  1186.       * XXX - Note : we must reprogram this when reselecting as 
  1187.       *    a target.
  1188.       */
  1189.  
  1190. +#ifdef notyet
  1191.      NCR53c7x0_write8(SCID_REG, (host->this_id & 7)|SCID_800_RRE|SCID_800_SRE);
  1192. +#else
  1193. +    NCR53c7x0_write8(SCID_REG, (host->this_id & 7)|SCID_800_RRE);
  1194. +#endif
  1195.      NCR53c7x0_write8(RESPID_REG_800, hostdata->this_id_mask);
  1196.  
  1197.      /*
  1198. @@ -2222,8 +2284,7 @@
  1199.  
  1200.      
  1201.      NCR53c7x0_write8(SIEN0_REG_800, ((hostdata->options & OPTION_PARITY) ?
  1202. -        SIEN_PAR : 0) | SIEN_RST | SIEN_UDC | SIEN_SGE | SIEN_800_SEL |
  1203. -            SIEN_800_RESEL | SIEN_MA);
  1204. +        SIEN_PAR : 0) | SIEN_RST | SIEN_UDC | SIEN_SGE | SIEN_MA);
  1205.      NCR53c7x0_write8(SIEN1_REG_800, SIEN1_800_STO | SIEN1_800_HTH);
  1206.  
  1207.      /* 
  1208. @@ -2243,11 +2304,13 @@
  1209.  /*
  1210.   * Function static struct NCR53c7x0_cmd *create_cmd (Scsi_Cmnd *cmd) 
  1211.   *
  1212. - * Purpose : Using scsi_malloc() if the system is initialized,
  1213. - *    scan_scsis_buf if not, allocate space to store the variable
  1214. - *    length NCR53c7x0_cmd structure.  Initialize it based on 
  1215. - *    the Scsi_Cmnd structure passed in, including dsa and 
  1216. - *    Linux field initialization, and dsa code relocation.
  1217. + * Purpose : If we have not allready allocated enough NCR53c7x0_cmd
  1218. + *    structures to satisfy any allowable number of simultaenous 
  1219. + *    commands for this host; do so (using either scsi_malloc()
  1220. + *    or kmalloc() depending on configuration), and add them to the 
  1221. + *    hostdata free list.  Take the first structure off the free list, 
  1222. + *    initialize it based on the Scsi_Cmnd structure passed in, 
  1223. + *    including dsa and Linux field initialization, and dsa code relocation.
  1224.   *
  1225.   * Inputs : cmd - SCSI command
  1226.   *
  1227. @@ -2255,26 +2318,86 @@
  1228.   *    NULL on failure.
  1229.   */
  1230.  
  1231. -static struct NCR53c7x0_cmd *create_cmd (Scsi_Cmnd *cmd) {
  1232. +static struct NCR53c7x0_cmd *
  1233. +create_cmd (Scsi_Cmnd *cmd) {
  1234.      NCR53c7x0_local_declare();
  1235.      struct Scsi_Host *host = cmd->host;
  1236.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1237.          host->hostdata;    
  1238. -    int size;            /* Size of *tmp */
  1239. -    struct NCR53c7x0_cmd *tmp;     /* NCR53c7x0_cmd structure for this command */
  1240. +    struct NCR53c7x0_cmd *tmp = NULL;     /* NCR53c7x0_cmd structure for this command */
  1241.      int datain,          /* Number of instructions per phase */
  1242.      dataout;
  1243.      int data_transfer_instructions, /* Count of dynamic instructions */
  1244. -        i,            /* Counter */
  1245. -    alignment;        /* Alignment adjustment (0 - 4) */
  1246. +        i;            /* Counter */
  1247.      unsigned long *cmd_datain,    /* Address of datain/dataout code */
  1248.      *cmd_dataout;        /* Incremented as we assemble */
  1249. +#ifdef notyet
  1250.      void *real;            /* Real address */
  1251. +    int size;            /* Size of *tmp */
  1252. +    int    alignment;        /* Alignment adjustment (0 - 4) */
  1253. +#endif
  1254. +    unsigned long flags;
  1255.      NCR53c7x0_local_setup(cmd->host);
  1256.  
  1257. +/* FIXME : when we start doing multiple simultaenous commands per LUN, 
  1258. +   we will need to either
  1259. +        - Do an attach_slave() and detach_slave() the right way (alocate
  1260. +          memory in attach_slave() as we do in scsi_register).
  1261. +        - Make sure this code works
  1262. +    with the former being cleaner.  At the same time, we can also go with
  1263. +    a per-device host_scribble, and introduce a NCR53c7x0_device structure
  1264. +    to replace the messy fixed length arrays we're starting to use. */
  1265. +
  1266. +#ifdef notyet
  1267. +
  1268. +    if (hostdata->num_commands < host->can_queue &&
  1269. +        !in_scan_scsis && 
  1270. +        !(hostdata->cmd_allocated[cmd->target] & (1 << cmd->lun))) {
  1271. +        for (i = host->hostt->cmd_per_lun - 1; i >= 0  --i) {
  1272. +#ifdef SCSI_MALLOC
  1273. +    /* scsi_malloc must allocate with a 512 byte granularity, but allways
  1274. +       returns buffers which are aligned on a 512 boundary */
  1275. +        size = (hostdata->max_cmd_size + 511) / 512 * 512;
  1276. +        tmp = (struct NCR53c7x0_cmd *) scsi_malloc (size);
  1277. +        if (!tmp)
  1278. +        break;
  1279. +        tmp->real = (void *) tmp; 
  1280. +#else
  1281. +    /* kmalloc() can allocate any size, but historically has returned 
  1282. +       unaligned addresses, so we need to allow for alignment */
  1283. +        size = hostdata->max_cmd_size + 4;
  1284. +        real = kmalloc (size, GFP_ATOMIC);
  1285. +        alignment = 4 - (((unsigned) real) & 3);
  1286. +        tmp = (struct NCR53c7x0_cmd *) (((char *) real) + alignment);
  1287. +        if (!tmp)
  1288. +        break;
  1289. +        tmp->real = real;
  1290. +#endif /* def SCSI_MALLOC */
  1291. +            tmp->size = size;            
  1292. +        /* Insert all but last into list */
  1293. +        if (i > 0) {
  1294. +        tmp->next = hostdata->free;
  1295. +        hostdata->free = tmp;
  1296. +        }
  1297. +    }
  1298. +    }
  1299. +#endif /* def notyet */
  1300. +    if (!tmp) {
  1301. +        save_flags(flags);
  1302. +        cli();
  1303. +        tmp = (struct NCR53c7x0_cmd *) hostdata->free;
  1304. +    if (tmp) {
  1305. +            hostdata->free = tmp->next;
  1306. +        restore_flags(flags);
  1307. +        } else {
  1308. +            restore_flags(flags);
  1309. +            return NULL;
  1310. +        }
  1311. +    }
  1312. +
  1313.  
  1314.      /*
  1315. -     * Decide weather we need to generate commands for DATA IN,
  1316. +     * Decide whether we need to generate commands for DATA IN,
  1317.       * DATA OUT, neither, or both based on the SCSI command 
  1318.       */
  1319.  
  1320. @@ -2323,10 +2446,6 @@
  1321.      datain = dataout = 2 * (cmd->use_sg ? cmd->use_sg : 1) + 3;
  1322.      }
  1323.  
  1324. -    /*
  1325. -     * Allocate memory for the NCR53c7x0_cmd structure.  
  1326. -     */
  1327. -
  1328.      /* 
  1329.       * For each data phase implemented, we need a JUMP instruction
  1330.       * to return control to other_transfer.  We also need a MOVE
  1331. @@ -2344,63 +2463,11 @@
  1332.      if (data_transfer_instructions < 2)
  1333.          data_transfer_instructions = 2;
  1334.  
  1335. -    /* 
  1336. -     * We need enough space to store the base NCR53c7x0 structure,
  1337. -     * DSA, and data transfer instructions at 2 long words each,
  1338. -     * as well as padding out to the next 512 bytes for scsi_malloc.
  1339. -     *
  1340. -     * We also need to guarantee alignment of _4_ bytes. 
  1341. -     */
  1342. -
  1343. -#ifdef SCSI_MALLOC
  1344. -    size = ((sizeof (struct NCR53c7x0_cmd) + (hostdata->dsa_end - 
  1345. -        hostdata->dsa_start) + 2 * sizeof(long) * 
  1346. -        data_transfer_instructions + 4 + 511) / 512) * 512;        
  1347. -#else
  1348. -    size = sizeof (struct NCR53c7x0_cmd) + (hostdata->dsa_end - 
  1349. -        hostdata->dsa_start) + 2 * sizeof(long) * 
  1350. -        data_transfer_instructions + 4;
  1351. -#endif
  1352. -
  1353. -
  1354. -#if 0
  1355. -    if (size > 512) {
  1356. -    printk("scsi%d : size = %d\n", host->host_no, size);
  1357. -    }
  1358. -#endif
  1359. -
  1360. -#ifdef SCSI_MALLOC
  1361. -    real = in_scan_scsis ? NULL : scsi_malloc (size);
  1362. -#else
  1363. -    real = kmalloc (size, GFP_ATOMIC);
  1364. -#endif
  1365. -
  1366. -    if (!real) {
  1367. -    if (!scan_scsis_buf_busy && size <= sizeof(scan_scsis_buf)) {
  1368. -        scan_scsis_buf_busy = 1;
  1369. -        real = scan_scsis_buf;
  1370. -    } else {
  1371. -        panic ("scsi%d : scan_scsis_buf too small (need %d bytes)\n",
  1372. -        host->host_no, size);
  1373. -    }
  1374. -    }
  1375. -
  1376. -    alignment = 4 - (((unsigned) real) & 3);
  1377. -
  1378. -    tmp = (struct NCR53c7x0_cmd *) (((char *) real) + alignment);
  1379. -
  1380. -    tmp->real = real;
  1381. -
  1382. -
  1383. -    if (((unsigned long) tmp->dsa) & 0x3) 
  1384. -    panic ("scsi%d : pid %d dsa structure not dword aligned!\n",
  1385. -        host->host_no, cmd->pid);
  1386.  
  1387.      /*
  1388.       * Initialize Linux specific fields.
  1389.       */
  1390.  
  1391. -    tmp->size = size;            
  1392.      tmp->cmd = cmd;
  1393.      tmp->next = NULL;
  1394.      tmp->prev = NULL;
  1395. @@ -2434,7 +2501,7 @@
  1396.      patch_dsa_32(tmp->dsa, dsa_select, 0, hostdata->sync[cmd->target].
  1397.          select_indirect);
  1398.      /*
  1399. -     * XXX - we need to figure this size based on weather
  1400. +     * XXX - we need to figure this size based on whether
  1401.       * or not we'll be using any additional messages.
  1402.       */
  1403.      patch_dsa_32(tmp->dsa, dsa_msgout, 0, 1);
  1404. @@ -2462,7 +2529,7 @@
  1405.      patch_dsa_32(tmp->dsa, dsa_status, 1, &cmd->result);
  1406.      patch_dsa_32(tmp->dsa, dsa_msgout_other, 0, 1);
  1407.      patch_dsa_32(tmp->dsa, dsa_msgout_other, 1, 
  1408. -        &NCR53c7xx_msg_nop);
  1409. +        &(hostdata->NCR53c7xx_msg_nop));
  1410.  
  1411.      
  1412.      /*
  1413. @@ -2486,8 +2553,8 @@
  1414.  #endif
  1415.  
  1416.  /* 
  1417. - * XXX - I'm undecided weather all of this nonsense is faster
  1418. - * in the long run, or weather I should just go and implement a loop
  1419. + * XXX - I'm undecided whether all of this nonsense is faster
  1420. + * in the long run, or whether I should just go and implement a loop
  1421.   * on the NCR chip using table indirect mode?
  1422.   *
  1423.   * In any case, this is how it _must_ be done for 53c700/700-66 chips,
  1424. @@ -2516,8 +2583,8 @@
  1425.          cmd_datain[2] = ((DCMD_TYPE_TCI | DCMD_TCI_OP_CALL | 
  1426.          DCMD_TCI_CD | DCMD_TCI_IO | DCMD_TCI_MSG) << 24) | 
  1427.          DBC_TCI_WAIT_FOR_VALID | DBC_TCI_COMPARE_PHASE | DBC_TCI_TRUE;
  1428. -        cmd_datain[3] = hostdata->script + hostdata->E_msg_in / 
  1429. -        sizeof(long);
  1430. +        cmd_datain[3] = (unsigned long) hostdata->script + 
  1431. +                hostdata->E_msg_in;
  1432.  #if 0
  1433.          print_insn (host, cmd_datain, "dynamic ", 1);
  1434.          print_insn (host, cmd_datain + 2, "dynamic ", 1);
  1435. @@ -2530,8 +2597,8 @@
  1436.          cmd_dataout[2] = ((DCMD_TYPE_TCI | DCMD_TCI_OP_CALL | 
  1437.          DCMD_TCI_CD | DCMD_TCI_IO | DCMD_TCI_MSG) << 24) | 
  1438.          DBC_TCI_WAIT_FOR_VALID | DBC_TCI_COMPARE_PHASE | DBC_TCI_TRUE;
  1439. -        cmd_dataout[3] = hostdata->script + hostdata->E_msg_in /
  1440. -        sizeof(long);
  1441. +        cmd_dataout[3] = (unsigned long) hostdata->script + 
  1442. +                hostdata->E_msg_in;
  1443.  #if 0
  1444.          print_insn (host, cmd_dataout, "dynamic ", 1);
  1445.          print_insn (host, cmd_dataout + 2, "dynamic ", 1);
  1446. @@ -2548,8 +2615,8 @@
  1447.      if (datain) {
  1448.      cmd_datain[0] = ((DCMD_TYPE_TCI | DCMD_TCI_OP_JUMP) << 24) |
  1449.              DBC_TCI_TRUE;
  1450. -    cmd_datain[1] = hostdata->script + hostdata->E_other_transfer
  1451. -        / sizeof(long);
  1452. +    cmd_datain[1] = (unsigned long) hostdata->script + 
  1453. +            hostdata->E_other_transfer;
  1454.  #if 0
  1455.      print_insn (host, cmd_datain, "dynamic jump ", 1);
  1456.  #endif
  1457. @@ -2567,8 +2634,8 @@
  1458.      if (dataout) {
  1459.      cmd_dataout[0] = ((DCMD_TYPE_TCI | DCMD_TCI_OP_JUMP) << 24) |
  1460.              DBC_TCI_TRUE;
  1461. -    cmd_dataout[1] = hostdata->script + hostdata->E_other_transfer
  1462. -        / sizeof(long);
  1463. +    cmd_dataout[1] = (unsigned long) hostdata->script + 
  1464. +            hostdata->E_other_transfer;
  1465.  #if 0
  1466.      print_insn (host, cmd_dataout, "dynamic jump ", 1);
  1467.  #endif
  1468. @@ -2603,7 +2670,7 @@
  1469.      struct Scsi_Host *host = cmd->host;
  1470.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1471.      host->hostdata;
  1472. -    int old_level;
  1473. +    unsigned long flags;
  1474.      unsigned char target_was_busy;
  1475.      NCR53c7x0_local_setup(host);
  1476.      
  1477. @@ -2671,7 +2738,8 @@
  1478.       * valid while the condition exists.
  1479.       */
  1480.  
  1481. -    old_level = splx(0);
  1482. +    save_flags(flags);
  1483. +    cli();
  1484.  
  1485.      /* 
  1486.       * Consider a target busy if there are _any_ commands running
  1487. @@ -2764,7 +2832,7 @@
  1488.              tmp->next; tmp = (struct NCR53c7x0_cmd *) tmp->next);
  1489.          tmp->next = tmp;
  1490.      }
  1491. -    splx(old_level);
  1492. +    restore_flags(flags);
  1493.      return 0;
  1494.  }
  1495.  
  1496. @@ -2848,9 +2916,9 @@
  1497.      
  1498.      if (sstat0_sist0 & SSTAT0_UDC) {
  1499.      fatal = 1;
  1500. -    printk("scsi%d : target %d lun %d unexpected disconnect\n",
  1501. -        host->host_no, cmd->cmd->target, cmd->cmd->lun);
  1502.      if (cmd) {
  1503. +        printk("scsi%d : target %d lun %d unexpected disconnect\n",
  1504. +        host->host_no, cmd->cmd->target, cmd->cmd->lun);
  1505.          abnormal_finished(cmd, DID_ERROR << 16);
  1506.      }
  1507.      hostdata->dsp = hostdata->script + hostdata->E_schedule / 
  1508. @@ -2950,7 +3018,7 @@
  1509.                             should terminate */
  1510.      int interrupted = 0;            /* This HA generated 
  1511.                             an interrupt */
  1512. -    int old_level;                
  1513. +    unsigned long flags;                
  1514.  
  1515.  #ifdef NCR_DEBUG
  1516.      char buf[80];                /* Debugging sprintf buffer */
  1517. @@ -3011,12 +3079,14 @@
  1518.               */
  1519.  
  1520.  
  1521. -            old_level = splx(0);
  1522. +            save_flags(flags);
  1523. +            cli();
  1524.  restart:
  1525.              for (cmd_prev_ptr = (struct NCR53c7x0_cmd **) 
  1526. -            &(hostdata->running_list), cmd = (struct NCR53c7x0_cmd *)
  1527. -            hostdata->running_list; cmd ; cmd_prev_ptr = 
  1528. -            &(cmd->next), cmd = (struct NCR53c7x0_cmd *) cmd->next) {
  1529. +             &(hostdata->running_list), cmd = 
  1530. +                         (struct NCR53c7x0_cmd *) hostdata->running_list; cmd ;
  1531. +                         cmd_prev_ptr = (struct NCR53c7x0_cmd **) &(cmd->next), 
  1532. +                         cmd = (struct NCR53c7x0_cmd *) cmd->next) {
  1533.              Scsi_Cmnd *tmp;
  1534.  
  1535.              if (!cmd) {
  1536. @@ -3045,7 +3115,7 @@
  1537.              if (cmd->prev)
  1538.                  cmd->prev->next = cmd->next;
  1539.              if (cmd_prev_ptr)
  1540. -                *cmd_prev_ptr = cmd->next;
  1541. +                *cmd_prev_ptr = (struct NCR53c7x0_cmd *) cmd->next;
  1542.  
  1543.  #ifdef LUN_BUSY
  1544.              /* Check for next command for target, add to issue queue */
  1545. @@ -3054,16 +3124,8 @@
  1546.  #endif
  1547.  
  1548.  
  1549. -            if (!scan_scsis_buf_busy) {
  1550. -#ifdef SCSI_MALLOC
  1551. -                scsi_free ((void *) cmd->real, cmd->size);
  1552. -#else
  1553. -                kfree_s ((void *) cmd->real, cmd->size);
  1554. -#endif
  1555. -            } else {
  1556. -                scan_scsis_buf_busy = 0;
  1557. -            }
  1558. -
  1559. +                        cmd->next = hostdata->free;
  1560. +                        hostdata->free = cmd;
  1561.  
  1562.                          tmp->host_scribble = NULL;
  1563.  
  1564. @@ -3081,7 +3143,7 @@
  1565.              goto restart;
  1566.  
  1567.              }
  1568. -            splx(old_level);
  1569. +            restore_flags(flags);
  1570.  
  1571.              if (!search_found)  {
  1572.              printk ("scsi%d : WARNING : INTFLY with no completed commands.\n",
  1573. @@ -3204,7 +3266,8 @@
  1574.   *
  1575.   */
  1576.  
  1577. -static int abort_connected (struct Scsi_Host *host) {
  1578. +static int 
  1579. +abort_connected (struct Scsi_Host *host) {
  1580.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1581.      host->hostdata;
  1582.  
  1583. @@ -3398,15 +3461,13 @@
  1584.      NCR53c7x0_local_declare();
  1585.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1586.      host->hostdata;
  1587. -    unsigned char dstat,    /* DSTAT */    
  1588. -    dbc_dcmd;        /* DCMD (high eight bits) + DBC */
  1589. +    unsigned char dstat;    /* DSTAT */    
  1590.      unsigned long *dsp,
  1591.      *next_dsp,        /* Current dsp */
  1592. -        *dsa;
  1593. -        
  1594. -
  1595. -    int ipl,            /* Old ipl from splx(0) */
  1596. -    tmp;
  1597. +        *dsa,
  1598. +    dbc_dcmd;        /* DCMD (high eight bits) + DBC */
  1599. +    int tmp;
  1600. +    unsigned long flags;
  1601.      NCR53c7x0_local_setup(host);
  1602.  
  1603.      if (!hostdata->dstat_valid) {
  1604. @@ -3460,12 +3521,13 @@
  1605.      if (hostdata->options & OPTION_DEBUG_TRACE) {
  1606.      } else if (hostdata->options & OPTION_DEBUG_SINGLE) {
  1607.          print_insn (host, dsp, "s ", 0);
  1608. -        ipl = splx(0);
  1609. +        save_flags(flags);
  1610. +        cli();
  1611.  /* XXX - should we do this, or can we get away with writing dsp? */
  1612.  
  1613.          NCR53c7x0_write8 (DCNTL_REG, (NCR53c7x0_read8(DCNTL_REG) & 
  1614.                  ~DCNTL_SSM) | DCNTL_STD);
  1615. -        splx(ipl);
  1616. +        restore_flags(flags);
  1617.      } else {
  1618.          printk("scsi%d : unexpected single step interrupt at\n"
  1619.             "         ", host->host_no);
  1620. @@ -3654,9 +3716,10 @@
  1621.      struct Scsi_Host *host = cmd->host;
  1622.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *) 
  1623.      host->hostdata;
  1624. -    int old_level;
  1625. +    unsigned long flags;
  1626.      struct NCR53c7x0_cmd *curr, **prev;
  1627. -    old_level = splx(0);
  1628. +    save_flags(flags);
  1629. +    cli();
  1630.  
  1631.  /*
  1632.   * The command could be hiding in the issue_queue.  This would be very
  1633. @@ -3668,28 +3731,23 @@
  1634.   * pull the command out of the old queue, and call it aborted.
  1635.   */
  1636.  
  1637. -    for (curr = hostdata->issue_queue, prev = &(hostdata->issue_queue);
  1638. -    curr && curr->cmd != cmd; prev = &(curr->next), curr = curr->next);
  1639. +    for (curr = (struct NCR53c7x0_cmd *) hostdata->issue_queue, 
  1640. +         prev = (struct NCR53c7x0_cmd **) &(hostdata->issue_queue);
  1641. +     curr && curr->cmd != cmd; prev = (struct NCR53c7x0_cmd **)
  1642. +         &(curr->next), curr = (struct NCR53c7x0_cmd *) curr->next);
  1643.  
  1644.      if (curr) {
  1645. -    *prev = curr->next;
  1646. +    *prev = (struct NCR53c7x0_cmd *) curr->next;
  1647.  /* XXX - get rid of DLL ? */
  1648.      if (curr->prev)
  1649.          curr->prev->next = curr->next;
  1650.  
  1651. -    if (!scan_scsis_buf_busy) {
  1652. -#ifdef SCSI_MALLOC
  1653. -        scsi_free ((void *) curr->real, curr->size);
  1654. -#else
  1655. -        kfree_s ((void *) curr->real, curr->size);
  1656. -#endif
  1657. -    } else {
  1658. -        scan_scsis_buf_busy = 0;
  1659. -    }
  1660. +        curr->next = hostdata->free;
  1661. +        hostdata->free = curr;
  1662.  
  1663.      cmd->result = 0;
  1664.      cmd->scsi_done(cmd);
  1665. -    splx(old_level);
  1666. +    restore_flags(flags);
  1667.      return SCSI_ABORT_SUCCESS;
  1668.      }
  1669.  
  1670. @@ -3698,11 +3756,13 @@
  1671.   * commands.  If this is the case, drastic measures are called for.  
  1672.   */ 
  1673.  
  1674. -    for (curr = hostdata->running_list, prev = &(hostdata->running_list);
  1675. -    curr && curr->cmd != cmd; prev = &(curr->next), curr = curr->next);
  1676. +    for (curr = (struct NCR53c7x0_cmd *) hostdata->running_list, 
  1677. +         prev = (struct NCR53c7x0_cmd **) &(hostdata->running_list);
  1678. +     curr && curr->cmd != cmd; prev = (struct NCR53c7x0_cmd **) 
  1679. +         &(curr->next), curr = (struct NCR53c7x0_cmd *) curr->next);
  1680.  
  1681.      if (curr) {
  1682. -    splx(old_level);
  1683. +    restore_flags(flags);
  1684.      printk ("scsi%d : DANGER : command in running list, can not abort.\n",
  1685.          cmd->host->host_no);
  1686.      return SCSI_ABORT_SNOOZE;
  1687. @@ -3715,16 +3775,8 @@
  1688.   */
  1689.  
  1690.      curr = (struct NCR53c7x0_cmd *) cmd->host_scribble;
  1691. -
  1692. -    if (!scan_scsis_buf_busy) {
  1693. -#ifdef SCSI_MALLOC
  1694. -    scsi_free ((void *) curr->real, curr->size);
  1695. -#else
  1696. -    kfree_s ((void *) curr->real, curr->size);
  1697. -#endif
  1698. -    } else {
  1699. -    scan_scsis_buf_busy = 0;
  1700. -    }
  1701. +    curr->next = hostdata->free;
  1702. +    hostdata->free = curr;
  1703.  
  1704.      if (((cmd->result & 0xff00) == 0xff00) ||
  1705.      ((cmd->result & 0xff) == 0xff)) {
  1706. @@ -3734,7 +3786,7 @@
  1707.          host->host_no);
  1708.      }
  1709.      cmd->scsi_done(cmd);
  1710. -    splx(old_level);
  1711. +    restore_flags(flags);
  1712.      return SCSI_ABORT_SNOOZE;
  1713.  }
  1714.  
  1715. @@ -3749,17 +3801,47 @@
  1716.   * Returns : 0 on success.
  1717.   */
  1718.   
  1719. -int NCR53c7xx_reset (Scsi_Cmnd *cmd) {
  1720. +int 
  1721. +NCR53c7xx_reset (Scsi_Cmnd *cmd) {
  1722.      NCR53c7x0_local_declare();
  1723. -    struct Scsi_Host *host = cmd ? cmd->host : NULL;
  1724. +    unsigned long flags;
  1725. +    int found;
  1726. +    struct NCR53c7x0_cmd * c;
  1727. +    Scsi_Cmnd *tmp;
  1728. +    struct Scsi_Host *host = cmd->host;
  1729.      struct NCR53c7x0_hostdata *hostdata = host ? 
  1730. -    (struct NCR53c7x0_hostdata *) host->hostdata : NULL;
  1731. -    if (host) NCR53c7x0_local_setup(host);
  1732. -    
  1733. +    (struct NCR53c7x0_hostdata *) host->hostdata : NULL;
  1734. +    NCR53c7x0_local_setup(host);
  1735. +    save_flags(flags);
  1736. +    halt (host);
  1737. +    NCR53c7x0_write8(SCNTL1_REG, SCNTL1_RST);
  1738. +    udelay(25);    /* Minimum ammount of time to assert RST */
  1739. +    NCR53c7x0_write8(SCNTL1_REG, SCNTL1_RST);
  1740. +    for (c = (struct NCR53c7x0_cmd *) hostdata->running_list, found = 0; c; 
  1741. +        c = (struct NCR53c7x0_cmd *) c->next)  {
  1742. +    tmp = c->cmd;
  1743. +        c->next = hostdata->free;
  1744. +        hostdata->free = c;
  1745. +
  1746. +    if (tmp == cmd)
  1747. +        found = 1; 
  1748. +        tmp->result = DID_RESET << 16;
  1749. +    tmp->scsi_done(tmp);
  1750. +    }
  1751. +    if (!found) {
  1752. +        c = (struct NCR53c7x0_cmd *) cmd->host_scribble;
  1753. +        if (c) {
  1754. +            c->next = hostdata->free;
  1755. +            hostdata->free = c;
  1756. +        }
  1757. +        cmd->result = DID_RESET << 16;
  1758. +        cmd->scsi_done(cmd);
  1759. +    }
  1760. +    restore_flags(flags);
  1761.  
  1762.      printk ("scsi%d : DANGER : NCR53c7xx_reset is NOP\n",
  1763.      cmd->host->host_no);
  1764. -    return SCSI_RESET_SNOOZE;
  1765. +    return SCSI_RESET_SUCCESS;
  1766.  }
  1767.  
  1768.  /*
  1769. @@ -3770,13 +3852,11 @@
  1770.  static void print_dsa (struct Scsi_Host *host, unsigned long *dsa) {
  1771.      struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1772.      host->hostdata;
  1773. -    Scsi_Cmnd * cmd;
  1774. -    struct NCR53c7x0_cmd * c;
  1775.      int i, len;
  1776.      char *ptr;
  1777.  
  1778.      printk("scsi%d : dsa at 0x%x\n"
  1779. -        "        + %d : dsa_msgout length = %d, data = 0x%x\n" ,
  1780. +        "        + %ld : dsa_msgout length = %lu, data = 0x%lx\n" ,
  1781.              host->host_no, (unsigned) dsa, hostdata->dsa_msgout,
  1782.              dsa[hostdata->dsa_msgout / sizeof(long)],
  1783.          dsa[hostdata->dsa_msgout / sizeof(long) + 1]);
  1784. @@ -3790,3 +3870,108 @@
  1785.      }
  1786.  }
  1787.  
  1788. +/*
  1789. + * Function : static int shutdown (struct Scsi_Host *host)
  1790. + * 
  1791. + * Purpose : does a clean (we hope) shutdown of the NCR SCSI 
  1792. + *    chip.  Use prior to dumping core, unloading the NCR driver,
  1793. + *    etc.
  1794. + * 
  1795. + * Returns : 0 on success
  1796. + */
  1797. +#ifdef MODULE
  1798. +static int 
  1799. +shutdown (struct Scsi_Host *host) {
  1800. +    NCR53c7x0_local_declare();
  1801. +    unsigned long flags;
  1802. +    struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1803. +    host->hostdata;
  1804. +    NCR53c7x0_local_setup(host);
  1805. +    save_flags (flags);
  1806. +    cli();
  1807. +    halt (host);
  1808. +    hostdata->soft_reset(host);
  1809. +/* 
  1810. + * For now, we take the simplest solution : reset the SCSI bus. Eventually,
  1811. + * - If a command is connected, kill it with an ABORT message
  1812. + * - If commands are disconnected, connect to each target/LUN and 
  1813. + *    do a ABORT, followed by a SOFT reset, followed by a hard 
  1814. + *    reset.  
  1815. + */
  1816. +    NCR53c7x0_write8(SCNTL1_REG, SCNTL1_RST);
  1817. +    udelay(25);    /* Minimum ammount of time to assert RST */
  1818. +    NCR53c7x0_write8(SCNTL1_REG, SCNTL1_RST);
  1819. +    restore_flags (flags);
  1820. +    return 0;
  1821. +}
  1822. +#endif
  1823. +
  1824. +
  1825. +/*
  1826. + * Function : static int halt (struct Scsi_Host *host)
  1827. + * 
  1828. + * Purpose : halts the SCSI SCRIPTS(tm) processor on the NCR chip
  1829. + *
  1830. + * Inputs : host - SCSI chip to halt
  1831. + *
  1832. + * Returns : 0 on success
  1833. + */
  1834. +
  1835. +static int 
  1836. +halt (struct Scsi_Host *host) {
  1837. +    NCR53c7x0_local_declare();
  1838. +    unsigned long flags;
  1839. +    unsigned char istat, tmp;
  1840. +    struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
  1841. +    host->hostdata;
  1842. +    NCR53c7x0_local_setup(host);
  1843. +
  1844. +    save_flags(flags);
  1845. +    cli();
  1846. +    NCR53c7x0_write8(hostdata->istat, ISTAT_ABRT);
  1847. +    /* Eat interrupts until we find what we're looking for */
  1848. +    for (;;) {
  1849. +    istat = NCR53c7x0_read8 (hostdata->istat);
  1850. +    if (istat & ISTAT_SIP) {
  1851. +        if ((hostdata->chip / 100) == 8) {
  1852. +        tmp = NCR53c7x0_read8(SIST0_REG_800);
  1853. +        udelay(1);
  1854. +        tmp = NCR53c7x0_read8(SIST1_REG_800);
  1855. +        } else {
  1856. +        tmp = NCR53c7x0_read8(SSTAT0_REG);
  1857. +        }
  1858. +    } else if (istat & ISTAT_DIP) {
  1859. +            NCR53c7x0_write8(hostdata->istat, 0);
  1860. +        tmp = NCR53c7x0_read8(DSTAT_REG);
  1861. +        if (tmp & DSTAT_ABRT)
  1862. +        break;
  1863. +        else
  1864. +        panic("scsi%d: could not halt NCR chip\n", host->host_no);
  1865. +    }
  1866. +    }
  1867. +    hostdata->state = STATE_HALTED;
  1868. +    restore_flags(flags);
  1869. +    return 0;
  1870. +}
  1871. +
  1872. +#ifdef MODULE
  1873. +int NCR53c7x0_release(struct Scsi_Host *host) {
  1874. +    shutdown (host);
  1875. +/* FIXME : need to recursively free tpnt structure */
  1876. +    if (host->irq != IRQ_NONE)
  1877. +    {
  1878. +        int irq_count;
  1879. +        struct Scsi_Host *tmp;
  1880. +        for (irq_count = 0, tmp = first_host; tmp; tmp = tmp->next)
  1881. +        if (tmp->hostt == the_template && tmp->irq == host->irq)
  1882. +            ++irq_count;
  1883. +        if (irq_count == 1)
  1884. +        free_irq(host->irq);
  1885. +    }
  1886. +    if (host->dma_channel != DMA_NONE)
  1887. +    free_dma(host->dma_channel);
  1888. +    return 1;
  1889. +}
  1890. +Scsi_Host_Template driver_template = NCR53c7xx;
  1891. +#include "scsi_module.c"
  1892. +#endif /* def MODULE */
  1893. diff -u --recursive --new-file v1.2.5/linux/drivers/scsi/53c7,8xx.h linux/drivers/scsi/53c7,8xx.h
  1894. --- v1.2.5/linux/drivers/scsi/53c7,8xx.h    Wed Jan 25 09:06:17 1995
  1895. +++ linux/drivers/scsi/53c7,8xx.h    Mon Apr 17 13:47:57 1995
  1896. @@ -46,20 +46,27 @@
  1897.   * array.
  1898.   */
  1899.  
  1900. -#ifdef HOSTS_C 
  1901. +#if defined(HOSTS_C) || defined(MODULE)
  1902.  #include <linux/scsicam.h>
  1903.  extern int NCR53c7xx_abort(Scsi_Cmnd *);
  1904.  extern int NCR53c7xx_detect(Scsi_Host_Template *tpnt);
  1905.  extern int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
  1906.  extern int NCR53c7xx_reset(Scsi_Cmnd *);
  1907. -
  1908. -#define NCR53c7xx {NULL, NULL, "NCR53c{7,8}xx (rel 3)", NCR53c7xx_detect,     \
  1909. -        NULL, NULL,                        \
  1910. -    NULL, NCR53c7xx_queue_command, NCR53c7xx_abort, NCR53c7xx_reset,\
  1911. -        NULL, scsicam_bios_param,                     \
  1912. -    /* can queue */ 1, /* id */ 7, 127 /* old SG_ALL */,         \
  1913. -    /* cmd per lun */ 1 , 0, 0, DISABLE_CLUSTERING}
  1914. +#ifdef MODULE
  1915. +extern int NCR53c7xx_release(struct Scsi_Host *);
  1916.  #else
  1917. +#define NCR53c7xx_release NULL
  1918. +#endif
  1919. +
  1920. +#define NCR53c7xx {NULL, NULL, "NCR53c{7,8}xx (rel 4)", NCR53c7xx_detect,     \
  1921. +        NULL, /* info */ NULL, /* command, depricated */ NULL,         \
  1922. +    NCR53c7xx_queue_command, NCR53c7xx_abort, NCR53c7xx_reset,    \
  1923. +        NULL /* slave attach */, scsicam_bios_param, /* can queue */ 1, \
  1924. +    /* id */ 7, 127 /* old SG_ALL */, /* cmd per lun */ 1 ,     \
  1925. +        /* present */ 0, /* unchecked isa dma */ 0, DISABLE_CLUSTERING} 
  1926. +#endif /* defined(HOSTS_C) || defined(MODULE) */ 
  1927. +
  1928. +#ifndef HOSTS_C
  1929.  /* Register addresses, ordered numerically */
  1930.  
  1931.  
  1932. @@ -932,6 +939,9 @@
  1933.  
  1934.  struct NCR53c7x0_cmd {
  1935.      void *real;                /* Real, unaligned address */
  1936. +    void (* free)(void *);        /* Command to deallocate; NULL
  1937. +                       for structures allocated with
  1938. +                       scsi_register, etc. */
  1939.      Scsi_Cmnd *cmd;            /* Associated Scsi_Cmnd 
  1940.                         structure, Scsi_Cmnd points
  1941.                         at NCR53c7x0_cmd using 
  1942. @@ -949,7 +959,11 @@
  1943.                       */
  1944.  
  1945.  
  1946. -    struct NCR53c7x0_cmd *next, *prev;    /* Linux maintained lists */
  1947. +    volatile struct NCR53c7x0_cmd *next, *prev;    
  1948. +                                        /* Linux maintained lists.  Note that
  1949. +                       hostdata->free is a singly linked
  1950. +                       list; the rest are doubly linked */
  1951. +                         
  1952.  
  1953.  
  1954.      unsigned long *data_transfer_start;    /* Start of data transfer routines */
  1955. @@ -986,10 +1000,12 @@
  1956.  /* Indicates that the NCR is executing other code. */
  1957.  #define STATE_RUNNING    2        
  1958.  /* 
  1959. - * Indicates that the NCR was being aborted.  Only used when running 
  1960. - * NCR53c700 compatible scripts.  
  1961. + * Indicates that the NCR was being aborted.
  1962.   */
  1963.  #define STATE_ABORTING    3
  1964. +/* 
  1965. + * Indicates that the NCR was successfully aborted. */
  1966. +#define STATE_ABORTED 4
  1967.      
  1968.  
  1969.  /* 
  1970. @@ -1072,6 +1088,7 @@
  1971.  
  1972.      int (* dstat_sir_intr)(struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd);
  1973.  
  1974. +    long dsa_size; /* Size of DSA structure */
  1975.  
  1976.      /*
  1977.       * Location of DSA fields for the SCSI SCRIPT corresponding to this 
  1978. @@ -1160,11 +1177,13 @@
  1979.      *breakpoint_current;        /* Current breakpoint being stepped 
  1980.                         through, NULL if we are running 
  1981.                         normally. */
  1982. +#ifdef NCR_DEBUG
  1983.      int debug_size;            /* Size of debug buffer */
  1984.      volatile int debug_count;        /* Current data count */
  1985.      volatile char *debug_buf;        /* Output ring buffer */
  1986.      volatile char *debug_write;        /* Current write pointer */
  1987.      volatile char *debug_read;        /* Current read pointer */
  1988. +#endif /* def NCR_DEBUG */
  1989.  
  1990.      /* XXX - primitive debugging junk, remove when working ? */
  1991.      int debug_print_limit;        /* Number of commands to print
  1992. @@ -1203,6 +1222,21 @@
  1993.                             nexus, ONLY valid for
  1994.                             NCR53c700/NCR53c700-66
  1995.                           */
  1996. +
  1997. +    volatile struct NCR53c7x0_cmd *spare;    /* pointer to spare,
  1998. +                                                   allocated at probe time,
  1999. +                                                   which we can use for 
  2000. +                           initialization */
  2001. +    volatile struct NCR53c7x0_cmd *free;
  2002. +    int max_cmd_size;                /* Maximum size of NCR53c7x0_cmd
  2003. +                               based on number of 
  2004. +                           scatter/gather segments, etc.
  2005. +                           */
  2006. +    volatile int num_cmds;            /* Number of commands 
  2007. +                           allocated */
  2008. +    volatile unsigned char cmd_allocated[8];    /* Have we allocated commands
  2009. +                           for this target yet?  If not,
  2010. +                           do so ASAP */
  2011.      volatile unsigned char busy[8][8];         /* number of commands 
  2012.                             executing on each target
  2013.                                                   */
  2014. @@ -1226,13 +1260,21 @@
  2015.      volatile unsigned char msg_buf[16];        /* buffer for messages
  2016.                             other than the command
  2017.                             complete message */
  2018. -    volatile struct NCR53c7x0_cmd *reconnect_dsa_head;    
  2019. +    volatile unsigned char *reconnect_dsa_head;    
  2020.                          /* disconnected commands,
  2021.                             maintained by NCR */
  2022.      /* Data identifying nexus we are trying to match during reselection */
  2023.      volatile unsigned char reselected_identify; /* IDENTIFY message */
  2024.      volatile unsigned char reselected_tag;    /* second byte of queue tag 
  2025.                             message or 0 */
  2026. +    /* These were static variables before we moved them */
  2027. +
  2028. +    long NCR53c7xx_zero;
  2029. +    long NCR53c7xx_sink;
  2030. +    char NCR53c7xx_msg_reject;
  2031. +    char NCR53c7xx_msg_abort;
  2032. +    char NCR53c7xx_msg_nop;
  2033. +
  2034.      int script_count;                /* Size of script in longs */
  2035.      unsigned long script[0];            /* Relocated SCSI script */
  2036.  
  2037. diff -u --recursive --new-file v1.2.5/linux/drivers/scsi/53c7,8xx.scr linux/drivers/scsi/53c7,8xx.scr
  2038. --- v1.2.5/linux/drivers/scsi/53c7,8xx.scr    Thu Mar  9 20:37:34 1995
  2039. +++ linux/drivers/scsi/53c7,8xx.scr    Mon Apr 17 13:52:38 1995
  2040. @@ -221,10 +221,10 @@
  2041.  ABSOLUTE int_test_2 = 0x04010000        ; Test 2 complete
  2042.  ABSOLUTE int_test_3 = 0x04020000        ; Test 3 complete
  2043.                          
  2044. -EXTERNAL NCR53c7xx_msg_abort         ; Pointer to abort message
  2045. -EXTERNAL NCR53c7xx_msg_reject         ; Pointer to reject message
  2046. -EXTERNAL NCR53c7xx_zero            ; long with zero in it, use for source
  2047. -EXTERNAL NCR53c7xx_sink            ; long to dump worthless data in
  2048. +ABSOLUTE NCR53c7xx_msg_abort = 0    ; Pointer to abort message
  2049. +ABSOLUTE NCR53c7xx_msg_reject = 0       ; Pointer to reject message
  2050. +ABSOLUTE NCR53c7xx_zero    = 0        ; long with zero in it, use for source
  2051. +ABSOLUTE NCR53c7xx_sink = 0        ; long to dump worthless data in
  2052.  
  2053.  ; Pointer to final bytes of multi-byte messages
  2054.  ABSOLUTE msg_buf = 0
  2055. @@ -881,13 +881,23 @@
  2056.  wait_reselect_failed:
  2057.  ; Reading CTEST2 clears the SIG_P bit in the ISTAT register.
  2058.      MOVE CTEST2 & 0x40 TO SFBR    
  2059. -    JUMP selected, IF NOT 0x40
  2060. +    JUMP schedule, IF 0x40
  2061. +    MOVE SIST0 & 0x20 TO SFBR
  2062. +    JUMP selected, IF 0x20
  2063. +; FIXME : Something bogus happened, and we shouldn't fail silently.
  2064.      JUMP schedule
  2065.  
  2066.  select_failed:
  2067. -    MOVE ISTAT & 0x20 TO SFBR
  2068. -    JUMP reselected, IF NOT 0x20
  2069. -    MOVE ISTAT & 0xdf TO ISTAT
  2070. +; If SIGP is set, the user just gave us another command, and
  2071. +; we should restart or return to the scheduler.
  2072. +; Reading CTEST2 clears the SIG_P bit in the ISTAT register.
  2073. +    MOVE CTEST2 & 0x40 TO SFBR    
  2074. +    JUMP select, IF 0x40
  2075. +; Otherwise, mask the selected and reselected bits off SIST0
  2076. +    MOVE SIST0 & 0x30 TO SFBR
  2077. +    JUMP selected, IF 0x20
  2078. +    JUMP reselected, IF 0x10 
  2079. +; FIXME : Something bogus happened, and we shouldn't fail silently.
  2080.      JUMP schedule
  2081.  
  2082.  ;
  2083. @@ -980,7 +990,10 @@
  2084.  ; If DSP points here, and a phase mismatch is encountered, we need to 
  2085.  ; do a bus reset.
  2086.  ;
  2087. +    
  2088. +    MOVE SCNTL2 & 0x7f TO SCNTL2
  2089.      MOVE 1, NCR53c7xx_msg_abort, WHEN MSG_OUT
  2090. +    WAIT DISCONNECT
  2091.      INT int_norm_aborted
  2092.  
  2093.  ;
  2094. diff -u --recursive --new-file v1.2.5/linux/drivers/scsi/53c8xx_d.h linux/drivers/scsi/53c8xx_d.h
  2095. --- v1.2.5/linux/drivers/scsi/53c8xx_d.h    Thu Mar  9 20:37:34 1995
  2096. +++ linux/drivers/scsi/53c8xx_d.h    Mon Apr 17 13:52:55 1995
  2097. @@ -127,7 +127,7 @@
  2098.  /*
  2099.      CALL scratch_to_dsa
  2100.  
  2101. -at 0x0000000a : */    0x88080000,0x00000800,
  2102. +at 0x0000000a : */    0x88080000,0x00000830,
  2103.  /*
  2104.      JUMP reselected_check_next
  2105.  
  2106. @@ -283,10 +283,10 @@
  2107.  ABSOLUTE int_test_2 = 0x04010000        ; Test 2 complete
  2108.  ABSOLUTE int_test_3 = 0x04020000        ; Test 3 complete
  2109.                          
  2110. -EXTERNAL NCR53c7xx_msg_abort         ; Pointer to abort message
  2111. -EXTERNAL NCR53c7xx_msg_reject         ; Pointer to reject message
  2112. -EXTERNAL NCR53c7xx_zero            ; long with zero in it, use for source
  2113. -EXTERNAL NCR53c7xx_sink            ; long to dump worthless data in
  2114. +ABSOLUTE NCR53c7xx_msg_abort = 0    ; Pointer to abort message
  2115. +ABSOLUTE NCR53c7xx_msg_reject = 0       ; Pointer to reject message
  2116. +ABSOLUTE NCR53c7xx_zero    = 0        ; long with zero in it, use for source
  2117. +ABSOLUTE NCR53c7xx_sink = 0        ; long to dump worthless data in
  2118.  
  2119.  ; Pointer to final bytes of multi-byte messages
  2120.  ABSOLUTE msg_buf = 0
  2121. @@ -325,7 +325,7 @@
  2122.  ;
  2123.      CALL dsa_to_scratch
  2124.  
  2125. -at 0x0000002d : */    0x88080000,0x000007b8,
  2126. +at 0x0000002d : */    0x88080000,0x000007e8,
  2127.  /*
  2128.  ; XXX - we need to deal with the NCR53c710, which lacks an add with
  2129.  ;    carry instruction, by moving around the DSA alignment to avoid
  2130. @@ -370,7 +370,7 @@
  2131.  ; And update the head pointer.
  2132.      CALL dsa_to_scratch
  2133.  
  2134. -at 0x00000041 : */    0x88080000,0x000007b8,
  2135. +at 0x00000041 : */    0x88080000,0x000007e8,
  2136.  /*
  2137.      MOVE dmode_ncr_to_memory TO DMODE    
  2138.  
  2139. @@ -422,7 +422,7 @@
  2140.  
  2141.      CALL scratch_to_dsa
  2142.  
  2143. -at 0x00000053 : */    0x88080000,0x00000800,
  2144. +at 0x00000053 : */    0x88080000,0x00000830,
  2145.  /*
  2146.  
  2147.  
  2148. @@ -514,7 +514,7 @@
  2149.  
  2150.      SELECT ATN FROM dsa_select, select_failed
  2151.  
  2152. -at 0x00000067 : */    0x4300003c,0x00000694,
  2153. +at 0x00000067 : */    0x4300003c,0x000006a4,
  2154.  /*
  2155.      JUMP select_msgout, WHEN MSG_OUT
  2156.  
  2157. @@ -539,7 +539,7 @@
  2158.  
  2159.      CALL dsa_to_scratch
  2160.  
  2161. -at 0x0000006d : */    0x88080000,0x000007b8,
  2162. +at 0x0000006d : */    0x88080000,0x000007e8,
  2163.  /*
  2164.  
  2165.      MOVE SCRATCH0 + dsa_next TO SCRATCH0
  2166. @@ -711,7 +711,7 @@
  2167.  do_dataout:
  2168.      CALL dsa_to_scratch
  2169.  
  2170. -at 0x0000009b : */    0x88080000,0x000007b8,
  2171. +at 0x0000009b : */    0x88080000,0x000007e8,
  2172.  /*
  2173.      MOVE SCRATCH0 + dsa_dataout TO SCRATCH0    
  2174.  
  2175. @@ -756,7 +756,7 @@
  2176.  do_datain:
  2177.      CALL dsa_to_scratch
  2178.  
  2179. -at 0x000000b1 : */    0x88080000,0x000007b8,
  2180. +at 0x000000b1 : */    0x88080000,0x000007e8,
  2181.  /*
  2182.      MOVE SCRATCH0 + dsa_datain TO SCRATCH0    
  2183.  
  2184. @@ -1100,7 +1100,7 @@
  2185.  /*
  2186.      MOVE 1, NCR53c7xx_msg_reject, WHEN MSG_OUT
  2187.  
  2188. -at 0x00000132 : */    0x0e000001,((unsigned long)&NCR53c7xx_msg_reject),
  2189. +at 0x00000132 : */    0x0e000001,0x00000000,
  2190.  /*
  2191.      RETURN
  2192.  
  2193. @@ -1295,7 +1295,7 @@
  2194.  reselected_notag:    
  2195.      MOVE MEMORY 1, NCR53c7xx_zero, reselected_tag
  2196.  
  2197. -at 0x0000015c : */    0xc0000001,((unsigned long)&NCR53c7xx_zero),0x00000000,
  2198. +at 0x0000015c : */    0xc0000001,0x00000000,0x00000000,
  2199.  /*
  2200.  
  2201.  
  2202. @@ -1317,7 +1317,7 @@
  2203.  /*
  2204.      CALL scratch_to_dsa
  2205.  
  2206. -at 0x00000166 : */    0x88080000,0x00000800,
  2207. +at 0x00000166 : */    0x88080000,0x00000830,
  2208.  /*
  2209.  
  2210.      ; Fix the update-next pointer so that the reconnect_dsa_head
  2211. @@ -1477,31 +1477,53 @@
  2212.  
  2213.  at 0x0000019f : */    0x741a4000,0x00000000,
  2214.  /*
  2215. -    JUMP selected, IF NOT 0x40
  2216. +    JUMP schedule, IF 0x40
  2217.  
  2218. -at 0x000001a1 : */    0x80040040,0x00000674,
  2219. +at 0x000001a1 : */    0x800c0040,0x00000130,
  2220.  /*
  2221. +    MOVE SIST0 & 0x20 TO SFBR
  2222. +
  2223. +at 0x000001a3 : */    0x74422000,0x00000000,
  2224. +/*
  2225. +    JUMP selected, IF 0x20
  2226. +
  2227. +at 0x000001a5 : */    0x800c0020,0x00000674,
  2228. +/*
  2229. +; FIXME : Something bogus happened, and we shouldn't fail silently.
  2230.      JUMP schedule
  2231.  
  2232. -at 0x000001a3 : */    0x80080000,0x00000130,
  2233. +at 0x000001a7 : */    0x80080000,0x00000130,
  2234.  /*
  2235.  
  2236.  select_failed:
  2237. -    MOVE ISTAT & 0x20 TO SFBR
  2238. +; If SIGP is set, the user just gave us another command, and
  2239. +; we should restart or return to the scheduler.
  2240. +; Reading CTEST2 clears the SIG_P bit in the ISTAT register.
  2241. +    MOVE CTEST2 & 0x40 TO SFBR    
  2242. +
  2243. +at 0x000001a9 : */    0x741a4000,0x00000000,
  2244. +/*
  2245. +    JUMP select, IF 0x40
  2246.  
  2247. -at 0x000001a5 : */    0x74142000,0x00000000,
  2248. +at 0x000001ab : */    0x800c0040,0x00000194,
  2249.  /*
  2250. -    JUMP reselected, IF NOT 0x20
  2251. +; Otherwise, mask the selected and reselected bits off SIST0
  2252. +    MOVE SIST0 & 0x30 TO SFBR
  2253.  
  2254. -at 0x000001a7 : */    0x80040020,0x00000568,
  2255. +at 0x000001ad : */    0x74423000,0x00000000,
  2256.  /*
  2257. -    MOVE ISTAT & 0xdf TO ISTAT
  2258. +    JUMP selected, IF 0x20
  2259.  
  2260. -at 0x000001a9 : */    0x7c14df00,0x00000000,
  2261. +at 0x000001af : */    0x800c0020,0x00000674,
  2262.  /*
  2263. +    JUMP reselected, IF 0x10 
  2264. +
  2265. +at 0x000001b1 : */    0x800c0010,0x00000568,
  2266. +/*
  2267. +; FIXME : Something bogus happened, and we shouldn't fail silently.
  2268.      JUMP schedule
  2269.  
  2270. -at 0x000001ab : */    0x80080000,0x00000130,
  2271. +at 0x000001b3 : */    0x80080000,0x00000130,
  2272.  /*
  2273.  
  2274.  ;
  2275. @@ -1525,11 +1547,11 @@
  2276.  test_1:
  2277.      MOVE MEMORY 4, test_src, test_dest
  2278.  
  2279. -at 0x000001ad : */    0xc0000004,0x00000000,0x00000000,
  2280. +at 0x000001b5 : */    0xc0000004,0x00000000,0x00000000,
  2281.  /*
  2282.      INT int_test_1
  2283.  
  2284. -at 0x000001b0 : */    0x98080000,0x04000000,
  2285. +at 0x000001b8 : */    0x98080000,0x04000000,
  2286.  /*
  2287.  
  2288.  ;
  2289. @@ -1540,61 +1562,61 @@
  2290.  test_2:
  2291.      CLEAR TARGET
  2292.  
  2293. -at 0x000001b2 : */    0x60000200,0x00000000,
  2294. +at 0x000001ba : */    0x60000200,0x00000000,
  2295.  /*
  2296.      SELECT ATN FROM 0, test_2_fail
  2297.  
  2298. -at 0x000001b4 : */    0x43000000,0x00000720,
  2299. +at 0x000001bc : */    0x43000000,0x00000740,
  2300.  /*
  2301.      JUMP test_2_msgout, WHEN MSG_OUT
  2302.  
  2303. -at 0x000001b6 : */    0x860b0000,0x000006e0,
  2304. +at 0x000001be : */    0x860b0000,0x00000700,
  2305.  /*
  2306.  ENTRY test_2_msgout
  2307.  test_2_msgout:
  2308.      MOVE FROM 8, WHEN MSG_OUT
  2309.  
  2310. -at 0x000001b8 : */    0x1e000000,0x00000008,
  2311. +at 0x000001c0 : */    0x1e000000,0x00000008,
  2312.  /*
  2313.      MOVE FROM 16, WHEN CMD 
  2314.  
  2315. -at 0x000001ba : */    0x1a000000,0x00000010,
  2316. +at 0x000001c2 : */    0x1a000000,0x00000010,
  2317.  /*
  2318.      MOVE FROM 24, WHEN DATA_IN
  2319.  
  2320. -at 0x000001bc : */    0x19000000,0x00000018,
  2321. +at 0x000001c4 : */    0x19000000,0x00000018,
  2322.  /*
  2323.      MOVE FROM 32, WHEN STATUS
  2324.  
  2325. -at 0x000001be : */    0x1b000000,0x00000020,
  2326. +at 0x000001c6 : */    0x1b000000,0x00000020,
  2327.  /*
  2328.      MOVE FROM 40, WHEN MSG_IN
  2329.  
  2330. -at 0x000001c0 : */    0x1f000000,0x00000028,
  2331. +at 0x000001c8 : */    0x1f000000,0x00000028,
  2332.  /*
  2333.      MOVE SCNTL2 & 0x7f TO SCNTL2
  2334.  
  2335. -at 0x000001c2 : */    0x7c027f00,0x00000000,
  2336. +at 0x000001ca : */    0x7c027f00,0x00000000,
  2337.  /*
  2338.      CLEAR ACK
  2339.  
  2340. -at 0x000001c4 : */    0x60000040,0x00000000,
  2341. +at 0x000001cc : */    0x60000040,0x00000000,
  2342.  /*
  2343.      WAIT DISCONNECT
  2344.  
  2345. -at 0x000001c6 : */    0x48000000,0x00000000,
  2346. +at 0x000001ce : */    0x48000000,0x00000000,
  2347.  /*
  2348.  test_2_fail:
  2349.      INT int_test_2
  2350.  
  2351. -at 0x000001c8 : */    0x98080000,0x04010000,
  2352. +at 0x000001d0 : */    0x98080000,0x04010000,
  2353.  /*
  2354.  
  2355.  ENTRY debug_break
  2356.  debug_break:
  2357.      INT int_debug_break
  2358.  
  2359. -at 0x000001ca : */    0x98080000,0x03000000,
  2360. +at 0x000001d2 : */    0x98080000,0x03000000,
  2361.  /*
  2362.  
  2363.  ;
  2364. @@ -1610,26 +1632,26 @@
  2365.  target_abort:
  2366.      SET TARGET
  2367.  
  2368. -at 0x000001cc : */    0x58000200,0x00000000,
  2369. +at 0x000001d4 : */    0x58000200,0x00000000,
  2370.  /*
  2371.      DISCONNECT
  2372.  
  2373. -at 0x000001ce : */    0x48000000,0x00000000,
  2374. +at 0x000001d6 : */    0x48000000,0x00000000,
  2375.  /*
  2376.      CLEAR TARGET
  2377.  
  2378. -at 0x000001d0 : */    0x60000200,0x00000000,
  2379. +at 0x000001d8 : */    0x60000200,0x00000000,
  2380.  /*
  2381.      JUMP schedule
  2382.  
  2383. -at 0x000001d2 : */    0x80080000,0x00000130,
  2384. +at 0x000001da : */    0x80080000,0x00000130,
  2385.  /*
  2386.      
  2387.  ENTRY initiator_abort
  2388.  initiator_abort:
  2389.      SET ATN
  2390.  
  2391. -at 0x000001d4 : */    0x58000008,0x00000000,
  2392. +at 0x000001dc : */    0x58000008,0x00000000,
  2393.  /*
  2394.  ; In order to abort the currently established nexus, we 
  2395.  ; need to source/sink up to one byte of data in any SCSI phase, 
  2396. @@ -1637,60 +1659,69 @@
  2397.  ; false->true
  2398.      JUMP no_eat_cmd, WHEN NOT CMD
  2399.  
  2400. -at 0x000001d6 : */    0x82030000,0x00000768,
  2401. +at 0x000001de : */    0x82030000,0x00000788,
  2402.  /*
  2403.      MOVE 1, NCR53c7xx_zero, WHEN CMD
  2404.  
  2405. -at 0x000001d8 : */    0x0a000001,((unsigned long)&NCR53c7xx_zero),
  2406. +at 0x000001e0 : */    0x0a000001,0x00000000,
  2407.  /*
  2408.  no_eat_cmd:
  2409.      JUMP no_eat_msg, WHEN NOT MSG_IN
  2410.  
  2411. -at 0x000001da : */    0x87030000,0x00000778,
  2412. +at 0x000001e2 : */    0x87030000,0x00000798,
  2413.  /*
  2414.      MOVE 1, NCR53c7xx_sink, WHEN MSG_IN
  2415.  
  2416. -at 0x000001dc : */    0x0f000001,((unsigned long)&NCR53c7xx_sink),
  2417. +at 0x000001e4 : */    0x0f000001,0x00000000,
  2418.  /*
  2419.  no_eat_msg:
  2420.      JUMP no_eat_data, WHEN NOT DATA_IN
  2421.  
  2422. -at 0x000001de : */    0x81030000,0x00000788,
  2423. +at 0x000001e6 : */    0x81030000,0x000007a8,
  2424.  /*
  2425.      MOVE 1, NCR53c7xx_sink, WHEN DATA_IN
  2426.  
  2427. -at 0x000001e0 : */    0x09000001,((unsigned long)&NCR53c7xx_sink),
  2428. +at 0x000001e8 : */    0x09000001,0x00000000,
  2429.  /*
  2430.  no_eat_data:
  2431.      JUMP no_eat_status, WHEN NOT STATUS
  2432.  
  2433. -at 0x000001e2 : */    0x83030000,0x00000798,
  2434. +at 0x000001ea : */    0x83030000,0x000007b8,
  2435.  /*
  2436.      MOVE 1, NCR53c7xx_sink, WHEN STATUS
  2437.  
  2438. -at 0x000001e4 : */    0x0b000001,((unsigned long)&NCR53c7xx_sink),
  2439. +at 0x000001ec : */    0x0b000001,0x00000000,
  2440.  /*
  2441.  no_eat_status:
  2442.      JUMP no_source_data, WHEN NOT DATA_OUT
  2443.  
  2444. -at 0x000001e6 : */    0x80030000,0x000007a8,
  2445. +at 0x000001ee : */    0x80030000,0x000007c8,
  2446.  /*
  2447.      MOVE 1, NCR53c7xx_zero, WHEN DATA_OUT
  2448.  
  2449. -at 0x000001e8 : */    0x08000001,((unsigned long)&NCR53c7xx_zero),
  2450. +at 0x000001f0 : */    0x08000001,0x00000000,
  2451.  /*
  2452.  no_source_data:
  2453.  ;
  2454.  ; If DSP points here, and a phase mismatch is encountered, we need to 
  2455.  ; do a bus reset.
  2456.  ;
  2457. +    
  2458. +    MOVE SCNTL2 & 0x7f TO SCNTL2
  2459. +
  2460. +at 0x000001f2 : */    0x7c027f00,0x00000000,
  2461. +/*
  2462.      MOVE 1, NCR53c7xx_msg_abort, WHEN MSG_OUT
  2463.  
  2464. -at 0x000001ea : */    0x0e000001,((unsigned long)&NCR53c7xx_msg_abort),
  2465. +at 0x000001f4 : */    0x0e000001,0x00000000,
  2466. +/*
  2467. +    WAIT DISCONNECT
  2468. +
  2469. +at 0x000001f6 : */    0x48000000,0x00000000,
  2470.  /*
  2471.      INT int_norm_aborted
  2472.  
  2473. -at 0x000001ec : */    0x98080000,0x02040000,
  2474. +at 0x000001f8 : */    0x98080000,0x02040000,
  2475.  /*
  2476.  
  2477.  ;
  2478. @@ -1711,77 +1742,101 @@
  2479.  dsa_to_scratch:
  2480.      MOVE DSA0 TO SFBR
  2481.  
  2482. -at 0x000001ee : */    0x72100000,0x00000000,
  2483. +at 0x000001fa : */    0x72100000,0x00000000,
  2484.  /*
  2485.      MOVE SFBR TO SCRATCH0
  2486.  
  2487. -at 0x000001f0 : */    0x6a340000,0x00000000,
  2488. +at 0x000001fc : */    0x6a340000,0x00000000,
  2489.  /*
  2490.      MOVE DSA1 TO SFBR
  2491.  
  2492. -at 0x000001f2 : */    0x72110000,0x00000000,
  2493. +at 0x000001fe : */    0x72110000,0x00000000,
  2494.  /*
  2495.      MOVE SFBR TO SCRATCH1
  2496.  
  2497. -at 0x000001f4 : */    0x6a350000,0x00000000,
  2498. +at 0x00000200 : */    0x6a350000,0x00000000,
  2499.  /*
  2500.      MOVE DSA2 TO SFBR
  2501.  
  2502. -at 0x000001f6 : */    0x72120000,0x00000000,
  2503. +at 0x00000202 : */    0x72120000,0x00000000,
  2504.  /*
  2505.      MOVE SFBR TO SCRATCH2
  2506.  
  2507. -at 0x000001f8 : */    0x6a360000,0x00000000,
  2508. +at 0x00000204 : */    0x6a360000,0x00000000,
  2509.  /*
  2510.      MOVE DSA3 TO SFBR
  2511.  
  2512. -at 0x000001fa : */    0x72130000,0x00000000,
  2513. +at 0x00000206 : */    0x72130000,0x00000000,
  2514.  /*
  2515.      MOVE SFBR TO SCRATCH3
  2516.  
  2517. -at 0x000001fc : */    0x6a370000,0x00000000,
  2518. +at 0x00000208 : */    0x6a370000,0x00000000,
  2519.  /*
  2520.      RETURN
  2521.  
  2522. -at 0x000001fe : */    0x90080000,0x00000000,
  2523. +at 0x0000020a : */    0x90080000,0x00000000,
  2524.  /*
  2525.  
  2526.  scratch_to_dsa:
  2527.      MOVE SCRATCH0 TO SFBR
  2528.  
  2529. -at 0x00000200 : */    0x72340000,0x00000000,
  2530. +at 0x0000020c : */    0x72340000,0x00000000,
  2531.  /*
  2532.      MOVE SFBR TO DSA0
  2533.  
  2534. -at 0x00000202 : */    0x6a100000,0x00000000,
  2535. +at 0x0000020e : */    0x6a100000,0x00000000,
  2536.  /*
  2537.      MOVE SCRATCH1 TO SFBR
  2538.  
  2539. -at 0x00000204 : */    0x72350000,0x00000000,
  2540. +at 0x00000210 : */    0x72350000,0x00000000,
  2541.  /*
  2542.      MOVE SFBR TO DSA1
  2543.  
  2544. -at 0x00000206 : */    0x6a110000,0x00000000,
  2545. +at 0x00000212 : */    0x6a110000,0x00000000,
  2546.  /*
  2547.      MOVE SCRATCH2 TO SFBR
  2548.  
  2549. -at 0x00000208 : */    0x72360000,0x00000000,
  2550. +at 0x00000214 : */    0x72360000,0x00000000,
  2551.  /*
  2552.      MOVE SFBR TO DSA2
  2553.  
  2554. -at 0x0000020a : */    0x6a120000,0x00000000,
  2555. +at 0x00000216 : */    0x6a120000,0x00000000,
  2556.  /*
  2557.      MOVE SCRATCH3 TO SFBR
  2558.  
  2559. -at 0x0000020c : */    0x72370000,0x00000000,
  2560. +at 0x00000218 : */    0x72370000,0x00000000,
  2561.  /*
  2562.      MOVE SFBR TO DSA3
  2563.  
  2564. -at 0x0000020e : */    0x6a130000,0x00000000,
  2565. +at 0x0000021a : */    0x6a130000,0x00000000,
  2566.  /*
  2567.      RETURN
  2568.  
  2569. -at 0x00000210 : */    0x90080000,0x00000000,
  2570. +at 0x0000021c : */    0x90080000,0x00000000,
  2571. +};
  2572. +
  2573. +#define A_NCR53c7xx_msg_abort    0x00000000
  2574. +unsigned long A_NCR53c7xx_msg_abort_used[] = {
  2575. +    0x000001f5,
  2576. +};
  2577. +
  2578. +#define A_NCR53c7xx_msg_reject    0x00000000
  2579. +unsigned long A_NCR53c7xx_msg_reject_used[] = {
  2580. +    0x00000133,
  2581. +};
  2582. +
  2583. +#define A_NCR53c7xx_sink    0x00000000
  2584. +unsigned long A_NCR53c7xx_sink_used[] = {
  2585. +    0x000001e5,
  2586. +    0x000001e9,
  2587. +    0x000001ed,
  2588. +};
  2589. +
  2590. +#define A_NCR53c7xx_zero    0x00000000
  2591. +unsigned long A_NCR53c7xx_zero_used[] = {
  2592. +    0x0000015d,
  2593. +    0x000001e1,
  2594. +    0x000001f1,
  2595.  };
  2596.  
  2597.  #define A_addr_scratch    0x00000000
  2598. @@ -1940,7 +1995,7 @@
  2599.  
  2600.  #define A_int_debug_break    0x03000000
  2601.  unsigned long A_int_debug_break_used[] = {
  2602. -    0x000001cb,
  2603. +    0x000001d3,
  2604.  };
  2605.  
  2606.  #define A_int_debug_dsa_loaded    0x03030000
  2607. @@ -2013,7 +2068,7 @@
  2608.  
  2609.  #define A_int_norm_aborted    0x02040000
  2610.  unsigned long A_int_norm_aborted_used[] = {
  2611. -    0x000001ed,
  2612. +    0x000001f9,
  2613.  };
  2614.  
  2615.  #define A_int_norm_command_complete    0x02020000
  2616. @@ -2038,12 +2093,12 @@
  2617.  
  2618.  #define A_int_test_1    0x04000000
  2619.  unsigned long A_int_test_1_used[] = {
  2620. -    0x000001b1,
  2621. +    0x000001b9,
  2622.  };
  2623.  
  2624.  #define A_int_test_2    0x04010000
  2625.  unsigned long A_int_test_2_used[] = {
  2626. -    0x000001c9,
  2627. +    0x000001d1,
  2628.  };
  2629.  
  2630.  #define A_int_test_3    0x04020000
  2631. @@ -2087,26 +2142,26 @@
  2632.  
  2633.  #define A_test_dest    0x00000000
  2634.  unsigned long A_test_dest_used[] = {
  2635. -    0x000001af,
  2636. +    0x000001b7,
  2637.  };
  2638.  
  2639.  #define A_test_src    0x00000000
  2640.  unsigned long A_test_src_used[] = {
  2641. -    0x000001ae,
  2642. +    0x000001b6,
  2643.  };
  2644.  
  2645.  #define Ent_accept_message    0x000004d8
  2646.  #define Ent_cmdout_cmdout    0x0000022c
  2647.  #define Ent_command_complete    0x00000508
  2648.  #define Ent_command_complete_msgin    0x00000518
  2649. -#define Ent_debug_break    0x00000728
  2650. +#define Ent_debug_break    0x00000748
  2651.  #define Ent_dsa_code_check_reselect    0x00000038
  2652.  #define Ent_dsa_code_template    0x00000000
  2653.  #define Ent_dsa_code_template_end    0x000000b4
  2654.  #define Ent_dsa_jump_resume    0x00000088
  2655.  #define Ent_dsa_schedule    0x000000b4
  2656.  #define Ent_dsa_zero    0x00000090
  2657. -#define Ent_initiator_abort    0x00000750
  2658. +#define Ent_initiator_abort    0x00000770
  2659.  #define Ent_msg_in    0x00000354
  2660.  #define Ent_other_transfer    0x0000031c
  2661.  #define Ent_reject_message    0x000004b8
  2662. @@ -2115,10 +2170,10 @@
  2663.  #define Ent_schedule    0x00000130
  2664.  #define Ent_select    0x00000194
  2665.  #define Ent_select_msgout    0x000001ac
  2666. -#define Ent_target_abort    0x00000730
  2667. -#define Ent_test_1    0x000006b4
  2668. -#define Ent_test_2    0x000006c8
  2669. -#define Ent_test_2_msgout    0x000006e0
  2670. +#define Ent_target_abort    0x00000750
  2671. +#define Ent_test_1    0x000006d4
  2672. +#define Ent_test_2    0x000006e8
  2673. +#define Ent_test_2_msgout    0x00000700
  2674.  unsigned long LABELPATCHES[] = {
  2675.      0x00000002,
  2676.      0x0000000b,
  2677. @@ -2178,18 +2233,21 @@
  2678.      0x0000017a,
  2679.      0x00000191,
  2680.      0x000001a2,
  2681. -    0x000001a4,
  2682. +    0x000001a6,
  2683.      0x000001a8,
  2684.      0x000001ac,
  2685. -    0x000001b5,
  2686. -    0x000001b7,
  2687. -    0x000001d3,
  2688. -    0x000001d7,
  2689. +    0x000001b0,
  2690. +    0x000001b2,
  2691. +    0x000001b4,
  2692. +    0x000001bd,
  2693. +    0x000001bf,
  2694.      0x000001db,
  2695.      0x000001df,
  2696.      0x000001e3,
  2697.      0x000001e7,
  2698. +    0x000001eb,
  2699. +    0x000001ef,
  2700.  };
  2701.  
  2702. -unsigned long INSTRUCTIONS    = 0x000000fe;
  2703. -unsigned long PATCHES    = 0x00000045;
  2704. +unsigned long INSTRUCTIONS    = 0x00000104;
  2705. +unsigned long PATCHES    = 0x00000048;
  2706. diff -u --recursive --new-file v1.2.5/linux/drivers/scsi/53c8xx_u.h linux/drivers/scsi/53c8xx_u.h
  2707. --- v1.2.5/linux/drivers/scsi/53c8xx_u.h    Tue Aug  2 11:29:17 1994
  2708. +++ linux/drivers/scsi/53c8xx_u.h    Mon Apr 17 13:48:24 1995
  2709. @@ -1,3 +1,7 @@
  2710. +#undef A_NCR53c7xx_msg_abort
  2711. +#undef A_NCR53c7xx_msg_reject
  2712. +#undef A_NCR53c7xx_sink
  2713. +#undef A_NCR53c7xx_zero
  2714.  #undef A_addr_scratch
  2715.  #undef A_addr_sfbr
  2716.  #undef A_addr_temp
  2717. diff -u --recursive --new-file v1.2.5/linux/drivers/scsi/ChangeLog linux/drivers/scsi/ChangeLog
  2718. --- v1.2.5/linux/drivers/scsi/ChangeLog    Tue Jan 31 09:39:01 1995
  2719. +++ linux/drivers/scsi/ChangeLog    Fri Apr 21 08:51:27 1995
  2720. @@ -1,3 +1,296 @@
  2721. +Wed Apr 12 15:25:52 1995  Eric Youngdale  (eric@andante)
  2722. +
  2723. +    * Linux 1.2.5 released.
  2724. +
  2725. +    * buslogic.c: Update to version 1.15 (From Dave G, I expect).
  2726. +    Fixed interrupt routine to avoid races when handling multiple
  2727. +    complete commands per interrupt.  Seems to come up with faster
  2728. +    cards.
  2729. +
  2730. +    * eata_dma.c: Modularize.  Update to 2.3.5r.
  2731. +
  2732. +    * scsi.c: If we get a FMK, EOM, or ILI when attempting to scan
  2733. +    the bus, assume that it was just noise on the bus, and ignore
  2734. +    the device.
  2735. +
  2736. +    * scsi.h: Update and add a bunch of missing commands which we
  2737. +    were never using.
  2738. +
  2739. +    * sd.c: Use restore_flags in do_sd_request - this may result in
  2740. +    latency conditions, but it gets rid of races and crashes.
  2741. +    Do not save flags again when searching for a second command to
  2742. +    queue.
  2743. +
  2744. +    * st.c: Use bytes, not STP->buffer->buffer_size when reading
  2745. +    from tape.
  2746. +
  2747. +
  2748. +Tue Apr  4 09:42:08 1995  Eric Youngdale  (eric@andante)
  2749. +
  2750. +    * Linux 1.2.4 released.
  2751. +
  2752. +    * st.c: Fix typo - restoring wrong flags.
  2753. +
  2754. +Wed Mar 29 06:55:12 1995  Eric Youngdale  (eric@andante)
  2755. +
  2756. +    * Linux 1.2.3 released.
  2757. +
  2758. +    * st.c: Perform some waiting operations with interrupts off.
  2759. +    Is this correct???
  2760. +
  2761. +Wed Mar 22 10:34:26 1995  Eric Youngdale  (eric@andante)
  2762. +
  2763. +    * Linux 1.2.2 released.
  2764. +
  2765. +    * aha152x.c: Modularize.  Add support for PCMCIA.
  2766. +
  2767. +    * eata.c: Update to version 2.0.  Fixed bug preventing media
  2768. +    detection.  If scsi_register_host returns NULL, fail gracefully.
  2769. +
  2770. +    * scsi.c: Detect as NEC (for photo-cd purposes) for the 84
  2771. +    and 25 models as "NEC_OLDCDR".
  2772. +
  2773. +    * scsi.h: Add define for NEC_OLDCDR
  2774. +
  2775. +    * sr.c: Add handling for NEC_OLDCDR.  Treat as unknown.
  2776. +
  2777. +    * u14-34f.c: Update to version 2.0.  Fixed same bug as in
  2778. +    eata.c.
  2779. +
  2780. +
  2781. +Mon Mar  6 11:11:20 1995  Eric Youngdale  (eric@andante)
  2782. +
  2783. +    * Linux 1.2.0 released.  Yeah!!!
  2784. +
  2785. +    * Minor spelling/punctuation changes throughout.  Nothing
  2786. +    substantive.
  2787. +
  2788. +Mon Feb 20 21:33:03 1995  Eric Youngdale  (eric@andante)
  2789. +
  2790. +    * Linux 1.1.95 released.
  2791. +
  2792. +    * qlogic.c: Update to version 0.41.
  2793. +
  2794. +    * seagate.c: Change some message to be more descriptive about what
  2795. +    we detected.
  2796. +
  2797. +    * sr.c: spelling/whitespace changes.
  2798. +
  2799. +Mon Feb 20 21:33:03 1995  Eric Youngdale  (eric@andante)
  2800. +
  2801. +    * Linux 1.1.94 released.
  2802. +
  2803. +Mon Feb 20 08:57:17 1995  Eric Youngdale  (eric@andante)
  2804. +
  2805. +    * Linux 1.1.93 released.
  2806. +
  2807. +    * hosts.h: Change io_port to long int from short.
  2808. +
  2809. +    * 53c7,8xx.c: crash on AEN fixed, SCSI reset is no longer a NOP,
  2810. +      NULL pointer panic on odd UDCs fixed, two bugs in diagnostic output 
  2811. +      fixed, should initialize correctly if left running, now loadable, 
  2812. +       new memory allocation, extraneous diagnostic output supressed,
  2813. +      splx() replaced with save/restore flags. [ Drew ]
  2814. +
  2815. +    * hosts.c, hosts.h, scsi_ioctl.c, sd.c, sd_ioctl.c, sg.c, sr.c,
  2816. +    sr_ioctl.c: Add special junk at end that Emacs will use for
  2817. +    formatting the file.
  2818. +
  2819. +    * qlogic.c: Update to v0.40a.  Improve parity handling.
  2820. +
  2821. +    * scsi.c: Add Hitachi DK312C to blacklist.  Change "};" to "}" in
  2822. +    many places.  Use scsi_init_malloc to get command block - may
  2823. +    need this to be dma compatible for some host adapters.
  2824. +    Restore interrupts after unregistering a host.
  2825. +
  2826. +    * sd.c: Use sti instead of restore flags - causes latency problems.
  2827. +
  2828. +    * seagate.c: Use controller_type to determine string used when
  2829. +    registering irq.
  2830. +
  2831. +    * sr.c: More photo-cd hacks to make sure we get the xa stuff right.
  2832. +    * sr.h, sr.c: Change is_xa to xa_flags field.
  2833. +
  2834. +    * st.c: Diable retries for write operations.
  2835. +
  2836. +Wed Feb 15 10:52:56 1995  Eric Youngdale  (eric@andante)
  2837. +
  2838. +    * Linux 1.1.92 released.
  2839. +
  2840. +    * eata.c: Update to 1.17.
  2841. +
  2842. +    * eata_dma.c: Add more support for /proc/scsi, add HBA_interpret flag.
  2843. +
  2844. +    * hosts.c: If we remove last host registered, reuse host number.
  2845. +    When freeing memory from host being deregistered, free extra_bytes
  2846. +    too.
  2847. +
  2848. +    * scsi.c (scan_scsis): memset(SDpnt, 0) and set SCmd.device to SDpnt.
  2849. +    Change memory allocation to work around bugs in __get_dma_pages.
  2850. +    Do not free host if usage count is not zero (for modules).
  2851. +
  2852. +    * sr_ioctl.c: Increase IOCTL_TIMEOUT to 3000.
  2853. +
  2854. +    * st.c: Allow for ST_EXTRA_DEVS in st data structures.
  2855. +
  2856. +    * u14-34f.c: Update to 1.17.
  2857. +
  2858. +Thu Feb  9 10:11:16 1995  Eric Youngdale  (eric@andante)
  2859. +
  2860. +    * Linux 1.1.91 released.
  2861. +
  2862. +    * eata.c: Update to 1.16.  Use wish_block instead of host->block.
  2863. +
  2864. +    * hosts.c: Initialize wish_block to 0.
  2865. +
  2866. +    * hosts.h: Add wish_block.
  2867. +
  2868. +    * scsi.c: Use wish_block as indicator that the host should be added
  2869. +    to block list.
  2870. +
  2871. +    * sg.c: Add SG_EXTRA_DEVS to number of slots.
  2872. +
  2873. +    * u14-34f.c: Use wish_block.
  2874. +
  2875. +Tue Feb  7 11:46:04 1995  Eric Youngdale  (eric@andante)
  2876. +
  2877. +    * Linux 1.1.90 released.
  2878. +
  2879. +    * eata.c: Change naming from eata_* to eata2x_*.  Now at vers 1.15.
  2880. +    Update interrupt handler to take pt_regs as arg.  Allow blocking
  2881. +    even if loaded as module.  Initialize target_time_out array.
  2882. +    Do not put sti(); in timing loop.
  2883. +
  2884. +    * hosts.c: Do not reuse host numbers.
  2885. +    Use scsi_make_blocked_list to generate blocking list.
  2886. +
  2887. +    * script_asm.pl:  Beats me.  Don't know perl.  Something to do with
  2888. +    phase index.
  2889. +
  2890. +    * scsi.c (scsi_make_blocked_list): New function - code copied from
  2891. +    hosts.c.
  2892. +
  2893. +    * scsi.c: Update code to disable photo CD for Toshiba cdroms.
  2894. +    Use just manufacturer name, not model number.
  2895. +
  2896. +    * sr.c: Fix setting density for Toshiba drives.
  2897. +
  2898. +    * u14-34f.c: Clear target_time_out array during reset.
  2899. +
  2900. +Wed Feb  1 09:20:45 1995  Eric Youngdale  (eric@andante)
  2901. +
  2902. +    * Linux 1.1.89 released.
  2903. +
  2904. +    * Makefile, u14-34f.c: Modulariz.e
  2905. +
  2906. +    * Makefile, eata.c: Modularize.  Now version 1.14
  2907. +
  2908. +    * NCR5380.c: Update interrupt handler with new arglist.  Minor
  2909. +    cleanups.
  2910. +
  2911. +    * eata_dma.c: Modularize.  Add hooks for /proc/scsi.  
  2912. +    New version 2.3.0a.
  2913. +    
  2914. +    * hosts.c: Initialize ->dma_channel and ->io_port when registering
  2915. +    a new host.
  2916. +
  2917. +    * qlogic.c: Modularize and add PCMCIA support.
  2918. +
  2919. +    * scsi.c: Add Hitachi to blacklist.
  2920. +
  2921. +    * scsi.c: Change default to no lun scan (too many problem devices).
  2922. +
  2923. +    * scsi.h: Define QUEUE_FULL condition.
  2924. +
  2925. +    * sd.c: Do not check for non-existant partition until after
  2926. +    new media check.
  2927. +
  2928. +    * sg.c: Undo previous change which was wrong.
  2929. +
  2930. +    * sr_ioctl.c: Increase IOCTL_TIMEOUT to 2000.
  2931. +
  2932. +    * st.c: Patches from Kai - improve filemark handling.
  2933. +
  2934. +Tue Jan 31 17:32:12 1995  Eric Youngdale  (eric@andante)
  2935. +
  2936. +    * Linux 1.1.88 released.
  2937. +
  2938. +    * Throughout - spelling/grammar fixups.
  2939. +
  2940. +    * scsi.c: Make sure that all buffers are 16 byte aligned - some
  2941. +    drivers (buslogic) need this.
  2942. +
  2943. +    * scsi.c (scan_scsis): Remove message printed.
  2944. +
  2945. +    * scsi.c (scsi_init): Move message here.
  2946. +
  2947. +Mon Jan 30 06:40:25 1995  Eric Youngdale  (eric@andante)
  2948. +
  2949. +    * Linux 1.1.87 released.
  2950. +
  2951. +    * sr.c: Photo-cd related changes. (Gerd Knorr??).
  2952. +
  2953. +    * st.c: Changes from Kai related to EOM detection.
  2954. +
  2955. +Mon Jan 23 23:53:10 1995  Eric Youngdale  (eric@andante)
  2956. +
  2957. +    * Linux 1.1.86 released.
  2958. +
  2959. +    * 53c7,8xx.h: Change SG size to 127.
  2960. +
  2961. +    * eata_dma: Update to version 0i.
  2962. +
  2963. +    * scsi.c: Test for Toshiba XM-3401TA and exclude from detection
  2964. +    as toshiba drive - photo cd does not work with this drive.
  2965. +
  2966. +    * sr.c:  Update photocd code.
  2967. +
  2968. +Mon Jan 23 23:53:10 1995  Eric Youngdale  (eric@andante)
  2969. +
  2970. +    * Linux 1.1.85 released.
  2971. +
  2972. +    * st.c, st_ioctl.c, sg.c, sd_ioctl.c, scsi_ioctl.c, hosts.c:
  2973. +    include linux/mm.h
  2974. +
  2975. +    * qlogic.c, buslogic.c, aha1542.c: Include linux/module.h.
  2976. +
  2977. +Sun Jan 22 22:08:46 1995  Eric Youngdale  (eric@andante)
  2978. +
  2979. +    * Linux 1.1.84 released.
  2980. +
  2981. +    * Makefile: Support for loadable QLOGIC boards.
  2982. +
  2983. +    * aha152x.c: Update to version 1.8 from Juergen.
  2984. +
  2985. +    * eata_dma.c: Update from Michael Neuffer
  2986. +
  2987. +    * in2000.c: Fix biosparam to support large disks.
  2988. +
  2989. +    * qlogic.c: Minor changes (change sti -> restore_flags).
  2990. +
  2991. +Wed Jan 18 23:33:09 1995  Eric Youngdale  (eric@andante)
  2992. +
  2993. +    * Linux 1.1.83 released.
  2994. +
  2995. +    * aha1542.c(aha1542_intr_handle): Use arguments handed down to find
  2996. +    which irq.
  2997. +
  2998. +    * buslogic.c: Likewise.
  2999. +
  3000. +    * eata_dma.c: Use min of 2 cmd_per_lun for OCS_enabled boards.
  3001. +
  3002. +    * scsi.c: Make RECOVERED_ERROR a SUGGEST_IS_OK.
  3003. +
  3004. +    * sd.c: Fail if we are opening a non-existant partition.
  3005. +
  3006. +    * sr.c: Bump SR_TIMEOUT to 15000.
  3007. +    Do not probe for media size at boot time(hard on changers).
  3008. +    Flag device as needing sector size instead.
  3009. +
  3010. +    * sr_ioctl.c: Remove CDROMMULTISESSION_SYS ioctl.
  3011. +
  3012. +    * ultrastor.c: Fix bug in call to ultrastor_interrupt (wrong #args).
  3013. +
  3014.  Mon Jan 16 07:18:23 1995  Eric Youngdale  (eric@andante)
  3015.  
  3016.      * Linux 1.1.82 released.
  3017. diff -u --recursive --new-file v1.2.5/linux/drivers/scsi/Makefile linux/drivers/scsi/Makefile
  3018. --- v1.2.5/linux/drivers/scsi/Makefile    Fri Apr 14 12:02:42 1995
  3019. +++ linux/drivers/scsi/Makefile    Mon Apr 17 13:53:22 1995
  3020. @@ -127,6 +127,8 @@
  3021.  ifdef CONFIG_SCSI_NCR53C7xx
  3022.  SCSI_OBJS := $(SCSI_OBJS) 53c7,8xx.o 
  3023.  SCSI_SRCS := $(SCSI_SRCS) 53c7,8xx.c
  3024. +else
  3025. +SCSI_MODULE_OBJS := $(SCSI_MODULE_OBJS) 53c7,8xx.o
  3026.  endif
  3027.  
  3028.  ifdef CONFIG_SCSI_PAS16
  3029. @@ -190,7 +192,7 @@
  3030.  
  3031.  53c8xx_d.h 53c8xx_u.h : 53c7,8xx.scr script_asm.pl
  3032.      ln 53c7,8xx.scr fake.c
  3033. -    $(CPP) -DCHIP=810 fake.c | grep -v ^# | perl script_asm.pl 
  3034. +    $(CPP) -traditional -DCHIP=810 fake.c | grep -v '^#' | perl script_asm.pl 
  3035.      mv script.h 53c8xx_d.h
  3036.      mv scriptu.h 53c8xx_u.h
  3037.      rm fake.c
  3038. diff -u --recursive --new-file v1.2.5/linux/drivers/scsi/buslogic.c linux/drivers/scsi/buslogic.c
  3039. --- v1.2.5/linux/drivers/scsi/buslogic.c    Fri Apr 14 12:02:42 1995
  3040. +++ linux/drivers/scsi/buslogic.c    Sun Apr 23 19:18:13 1995
  3041. @@ -469,10 +469,7 @@
  3042.      interrupt_flags = inb(INTERRUPT(base));
  3043.  
  3044.      if (!(interrupt_flags & INTV))
  3045. -      {
  3046. -    buslogic_printk("interrupt received, but INTV not set\n");
  3047. -    return;
  3048. -      }
  3049. +      buslogic_printk("interrupt received, but INTV not set\n");
  3050.  
  3051.      /*
  3052.        Reset the Host Adapter Interrupt Register.  It appears to be
  3053. @@ -504,16 +501,27 @@
  3054.      while (mb[mbi].status != MBX_NOT_IN_USE && found < BUSLOGIC_MAILBOXES)
  3055.        {
  3056.      int mbo = (struct ccb *)mb[mbi].ccbptr - ccb;
  3057. -    int result = 0;
  3058.  
  3059. -    saved_mbo[found++] = mbo;
  3060. +    sctmp = HOSTDATA(shpnt)->sc[mbo];
  3061. +
  3062. +    /*
  3063. +      If sctmp has become NULL, higher level code must have aborted
  3064. +      this operation and called the necessary completion routine.
  3065. +    */
  3066. +
  3067. +    if (sctmp != NULL && mb[mbi].status != MBX_COMPLETION_NOT_FOUND)
  3068. +      {
  3069. +        int result = 0;
  3070. +
  3071. +        saved_mbo[found++] = mbo;
  3072.  
  3073. -    if (mb[mbi].status != MBX_COMPLETION_OK)
  3074. -      result = makecode(ccb[mbo].hastat, ccb[mbo].tarstat);
  3075. +        if (mb[mbi].status != MBX_COMPLETION_OK)
  3076. +          result = makecode(ccb[mbo].hastat, ccb[mbo].tarstat);
  3077.  
  3078. -    HOSTDATA(shpnt)->sc[mbo]->result = result;
  3079. +        sctmp->result = result;
  3080.  
  3081. -    mb[mbi].status = MBX_NOT_IN_USE;
  3082. +        mb[mbi].status = MBX_NOT_IN_USE;
  3083. +      }
  3084.  
  3085.      HOSTDATA(shpnt)->last_mbi_used = mbi;
  3086.  
  3087. @@ -535,6 +543,7 @@
  3088.        {
  3089.      int mbo = saved_mbo[i];
  3090.      sctmp = HOSTDATA(shpnt)->sc[mbo];
  3091. +    if (sctmp == NULL) continue;
  3092.      /*
  3093.        First, free any storage allocated for a scatter/gather
  3094.        data segment list.
  3095. @@ -542,14 +551,15 @@
  3096.      if (sctmp->host_scribble)
  3097.        scsi_free(sctmp->host_scribble, BUSLOGIC_SG_MALLOC);
  3098.      /*
  3099. -      Next, call the SCSI command completion handler.
  3100. +      Next, mark the SCSI Command as completed so it may be reused
  3101. +      for another command by buslogic_queuecommand.  This also signals
  3102. +      to buslogic_reset that the command is no longer active.
  3103.      */
  3104. -    sctmp->scsi_done(sctmp);
  3105. +    HOSTDATA(shpnt)->sc[mbo] = NULL;
  3106.      /*
  3107. -      Finally, mark the SCSI Command as completed so it may be reused
  3108. -      for another command by buslogic_queuecommand.
  3109. +      Finally, call the SCSI command completion handler.
  3110.      */
  3111. -    HOSTDATA(shpnt)->sc[mbo] = NULL;
  3112. +    sctmp->scsi_done(sctmp);
  3113.        }
  3114.  }
  3115.  
  3116. @@ -1344,7 +1354,7 @@
  3117.  #if 1
  3118.      static const unsigned char buscmd[] = { CMD_START_SCSI };
  3119.      struct mailbox *mb;
  3120. -    size_t mbi, mbo;
  3121. +    int mbi, mbo, last_mbi;
  3122.      unsigned long flags;
  3123.      unsigned int i;
  3124.  
  3125. @@ -1355,28 +1365,30 @@
  3126.      save_flags(flags);
  3127.      cli();
  3128.      mb = HOSTDATA(scpnt->host)->mb;
  3129. -    mbi = HOSTDATA(scpnt->host)->last_mbi_used + 1;
  3130. +    last_mbi = HOSTDATA(scpnt->host)->last_mbi_used;
  3131. +    mbi = last_mbi + 1;
  3132.      if (mbi >= 2 * BUSLOGIC_MAILBOXES)
  3133.      mbi = BUSLOGIC_MAILBOXES;
  3134.  
  3135.      do {
  3136.      if (mb[mbi].status != MBX_NOT_IN_USE)
  3137.          break;
  3138. +    last_mbi = mbi;
  3139.      mbi++;
  3140.      if (mbi >= 2 * BUSLOGIC_MAILBOXES)
  3141.          mbi = BUSLOGIC_MAILBOXES;
  3142.      } while (mbi != HOSTDATA(scpnt->host)->last_mbi_used);
  3143. -    restore_flags(flags);
  3144.  
  3145.      if (mb[mbi].status != MBX_NOT_IN_USE) {
  3146. -    buslogic_printk("lost interrupt discovered on irq %d"
  3147. +    buslogic_printk("lost interrupt discovered on irq %d, "
  3148.              " - attempting to recover...\n",
  3149.              scpnt->host->irq);
  3150. -    {
  3151. -        buslogic_interrupt(scpnt->host->irq, NULL);
  3152. -        return SCSI_ABORT_SUCCESS;
  3153. -    }
  3154. +    HOSTDATA(scpnt->host)->last_mbi_used = last_mbi;
  3155. +    buslogic_interrupt(scpnt->host->irq, NULL);
  3156. +    restore_flags(flags);
  3157. +    return SCSI_ABORT_SUCCESS;
  3158.      }
  3159. +    restore_flags(flags);
  3160.  
  3161.      /* OK, no lost interrupt.  Try looking to see how many pending commands we
  3162.         think we have. */
  3163. diff -u --recursive --new-file v1.2.5/linux/drivers/scsi/eata_dma.c linux/drivers/scsi/eata_dma.c
  3164. --- v1.2.5/linux/drivers/scsi/eata_dma.c    Fri Apr 14 12:02:42 1995
  3165. +++ linux/drivers/scsi/eata_dma.c    Fri Apr 14 12:01:41 1995
  3166. @@ -710,7 +710,7 @@
  3167.          while (inb((uint) base + HA_RSTATUS) & HA_SDRQ) 
  3168.              inw((uint) base + HA_RDATA);
  3169.              if (warning == TRUE)
  3170. -                printk("Warning: HBA with IO on 0x%p dectected,\n"
  3171. +                printk("Warning: HBA with IO on 0x%p detected,\n"
  3172.                         "         this IO space is already allocated, probably by the IDE driver.\n"
  3173.                         "         This might lead to problems.", base);
  3174.           return (TRUE);
  3175. diff -u --recursive --new-file v1.2.5/linux/fs/nfs/file.c linux/fs/nfs/file.c
  3176. --- v1.2.5/linux/fs/nfs/file.c    Mon Jan 23 10:38:29 1995
  3177. +++ linux/fs/nfs/file.c    Mon Apr 17 13:41:26 1995
  3178. @@ -123,7 +123,7 @@
  3179.          if ((cache[i].inode_num == inode->i_ino)
  3180.              && (cache[i].file_pos <= pos)
  3181.              && (cache[i].file_pos + cache[i].len >= pos + count)
  3182. -            && (abs(jiffies - cache[i].time) <= EXPIRE_CACHE))
  3183. +            && (abs(jiffies - cache[i].time) < EXPIRE_CACHE))
  3184.              break;
  3185.      if (i < READ_CACHE_SIZE) {
  3186.          ++cache[i].in_use;
  3187. diff -u --recursive --new-file v1.2.5/linux/fs/select.c linux/fs/select.c
  3188. --- v1.2.5/linux/fs/select.c    Mon Jan 23 23:04:10 1995
  3189. +++ linux/fs/select.c    Tue Apr 18 08:57:32 1995
  3190. @@ -237,11 +237,10 @@
  3191.      }
  3192.      current->timeout = timeout;
  3193.      i = do_select(n, &in, &out, &ex, &res_in, &res_out, &res_ex);
  3194. -    if (current->timeout > jiffies)
  3195. -        timeout = current->timeout - jiffies;
  3196. -    else
  3197. -        timeout = 0;
  3198. +    timeout = current->timeout - jiffies - 1;
  3199.      current->timeout = 0;
  3200. +    if ((long) timeout < 0)
  3201. +        timeout = 0;
  3202.      if (tvp && !(current->personality & STICKY_TIMEOUTS)) {
  3203.          put_fs_long(timeout/HZ, (unsigned long *) &tvp->tv_sec);
  3204.          timeout %= HZ;
  3205. diff -u --recursive --new-file v1.2.5/linux/include/asm-alpha/byteorder.h linux/include/asm-alpha/byteorder.h
  3206. --- v1.2.5/linux/include/asm-alpha/byteorder.h    Tue Feb 21 09:05:02 1995
  3207. +++ linux/include/asm-alpha/byteorder.h    Mon Apr 17 13:47:56 1995
  3208. @@ -6,6 +6,9 @@
  3209.  #undef htonl
  3210.  #undef htons
  3211.  
  3212. +#define LITTLE_ENDIAN
  3213. +#define LITTLE_ENDIAN_BITFIELD
  3214. +
  3215.  extern unsigned long int    ntohl(unsigned long int);
  3216.  extern unsigned short int    ntohs(unsigned short int);
  3217.  extern unsigned long int    htonl(unsigned long int);
  3218. diff -u --recursive --new-file v1.2.5/linux/include/asm-i386/byteorder.h linux/include/asm-i386/byteorder.h
  3219. --- v1.2.5/linux/include/asm-i386/byteorder.h    Tue Feb 21 09:02:02 1995
  3220. +++ linux/include/asm-i386/byteorder.h    Mon Apr 17 13:47:56 1995
  3221. @@ -6,6 +6,9 @@
  3222.  #undef htonl
  3223.  #undef htons
  3224.  
  3225. +#define LITTLE_ENDIAN 1234
  3226. +#define LITTLE_ENDIAN_BITFIELD
  3227. +
  3228.  extern unsigned long int    ntohl(unsigned long int);
  3229.  extern unsigned short int    ntohs(unsigned short int);
  3230.  extern unsigned long int    htonl(unsigned long int);
  3231. diff -u --recursive --new-file v1.2.5/linux/include/asm-mips/byteorder.h linux/include/asm-mips/byteorder.h
  3232. --- v1.2.5/linux/include/asm-mips/byteorder.h    Sat Jan 14 02:27:06 1995
  3233. +++ linux/include/asm-mips/byteorder.h    Mon Apr 17 13:47:56 1995
  3234. @@ -6,6 +6,16 @@
  3235.  #undef htonl
  3236.  #undef htons
  3237.  
  3238. +#ifdef MIPSEL
  3239. +#define LITTLE_ENDIAN
  3240. +#define LITTLE_ENDIAN_BITFIELD
  3241. +#elif MIPSEB
  3242. +#define BIG_ENDIAN
  3243. +#define BIG_ENDIAN_BITFIELD
  3244. +#else
  3245. +#error "MIPS but neither MIPSEL nor MIPSEB?"
  3246. +#endif
  3247. +
  3248.  extern unsigned long int    ntohl(unsigned long int);
  3249.  extern unsigned short int    ntohs(unsigned short int);
  3250.  extern unsigned long int    htonl(unsigned long int);
  3251. diff -u --recursive --new-file v1.2.5/linux/include/asm-sparc/byteorder.h linux/include/asm-sparc/byteorder.h
  3252. --- v1.2.5/linux/include/asm-sparc/byteorder.h    Thu Feb  2 08:42:35 1995
  3253. +++ linux/include/asm-sparc/byteorder.h    Mon Apr 17 13:47:56 1995
  3254. @@ -6,6 +6,9 @@
  3255.  #undef htonl
  3256.  #undef htons
  3257.  
  3258. +#define BIG_ENDIAN
  3259. +#define BIG_ENDIAN_BITFIELD
  3260. +
  3261.  extern unsigned long int    ntohl(unsigned long int);
  3262.  extern unsigned short int    ntohs(unsigned short int);
  3263.  extern unsigned long int    htonl(unsigned long int);
  3264. diff -u --recursive --new-file v1.2.5/linux/include/linux/bios32.h linux/include/linux/bios32.h
  3265. --- v1.2.5/linux/include/linux/bios32.h    Fri Feb  3 19:28:28 1995
  3266. +++ linux/include/linux/bios32.h    Mon Apr 17 13:48:18 1995
  3267. @@ -48,5 +48,5 @@
  3268.      unsigned char device_fn, unsigned char where, unsigned short value);
  3269.  extern pcibios_write_config_dword (unsigned char bus,
  3270.      unsigned char device_fn, unsigned char where, unsigned long value);
  3271. -
  3272. +extern char *pcibios_strerror (int error);
  3273.  #endif /* ndef BIOS32_H */
  3274. diff -u --recursive --new-file v1.2.5/linux/include/linux/ip.h linux/include/linux/ip.h
  3275. --- v1.2.5/linux/include/linux/ip.h    Mon Feb 20 08:59:52 1995
  3276. +++ linux/include/linux/ip.h    Mon Apr 17 13:47:56 1995
  3277. @@ -16,7 +16,7 @@
  3278.   */
  3279.  #ifndef _LINUX_IP_H
  3280.  #define _LINUX_IP_H
  3281. -
  3282. +#include <asm/byteorder.h>
  3283.  
  3284.  #define IPOPT_END    0
  3285.  #define IPOPT_NOOP    1
  3286. @@ -34,26 +34,14 @@
  3287.      __u8    len;
  3288.      __u8    ptr;
  3289.      union {
  3290. -#if defined(__i386__)
  3291. -    __u8    flags:4,
  3292. -        overflow:4;
  3293. -#elif defined(__mc68000__)
  3294. -    __u8    overflow:4,
  3295. -        flags:4;
  3296. -#elif defined(__MIPSEL__) 
  3297. -    __u8    flags:4,
  3298. -        overflow:4;
  3299. -#elif defined(__MIPSEB__)
  3300. -    __u8    overflow:4,
  3301. -        flags:4;
  3302. -#elif defined(__alpha__)
  3303. +#if defined(LITTLE_ENDIAN_BITFIELD)
  3304.      __u8    flags:4,
  3305.          overflow:4;
  3306. -#elif defined(__sparc__)
  3307. +#elif defined(BIG_ENDIAN_BITFIELD)
  3308.      __u8    overflow:4,
  3309.          flags:4;
  3310.  #else
  3311. -#error    "Adjust this structure to match your CPU"
  3312. +#error    "Please fix <asm/byteorder.h>"
  3313.  #endif                        
  3314.      __u8    full_char;
  3315.      } x;
  3316. @@ -84,26 +72,14 @@
  3317.  
  3318.  
  3319.  struct iphdr {
  3320. -#if defined(__i386__)
  3321. -    __u8    ihl:4,
  3322. -        version:4;
  3323. -#elif defined (__mc68000__)
  3324. -    __u8    version:4,
  3325. -          ihl:4;
  3326. -#elif defined(__MIPSEL__)
  3327. -    __u8    ihl:4,
  3328. -        version:4;
  3329. -#elif defined(__MIPSEB__)
  3330. -    __u8    version:4,
  3331. -          ihl:4;
  3332. -#elif defined(__alpha__)
  3333. +#if defined(LITTLE_ENDIAN_BITFIELD)
  3334.      __u8    ihl:4,
  3335.          version:4;
  3336. -#elif defined (__sparc__)
  3337. +#elif defined (BIG_ENDIAN_BITFIELD)
  3338.      __u8    version:4,
  3339.            ihl:4;
  3340.  #else
  3341. -#error "Adjust this structure to match your CPU"
  3342. +#error    "Please fix <asm/byteorder.h>"
  3343.  #endif
  3344.      __u8    tos;
  3345.      __u16    tot_len;
  3346. diff -u --recursive --new-file v1.2.5/linux/include/linux/tcp.h linux/include/linux/tcp.h
  3347. --- v1.2.5/linux/include/linux/tcp.h    Mon Feb 20 08:59:52 1995
  3348. +++ linux/include/linux/tcp.h    Mon Apr 17 13:47:56 1995
  3349. @@ -26,7 +26,7 @@
  3350.      __u16    dest;
  3351.      __u32    seq;
  3352.      __u32    ack_seq;
  3353. -#if defined(__i386__)
  3354. +#if defined(LITTLE_ENDIAN_BITFIELD)
  3355.      __u16    res1:4,
  3356.          doff:4,
  3357.          fin:1,
  3358. @@ -36,47 +36,7 @@
  3359.          ack:1,
  3360.          urg:1,
  3361.          res2:2;
  3362. -#elif defined(__mc68000__)
  3363. -    __u16    res2:2,
  3364. -        urg:1,
  3365. -        ack:1,
  3366. -        psh:1,
  3367. -        rst:1,
  3368. -        syn:1,
  3369. -        fin:1,
  3370. -        doff:4,
  3371. -        res1:4;
  3372. -#elif defined(__MIPSEL__)
  3373. -    __u16    res1:4,
  3374. -        doff:4,
  3375. -        fin:1,
  3376. -        syn:1,
  3377. -        rst:1,
  3378. -        psh:1,
  3379. -        ack:1,
  3380. -        urg:1,
  3381. -        res2:2;
  3382. -#elif defined(__MIPSEB__)
  3383. -    __u16    res2:2,
  3384. -        urg:1,
  3385. -        ack:1,
  3386. -        psh:1,
  3387. -        rst:1,
  3388. -        syn:1,
  3389. -        fin:1,
  3390. -        doff:4,
  3391. -        res1:4;
  3392. -#elif defined(__alpha__)
  3393. -    __u16    res1:4,
  3394. -        doff:4,
  3395. -        fin:1,
  3396. -        syn:1,
  3397. -        rst:1,
  3398. -        psh:1,
  3399. -        ack:1,
  3400. -        urg:1,
  3401. -        res2:2;
  3402. -#elif defined(__sparc__)
  3403. +#elif defined(BIG_ENDIAN_BITFIELD)
  3404.      __u16    res2:2,
  3405.          urg:1,
  3406.          ack:1,
  3407. @@ -87,7 +47,7 @@
  3408.          doff:4,
  3409.          res1:4;
  3410.  #else
  3411. -#error    "Adjust this structure for your cpu alignment rules"
  3412. +#error    "Adjust your <asm/byteorder.h> defines"
  3413.  #endif    
  3414.      __u16    window;
  3415.      __u16    check;
  3416. diff -u --recursive --new-file v1.2.5/linux/kernel/ksyms.c linux/kernel/ksyms.c
  3417. --- v1.2.5/linux/kernel/ksyms.c    Fri Apr 14 12:02:43 1995
  3418. +++ linux/kernel/ksyms.c    Mon Apr 17 13:48:23 1995
  3419. @@ -34,9 +34,10 @@
  3420.  #include <linux/delay.h>
  3421.  #include <linux/config.h>
  3422.  
  3423. -#ifdef CONFIG_INET
  3424. +#ifdef CONFIG_NET
  3425.  #include <linux/net.h>
  3426.  #include <linux/netdevice.h>
  3427. +#ifdef CONFIG_INET
  3428.  #include <linux/ip.h>
  3429.  #include <linux/tcp.h>
  3430.  #include "../net/inet/protocol.h"
  3431. @@ -45,6 +46,7 @@
  3432.  #include "../drivers/net/slhc.h"
  3433.  #endif
  3434.  #endif
  3435. +#endif
  3436.  #ifdef CONFIG_PCI
  3437.  #include <linux/pci.h>
  3438.  #endif
  3439. @@ -105,6 +107,7 @@
  3440.      X(pcibios_read_config_byte),
  3441.      X(pcibios_read_config_word),
  3442.      X(pcibios_read_config_dword),
  3443. +        X(pcibios_strerror),
  3444.      X(pcibios_write_config_byte),
  3445.      X(pcibios_write_config_word),
  3446.      X(pcibios_write_config_dword),
  3447. @@ -277,6 +280,7 @@
  3448.      X(inet_add_protocol),
  3449.      X(inet_del_protocol),
  3450.  #if defined(CONFIG_PPP) || defined(CONFIG_SLIP)
  3451. +        /* VJ header compression */
  3452.      X(slhc_init),
  3453.      X(slhc_free),
  3454.      X(slhc_remember),
  3455. @@ -321,6 +325,11 @@
  3456.  #endif
  3457.  #ifdef CONFIG_SCSI
  3458.      /* Supports loadable scsi drivers */
  3459. +        /* 
  3460. +      * in_scan_scsis is a hack, and should go away once the new 
  3461. +     * memory allocation code is in the NCR driver 
  3462. +     */
  3463. +        X(in_scan_scsis),
  3464.      X(scsi_register_module),
  3465.      X(scsi_unregister_module),
  3466.      X(scsi_free),
  3467. @@ -331,6 +340,8 @@
  3468.          X(scsi_init_malloc),
  3469.          X(scsi_init_free),
  3470.      X(print_command),
  3471. +        X(print_msg),
  3472. +    X(print_status),
  3473.  #endif
  3474.      /* Added to make file system as module */
  3475.      X(set_writetime),
  3476. diff -u --recursive --new-file v1.2.5/linux/mm/swap.c linux/mm/swap.c
  3477. --- v1.2.5/linux/mm/swap.c    Sun Apr  9 11:59:57 1995
  3478. +++ linux/mm/swap.c    Fri Apr 21 13:41:36 1995
  3479. @@ -523,7 +523,7 @@
  3480.      int loop, counter;
  3481.      struct task_struct *p;
  3482.  
  3483. -    counter = 2*nr_tasks >> priority;
  3484. +    counter = 6*nr_tasks >> priority;
  3485.      for(; counter >= 0; counter--) {
  3486.          /*
  3487.           * Check that swap_task is suitable for swapping.  If not, look for
  3488. @@ -605,7 +605,7 @@
  3489.              if (swap_out(i))
  3490.                  return 1;
  3491.              state = 0;
  3492. -        } while(--i);
  3493. +        } while(i--);
  3494.      }
  3495.      return 0;
  3496.  }
  3497.