xref: /titanic_41/usr/src/uts/common/sys/mtio.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  *
26  *	Copyright (c) 1983-1989 by AT&T.
27  *	All rights reserved.
28  */
29 
30 /*
31  * Portions of this source code were derived from Berkeley 4.3 BSD
32  * under license from the Regents of the University of California.
33  */
34 
35 #ifndef	_SYS_MTIO_H
36 #define	_SYS_MTIO_H
37 
38 #pragma ident	"%Z%%M%	%I%	%E% SMI"
39 
40 #include <sys/types.h>
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 /*
47  * Structures and definitions for mag tape io control commands
48  */
49 
50 /*
51  * structure for MTIOCTOP - mag tape op command
52  */
53 struct mtop	{
54 	short		mt_op;		/* operations defined below */
55 	daddr_t		mt_count;	/* how many of them */
56 };
57 
58 #if defined(_SYSCALL32)
59 struct mtop32	{
60 	short		mt_op;		/* operations defined below */
61 	daddr32_t	mt_count;	/* how many of them */
62 };
63 #endif /* _SYSCALL32 */
64 
65 
66 /*
67  * values for mt_op
68  */
69 #define	MTWEOF		0	/* write an end-of-file record */
70 #define	MTFSF		1	/* forward space over file mark */
71 #define	MTBSF		2	/* backward space over file mark (1/2" only ) */
72 #define	MTFSR		3	/* forward space to inter-record gap */
73 #define	MTBSR		4	/* backward space to inter-record gap */
74 #define	MTREW		5	/* rewind */
75 #define	MTOFFL		6	/* rewind and put the drive offline */
76 #define	MTNOP		7	/* no operation, sets status only */
77 #define	MTRETEN		8	/* retension the tape (cartridge tape only) */
78 #define	MTERASE		9	/* erase the entire tape */
79 #define	MTEOM		10	/* position to end of media */
80 #define	MTNBSF		11	/* backward space file to BOF */
81 #define	MTSRSZ		12	/* set record size */
82 #define	MTGRSZ		13	/* get record size */
83 #define	MTLOAD		14	/* for loading a tape (use o_delay to open */
84 				/* the tape device) */
85 
86 /*
87  * structure for MTIOCGET - mag tape get status command
88  */
89 struct mtget	{
90 	short		mt_type;	/* type of magtape device */
91 	/* the following two registers are grossly device dependent */
92 	short		mt_dsreg;	/* ``drive status'' register */
93 	short		mt_erreg;	/* ``error'' register */
94 	/* optional error info. */
95 	daddr_t		mt_resid;	/* residual count */
96 	daddr_t		mt_fileno;	/* file number of current position */
97 	daddr_t		mt_blkno;	/* block number of current position */
98 	ushort_t	mt_flags;
99 	short		mt_bf;		/* optimum blocking factor */
100 };
101 
102 #if defined(_SYSCALL32)
103 struct mtget32	{
104 	short		mt_type;	/* type of magtape device */
105 	/* the following two registers are grossly device dependent */
106 	short		mt_dsreg;	/* ``drive status'' register */
107 	short		mt_erreg;	/* ``error'' register */
108 	/* optional error info. */
109 	daddr32_t	mt_resid;	/* residual count */
110 	daddr32_t	mt_fileno;	/* file number of current position */
111 	daddr32_t	mt_blkno;	/* block number of current position */
112 	ushort_t	mt_flags;
113 	short		mt_bf;		/* optimum blocking factor */
114 };
115 #endif /* _SYSCALL32 */
116 
117 #define	MT_NDENSITIES	4
118 #define	MT_NSPEEDS	4
119 
120 /*
121  * struct for MTIOCGETDRIVETYPE - get tape config data
122  */
123 struct mtdrivetype {
124 	char    name[64];		/* Name, for debug */
125 	char    vid[25];		/* Vendor id and model (product) id */
126 	char    type;			/* Drive type for driver */
127 	int	bsize;			/* Block size */
128 	int	options;		/* Drive options */
129 	int	max_rretries;		/* Max read retries */
130 	int	max_wretries;		/* Max write retries */
131 	uchar_t densities[MT_NDENSITIES];	/* density codes, low->hi */
132 	uchar_t	default_density;	/* Default density chosen */
133 	uchar_t speeds[MT_NSPEEDS];	/* speed codes, low->hi */
134 	ushort_t non_motion_timeout;    /* Inquiry type commands */
135 	ushort_t io_timeout;		/* io timeout. seconds */
136 	ushort_t rewind_timeout;	/* rewind timeout. seconds */
137 	ushort_t space_timeout;		/* space cmd timeout. seconds */
138 	ushort_t load_timeout;		/* load tape time in seconds */
139 	ushort_t unload_timeout;	/* Unload tape time in scounds */
140 	ushort_t erase_timeout;		/* erase timeout. seconds */
141 };
142 
143 
144 struct mtdrivetype_request {
145 	int	size;
146 	struct  mtdrivetype *mtdtp;
147 };
148 
149 #if defined(_SYSCALL32)
150 struct mtdrivetype_request32 {
151 	int		size;
152 	caddr32_t	mtdtp;
153 };
154 #endif /* _SYSCALL32 */
155 
156 
157 /*
158  * values for mt_flags
159  */
160 #define	MTF_SCSI	0x01
161 #define	MTF_REEL	0x02
162 #define	MTF_ASF		0x04
163 
164 #define	MTF_TAPE_HEAD_DIRTY	0x08
165 #define	MTF_TAPE_CLN_SUPPORTED	0x10
166 
167 /*
168  * Constants for mt_type byte (these are somewhat obsolete)
169  */
170 #define	MT_ISTS		0x01		/* vax: unibus ts-11 */
171 #define	MT_ISHT		0x02		/* vax: massbus tu77, etc */
172 #define	MT_ISTM		0x03		/* vax: unibus tm-11 */
173 #define	MT_ISMT		0x04		/* vax: massbus tu78 */
174 #define	MT_ISUT		0x05		/* vax: unibus gcr */
175 #define	MT_ISCPC	0x06		/* sun: multibus cpc */
176 #define	MT_ISAR		0x07		/* sun: multibus archive */
177 #define	MT_ISSC		0x08		/* sun: SCSI archive */
178 #define	MT_ISSYSGEN11	0x10		/* sun: SCSI Sysgen, QIC-11 only */
179 #define	MT_ISSYSGEN	0x11		/* sun: SCSI Sysgen QIC-24/11 */
180 #define	MT_ISDEFAULT	0x12		/* sun: SCSI default CCS */
181 #define	MT_ISCCS3	0x13		/* sun: SCSI generic (unknown) CCS */
182 #define	MT_ISMT02	0x14		/* sun: SCSI Emulex MT02 */
183 #define	MT_ISVIPER1	0x15		/* sun: SCSI Archive QIC-150 Viper */
184 #define	MT_ISWANGTEK1	0x16		/* sun: SCSI Wangtek QIC-150 */
185 #define	MT_ISCCS7	0x17		/* sun: SCSI generic (unknown) CCS */
186 #define	MT_ISCCS8	0x18		/* sun: SCSI generic (unknown) CCS */
187 #define	MT_ISCCS9	0x19		/* sun: SCSI generic (unknown) CCS */
188 #define	MT_ISCCS11	0x1a		/* sun: SCSI generic (unknown) CCS */
189 #define	MT_ISCCS12	0x1b		/* sun: SCSI generic (unknown) CCS */
190 #define	MT_ISCCS13	0x1c		/* sun: SCSI generic (unknown) CCS */
191 #define	MT_ISCCS14	0x1d		/* sun: SCSI generic (unknown) CCS */
192 #define	MT_ISCCS15	0x1e		/* sun: SCSI generic (unknown) CCS */
193 #define	MT_ISCCS16	0x1f		/* sun: SCSI generic (unknown) CCS */
194 #define	MT_ISCDC	0x20		/* sun: SCSI CDC 1/2" cartridge */
195 #define	MT_ISFUJI	0x21		/* sun: SCSI Fujitsu 1/2" cartridge */
196 #define	MT_ISKENNEDY	0x22		/* sun: SCSI Kennedy 1/2" reel */
197 #define	MT_ISHP		0x23		/* sun: SCSI HP 1/2" reel */
198 #define	MT_ISSTC	0x24		/* sun: SCSI IBM STC 3490 */
199 #define	MT_ISANRITSU	0x25		/* nihon sun: Anritsu 1/2" reel */
200 #define	MT_ISCCS23	0x26		/* sun: SCSI generic  1/2" */
201 #define	MT_ISCCS24	0x27		/* sun: SCSI generic  1/2" */
202 #define	MT_ISEXABYTE	0x28		/* sun: SCSI Exabyte 8mm cartridge */
203 #define	MT_ISEXB8500	0x29		/* sun: SCSI Exabyte 8500 8mm cart */
204 #define	MT_ISWANGTHS	0x2a		/* sun: SCSI Wangtek 6130HS RDAT */
205 #define	MT_ISWANGDAT	0x2b		/* sun: SCSI WangDAT */
206 #define	MT_ISPYTHON	0x2c		/* sun: SCSI Archive Python DAT  */
207 #define	MT_ISCCS28	0x2d		/* sun: SCSI generic DAT CCS */
208 #define	MT_ISCCS29	0x2e		/* sun: SCSI generic (unknown) CCS */
209 #define	MT_ISCCS30	0x2f		/* sun: SCSI generic (unknown) CCS */
210 #define	MT_ISCCS31	0x30		/* sun: SCSI generic (unknown) CCS */
211 #define	MT_ISCCS32	0x31		/* sun: SCSI generic (unknown) CCS */
212 
213 
214 /*
215  * these are recommended
216  */
217 #define	MT_ISQIC	0x32		/* generic QIC tape drive */
218 #define	MT_ISREEL	0x33		/* generic reel tape drive */
219 #define	MT_ISDAT	0x34		/* generic DAT tape drive */
220 #define	MT_IS8MM	0x35		/* generic 8mm tape drive */
221 #define	MT_ISOTHER	0x36		/* generic other type of tape drive */
222 
223 /* more Sun devices */
224 #define	MT_ISTAND25G	0x37		/* sun: SCSI Tandberg 2.5 Gig QIC */
225 #define	MT_ISDLT	0x38		/* sun: SCSI DLT tape drive */
226 #define	MT_ISSTK9840	0x39		/* sun: STK 9840, 9940, 9840B */
227 #define	MT_ISBMDLT1	0x3a		/* sun: Benchmark DLT1 */
228 #define	MT_LTO		0x3b		/* sun: LTO,s by Hp, Seagate, IBM .. */
229 
230 /*
231  * Device table structure and data for looking tape name from
232  * tape id number.  Used by mt.c.
233  */
234 struct mt_tape_info {
235 	short	t_type;		/* type of magtape device */
236 	char	*t_name;	/* printing name */
237 	char	*t_dsbits;	/* "drive status" register */
238 	char	*t_erbits;	/* "error" register */
239 };
240 
241 /*
242  * this table is now obsolete, use MTIOCGETDRIVETYPE ioctl
243  *
244  * WARNING: this table will be eliminated in some future release
245  */
246 #define	MT_TAPE_INFO  {\
247 { MT_ISSYSGEN11,	"Sysgen QIC-11",		0, 0 }, \
248 { MT_ISSYSGEN,		"Sysgen QIC-24",		0, 0 }, \
249 { MT_ISMT02,		"Emulex MT-02 QIC-24",		0, 0 }, \
250 { MT_ISVIPER1,		"Archive QIC-150",		0, 0 }, \
251 { MT_ISWANGTEK1,	"Wangtek QIC-150",		0, 0 }, \
252 { MT_ISKENNEDY,		"Kennedy 9612 1/2-inch",	0, 0 }, \
253 { MT_ISANRITSU,		"Anritsu 1/2-inch",		0, 0 }, \
254 { MT_ISHP,		"HP 88780 1/2-inch",		0, 0 }, \
255 { MT_ISEXABYTE,		"Exabyte EXB-8200 8mm",		0, 0 }, \
256 { MT_ISEXB8500,		"Exabyte EXB-8500 8mm",		0, 0 }, \
257 { MT_ISWANGDAT,		"WangDAT 3.81mm",		0, 0 }, \
258 { MT_ISWANGTHS,		"Wangtek 4mm RDAT",		0, 0 }, \
259 { MT_ISPYTHON,		"Archive Python 4mm Helical Scan",	0, 0 }, \
260 { MT_ISSTC,		"STC 1/2\" Cartridge",		0, 0}, \
261 { MT_ISTAND25G,		"Tandberg 2.5 Gig QIC",		0, 0}, \
262 { MT_ISQIC,		"QIC",		0, 0}, \
263 { MT_ISREEL,		"REEL",		0, 0}, \
264 { MT_ISDAT,		"DAT",		0, 0}, \
265 { MT_IS8MM,		"8mm",		0, 0}, \
266 { MT_ISOTHER,		"Other",	0, 0}, \
267 { 0 } \
268 }
269 
270 /* mag tape io control commands */
271 #define	MTIOC			('m'<<8)
272 #define	MTIOCTOP		(MTIOC|1)	/* do a mag tape op */
273 #define	MTIOCGET		(MTIOC|2)	/* get tape status */
274 #define	MTIOCGETDRIVETYPE	(MTIOC|3)	/* get tape config data */
275 #define	MTIOCPERSISTENT		(MTIOC|4)	/* turn on persistent errors */
276 #define	MTIOCPERSISTENTSTATUS	(MTIOC|5)	/* query persis. err status */
277 #define	MTIOCLRERR		(MTIOC|6)	/* clear a persitent error */
278 #define	MTIOCGUARANTEEDORDER	(MTIOC|7)	/* check for guaranteed order */
279 #define	MTIOCRESERVE		(MTIOC|8)	/* preserve reserve */
280 #define	MTIOCRELEASE		(MTIOC|9)	/* turnoff preserve reserve */
281 #define	MTIOCFORCERESERVE	(MTIOC|10)	/* break reservation drive */
282 
283 #define	MTIOCSTATE		(MTIOC|13)	/* Inquire insert/eject state */
284 
285 #define	MTIOCREADIGNOREILI  	(MTIOC|14)	/* Enable/Disable ILI */
286 #define	MTIOCREADIGNOREEOFS 	(MTIOC|15)	/* Enable/Disable Ignore EOF */
287 #define	MTIOCSHORTFMK		(MTIOC|16)	/* Enable/Disable Short FMK */
288 
289 /*
290  * This state enum is the argument passed to the MTIOCSTATE ioctl.
291  */
292 enum mtio_state { MTIO_NONE, MTIO_EJECTED, MTIO_INSERTED };
293 
294 #ifndef KERNEL
295 /*
296  * don't use DEFTAPE.
297  */
298 #define	DEFTAPE	"/dev/rmt/0"
299 #endif
300 
301 /*
302  * Layout of minor device byte
303  * 15 - 8    7    6    5    4    3    2    1    0
304  * --------------------------------------------
305  * |    |    |    |    |    |    |    |    |----| Unit #. lower 2 bits
306  * |    |    |    |    |    |    |    |---------- No rewind on close bit....
307  * |    |    |    |    |    |----|--------------- Density Select
308  * |    |    |    |    |------------------------- Resrvd.(add. campus dens. bit)
309  * |    |    |    |------------------------------ BSD behavior
310  * |----|----|----------------------------------- Unit #  bit 2-6
311  */
312 
313 #define	MTUNIT(dev)	(((getminor(dev) & 0xff80) >> 5) + \
314 			    (getminor(dev) & 0x3))
315 #define	MT_NOREWIND	(1 <<2)
316 #define	MT_DENSITY_MASK	(3 <<3)
317 #define	MT_DENSITY1	(0 <<3)		/* Lowest density/format */
318 #define	MT_DENSITY2	(1 <<3)
319 #define	MT_DENSITY3	(2 <<3)
320 #define	MT_DENSITY4	(3 <<3)		/* Highest density/format */
321 #define	MTMINOR(unit)	(((unit & 0x7fc) << 5) + (unit & 0x3))
322 #define	MT_BSD		(1 <<6)		/* BSD behavior on close */
323 #define	MT_DENSITY(dev) ((getminor(dev) & MT_DENSITY_MASK) >> 3)
324 
325 
326 #ifdef	__cplusplus
327 }
328 #endif
329 
330 #endif /* _SYS_MTIO_H */
331