1
2
3
4
5
6#include <asm/byteorder.h>
7#include <linux/completion.h>
8#include <linux/mutex.h>
9
10
11
12
13
14typedef struct {
15 unsigned device_type :5;
16 unsigned reserved0_765 :3;
17 unsigned reserved1_6t0 :7;
18 unsigned rmb :1;
19 unsigned ansi_version :3;
20 unsigned ecma_version :3;
21 unsigned iso_version :2;
22 unsigned response_format :4;
23 unsigned reserved3_45 :2;
24 unsigned reserved3_6 :1;
25 unsigned reserved3_7 :1;
26 u8 additional_length;
27 u8 rsv5, rsv6, rsv7;
28 u8 vendor_id[8];
29 u8 product_id[16];
30 u8 revision_level[4];
31 u8 vendor_specific[20];
32 u8 reserved56t95[40];
33
34} idetape_inquiry_result_t;
35
36
37
38
39typedef struct {
40 unsigned reserved0_10 :2;
41 unsigned bpu :1;
42 unsigned reserved0_543 :3;
43 unsigned eop :1;
44 unsigned bop :1;
45 u8 partition;
46 u8 reserved2, reserved3;
47 u32 first_block;
48 u32 last_block;
49 u8 reserved12;
50 u8 blocks_in_buffer[3];
51 u32 bytes_in_buffer;
52} idetape_read_position_result_t;
53
54
55
56
57
58#define COMPRESSION_PAGE 0x0f
59#define COMPRESSION_PAGE_LENGTH 16
60
61#define CAPABILITIES_PAGE 0x2a
62#define CAPABILITIES_PAGE_LENGTH 20
63
64#define TAPE_PARAMTR_PAGE 0x2b
65#define TAPE_PARAMTR_PAGE_LENGTH 16
66
67#define NUMBER_RETRIES_PAGE 0x2f
68#define NUMBER_RETRIES_PAGE_LENGTH 4
69
70#define BLOCK_SIZE_PAGE 0x30
71#define BLOCK_SIZE_PAGE_LENGTH 4
72
73#define BUFFER_FILLING_PAGE 0x33
74#define BUFFER_FILLING_PAGE_LENGTH 4
75
76#define VENDOR_IDENT_PAGE 0x36
77#define VENDOR_IDENT_PAGE_LENGTH 8
78
79#define LOCATE_STATUS_PAGE 0x37
80#define LOCATE_STATUS_PAGE_LENGTH 0
81
82#define MODE_HEADER_LENGTH 4
83
84
85
86
87
88typedef struct {
89 unsigned error_code :7;
90 unsigned valid :1;
91 u8 reserved1 :8;
92 unsigned sense_key :4;
93 unsigned reserved2_4 :1;
94 unsigned ili :1;
95 unsigned eom :1;
96 unsigned filemark :1;
97 u32 information __attribute__ ((packed));
98 u8 asl;
99 u32 command_specific;
100 u8 asc;
101 u8 ascq;
102 u8 replaceable_unit_code;
103 unsigned sk_specific1 :7;
104 unsigned sksv :1;
105 u8 sk_specific2;
106 u8 sk_specific3;
107 u8 pad[2];
108} idetape_request_sense_result_t;
109
110
111
112
113typedef struct {
114 u8 mode_data_length;
115 u8 medium_type;
116 u8 dsp;
117 u8 bdl;
118} osst_mode_parameter_header_t;
119
120
121
122
123
124
125typedef struct {
126 u8 density_code;
127 u8 blocks[3];
128 u8 reserved4;
129 u8 length[3];
130} osst_parameter_block_descriptor_t;
131
132
133
134
135typedef struct {
136#if defined(__BIG_ENDIAN_BITFIELD)
137 unsigned ps :1;
138 unsigned reserved0 :1;
139 unsigned page_code :6;
140#elif defined(__LITTLE_ENDIAN_BITFIELD)
141 unsigned page_code :6;
142 unsigned reserved0 :1;
143 unsigned ps :1;
144#else
145#error "Please fix <asm/byteorder.h>"
146#endif
147 u8 page_length;
148#if defined(__BIG_ENDIAN_BITFIELD)
149 unsigned dce :1;
150 unsigned dcc :1;
151 unsigned reserved2 :6;
152#elif defined(__LITTLE_ENDIAN_BITFIELD)
153 unsigned reserved2 :6;
154 unsigned dcc :1;
155 unsigned dce :1;
156#else
157#error "Please fix <asm/byteorder.h>"
158#endif
159#if defined(__BIG_ENDIAN_BITFIELD)
160 unsigned dde :1;
161 unsigned red :2;
162 unsigned reserved3 :5;
163#elif defined(__LITTLE_ENDIAN_BITFIELD)
164 unsigned reserved3 :5;
165 unsigned red :2;
166 unsigned dde :1;
167#else
168#error "Please fix <asm/byteorder.h>"
169#endif
170 u32 ca;
171 u32 da;
172 u8 reserved[4];
173} osst_data_compression_page_t;
174
175
176
177
178typedef struct {
179#if defined(__BIG_ENDIAN_BITFIELD)
180 unsigned ps :1;
181 unsigned reserved1_6 :1;
182 unsigned page_code :6;
183#elif defined(__LITTLE_ENDIAN_BITFIELD)
184 unsigned page_code :6;
185 unsigned reserved1_6 :1;
186 unsigned ps :1;
187#else
188#error "Please fix <asm/byteorder.h>"
189#endif
190 u8 page_length;
191 u8 map;
192 u8 apd;
193#if defined(__BIG_ENDIAN_BITFIELD)
194 unsigned fdp :1;
195 unsigned sdp :1;
196 unsigned idp :1;
197 unsigned psum :2;
198 unsigned reserved4_012 :3;
199#elif defined(__LITTLE_ENDIAN_BITFIELD)
200 unsigned reserved4_012 :3;
201 unsigned psum :2;
202 unsigned idp :1;
203 unsigned sdp :1;
204 unsigned fdp :1;
205#else
206#error "Please fix <asm/byteorder.h>"
207#endif
208 u8 mfr;
209 u8 reserved[2];
210} osst_medium_partition_page_t;
211
212
213
214
215typedef struct {
216#if defined(__BIG_ENDIAN_BITFIELD)
217 unsigned reserved1_67 :2;
218 unsigned page_code :6;
219#elif defined(__LITTLE_ENDIAN_BITFIELD)
220 unsigned page_code :6;
221 unsigned reserved1_67 :2;
222#else
223#error "Please fix <asm/byteorder.h>"
224#endif
225 u8 page_length;
226 u8 reserved2, reserved3;
227#if defined(__BIG_ENDIAN_BITFIELD)
228 unsigned reserved4_67 :2;
229 unsigned sprev :1;
230 unsigned reserved4_1234 :4;
231 unsigned ro :1;
232#elif defined(__LITTLE_ENDIAN_BITFIELD)
233 unsigned ro :1;
234 unsigned reserved4_1234 :4;
235 unsigned sprev :1;
236 unsigned reserved4_67 :2;
237#else
238#error "Please fix <asm/byteorder.h>"
239#endif
240#if defined(__BIG_ENDIAN_BITFIELD)
241 unsigned reserved5_67 :2;
242 unsigned qfa :1;
243 unsigned reserved5_4 :1;
244 unsigned efmt :1;
245 unsigned reserved5_012 :3;
246#elif defined(__LITTLE_ENDIAN_BITFIELD)
247 unsigned reserved5_012 :3;
248 unsigned efmt :1;
249 unsigned reserved5_4 :1;
250 unsigned qfa :1;
251 unsigned reserved5_67 :2;
252#else
253#error "Please fix <asm/byteorder.h>"
254#endif
255#if defined(__BIG_ENDIAN_BITFIELD)
256 unsigned cmprs :1;
257 unsigned ecc :1;
258 unsigned reserved6_45 :2;
259 unsigned eject :1;
260 unsigned prevent :1;
261 unsigned locked :1;
262 unsigned lock :1;
263#elif defined(__LITTLE_ENDIAN_BITFIELD)
264 unsigned lock :1;
265 unsigned locked :1;
266 unsigned prevent :1;
267 unsigned eject :1;
268 unsigned reserved6_45 :2;
269 unsigned ecc :1;
270 unsigned cmprs :1;
271#else
272#error "Please fix <asm/byteorder.h>"
273#endif
274#if defined(__BIG_ENDIAN_BITFIELD)
275 unsigned blk32768 :1;
276
277
278 unsigned reserved7_3_6 :4;
279 unsigned blk1024 :1;
280 unsigned blk512 :1;
281 unsigned reserved7_0 :1;
282#elif defined(__LITTLE_ENDIAN_BITFIELD)
283 unsigned reserved7_0 :1;
284 unsigned blk512 :1;
285 unsigned blk1024 :1;
286 unsigned reserved7_3_6 :4;
287 unsigned blk32768 :1;
288
289
290#else
291#error "Please fix <asm/byteorder.h>"
292#endif
293 __be16 max_speed;
294 u8 reserved10, reserved11;
295 __be16 ctl;
296 __be16 speed;
297 __be16 buffer_size;
298 u8 reserved18, reserved19;
299} osst_capabilities_page_t;
300
301
302
303
304typedef struct {
305#if defined(__BIG_ENDIAN_BITFIELD)
306 unsigned ps :1;
307 unsigned reserved1_6 :1;
308 unsigned page_code :6;
309#elif defined(__LITTLE_ENDIAN_BITFIELD)
310 unsigned page_code :6;
311 unsigned reserved1_6 :1;
312 unsigned ps :1;
313#else
314#error "Please fix <asm/byteorder.h>"
315#endif
316 u8 page_length;
317 u8 reserved2;
318#if defined(__BIG_ENDIAN_BITFIELD)
319 unsigned one :1;
320 unsigned reserved2_6 :1;
321 unsigned record32_5 :1;
322 unsigned record32 :1;
323 unsigned reserved2_23 :2;
324 unsigned play32_5 :1;
325 unsigned play32 :1;
326#elif defined(__LITTLE_ENDIAN_BITFIELD)
327 unsigned play32 :1;
328 unsigned play32_5 :1;
329 unsigned reserved2_23 :2;
330 unsigned record32 :1;
331 unsigned record32_5 :1;
332 unsigned reserved2_6 :1;
333 unsigned one :1;
334#else
335#error "Please fix <asm/byteorder.h>"
336#endif
337} osst_block_size_page_t;
338
339
340
341
342typedef struct {
343#if defined(__BIG_ENDIAN_BITFIELD)
344 unsigned ps :1;
345 unsigned reserved1_6 :1;
346 unsigned page_code :6;
347#elif defined(__LITTLE_ENDIAN_BITFIELD)
348 unsigned page_code :6;
349 unsigned reserved1_6 :1;
350 unsigned ps :1;
351#else
352#error "Please fix <asm/byteorder.h>"
353#endif
354 u8 reserved2;
355 u8 density;
356 u8 reserved3,reserved4;
357 __be16 segtrk;
358 __be16 trks;
359 u8 reserved5,reserved6,reserved7,reserved8,reserved9,reserved10;
360} osst_tape_paramtr_page_t;
361
362
363
364#define OS_CONFIG_PARTITION (0xff)
365#define OS_DATA_PARTITION (0)
366#define OS_PARTITION_VERSION (1)
367
368
369
370
371typedef struct os_partition_s {
372 __u8 partition_num;
373 __u8 par_desc_ver;
374 __be16 wrt_pass_cntr;
375 __be32 first_frame_ppos;
376 __be32 last_frame_ppos;
377 __be32 eod_frame_ppos;
378} os_partition_t;
379
380
381
382
383typedef struct os_dat_entry_s {
384 __be32 blk_sz;
385 __be16 blk_cnt;
386 __u8 flags;
387 __u8 reserved;
388} os_dat_entry_t;
389
390
391
392
393#define OS_DAT_FLAGS_DATA (0xc)
394#define OS_DAT_FLAGS_MARK (0x1)
395
396typedef struct os_dat_s {
397 __u8 dat_sz;
398 __u8 reserved1;
399 __u8 entry_cnt;
400 __u8 reserved3;
401 os_dat_entry_t dat_list[16];
402} os_dat_t;
403
404
405
406
407#define OS_FRAME_TYPE_FILL (0)
408#define OS_FRAME_TYPE_EOD (1 << 0)
409#define OS_FRAME_TYPE_MARKER (1 << 1)
410#define OS_FRAME_TYPE_HEADER (1 << 3)
411#define OS_FRAME_TYPE_DATA (1 << 7)
412
413
414
415
416typedef struct os_aux_s {
417 __be32 format_id;
418 char application_sig[4];
419 __be32 hdwr;
420 __be32 update_frame_cntr;
421 __u8 frame_type;
422 __u8 frame_type_reserved;
423 __u8 reserved_18_19[2];
424 os_partition_t partition;
425 __u8 reserved_36_43[8];
426 __be32 frame_seq_num;
427 __be32 logical_blk_num_high;
428 __be32 logical_blk_num;
429 os_dat_t dat;
430 __u8 reserved188_191[4];
431 __be32 filemark_cnt;
432 __be32 phys_fm;
433 __be32 last_mark_ppos;
434 __u8 reserved204_223[20];
435
436
437
438
439
440
441 __be32 next_mark_ppos;
442 __be32 last_mark_lbn;
443 __u8 linux_specific[24];
444
445 __u8 reserved_256_511[256];
446} os_aux_t;
447
448#define OS_FM_TAB_MAX 1024
449
450typedef struct os_fm_tab_s {
451 __u8 fm_part_num;
452 __u8 reserved_1;
453 __u8 fm_tab_ent_sz;
454 __u8 reserved_3;
455 __be16 fm_tab_ent_cnt;
456 __u8 reserved6_15[10];
457 __be32 fm_tab_ent[OS_FM_TAB_MAX];
458} os_fm_tab_t;
459
460typedef struct os_ext_trk_ey_s {
461 __u8 et_part_num;
462 __u8 fmt;
463 __be16 fm_tab_off;
464 __u8 reserved4_7[4];
465 __be32 last_hlb_hi;
466 __be32 last_hlb;
467 __be32 last_pp;
468 __u8 reserved20_31[12];
469} os_ext_trk_ey_t;
470
471typedef struct os_ext_trk_tb_s {
472 __u8 nr_stream_part;
473 __u8 reserved_1;
474 __u8 et_ent_sz;
475 __u8 reserved3_15[13];
476 os_ext_trk_ey_t dat_ext_trk_ey;
477 os_ext_trk_ey_t qfa_ext_trk_ey;
478} os_ext_trk_tb_t;
479
480typedef struct os_header_s {
481 char ident_str[8];
482 __u8 major_rev;
483 __u8 minor_rev;
484 __be16 ext_trk_tb_off;
485 __u8 reserved12_15[4];
486 __u8 pt_par_num;
487 __u8 pt_reserved1_3[3];
488 os_partition_t partition[16];
489 __be32 cfg_col_width;
490 __be32 dat_col_width;
491 __be32 qfa_col_width;
492 __u8 cartridge[16];
493 __u8 reserved304_511[208];
494 __be32 old_filemark_list[16680/4];
495 os_ext_trk_tb_t ext_track_tb;
496 __u8 reserved17272_17735[464];
497 os_fm_tab_t dat_fm_tab;
498 os_fm_tab_t qfa_fm_tab;
499 __u8 reserved25960_32767[6808];
500} os_header_t;
501
502
503
504
505
506#define OS_FRAME_SIZE (32 * 1024 + 512)
507#define OS_DATA_SIZE (32 * 1024)
508#define OS_AUX_SIZE (512)
509
510
511
512struct osst_buffer {
513 unsigned char in_use;
514 unsigned char dma;
515 int buffer_size;
516 int buffer_blocks;
517 int buffer_bytes;
518 int read_pointer;
519 int writing;
520 int midlevel_result;
521 int syscall_result;
522 struct osst_request *last_SRpnt;
523 struct st_cmdstatus cmdstat;
524 struct rq_map_data map_data;
525 unsigned char *b_data;
526 os_aux_t *aux;
527 unsigned short use_sg;
528 unsigned short sg_segs;
529 unsigned short orig_sg_segs;
530 struct scatterlist sg[1];
531} ;
532
533
534struct osst_tape {
535 struct scsi_driver *driver;
536 unsigned capacity;
537 struct scsi_device *device;
538 struct mutex lock;
539 struct completion wait;
540 struct osst_buffer * buffer;
541
542
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;
552 unsigned char pos_unknown;
553 int write_threshold;
554 int timeout;
555 int long_timeout;
556
557
558 struct st_modedef modes[ST_NBR_MODES];
559 int current_mode;
560
561
562 int partition;
563 int new_partition;
564 int nbr_partitions;
565 struct st_partstat ps[ST_NBR_PARTITIONS];
566 unsigned char dirty;
567 unsigned char ready;
568 unsigned char write_prot;
569 unsigned char drv_write_prot;
570 unsigned char in_use;
571 unsigned char blksize_changed;
572 unsigned char density_changed;
573 unsigned char compression_changed;
574 unsigned char drv_buffer;
575 unsigned char density;
576 unsigned char door_locked;
577 unsigned char rew_at_close;
578 unsigned char inited;
579 int block_size;
580 int min_block;
581 int max_block;
582 int recover_count;
583 int abort_count;
584 int write_count;
585 int read_count;
586 int recover_erreg;
587
588
589
590 int os_fw_rev;
591 unsigned char raw;
592 unsigned char poll;
593 unsigned char frame_in_buffer;
594
595 int frame_seq_number;
596 int logical_blk_num;
597 unsigned first_frame_position;
598 unsigned last_frame_position;
599 int cur_frames;
600 int max_frames;
601 char application_sig[5];
602 unsigned char fast_open;
603 unsigned short wrt_pass_cntr;
604 int update_frame_cntr;
605 int onstream_write_error;
606 int header_ok;
607 int linux_media;
608 int linux_media_version;
609 os_header_t * header_cache;
610 int filemark_cnt;
611 int first_mark_ppos;
612 int last_mark_ppos;
613 int last_mark_lbn;
614 int first_data_ppos;
615 int eod_frame_ppos;
616 int eod_frame_lfa;
617 int write_type;
618 int read_error_frame;
619 unsigned long cmd_start_time;
620 unsigned long max_cmd_time;
621
622#if DEBUG
623 unsigned char write_pending;
624 int nbr_finished;
625 int nbr_waits;
626 unsigned char last_cmnd[6];
627 unsigned char last_sense[16];
628#endif
629 struct gendisk *drive;
630} ;
631
632
633struct osst_request {
634 unsigned char cmd[MAX_COMMAND_SIZE];
635 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
636 int result;
637 struct osst_tape *stp;
638 struct completion *waiting;
639 struct bio *bio;
640};
641
642
643#define OS_WRITE_DATA 0
644#define OS_WRITE_EOD 1
645#define OS_WRITE_NEW_MARK 2
646#define OS_WRITE_LAST_MARK 3
647#define OS_WRITE_HEADER 4
648#define OS_WRITE_FILLER 5
649
650
651#define OS_WRITING_COMPLETE 3
652