psi240i.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /*+M*************************************************************************
  2. * Perceptive Solutions, Inc. PSI-240I device driver proc support for Linux.
  3. *
  4. * Copyright (c) 1997 Perceptive Solutions, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; see the file COPYING. If not, write to
  18. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. *
  21. * File Name: psi240i.h
  22. *
  23. * Description: Header file for the SCSI driver for the PSI240I
  24. * EIDE interface card.
  25. *
  26. *-M*************************************************************************/
  27. #ifndef _PSI240I_H
  28. #define _PSI240I_H
  29. #include <linux/types.h>
  30. #ifndef PSI_EIDE_SCSIOP
  31. #define PSI_EIDE_SCSIOP 1
  32. /************************************************/
  33. /* Some defines that we like */
  34. /************************************************/
  35. #define CHAR char
  36. #define UCHAR unsigned char
  37. #define SHORT short
  38. #define USHORT unsigned short
  39. #define BOOL unsigned short
  40. #define LONG long
  41. #define ULONG unsigned long
  42. #define VOID void
  43. /************************************************/
  44. /* Timeout konstants */
  45. /************************************************/
  46. #define TIMEOUT_READY 10 // 100 mSec
  47. #define TIMEOUT_DRQ 40 // 400 mSec
  48. /************************************************/
  49. /* Misc. macros */
  50. /************************************************/
  51. #define ANY2SCSI(up, p) \
  52. ((UCHAR *)up)[0] = (((ULONG)(p)) >> 8); \
  53. ((UCHAR *)up)[1] = ((ULONG)(p));
  54. #define SCSI2LONG(up) \
  55. ( (((long)*(((UCHAR *)up))) << 16) \
  56. + (((long)(((UCHAR *)up)[1])) << 8) \
  57. + ((long)(((UCHAR *)up)[2])) )
  58. #define XANY2SCSI(up, p) \
  59. ((UCHAR *)up)[0] = ((long)(p)) >> 24; \
  60. ((UCHAR *)up)[1] = ((long)(p)) >> 16; \
  61. ((UCHAR *)up)[2] = ((long)(p)) >> 8; \
  62. ((UCHAR *)up)[3] = ((long)(p));
  63. #define XSCSI2LONG(up) \
  64. ( (((long)(((UCHAR *)up)[0])) << 24) \
  65. + (((long)(((UCHAR *)up)[1])) << 16) \
  66. + (((long)(((UCHAR *)up)[2])) << 8) \
  67. + ((long)(((UCHAR *)up)[3])) )
  68. /************************************************/
  69. /* SCSI CDB operation codes */
  70. /************************************************/
  71. #define SCSIOP_TEST_UNIT_READY 0x00
  72. #define SCSIOP_REZERO_UNIT 0x01
  73. #define SCSIOP_REWIND 0x01
  74. #define SCSIOP_REQUEST_BLOCK_ADDR 0x02
  75. #define SCSIOP_REQUEST_SENSE 0x03
  76. #define SCSIOP_FORMAT_UNIT 0x04
  77. #define SCSIOP_READ_BLOCK_LIMITS 0x05
  78. #define SCSIOP_REASSIGN_BLOCKS 0x07
  79. #define SCSIOP_READ6 0x08
  80. #define SCSIOP_RECEIVE 0x08
  81. #define SCSIOP_WRITE6 0x0A
  82. #define SCSIOP_PRINT 0x0A
  83. #define SCSIOP_SEND 0x0A
  84. #define SCSIOP_SEEK6 0x0B
  85. #define SCSIOP_TRACK_SELECT 0x0B
  86. #define SCSIOP_SLEW_PRINT 0x0B
  87. #define SCSIOP_SEEK_BLOCK 0x0C
  88. #define SCSIOP_PARTITION 0x0D
  89. #define SCSIOP_READ_REVERSE 0x0F
  90. #define SCSIOP_WRITE_FILEMARKS 0x10
  91. #define SCSIOP_FLUSH_BUFFER 0x10
  92. #define SCSIOP_SPACE 0x11
  93. #define SCSIOP_INQUIRY 0x12
  94. #define SCSIOP_VERIFY6 0x13
  95. #define SCSIOP_RECOVER_BUF_DATA 0x14
  96. #define SCSIOP_MODE_SELECT 0x15
  97. #define SCSIOP_RESERVE_UNIT 0x16
  98. #define SCSIOP_RELEASE_UNIT 0x17
  99. #define SCSIOP_COPY 0x18
  100. #define SCSIOP_ERASE 0x19
  101. #define SCSIOP_MODE_SENSE 0x1A
  102. #define SCSIOP_START_STOP_UNIT 0x1B
  103. #define SCSIOP_STOP_PRINT 0x1B
  104. #define SCSIOP_LOAD_UNLOAD 0x1B
  105. #define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
  106. #define SCSIOP_SEND_DIAGNOSTIC 0x1D
  107. #define SCSIOP_MEDIUM_REMOVAL 0x1E
  108. #define SCSIOP_READ_CAPACITY 0x25
  109. #define SCSIOP_READ 0x28
  110. #define SCSIOP_WRITE 0x2A
  111. #define SCSIOP_SEEK 0x2B
  112. #define SCSIOP_LOCATE 0x2B
  113. #define SCSIOP_WRITE_VERIFY 0x2E
  114. #define SCSIOP_VERIFY 0x2F
  115. #define SCSIOP_SEARCH_DATA_HIGH 0x30
  116. #define SCSIOP_SEARCH_DATA_EQUAL 0x31
  117. #define SCSIOP_SEARCH_DATA_LOW 0x32
  118. #define SCSIOP_SET_LIMITS 0x33
  119. #define SCSIOP_READ_POSITION 0x34
  120. #define SCSIOP_SYNCHRONIZE_CACHE 0x35
  121. #define SCSIOP_COMPARE 0x39
  122. #define SCSIOP_COPY_COMPARE 0x3A
  123. #define SCSIOP_WRITE_DATA_BUFF 0x3B
  124. #define SCSIOP_READ_DATA_BUFF 0x3C
  125. #define SCSIOP_CHANGE_DEFINITION 0x40
  126. #define SCSIOP_READ_SUB_CHANNEL 0x42
  127. #define SCSIOP_READ_TOC 0x43
  128. #define SCSIOP_READ_HEADER 0x44
  129. #define SCSIOP_PLAY_AUDIO 0x45
  130. #define SCSIOP_PLAY_AUDIO_MSF 0x47
  131. #define SCSIOP_PLAY_TRACK_INDEX 0x48
  132. #define SCSIOP_PLAY_TRACK_RELATIVE 0x49
  133. #define SCSIOP_PAUSE_RESUME 0x4B
  134. #define SCSIOP_LOG_SELECT 0x4C
  135. #define SCSIOP_LOG_SENSE 0x4D
  136. #define SCSIOP_MODE_SELECT10 0x55
  137. #define SCSIOP_MODE_SENSE10 0x5A
  138. #define SCSIOP_LOAD_UNLOAD_SLOT 0xA6
  139. #define SCSIOP_MECHANISM_STATUS 0xBD
  140. #define SCSIOP_READ_CD 0xBE
  141. // IDE command definitions
  142. #define IDE_COMMAND_ATAPI_RESET 0x08
  143. #define IDE_COMMAND_READ 0x20
  144. #define IDE_COMMAND_WRITE 0x30
  145. #define IDE_COMMAND_RECALIBRATE 0x10
  146. #define IDE_COMMAND_SEEK 0x70
  147. #define IDE_COMMAND_SET_PARAMETERS 0x91
  148. #define IDE_COMMAND_VERIFY 0x40
  149. #define IDE_COMMAND_ATAPI_PACKET 0xA0
  150. #define IDE_COMMAND_ATAPI_IDENTIFY 0xA1
  151. #define IDE_CMD_READ_MULTIPLE 0xC4
  152. #define IDE_CMD_WRITE_MULTIPLE 0xC5
  153. #define IDE_CMD_SET_MULTIPLE 0xC6
  154. #define IDE_COMMAND_WRITE_DMA 0xCA
  155. #define IDE_COMMAND_READ_DMA 0xC8
  156. #define IDE_COMMAND_IDENTIFY 0xEC
  157. // IDE status definitions
  158. #define IDE_STATUS_ERROR 0x01
  159. #define IDE_STATUS_INDEX 0x02
  160. #define IDE_STATUS_CORRECTED_ERROR 0x04
  161. #define IDE_STATUS_DRQ 0x08
  162. #define IDE_STATUS_DSC 0x10
  163. #define IDE_STATUS_WRITE_FAULT 0x20
  164. #define IDE_STATUS_DRDY 0x40
  165. #define IDE_STATUS_BUSY 0x80
  166. // IDE error definitions
  167. #define IDE_ERROR_AMNF 0x01
  168. #define IDE_ERROR_TKONF 0x02
  169. #define IDE_ERROR_ABRT 0x04
  170. #define IDE_ERROR_MCR 0x08
  171. #define IDE_ERROR_IDFN 0x10
  172. #define IDE_ERROR_MC 0x20
  173. #define IDE_ERROR_UNC 0x40
  174. #define IDE_ERROR_BBK 0x80
  175. // IDE interface structure
  176. typedef struct _IDE_STRUCT
  177. {
  178. union
  179. {
  180. UCHAR ide[9];
  181. struct
  182. {
  183. USHORT data;
  184. UCHAR sectors;
  185. UCHAR lba[4];
  186. UCHAR cmd;
  187. UCHAR spigot;
  188. } ides;
  189. } ide;
  190. } IDE_STRUCT;
  191. // SCSI read capacity structure
  192. typedef struct _READ_CAPACITY_DATA
  193. {
  194. ULONG blks; /* total blocks (converted to little endian) */
  195. ULONG blksiz; /* size of each (converted to little endian) */
  196. } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
  197. // SCSI inquiry data
  198. #ifndef HOSTS_C
  199. typedef struct _INQUIRYDATA
  200. {
  201. UCHAR DeviceType :5;
  202. UCHAR DeviceTypeQualifier :3;
  203. UCHAR DeviceTypeModifier :7;
  204. UCHAR RemovableMedia :1;
  205. UCHAR Versions;
  206. UCHAR ResponseDataFormat;
  207. UCHAR AdditionalLength;
  208. UCHAR Reserved[2];
  209. UCHAR SoftReset :1;
  210. UCHAR CommandQueue :1;
  211. UCHAR Reserved2 :1;
  212. UCHAR LinkedCommands :1;
  213. UCHAR Synchronous :1;
  214. UCHAR Wide16Bit :1;
  215. UCHAR Wide32Bit :1;
  216. UCHAR RelativeAddressing :1;
  217. UCHAR VendorId[8];
  218. UCHAR ProductId[16];
  219. UCHAR ProductRevisionLevel[4];
  220. UCHAR VendorSpecific[20];
  221. UCHAR Reserved3[40];
  222. } INQUIRYDATA, *PINQUIRYDATA;
  223. #endif
  224. // IDE IDENTIFY data
  225. typedef struct _IDENTIFY_DATA
  226. {
  227. USHORT GeneralConfiguration; // 00
  228. USHORT NumberOfCylinders; // 02
  229. USHORT Reserved1; // 04
  230. USHORT NumberOfHeads; // 06
  231. USHORT UnformattedBytesPerTrack; // 08
  232. USHORT UnformattedBytesPerSector; // 0A
  233. USHORT SectorsPerTrack; // 0C
  234. USHORT VendorUnique1[3]; // 0E
  235. USHORT SerialNumber[10]; // 14
  236. USHORT BufferType; // 28
  237. USHORT BufferSectorSize; // 2A
  238. USHORT NumberOfEccBytes; // 2C
  239. USHORT FirmwareRevision[4]; // 2E
  240. USHORT ModelNumber[20]; // 36
  241. UCHAR MaximumBlockTransfer; // 5E
  242. UCHAR VendorUnique2; // 5F
  243. USHORT DoubleWordIo; // 60
  244. USHORT Capabilities; // 62
  245. USHORT Reserved2; // 64
  246. UCHAR VendorUnique3; // 66
  247. UCHAR PioCycleTimingMode; // 67
  248. UCHAR VendorUnique4; // 68
  249. UCHAR DmaCycleTimingMode; // 69
  250. USHORT TranslationFieldsValid:1; // 6A
  251. USHORT Reserved3:15;
  252. USHORT NumberOfCurrentCylinders; // 6C
  253. USHORT NumberOfCurrentHeads; // 6E
  254. USHORT CurrentSectorsPerTrack; // 70
  255. ULONG CurrentSectorCapacity; // 72
  256. USHORT Reserved4[197]; // 76
  257. } IDENTIFY_DATA, *PIDENTIFY_DATA;
  258. // Identify data without the Reserved4.
  259. typedef struct _IDENTIFY_DATA2 {
  260. USHORT GeneralConfiguration; // 00
  261. USHORT NumberOfCylinders; // 02
  262. USHORT Reserved1; // 04
  263. USHORT NumberOfHeads; // 06
  264. USHORT UnformattedBytesPerTrack; // 08
  265. USHORT UnformattedBytesPerSector; // 0A
  266. USHORT SectorsPerTrack; // 0C
  267. USHORT VendorUnique1[3]; // 0E
  268. USHORT SerialNumber[10]; // 14
  269. USHORT BufferType; // 28
  270. USHORT BufferSectorSize; // 2A
  271. USHORT NumberOfEccBytes; // 2C
  272. USHORT FirmwareRevision[4]; // 2E
  273. USHORT ModelNumber[20]; // 36
  274. UCHAR MaximumBlockTransfer; // 5E
  275. UCHAR VendorUnique2; // 5F
  276. USHORT DoubleWordIo; // 60
  277. USHORT Capabilities; // 62
  278. USHORT Reserved2; // 64
  279. UCHAR VendorUnique3; // 66
  280. UCHAR PioCycleTimingMode; // 67
  281. UCHAR VendorUnique4; // 68
  282. UCHAR DmaCycleTimingMode; // 69
  283. USHORT TranslationFieldsValid:1; // 6A
  284. USHORT Reserved3:15;
  285. USHORT NumberOfCurrentCylinders; // 6C
  286. USHORT NumberOfCurrentHeads; // 6E
  287. USHORT CurrentSectorsPerTrack; // 70
  288. ULONG CurrentSectorCapacity; // 72
  289. } IDENTIFY_DATA2, *PIDENTIFY_DATA2;
  290. #endif // PSI_EIDE_SCSIOP
  291. // function prototypes
  292. int Psi240i_Command (Scsi_Cmnd *SCpnt);
  293. int Psi240i_Abort (Scsi_Cmnd *SCpnt);
  294. int Psi240i_Reset (Scsi_Cmnd *SCpnt, unsigned int flags);
  295. #endif