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