1139825Simp/*- 21541Srgrimes * Copyright (c) 1982, 1986, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 4. Neither the name of the University nor the names of its contributors 141541Srgrimes * may be used to endorse or promote products derived from this software 151541Srgrimes * without specific prior written permission. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 291541Srgrimes * @(#)mtio.h 8.1 (Berkeley) 6/2/93 3050477Speter * $FreeBSD$ 311541Srgrimes */ 321541Srgrimes 3318444Sbde#ifndef _SYS_MTIO_H_ 3418444Sbde#define _SYS_MTIO_H_ 351549Srgrimes 3655205Speter#ifndef _KERNEL 3718444Sbde#include <sys/types.h> 3818444Sbde#endif 3918444Sbde#include <sys/ioccom.h> 4018444Sbde 411541Srgrimes/* 421541Srgrimes * Structures and definitions for mag tape io control commands 431541Srgrimes */ 441541Srgrimes 451541Srgrimes/* structure for MTIOCTOP - mag tape op command */ 461541Srgrimesstruct mtop { 471541Srgrimes short mt_op; /* operations defined below */ 4896564Sphk int32_t mt_count; /* how many of them */ 491541Srgrimes}; 501541Srgrimes 511541Srgrimes/* operations */ 521541Srgrimes#define MTWEOF 0 /* write an end-of-file record */ 531541Srgrimes#define MTFSF 1 /* forward space file */ 541541Srgrimes#define MTBSF 2 /* backward space file */ 551541Srgrimes#define MTFSR 3 /* forward space record */ 561541Srgrimes#define MTBSR 4 /* backward space record */ 571541Srgrimes#define MTREW 5 /* rewind */ 581541Srgrimes#define MTOFFL 6 /* rewind and put the drive offline */ 591541Srgrimes#define MTNOP 7 /* no operation, sets status only */ 601541Srgrimes#define MTCACHE 8 /* enable controller cache */ 611541Srgrimes#define MTNOCACHE 9 /* disable controller cache */ 621541Srgrimes 631549Srgrimes#if defined(__FreeBSD__) 641549Srgrimes/* Set block size for device. If device is a variable size dev */ 651549Srgrimes/* a non zero parameter will change the device to a fixed block size */ 661549Srgrimes/* device with block size set to that of the parameter passed in. */ 671549Srgrimes/* Resetting the block size to 0 will restore the device to a variable */ 681549Srgrimes/* block size device. */ 691549Srgrimes 701549Srgrimes#define MTSETBSIZ 10 711549Srgrimes 7241991Smjacob/* Set density values for device. Sets the value for the opened mode only. */ 731549Srgrimes 741549Srgrimes#define MTSETDNSTY 11 753963Sjkh 767217Sdufault#define MTERASE 12 /* erase to EOM */ 7713347Sjoerg#define MTEOD 13 /* Space to EOM */ 787217Sdufault#define MTCOMP 14 /* select compression mode 0=off, 1=def */ 7913347Sjoerg#define MTRETENS 15 /* re-tension tape */ 8041991Smjacob#define MTWSS 16 /* write setmark(s) */ 8141991Smjacob#define MTFSS 17 /* forward space setmark */ 8241991Smjacob#define MTBSS 18 /* backward space setmark */ 833963Sjkh 8439248Sgibbs#define MT_COMP_ENABLE 0xffffffff 8539248Sgibbs#define MT_COMP_DISABLED 0xfffffffe 8639248Sgibbs#define MT_COMP_UNSUPP 0xfffffffd 8743630Smjacob 8843630Smjacob/* 8943630Smjacob * Values in mt_dsreg that say what the device is doing 9043630Smjacob */ 9143630Smjacob#define MTIO_DSREG_NIL 0 /* Unknown */ 9243630Smjacob#define MTIO_DSREG_REST 1 /* Doing Nothing */ 9343630Smjacob#define MTIO_DSREG_RBSY 2 /* Communicating with tape (but no motion) */ 9443630Smjacob#define MTIO_DSREG_WR 20 /* Writing */ 9543630Smjacob#define MTIO_DSREG_FMK 21 /* Writing Filemarks */ 9643630Smjacob#define MTIO_DSREG_ZER 22 /* Erasing */ 9743630Smjacob#define MTIO_DSREG_RD 30 /* Reading */ 9843630Smjacob#define MTIO_DSREG_FWD 40 /* Spacing Forward */ 9943630Smjacob#define MTIO_DSREG_REV 41 /* Spacing Reverse */ 10043630Smjacob#define MTIO_DSREG_POS 42 /* Hardware Positioning (direction unknown) */ 10143630Smjacob#define MTIO_DSREG_REW 43 /* Rewinding */ 10243630Smjacob#define MTIO_DSREG_TEN 44 /* Retensioning */ 10343630Smjacob#define MTIO_DSREG_UNL 45 /* Unloading */ 10446925Smjacob#define MTIO_DSREG_LD 46 /* Loading */ 10543630Smjacob 10641944Smjacob#endif /* __FreeBSD__ */ 1071549Srgrimes 1081541Srgrimes/* structure for MTIOCGET - mag tape get status command */ 1091541Srgrimes 1101541Srgrimesstruct mtget { 1111541Srgrimes short mt_type; /* type of magtape device */ 1121541Srgrimes/* the following two registers are grossly device dependent */ 1131541Srgrimes short mt_dsreg; /* ``drive status'' register */ 1141541Srgrimes short mt_erreg; /* ``error'' register */ 1151541Srgrimes/* end device-dependent registers */ 11671312Smjacob /* 11771312Smjacob * Note that the residual count, while maintained, may be 11871312Smjacob * be nonsense because the size of the residual may (greatly) 11971312Smjacob * exceed 32 K-bytes. Use the MTIOCERRSTAT ioctl to get a 12071312Smjacob * more accurate count. 12171312Smjacob */ 1221541Srgrimes short mt_resid; /* residual count */ 1231549Srgrimes#if defined (__FreeBSD__) 12496564Sphk int32_t mt_blksiz; /* presently operating blocksize */ 12596564Sphk int32_t mt_density; /* presently operating density */ 12639248Sgibbs u_int32_t mt_comp; /* presently operating compression */ 12796564Sphk int32_t mt_blksiz0; /* blocksize for mode 0 */ 12896564Sphk int32_t mt_blksiz1; /* blocksize for mode 1 */ 12996564Sphk int32_t mt_blksiz2; /* blocksize for mode 2 */ 13096564Sphk int32_t mt_blksiz3; /* blocksize for mode 3 */ 13196564Sphk int32_t mt_density0; /* density for mode 0 */ 13296564Sphk int32_t mt_density1; /* density for mode 1 */ 13396564Sphk int32_t mt_density2; /* density for mode 2 */ 13496564Sphk int32_t mt_density3; /* density for mode 3 */ 1357217Sdufault/* the following are not yet implemented */ 13639248Sgibbs u_int32_t mt_comp0; /* compression type for mode 0 */ 13739248Sgibbs u_int32_t mt_comp1; /* compression type for mode 1 */ 13839248Sgibbs u_int32_t mt_comp2; /* compression type for mode 2 */ 13939248Sgibbs u_int32_t mt_comp3; /* compression type for mode 3 */ 14043639Smjacob/* end not yet implemented */ 1411549Srgrimes#endif 14296564Sphk int32_t mt_fileno; /* relative file number of current position */ 14396564Sphk int32_t mt_blkno; /* relative block number of current position */ 1441541Srgrimes}; 1451541Srgrimes 14641944Smjacob/* structure for MTIOCERRSTAT - tape get error status command */ 14741944Smjacob/* really only supported for SCSI tapes right now */ 14841944Smjacobstruct scsi_tape_errors { 14941944Smjacob /* 15041944Smjacob * These are latched from the last command that had a SCSI 15141944Smjacob * Check Condition noted for these operations. The act 15241944Smjacob * of issuing an MTIOCERRSTAT unlatches and clears them. 15341944Smjacob */ 15441944Smjacob u_int8_t io_sense[32]; /* Last Sense Data For Data I/O */ 15571312Smjacob int32_t io_resid; /* residual count from last Data I/O */ 15642008Smjacob u_int8_t io_cdb[16]; /* Command that Caused the Last Data Sense */ 15741944Smjacob u_int8_t ctl_sense[32]; /* Last Sense Data For Control I/O */ 15871312Smjacob int32_t ctl_resid; /* residual count from last Control I/O */ 15942008Smjacob u_int8_t ctl_cdb[16]; /* Command that Caused the Last Control Sense */ 16041944Smjacob /* 16141944Smjacob * These are the read and write cumulative error counters. 16241944Smjacob * (how to reset cumulative error counters is not yet defined). 16341944Smjacob * (not implemented as yet but space is being reserved for them) 16441944Smjacob */ 16541944Smjacob struct { 16641944Smjacob u_int32_t retries; /* total # retries performed */ 16741944Smjacob u_int32_t corrected; /* total # corrections performed */ 16889609Smpp u_int32_t processed; /* total # corrections successful */ 16941944Smjacob u_int32_t failures; /* total # corrections/retries failed */ 17041944Smjacob u_int64_t nbytes; /* total # bytes processed */ 17143639Smjacob } wterr, rderr; 17241944Smjacob}; 17341944Smjacob 17441944Smjacobunion mterrstat { 17541944Smjacob struct scsi_tape_errors scsi_errstat; 17641944Smjacob char _reserved_padding[256]; 17741944Smjacob}; 17841944Smjacob 1791541Srgrimes/* 1801541Srgrimes * Constants for mt_type byte. These are the same 1811541Srgrimes * for controllers compatible with the types listed. 1821541Srgrimes */ 1831541Srgrimes#define MT_ISTS 0x01 /* TS-11 */ 1841541Srgrimes#define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */ 1851541Srgrimes#define MT_ISTM 0x03 /* TM11/TE10 Unibus */ 1861541Srgrimes#define MT_ISMT 0x04 /* TM78/TU78 Massbus */ 1871541Srgrimes#define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */ 1881541Srgrimes#define MT_ISCPC 0x06 /* SUN */ 1891541Srgrimes#define MT_ISAR 0x07 /* SUN */ 1901541Srgrimes#define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */ 1911541Srgrimes#define MT_ISCY 0x09 /* CCI Cipher */ 1921541Srgrimes#define MT_ISCT 0x0a /* HP 1/4 tape */ 1931541Srgrimes#define MT_ISFHP 0x0b /* HP 7980 1/2 tape */ 1941541Srgrimes#define MT_ISEXABYTE 0x0c /* Exabyte */ 1951541Srgrimes#define MT_ISEXA8200 0x0c /* Exabyte EXB-8200 */ 1961541Srgrimes#define MT_ISEXA8500 0x0d /* Exabyte EXB-8500 */ 1971541Srgrimes#define MT_ISVIPER1 0x0e /* Archive Viper-150 */ 1981541Srgrimes#define MT_ISPYTHON 0x0f /* Archive Python (DAT) */ 1991541Srgrimes#define MT_ISHPDAT 0x10 /* HP 35450A DAT drive */ 2001541Srgrimes#define MT_ISMFOUR 0x11 /* M4 Data 1/2 9track drive */ 2011541Srgrimes#define MT_ISTK50 0x12 /* DEC SCSI TK50 */ 2021541Srgrimes#define MT_ISMT02 0x13 /* Emulex MT02 SCSI tape controller */ 2031541Srgrimes 2041541Srgrimes/* mag tape io control commands */ 2051541Srgrimes#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */ 2061541Srgrimes#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */ 20741944Smjacob/* these two do not appear to be used anywhere */ 2081541Srgrimes#define MTIOCIEOT _IO('m', 3) /* ignore EOT error */ 2091541Srgrimes#define MTIOCEEOT _IO('m', 4) /* enable EOT error */ 21041909Smjacob/* 21141909Smjacob * When more SCSI-3 SSC (streaming device) devices are out there 21241909Smjacob * that support the full 32 byte type 2 structure, we'll have to 21341909Smjacob * rethink these ioctls to support all the entities they haul into 21441909Smjacob * the picture (64 bit blocks, logical file record numbers, etc..). 21541909Smjacob */ 21641909Smjacob#define MTIOCRDSPOS _IOR('m', 5, u_int32_t) /* get logical blk addr */ 21741909Smjacob#define MTIOCRDHPOS _IOR('m', 6, u_int32_t) /* get hardware blk addr */ 21841909Smjacob#define MTIOCSLOCATE _IOW('m', 5, u_int32_t) /* seek to logical blk addr */ 21941909Smjacob#define MTIOCHLOCATE _IOW('m', 6, u_int32_t) /* seek to hardware blk addr */ 22041944Smjacob#define MTIOCERRSTAT _IOR('m', 7, union mterrstat) /* get tape errors */ 22146925Smjacob/* 22246925Smjacob * Set EOT model- argument is number of filemarks to end a tape with. 22346925Smjacob * Note that not all possible values will be accepted. 22446925Smjacob */ 22546925Smjacob#define MTIOCSETEOTMODEL _IOW('m', 8, u_int32_t) 22646925Smjacob/* Get current EOT model */ 22746925Smjacob#define MTIOCGETEOTMODEL _IOR('m', 8, u_int32_t) 2281541Srgrimes 22955205Speter#ifndef _KERNEL 23070545Smjacob#define DEFTAPE "/dev/nsa0" 2311541Srgrimes#endif 2321541Srgrimes 23318444Sbde#endif /* !_SYS_MTIO_H_ */ 234