eata_generic.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /********************************************************
  2. * Header file for eata_dma.c and eata_pio.c *
  3. * Linux EATA SCSI drivers *
  4. * (c) 1993-96 Michael Neuffer *
  5. * mike@i-Connect.Net *
  6. * neuffer@mail.uni-mainz.de *
  7. *********************************************************
  8. * last change: 96/08/14 *
  9. ********************************************************/
  10. #ifndef _EATA_GENERIC_H
  11. #define _EATA_GENERIC_H
  12. /*********************************************
  13. * Misc. definitions *
  14. *********************************************/
  15. #define R_LIMIT 0x20000
  16. #define MAXISA 4
  17. #define MAXEISA 16
  18. #define MAXPCI 16
  19. #define MAXIRQ 16
  20. #define MAXTARGET 16
  21. #define MAXCHANNEL 3
  22. #define IS_ISA 'I'
  23. #define IS_EISA 'E'
  24. #define IS_PCI 'P'
  25. #define BROKEN_INQUIRY 1
  26. #define BUSMASTER 0xff
  27. #define PIO 0xfe
  28. #define EATA_SIGNATURE 0x45415441 /* BIG ENDIAN coded "EATA" sig. */
  29. #define DPT_ID1 0x12
  30. #define DPT_ID2 0x14
  31. #define ATT_ID1 0x06
  32. #define ATT_ID2 0x94
  33. #define ATT_ID3 0x0
  34. #define NEC_ID1 0x38
  35. #define NEC_ID2 0xa3
  36. #define NEC_ID3 0x82
  37. #define EATA_CP_SIZE 44
  38. #define MAX_PCI_DEVICES 32 /* Maximum # Of Devices Per Bus */
  39. #define MAX_METHOD_2 16 /* Max Devices For Method 2 */
  40. #define MAX_PCI_BUS 16 /* Maximum # Of Busses Allowed */
  41. #define SG_SIZE 64
  42. #define SG_SIZE_BIG 252 /* max. 8096 elements, 64k */
  43. #define UPPER_DEVICE_QUEUE_LIMIT 64 /* The limit we have to set for the
  44. * device queue to keep the broken
  45. * midlevel SCSI code from producing
  46. * bogus timeouts
  47. */
  48. #define TYPE_DISK_QUEUE 16
  49. #define TYPE_TAPE_QUEUE 4
  50. #define TYPE_ROM_QUEUE 4
  51. #define TYPE_OTHER_QUEUE 2
  52. #define FREE 0
  53. #define OK 0
  54. #define NO_TIMEOUT 0
  55. #define USED 1
  56. #define TIMEOUT 2
  57. #define RESET 4
  58. #define LOCKED 8
  59. #define ABORTED 16
  60. #define READ 0
  61. #define WRITE 1
  62. #define OTHER 2
  63. #define HD(cmd) ((hostdata *)&(cmd->device->host->hostdata))
  64. #define CD(cmd) ((struct eata_ccb *)(cmd->host_scribble))
  65. #define SD(host) ((hostdata *)&(host->hostdata))
  66. /***********************************************
  67. * EATA Command & Register definitions *
  68. ***********************************************/
  69. #define PCI_REG_DPTconfig 0x40
  70. #define PCI_REG_PumpModeAddress 0x44
  71. #define PCI_REG_PumpModeData 0x48
  72. #define PCI_REG_ConfigParam1 0x50
  73. #define PCI_REG_ConfigParam2 0x54
  74. #define EATA_CMD_PIO_SETUPTEST 0xc6
  75. #define EATA_CMD_PIO_READ_CONFIG 0xf0
  76. #define EATA_CMD_PIO_SET_CONFIG 0xf1
  77. #define EATA_CMD_PIO_SEND_CP 0xf2
  78. #define EATA_CMD_PIO_RECEIVE_SP 0xf3
  79. #define EATA_CMD_PIO_TRUNC 0xf4
  80. #define EATA_CMD_RESET 0xf9
  81. #define EATA_CMD_IMMEDIATE 0xfa
  82. #define EATA_CMD_DMA_READ_CONFIG 0xfd
  83. #define EATA_CMD_DMA_SET_CONFIG 0xfe
  84. #define EATA_CMD_DMA_SEND_CP 0xff
  85. #define ECS_EMULATE_SENSE 0xd4
  86. #define EATA_GENERIC_ABORT 0x00
  87. #define EATA_SPECIFIC_RESET 0x01
  88. #define EATA_BUS_RESET 0x02
  89. #define EATA_SPECIFIC_ABORT 0x03
  90. #define EATA_QUIET_INTR 0x04
  91. #define EATA_COLD_BOOT_HBA 0x06 /* Only as a last resort */
  92. #define EATA_FORCE_IO 0x07
  93. #define HA_CTRLREG 0x206 /* control register for HBA */
  94. #define HA_CTRL_DISINT 0x02 /* CTRLREG: disable interrupts */
  95. #define HA_CTRL_RESCPU 0x04 /* CTRLREG: reset processor */
  96. #define HA_CTRL_8HEADS 0x08 /* CTRLREG: set for drives with*
  97. * >=8 heads (WD1003 rudimentary :-) */
  98. #define HA_WCOMMAND 0x07 /* command register offset */
  99. #define HA_WIFC 0x06 /* immediate command offset */
  100. #define HA_WCODE 0x05
  101. #define HA_WCODE2 0x04
  102. #define HA_WDMAADDR 0x02 /* DMA address LSB offset */
  103. #define HA_RAUXSTAT 0x08 /* aux status register offset*/
  104. #define HA_RSTATUS 0x07 /* status register offset */
  105. #define HA_RDATA 0x00 /* data register (16bit) */
  106. #define HA_WDATA 0x00 /* data register (16bit) */
  107. #define HA_ABUSY 0x01 /* aux busy bit */
  108. #define HA_AIRQ 0x02 /* aux IRQ pending bit */
  109. #define HA_SERROR 0x01 /* pr. command ended in error*/
  110. #define HA_SMORE 0x02 /* more data soon to come */
  111. #define HA_SCORR 0x04 /* data corrected */
  112. #define HA_SDRQ 0x08 /* data request active */
  113. #define HA_SSC 0x10 /* seek complete */
  114. #define HA_SFAULT 0x20 /* write fault */
  115. #define HA_SREADY 0x40 /* drive ready */
  116. #define HA_SBUSY 0x80 /* drive busy */
  117. #define HA_SDRDY HA_SSC+HA_SREADY+HA_SDRQ
  118. /**********************************************
  119. * Message definitions *
  120. **********************************************/
  121. #define HA_NO_ERROR 0x00 /* No Error */
  122. #define HA_ERR_SEL_TO 0x01 /* Selection Timeout */
  123. #define HA_ERR_CMD_TO 0x02 /* Command Timeout */
  124. #define HA_BUS_RESET 0x03 /* SCSI Bus Reset Received */
  125. #define HA_INIT_POWERUP 0x04 /* Initial Controller Power-up */
  126. #define HA_UNX_BUSPHASE 0x05 /* Unexpected Bus Phase */
  127. #define HA_UNX_BUS_FREE 0x06 /* Unexpected Bus Free */
  128. #define HA_BUS_PARITY 0x07 /* Bus Parity Error */
  129. #define HA_SCSI_HUNG 0x08 /* SCSI Hung */
  130. #define HA_UNX_MSGRJCT 0x09 /* Unexpected Message Rejected */
  131. #define HA_RESET_STUCK 0x0a /* SCSI Bus Reset Stuck */
  132. #define HA_RSENSE_FAIL 0x0b /* Auto Request-Sense Failed */
  133. #define HA_PARITY_ERR 0x0c /* Controller Ram Parity Error */
  134. #define HA_CP_ABORT_NA 0x0d /* Abort Message sent to non-active cmd */
  135. #define HA_CP_ABORTED 0x0e /* Abort Message sent to active cmd */
  136. #define HA_CP_RESET_NA 0x0f /* Reset Message sent to non-active cmd */
  137. #define HA_CP_RESET 0x10 /* Reset Message sent to active cmd */
  138. #define HA_ECC_ERR 0x11 /* Controller Ram ECC Error */
  139. #define HA_PCI_PARITY 0x12 /* PCI Parity Error */
  140. #define HA_PCI_MABORT 0x13 /* PCI Master Abort */
  141. #define HA_PCI_TABORT 0x14 /* PCI Target Abort */
  142. #define HA_PCI_STABORT 0x15 /* PCI Signaled Target Abort */
  143. /**********************************************
  144. * Other definitions *
  145. **********************************************/
  146. struct reg_bit { /* reading this one will clear the interrupt */
  147. __u8 error:1; /* previous command ended in an error */
  148. __u8 more:1; /* more DATA coming soon, poll BSY & DRQ (PIO) */
  149. __u8 corr:1; /* data read was successfully corrected with ECC*/
  150. __u8 drq:1; /* data request active */
  151. __u8 sc:1; /* seek complete */
  152. __u8 fault:1; /* write fault */
  153. __u8 ready:1; /* drive ready */
  154. __u8 busy:1; /* controller busy */
  155. };
  156. struct reg_abit { /* reading this won't clear the interrupt */
  157. __u8 abusy:1; /* auxiliary busy */
  158. __u8 irq:1; /* set when drive interrupt is asserted */
  159. __u8 dummy:6;
  160. };
  161. struct eata_register { /* EATA register set */
  162. __u8 data_reg[2]; /* R, couldn't figure this one out */
  163. __u8 cp_addr[4]; /* W, CP address register */
  164. union {
  165. __u8 command; /* W, command code: [read|set] conf, send CP*/
  166. struct reg_bit status; /* R, see register_bit1 */
  167. __u8 statusbyte;
  168. } ovr;
  169. struct reg_abit aux_stat; /* R, see register_bit2 */
  170. };
  171. struct get_conf { /* Read Configuration Array */
  172. __u32 len; /* Should return 0x22, 0x24, etc */
  173. __u32 signature; /* Signature MUST be "EATA" */
  174. __u8 version2:4,
  175. version:4; /* EATA Version level */
  176. __u8 OCS_enabled:1, /* Overlap Command Support enabled */
  177. TAR_support:1, /* SCSI Target Mode supported */
  178. TRNXFR:1, /* Truncate Transfer Cmd not necessary *
  179. * Only used in PIO Mode */
  180. MORE_support:1, /* MORE supported (only PIO Mode) */
  181. DMA_support:1, /* DMA supported Driver uses only *
  182. * this mode */
  183. DMA_valid:1, /* DRQ value in Byte 30 is valid */
  184. ATA:1, /* ATA device connected (not supported) */
  185. HAA_valid:1; /* Hostadapter Address is valid */
  186. __u16 cppadlen; /* Number of pad bytes send after CD data *
  187. * set to zero for DMA commands */
  188. __u8 scsi_id[4]; /* SCSI ID of controller 2-0 Byte 0 res. *
  189. * if not, zero is returned */
  190. __u32 cplen; /* CP length: number of valid cp bytes */
  191. __u32 splen; /* Number of bytes returned after *
  192. * Receive SP command */
  193. __u16 queuesiz; /* max number of queueable CPs */
  194. __u16 dummy;
  195. __u16 SGsiz; /* max number of SG table entries */
  196. __u8 IRQ:4, /* IRQ used this HA */
  197. IRQ_TR:1, /* IRQ Trigger: 0=edge, 1=level */
  198. SECOND:1, /* This is a secondary controller */
  199. DMA_channel:2; /* DRQ index, DRQ is 2comp of DRQX */
  200. __u8 sync; /* device at ID 7 tru 0 is running in *
  201. * synchronous mode, this will disappear */
  202. __u8 DSBLE:1, /* ISA i/o addressing is disabled */
  203. FORCADR:1, /* i/o address has been forced */
  204. SG_64K:1,
  205. SG_UAE:1,
  206. :4;
  207. __u8 MAX_ID:5, /* Max number of SCSI target IDs */
  208. MAX_CHAN:3; /* Number of SCSI busses on HBA */
  209. __u8 MAX_LUN; /* Max number of LUNs */
  210. __u8 :3,
  211. AUTOTRM:1,
  212. M1_inst:1,
  213. ID_qest:1, /* Raidnum ID is questionable */
  214. is_PCI:1, /* HBA is PCI */
  215. is_EISA:1; /* HBA is EISA */
  216. __u8 RAIDNUM; /* unique HBA identifier */
  217. __u8 unused[474];
  218. };
  219. struct eata_sg_list
  220. {
  221. __u32 data;
  222. __u32 len;
  223. };
  224. struct eata_ccb { /* Send Command Packet structure */
  225. __u8 SCSI_Reset:1, /* Cause a SCSI Bus reset on the cmd */
  226. HBA_Init:1, /* Cause Controller to reinitialize */
  227. Auto_Req_Sen:1, /* Do Auto Request Sense on errors */
  228. scatter:1, /* Data Ptr points to a SG Packet */
  229. Resrvd:1, /* RFU */
  230. Interpret:1, /* Interpret the SCSI cdb of own use */
  231. DataOut:1, /* Data Out phase with command */
  232. DataIn:1; /* Data In phase with command */
  233. __u8 reqlen; /* Request Sense Length *
  234. * Valid if Auto_Req_Sen=1 */
  235. __u8 unused[3];
  236. __u8 FWNEST:1, /* send cmd to phys RAID component */
  237. unused2:7;
  238. __u8 Phsunit:1, /* physical unit on mirrored pair */
  239. I_AT:1, /* inhibit address translation */
  240. I_HBA_C:1, /* HBA inhibit caching */
  241. unused3:5;
  242. __u8 cp_id:5, /* SCSI Device ID of target */
  243. cp_channel:3; /* SCSI Channel # of HBA */
  244. __u8 cp_lun:3,
  245. :2,
  246. cp_luntar:1, /* CP is for target ROUTINE */
  247. cp_dispri:1, /* Grant disconnect privilege */
  248. cp_identify:1; /* Always TRUE */
  249. __u8 cp_msg1; /* Message bytes 0-3 */
  250. __u8 cp_msg2;
  251. __u8 cp_msg3;
  252. __u8 cp_cdb[12]; /* Command Descriptor Block */
  253. __u32 cp_datalen; /* Data Transfer Length *
  254. * If scatter=1 len of sg package */
  255. void *cp_viraddr; /* address of this ccb */
  256. __u32 cp_dataDMA; /* Data Address, if scatter=1 *
  257. * address of scatter packet */
  258. __u32 cp_statDMA; /* address for Status Packet */
  259. __u32 cp_reqDMA; /* Request Sense Address, used if *
  260. * CP command ends with error */
  261. /* Additional CP info begins here */
  262. __u32 timestamp; /* Needed to measure command latency */
  263. __u32 timeout;
  264. __u8 sizeindex;
  265. __u8 rw_latency;
  266. __u8 retries;
  267. __u8 status; /* status of this queueslot */
  268. struct scsi_cmnd *cmd; /* address of cmd */
  269. struct eata_sg_list *sg_list;
  270. };
  271. struct eata_sp {
  272. __u8 hba_stat:7, /* HBA status */
  273. EOC:1; /* True if command finished */
  274. __u8 scsi_stat; /* Target SCSI status */
  275. __u8 reserved[2];
  276. __u32 residue_len; /* Number of bytes not transferred */
  277. struct eata_ccb *ccb; /* Address set in COMMAND PACKET */
  278. __u8 msg[12];
  279. };
  280. typedef struct hstd {
  281. __u8 vendor[9];
  282. __u8 name[18];
  283. __u8 revision[6];
  284. __u8 EATA_revision;
  285. __u32 firmware_revision;
  286. __u8 HBA_number;
  287. __u8 bustype; /* bustype of HBA */
  288. __u8 channel; /* # of avail. scsi channels */
  289. __u8 state; /* state of HBA */
  290. __u8 primary; /* true if primary */
  291. __u8 more_support:1, /* HBA supports MORE flag */
  292. immediate_support:1, /* HBA supports IMMEDIATE CMDs*/
  293. broken_INQUIRY:1; /* This is an EISA HBA with *
  294. * broken INQUIRY */
  295. __u8 do_latency; /* Latency measurement flag */
  296. __u32 reads[13];
  297. __u32 writes[13];
  298. __u32 reads_lat[12][4];
  299. __u32 writes_lat[12][4];
  300. __u32 all_lat[4];
  301. __u8 resetlevel[MAXCHANNEL];
  302. __u32 last_ccb; /* Last used ccb */
  303. __u32 cplen; /* size of CP in words */
  304. __u16 cppadlen; /* pad length of cp in words */
  305. __u16 queuesize;
  306. __u16 sgsize; /* # of entries in the SG list*/
  307. __u16 devflags; /* bits set for detected devices */
  308. __u8 hostid; /* SCSI ID of HBA */
  309. __u8 moresupport; /* HBA supports MORE flag */
  310. struct Scsi_Host *next;
  311. struct Scsi_Host *prev;
  312. struct pci_dev *pdev; /* PCI device or NULL for non PCI */
  313. struct eata_sp sp; /* status packet */
  314. struct eata_ccb ccb[0]; /* ccb array begins here */
  315. }hostdata;
  316. /* structure for max. 2 emulated drives */
  317. struct drive_geom_emul {
  318. __u8 trans; /* translation flag 1=transl */
  319. __u8 channel; /* SCSI channel number */
  320. __u8 HBA; /* HBA number (prim/sec) */
  321. __u8 id; /* drive id */
  322. __u8 lun; /* drive lun */
  323. __u32 heads; /* number of heads */
  324. __u32 sectors; /* number of sectors */
  325. __u32 cylinder; /* number of cylinders */
  326. };
  327. struct geom_emul {
  328. __u8 bios_drives; /* number of emulated drives */
  329. struct drive_geom_emul drv[2]; /* drive structures */
  330. };
  331. #endif /* _EATA_GENERIC_H */
  332. /*
  333. * Overrides for Emacs so that we almost follow Linus's tabbing style.
  334. * Emacs will notice this stuff at the end of the file and automatically
  335. * adjust the settings for this buffer only. This must remain at the end
  336. * of the file.
  337. * ---------------------------------------------------------------------------
  338. * Local variables:
  339. * c-indent-level: 4
  340. * c-brace-imaginary-offset: 0
  341. * c-brace-offset: -4
  342. * c-argdecl-indent: 4
  343. * c-label-offset: -4
  344. * c-continued-statement-offset: 4
  345. * c-continued-brace-offset: 0
  346. * tab-width: 8
  347. * End:
  348. */