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