1 /* @(#)rmtio.h	1.5 03/06/15 Copyright 1995,2000 J. Schilling */
2 /*
3  *	Definition for enhanced remote tape IO
4  *
5  *	Copyright (c) 1995,2000-2002 J. Schilling
6  */
7 /*
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * this program; see the file COPYING.  If not, write to the Free Software
20  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  */
22 
23 #ifndef	_RMTIO_H
24 #define	_RMTIO_H
25 
26 #ifndef _MCONFIG_H
27 #include <mconfig.h>
28 #endif
29 #ifndef	_UTYPES_H
30 #include <utypes.h>
31 #endif
32 
33 /*
34  * values for mt_op
35  */
36 #define	RMTWEOF		0	/* write an end-of-file record */
37 #define	RMTFSF		1	/* forward space over file mark */
38 #define	RMTBSF		2	/* backward space over file mark (1/2" only ) */
39 #define	RMTFSR		3	/* forward space to inter-record gap */
40 #define	RMTBSR		4	/* backward space to inter-record gap */
41 #define	RMTREW		5	/* rewind */
42 #define	RMTOFFL		6	/* rewind and put the drive offline */
43 #define	RMTNOP		7	/* no operation, sets status only */
44 
45 #ifdef	__needed__
46 #define	MTRETEN		8	/* retension the tape (cartridge tape only) */
47 #define	MTERASE		9	/* erase the entire tape */
48 #define	MTEOM		10	/* position to end of media */
49 #define	MTNBSF		11	/* backward space file to BOF */
50 
51 #define	MTSRSZ		12	/* set record size */
52 #define	MTGRSZ		13	/* get record size */
53 #define	MTLOAD		14	/* for loading a tape (use o_delay to open */
54 				/* the tape device) */
55 #endif
56 
57 /*
58  * Definitions for the new RMT Protocol version 1
59  *
60  * The new Protocol version tries to make the use
61  * of rmtioctl() more portable between different platforms.
62  */
63 #define	RMTIVERSION	-1	/* Opcode to request version */
64 #define	RMT_NOVERSION	-1	/* Old version code */
65 #define	RMT_VERSION	1	/* New (current) version code */
66 
67 /*
68  * Support for commands bejond MTWEOF..MTNOP (0..7)
69  */
70 #define	RMTICACHE	0	/* enable controller cache */
71 #define	RMTINOCACHE	1	/* disable controller cache */
72 #define	RMTIRETEN	2	/* retension the tape (cartridge tape only) */
73 #define	RMTIERASE	3	/* erase the entire tape */
74 #define	RMTIEOM		4	/* position to end of media */
75 #define	RMTINBSF	5	/* backward space file to BOF */
76 
77 /*
78  * Old MTIOCGET copies a binary version of struct mtget back
79  * over the wire. This is highly non portable.
80  * MTS_* retrieves ascii versions (%d format) of a single
81  * field in the struct mtget.
82  * NOTE: MTS_ERREG may only be valid on the first call and
83  *	 must be retrived first.
84  */
85 #define	MTS_TYPE	'T'		/* mtget.mt_type */
86 #define	MTS_DSREG	'D'		/* mtget.mt_dsreg */
87 #define	MTS_ERREG	'E'		/* mtget.mt_erreg */
88 #define	MTS_RESID	'R'		/* mtget.mt_resid */
89 #define	MTS_FILENO	'F'		/* mtget.mt_fileno */
90 #define	MTS_BLKNO	'B'		/* mtget.mt_blkno */
91 #define	MTS_FLAGS	'f'		/* mtget.mt_flags */
92 #define	MTS_BF		'b'		/* mtget.mt_bf */
93 
94 /*
95  * structure for remote MTIOCGET - mag tape get status command
96  */
97 struct rmtget	{
98 	Llong		mt_type;	/* type of magtape device	    */
99 	/* the following two registers are grossly device dependent	    */
100 	Llong		mt_dsreg;	/* ``drive status'' register	    */
101 	Int32_t		mt_dsreg1;	/* ``drive status'' register	    */
102 	Int32_t		mt_dsreg2;	/* ``drive status'' register	    */
103 	Llong		mt_gstat;	/* ``generic status'' register	    */
104 	Llong		mt_erreg;	/* ``error'' register		    */
105 	/* optional error info.						    */
106 	Llong		mt_resid;	/* residual count		    */
107 	Llong		mt_fileno;	/* file number of current position  */
108 	Llong		mt_blkno;	/* block number of current position */
109 	Llong		mt_flags;
110 	Llong		mt_gflags;	/* generic flags		    */
111 	long		mt_bf;		/* optimum blocking factor	    */
112 	int		mt_xflags;	/* eXistence flags for struct members */
113 };
114 
115 /*
116  * Values for mt_xflags
117  */
118 #define	RMT_TYPE		0x0001	/* mt_type/mt_model present	*/
119 #define	RMT_DSREG		0x0002	/* mt_dsreg present		*/
120 #define	RMT_DSREG1		0x0004	/* mt_dsreg1 present		*/
121 #define	RMT_DSREG2		0x0008	/* mt_dsreg2 present		*/
122 #define	RMT_GSTAT		0x0010	/* mt_gstat present		*/
123 #define	RMT_ERREG		0x0020	/* mt_erreg present		*/
124 #define	RMT_RESID		0x0040	/* mt_resid present		*/
125 #define	RMT_FILENO		0x0080	/* mt_fileno present		*/
126 #define	RMT_BLKNO		0x0100	/* mt_blkno present		*/
127 #define	RMT_FLAGS		0x0200	/* mt_flags present		*/
128 #define	RMT_BF			0x0400	/* mt_bf present		*/
129 #define	RMT_COMPAT		0x0800	/* Created from old compat data	*/
130 
131 /*
132  * values for mt_flags
133  */
134 #define	RMTF_SCSI		0x01
135 #define	RMTF_REEL		0x02
136 #define	RMTF_ASF		0x04
137 #define	RMTF_TAPE_HEAD_DIRTY	0x08
138 #define	RMTF_TAPE_CLN_SUPPORTED	0x10
139 
140 /*
141  * these are recommended
142  */
143 #ifdef	__needed__
144 #define	MT_ISQIC	0x32		/* generic QIC tape drive */
145 #define	MT_ISREEL	0x33		/* generic reel tape drive */
146 #define	MT_ISDAT	0x34		/* generic DAT tape drive */
147 #define	MT_IS8MM	0x35		/* generic 8mm tape drive */
148 #define	MT_ISOTHER	0x36		/* generic other type of tape drive */
149 
150 /* more Sun devices */
151 #define	MT_ISTAND25G	0x37		/* sun: SCSI Tandberg 2.5 Gig QIC */
152 #define	MT_ISDLT	0x38		/* sun: SCSI DLT tape drive */
153 #define	MT_ISSTK9840	0x39		/* sun: STK 9840 (Ironsides) */
154 #endif
155 
156 #endif /* _RMTIO_H */
157