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