psi240i.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:11k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  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. #include <linux/kdev_t.h>
  31. #ifndef PSI_EIDE_SCSIOP
  32. #define PSI_EIDE_SCSIOP 1
  33. /************************************************/
  34. /* Some defines that we like  */
  35. /************************************************/
  36. #define CHAR char
  37. #define UCHAR unsigned char
  38. #define SHORT short
  39. #define USHORT unsigned short
  40. #define BOOL unsigned short
  41. #define LONG long
  42. #define ULONG unsigned long
  43. #define VOID void
  44. /************************************************/
  45. /* Timeout konstants   */
  46. /************************************************/
  47. #define TIMEOUT_READY 10 // 100 mSec
  48. #define TIMEOUT_DRQ 40 // 400 mSec
  49. /************************************************/
  50. /* Misc. macros   */
  51. /************************************************/
  52. #define ANY2SCSI(up, p)
  53. ((UCHAR *)up)[0] = (((ULONG)(p)) >> 8);
  54. ((UCHAR *)up)[1] = ((ULONG)(p));
  55. #define SCSI2LONG(up)
  56. ( (((long)*(((UCHAR *)up))) << 16)
  57. + (((long)(((UCHAR *)up)[1])) << 8)
  58. + ((long)(((UCHAR *)up)[2])) )
  59. #define XANY2SCSI(up, p)
  60. ((UCHAR *)up)[0] = ((long)(p)) >> 24;
  61. ((UCHAR *)up)[1] = ((long)(p)) >> 16;
  62. ((UCHAR *)up)[2] = ((long)(p)) >> 8;
  63. ((UCHAR *)up)[3] = ((long)(p));
  64. #define XSCSI2LONG(up)
  65. ( (((long)(((UCHAR *)up)[0])) << 24)
  66. + (((long)(((UCHAR *)up)[1])) << 16)
  67. + (((long)(((UCHAR *)up)[2])) <<  8)
  68. + ((long)(((UCHAR *)up)[3])) )
  69. /************************************************/
  70. /* SCSI CDB operation codes  */
  71. /************************************************/
  72. #define SCSIOP_TEST_UNIT_READY 0x00
  73. #define SCSIOP_REZERO_UNIT 0x01
  74. #define SCSIOP_REWIND 0x01
  75. #define SCSIOP_REQUEST_BLOCK_ADDR 0x02
  76. #define SCSIOP_REQUEST_SENSE 0x03
  77. #define SCSIOP_FORMAT_UNIT 0x04
  78. #define SCSIOP_READ_BLOCK_LIMITS 0x05
  79. #define SCSIOP_REASSIGN_BLOCKS 0x07
  80. #define SCSIOP_READ6 0x08
  81. #define SCSIOP_RECEIVE 0x08
  82. #define SCSIOP_WRITE6 0x0A
  83. #define SCSIOP_PRINT 0x0A
  84. #define SCSIOP_SEND 0x0A
  85. #define SCSIOP_SEEK6 0x0B
  86. #define SCSIOP_TRACK_SELECT 0x0B
  87. #define SCSIOP_SLEW_PRINT 0x0B
  88. #define SCSIOP_SEEK_BLOCK 0x0C
  89. #define SCSIOP_PARTITION 0x0D
  90. #define SCSIOP_READ_REVERSE 0x0F
  91. #define SCSIOP_WRITE_FILEMARKS 0x10
  92. #define SCSIOP_FLUSH_BUFFER 0x10
  93. #define SCSIOP_SPACE 0x11
  94. #define SCSIOP_INQUIRY 0x12
  95. #define SCSIOP_VERIFY6 0x13
  96. #define SCSIOP_RECOVER_BUF_DATA 0x14
  97. #define SCSIOP_MODE_SELECT 0x15
  98. #define SCSIOP_RESERVE_UNIT 0x16
  99. #define SCSIOP_RELEASE_UNIT 0x17
  100. #define SCSIOP_COPY 0x18
  101. #define SCSIOP_ERASE 0x19
  102. #define SCSIOP_MODE_SENSE 0x1A
  103. #define SCSIOP_START_STOP_UNIT 0x1B
  104. #define SCSIOP_STOP_PRINT 0x1B
  105. #define SCSIOP_LOAD_UNLOAD 0x1B
  106. #define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
  107. #define SCSIOP_SEND_DIAGNOSTIC 0x1D
  108. #define SCSIOP_MEDIUM_REMOVAL 0x1E
  109. #define SCSIOP_READ_CAPACITY 0x25
  110. #define SCSIOP_READ 0x28
  111. #define SCSIOP_WRITE 0x2A
  112. #define SCSIOP_SEEK 0x2B
  113. #define SCSIOP_LOCATE 0x2B
  114. #define SCSIOP_WRITE_VERIFY 0x2E
  115. #define SCSIOP_VERIFY 0x2F
  116. #define SCSIOP_SEARCH_DATA_HIGH 0x30
  117. #define SCSIOP_SEARCH_DATA_EQUAL 0x31
  118. #define SCSIOP_SEARCH_DATA_LOW 0x32
  119. #define SCSIOP_SET_LIMITS 0x33
  120. #define SCSIOP_READ_POSITION 0x34
  121. #define SCSIOP_SYNCHRONIZE_CACHE 0x35
  122. #define SCSIOP_COMPARE 0x39
  123. #define SCSIOP_COPY_COMPARE 0x3A
  124. #define SCSIOP_WRITE_DATA_BUFF 0x3B
  125. #define SCSIOP_READ_DATA_BUFF 0x3C
  126. #define SCSIOP_CHANGE_DEFINITION 0x40
  127. #define SCSIOP_READ_SUB_CHANNEL 0x42
  128. #define SCSIOP_READ_TOC 0x43
  129. #define SCSIOP_READ_HEADER 0x44
  130. #define SCSIOP_PLAY_AUDIO 0x45
  131. #define SCSIOP_PLAY_AUDIO_MSF 0x47
  132. #define SCSIOP_PLAY_TRACK_INDEX 0x48
  133. #define SCSIOP_PLAY_TRACK_RELATIVE 0x49
  134. #define SCSIOP_PAUSE_RESUME 0x4B
  135. #define SCSIOP_LOG_SELECT 0x4C
  136. #define SCSIOP_LOG_SENSE 0x4D
  137. #define SCSIOP_MODE_SELECT10 0x55
  138. #define SCSIOP_MODE_SENSE10 0x5A
  139. #define SCSIOP_LOAD_UNLOAD_SLOT 0xA6
  140. #define SCSIOP_MECHANISM_STATUS 0xBD
  141. #define SCSIOP_READ_CD 0xBE
  142. // IDE command definitions
  143. #define IDE_COMMAND_ATAPI_RESET 0x08
  144. #define IDE_COMMAND_READ 0x20
  145. #define IDE_COMMAND_WRITE 0x30
  146. #define IDE_COMMAND_RECALIBRATE 0x10
  147. #define IDE_COMMAND_SEEK 0x70
  148. #define IDE_COMMAND_SET_PARAMETERS 0x91
  149. #define IDE_COMMAND_VERIFY 0x40
  150. #define IDE_COMMAND_ATAPI_PACKET 0xA0
  151. #define IDE_COMMAND_ATAPI_IDENTIFY 0xA1
  152. #define IDE_CMD_READ_MULTIPLE 0xC4
  153. #define IDE_CMD_WRITE_MULTIPLE 0xC5
  154. #define IDE_CMD_SET_MULTIPLE 0xC6
  155. #define IDE_COMMAND_WRITE_DMA 0xCA
  156. #define IDE_COMMAND_READ_DMA 0xC8
  157. #define IDE_COMMAND_IDENTIFY 0xEC
  158. // IDE status definitions
  159. #define IDE_STATUS_ERROR 0x01
  160. #define IDE_STATUS_INDEX 0x02
  161. #define IDE_STATUS_CORRECTED_ERROR 0x04
  162. #define IDE_STATUS_DRQ 0x08
  163. #define IDE_STATUS_DSC 0x10
  164. #define IDE_STATUS_WRITE_FAULT 0x20
  165. #define IDE_STATUS_DRDY 0x40
  166. #define IDE_STATUS_BUSY 0x80
  167. // IDE error definitions
  168. #define IDE_ERROR_AMNF 0x01
  169. #define IDE_ERROR_TKONF 0x02
  170. #define IDE_ERROR_ABRT 0x04
  171. #define IDE_ERROR_MCR 0x08
  172. #define IDE_ERROR_IDFN 0x10
  173. #define IDE_ERROR_MC 0x20
  174. #define IDE_ERROR_UNC 0x40
  175. #define IDE_ERROR_BBK 0x80
  176. // IDE interface structure
  177. typedef struct _IDE_STRUCT
  178. {
  179. union
  180. {
  181. UCHAR ide[9];
  182. struct
  183. {
  184. USHORT data;
  185. UCHAR sectors;
  186. UCHAR lba[4];
  187. UCHAR cmd;
  188. UCHAR spigot;
  189. } ides;
  190. } ide;
  191. } IDE_STRUCT;
  192. // SCSI read capacity structure
  193. typedef struct _READ_CAPACITY_DATA
  194. {
  195. ULONG blks; /* total blocks (converted to little endian) */
  196. ULONG blksiz; /* size of each (converted to little endian) */
  197. } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
  198. // SCSI inquiry data
  199. #ifndef HOSTS_C
  200. typedef struct _INQUIRYDATA
  201. {
  202. UCHAR DeviceType :5;
  203. UCHAR DeviceTypeQualifier :3;
  204. UCHAR DeviceTypeModifier :7;
  205. UCHAR RemovableMedia :1;
  206.     UCHAR Versions;
  207.     UCHAR ResponseDataFormat;
  208.     UCHAR AdditionalLength;
  209.     UCHAR Reserved[2];
  210. UCHAR SoftReset :1;
  211. UCHAR CommandQueue :1;
  212. UCHAR Reserved2 :1;
  213. UCHAR LinkedCommands :1;
  214. UCHAR Synchronous :1;
  215. UCHAR Wide16Bit :1;
  216. UCHAR Wide32Bit :1;
  217. UCHAR RelativeAddressing :1;
  218.     UCHAR VendorId[8];
  219.     UCHAR ProductId[16];
  220.     UCHAR ProductRevisionLevel[4];
  221.     UCHAR VendorSpecific[20];
  222.     UCHAR Reserved3[40];
  223. } INQUIRYDATA, *PINQUIRYDATA;
  224. #endif
  225. // IDE IDENTIFY data
  226. typedef struct _IDENTIFY_DATA
  227. {
  228.     USHORT GeneralConfiguration;            // 00
  229.     USHORT NumberOfCylinders;               // 02
  230.     USHORT Reserved1;                       // 04
  231.     USHORT NumberOfHeads;                   // 06
  232.     USHORT UnformattedBytesPerTrack;        // 08
  233.     USHORT UnformattedBytesPerSector;       // 0A
  234.     USHORT SectorsPerTrack;                 // 0C
  235.     USHORT VendorUnique1[3];                // 0E
  236.     USHORT SerialNumber[10];                // 14
  237.     USHORT BufferType;                      // 28
  238.     USHORT BufferSectorSize;                // 2A
  239.     USHORT NumberOfEccBytes;                // 2C
  240.     USHORT FirmwareRevision[4];             // 2E
  241.     USHORT ModelNumber[20];                 // 36
  242.     UCHAR  MaximumBlockTransfer;            // 5E
  243.     UCHAR  VendorUnique2;                   // 5F
  244.     USHORT DoubleWordIo;                    // 60
  245.     USHORT Capabilities;                    // 62
  246.     USHORT Reserved2;                       // 64
  247.     UCHAR  VendorUnique3;                   // 66
  248.     UCHAR  PioCycleTimingMode;              // 67
  249.     UCHAR  VendorUnique4;                   // 68
  250.     UCHAR  DmaCycleTimingMode;              // 69
  251.     USHORT TranslationFieldsValid:1;        // 6A
  252.     USHORT Reserved3:15;
  253.     USHORT NumberOfCurrentCylinders;        // 6C
  254.     USHORT NumberOfCurrentHeads;            // 6E
  255.     USHORT CurrentSectorsPerTrack;          // 70
  256.     ULONG  CurrentSectorCapacity;           // 72
  257.     USHORT Reserved4[197];                  // 76
  258. } IDENTIFY_DATA, *PIDENTIFY_DATA;
  259. // Identify data without the Reserved4.
  260. typedef struct _IDENTIFY_DATA2 {
  261.     USHORT GeneralConfiguration;            // 00
  262.     USHORT NumberOfCylinders;               // 02
  263.     USHORT Reserved1;                       // 04
  264.     USHORT NumberOfHeads;                   // 06
  265.     USHORT UnformattedBytesPerTrack;        // 08
  266.     USHORT UnformattedBytesPerSector;       // 0A
  267.     USHORT SectorsPerTrack;                 // 0C
  268.     USHORT VendorUnique1[3];                // 0E
  269.     USHORT SerialNumber[10];                // 14
  270.     USHORT BufferType;                      // 28
  271.     USHORT BufferSectorSize;                // 2A
  272.     USHORT NumberOfEccBytes;                // 2C
  273.     USHORT FirmwareRevision[4];             // 2E
  274.     USHORT ModelNumber[20];                 // 36
  275.     UCHAR  MaximumBlockTransfer;            // 5E
  276.     UCHAR  VendorUnique2;                   // 5F
  277.     USHORT DoubleWordIo;                    // 60
  278.     USHORT Capabilities;                    // 62
  279.     USHORT Reserved2;                       // 64
  280.     UCHAR  VendorUnique3;                   // 66
  281.     UCHAR  PioCycleTimingMode;              // 67
  282.     UCHAR  VendorUnique4;                   // 68
  283.     UCHAR  DmaCycleTimingMode;              // 69
  284. USHORT TranslationFieldsValid:1;      // 6A
  285.     USHORT Reserved3:15;
  286.     USHORT NumberOfCurrentCylinders;        // 6C
  287.     USHORT NumberOfCurrentHeads;            // 6E
  288.     USHORT CurrentSectorsPerTrack;          // 70
  289.     ULONG  CurrentSectorCapacity;           // 72
  290. } IDENTIFY_DATA2, *PIDENTIFY_DATA2;
  291. #endif // PSI_EIDE_SCSIOP
  292. // function prototypes
  293. int Psi240i_Detect (Scsi_Host_Template *tpnt);
  294. int Psi240i_Command (Scsi_Cmnd *SCpnt);
  295. int Psi240i_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *));
  296. int Psi240i_Abort (Scsi_Cmnd *SCpnt);
  297. int Psi240i_Reset (Scsi_Cmnd *SCpnt, unsigned int flags);
  298. int Psi240i_BiosParam (Disk *disk, kdev_t dev, int geom[]);
  299. #ifndef NULL
  300. #define NULL 0
  301. #endif
  302. #define PSI240I { proc_name:      "psi240i", 
  303.   name:           "PSI-240I EIDE Disk Controller",
  304.   detect:         Psi240i_Detect,
  305.   command:   Psi240i_Command,
  306.   queuecommand:   Psi240i_QueueCommand,
  307.   abort:   Psi240i_Abort,
  308.   reset:   Psi240i_Reset,
  309.   bios_param:   Psi240i_BiosParam,                 
  310.   can_queue:   1, 
  311.   this_id:   -1, 
  312.   sg_tablesize:   SG_NONE,  
  313.   cmd_per_lun:   1, 
  314.   use_clustering: DISABLE_CLUSTERING }
  315. #endif