home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / kernel-s / v1.1 / slackwar.001 < prev    next >
Text File  |  1995-10-10  |  241KB  |  7,831 lines

  1. diff -u --recursive --new-file linux-1.1.58/ANNOUNCE.eata linux/ANNOUNCE.eata
  2. --- linux-1.1.58/ANNOUNCE.eata    Wed Dec 31 18:00:00 1969
  3. +++ linux/ANNOUNCE.eata    Wed Oct 26 23:01:49 1994
  4. @@ -0,0 +1,39 @@
  5. +This is the announcement for the EATA SCSI driver
  6. +
  7. +The driver supports all EATA-DMA Protocol compliant SCSI 
  8. +ISA and EISA controllers (PCI rsn.)
  9. +
  10. +Those are for example:
  11. +        DPT Smartcache    : PM2011 (ISA), PM2012A (EISA), 
  12. +                            PM2012B (EISA) 
  13. +            Smartcache III: PM2021 (ISA), PM2022 (EISA), 
  14. +                            PM2122 (EISA), PM2322 (EISA)
  15. +        controllers from NEC and AT&T.
  16. +
  17. +The driver has been tested on the PM2011, PM2021 and PM2022 
  18. +
  19. +I call it still ALPHA software but the driver is pretty stable
  20. +and has been used for some months now. There are just some  
  21. +features missing (PCI/multiple HAs) which I want to implement
  22. +in the next time.
  23. +
  24. +The installation is basically a plug and play installation.
  25. +Just "cd" to your linux directory and extract the files from the 
  26. +TAR archive. Then you will find the diffile eata_patch.
  27. +Apply that with  "patch -p1 <patch.eata" against your linux source 
  28. +tree. The diffs were made against Linux 1.1.51
  29. +
  30. +The (hopefully) only problem that might appear is that you have
  31. +to configure the disk geometry of your first two drives. This 
  32. +problem only appears for people who were already able to use
  33. +their controller under Linux in IDE emulation mode and are sharing
  34. +the drives with DOS or some other OS that operates the controller
  35. +in IDE emulation mode (ie. doesn't use a SCSI driver).
  36. +
  37. +If you've got problems, questions or whatever, send me a mail 
  38. +
  39. +neuffer@goofy.zdv.uni-mainz.de
  40. +Michael_Neuffer@wi2.maus.de (Mails<16KB & <48KB per day)
  41. +
  42. +
  43. +Mike
  44. diff -u --recursive --new-file linux-1.1.58/README-Slackware linux/README-Slackware
  45. --- linux-1.1.58/README-Slackware    Wed Dec 31 18:00:00 1969
  46. +++ linux/README-Slackware    Wed Oct 26 23:01:49 1994
  47. @@ -0,0 +1,14 @@
  48. +The following changes were made to this kernel:
  49. +
  50. +Added nec260-0_3 patches (NEC CD-ROM on the IDE interface)
  51. +Added sony535-0.6 patches (Sony 531/535 CD-ROM drives)
  52. +Added dpt_EATA_0.3a patches (EATA compliant ISA and EISA SCSI)
  53. +Added Adaptec 274x SCSI patches.
  54. +Added Always in2000 patches.
  55. +
  56. +NOTE: IN2000 and Adaptec 1742 drivers should not be compiled into the same
  57. +kernel.  Do not compile the NEC CD-ROM driver into your kernel unless you
  58. +have an NEC CD-ROM driver attached as the slave device on your IDE controller.
  59. +I have no idea what it does if it finds a hard drive there...
  60. +
  61. +Pat
  62. diff -u --recursive --new-file linux-1.1.58/arch/i386/config.in linux/arch/i386/config.in
  63. --- linux-1.1.58/arch/i386/config.in    Mon Oct 24 17:43:29 1994
  64. +++ linux/arch/i386/config.in    Wed Oct 26 23:05:33 1994
  65. @@ -11,8 +11,9 @@
  66.  bool 'Networking support' CONFIG_NET y
  67.  bool 'Limit memory to low 16MB' CONFIG_MAX_16M n
  68.  bool 'System V IPC' CONFIG_SYSVIPC y
  69. -bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF y
  70.  bool 'Use -m486 flag for 486-specific optimizations' CONFIG_M486 y
  71. +bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF y
  72. +bool 'Do you wish to be offered ALPHA drivers added by Slackware?' ALPHA_SLACK y
  73.  
  74.  if [ "$CONFIG_NET" = "y" ]; then
  75.  comment 'Networking options'
  76. @@ -51,11 +52,15 @@
  77.  bool 'Adaptec AHA152X support' CONFIG_SCSI_AHA152X n
  78.  bool 'Adaptec AHA1542 support' CONFIG_SCSI_AHA1542 y
  79.  bool 'Adaptec AHA1740 support' CONFIG_SCSI_AHA1740 n
  80. +if [ "$ALPHA_SLACK" = "y" ]; then
  81. +  bool 'Adaptec AHA274X/284X support' CONFIG_SCSI_AHA274X y
  82. +  bool 'Always IN2000 SCSI support' CONFIG_SCSI_IN2000 n
  83. +  bool 'EATA-DMA (rev. 2.0b) (DPT,NEC,AT&T) support' CONFIG_SCSI_EATA n
  84. +fi
  85.  bool 'BusLogic SCSI support' CONFIG_SCSI_BUSLOGIC n
  86.  bool 'Future Domain 16xx SCSI support' CONFIG_SCSI_FUTURE_DOMAIN n
  87.  bool 'Generic NCR5380 SCSI support' CONFIG_SCSI_GENERIC_NCR5380 n
  88.  bool 'NCR53c7,8xx SCSI support'  CONFIG_SCSI_NCR53C7xx n
  89. -#bool 'Always IN2000 SCSI support' CONFIG_SCSI_IN2000 n
  90.  bool 'PAS16 SCSI support' CONFIG_SCSI_PAS16 n
  91.  bool 'Seagate ST-02 and Future Domain TMC-8xx SCSI support' CONFIG_SCSI_SEAGATE n
  92.  bool 'Trantor T128/T128F/T228 SCSI support' CONFIG_SCSI_T128 n
  93. @@ -133,6 +138,10 @@
  94.  comment 'CD-ROM drivers'
  95.  
  96.  bool 'Sony CDU31A/CDU33A CDROM driver support' CONFIG_CDU31A n
  97. +if [ "$ALPHA_SLACK" = "y" ]; then
  98. +  bool 'Sony CDU535 CDROM driver support' CONFIG_CDU535 n
  99. +  bool 'NEC CDR-260 CDROM driver support' CONFIG_NEC260 n
  100. +fi
  101.  bool 'Mitsumi CDROM driver support' CONFIG_MCD n
  102.  bool 'Matsushita/Panasonic CDROM driver support' CONFIG_SBPCD n
  103.  if [ "$CONFIG_SBPCD" = "y" ]; then
  104. diff -u --recursive --new-file linux-1.1.58/config.in linux/config.in
  105. --- linux-1.1.58/config.in    Sat Sep 17 21:48:10 1994
  106. +++ linux/config.in    Wed Oct 26 23:05:42 1994
  107. @@ -12,6 +12,8 @@
  108.  bool 'Limit memory to low 16MB' CONFIG_MAX_16M n
  109.  bool 'System V IPC' CONFIG_SYSVIPC y
  110.  bool 'Use -m486 flag for 486-specific optimizations' CONFIG_M486 y
  111. +bool 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF y
  112. +bool 'Do you wish to be offered ALPHA drivers added by Slackware?' ALPHA_SLACK y
  113.  
  114.  if [ "$CONFIG_NET" = "y" ]; then
  115.  comment 'Networking options'
  116. @@ -24,7 +26,7 @@
  117.  bool 'Assume subnets are local' CONFIG_INET_SNARL y
  118.  bool 'Disable NAGLE algorithm (normally enabled)' CONFIG_TCP_NAGLE_OFF n
  119.  fi
  120. -bool 'The IPX protocol' CONFIG_IPX y
  121. +bool 'The IPX protocol' CONFIG_IPX n
  122.  #bool 'Amateur Radio AX.25 Level 2' CONFIG_AX25 n
  123.  fi
  124.  
  125. @@ -50,11 +52,15 @@
  126.  bool 'Adaptec AHA152X support' CONFIG_SCSI_AHA152X n
  127.  bool 'Adaptec AHA1542 support' CONFIG_SCSI_AHA1542 y
  128.  bool 'Adaptec AHA1740 support' CONFIG_SCSI_AHA1740 n
  129. +if [ "$ALPHA_SLACK" = "y" ]; then
  130. +  bool 'Adaptec AHA274X/284X support' CONFIG_SCSI_AHA274X y
  131. +  bool 'Always IN2000 SCSI support' CONFIG_SCSI_IN2000 n
  132. +  bool 'EATA-DMA (rev. 2.0b) (DPT,NEC,AT&T) support' CONFIG_SCSI_EATA n
  133. +fi
  134.  bool 'BusLogic SCSI support' CONFIG_SCSI_BUSLOGIC n
  135.  bool 'Future Domain 16xx SCSI support' CONFIG_SCSI_FUTURE_DOMAIN n
  136.  bool 'Generic NCR5380 SCSI support' CONFIG_SCSI_GENERIC_NCR5380 n
  137.  bool 'NCR53c7,8xx SCSI support'  CONFIG_SCSI_NCR53C7xx n
  138. -#bool 'Always IN2000 SCSI support' CONFIG_SCSI_IN2000 n
  139.  bool 'PAS16 SCSI support' CONFIG_SCSI_PAS16 n
  140.  bool 'Seagate ST-02 and Future Domain TMC-8xx SCSI support' CONFIG_SCSI_SEAGATE n
  141.  bool 'Trantor T128/T128F/T228 SCSI support' CONFIG_SCSI_T128 n
  142. @@ -107,6 +113,8 @@
  143.      if [ "$CONFIG_NET_ALPHA" = "y" ]; then
  144.          bool 'EtherExpress support' CONFIG_EEXPRESS n
  145.          bool 'AT1700 support' CONFIG_AT1700 n
  146. +        bool 'NI5210 support' CONFIG_NI52 n
  147. +        bool 'NI6510 support' CONFIG_NI65 n
  148.      fi
  149.      bool 'HP PCLAN support' CONFIG_HPLAN n
  150.      bool 'NE2000/NE1000 support' CONFIG_NE2000 y
  151. @@ -117,8 +125,6 @@
  152.          bool 'Ansel Communications EISA 3200 support' CONFIG_AC3200 n
  153.      fi
  154.      bool 'Apricot Xen-II on board ethernet' CONFIG_APRICOT n
  155. -#bool 'NI52EE support' CONFIG_NI52 n
  156. -#bool 'NI65EE support' CONFIG_NI65 n
  157.  bool 'Pocket and portable adaptors' CONFIG_NET_POCKET n
  158.  if [ "$CONFIG_NET_POCKET" = "y" ]; then
  159.      bool 'D-Link DE600 pocket adaptor support' CONFIG_DE600 n
  160. @@ -132,6 +138,10 @@
  161.  comment 'CD-ROM drivers'
  162.  
  163.  bool 'Sony CDU31A/CDU33A CDROM driver support' CONFIG_CDU31A n
  164. +if [ "$ALPHA_SLACK" = "y" ]; then
  165. +  bool 'Sony CDU535 CDROM driver support' CONFIG_CDU535 n
  166. +  bool 'NEC CDR-260 CDROM driver support' CONFIG_NEC260 n
  167. +fi
  168.  bool 'Mitsumi CDROM driver support' CONFIG_MCD n
  169.  bool 'Matsushita/Panasonic CDROM driver support' CONFIG_SBPCD n
  170.  if [ "$CONFIG_SBPCD" = "y" ]; then
  171. diff -u --recursive --new-file linux-1.1.58/drivers/block/Makefile linux/drivers/block/Makefile
  172. --- linux-1.1.58/drivers/block/Makefile    Sat Sep 17 21:44:49 1994
  173. +++ linux/drivers/block/Makefile    Wed Oct 26 23:01:59 1994
  174. @@ -64,7 +64,16 @@
  175.  SRCS := $(SRCS) xd.c
  176.  endif
  177.  
  178. -all: block.a
  179. +ifdef CONFIG_CDU535
  180. +OBJS := $(OBJS) sonycd535.o
  181. +SRCS := $(SRCS) sonycd535.c
  182. +endif
  183. +
  184. +ifdef CONFIG_NEC260
  185. +OBJS := $(OBJS) nec260.o
  186. +SRCS := $(SRCS) nec260.c
  187. +CFLAGS := $(CFLAGS) -DLINKED_IN_KERNEL -DNO_IRQACTION
  188. +endif
  189.  
  190.  block.a: $(OBJS)
  191.      rm -f block.a
  192. diff -u --recursive --new-file linux-1.1.58/drivers/block/blk.h linux/drivers/block/blk.h
  193. --- linux-1.1.58/drivers/block/blk.h    Thu Oct 13 21:31:06 1994
  194. +++ linux/drivers/block/blk.h    Wed Oct 26 23:02:00 1994
  195. @@ -40,6 +40,9 @@
  196.  extern unsigned long hd_init(unsigned long mem_start, unsigned long mem_end);
  197.  extern unsigned long cdu31a_init(unsigned long mem_start, unsigned long mem_end);
  198.  extern unsigned long mcd_init(unsigned long mem_start, unsigned long mem_end);
  199. +#ifdef CONFIG_CDU535
  200. +extern unsigned long init_sony535(unsigned long mem_start, unsigned long mem_end);
  201. +#endif
  202.  #ifdef CONFIG_SBPCD
  203.  extern unsigned long sbpcd_init(unsigned long, unsigned long);
  204.  #endif CONFIG_SBPCD
  205. @@ -135,6 +138,14 @@
  206.  
  207.  #define DEVICE_NAME "CDU31A"
  208.  #define DEVICE_REQUEST do_cdu31a_request
  209. +#define DEVICE_NR(device) (MINOR(device))
  210. +#define DEVICE_ON(device)
  211. +#define DEVICE_OFF(device)
  212. +
  213. +#elif (MAJOR_NR == CDU535_CDROM_MAJOR)
  214. +#define DEVICE_NAME "SONY-CDU535"
  215. +#define DEVICE_INTR do_cdu535
  216. +#define DEVICE_REQUEST do_cdu535_request
  217.  #define DEVICE_NR(device) (MINOR(device))
  218.  #define DEVICE_ON(device)
  219.  #define DEVICE_OFF(device)
  220. diff -u --recursive --new-file linux-1.1.58/drivers/block/hd.c linux/drivers/block/hd.c
  221. --- linux-1.1.58/drivers/block/hd.c    Mon Oct 24 17:43:36 1994
  222. +++ linux/drivers/block/hd.c    Wed Oct 26 23:02:00 1994
  223. @@ -43,6 +43,10 @@
  224.  #define MAJOR_NR HD_MAJOR
  225.  #include "blk.h"
  226.  
  227. +#ifdef CONFIG_NEC260
  228. +int the_nec260_major = 0;
  229. +#endif
  230. +
  231.  #define HD_IRQ 14
  232.  
  233.  static int revalidate_hddisk(int, int);
  234. @@ -660,6 +664,9 @@
  235.      reset = 1;
  236.      dev = DEVICE_NR(CURRENT->dev);
  237.      printk("hd%c: timeout\n", dev+'a');
  238. +#ifdef CONFIG_NEC260
  239. +    if (CURRENT->dev < 0) return;
  240. +#endif
  241.      if (++CURRENT->errors >= MAX_ERRORS) {
  242.  #ifdef DEBUG
  243.          printk("hd%c: too many errors\n", dev+'a');
  244. @@ -718,6 +725,14 @@
  245.          return;
  246.  repeat:
  247.      timer_active &= ~(1<<HD_TIMER);
  248. +#ifdef CONFIG_NEC260
  249. +    if (!CURRENT && the_nec260_major > 0 &&
  250. +        blk_dev[the_nec260_major].current_request) {
  251. +      cli ();
  252. +      (blk_dev[the_nec260_major].request_fn) ();
  253. +    }
  254. +    if (CURRENT && CURRENT->dev < 0) return;
  255. +#endif
  256.      sti();
  257.      INIT_REQUEST;
  258.      if (reset) {
  259. diff -u --recursive --new-file linux-1.1.58/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c
  260. --- linux-1.1.58/drivers/block/ll_rw_blk.c    Mon Oct 24 17:43:36 1994
  261. +++ linux/drivers/block/ll_rw_blk.c    Wed Oct 26 23:02:00 1994
  262. @@ -35,6 +35,10 @@
  263.  
  264.  int read_ahead[MAX_BLKDEV] = {0, };
  265.  
  266. +#if defined(CONFIG_CDU535) && defined(CONFIG_CDU31A)
  267. +    int sonycd_save_mem_start;
  268. +#endif
  269. +
  270.  /* blk_dev_struct is:
  271.   *    do_request-address
  272.   *    next-request
  273. @@ -501,15 +505,36 @@
  274.  #ifdef CONFIG_BLK_DEV_XD
  275.      mem_start = xd_init(mem_start,mem_end);
  276.  #endif
  277. +#if defined(CONFIG_CDU535) && defined(CONFIG_CDU31A)
  278. +    {  /* since controllers for 535 and 31A can be at same location
  279. +        * we have to be careful.
  280. +        */
  281. +        sonycd_save_mem_start = mem_start;
  282. +        mem_start = cdu31a_init(mem_start,mem_end);
  283. +        if ( mem_start == sonycd_save_mem_start ) {  /* CDU31A not found */
  284. +            mem_start = init_sony535(mem_start,mem_end);
  285. +        }
  286. +    }
  287. +#else
  288.  #ifdef CONFIG_CDU31A
  289.      mem_start = cdu31a_init(mem_start,mem_end);
  290.  #endif
  291. +#ifdef CONFIG_CDU535
  292. +    mem_start = init_sony535(mem_start,mem_end);
  293. +#endif
  294. +#endif  /* CONFIG_CDU31A && CONFIG_CDU535 */
  295.  #ifdef CONFIG_MCD
  296.      mem_start = mcd_init(mem_start,mem_end);
  297.  #endif
  298.  #ifdef CONFIG_SBPCD
  299.      mem_start = sbpcd_init(mem_start, mem_end);
  300.  #endif CONFIG_SBPCD
  301. +#ifdef CONFIG_NEC260
  302. +        {
  303. +          extern unsigned long nec260_init (unsigned long, unsigned long);
  304. +      mem_start = nec260_init(mem_start, mem_end);
  305. +    }
  306. +#endif
  307.      if (ramdisk_size)
  308.          mem_start += rd_init(mem_start, ramdisk_size*1024);
  309.      return mem_start;
  310. diff -u --recursive --new-file linux-1.1.58/drivers/block/mcd.c linux/drivers/block/mcd.c
  311. --- linux-1.1.58/drivers/block/mcd.c    Sat Sep 17 21:48:13 1994
  312. +++ linux/drivers/block/mcd.c    Wed Oct 26 23:02:00 1994
  313. @@ -1182,7 +1182,6 @@
  314.  
  315.      mcd_invalidate_buffers();
  316.      mcdPresent = 1;
  317. -    printk("\n");
  318.      return mem_start;
  319.  }
  320.  
  321. diff -u --recursive --new-file linux-1.1.58/drivers/block/nec260.c linux/drivers/block/nec260.c
  322. --- linux-1.1.58/drivers/block/nec260.c    Wed Dec 31 18:00:00 1969
  323. +++ linux/drivers/block/nec260.c    Wed Oct 26 23:02:00 1994
  324. @@ -0,0 +1,852 @@
  325. +/*
  326. + * nec260.c - NEC CDR-260 driver
  327. + *  some pieces derived from mcd.c.
  328. + *
  329. + * scott snyder  <snyder@fnald0.fnal.gov>
  330. + *
  331. + *   0.1  May 31, 1994  Initial alpha release.
  332. + *   0.2  Sep  4, 1994  Converted into a loadable kernel module.
  333. + *                      Made more flexible wrt. hardware configurations.
  334. + *                      Sense disk changes properly.
  335. + *   0.3  Sep. 11, 1994 Add LINKED_IN_KERNEL #ifdef's.
  336. + *
  337. + *   Copyright (c) 1994  scott snyder <snyder@fnald0.fnal.gov>
  338. + *
  339. + *   This program is free software; you can redistribute it and/or modify
  340. + *   it under the terms of the GNU General Public License as published by
  341. + *   the Free Software Foundation; either version 2, or (at your option)
  342. + *   any later version.
  343. + *
  344. + *   You should have received a copy of the GNU General Public License
  345. + *   (for example /usr/src/linux/COPYING); if not, write to the Free
  346. + *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  347. + */
  348. +
  349. +#define REALLY_SLOW_IO
  350. +#include <asm/io.h>
  351. +
  352. +#include <linux/string.h>
  353. +#include <linux/sched.h>
  354. +#include <linux/timer.h>
  355. +#include <asm/io.h>
  356. +#include <linux/hdreg.h>
  357. +#include <linux/signal.h>
  358. +#include <linux/autoconf.h>
  359. +
  360. +#ifdef LINKED_IN_KERNEL
  361. +# define MAYBE_STATIC static
  362. +#else
  363. +# include <linux/module.h>
  364. +# define MAYBE_STATIC
  365. +#endif
  366. +
  367. +#include "version.h"
  368. +
  369. +/***************************************************************************/
  370. +
  371. +/* Configuration options which may be set when loading the driver. */
  372. +
  373. +/* Major device number. */
  374. +MAYBE_STATIC int nec260_major = 26;
  375. +
  376. +/* IRQ level used.  Only matters if nec260_no_hd is turned on. */
  377. +MAYBE_STATIC int nec260_irq = 14;
  378. +
  379. +/* Base I/O address for the IDE adapter registers. */
  380. +MAYBE_STATIC int nec260_base = HD_DATA;
  381. +
  382. +/* Set this to 1 if the device is configured as the master on the bus. */
  383. +MAYBE_STATIC int nec260_master = 0;
  384. +/* Set this to 1 if the cdrom drive is on the bus by itself. */
  385. +MAYBE_STATIC int nec260_no_hd = 0;
  386. +
  387. +/***************************************************************************/
  388. +
  389. +#define HD_DATA_OFFSET    (HD_DATA   - HD_DATA)
  390. +#define HD_STATUS_OFFSET  (HD_STATUS - HD_DATA)
  391. +#define HD_ERROR_OFFSET   (HD_ERROR  - HD_DATA)
  392. +#define HD_LCYL_OFFSET    (HD_LCYL   - HD_DATA)
  393. +#define HD_HCYL_OFFSET    (HD_HCYL   - HD_DATA)
  394. +#define HD_CURRENT_OFFSET (HD_CURRENT - HD_DATA)
  395. +#define HD_COMMAND_OFFSET (HD_COMMAND - HD_DATA)
  396. +
  397. +#define MAJOR_NR nec260_major
  398. +#define DEVICE_NAME "NEC IDE CD-ROM"
  399. +#define DEVICE_REQUEST do_nec260_request
  400. +#define DEVICE_NR(device) (MINOR(device))
  401. +#define DEVICE_ON(device)
  402. +#define DEVICE_OFF(device)
  403. +#define DEVICE_INTR do_nec260
  404. +
  405. +#include "blk.h"
  406. +
  407. +/* The call interface for binding interrupts changed in 1.1.43 :-( */
  408. +
  409. +#if (KERNEL_MAJOR >= 1) && \
  410. +    (KERNEL_MINOR >= 1) && \
  411. +    (KERNEL_PATCH >= 43)
  412. +# define NO_IRQACTION
  413. +#endif
  414. +
  415. +/***************************************************************************/
  416. +
  417. +/* special command codes for strategy routine. */
  418. +#define CHECK_STATUS 4314
  419. +
  420. +#define CD_BLOCK_SIZE 2048
  421. +
  422. +static void nec260_timeout (unsigned long x);
  423. +static void do_read_callback (void);
  424. +static void do_read_callback_2 (void);
  425. +static int test_read (unsigned int dev, unsigned int block,
  426. +              unsigned int nsect);
  427. +
  428. +
  429. +/* Values to write to the controller registers to start a transaction. */
  430. +
  431. +static char regimage[7] = {
  432. +  0,                          /* HD_PRECOMP */
  433. +  0,                          /* HD_NSECTOR */
  434. +  0,                          /* HD_SECTOR  */
  435. +  (CD_BLOCK_SIZE & 0xff),     /* HD_LCYL   # of bytes to read  (lo) */
  436. +  (CD_BLOCK_SIZE >> 8),       /* HD_HCYL   # of bytes to read  (hi) */
  437. +  0xf0,                       /* HD_CURRENT   (device select) (slave)     */
  438. +  0xa0                        /* HD_COMMAND                         */
  439. +};
  440. +
  441. +
  442. +/* Image of command to be sent to the device for a read.
  443. +   Portions of this will be overwritten to set the sector number.
  444. +   If i actually had documentation for this device, i could probably
  445. +   give these values some meaningful names... */
  446. +
  447. +static char cmdimage[12] = {0x28, 0, 0, 0, 0x0f, 0x54, 0, 0, 1, 0, 0, 0};
  448. +
  449. +static int nec260_request_in_progress = 0;
  450. +static int nec260_waiting_for_int = 0;
  451. +static int nec260_open_count = 0;
  452. +static int nec260_media_changed = 0;
  453. +static void (**nec260_handler_ptr)(void);
  454. +static int the_hd_major;
  455. +static int retrying = 0;
  456. +
  457. +static struct timer_list nec260_timer = {NULL, NULL, 0, 0, nec260_timeout};
  458. +
  459. +/* The transfer buffer. */
  460. +static char nec260_buf[CD_BLOCK_SIZE];
  461. +static int  nec260_bn = -1;
  462. +
  463. +/* The dummy request which we use to plug up the HD queue. */
  464. +static struct request plug;
  465. +
  466. +/* Symbols from hd.c. */
  467. +extern int the_nec260_major;
  468. +extern void (*do_hd)(void);
  469. +#ifdef CONFIG_BLK_DEV_HD1
  470. +extern void (*do_hd1)(void);
  471. +#endif
  472. +
  473. +
  474. +/***************************************************************************/
  475. +
  476. +/*
  477. + * Wait until the controller is idle.
  478. + * Returns the status field; if it has the bit BUSY_STAT set,
  479. + * we timed out.
  480. + */
  481. +static int controller_busy (void)
  482. +{
  483. +  int retries = 100000;
  484. +  unsigned char status;
  485. +
  486. +  do 
  487. +    {
  488. +      status = inb_p (nec260_base + HD_STATUS_OFFSET);
  489. +    } while ((status & BUSY_STAT) && --retries);
  490. +#ifdef SHY_DEVICE
  491. +  {
  492. +    static doneonce = 0;
  493. +    if (status == 0xff && !doneonce)
  494. +      status = 0;
  495. +    doneonce = 1;
  496. +  }
  497. +#endif
  498. +  return status;
  499. +}
  500. +
  501. +
  502. +/*
  503. + * Wait for the controller to be ready to receive a command.
  504. + * Returns 0 if successful, -1 if we timed out.
  505. + */
  506. +static inline int wait_DRQ (void)
  507. +{
  508. +  int retries = 100000;
  509. +
  510. +  while (--retries > 0)
  511. +    if (inb_p (nec260_base + HD_STATUS_OFFSET) & DRQ_STAT)
  512. +      return 0;
  513. +  return -1;
  514. +}
  515. +
  516. +
  517. +/*
  518. + * Stick a dummy request at the head of the HD request queue
  519. + * to prevent any HD activity while we're using the controller.
  520. + * The HD queue must be empty.
  521. + */
  522. +static void plug_hd (void)
  523. +{
  524. +  if (nec260_no_hd)
  525. +    printk ("nec260: spurious call to plug_hd\n");
  526. +  else
  527. +    { 
  528. +      cli ();  /* safety */
  529. +      if (blk_dev[the_hd_major].current_request != NULL)
  530. +    {
  531. +      printk ("nec260 (plug_hd): hd already active!\n");
  532. +      return;
  533. +    }
  534. +      blk_dev[the_hd_major].current_request = &plug;
  535. +      plug.dev = -1;
  536. +      plug.next = NULL;
  537. +      
  538. +      /* exits with ints clear */
  539. +    }
  540. +}
  541. +
  542. +
  543. +/*
  544. + * Remove the dummy request from the start of the HD queue.
  545. + */
  546. +static void unplug_hd (void)
  547. +{
  548. +  if (nec260_no_hd)
  549. +    printk ("nec260: spurious call to unplug_hd\n");
  550. +  else
  551. +    { 
  552. +      cli ();  /* safety */
  553. +      if (blk_dev[the_hd_major].current_request != &plug) 
  554. +    {
  555. +      printk ("nec260 (unplug_hd): hd not plugged!\n");
  556. +      return;
  557. +    }
  558. +      blk_dev[the_hd_major].current_request = plug.next;
  559. +      (blk_dev[the_hd_major].request_fn) ();
  560. +    }
  561. +}
  562. +
  563. +
  564. +/*
  565. + * Unplug the HD queue and end a idecd request.
  566. + */
  567. +static void end_read_request (int flag)
  568. +{
  569. +  if (! nec260_no_hd)
  570. +    unplug_hd ();
  571. +  end_request (flag);
  572. +  nec260_request_in_progress = 0;
  573. +}
  574. +
  575. +
  576. +/*
  577. + * Transfer as much data as we can from NEC260_BUF to the output buffer.
  578. + */
  579. +static void
  580. +nec260_transfer(void)
  581. +{
  582. +  long offs;
  583. +
  584. +  while (CURRENT -> nr_sectors > 0 && nec260_bn == CURRENT -> sector / 4)
  585. +    {
  586. +      offs = (CURRENT -> sector & 3) * 512;
  587. +      memcpy (CURRENT -> buffer, nec260_buf + offs, 512);
  588. +      CURRENT -> nr_sectors--;
  589. +      CURRENT -> sector++;
  590. +      CURRENT -> buffer += 512;
  591. +    }
  592. +}
  593. +
  594. +
  595. +/*
  596. + * Invalidate any data saved in our internal buffer
  597. + */
  598. +static void
  599. +nec260_invalidate_buffers (void)
  600. +{
  601. +  nec260_bn = -1;
  602. +}
  603. +
  604. +
  605. +/*
  606. + * Complete a read request with status STAT, and call the request routine
  607. + * to start off the next one.
  608. + */
  609. +static void complete_read_request (int stat)
  610. +{
  611. +  del_timer (&nec260_timer);    /* Cancel the timeout */
  612. +  end_read_request (stat);
  613. +  cli ();
  614. +  do_nec260_request ();
  615. +}
  616. +
  617. +
  618. +/*
  619. + * Called when our timer goes off.
  620. + */
  621. +static void nec260_timeout (unsigned long x)
  622. +{
  623. +  /* Ignore if we're not waiting for an interrupt. */
  624. +  if (! nec260_waiting_for_int) return;
  625. +
  626. +  /* Complete the request with error status. */
  627. +  nec260_waiting_for_int = 0;
  628. +  printk ("nec260: request timed out\n");
  629. +  if (*nec260_handler_ptr == do_read_callback ||
  630. +      *nec260_handler_ptr == do_read_callback_2)
  631. +    *nec260_handler_ptr = NULL;
  632. +  else
  633. +    printk ("nec260: funny value for interrupt handler\n");
  634. +  complete_read_request (0);
  635. +}
  636. +
  637. +/*
  638. + * Interrupt routine to swallow the extra interrupt from the device.
  639. + */
  640. +static void do_read_callback_2 (void)
  641. +{
  642. +  int stat;
  643. +
  644. +  *nec260_handler_ptr = NULL;
  645. +
  646. +  if (! nec260_waiting_for_int) 
  647. +    {
  648. +      printk ("nec260 (do_read_callback_2): spurious call?\n");
  649. +      return;
  650. +    }
  651. +
  652. +  nec260_waiting_for_int = 0;
  653. +
  654. +  /* Check error flag and complete the I/O. */
  655. +  stat = inb (nec260_base + HD_ERROR_OFFSET);
  656. +  stat = ((stat & ERR_STAT) == 0);
  657. +  complete_read_request (stat);
  658. +}
  659. +
  660. +
  661. +/*
  662. + * Interrupt routine.  Called when a read request has completed.
  663. + */
  664. +static void do_read_callback (void)
  665. +{
  666. +  int stat, len, thislen;
  667. +
  668. +  if (! nec260_waiting_for_int) 
  669. +    {
  670. +      printk ("nec260 (do_read_callback): spurious call?\n");
  671. +      return;
  672. +    }
  673. +
  674. +  nec260_waiting_for_int = 0;
  675. +
  676. +  /* Check for errors. */
  677. +  stat = inb (nec260_base + HD_ERROR_OFFSET);
  678. +
  679. +  if (stat & ERR_STAT)
  680. +    stat = 0;
  681. +  else
  682. +    {
  683. +      if (CURRENT->cmd != CHECK_STATUS)
  684. +    {
  685. +      /* Error bit not set.
  686. +         Read the device registers to see how much data is waiting. */
  687. +      len = inb_p (nec260_base + HD_LCYL_OFFSET) +
  688. +               256 * inb_p (nec260_base + HD_HCYL_OFFSET);
  689. +
  690. +      /* Read the data into our buffer. */
  691. +      thislen = len;
  692. +      if (thislen > sizeof (nec260_buf)) thislen = sizeof (nec260_buf);
  693. +      insw (nec260_base + HD_DATA_OFFSET, nec260_buf, thislen/2);
  694. +      len -= thislen;
  695. +
  696. +      /* Warn if the size of the data from the device is
  697. +         larger than the buffer. */
  698. +      if (len > 0)
  699. +        {
  700. +          printk ("nec260: discarding %x bytes\n", len);
  701. +          while (len > 0) 
  702. +        {
  703. +          (void) inw_p (nec260_base + HD_DATA_OFFSET);
  704. +          len -= 2;
  705. +        }
  706. +        }
  707. +    }
  708. +
  709. +      /* Check for tray open/disk changed.
  710. +     For some reason, these don't set the `error' bit. */
  711. +      if (stat == 0x24)
  712. +    {
  713. +      /* Tray open.  The request fails. */
  714. +      printk ("nec260: tray open\n");
  715. +      nec260_invalidate_buffers ();
  716. +      nec260_media_changed = 1;
  717. +      stat = 0;
  718. +    }
  719. +      else if (stat == 0x64)
  720. +    {
  721. +      /* Media changed.  Try the operation again. */
  722. +      printk ("nec260: media change\n");
  723. +      nec260_invalidate_buffers ();
  724. +      nec260_media_changed = 1;
  725. +      if (CURRENT->cmd != CHECK_STATUS && !retrying)
  726. +        {
  727. +          del_timer (&nec260_timer);
  728. +          retrying = 1;
  729. +          test_read (MINOR (CURRENT->dev),
  730. +             CURRENT->sector, CURRENT->nr_sectors);
  731. +          return;
  732. +        }
  733. +      stat = 0;
  734. +    }
  735. +      else if (CURRENT->cmd == CHECK_STATUS)
  736. +    stat = 1;
  737. +      else
  738. +    {
  739. +      /* Copy as much as we can into the output buffer. */
  740. +      nec260_bn = CURRENT->sector / 4;
  741. +      nec260_transfer ();
  742. +
  743. +      stat = 1;
  744. +    }
  745. +    }
  746. +
  747. +  /* If there was an error, complete the request now with an error.
  748. +     But if the read is successful, the device is going to be sending
  749. +     us another interrupt.  It likes long goodbyes, i guess.  Anyway,
  750. +     wait until we see this extra interrupt before ending the request. */
  751. +  if (stat && CURRENT->cmd != CHECK_STATUS)
  752. +    {
  753. +      *nec260_handler_ptr = do_read_callback_2;
  754. +      nec260_waiting_for_int = 1;
  755. +    }
  756. +  else
  757. +    complete_read_request (stat);
  758. +}
  759. +
  760. +/*
  761. + * Start a read request from the CD-ROM.
  762. + * Returns 0 if the request was started successfully,
  763. + *  -1 if there was an error.
  764. + * Note: The NSECT arg is presently ignored; we always read exactly
  765. + *       one block.
  766. + */
  767. +static int do_read (unsigned int dev, unsigned int block, unsigned int nsect)
  768. +{
  769. +  int i;
  770. +  char *the_regimage;
  771. +  char check_status_regimage[sizeof (regimage)];
  772. +  char *the_cmdimage;
  773. +  char check_status_cmdimage[sizeof (cmdimage)];
  774. +
  775. +  /* Wait for the controller to be idle. */
  776. +  if (controller_busy () & BUSY_STAT) return -1;
  777. +
  778. +  if (CURRENT->cmd == CHECK_STATUS)
  779. +    {
  780. +      the_regimage = check_status_regimage;
  781. +      for (i=0; i<sizeof (check_status_regimage); i++)
  782. +    check_status_regimage[i] = 0;
  783. +      check_status_regimage[HD_CURRENT_OFFSET-1]=regimage[HD_CURRENT_OFFSET-1];
  784. +      check_status_regimage[HD_COMMAND_OFFSET-1]=regimage[HD_COMMAND_OFFSET-1];
  785. +    }
  786. +  else
  787. +    the_regimage = regimage;
  788. +
  789. +  /* Set up the controller registers. */
  790. +  for (i=0; i<sizeof (regimage); i++)
  791. +    outb_p (the_regimage[i], nec260_base + HD_ERROR_OFFSET + i);
  792. +
  793. +  /* Wait for the controller to be ready to receive the comand. */
  794. +  if (controller_busy () & BUSY_STAT) {
  795. +    printk ("nec260: controller busy\n"); return -1;
  796. +  }
  797. +  if (wait_DRQ ()) {
  798. +    printk ("nec260: controller not ready\n"); return -1;
  799. +  }
  800. +  if (controller_busy () & BUSY_STAT) {
  801. +    printk ("nec260: controller busy (2)\n"); return -1;
  802. +  }
  803. +
  804. +  if (CURRENT->cmd == CHECK_STATUS)
  805. +    {
  806. +      the_cmdimage = check_status_cmdimage;
  807. +      for (i=0; i<sizeof (check_status_cmdimage); i++)
  808. +    check_status_cmdimage[i] = 0;
  809. +    }
  810. +  else
  811. +    {
  812. +      /* Write the sector address into the command image. */
  813. +      {
  814. +    union {
  815. +      struct {unsigned char b0, b1, b2, b3;} b;
  816. +      struct {unsigned long l0;} l;
  817. +    } conv;
  818. +    conv.l.l0 = CURRENT->sector / 4;
  819. +    cmdimage[2] = conv.b.b3;
  820. +    cmdimage[3] = conv.b.b2;
  821. +    cmdimage[4] = conv.b.b1;
  822. +    cmdimage[5] = conv.b.b0;
  823. +      }
  824. +      the_cmdimage = cmdimage;
  825. +    }
  826. +
  827. +  /* Send the command to the device. */
  828. +  outsw (nec260_base + HD_DATA_OFFSET, the_cmdimage, sizeof (cmdimage)/2);
  829. +
  830. +  /* Set up our interrupt handler and return. */
  831. +  *nec260_handler_ptr = do_read_callback;
  832. +  nec260_waiting_for_int = 1;
  833. +
  834. +  /* Set up a timeout. */
  835. +  nec260_timer.expires = 500;
  836. +  add_timer (&nec260_timer);
  837. +
  838. +  return 0;
  839. +}
  840. +
  841. +
  842. +/*
  843. + * Start a read request.
  844. + * If there is an error starting it, terminate the current request
  845. + * immediately with an error.
  846. + */
  847. +static int test_read (unsigned int dev, unsigned int block,
  848. +              unsigned int nsect)
  849. +{
  850. +  int stat;
  851. +  stat = do_read (dev, block, nsect);
  852. +
  853. +  if (stat)
  854. +    end_read_request (0);
  855. +  return 1;
  856. +}
  857. +
  858. +
  859. +/*
  860. + * I/O request routine called from kernel.
  861. + */
  862. +static void do_nec260_request (void)
  863. +{
  864. +  unsigned int block,dev;
  865. +  unsigned int nsect;
  866. +
  867. +  /* Don't do anything if we're waiting for a request to complete.
  868. +     (Can this actually happen?) */
  869. +  if (nec260_request_in_progress) return;
  870. +
  871. + repeat:
  872. +  cli (); /* safety */
  873. +  nec260_request_in_progress = 0;
  874. +
  875. +  /* Return if our queue is plugged. */
  876. +  if (!(CURRENT) || CURRENT->dev < 0) return;
  877. +
  878. +  /* Get the next request on the queue. */
  879. +  INIT_REQUEST;
  880. +  dev = MINOR (CURRENT->dev);
  881. +  block = CURRENT->sector;
  882. +  nsect = CURRENT->nr_sectors;
  883. +
  884. +  /* Return if there wasn't one. */
  885. +  if (CURRENT == NULL || CURRENT -> sector == -1)
  886. +    return;
  887. +
  888. +  /* We can only read. */
  889. +  if (CURRENT -> cmd != READ && CURRENT->cmd != CHECK_STATUS)
  890. +    {
  891. +      printk ("nec260: bad cmd %d\n", CURRENT -> cmd);
  892. +      end_request (0);
  893. +      goto repeat;
  894. +    }
  895. +
  896. +  if (CURRENT->cmd != CHECK_STATUS)
  897. +    {
  898. +      /* Try to satisfy the request from the buffer. */
  899. +      nec260_transfer ();
  900. +
  901. +      /* If we got the entire request, we're done. */
  902. +      if (CURRENT->nr_sectors == 0) 
  903. +    {
  904. +      end_request (1);
  905. +      goto repeat;
  906. +    }
  907. +    }
  908. +
  909. +  /* If the HD is currently active,  return - we must wait for it to finish.
  910. +     If it is idle (no requests in the queue), plug up the queue with a dummy
  911. +     request until we're done using the controller. */
  912. +  if (! nec260_no_hd)
  913. +    {
  914. +      if (blk_dev[the_hd_major].current_request) return;
  915. +      plug_hd ();
  916. +    }
  917. +  nec260_request_in_progress = 1;
  918. +
  919. +  retrying = 0;
  920. +  if (!test_read (dev, block, nsect))
  921. +    goto repeat;
  922. +
  923. +  sti ();
  924. +  return;
  925. +}
  926. +
  927. +
  928. +/*
  929. + * Open the device.
  930. + */
  931. +
  932. +static int
  933. +nec260_open (struct inode *ip, struct file *fp)
  934. +{
  935. +  /* should check that h/w is available... */
  936. +
  937. +  /* no write access */
  938. +  if (fp->f_mode & 2) return -EROFS;
  939. +
  940. +  if (!nec260_open_count)
  941. +    {
  942. +      nec260_invalidate_buffers ();
  943. +
  944. +      /* should check that there's a disk in the drive? */
  945. +    }
  946. +
  947. +  /* Opened ok.  Count this access and return success. */
  948. +  ++nec260_open_count;
  949. +#ifndef LINKED_IN_KERNEL
  950. +  MOD_INC_USE_COUNT;
  951. +#endif
  952. +  return 0;
  953. +}
  954. +
  955. +
  956. +/*
  957. + * Close down the device.  Invalidate all cached blocks.
  958. + */
  959. +
  960. +static void
  961. +nec260_release (struct inode *inode, struct file *file)
  962. +{
  963. +  --nec260_open_count;
  964. +  if (nec260_open_count < 0)
  965. +    {
  966. +      printk ("nec260: inconsistent open count %d\n", nec260_open_count);
  967. +      nec260_open_count = 0;
  968. +    }
  969. +
  970. +  if (nec260_open_count == 0)
  971. +    {
  972. +      nec260_invalidate_buffers ();
  973. +      sync_dev (inode->i_rdev);
  974. +      invalidate_buffers (inode->i_rdev);
  975. +    }
  976. +#ifndef LINKED_IN_KERNEL
  977. +  MOD_DEC_USE_COUNT;
  978. +#endif
  979. +}
  980. +
  981. +
  982. +static
  983. +void nec260_do_check_status (dev_t full_dev)
  984. +{
  985. +  struct request check_status_req;
  986. +  struct semaphore sem = MUTEX_LOCKED;
  987. +
  988. +  check_status_req.dev = full_dev;
  989. +  check_status_req.cmd = CHECK_STATUS;
  990. +  check_status_req.errors = 0;
  991. +  check_status_req.sector = 0;
  992. +  check_status_req.nr_sectors = 0;
  993. +  check_status_req.current_nr_sectors = 0;
  994. +  check_status_req.buffer = NULL;
  995. +  check_status_req.sem = &sem;
  996. +  check_status_req.bh = NULL;
  997. +  check_status_req.bhtail = NULL;
  998. +  check_status_req.next = NULL;
  999. +
  1000. +  cli ();
  1001. +  if (CURRENT == NULL)
  1002. +    {
  1003. +      CURRENT = &check_status_req;
  1004. +      do_nec260_request ();
  1005. +    }
  1006. +  else
  1007. +    {
  1008. +      check_status_req.next = CURRENT;
  1009. +      CURRENT->next = &check_status_req;
  1010. +    }
  1011. +  sti ();
  1012. +
  1013. +  down (&sem);
  1014. +}
  1015. +
  1016. +
  1017. +static
  1018. +int nec260_disk_change (dev_t full_dev)
  1019. +{
  1020. +  int retval, target;
  1021. +
  1022. +  target = MINOR (full_dev);
  1023. +
  1024. +  if (target > 0)
  1025. +    {
  1026. +      printk ("nec260 (nec260_disk_change): invalid device %d\n", target);
  1027. +      return 0;
  1028. +    }
  1029. +
  1030. +  if (nec260_media_changed == 0)
  1031. +    nec260_do_check_status (full_dev);
  1032. +
  1033. +  retval = nec260_media_changed;
  1034. +  nec260_media_changed = 0;
  1035. +
  1036. +  printk ("nec260: disk change %d\n", retval);
  1037. +
  1038. +  return retval;
  1039. +}
  1040. +
  1041. +
  1042. +static void nec260_interrupt (int unused)
  1043. +{
  1044. +  void (*handler)(void) = DEVICE_INTR;
  1045. +    
  1046. +  DEVICE_INTR = NULL;
  1047. +  if (!handler)
  1048. +    printk ("nec260: unexpected interrupt\n");
  1049. +  else
  1050. +    handler();
  1051. +  sti();
  1052. +}
  1053. +
  1054. +
  1055. +#ifndef NO_IRQACTION
  1056. +/*
  1057. + * This is the cdrom IRQ description. The SA_INTERRUPT in sa_flags
  1058. + * means we run the IRQ-handler with interrupts disabled.
  1059. + */
  1060. +static struct sigaction nec260_sigaction = {
  1061. +    nec260_interrupt,
  1062. +    0,
  1063. +    SA_INTERRUPT,
  1064. +    NULL
  1065. +};
  1066. +#endif /* ! NO_IRQACTION */
  1067. +
  1068. +
  1069. +
  1070. +static struct file_operations nec260_fops = {
  1071. +    NULL,            /* lseek - default */
  1072. +    block_read,        /* read - general block-dev read */
  1073. +    block_write,        /* write - general block-dev write */
  1074. +    NULL,            /* readdir - bad */
  1075. +    NULL,            /* select */
  1076. +    NULL,             /* ioctl */
  1077. +    NULL,            /* mmap */
  1078. +    nec260_open,        /* open */
  1079. +        nec260_release,        /* release */
  1080. +        NULL,                    /* fsync */  
  1081. +        NULL,                    /* fasync */  
  1082. +        nec260_disk_change,    /* check_media_change */  
  1083. +        NULL,                    /* revalidate */  
  1084. +};
  1085. +
  1086. +
  1087. +MAYBE_STATIC int init_module (void)
  1088. +{
  1089. +  /* Find the major numbe of the HD on our IDE bus. */
  1090. +  the_hd_major = HD_MAJOR;
  1091. +#ifdef CONFIG_BLK_DEV_HD1
  1092. +  if (nec260_base == HD1_DATA)
  1093. +    the_hd_major = HD1_MAJOR;
  1094. +#endif
  1095. +
  1096. +  /* Register ourselves with the kernel. */
  1097. +  if (register_blkdev (nec260_major, "nec260", &nec260_fops) != 0) 
  1098. +    {
  1099. +      printk("nec260: Unable to get major %d for NEC CDR-260\n", nec260_major);
  1100. +      return -EIO;
  1101. +    }
  1102. +
  1103. +  printk ("nec260: registered with major #%d\n", nec260_major);
  1104. +
  1105. +  /* Install our device request routine. */
  1106. +  blk_dev[nec260_major].request_fn = DEVICE_REQUEST;
  1107. +  read_ahead[nec260_major] = 4;
  1108. +
  1109. +  /* Set the proper device select code. */
  1110. +  if (nec260_master)
  1111. +    regimage[5] = 0xe0;
  1112. +  else
  1113. +    regimage[5] = 0xf0;
  1114. +
  1115. +  if (nec260_no_hd)
  1116. +    {
  1117. +      /* Set up the interrupt. */
  1118. +      do_nec260 = NULL;
  1119. +      nec260_handler_ptr = &do_nec260;
  1120. +#ifdef NO_IRQACTION
  1121. +      if (request_irq (nec260_irq, nec260_interrupt, SA_INTERRUPT, "nec260"))
  1122. +#else
  1123. +      if (irqaction (nec260_irq, &nec260_sigaction))
  1124. +#endif
  1125. +    {
  1126. +      printk ("Unable to get IRQ%d for NEC CDR-260 CD-ROM\n", nec260_irq);
  1127. +      unregister_blkdev (nec260_major, "nec260");
  1128. +      return -EIO;
  1129. +    }
  1130. +    }
  1131. +  else
  1132. +    {
  1133. +      /* tell hd.c our major number */
  1134. +      the_nec260_major = nec260_major;
  1135. +
  1136. +      /* Set up nec260_handler_ptr to point to the HD interrupt vector. */
  1137. +      nec260_handler_ptr = &do_hd;
  1138. +#ifdef CONFIG_BLK_DEV_HD1
  1139. +      if (nec260_base == HD1_DATA)
  1140. +    the_hd_major = &do_hd1;
  1141. +#endif
  1142. +    }
  1143. +
  1144. +  return 0;
  1145. +}
  1146. +
  1147. +#ifdef LINKED_IN_KERNEL
  1148. +
  1149. +unsigned long nec260_init (unsigned long mem_start, unsigned long mem_end)
  1150. +{
  1151. +  init_module ();
  1152. +  return mem_start;
  1153. +}
  1154. +
  1155. +#else
  1156. +
  1157. +void cleanup_module (void)
  1158. +{
  1159. +  if (MOD_IN_USE)
  1160. +    printk("nec260: device busy, remove delayed\n");
  1161. +
  1162. +  if (unregister_blkdev (nec260_major, "nec260") != 0)
  1163. +    printk ("nec260: cleanup_module failed\n");
  1164. +  else 
  1165. +    {
  1166. +      printk ("nec260: cleanup_module succeeded\n");
  1167. +      if (nec260_no_hd)
  1168. +    free_irq (nec260_irq);
  1169. +      else
  1170. +    the_nec260_major = 0;
  1171. +    }
  1172. +}
  1173. +
  1174. +#endif
  1175. diff -u --recursive --new-file linux-1.1.58/drivers/block/sonycd535.c linux/drivers/block/sonycd535.c
  1176. --- linux-1.1.58/drivers/block/sonycd535.c    Wed Dec 31 18:00:00 1969
  1177. +++ linux/drivers/block/sonycd535.c    Wed Oct 26 23:02:00 1994
  1178. @@ -0,0 +1,1537 @@
  1179. +/*
  1180. + * Sony CDU-535 interface device driver
  1181. + *
  1182. + * This is a modified version of the CDU-31A device driver (see below).
  1183. + * Changes were made using documentation for the CDU-531 (which Sony
  1184. + * assures me is very similar to the 535) and partial disassembly of the
  1185. + * DOS driver.  I used Minyard's driver and replaced the the CDU-31A 
  1186. + * commands with the CDU-531 commands.  This was complicated by a different
  1187. + * interface protocol with the drive.  The driver is still polled.
  1188. + *
  1189. + * Data transfer rate is about 110 Kb/sec, theoretical maximum is 150 Kb/sec.
  1190. + * I tried polling without the sony_sleep during the data transfers but
  1191. + * it did not speed things up any.
  1192. + *
  1193. + *  5/23/93 (rgj) changed the major number to 21 to get rid of conflict
  1194. + * with CDU-31A driver.  This is the also the number from the Linux
  1195. + * Device Driver Registry for the Sony Drive.  Hope nobody else is using it.
  1196. + *
  1197. + *  8/29/93 (rgj) remove the configuring of the interface board address
  1198. + * from the top level configuration, you have to modify it in this file.
  1199. + *
  1200. + * Things to do:
  1201. + *    - handle errors and status better, put everything into a single word
  1202. + *    - use interrupts, DMA
  1203. + *
  1204. + *  Known Bugs:
  1205. + *    -
  1206. + *
  1207. + *   Ron Jeppesen (ronj.an@site007.saic.com)
  1208. + *
  1209. + *
  1210. + *------------------------------------------------------------------------
  1211. + * Sony CDROM interface device driver.
  1212. + *
  1213. + * Corey Minyard (minyard@wf-rch.cirr.com) (CDU-535 complaints to ronj above)
  1214. + *
  1215. + * Colossians 3:17
  1216. + *
  1217. + * The Sony interface device driver handles Sony interface CDROM
  1218. + * drives and provides a complete block-level interface as well as an
  1219. + * ioctl() interface compatible with the Sun (as specified in
  1220. + * include/linux/cdrom.h).  With this interface, CDROMs can be
  1221. + * accessed and standard audio CDs can be played back normally.
  1222. + *
  1223. + * This interface is (unfortunatly) a polled interface.  This is
  1224. + * because most Sony interfaces are set up with DMA and interrupts
  1225. + * disables.  Some (like mine) do not even have the capability to
  1226. + * handle interrupts or DMA.  For this reason you will see a lot of
  1227. + * the following:
  1228. + *
  1229. + *   retry_count = jiffies+ SONY_JIFFIES_TIMEOUT;
  1230. + *   while ((retry_count > jiffies) && (! <some condition to wait for))
  1231. + *   {
  1232. + *      while (handle_sony_cd_attention())
  1233. + *         ;
  1234. + *
  1235. + *      sony_sleep();
  1236. + *   }
  1237. + *   if (the condition not met)
  1238. + *   {
  1239. + *      return an error;
  1240. + *   }
  1241. + *
  1242. + * This ugly hack waits for something to happen, sleeping a little
  1243. + * between every try.  it also handles attentions, which are
  1244. + * asyncronous events from the drive informing the driver that a disk
  1245. + * has been inserted, removed, etc.
  1246. + *
  1247. + * One thing about these drives: They talk in MSF (Minute Second Frame) format.
  1248. + * There are 75 frames a second, 60 seconds a minute, and up to 75 minutes on a
  1249. + * disk.  The funny thing is that these are sent to the drive in BCD, but the
  1250. + * interface wants to see them in decimal.  A lot of conversion goes on.
  1251. + *
  1252. + *  Copyright (C) 1993  Corey Minyard
  1253. + *
  1254. + *  This program is free software; you can redistribute it and/or modify
  1255. + *  it under the terms of the GNU General Public License as published by
  1256. + *  the Free Software Foundation; either version 2 of the License, or
  1257. + *  (at your option) any later version.
  1258. + *
  1259. + *  This program is distributed in the hope that it will be useful,
  1260. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1261. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1262. + *  GNU General Public License for more details.
  1263. + *
  1264. + *  You should have received a copy of the GNU General Public License
  1265. + *  along with this program; if not, write to the Free Software
  1266. + *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1267. + *
  1268. + */
  1269. +
  1270. +
  1271. +#include <linux/config.h>
  1272. +#ifdef CONFIG_CDU535
  1273. +
  1274. +#include <linux/errno.h>
  1275. +#include <linux/signal.h>
  1276. +#include <linux/sched.h>
  1277. +#include <linux/timer.h>
  1278. +#include <linux/fs.h>
  1279. +#include <linux/kernel.h>
  1280. +#include <linux/hdreg.h>
  1281. +#include <linux/genhd.h>
  1282. +
  1283. +#define REALLY_SLOW_IO
  1284. +#include <asm/system.h>
  1285. +#include <asm/io.h>
  1286. +#include <asm/segment.h>
  1287. +
  1288. +#include <linux/cdrom.h>
  1289. +#include <linux/sonycd535.h>
  1290. +
  1291. +#define MAJOR_NR CDU535_CDROM_MAJOR
  1292. +#include "blk.h"
  1293. +
  1294. +/*
  1295. + * this is the base address of the interface card for the Sony CDU535
  1296. + * CDROM drive.  If your jumpers are set for an address other than
  1297. + * this one (the default), change the following line to the
  1298. + * proper address.
  1299. + */
  1300. +#define CDU535_ADDRESS    (0x340)
  1301. +
  1302. +#define DEBUG
  1303. +
  1304. +/*
  1305. + *  SONY535_BUFFER_SIZE determines the size of internal buffer used
  1306. + *  by the drive.  It must be at least 2K and the larger the buffer
  1307. + *  the better the transfer rate.  It does however take system memory.
  1308. + *   On my system I get the following transfer rates using dd to read
  1309. + *  10 Mb off /dev/cdrom.
  1310. + *
  1311. + *      8K buffer         43 Kb/sec
  1312. + *    16K buffer         66 Kb/sec
  1313. + *    32K buffer         91 Kb/sec
  1314. + *    64K buffer        111 Kb/sec
  1315. + *    128K buffer        123 Kb/sec
  1316. + *    512K buffer        123 Kb/sec
  1317. + */
  1318. +#define SONY535_BUFFER_SIZE    (64*1024)
  1319. +
  1320. +/*
  1321. + *  if LOCK_DOORS is defined then the eject button is disabled while
  1322. + * the device is open.
  1323. + */
  1324. +#define LOCK_DOORS
  1325. +
  1326. +static int read_subcode(void);
  1327. +static void sony_get_toc(void);
  1328. +static int cdu_open( struct inode *inode, struct file *filp );
  1329. +static inline unsigned int int_to_bcd(unsigned int val);
  1330. +static unsigned int bcd_to_int(unsigned int bcd);
  1331. +static int do_sony_cmd( Byte *cmd, int nCmd, Byte status[2], 
  1332. +                 Byte *response, int nResponse, int ignoreStatusBit7 );
  1333. +
  1334. +/* The base I/O address of the Sony Interface.  This is a variable (not a
  1335. +   #define) so it can be easily changed via some future ioctl() */
  1336. +static unsigned short sony_cd_base_io = CDU535_ADDRESS;
  1337. +
  1338. +/*
  1339. + * The following are I/O addresses of the various registers for the drive.  The
  1340. + * comment for the base address also applies here.
  1341. + */
  1342. +static unsigned short select_unit_reg;
  1343. +static unsigned short result_reg;
  1344. +static unsigned short command_reg;
  1345. +static unsigned short read_status_reg;
  1346. +static unsigned short data_reg;
  1347. +
  1348. +static int initialized = 0;                /* Has the drive been initialized? */
  1349. +static int sony_disc_changed = 1;          /* Has the disk been changed
  1350. +                                              since the last check? */
  1351. +static int sony_toc_read = 0;              /* Has the table of contents been
  1352. +                                              read? */
  1353. +static unsigned int sony_buffer_size;      /* Size in bytes of the read-ahead
  1354. +                                              buffer. */
  1355. +static unsigned int sony_buffer_sectors;   /* Size (in 2048 byte records) of
  1356. +                                              the read-ahead buffer. */
  1357. +static unsigned int sony_usage = 0;        /* How many processes have the
  1358. +                                              drive open. */
  1359. +
  1360. +static int sony_first_block = -1;          /* First OS block (512 byte) in
  1361. +                                              the read-ahead buffer */
  1362. +static int sony_last_block = -1;           /* Last OS block (512 byte) in
  1363. +                                              the read-ahead buffer */
  1364. +
  1365. +static struct s535_sony_toc *sony_toc;           /* Points to the table of
  1366. +                                                    contents. */
  1367. +static struct s535_sony_subcode *last_sony_subcode; /* Points to the last
  1368. +                                                    subcode address read */
  1369. +static unsigned char *sony_buffer;               /* Points to the read-ahead
  1370. +                                                    buffer */
  1371. +static int sony_inuse = 0;        /* is the drive in use? Only one
  1372. +                       open at a time allowed */
  1373. +
  1374. +/*
  1375. + * The audio status uses the values from read subchannel data as specified
  1376. + * in include/linux/cdrom.h.
  1377. + */
  1378. +static int sony_audio_status = CDROM_AUDIO_NO_STATUS;
  1379. +
  1380. +/*
  1381. + * The following are a hack for pausing and resuming audio play.  The drive
  1382. + * does not work as I would expect it, if you stop it then start it again,
  1383. + * the drive seeks back to the beginning and starts over.  This holds the
  1384. + * position during a pause so a resume can restart it.  It uses the
  1385. + * audio status variable above to tell if it is paused.
  1386. + *   I just kept the CDU-31A driver behavior rather than using the PAUSE
  1387. + * command on the CDU-535.
  1388. + */
  1389. +static unsigned char cur_pos_msf[3] = { 0, 0, 0 };
  1390. +static unsigned char final_pos_msf[3] = { 0, 0, 0 };
  1391. +
  1392. +
  1393. +/*
  1394. + * This routine returns 1 if the disk has been changed since the last
  1395. + * check or 0 if it hasn't.
  1396. + */
  1397. +static int
  1398. +cdu535_check_media_change(dev_t full_dev)
  1399. +{
  1400. +   int retval, target;
  1401. +
  1402. +   target = MINOR(full_dev);
  1403. +
  1404. +   if (target > 0) {
  1405. +      printk("Sony CD-ROM request error: invalid device.\n");
  1406. +      return 0;
  1407. +   }
  1408. +
  1409. +   /* if driver is not initialized, always return 0 */
  1410. +   retval = ( initialized ? sony_disc_changed : 0 );
  1411. +   sony_disc_changed = 0;
  1412. +   return retval;
  1413. +}
  1414. +
  1415. +
  1416. +/*
  1417. + * Wait a little while (used for polling the drive).  If in initialization,
  1418. + * setting a timeout doesn't work, so just loop for a while  (we trust
  1419. + * that the sony_sleep() call is protected by a test for proper jiffies count).
  1420. + */
  1421. +static inline void
  1422. +sony_sleep(void)
  1423. +{
  1424. +   current->state = TASK_INTERRUPTIBLE;
  1425. +   current->timeout = jiffies;
  1426. +   schedule();
  1427. +}
  1428. +
  1429. +/*------------------start of SONY CDU535 very specific ---------------------*/
  1430. +
  1431. +/****************************************************************************
  1432. + * void select_unit( int unit_no )
  1433. + *
  1434. + *  Select the specified unit (0-3) so that subsequent commands reference it
  1435. + ****************************************************************************/
  1436. +static void 
  1437. +select_unit( int unit_no )
  1438. +{
  1439. +   unsigned int select_mask = ~(1 << unit_no);
  1440. +   outb( select_mask, select_unit_reg );
  1441. +}  /* select_unit() */
  1442. +
  1443. +/***************************************************************************
  1444. + * int read_result_reg( unsigned char *data_ptr )
  1445. + *
  1446. + *  Read a result byte from the Sony CDU controller, store in location pointed
  1447. + * to by data_ptr.  Return zero on success, TIME_OUT if we did not receive
  1448. + * data.
  1449. + ***************************************************************************/
  1450. +static int 
  1451. +read_result_reg( unsigned char *data_ptr )
  1452. +{
  1453. +   int retry_count;
  1454. +   int read_status;
  1455. +  
  1456. +   retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
  1457. +   while ( retry_count > jiffies ) 
  1458. +   {
  1459. +      if ( ((read_status=inb(read_status_reg)) & SONY535_RESULT_NOT_READY_BIT) == 0 ) 
  1460. +      {
  1461. +#if 0
  1462. +         printk("read_result_reg(): readStatReg = 0x%x\n", read_status );
  1463. +#endif
  1464. +         *data_ptr = inb(result_reg);
  1465. +         return( 0 );
  1466. +      }
  1467. +      else 
  1468. +      {
  1469. +         sony_sleep();
  1470. +      }
  1471. +   }
  1472. +   printk(" Sony CDROM read_result_reg: TIME OUT!\n");
  1473. +   return( TIME_OUT );
  1474. +}  /* read_result_reg() */
  1475. +
  1476. +/****************************************************************************
  1477. + * int read_exec_status( Byte status[2] )
  1478. + *
  1479. + *  Read the execution status of the last command and put into status. 
  1480. + * Handles reading second status word if available.  Returns 0 on success,
  1481. + * TIME_OUT on failure.
  1482. + ****************************************************************************/
  1483. +static int 
  1484. +read_exec_status( Byte status[2] )
  1485. +{
  1486. +   status[1] = 0;
  1487. +   if ( read_result_reg( &(status[0]) ) != 0 ) return( TIME_OUT );
  1488. +   if ( (status[0] & 0x80) != 0 )  /* byte two follows */
  1489. +   {
  1490. +      if ( read_result_reg( &(status[1]) ) != 0 ) return( TIME_OUT );
  1491. +   }
  1492. +#if 0
  1493. +   printk("read_exec_status: read 0x%x\n", status[0] );
  1494. +   if (status[0] & 0x80) printk(" and 0x%x\n", status[1] );
  1495. +   printk("\n");
  1496. +#endif
  1497. +   return( 0 );
  1498. +}  /* read_exec_status() */
  1499. +
  1500. +/****************************************************************************
  1501. + * int check_drive_status( void )
  1502. + *
  1503. + *  Check the current drive status.  Using this before executing a command
  1504. + * takes care of the problem of unsolicited drive status-2 messages.
  1505. + * Add a check of the audio status if we think the disk is playing.
  1506. + ****************************************************************************/
  1507. +static int 
  1508. +check_drive_status( void )
  1509. +{
  1510. +   Byte status, e_status[2];
  1511. +   int CDD, ATN;
  1512. +   unsigned char cmd;
  1513. +  
  1514. +   select_unit(0);
  1515. +   if ( sony_audio_status == CDROM_AUDIO_PLAY )  /* check status */
  1516. +   {
  1517. +      outb( SONY535_REQUEST_AUDIO_STATUS, command_reg );
  1518. +      if ( read_result_reg( &status ) == 0 ) 
  1519. +      {
  1520. +         switch( status ) 
  1521. +         {
  1522. +            case 0x0:  break;            /* play in progress */
  1523. +            case 0x1:  break;            /* paused */
  1524. +            case 0x3:                /* audio play completed */
  1525. +            case 0x5:                /* play not requested */
  1526. +                       sony_audio_status = CDROM_AUDIO_COMPLETED;
  1527. +                       read_subcode();
  1528. +                       break;
  1529. +            case 0x4:                /* error during play */
  1530. +                       sony_audio_status = CDROM_AUDIO_ERROR;
  1531. +                       break;
  1532. +         }
  1533. +      }
  1534. +   }
  1535. +    /* now check drive status */
  1536. +   outb( SONY535_REQUEST_DRIVE_STATUS_2, command_reg );
  1537. +   if ( read_result_reg( &status ) != 0 ) 
  1538. +      return( TIME_OUT );
  1539. +
  1540. +#if 0
  1541. +   printk("--check_drive_status() got 0x%x\n", status );
  1542. +#endif
  1543. +  
  1544. +   if ( status == 0 ) return( 0 );
  1545. +  
  1546. +   ATN = status & 0xf;
  1547. +   CDD = (status >> 4) & 0xf;
  1548. +  
  1549. +   switch ( ATN ) 
  1550. +   {
  1551. +      case 0x0:
  1552. +                 break;  /* go on to CDD stuff */
  1553. +      case SONY535_ATN_BUSY:
  1554. +                 if ( initialized )
  1555. +                    printk("Sony CDROM error, drive busy\n");
  1556. +                 return( CD_BUSY);
  1557. +      case SONY535_ATN_EJECT_IN_PROGRESS:
  1558. +                 printk("Sony CDROM error, eject in progress\n");
  1559. +                 sony_audio_status = CDROM_AUDIO_INVALID;
  1560. +                 return( CD_BUSY);
  1561. +      case SONY535_ATN_RESET_OCCURRED:
  1562. +      case SONY535_ATN_DISC_CHANGED:
  1563. +      case SONY535_ATN_RESET_AND_DISC_CHANGED:
  1564. +#ifdef DEBUG
  1565. +                 printk("Sony CDROM, reset occurred or disc changed\n");
  1566. +#endif
  1567. +                 sony_disc_changed = 1;
  1568. +                 sony_toc_read = 0;
  1569. +                 sony_audio_status = CDROM_AUDIO_NO_STATUS;
  1570. +                 sony_first_block = -1;
  1571. +                 sony_last_block = -1;
  1572. +                 if (initialized)
  1573. +                 {
  1574. +                    cmd = SONY535_SPIN_UP;
  1575. +                    do_sony_cmd( &cmd,1, e_status, NULL,0, 0 );
  1576. +                    sony_get_toc();
  1577. +                 }
  1578. +                 return( 0 );
  1579. +      default:
  1580. +                 printk("Sony CDROM error, drive busy (ATN=0x%x)\n", ATN );
  1581. +                 return( CD_BUSY );
  1582. +   }
  1583. +   switch ( CDD ) 
  1584. +   {  /* the 531 docs are not helpful in decoding this */
  1585. +      case 0x0:       /* just use the values from the DOS driver */
  1586. +      case 0x2:
  1587. +      case 0xa:
  1588. +                 break;  /* no error */
  1589. +      case 0xc:
  1590. +                 printk("check_drive_status(): CDD = 0xc! Not properly handled!\n");
  1591. +                 return( CD_BUSY );  /* ? */
  1592. +      default:
  1593. +                 return( CD_BUSY );
  1594. +   }
  1595. +   return( 0 );
  1596. +}  /* check_drive_status() */
  1597. +
  1598. +/*****************************************************************************
  1599. + * int do_sony_cmd( Byte *cmd, int n_cmd, Byte status[2], 
  1600. + *                Byte *response, int n_response, int ignore_status_bit7 )
  1601. + *
  1602. + *  Generic routine for executing commands.  The command and its parameters
  1603. + *  should be placed in the cmd[] array, number of bytes in the command is
  1604. + *  stored in nCmd.  The response from the command will be stored in the
  1605. + *  response array.  The number of bytes you expect back (excluding status)
  1606. + *  should be passed in nReponse.  Finally, some
  1607. + *  commands set bit 7 of the return status even when there is no second
  1608. + *  status byte, on these commands set ignoreStatusBit7 TRUE.
  1609. + *    If the command was sent and data recieved back, then we return 0,
  1610. + *  else we return TIME_OUT.  You still have to check the status yourself.
  1611. + *    You should call check_drive_status() before calling this routine
  1612. + *  so that you do not lose notifications of disk changes, etc.
  1613. + ****************************************************************************/
  1614. +static int 
  1615. +do_sony_cmd( Byte *cmd, int n_cmd, Byte status[2], 
  1616. +             Byte *response, int n_response, int ignore_status_bit7 )
  1617. +{
  1618. +   int i;
  1619. +  
  1620. +    /* write out the command */
  1621. +   for ( i=0; i < n_cmd; i++ )
  1622. +      outb( cmd[i], command_reg );
  1623. +  
  1624. +    /* read back the status */
  1625. +   if ( read_result_reg( status ) != 0 )
  1626. +      return( TIME_OUT );
  1627. +   if ( !ignore_status_bit7 && ((status[0] & 0x80) != 0) ) /* get second status byte */
  1628. +   {
  1629. +      if ( read_result_reg( status+1 ) != 0 )
  1630. +         return( TIME_OUT );
  1631. +   }
  1632. +   else
  1633. +   {
  1634. +      status[1] = 0;
  1635. +   }
  1636. +    
  1637. +   /* do not know about when I should read set of data and when not to */
  1638. +   if ( (status[0] & ((ignore_status_bit7 ? 0x7f : 0xff) & 0x8f)) != 0 )
  1639. +      return( 0 );
  1640. +  
  1641. +    /* else, read in rest of data */
  1642. +   for ( i=0; n_response > 0; n_response--, i++ )
  1643. +      if ( read_result_reg( response+i ) != 0 ) return(TIME_OUT);
  1644. +   return( 0 );
  1645. +}  /* do_sony_cmd() */
  1646. +
  1647. +/**************************************************************************
  1648. + * int set_drive_mode( int mode, Byte status[2] )
  1649. + *
  1650. + *  Set the drive mode to the specified value (mode=0 is audio, mode=e0
  1651. + * is mode-1 CDROM
  1652. + **************************************************************************/
  1653. +static int 
  1654. +set_drive_mode( int mode, Byte status[2] )
  1655. +{
  1656. +   Byte cmd_buff[2], ret_buff[1];
  1657. +  
  1658. +   cmd_buff[0] = SONY535_SET_DRIVE_MODE;
  1659. +   cmd_buff[1] = mode;
  1660. +   return( do_sony_cmd( cmd_buff,2, status, ret_buff,1, 1 ) );
  1661. +}  /* set_drive_mode() */
  1662. +
  1663. +/***************************************************************************
  1664. + * int seek_and_read_N_blocks( Byte params[], int n_blocks, Byte status[2], 
  1665. + *                             Byte *data_buff, int buff_size )
  1666. + *
  1667. + *  Read n_blocks of data from the CDROM starting at position params[0:2],
  1668. + *  number of blocks in stored in params[3:5] -- both these are already
  1669. + *  int bcd format.
  1670. + *  Transfer the data into the buffer pointed at by data_buff.  buff_size
  1671. + *  gives the number of bytes available in the buffer.
  1672. + *    The routine returns number of bytes read in if successful, otherwise
  1673. + *  it returns one of the standard error returns.
  1674. + ***************************************************************************/
  1675. +static int 
  1676. +seek_and_read_N_blocks( Byte params[], int n_blocks, Byte status[2],
  1677. +                        Byte *data_buff, int buf_size )
  1678. +{
  1679. +   int i;
  1680. +   const int block_size = 2048;
  1681. +   Byte cmd_buff[7];
  1682. +   int read_status;
  1683. +   Byte *start_pos = data_buff;
  1684. +   int retry_count;
  1685. +  
  1686. +   if ( ((long)block_size)*n_blocks > buf_size )
  1687. +      return( NO_ROOM );
  1688. +  
  1689. +   set_drive_mode( SONY535_CDROM_DRIVE_MODE, status );
  1690. +  
  1691. +    /* send command to read the data */
  1692. +   cmd_buff[0] = SONY535_SEEK_AND_READ_N_BLOCKS_1;
  1693. +   for ( i=0; i < 6; i++ )
  1694. +      cmd_buff[i+1] = params[i];
  1695. +   for ( i=0; i < 7; i++ )
  1696. +      outb( cmd_buff[i], command_reg );
  1697. +  
  1698. +    /* read back the data one block at a time */
  1699. +   while ( n_blocks-- > 0 ) 
  1700. +   {
  1701. +       /* wait for data to be ready */
  1702. +      retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
  1703. +      while ( retry_count > jiffies ) 
  1704. +      {
  1705. +         read_status = inb(read_status_reg);
  1706. +         if ( (read_status & SONY535_RESULT_NOT_READY_BIT) == 0 ) 
  1707. +         {
  1708. +            read_exec_status( status );
  1709. +            return( BAD_STATUS );
  1710. +         }
  1711. +         if ( (read_status & SONY535_DATA_NOT_READY_BIT) == 0 ) 
  1712. +         {
  1713. +             /* data is ready, read it */
  1714. +            for ( i=0; i < block_size; i++ )
  1715. +               *data_buff++ = inb( data_reg );  /* unrolling this loop does not seem to help */
  1716. +            break;  /* exit the timeout loop */
  1717. +         }
  1718. +         sony_sleep();  /* data not ready, sleep a while */
  1719. +      }
  1720. +      if ( retry_count <= jiffies )
  1721. +      return( TIME_OUT );  /* if we reach this stage */
  1722. +   }
  1723. +  
  1724. +    /* read all the data, now read the status */
  1725. +   if ( (i=read_exec_status( status )) != 0 )
  1726. +      return( i );
  1727. +   return( data_buff - start_pos );
  1728. +}  /* seek_and_read_N_blocks() */
  1729. +
  1730. +/****************************************************************************
  1731. + * int request_toc_data( Byte status[2], struct s535_sony_toc *toc )
  1732. + *
  1733. + *  Read in the table of contents data.  Converts all the bcd data
  1734. + * into integers in the toc structure.
  1735. + ****************************************************************************/
  1736. +static int 
  1737. +request_toc_data( Byte status[2], struct s535_sony_toc *toc )
  1738. +{
  1739. +   int to_status;
  1740. +   int i, j, n_tracks, track_no;
  1741. +   Byte cmd_no = 0xb2;
  1742. +   Byte track_address_buffer[5];
  1743. +   int first_track_num, last_track_num;
  1744. +
  1745. +    /* read the fixed portion of the table of contents */
  1746. +   if ((to_status=do_sony_cmd( &cmd_no,1, status, (Byte *)toc,15, 1 )) != 0 )
  1747. +      return( to_status );
  1748. +  
  1749. +    /* convert the data into integers so we can use them */
  1750. +   first_track_num = bcd_to_int(toc->first_track_num);
  1751. +   last_track_num = bcd_to_int(toc->last_track_num);
  1752. +   n_tracks = last_track_num - first_track_num + 1;
  1753. +  
  1754. +    /* read each of the track address descriptors */
  1755. +   for ( i=0; i < n_tracks; i++ ) 
  1756. +   {
  1757. +       /* read the descriptor into a temporary buffer */
  1758. +      for ( j=0; j < 5; j++ ) 
  1759. +      {
  1760. +         if ( read_result_reg( track_address_buffer+j ) != 0 )
  1761. +            return( TIME_OUT );
  1762. +         if ( j == 1 )  /* need to convert from bcd */
  1763. +            track_no = bcd_to_int(track_address_buffer[j]);
  1764. +      }
  1765. +       /* copy the descriptor to proper location - sonycd.c just fills */
  1766. +      memcpy( toc->tracks+i, track_address_buffer, 5 );
  1767. +   }
  1768. +   return( 0 );
  1769. +}  /* request_toc_data() */
  1770. +
  1771. +/***************************************************************************
  1772. + * int spin_up_drive( Byte status[2] )
  1773. + *
  1774. + *  Spin up the drive (unless it is already spinning).
  1775. + ***************************************************************************/
  1776. +static int 
  1777. +spin_up_drive( Byte status[2] )
  1778. +{
  1779. +   Byte cmd_buff[1];
  1780. +  
  1781. +    /* first see if the drive is already spinning */
  1782. +   cmd_buff[0] = SONY535_REQUEST_DRIVE_STATUS_1;
  1783. +   if ( do_sony_cmd( cmd_buff,1, status, NULL,0, 0 ) != 0 )
  1784. +      return(TIME_OUT );
  1785. +   if ( (status[0] & SONY535_STATUS1_NOT_SPINNING) == 0 )
  1786. +      return( 0 );  /* its already spinning */
  1787. +  
  1788. +    /* else, give the spin-up command */
  1789. +   cmd_buff[0] = SONY535_SPIN_UP;
  1790. +   return( do_sony_cmd( cmd_buff, 1, status, NULL,0, 0 )  );
  1791. +}  /* spin_up_drive() */
  1792. +
  1793. +/*--------------------end of SONY CDU535 very specific ---------------------*/
  1794. +
  1795. +/* Convert from an integer 0-99 to BCD */
  1796. +static inline unsigned int
  1797. +int_to_bcd(unsigned int val)
  1798. +{
  1799. +   int retval;
  1800. +
  1801. +
  1802. +   retval = (val / 10) << 4;
  1803. +   retval = retval | val % 10;
  1804. +   return(retval);
  1805. +}
  1806. +
  1807. +
  1808. +/* Convert from BCD to an integer from 0-99 */
  1809. +static unsigned int
  1810. +bcd_to_int(unsigned int bcd)
  1811. +{
  1812. +   return((((bcd >> 4) & 0x0f) * 10) + (bcd & 0x0f));
  1813. +}
  1814. +
  1815. +
  1816. +/*
  1817. + * Convert a logical sector value (like the OS would want to use for
  1818. + * a block device) to an MSF format.
  1819. + */
  1820. +static void
  1821. +log_to_msf(unsigned int log, unsigned char *msf)
  1822. +{
  1823. +   log = log + LOG_START_OFFSET;
  1824. +   msf[0] = int_to_bcd(log / 4500);
  1825. +   log = log % 4500;
  1826. +   msf[1] = int_to_bcd(log / 75);
  1827. +   msf[2] = int_to_bcd(log % 75);
  1828. +}
  1829. +
  1830. +
  1831. +/*
  1832. + * Convert an MSF format to a logical sector.
  1833. + */
  1834. +static unsigned int
  1835. +msf_to_log(unsigned char *msf)
  1836. +{
  1837. +   unsigned int log;
  1838. +
  1839. +
  1840. +   log = bcd_to_int(msf[2]);
  1841. +   log += bcd_to_int(msf[1]) * 75;
  1842. +   log += bcd_to_int(msf[0]) * 4500;
  1843. +   log = log - LOG_START_OFFSET;
  1844. +
  1845. +   return log;
  1846. +}
  1847. +
  1848. +
  1849. +/*
  1850. + * Take in integer size value and put it into a buffer like
  1851. + * the drive would want to see a number-of-sector value.
  1852. + */
  1853. +static void
  1854. +size_to_buf(unsigned int size,
  1855. +            unsigned char *buf)
  1856. +{
  1857. +   buf[0] = size / 65536;
  1858. +   size = size % 65536;
  1859. +   buf[1] = size / 256;
  1860. +   buf[2] = size % 256;
  1861. +}
  1862. +
  1863. +
  1864. +/*
  1865. + * The OS calls this to perform a read or write operation to the drive.
  1866. + * Write obviously fail.  Reads to a read ahead of sony_buffer_size
  1867. + * bytes to help speed operations.  This especially helps since the OS
  1868. + * uses 1024 byte blocks and the drive uses 2048 byte blocks.  Since most
  1869. + * data access on a CD is done sequentially, this saves a lot of operations.
  1870. + */
  1871. +static void
  1872. +do_cdu535_request(void)
  1873. +{
  1874. +   int block;
  1875. +   unsigned int dev;
  1876. +   int nsect;
  1877. +   unsigned char params[10];
  1878. +   int copyoff;
  1879. +   int spin_up_retry;
  1880. +   unsigned int read_size;
  1881. +   unsigned char status[2], cmd[2];
  1882. +
  1883. +
  1884. +   if ( !sony_inuse )
  1885. +   {
  1886. +      cdu_open( NULL, NULL );
  1887. +   }
  1888. +   
  1889. +   while (1)
  1890. +   {
  1891. +      /*
  1892. +       * The beginning here is stolen from the hard disk driver.  I hope
  1893. +       * its right.
  1894. +       */
  1895. +      if (!(CURRENT) || CURRENT->dev < 0)
  1896. +      {
  1897. +         return;
  1898. +      }
  1899. +
  1900. +      INIT_REQUEST;
  1901. +      dev = MINOR(CURRENT->dev);
  1902. +      block = CURRENT->sector;
  1903. +      nsect = CURRENT->nr_sectors;
  1904. +      if (dev != 0)
  1905. +      {
  1906. +         end_request(0);
  1907. +         continue;
  1908. +      }
  1909. +
  1910. +      switch(CURRENT->cmd)
  1911. +      {
  1912. +      case READ:
  1913. +         /*
  1914. +          * If the block address is invalid or the request goes beyond the end of
  1915. +          * the media, return an error.
  1916. +          */
  1917. +         if ((block / 4) >= sony_toc->lead_out_start_lba)
  1918. +         {
  1919. +            end_request(0);
  1920. +            return;
  1921. +         }
  1922. +         if (((block + nsect) / 4) >= sony_toc->lead_out_start_lba)
  1923. +         {
  1924. +            end_request(0);
  1925. +            return;
  1926. +         }
  1927. +
  1928. +         while (nsect > 0)
  1929. +         {
  1930. +            /*
  1931. +             * If the requested sector is not currently in the read-ahead buffer,
  1932. +             * it must be read in.
  1933. +             */
  1934. +            if ((block < sony_first_block) || (block > sony_last_block))
  1935. +            {
  1936. +               sony_first_block = (block / 4) * 4;
  1937. +               log_to_msf(block/4, params);
  1938. +
  1939. +               /*
  1940. +                * If the full read-ahead would go beyond the end of the media, trim
  1941. +                * it back to read just till the end of the media.
  1942. +                */
  1943. +               if (((block / 4) + sony_buffer_sectors) >= sony_toc->lead_out_start_lba)
  1944. +               {
  1945. +                  sony_last_block = (sony_toc->lead_out_start_lba * 4) - 1;
  1946. +                  read_size = sony_toc->lead_out_start_lba - (block / 4);
  1947. +               }
  1948. +               else
  1949. +               {
  1950. +                  sony_last_block = sony_first_block + (sony_buffer_sectors * 4) - 1;
  1951. +                  read_size = sony_buffer_sectors;
  1952. +               }
  1953. +               size_to_buf(read_size, ¶ms[3]);
  1954. +
  1955. +               /*
  1956. +                * Read the data.  If the drive was not spinning, spin it up and try
  1957. +                * once more.  I know, the goto is ugly, but I am too lazy to fix it.
  1958. +                */
  1959. +               spin_up_retry = 0;
  1960. +try_read_again:
  1961. +#if 0
  1962. +               if ( check_drive_status() != 0 ) {  /* drive not ready */
  1963. +                  sony_first_block = -1;
  1964. +                  sony_last_block = -1;
  1965. +                  end_request(0);
  1966. +                  return;
  1967. +                  }
  1968. +#endif
  1969. +               if ( seek_and_read_N_blocks( params, read_size, status, sony_buffer,
  1970. +                         (read_size * 2048) ) < 0 ) {
  1971. +                  if ((status[0] & SONY535_STATUS1_NOT_SPINNING) && (!spin_up_retry))
  1972. +                  {
  1973. +                     printk(" Sony535 Debug -- calling spin up when reading data!\n");
  1974. +                     cmd[0] = SONY535_SPIN_UP;
  1975. +                     do_sony_cmd( cmd,1, status, NULL,0, 0);
  1976. +                     spin_up_retry = 1;
  1977. +                     goto try_read_again;
  1978. +                  }
  1979. +
  1980. +                  printk("Sony CDROM Read error: 0x%.2x\n", status[0]);
  1981. +                  sony_first_block = -1;
  1982. +                  sony_last_block = -1;
  1983. +                  end_request(0);
  1984. +                  return;
  1985. +               }
  1986. +            }
  1987. +   
  1988. +            /*
  1989. +             * The data is in memory now, copy it to the buffer and advance to the
  1990. +             * next block to read.
  1991. +             */
  1992. +            copyoff = (block - sony_first_block) * 512;
  1993. +            memcpy(CURRENT->buffer, sony_buffer+copyoff, 512);
  1994. +               
  1995. +            block += 1;
  1996. +            nsect -= 1;
  1997. +            CURRENT->buffer += 512;
  1998. +         }
  1999. +               
  2000. +         end_request(1);
  2001. +         break;
  2002. +            
  2003. +      case WRITE:
  2004. +         end_request(0);
  2005. +         break;
  2006. +            
  2007. +      default:
  2008. +         panic("Unkown SONY CD cmd");
  2009. +      }
  2010. +   }
  2011. +}
  2012. +
  2013. +
  2014. +/*
  2015. + * Read the table of contents from the drive and set sony_toc_read if
  2016. + * successful.
  2017. + */
  2018. +static void
  2019. +sony_get_toc(void)
  2020. +{
  2021. +   unsigned char status[2];
  2022. +  
  2023. +   if ( !sony_toc_read ) 
  2024. +   {
  2025. +       /* do not call check_drive_status() from here since it can call this routine */
  2026. +      if ( request_toc_data( status, sony_toc ) < 0 )
  2027. +         return;
  2028. +      sony_toc->lead_out_start_lba = msf_to_log(sony_toc->lead_out_start_msf);
  2029. +      sony_toc_read = 1;
  2030. +   }
  2031. +}
  2032. +
  2033. +
  2034. +/*
  2035. + * Search for a specific track in the table of contents.  track is
  2036. + * passed in bcd format
  2037. + */
  2038. +static int
  2039. +find_track(int track)
  2040. +{
  2041. +   int i;
  2042. +   int num_tracks;
  2043. +
  2044. +
  2045. +   num_tracks = bcd_to_int(sony_toc->last_track_num) - 
  2046. +                   bcd_to_int(sony_toc->first_track_num) + 1;
  2047. +   for (i = 0; i < num_tracks; i++)
  2048. +   {
  2049. +      if (sony_toc->tracks[i].track == track)
  2050. +      {
  2051. +         return i;
  2052. +      }
  2053. +   }
  2054. +
  2055. +   return -1;
  2056. +}
  2057. +
  2058. +/*
  2059. + * Read the subcode and put it int last_sony_subcode for future use.
  2060. + */
  2061. +static int
  2062. +read_subcode(void)
  2063. +{
  2064. +   Byte cmd = SONY535_REQUEST_SUB_Q_DATA, status[2];
  2065. +   int dsc_status;
  2066. +   
  2067. +   if ( check_drive_status() != 0 )
  2068. +      return( -EIO );
  2069. +     
  2070. +   if ( (dsc_status=do_sony_cmd( &cmd,1, status, (Byte *)last_sony_subcode, 
  2071. +                      sizeof(struct s535_sony_subcode), 1 )) != 0 ) 
  2072. +   {
  2073. +      printk("Sony CDROM error 0x%.2x, %d (read_subcode)\n", status[0], 
  2074. +              dsc_status );
  2075. +      return( -EIO );
  2076. +   }
  2077. +   return(0);
  2078. +}
  2079. +
  2080. +
  2081. +/*
  2082. + * Get the subchannel info like the CDROMSUBCHNL command wants to see it.  If
  2083. + * the drive is playing, the subchannel needs to be read (since it would be
  2084. + * changing).  If the drive is paused or completed, the subcode information has
  2085. + * already been stored, just use that.  The ioctl call wants things in decimal
  2086. + * (not BCD), so all the conversions are done.
  2087. + */
  2088. +static int
  2089. +sony_get_subchnl_info(long arg)
  2090. +{
  2091. +   struct cdrom_subchnl schi;
  2092. +
  2093. +
  2094. +   /* Get attention stuff */
  2095. +   if ( check_drive_status() != 0 )
  2096. +      return( -EIO );
  2097. +
  2098. +   sony_get_toc();
  2099. +   if (!sony_toc_read)
  2100. +   {
  2101. +      return -EIO;
  2102. +   }
  2103. +
  2104. +   verify_area(VERIFY_WRITE /* and read */, (char *) arg, sizeof(schi));
  2105. +
  2106. +   memcpy_fromfs(&schi, (char *) arg, sizeof(schi));
  2107. +   
  2108. +   switch (sony_audio_status)
  2109. +   {
  2110. +   case CDROM_AUDIO_PLAY:
  2111. +      if (read_subcode() < 0)
  2112. +      {
  2113. +         return -EIO;
  2114. +      }
  2115. +      break;
  2116. +
  2117. +   case CDROM_AUDIO_PAUSED:
  2118. +   case CDROM_AUDIO_COMPLETED:
  2119. +      break;
  2120. +
  2121. +   case CDROM_AUDIO_NO_STATUS:
  2122. +      schi.cdsc_audiostatus = sony_audio_status;
  2123. +      memcpy_tofs((char *) arg, &schi, sizeof(schi));
  2124. +      return 0;
  2125. +      break;
  2126. +
  2127. +   case CDROM_AUDIO_INVALID:
  2128. +   case CDROM_AUDIO_ERROR:
  2129. +   default:
  2130. +      return -EIO;
  2131. +   }
  2132. +
  2133. +   schi.cdsc_audiostatus = sony_audio_status;
  2134. +   schi.cdsc_adr = last_sony_subcode->address;
  2135. +   schi.cdsc_ctrl = last_sony_subcode->control;
  2136. +   schi.cdsc_trk = bcd_to_int(last_sony_subcode->track_num);
  2137. +   schi.cdsc_ind = bcd_to_int(last_sony_subcode->index_num);
  2138. +   if (schi.cdsc_format == CDROM_MSF)
  2139. +   {
  2140. +      schi.cdsc_absaddr.msf.minute = bcd_to_int(last_sony_subcode->abs_msf[0]);
  2141. +      schi.cdsc_absaddr.msf.second = bcd_to_int(last_sony_subcode->abs_msf[1]);
  2142. +      schi.cdsc_absaddr.msf.frame = bcd_to_int(last_sony_subcode->abs_msf[2]);
  2143. +
  2144. +      schi.cdsc_reladdr.msf.minute = bcd_to_int(last_sony_subcode->rel_msf[0]);
  2145. +      schi.cdsc_reladdr.msf.second = bcd_to_int(last_sony_subcode->rel_msf[1]);
  2146. +      schi.cdsc_reladdr.msf.frame = bcd_to_int(last_sony_subcode->rel_msf[2]);
  2147. +   }
  2148. +   else if (schi.cdsc_format == CDROM_LBA)
  2149. +   {
  2150. +      schi.cdsc_absaddr.lba = msf_to_log(last_sony_subcode->abs_msf);
  2151. +      schi.cdsc_reladdr.lba = msf_to_log(last_sony_subcode->rel_msf);
  2152. +   }
  2153. +   
  2154. +   memcpy_tofs((char *) arg, &schi, sizeof(schi));
  2155. +   return 0;
  2156. +}
  2157. +
  2158. +
  2159. +/*
  2160. + * The big ugly ioctl handler.
  2161. + */
  2162. +static int
  2163. +cdu_ioctl(struct inode *inode,
  2164. +          struct file  *file,
  2165. +          unsigned int cmd,
  2166. +          unsigned long arg)
  2167. +{
  2168. +   unsigned int dev;
  2169. +   unsigned char status[2];
  2170. +   unsigned char cmd_buff[10], params[10];
  2171. +   int i, dsc_status;
  2172. +
  2173. +
  2174. +   if (!inode)
  2175. +   {
  2176. +      return -EINVAL;
  2177. +   }
  2178. +   dev = MINOR(inode->i_rdev) >> 6;
  2179. +   if (dev != 0)
  2180. +   {
  2181. +      return -EINVAL;
  2182. +   }
  2183. +   
  2184. +   if ( check_drive_status() != 0 )
  2185. +      return( -EIO );
  2186. +
  2187. +   switch (cmd)
  2188. +   {
  2189. +   case CDROMSTART:     /* Spin up the drive */
  2190. +      if ( spin_up_drive( status ) < 0 )
  2191. +      {
  2192. +         printk("Sony CDROM error 0x%.2x (CDROMSTART)\n", status[0]);
  2193. +         return -EIO;
  2194. +      }
  2195. +      return 0;
  2196. +      break;
  2197. +      
  2198. +   case CDROMSTOP:      /* Spin down the drive */
  2199. +      cmd_buff[0] = SONY535_HOLD;
  2200. +      do_sony_cmd( cmd_buff,1, status, NULL,0, 0 );
  2201. +
  2202. +      /*
  2203. +       * Spin the drive down, ignoring the error if the disk was
  2204. +       * already not spinning.
  2205. +       */
  2206. +      sony_audio_status = CDROM_AUDIO_NO_STATUS;
  2207. +      cmd_buff[0] = SONY535_SPIN_DOWN;
  2208. +      dsc_status = do_sony_cmd( cmd_buff,1, status, NULL,0, 0 );
  2209. +      if ( (( dsc_status < 0 ) && (dsc_status != BAD_STATUS)) ||
  2210. +           ( (status[0] & ~(SONY535_STATUS1_NOT_SPINNING)) != 0) ) 
  2211. +      {
  2212. +         printk("Sony CDROM error 0x%.2x (CDROMSTOP)\n", status[0]);
  2213. +         return -EIO;
  2214. +      }
  2215. +      
  2216. +      return 0;
  2217. +      break;
  2218. +
  2219. +   case CDROMPAUSE:     /* Pause the drive */
  2220. +      cmd_buff[0] = SONY535_HOLD;  /* CDU-31 driver uses AUDIO_STOP, not pause */
  2221. +      if ( do_sony_cmd( cmd_buff,1, status, NULL,0, 0 ) != 0 ) 
  2222. +      {
  2223. +         printk("Sony CDROM error 0x%.2x (CDROMPAUSE)\n", status[0]);
  2224. +         return -EIO;
  2225. +      }
  2226. +
  2227. +      /* Get the current position and save it for resuming */
  2228. +      if (read_subcode() < 0)
  2229. +      {
  2230. +         return -EIO;
  2231. +      }
  2232. +      cur_pos_msf[0] = last_sony_subcode->abs_msf[0];
  2233. +      cur_pos_msf[1] = last_sony_subcode->abs_msf[1];
  2234. +      cur_pos_msf[2] = last_sony_subcode->abs_msf[2];
  2235. +      sony_audio_status = CDROM_AUDIO_PAUSED;
  2236. +      return 0;
  2237. +      break;
  2238. +
  2239. +   case CDROMRESUME:    /* Start the drive after being paused */
  2240. +      set_drive_mode( SONY535_AUDIO_DRIVE_MODE, status );
  2241. +      
  2242. +      if (sony_audio_status != CDROM_AUDIO_PAUSED)
  2243. +      {
  2244. +         return -EINVAL;
  2245. +      }
  2246. +      
  2247. +      spin_up_drive( status );
  2248. +      
  2249. +      /* Start the drive at the saved position. */
  2250. +      cmd_buff[0] = SONY535_PLAY_AUDIO;
  2251. +      cmd_buff[1] = 0;  /* play back starting at this address */
  2252. +      cmd_buff[2] = cur_pos_msf[0];
  2253. +      cmd_buff[3] = cur_pos_msf[1];
  2254. +      cmd_buff[4] = cur_pos_msf[2];
  2255. +      cmd_buff[5] = SONY535_PLAY_AUDIO;
  2256. +      cmd_buff[6] = 2;  /* set ending address */
  2257. +      cmd_buff[7] = final_pos_msf[0];
  2258. +      cmd_buff[8] = final_pos_msf[1];
  2259. +      cmd_buff[9] = final_pos_msf[2];
  2260. +      if ( (do_sony_cmd( cmd_buff,5, status, NULL,0, 0 ) != 0 ) ||
  2261. +           (do_sony_cmd( cmd_buff+5,5, status, NULL,0, 0 ) != 0 ) )
  2262. +      {
  2263. +         printk("Sony CDROM error 0x%.2x (CDROMRESUME)\n", status[0]);
  2264. +         return -EIO;
  2265. +      }
  2266. +      sony_audio_status = CDROM_AUDIO_PLAY;
  2267. +      return 0;
  2268. +      break;
  2269. +
  2270. +   case CDROMPLAYMSF:   /* Play starting at the given MSF address. */
  2271. +      verify_area(VERIFY_READ, (char *) arg, 6);
  2272. +      spin_up_drive( status );
  2273. +      set_drive_mode( SONY535_AUDIO_DRIVE_MODE, status );
  2274. +      memcpy_fromfs(params, (void *) arg, 6);
  2275. +      
  2276. +      /* The parameters are given in int, must be converted */
  2277. +      for (i=0; i<3; i++)
  2278. +      {
  2279. +         cmd_buff[2+i] = int_to_bcd(params[i]);
  2280. +         cmd_buff[7+i] = int_to_bcd(params[i+3]);
  2281. +      }
  2282. +      cmd_buff[0] = SONY535_PLAY_AUDIO;
  2283. +      cmd_buff[1] = 0;  /* play back starting at this address */
  2284. +       /* cmd_buff[2-4] are filled in for loop above */
  2285. +      cmd_buff[5] = SONY535_PLAY_AUDIO;
  2286. +      cmd_buff[6] = 2;  /* set ending address */
  2287. +       /* cmd_buff[7-9] are filled in for loop above */
  2288. +      if ( (do_sony_cmd( cmd_buff,5, status, NULL,0, 0 ) != 0 ) ||
  2289. +           (do_sony_cmd( cmd_buff+5,5, status, NULL,0, 0 ) != 0 ) )
  2290. +      {
  2291. +         printk("Sony CDROM error 0x%.2x (CDROMPLAYMSF)\n", status[0]);
  2292. +         return -EIO;
  2293. +      }
  2294. +      
  2295. +      /* Save the final position for pauses and resumes */
  2296. +      final_pos_msf[0] = cmd_buff[7];
  2297. +      final_pos_msf[1] = cmd_buff[8];
  2298. +      final_pos_msf[2] = cmd_buff[9];
  2299. +      sony_audio_status = CDROM_AUDIO_PLAY;
  2300. +      return 0;
  2301. +      break;
  2302. +
  2303. +   case CDROMREADTOCHDR:        /* Read the table of contents header */
  2304. +      {
  2305. +         struct cdrom_tochdr *hdr;
  2306. +         struct cdrom_tochdr loc_hdr;
  2307. +         
  2308. +         sony_get_toc();
  2309. +         if (!sony_toc_read)
  2310. +         {
  2311. +            return -EIO;
  2312. +         }
  2313. +         
  2314. +         hdr = (struct cdrom_tochdr *) arg;
  2315. +         verify_area(VERIFY_WRITE, hdr, sizeof(*hdr));
  2316. +         loc_hdr.cdth_trk0 = bcd_to_int(sony_toc->first_track_num);
  2317. +         loc_hdr.cdth_trk1 = bcd_to_int(sony_toc->last_track_num);
  2318. +         memcpy_tofs(hdr, &loc_hdr, sizeof(*hdr));
  2319. +      }
  2320. +      return 0;
  2321. +      break;
  2322. +
  2323. +   case CDROMREADTOCENTRY:      /* Read a given table of contents entry */
  2324. +      {
  2325. +         struct cdrom_tocentry *entry;
  2326. +         struct cdrom_tocentry loc_entry;
  2327. +         int track_idx;
  2328. +         unsigned char *msf_val = NULL;
  2329. +         
  2330. +         sony_get_toc();
  2331. +         if (!sony_toc_read)
  2332. +         {
  2333. +            return -EIO;
  2334. +         }
  2335. +         
  2336. +         entry = (struct cdrom_tocentry *) arg;
  2337. +         verify_area(VERIFY_WRITE /* and read */, entry, sizeof(*entry));
  2338. +         
  2339. +         memcpy_fromfs(&loc_entry, entry, sizeof(loc_entry));
  2340. +         
  2341. +         /* Lead out is handled separately since it is special. */
  2342. +         if (loc_entry.cdte_track == CDROM_LEADOUT)
  2343. +         {
  2344. +            loc_entry.cdte_adr = 0 /*sony_toc->address2*/;
  2345. +            loc_entry.cdte_ctrl = sony_toc->control2;
  2346. +            msf_val = sony_toc->lead_out_start_msf;
  2347. +         }
  2348. +         else
  2349. +         {
  2350. +            track_idx = find_track(int_to_bcd(loc_entry.cdte_track));
  2351. +            if (track_idx < 0)
  2352. +            {
  2353. +               return -EINVAL;
  2354. +            }
  2355. +            
  2356. +            loc_entry.cdte_adr = 0 /*sony_toc->tracks[track_idx].address*/;
  2357. +            loc_entry.cdte_ctrl = sony_toc->tracks[track_idx].control;
  2358. +            msf_val = sony_toc->tracks[track_idx].track_start_msf;
  2359. +         }
  2360. +         
  2361. +         /* Logical buffer address or MSF format requested? */
  2362. +         if (loc_entry.cdte_format == CDROM_LBA)
  2363. +         {
  2364. +            loc_entry.cdte_addr.lba = msf_to_log(msf_val);
  2365. +         }
  2366. +         else if (loc_entry.cdte_format == CDROM_MSF)
  2367. +         {
  2368. +            loc_entry.cdte_addr.msf.minute = bcd_to_int(*msf_val);
  2369. +            loc_entry.cdte_addr.msf.second = bcd_to_int(*(msf_val+1));
  2370. +            loc_entry.cdte_addr.msf.frame = bcd_to_int(*(msf_val+2));
  2371. +         }
  2372. +         memcpy_tofs(entry, &loc_entry, sizeof(*entry));
  2373. +      }
  2374. +      return 0;
  2375. +      break;
  2376. +
  2377. +   case CDROMPLAYTRKIND:     /* Play a track.  This currently ignores index. */
  2378. +      {
  2379. +         struct cdrom_ti ti;
  2380. +         int track_idx;
  2381. +         
  2382. +         sony_get_toc();
  2383. +         if (!sony_toc_read)
  2384. +         {
  2385. +            return -EIO;
  2386. +         }
  2387. +         
  2388. +         verify_area( VERIFY_READ, (char *) arg, sizeof(ti));
  2389. +         
  2390. +         memcpy_fromfs(&ti, (char *) arg, sizeof(ti));
  2391. +         if (   (ti.cdti_trk0 < sony_toc->first_track_num)
  2392. +             || (ti.cdti_trk0 > sony_toc->last_track_num)
  2393. +             || (ti.cdti_trk1 < ti.cdti_trk0))
  2394. +         {
  2395. +            return -EINVAL;
  2396. +         }
  2397. +         
  2398. +         track_idx = find_track(int_to_bcd(ti.cdti_trk0));
  2399. +         if (track_idx < 0)
  2400. +         {
  2401. +            return -EINVAL;
  2402. +         }
  2403. +         params[1] = sony_toc->tracks[track_idx].track_start_msf[0];
  2404. +         params[2] = sony_toc->tracks[track_idx].track_start_msf[1];
  2405. +         params[3] = sony_toc->tracks[track_idx].track_start_msf[2];
  2406. +         /*
  2407. +          * If we want to stop after the last track, use the lead-out
  2408. +          * MSF to do that.
  2409. +          */
  2410. +         if (ti.cdti_trk1 >= bcd_to_int(sony_toc->last_track_num))
  2411. +         {
  2412. +            log_to_msf(msf_to_log(sony_toc->lead_out_start_msf)-1,
  2413. +                       &(params[4]));
  2414. +         }
  2415. +         else
  2416. +         {
  2417. +            track_idx = find_track(int_to_bcd(ti.cdti_trk1+1));
  2418. +            if (track_idx < 0)
  2419. +            {
  2420. +               return -EINVAL;
  2421. +            }
  2422. +            log_to_msf(msf_to_log(sony_toc->tracks[track_idx].track_start_msf)-1,
  2423. +                       &(params[4]));
  2424. +         }
  2425. +         params[0] = 0x03;
  2426. +         
  2427. +         spin_up_drive( status );
  2428. +         
  2429. +         set_drive_mode( SONY535_AUDIO_DRIVE_MODE, status );
  2430. +      
  2431. +         /* Start the drive at the saved position. */
  2432. +         cmd_buff[0] = SONY535_PLAY_AUDIO;
  2433. +         cmd_buff[1] = 0;  /* play back starting at this address */
  2434. +         cmd_buff[2] = params[1];
  2435. +         cmd_buff[3] = params[2];
  2436. +         cmd_buff[4] = params[3];
  2437. +         cmd_buff[5] = SONY535_PLAY_AUDIO;
  2438. +         cmd_buff[6] = 2;  /* set ending address */
  2439. +         cmd_buff[7] = params[4];
  2440. +         cmd_buff[8] = params[5];
  2441. +         cmd_buff[9] = params[6];
  2442. +         if ( (do_sony_cmd( cmd_buff,5, status, NULL,0, 0 ) != 0 ) ||
  2443. +              (do_sony_cmd( cmd_buff+5,5, status, NULL,0, 0 ) != 0 ) )
  2444. +         {
  2445. +            printk("Params: %x %x %x %x %x %x %x\n", params[0], params[1],
  2446. +                   params[2], params[3], params[4], params[5], params[6]);
  2447. +            printk("Sony CDROM error 0x%.2x (CDROMPLAYTRKIND)\n", status[0]);
  2448. +            return -EIO;
  2449. +         }
  2450. +         
  2451. +         /* Save the final position for pauses and resumes */
  2452. +         final_pos_msf[0] = params[4];
  2453. +         final_pos_msf[1] = params[5];
  2454. +         final_pos_msf[2] = params[6];
  2455. +         sony_audio_status = CDROM_AUDIO_PLAY;
  2456. +         return 0;
  2457. +      }
  2458. +     
  2459. +   case CDROMSUBCHNL:   /* Get subchannel info */
  2460. +      return sony_get_subchnl_info(arg);
  2461. +
  2462. +   case CDROMVOLCTRL:   /* Volume control.  What volume does this change, anyway? */
  2463. +      {
  2464. +         struct cdrom_volctrl volctrl;
  2465. +         
  2466. +         verify_area(VERIFY_READ, (char *) arg, sizeof(volctrl));
  2467. +         
  2468. +         memcpy_fromfs(&volctrl, (char *) arg, sizeof(volctrl));
  2469. +         cmd_buff[0] = SONY535_SET_VOLUME;
  2470. +         cmd_buff[1] = volctrl.channel0;
  2471. +         cmd_buff[2] = volctrl.channel1;
  2472. +         if ( do_sony_cmd( cmd_buff,3, status, NULL,0, 0 ) != 0 )
  2473. +         {
  2474. +            printk("Sony CDROM error 0x%.2x (CDROMVOLCTRL)\n", status[0]);
  2475. +            return -EIO;
  2476. +         }
  2477. +      }
  2478. +      return 0;
  2479. +
  2480. +   case CDROMEJECT:     /* Eject the drive */
  2481. +      cmd_buff[0] = SONY535_STOP;
  2482. +      do_sony_cmd( cmd_buff,1, status, NULL,0, 0 );
  2483. +      cmd_buff[0] = SONY535_SPIN_DOWN;
  2484. +      do_sony_cmd( cmd_buff,1, status, NULL,0, 0 );
  2485. +
  2486. +      sony_audio_status = CDROM_AUDIO_INVALID;
  2487. +      cmd_buff[0] = SONY535_EJECT_CADDY;
  2488. +      if ( do_sony_cmd( cmd_buff,1, status, NULL,0, 0 ) != 0 )
  2489. +      {
  2490. +         printk("Sony CDROM error 0x%.2x (CDROMEJECT)\n", status[0]);
  2491. +         return -EIO;
  2492. +      }
  2493. +      return 0;
  2494. +      break;
  2495. +     
  2496. +   default:
  2497. +      return -EINVAL;
  2498. +   }
  2499. +}
  2500. +
  2501. +
  2502. +/*
  2503. + * Open the drive for operations.  Spin the drive up and read the table of
  2504. + * contents if these have not already been done.
  2505. + */
  2506. +static int
  2507. +cdu_open(struct inode *inode,
  2508. +         struct file *filp)
  2509. +{
  2510. +   unsigned char status[2], cmd_buff[2];
  2511. +
  2512. +
  2513. +   if ( sony_inuse )
  2514. +   {
  2515. +      return( -EBUSY );
  2516. +   }
  2517. +   
  2518. +   if ( check_drive_status() != 0 )
  2519. +   {
  2520. +      return( -EIO );
  2521. +   }
  2522. +      
  2523. +   sony_inuse = 1;
  2524. +   
  2525. +   if ( spin_up_drive( status ) != 0 )
  2526. +   {
  2527. +      printk("Sony CDROM error 0x%.2x (cdu_open, spin up)\n", status[0]);
  2528. +      sony_inuse = 0;
  2529. +      return -EIO;
  2530. +   }
  2531. +      
  2532. +#if 0  /* what is this doing - CDU-535 does not have separate READ and REQ_TOC */
  2533. +   do_sony_cd_cmd(SONY_READ_TOC_CMD, NULL, 0, res_reg, &res_size);
  2534. +   if ((res_size < 2) || (res_reg[0] != 0))
  2535. +   {
  2536. +      /* If the drive is already playing, its ok. */
  2537. +      if (res_reg[1] == SONY_AUDIO_PLAYING_ERR)
  2538. +      {
  2539. +         goto drive_spinning;
  2540. +      }
  2541. +
  2542. +      printk("Sony CDROM error 0x%.2x (cdu_open, read toc)\n", res_reg[1]);
  2543. +      do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, &res_size);
  2544. +      
  2545. +      sony_inuse = 0;
  2546. +      return -EIO;
  2547. +   }
  2548. +#endif
  2549. +
  2550. +   sony_get_toc();
  2551. +   if (!sony_toc_read)
  2552. +   {
  2553. +      cmd_buff[0] = SONY535_SPIN_DOWN;
  2554. +      do_sony_cmd( cmd_buff,1, status, NULL,0, 0 );
  2555. +      sony_inuse = 0;
  2556. +      return -EIO;
  2557. +   }
  2558. +      
  2559. +#if 0  /* not used without stuff read toc above */
  2560. +drive_spinning:
  2561. +#endif
  2562. +
  2563. +   if ( inode ) 
  2564. +   {
  2565. +      check_disk_change(inode->i_rdev);
  2566. +   }
  2567. +
  2568. +   sony_usage++;
  2569. +   
  2570. +#ifdef LOCK_DOORS
  2571. +    /* disable the eject button while mounted */
  2572. +   cmd_buff[0] = SONY535_DISABLE_EJECT_BUTTON;
  2573. +   do_sony_cmd( cmd_buff,1, status, NULL,0, 0 );
  2574. +#endif
  2575. +
  2576. +   return 0;
  2577. +}
  2578. +
  2579. +
  2580. +/*
  2581. + * Close the drive.  Spin it down if no task is using it.  The spin
  2582. + * down will fail if playing audio, so audio play is OK.
  2583. + */
  2584. +static void
  2585. +cdu_release(struct inode *inode,
  2586. +         struct file *filp)
  2587. +{
  2588. +   unsigned char status[2], cmd_no;
  2589. +
  2590. +   sony_inuse = 0;
  2591. +
  2592. +   if (sony_usage > 0)
  2593. +   {
  2594. +      sony_usage--;
  2595. +   }
  2596. +   if (sony_usage == 0)
  2597. +   {
  2598. +      sync_dev(inode->i_rdev);
  2599. +      check_drive_status();
  2600. +
  2601. +      if ( sony_audio_status != CDROM_AUDIO_PLAY ) {
  2602. +         cmd_no = SONY535_SPIN_DOWN;
  2603. +         do_sony_cmd( &cmd_no,1, status, NULL,0, 0 );
  2604. +         }
  2605. +#ifdef LOCK_DOORS
  2606. +       /* enable the eject button after umount */
  2607. +      cmd_no = SONY535_ENABLE_EJECT_BUTTON;
  2608. +      do_sony_cmd( &cmd_no,1, status, NULL,0, 0 );
  2609. +#endif
  2610. +   }
  2611. +}
  2612. +
  2613. +
  2614. +static struct file_operations cdu_fops = {
  2615. +   NULL,                   /* lseek - default */
  2616. +   block_read,             /* read - general block-dev read */
  2617. +   block_write,            /* write - general block-dev write */
  2618. +   NULL,                   /* readdir - bad */
  2619. +   NULL,                   /* select */
  2620. +   cdu_ioctl,              /* ioctl */
  2621. +   NULL,                   /* mmap */
  2622. +   cdu_open,               /* open */
  2623. +   cdu_release,            /* release */
  2624. +   NULL,                   /* fsync */
  2625. +   NULL,                   /* fasync */
  2626. +   cdu535_check_media_change, /* check_media_change */
  2627. +   NULL                    /* revalidate */
  2628. +};
  2629. +
  2630. +
  2631. +/*
  2632. + * Initialize the driver.
  2633. + */
  2634. +unsigned long
  2635. +init_sony535(unsigned long mem_start, unsigned long mem_end)
  2636. +{
  2637. +   struct s535_sony_drive_config drive_config;
  2638. +   unsigned char cmd_buff[3], ret_buff[2];
  2639. +   unsigned char status[2];
  2640. +   int retry_count;
  2641. +
  2642. +
  2643. +   /* Set up all the register locations */
  2644. +   result_reg = sony_cd_base_io;
  2645. +   command_reg = sony_cd_base_io;
  2646. +   data_reg = sony_cd_base_io + 1;
  2647. +   read_status_reg = sony_cd_base_io + 2;
  2648. +   select_unit_reg = sony_cd_base_io + 3;
  2649. +
  2650. +    /* look for the CD-ROM, follows the procedure in the DOS driver */
  2651. +   inb( select_unit_reg );
  2652. +   retry_count = jiffies + 2*HZ;
  2653. +   while ( retry_count > jiffies )
  2654. +      sony_sleep();        /* wait for 40 18 Hz ticks (from DOS driver) */
  2655. +   inb( result_reg );
  2656. +   
  2657. +   outb( 0, read_status_reg );    /* does a reset? */
  2658. +   retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
  2659. +   while ( retry_count > jiffies ) 
  2660. +   {
  2661. +      select_unit(0);
  2662. +      if ( inb( result_reg ) != 0xff )
  2663. +         break;
  2664. +      sony_sleep();  /* about 1-2 ms on my machine */
  2665. +   }
  2666. +   
  2667. +   if ( (retry_count > jiffies) && (check_drive_status() != TIME_OUT) ) 
  2668. +   {  
  2669. +       /* CD-ROM drive responded --  get the drive configuration */
  2670. +      cmd_buff[0] = SONY535_INQUIRY;
  2671. +      if ( do_sony_cmd( cmd_buff,1, status, (Byte *)&drive_config, 28, 1) == 0 ) 
  2672. +      {
  2673. +          /* was able to get the configuration, set drive mode as rest of init */
  2674. +         if ( (status[0] & 0x7f) != 0 )
  2675. +            printk("Inquiry command returned status = 0x%x\n",status[0]);
  2676. +         cmd_buff[0] = SONY535_SET_DRIVE_MODE;
  2677. +         cmd_buff[1] = 0x0;  /* default audio */
  2678. +         if (do_sony_cmd( cmd_buff,2, status, ret_buff,1, 1 ) == 0 ) 
  2679. +         {
  2680. +             /* set the drive mode successful, we are set! */
  2681. +            sony_buffer_size = SONY535_BUFFER_SIZE;
  2682. +            sony_buffer_sectors = sony_buffer_size / 2048;
  2683. +
  2684. +            printk("Sony I/F CDROM : %8.8s %16.16s %4.4s",
  2685. +                   drive_config.vendor_id,
  2686. +                   drive_config.product_id,
  2687. +                   drive_config.product_rev_level );
  2688. +            printk("  using %d byte buffer\n", sony_buffer_size);
  2689. +
  2690. +        if (register_blkdev(MAJOR_NR,"cdu",&cdu_fops)) {
  2691. +        printk("Unable to get major %d for sony CDU-535 cd\n",MAJOR_NR);
  2692. +        return( mem_start );
  2693. +        }
  2694. +            blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;
  2695. +            read_ahead[MAJOR_NR] = 8;               /* 8 sector (4kB) read-ahead */
  2696. +
  2697. +            sony_toc = (struct s535_sony_toc *) mem_start;
  2698. +            mem_start += sizeof(*sony_toc);
  2699. +            last_sony_subcode = (struct s535_sony_subcode *) mem_start;
  2700. +            mem_start += sizeof(*last_sony_subcode);
  2701. +            sony_buffer = (unsigned char *) mem_start;
  2702. +            mem_start += sony_buffer_size;
  2703. +
  2704. +            initialized = 1;
  2705. +         }
  2706. +      }
  2707. +   }
  2708. +
  2709. +   if ( !initialized )
  2710. +      printk( "Did not find a Sony CDU-535 drive\n");
  2711. +
  2712. +   return mem_start;
  2713. +}
  2714. +
  2715. +#endif  /* CONFIG_CDU535 */
  2716. diff -u --recursive --new-file linux-1.1.58/drivers/block/version.h linux/drivers/block/version.h
  2717. --- linux-1.1.58/drivers/block/version.h    Wed Dec 31 18:00:00 1969
  2718. +++ linux/drivers/block/version.h    Wed Oct 26 23:02:00 1994
  2719. @@ -0,0 +1,7 @@
  2720. +#define UTS_RELEASE "1.1.53"
  2721. +#define UTS_VERSION "#8 Wed Oct 12 21:48:39 CDT 1994"
  2722. +#define LINUX_COMPILE_TIME "21:48:39"
  2723. +#define LINUX_COMPILE_BY "root"
  2724. +#define LINUX_COMPILE_HOST "fuzzy"
  2725. +#define LINUX_COMPILE_DOMAIN "is.a.good.cat"
  2726. +#define LINUX_COMPILER "gcc version 2.5.8"
  2727. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/53c8xx_d.h linux/drivers/scsi/53c8xx_d.h
  2728. --- linux-1.1.58/drivers/scsi/53c8xx_d.h    Sat Sep 17 21:48:35 1994
  2729. +++ linux/drivers/scsi/53c8xx_d.h    Wed Oct 26 23:02:00 1994
  2730. @@ -296,7 +296,7 @@
  2731.  ABSOLUTE reselected_tag = 0
  2732.  
  2733.  ; Request sense command pointer, its a 6 byte command, should
  2734. -; be constant for all commands since we allays want 16 bytes of 
  2735. +; be constant for all commands since we always want 16 bytes of 
  2736.  ; sense and we don't need to change any fields as we did under 
  2737.  ; SCSI-I when we actually cared about the LUN field.
  2738.  ;EXTERNAL NCR53c7xx_sense        ; Request sense command
  2739. @@ -314,7 +314,7 @@
  2740.  ;
  2741.  ; MODIFIES : SCRATCH, reconnect_dsa_head
  2742.  ; 
  2743. -; EXITS : allays passes control to schedule
  2744. +; EXITS : always passes control to schedule
  2745.  
  2746.  ENTRY dsa_schedule
  2747.  dsa_schedule:
  2748. @@ -1378,7 +1378,7 @@
  2749.      ; XXX the ALU is only eight bits wide, and the assembler
  2750.      ; wont do the dirt work for us.  As long as dsa_check_reselect
  2751.      ; is negative, we need to sign extend with 1 bits to the full
  2752. -    ; 32 bit width of the address.
  2753. +    ; 32 bit width os the address.
  2754.      ;
  2755.      ; A potential work around would be to have a known alignment 
  2756.      ; of the DSA structure such that the base address plus 
  2757. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/Makefile linux/drivers/scsi/Makefile
  2758. --- linux-1.1.58/drivers/scsi/Makefile    Sat Sep 17 21:47:29 1994
  2759. +++ linux/drivers/scsi/Makefile    Wed Oct 26 23:02:01 1994
  2760. @@ -62,6 +62,11 @@
  2761.  SCSI_SRCS := $(SCSI_SRCS) aha1740.c
  2762.  endif
  2763.  
  2764. +ifdef CONFIG_SCSI_AHA274X
  2765. +SCSI_OBJS := $(SCSI_OBJS) aha274x.o
  2766. +SCSI_SRCS := $(SCSI_SRCS) aha274x.c
  2767. +endif
  2768. +
  2769.  ifdef CONFIG_SCSI_BUSLOGIC
  2770.  SCSI_OBJS := $(SCSI_OBJS) buslogic.o
  2771.  SCSI_SRCS := $(SCSI_SRCS) buslogic.c
  2772. @@ -70,6 +75,11 @@
  2773.  ifdef CONFIG_SCSI_DEBUG
  2774.  SCSI_OBJS := $(SCSI_OBJS) scsi_debug.o
  2775.  SCSI_SRCS := $(SCSI_SRCS) scsi_debug.c
  2776. +endif
  2777. +
  2778. +ifdef CONFIG_SCSI_EATA
  2779. +SCSI_OBJS := $(SCSI_OBJS) eata.o
  2780. +SCSI_SRCS := $(SCSI_SRCS) eata.c
  2781.  endif
  2782.  
  2783.  ifdef CONFIG_SCSI_FUTURE_DOMAIN
  2784. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/aha274x.c linux/drivers/scsi/aha274x.c
  2785. --- linux-1.1.58/drivers/scsi/aha274x.c    Wed Dec 31 18:00:00 1969
  2786. +++ linux/drivers/scsi/aha274x.c    Wed Oct 26 23:02:01 1994
  2787. @@ -0,0 +1,1449 @@
  2788. +/*
  2789. + *  @(#)aha274x.c 1.28 94/10/04 jda
  2790. + *
  2791. + *  Adaptec 274x device driver for Linux.
  2792. + *  Copyright (c) 1994 The University of Calgary Department of Computer Science.
  2793. + *  
  2794. + *  This program is free software; you can redistribute it and/or modify
  2795. + *  it under the terms of the GNU General Public License as published by
  2796. + *  the Free Software Foundation; either version 2 of the License, or
  2797. + *  (at your option) any later version.
  2798. + *  
  2799. + *  This program is distributed in the hope that it will be useful,
  2800. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2801. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2802. + *  GNU General Public License for more details.
  2803. + *  
  2804. + *  You should have received a copy of the GNU General Public License
  2805. + *  along with this program; if not, write to the Free Software
  2806. + *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2807. + *
  2808. + *  Sources include the Adaptec 1740 driver (aha1740.c), the
  2809. + *  Ultrastor 24F driver (ultrastor.c), various Linux kernel
  2810. + *  source, the Adaptec EISA config file (!adp7771.cfg), the
  2811. + *  Adaptec AHA-2740A Series User's Guide, the Linux Kernel
  2812. + *  Hacker's Guide, Writing a SCSI Device Driver for Linux,
  2813. + *  the Adaptec 1542 driver (aha1542.c), the Adaptec EISA
  2814. + *  overlay file (adp7770.ovl), the Adaptec AHA-2740 Series
  2815. + *  Technical Reference Manual, the Adaptec AIC-7770 Data
  2816. + *  Book, the ANSI SCSI specification, the ANSI SCSI-2
  2817. + *  specification (draft 10c), ...
  2818. + *
  2819. + *  On a twin-bus adapter card, channel B is ignored.  Rationale:
  2820. + *  it would greatly complicate the sequencer and host driver code,
  2821. + *  and both busses are multiplexed on to the EISA bus anyway.  So
  2822. + *  I don't really see any technical advantage to supporting both.
  2823. + *
  2824. + *  As well, multiple adapter card using the same IRQ level are
  2825. + *  not supported.  It doesn't make sense to configure the cards
  2826. + *  this way from a performance standpoint.  Not to mention that
  2827. + *  the kernel would have to support two devices per registered IRQ.
  2828. + */
  2829. +
  2830. +#include <stdarg.h>
  2831. +#include <asm/io.h>
  2832. +#include <linux/string.h>
  2833. +#include <linux/kernel.h>
  2834. +#include <linux/ioport.h>
  2835. +#include <linux/delay.h>
  2836. +
  2837. +#include "../block/blk.h"
  2838. +#include "sd.h"
  2839. +#include "scsi.h"
  2840. +#include "hosts.h"
  2841. +#include "aha274x.h"
  2842. +
  2843. +/*
  2844. + *  There should be a specific return value for this in scsi.h, but
  2845. + *  it seems that most drivers ignore it.
  2846. + */
  2847. +#define DID_UNDERFLOW    DID_ERROR
  2848. +
  2849. +/* EISA stuff */
  2850. +
  2851. +#define MINEISA        1
  2852. +#define MAXEISA        15
  2853. +#define SLOTBASE(x)    ((x) << 12)
  2854. +
  2855. +#define MAXIRQ        15
  2856. +
  2857. +/* AIC-7770 offset definitions */
  2858. +
  2859. +#define O_MINREG(x)    ((x) + 0xc00)        /* i/o range to reserve */
  2860. +#define O_MAXREG(x)    ((x) + 0xcbf)
  2861. +
  2862. +#define O_SCSISEQ(x)    ((x) + 0xc00)        /* scsi sequence control */
  2863. +#define O_SCSISIGI(x)    ((x) + 0xc03)        /* scsi control signal read */
  2864. +#define O_SCSISIGO(x)    ((x) + 0xc03)        /* scsi control signal write */
  2865. +#define O_SCSIID(x)    ((x) + 0xc05)        /* scsi id */
  2866. +#define O_SSTAT0(x)    ((x) + 0xc0b)        /* scsi status register 0 */
  2867. +#define O_CLRSINT1(x)    ((x) + 0xc0c)        /* clear scsi interrupt 1 */
  2868. +#define O_SSTAT1(x)    ((x) + 0xc0c)        /* scsi status register 1 */
  2869. +#define O_SELID(x)    ((x) + 0xc19)        /* [re]selection id */
  2870. +#define O_SBLKCTL(x)    ((x) + 0xc1f)        /* scsi block control */
  2871. +#define O_SEQCTL(x)    ((x) + 0xc60)        /* sequencer control */
  2872. +#define O_SEQRAM(x)    ((x) + 0xc61)        /* sequencer ram data */
  2873. +#define O_SEQADDR(x)    ((x) + 0xc62)        /* sequencer address (W) */
  2874. +#define O_BIDx(x)    ((x) + 0xc80)        /* board id */
  2875. +#define O_BCTL(x)    ((x) + 0xc84)        /* board control */
  2876. +#define O_HCNTRL(x)    ((x) + 0xc87)        /* host control */
  2877. +#define O_SCBPTR(x)    ((x) + 0xc90)        /* scb pointer */
  2878. +#define O_INTSTAT(x)    ((x) + 0xc91)        /* interrupt status */
  2879. +#define O_ERROR(x)    ((x) + 0xc92)        /* hard error */
  2880. +#define O_CLRINT(x)    ((x) + 0xc92)        /* clear interrupt status */
  2881. +#define O_SCBCNT(x)    ((x) + 0xc9a)        /* scb auto increment */
  2882. +#define O_QINFIFO(x)    ((x) + 0xc9b)        /* queue in fifo */
  2883. +#define O_QINCNT(x)    ((x) + 0xc9c)        /* queue in count */
  2884. +#define O_QOUTFIFO(x)    ((x) + 0xc9d)        /* queue out fifo */
  2885. +#define O_QOUTCNT(x)    ((x) + 0xc9e)        /* queue out count */
  2886. +#define O_SCBARRAY(x)    ((x) + 0xca0)        /* scb array start */
  2887. +
  2888. +/* host adapter offset definitions */
  2889. +
  2890. +#define HA_REJBYTE(x)    ((x) + 0xc31)        /* 1st message in byte */
  2891. +#define HA_MSG_FLAGS(x)    ((x) + 0xc35)        /* outgoing message flag */
  2892. +#define HA_MSG_LEN(x)    ((x) + 0xc36)        /* outgoing message length */
  2893. +#define HA_MSG_START(x)    ((x) + 0xc37)        /* outgoing message body */
  2894. +#define HA_ARG_1(x)    ((x) + 0xc4c)        /* sdtr <-> rate parameters */
  2895. +#define HA_ARG_2(x)    ((x) + 0xc4d)
  2896. +#define HA_RETURN_1(x)    ((x) + 0xc4c)
  2897. +#define HA_RETURN_2(x)    ((x) + 0xc4d)
  2898. +#define HA_SIGSTATE(x)    ((x) + 0xc4e)        /* value in SCSISIGO */
  2899. +#define HA_NEEDSDTR(x)    ((x) + 0xc4f)        /* synchronous negotiation? */
  2900. +
  2901. +#define HA_SCSICONF(x)    ((x) + 0xc5a)        /* SCSI config register */
  2902. +#define HA_INTDEF(x)    ((x) + 0xc5c)        /* interrupt def'n register */
  2903. +#define HA_HOSTCONF(x)    ((x) + 0xc5d)        /* host config def'n register */
  2904. +
  2905. +/* debugging code */
  2906. +
  2907. +#define AHA274X_DEBUG
  2908. +
  2909. +/*
  2910. + *  If a parity error occurs during a data transfer phase, run the
  2911. + *  command to completion - it's easier that way - making a note
  2912. + *  of the error condition in this location.  This then will modify
  2913. + *  a DID_OK status into a DID_PARITY one for the higher-level SCSI
  2914. + *  code.
  2915. + */
  2916. +#define aha274x_parity(cmd)    ((cmd)->SCp.Status)
  2917. +
  2918. +/*
  2919. + *  Since the sequencer code DMAs the scatter-gather structures
  2920. + *  directly from memory, we use this macro to assert that the
  2921. + *  kernel structure hasn't changed.
  2922. + */
  2923. +#define SG_STRUCT_CHECK(sg) \
  2924. +    ((char *)&(sg).address - (char *)&(sg) != 0 ||    \
  2925. +     (char *)&(sg).length  - (char *)&(sg) != 8 ||    \
  2926. +     sizeof((sg).address) != 4 ||            \
  2927. +     sizeof((sg).length)  != 4 ||            \
  2928. +     sizeof(sg)          != 12)
  2929. +
  2930. +/*
  2931. + *  "Static" structures.  Note that these are NOT initialized
  2932. + *  to zero inside the kernel - we have to initialize them all
  2933. + *  explicitly.
  2934. + *
  2935. + *  We support a maximum of one adapter card per IRQ level (see the
  2936. + *  rationale for this above).  On an interrupt, use the IRQ as an
  2937. + *  index into aha274x_boards[] to locate the card information.
  2938. + */
  2939. +static struct Scsi_Host *aha274x_boards[MAXIRQ + 1];
  2940. +
  2941. +struct aha274x_host {
  2942. +    int base;                    /* card base address */
  2943. +    int startup;                    /* intr type check */
  2944. +    volatile int unpause;                /* value for HCNTRL */
  2945. +    volatile Scsi_Cmnd *SCB_array[AHA274X_MAXSCB];    /* active commands */
  2946. +};
  2947. +
  2948. +struct aha274x_scb {
  2949. +    unsigned char control;
  2950. +    unsigned char target_channel_lun;        /* 4/1/3 bits */
  2951. +    unsigned char SG_segment_count;
  2952. +    unsigned char SG_list_pointer[4];
  2953. +    unsigned char SCSI_cmd_pointer[4];
  2954. +    unsigned char SCSI_cmd_length;
  2955. +    unsigned char RESERVED[2];            /* must be zero */
  2956. +    unsigned char target_status;
  2957. +    unsigned char residual_data_count[3];
  2958. +    unsigned char residual_SG_segment_count;
  2959. +    unsigned char data_pointer[4];
  2960. +    unsigned char data_count[3];
  2961. +#if 0
  2962. +    /*
  2963. +     *  No real point in transferring this to the
  2964. +     *  SCB registers.
  2965. +     */
  2966. +    unsigned char RESERVED[6];
  2967. +#endif
  2968. +};
  2969. +
  2970. +/*
  2971. + *  NB.  This table MUST be ordered shortest period first.
  2972. + */
  2973. +static struct {
  2974. +    short period;
  2975. +    short rate;
  2976. +    char *english;
  2977. +} aha274x_synctab[] = {
  2978. +    100,    0,    "10.0",
  2979. +    125,    1,    "8.0",
  2980. +    150,    2,    "6.67",
  2981. +    175,    3,    "5.7",
  2982. +    200,    4,    "5.0",
  2983. +    225,    5,    "4.4",
  2984. +    250,    6,    "4.0",
  2985. +    275,    7,    "3.6"
  2986. +};
  2987. +
  2988. +static int aha274x_synctab_max =
  2989. +    sizeof(aha274x_synctab) / sizeof(aha274x_synctab[0]);
  2990. +
  2991. +enum aha_type {
  2992. +    T_NONE,
  2993. +    T_274X,
  2994. +    T_284X,
  2995. +    T_MAX
  2996. +};
  2997. +
  2998. +#ifdef AHA274X_DEBUG
  2999. +
  3000. +    extern int vsprintf(char *, const char *, va_list);
  3001. +
  3002. +    static
  3003. +    void debug(const char *fmt, ...)
  3004. +    {
  3005. +        va_list ap;
  3006. +        char buf[256];
  3007. +
  3008. +        va_start(ap, fmt);
  3009. +          vsprintf(buf, fmt, ap);
  3010. +          printk(buf);
  3011. +        va_end(ap);
  3012. +    }
  3013. +
  3014. +    static
  3015. +    void debug_config(enum aha_type type, int base)
  3016. +    {
  3017. +        int ioport2, ioport3, ioport4;
  3018. +
  3019. +        static char *BRT[T_MAX][16] = {
  3020. +            { },                    /* T_NONE */
  3021. +            {
  3022. +                "2",   "???", "???", "12",    /* T_274X */
  3023. +                "???", "???", "???", "28",
  3024. +                "???", "???", "???", "44",
  3025. +                "???", "???", "???", "60"
  3026. +            },
  3027. +            {
  3028. +                "2",  "4",  "8",  "12",        /* T_284X */
  3029. +                "16", "20", "24", "28",
  3030. +                "32", "36", "40", "44",
  3031. +                "48", "52", "56", "60"
  3032. +            }
  3033. +        };
  3034. +        static int DFT[4] = {
  3035. +            0, 50, 75, 100
  3036. +        };
  3037. +        static int SST[4] = {
  3038. +            256, 128, 64, 32
  3039. +        };
  3040. +
  3041. +        ioport2 = inb(HA_HOSTCONF(base));
  3042. +        ioport3 = inb(HA_SCSICONF(base));
  3043. +        ioport4 = inb(HA_INTDEF(base));
  3044. +
  3045. +        if (type == T_284X)
  3046. +            printk("AHA284X AT SLOT %d:\n", base >> 12);
  3047. +        else
  3048. +            printk("AHA274X AT EISA SLOT %d:\n", base >> 12);
  3049. +
  3050. +        printk("    irq %d\n"
  3051. +               "    bus release time %s bclks\n"
  3052. +               "    data fifo threshold %d%%\n",
  3053. +               ioport4 & 0xf,
  3054. +               BRT[type][(ioport2 >> 2) & 0xf],
  3055. +               DFT[(ioport2 >> 6) & 0x3]);
  3056. +
  3057. +        printk("    SCSI CHANNEL A:\n"
  3058. +               "        scsi id %d\n"
  3059. +               "        scsi bus parity check %sabled\n"
  3060. +               "        scsi selection timeout %d ms\n"
  3061. +               "        scsi bus reset at power-on %sabled\n",
  3062. +               ioport3 & 0x7,
  3063. +               (ioport3 & 0x20) ? "en" : "dis",
  3064. +               SST[(ioport3 >> 3) & 0x3],
  3065. +               (ioport3 & 0x40) ? "en" : "dis");
  3066. +
  3067. +        if (type == T_274X) {
  3068. +            printk("        scsi bus termination %sabled\n",
  3069. +                   (ioport3 & 0x80) ? "en" : "dis");
  3070. +        }
  3071. +    }
  3072. +
  3073. +    static
  3074. +    void debug_rate(int base, int rate)
  3075. +    {
  3076. +        int target = inb(O_SCSIID(base)) >> 4;
  3077. +
  3078. +        if (rate) {
  3079. +            printk("aha274x: target %d now synchronous at %sMb/s\n",
  3080. +                   target,
  3081. +                   aha274x_synctab[(rate >> 4) & 0x7].english);
  3082. +        } else {
  3083. +            printk("aha274x: target %d using asynchronous mode\n",
  3084. +                   target);
  3085. +        }
  3086. +    }
  3087. +
  3088. +#else
  3089. +
  3090. +#    define debug(fmt, args...)
  3091. +#    define debug_config(x)
  3092. +#    define debug_rate(x,y)
  3093. +
  3094. +#endif AHA274X_DEBUG
  3095. +
  3096. +static
  3097. +void aha274x_getscb(int base, struct aha274x_scb *scb)
  3098. +{
  3099. +    /*
  3100. +     *  This is almost identical to aha274x_putscb().
  3101. +     */
  3102. +    outb(0x80, O_SCBCNT(base));    /* SCBAUTO */
  3103. +
  3104. +    asm volatile("cld\n\t"
  3105. +             "rep\n\t"
  3106. +             "insb"
  3107. +             : /* no output */
  3108. +             :"D" (scb), "c" (sizeof(*scb)), "d" (O_SCBARRAY(base))
  3109. +             :"di", "cx", "dx");
  3110. +
  3111. +    outb(0, O_SCBCNT(base));
  3112. +}
  3113. +
  3114. +/*
  3115. + *  How much data should be transferred for this SCSI command?  Stop
  3116. + *  at segment sg_last if it's a scatter-gather command so we can
  3117. + *  compute underflow easily.
  3118. + */
  3119. +static
  3120. +unsigned aha274x_length(Scsi_Cmnd *cmd, int sg_last)
  3121. +{
  3122. +    int i, segments;
  3123. +    unsigned length;
  3124. +    struct scatterlist *sg;
  3125. +
  3126. +    segments = cmd->use_sg - sg_last;
  3127. +    sg = (struct scatterlist *)cmd->buffer;
  3128. +
  3129. +    if (cmd->use_sg) {
  3130. +        for (i = length = 0;
  3131. +             i < cmd->use_sg && i < segments;
  3132. +             i++)
  3133. +        {
  3134. +            length += sg[i].length;
  3135. +        }
  3136. +    } else
  3137. +        length = cmd->request_bufflen;
  3138. +
  3139. +    return(length);
  3140. +}
  3141. +
  3142. +static
  3143. +void aha274x_sg_check(Scsi_Cmnd *cmd)
  3144. +{
  3145. +    int i;
  3146. +    struct scatterlist *sg = (struct scatterlist *)cmd->buffer;
  3147. +
  3148. +    if (cmd->use_sg) {
  3149. +        for (i = 0; i < cmd->use_sg; i++)
  3150. +            if ((unsigned)sg[i].length > 0xffff)
  3151. +                panic("aha274x_sg_check: s/g segment > 64k\n");
  3152. +    }
  3153. +}
  3154. +
  3155. +static
  3156. +void aha274x_to_scsirate(unsigned char *rate,
  3157. +             unsigned char transfer,
  3158. +             unsigned char offset)
  3159. +{
  3160. +    int i;
  3161. +
  3162. +    transfer *= 4;
  3163. +
  3164. +    for (i = 0; i < aha274x_synctab_max-1; i++) {
  3165. +
  3166. +        if (transfer == aha274x_synctab[i].period) {
  3167. +            *rate = (aha274x_synctab[i].rate << 4) | (offset & 0xf);
  3168. +            return;
  3169. +        }
  3170. +
  3171. +        if (transfer > aha274x_synctab[i].period &&
  3172. +            transfer < aha274x_synctab[i+1].period)
  3173. +        {
  3174. +            *rate = (aha274x_synctab[i+1].rate << 4) |
  3175. +                (offset & 0xf);
  3176. +            return;
  3177. +        }
  3178. +    }
  3179. +    *rate = 0;
  3180. +}
  3181. +
  3182. +/*
  3183. + *  Pause the sequencer and wait for it to actually stop - this
  3184. + *  is important since the sequencer can disable pausing for critical
  3185. + *  sections.
  3186. + */
  3187. +#define PAUSE_SEQUENCER(p)    \
  3188. +    do {                                \
  3189. +        outb(0xe, O_HCNTRL(p->base));    /* IRQMS|PAUSE|INTEN */    \
  3190. +                                    \
  3191. +        while ((inb(O_HCNTRL(p->base)) & 0x4) == 0)        \
  3192. +            ;                        \
  3193. +    } while (0)
  3194. +
  3195. +/*
  3196. + *  Unpause the sequencer.  Unremarkable, yet done often enough to
  3197. + *  warrant an easy way to do it.
  3198. + */
  3199. +#define UNPAUSE_SEQUENCER(p)    \
  3200. +    outb(p->unpause, O_HCNTRL(p->base))    /* IRQMS|INTEN */
  3201. +
  3202. +/*
  3203. + *  See comments in aha274x_loadram() wrt this.
  3204. + */
  3205. +#define RESTART_SEQUENCER(p)    \
  3206. +    do {                        \
  3207. +        do {                    \
  3208. +            outb(0x2, O_SEQCTL(p->base));    \
  3209. +        } while (inw(O_SEQADDR(p->base)) != 0);    \
  3210. +                            \
  3211. +        UNPAUSE_SEQUENCER(p);            \
  3212. +    } while (0)
  3213. +
  3214. +/*
  3215. + *  Since we declared this using SA_INTERRUPT, interrupts should
  3216. + *  be disabled all through this function unless we say otherwise.
  3217. + */
  3218. +static
  3219. +void aha274x_isr(int irq)
  3220. +{
  3221. +    int base, intstat;
  3222. +    struct aha274x_host *p;
  3223. +    
  3224. +    p = (struct aha274x_host *)aha274x_boards[irq]->hostdata;
  3225. +    base = p->base;
  3226. +
  3227. +    /*
  3228. +     *  Check the startup flag - if no commands have been queued,
  3229. +     *  we probably have the interrupt type set wrong.  Reverse
  3230. +     *  the stored value and the active one in the host control
  3231. +     *  register.
  3232. +     */
  3233. +    if (p->startup) {
  3234. +        p->unpause ^= 0x8;
  3235. +        outb(inb(O_HCNTRL(p->base)) ^ 0x8, O_HCNTRL(p->base));
  3236. +        return;
  3237. +    }
  3238. +
  3239. +    /*
  3240. +     *  Handle all the interrupt sources - especially for SCSI
  3241. +     *  interrupts, we won't get a second chance at them.
  3242. +     */
  3243. +    intstat = inb(O_INTSTAT(base));
  3244. +
  3245. +    if (intstat & 0x8) {                /* BRKADRINT */
  3246. +
  3247. +        panic("aha274x_isr: brkadrint, error = 0x%x, seqaddr = 0x%x\n",
  3248. +              inb(O_ERROR(base)), inw(O_SEQADDR(base)));
  3249. +    }
  3250. +
  3251. +    if (intstat & 0x4) {                /* SCSIINT */
  3252. +
  3253. +        int scbptr = inb(O_SCBPTR(base));
  3254. +        int status = inb(O_SSTAT1(base));
  3255. +        Scsi_Cmnd *cmd;
  3256. +
  3257. +        cmd = (Scsi_Cmnd *)p->SCB_array[scbptr];
  3258. +        if (!cmd) {
  3259. +            printk("aha274x_isr: no command for scb (scsiint)\n");
  3260. +            /*
  3261. +             *  Turn off the interrupt and set status
  3262. +             *  to zero, so that it falls through the
  3263. +             *  reset of the SCSIINT code.
  3264. +             */
  3265. +            outb(status, O_CLRSINT1(base));
  3266. +            UNPAUSE_SEQUENCER(p);
  3267. +            outb(0x4, O_CLRINT(base));    /* undocumented */
  3268. +            status = 0;
  3269. +        }
  3270. +        p->SCB_array[scbptr] = NULL;
  3271. +
  3272. +        /*
  3273. +         *  Only the SCSI Status 1 register has information
  3274. +         *  about exceptional conditions that we'd have a
  3275. +         *  SCSIINT about; anything in SSTAT0 will be handled
  3276. +         *  by the sequencer.  Note that there can be multiple
  3277. +         *  bits set.
  3278. +         */
  3279. +        if (status & 0x80) {            /* SELTO */
  3280. +            /*
  3281. +             *  Hardware selection timer has expired.  Turn
  3282. +             *  off SCSI selection sequence.
  3283. +             */
  3284. +            outb(0, O_SCSISEQ(base));
  3285. +            cmd->result = DID_TIME_OUT << 16;
  3286. +
  3287. +            /*
  3288. +             *  If there's an active message, it belongs to the
  3289. +             *  command that is getting punted - remove it.
  3290. +             */
  3291. +            outb(0, HA_MSG_FLAGS(base));
  3292. +
  3293. +            /*
  3294. +             *  Shut off the offending interrupt sources, reset
  3295. +             *  the sequencer address to zero and unpause it,
  3296. +             *  then call the high-level SCSI completion routine.
  3297. +             *
  3298. +             *  WARNING!  This is a magic sequence!  After many
  3299. +             *  hours of guesswork, turning off the SCSI interrupts
  3300. +             *  in CLRSINT? does NOT clear the SCSIINT bit in
  3301. +             *  INTSTAT.  By writing to the (undocumented, unused
  3302. +             *  according to the AIC-7770 manual) third bit of
  3303. +             *  CLRINT, you can clear INTSTAT.  But, if you do it
  3304. +             *  while the sequencer is paused, you get a BRKADRINT
  3305. +             *  with an Illegal Host Address status, so the
  3306. +             *  sequencer has to be restarted first.
  3307. +             */
  3308. +            outb(0x80, O_CLRSINT1(base));    /* CLRSELTIMO */
  3309. +            RESTART_SEQUENCER(p);
  3310. +
  3311. +            outb(0x4, O_CLRINT(base));    /* undocumented */
  3312. +            cmd->scsi_done(cmd);
  3313. +        }
  3314. +
  3315. +        if (status & 0x4) {            /* SCSIPERR */
  3316. +            /*
  3317. +             *  A parity error has occurred during a data
  3318. +             *  transfer phase.  Flag it and continue.
  3319. +             */
  3320. +            printk("aha274x: parity error on target %d, lun %d\n",
  3321. +                   cmd->target,
  3322. +                   cmd->lun);
  3323. +            aha274x_parity(cmd) = DID_PARITY;
  3324. +
  3325. +            /*
  3326. +             *  Clear interrupt and resume as above.
  3327. +             */
  3328. +            outb(0x4, O_CLRSINT1(base));    /* CLRSCSIPERR */
  3329. +            UNPAUSE_SEQUENCER(p);
  3330. +
  3331. +            outb(0x4, O_CLRINT(base));    /* undocumented */
  3332. +        }
  3333. +
  3334. +        if ((status & (0x8|0x4)) == 0 && status) {
  3335. +            /*
  3336. +             *  We don't know what's going on.  Turn off the
  3337. +             *  interrupt source and try to continue.
  3338. +             */
  3339. +            printk("aha274x_isr: sstat1 = 0x%x\n", status);
  3340. +            outb(status, O_CLRSINT1(base));
  3341. +            UNPAUSE_SEQUENCER(p);
  3342. +            outb(0x4, O_CLRINT(base));    /* undocumented */
  3343. +        }
  3344. +    }
  3345. +
  3346. +    if (intstat & 0x2) {                /* CMDCMPLT */
  3347. +
  3348. +        int complete, old_scbptr;
  3349. +        struct aha274x_scb scb;
  3350. +        unsigned actual;
  3351. +        Scsi_Cmnd *cmd;
  3352. +
  3353. +        /*
  3354. +         *  The sequencer will continue running when it
  3355. +         *  issues this interrupt.  There may be >1 commands
  3356. +         *  finished, so loop until we've processed them all.
  3357. +         */
  3358. +        do {
  3359. +            complete = inb(O_QOUTFIFO(base));
  3360. +
  3361. +            cmd = (Scsi_Cmnd *)p->SCB_array[complete];
  3362. +            if (!cmd) {
  3363. +                printk("aha274x warning: "
  3364. +                       "no command for scb (cmdcmplt)\n");
  3365. +                continue;
  3366. +            }
  3367. +            p->SCB_array[complete] = NULL;
  3368. +            
  3369. +            PAUSE_SEQUENCER(p);
  3370. +
  3371. +            /*
  3372. +             *  After pausing the sequencer (and waiting
  3373. +             *  for it to stop), save its SCB pointer, then
  3374. +             *  write in our completed one and read the SCB
  3375. +             *  registers.  Afterwards, restore the saved
  3376. +             *  pointer, unpause the sequencer and call the
  3377. +             *  higher-level completion function - unpause
  3378. +             *  first since we have no idea how long done()
  3379. +             *  will take.
  3380. +             */
  3381. +            old_scbptr = inb(O_SCBPTR(base));
  3382. +            outb(complete, O_SCBPTR(base));
  3383. +
  3384. +            aha274x_getscb(base, &scb);
  3385. +            outb(old_scbptr, O_SCBPTR(base));
  3386. +
  3387. +            UNPAUSE_SEQUENCER(p);
  3388. +
  3389. +            cmd->result = scb.target_status |
  3390. +                     (aha274x_parity(cmd) << 16);
  3391. +
  3392. +            /*
  3393. +             *  Did we underflow?  At this time, there's only
  3394. +             *  one other driver that bothers to check for this,
  3395. +             *  and cmd->underflow seems to be set rather half-
  3396. +             *  heartedly in the higher-level SCSI code.
  3397. +             */
  3398. +            actual = aha274x_length(cmd,
  3399. +                        scb.residual_SG_segment_count);
  3400. +
  3401. +            actual -= ((scb.residual_data_count[2] << 16) |
  3402. +                   (scb.residual_data_count[1] <<  8) |
  3403. +                   (scb.residual_data_count[0]));
  3404. +
  3405. +            if (actual < cmd->underflow) {
  3406. +                printk("aha274x: target %d underflow - "
  3407. +                       "wanted (at least) %u, got %u\n",
  3408. +                       cmd->target, cmd->underflow, actual);
  3409. +
  3410. +                cmd->result = scb.target_status |
  3411. +                         (DID_UNDERFLOW << 16);
  3412. +            }
  3413. +
  3414. +            cmd->scsi_done(cmd);
  3415. +
  3416. +            /*
  3417. +             *  Clear interrupt status before checking
  3418. +             *  the output queue again.  This eliminates
  3419. +             *  a race condition whereby a command could
  3420. +             *  complete between the queue poll and the
  3421. +             *  interrupt clearing, so notification of the
  3422. +             *  command being complete never made it back
  3423. +             *  up to the kernel.
  3424. +             */
  3425. +            outb(0x2, O_CLRINT(base));    /* CLRCMDINT */
  3426. +
  3427. +        } while (inb(O_QOUTCNT(base)));
  3428. +    }
  3429. +
  3430. +    if (intstat & 0x1) {                /* SEQINT */
  3431. +
  3432. +        unsigned char transfer, offset, rate;
  3433. +
  3434. +        /*
  3435. +         *  Although the sequencer is paused immediately on
  3436. +         *  a SEQINT, an interrupt for a SCSIINT or a CMDCMPLT
  3437. +         *  condition will have unpaused the sequencer before
  3438. +         *  this point.
  3439. +         */
  3440. +        PAUSE_SEQUENCER(p);
  3441. +
  3442. +        switch (intstat & 0xf0) {
  3443. +            case 0x00:
  3444. +            panic("aha274x_isr: unknown scsi bus phase\n");
  3445. +            case 0x10:
  3446. +            debug("aha274x_isr warning: "
  3447. +                  "issuing message reject, 1st byte 0x%x\n",
  3448. +                  inb(HA_REJBYTE(base)));
  3449. +            break;
  3450. +            case 0x20:
  3451. +            panic("aha274x_isr: reconnecting target %d "
  3452. +                  "didn't issue IDENTIFY message\n",
  3453. +                  (inb(O_SELID(base)) >> 4) & 0xf);
  3454. +            case 0x30:
  3455. +            debug("aha274x_isr: sequencer couldn't find match "
  3456. +                  "for reconnecting target %d - issuing ABORT\n",
  3457. +                  (inb(O_SELID(base)) >> 4) & 0xf);
  3458. +            break;
  3459. +            case 0x40:
  3460. +            transfer = inb(HA_ARG_1(base));
  3461. +            offset = inb(HA_ARG_2(base));
  3462. +            aha274x_to_scsirate(&rate, transfer, offset);
  3463. +            outb(rate, HA_RETURN_1(base));
  3464. +            debug_rate(base, rate);
  3465. +            break;
  3466. +            default:
  3467. +            debug("aha274x_isr: seqint, "
  3468. +                  "intstat = 0x%x, scsisigi = 0x%x\n",
  3469. +                  intstat, inb(O_SCSISIGI(base)));
  3470. +            break;
  3471. +        }
  3472. +
  3473. +        outb(0x1, O_CLRINT(base));        /* CLRSEQINT */
  3474. +        UNPAUSE_SEQUENCER(p);
  3475. +    }
  3476. +}
  3477. +
  3478. +/*
  3479. + *  Probing for EISA boards: it looks like the first two bytes
  3480. + *  are a manufacturer code - three characters, five bits each:
  3481. + *
  3482. + *         BYTE 0   BYTE 1   BYTE 2   BYTE 3
  3483. + *        ?1111122 22233333 PPPPPPPP RRRRRRRR
  3484. + *
  3485. + *  The characters are baselined off ASCII '@', so add that value
  3486. + *  to each to get the real ASCII code for it.  The next two bytes
  3487. + *  appear to be a product and revision number, probably vendor-
  3488. + *  specific.  This is what is being searched for at each port,
  3489. + *  and what should probably correspond to the ID= field in the
  3490. + *  ECU's .cfg file for the card - if your card is not detected,
  3491. + *  make sure your signature is listed in the array.
  3492. + *
  3493. + *  The fourth byte's lowest bit seems to be an enabled/disabled
  3494. + *  flag (rest of the bits are reserved?).
  3495. + */
  3496. +
  3497. +static
  3498. +enum aha_type aha274x_probe(int slot, int s_base)
  3499. +{
  3500. +    int i;
  3501. +    unsigned char buf[4];
  3502. +
  3503. +    static struct {
  3504. +        int n;
  3505. +        unsigned char signature[sizeof(buf)];
  3506. +        enum aha_type type;
  3507. +    } S[] = {
  3508. +        4, { 0x04, 0x90, 0x77, 0x71 }, T_274X,    /* host adapter 274x */
  3509. +        4, { 0x04, 0x90, 0x77, 0x70 }, T_274X,    /* motherboard 274x  */
  3510. +        4, { 0x04, 0x90, 0x77, 0x56 }, T_284X,    /* 284x, BIOS enabled */
  3511. +    };
  3512. +
  3513. +    for (i = 0; i < sizeof(buf); i++) {
  3514. +        /*
  3515. +         *  The VL-bus cards need to be primed by
  3516. +         *  writing before a signature check.
  3517. +         */
  3518. +        outb(0x80 + i, s_base);
  3519. +        buf[i] = inb(s_base + i);
  3520. +    }
  3521. +
  3522. +    for (i = 0; i < sizeof(S)/sizeof(S[0]); i++) {
  3523. +        if (!memcmp(buf, S[i].signature, S[i].n)) {
  3524. +            /*
  3525. +             *  Signature match on enabled card?
  3526. +             */
  3527. +            if (inb(s_base + 4) & 1)
  3528. +                return(S[i].type);
  3529. +            printk("aha274x disabled at slot %d, ignored\n", slot);
  3530. +        }
  3531. +    }
  3532. +    return(T_NONE);
  3533. +}
  3534. +
  3535. +/*
  3536. + *  Return ' ' for plain 274x, 'T' for twin-channel, 'W' for
  3537. + *  wide channel, '?' for anything else.
  3538. + */
  3539. +
  3540. +static
  3541. +char aha274x_type(int base)
  3542. +{
  3543. +    /*
  3544. +     *  The AIC-7770 can be wired so that, on chip reset,
  3545. +     *  the SCSI Block Control register indicates how many
  3546. +     *  busses the chip is configured for.
  3547. +     */
  3548. +    switch (inb(O_SBLKCTL(base))) {
  3549. +        case 0:
  3550. +        return(' ');
  3551. +        case 2:
  3552. +        return('W');
  3553. +        case 8:
  3554. +        return('T');
  3555. +        default:
  3556. +        printk("aha274x has unknown bus configuration\n");
  3557. +        return('?');
  3558. +    }
  3559. +}
  3560. +
  3561. +static
  3562. +void aha274x_loadram(int base)
  3563. +{
  3564. +    static unsigned char seqprog[] = {
  3565. +        /*
  3566. +         *  Each sequencer instruction is 29 bits
  3567. +         *  long (fill in the excess with zeroes)
  3568. +         *  and has to be loaded from least -> most
  3569. +         *  significant byte, so this table has the
  3570. +         *  byte ordering reversed.
  3571. +         */
  3572. +#        include "aha274x_seq.h"
  3573. +    };
  3574. +
  3575. +    /*
  3576. +     *  When the AIC-7770 is paused (as on chip reset), the
  3577. +     *  sequencer address can be altered and a sequencer
  3578. +     *  program can be loaded by writing it, byte by byte, to
  3579. +     *  the sequencer RAM port - the Adaptec documentation
  3580. +     *  recommends using REP OUTSB to do this, hence the inline
  3581. +     *  assembly.  Since the address autoincrements as we load
  3582. +     *  the program, reset it back to zero afterward.  Disable
  3583. +     *  sequencer RAM parity error detection while loading, and
  3584. +     *  make sure the LOADRAM bit is enabled for loading.
  3585. +     */
  3586. +    outb(0x83, O_SEQCTL(base));    /* PERRORDIS|SEQRESET|LOADRAM */
  3587. +
  3588. +    asm volatile("cld\n\t"
  3589. +             "rep\n\t"
  3590. +             "outsb"
  3591. +             : /* no output */
  3592. +             :"S" (seqprog), "c" (sizeof(seqprog)), "d" (O_SEQRAM(base))
  3593. +             :"si", "cx", "dx");
  3594. +
  3595. +    /*
  3596. +     *  WARNING!  This is a magic sequence!  After extensive
  3597. +     *  experimentation, it seems that you MUST turn off the
  3598. +     *  LOADRAM bit before you play with SEQADDR again, else
  3599. +     *  you will end up with parity errors being flagged on
  3600. +     *  your sequencer program.  (You would also think that
  3601. +     *  turning off LOADRAM and setting SEQRESET to reset the
  3602. +     *  address to zero would work, but you need to do it twice
  3603. +     *  for it to take effect on the address.  Timing problem?)
  3604. +     */
  3605. +    outb(0, O_SEQCTL(base));
  3606. +    do {
  3607. +        /*
  3608. +         *  Actually, reset it until
  3609. +         *  the address shows up as
  3610. +         *  zero just to be safe..
  3611. +         */
  3612. +        outb(0x2, O_SEQCTL(base));    /* SEQRESET */
  3613. +
  3614. +    } while (inw(O_SEQADDR(base)) != 0);
  3615. +}
  3616. +
  3617. +static
  3618. +int aha274x_register(Scsi_Host_Template *template,
  3619. +             enum aha_type type,
  3620. +             int base)
  3621. +{
  3622. +    int i, irq, scsi_id;
  3623. +    struct Scsi_Host *host;
  3624. +    struct aha274x_host *p;
  3625. +
  3626. +    /*
  3627. +     *  Give the AIC-7770 a reset - reading the 274x's registers
  3628. +     *  returns zeroes unless you do.  This forces a pause of the
  3629. +     *  Sequencer.
  3630. +     */
  3631. +    outb(1, O_HCNTRL(base));    /* CHIPRST */
  3632. +
  3633. +    /*
  3634. +     *  The IRQ level in i/o port 4 maps directly onto the real
  3635. +     *  IRQ number.  If it's ok, register it with the kernel.
  3636. +     *
  3637. +     *  NB. the Adaptec documentation says the IRQ number is only
  3638. +     *    in the lower four bits; the ECU information shows the
  3639. +     *    high bit being used as well.  Which is correct?
  3640. +     */
  3641. +    irq = inb(HA_INTDEF(base)) & 0xf;
  3642. +    if (irq < 9 || irq > 15) {
  3643. +        printk("aha274x uses unsupported IRQ level, ignoring\n");
  3644. +        return(0);
  3645. +    }
  3646. +    
  3647. +    /*
  3648. +     *  Lock out other contenders for our i/o space.
  3649. +     */
  3650. +    snarf_region(O_MINREG(base), O_MAXREG(base)-O_MINREG(base));
  3651. +
  3652. +    /*
  3653. +     *  Any card-type-specific adjustments before we register
  3654. +     *  the scsi host(s).
  3655. +     */
  3656. +
  3657. +    scsi_id = inb(HA_SCSICONF(base)) & 0x7;
  3658. +
  3659. +    switch (aha274x_type(base)) {
  3660. +        case 'T':
  3661. +        printk("aha274x warning: ignoring channel B of 274x-twin\n");
  3662. +        break;
  3663. +        case ' ':
  3664. +        break;
  3665. +        default:
  3666. +        printk("aha274x is an unsupported type, ignoring\n");
  3667. +        return(0);
  3668. +    }
  3669. +
  3670. +    /*
  3671. +     *  Before registry, make sure that the offsets of the
  3672. +     *  struct scatterlist are what the sequencer will expect,
  3673. +     *  otherwise disable scatter-gather altogether until someone
  3674. +     *  can fix it.  This is important since the sequencer will
  3675. +     *  DMA elements of the SG array in while executing commands.
  3676. +     */
  3677. +    if (template->sg_tablesize != SG_NONE) {
  3678. +        struct scatterlist sg;
  3679. +
  3680. +        if (SG_STRUCT_CHECK(sg)) {
  3681. +            printk("aha274x warning: kernel scatter-gather "
  3682. +                   "structures changed, disabling it\n");
  3683. +            template->sg_tablesize = SG_NONE;
  3684. +        }
  3685. +    }
  3686. +    
  3687. +    /*
  3688. +     *  Register each "host" and fill in the returned Scsi_Host
  3689. +     *  structure as best we can.  Some of the parameters aren't
  3690. +     *  really relevant for EISA, and none of the high-level SCSI
  3691. +     *  code looks at it anyway.. why are the fields there?  Also
  3692. +     *  save the pointer so that we can find the information when
  3693. +     *  an IRQ is triggered.
  3694. +     */
  3695. +    host = scsi_register(template, sizeof(struct aha274x_host));
  3696. +    host->this_id = scsi_id;
  3697. +    host->irq = irq;
  3698. +
  3699. +    aha274x_boards[irq] = host;
  3700. +    
  3701. +    p = (struct aha274x_host *)host->hostdata;
  3702. +    for (i = 0; i < AHA274X_MAXSCB; i++)
  3703. +        p->SCB_array[i] = NULL;
  3704. +    p->base = base;
  3705. +
  3706. +    /*
  3707. +     *  The interrupt trigger is different depending
  3708. +     *  on whether the card is EISA or VL-bus - sometimes.
  3709. +     *  The startup variable will be cleared once the first
  3710. +     *  command is queued, and is checked in the isr to
  3711. +     *  try and detect when the interrupt type is set
  3712. +     *  incorrectly, triggering an interrupt immediately.
  3713. +     */
  3714. +    p->unpause = (type != T_274X ? 0x2 : 0xa);
  3715. +    p->startup = !0;
  3716. +
  3717. +    /*
  3718. +     *  Register IRQ with the kernel _after_ the host information
  3719. +     *  is set up, in case we take an interrupt right away, due to
  3720. +     *  the interrupt type being set wrong.
  3721. +     */
  3722. +    if (request_irq(irq, aha274x_isr, SA_INTERRUPT, "AHA274x/284x")) {
  3723. +        printk("aha274x couldn't register irq %d, ignoring\n", irq);
  3724. +        return(0);
  3725. +    }
  3726. +
  3727. +    /*
  3728. +     *  Print out debugging information before re-enabling
  3729. +     *  the card - a lot of registers on it can't be read
  3730. +     *  when the sequencer is active.
  3731. +     */
  3732. +    debug_config(type, base);
  3733. +
  3734. +    /*
  3735. +     *  Load the sequencer program, then re-enable the board -
  3736. +     *  resetting the AIC-7770 disables it, leaving the lights
  3737. +     *  on with nobody home.
  3738. +     */
  3739. +    aha274x_loadram(base);
  3740. +    outb(1, O_BCTL(base));        /* ENABLE */
  3741. +
  3742. +    /*
  3743. +     *  Set the host adapter registers to indicate that synchronous
  3744. +     *  negotiation should be attempted the first time the targets
  3745. +     *  are communicated with.  Also initialize the active message
  3746. +     *  flag to indicate that there is no message.
  3747. +     */
  3748. +    outb(0xff, HA_NEEDSDTR(base));
  3749. +    outb(0, HA_MSG_FLAGS(base));
  3750. +
  3751. +    /*
  3752. +     *  Unpause the sequencer before returning and enable
  3753. +     *  interrupts - we shouldn't get any until the first
  3754. +     *  command is sent to us by the high-level SCSI code.
  3755. +     */
  3756. +    UNPAUSE_SEQUENCER(p);
  3757. +    return(1);
  3758. +}
  3759. +
  3760. +int aha274x_detect(Scsi_Host_Template *template)
  3761. +{
  3762. +    enum aha_type type;
  3763. +    int found = 0, slot, base;
  3764. +
  3765. +    for (slot = MINEISA; slot <= MAXEISA; slot++) {
  3766. +
  3767. +        base = SLOTBASE(slot);
  3768. +        
  3769. +        if (check_region(O_MINREG(base),
  3770. +                 O_MAXREG(base)-O_MINREG(base)))
  3771. +        {
  3772. +            /*
  3773. +             *  Some other driver has staked a
  3774. +             *  claim to this i/o region already.
  3775. +             */
  3776. +            continue;
  3777. +        }
  3778. +
  3779. +        type = aha274x_probe(slot, O_BIDx(base));
  3780. +
  3781. +        if (type != T_NONE) {
  3782. +            /*
  3783. +             *  We "find" a 274x if we locate the card
  3784. +             *  signature and we can set it up and register
  3785. +             *  it with the kernel without incident.
  3786. +             */
  3787. +            found += aha274x_register(template, type, base);
  3788. +        }
  3789. +    }
  3790. +    template->name = (char *)aha274x_info();
  3791. +    return(found);
  3792. +}
  3793. +
  3794. +const char *aha274x_info(void)
  3795. +{
  3796. +    return("Adaptec AHA274x/284x (EISA/VL-bus -> Fast SCSI) "
  3797. +           AHA274X_SEQ_VERSION "/"
  3798. +           AHA274X_H_VERSION "/"
  3799. +           "1.28");
  3800. +}
  3801. +
  3802. +int aha274x_command(Scsi_Cmnd *cmd)
  3803. +{
  3804. +    /*
  3805. +     *  This is a relic of non-interrupt-driven SCSI
  3806. +     *  drivers.  With the can_queue variable set, this
  3807. +     *  should never be called.
  3808. +     */
  3809. +    panic("aha274x_command was called\n");
  3810. +}
  3811. +
  3812. +static
  3813. +void aha274x_buildscb(struct aha274x_host *p,
  3814. +              Scsi_Cmnd *cmd,
  3815. +              struct aha274x_scb *scb)
  3816. +{
  3817. +    void *addr;
  3818. +    unsigned length;
  3819. +
  3820. +    memset(scb, 0, sizeof(*scb));
  3821. +
  3822. +    /*
  3823. +     *  NB. channel selection (bit 3) is always zero.
  3824. +     */
  3825. +    scb->target_channel_lun = ((cmd->target << 4) & 0xf0) |
  3826. +                   (cmd->lun & 0x7);
  3827. +
  3828. +    /*
  3829. +     *  The interpretation of request_buffer and request_bufflen
  3830. +     *  changes depending on whether or not use_sg is zero; a
  3831. +     *  non-zero use_sg indicates the number of elements in the
  3832. +     *  scatter-gather array.
  3833. +     *
  3834. +     *  The AIC-7770 can't support transfers of any sort larger
  3835. +     *  than 2^24 (three-byte count) without backflips.  For what
  3836. +     *  the kernel is doing, this shouldn't occur.  I hope.
  3837. +     */
  3838. +    length = aha274x_length(cmd, 0);
  3839. +
  3840. +    /*
  3841. +     *  The sequencer code cannot yet handle scatter-gather segments
  3842. +     *  larger than 64k (two-byte length).  The 1.1.x kernels, however,
  3843. +     *  have a four-byte length field in the struct scatterlist, so
  3844. +     *  make sure we don't exceed 64k on these kernels for now.
  3845. +     */
  3846. +    aha274x_sg_check(cmd);
  3847. +
  3848. +    if (length > 0xffffff) {
  3849. +        panic("aha274x_buildscb: can't transfer > 2^24 - 1 bytes\n");
  3850. +    }
  3851. +
  3852. +    /*
  3853. +     *  XXX - this relies on the host data being stored in a
  3854. +     *      little-endian format.
  3855. +     */
  3856. +    addr = cmd->cmnd;
  3857. +    scb->SCSI_cmd_length = COMMAND_SIZE(cmd->cmnd[0]);
  3858. +    memcpy(scb->SCSI_cmd_pointer, &addr, sizeof(scb->SCSI_cmd_pointer));
  3859. +
  3860. +    if (cmd->use_sg) {
  3861. +#if 0
  3862. +        debug("aha274x_buildscb: SG used, %d segments, length %u\n",
  3863. +              cmd->use_sg,
  3864. +              length);
  3865. +#endif
  3866. +        scb->SG_segment_count = cmd->use_sg;
  3867. +        memcpy(scb->SG_list_pointer,
  3868. +               &cmd->request_buffer,
  3869. +               sizeof(scb->SG_list_pointer));
  3870. +    } else {
  3871. +        scb->SG_segment_count = 0;
  3872. +        memcpy(scb->data_pointer,
  3873. +               &cmd->request_buffer,
  3874. +               sizeof(scb->data_pointer));
  3875. +        memcpy(scb->data_count,
  3876. +               &cmd->request_bufflen,
  3877. +               sizeof(scb->data_count));
  3878. +    }
  3879. +}
  3880. +
  3881. +static
  3882. +void aha274x_putscb(int base, struct aha274x_scb *scb)
  3883. +{
  3884. +    /*
  3885. +     *  By turning on the SCB auto increment, any reference
  3886. +     *  to the SCB I/O space postincrements the SCB address
  3887. +     *  we're looking at.  So turn this on and dump the relevant
  3888. +     *  portion of the SCB to the card.
  3889. +     */
  3890. +    outb(0x80, O_SCBCNT(base));    /* SCBAUTO */
  3891. +
  3892. +    asm volatile("cld\n\t"
  3893. +             "rep\n\t"
  3894. +             "outsb"
  3895. +             : /* no output */
  3896. +             :"S" (scb), "c" (sizeof(*scb)), "d" (O_SCBARRAY(base))
  3897. +             :"si", "cx", "dx");
  3898. +
  3899. +    outb(0, O_SCBCNT(base));
  3900. +}
  3901. +
  3902. +int aha274x_queue(Scsi_Cmnd *cmd, void (*fn)(Scsi_Cmnd *))
  3903. +{
  3904. +    long flags;
  3905. +    int empty, old_scbptr;
  3906. +    struct aha274x_host *p;
  3907. +    struct aha274x_scb scb;
  3908. +
  3909. +#if 0
  3910. +    debug("aha274x_queue: cmd 0x%x (size %u), target %d, lun %d\n",
  3911. +          cmd->cmnd[0],
  3912. +          COMMAND_SIZE(cmd->cmnd[0]),
  3913. +          cmd->target,
  3914. +          cmd->lun);
  3915. +#endif
  3916. +
  3917. +    p = (struct aha274x_host *)cmd->host->hostdata;
  3918. +
  3919. +    /*
  3920. +     *  Construct the SCB beforehand, so the sequencer is
  3921. +     *  paused a minimal amount of time.
  3922. +     */
  3923. +    aha274x_buildscb(p, cmd, &scb);
  3924. +
  3925. +    /*
  3926. +     *  Clear the startup flag - we can now legitimately
  3927. +     *  expect interrupts.
  3928. +     */
  3929. +    p->startup = 0;
  3930. +
  3931. +    /*
  3932. +     *  This is a critical section, since we don't want the
  3933. +     *  interrupt routine mucking with the host data or the
  3934. +     *  card.  Since the kernel documentation is vague on
  3935. +     *  whether or not we are in a cli/sti pair already, save
  3936. +     *  the flags to be on the safe side.
  3937. +     */
  3938. +    save_flags(flags);
  3939. +    cli();
  3940. +
  3941. +    /*
  3942. +     *  Find a free slot in the SCB array to load this command
  3943. +     *  into.  Since can_queue is set to AHA274X_MAXSCB, we
  3944. +     *  should always find one.
  3945. +     */
  3946. +    for (empty = 0; empty < AHA274X_MAXSCB; empty++)
  3947. +        if (!p->SCB_array[empty])
  3948. +            break;
  3949. +    if (empty == AHA274X_MAXSCB)
  3950. +        panic("aha274x_queue: couldn't find a free scb\n");
  3951. +
  3952. +    /*
  3953. +     *  Pause the sequencer so we can play with its registers -
  3954. +     *  wait for it to acknowledge the pause.
  3955. +     *
  3956. +     *  XXX - should the interrupts be left on while doing this?
  3957. +     */
  3958. +    PAUSE_SEQUENCER(p);
  3959. +
  3960. +    /*
  3961. +     *  Save the SCB pointer and put our own pointer in - this
  3962. +     *  selects one of the four banks of SCB registers.  Load
  3963. +     *  the SCB, then write its pointer into the queue in FIFO
  3964. +     *  and restore the saved SCB pointer.
  3965. +     */
  3966. +    old_scbptr = inb(O_SCBPTR(p->base));
  3967. +    outb(empty, O_SCBPTR(p->base));
  3968. +    
  3969. +    aha274x_putscb(p->base, &scb);
  3970. +
  3971. +    outb(empty, O_QINFIFO(p->base));
  3972. +    outb(old_scbptr, O_SCBPTR(p->base));
  3973. +
  3974. +    /*
  3975. +     *  Make sure the Scsi_Cmnd pointer is saved, the struct it
  3976. +     *  points to is set up properly, and the parity error flag
  3977. +     *  is reset, then unpause the sequencer and watch the fun
  3978. +     *  begin.
  3979. +     */
  3980. +    cmd->scsi_done = fn;
  3981. +    p->SCB_array[empty] = cmd;
  3982. +    aha274x_parity(cmd) = DID_OK;
  3983. +
  3984. +    UNPAUSE_SEQUENCER(p);
  3985. +
  3986. +    restore_flags(flags);
  3987. +    return(0);
  3988. +}
  3989. +
  3990. +/* return values from aha274x_kill */
  3991. +
  3992. +enum k_state {
  3993. +    k_ok,                /* scb found and message sent */
  3994. +    k_busy,                /* message already present */
  3995. +    k_absent,            /* couldn't locate scb */
  3996. +    k_disconnect,            /* scb found, but disconnected */
  3997. +};
  3998. +
  3999. +/*
  4000. + *  This must be called with interrupts disabled - it's going to
  4001. + *  be messing around with the host data, and an interrupt being
  4002. + *  fielded in the middle could get ugly.
  4003. + *
  4004. + *  Since so much of the abort and reset code is shared, this
  4005. + *  function performs more magic than it really should.  If the
  4006. + *  command completes ok, then it will call scsi_done with the
  4007. + *  result code passed in.  The unpause parameter controls whether
  4008. + *  or not the sequencer gets unpaused - the reset function, for
  4009. + *  instance, may want to do something more aggressive.
  4010. + *
  4011. + *  Note that the command is checked for in our SCB_array first
  4012. + *  before the sequencer is paused, so if k_absent is returned,
  4013. + *  then the sequencer is NOT paused.
  4014. + */
  4015. +
  4016. +static
  4017. +enum k_state aha274x_kill(Scsi_Cmnd *cmd, unsigned char message,
  4018. +              unsigned int result, int unpause)
  4019. +{
  4020. +    struct aha274x_host *p;
  4021. +    int i, scb, found, queued;
  4022. +    unsigned char scbsave[AHA274X_MAXSCB];
  4023. +
  4024. +    p = (struct aha274x_host *)cmd->host->hostdata;
  4025. +
  4026. +    /*
  4027. +     *  If we can't find the command, assume it just completed
  4028. +     *  and shrug it away.
  4029. +     */
  4030. +    for (scb = 0; scb < AHA274X_MAXSCB; scb++)
  4031. +        if (p->SCB_array[scb] == cmd)
  4032. +            break;
  4033. +
  4034. +    if (scb == AHA274X_MAXSCB)
  4035. +        return(k_absent);
  4036. +
  4037. +    PAUSE_SEQUENCER(p);
  4038. +
  4039. +    /*
  4040. +     *  This is the best case, really.  Check to see if the
  4041. +     *  command is still in the sequencer's input queue.  If
  4042. +     *  so, simply remove it.  Reload the queue afterward.
  4043. +     */
  4044. +    queued = inb(O_QINCNT(p->base));
  4045. +    
  4046. +    for (i = found = 0; i < queued; i++) {
  4047. +        scbsave[i] = inb(O_QINFIFO(p->base));
  4048. +
  4049. +        if (scbsave[i] == scb) {
  4050. +            found = 1;
  4051. +            i -= 1;
  4052. +        }
  4053. +    }
  4054. +
  4055. +    queued -= found;
  4056. +    for (i = 0; i < queued; i++)
  4057. +        outb(scbsave[i], O_QINFIFO(p->base));
  4058. +
  4059. +    if (found)
  4060. +        goto complete;
  4061. +
  4062. +    /*
  4063. +     *  Check the current SCB bank.  If it's not the one belonging
  4064. +     *  to the command we want to kill, assume that the command
  4065. +     *  is disconnected.  It's rather a pain to force a reconnect
  4066. +     *  and send a message to the target, so we abdicate responsibility
  4067. +     *  in this case.
  4068. +     */
  4069. +    if (inb(O_SCBPTR(p->base)) != scb) {
  4070. +        if (unpause)
  4071. +            UNPAUSE_SEQUENCER(p);
  4072. +        return(k_disconnect);
  4073. +    }
  4074. +
  4075. +    /*
  4076. +     *  Presumably at this point our target command is active.  Check
  4077. +     *  to see if there's a message already in effect.  If not, place
  4078. +     *  our message in and assert ATN so the target goes into MESSAGE
  4079. +     *  OUT phase.
  4080. +     */
  4081. +    if (inb(HA_MSG_FLAGS(p->base)) & 0x80) {
  4082. +        if (unpause)
  4083. +            UNPAUSE_SEQUENCER(p);
  4084. +        return(k_busy);
  4085. +    }
  4086. +
  4087. +    outb(0x80, HA_MSG_FLAGS(p->base));        /* active message */
  4088. +    outb(1, HA_MSG_LEN(p->base));            /* length = 1 */
  4089. +    outb(message, HA_MSG_START(p->base));        /* message body */
  4090. +
  4091. +    /*
  4092. +     *  Assert ATN.  Use the value of SCSISIGO saved by the
  4093. +     *  sequencer code so we don't alter its contents radically
  4094. +     *  in the middle of something critical.
  4095. +     */
  4096. +    outb(inb(HA_SIGSTATE(p->base)) | 0x10, O_SCSISIGO(p->base));
  4097. +
  4098. +    /*
  4099. +     *  The command has been killed.  Do the bookkeeping, unpause
  4100. +     *  the sequencer, and notify the higher-level SCSI code.
  4101. +     */
  4102. +complete:
  4103. +    p->SCB_array[scb] = NULL;
  4104. +    if (unpause)
  4105. +        UNPAUSE_SEQUENCER(p);
  4106. +
  4107. +    cmd->result = result << 16;
  4108. +    cmd->scsi_done(cmd);
  4109. +    return(k_ok);
  4110. +}
  4111. +
  4112. +int aha274x_abort(Scsi_Cmnd *cmd)
  4113. +{
  4114. +    int rv;
  4115. +    long flags;
  4116. +
  4117. +    save_flags(flags);
  4118. +    cli();
  4119. +
  4120. +    switch (aha274x_kill(cmd, ABORT, DID_ABORT, !0)) {
  4121. +        case k_ok:        rv = SCSI_ABORT_SUCCESS;    break;
  4122. +        case k_busy:    rv = SCSI_ABORT_BUSY;        break;
  4123. +        case k_absent:    rv = SCSI_ABORT_NOT_RUNNING;    break;
  4124. +        case k_disconnect:    rv = SCSI_ABORT_SNOOZE;        break;
  4125. +        default:
  4126. +        panic("aha274x_do_abort: internal error\n");
  4127. +    }
  4128. +
  4129. +    restore_flags(flags);
  4130. +    return(rv);
  4131. +}
  4132. +
  4133. +/*
  4134. + *  Resetting the bus always succeeds - is has to, otherwise the
  4135. + *  kernel will panic!  Try a surgical technique - sending a BUS
  4136. + *  DEVICE RESET message - on the offending target before pulling
  4137. + *  the SCSI bus reset line.
  4138. + */
  4139. +
  4140. +int aha274x_reset(Scsi_Cmnd *cmd)
  4141. +{
  4142. +    int i;
  4143. +    long flags;
  4144. +    Scsi_Cmnd *reset;
  4145. +    struct aha274x_host *p;
  4146. +
  4147. +    p = (struct aha274x_host *)cmd->host->hostdata;
  4148. +    save_flags(flags);
  4149. +    cli();
  4150. +
  4151. +    switch (aha274x_kill(cmd, BUS_DEVICE_RESET, DID_RESET, 0)) {
  4152. +
  4153. +        case k_ok:
  4154. +        /*
  4155. +         *  The RESET message was sent to the target
  4156. +         *  with no problems.  Flag that target as
  4157. +         *  needing a SDTR negotiation on the next
  4158. +         *  connection and restart the sequencer.
  4159. +         */
  4160. +        outb((1 << cmd->target), HA_NEEDSDTR(p->base));
  4161. +        UNPAUSE_SEQUENCER(p);
  4162. +        break;
  4163. +
  4164. +        case k_absent:
  4165. +        /*
  4166. +         *  The sequencer will not be paused if aha274x_kill()
  4167. +         *  couldn't find the command.
  4168. +         */
  4169. +        PAUSE_SEQUENCER(p);
  4170. +        /* falls through */
  4171. +
  4172. +        case k_busy:
  4173. +        case k_disconnect:
  4174. +        /*
  4175. +         *  Do a hard reset of the SCSI bus.  According to the
  4176. +         *  SCSI-2 draft specification, reset has to be asserted
  4177. +         *  for at least 25us.  I'm invoking the kernel delay
  4178. +         *  function for 30us since I'm not totally trusting of
  4179. +         *  the busy loop timing.
  4180. +         *
  4181. +         *  XXX - I'm not convinced this works.  I tried resetting
  4182. +         *      the bus before, trying to get the devices on the
  4183. +         *      bus to revert to asynchronous transfer, and it
  4184. +         *      never seemed to work.
  4185. +         */
  4186. +        debug("aha274x: attempting to reset scsi bus and card\n");
  4187. +
  4188. +        outb(1, O_SCSISEQ(p->base));        /* SCSIRSTO */
  4189. +        udelay(30);
  4190. +        outb(0, O_SCSISEQ(p->base));        /* !SCSIRSTO */
  4191. +
  4192. +        outb(0xff, HA_NEEDSDTR(p->base));
  4193. +        UNPAUSE_SEQUENCER(p);
  4194. +
  4195. +        /*
  4196. +         *  Locate the command and return a "reset" status
  4197. +         *  for it.  This is not completely correct and will
  4198. +         *  probably return to haunt me later.
  4199. +         */
  4200. +        for (i = 0; i < AHA274X_MAXSCB; i++) {
  4201. +            if (cmd == p->SCB_array[i]) {
  4202. +                reset = (Scsi_Cmnd *)p->SCB_array[i];
  4203. +                p->SCB_array[i] = NULL;
  4204. +                reset->result = DID_RESET << 16;
  4205. +                reset->scsi_done(reset);
  4206. +                break;
  4207. +            }
  4208. +        }
  4209. +        break;
  4210. +
  4211. +        default:
  4212. +        panic("aha274x_reset: internal error\n");
  4213. +    }
  4214. +
  4215. +    restore_flags(flags);
  4216. +    return(SCSI_RESET_SUCCESS);
  4217. +}
  4218. +
  4219. +int aha274x_biosparam(Disk *disk, int devno, int geom[])
  4220. +{
  4221. +    /*
  4222. +     *  XXX - when I find the EISA configuration information,
  4223. +     *      this should change to handle the "extended translation
  4224. +     *      for drives >1G" option, which uses 255 heads and
  4225. +     *      63 sectors/track for drives >1G.  Right now, just
  4226. +     *      assume it's turned off.
  4227. +     */
  4228. +    debug("aha274x_biosparam warning: don't know translation config\n");
  4229. +
  4230. +    geom[0] = 64;
  4231. +    geom[1] = 32;
  4232. +    geom[2] = disk->capacity / (64 * 32);
  4233. +
  4234. +    return(0);
  4235. +}
  4236. +
  4237. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/aha274x.h linux/drivers/scsi/aha274x.h
  4238. --- linux-1.1.58/drivers/scsi/aha274x.h    Wed Dec 31 18:00:00 1969
  4239. +++ linux/drivers/scsi/aha274x.h    Wed Oct 26 23:02:01 1994
  4240. @@ -0,0 +1,62 @@
  4241. +/* @(#)aha274x.h 1.11 94/09/06 jda */
  4242. +
  4243. +/*
  4244. + * Adaptec 274x device driver for Linux.
  4245. + * Copyright (c) 1994 The University of Calgary Department of Computer Science.
  4246. + * 
  4247. + * This program is free software; you can redistribute it and/or modify
  4248. + * it under the terms of the GNU General Public License as published by
  4249. + * the Free Software Foundation; either version 2 of the License, or
  4250. + * (at your option) any later version.
  4251. + * 
  4252. + * This program is distributed in the hope that it will be useful,
  4253. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4254. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4255. + * GNU General Public License for more details.
  4256. + * 
  4257. + * You should have received a copy of the GNU General Public License
  4258. + * along with this program; if not, write to the Free Software
  4259. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  4260. + */
  4261. +
  4262. +#ifndef aha274x_h
  4263. +#define aha274x_h
  4264. +
  4265. +#define    AHA274X_MAXSCB        4
  4266. +#define AHA274X_H_VERSION    "1.11"
  4267. +
  4268. +/*
  4269. + *  Scsi_Host_Template (see hosts.h) for 274x - some fields
  4270. + *  to do with card config are filled in after the card is
  4271. + *  detected.
  4272. + */
  4273. +#define AHA274X    {                        \
  4274. +    NULL,                            \
  4275. +    "",                            \
  4276. +    aha274x_detect,                        \
  4277. +    NULL,                            \
  4278. +    aha274x_info,                        \
  4279. +    aha274x_command,                    \
  4280. +    aha274x_queue,                        \
  4281. +    aha274x_abort,                        \
  4282. +    aha274x_reset,                        \
  4283. +    NULL,                            \
  4284. +    aha274x_biosparam,                    \
  4285. +    AHA274X_MAXSCB,        /* max simultaneous cmds      */\
  4286. +    -1,            /* scsi id of host adapter    */\
  4287. +    SG_ALL,            /* max scatter-gather cmds    */\
  4288. +    1,            /* cmds per lun (linked cmds) */\
  4289. +    0,            /* number of 274x's present   */\
  4290. +    0,            /* no memory DMA restrictions */\
  4291. +    DISABLE_CLUSTERING                    \
  4292. +}
  4293. +
  4294. +extern int aha274x_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
  4295. +extern int aha274x_biosparam(Disk *, int, int[]);
  4296. +extern int aha274x_detect(Scsi_Host_Template *);
  4297. +extern int aha274x_command(Scsi_Cmnd *);
  4298. +extern int aha274x_abort(Scsi_Cmnd *);
  4299. +extern int aha274x_reset(Scsi_Cmnd *);
  4300. +extern const char *aha274x_info(void);
  4301. +
  4302. +#endif
  4303. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/aha274x.seq linux/drivers/scsi/aha274x.seq
  4304. --- linux-1.1.58/drivers/scsi/aha274x.seq    Wed Dec 31 18:00:00 1969
  4305. +++ linux/drivers/scsi/aha274x.seq    Wed Oct 26 23:02:01 1994
  4306. @@ -0,0 +1,1021 @@
  4307. +# @(#)aha274x.seq 1.28 94/10/04 jda
  4308. +#
  4309. +# Adaptec 274x device driver for Linux.
  4310. +# Copyright (c) 1994 The University of Calgary Department of Computer Science.
  4311. +# 
  4312. +# This program is free software; you can redistribute it and/or modify
  4313. +# it under the terms of the GNU General Public License as published by
  4314. +# the Free Software Foundation; either version 2 of the License, or
  4315. +# (at your option) any later version.
  4316. +# 
  4317. +# This program is distributed in the hope that it will be useful,
  4318. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  4319. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4320. +# GNU General Public License for more details.
  4321. +# 
  4322. +# You should have received a copy of the GNU General Public License
  4323. +# along with this program; if not, write to the Free Software
  4324. +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  4325. +
  4326. +VERSION AHA274X_SEQ_VERSION 1.28
  4327. +
  4328. +MAXSCB        = 4
  4329. +
  4330. +SCSISEQ        = 0x00
  4331. +SXFRCTL0    = 0x01
  4332. +SXFRCTL1    = 0x02
  4333. +SCSISIGI    = 0x03
  4334. +SCSISIGO    = 0x03
  4335. +SCSIRATE    = 0x04
  4336. +SCSIID        = 0x05
  4337. +SCSIDATL    = 0x06
  4338. +STCNT        = 0x08
  4339. +STCNT+0        = 0x08
  4340. +STCNT+1        = 0x09
  4341. +STCNT+2        = 0x0a
  4342. +SSTAT0        = 0x0b
  4343. +CLRSINT1    = 0x0c
  4344. +SSTAT1        = 0x0c
  4345. +SIMODE1        = 0x11
  4346. +SCSIBUSL    = 0x12
  4347. +SHADDR        = 0x14
  4348. +SELID        = 0x19
  4349. +SBLKCTL        = 0x1f
  4350. +SEQCTL        = 0x60
  4351. +A        = 0x64                # == ACCUM
  4352. +SINDEX        = 0x65
  4353. +DINDEX        = 0x66
  4354. +ALLZEROS    = 0x6a
  4355. +NONE        = 0x6a
  4356. +SINDIR        = 0x6c
  4357. +DINDIR        = 0x6d
  4358. +FUNCTION1    = 0x6e
  4359. +HADDR        = 0x88
  4360. +HCNT        = 0x8c
  4361. +HCNT+0        = 0x8c
  4362. +HCNT+1        = 0x8d
  4363. +HCNT+2        = 0x8e
  4364. +SCBPTR        = 0x90
  4365. +INTSTAT        = 0x91
  4366. +DFCNTRL        = 0x93
  4367. +DFSTATUS    = 0x94
  4368. +DFDAT        = 0x99
  4369. +QINFIFO        = 0x9b
  4370. +QINCNT        = 0x9c
  4371. +QOUTFIFO    = 0x9d
  4372. +
  4373. +SCSICONF    = 0x5a
  4374. +
  4375. +#  The two reserved bytes at SCBARRAY+1[23] are expected to be set to
  4376. +#  zero, and the reserved bit in SCBARRAY+0 is used as an internal flag
  4377. +#  to indicate whether or not to reload scatter-gather parameters after
  4378. +#  a disconnect.
  4379. +#
  4380. +SCBARRAY+0    = 0xa0
  4381. +SCBARRAY+1    = 0xa1
  4382. +SCBARRAY+2    = 0xa2
  4383. +SCBARRAY+3    = 0xa3
  4384. +SCBARRAY+7    = 0xa7
  4385. +SCBARRAY+11    = 0xab
  4386. +SCBARRAY+14    = 0xae
  4387. +SCBARRAY+15    = 0xaf
  4388. +SCBARRAY+16    = 0xb0
  4389. +SCBARRAY+17    = 0xb1
  4390. +SCBARRAY+18    = 0xb2
  4391. +SCBARRAY+19    = 0xb3
  4392. +SCBARRAY+20    = 0xb4
  4393. +SCBARRAY+21    = 0xb5
  4394. +SCBARRAY+22    = 0xb6
  4395. +SCBARRAY+23    = 0xb7
  4396. +SCBARRAY+24    = 0xb8
  4397. +SCBARRAY+25    = 0xb9
  4398. +
  4399. +SIGNAL_0    = 0x01                # unknown scsi bus phase
  4400. +SIGNAL_1    = 0x11                # message reject
  4401. +SIGNAL_2    = 0x21                # no IDENTIFY after reconnect
  4402. +SIGNAL_3    = 0x31                # no cmd match for reconnect
  4403. +SIGNAL_4    = 0x41                # SDTR -> SCSIRATE conversion
  4404. +
  4405. +#  The host adapter card (at least the BIOS) uses 20-2f for SCSI
  4406. +#  device information, 32-33 and 5a-5f as well.  Since we don't support
  4407. +#  wide or twin-bus SCSI, 28-2f can be reclaimed.  As it turns out, the
  4408. +#  BIOS trashes 20-27 anyway, writing the synchronous negotiation results
  4409. +#  on top of the BIOS values, so we re-use those for our per-target
  4410. +#  scratchspace (actually a value that can be copied directly into
  4411. +#  SCSIRATE).  This implies, since we can't get the BIOS config values,
  4412. +#  that all targets will be negotiated with for synchronous transfer.
  4413. +#  NEEDSDTR has one bit per target indicating if an SDTR message is
  4414. +#  needed for that device - this will be set initially, as well as
  4415. +#  after a bus reset condition.
  4416. +#
  4417. +#  The high bit of DROPATN is set if ATN should be dropped before the ACK
  4418. +#  when outb is called.  REJBYTE contains the first byte of a MESSAGE IN
  4419. +#  message, so the driver can report an intelligible error if a message is
  4420. +#  rejected.
  4421. +#
  4422. +#  RESELECT's high bit is true if we are currently handling a reselect;
  4423. +#  its next-highest bit is true ONLY IF we've seen an IDENTIFY message
  4424. +#  from the reselecting target.  If we haven't had IDENTIFY, then we have
  4425. +#  no idea what the lun is, and we can't select the right SCB register
  4426. +#  bank, so force a kernel panic if the target attempts a data in/out or
  4427. +#  command phase instead of corrupting something.
  4428. +#
  4429. +#  Note that SG_NEXT occupies four bytes.
  4430. +#
  4431. +SYNCNEG        = 0x20
  4432. +DISC_DSB_A    = 0x32
  4433. +
  4434. +DROPATN        = 0x30
  4435. +REJBYTE        = 0x31
  4436. +RESELECT    = 0x34
  4437. +
  4438. +MSG_FLAGS    = 0x35
  4439. +MSG_LEN        = 0x36
  4440. +MSG_START+0    = 0x37
  4441. +MSG_START+1    = 0x38
  4442. +MSG_START+2    = 0x39
  4443. +MSG_START+3    = 0x3a
  4444. +MSG_START+4    = 0x3b
  4445. +MSG_START+5    = 0x3c
  4446. +-MSG_START+0    = 0xc9                # 2's complement of MSG_START+0
  4447. +
  4448. +ARG_1        = 0x4c                # sdtr conversion args & return
  4449. +ARG_2        = 0x4d
  4450. +RETURN_1    = 0x4c
  4451. +
  4452. +SIGSTATE    = 0x4e                # value written to SCSISIGO
  4453. +NEEDSDTR    = 0x4f                # send SDTR message, 1 bit/trgt
  4454. +
  4455. +SG_SIZEOF    = 12                # sizeof(struct scatterlist)
  4456. +SG_NOLOAD    = 0x50                # load SG pointer/length?
  4457. +SG_COUNT    = 0x51                # working value of SG count
  4458. +SG_NEXT        = 0x52                # working value of SG pointer
  4459. +SG_NEXT+0    = 0x52
  4460. +SG_NEXT+1    = 0x53
  4461. +SG_NEXT+2    = 0x54
  4462. +SG_NEXT+3    = 0x55
  4463. +
  4464. +#  Poll QINCNT for work - the lower three bits contain
  4465. +#  the number of entries in the Queue In FIFO.
  4466. +#
  4467. +start:
  4468. +    test    SCSISIGI,0x4    jnz reselect    # BSYI
  4469. +    test    QINCNT,0x7    jz start
  4470. +
  4471. +#  We have at least one queued SCB now.  Set the SCB pointer
  4472. +#  from the FIFO so we see the right bank of SCB registers,
  4473. +#  then set SCSI options and set the initiator and target
  4474. +#  SCSI IDs.
  4475. +#
  4476. +    mov    SCBPTR,QINFIFO
  4477. +    mov    SCBARRAY+1    call initialize
  4478. +    clr    SG_NOLOAD
  4479. +    clr    RESELECT
  4480. +
  4481. +#  As soon as we get a successful selection, the target should go
  4482. +#  into the message out phase since we have ATN asserted.  Prepare
  4483. +#  the message to send, locking out the device driver.  If the device
  4484. +#  driver hasn't beaten us with an ABORT or RESET message, then tack
  4485. +#  on a SDTR negotation if required.
  4486. +#
  4487. +#  Messages are stored in scratch RAM starting with a flag byte (high bit
  4488. +#  set means active message), one length byte, and then the message itself.
  4489. +#
  4490. +    mov    SCBARRAY+1    call disconnect    # disconnect ok?
  4491. +
  4492. +    and    SINDEX,0x7,SCBARRAY+1        # lun
  4493. +    or    SINDEX,A            # return value from disconnect
  4494. +    or    SINDEX,0x80    call mk_mesg    # IDENTIFY message
  4495. +
  4496. +    mov    A,SINDEX
  4497. +    cmp    MSG_START+0,A    jne !message    # did driver beat us?
  4498. +    mvi    MSG_START+1    call mk_sdtr    # build SDTR message if needed
  4499. +
  4500. +!message:
  4501. +
  4502. +#  Enable selection phase as an initiator, and do automatic ATN
  4503. +#  after the selection.
  4504. +#
  4505. +    mvi    SCSISEQ,0x48            # ENSELO|ENAUTOATNO
  4506. +
  4507. +#  Wait for successful arbitration.  The AIC-7770 documentation says
  4508. +#  that SELINGO indicates successful arbitration, and that it should
  4509. +#  be used to look for SELDO.  However, if the sequencer is paused at
  4510. +#  just the right time - a parallel fsck(8) on two drives did it for
  4511. +#  me - then SELINGO can flip back to false before we've seen it.  This
  4512. +#  makes the sequencer sit in the arbitration loop forever.  This is
  4513. +#  Not Good.
  4514. +#
  4515. +#  Therefore, I've added a check in the arbitration loop for SELDO
  4516. +#  too.  This could arguably be made a critical section by disabling
  4517. +#  pauses, but I don't want to make a potentially infinite loop a CS.
  4518. +#  I suppose you could fold it into the select loop, too, but since
  4519. +#  I've been hunting this bug for four days it's kinda like a trophy.
  4520. +#
  4521. +arbitrate:
  4522. +    test    SSTAT0,0x40    jnz *select    # SELDO
  4523. +    test    SSTAT0,0x10    jz arbitrate    # SELINGO
  4524. +
  4525. +#  Wait for a successful selection.  If the hardware selection
  4526. +#  timer goes off, then the driver gets the interrupt, so we don't
  4527. +#  need to worry about it.
  4528. +#
  4529. +select:
  4530. +    test    SSTAT0,0x40    jz select    # SELDO
  4531. +    jmp    *select
  4532. +
  4533. +#  Reselection is being initiated by a target - we've seen the BSY
  4534. +#  line driven active, and we didn't do it!  Enable the reselection
  4535. +#  hardware, and wait for it to finish.  Make a note that we've been
  4536. +#  reselected, but haven't seen an IDENTIFY message from the target
  4537. +#  yet.
  4538. +#
  4539. +reselect:
  4540. +    mvi    SCSISEQ,0x10            # ENRSELI
  4541. +
  4542. +reselect1:
  4543. +    test    SSTAT0,0x20    jz reselect1    # SELDI
  4544. +    mov    SELID        call initialize
  4545. +
  4546. +    mvi    RESELECT,0x80            # reselected, no IDENTIFY
  4547. +
  4548. +#  After the [re]selection, make sure that the [re]selection enable
  4549. +#  bit is off.  This chip is flaky enough without extra things
  4550. +#  turned on.  Also clear the BUSFREE bit in SSTAT1 since we'll be
  4551. +#  using it shortly.
  4552. +#
  4553. +*select:
  4554. +    clr    SCSISEQ
  4555. +    mvi    CLRSINT1,0x8            # CLRBUSFREE
  4556. +
  4557. +#  Main loop for information transfer phases.  If BSY is false, then
  4558. +#  we have a bus free condition, expected or not.  Otherwise, wait
  4559. +#  for the target to assert REQ before checking MSG, C/D and I/O
  4560. +#  for the bus phase.
  4561. +#
  4562. +#  We can't simply look at the values of SCSISIGI here (if we want
  4563. +#  to do synchronous data transfer), because the target won't assert
  4564. +#  REQ if it's already sent us some data that we haven't acknowledged
  4565. +#  yet.
  4566. +#
  4567. +ITloop:
  4568. +    test    SSTAT1,0x8    jnz p_busfree    # BUSFREE
  4569. +    test    SSTAT1,0x1    jz ITloop    # REQINIT
  4570. +
  4571. +    and    A,0xe0,SCSISIGI            # CDI|IOI|MSGI
  4572. +
  4573. +    cmp    ALLZEROS,A    je p_dataout
  4574. +    cmp    A,0x40        je p_datain
  4575. +    cmp    A,0x80        je p_command
  4576. +    cmp    A,0xc0        je p_status
  4577. +    cmp    A,0xa0        je p_mesgout
  4578. +    cmp    A,0xe0        je p_mesgin
  4579. +
  4580. +    mvi    INTSTAT,SIGNAL_0        # unknown - signal driver
  4581. +
  4582. +p_dataout:
  4583. +    mvi    0        call scsisig    # !CDO|!IOO|!MSGO
  4584. +    call    assert
  4585. +    call    sg_load
  4586. +
  4587. +    mvi    A,3
  4588. +    mvi    DINDEX,HCNT
  4589. +    mvi    SCBARRAY+23    call bcopy
  4590. +
  4591. +    mvi    A,3
  4592. +    mvi    DINDEX,STCNT
  4593. +    mvi    SCBARRAY+23    call bcopy
  4594. +
  4595. +    mvi    A,4
  4596. +    mvi    DINDEX,HADDR
  4597. +    mvi    SCBARRAY+19    call bcopy
  4598. +
  4599. +    mvi    0x3d        call dma    # SCSIEN|SDMAEN|HDMAEN|
  4600. +                        #   DIRECTION|FIFORESET
  4601. +
  4602. +#  After a DMA finishes, save the final transfer pointer and count
  4603. +#  back into the SCB, in case a device disconnects in the middle of
  4604. +#  a transfer.  Use SHADDR and STCNT instead of HADDR and HCNT, since
  4605. +#  it's a reflection of how many bytes were transferred on the SCSI
  4606. +#  (as opposed to the host) bus.
  4607. +#
  4608. +    mvi    A,3
  4609. +    mvi    DINDEX,SCBARRAY+23
  4610. +    mvi    STCNT        call bcopy
  4611. +
  4612. +    mvi    A,4
  4613. +    mvi    DINDEX,SCBARRAY+19
  4614. +    mvi    SHADDR        call bcopy
  4615. +
  4616. +    call    sg_advance
  4617. +    mov    SCBARRAY+18,SG_COUNT        # residual S/G count
  4618. +
  4619. +    jmp    ITloop
  4620. +
  4621. +p_datain:
  4622. +    mvi    0x40        call scsisig    # !CDO|IOO|!MSGO
  4623. +    call    assert
  4624. +    call    sg_load
  4625. +
  4626. +    mvi    A,3
  4627. +    mvi    DINDEX,HCNT
  4628. +    mvi    SCBARRAY+23    call bcopy
  4629. +
  4630. +    mvi    A,3
  4631. +    mvi    DINDEX,STCNT
  4632. +    mvi    SCBARRAY+23    call bcopy
  4633. +
  4634. +    mvi    A,4
  4635. +    mvi    DINDEX,HADDR
  4636. +    mvi    SCBARRAY+19    call bcopy
  4637. +
  4638. +    mvi    0x39        call dma    # SCSIEN|SDMAEN|HDMAEN|
  4639. +                        #   !DIRECTION|FIFORESET
  4640. +    mvi    A,3
  4641. +    mvi    DINDEX,SCBARRAY+23
  4642. +    mvi    STCNT        call bcopy
  4643. +
  4644. +    mvi    A,4
  4645. +    mvi    DINDEX,SCBARRAY+19
  4646. +    mvi    SHADDR        call bcopy
  4647. +
  4648. +    call    sg_advance
  4649. +    mov    SCBARRAY+18,SG_COUNT        # residual S/G count
  4650. +
  4651. +    jmp    ITloop
  4652. +
  4653. +#  Command phase.  Set up the DMA registers and let 'er rip - the
  4654. +#  two bytes after the SCB SCSI_cmd_length are zeroed by the driver,
  4655. +#  so we can copy those three bytes directly into HCNT.
  4656. +#
  4657. +p_command:
  4658. +    mvi    0x80        call scsisig    # CDO|!IOO|!MSGO
  4659. +    call    assert
  4660. +
  4661. +    mvi    A,3
  4662. +    mvi    DINDEX,HCNT
  4663. +    mvi    SCBARRAY+11    call bcopy
  4664. +
  4665. +    mvi    A,3
  4666. +    mvi    DINDEX,STCNT
  4667. +    mvi    SCBARRAY+11    call bcopy
  4668. +
  4669. +    mvi    A,4
  4670. +    mvi    DINDEX,HADDR
  4671. +    mvi    SCBARRAY+7    call bcopy
  4672. +
  4673. +    mvi    0x3d        call dma    # SCSIEN|SDMAEN|HDMAEN|
  4674. +                        #   DIRECTION|FIFORESET
  4675. +    jmp    ITloop
  4676. +
  4677. +#  Status phase.  Wait for the data byte to appear, then read it
  4678. +#  and store it into the SCB.
  4679. +#
  4680. +p_status:
  4681. +    mvi    0xc0        call scsisig    # CDO|IOO|!MSGO
  4682. +
  4683. +    mvi    SCBARRAY+14    call inb
  4684. +    jmp    ITloop
  4685. +
  4686. +#  Message out phase.  If there is no active message, but the target
  4687. +#  took us into this phase anyway, build a no-op message and send it.
  4688. +#
  4689. +p_mesgout:
  4690. +    mvi    0xa0        call scsisig    # CDO|!IOO|MSGO
  4691. +    mvi    0x8        call mk_mesg    # build NOP message
  4692. +
  4693. +#  Set up automatic PIO transfer from MSG_START.  Bit 3 in
  4694. +#  SXFRCTL0 (SPIOEN) is already on.
  4695. +#
  4696. +    mvi    SINDEX,MSG_START+0
  4697. +    mov    DINDEX,MSG_LEN
  4698. +    clr    A
  4699. +
  4700. +#  When target asks for a byte, drop ATN if it's the last one in
  4701. +#  the message.  Otherwise, keep going until the message is exhausted.
  4702. +#  (We can't use outb for this since it wants the input in SINDEX.)
  4703. +#
  4704. +#  Keep an eye out for a phase change, in case the target issues
  4705. +#  a MESSAGE REJECT.
  4706. +#
  4707. +p_mesgout2:
  4708. +    test    SSTAT0,0x2    jz p_mesgout2    # SPIORDY
  4709. +    test    SSTAT1,0x10    jnz p_mesgout6    # PHASEMIS
  4710. +
  4711. +    cmp    DINDEX,1    jne p_mesgout3    # last byte?
  4712. +    mvi    CLRSINT1,0x40            # CLRATNO - drop ATN
  4713. +
  4714. +#  Write a byte to the SCSI bus.  The AIC-7770 refuses to automatically
  4715. +#  send ACKs in automatic PIO or DMA mode unless you make sure that the
  4716. +#  "expected" bus phase in SCSISIGO matches the actual bus phase.  This
  4717. +#  behaviour is completely undocumented and caused me several days of
  4718. +#  grief.
  4719. +#
  4720. +#  After plugging in different drives to test with and using a longer
  4721. +#  SCSI cable, I found that I/O in Automatic PIO mode ceased to function,
  4722. +#  especially when transferring >1 byte.  It seems to be much more stable
  4723. +#  if STCNT is set to one before the transfer, and SDONE (in SSTAT0) is
  4724. +#  polled for transfer completion - for both output _and_ input.  The
  4725. +#  only theory I have is that SPIORDY doesn't drop right away when SCSIDATL
  4726. +#  is accessed (like the documentation says it does), and that on a longer
  4727. +#  cable run, the sequencer code was fast enough to loop back and see
  4728. +#  an SPIORDY that hadn't dropped yet.
  4729. +#
  4730. +p_mesgout3:
  4731. +    call    one_stcnt
  4732. +    mov    SCSIDATL,SINDIR
  4733. +
  4734. +p_mesgout4:
  4735. +    test    SSTAT0,0x4    jz p_mesgout4    # SDONE
  4736. +    dec    DINDEX
  4737. +    inc    A
  4738. +    cmp    MSG_LEN,A    jne p_mesgout2
  4739. +
  4740. +#  If the next bus phase after ATN drops is a message out, it means
  4741. +#  that the target is requesting that the last message(s) be resent.
  4742. +#
  4743. +p_mesgout5:
  4744. +    test    SSTAT1,0x8    jnz p_mesgout6    # BUSFREE
  4745. +    test    SSTAT1,0x1    jz p_mesgout5    # REQINIT
  4746. +
  4747. +    and    A,0xe0,SCSISIGI            # CDI|IOI|MSGI
  4748. +    cmp    A,0xa0        jne p_mesgout6
  4749. +    mvi    0x10        call scsisig    # ATNO - re-assert ATN
  4750. +
  4751. +    jmp    ITloop
  4752. +
  4753. +p_mesgout6:
  4754. +    mvi    CLRSINT1,0x40            # CLRATNO - in case of PHASEMIS
  4755. +    clr    MSG_FLAGS            # no active msg
  4756. +    jmp    ITloop
  4757. +
  4758. +#  Message in phase.  Bytes are read using Automatic PIO mode, but not
  4759. +#  using inb.  This alleviates a race condition, namely that if ATN had
  4760. +#  to be asserted under Automatic PIO mode, it had to beat the SCSI
  4761. +#  circuitry sending an ACK to the target.  This showed up under heavy
  4762. +#  loads and really confused things, since ABORT commands wouldn't be
  4763. +#  seen by the drive after an IDENTIFY message in until it had changed
  4764. +#  to a data I/O phase.
  4765. +#
  4766. +p_mesgin:
  4767. +    mvi    0xe0        call scsisig    # CDO|IOO|MSGO
  4768. +    mvi    A        call inb_first    # read the 1st message byte
  4769. +    mvi    REJBYTE,A            # save it for the driver
  4770. +
  4771. +    cmp    ALLZEROS,A    jne p_mesgin1
  4772. +
  4773. +#  We got a "command complete" message, so put the SCB pointer
  4774. +#  into the Queue Out, and trigger a completion interrupt.
  4775. +#
  4776. +    mov    QOUTFIFO,SCBPTR
  4777. +    mvi    INTSTAT,0x2            # CMDCMPLT
  4778. +    jmp    p_mesgin_done
  4779. +
  4780. +#  Is it an extended message?  We only support the synchronous data
  4781. +#  transfer request message, which will probably be in response to
  4782. +#  an SDTR message out from us.  If it's not an SDTR, reject it -
  4783. +#  apparently this can be done after any message in byte, according
  4784. +#  to the SCSI-2 spec.
  4785. +#
  4786. +#  XXX - we should really reject this if we didn't initiate the SDTR
  4787. +#     negotiation; this may cause problems with unusual devices.
  4788. +#
  4789. +p_mesgin1:
  4790. +    cmp    A,1        jne p_mesgin2    # extended message code?
  4791. +    
  4792. +    mvi    A        call inb_next
  4793. +    cmp    A,3        jne p_mesginN    # extended mesg length = 3
  4794. +    mvi    A        call inb_next
  4795. +    cmp    A,1        jne p_mesginN    # SDTR code
  4796. +
  4797. +    mvi    ARG_1        call inb_next    # xfer period
  4798. +    mvi    ARG_2        call inb_next    # REQ/ACK offset
  4799. +    mvi    INTSTAT,SIGNAL_4        # call driver to convert
  4800. +
  4801. +    call    ndx_sdtr            # index sync config for target
  4802. +    mov    DINDEX,SINDEX
  4803. +    mov    DINDIR,RETURN_1            # save returned value
  4804. +
  4805. +    not    A                # turn off "need sdtr" flag
  4806. +    and    NEEDSDTR,A
  4807. +
  4808. +#  Even though the SCSI-2 specification says that a device responding
  4809. +#  to our SDTR message should honor our parameters for transmitting
  4810. +#  to us, it doesn't seem to work too well in real life.  In particular,
  4811. +#  a lot of CD-ROM and tape units don't function: try using the SDTR
  4812. +#  parameters the device sent us for both transmitting and receiving.
  4813. +#
  4814. +    mov    SCSIRATE,RETURN_1
  4815. +    jmp    p_mesgin_done
  4816. +
  4817. +#  Is it a disconnect message?  Set a flag in the SCB to remind us
  4818. +#  and await the bus going free.
  4819. +#
  4820. +p_mesgin2:
  4821. +    cmp    A,4        jne p_mesgin3    # disconnect code?
  4822. +
  4823. +    or    SCBARRAY+0,0x4            # set "disconnected" bit
  4824. +    jmp    p_mesgin_done
  4825. +
  4826. +#  Save data pointers message?  Copy working values into the SCB,
  4827. +#  usually in preparation for a disconnect.
  4828. +#
  4829. +p_mesgin3:
  4830. +    cmp    A,2        jne p_mesgin4    # save data pointers code?
  4831. +
  4832. +    call    sg_ram2scb
  4833. +    jmp    p_mesgin_done
  4834. +
  4835. +#  Restore pointers message?  Data pointers are recopied from the
  4836. +#  SCB anyway at the start of any DMA operation, so the only thing
  4837. +#  to copy is the scatter-gather values.
  4838. +#
  4839. +p_mesgin4:
  4840. +    cmp    A,3        jne p_mesgin5    # restore pointers code?
  4841. +
  4842. +    call    sg_scb2ram
  4843. +    jmp    p_mesgin_done
  4844. +
  4845. +#  Identify message?  For a reconnecting target, this tells us the lun
  4846. +#  that the reconnection is for - find the correct SCB and switch to it,
  4847. +#  clearing the "disconnected" bit so we don't "find" it by accident later.
  4848. +#
  4849. +p_mesgin5:
  4850. +    test    A,0x80        jz p_mesgin6    # identify message?
  4851. +
  4852. +    test    A,0x78        jnz p_mesginN    # !DiscPriv|!LUNTAR|!Reserved
  4853. +
  4854. +    mov    A        call findSCB    # switch to correct SCB
  4855. +
  4856. +#  If a active message is present after calling findSCB, then either it
  4857. +#  or the driver is trying to abort the command.  Either way, something
  4858. +#  untoward has happened and we should just leave it alone.
  4859. +#
  4860. +    test    MSG_FLAGS,0x80    jnz p_mesgin_done
  4861. +
  4862. +    xor    SCBARRAY+0,0x4            # clear disconnect bit in SCB
  4863. +    mvi    RESELECT,0xc0            # make note of IDENTIFY
  4864. +
  4865. +    call    sg_scb2ram            # implied restore pointers
  4866. +                        #   required on reselect
  4867. +    jmp    p_mesgin_done
  4868. +
  4869. +#  Message reject?  If we have an outstanding SDTR negotiation, assume
  4870. +#  that it's a response from the target selecting asynchronous transfer,
  4871. +#  otherwise just ignore it since we have no clue what it pertains to.
  4872. +#
  4873. +#  XXX - I don't have a device that responds this way.  Does this code
  4874. +#     actually work?
  4875. +#
  4876. +p_mesgin6:
  4877. +    cmp    A,7        jne p_mesgin7    # message reject code?
  4878. +
  4879. +    and    FUNCTION1,0x70,SCSIID        # outstanding SDTR message?
  4880. +    mov    A,FUNCTION1
  4881. +    test    NEEDSDTR,A    jz p_mesgin_done  # no - ignore rejection
  4882. +
  4883. +    call    ndx_sdtr            # note use of asynch xfer
  4884. +    mov    DINDEX,SINDEX
  4885. +    clr    DINDIR
  4886. +
  4887. +    not    A                # turn off "active sdtr" flag
  4888. +    and    NEEDSDTR,A
  4889. +
  4890. +    clr    SCSIRATE            # select asynch xfer
  4891. +    jmp    p_mesgin_done
  4892. +
  4893. +#  [ ADD MORE MESSAGE HANDLING HERE ]
  4894. +#
  4895. +p_mesgin7:
  4896. +
  4897. +#  We have no idea what this message in is, and there's no way
  4898. +#  to pass it up to the kernel, so we issue a message reject and
  4899. +#  hope for the best.  Since we're now using manual PIO mode to
  4900. +#  read in the message, there should no longer be a race condition
  4901. +#  present when we assert ATN.  In any case, rejection should be a
  4902. +#  rare occurrence - signal the driver when it happens.
  4903. +#
  4904. +p_mesginN:
  4905. +    or    SINDEX,0x10,SIGSTATE        # turn on ATNO
  4906. +    call    scsisig
  4907. +    mvi    INTSTAT,SIGNAL_1        # let driver know
  4908. +
  4909. +    mvi    0x7        call mk_mesg    # MESSAGE REJECT message
  4910. +
  4911. +p_mesgin_done:
  4912. +    call    inb_last            # ack & turn auto PIO back on
  4913. +    jmp    ITloop
  4914. +
  4915. +#  Bus free phase.  It might be useful to interrupt the device
  4916. +#  driver if we aren't expecting this.  For now, make sure that
  4917. +#  ATN isn't being asserted and look for a new command.
  4918. +#
  4919. +p_busfree:
  4920. +    mvi    CLRSINT1,0x40            # CLRATNO
  4921. +    clr    SIGSTATE
  4922. +    jmp    start
  4923. +
  4924. +#  Bcopy: number of bytes to transfer should be in A, DINDEX should
  4925. +#  contain the destination address, and SINDEX should contain the
  4926. +#  source address.  All input parameters are trashed on return.
  4927. +#
  4928. +bcopy:
  4929. +    mov    DINDIR,SINDIR
  4930. +    dec    A
  4931. +    cmp    ALLZEROS,A    jne bcopy
  4932. +    ret
  4933. +
  4934. +#  Locking the driver out, build a one-byte message passed in SINDEX
  4935. +#  if there is no active message already.  SINDEX is returned intact.
  4936. +#
  4937. +mk_mesg:
  4938. +    mvi    SEQCTL,0x40            # PAUSEDIS
  4939. +    test    MSG_FLAGS,0x80    jnz mk_mesg1    # active message?
  4940. +
  4941. +    mvi    MSG_FLAGS,0x80            # if not, there is now
  4942. +    mvi    MSG_LEN,1            # length = 1
  4943. +    mov    MSG_START+0,SINDEX        # 1-byte message
  4944. +
  4945. +mk_mesg1:
  4946. +    clr    SEQCTL                # !PAUSEDIS
  4947. +    ret
  4948. +
  4949. +#  Input byte in Automatic PIO mode.  The address to store the byte
  4950. +#  in should be in SINDEX.  DINDEX will be used by this routine.
  4951. +#
  4952. +inb:
  4953. +    test    SSTAT0,0x2    jz inb        # SPIORDY
  4954. +    mov    DINDEX,SINDEX
  4955. +    call    one_stcnt            # xfer one byte
  4956. +    mov    DINDIR,SCSIDATL
  4957. +inb1:
  4958. +    test    SSTAT0,0x4    jz inb1        # SDONE - wait to "finish"
  4959. +    ret
  4960. +
  4961. +#  Carefully read data in Automatic PIO mode.  I first tried this using
  4962. +#  Manual PIO mode, but it gave me continual underrun errors, probably
  4963. +#  indicating that I did something wrong, but I feel more secure leaving
  4964. +#  Automatic PIO on all the time.
  4965. +#
  4966. +#  According to Adaptec's documentation, an ACK is not sent on input from
  4967. +#  the target until SCSIDATL is read from.  So we wait until SCSIDATL is
  4968. +#  latched (the usual way), then read the data byte directly off the bus
  4969. +#  using SCSIBUSL.  When we have pulled the ATN line, or we just want to
  4970. +#  acknowledge the byte, then we do a dummy read from SCISDATL.  The SCSI
  4971. +#  spec guarantees that the target will hold the data byte on the bus until
  4972. +#  we send our ACK.
  4973. +#
  4974. +#  The assumption here is that these are called in a particular sequence,
  4975. +#  and that REQ is already set when inb_first is called.  inb_{first,next}
  4976. +#  use the same calling convention as inb.
  4977. +#
  4978. +inb_first:
  4979. +    mov    DINDEX,SINDEX
  4980. +    mov    DINDIR,SCSIBUSL    ret        # read byte directly from bus
  4981. +
  4982. +inb_next:
  4983. +    mov    DINDEX,SINDEX            # save SINDEX
  4984. +
  4985. +    call    one_stcnt            # xfer one byte
  4986. +    mov    NONE,SCSIDATL            # dummy read from latch to ACK
  4987. +inb_next1:
  4988. +    test    SSTAT0,0x4    jz inb_next1    # SDONE
  4989. +inb_next2:
  4990. +    test    SSTAT0,0x2    jz inb_next2    # SPIORDY - wait for next byte
  4991. +    mov    DINDIR,SCSIBUSL    ret        # read byte directly from bus
  4992. +
  4993. +inb_last:
  4994. +    call    one_stcnt            # ACK with dummy read
  4995. +    mov    NONE,SCSIDATL
  4996. +inb_last1:
  4997. +    test    SSTAT0,0x4    jz inb_last1    # wait for completion
  4998. +    ret
  4999. +
  5000. +#  Output byte in Automatic PIO mode.  The byte to output should be
  5001. +#  in SINDEX.  If DROPATN's high bit is set, then ATN will be dropped
  5002. +#  before the byte is output.
  5003. +#
  5004. +outb:
  5005. +    test    SSTAT0,0x2    jz outb        # SPIORDY
  5006. +    call    one_stcnt            # xfer one byte
  5007. +
  5008. +    test    DROPATN,0x80    jz outb1
  5009. +    mvi    CLRSINT1,0x40            # CLRATNO
  5010. +    clr    DROPATN
  5011. +outb1:
  5012. +    mov    SCSIDATL,SINDEX
  5013. +outb2:
  5014. +    test    SSTAT0,0x4    jz outb2    # SDONE
  5015. +    ret
  5016. +
  5017. +#  Write the value "1" into the STCNT registers, for Automatic PIO
  5018. +#  transfers.
  5019. +#
  5020. +one_stcnt:
  5021. +    clr    STCNT+2
  5022. +    clr    STCNT+1
  5023. +    mvi    STCNT+0,1    ret
  5024. +
  5025. +#  DMA data transfer.  HADDR and HCNT must be loaded first, and
  5026. +#  SINDEX should contain the value to load DFCNTRL with - 0x3d for
  5027. +#  host->scsi, or 0x39 for scsi->host.  The SCSI channel is cleared
  5028. +#  during initialization.
  5029. +#
  5030. +dma:
  5031. +    mov    DFCNTRL,SINDEX
  5032. +dma1:
  5033. +dma2:
  5034. +    test    SSTAT0,0x1    jnz dma3    # DMADONE
  5035. +    test    SSTAT1,0x10    jz dma1        # PHASEMIS, ie. underrun
  5036. +
  5037. +#  We will be "done" DMAing when the transfer count goes to zero, or
  5038. +#  the target changes the phase (in light of this, it makes sense that
  5039. +#  the DMA circuitry doesn't ACK when PHASEMIS is active).  If we are
  5040. +#  doing a SCSI->Host transfer, flush the data FIFO.
  5041. +#
  5042. +dma3:
  5043. +    test    SINDEX,0x4    jnz dma5    # DIRECTION
  5044. +    and    SINDEX,0xfe            # mask out FIFORESET
  5045. +    or    DFCNTRL,0x2,SINDEX        # FIFOFLUSH
  5046. +dma4:
  5047. +    test    DFCNTRL,0x2    jnz dma4    # FIFOFLUSHACK
  5048. +
  5049. +#  Now shut the DMA enables off, and copy STCNT (ie. the underrun
  5050. +#  amount, if any) to the SCB registers; SG_COUNT will get copied to
  5051. +#  the SCB's residual S/G count field after sg_advance is called.  Make
  5052. +#  sure that the DMA enables are actually off first lest we get an ILLSADDR.
  5053. +#
  5054. +dma5:
  5055. +    clr    DFCNTRL                # disable DMA
  5056. +dma6:
  5057. +    test    DFCNTRL,0x38    jnz dma6    # SCSIENACK|SDMAENACK|HDMAENACK
  5058. +
  5059. +    mvi    A,3
  5060. +    mvi    DINDEX,SCBARRAY+15
  5061. +    mvi    STCNT        call bcopy
  5062. +
  5063. +    ret
  5064. +
  5065. +#  Common SCSI initialization for selection and reselection.  Expects
  5066. +#  the target SCSI ID to be in the upper four bits of SINDEX, and A's
  5067. +#  contents are stomped on return.
  5068. +#
  5069. +initialize:
  5070. +    clr    SBLKCTL                # channel A, !wide
  5071. +    and    SCSIID,0xf0,SINDEX        # target ID
  5072. +    and    A,0x7,SCSICONF            # SCSI_ID_A[210]
  5073. +    or    SCSIID,A
  5074. +
  5075. +#  Esundry initialization.
  5076. +#
  5077. +    clr    DROPATN
  5078. +    clr    SIGSTATE
  5079. +
  5080. +#  Turn on Automatic PIO mode now, before we expect to see an REQ
  5081. +#  from the target.  It shouldn't hurt anything to leave it on.  Set
  5082. +#  CLRCHN here before the target has entered a data transfer mode -
  5083. +#  with synchronous SCSI, if you do it later, you blow away some
  5084. +#  data in the SCSI FIFO that the target has already sent to you.
  5085. +#
  5086. +    mvi    SXFRCTL0,0xa            # SPIOEN|CLRCHN
  5087. +
  5088. +#  Set SCSI bus parity checking and the selection timeout value,
  5089. +#  and enable the hardware selection timer.  Set the SELTO interrupt
  5090. +#  to signal the driver.
  5091. +#
  5092. +    and    A,0x38,SCSICONF            # PARITY_ENB_A|SEL_TIM_A[10]
  5093. +    or    SXFRCTL1,0x4,A            # ENSTIMER
  5094. +    mvi    SIMODE1,0x84            # ENSELTIMO|ENSCSIPERR
  5095. +    
  5096. +#  Initialize scatter-gather pointers by setting up the working copy
  5097. +#  in scratch RAM.
  5098. +#
  5099. +    call    sg_scb2ram
  5100. +
  5101. +#  Initialize SCSIRATE with the appropriate value for this target.
  5102. +#
  5103. +    call    ndx_sdtr
  5104. +    mov    SCSIRATE,SINDIR
  5105. +    ret
  5106. +
  5107. +#  Assert that if we've been reselected, then we've seen an IDENTIFY
  5108. +#  message.
  5109. +#
  5110. +assert:
  5111. +    test    RESELECT,0x80    jz assert1    # reselected?
  5112. +    test    RESELECT,0x40    jnz assert1    # seen IDENTIFY?
  5113. +
  5114. +    mvi    INTSTAT,SIGNAL_2        # no - cause a kernel panic
  5115. +
  5116. +assert1:
  5117. +    ret
  5118. +
  5119. +#  Find out if disconnection is ok from the information the BIOS has left
  5120. +#  us.  The target ID should be in the upper four bits of SINDEX; A will
  5121. +#  contain either 0x40 (disconnection ok) or 0x00 (diconnection not ok)
  5122. +#  on exit.
  5123. +#
  5124. +#  This is the only place the target ID is limited to three bits, so we
  5125. +#  can use the FUNCTION1 register.
  5126. +#
  5127. +disconnect:
  5128. +    and    FUNCTION1,0x70,SINDEX        # strip off extra just in case
  5129. +    mov    A,FUNCTION1
  5130. +    test    DISC_DSB_A,A    jz disconnect1    # bit nonzero if DISabled
  5131. +
  5132. +    clr    A        ret
  5133. +disconnect1:
  5134. +    mvi    A,0x40        ret
  5135. +
  5136. +#  Locate the SCB matching the target ID in SELID and the lun in the lower
  5137. +#  three bits of SINDEX, and switch the SCB to it.  Have the kernel print
  5138. +#  a warning message if it can't be found - this seems to happen occasionally
  5139. +#  under high loads.  Also, if not found, generate an ABORT message to the
  5140. +#  target.
  5141. +#
  5142. +findSCB:
  5143. +    and    A,0x7,SINDEX            # lun in lower three bits
  5144. +    or    A,A,SELID            # can I do this?
  5145. +    and    A,0xf7                # only channel A implemented
  5146. +
  5147. +    clr    SINDEX
  5148. +
  5149. +findSCB1:
  5150. +    mov    SCBPTR,SINDEX            # switch to new SCB
  5151. +    cmp    SCBARRAY+1,A    jne findSCB2    # target ID/channel/lun match?
  5152. +    test    SCBARRAY+0,0x4    jz findSCB2    # should be disconnected
  5153. +
  5154. +    ret
  5155. +
  5156. +findSCB2:
  5157. +    inc    SINDEX
  5158. +    cmp    SINDEX,MAXSCB    jne findSCB1
  5159. +
  5160. +    mvi    INTSTAT,SIGNAL_3        # not found - signal kernel
  5161. +    mvi    0x6        call mk_mesg    # ABORT message
  5162. +
  5163. +    or    SINDEX,0x10,SIGSTATE        # assert ATNO
  5164. +    call    scsisig
  5165. +    ret
  5166. +
  5167. +#  Make a working copy of the scatter-gather parameters in the SCB.
  5168. +#
  5169. +sg_scb2ram:
  5170. +    mov    SG_COUNT,SCBARRAY+2
  5171. +
  5172. +    mvi    A,4
  5173. +    mvi    DINDEX,SG_NEXT
  5174. +    mvi    SCBARRAY+3    call bcopy
  5175. +
  5176. +    mvi    SG_NOLOAD,0x80
  5177. +    test    SCBARRAY+0,0x10    jnz sg_scb2ram1    # don't reload s/g?
  5178. +    clr    SG_NOLOAD
  5179. +
  5180. +sg_scb2ram1:
  5181. +    ret
  5182. +
  5183. +#  Copying RAM values back to SCB, for Save Data Pointers message.
  5184. +#
  5185. +sg_ram2scb:
  5186. +    mov    SCBARRAY+2,SG_COUNT
  5187. +
  5188. +    mvi    A,4
  5189. +    mvi    DINDEX,SCBARRAY+3
  5190. +    mvi    SG_NEXT        call bcopy
  5191. +
  5192. +    and    SCBARRAY+0,0xef,SCBARRAY+0
  5193. +    test    SG_NOLOAD,0x80    jz sg_ram2scb1    # reload s/g?
  5194. +    or    SCBARRAY+0,0x10
  5195. +
  5196. +sg_ram2scb1:
  5197. +    ret
  5198. +
  5199. +#  Load a struct scatter if needed and set up the data address and
  5200. +#  length.  If the working value of the SG count is nonzero, then
  5201. +#  we need to load a new set of values.
  5202. +#
  5203. +#  This, like the above DMA, assumes a little-endian host data storage.
  5204. +#
  5205. +sg_load:
  5206. +    test    SG_COUNT,0xff    jz sg_load3    # SG being used?
  5207. +    test    SG_NOLOAD,0x80    jnz sg_load3    # don't reload s/g?
  5208. +
  5209. +    clr    HCNT+2
  5210. +    clr    HCNT+1
  5211. +    mvi    HCNT+0,SG_SIZEOF
  5212. +
  5213. +    mvi    A,4
  5214. +    mvi    DINDEX,HADDR
  5215. +    mvi    SG_NEXT        call bcopy
  5216. +
  5217. +    mvi    DFCNTRL,0xd            # HDMAEN|DIRECTION|FIFORESET
  5218. +
  5219. +#  Wait for DMA from host memory to data FIFO to complete, then disable
  5220. +#  DMA and wait for it to acknowledge that it's off.
  5221. +#
  5222. +sg_load1:
  5223. +    test    DFSTATUS,0x8    jz sg_load1    # HDONE
  5224. +
  5225. +    clr    DFCNTRL                # disable DMA
  5226. +sg_load2:
  5227. +    test    DFCNTRL,0x8    jnz sg_load2    # HDMAENACK
  5228. +
  5229. +#  Copy data from FIFO into SCB data pointer and data count.  This assumes
  5230. +#  that the struct scatterlist has this structure (this and sizeof(struct
  5231. +#  scatterlist) == 12 are asserted in aha274x.c):
  5232. +#
  5233. +#    struct scatterlist {
  5234. +#        char *address;        /* four bytes, little-endian order */
  5235. +#        ...            /* four bytes, ignored */
  5236. +#        unsigned short length;    /* two bytes, little-endian order */
  5237. +#    }
  5238. +#
  5239. +    mov    SCBARRAY+19,DFDAT        # new data address
  5240. +    mov    SCBARRAY+20,DFDAT
  5241. +    mov    SCBARRAY+21,DFDAT
  5242. +    mov    SCBARRAY+22,DFDAT
  5243. +
  5244. +    mov    NONE,DFDAT            # throw away four bytes
  5245. +    mov    NONE,DFDAT
  5246. +    mov    NONE,DFDAT
  5247. +    mov    NONE,DFDAT
  5248. +
  5249. +    mov    SCBARRAY+23,DFDAT
  5250. +    mov    SCBARRAY+24,DFDAT
  5251. +    clr    SCBARRAY+25
  5252. +
  5253. +sg_load3:
  5254. +    ret
  5255. +
  5256. +#  Advance the scatter-gather pointers only IF NEEDED.  If SG is enabled,
  5257. +#  and the SCSI transfer count is zero (note that this should be called
  5258. +#  right after a DMA finishes), then move the working copies of the SG
  5259. +#  pointer/length along.  If the SCSI transfer count is not zero, then
  5260. +#  presumably the target is disconnecting - do not reload the SG values
  5261. +#  next time.
  5262. +#
  5263. +sg_advance:
  5264. +    test    SG_COUNT,0xff    jz sg_advance2    # s/g enabled?
  5265. +
  5266. +    test    STCNT+0,0xff    jnz sg_advance1    # SCSI transfer count nonzero?
  5267. +    test    STCNT+1,0xff    jnz sg_advance1
  5268. +    test    STCNT+2,0xff    jnz sg_advance1
  5269. +
  5270. +    clr    SG_NOLOAD            # reload s/g next time
  5271. +    dec    SG_COUNT            # one less segment to go
  5272. +
  5273. +    clr    A                # add sizeof(struct scatter)
  5274. +    add    SG_NEXT+0,SG_SIZEOF,SG_NEXT+0
  5275. +    adc    SG_NEXT+1,A,SG_NEXT+1
  5276. +    adc    SG_NEXT+2,A,SG_NEXT+2
  5277. +    adc    SG_NEXT+3,A,SG_NEXT+3
  5278. +
  5279. +    ret
  5280. +
  5281. +sg_advance1:
  5282. +    mvi    SG_NOLOAD,0x80            # don't reload s/g next time
  5283. +sg_advance2:
  5284. +    ret
  5285. +
  5286. +#  Add the array base SYNCNEG to the target offset (the target address
  5287. +#  is in SCSIID), and return the result in SINDEX.  The accumulator
  5288. +#  contains the 3->8 decoding of the target ID on return.
  5289. +#
  5290. +ndx_sdtr:
  5291. +    shr    A,SCSIID,4
  5292. +    and    A,0x7
  5293. +    add    SINDEX,SYNCNEG,A
  5294. +
  5295. +    and    FUNCTION1,0x70,SCSIID        # 3-bit target address decode
  5296. +    mov    A,FUNCTION1    ret
  5297. +
  5298. +#  If we need to negotiate transfer parameters, build the SDTR message
  5299. +#  starting at the address passed in SINDEX.  DINDEX is modified on return.
  5300. +#
  5301. +mk_sdtr:
  5302. +    mov    DINDEX,SINDEX            # save SINDEX
  5303. +
  5304. +    call    ndx_sdtr
  5305. +    test    NEEDSDTR,A    jnz mk_sdtr1    # do we need negotiation?
  5306. +    ret
  5307. +
  5308. +mk_sdtr1:
  5309. +    mvi    DINDIR,1            # extended message
  5310. +    mvi    DINDIR,3            # extended message length = 3
  5311. +    mvi    DINDIR,1            # SDTR code
  5312. +    mvi    DINDIR,25            # REQ/ACK transfer period
  5313. +    mvi    DINDIR,15            # REQ/ACK offset
  5314. +
  5315. +    add    MSG_LEN,-MSG_START+0,DINDEX    # update message length
  5316. +    ret
  5317. +
  5318. +#  Set SCSI bus control signal state.  This also saves the last-written
  5319. +#  value into a location where the higher-level driver can read it - if
  5320. +#  it has to send an ABORT or RESET message, then it needs to know this
  5321. +#  so it can assert ATN without upsetting SCSISIGO.  The new value is
  5322. +#  expected in SINDEX.  Change the actual state last to avoid contention
  5323. +#  from the driver.
  5324. +#
  5325. +scsisig:
  5326. +    mov    SIGSTATE,SINDEX
  5327. +    mov    SCSISIGO,SINDEX    ret
  5328. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/aha274x_seq.h linux/drivers/scsi/aha274x_seq.h
  5329. --- linux-1.1.58/drivers/scsi/aha274x_seq.h    Wed Dec 31 18:00:00 1969
  5330. +++ linux/drivers/scsi/aha274x_seq.h    Wed Oct 26 23:02:01 1994
  5331. @@ -0,0 +1,336 @@
  5332. +#define AHA274X_SEQ_VERSION "1.26"
  5333. +    0x04, 0x03, 0x12, 0x1a,
  5334. +    0x07, 0x9c, 0x00, 0x1e,
  5335. +    0xff, 0x9b, 0x90, 0x02,
  5336. +    0x00, 0xa1, 0xe1, 0x16,
  5337. +    0xff, 0x6a, 0x54, 0x02,
  5338. +    0xff, 0x6a, 0x34, 0x02,
  5339. +    0x00, 0xa1, 0xf3, 0x16,
  5340. +    0x07, 0xa1, 0x65, 0x02,
  5341. +    0x00, 0x65, 0x65, 0x00,
  5342. +    0x80, 0x65, 0xad, 0x16,
  5343. +    0xff, 0x65, 0x64, 0x02,
  5344. +    0x00, 0x37, 0x0d, 0x18,
  5345. +    0x38, 0x6a, 0x42, 0x17,
  5346. +    0x48, 0x6a, 0x00, 0x00,
  5347. +    0x40, 0x0b, 0x16, 0x1a,
  5348. +    0x10, 0x0b, 0x0e, 0x1e,
  5349. +    0x40, 0x0b, 0x10, 0x1e,
  5350. +    0x00, 0x65, 0x16, 0x10,
  5351. +    0x10, 0x6a, 0x00, 0x00,
  5352. +    0x20, 0x0b, 0x13, 0x1e,
  5353. +    0x00, 0x19, 0xe1, 0x16,
  5354. +    0x80, 0x6a, 0x34, 0x00,
  5355. +    0xff, 0x6a, 0x00, 0x02,
  5356. +    0x08, 0x6a, 0x0c, 0x00,
  5357. +    0x08, 0x0c, 0xa6, 0x1a,
  5358. +    0x01, 0x0c, 0x18, 0x1e,
  5359. +    0xe0, 0x03, 0x64, 0x02,
  5360. +    0x00, 0x6a, 0x22, 0x1c,
  5361. +    0x40, 0x64, 0x32, 0x1c,
  5362. +    0x80, 0x64, 0x42, 0x1c,
  5363. +    0xc0, 0x64, 0x4f, 0x1c,
  5364. +    0xa0, 0x64, 0x52, 0x1c,
  5365. +    0xe0, 0x64, 0x68, 0x1c,
  5366. +    0x01, 0x6a, 0x91, 0x00,
  5367. +    0x00, 0x6a, 0x4d, 0x17,
  5368. +    0x00, 0x65, 0xef, 0x16,
  5369. +    0x00, 0x65, 0x17, 0x17,
  5370. +    0x03, 0x6a, 0x64, 0x00,
  5371. +    0x8c, 0x6a, 0x66, 0x00,
  5372. +    0xb7, 0x6a, 0xa9, 0x16,
  5373. +    0x03, 0x6a, 0x64, 0x00,
  5374. +    0x08, 0x6a, 0x66, 0x00,
  5375. +    0xb7, 0x6a, 0xa9, 0x16,
  5376. +    0x04, 0x6a, 0x64, 0x00,
  5377. +    0x88, 0x6a, 0x66, 0x00,
  5378. +    0xb3, 0x6a, 0xa9, 0x16,
  5379. +    0x3d, 0x6a, 0xd1, 0x16,
  5380. +    0x00, 0x65, 0x2f, 0x17,
  5381. +    0xff, 0x55, 0xb2, 0x02,
  5382. +    0x00, 0x65, 0x18, 0x10,
  5383. +    0x40, 0x6a, 0x4d, 0x17,
  5384. +    0x00, 0x65, 0xef, 0x16,
  5385. +    0x00, 0x65, 0x17, 0x17,
  5386. +    0x03, 0x6a, 0x64, 0x00,
  5387. +    0x8c, 0x6a, 0x66, 0x00,
  5388. +    0xb7, 0x6a, 0xa9, 0x16,
  5389. +    0x03, 0x6a, 0x64, 0x00,
  5390. +    0x08, 0x6a, 0x66, 0x00,
  5391. +    0xb7, 0x6a, 0xa9, 0x16,
  5392. +    0x04, 0x6a, 0x64, 0x00,
  5393. +    0x88, 0x6a, 0x66, 0x00,
  5394. +    0xb3, 0x6a, 0xa9, 0x16,
  5395. +    0x39, 0x6a, 0xd1, 0x16,
  5396. +    0x00, 0x65, 0x2f, 0x17,
  5397. +    0xff, 0x55, 0xb2, 0x02,
  5398. +    0x00, 0x65, 0x18, 0x10,
  5399. +    0x80, 0x6a, 0x4d, 0x17,
  5400. +    0x00, 0x65, 0xef, 0x16,
  5401. +    0x03, 0x6a, 0x64, 0x00,
  5402. +    0x8c, 0x6a, 0x66, 0x00,
  5403. +    0xab, 0x6a, 0xa9, 0x16,
  5404. +    0x03, 0x6a, 0x64, 0x00,
  5405. +    0x08, 0x6a, 0x66, 0x00,
  5406. +    0xab, 0x6a, 0xa9, 0x16,
  5407. +    0x04, 0x6a, 0x64, 0x00,
  5408. +    0x88, 0x6a, 0x66, 0x00,
  5409. +    0xa7, 0x6a, 0xa9, 0x16,
  5410. +    0x3d, 0x6a, 0xd1, 0x16,
  5411. +    0x00, 0x65, 0x18, 0x10,
  5412. +    0xc0, 0x6a, 0x4d, 0x17,
  5413. +    0xae, 0x6a, 0xb4, 0x16,
  5414. +    0x00, 0x65, 0x18, 0x10,
  5415. +    0xa0, 0x6a, 0x4d, 0x17,
  5416. +    0x08, 0x6a, 0xad, 0x16,
  5417. +    0x37, 0x6a, 0x65, 0x00,
  5418. +    0xff, 0x36, 0x66, 0x02,
  5419. +    0xff, 0x6a, 0x64, 0x02,
  5420. +    0x02, 0x0b, 0x57, 0x1e,
  5421. +    0x01, 0x66, 0x5a, 0x18,
  5422. +    0x40, 0x6a, 0x0c, 0x00,
  5423. +    0x00, 0x65, 0xce, 0x16,
  5424. +    0xff, 0x6c, 0x06, 0x02,
  5425. +    0x04, 0x0b, 0x5c, 0x1e,
  5426. +    0xff, 0x66, 0x66, 0x06,
  5427. +    0x01, 0x64, 0x64, 0x06,
  5428. +    0x00, 0x36, 0x57, 0x18,
  5429. +    0x08, 0x0c, 0x66, 0x1a,
  5430. +    0x01, 0x0c, 0x60, 0x1e,
  5431. +    0xe0, 0x03, 0x64, 0x02,
  5432. +    0xa0, 0x64, 0x66, 0x18,
  5433. +    0x10, 0x6a, 0x4d, 0x17,
  5434. +    0x00, 0x65, 0x18, 0x10,
  5435. +    0xff, 0x6a, 0x35, 0x02,
  5436. +    0x00, 0x65, 0x18, 0x10,
  5437. +    0xe0, 0x6a, 0x4d, 0x17,
  5438. +    0x64, 0x6a, 0xba, 0x16,
  5439. +    0x00, 0x6a, 0x31, 0x00,
  5440. +    0x00, 0x6a, 0x6f, 0x18,
  5441. +    0xff, 0x90, 0x9d, 0x02,
  5442. +    0x02, 0x6a, 0x91, 0x00,
  5443. +    0x00, 0x65, 0xa4, 0x10,
  5444. +    0x01, 0x64, 0x7e, 0x18,
  5445. +    0x64, 0x6a, 0xbc, 0x16,
  5446. +    0x03, 0x64, 0xa0, 0x18,
  5447. +    0x64, 0x6a, 0xbc, 0x16,
  5448. +    0x01, 0x64, 0xa0, 0x18,
  5449. +    0x4c, 0x6a, 0xbc, 0x16,
  5450. +    0x4d, 0x6a, 0xbc, 0x16,
  5451. +    0x41, 0x6a, 0x91, 0x00,
  5452. +    0x00, 0x65, 0x3d, 0x17,
  5453. +    0xff, 0x65, 0x66, 0x02,
  5454. +    0xff, 0x4c, 0x6d, 0x02,
  5455. +    0xff, 0x64, 0x64, 0x04,
  5456. +    0x00, 0x4f, 0x4f, 0x02,
  5457. +    0xff, 0x4c, 0x04, 0x02,
  5458. +    0x00, 0x65, 0xa4, 0x10,
  5459. +    0x04, 0x64, 0x81, 0x18,
  5460. +    0x04, 0xa0, 0xa0, 0x00,
  5461. +    0x00, 0x65, 0xa4, 0x10,
  5462. +    0x02, 0x64, 0x8a, 0x18,
  5463. +    0x04, 0x6a, 0x64, 0x00,
  5464. +    0xb3, 0x6a, 0x66, 0x00,
  5465. +    0x50, 0x6a, 0xa9, 0x16,
  5466. +    0x03, 0x6a, 0x64, 0x00,
  5467. +    0xb7, 0x6a, 0x66, 0x00,
  5468. +    0xaf, 0x6a, 0xa9, 0x16,
  5469. +    0x00, 0x65, 0x0f, 0x17,
  5470. +    0x00, 0x65, 0xa4, 0x10,
  5471. +    0x03, 0x64, 0x8d, 0x18,
  5472. +    0x00, 0x65, 0x07, 0x17,
  5473. +    0x00, 0x65, 0xa4, 0x10,
  5474. +    0x80, 0x64, 0x95, 0x1e,
  5475. +    0x78, 0x64, 0xa0, 0x1a,
  5476. +    0x00, 0x64, 0xf8, 0x16,
  5477. +    0x80, 0x35, 0xa4, 0x1a,
  5478. +    0x04, 0xa0, 0xa0, 0x04,
  5479. +    0xc0, 0x6a, 0x34, 0x00,
  5480. +    0x00, 0x65, 0x07, 0x17,
  5481. +    0x00, 0x65, 0xa4, 0x10,
  5482. +    0x07, 0x64, 0xa0, 0x18,
  5483. +    0x70, 0x05, 0x6e, 0x02,
  5484. +    0xff, 0x6e, 0x64, 0x02,
  5485. +    0x00, 0x4f, 0xa4, 0x1e,
  5486. +    0x00, 0x65, 0x3d, 0x17,
  5487. +    0xff, 0x65, 0x66, 0x02,
  5488. +    0xff, 0x6a, 0x6d, 0x02,
  5489. +    0xff, 0x64, 0x64, 0x04,
  5490. +    0x00, 0x4f, 0x4f, 0x02,
  5491. +    0xff, 0x6a, 0x04, 0x02,
  5492. +    0x00, 0x65, 0xa4, 0x10,
  5493. +    0x10, 0x4e, 0x65, 0x00,
  5494. +    0x00, 0x65, 0x4d, 0x17,
  5495. +    0x11, 0x6a, 0x91, 0x00,
  5496. +    0x07, 0x6a, 0xad, 0x16,
  5497. +    0x00, 0x65, 0xc2, 0x16,
  5498. +    0x00, 0x65, 0x18, 0x10,
  5499. +    0x40, 0x6a, 0x0c, 0x00,
  5500. +    0xff, 0x6a, 0x4e, 0x02,
  5501. +    0x00, 0x65, 0x00, 0x10,
  5502. +    0xff, 0x6c, 0x6d, 0x02,
  5503. +    0xff, 0x64, 0x64, 0x06,
  5504. +    0x00, 0x6a, 0xa9, 0x18,
  5505. +    0xff, 0x6a, 0x6a, 0x03,
  5506. +    0x40, 0x6a, 0x60, 0x00,
  5507. +    0x80, 0x35, 0xb2, 0x1a,
  5508. +    0x80, 0x6a, 0x35, 0x00,
  5509. +    0x01, 0x6a, 0x36, 0x00,
  5510. +    0xff, 0x65, 0x37, 0x02,
  5511. +    0xff, 0x6a, 0x60, 0x02,
  5512. +    0xff, 0x6a, 0x6a, 0x03,
  5513. +    0x02, 0x0b, 0xb4, 0x1e,
  5514. +    0xff, 0x65, 0x66, 0x02,
  5515. +    0x00, 0x65, 0xce, 0x16,
  5516. +    0xff, 0x06, 0x6d, 0x02,
  5517. +    0x04, 0x0b, 0xb8, 0x1e,
  5518. +    0xff, 0x6a, 0x6a, 0x03,
  5519. +    0xff, 0x65, 0x66, 0x02,
  5520. +    0xff, 0x12, 0x6d, 0x03,
  5521. +    0xff, 0x65, 0x66, 0x02,
  5522. +    0x00, 0x65, 0xce, 0x16,
  5523. +    0xff, 0x06, 0x6a, 0x02,
  5524. +    0x04, 0x0b, 0xbf, 0x1e,
  5525. +    0x02, 0x0b, 0xc0, 0x1e,
  5526. +    0xff, 0x12, 0x6d, 0x03,
  5527. +    0x00, 0x65, 0xce, 0x16,
  5528. +    0xff, 0x06, 0x6a, 0x02,
  5529. +    0x04, 0x0b, 0xc4, 0x1e,
  5530. +    0xff, 0x6a, 0x6a, 0x03,
  5531. +    0x02, 0x0b, 0xc6, 0x1e,
  5532. +    0x00, 0x65, 0xce, 0x16,
  5533. +    0x80, 0x30, 0xcb, 0x1e,
  5534. +    0x40, 0x6a, 0x0c, 0x00,
  5535. +    0xff, 0x6a, 0x30, 0x02,
  5536. +    0xff, 0x65, 0x06, 0x02,
  5537. +    0x04, 0x0b, 0xcc, 0x1e,
  5538. +    0xff, 0x6a, 0x6a, 0x03,
  5539. +    0xff, 0x6a, 0x0a, 0x02,
  5540. +    0xff, 0x6a, 0x09, 0x02,
  5541. +    0x01, 0x6a, 0x08, 0x01,
  5542. +    0xff, 0x65, 0x93, 0x02,
  5543. +    0x01, 0x0b, 0xd4, 0x1a,
  5544. +    0x10, 0x0c, 0xd2, 0x1e,
  5545. +    0x04, 0x65, 0xd8, 0x1a,
  5546. +    0xfe, 0x65, 0x65, 0x02,
  5547. +    0x02, 0x65, 0x93, 0x00,
  5548. +    0x02, 0x93, 0xd7, 0x1a,
  5549. +    0xff, 0x6a, 0x93, 0x02,
  5550. +    0x38, 0x93, 0xd9, 0x1a,
  5551. +    0x04, 0x6a, 0x64, 0x00,
  5552. +    0x50, 0x6a, 0x66, 0x00,
  5553. +    0x14, 0x6a, 0xa9, 0x16,
  5554. +    0x03, 0x6a, 0x64, 0x00,
  5555. +    0xaf, 0x6a, 0x66, 0x00,
  5556. +    0x08, 0x6a, 0xa9, 0x16,
  5557. +    0xff, 0x6a, 0x6a, 0x03,
  5558. +    0xff, 0x6a, 0x1f, 0x02,
  5559. +    0xf0, 0x65, 0x05, 0x02,
  5560. +    0x07, 0x5a, 0x64, 0x02,
  5561. +    0x00, 0x05, 0x05, 0x00,
  5562. +    0xff, 0x6a, 0x30, 0x02,
  5563. +    0xff, 0x6a, 0x4e, 0x02,
  5564. +    0x0a, 0x6a, 0x01, 0x00,
  5565. +    0x38, 0x5a, 0x64, 0x02,
  5566. +    0x04, 0x64, 0x02, 0x00,
  5567. +    0x84, 0x6a, 0x11, 0x00,
  5568. +    0x00, 0x65, 0x07, 0x17,
  5569. +    0x00, 0x65, 0x3d, 0x17,
  5570. +    0xff, 0x6c, 0x04, 0x02,
  5571. +    0xff, 0x6a, 0x6a, 0x03,
  5572. +    0x80, 0x34, 0xf2, 0x1e,
  5573. +    0x40, 0x34, 0xf2, 0x1a,
  5574. +    0x21, 0x6a, 0x91, 0x00,
  5575. +    0xff, 0x6a, 0x6a, 0x03,
  5576. +    0x70, 0x65, 0x6e, 0x02,
  5577. +    0xff, 0x6e, 0x64, 0x02,
  5578. +    0x00, 0x32, 0xf7, 0x1e,
  5579. +    0xff, 0x6a, 0x64, 0x03,
  5580. +    0x40, 0x6a, 0x64, 0x01,
  5581. +    0x07, 0x65, 0x64, 0x02,
  5582. +    0x00, 0x19, 0x64, 0x00,
  5583. +    0xf7, 0x64, 0x64, 0x02,
  5584. +    0xff, 0x6a, 0x65, 0x02,
  5585. +    0xff, 0x65, 0x90, 0x02,
  5586. +    0x00, 0xa1, 0x00, 0x19,
  5587. +    0x04, 0xa0, 0x00, 0x1f,
  5588. +    0xff, 0x6a, 0x6a, 0x03,
  5589. +    0x01, 0x65, 0x65, 0x06,
  5590. +    0x04, 0x65, 0xfc, 0x18,
  5591. +    0x31, 0x6a, 0x91, 0x00,
  5592. +    0x06, 0x6a, 0xad, 0x16,
  5593. +    0x10, 0x4e, 0x65, 0x00,
  5594. +    0x00, 0x65, 0x4d, 0x17,
  5595. +    0xff, 0x6a, 0x6a, 0x03,
  5596. +    0xff, 0xa2, 0x55, 0x02,
  5597. +    0x04, 0x6a, 0x64, 0x00,
  5598. +    0x56, 0x6a, 0x66, 0x00,
  5599. +    0xa3, 0x6a, 0xa9, 0x16,
  5600. +    0x80, 0x6a, 0x54, 0x00,
  5601. +    0x10, 0xa0, 0x0e, 0x1b,
  5602. +    0xff, 0x6a, 0x54, 0x02,
  5603. +    0xff, 0x6a, 0x6a, 0x03,
  5604. +    0xff, 0x55, 0xa2, 0x02,
  5605. +    0x04, 0x6a, 0x64, 0x00,
  5606. +    0xa3, 0x6a, 0x66, 0x00,
  5607. +    0x56, 0x6a, 0xa9, 0x16,
  5608. +    0xef, 0xa0, 0xa0, 0x02,
  5609. +    0x80, 0x54, 0x16, 0x1f,
  5610. +    0x10, 0xa0, 0xa0, 0x00,
  5611. +    0xff, 0x6a, 0x6a, 0x03,
  5612. +    0xff, 0x55, 0x2e, 0x1f,
  5613. +    0x80, 0x54, 0x2e, 0x1b,
  5614. +    0xff, 0x6a, 0x8e, 0x02,
  5615. +    0xff, 0x6a, 0x8d, 0x02,
  5616. +    0x0c, 0x6a, 0x8c, 0x00,
  5617. +    0x04, 0x6a, 0x64, 0x00,
  5618. +    0x88, 0x6a, 0x66, 0x00,
  5619. +    0x56, 0x6a, 0xa9, 0x16,
  5620. +    0x0d, 0x6a, 0x93, 0x00,
  5621. +    0x08, 0x94, 0x20, 0x1f,
  5622. +    0xff, 0x6a, 0x93, 0x02,
  5623. +    0x08, 0x93, 0x22, 0x1b,
  5624. +    0xff, 0x99, 0xb3, 0x02,
  5625. +    0xff, 0x99, 0xb4, 0x02,
  5626. +    0xff, 0x99, 0xb5, 0x02,
  5627. +    0xff, 0x99, 0xb6, 0x02,
  5628. +    0xff, 0x99, 0x6a, 0x02,
  5629. +    0xff, 0x99, 0x6a, 0x02,
  5630. +    0xff, 0x99, 0x6a, 0x02,
  5631. +    0xff, 0x99, 0x6a, 0x02,
  5632. +    0xff, 0x99, 0xb7, 0x02,
  5633. +    0xff, 0x99, 0xb8, 0x02,
  5634. +    0xff, 0x6a, 0xb9, 0x02,
  5635. +    0xff, 0x6a, 0x6a, 0x03,
  5636. +    0xff, 0x55, 0x3c, 0x1f,
  5637. +    0xff, 0x08, 0x3b, 0x1b,
  5638. +    0xff, 0x09, 0x3b, 0x1b,
  5639. +    0xff, 0x0a, 0x3b, 0x1b,
  5640. +    0xff, 0x6a, 0x54, 0x02,
  5641. +    0xff, 0x55, 0x55, 0x06,
  5642. +    0xff, 0x6a, 0x64, 0x02,
  5643. +    0x0c, 0x56, 0x56, 0x06,
  5644. +    0x00, 0x57, 0x57, 0x08,
  5645. +    0x00, 0x58, 0x58, 0x08,
  5646. +    0x00, 0x59, 0x59, 0x08,
  5647. +    0xff, 0x6a, 0x6a, 0x03,
  5648. +    0x80, 0x6a, 0x54, 0x00,
  5649. +    0xff, 0x6a, 0x6a, 0x03,
  5650. +    0x4c, 0x05, 0x64, 0x0a,
  5651. +    0x07, 0x64, 0x64, 0x02,
  5652. +    0x20, 0x64, 0x65, 0x06,
  5653. +    0x70, 0x05, 0x6e, 0x02,
  5654. +    0xff, 0x6e, 0x64, 0x03,
  5655. +    0xff, 0x65, 0x66, 0x02,
  5656. +    0x00, 0x65, 0x3d, 0x17,
  5657. +    0x00, 0x4f, 0x46, 0x1b,
  5658. +    0xff, 0x6a, 0x6a, 0x03,
  5659. +    0x01, 0x6a, 0x6d, 0x00,
  5660. +    0x03, 0x6a, 0x6d, 0x00,
  5661. +    0x01, 0x6a, 0x6d, 0x00,
  5662. +    0x19, 0x6a, 0x6d, 0x00,
  5663. +    0x0f, 0x6a, 0x6d, 0x00,
  5664. +    0xc9, 0x66, 0x36, 0x06,
  5665. +    0xff, 0x6a, 0x6a, 0x03,
  5666. +    0xff, 0x65, 0x4e, 0x02,
  5667. +    0xff, 0x65, 0x03, 0x03,
  5668. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/eata.c linux/drivers/scsi/eata.c
  5669. --- linux-1.1.58/drivers/scsi/eata.c    Wed Dec 31 18:00:00 1969
  5670. +++ linux/drivers/scsi/eata.c    Wed Oct 26 23:02:01 1994
  5671. @@ -0,0 +1,621 @@
  5672. +/************************************************************
  5673. + *                                                          *
  5674. + *                  Linux EATA SCSI driver                  *
  5675. + *                                                          *
  5676. + *  based on the EATA proposal rev 2.0b, DPT DOS driver kit *
  5677. + *  some proprietary source (DPT Unix driver), several      *
  5678. + *  other linux scsi drivers and kernel documentation       *
  5679. + *                                                          *
  5680. + *  The driver currently:                                   *
  5681. + *      -has ISA detection routines                         *
  5682. + *      -has EISA detection routines (new)                  *
  5683. + *      -doesn't support more than one HA and one channel   *
  5684. + *      -gets sometimes timeouts when accessing more than   *
  5685. + *       one device "simultaniously"                        *
  5686. + *                                                          *
  5687. + *  ECS_emulation_sense() doesn't work and I don't know why * 
  5688. + *  Until this is working, the drive geometry has to be     * 
  5689. + *  hardcoded into the driver :-( (Any ideas ?)             *
  5690. + *                                                          *
  5691. + *  (c)1993,94 Michael Neuffer                              *
  5692. + *             Michael_Neuffer@wi2.maus.de (mails <16KB!)   *
  5693. + *             neuffer@goofy.zdv.uni-mainz.de               *
  5694. + *                                                          *
  5695. + *  This program is free software; you can redistribute it  * 
  5696. + *  and/or modify it under the terms of the GNU General     *
  5697. + *  Public License as published by the Free Software        *
  5698. + *  Foundation; either version 2 of the License, or         *
  5699. + *  (at your option) any later version.                     *
  5700. + *                                                          *
  5701. + *  This program is distributed in the hope that it will be *
  5702. + *  useful, but WITHOUT ANY WARRANTY; without even the      *
  5703. + *  implied warranty of MERCHANTABILITY or FITNESS FOR A    *
  5704. + *  PARTICULAR PURPOSE.  See the GNU General Public License *
  5705. + *  for more details.                                       *
  5706. + *                                                          *
  5707. + *  You should have received a copy of the GNU General      * 
  5708. + *  Public License along with this kernel; if not, write to *
  5709. + *  the Free Software Foundation, Inc., 675 Mass Ave,       *
  5710. + *  Cambridge, MA 02139, USA.                               *
  5711. + *                                                          *
  5712. + *                                                          *
  5713. + * I have to thank DPT for their excellent support. I took  *
  5714. + * me almost a year and a stopover at their HQ on my first  *
  5715. + * trip to the USA to get it, but now they are very helpful *
  5716. + * and try to give me all the infos and support I need....  *
  5717. + *                                                          *
  5718. + ************************************************************
  5719. + *  last change: 02.10.94                                   *
  5720. + ************************************************************/
  5721. +
  5722. +/* Look in eata.h for configuration information */
  5723. +
  5724. +#include <linux/kernel.h>
  5725. +#include <linux/sched.h>
  5726. +#include <linux/string.h>
  5727. +#include <linux/ioport.h>
  5728. +#include <asm/io.h>
  5729. +#include <asm/dma.h>
  5730. +#include "eata.h"
  5731. +#include "scsi.h"
  5732. +#include "sd.h"
  5733. +
  5734. +#define MAXISA  4
  5735. +#define MAXEISA 16  
  5736. +
  5737. +static unsigned int ISAbases[]={0x1F0,0x170,0x330,0x230};
  5738. +static unsigned int EISAbases[]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
  5739. +static struct eata_register *EATA_base;
  5740. +
  5741. +static unsigned char dma_channel;
  5742. +static struct geom_emul geometry;       /* Drive 1 & 2 geometry              */
  5743. +
  5744. +static int eata_int_happened, eata_status, expecting_ints;
  5745. +
  5746. +struct eata_cmd_queue outstanding[64];  /* We should allocate this dynamicly */
  5747. +
  5748. +int cont_errs[]=
  5749. +{
  5750. +  DID_OK,         /* No error                    */
  5751. +  DID_NO_CONNECT, /* Selection Timeout           */
  5752. +  DID_TIME_OUT,   /* Command Timeout             */
  5753. +  DID_RESET,      /* SCSI Bus Reset Received     */
  5754. +  DID_ERROR,      /* Initial Controller Power up */
  5755. +  DID_ERROR,      /* Unexpected Bus Phase        */
  5756. +  DID_ERROR,      /* Unexpected Bus Free         */
  5757. +  DID_PARITY,     /* Bus Parity Error            */
  5758. +  DID_ERROR,      /* SCSI Hung                   */
  5759. +  DID_ERROR,      /* Unexpected Message Rejected */
  5760. +  DID_ERROR,      /* SCSI Bus Reset STUCK        */            
  5761. +  DID_ERROR,      /* Auto Request-Sense Failed   */
  5762. +  DID_PARITY,     /* Controller Ram Parity Error */
  5763. +};
  5764. +
  5765. +inline void end_of_command(void)
  5766. +{
  5767. +  Scsi_Cmnd *cmd;
  5768. +  struct eata_ccb *cp;
  5769. +  struct eata_sp  *sp;
  5770. +  int i, result;
  5771. +        /* Find out which CP caused the interrupt */
  5772. +  for(i=0; i<64; i++)
  5773. +    {
  5774. +      if(outstanding[i].used && outstanding[i].sp.cont_stat & 0x80)
  5775. +    break;
  5776. +    }
  5777. +  if(i==64)
  5778. +    {
  5779. +      printk("Got interrupt but no finished packet found!\n");
  5780. +      return;
  5781. +    }
  5782. +  DBG(DBG_AHMON,outb(i, 0x80));                   /* Ahmon's special */     
  5783. +  cmd=outstanding[i].cmd;
  5784. +  cp=&outstanding[i].cp;
  5785. +  sp=&outstanding[i].sp;
  5786. +  outstanding[i].used=0;
  5787. +  if(cmd->use_sg) scsi_free(cmd->host_scribble, 512);
  5788. +  result=sp->scsi_stat;                             
  5789. +  
  5790. +  DBG(DBG_INTR,printk("end_of_command: queuenr: %d message bytes: %x,%x,%x\n",
  5791. +              i,sp->msg[0],sp->msg[1],sp->msg[2]));
  5792. +  result|=COMMAND_COMPLETE<<8; 
  5793. +  result|=cont_errs[sp->cont_stat&0x7f] << 16; /* Fixed the error array */
  5794. +  cmd->result=result;
  5795. +  
  5796. +  cmd->scsi_done(cmd);
  5797. +}
  5798. +
  5799. +void eata_int_handler(int irq)
  5800. +{
  5801. +  eata_status=inb(((int)EATA_base)+HA_RSTATUS); /* Acknowledge interrupt */
  5802. +  DBG(DBG_INTR, printk(" Interrupt %d received, expected: %d,Status: %x\n",irq,
  5803. +               expecting_ints,eata_status));
  5804. +  if(expecting_ints==EXP_NOTHING)
  5805. +    {
  5806. +      printk("eata_int_handler: Unexpected interrupt!\n");
  5807. +      return;
  5808. +    }
  5809. +  if(expecting_ints==EXP_NORMAL)
  5810. +    {
  5811. +      eata_int_happened=1;
  5812. +      return;
  5813. +    }
  5814. +  end_of_command();
  5815. +}
  5816. +
  5817. +inline void eata_set_dma_address(int add)
  5818. +{
  5819. +  outb(add & 0x000000ff, ((int)EATA_base)+HA_WDMAADDR);
  5820. +  outb((add & 0x0000ff00) >> 8, ((int)EATA_base)+HA_WDMAADDR+1);
  5821. +  outb((add & 0x00ff0000) >> 16, ((int)EATA_base)+HA_WDMAADDR+2);
  5822. +  outb((add & 0xff000000) >> 24, ((int)EATA_base)+HA_WDMAADDR+3);
  5823. +}
  5824. +
  5825. +const char *eata_info(void)
  5826. +{
  5827. +  static char *information="EATA SCSI Controller Driver\n";
  5828. +  return information;
  5829. +}
  5830. +
  5831. +inline int eata_reverse(int arg)
  5832. +{
  5833. +  int result;
  5834. +  result=(arg & 0xff000000) >> 24;
  5835. +  result|=((arg & 0x00ff0000) >> 8);
  5836. +  result|=((arg & 0x0000ff00) << 8);
  5837. +  result|=((arg & 0x000000ff) << 24);
  5838. +  return result;
  5839. +}
  5840. +
  5841. +int eata_queue(Scsi_Cmnd *cmd, void *(done)(struct scsi_cmnd *))
  5842. +{
  5843. +  int i=64,status;
  5844. +  struct eata_sp  *sp;
  5845. +  struct eata_ccb *cp;
  5846. +  struct eata_sg_list *sglist;
  5847. +  struct scatterlist *sl;
  5848. +
  5849. +        /* Search for an open command slot.  If i==64, then
  5850. +       there must be none free.  If this is the case, keep
  5851. +       trying because an interrupt will eventually happen
  5852. +       that will free up a slot. 
  5853. +    
  5854. +       This is assuming that interrupts are enabled when this
  5855. +       routine is called.  Is that true? 
  5856. +        */
  5857. +
  5858. +  i=64;
  5859. +  while(i==64) for(i=0; i<64 && outstanding[i].used; i++);
  5860. +  cli();
  5861. +  outstanding[i].used=1; /* Claim it    */
  5862. +  cmd->scsi_done=done;
  5863. +  sp=&outstanding[i].sp;
  5864. +  cp=&outstanding[i].cp;
  5865. +  sp->cont_stat=0; /* Clear this out because the interrupt handler
  5866. +              checks it. Note that I clear it BEFORE I set the
  5867. +              pointer in outstanding[] */
  5868. +  outstanding[i].cmd=cmd;
  5869. +  sti();
  5870. +  if(cmd->cmnd[0]==WRITE_6 || cmd->cmnd[0]==WRITE_10)
  5871. +    cp->cp_option.Byte=HA_DATA_OUT;                       /* Output mode */
  5872. +  else
  5873. +    cp->cp_option.Byte=HA_DATA_IN;                        /* Input mode  */
  5874. +  if(cmd->use_sg) {
  5875. +    cp->cp_option.Byte|=HA_SC_GA;                         /* SG mode     */
  5876. +    sglist=(struct eata_sg_list *)scsi_malloc(512);       /* Max needed 64 */
  5877. +    if(!sglist) 
  5878. +      {
  5879. +    panic("eata_queue: scsi_malloc failed. No memory for SG list\n");
  5880. +      }
  5881. +    cmd->host_scribble=(unsigned char *)sglist;
  5882. +    sl=(struct scatterlist *)cmd->request_buffer;
  5883. +    for(i=0; i<cmd->use_sg; i++, sglist++, sl++)
  5884. +      {
  5885. +    sglist->data=(void *)eata_reverse((int )sl->address);
  5886. +    sglist->len=eata_reverse((int )sl->length);
  5887. +      }
  5888. +    sglist=(struct eata_sg_list *)cmd->host_scribble;
  5889. +  }
  5890. +  cp->reqlen=38;
  5891. +  cp->cp_option2.Byte=0x00;
  5892. +  cp->cp_id=cmd->target;
  5893. +  cp->cp_msg0=cmd->lun+HA_IDENTIFY_MSG+HA_G_DISCO_RECO; /*Those bits should always be set*/
  5894. +  cp->cp_msg1=cp->cp_msg2=cp->cp_msg3=0;
  5895. +  memset(cp->cp_cdb, 0, 12);
  5896. +  memcpy(cp->cp_cdb, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
  5897. +  if(cmd->use_sg)
  5898. +    {
  5899. +      *((int *)cp->cp_dataDMA)=eata_reverse((int )sglist);
  5900. +      *((int *)cp->cp_datalen)=eata_reverse(cmd->use_sg*8);
  5901. +    }
  5902. +  else
  5903. +    {
  5904. +      *((int *)cp->cp_datalen)=eata_reverse(cmd->request_bufflen);
  5905. +      *((int *)cp->cp_dataDMA)=eata_reverse((int )cmd->request_buffer);
  5906. +    }
  5907. +  *((int *)cp->cp_statDMA)=eata_reverse((int )sp);
  5908. +  *((int *)cp->cp_viraddr)=i;      
  5909. +  DBG(DBG_QUEUE,printk("EATA_QUEUE pos: %d, com: %x, SG: %d\n",i,cmd->cmnd[0],
  5910. +               cmd->use_sg));
  5911. +  status=inb(((int)EATA_base)+HA_RSTATUS);
  5912. +  while(status & HA_SBSY) status=inb(((int)EATA_base)+HA_RSTATUS);
  5913. +  expecting_ints=EXP_RETURN;
  5914. +  eata_set_dma_address((int )cp);
  5915. +  outb(EATA_CMD_DMA_SEND_CP, ((int)EATA_base)+HA_WCOMMAND); /* Let 'er rip */
  5916. +  return(0);
  5917. +}
  5918. +
  5919. +static volatile int internal_done_flag = 0;
  5920. +static volatile int internal_done_errcode = 0;
  5921. +
  5922. +static void internal_done(Scsi_Cmnd * SCpnt)
  5923. +{
  5924. +    internal_done_errcode = SCpnt->result;
  5925. +    ++internal_done_flag;
  5926. +}
  5927. +
  5928. +int eata_command(Scsi_Cmnd *SCpnt)
  5929. +{
  5930. +
  5931. +  DBG(DBG_FUNC,printk("eata_command: calling eata_queue\n"));
  5932. +
  5933. +  eata_queue(SCpnt, internal_done);
  5934. +  
  5935. +  while (!internal_done_flag);
  5936. +  internal_done_flag = 0;
  5937. +  return internal_done_errcode;
  5938. +}
  5939. +
  5940. +int eata_abort(Scsi_Cmnd *cmd)
  5941. +{
  5942. +  int i;
  5943. +
  5944. +  /* Just act like we did something */
  5945. +  DBG(DBG_ABNORM,printk("eata_abort()\n"));
  5946. +  DELAY(200);
  5947. +  /*
  5948. +  eata_reset(cmd);
  5949. +  */
  5950. +  
  5951. +  for(i=0; i<64; i++) 
  5952. +    if((outstanding[i].cmd==cmd)&& outstanding[i].used)
  5953. +      return(SCSI_ABORT_BUSY);
  5954. +  return(SCSI_ABORT_NOT_RUNNING); /*SNOOZE*/
  5955. +}
  5956. +
  5957. +int eata_reset(Scsi_Cmnd *cmd)
  5958. +{
  5959. +  int i;
  5960. +  long time;
  5961. +  DBG(DBG_ABNORM,printk("eata_reset()\n"));
  5962. +  DELAY(200);
  5963. +  outb(EATA_CMD_RESET, ((int)EATA_base)+HA_WCOMMAND);
  5964. +/*  if(cmd)
  5965. +    cmd->flags|=NEEDS_JUMPSTART;                                         
  5966. +*/  
  5967. +  time=jiffies+75;
  5968. +  while(time>jiffies);
  5969. +  for(i=0; i<64; i++) outstanding[i].used=0;
  5970. +  return(SCSI_RESET_WAKEUP);
  5971. +}
  5972. +
  5973. +int eata_biosparam(Scsi_Disk * disk, int dev, int geo[])
  5974. +{
  5975. +  int id;
  5976. +  int size = disk->capacity;
  5977. +  
  5978. +  id=MINOR(dev);
  5979. +  if (id) id>>=4;
  5980. +
  5981. +  DBG(DBG_PROBE,printk("\nSize: %d, Device: %x, id: %x\n\n",size,dev,id));
  5982. +  
  5983. +  if(geometry.drv[0].id==id){
  5984. +    geo[0]=geometry.drv[0].heads;
  5985. +    geo[1]=geometry.drv[0].sectors;
  5986. +    geo[2]=geometry.drv[0].cylinder;
  5987. +  }else if(geometry.drv[1].id==id){
  5988. +    geo[0]=geometry.drv[1].heads;
  5989. +    geo[1]=geometry.drv[1].sectors;
  5990. +    geo[2]=geometry.drv[1].cylinder;
  5991. +  }else{
  5992. +    if(size<0x200000){
  5993. +      geo[0]=64;
  5994. +      geo[1]=32;
  5995. +    }else if(size<0x400000){
  5996. +      geo[0]=65;
  5997. +      geo[1]=63;
  5998. +    }else if(size<0x800000){
  5999. +      geo[0]=128;
  6000. +      geo[1]=63;
  6001. +    }else{
  6002. +      geo[0]=255;
  6003. +      geo[1]=63;
  6004. +    }    
  6005. +    geo[2]=size/(geo[0]*geo[1]);
  6006. +  }
  6007. +  return(0);
  6008. +}
  6009. +
  6010. +int get_conf_DMA(struct eata_register *base,struct get_conf *buf)
  6011. +{
  6012. +   long i;
  6013. +  
  6014. +  inb(((int)base)+HA_RSTATUS);               /* Clear any pending conditions */
  6015. +  i=jiffies;
  6016. +  expecting_ints=EXP_NORMAL;
  6017. +  eata_int_happened=0;
  6018. +
  6019. +  outb((unchar)((long)(buf)>>24),(int)base+HA_WDMAADDR+3);/*get config of    */
  6020. +  outb((unchar)((long)(buf)>>16),(int)base+HA_WDMAADDR+2);/*poss. controllers*/
  6021. +  outb((unchar)((long)(buf)>>8), (int)base+HA_WDMAADDR+1);
  6022. +  outb((unchar)((long)(buf)),    (int)base+HA_WDMAADDR); 
  6023. +  outb(EATA_CMD_DMA_READ_CONFIG, (int)base+HA_WCOMMAND);  /* set opcode      */
  6024. +
  6025. +  while(!eata_int_happened && jiffies<i+200);             /* wait for 2 sec. */
  6026. +  expecting_ints=EXP_NOTHING;
  6027. +
  6028. +  if(!eata_int_happened){
  6029. +    printk("eata.c get_conf_DMA: Controller timeout\n");
  6030. +    return (0);
  6031. +  }
  6032. +  
  6033. +  DBG(DBG_PROBE,printk("\nSignature: %c %c %c %c \n",(char)buf->gco_sig[0],
  6034. +           (char)buf->gco_sig[1],(char)buf->gco_sig[2],(char)buf->gco_sig[3]));
  6035. +  if((buf->gco_sig[0]=='E')&&(buf->gco_sig[1]== 'A')
  6036. +       &&(buf->gco_sig[2]== 'T')&&(buf->gco_sig[3]== 'A')) { 
  6037. +    DBG(DBG_PROBE,printk("EATA Controller found at %x EATA Level: %x\n",
  6038. +            (unsigned int) base,(unsigned int)(buf->gco_version>>4)));
  6039. +    return(1);
  6040. +  }
  6041. +  return(0);
  6042. +}
  6043. +
  6044. +long find_EISA(int flag, struct get_conf *buf)
  6045. +{
  6046. +/* 
  6047. +   Is there anyone using more than 2 controllers
  6048. +   at the same time ? ie. more than one secondary ?
  6049. +   I don't think so.
  6050. +*/
  6051. +  struct eata_register *base;
  6052. +  int i;
  6053. +  unsigned char pal1,pal2,pal3,*p;
  6054. +
  6055. +  for(i=0; i<MAXEISA;i++){
  6056. +    if(EISAbases[i]){                      /* Still a possibility ?          */
  6057. +      base=(void *)0x1c88+(i*0x1000);
  6058. +      p=(char*)base;
  6059. +      pal1=*(p-8);
  6060. +      pal2=*(p-7);
  6061. +      pal3=*(p-6);
  6062. +      if(((pal1==0x12)&&(pal2==0x14))||    /* Check for id tags              */
  6063. +     ((pal1==0x38)&&(pal2==0xa3)&&(pal3==0x82))||
  6064. +     ((pal1==0x5d)&&(pal2==0xc3)&&(pal3==0x90))||        /* SCIII PM2022 */
  6065. +     ((pal1==0x06)&&(pal2==0x94)&&(pal3==0x24)))
  6066. +    if(get_conf_DMA(base,buf)){
  6067. +      if((!buf->bit2.SECOND)&&(buf->bit2.IRQ)&&(flag==-1)){
  6068. +                                       /* We just found a primary EISA   */
  6069. +        ISAbases[0]=0;                 /* so there is no prim. ISA cont. */
  6070. +        EISAbases[i]=0;                /* and we don't need to look for  */
  6071. +        return((long)base);            /* a sec. EISA controller here    */
  6072. +      }
  6073. +      else if((buf->bit2.SECOND)&&(buf->bit2.IRQ)&&(!flag)){ 
  6074. +                                       /* We've found a EISA secondary   */
  6075. +        ISAbases[1]=0;                 /* so there is no sec. ISA cont.  */
  6076. +        EISAbases[i]=0;
  6077. +        return((long)base);
  6078. +      }
  6079. +      else EISAbases[i]=0;
  6080. +    }
  6081. +    }
  6082. +  }
  6083. +  return(0l);                              /* Nothing found  :-(             */
  6084. +}
  6085. +
  6086. +long find_ISA(struct eata_register *base, struct get_conf *buf)
  6087. +{
  6088. +  int i,l;
  6089. +  long ret;
  6090. +
  6091. +  ret=0;
  6092. +  if(!base){
  6093. +    for (l=1;l<=MAXISA;l++){
  6094. +      if(ISAbases[l]){
  6095. +    i=get_conf_DMA(base,buf);
  6096. +    if (!i) ISAbases[l]=0;
  6097. +    else{
  6098. +      ret=(int)base;
  6099. +      break;
  6100. +    }
  6101. +      }
  6102. +    }
  6103. +  }else{
  6104. +    i=get_conf_DMA(base, buf);
  6105. +    if((i==1)&&((((long)base==0x1F0l)&&!buf->bit2.SECOND)
  6106. +             ||(((long)base!=0x1F0l)&&buf->bit2.SECOND))) 
  6107. +      ret=(long)base;
  6108. +    else ret=0;
  6109. +  }
  6110. +  return(ret);
  6111. +}
  6112. +
  6113. +int ECS_emulation_sense(long base,int drive)
  6114. +{
  6115. + /*
  6116. +     I'm not sure what's going wrong here, because now I have 
  6117. +     documentation of the ECS command set but still I don't 
  6118. +     get it to work, I don't get a reponse from the 
  6119. +     controller (Ready + Seek complete...) :-(
  6120. + */
  6121. +  int x,ret;
  6122. +  struct emul_sense *p;
  6123. +  char buff[256];
  6124. + /* long time;*/
  6125. +
  6126. +  ret=0;
  6127. +
  6128. +  while(inb_p(base+HA_RSTATUS)&HA_SBSY);      /* Waiting to get not busy */
  6129. +
  6130. +  expecting_ints=EXP_NORMAL;
  6131. +  eata_int_happened=0;
  6132. +
  6133. +  x=drive<<5;
  6134. +  outb(base+1,0);
  6135. +  outb(base+2,0);
  6136. +  outb(base+3,255);
  6137. +  outb(base+4,0);
  6138. +  outb(base+5,0);
  6139. +  outb(base+HA_WCOMMAND-1,x);
  6140. +  outb(base+HA_WCOMMAND,ECS_EMULATE_SENSE);
  6141. +
  6142. +  DBG(DBG_WINTR,printk("ECS: Waiting for interrupt\n"));
  6143. +
  6144. +/* while(!eata_int_happened); */                /* wait for interrupt  */
  6145. +
  6146. +  expecting_ints=EXP_NOTHING;
  6147. +  while(!((x=inb_p(base+HA_RSTATUS))&HA_SDRQ)){
  6148. +    DBG(DBG_WINTR,printk("Controller status %x\n",x));
  6149. +    DELAY(50);
  6150. +  }
  6151. +  insw(base+HA_RDATA,buff,256);             /* Get the Data and    */
  6152. +  while(inb(base+HA_RSTATUS)&HA_SDRQ)       /* throw away the rest */
  6153. +    inb(base+HA_RDATA);
  6154. +  p=(struct emul_sense *)buff;
  6155. +  geometry.drv[drive].heads=p->Heads;
  6156. +  geometry.drv[drive].sectors=p->Sectors;
  6157. +  geometry.drv[drive].cylinder=(p->Cyls[0]<<8)+p->Cyls[1];
  6158. +  if(p->lunmap[drive]&0x80)
  6159. +    geometry.drv[drive].trans=0;
  6160. +  if(drive==0){
  6161. +    if(p->lunmap[2]&0x80) ret=0;
  6162. +    else ret=1;
  6163. +    geometry.drv[drive].id=p->lunmap[0];
  6164. +    geometry.drv[drive].lun=p->lunmap[1];
  6165. +  } else if(drive==1){
  6166. +    ret=1;
  6167. +    geometry.drv[drive].id=p->lunmap[2];
  6168. +    geometry.drv[drive].lun=p->lunmap[3];
  6169. +  }
  6170. +  return(ret);
  6171. +}
  6172. +
  6173. +void get_geo_trans(long base)
  6174. +{ 
  6175. +  outb(0x70,0x12);
  6176. +  if(inb(0x71)){
  6177. +    geometry.drv[0].trans=1;
  6178. +    if(ECS_emulation_sense(base,0)){
  6179. +      outb(0x70,0x12);
  6180. +      if(inb(0x71)&0xF){
  6181. +    geometry.drv[1].trans=1;
  6182. +    ECS_emulation_sense(base,1);
  6183. +      }
  6184. +    }
  6185. +  }
  6186. +}
  6187. +
  6188. +/* int eata_detect(int index) */
  6189. +int eata_detect(Scsi_Host_Template * tpnt)
  6190. +{
  6191. +  struct get_conf gc;
  6192. +  int i;
  6193. +  int err;
  6194. +  long base;
  6195. +  long time;
  6196. +  unsigned int irqlist[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  6197. +
  6198. +  geometry.drv[0].trans=geometry.drv[1].trans=0; 
  6199. +  base=0;
  6200. +  err=0;
  6201. +
  6202. +  
  6203. +  for(i=0;i<16;i++)                        /* Here we grab every available IRQ    */
  6204. +    if(!request_irq(i,eata_int_handler,SA_INTERRUPT,"EATA"))/* until we know which one we  */
  6205. +      irqlist[i]=1;                        /* will need                   */
  6206. +
  6207. +
  6208. +  base=find_EISA(-1,&gc);                  /* Check for primary EISA HA */
  6209. +  if(base) ISAbases[0]=0; /* If found, there can't be an ISA prim. here */
  6210. +  else base=find_ISA((void *)0x1F0,&gc);   /* Check for primary ISA HA  */
  6211. +  if (!base) {                             /* no primary found          */
  6212. +    base=find_EISA(0,&gc);                 /* Check for secondary EISA  */
  6213. +    if (!base) base=find_ISA((void *)0,&gc); 
  6214. +    if (!base) {                           /* No controller fould :-(   */
  6215. +      for(i=0;i<16;i++)                    /* release all interrupts    */ 
  6216. +    if(irqlist[i]){
  6217. +      free_irq(i);
  6218. +      irqlist[i]=0;
  6219. +    }
  6220. +      return(0);
  6221. +    }
  6222. +  }
  6223. +/*  else get_geo_trans(base); */           /* set emulation parameters  */
  6224. +
  6225. +  else if(IDE_EMULATION){                  /* Unfortionally,we have to  */
  6226. +    geometry.drv[0].heads=HEADS0;          /* hardcode the drive geometry */
  6227. +    geometry.drv[0].sectors=SECTORS0;      /* into the driver for now   */
  6228. +    geometry.drv[0].cylinder=CYLINDER0;
  6229. +    geometry.drv[0].id=ID0;
  6230. +    geometry.drv[1].heads=HEADS1;
  6231. +    geometry.drv[1].sectors=SECTORS1;
  6232. +    geometry.drv[1].cylinder=CYLINDER1;
  6233. +    geometry.drv[1].id=ID1;
  6234. +  } else {
  6235. +    geometry.drv[0].id=-1;
  6236. +    geometry.drv[1].id=-1;
  6237. +  }
  6238. +
  6239. +  dma_channel=(8-gc.bit2.DRQX)&7;          /* Which DMA channel ?      */
  6240. +  if (!gc.bit1.DRQ_valid) {
  6241. +    DBG(DBG_PROBE,printk("EISA EATA controller found.\n"));
  6242. +    err=0;
  6243. +  }else if (request_dma(dma_channel,"DPT_EATA")) {
  6244. +    printk("Unable to allocate DMA channel %d for EATA controller.\n",
  6245. +       dma_channel);
  6246. +    err=1;
  6247. +  }
  6248. +
  6249. +  for(i=0;i<16;i++)                         /* Now we can release all  */
  6250. +    if(irqlist[i] && (i!=gc.bit2.IRQ)){     /* unused interrupts again */
  6251. +      free_irq(i);
  6252. +      irqlist[i]=0;
  6253. +    }
  6254. +  if (err) {
  6255. +    free_irq((unsigned int)gc.bit2.IRQ);
  6256. +    return(0);
  6257. +  }
  6258. +  if(!irqlist[(unsigned int) gc.bit2.IRQ]){
  6259. +    printk("eata_detect: Couldn't alloc. IRQ%d!\n",(unsigned int)gc.bit2.IRQ);
  6260. +    return(0);
  6261. +  }
  6262. +
  6263. +  tpnt->can_queue=((int)(gc.gco_queuesiz[0])<<8) + ((int)(gc.gco_queuesiz[1]));
  6264. +  DBG(DBG_PROBE, printk("Can queue %d commands \n",tpnt->can_queue));
  6265. +  if(tpnt->can_queue>64)                 /* This is only temporarily in here */
  6266. +    tpnt->can_queue=64;                   /* We'll allocate the needed space */
  6267. +
  6268. +  tpnt->this_id=(int)(xscsi2int(gc.gco_HAaddress));
  6269. +  tpnt->sg_tablesize=((short unsigned int)(gc.gco_SGsiz[0])<<8)
  6270. +                                      +((short unsigned int)(gc.gco_SGsiz[1]));
  6271. +  tpnt->cmd_per_lun=1;                    
  6272. +                               
  6273. +  if (!gc.bit1.DRQ_valid) tpnt->unchecked_isa_dma=0; /* This is an EISA contr.*/
  6274. +  else tpnt->unchecked_isa_dma=1;                    /* Here we have only ISA */
  6275. +
  6276. +  snarf_region(base, 9);
  6277. +  scsi_register(tpnt,0);
  6278. +  printk("EATA - DMA driver version: %d.%d%s\n",VER_MAJOR,VER_MINOR,VER_SUB);
  6279. +  printk("EATA compliant controller detected. EATA Level %x, SCSI ID is %d \n",
  6280. +            (unsigned int)(gc.gco_version>>4),tpnt->this_id);
  6281. +  printk("Using IRQ %d, DMA channel %d, at %lx\n",(unsigned int)gc.bit2.IRQ,
  6282. +            dma_channel,base); 
  6283. +  time=jiffies;
  6284. +  while(jiffies<time+300);                               /* Let 'em read 8-) */
  6285. +  for(i=0; i<64; i++) outstanding[i].used=0;             /* Do some setup    */
  6286. +  EATA_base=(void *)base;
  6287. +  return(1);
  6288. +
  6289. +}  
  6290. +  
  6291. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/eata.h linux/drivers/scsi/eata.h
  6292. --- linux-1.1.58/drivers/scsi/eata.h    Wed Dec 31 18:00:00 1969
  6293. +++ linux/drivers/scsi/eata.h    Wed Oct 26 23:02:02 1994
  6294. @@ -0,0 +1,349 @@
  6295. +/***************************************************
  6296. + *  Header file for eata.c Linux EATA SCSI driver  *
  6297. + *  currently contains lots of unused stuff        *
  6298. + *  (c) 1993,94 Michael Neuffer                    *
  6299. + ***************************************************
  6300. + * last change: 20.09.94                           *
  6301. + ***************************************************/
  6302. +
  6303. +
  6304. +#ifndef _EATA_H
  6305. +#define _EATA_H
  6306. +
  6307. +#include "../block/blk.h"
  6308. +#include "scsi.h"
  6309. +#include "hosts.h"
  6310. +
  6311. +
  6312. +#define VER_MAJOR 0
  6313. +#define VER_MINOR 3
  6314. +#define VER_SUB   "a"
  6315. +
  6316. +/************************************************************************
  6317. + * Here you can configure your drives that are running in IDE           *
  6318. + * emulation mode                                                       *
  6319. + * If all your drives are running in native mode (not emulated), set    *
  6320. + * IDE_EMULATION to 0                                                   * 
  6321. + * If you have only one drive (running in IDE emu. mode), set ID1 to -1 *
  6322. + ************************************************************************/
  6323. +#define IDE_EMULATION 1          /* Here are drives running in emu. mode   */
  6324. +
  6325. +#define ID0           0          /* SCSI ID of "IDE" drive mapped to C:    */
  6326. +                                 /* If you're not sure check your config
  6327. +                  * utility that came with your controller
  6328. +                  */
  6329. +#define HEADS0       13          /* Number of emulated heads of this drive */  
  6330. +#define SECTORS0     38          /* Number of emulated sectors             */ 
  6331. +#define CYLINDER0   719          /* Number of emulated cylinders           */
  6332. +   
  6333. +#define ID1           1          /* SCSI ID of "IDE" drive mapped to D:    */
  6334. +#define HEADS1       16          /* Number of emulated heads of this drive */ 
  6335. +#define SECTORS1     62          /* Number of emulated sectors             */
  6336. +#define CYLINDER1  1024          /* Number of emulated cylinders           */
  6337. +
  6338. +/************************************************************************
  6339. + * Debug options.                                                       * 
  6340. + * Enable DEBUG and whichever options you require.                      *
  6341. + ************************************************************************/
  6342. +#define DEBUG        0    /* Enable debug code.             */
  6343. +#define DBG_PROBE    1    /* Debug probe routines.         */
  6344. +#define    DBG_DUMP    1    /* Dump response to probes in hex.     */
  6345. +#define DBG_DELAY    0    /* Build in delays so debug messages can be
  6346. +                 * be read before they vanish of the top of
  6347. +                 * the screen!
  6348. +                 */
  6349. +#define DBG_FUNC    1    /* Trace function calls.         */
  6350. +#define DBG_TRAP    1    /* Trap errors from higher levels.    */
  6351. +#define DBG_QUEUE    1    /* Trace command queueing.         */
  6352. +#define DBG_INTR    0       /* Trace interrupt service routine.     */
  6353. +#define DBG_WINTR       1       /* Trace Wait for interrupt             */
  6354. +#define DBG_ABNORM    1    /* Debug abnormal actions (reset, abort)*/
  6355. +#define DBG_AHMON       0       /* Ahmon's special  (-;                 */  
  6356. +
  6357. +#if DEBUG
  6358. +static char dummy;
  6359. +#define DBG(x, y)    if ((x)) {y;} else dummy=0
  6360. +#else
  6361. +#define DBG(x, y)
  6362. +#endif
  6363. +
  6364. +#if DEBUG && DBG_DELAY
  6365. +#define DELAY(x)    if (1) { int i; i = jiffies + x; while (jiffies < i); } else dummy=0
  6366. +#else
  6367. +#define DELAY(x)    
  6368. +#endif
  6369. +
  6370. +
  6371. +#define EATA {                       \
  6372. +    NULL,                        \
  6373. +        "Generic EATA - DMA (rev. 2.0b) driver", \
  6374. +        eata_detect,                 \
  6375. +        NULL,                        \
  6376. +        eata_info,                   \
  6377. +        eata_command,                \
  6378. +        eata_queue,                  \
  6379. +        eata_abort,                  \
  6380. +        eata_reset,                  \
  6381. +        NULL, /* Slave attach */     \
  6382. +        eata_biosparam,              \
  6383. +        1,      /* Canqueue */       \
  6384. +        7,      /* this_id */        \
  6385. +        64,     /* sg_tablesize */   \
  6386. +        1,      /* cmd_per_lun */    \
  6387. +        0,      /* present */        \
  6388. +        0,      /* unchecked_isa_dma */\
  6389. +    ENABLE_CLUSTERING }
  6390. +
  6391. +int eata_detect(Scsi_Host_Template *);
  6392. +const char *eata_info(void);
  6393. +int eata_command(Scsi_Cmnd *);
  6394. +int eata_queue(Scsi_Cmnd *, void *(done)(struct scsi_cmnd *));
  6395. +int eata_abort(Scsi_Cmnd *);
  6396. +int eata_reset(Scsi_Cmnd *);
  6397. +int eata_biosparam(Disk *, int, int []);
  6398. +
  6399. +
  6400. +typedef unsigned char byte;
  6401. +
  6402. +/***********************************************
  6403. + *         EATA Register definitions           *
  6404. + ***********************************************/
  6405. +
  6406. +#define EATA_CMD_PIO_READ_CONFIG 0xf0
  6407. +#define EATA_CMD_PIO_SET_CONFIG  0xf1
  6408. +#define EATA_CMD_PIO_SEND_CP     0xf2
  6409. +#define EATA_CMD_PIO_RECEIVE_SP  0xf3
  6410. +#define EATA_CMD_PIO_TRUNC       0xf4
  6411. +#define EATA_CMD_RESET           0xf9
  6412. +
  6413. +#define EATA_CMD_DMA_READ_CONFIG 0xfd
  6414. +#define EATA_CMD_DMA_SET_CONFIG  0xfe
  6415. +#define EATA_CMD_DMA_SEND_CP     0xff
  6416. +
  6417. +#define ECS_EMULATE_SENSE        0xd4
  6418. +
  6419. +#define HA_WCOMMAND 0x07        /* command register offset   */
  6420. +#define HA_WDMAADDR 0x02        /* DMA address LSB offset    */  
  6421. +#define HA_RAUXSTAT 0x08        /* aux status register offset*/
  6422. +#define HA_RSTATUS  0x07        /* status register offset    */
  6423. +#define HA_RDATA    0x00        /* data register (16bit)     */
  6424. +
  6425. +#define HA_ABUSY    0x01        /* aux busy bit              */
  6426. +#define HA_AIRQ     0x02        /* aux IRQ pending bit       */
  6427. +#define HA_SERROR   0x01        /* pr. command ended in error*/
  6428. +#define HA_SMORE    0x02        /* more data soon to come    */
  6429. +#define HA_SCORR    0x04        /* data corrected            */
  6430. +#define HA_SDRQ     0x08        /* data request active       */
  6431. +#define HA_SSC      0x10        /* seek complete             */
  6432. +#define HA_SFAULT   0x20        /* write fault               */
  6433. +#define HA_SRDY     0x40        /* drive ready               */
  6434. +#define HA_SBSY     0x80        /* drive busy                */
  6435. +#define HA_SDRDY    HA_SSC+HA_SRDY+HA_SDRQ 
  6436. +
  6437. +struct reg_bit {        /* reading this one will clear the interrupt     */
  6438. +  byte error:1;     /* previous command ended in an error           */
  6439. +  byte more:1;      /* more DATA comming soon, poll BSY & DRQ (PIO) */
  6440. +  byte corr:1;      /* data read was successfully corrected with ECC*/
  6441. +  byte drq:1;       /* data request aktive  */     
  6442. +  byte sc:1;        /* seek complete        */
  6443. +  byte fault:1;     /* write fault          */
  6444. +  byte ready:1;     /* drive ready          */
  6445. +  byte busy:1;      /* controller busy      */
  6446. +};
  6447. +
  6448. +struct reg_abit {       /* reading this won't clear the interrupt */
  6449. +  byte abusy:1;     /* auxiliary busy                         */
  6450. +  byte irq:1;       /* set when drive interrupt is asserted   */
  6451. +  byte dummy:6;
  6452. +};
  6453. +
  6454. +struct eata_register {              /* EATA register set */
  6455. +  byte data_reg[2];         /* R, couldn't figure this one out          */
  6456. +  byte cp_addr[4];          /* W, CP address register                   */
  6457. +  union { 
  6458. +    byte command;                 /* W, command code: [read|set] conf, send CP*/
  6459. +    struct reg_bit status;    /* R, see register_bit1                     */
  6460. +    byte statusbyte;
  6461. +  } ovr;   
  6462. +  struct reg_abit aux_stat;     /* R, see register_bit2                       */
  6463. +};
  6464. +
  6465. +/**********************************************
  6466. + *  Other (command) definitions               *
  6467. + **********************************************/
  6468. +
  6469. +struct gco_bits1 {
  6470. +  byte OCS_enabled:1;            /* Overlap Command Support enabled      */
  6471. +  byte TAR_support:1;            /* SCSI Target Mode supported        */
  6472. +  byte TRNXFR:1;        /* Truncate Transfer Cmd not necessary    */
  6473. +                                /* Only used in PIO Mode         */
  6474. +  byte MORE_support:1;            /* MORE supported (only PIO Mode)     */
  6475. +  byte DMA_support:1;            /* DMA supported Driver uses only     */
  6476. +                            /* this mode                */
  6477. +  byte DRQ_valid:1;        /* DRQ value in Byte 30 is valid    */
  6478. +  byte ATA:1;                /* ATA device connected (no support)    */
  6479. +  byte HAA_valid:1;        /* Hostadapter Address is valid         */
  6480. +};
  6481. +
  6482. +struct gco_bits2 {
  6483. +  byte IRQ:4;                 /* IRQ used this HA            */
  6484. +  byte SECOND:1;              /* This is a secondary controller            */
  6485. +  byte IRQ_TR:1;              /* IRQ Trigger: 0=edge, 1=level            */
  6486. +  byte DRQX:2;                /* DRQ index, DRQ is 2comp of DRQX    */
  6487. +};
  6488. +
  6489. +struct get_conf {               /* Read Configuration Array  */
  6490. +  byte gco_len[4];            /* Should return 0x1c             */
  6491. +  byte gco_sig[4];            /* Signature MUST be "EATA"         */
  6492. +  byte gco_version;           /* upper nibble contains Version          */
  6493. +  struct gco_bits1 bit1;                
  6494. +  byte gco_cppadlen[2];          /* Number of pad bytes send after CD data */
  6495. +                              /* set to zero for DMA commands        */
  6496. +  byte gco_HAaddress[4];      /* SCSI ID of controller if SCSI device   */
  6497. +                              /* if not, zero is returned         */
  6498. +  byte gco_cplen[4];          /* CP length: number of valid cp bytes     */
  6499. +  byte gco_splen[4];          /* Number of bytes returned after            */ 
  6500. +                              /* Receive SP command            */
  6501. +  byte gco_queuesiz[2];          /* max number of queueable CPs        */
  6502. +  byte gco_dummy[2];
  6503. +  byte gco_SGsiz[2];          /* max number of SG table entries            */
  6504. +  struct gco_bits2 bit2;
  6505. +  byte gco_sync;              /* device at ID 7 tru 0 is running in     */
  6506. +                              /* synchronous mode                       */
  6507. +  byte gco_unused[480];
  6508. +};
  6509. +
  6510. +struct sco_bits {
  6511. +  byte EATA_disable:1;          /* Disable EATA interface :-(        */
  6512. +  byte OC_enable:1;          /* Enable overlapped commands        */
  6513. +  byte MPD_enable:1;          /* Enable sending of all Save, Restore    */
  6514. +                              /* and Modify Data Pointer Messages       */
  6515. +  byte TAR_enable:1;          /* Enable HA Target mode                       */
  6516. +}; 
  6517. +
  6518. +struct set_conf {          /* Set Configuration Array */
  6519. +  byte sco_trlen[2];          /* Number of bytes following this field    */
  6520. +  struct sco_bits bit;
  6521. +  byte sco_zero;              /* set this one to zero               */  
  6522. +  char   sco_unused[508];
  6523. +};
  6524. +
  6525. +#define HA_DATA_IN  0x80
  6526. +#define HA_DATA_OUT 0x40
  6527. +#define HA_SC_GA    0x08
  6528. +
  6529. +
  6530. +struct cp_bits {              /* Send Command Packet Bits           */
  6531. +  byte SCSI_Reset:1;          /* Cause a SCSI Bus reset on the cmd  */
  6532. +  byte HBA_Init:1;            /* Cause Controller to reInitialize   */
  6533. +  byte Auto_Req_Sen:1;        /* Do Auto Request Sense on errors    */
  6534. +  byte scatter:1;             /* Data Ptr points to a SG Packet     */
  6535. +  byte Resrvd:1;              /* RFU                                */
  6536. +  byte Interpret:1;           /* Interpret the SCSI cdb of own use  */
  6537. +  byte DataOut:1;             /* Data Out phase with command        */
  6538. +  byte DataIn:1;              /* Data In phase with command         */
  6539. +};
  6540. +
  6541. +struct cp_bits2 {
  6542. +  byte Phsunit:1;             /* physical unit on mirrored pair        */
  6543. +  byte Iat:1;                 /* inhibit address translation        */
  6544. +  byte HBA_Cin:1;             /* HBA Inhibit caching                */
  6545. +};
  6546. +
  6547. +struct eata_ccb {             /* Send Command Packet structure      */
  6548. +  union {
  6549. +    struct cp_bits bit;       /* CP Bits                */
  6550. +    byte Byte;
  6551. +  } cp_option;
  6552. +  byte reqlen;               /* Request Sense Length               */ 
  6553. +                              /* Valid if Auto_Req_Sen=1            */
  6554. +  byte unused[4];
  6555. +  union {
  6556. +    struct cp_bits2 bit;      /* Send command direct to physical unit   */   
  6557. +    byte Byte;
  6558. +  } cp_option2;
  6559. +  byte cp_id;                 /* SCSI Device ID of target       */ 
  6560. +  byte cp_msg0;               /* Message bytes 0-3              */
  6561. +  byte cp_msg1;
  6562. +  byte cp_msg2;
  6563. +  byte cp_msg3;
  6564. +  byte cp_cdb[12];              /* Command Descriptor Block       */
  6565. +  byte cp_datalen[4];           /* Data Transfer Length           */
  6566. +                              /* If scatter=1 len of sg package */
  6567. +  byte cp_viraddr[4];         /* Virtual address of CP          */
  6568. +  byte cp_dataDMA[4];           /* Data Address, if scatter=1     */
  6569. +                              /* address of scatter packet      */  
  6570. +  byte cp_statDMA[4];         /* address for Status Packet      */ 
  6571. +  byte cp_reqDMA[4];          /* Request Sense Address, used if */
  6572. +                              /* CP command ends with error     */
  6573. +};
  6574. +
  6575. +
  6576. +struct eata_sp
  6577. +{
  6578. +  byte cont_stat, scsi_stat, reserved[2];
  6579. +  byte residue_len[4], cp_id[4], msg[12];
  6580. +};
  6581. +
  6582. +struct eata_cmd_queue
  6583. +{
  6584. +  int used;
  6585. +  struct eata_sp  sp;
  6586. +  struct eata_ccb cp;
  6587. +  Scsi_Cmnd *cmd;
  6588. +};
  6589. +
  6590. +struct eata_sg_list
  6591. +{
  6592. +        void *data;
  6593. +        int len;
  6594. +};
  6595. +
  6596. +
  6597. +
  6598. +
  6599. +/* structure for max. 2 emulated drives */
  6600. +struct drive_geom_emul {
  6601. +  byte trans;                 /* translation flag 1=transl */
  6602. +  int  channel;               /* SCSI channel number       */
  6603. +  byte HBA;                   /* HBA number (prim/sec)     */
  6604. +  byte id;                    /* drive id                  */
  6605. +  byte lun;                   /* drive lun                 */
  6606. +  uint heads;                 /* number of heads           */
  6607. +  uint sectors;               /* number of sectors         */
  6608. +  uint cylinder;              /* number of cylinders       */
  6609. +};
  6610. +
  6611. +struct geom_emul {
  6612. +  int bios_drives;               /* number of emulated drives */
  6613. +  struct drive_geom_emul drv[2]; /* drive structures          */
  6614. +};
  6615. +
  6616. +struct emul_sense {
  6617. +  byte Byte0;
  6618. +  byte Cyls[2];
  6619. +  byte Heads;
  6620. +  byte Sectors;
  6621. +  byte padding;
  6622. +  byte drtype[2];
  6623. +  byte lunmap[8];
  6624. +};
  6625. +
  6626. +/**********************************************
  6627. + * Message definitions                        *
  6628. + **********************************************/
  6629. +#define HA_IDENTIFY_MSG 0x80       /* Sent identify message      */
  6630. +#define HA_G_DISCO_RECO 0x40       /* Grant disconnect privilege */
  6631. +
  6632. +/*********************************************
  6633. + * Misc. definitions                         *
  6634. + *********************************************/
  6635. +#define EXP_NOTHING 0
  6636. +#define EXP_RETURN  2
  6637. +#define EXP_NORMAL  1
  6638. +
  6639. +
  6640. +#define xscsi2int(up) ( (((long)(up)[0]) << 24) + (((long)(up)[1]) << 16) \
  6641. +                      + (((long)(up)[2]) <<  8) +  ((long)(up)[3]) )
  6642. +
  6643. +#endif /* _EATA_H */
  6644. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/hosts.c linux/drivers/scsi/hosts.c
  6645. --- linux-1.1.58/drivers/scsi/hosts.c    Sat Sep 17 21:49:42 1994
  6646. +++ linux/drivers/scsi/hosts.c    Wed Oct 26 23:02:02 1994
  6647. @@ -39,10 +39,20 @@
  6648.  #include "aha1740.h"
  6649.  #endif
  6650.  
  6651. +#ifdef CONFIG_SCSI_AHA274X
  6652. +#include "aha274x.h"
  6653. +#endif
  6654. +
  6655. +
  6656. +
  6657.  #ifdef CONFIG_SCSI_BUSLOGIC
  6658.  #include "buslogic.h"
  6659.  #endif
  6660.  
  6661. +#ifdef CONFIG_SCSI_EATA            
  6662. +#include "eata.h"
  6663. +#endif
  6664. +
  6665.  #ifdef CONFIG_SCSI_FUTURE_DOMAIN
  6666.  #include "fdomain.h"
  6667.  #endif
  6668. @@ -131,6 +141,12 @@
  6669.  #endif
  6670.  #ifdef CONFIG_SCSI_AHA1740
  6671.      AHA1740,
  6672. +#endif
  6673. +#ifdef CONFIG_SCSI_AHA274X
  6674. +    AHA274X,
  6675. +#endif
  6676. +#ifdef CONFIG_SCSI_EATA 
  6677. +        EATA,
  6678.  #endif
  6679.  #ifdef CONFIG_SCSI_FUTURE_DOMAIN
  6680.      FDOMAIN_16X0,
  6681. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/in2000.c linux/drivers/scsi/in2000.c
  6682. --- linux-1.1.58/drivers/scsi/in2000.c    Wed Dec 31 18:00:00 1969
  6683. +++ linux/drivers/scsi/in2000.c    Wed Oct 26 23:02:02 1994
  6684. @@ -0,0 +1,677 @@
  6685. +/*
  6686. + *  This file is in2000.c, written and
  6687. + *  Copyright (C) 1993  Brad McLean
  6688. + *    Last edit 07/19/94 WDE
  6689. + * Disclaimer:
  6690. + * Note:  This is ugly.  I know it, I wrote it, but my whole
  6691. + * focus was on getting the damn thing up and out quickly.
  6692. + * Future stuff that would be nice:  Command chaining, and
  6693. + * a local queue of commands would speed stuff up considerably.
  6694. + * Disconnection needs some supporting code.  All of this
  6695. + * is beyond the scope of what I wanted to address, but if you
  6696. + * have time and patience, more power to you.
  6697. + * Also, there are some constants scattered throughout that
  6698. + * should have defines, and I should have built functions to
  6699. + * address the registers on the WD chip.
  6700. + * Oh well, I'm out of time for this project.
  6701. + * The one good thing to be said is that you can use the card.
  6702. + */
  6703. +
  6704. +/*
  6705. + * This module was updated by Shaun Savage first on 5-13-93
  6706. + * At that time the write was fixed, irq detection, and some
  6707. + * timing stuff.  since that time other problems were fixed.
  6708. + * On 7-20-93 this file was updated for patch level 11
  6709. + * There are still problems with it but it work on 95% of
  6710. + * the machines.  There are still problems with it working with
  6711. + * IDE drives, as swap drive and HD that support reselection.
  6712. + * But for most people it will work.
  6713. + */
  6714. +/* More changes by Bill Earnest, wde@aluxpo.att.com
  6715. + * through 4/07/94. Includes rewrites of FIFO routines,
  6716. + * length-limited commands to make swap partitions work.
  6717. + * Merged the changes released by Larry Doolittle, based on input
  6718. + * from Jon Luckey, Roger Sunshine, John Shifflett. The FAST_FIFO
  6719. + * doesn't work for me. Scatter-gather code from Eric. The change to
  6720. + * an IF stmt. in the interrupt routine finally made it stable.
  6721. + * Limiting swap request size patch to ll_rw_blk.c not needed now.
  6722. + * Please ignore the clutter of debug stmts., pretty can come later.
  6723. + */
  6724. +/* Merged code from Matt Postiff improving the auto-sense validation
  6725. + * for all I/O addresses. Some reports of problems still come in, but
  6726. + * have been unable to reproduce or localize the cause. Some are from
  6727. + * LUN > 0 problems, but that is not host specific. Now 6/6/94.
  6728. + */
  6729. +/* Changes for 1.1.28 kernel made 7/19/94, code not affected. (WDE)
  6730. + */
  6731. +
  6732. +#include <linux/kernel.h>
  6733. +#include <linux/head.h>
  6734. +#include <linux/types.h>
  6735. +#include <linux/string.h>
  6736. +
  6737. +#include <linux/sched.h>
  6738. +#include <asm/dma.h>
  6739. +
  6740. +#include <asm/system.h>
  6741. +#include <asm/io.h>
  6742. +#include "../block/blk.h"
  6743. +#include "scsi.h"
  6744. +#include "hosts.h"
  6745. +
  6746. +#include "in2000.h"
  6747. +
  6748. +/*#define FAST_FIFO_IO*/
  6749. +
  6750. +/*#define DEBUG*/
  6751. +#ifdef DEBUG
  6752. +#define DEB(x) x
  6753. +#else
  6754. +#define DEB(x)
  6755. +#endif
  6756. +
  6757. +/* These functions are based on include/asm/io.h */
  6758. +#ifndef inw
  6759. +inline static unsigned short inw( unsigned short port )
  6760. +{
  6761. +   unsigned short _v;
  6762. +   
  6763. +   __asm__ volatile ("inw %1,%0"
  6764. +             :"=a" (_v):"d" ((unsigned short) port));
  6765. +   return _v;
  6766. +}
  6767. +#endif
  6768. +
  6769. +#ifndef outw
  6770. +inline static void outw( unsigned short value, unsigned short port )
  6771. +{
  6772. +   __asm__ volatile ("outw %0,%1"
  6773. +            : /* no outputs */
  6774. +            :"a" ((unsigned short) value),
  6775. +            "d" ((unsigned short) port));
  6776. +}
  6777. +#endif
  6778. +
  6779. +/* These functions are lifted from drivers/block/hd.c */
  6780. +
  6781. +#define port_read(port,buf,nr) \
  6782. +__asm__("cld;rep;insw": :"d" (port),"D" (buf),"c" (nr):"cx","di")
  6783. +
  6784. +#define port_write(port,buf,nr) \
  6785. +__asm__("cld;rep;outsw": :"d" (port),"S" (buf),"c" (nr):"cx","si")
  6786. +
  6787. +static unsigned int base;
  6788. +static unsigned int ficmsk;
  6789. +static unsigned char irq_level;
  6790. +static int in2000_datalen;
  6791. +static unsigned int in2000_nsegment;
  6792. +static unsigned int in2000_current_segment;
  6793. +static unsigned short *in2000_dataptr;
  6794. +static char    in2000_datawrite;
  6795. +struct scatterlist * in2000_scatter;
  6796. +static Scsi_Cmnd *in2000_SCptr = 0;
  6797. +
  6798. +void (*in2000_done)(Scsi_Cmnd *);
  6799. +
  6800. +int in2000_test_port(int index)
  6801. +{
  6802. +    static const int *bios_tab[] = {
  6803. +    (int *) 0xc8000, (int *) 0xd0000, (int *) 0xd8000 };
  6804. +    int    i;
  6805. +    char    tmp;
  6806. +
  6807. +    tmp = inb(INFLED);
  6808. +    /* First, see if the DIP switch values are valid */
  6809. +    /* The test of B7 may fail on some early boards, mine works. */
  6810. +    if (((~tmp & 0x3) != index ) || (tmp & 0x80) || !(tmp & 0x4) )
  6811. +        return 0;
  6812. +    printk("IN-2000 probe got dip setting of %02X\n", tmp);
  6813. +    tmp = inb(INVERS);
  6814. +/* Add some extra sanity checks here */
  6815. +    for(i=0; i < 3; i++)
  6816. +    if(*(bios_tab[i]+0x04) == 0x41564f4e) {
  6817. +      printk("IN-2000 probe found hdw. vers. %02x, BIOS at %06x\n",
  6818. +        tmp, (unsigned int)bios_tab[i]);
  6819. +        return 1;
  6820. +    }
  6821. +    printk("in2000 BIOS not found.\n");
  6822. +    return 0;
  6823. +}
  6824. +
  6825. +
  6826. +/*
  6827. + * retreive the current transaction counter from the WD
  6828. + */
  6829. +
  6830. +unsigned in2000_txcnt(void)
  6831. +{
  6832. +    unsigned total=0;
  6833. +
  6834. +    if(inb(INSTAT) & 0x20) return 0xffffff;    /* not readable now */
  6835. +    outb(TXCNTH,INSTAT);    /* then autoincrement */
  6836. +    total =  (inb(INDATA) & 0xff) << 16;
  6837. +    outb(TXCNTM,INSTAT);
  6838. +    total += (inb(INDATA) & 0xff) << 8;
  6839. +    outb(TXCNTL,INSTAT);
  6840. +    total += (inb(INDATA) & 0xff);
  6841. +    return total;
  6842. +}
  6843. +
  6844. +/*
  6845. + * Note: the FIFO is screwy, and has a counter granularity of 16 bytes, so
  6846. + * we have to reconcile the FIFO counter, the transaction byte count from the
  6847. + * WD chip, and of course, our desired transaction size.  It may look strange,
  6848. + * and could probably use improvement, but it works, for now.
  6849. + */
  6850. +
  6851. +void in2000_fifo_out(void)    /* uses FIFOCNTR */
  6852. +{
  6853. +    unsigned count, infcnt, txcnt;
  6854. +
  6855. +    infcnt = inb(INFCNT)& 0xfe;    /* FIFO counter */
  6856. +    do {
  6857. +    txcnt = in2000_txcnt();
  6858. +/*DEB(printk("FIw:%d %02x %d\n", in2000_datalen, infcnt, txcnt));*/
  6859. +    count = (infcnt << 3) - 32;    /* dont fill completely */
  6860. +    if ( count > in2000_datalen )
  6861. +        count = in2000_datalen;    /* limit to actual data on hand */
  6862. +    count >>= 1;        /* Words, not bytes */
  6863. +#ifdef FAST_FIFO_IO
  6864. +    if ( count ) {
  6865. +        port_write(INFIFO, in2000_dataptr, count);
  6866. +        in2000_datalen -= (count<<1);
  6867. +    }
  6868. +#else
  6869. +    while ( count-- )
  6870. +        {
  6871. +        outw(*in2000_dataptr++, INFIFO);
  6872. +        in2000_datalen -= 2;
  6873. +        }
  6874. +#endif
  6875. +    } while((in2000_datalen > 0) && ((infcnt = (inb(INFCNT)) & 0xfe) >= 0x20) );
  6876. +    /* If scatter-gather, go on to next segment */
  6877. +    if( !in2000_datalen && in2000_current_segment < in2000_nsegment)
  6878. +      {
  6879. +      in2000_scatter++;
  6880. +      in2000_current_segment++;
  6881. +      in2000_datalen = in2000_scatter->length;
  6882. +      in2000_dataptr = (unsigned short*)in2000_scatter->address;
  6883. +      }
  6884. +    if ( in2000_datalen <= 0 )
  6885. +    {
  6886. +    ficmsk = 0;
  6887. +    count = 32;    /* Always says to use this much flush */
  6888. +    while ( count-- )
  6889. +        outw(0, INFIFO);
  6890. +    outb(2, ININTR); /* Mask FIFO Interrupts when done */
  6891. +    }
  6892. +}
  6893. +
  6894. +void in2000_fifo_in(void)    /* uses FIFOCNTR */
  6895. +{
  6896. +    unsigned fic, count, count2;
  6897. +
  6898. +    count = inb(INFCNT) & 0xe1;
  6899. +    do{
  6900. +    count2 = count;
  6901. +    count = (fic = inb(INFCNT)) & 0xe1;
  6902. +    } while ( count != count2 );
  6903. +DEB(printk("FIir:%d %02x %08x\n", in2000_datalen,fic,(unsigned int )in2000_dataptr));
  6904. +    do {
  6905. +    count2 = in2000_txcnt();    /* bytes yet to come over SCSI bus */
  6906. +DEB(printk("FIr:%d %02x %08x %08x\n", in2000_datalen,fic,count2,(unsigned int)in2000_dataptr));
  6907. +    if(count2 > 65536) count2 = 0;
  6908. +    if(fic > 128) count = 1024;
  6909. +      else if(fic > 64) count = 512;
  6910. +        else if (fic > 32) count = 256;
  6911. +          else if ( count2 < in2000_datalen ) /* if drive has < what we want */
  6912. +            count = in2000_datalen - count2;    /* FIFO has the rest */
  6913. +    if ( count > in2000_datalen )    /* count2 is lesser of FIFO & rqst */
  6914. +        count2 = in2000_datalen >> 1;    /* converted to word count */
  6915. +    else
  6916. +        count2 = count >> 1;
  6917. +    count >>= 1;        /* also to words */
  6918. +    count -= count2;    /* extra left over in FIFO */
  6919. +#ifdef FAST_FIFO_IO
  6920. +    if ( count2 ) {
  6921. +        port_read(INFIFO, in2000_dataptr, count2);
  6922. +        in2000_datalen -= (count2<<1);
  6923. +    }
  6924. +#else
  6925. +    while ( count2-- )
  6926. +    {
  6927. +        *in2000_dataptr++ = inw(INFIFO);
  6928. +        in2000_datalen -=2;
  6929. +    }
  6930. +#endif
  6931. +    } while((in2000_datalen > 0) && (fic = inb(INFCNT)) );
  6932. +DEB(printk("FIer:%d %02x %08x\n", in2000_datalen,fic,(unsigned int )in2000_dataptr));
  6933. +/*    while ( count-- )
  6934. +        inw(INFIFO);*/    /* Throw away some extra stuff */
  6935. +    if( !in2000_datalen && in2000_current_segment < in2000_nsegment)
  6936. +      {
  6937. +      in2000_scatter++;
  6938. +      in2000_current_segment++;
  6939. +      in2000_datalen = in2000_scatter->length;
  6940. +      in2000_dataptr = (unsigned short*)in2000_scatter->address;
  6941. +      }
  6942. +    if ( ! in2000_datalen ){
  6943. +    outb(2, ININTR); /* Mask FIFO Interrupts when done */
  6944. +    ficmsk = 0;}
  6945. +}
  6946. +
  6947. +const char *in2000_info(void)
  6948. +{
  6949. +    static char buffer[] = "";
  6950. +    return buffer;
  6951. +}
  6952. +
  6953. +void in2000_intr_handle(int foo)
  6954. +{
  6955. +    int result=0;
  6956. +    unsigned int count,auxstatus,scsistatus,cmdphase,scsibyte;
  6957. +    int action=0;
  6958. +    Scsi_Cmnd *SCptr;
  6959. +
  6960. +  DEB(printk("INT:%d %02x %08x\n", in2000_datalen, inb(INFCNT),(unsigned int)in2000_dataptr));
  6961. +
  6962. +    if (( (ficmsk & (count = inb(INFCNT))) == 0xfe ) ||
  6963. +        ( (inb(INSTAT) & 0x8c) == 0x80))
  6964. +    {    /* FIFO interrupt or WD interrupt */
  6965. +       auxstatus = inb(INSTAT);    /* need to save now */
  6966. +       outb(SCSIST,INSTAT);
  6967. +       scsistatus = inb(INDATA); /* This clears the WD intrpt bit */
  6968. +       outb(TARGETU,INSTAT);    /* then autoincrement */
  6969. +       scsibyte = inb(INDATA);    /* Get the scsi status byte */
  6970. +       outb(CMDPHAS,INSTAT);
  6971. +       cmdphase = inb(INDATA);
  6972. +       DEB(printk("(int2000:%02x %02x %02x %02x %02x)\n",count,auxstatus,
  6973. +        scsistatus,cmdphase,scsibyte));
  6974. +
  6975. +    /* Why do we assume that we need to send more data here??? ERY */
  6976. +       if ( in2000_datalen && in2000_dataptr )    /* data xfer pending */
  6977. +           {
  6978. +           if ( in2000_datawrite )
  6979. +        in2000_fifo_out();
  6980. +        else
  6981. +        in2000_fifo_in();
  6982. +           } else ficmsk = 0;
  6983. +    if ( (auxstatus & 0x8c) == 0x80 )
  6984. +        {    /* There is a WD Chip interrupt & register read good */
  6985. +        outb(2,ININTR);    /* Disable fifo interrupts */
  6986. +        ficmsk = 0;
  6987. +        result = DID_OK << 16;
  6988. +        /* 16=Select & transfer complete, 85=got disconnect */
  6989. +        if ((scsistatus != 0x16) && (scsistatus != 0x85)
  6990. +        && (scsistatus != 0x42)){
  6991. +/*           printk("(WDi2000:%02x %02x %02x %02x %02x)\n",count,auxstatus,
  6992. +            scsistatus,cmdphase,scsibyte);*/
  6993. +/*        printk("QDAT:%d %08x %02x\n",
  6994. +        in2000_datalen,(unsigned int)in2000_dataptr,ficmsk);*/
  6995. +        ;
  6996. +        }
  6997. +        switch ( scsistatus & 0xf0 )
  6998. +            {
  6999. +            case    0x00:    /* Card Reset Completed */
  7000. +            action = 3;
  7001. +            break;
  7002. +            case    0x10:    /* Successful Command Completion */
  7003. +            if ( scsistatus & 0x8 )
  7004. +                    action = 1;
  7005. +            break;
  7006. +            case    0x20:    /* Command Paused or Aborted */
  7007. +            if ( (scsistatus & 0x8) )
  7008. +                    action = 1;
  7009. +            else if ( (scsistatus & 7) < 2 )
  7010. +                    action = 2;
  7011. +                 else
  7012. +                    result = DID_ABORT << 16;
  7013. +            break;
  7014. +            case    0x40:    /* Terminated early */
  7015. +            if ( scsistatus & 0x8 )
  7016. +                     action = 1;
  7017. +            else if ( (scsistatus & 7) > 2 )
  7018. +                     action = 2;
  7019. +                 else
  7020. +                    result = DID_TIME_OUT << 16;
  7021. +            break;
  7022. +            case    0x80:    /* Service Required from SCSI bus */
  7023. +            if ( scsistatus & 0x8 )
  7024. +                action = 1;
  7025. +            else
  7026. +                action = 2;
  7027. +            break;
  7028. +            }        /* end switch(scsistatus) */
  7029. +        outb(0,INFLED);
  7030. +        switch ( action )
  7031. +            {
  7032. +            case    0x02:    /* Issue an abort */
  7033. +            outb(COMMAND,INSTAT);
  7034. +            outb(1,INDATA);     /* ABORT COMMAND */
  7035. +            result = DID_ABORT << 16;
  7036. +            case    0x00:    /* Basically all done */
  7037. +            if ( ! in2000_SCptr )
  7038. +                return;
  7039. +            in2000_SCptr->result = result | scsibyte;
  7040. +            SCptr = in2000_SCptr;
  7041. +            in2000_SCptr = 0;
  7042. +            if ( in2000_done )
  7043. +                     (*in2000_done)(SCptr);
  7044. +            break;
  7045. +            case    0x01:    /* We need to reissue a command */
  7046. +            outb(CMDPHAS,INSTAT);
  7047. +            switch ( scsistatus & 7 )
  7048. +                {
  7049. +                case    0:    /* Data out phase */
  7050. +                    case    1:    /* Data in phase */
  7051. +                    case    4:    /* Unspec info out phase */
  7052. +                    case    5:    /* Unspec info in phase */
  7053. +                    case    6:    /* Message in phase */
  7054. +                    case    7:    /* Message in phase */
  7055. +                outb(0x41,INDATA); /* rdy to disconn */
  7056. +                break;
  7057. +                    case    2:    /* command phase */
  7058. +                outb(0x30,INDATA); /* rdy to send cmd bytes */
  7059. +                break;
  7060. +                    case    3:    /* status phase */
  7061. +                outb(0x45,INDATA); /* To go to status phase,*/
  7062. +                outb(TXCNTH,INSTAT); /* elim. data, autoinc */
  7063. +                outb(0,INDATA);
  7064. +                outb(0,INDATA);
  7065. +                outb(0,INDATA);
  7066. +                in2000_datalen = 0;
  7067. +                in2000_dataptr = 0;
  7068. +                break;
  7069. +                }    /* end switch(scsistatus) */
  7070. +            outb(COMMAND,INSTAT);
  7071. +            outb(8,INDATA);     /* RESTART THE COMMAND */
  7072. +            break;
  7073. +            case    0x03:    /* Finish up a Card Reset */
  7074. +            outb(TIMEOUT,INSTAT);    /* I got these values */
  7075. +                        /* by reverse Engineering */
  7076. +            outb(IN2000_TMOUT,INDATA); /* the Always' bios. */
  7077. +            outb(CONTROL,INSTAT);
  7078. +            outb(0,INDATA);
  7079. +            outb(SYNCTXR,INSTAT);
  7080. +            outb(0x40,INDATA);    /* async, 4 cyc xfer per. */
  7081. +            break;
  7082. +            }        /* end switch(action) */
  7083. +        }            /* end if auxstatus for WD int */
  7084. +    }            /* end while intrpt active */
  7085. +}
  7086. +
  7087. +int in2000_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
  7088. +{
  7089. +    unchar direction;
  7090. +    unchar *cmd = (unchar *) SCpnt->cmnd;
  7091. +    unchar target = SCpnt->target;
  7092. +    void *buff = SCpnt->request_buffer;
  7093. +    int bufflen = SCpnt->request_bufflen;
  7094. +    int timeout, size, loop;
  7095. +    int i;
  7096. +
  7097. +    /*
  7098. +     * This SCSI command has no data phase, but unfortunately the mid-level
  7099. +     * SCSI drivers ask for 256 bytes of data xfer.  Our card hangs if you
  7100. +     * do this, so we protect against it here.  It would be nice if the mid-
  7101. +     * level could be changed, but who knows if that would break other host
  7102. +     * adapter drivers.
  7103. +     */
  7104. +    if ( *cmd == TEST_UNIT_READY )
  7105. +    bufflen = 0;
  7106. +
  7107. +    /*
  7108. +     * What it looks like.  Boy did I get tired of reading it's output.
  7109. +     */
  7110. +    if (*cmd == READ_10 || *cmd == WRITE_10) {
  7111. +    i = xscsi2int((cmd+1));
  7112. +    } else if (*cmd == READ_6 || *cmd == WRITE_6) {
  7113. +    i = scsi2int((cmd+1));
  7114. +    } else {
  7115. +    i = -1;
  7116. +    }
  7117. +#ifdef DEBUG
  7118. +    printk("in2000qcmd: pos %d len %d ", i, bufflen);
  7119. +    printk("scsi cmd:");
  7120. +    for (i = 0; i < (COMMAND_SIZE(*cmd)); i++) printk("%02x ", cmd[i]);
  7121. +    printk("\n");
  7122. +#endif
  7123. +    direction = 1;    /* assume for most commands */
  7124. +    if (*cmd == WRITE_10 || *cmd == WRITE_6)
  7125. +    direction = 0;
  7126. +    size = COMMAND_SIZE(*cmd);    /* CDB length */ 
  7127. +    /*
  7128. +     * Setup our current pointers
  7129. +     * This is where you would allocate a control structure in a queue,
  7130. +     * If you were going to upgrade this to do multiple issue.
  7131. +     * Note that datalen and dataptr exist because we can change the
  7132. +     * values during the course of the operation, while managing the
  7133. +     * FIFO.
  7134. +     * Note the nasty little first clause.  In theory, the mid-level
  7135. +     * drivers should never hand us more than one command at a time,
  7136. +     * but just in case someone gets cute in configuring the driver,
  7137. +     * we'll protect them, although not very politely.
  7138. +     */
  7139. +    if ( in2000_SCptr )
  7140. +    {
  7141. +    printk("in2000_queue_command waiting for free command block!\n");
  7142. +    while ( in2000_SCptr );
  7143. +    }
  7144. +    for ( timeout = jiffies + 5; timeout > jiffies; )
  7145. +    {
  7146. +    if ( ! ( inb(INSTAT) & 0xb0 ) )
  7147. +    {
  7148. +        timeout = 0;
  7149. +        break;
  7150. +    }
  7151. +    else
  7152. +    {
  7153. +        inb(INSTAT);
  7154. +        outb(SCSIST,INSTAT);
  7155. +        inb(INDATA);
  7156. +        outb(TARGETU,INSTAT);     /* then autoinc */
  7157. +        inb(INDATA);
  7158. +        inb(INDATA);
  7159. +    }
  7160. +    }
  7161. +    if ( timeout )
  7162. +    {
  7163. +    printk("in2000_queue_command timeout!\n");
  7164. +    SCpnt->result = DID_TIME_OUT << 16;
  7165. +    (*done)(SCpnt);
  7166. +    return 1;
  7167. +    }
  7168. +    /* Added for scatter-gather support */
  7169. +    in2000_nsegment = SCpnt->use_sg;
  7170. +    in2000_current_segment = 0;
  7171. +    if(SCpnt->use_sg){
  7172. +      in2000_scatter = (struct scatterlist *) buff;
  7173. +      in2000_datalen = in2000_scatter->length;
  7174. +      in2000_dataptr = (unsigned short*)in2000_scatter->address;
  7175. +    } else {
  7176. +      in2000_scatter = NULL;
  7177. +      in2000_datalen = bufflen;
  7178. +      in2000_dataptr = (unsigned short*) buff;
  7179. +    };
  7180. +    in2000_done = done;
  7181. +    in2000_SCptr = SCpnt;
  7182. +    /*
  7183. +     * Write the CDB to the card, then the LUN, the length, and the target.
  7184. +     */
  7185. +    outb(TOTSECT, INSTAT);    /* start here then autoincrement */
  7186. +    for ( loop=0; loop < size; loop++ )
  7187. +    outb(cmd[loop],INDATA);
  7188. +    outb(TARGETU,INSTAT);
  7189. +    outb(SCpnt->lun & 7,INDATA);
  7190. +    SCpnt->host_scribble = NULL;
  7191. +    outb(TXCNTH,INSTAT);    /* then autoincrement */
  7192. +    outb(bufflen>>16,INDATA);
  7193. +    outb(bufflen>>8,INDATA);
  7194. +    outb(bufflen,INDATA);
  7195. +    outb(target&7,INDATA);
  7196. +    /*
  7197. +     * Set up the FIFO
  7198. +     */
  7199. +    cli();        /* so FIFO init waits till WD set */
  7200. +    outb(0,INFRST);
  7201. +    if ( direction == 1 )
  7202. +    {
  7203. +    in2000_datawrite = 0;
  7204. +    outb(0,INFWRT);
  7205. +    }
  7206. +    else
  7207. +    {
  7208. +    in2000_datawrite = 1;
  7209. +    for ( loop=16; --loop; ) /* preload the outgoing fifo */
  7210. +        {
  7211. +        outw(*in2000_dataptr++,INFIFO);
  7212. +        if(in2000_datalen > 0) in2000_datalen-=2;
  7213. +        }
  7214. +    }
  7215. +    ficmsk = 0xff;
  7216. +    /*
  7217. +     * Start it up
  7218. +     */
  7219. +    outb(CONTROL,INSTAT);    /* WD BUS Mode */
  7220. +    outb(0x4C,INDATA);
  7221. +    if ( in2000_datalen )        /* if data xfer cmd */
  7222. +        outb(0,ININTR);        /* Enable FIFO intrpt some boards? */
  7223. +    outb(COMMAND,INSTAT);
  7224. +    outb(0,INNLED);
  7225. +    outb(8,INDATA);        /* Select w/ATN & Transfer */
  7226. +    sti();            /* let the intrpt rip */
  7227. +    return 0;
  7228. +}
  7229. +
  7230. +static volatile int internal_done_flag = 0;
  7231. +static volatile int internal_done_errcode = 0;
  7232. +
  7233. +static void internal_done(Scsi_Cmnd * SCpnt)
  7234. +{
  7235. +    internal_done_errcode = SCpnt->result;
  7236. +    ++internal_done_flag;
  7237. +}
  7238. +
  7239. +int in2000_command(Scsi_Cmnd * SCpnt)
  7240. +{
  7241. +    in2000_queuecommand(SCpnt, internal_done);
  7242. +
  7243. +    while (!internal_done_flag);
  7244. +    internal_done_flag = 0;
  7245. +    return internal_done_errcode;
  7246. +}
  7247. +
  7248. +int in2000_detect(Scsi_Host_Template * tpnt)
  7249. +{
  7250. +/* Order chosen to reduce conflicts with some multi-port serial boards */
  7251. +    int base_tab[] = { 0x220,0x200,0x110,0x100 };
  7252. +    int int_tab[] = { 15,14,11,10 };
  7253. +    int loop, tmp;
  7254. +
  7255. +    DEB(printk("in2000_detect: \n"));
  7256. +    
  7257. +    for ( loop=0; loop < 4; loop++ )
  7258. +    {
  7259. +    base = base_tab[loop];
  7260. +    if ( in2000_test_port(loop))  break;
  7261. +    }
  7262. +    if ( loop == 4 )
  7263. +    return 0;
  7264. +
  7265. +  /* Read the dip switch values again for miscellaneous checking and
  7266. +     informative messages */
  7267. +  tmp = inb(INFLED);
  7268. +
  7269. +  /* Bit 2 tells us if interrupts are disabled */
  7270. +  if ( (tmp & 0x4) == 0 ) {
  7271. +    printk("The IN-2000 is not configured for interrupt operation\n");
  7272. +    printk("Change the DIP switch settings to enable interrupt operation\n");
  7273. +  }
  7274. +
  7275. +  /* Bit 6 tells us about floppy controller */
  7276. +  printk("IN-2000 probe found floppy controller on IN-2000 ");
  7277. +  if ( (tmp & 0x40) == 0)
  7278. +    printk("enabled\n");
  7279. +  else
  7280. +    printk("disabled\n");
  7281. +
  7282. +  /* Bit 5 tells us about synch/asynch mode */
  7283. +  printk("IN-2000 probe found IN-2000 in ");
  7284. +  if ( (tmp & 0x20) == 0)
  7285. +    printk("synchronous mode\n");
  7286. +  else
  7287. +    printk("asynchronous mode\n");
  7288. +
  7289. +    irq_level = int_tab [ ((~inb(INFLED)>>3)&0x3) ];
  7290. +
  7291. +    printk("Configuring IN2000 at IO:%x, IRQ %d"
  7292. +#ifdef FAST_FIFO_IO
  7293. +        " (using fast FIFO I/O code)"
  7294. +#endif
  7295. +        "\n",base, irq_level);
  7296. +
  7297. +    outb(2,ININTR);    /* Shut off the FIFO first, so it won't ask for data.*/
  7298. +    if (request_irq(irq_level, in2000_intr_handle, SA_INTERRUPT, "IN2000"))
  7299. +    {
  7300. +    printk("in2000_detect: Unable to allocate IRQ.\n");
  7301. +    return 0;
  7302. +    }
  7303. +    outb(0,INFWRT);    /* read mode so WD can intrpt */
  7304. +    outb(SCSIST,INSTAT);
  7305. +    inb(INDATA);    /* free status reg, clear WD intrpt */
  7306. +    outb(OWNID,INSTAT);
  7307. +    outb(0x7,INDATA);    /* we use addr 7 */
  7308. +    outb(COMMAND,INSTAT);
  7309. +    outb(0,INDATA);    /* do chip reset */
  7310. +    return 1;
  7311. +}
  7312. +
  7313. +int in2000_abort(Scsi_Cmnd * SCpnt, int i)
  7314. +{
  7315. +    DEB(printk("in2000_abort\n"));
  7316. +    /*
  7317. +     * Ask no stupid questions, just order the abort.
  7318. +     */
  7319. +    outb(COMMAND,INSTAT);
  7320. +    outb(1,INDATA);    /* Abort Command */
  7321. +    return 0;
  7322. +}
  7323. +
  7324. +static inline void delay( unsigned how_long )
  7325. +{
  7326. +    unsigned long time = jiffies + how_long;
  7327. +    while (jiffies < time) ;
  7328. +}
  7329. +
  7330. +int in2000_reset(Scsi_Cmnd * SCpnt)
  7331. +{
  7332. +    DEB(printk("in2000_reset called\n"));
  7333. +    /*
  7334. +     * Note: this is finished off by an incoming interrupt
  7335. +     */
  7336. +    outb(0,INFWRT);    /* read mode so WD can intrpt */
  7337. +    outb(SCSIST,INSTAT);
  7338. +    inb(INDATA);
  7339. +    outb(OWNID,INSTAT);
  7340. +    outb(0x7,INDATA);    /* ID=7,noadv, no parity, clk div=2 (8-10Mhz clk) */
  7341. +    outb(COMMAND,INSTAT);
  7342. +    outb(0,INDATA);    /* reset WD chip */
  7343. +    delay(2);
  7344. +#ifdef SCSI_RESET_PENDING
  7345. +    return SCSI_RESET_PENDING;
  7346. +#else
  7347. +    if(SCpnt) SCpnt->flags |= NEEDS_JUMPSTART;
  7348. +    return 0;
  7349. +#endif
  7350. +}
  7351. +
  7352. +int in2000_biosparam(int size, int dev, int* iinfo)
  7353. +    {
  7354. +    DEB(printk("in2000_biosparam\n"));
  7355. +    iinfo[0] = 64;
  7356. +    iinfo[1] = 32;
  7357. +    iinfo[2] = size >> 11;
  7358. +    return 0;
  7359. +    }
  7360. +
  7361. diff -u --recursive --new-file linux-1.1.58/drivers/scsi/in2000.h linux/drivers/scsi/in2000.h
  7362. --- linux-1.1.58/drivers/scsi/in2000.h    Wed Dec 31 18:00:00 1969
  7363. +++ linux/drivers/scsi/in2000.h    Wed Oct 26 23:02:02 1994
  7364. @@ -0,0 +1,124 @@
  7365. +#ifndef _IN2000_H
  7366. +
  7367. +/* $Id: in2000.h,v 1.1 1994/03/14 06:27:38 root Exp root $
  7368. + *
  7369. + * Header file for the Always IN 2000 driver for Linux
  7370. + *
  7371. + */
  7372. +
  7373. +#include <linux/types.h>
  7374. +
  7375. +/* The IN-2000 is based on a WD33C93 */
  7376. +
  7377. +#define    INSTAT    (base + 0x0)    /* R: Auxiliary Status; W: register select */
  7378. +#define    INDATA    (base + 0x1)    /* R/W: Data port */
  7379. +#define    INFIFO    (base + 0x2)    /* R/W FIFO, Word access only */
  7380. +#define    INREST    (base + 0x3)    /* W: Reset everything */
  7381. +#define    INFCNT    (base + 0x4)    /* R: FIFO byte count */
  7382. +#define    INFRST    (base + 0x5)    /* W: Reset Fifo count and to write */
  7383. +#define    INFWRT    (base + 0x7)    /* W: Set FIFO to read */
  7384. +#define    INFLED    (base + 0x8)    /* W: Set LED; R: Dip Switch settings */
  7385. +#define    INNLED    (base + 0x9)    /* W: reset LED */
  7386. +#define    INVERS    (base + 0xa)    /* R: Read hw version, end-reset */
  7387. +#define    ININTR    (base + 0xc)    /* W: Interrupt Mask Port */
  7388. +#define G2CNTRL_HRDY    0x20        /* Sets HOST ready */
  7389. +
  7390. +/* WD33C93 defines */
  7391. +#define    OWNID    0
  7392. +#define    CONTROL    1
  7393. +#define    TIMEOUT    2
  7394. +#define    TOTSECT    3
  7395. +#define    TOTHEAD    4
  7396. +#define    TOTCYLH 5
  7397. +#define    TOTCYLL    6
  7398. +#define    LADRSHH    7
  7399. +#define    LADRSHL    8
  7400. +#define    LADRSLH    9
  7401. +#define    LADRSLL    10
  7402. +#define    SECTNUM    11
  7403. +#define    HEADNUM    12
  7404. +#define    CYLNUMH    13
  7405. +#define    CYLNUML    14
  7406. +#define    TARGETU    15
  7407. +#define    CMDPHAS    16
  7408. +#define    SYNCTXR    17
  7409. +#define    TXCNTH    18
  7410. +#define    TXCNTM    19
  7411. +#define TXCNTL    20
  7412. +#define DESTID    21
  7413. +#define    SRCID    22
  7414. +#define    SCSIST    23
  7415. +#define    COMMAND    24
  7416. +#define    WDDATA    25
  7417. +#define    AUXSTAT    31
  7418. +
  7419. +/* OWNID Register Bits */
  7420. +#define    OWN_EAF    0x08
  7421. +#define    OWN_EHP    0x10
  7422. +#define    OWN_FS0    0x40
  7423. +#define    OWN_FS1    0x80
  7424. +/* AUX Register Bits */
  7425. +#define    AUX_DBR    0
  7426. +#define    AUX_PE    1
  7427. +#define    AUX_CIP    0x10
  7428. +#define    AUX_BSY    0x20
  7429. +#define    AUX_LCI    0x40
  7430. +#define    AUX_INT    0x80
  7431. +
  7432. +/* Select timeout const, 1 count = 8ms */
  7433. +#define IN2000_TMOUT 0x1f
  7434. +
  7435. +#if 0
  7436. +/* This is used with scatter-gather */
  7437. +struct in2000_chain {
  7438. +  ulong  dataptr;        /* Location of data */
  7439. +  ulong  datalen;        /* Size of this part of chain */
  7440. +};
  7441. +#endif
  7442. +
  7443. +/* These belong in scsi.h also */
  7444. +#define any2scsi(up, p)                \
  7445. +(up)[0] = (((unsigned long)(p)) >> 16);        \
  7446. +(up)[1] = (((unsigned long)(p)) >> 8);        \
  7447. +(up)[2] = ((unsigned long)(p));
  7448. +
  7449. +#define scsi2int(up) ( ((((long)*(up))&0x1f) << 16) + (((long)(up)[1]) << 8) + ((long)(up)[2]) )
  7450. +
  7451. +#define xany2scsi(up, p)    \
  7452. +(up)[0] = ((long)(p)) >> 24;    \
  7453. +(up)[1] = ((long)(p)) >> 16;    \
  7454. +(up)[2] = ((long)(p)) >> 8;    \
  7455. +(up)[3] = ((long)(p));
  7456. +
  7457. +#define xscsi2int(up) ( (((long)(up)[0]) << 24) + (((long)(up)[1]) << 16) \
  7458. +              + (((long)(up)[2]) <<  8) +  ((long)(up)[3]) )
  7459. +
  7460. +#define MAX_CDB 12
  7461. +#define MAX_SENSE 14
  7462. +#define MAX_STATUS 32
  7463. +
  7464. +int in2000_detect(Scsi_Host_Template *);
  7465. +int in2000_command(Scsi_Cmnd *);
  7466. +int in2000_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
  7467. +int in2000_abort(Scsi_Cmnd *, int);
  7468. +const char *in2000_info(void);
  7469. +int in2000_reset(Scsi_Cmnd *);
  7470. +int in2000_biosparam(int, int, int*);
  7471. +
  7472. +
  7473. +#ifndef NULL
  7474. +    #define NULL 0
  7475. +#endif
  7476. +
  7477. +/* next may be "SG_NONE" or "SG_ALL" or nr. of (1k) blocks per R/W Cmd. */
  7478. +#define IN2000_SG SG_ALL
  7479. +#define IN2000 {NULL, "Always IN2000", in2000_detect, NULL,    \
  7480. +        in2000_info, in2000_command,    \
  7481. +        in2000_queuecommand,        \
  7482. +        in2000_abort,            \
  7483. +        in2000_reset,            \
  7484. +            NULL,                        \
  7485. +        in2000_biosparam,               \
  7486. +        1, 7, IN2000_SG, 1, 0, 0}
  7487. +
  7488. +#endif
  7489. diff -u --recursive --new-file linux-1.1.58/drivers/sound/local.h linux/drivers/sound/local.h
  7490. --- linux-1.1.58/drivers/sound/local.h    Wed Dec 31 18:00:00 1969
  7491. +++ linux/drivers/sound/local.h    Wed Oct 26 23:02:02 1994
  7492. @@ -0,0 +1,9 @@
  7493. +/*    Generated by configure. Don't edit!!!!    */
  7494. +
  7495. +#undef CONFIGURE_SOUNDCARD
  7496. +#undef KERNEL_SOUNDCARD
  7497. +#define SOUND_VERSION_STRING "2.90-2"
  7498. +#define SOUND_CONFIG_DATE "Wed Oct 12 19:29:11 CDT 1994"
  7499. +#define SOUND_CONFIG_BY "root"
  7500. +#define SOUND_CONFIG_HOST "fuzzy"
  7501. +#define SOUND_CONFIG_DOMAIN ""
  7502. diff -u --recursive --new-file linux-1.1.58/eata.lsm linux/eata.lsm
  7503. --- linux-1.1.58/eata.lsm    Wed Dec 31 18:00:00 1969
  7504. +++ linux/eata.lsm    Wed Oct 26 23:02:02 1994
  7505. @@ -0,0 +1,29 @@
  7506. +Begin2
  7507. +Title        = EATA SCSI driver (DPT/NEC/AT&T)
  7508. +Version      = 0.3a
  7509. +Desc1        = Lowlevel device driver for all EATA compliant ISA and EISA 
  7510. +Desc2        = SCSI controllers
  7511. +Desc3        = Supported controllers are DPT PM2011, PM2012A, PM2012B
  7512. +Desc4        = PM2021, PM2022, PM2122, PM2322 and some OEMs from NEC and AT&T
  7513. +Author       = Michael Neuffer
  7514. +AuthorEmail  = Michael_Neuffer@wi2.maus.de, neuffer@goofy.zdv.uni-mainz.de
  7515. +Maintainer   = Michael Neuffer
  7516. +MaintEmail   = Michael_Neuffer@wi2.maus.de, neuffer@goofy.zdv.uni-mainz.de
  7517. +Site1        = tsx-11.mit.edu
  7518. +Path1        = /pub/linux/ALPHA/scsi/
  7519. +File1        = dpt_eata3a.tgz
  7520. +Site2        = sunsite.unc.edu
  7521. +Path2        = /pub/Linux/ALPHA/scsi
  7522. +File2        = dpt_eata03a.tgz
  7523. +Site3        = ftp.uni-mainz.de
  7524. +Path3        = /pub/Linux/Driver/SCSI
  7525. +File3        = dpt_eata03a.tgz
  7526. +Required1    = EATA compilant controller, Linux 1.1.51
  7527. +CopyPolicy1  = Code copyrighted be Michael Neuffer
  7528. +CopyPolicy2  = GNU Copyleft
  7529. +Keywords     = SCSI EATA DPT PM2011 PM2012A PM2012B PM2021 PM2022 PM2122 PM2322 NEC AT&T
  7530. +RelFiles1    = Slackboot_eata.gz Linux 1.1.51 Slackware bootdisk, kernel with many enabled features
  7531. +Entered      = 15AUG94
  7532. +EnteredBy    = Michael Neuffer
  7533. +End
  7534. +
  7535. diff -u --recursive --new-file linux-1.1.58/include/linux/sonycd535.h linux/include/linux/sonycd535.h
  7536. --- linux-1.1.58/include/linux/sonycd535.h    Wed Dec 31 18:00:00 1969
  7537. +++ linux/include/linux/sonycd535.h    Wed Oct 26 23:02:02 1994
  7538. @@ -0,0 +1,183 @@
  7539. +#ifndef SONYCD535_H
  7540. +#define SONYCD535_H
  7541. +
  7542. +/*
  7543. + * define all the commands recognized by the CDU-531/5
  7544. + */
  7545. +#define SONY535_REQUEST_DRIVE_STATUS_1        (0x80)
  7546. +#define SONY535_REQUEST_SENSE            (0x82)
  7547. +#define SONY535_REQUEST_DRIVE_STATUS_2        (0x84)
  7548. +#define SONY535_REQUEST_ERROR_STATUS        (0x86)
  7549. +#define SONY535_REQUEST_AUDIO_STATUS        (0x88)
  7550. +#define SONY535_INQUIRY                (0x8a)
  7551. +
  7552. +#define SONY535_SET_INACTIVITY_TIME        (0x90)
  7553. +
  7554. +#define SONY535_SEEK_AND_READ_N_BLOCKS_1    (0xa0)
  7555. +#define SONY535_SEEK_AND_READ_N_BLOCKS_2    (0xa4)
  7556. +#define SONY535_PLAY_AUDIO            (0xa6)
  7557. +
  7558. +#define SONY535_REQUEST_DISC_CAPACITY        (0xb0)
  7559. +#define SONY535_REQUEST_TOC_DATA        (0xb2)
  7560. +#define SONY535_REQUEST_SUB_Q_DATA        (0xb4)
  7561. +#define SONY535_REQUEST_ISRC            (0xb6)
  7562. +#define SONY535_REQUEST_UPC_EAN            (0xb8)
  7563. +
  7564. +#define SONY535_SET_DRIVE_MODE            (0xc0)
  7565. +#define SONY535_REQUEST_DRIVE_MODE        (0xc2)
  7566. +#define SONY535_SET_RETRY_COUNT            (0xc4)
  7567. +
  7568. +#define SONY535_DIAGNOSTIC_1            (0xc6)
  7569. +#define SONY535_DIAGNOSTIC_4            (0xcc)
  7570. +#define SONY535_DIAGNOSTIC_5            (0xce)
  7571. +
  7572. +#define SONY535_EJECT_CADDY            (0xd0)
  7573. +#define SONY535_DISABLE_EJECT_BUTTON        (0xd2)
  7574. +#define SONY535_ENABLE_EJECT_BUTTON        (0xd4)
  7575. +
  7576. +#define SONY535_HOLD                (0xe0)
  7577. +#define SONY535_AUDIO_PAUSE_ON_OFF        (0xe2)
  7578. +#define SONY535_SET_VOLUME            (0xe8)
  7579. +
  7580. +#define SONY535_STOP                (0xf0)
  7581. +#define SONY535_SPIN_UP                (0xf2)
  7582. +#define SONY535_SPIN_DOWN            (0xf4)
  7583. +
  7584. +#define SONY535_CLEAR_PARAMETERS        (0xf6)
  7585. +#define SONY535_CLEAR_ENDING_ADDRESS        (0xf8)
  7586. +
  7587. +/*
  7588. + * define some masks
  7589. + */
  7590. +#define SONY535_DATA_NOT_READY_BIT        (0x1)
  7591. +#define SONY535_RESULT_NOT_READY_BIT        (0x2)
  7592. +
  7593. +/*
  7594. + *  drive status 1
  7595. + */
  7596. +#define SONY535_STATUS1_COMMAND_ERROR        (0x1)
  7597. +#define SONY535_STATUS1_DATA_ERROR        (0x2)
  7598. +#define SONY535_STATUS1_SEEK_ERROR        (0x4)
  7599. +#define SONY535_STATUS1_DISC_TYPE_ERROR        (0x8)
  7600. +#define SONY535_STATUS1_NOT_SPINNING        (0x10)
  7601. +#define SONY535_STATUS1_EJECT_BUTTON_PRESSED    (0x20)
  7602. +#define SONY535_STATUS1_CADDY_NOT_INSERTED    (0x40)
  7603. +#define SONY535_STATUS1_BYTE_TWO_FOLLOWS    (0x80)
  7604. +
  7605. +/*
  7606. + * drive status 2
  7607. + */
  7608. +#define SONY535_CDD_LOADING_ERROR        (0x7)
  7609. +#define SONY535_CDD_NO_DISC            (0x8)
  7610. +#define SONY535_CDD_UNLOADING_ERROR        (0x9)
  7611. +#define SONY535_CDD_CADDY_NOT_INSERTED        (0xd)
  7612. +#define SONY535_ATN_RESET_OCCURRED        (0x2)
  7613. +#define SONY535_ATN_DISC_CHANGED        (0x4)
  7614. +#define SONY535_ATN_RESET_AND_DISC_CHANGED    (0x6)
  7615. +#define SONY535_ATN_EJECT_IN_PROGRESS        (0xe)
  7616. +#define SONY535_ATN_BUSY            (0xf)
  7617. +
  7618. +/*
  7619. + * define some parameters
  7620. + */
  7621. +#define SONY535_AUDIO_DRIVE_MODE        (0)
  7622. +#define SONY535_CDROM_DRIVE_MODE        (0xe0)
  7623. +
  7624. +#define SONY535_PLAY_OP_PLAYBACK        (0)
  7625. +#define SONY535_PLAY_OP_ENTER_HOLD        (1)
  7626. +#define SONY535_PLAY_OP_SET_AUDIO_ENDING_ADDR    (2)
  7627. +#define SONY535_PLAY_OP_SCAN_FORWARD        (3)
  7628. +#define SONY535_PLAY_OP_SCAN_BACKWARD        (4)
  7629. +
  7630. +/*
  7631. + *  convert from msf format to block number 
  7632. + */
  7633. +#define SONY_BLOCK_NUMBER(m,s,f) (((m)*60L+(s))*75L+(f))
  7634. +#define SONY_BLOCK_NUMBER_MSF(x) (((x)[0]*60L+(x)[1])*75L+(x)[2])
  7635. +
  7636. +/*
  7637. + *  error return values from the doSonyCmd() routines
  7638. + */
  7639. +#define TIME_OUT            (-1)
  7640. +#define NO_CDROM            (-2)
  7641. +#define BAD_STATUS            (-3)
  7642. +#define CD_BUSY                (-4)
  7643. +#define NOT_DATA_CD            (-5)
  7644. +#define NO_ROOM                (-6)
  7645. +
  7646. +#define LOG_START_OFFSET        150     /* Offset of first logical sector */
  7647. +
  7648. +#define SONY_JIFFIES_TIMEOUT            500  /* Maximum number of jiffies (10ms)
  7649. +                                                  the drive will wait/try for an
  7650. +                                                  operation */
  7651. +#define SONY_READY_RETRIES      (50000)  /* How many times to retry a
  7652. +                                                  spin waiting for a register
  7653. +                                                  to come ready */
  7654. +#define SONY535_FAST_POLLS    (10000)   /* how many times recheck 
  7655. +                                                  status waiting for a data
  7656. +                                                  to become ready */
  7657. +
  7658. +typedef unsigned char Byte;
  7659. +
  7660. +/*
  7661. + * This is the complete status returned from the drive configuration request
  7662. + * command.
  7663. + */
  7664. +struct s535_sony_drive_config
  7665. +{
  7666. +   char vendor_id[8];
  7667. +   char product_id[16];
  7668. +   char product_rev_level[4];
  7669. +};
  7670. +
  7671. +/* The following is returned from the request sub-q data command */
  7672. +struct s535_sony_subcode
  7673. +{
  7674. +   unsigned char address        :4;
  7675. +   unsigned char control        :4;
  7676. +   unsigned char track_num;
  7677. +   unsigned char index_num;
  7678. +   unsigned char rel_msf[3];
  7679. +   unsigned char abs_msf[3];
  7680. +};
  7681. +
  7682. +struct s535_sony_disc_capacity
  7683. +{
  7684. +   Byte mFirstTrack, sFirstTrack, fFirstTrack;
  7685. +   Byte mLeadOut, sLeadOut, fLeadOut;
  7686. +};
  7687. +
  7688. +/*
  7689. + * The following is returned from the request TOC (Table Of Contents) command.
  7690. + * (last_track_num-first_track_num+1) values are valid in tracks.
  7691. + */
  7692. +struct s535_sony_toc
  7693. +{
  7694. +   unsigned char reserved0      :4;
  7695. +   unsigned char control0       :4;
  7696. +   unsigned char point0;
  7697. +   unsigned char first_track_num;
  7698. +   unsigned char reserved0a;
  7699. +   unsigned char reserved0b;
  7700. +   unsigned char reserved1      :4;
  7701. +   unsigned char control1       :4;
  7702. +   unsigned char point1;
  7703. +   unsigned char last_track_num;
  7704. +   unsigned char dummy1;
  7705. +   unsigned char dummy2;
  7706. +   unsigned char reserved2      :4;
  7707. +   unsigned char control2       :4;
  7708. +   unsigned char point2;
  7709. +   unsigned char lead_out_start_msf[3];
  7710. +   struct
  7711. +   {
  7712. +      unsigned char reserved    :4;
  7713. +      unsigned char control     :4;
  7714. +      unsigned char track;
  7715. +      unsigned char track_start_msf[3];
  7716. +   } tracks[100];
  7717. +
  7718. +   unsigned int lead_out_start_lba;
  7719. +};
  7720. +
  7721. +#endif /* SONYCD535_H */
  7722. diff -u --recursive --new-file linux-1.1.58/kernel/ksyms.c linux/kernel/ksyms.c
  7723. --- linux-1.1.58/kernel/ksyms.c    Mon Oct 24 17:43:34 1994
  7724. +++ linux/kernel/ksyms.c    Wed Oct 26 23:04:07 1994
  7725. @@ -53,6 +53,15 @@
  7726.  
  7727.  extern void (* iABI_hook)(struct pt_regs * regs);
  7728.  
  7729. +#ifdef CONFIG_NEC260
  7730. +#include <linux/sched.h>
  7731. +extern int the_nec260_major;
  7732. +extern void (*do_hd) (void);
  7733. +#ifdef CONFIG_BLK_DEV_HD1
  7734. +extern void (*do_hd1) (void);
  7735. +#endif
  7736. +#endif
  7737. +
  7738.  struct symbol_table symbol_table = { 0, 0, 0, /* for stacked module support */
  7739.      {
  7740.      /* stackable module support */
  7741. @@ -199,6 +208,19 @@
  7742.      X(dev_queue_xmit),
  7743.      X(dev_base),
  7744.  #endif
  7745. +#ifdef CONFIG_NEC260
  7746. +    /* for the nec cdr-260 cdrom drive */
  7747. +    X (the_nec260_major),
  7748. +    X (do_hd),
  7749. +    X (read_ahead),
  7750. +    X (sync_dev),
  7751. +    X (invalidate_buffers),
  7752. +    X (__down),
  7753. +#ifdef CONFIG_BLK_DEV_HD1
  7754. +    X (do_hd1),
  7755. +#endif
  7756. +#endif
  7757. +
  7758.  
  7759.      /********************************************************
  7760.       * Do not add anything below this line,
  7761. diff -u --recursive --new-file linux-1.1.58/patch.eata linux/patch.eata
  7762. --- linux-1.1.58/patch.eata    Wed Dec 31 18:00:00 1969
  7763. +++ linux/patch.eata    Wed Oct 26 23:02:02 1994
  7764. @@ -0,0 +1,50 @@
  7765. +diff -u --recursive --new-file linux50/config.in linux/config.in
  7766. +--- config.old  Tue Sep 27 17:54:13 1994
  7767. ++++ config.in   Tue Sep 27 17:53:40 1994
  7768. +@@ -51,6 +51,7 @@
  7769. + bool 'Adaptec AHA1542 support' CONFIG_SCSI_AHA1542 n
  7770. + bool 'Adaptec AHA1740 support' CONFIG_SCSI_AHA1740 n
  7771. + bool 'BusLogic SCSI support' CONFIG_SCSI_BUSLOGIC n
  7772. ++bool 'EATA-DMA (rev. 2.0b) (DPT,NEC,AT&T) support' CONFIG_SCSI_EATA y
  7773. + bool 'Future Domain 16xx SCSI support' CONFIG_SCSI_FUTURE_DOMAIN n
  7774. + bool 'Generic NCR5380 SCSI support' CONFIG_SCSI_GENERIC_NCR5380 n
  7775. + bool 'NCR53c7,8xx SCSI support'  CONFIG_SCSI_NCR53C7xx n
  7776. +diff -u --recursive --new-file linux50/drivers/scsi/Makefile linux/drivers/scsi/Makefile
  7777. +--- linux50/drivers/scsi/Makefile    Tue Sep 27 18:02:02 1994
  7778. ++++ linux/drivers/scsi/Makefile    Thu Sep  8 23:23:19 1994
  7779. +@@ -72,6 +72,11 @@
  7780. + SCSI_SRCS := $(SCSI_SRCS) scsi_debug.c
  7781. + endif
  7782. ++ifdef CONFIG_SCSI_EATA
  7783. ++SCSI_OBJS := $(SCSI_OBJS) eata.o
  7784. ++SCSI_SRCS := $(SCSI_SRCS) eata.c
  7785. ++endif
  7786. ++
  7787. + ifdef CONFIG_SCSI_FUTURE_DOMAIN
  7788. + SCSI_OBJS := $(SCSI_OBJS) fdomain.o
  7789. + SCSI_SRCS := $(SCSI_SRCS) fdomain.c
  7790. +diff -u --recursive --new-file linux50/drivers/scsi/hosts.c linux/drivers/scsi/hosts.c
  7791. +--- linux50/drivers/scsi/hosts.c    Tue Sep 27 18:03:15 1994
  7792. ++++ linux/drivers/scsi/hosts.c    Thu Sep  8 23:23:19 1994
  7793. +@@ -43,6 +43,10 @@
  7794. + #include "buslogic.h"
  7795. + #endif
  7796. ++#ifdef CONFIG_SCSI_EATA            
  7797. ++#include "eata.h"
  7798. ++#endif
  7799. ++
  7800. + #ifdef CONFIG_SCSI_FUTURE_DOMAIN
  7801. + #include "fdomain.h"
  7802. + #endif
  7803. +@@ -131,6 +135,9 @@
  7804. + #ifdef CONFIG_SCSI_AHA1740
  7805. +     AHA1740,
  7806. + #endif
  7807. ++#ifdef CONFIG_SCSI_EATA 
  7808. ++        EATA,
  7809. ++#endif
  7810. + #ifdef CONFIG_SCSI_FUTURE_DOMAIN
  7811. +     FDOMAIN_16X0,
  7812. + #endif
  7813. diff -u --recursive --new-file linux-1.1.58/tools/version.h linux/tools/version.h
  7814. --- linux-1.1.58/tools/version.h    Wed Dec 31 18:00:00 1969
  7815. +++ linux/tools/version.h    Wed Oct 26 23:02:02 1994
  7816. @@ -0,0 +1,7 @@
  7817. +#define UTS_RELEASE "1.1.53"
  7818. +#define UTS_VERSION "#8 Wed Oct 12 21:48:39 CDT 1994"
  7819. +#define LINUX_COMPILE_TIME "21:48:39"
  7820. +#define LINUX_COMPILE_BY "root"
  7821. +#define LINUX_COMPILE_HOST "fuzzy"
  7822. +#define LINUX_COMPILE_DOMAIN "is.a.good.cat"
  7823. +#define LINUX_COMPILER "gcc version 2.5.8"
  7824.