1*6f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3607ca46eSDavid Howells * linux/mtio.h header file for Linux. Written by H. Bergman 4607ca46eSDavid Howells * 5607ca46eSDavid Howells * Modified for special ioctls provided by zftape in September 1997 6607ca46eSDavid Howells * by C.-J. Heine. 7607ca46eSDavid Howells */ 8607ca46eSDavid Howells 9607ca46eSDavid Howells #ifndef _LINUX_MTIO_H 10607ca46eSDavid Howells #define _LINUX_MTIO_H 11607ca46eSDavid Howells 12607ca46eSDavid Howells #include <linux/types.h> 13607ca46eSDavid Howells #include <linux/ioctl.h> 14607ca46eSDavid Howells 15607ca46eSDavid Howells /* 16607ca46eSDavid Howells * Structures and definitions for mag tape io control commands 17607ca46eSDavid Howells */ 18607ca46eSDavid Howells 19607ca46eSDavid Howells /* structure for MTIOCTOP - mag tape op command */ 20607ca46eSDavid Howells struct mtop { 21607ca46eSDavid Howells short mt_op; /* operations defined below */ 22607ca46eSDavid Howells int mt_count; /* how many of them */ 23607ca46eSDavid Howells }; 24607ca46eSDavid Howells 25607ca46eSDavid Howells /* Magnetic Tape operations [Not all operations supported by all drivers]: */ 26607ca46eSDavid Howells #define MTRESET 0 /* +reset drive in case of problems */ 27607ca46eSDavid Howells #define MTFSF 1 /* forward space over FileMark, 28607ca46eSDavid Howells * position at first record of next file 29607ca46eSDavid Howells */ 30607ca46eSDavid Howells #define MTBSF 2 /* backward space FileMark (position before FM) */ 31607ca46eSDavid Howells #define MTFSR 3 /* forward space record */ 32607ca46eSDavid Howells #define MTBSR 4 /* backward space record */ 33607ca46eSDavid Howells #define MTWEOF 5 /* write an end-of-file record (mark) */ 34607ca46eSDavid Howells #define MTREW 6 /* rewind */ 35607ca46eSDavid Howells #define MTOFFL 7 /* rewind and put the drive offline (eject?) */ 36607ca46eSDavid Howells #define MTNOP 8 /* no op, set status only (read with MTIOCGET) */ 37607ca46eSDavid Howells #define MTRETEN 9 /* retension tape */ 38607ca46eSDavid Howells #define MTBSFM 10 /* +backward space FileMark, position at FM */ 39607ca46eSDavid Howells #define MTFSFM 11 /* +forward space FileMark, position at FM */ 40607ca46eSDavid Howells #define MTEOM 12 /* goto end of recorded media (for appending files). 41607ca46eSDavid Howells * MTEOM positions after the last FM, ready for 42607ca46eSDavid Howells * appending another file. 43607ca46eSDavid Howells */ 44607ca46eSDavid Howells #define MTERASE 13 /* erase tape -- be careful! */ 45607ca46eSDavid Howells 46607ca46eSDavid Howells #define MTRAS1 14 /* run self test 1 (nondestructive) */ 47607ca46eSDavid Howells #define MTRAS2 15 /* run self test 2 (destructive) */ 48607ca46eSDavid Howells #define MTRAS3 16 /* reserved for self test 3 */ 49607ca46eSDavid Howells 50607ca46eSDavid Howells #define MTSETBLK 20 /* set block length (SCSI) */ 51607ca46eSDavid Howells #define MTSETDENSITY 21 /* set tape density (SCSI) */ 52607ca46eSDavid Howells #define MTSEEK 22 /* seek to block (Tandberg, etc.) */ 53607ca46eSDavid Howells #define MTTELL 23 /* tell block (Tandberg, etc.) */ 54607ca46eSDavid Howells #define MTSETDRVBUFFER 24 /* set the drive buffering according to SCSI-2 */ 55607ca46eSDavid Howells /* ordinary buffered operation with code 1 */ 56607ca46eSDavid Howells #define MTFSS 25 /* space forward over setmarks */ 57607ca46eSDavid Howells #define MTBSS 26 /* space backward over setmarks */ 58607ca46eSDavid Howells #define MTWSM 27 /* write setmarks */ 59607ca46eSDavid Howells 60607ca46eSDavid Howells #define MTLOCK 28 /* lock the drive door */ 61607ca46eSDavid Howells #define MTUNLOCK 29 /* unlock the drive door */ 62607ca46eSDavid Howells #define MTLOAD 30 /* execute the SCSI load command */ 63607ca46eSDavid Howells #define MTUNLOAD 31 /* execute the SCSI unload command */ 64607ca46eSDavid Howells #define MTCOMPRESSION 32/* control compression with SCSI mode page 15 */ 65607ca46eSDavid Howells #define MTSETPART 33 /* Change the active tape partition */ 66607ca46eSDavid Howells #define MTMKPART 34 /* Format the tape with one or two partitions */ 67607ca46eSDavid Howells #define MTWEOFI 35 /* write an end-of-file record (mark) in immediate mode */ 68607ca46eSDavid Howells 69607ca46eSDavid Howells /* structure for MTIOCGET - mag tape get status command */ 70607ca46eSDavid Howells 71607ca46eSDavid Howells struct mtget { 72607ca46eSDavid Howells long mt_type; /* type of magtape device */ 73607ca46eSDavid Howells long mt_resid; /* residual count: (not sure) 74607ca46eSDavid Howells * number of bytes ignored, or 75607ca46eSDavid Howells * number of files not skipped, or 76607ca46eSDavid Howells * number of records not skipped. 77607ca46eSDavid Howells */ 78607ca46eSDavid Howells /* the following registers are device dependent */ 79607ca46eSDavid Howells long mt_dsreg; /* status register */ 80607ca46eSDavid Howells long mt_gstat; /* generic (device independent) status */ 81607ca46eSDavid Howells long mt_erreg; /* error register */ 82607ca46eSDavid Howells /* The next two fields are not always used */ 83607ca46eSDavid Howells __kernel_daddr_t mt_fileno; /* number of current file on tape */ 84607ca46eSDavid Howells __kernel_daddr_t mt_blkno; /* current block number */ 85607ca46eSDavid Howells }; 86607ca46eSDavid Howells 87607ca46eSDavid Howells 88607ca46eSDavid Howells 89607ca46eSDavid Howells /* 90607ca46eSDavid Howells * Constants for mt_type. Not all of these are supported, 91607ca46eSDavid Howells * and these are not all of the ones that are supported. 92607ca46eSDavid Howells */ 93607ca46eSDavid Howells #define MT_ISUNKNOWN 0x01 94607ca46eSDavid Howells #define MT_ISQIC02 0x02 /* Generic QIC-02 tape streamer */ 95607ca46eSDavid Howells #define MT_ISWT5150 0x03 /* Wangtek 5150EQ, QIC-150, QIC-02 */ 96607ca46eSDavid Howells #define MT_ISARCHIVE_5945L2 0x04 /* Archive 5945L-2, QIC-24, QIC-02? */ 97607ca46eSDavid Howells #define MT_ISCMSJ500 0x05 /* CMS Jumbo 500 (QIC-02?) */ 98607ca46eSDavid Howells #define MT_ISTDC3610 0x06 /* Tandberg 6310, QIC-24 */ 99607ca46eSDavid Howells #define MT_ISARCHIVE_VP60I 0x07 /* Archive VP60i, QIC-02 */ 100607ca46eSDavid Howells #define MT_ISARCHIVE_2150L 0x08 /* Archive Viper 2150L */ 101607ca46eSDavid Howells #define MT_ISARCHIVE_2060L 0x09 /* Archive Viper 2060L */ 102607ca46eSDavid Howells #define MT_ISARCHIVESC499 0x0A /* Archive SC-499 QIC-36 controller */ 103607ca46eSDavid Howells #define MT_ISQIC02_ALL_FEATURES 0x0F /* Generic QIC-02 with all features */ 104607ca46eSDavid Howells #define MT_ISWT5099EEN24 0x11 /* Wangtek 5099-een24, 60MB, QIC-24 */ 105607ca46eSDavid Howells #define MT_ISTEAC_MT2ST 0x12 /* Teac MT-2ST 155mb drive, Teac DC-1 card (Wangtek type) */ 106607ca46eSDavid Howells #define MT_ISEVEREX_FT40A 0x32 /* Everex FT40A (QIC-40) */ 107607ca46eSDavid Howells #define MT_ISDDS1 0x51 /* DDS device without partitions */ 108607ca46eSDavid Howells #define MT_ISDDS2 0x52 /* DDS device with partitions */ 109607ca46eSDavid Howells #define MT_ISONSTREAM_SC 0x61 /* OnStream SCSI tape drives (SC-x0) 110607ca46eSDavid Howells and SCSI emulated (DI, DP, USB) */ 111607ca46eSDavid Howells #define MT_ISSCSI1 0x71 /* Generic ANSI SCSI-1 tape unit */ 112607ca46eSDavid Howells #define MT_ISSCSI2 0x72 /* Generic ANSI SCSI-2 tape unit */ 113607ca46eSDavid Howells 114607ca46eSDavid Howells /* QIC-40/80/3010/3020 ftape supported drives. 115607ca46eSDavid Howells * 20bit vendor ID + 0x800000 (see ftape-vendors.h) 116607ca46eSDavid Howells */ 117607ca46eSDavid Howells #define MT_ISFTAPE_UNKNOWN 0x800000 /* obsolete */ 118607ca46eSDavid Howells #define MT_ISFTAPE_FLAG 0x800000 119607ca46eSDavid Howells 120607ca46eSDavid Howells 121607ca46eSDavid Howells /* structure for MTIOCPOS - mag tape get position command */ 122607ca46eSDavid Howells 123607ca46eSDavid Howells struct mtpos { 124607ca46eSDavid Howells long mt_blkno; /* current block number */ 125607ca46eSDavid Howells }; 126607ca46eSDavid Howells 127607ca46eSDavid Howells 128607ca46eSDavid Howells /* mag tape io control commands */ 129607ca46eSDavid Howells #define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */ 130607ca46eSDavid Howells #define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */ 131607ca46eSDavid Howells #define MTIOCPOS _IOR('m', 3, struct mtpos) /* get tape position */ 132607ca46eSDavid Howells 133607ca46eSDavid Howells 134607ca46eSDavid Howells /* Generic Mag Tape (device independent) status macros for examining 135607ca46eSDavid Howells * mt_gstat -- HP-UX compatible. 136607ca46eSDavid Howells * There is room for more generic status bits here, but I don't 137607ca46eSDavid Howells * know which of them are reserved. At least three or so should 138607ca46eSDavid Howells * be added to make this really useful. 139607ca46eSDavid Howells */ 140607ca46eSDavid Howells #define GMT_EOF(x) ((x) & 0x80000000) 141607ca46eSDavid Howells #define GMT_BOT(x) ((x) & 0x40000000) 142607ca46eSDavid Howells #define GMT_EOT(x) ((x) & 0x20000000) 143607ca46eSDavid Howells #define GMT_SM(x) ((x) & 0x10000000) /* DDS setmark */ 144607ca46eSDavid Howells #define GMT_EOD(x) ((x) & 0x08000000) /* DDS EOD */ 145607ca46eSDavid Howells #define GMT_WR_PROT(x) ((x) & 0x04000000) 146607ca46eSDavid Howells /* #define GMT_ ? ((x) & 0x02000000) */ 147607ca46eSDavid Howells #define GMT_ONLINE(x) ((x) & 0x01000000) 148607ca46eSDavid Howells #define GMT_D_6250(x) ((x) & 0x00800000) 149607ca46eSDavid Howells #define GMT_D_1600(x) ((x) & 0x00400000) 150607ca46eSDavid Howells #define GMT_D_800(x) ((x) & 0x00200000) 151607ca46eSDavid Howells /* #define GMT_ ? ((x) & 0x00100000) */ 152607ca46eSDavid Howells /* #define GMT_ ? ((x) & 0x00080000) */ 153607ca46eSDavid Howells #define GMT_DR_OPEN(x) ((x) & 0x00040000) /* door open (no tape) */ 154607ca46eSDavid Howells /* #define GMT_ ? ((x) & 0x00020000) */ 155607ca46eSDavid Howells #define GMT_IM_REP_EN(x) ((x) & 0x00010000) /* immediate report mode */ 156607ca46eSDavid Howells #define GMT_CLN(x) ((x) & 0x00008000) /* cleaning requested */ 157607ca46eSDavid Howells /* 15 generic status bits unused */ 158607ca46eSDavid Howells 159607ca46eSDavid Howells 160607ca46eSDavid Howells /* SCSI-tape specific definitions */ 161607ca46eSDavid Howells /* Bitfield shifts in the status */ 162607ca46eSDavid Howells #define MT_ST_BLKSIZE_SHIFT 0 163607ca46eSDavid Howells #define MT_ST_BLKSIZE_MASK 0xffffff 164607ca46eSDavid Howells #define MT_ST_DENSITY_SHIFT 24 165607ca46eSDavid Howells #define MT_ST_DENSITY_MASK 0xff000000 166607ca46eSDavid Howells 167607ca46eSDavid Howells #define MT_ST_SOFTERR_SHIFT 0 168607ca46eSDavid Howells #define MT_ST_SOFTERR_MASK 0xffff 169607ca46eSDavid Howells 170607ca46eSDavid Howells /* Bitfields for the MTSETDRVBUFFER ioctl */ 171607ca46eSDavid Howells #define MT_ST_OPTIONS 0xf0000000 172607ca46eSDavid Howells #define MT_ST_BOOLEANS 0x10000000 173607ca46eSDavid Howells #define MT_ST_SETBOOLEANS 0x30000000 174607ca46eSDavid Howells #define MT_ST_CLEARBOOLEANS 0x40000000 175607ca46eSDavid Howells #define MT_ST_WRITE_THRESHOLD 0x20000000 176607ca46eSDavid Howells #define MT_ST_DEF_BLKSIZE 0x50000000 177607ca46eSDavid Howells #define MT_ST_DEF_OPTIONS 0x60000000 178607ca46eSDavid Howells #define MT_ST_TIMEOUTS 0x70000000 179607ca46eSDavid Howells #define MT_ST_SET_TIMEOUT (MT_ST_TIMEOUTS | 0x000000) 180607ca46eSDavid Howells #define MT_ST_SET_LONG_TIMEOUT (MT_ST_TIMEOUTS | 0x100000) 181607ca46eSDavid Howells #define MT_ST_SET_CLN 0x80000000 182607ca46eSDavid Howells 183607ca46eSDavid Howells #define MT_ST_BUFFER_WRITES 0x1 184607ca46eSDavid Howells #define MT_ST_ASYNC_WRITES 0x2 185607ca46eSDavid Howells #define MT_ST_READ_AHEAD 0x4 186607ca46eSDavid Howells #define MT_ST_DEBUGGING 0x8 187607ca46eSDavid Howells #define MT_ST_TWO_FM 0x10 188607ca46eSDavid Howells #define MT_ST_FAST_MTEOM 0x20 189607ca46eSDavid Howells #define MT_ST_AUTO_LOCK 0x40 190607ca46eSDavid Howells #define MT_ST_DEF_WRITES 0x80 191607ca46eSDavid Howells #define MT_ST_CAN_BSR 0x100 192607ca46eSDavid Howells #define MT_ST_NO_BLKLIMS 0x200 193607ca46eSDavid Howells #define MT_ST_CAN_PARTITIONS 0x400 194607ca46eSDavid Howells #define MT_ST_SCSI2LOGICAL 0x800 195607ca46eSDavid Howells #define MT_ST_SYSV 0x1000 196607ca46eSDavid Howells #define MT_ST_NOWAIT 0x2000 197607ca46eSDavid Howells #define MT_ST_SILI 0x4000 198607ca46eSDavid Howells #define MT_ST_NOWAIT_EOF 0x8000 199607ca46eSDavid Howells 200607ca46eSDavid Howells /* The mode parameters to be controlled. Parameter chosen with bits 20-28 */ 201607ca46eSDavid Howells #define MT_ST_CLEAR_DEFAULT 0xfffff 202607ca46eSDavid Howells #define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000) 203607ca46eSDavid Howells #define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000) 204607ca46eSDavid Howells #define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000) 205607ca46eSDavid Howells 206607ca46eSDavid Howells /* The offset for the arguments for the special HP changer load command. */ 207607ca46eSDavid Howells #define MT_ST_HPLOADER_OFFSET 10000 208607ca46eSDavid Howells 209607ca46eSDavid Howells #endif /* _LINUX_MTIO_H */ 210