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