File: /usr/src/linux/drivers/scsi/st.h
1
2 #ifndef _ST_H
3 #define _ST_H
4 /*
5 $Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/st.h,v 1.1 1992/04/24 18:01:50 root Exp root $
6 */
7
8 #ifndef _SCSI_H
9 #include "scsi.h"
10 #endif
11 #include <linux/devfs_fs_kernel.h>
12 #include <linux/completion.h>
13
14 /* The tape buffer descriptor. */
15 typedef struct {
16 unsigned char in_use;
17 unsigned char dma; /* DMA-able buffer */
18 int buffer_size;
19 int buffer_blocks;
20 int buffer_bytes;
21 int read_pointer;
22 int writing;
23 int midlevel_result;
24 int syscall_result;
25 Scsi_Request *last_SRpnt;
26 unsigned char *b_data;
27 unsigned short use_sg; /* zero or number of segments for this adapter */
28 unsigned short sg_segs; /* total number of allocated segments */
29 unsigned short orig_sg_segs; /* number of segments allocated at first try */
30 struct scatterlist sg[1]; /* MUST BE last item */
31 } ST_buffer;
32
33
34 /* The tape mode definition */
35 typedef struct {
36 unsigned char defined;
37 unsigned char sysv; /* SYS V semantics? */
38 unsigned char do_async_writes;
39 unsigned char do_buffer_writes;
40 unsigned char do_read_ahead;
41 unsigned char defaults_for_writes;
42 unsigned char default_compression; /* 0 = don't touch, etc */
43 short default_density; /* Forced density, -1 = no value */
44 int default_blksize; /* Forced blocksize, -1 = no value */
45 } ST_mode;
46
47 #define ST_NBR_MODE_BITS 2
48 #define ST_NBR_MODES (1 << ST_NBR_MODE_BITS)
49 #define ST_MODE_SHIFT (7 - ST_NBR_MODE_BITS)
50 #define ST_MODE_MASK ((ST_NBR_MODES - 1) << ST_MODE_SHIFT)
51 #define ST_MAX_TAPES (1 << ST_MODE_SHIFT)
52
53 /* The status related to each partition */
54 typedef struct {
55 unsigned char rw;
56 unsigned char eof;
57 unsigned char at_sm;
58 unsigned char last_block_valid;
59 u32 last_block_visited;
60 int drv_block; /* The block where the drive head is */
61 int drv_file;
62 } ST_partstat;
63
64 #define ST_NBR_PARTITIONS 4
65
66 /* The tape drive descriptor */
67 typedef struct {
68 kdev_t devt;
69 Scsi_Device *device;
70 struct semaphore lock; /* For serialization */
71 struct completion wait; /* For SCSI commands */
72 ST_buffer *buffer;
73
74 /* Drive characteristics */
75 unsigned char omit_blklims;
76 unsigned char do_auto_lock;
77 unsigned char can_bsr;
78 unsigned char can_partitions;
79 unsigned char two_fm;
80 unsigned char fast_mteom;
81 unsigned char restr_dma;
82 unsigned char scsi2_logical;
83 unsigned char default_drvbuffer; /* 0xff = don't touch, value 3 bits */
84 unsigned char use_pf; /* Set Page Format bit in all mode selects? */
85 int tape_type;
86 int write_threshold;
87 int timeout; /* timeout for normal commands */
88 int long_timeout; /* timeout for commands known to take long time */
89
90 /* Mode characteristics */
91 ST_mode modes[ST_NBR_MODES];
92 int current_mode;
93 devfs_handle_t de_r[ST_NBR_MODES]; /* Rewind entries */
94 devfs_handle_t de_n[ST_NBR_MODES]; /* No-rewind entries */
95
96 /* Status variables */
97 int partition;
98 int new_partition;
99 int nbr_partitions; /* zero until partition support enabled */
100 ST_partstat ps[ST_NBR_PARTITIONS];
101 unsigned char dirty;
102 unsigned char ready;
103 unsigned char write_prot;
104 unsigned char drv_write_prot;
105 unsigned char in_use;
106 unsigned char blksize_changed;
107 unsigned char density_changed;
108 unsigned char compression_changed;
109 unsigned char drv_buffer;
110 unsigned char density;
111 unsigned char door_locked;
112 unsigned char autorew_dev; /* auto-rewind device */
113 unsigned char rew_at_close; /* rewind necessary at close */
114 unsigned char inited;
115 int block_size;
116 int min_block;
117 int max_block;
118 int recover_count; /* From tape opening */
119 int recover_reg; /* From last status call */
120
121 #if DEBUG
122 unsigned char write_pending;
123 int nbr_finished;
124 int nbr_waits;
125 unsigned char last_cmnd[6];
126 unsigned char last_sense[16];
127 #endif
128 } Scsi_Tape;
129
130 /* Bit masks for use_pf */
131 #define USE_PF 1
132 #define PF_TESTED 2
133
134 /* Values of eof */
135 #define ST_NOEOF 0
136 #define ST_FM_HIT 1
137 #define ST_FM 2
138 #define ST_EOM_OK 3
139 #define ST_EOM_ERROR 4
140 #define ST_EOD_1 5
141 #define ST_EOD_2 6
142 #define ST_EOD 7
143 /* EOD hit while reading => ST_EOD_1 => return zero => ST_EOD_2 =>
144 return zero => ST_EOD, return ENOSPC */
145
146 /* Values of rw */
147 #define ST_IDLE 0
148 #define ST_READING 1
149 #define ST_WRITING 2
150
151 /* Values of ready state */
152 #define ST_READY 0
153 #define ST_NOT_READY 1
154 #define ST_NO_TAPE 2
155
156 /* Values for door lock state */
157 #define ST_UNLOCKED 0
158 #define ST_LOCKED_EXPLICIT 1
159 #define ST_LOCKED_AUTO 2
160 #define ST_LOCK_FAILS 3
161
162 /* Positioning SCSI-commands for Tandberg, etc. drives */
163 #define QFA_REQUEST_BLOCK 0x02
164 #define QFA_SEEK_BLOCK 0x0c
165
166 /* Setting the binary options */
167 #define ST_DONT_TOUCH 0
168 #define ST_NO 1
169 #define ST_YES 2
170
171 #endif
172