OSDN Git Service

* include/cygwin/config.h (_GLIBC_EXTENSION): Define.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / include / cygwin / mtio.h
1 /* cygwin/mtio.h
2
3    Copyright 1999, 2001, 2004 Red Hat, Inc.
4
5    Written by Corinna Vinschen <corinna@vinschen.de>
6
7 This file is part of Cygwin.
8
9 This software is a copyrighted work licensed under the terms of the
10 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
11 details. */
12
13 /* cygwin/mtio.h header file for Cygwin.
14
15    by C. Vinschen.  */
16
17 #ifndef _CYGWIN_MTIO_H
18 #define _CYGWIN_MTIO_H
19
20 #include <sys/ioctl.h>
21 #include <asm/socket.h>
22
23 #ifndef DEFTAPE
24 #define DEFTAPE "/dev/tape"
25 #endif
26
27 /*
28  * Structures and definitions for mag tape io control commands
29  */
30
31 /* structure for MTIOCTOP - mag tape op command */
32 struct  mtop {
33         short   mt_op;          /* operations defined below */
34         int     mt_count;       /* how many of them */
35 };
36
37 /* Magnetic Tape operations [Not all operations supported by all drivers]: */
38 #define MTRESET 0       /* reset drive in case of problems */
39 #define MTFSF   1       /* forward space over FileMark,
40                          * position at first record of next file
41                          */
42 #define MTBSF   2       /* backward space FileMark (position before FM) */
43 #define MTFSR   3       /* forward space record */
44 #define MTBSR   4       /* backward space record */
45 #define MTWEOF  5       /* write an end-of-file record (mark) */
46 #define MTREW   6       /* rewind */
47 #define MTOFFL  7       /* rewind and put the drive offline (eject?) */
48 #define MTNOP   8       /* no op, set status only (read with MTIOCGET) */
49 #define MTRETEN 9       /* retension tape */
50 #define MTBSFM  10      /* +backward space FileMark, position at FM */
51 #define MTFSFM  11      /* +forward space FileMark, position at FM */
52 #define MTEOM   12      /* goto end of recorded media (for appending files).
53                          * MTEOM positions after the last FM, ready for
54                          * appending another file.
55                          */
56 #define MTERASE 13      /* erase tape -- be careful! */
57
58 #define MTRAS1  14      /* run self test 1 (nondestructive) */
59 #define MTRAS2  15      /* run self test 2 (destructive) */
60 #define MTRAS3  16      /* reserved for self test 3 */
61
62 #define MTSETBLK 20     /* set block length (SCSI) */
63 #define MTSETDENSITY 21 /* set tape density (SCSI) */
64 #define MTSEEK  22      /* seek to block (Tandberg, etc.) */
65 #define MTTELL  23      /* tell block (Tandberg, etc.) */
66 #define MTSETDRVBUFFER 24 /* set the drive buffering according to SCSI-2 */
67                         /* ordinary buffered operation with code 1 */
68 #define MTFSS   25      /* space forward over setmarks */
69 #define MTBSS   26      /* space backward over setmarks */
70 #define MTWSM   27      /* write setmarks */
71
72 #define MTLOCK  28      /* lock the drive door */
73 #define MTUNLOCK 29     /* unlock the drive door */
74 #define MTLOAD  30      /* execute the SCSI load command */
75 #define MTUNLOAD 31     /* execute the SCSI unload command */
76 #define MTCOMPRESSION 32/* control compression with SCSI mode page 15 */
77 #define MTSETPART 33    /* Change the active tape partition */
78 #define MTMKPART  34    /* Format the tape with one or two partitions */
79
80 /* structure for MTIOCGET - mag tape get status command */
81
82 struct  mtget {
83         long    mt_type;        /* type of magtape device */
84         long    mt_resid;       /* residual count: (not sure)
85                                  *      number of bytes ignored, or
86                                  *      number of files not skipped, or
87                                  *      number of records not skipped.
88                                  *  Cygwin: remaining KB until 1.5.7.
89                                  *          active partition since 1.5.8
90                                  *          (same as on GNU-Linux).
91                                  */
92         /* the following registers are device dependent */
93         long    mt_dsreg;       /* status register, Contains blocksize and
94                                    density code.  See MT_ST_xxx macros below */
95         long    mt_gstat;       /* generic (device independent) status */
96         long    mt_erreg;       /* error register */
97         /* The next two fields are not always used */
98         long    mt_fileno;      /* number of current file on tape */
99         long    mt_blkno;       /* current block number */
100         /* The next are Windows NT specific */
101         long long       mt_capacity;    /* Tape capacity in bytes */
102         long long       mt_remaining;   /* Remaining bytes */
103         int             mt_minblksize;
104         int             mt_maxblksize;
105         int             mt_defblksize;
106         unsigned long   mt_featureslow;
107         unsigned long   mt_featureshigh;
108         unsigned long   mt_eotwarningzonesize;
109 };
110
111 /* structure for MTIOCPOS - mag tape get position command */
112
113 struct  mtpos {
114         long    mt_blkno;       /* current block number */
115 };
116
117
118 /* mag tape io control commands */
119 #define MTIOCTOP        _IOW('m', 1, struct mtop)       /* do a mag tape op */
120 #define MTIOCGET        _IOR('m', 2, struct mtget)      /* get tape status */
121 #define MTIOCPOS        _IOR('m', 3, struct mtpos)      /* get tape position */
122
123 /* Generic Mag Tape (device independent) status macros for examining
124  * mt_gstat -- HP-UX compatible.
125  * There is room for more generic status bits here, but I don't
126  * know which of them are reserved. At least three or so should
127  * be added to make this really useful.
128  */
129 #define GMT_EOF(x)              ((x) & 0x80000000)
130 #define GMT_BOT(x)              ((x) & 0x40000000)
131 #define GMT_EOT(x)              ((x) & 0x20000000)
132 #define GMT_SM(x)               ((x) & 0x10000000)  /* DDS setmark */
133 #define GMT_EOD(x)              ((x) & 0x08000000)  /* DDS EOD */
134 #define GMT_WR_PROT(x)          ((x) & 0x04000000)
135 #define GMT_REP_SM(x)           ((x) & 0x02000000)  /* Cygwin: rep. setmarks */
136 #define GMT_ONLINE(x)           ((x) & 0x01000000)
137 #define GMT_D_6250(x)           ((x) & 0x00800000)
138 #define GMT_D_1600(x)           ((x) & 0x00400000)
139 #define GMT_D_800(x)            ((x) & 0x00200000)
140 #define GMT_PADDING(x)          ((x) & 0x00100000)  /* Cygwin: data padding */
141 #define GMT_HW_ECC(x)           ((x) & 0x00080000)  /* Cygwin: HW error corr. */
142 #define GMT_DR_OPEN(x)          ((x) & 0x00040000)  /* door open (no tape) */
143 #define GMT_HW_COMP(x)          ((x) & 0x00020000)  /* Cygwin: HW compression */
144 #define GMT_IM_REP_EN(x)        ((x) & 0x00010000)  /* immediate report mode */
145 #define GMT_CLN(x)              ((x) & 0x00008000)  /* cleaning requested */
146 /* 15 generic status bits unused */
147 /* Cygwin only: The below settings are also used by the GNU-Linux SCSI tape
148    driver but they aren't usually reported here.  Unfortunately, there's no
149    other official method to retrieve the values of these settings and
150    reporting them here apparently doesn't hurt. */
151 #define GMT_TWO_FM(x)           ((x) & 0x00000080)  /* two fm after write */
152 #define GMT_FAST_MTEOM(x)       ((x) & 0x00000040)  /* fast seek to eom */
153 #define GMT_AUTO_LOCK(x)        ((x) & 0x00000020)  /* auto door lock on r/w */
154 #define GMT_SYSV(x)             ((x) & 0x00000010)  /* SYSV read semantics */
155 #define GMT_NOWAIT(x)           ((x) & 0x00000008)  /* don't wait for positioning commands */
156 #define GMT_ASYNC(x)            ((x) & 0x00000004)  /* asynchronous writes */
157
158
159 /* SCSI-tape specific definitions */
160 /* Bitfield shifts in the status mt_dsreg */
161 #define MT_ST_BLKSIZE_SHIFT     0
162 #define MT_ST_BLKSIZE_MASK      0xffffff
163 #define MT_ST_DENSITY_SHIFT     24
164 #define MT_ST_DENSITY_MASK      0xff000000
165
166 #define MT_ST_SOFTERR_SHIFT     0
167 #define MT_ST_SOFTERR_MASK      0xffff
168
169 /* Bitfields for the MTSETDRVBUFFER ioctl.  */
170 #define MT_ST_OPTIONS           0xf0000000
171 #define MT_ST_BOOLEANS          0x10000000
172 #define MT_ST_SETBOOLEANS       0x30000000
173 #define MT_ST_CLEARBOOLEANS     0x40000000
174 #define MT_ST_WRITE_THRESHOLD   0x20000000      /* Not supported */
175 #define MT_ST_DEF_OPTIONS       0x60000000      /* Not supported */
176 #define MT_ST_EOT_WZ_SIZE       0xf0000000      /* Cygwin only */
177
178 #define MT_ST_BUFFER_WRITES     0x00000001
179 #define MT_ST_ASYNC_WRITES      0x00000002
180 #define MT_ST_READ_AHEAD        0x00000004      /* Not supported */
181 #define MT_ST_DEBUGGING         0x00000008      /* Not supported */
182 #define MT_ST_TWO_FM            0x00000010
183 #define MT_ST_FAST_MTEOM        0x00000020
184 #define MT_ST_AUTO_LOCK         0x00000040
185 #define MT_ST_DEF_WRITES        0x00000080      /* Not supported */
186 #define MT_ST_CAN_BSR           0x00000100      /* Not supported */
187 #define MT_ST_NO_BLKLIMS        0x00000200      /* Not supported */
188 #define MT_ST_CAN_PARTITIONS    0x00000400      /* Not supported */
189 #define MT_ST_SCSI2LOGICAL      0x00000800      /* Not supported */
190 #define MT_ST_SYSV              0x00001000
191 #define MT_ST_NOWAIT            0x00002000
192 #define MT_ST_ECC               0x00010000      /* Cygwin only */
193 #define MT_ST_PADDING           0x00020000      /* Cygwin only */
194 #define MT_ST_REPORT_SM         0x00040000      /* Cygwin only */
195
196 /*
197  * Constants for mt_type. Not all of these are supported,
198  * and these are not all of the ones that are supported.
199  *
200  * Only used when not colliding with Windows codes (see below)
201  */
202 #define MT_ISUNKNOWN            0x01
203 #define MT_ISQIC02              0x02    /* Generic QIC-02 tape streamer */
204 #define MT_ISWT5150             0x03    /* Wangtek 5150EQ, QIC-150, QIC-02 */
205 #define MT_ISARCHIVE_5945L2     0x04    /* Archive 5945L-2, QIC-24, QIC-02? */
206 #define MT_ISCMSJ500            0x05    /* CMS Jumbo 500 (QIC-02?) */
207 #define MT_ISTDC3610            0x06    /* Tandberg 6310, QIC-24 */
208 #define MT_ISARCHIVE_VP60I      0x07    /* Archive VP60i, QIC-02 */
209 #define MT_ISARCHIVE_2150L      0x08    /* Archive Viper 2150L */
210 #define MT_ISARCHIVE_2060L      0x09    /* Archive Viper 2060L */
211 #define MT_ISARCHIVESC499       0x0A    /* Archive SC-499 QIC-36 controller */
212 #define MT_ISQIC02_ALL_FEATURES 0x0F    /* Generic QIC-02 with all features */
213 #define MT_ISWT5099EEN24        0x11    /* Wangtek 5099-een24, 60MB, QIC-24 */
214 #define MT_ISTEAC_MT2ST         0x12    /* Teac MT-2ST 155mb drive, Teac DC-1 card (Wangtek type) */
215 #define MT_ISEVEREX_FT40A       0x32    /* Everex FT40A (QIC-40) */
216 #define MT_ISDDS1               0x51    /* DDS device without partitions */
217 #define MT_ISDDS2               0x52    /* DDS device with partitions */
218 #define MT_ISSCSI1              0x71    /* Generic ANSI SCSI-1 tape unit */
219 #define MT_ISSCSI2              0x72    /* Generic ANSI SCSI-2 tape unit */
220
221 /* More constants for mt_type.  These are the codes used by Windows >= 5.1 */
222 #define MT_ISDDS_4mm            0x20
223 #define MT_ISMiniQic            0x21
224 #define MT_ISTravan             0x22
225 #define MT_ISQIC                0x23
226 #define MT_ISMP_8mm             0x24
227 #define MT_ISAME_8mm            0x25
228 #define MT_ISAIT1_8mm           0x26
229 #define MT_ISDLT                0x27
230 #define MT_ISNCTP               0x28
231 #define MT_ISIBM_3480           0x29
232 #define MT_ISIBM_3490E          0x2a
233 #define MT_ISIBM_Magstar_3590   0x2b
234 #define MT_ISIBM_Magstar_MP     0x2c
235 #define MT_ISSTK_DATA_D3        0x2d
236 #define MT_ISSONY_DTF           0x2e
237 #define MT_ISDV_6mm             0x2f
238 #define MT_ISDMI                0x30
239 #define MT_ISSONY_D2            0x31
240 #define MT_ISCLEANER_CARTRIDGE  0x32
241 #define MT_ISAVATAR_F2          0x4f
242 #define MT_ISMP2_8mm            0x50
243 #define MT_ISDST_S              0x51
244 #define MT_ISDST_M              0x52
245 #define MT_ISDST_L              0x53
246 #define MT_ISVXATape_1          0x54
247 #define MT_ISVXATape_2          0x55
248 #define MT_ISSTK_9840           0x56
249 #define MT_ISLTO_Ultrium        0x57
250 #define MT_ISLTO_Accelis        0x58
251 #define MT_ISAIT_8mm            0x5a
252 #define MT_ISADR_1              0x5b
253 #define MT_ISADR_2              0x5c
254 #define MT_ISSTK_9940           0x5d
255
256 struct mt_tape_info {
257         long t_type;            /* device type id (mt_type) */
258         char *t_name;           /* descriptive name */
259 };
260
261 #define MT_TAPE_INFO    { \
262         {MT_ISUNKNOWN,          "Unknown type of tape device"}, \
263         {MT_ISQIC02,            "Generic QIC-02 tape streamer"}, \
264         {MT_ISWT5150,           "Wangtek 5150, QIC-150"}, \
265         {MT_ISARCHIVE_5945L2,   "Archive 5945L-2"}, \
266         {MT_ISCMSJ500,          "CMS Jumbo 500"}, \
267         {MT_ISTDC3610,          "Tandberg TDC 3610, QIC-24"}, \
268         {MT_ISARCHIVE_VP60I,    "Archive VP60i, QIC-02"}, \
269         {MT_ISARCHIVE_2150L,    "Archive Viper 2150L"}, \
270         {MT_ISARCHIVE_2060L,    "Archive Viper 2060L"}, \
271         {MT_ISARCHIVESC499,     "Archive SC-499 QIC-36 controller"}, \
272         {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \
273         {MT_ISWT5099EEN24,      "Wangtek 5099-een24, 60MB"}, \
274         {MT_ISTEAC_MT2ST,       "Teac MT-2ST 155mb data cassette drive"}, \
275         {MT_ISDDS_4mm,          "DDS"}, \
276         {MT_ISMiniQic,          "MiniQic"}, \
277         {MT_ISTravan,           "Travan tape"}, \
278         {MT_ISQIC,              "QIC tape"}, \
279         {MT_ISMP_8mm,           "8mm Exabyte metal particle tape"}, \
280         {MT_ISAME_8mm,          "8mm Exabyte advanced metal evap tape"}, \
281         {MT_ISAIT1_8mm,         "8mm Sony AIT1 tape"}, \
282         {MT_ISDLT,              "DLT compact tape)"}, \
283         {MT_ISNCTP,             "Philips NCTP tape"}, \
284         {MT_ISIBM_3480,         "IBM 3480 tape"}, \
285         {MT_ISIBM_3490E,        "IBM 3490E tape"}, \
286         {MT_ISIBM_Magstar_3590, "IBM Magstar 3590 tape"}, \
287         {MT_ISIBM_Magstar_MP,   "IBM Magstar MP tape"}, \
288         {MT_ISSTK_DATA_D3,      "STK data D3 tape"}, \
289         {MT_ISSONY_DTF,         "Sony DTF tape"}, \
290         {MT_ISDV_6mm,           "6mm digital video tape"}, \
291         {MT_ISDMI,              "Exabyte DMI tape"}, \
292         {MT_ISSONY_D2,          "Sony D2S or D2L tape"}, \
293         {MT_ISCLEANER_CARTRIDGE, "Cleaner (all drive types that support cleaners)"}, \
294         {MT_ISAVATAR_F2,        "Avatar 2"}, \
295         {MT_ISMP2_8mm,          "8mm Hitachi tape"}, \
296         {MT_ISDST_S,            "Ampex DST small tape"}, \
297         {MT_ISDST_M,            "Ampex DST medium tape"}, \
298         {MT_ISDST_L,            "Ampex DST large tape"}, \
299         {MT_ISVXATape_1,        "Ecrix 8mm tape"}, \
300         {MT_ISVXATape_2,        "Ecrix 8mm tape"}, \
301         {MT_ISSTK_9840,         "STK 9840"}, \
302         {MT_ISLTO_Ultrium,      "LTO Ultrium (IBM, HP, Seagate)"}, \
303         {MT_ISLTO_Accelis,      "LTO Accelis (IBM, HP, Seagate)"}, \
304         {MT_ISAIT_8mm,          "AIT tape (AIT2 or higher)"}, \
305         {MT_ISADR_1,            "OnStream ADR1"}, \
306         {MT_ISADR_2,            "OnStream ADR2"}, \
307         {MT_ISSTK_9940,         "STK 9940"}, \
308         {MT_ISSCSI1,            "Generic SCSI-1 tape"}, \
309         {MT_ISSCSI2,            "Generic SCSI-2 tape"}, \
310         {0, NULL} \
311 }
312
313 #endif /* _CYGWIN_MTIO_H */