1 /* check-sources:disable-copyright-check */
2 /* Structures and definitions for magnetic tape I/O control commands.
3    Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
5 
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10 
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15 
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20 
21 /* Written by H. Bergman <hennus@cybercomm.nl>.  */
22 
23 #ifndef _SYS_MTIO_H
24 #define _SYS_MTIO_H 1
25 
26 /* Get necessary definitions from system and kernel headers.  */
27 #include <sys/types.h>
28 #include <sys/ioctl.h>
29 
30 
31 /* Structure for MTIOCTOP - magnetic tape operation command.  */
32 struct mtop {
33   short int mt_op; /* Operations defined below.  */
34   int mt_count;    /* How many of them.  */
35 };
36 #define _IOT_mtop /* Hurd ioctl type field.  */ \
37   _IOT(_IOTS(short), 1, _IOTS(int), 1, 0, 0)
38 
39 /* Magnetic Tape operations [Not all operations supported by all drivers].  */
40 #define MTRESET 0 /* +reset drive in case of problems.  */
41 #define MTFSF                                     \
42   1               /* Forward space over FileMark, \
43                    * position at first record of next file.  */
44 #define MTBSF 2   /* Backward space FileMark (position before FM).  */
45 #define MTFSR 3   /* Forward space record.  */
46 #define MTBSR 4   /* Backward space record.  */
47 #define MTWEOF 5  /* Write an end-of-file record (mark).  */
48 #define MTREW 6   /* Rewind.  */
49 #define MTOFFL 7  /* Rewind and put the drive offline (eject?).  */
50 #define MTNOP 8   /* No op, set status only (read with MTIOCGET).  */
51 #define MTRETEN 9 /* Retension tape.  */
52 #define MTBSFM 10 /* +backward space FileMark, position at FM.  */
53 #define MTFSFM 11 /* +forward space FileMark, position at FM.  */
54 #define MTEOM                                                           \
55   12               /* Goto end of recorded media (for appending files). \
56                       MTEOM positions after the last FM, ready for      \
57                       appending another file.  */
58 #define MTERASE 13 /* Erase tape -- be careful!  */
59 
60 #define MTRAS1 14 /* Run self test 1 (nondestructive).  */
61 #define MTRAS2 15 /* Run self test 2 (destructive).  */
62 #define MTRAS3 16 /* Reserved for self test 3.  */
63 
64 #define MTSETBLK 20     /* Set block length (SCSI).  */
65 #define MTSETDENSITY 21 /* Set tape density (SCSI).  */
66 #define MTSEEK 22       /* Seek to block (Tandberg, etc.).  */
67 #define MTTELL 23       /* Tell block (Tandberg, etc.).  */
68 #define MTSETDRVBUFFER                                           \
69   24             /* Set the drive buffering according to SCSI-2. \
70                     Ordinary buffered operation with code 1.  */
71 #define MTFSS 25 /* Space forward over setmarks.  */
72 #define MTBSS 26 /* Space backward over setmarks.  */
73 #define MTWSM 27 /* Write setmarks.  */
74 
75 #define MTLOCK 28        /* Lock the drive door.  */
76 #define MTUNLOCK 29      /* Unlock the drive door.  */
77 #define MTLOAD 30        /* Execute the SCSI load command.  */
78 #define MTUNLOAD 31      /* Execute the SCSI unload command.  */
79 #define MTCOMPRESSION 32 /* Control compression with SCSI mode page 15.  */
80 #define MTSETPART 33     /* Change the active tape partition.  */
81 #define MTMKPART 34      /* Format the tape with one or two partitions.  */
82 
83 /* structure for MTIOCGET - mag tape get status command */
84 
85 struct mtget {
86   long int mt_type;  /* Type of magtape device.  */
87   long int mt_resid; /* Residual count: (not sure)
88                         number of bytes ignored, or
89                         number of files not skipped, or
90                         number of records not skipped.  */
91   /* The following registers are device dependent.  */
92   long int mt_dsreg; /* Status register.  */
93   long int mt_gstat; /* Generic (device independent) status.  */
94   long int mt_erreg; /* Error register.  */
95   /* The next two fields are not always used.  */
96   __daddr_t mt_fileno; /* Number of current file on tape.  */
97   __daddr_t mt_blkno;  /* Current block number.  */
98 };
99 #define _IOT_mtget /* Hurd ioctl type field.  */ \
100   _IOT(_IOTS(long), 7, 0, 0, 0, 0)
101 
102 
103 /* Constants for mt_type. Not all of these are supported, and
104    these are not all of the ones that are supported.  */
105 #define MT_ISUNKNOWN 0x01
106 #define MT_ISQIC02 0x02              /* Generic QIC-02 tape streamer.  */
107 #define MT_ISWT5150 0x03             /* Wangtek 5150EQ, QIC-150, QIC-02.  */
108 #define MT_ISARCHIVE_5945L2 0x04     /* Archive 5945L-2, QIC-24, QIC-02?. */
109 #define MT_ISCMSJ500 0x05            /* CMS Jumbo 500 (QIC-02?).  */
110 #define MT_ISTDC3610 0x06            /* Tandberg 6310, QIC-24.  */
111 #define MT_ISARCHIVE_VP60I 0x07      /* Archive VP60i, QIC-02.  */
112 #define MT_ISARCHIVE_2150L 0x08      /* Archive Viper 2150L.  */
113 #define MT_ISARCHIVE_2060L 0x09      /* Archive Viper 2060L.  */
114 #define MT_ISARCHIVESC499 0x0A       /* Archive SC-499 QIC-36 controller. */
115 #define MT_ISQIC02_ALL_FEATURES 0x0F /* Generic QIC-02 with all features. */
116 #define MT_ISWT5099EEN24 0x11        /* Wangtek 5099-een24, 60MB, QIC-24. */
117 #define MT_ISTEAC_MT2ST                                    \
118   0x12                         /* Teac MT-2ST 155mb drive, \
119                                   Teac DC-1 card (Wangtek type).  */
120 #define MT_ISEVEREX_FT40A 0x32 /* Everex FT40A (QIC-40).  */
121 #define MT_ISDDS1 0x51         /* DDS device without partitions.  */
122 #define MT_ISDDS2 0x52         /* DDS device with partitions.  */
123 #define MT_ISSCSI1 0x71        /* Generic ANSI SCSI-1 tape unit.  */
124 #define MT_ISSCSI2 0x72        /* Generic ANSI SCSI-2 tape unit.  */
125 
126 /* QIC-40/80/3010/3020 ftape supported drives.
127    20bit vendor ID + 0x800000 (see vendors.h in ftape distribution).  */
128 #define MT_ISFTAPE_UNKNOWN 0x800000 /* obsolete */
129 #define MT_ISFTAPE_FLAG 0x800000
130 
131 struct mt_tape_info {
132   long int t_type; /* Device type id (mt_type).  */
133   char* t_name;    /* Descriptive name.  */
134 };
135 
136 #define MT_TAPE_INFO                                                    \
137   {                                                                     \
138     {MT_ISUNKNOWN, "Unknown type of tape device"},                      \
139         {MT_ISQIC02, "Generic QIC-02 tape streamer"},                   \
140         {MT_ISWT5150, "Wangtek 5150, QIC-150"},                         \
141         {MT_ISARCHIVE_5945L2, "Archive 5945L-2"},                       \
142         {MT_ISCMSJ500, "CMS Jumbo 500"},                                \
143         {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"},                    \
144         {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"},                  \
145         {MT_ISARCHIVE_2150L, "Archive Viper 2150L"},                    \
146         {MT_ISARCHIVE_2060L, "Archive Viper 2060L"},                    \
147         {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"},        \
148         {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
149         {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"},                 \
150         {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"},     \
151         {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"},                    \
152         {MT_ISSCSI1, "Generic SCSI-1 tape"},                            \
153         {MT_ISSCSI2, "Generic SCSI-2 tape"},                            \
154     {                                                                   \
155       0, NULL                                                           \
156     }                                                                   \
157   }
158 
159 
160 /* Structure for MTIOCPOS - mag tape get position command.  */
161 
162 struct mtpos {
163   long int mt_blkno; /* Current block number.  */
164 };
165 #define _IOT_mtpos /* Hurd ioctl type field.  */ _IOT_SIMPLE(long)
166 
167 
168 /* Structure for MTIOCGETCONFIG/MTIOCSETCONFIG primarily intended
169    as an interim solution for QIC-02 until DDI is fully implemented.  */
170 struct mtconfiginfo {
171   long int mt_type;         /* Drive type.  */
172   long int ifc_type;        /* Interface card type.  */
173   unsigned short int irqnr; /* IRQ number to use.  */
174   unsigned short int dmanr; /* DMA channel to use.  */
175   unsigned short int port;  /* IO port base address.  */
176 
177   unsigned long int debug; /* Debugging flags.  */
178 
179   unsigned have_dens : 1;
180   unsigned have_bsf : 1;
181   unsigned have_fsr : 1;
182   unsigned have_bsr : 1;
183   unsigned have_eod : 1;
184   unsigned have_seek : 1;
185   unsigned have_tell : 1;
186   unsigned have_ras1 : 1;
187   unsigned have_ras2 : 1;
188   unsigned have_ras3 : 1;
189   unsigned have_qfa : 1;
190 
191   unsigned pad1 : 5;
192   char reserved[10];
193 };
194 #define _IOT_mtconfiginfo /* Hurd ioctl type field.  */ \
195   _IOT(_IOTS(long), 2, _IOTS(short), 3, _IOTS(long), 1) /* XXX wrong */
196 
197 
198 /* Magnetic tape I/O control commands.  */
199 #define MTIOCTOP _IOW('m', 1, struct mtop)  /* Do a mag tape op. */
200 #define MTIOCGET _IOR('m', 2, struct mtget) /* Get tape status.  */
201 #define MTIOCPOS _IOR('m', 3, struct mtpos) /* Get tape position.*/
202 
203 /* The next two are used by the QIC-02 driver for runtime reconfiguration.
204    See tpqic02.h for struct mtconfiginfo.  */
205 #define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo) /* Get tape config.*/
206 #define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo) /* Set tape config.*/
207 
208 /* Generic Mag Tape (device independent) status macros for examining
209    mt_gstat -- HP-UX compatible.
210    There is room for more generic status bits here, but I don't
211    know which of them are reserved. At least three or so should
212    be added to make this really useful.  */
213 #define GMT_EOF(x) ((x)&0x80000000)
214 #define GMT_BOT(x) ((x)&0x40000000)
215 #define GMT_EOT(x) ((x)&0x20000000)
216 #define GMT_SM(x) ((x)&0x10000000)  /* DDS setmark */
217 #define GMT_EOD(x) ((x)&0x08000000) /* DDS EOD */
218 #define GMT_WR_PROT(x) ((x)&0x04000000)
219 /* #define GMT_ ?       ((x) & 0x02000000) */
220 #define GMT_ONLINE(x) ((x)&0x01000000)
221 #define GMT_D_6250(x) ((x)&0x00800000)
222 #define GMT_D_1600(x) ((x)&0x00400000)
223 #define GMT_D_800(x) ((x)&0x00200000)
224 /* #define GMT_ ?       ((x) & 0x00100000) */
225 /* #define GMT_ ?       ((x) & 0x00080000) */
226 #define GMT_DR_OPEN(x) ((x)&0x00040000) /* Door open (no tape).  */
227 /* #define GMT_ ?       ((x) & 0x00020000) */
228 #define GMT_IM_REP_EN(x) ((x)&0x00010000) /* Immediate report mode.*/
229 /* 16 generic status bits unused.  */
230 
231 
232 /* SCSI-tape specific definitions.  Bitfield shifts in the status  */
233 #define MT_ST_BLKSIZE_SHIFT 0
234 #define MT_ST_BLKSIZE_MASK 0xffffff
235 #define MT_ST_DENSITY_SHIFT 24
236 #define MT_ST_DENSITY_MASK 0xff000000
237 
238 #define MT_ST_SOFTERR_SHIFT 0
239 #define MT_ST_SOFTERR_MASK 0xffff
240 
241 /* Bitfields for the MTSETDRVBUFFER ioctl.  */
242 #define MT_ST_OPTIONS 0xf0000000
243 #define MT_ST_BOOLEANS 0x10000000
244 #define MT_ST_SETBOOLEANS 0x30000000
245 #define MT_ST_CLEARBOOLEANS 0x40000000
246 #define MT_ST_WRITE_THRESHOLD 0x20000000
247 #define MT_ST_DEF_BLKSIZE 0x50000000
248 #define MT_ST_DEF_OPTIONS 0x60000000
249 
250 #define MT_ST_BUFFER_WRITES 0x1
251 #define MT_ST_ASYNC_WRITES 0x2
252 #define MT_ST_READ_AHEAD 0x4
253 #define MT_ST_DEBUGGING 0x8
254 #define MT_ST_TWO_FM 0x10
255 #define MT_ST_FAST_MTEOM 0x20
256 #define MT_ST_AUTO_LOCK 0x40
257 #define MT_ST_DEF_WRITES 0x80
258 #define MT_ST_CAN_BSR 0x100
259 #define MT_ST_NO_BLKLIMS 0x200
260 #define MT_ST_CAN_PARTITIONS 0x400
261 #define MT_ST_SCSI2LOGICAL 0x800
262 
263 /* The mode parameters to be controlled. Parameter chosen with bits 20-28.  */
264 #define MT_ST_CLEAR_DEFAULT 0xfffff
265 #define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000)
266 #define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000)
267 #define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000)
268 
269 /* The offset for the arguments for the special HP changer load command.  */
270 #define MT_ST_HPLOADER_OFFSET 10000
271 
272 
273 /* Specify default tape device.  */
274 #ifndef DEFTAPE
275 #  define DEFTAPE "/dev/tape"
276 #endif
277 
278 #endif /* mtio.h */
279