File: /usr/src/linux/include/linux/qic117.h

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