qic117.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. #ifndef _QIC117_H
  2. #define _QIC117_H
  3. /*
  4. * Copyright (C) 1993-1996 Bas Laarhoven,
  5. * (C) 1997 Claus-Justus Heine.
  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. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; see the file COPYING. If not, write to
  16. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. * $Source: /homes/cvs/ftape-stacked/include/linux/qic117.h,v $
  19. * $Revision: 1.2 $
  20. * $Date: 1997/10/05 19:19:32 $
  21. *
  22. * This file contains QIC-117 spec. related definitions for the
  23. * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
  24. *
  25. * These data were taken from the Quarter-Inch Cartridge
  26. * Drive Standards, Inc. document titled:
  27. * `Common Command Set Interface Specification for Flexible
  28. * Disk Controller Based Minicartridge Tape Drives'
  29. * document QIC-117 Revision J, 28 Aug 96.
  30. * For more information, contact:
  31. * Quarter-Inch Cartridge Drive Standards, Inc.
  32. * 311 East Carrillo Street
  33. * Santa Barbara, California 93101
  34. * Telephone (805) 963-3853
  35. * Fax (805) 962-1541
  36. * WWW http://www.qic.org
  37. *
  38. * Current QIC standard revisions (of interest) are:
  39. * QIC-40-MC, Rev. M, 2 Sep 92.
  40. * QIC-80-MC, Rev. N, 20 Mar 96.
  41. * QIC-80-MC, Rev. K, 15 Dec 94.
  42. * QIC-113, Rev. G, 15 Jun 95.
  43. * QIC-117, Rev. J, 28 Aug 96.
  44. * QIC-122, Rev. B, 6 Mar 91.
  45. * QIC-130, Rev. C, 2 Sep 92.
  46. * QIC-3010-MC, Rev. F, 14 Jun 95.
  47. * QIC-3020-MC, Rev. G, 31 Aug 95.
  48. * QIC-CRF3, Rev. B, 15 Jun 95.
  49. * */
  50. /*
  51. * QIC-117 common command set rev. J.
  52. * These commands are sent to the tape unit
  53. * as number of pulses over the step line.
  54. */
  55. typedef enum {
  56. QIC_NO_COMMAND = 0,
  57. QIC_RESET = 1,
  58. QIC_REPORT_NEXT_BIT = 2,
  59. QIC_PAUSE = 3,
  60. QIC_MICRO_STEP_PAUSE = 4,
  61. QIC_ALTERNATE_TIMEOUT = 5,
  62. QIC_REPORT_DRIVE_STATUS = 6,
  63. QIC_REPORT_ERROR_CODE = 7,
  64. QIC_REPORT_DRIVE_CONFIGURATION = 8,
  65. QIC_REPORT_ROM_VERSION = 9,
  66. QIC_LOGICAL_FORWARD = 10,
  67. QIC_PHYSICAL_REVERSE = 11,
  68. QIC_PHYSICAL_FORWARD = 12,
  69. QIC_SEEK_HEAD_TO_TRACK = 13,
  70. QIC_SEEK_LOAD_POINT = 14,
  71. QIC_ENTER_FORMAT_MODE = 15,
  72. QIC_WRITE_REFERENCE_BURST = 16,
  73. QIC_ENTER_VERIFY_MODE = 17,
  74. QIC_STOP_TAPE = 18,
  75. /* commands 19-20: reserved */
  76. QIC_MICRO_STEP_HEAD_UP = 21,
  77. QIC_MICRO_STEP_HEAD_DOWN = 22,
  78. QIC_SOFT_SELECT = 23,
  79. QIC_SOFT_DESELECT = 24,
  80. QIC_SKIP_REVERSE = 25,
  81. QIC_SKIP_FORWARD = 26,
  82. QIC_SELECT_RATE = 27,
  83. /* command 27, in ccs2: Select Rate or Format */
  84. QIC_ENTER_DIAGNOSTIC_1 = 28,
  85. QIC_ENTER_DIAGNOSTIC_2 = 29,
  86. QIC_ENTER_PRIMARY_MODE = 30,
  87. /* command 31: vendor unique */
  88. QIC_REPORT_VENDOR_ID = 32,
  89. QIC_REPORT_TAPE_STATUS = 33,
  90. QIC_SKIP_EXTENDED_REVERSE = 34,
  91. QIC_SKIP_EXTENDED_FORWARD = 35,
  92. QIC_CALIBRATE_TAPE_LENGTH = 36,
  93. QIC_REPORT_FORMAT_SEGMENTS = 37,
  94. QIC_SET_FORMAT_SEGMENTS = 38,
  95. /* commands 39-45: reserved */
  96. QIC_PHANTOM_SELECT = 46,
  97. QIC_PHANTOM_DESELECT = 47
  98. } qic117_cmd_t;
  99. typedef enum {
  100. discretional = 0, required, ccs1, ccs2
  101. } qic_compatibility;
  102. typedef enum {
  103. unused, mode, motion, report
  104. } command_types;
  105. struct qic117_command_table {
  106. char *name;
  107. __u8 mask;
  108. __u8 state;
  109. __u8 cmd_type;
  110. __u8 non_intr;
  111. __u8 level;
  112. };
  113. #define QIC117_COMMANDS {\
  114. /* command mask state cmd_type */\
  115. /* | name | | | non_intr */\
  116. /* | | | | | | level */\
  117. /* 0*/ {NULL, 0x00, 0x00, mode, 0, discretional},\
  118. /* 1*/ {"soft reset", 0x00, 0x00, motion, 1, required},\
  119. /* 2*/ {"report next bit", 0x00, 0x00, report, 0, required},\
  120. /* 3*/ {"pause", 0x36, 0x24, motion, 1, required},\
  121. /* 4*/ {"micro step pause", 0x36, 0x24, motion, 1, required},\
  122. /* 5*/ {"alternate command timeout", 0x00, 0x00, mode, 0, required},\
  123. /* 6*/ {"report drive status", 0x00, 0x00, report, 0, required},\
  124. /* 7*/ {"report error code", 0x01, 0x01, report, 0, required},\
  125. /* 8*/ {"report drive configuration",0x00, 0x00, report, 0, required},\
  126. /* 9*/ {"report rom version", 0x00, 0x00, report, 0, required},\
  127. /*10*/ {"logical forward", 0x37, 0x25, motion, 0, required},\
  128. /*11*/ {"physical reverse", 0x17, 0x05, motion, 0, required},\
  129. /*12*/ {"physical forward", 0x17, 0x05, motion, 0, required},\
  130. /*13*/ {"seek head to track", 0x37, 0x25, motion, 0, required},\
  131. /*14*/ {"seek load point", 0x17, 0x05, motion, 1, required},\
  132. /*15*/ {"enter format mode", 0x1f, 0x05, mode, 0, required},\
  133. /*16*/ {"write reference burst", 0x1f, 0x05, motion, 1, required},\
  134. /*17*/ {"enter verify mode", 0x37, 0x25, mode, 0, required},\
  135. /*18*/ {"stop tape", 0x00, 0x00, motion, 1, required},\
  136. /*19*/ {"reserved (19)", 0x00, 0x00, unused, 0, discretional},\
  137. /*20*/ {"reserved (20)", 0x00, 0x00, unused, 0, discretional},\
  138. /*21*/ {"micro step head up", 0x02, 0x00, motion, 0, required},\
  139. /*22*/ {"micro step head down", 0x02, 0x00, motion, 0, required},\
  140. /*23*/ {"soft select", 0x00, 0x00, mode, 0, discretional},\
  141. /*24*/ {"soft deselect", 0x00, 0x00, mode, 0, discretional},\
  142. /*25*/ {"skip segments reverse", 0x36, 0x24, motion, 1, required},\
  143. /*26*/ {"skip segments forward", 0x36, 0x24, motion, 1, required},\
  144. /*27*/ {"select rate or format", 0x03, 0x01, mode, 0, required /* [ccs2] */},\
  145. /*28*/ {"enter diag mode 1", 0x00, 0x00, mode, 0, discretional},\
  146. /*29*/ {"enter diag mode 2", 0x00, 0x00, mode, 0, discretional},\
  147. /*30*/ {"enter primary mode", 0x00, 0x00, mode, 0, required},\
  148. /*31*/ {"vendor unique (31)", 0x00, 0x00, unused, 0, discretional},\
  149. /*32*/ {"report vendor id", 0x00, 0x00, report, 0, required},\
  150. /*33*/ {"report tape status", 0x04, 0x04, report, 0, ccs1},\
  151. /*34*/ {"skip extended reverse", 0x36, 0x24, motion, 1, ccs1},\
  152. /*35*/ {"skip extended forward", 0x36, 0x24, motion, 1, ccs1},\
  153. /*36*/ {"calibrate tape length", 0x17, 0x05, motion, 1, ccs2},\
  154. /*37*/ {"report format segments", 0x17, 0x05, report, 0, ccs2},\
  155. /*38*/ {"set format segments", 0x17, 0x05, mode, 0, ccs2},\
  156. /*39*/ {"reserved (39)", 0x00, 0x00, unused, 0, discretional},\
  157. /*40*/ {"vendor unique (40)", 0x00, 0x00, unused, 0, discretional},\
  158. /*41*/ {"vendor unique (41)", 0x00, 0x00, unused, 0, discretional},\
  159. /*42*/ {"vendor unique (42)", 0x00, 0x00, unused, 0, discretional},\
  160. /*43*/ {"vendor unique (43)", 0x00, 0x00, unused, 0, discretional},\
  161. /*44*/ {"vendor unique (44)", 0x00, 0x00, unused, 0, discretional},\
  162. /*45*/ {"vendor unique (45)", 0x00, 0x00, unused, 0, discretional},\
  163. /*46*/ {"phantom select", 0x00, 0x00, mode, 0, discretional},\
  164. /*47*/ {"phantom deselect", 0x00, 0x00, mode, 0, discretional},\
  165. }
  166. /*
  167. * Status bits returned by QIC_REPORT_DRIVE_STATUS
  168. */
  169. #define QIC_STATUS_READY 0x01 /* Drive is ready or idle. */
  170. #define QIC_STATUS_ERROR 0x02 /* Error detected, must read
  171. error code to clear this */
  172. #define QIC_STATUS_CARTRIDGE_PRESENT 0x04 /* Tape is present */
  173. #define QIC_STATUS_WRITE_PROTECT 0x08 /* Tape is write protected */
  174. #define QIC_STATUS_NEW_CARTRIDGE 0x10 /* New cartridge inserted, must
  175. read error status to clear. */
  176. #define QIC_STATUS_REFERENCED 0x20 /* Cartridge appears to have been
  177. formatted. */
  178. #define QIC_STATUS_AT_BOT 0x40 /* Cartridge is at physical
  179. beginning of tape. */
  180. #define QIC_STATUS_AT_EOT 0x80 /* Cartridge is at physical end
  181. of tape. */
  182. /*
  183. * Status bits returned by QIC_REPORT_DRIVE_CONFIGURATION
  184. */
  185. #define QIC_CONFIG_RATE_MASK 0x18
  186. #define QIC_CONFIG_RATE_SHIFT 3
  187. #define QIC_CONFIG_RATE_250 0
  188. #define QIC_CONFIG_RATE_500 2
  189. #define QIC_CONFIG_RATE_1000 3
  190. #define QIC_CONFIG_RATE_2000 1
  191. #define QIC_CONFIG_RATE_4000 0 /* since QIC-117 Rev. J */
  192. #define QIC_CONFIG_LONG 0x40 /* Extra Length Tape Detected */
  193. #define QIC_CONFIG_80 0x80 /* QIC-80 detected. */
  194. /*
  195. * Status bits returned by QIC_REPORT_TAPE_STATUS
  196. */
  197. #define QIC_TAPE_STD_MASK 0x0f
  198. #define QIC_TAPE_QIC40 0x01
  199. #define QIC_TAPE_QIC80 0x02
  200. #define QIC_TAPE_QIC3020 0x03
  201. #define QIC_TAPE_QIC3010 0x04
  202. #define QIC_TAPE_LEN_MASK 0x70
  203. #define QIC_TAPE_205FT 0x10
  204. #define QIC_TAPE_307FT 0x20
  205. #define QIC_TAPE_VARIABLE 0x30
  206. #define QIC_TAPE_1100FT 0x40
  207. #define QIC_TAPE_FLEX 0x60
  208. #define QIC_TAPE_WIDE 0x80
  209. /* Define a value (in feet) slightly higher than
  210. * the possible maximum tape length.
  211. */
  212. #define QIC_TOP_TAPE_LEN 1500
  213. /*
  214. * Errors: List of error codes, and their severity.
  215. */
  216. typedef struct {
  217. char *message; /* Text describing the error. */
  218. unsigned int fatal:1; /* Non-zero if the error is fatal. */
  219. } ftape_error;
  220. #define QIC117_ERRORS {\
  221. /* 0*/ { "No error", 0, },\
  222. /* 1*/ { "Command Received while Drive Not Ready", 0, },\
  223. /* 2*/ { "Cartridge Not Present or Removed", 1, },\
  224. /* 3*/ { "Motor Speed Error (not within 1%)", 1, },\
  225. /* 4*/ { "Motor Speed Fault (jammed, or gross speed error", 1, },\
  226. /* 5*/ { "Cartridge Write Protected", 1, },\
  227. /* 6*/ { "Undefined or Reserved Command Code", 1, },\
  228. /* 7*/ { "Illegal Track Address Specified for Seek", 1, },\
  229. /* 8*/ { "Illegal Command in Report Subcontext", 0, },\
  230. /* 9*/ { "Illegal Entry into a Diagnostic Mode", 1, },\
  231. /*10*/ { "Broken Tape Detected (based on hole sensor)", 1, },\
  232. /*11*/ { "Warning--Read Gain Setting Error", 1, },\
  233. /*12*/ { "Command Received While Error Status Pending (obs)", 1, },\
  234. /*13*/ { "Command Received While New Cartridge Pending", 1, },\
  235. /*14*/ { "Command Illegal or Undefined in Primary Mode", 1, },\
  236. /*15*/ { "Command Illegal or Undefined in Format Mode", 1, },\
  237. /*16*/ { "Command Illegal or Undefined in Verify Mode", 1, },\
  238. /*17*/ { "Logical Forward Not at Logical BOT or no Format Segments in Format Mode", 1, },\
  239. /*18*/ { "Logical EOT Before All Segments generated", 1, },\
  240. /*19*/ { "Command Illegal When Cartridge Not Referenced", 1, },\
  241. /*20*/ { "Self-Diagnostic Failed (cannot be cleared)", 1, },\
  242. /*21*/ { "Warning EEPROM Not Initialized, Defaults Set", 1, },\
  243. /*22*/ { "EEPROM Corrupted or Hardware Failure", 1, },\
  244. /*23*/ { "Motion Time-out Error", 1, },\
  245. /*24*/ { "Data Segment Too Long -- Logical Forward or Pause", 1, },\
  246. /*25*/ { "Transmit Overrun (obs)", 1, },\
  247. /*26*/ { "Power On Reset Occurred", 0, },\
  248. /*27*/ { "Software Reset Occurred", 0, },\
  249. /*28*/ { "Diagnostic Mode 1 Error", 1, },\
  250. /*29*/ { "Diagnostic Mode 2 Error", 1, },\
  251. /*30*/ { "Command Received During Non-Interruptible Process", 1, },\
  252. /*31*/ { "Rate or Format Selection Error", 1, },\
  253. /*32*/ { "Illegal Command While in High Speed Mode", 1, },\
  254. /*33*/ { "Illegal Seek Segment Value", 1, },\
  255. /*34*/ { "Invalid Media", 1, },\
  256. /*35*/ { "Head Positioning Failure", 1, },\
  257. /*36*/ { "Write Reference Burst Failure", 1, },\
  258. /*37*/ { "Prom Code Missing", 1, },\
  259. /*38*/ { "Invalid Format", 1, },\
  260. /*39*/ { "EOT/BOT System Failure", 1, },\
  261. /*40*/ { "Prom A Checksum Error", 1, },\
  262. /*41*/ { "Drive Wakeup Reset Occurred", 1, },\
  263. /*42*/ { "Prom B Checksum Error", 1, },\
  264. /*43*/ { "Illegal Entry into Format Mode", 1, },\
  265. }
  266. #endif /* _QIC117_H */