1 /* $NetBSD: mtio.h,v 1.19 2002/04/08 12:09:09 simonb Exp $ */ 2 3 /* 4 * Copyright (c) 1982, 1986, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by the University of 18 * California, Berkeley and its contributors. 19 * 4. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)mtio.h 8.1 (Berkeley) 6/2/93 36 */ 37 38 #ifndef _SYS_MTIO_H_ 39 #define _SYS_MTIO_H_ 40 41 /* 42 * Structures and definitions for mag tape io control commands 43 */ 44 45 /* structure for MTIOCTOP - mag tape op command */ 46 struct mtop { 47 short mt_op; /* operations defined below */ 48 daddr_t mt_count; /* how many of them */ 49 }; 50 51 /* operations */ 52 #define MTWEOF 0 /* write an end-of-file record */ 53 #define MTFSF 1 /* forward space file */ 54 #define MTBSF 2 /* backward space file */ 55 #define MTFSR 3 /* forward space record */ 56 #define MTBSR 4 /* backward space record */ 57 #define MTREW 5 /* rewind */ 58 #define MTOFFL 6 /* rewind and put the drive offline */ 59 #define MTNOP 7 /* no operation, sets status only */ 60 #define MTRETEN 8 /* retension */ 61 #define MTERASE 9 /* erase entire tape */ 62 #define MTEOM 10 /* forward to end of media */ 63 #define MTNBSF 11 /* backward space to beginning of file */ 64 #define MTCACHE 12 /* enable controller cache */ 65 #define MTNOCACHE 13 /* disable controller cache */ 66 #define MTSETBSIZ 14 /* set block size; 0 for variable */ 67 #define MTSETDNSTY 15 /* set density code for current mode */ 68 #define MTCMPRESS 16 /* set/clear device compression */ 69 #define MTEWARN 17 /* set/clear early warning behaviour */ 70 71 /* structure for MTIOCGET - mag tape get status command */ 72 73 struct mtget { 74 short mt_type; /* type of magtape device */ 75 /* the following two registers are grossly device dependent */ 76 short mt_dsreg; /* ``drive status'' register */ 77 short mt_erreg; /* ``error'' register */ 78 /* end device-dependent registers */ 79 short mt_resid; /* residual count */ 80 /* the following two are not yet implemented by most tape drivers */ 81 daddr_t mt_fileno; /* file number of current position */ 82 daddr_t mt_blkno; /* block number of current position */ 83 /* end not yet implemented */ 84 daddr_t mt_blksiz; /* current block size */ 85 daddr_t mt_density; /* current density code */ 86 daddr_t mt_mblksiz[4]; /* block size for different modes */ 87 daddr_t mt_mdensity[4]; /* density codes for different modes */ 88 }; 89 90 /* 91 * Constants for mt_type byte. These are the same 92 * for controllers compatible with the types listed. 93 */ 94 #define MT_ISTS 0x01 /* TS-11 */ 95 #define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */ 96 #define MT_ISTM 0x03 /* TM11/TE10 Unibus */ 97 #define MT_ISMT 0x04 /* TM78/TU78 Massbus */ 98 #define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */ 99 #define MT_ISCPC 0x06 /* SUN */ 100 #define MT_ISAR 0x07 /* SUN - Also "GENERIC SCSI" */ 101 #define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */ 102 #define MT_ISCY 0x09 /* CCI Cipher */ 103 #define MT_ISCT 0x0a /* HP 1/4 tape */ 104 #define MT_ISFHP 0x0b /* HP 7980 1/2 tape */ 105 #define MT_ISEXABYTE 0x0c /* Exabyte */ 106 #define MT_ISEXA8200 0x0c /* Exabyte EXB-8200 */ 107 #define MT_ISEXA8500 0x0d /* Exabyte EXB-8500 */ 108 #define MT_ISVIPER1 0x0e /* Archive Viper-150 */ 109 #define MT_ISPYTHON 0x0f /* Archive Python (DAT) */ 110 #define MT_ISHPDAT 0x10 /* HP 35450A DAT drive */ 111 #define MT_ISWANGTEK 0x11 /* WANGTEK 5150ES */ 112 #define MT_ISCALIPER 0x12 /* Caliper CP150 */ 113 #define MT_ISWTEK5099 0x13 /* WANGTEK 5099ES */ 114 #define MT_ISVIPER2525 0x14 /* Archive Viper 2525 */ 115 #define MT_ISMFOUR 0x11 /* M4 Data 1/2 9track drive */ 116 #define MT_ISTK50 0x12 /* DEC SCSI TK50 */ 117 #define MT_ISMT02 0x13 /* Emulex MT02 SCSI tape controller */ 118 119 /* bits defined for the mt_dsreg field */ 120 #define MT_DS_RDONLY 0x10 /* tape mounted readonly */ 121 #define MT_DS_MOUNTED 0x03 /* tape mounted (for control opens) */ 122 123 /* 124 * For the mt_erreg field.....This is supposed to be a *generic* 125 * MT interface, so we cannot overload it with SCSI specific entities, 126 * (like ASC/ASCQ) nor is there enough room to put all the information 127 * in that is desirable. This whole structure should be redone. 128 * 129 * In the interim, this will be considered device-specific. For SCSI, 130 * this will be taken to mean the last Sense Key seen. It is not 131 * guaranteed to always be sensibly associated with any command. 132 */ 133 134 /* 135 * The action of a MTIOCGET command clears mt_dsreg, mt_erreg, and mt_resid 136 */ 137 138 /* mag tape io control commands */ 139 #define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */ 140 #define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */ 141 #define MTIOCIEOT _IO('m', 3) /* ignore EOT error */ 142 #define MTIOCEEOT _IO('m', 4) /* enable EOT error */ 143 /* 144 * When more SCSI-3 SSC (streaming device) devices are out there 145 * that support the full 32 byte type 2 structure, we'll have to 146 * rethink these ioctls to support all the entities they haul into 147 * the picture (64 bit blocks, logical file record numbers, etc..). 148 */ 149 #define MTIOCRDSPOS _IOR('m', 5, u_int32_t) /* get logical blk addr */ 150 #define MTIOCRDHPOS _IOR('m', 6, u_int32_t) /* get hardware blk addr */ 151 #define MTIOCSLOCATE _IOW('m', 5, u_int32_t) /* seek to logical blk addr */ 152 #define MTIOCHLOCATE _IOW('m', 6, u_int32_t) /* seek to hardware blk addr */ 153 154 #ifdef _KERNEL 155 /* 156 * minor device number 157 */ 158 159 #define T_UNIT 003 /* unit selection */ 160 #define T_NOREWIND 004 /* no rewind on close */ 161 #define T_DENSEL 030 /* density select */ 162 #define T_800BPI 000 /* select 800 bpi */ 163 #define T_1600BPI 010 /* select 1600 bpi */ 164 #define T_6250BPI 020 /* select 6250 bpi */ 165 #define T_BADBPI 030 /* undefined selection */ 166 #endif /* _KERNEL */ 167 168 #endif /* !_SYS_MTIO_H_ */ 169