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

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