1 /*
2  *	$Header: /cvsroot/osst/Driver/osst.h,v 1.12 2001/10/11 00:30:15 riede Exp $
3  */
4 
5 #include <asm/byteorder.h>
6 #include <linux/config.h>
7 #include <linux/completion.h>
8 #ifdef CONFIG_DEVFS_FS
9 #include <linux/devfs_fs_kernel.h>
10 #endif
11 
12 /*	FIXME - rename and use the following two types or delete them!
13  *              and the types really should go to st.h anyway...
14  *	INQUIRY packet command - Data Format (From Table 6-8 of QIC-157C)
15  */
16 typedef struct {
17 	unsigned	device_type	:5;	/* Peripheral Device Type */
18 	unsigned	reserved0_765	:3;	/* Peripheral Qualifier - Reserved */
19 	unsigned	reserved1_6t0	:7;	/* Reserved */
20 	unsigned	rmb		:1;	/* Removable Medium Bit */
21 	unsigned	ansi_version	:3;	/* ANSI Version */
22 	unsigned	ecma_version	:3;	/* ECMA Version */
23 	unsigned	iso_version	:2;	/* ISO Version */
24 	unsigned	response_format :4;	/* Response Data Format */
25 	unsigned	reserved3_45	:2;	/* Reserved */
26 	unsigned	reserved3_6	:1;	/* TrmIOP - Reserved */
27 	unsigned	reserved3_7	:1;	/* AENC - Reserved */
28 	u8		additional_length;	/* Additional Length (total_length-4) */
29 	u8		rsv5, rsv6, rsv7;	/* Reserved */
30 	u8		vendor_id[8];		/* Vendor Identification */
31 	u8		product_id[16];		/* Product Identification */
32 	u8		revision_level[4];	/* Revision Level */
33 	u8		vendor_specific[20];	/* Vendor Specific - Optional */
34 	u8		reserved56t95[40];	/* Reserved - Optional */
35 						/* Additional information may be returned */
36 } idetape_inquiry_result_t;
37 
38 /*
39  *	READ POSITION packet command - Data Format (From Table 6-57)
40  */
41 typedef struct {
42 	unsigned	reserved0_10	:2;	/* Reserved */
43 	unsigned	bpu		:1;	/* Block Position Unknown */
44 	unsigned	reserved0_543	:3;	/* Reserved */
45 	unsigned	eop		:1;	/* End Of Partition */
46 	unsigned	bop		:1;	/* Beginning Of Partition */
47 	u8		partition;		/* Partition Number */
48 	u8		reserved2, reserved3;	/* Reserved */
49 	u32		first_block;		/* First Block Location */
50 	u32		last_block;		/* Last Block Location (Optional) */
51 	u8		reserved12;		/* Reserved */
52 	u8		blocks_in_buffer[3];	/* Blocks In Buffer - (Optional) */
53 	u32		bytes_in_buffer;	/* Bytes In Buffer (Optional) */
54 } idetape_read_position_result_t;
55 
56 /*
57  *      Follows structures which are related to the SELECT SENSE / MODE SENSE
58  *      packet commands.
59  */
60 #define COMPRESSION_PAGE           0x0f
61 #define COMPRESSION_PAGE_LENGTH    16
62 
63 #define CAPABILITIES_PAGE          0x2a
64 #define CAPABILITIES_PAGE_LENGTH   20
65 
66 #define TAPE_PARAMTR_PAGE          0x2b
67 #define TAPE_PARAMTR_PAGE_LENGTH   16
68 
69 #define NUMBER_RETRIES_PAGE        0x2f
70 #define NUMBER_RETRIES_PAGE_LENGTH 4
71 
72 #define BLOCK_SIZE_PAGE            0x30
73 #define BLOCK_SIZE_PAGE_LENGTH     4
74 
75 #define BUFFER_FILLING_PAGE        0x33
76 #define BUFFER_FILLING_PAGE_LENGTH
77 
78 #define VENDOR_IDENT_PAGE          0x36
79 #define VENDOR_IDENT_PAGE_LENGTH   8
80 
81 #define LOCATE_STATUS_PAGE         0x37
82 #define LOCATE_STATUS_PAGE_LENGTH  0
83 
84 #define MODE_HEADER_LENGTH         4
85 
86 
87 /*
88  *	REQUEST SENSE packet command result - Data Format.
89  */
90 typedef struct {
91 	unsigned	error_code	:7;	/* Current of deferred errors */
92 	unsigned	valid		:1;	/* The information field conforms to QIC-157C */
93 	u8		reserved1	:8;	/* Segment Number - Reserved */
94 	unsigned	sense_key	:4;	/* Sense Key */
95 	unsigned	reserved2_4	:1;	/* Reserved */
96 	unsigned	ili		:1;	/* Incorrect Length Indicator */
97 	unsigned	eom		:1;	/* End Of Medium */
98 	unsigned	filemark 	:1;	/* Filemark */
99 	u32		information __attribute__ ((packed));
100 	u8		asl;			/* Additional sense length (n-7) */
101 	u32		command_specific;	/* Additional command specific information */
102 	u8		asc;			/* Additional Sense Code */
103 	u8		ascq;			/* Additional Sense Code Qualifier */
104 	u8		replaceable_unit_code;	/* Field Replaceable Unit Code */
105 	unsigned	sk_specific1 	:7;	/* Sense Key Specific */
106 	unsigned	sksv		:1;	/* Sense Key Specific information is valid */
107 	u8		sk_specific2;		/* Sense Key Specific */
108 	u8		sk_specific3;		/* Sense Key Specific */
109 	u8		pad[2];			/* Padding to 20 bytes */
110 } idetape_request_sense_result_t;
111 
112 /*
113  *      Mode Parameter Header for the MODE SENSE packet command
114  */
115 typedef struct {
116         u8              mode_data_length;       /* Length of the following data transfer */
117         u8              medium_type;            /* Medium Type */
118         u8              dsp;                    /* Device Specific Parameter */
119         u8              bdl;                    /* Block Descriptor Length */
120 } osst_mode_parameter_header_t;
121 
122 /*
123  *      Mode Parameter Block Descriptor the MODE SENSE packet command
124  *
125  *      Support for block descriptors is optional.
126  */
127 typedef struct {
128         u8              density_code;           /* Medium density code */
129         u8              blocks[3];              /* Number of blocks */
130         u8              reserved4;              /* Reserved */
131         u8              length[3];              /* Block Length */
132 } osst_parameter_block_descriptor_t;
133 
134 /*
135  *      The Data Compression Page, as returned by the MODE SENSE packet command.
136  */
137 typedef struct {
138 #if   defined(__BIG_ENDIAN_BITFIELD)
139         unsigned        ps              :1;
140         unsigned        reserved0       :1;     /* Reserved */
141 	unsigned        page_code       :6;     /* Page Code - Should be 0xf */
142 #elif defined(__LITTLE_ENDIAN_BITFIELD)
143 	unsigned        page_code       :6;     /* Page Code - Should be 0xf */
144         unsigned        reserved0       :1;     /* Reserved */
145         unsigned        ps              :1;
146 #else
147 #error "Please fix <asm/byteorder.h>"
148 #endif
149         u8              page_length;            /* Page Length - Should be 14 */
150 #if   defined(__BIG_ENDIAN_BITFIELD)
151         unsigned        dce             :1;     /* Data Compression Enable */
152         unsigned        dcc             :1;     /* Data Compression Capable */
153 	unsigned        reserved2       :6;     /* Reserved */
154 #elif defined(__LITTLE_ENDIAN_BITFIELD)
155 	unsigned        reserved2       :6;     /* Reserved */
156         unsigned        dcc             :1;     /* Data Compression Capable */
157         unsigned        dce             :1;     /* Data Compression Enable */
158 #else
159 #error "Please fix <asm/byteorder.h>"
160 #endif
161 #if   defined(__BIG_ENDIAN_BITFIELD)
162         unsigned        dde             :1;     /* Data Decompression Enable */
163         unsigned        red             :2;     /* Report Exception on Decompression */
164 	unsigned        reserved3       :5;     /* Reserved */
165 #elif defined(__LITTLE_ENDIAN_BITFIELD)
166 	unsigned        reserved3       :5;     /* Reserved */
167         unsigned        red             :2;     /* Report Exception on Decompression */
168         unsigned        dde             :1;     /* Data Decompression Enable */
169 #else
170 #error "Please fix <asm/byteorder.h>"
171 #endif
172         u32             ca;                     /* Compression Algorithm */
173         u32             da;                     /* Decompression Algorithm */
174         u8              reserved[4];            /* Reserved */
175 } osst_data_compression_page_t;
176 
177 /*
178  *      The Medium Partition Page, as returned by the MODE SENSE packet command.
179  */
180 typedef struct {
181 #if   defined(__BIG_ENDIAN_BITFIELD)
182         unsigned        ps              :1;
183         unsigned        reserved1_6     :1;     /* Reserved */
184 	unsigned        page_code       :6;     /* Page Code - Should be 0x11 */
185 #elif defined(__LITTLE_ENDIAN_BITFIELD)
186 	unsigned        page_code       :6;     /* Page Code - Should be 0x11 */
187         unsigned        reserved1_6     :1;     /* Reserved */
188         unsigned        ps              :1;
189 #else
190 #error "Please fix <asm/byteorder.h>"
191 #endif
192         u8              page_length;            /* Page Length - Should be 6 */
193         u8              map;                    /* Maximum Additional Partitions - Should be 0 */
194         u8              apd;                    /* Additional Partitions Defined - Should be 0 */
195 #if   defined(__BIG_ENDIAN_BITFIELD)
196         unsigned        fdp             :1;     /* Fixed Data Partitions */
197         unsigned        sdp             :1;     /* Should be 0 */
198         unsigned        idp             :1;     /* Should be 0 */
199         unsigned        psum            :2;     /* Should be 0 */
200 	unsigned        reserved4_012   :3;     /* Reserved */
201 #elif defined(__LITTLE_ENDIAN_BITFIELD)
202 	unsigned        reserved4_012   :3;     /* Reserved */
203         unsigned        psum            :2;     /* Should be 0 */
204         unsigned        idp             :1;     /* Should be 0 */
205         unsigned        sdp             :1;     /* Should be 0 */
206         unsigned        fdp             :1;     /* Fixed Data Partitions */
207 #else
208 #error "Please fix <asm/byteorder.h>"
209 #endif
210         u8              mfr;                    /* Medium Format Recognition */
211         u8              reserved[2];            /* Reserved */
212 } osst_medium_partition_page_t;
213 
214 /*
215  *      Capabilities and Mechanical Status Page
216  */
217 typedef struct {
218 #if   defined(__BIG_ENDIAN_BITFIELD)
219         unsigned        reserved1_67    :2;
220 	unsigned        page_code       :6;     /* Page code - Should be 0x2a */
221 #elif defined(__LITTLE_ENDIAN_BITFIELD)
222 	unsigned        page_code       :6;     /* Page code - Should be 0x2a */
223         unsigned        reserved1_67    :2;
224 #else
225 #error "Please fix <asm/byteorder.h>"
226 #endif
227         u8              page_length;            /* Page Length - Should be 0x12 */
228         u8              reserved2, reserved3;
229 #if   defined(__BIG_ENDIAN_BITFIELD)
230         unsigned        reserved4_67    :2;
231         unsigned        sprev           :1;     /* Supports SPACE in the reverse direction */
232         unsigned        reserved4_1234  :4;
233 	unsigned        ro              :1;     /* Read Only Mode */
234 #elif defined(__LITTLE_ENDIAN_BITFIELD)
235 	unsigned        ro              :1;     /* Read Only Mode */
236         unsigned        reserved4_1234  :4;
237         unsigned        sprev           :1;     /* Supports SPACE in the reverse direction */
238         unsigned        reserved4_67    :2;
239 #else
240 #error "Please fix <asm/byteorder.h>"
241 #endif
242 #if   defined(__BIG_ENDIAN_BITFIELD)
243         unsigned        reserved5_67    :2;
244         unsigned        qfa             :1;     /* Supports the QFA two partition formats */
245         unsigned        reserved5_4     :1;
246         unsigned        efmt            :1;     /* Supports ERASE command initiated formatting */
247 	unsigned        reserved5_012   :3;
248 #elif defined(__LITTLE_ENDIAN_BITFIELD)
249 	unsigned        reserved5_012   :3;
250         unsigned        efmt            :1;     /* Supports ERASE command initiated formatting */
251         unsigned        reserved5_4     :1;
252         unsigned        qfa             :1;     /* Supports the QFA two partition formats */
253         unsigned        reserved5_67    :2;
254 #else
255 #error "Please fix <asm/byteorder.h>"
256 #endif
257 #if   defined(__BIG_ENDIAN_BITFIELD)
258         unsigned        cmprs           :1;     /* Supports data compression */
259         unsigned        ecc             :1;     /* Supports error correction */
260 	unsigned        reserved6_45    :2;     /* Reserved */
261         unsigned        eject           :1;     /* The device can eject the volume */
262         unsigned        prevent         :1;     /* The device defaults in the prevent state after power up */
263         unsigned        locked          :1;     /* The volume is locked */
264 	unsigned        lock            :1;     /* Supports locking the volume */
265 #elif defined(__LITTLE_ENDIAN_BITFIELD)
266 	unsigned        lock            :1;     /* Supports locking the volume */
267         unsigned        locked          :1;     /* The volume is locked */
268         unsigned        prevent         :1;     /* The device defaults in the prevent state after power up */
269         unsigned        eject           :1;     /* The device can eject the volume */
270 	unsigned        reserved6_45    :2;     /* Reserved */
271         unsigned        ecc             :1;     /* Supports error correction */
272         unsigned        cmprs           :1;     /* Supports data compression */
273 #else
274 #error "Please fix <asm/byteorder.h>"
275 #endif
276 #if   defined(__BIG_ENDIAN_BITFIELD)
277         unsigned        blk32768        :1;     /* slowb - the device restricts the byte count for PIO */
278                                                 /* transfers for slow buffer memory ??? */
279                                                 /* Also 32768 block size in some cases */
280         unsigned        reserved7_3_6   :4;
281         unsigned        blk1024         :1;     /* Supports 1024 bytes block size */
282         unsigned        blk512          :1;     /* Supports 512 bytes block size */
283 	unsigned        reserved7_0     :1;
284 #elif defined(__LITTLE_ENDIAN_BITFIELD)
285 	unsigned        reserved7_0     :1;
286         unsigned        blk512          :1;     /* Supports 512 bytes block size */
287         unsigned        blk1024         :1;     /* Supports 1024 bytes block size */
288         unsigned        reserved7_3_6   :4;
289         unsigned        blk32768        :1;     /* slowb - the device restricts the byte count for PIO */
290                                                 /* transfers for slow buffer memory ??? */
291                                                 /* Also 32768 block size in some cases */
292 #else
293 #error "Please fix <asm/byteorder.h>"
294 #endif
295         u16             max_speed;              /* Maximum speed supported in KBps */
296         u8              reserved10, reserved11;
297         u16             ctl;                    /* Continuous Transfer Limit in blocks */
298         u16             speed;                  /* Current Speed, in KBps */
299         u16             buffer_size;            /* Buffer Size, in 512 bytes */
300         u8              reserved18, reserved19;
301 } osst_capabilities_page_t;
302 
303 /*
304  *      Block Size Page
305  */
306 typedef struct {
307 #if   defined(__BIG_ENDIAN_BITFIELD)
308         unsigned        ps              :1;
309         unsigned        reserved1_6     :1;
310 	unsigned        page_code       :6;     /* Page code - Should be 0x30 */
311 #elif defined(__LITTLE_ENDIAN_BITFIELD)
312 	unsigned        page_code       :6;     /* Page code - Should be 0x30 */
313         unsigned        reserved1_6     :1;
314         unsigned        ps              :1;
315 #else
316 #error "Please fix <asm/byteorder.h>"
317 #endif
318         u8              page_length;            /* Page Length - Should be 2 */
319         u8              reserved2;
320 #if   defined(__BIG_ENDIAN_BITFIELD)
321         unsigned        one             :1;
322         unsigned        reserved2_6     :1;
323         unsigned        record32_5      :1;
324         unsigned        record32        :1;
325         unsigned        reserved2_23    :2;
326         unsigned        play32_5        :1;
327 	unsigned        play32          :1;
328 #elif defined(__LITTLE_ENDIAN_BITFIELD)
329 	unsigned        play32          :1;
330         unsigned        play32_5        :1;
331         unsigned        reserved2_23    :2;
332         unsigned        record32        :1;
333         unsigned        record32_5      :1;
334         unsigned        reserved2_6     :1;
335         unsigned        one             :1;
336 #else
337 #error "Please fix <asm/byteorder.h>"
338 #endif
339 } osst_block_size_page_t;
340 
341 /*
342  *	Tape Parameters Page
343  */
344 typedef struct {
345 #if   defined(__BIG_ENDIAN_BITFIELD)
346         unsigned        ps              :1;
347         unsigned        reserved1_6     :1;
348 	unsigned        page_code       :6;     /* Page code - Should be 0x2b */
349 #elif defined(__LITTLE_ENDIAN_BITFIELD)
350 	unsigned        page_code       :6;     /* Page code - Should be 0x2b */
351         unsigned        reserved1_6     :1;
352         unsigned        ps              :1;
353 #else
354 #error "Please fix <asm/byteorder.h>"
355 #endif
356 	u8		reserved2;
357 	u8		density;
358 	u8		reserved3,reserved4;
359 	u16		segtrk;
360 	u16		trks;
361 	u8		reserved5,reserved6,reserved7,reserved8,reserved9,reserved10;
362 } osst_tape_paramtr_page_t;
363 
364 /* OnStream definitions */
365 
366 #define OS_CONFIG_PARTITION     (0xff)
367 #define OS_DATA_PARTITION       (0)
368 #define OS_PARTITION_VERSION    (1)
369 
370 /*
371  * partition
372  */
373 typedef struct os_partition_s {
374         __u8    partition_num;
375         __u8    par_desc_ver;
376         __u16   wrt_pass_cntr;
377         __u32   first_frame_ppos;
378         __u32   last_frame_ppos;
379         __u32   eod_frame_ppos;
380 } os_partition_t;
381 
382 /*
383  * DAT entry
384  */
385 typedef struct os_dat_entry_s {
386         __u32   blk_sz;
387         __u16   blk_cnt;
388         __u8    flags;
389         __u8    reserved;
390 } os_dat_entry_t;
391 
392 /*
393  * DAT
394  */
395 #define OS_DAT_FLAGS_DATA       (0xc)
396 #define OS_DAT_FLAGS_MARK       (0x1)
397 
398 typedef struct os_dat_s {
399         __u8            dat_sz;
400         __u8            reserved1;
401         __u8            entry_cnt;
402         __u8            reserved3;
403         os_dat_entry_t  dat_list[16];
404 } os_dat_t;
405 
406 /*
407  * Frame types
408  */
409 #define OS_FRAME_TYPE_FILL      (0)
410 #define OS_FRAME_TYPE_EOD       (1 << 0)
411 #define OS_FRAME_TYPE_MARKER    (1 << 1)
412 #define OS_FRAME_TYPE_HEADER    (1 << 3)
413 #define OS_FRAME_TYPE_DATA      (1 << 7)
414 
415 /*
416  * AUX
417  */
418 typedef struct os_aux_s {
419         __u32           format_id;              /* hardware compability AUX is based on */
420         char            application_sig[4];     /* driver used to write this media */
421         __u32           hdwr;                   /* reserved */
422         __u32           update_frame_cntr;      /* for configuration frame */
423         __u8            frame_type;
424         __u8            frame_type_reserved;
425         __u8            reserved_18_19[2];
426         os_partition_t  partition;
427         __u8            reserved_36_43[8];
428         __u32           frame_seq_num;
429         __u32           logical_blk_num_high;
430         __u32           logical_blk_num;
431         os_dat_t        dat;
432         __u8            reserved188_191[4];
433         __u32           filemark_cnt;
434         __u32           phys_fm;
435         __u32           last_mark_ppos;
436         __u8            reserved204_223[20];
437 
438         /*
439          * __u8         app_specific[32];
440          *
441          * Linux specific fields:
442          */
443          __u32          next_mark_ppos;         /* when known, points to next marker */
444 	 __u32		last_mark_lbn;		/* storing log_blk_num of last mark is extends ADR spec */
445          __u8           linux_specific[24];
446 
447         __u8            reserved_256_511[256];
448 } os_aux_t;
449 
450 #define OS_FM_TAB_MAX 1024
451 
452 typedef struct os_fm_tab_s {
453 	__u8		fm_part_num;
454 	__u8		reserved_1;
455 	__u8		fm_tab_ent_sz;
456 	__u8		reserved_3;
457 	__u16		fm_tab_ent_cnt;
458 	__u8		reserved6_15[10];
459 	__u32		fm_tab_ent[OS_FM_TAB_MAX];
460 } os_fm_tab_t;
461 
462 typedef struct os_ext_trk_ey_s {
463 	__u8		et_part_num;
464 	__u8		fmt;
465 	__u16		fm_tab_off;
466 	__u8		reserved4_7[4];
467 	__u32		last_hlb_hi;
468 	__u32		last_hlb;
469 	__u32		last_pp;
470 	__u8		reserved20_31[12];
471 } os_ext_trk_ey_t;
472 
473 typedef struct os_ext_trk_tb_s {
474 	__u8		nr_stream_part;
475 	__u8		reserved_1;
476 	__u8		et_ent_sz;
477 	__u8		reserved3_15[13];
478 	os_ext_trk_ey_t	dat_ext_trk_ey;
479 	os_ext_trk_ey_t	qfa_ext_trk_ey;
480 } os_ext_trk_tb_t;
481 
482 typedef struct os_header_s {
483         char            ident_str[8];
484         __u8            major_rev;
485         __u8            minor_rev;
486 	__u16		ext_trk_tb_off;
487         __u8            reserved12_15[4];
488         __u8            pt_par_num;
489         __u8            pt_reserved1_3[3];
490         os_partition_t  partition[16];
491 	__u32		cfg_col_width;
492 	__u32		dat_col_width;
493 	__u32		qfa_col_width;
494 	__u8		cartridge[16];
495 	__u8		reserved304_511[208];
496 	__u32		old_filemark_list[16680/4];		/* in ADR 1.4 __u8 track_table[16680] */
497 	os_ext_trk_tb_t	ext_track_tb;
498 	__u8		reserved17272_17735[464];
499 	os_fm_tab_t	dat_fm_tab;
500 	os_fm_tab_t	qfa_fm_tab;
501 	__u8		reserved25960_32767[6808];
502 } os_header_t;
503 
504 
505 /*
506  * OnStream ADRL frame
507  */
508 #define OS_FRAME_SIZE   (32 * 1024 + 512)
509 #define OS_DATA_SIZE    (32 * 1024)
510 #define OS_AUX_SIZE     (512)
511 //#define OSST_MAX_SG      2
512 
513 /* The tape buffer descriptor. */
514 typedef struct {
515   unsigned char in_use;
516   unsigned char dma;	/* DMA-able buffer */
517   int buffer_size;
518   int buffer_blocks;
519   int buffer_bytes;
520   int read_pointer;
521   int writing;
522   int midlevel_result;
523   int syscall_result;
524   Scsi_Request *last_SRpnt;
525   unsigned char *b_data;
526   os_aux_t *aux;               /* onstream AUX structure at end of each block */
527   unsigned short use_sg;       /* zero or number of segments for this adapter */
528   unsigned short sg_segs;      /* total number of allocated segments */
529   unsigned short orig_sg_segs; /* number of segments allocated at first try */
530   struct scatterlist sg[1];    /* MUST BE last item */
531 } OSST_buffer;
532 
533 /* The tape drive descriptor */
534 typedef struct {
535   kdev_t devt;
536   unsigned capacity;
537   Scsi_Device* device;
538   struct semaphore lock;       /* for serialization */
539   struct completion wait;      /* for SCSI commands */
540   OSST_buffer * buffer;
541 
542   /* Drive characteristics */
543   unsigned char omit_blklims;
544   unsigned char do_auto_lock;
545   unsigned char can_bsr;
546   unsigned char can_partitions;
547   unsigned char two_fm;
548   unsigned char fast_mteom;
549   unsigned char restr_dma;
550   unsigned char scsi2_logical;
551   unsigned char default_drvbuffer;  /* 0xff = don't touch, value 3 bits */
552   int write_threshold;
553   int timeout;			/* timeout for normal commands */
554   int long_timeout;		/* timeout for commands known to take long time*/
555 
556   /* Mode characteristics */
557   ST_mode modes[ST_NBR_MODES];
558   int current_mode;
559 #ifdef CONFIG_DEVFS_FS
560   devfs_handle_t de_r[ST_NBR_MODES];  /*  Rewind entries     */
561   devfs_handle_t de_n[ST_NBR_MODES];  /*  No-rewind entries  */
562 #endif
563 
564   /* Status variables */
565   int partition;
566   int new_partition;
567   int nbr_partitions;    /* zero until partition support enabled */
568   ST_partstat ps[ST_NBR_PARTITIONS];
569   unsigned char dirty;
570   unsigned char ready;
571   unsigned char write_prot;
572   unsigned char drv_write_prot;
573   unsigned char in_use;
574   unsigned char blksize_changed;
575   unsigned char density_changed;
576   unsigned char compression_changed;
577   unsigned char drv_buffer;
578   unsigned char density;
579   unsigned char door_locked;
580   unsigned char rew_at_close;
581   unsigned char inited;
582   int block_size;
583   int min_block;
584   int max_block;
585   int recover_count;            /* from tape opening */
586   int write_count;
587   int read_count;
588   int recover_erreg;            /* from last status call */
589   /*
590    * OnStream specific data
591    */
592   int	   os_fw_rev;			       /* the firmware revision * 10000 */
593   unsigned char  raw;                          /* flag OnStream raw access (32.5KB block size) */
594   unsigned char  poll;                         /* flag that this drive needs polling (IDE|firmware) */
595   unsigned char  frame_in_buffer;	       /* flag that the frame as per frame_seq_number
596 						* has been read into STp->buffer and is valid */
597   int      frame_seq_number;                   /* logical frame number */
598   int      logical_blk_num;                    /* logical block number */
599   unsigned first_frame_position;               /* physical frame to be transferred to/from host */
600   unsigned last_frame_position;                /* physical frame to be transferd to/from tape */
601   int      cur_frames;                         /* current number of frames in internal buffer */
602   int      max_frames;                         /* max number of frames in internal buffer */
603   char     application_sig[5];                 /* application signature */
604   unsigned char  fast_open;                    /* flag that reminds us we didn't check headers at open */
605   unsigned short wrt_pass_cntr;                /* write pass counter */
606   int      update_frame_cntr;                  /* update frame counter */
607   int      onstream_write_error;               /* write error recovery active */
608   int      header_ok;                          /* header frame verified ok */
609   int      linux_media;                        /* reading linux-specifc media */
610   int      linux_media_version;
611   os_header_t * header_cache;		       /* cache is kept for filemark positions */
612   int      filemark_cnt;
613   int      first_mark_ppos;
614   int      last_mark_ppos;
615   int      last_mark_lbn;			/* storing log_blk_num of last mark is extends ADR spec */
616   int      first_data_ppos;
617   int      eod_frame_ppos;
618   int      eod_frame_lfa;
619   int      write_type;				/* used in write error recovery */
620   int      read_error_frame;			/* used in read error recovery */
621   unsigned long cmd_start_time;
622   unsigned long max_cmd_time;
623 
624 #if DEBUG
625   unsigned char write_pending;
626   int nbr_finished;
627   int nbr_waits;
628   unsigned char last_cmnd[6];
629   unsigned char last_sense[16];
630 #endif
631 } OS_Scsi_Tape;
632 
633 /* Values of write_type */
634 #define OS_WRITE_DATA      0
635 #define OS_WRITE_EOD       1
636 #define OS_WRITE_NEW_MARK  2
637 #define OS_WRITE_LAST_MARK 3
638 #define OS_WRITE_HEADER    4
639 #define OS_WRITE_FILLER    5
640 
641 /* Additional rw state */
642 #define OS_WRITING_COMPLETE 3
643