1/* $NetBSD: mtreg.h,v 1.4 2005/12/11 12:17:14 christos Exp $ */ 2 3/* 4 * Copyright (c) 1992, The University of Utah and 5 * the Computer Systems Laboratory at the University of Utah (CSL). 6 * All rights reserved. 7 * 8 * Permission to use, copy, modify and distribute this software is hereby 9 * granted provided that (1) source code retains these copyright, permission, 10 * and disclaimer notices, and (2) redistributions including binaries 11 * reproduce the notices in supporting documentation, and (3) all advertising 12 * materials mentioning features or use of this software display the following 13 * acknowledgement: ``This product includes software developed by the 14 * Computer Systems Laboratory at the University of Utah.'' 15 * 16 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS 17 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF 18 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 * 20 * CSL requests users of this software to return to csl-dist@cs.utah.edu any 21 * improvements that they make and grant CSL redistribution rights. 22 * 23 * Utah $Hdr: mtreg.h 1.4 95/09/12$ 24 */ 25/* @(#)mtreg.h 3.4 90/07/10 mt Xinu 26 * 27 * Hewlett-Packard 7974, 7978, 7979 and 7980 HPIB Mag-Tape declarations. 28 */ 29 30/* 31 * Hardware Id's 32 */ 33 34#define MT7974AID 0x174 35#define MT7978ID 0x178 36#define MT7979AID 0x179 37#define MT7980ID 0x180 38 39/* convert bytes to 1k tape block and back */ 40#define CTBTOK(x) ((x) >> 10) 41#define CTKTOB(x) ((x) << 10) 42 43/* 44 * Listen Secondary Commands 45 */ 46 47#define MTL_WRITE 0 /* write execute */ 48#define MTL_TCMD 1 /* tape command */ 49#define MTL_DIAG 4 /* download diagnostic */ 50#define MTL_FUP 6 /* write firmware update */ 51#define MTL_ECMD 7 /* end command */ 52#define MTL_DCL 16 /* amigo device clear */ 53#define MTL_CCRC 17 /* clear CRC */ 54#define MTL_XTEST 29 /* run 7979a/7980 extended self test */ 55#define MTL_LOOP 30 /* write interface loopback */ 56#define MTL_TEST 31 /* run self test */ 57 58/* 59 * Talk Secondary Commands 60 */ 61 62#define MTT_READ 0 /* read execute */ 63#define MTT_STAT 1 /* read status */ 64#define MTT_BCNT 2 /* read byte count */ 65#define MTT_DIAG 3 /* read diagnostic results */ 66#define MTT_FREV 4 /* read firmware revisions (7980xc) */ 67#define MTT_LOG 5 /* read diagnostic log */ 68#define MTT_FUP 6 /* read firmware update */ 69#define MTT_XSTAT 15 /* read extended status (7979a/7980a) */ 70#define MTT_DSJ 16 /* read DSJ (device specified jump) */ 71#define MTT_RCRC 17 /* read CRC */ 72#define MTT_XTEST 29 /* read 7979a/7980 extended self test */ 73#define MTT_LOOP 30 /* read interface loopback */ 74#define MTT_TEST 31 /* read self test */ 75 76/* 77 * Tape commands 78 */ 79 80#define MTTC_SEL0 0 /* Select Unit 0 (native protocol) */ 81#define MTTC_WRITE 5 /* Write Record */ 82#define MTTC_WFM 6 /* Write File Mark */ 83#define MTTC_WGAP 7 /* Write Gap */ 84#define MTTC_READ 8 /* Read record */ 85#define MTTC_FSR 9 /* forward space record */ 86#define MTTC_BSR 10 /* backward space record */ 87#define MTTC_FSF 11 /* forward space file */ 88#define MTTC_BSF 12 /* backward space file */ 89#define MTTC_REW 13 /* rewind */ 90#define MTTC_REWOFF 14 /* rewind and go offline */ 91#define MTTC_DC6250 15 /* set data compressed 6250 */ 92#define MTTC_6250 16 /* set 6250 bpi */ 93#define MTTC_1600 17 /* set 1600 bpi */ 94#define MTTC_800 18 /* set 800 bpi */ 95#define MTTC_NC6250 19 /* set non-compressed 6250 */ 96#define MTTC_STSTP 20 /* start/stop mode only */ 97#define MTTC_STRM 21 /* enable streaming */ 98#define MTTC_DIRM 22 /* disable immediate report mode */ 99#define MTTC_EIRM 23 /* enable immediate report mode */ 100#define MTTC_STAT 24 /* request status */ 101#define MTTC_RLD 25 /* remote load */ 102#define MTTC_RUNLD 26 /* remote unload */ 103#define MTTC_RON 28 /* remote online */ 104#define MTTC_DDC 30 /* disable data compression */ 105#define MTTC_EDC 31 /* enable data compression */ 106 107/* 108 * End Command Bits (of any interest) 109 */ 110#define MTE_COMPLETE 0x08 /* "marks the end of the report phase" */ 111#define MTE_IDLE 0x04 /* enables parallel poll resp. for online */ 112#define MTE_STOP 0x02 /* aborts transfer of "read" data */ 113 114#define MTE_DSJ_FORCE 0x100 /* XXX During readDSJ, force a status fetch */ 115 116 117struct mt_stat { 118 u_char m_stat[6]; 119}; 120 121/* sc_flags */ 122#define MTF_OPEN 0x0001 /* drive is in use (single-access device) */ 123#define MTF_EXISTS 0x0002 /* device was found at boot time */ 124#define MTF_ALIVE 0x0004 /* drive actually talks to us */ 125#define MTF_WRT 0x0008 /* last command was a WRITE */ 126#define MTF_IO 0x0010 /* next interrupt should start I/O (DMA) */ 127#define MTF_REW 0x0020 /* tape is rewinding - must wait for it */ 128#define MTF_HITEOF 0x0040 /* last read or FSR hit EOF (file mark) */ 129#define MTF_HITBOF 0x0080 /* last BSR hit EOF (file mark) */ 130#define MTF_ATEOT 0x0100 /* tape hit EOT - can allow one forward op */ 131#define MTF_PASTEOT 0x0200 /* tape is beyond EOT - force backward motion */ 132#define MTF_DSJTIMEO 0x0400 /* timed out hpibrecv()ing DSJ - continue it */ 133#define MTF_STATTIMEO 0x0800 /* timed out recieving STATUS - continue it */ 134#define MTF_STATCONT 0x1000 /* STATTIMEO is continuable */ 135 136/* additional "mtcommand"s */ 137#define MTRESET 16 /* reset the thing from scratch */ 138#define MTSET800BPI 17 /* density select */ 139#define MTSET1600BPI 18 140#define MTSET6250BPI 19 141#define MTSET6250DC 20 /* (data compressed - MT7980ID only) */ 142 143/* status bytes */ 144#define sc_stat1 sc_stat.m_stat[0] 145#define sc_stat2 sc_stat.m_stat[1] 146#define sc_stat3 sc_stat.m_stat[2] 147#define sc_stat4 sc_stat.m_stat[3] 148#define sc_stat5 sc_stat.m_stat[4] 149#define sc_stat6 sc_stat.m_stat[5] 150 151/* 152 * Status Register definitions 153 */ 154 155#define SR1_EOF 0x80 /* positioned at File Mark */ 156#define SR1_BOT 0x40 /* positioned at Beginning of Tape */ 157#define SR1_EOT 0x20 /* positioned at End of Tape */ 158#define SR1_SOFTERR 0x10 /* Recoverable Error has Occurred */ 159#define SR1_REJECT 0x08 /* HPIB Cmd rejected - Regs 4 & 5 have info */ 160#define SR1_RO 0x04 /* No Write Ring */ 161#define SR1_ERR 0x02 /* Unrecoverable Data error - Reg 5 has info */ 162#define SR1_ONLINE 0x01 /* Drive Online (must be to do any operation) */ 163 164#define SR2_6250 0x80 /* tape is 6250BPI */ 165#define SR2_UNKDEN 0x40 /* non-blank tape is of unknown density */ 166#define SR2_PARITY 0x20 /* internal bus data parity error detected */ 167#define SR2_OVERRUN 0x10 /* data buffer overrun (not possible?) */ 168#define SR2_RUNAWAY 0x08 /* during read, no data detected on tape */ 169#define SR2_OPEN 0x04 /* tape door is open */ 170#define SR2_LONGREC 0x02 /* large record support (32k@1600, 60K@6250, 171 otherwise, it's 16K at all densities) */ 172#define SR2_IMMED 0x01 /* Immediate Response (for writes) enabled */ 173 174#define SR3_1600 0x80 /* tape is 1600BPI */ 175#define SR3_800 0x40 /* tape is 800BPI */ 176#define SR3_POWERUP 0x20 /* power recently restored or Dev Clr done */ 177#define SR3_HPIBPAR 0x10 /* HPIB command parity error detected */ 178#define SR3_LOST 0x08 /* position on tape is unknown */ 179#define SR3_FMTERR 0x04 /* formatter error - Reg 5 has info */ 180#define SR3_SVOERR 0x02 /* motion servo error - Reg 4 has info */ 181#define SR3_CTLERR 0x01 /* controller error - Reg 5 has info */ 182 183#define SR4_ERCLMASK 0xe0 /* Mask of error classes (for SR1_REJECT) */ 184#define SR4_NONE 0x00 185#define SR4_DEVICE 0x40 186#define SR4_PROTOCOL 0x60 187#define SR4_SELFTEST 0xe0 188#define SR4_RETRYMASK 0x1f /* Mask for retry count (for any error) */ 189 190/* SR5 holds lots of error codes, referenced above. Complete list: 191 * (DEVICE REJECT) 192 * 5 Tape is write protected 193 * 6 Tape isn't loaded 194 * 7 Requested density not supported 195 * 9 Tape being read is unreadable 196 * 10 Tape being written is unidentifiable 197 * 11 Drive offline 198 * 16 Changing density while not at BOT 199 * 19 Backward motion requested while at BOT 200 * 23 Protocol out of sync 201 * 24 Unknown tape command 202 * 31 Write request too big for drive/density 203 * 32 Beyond EOT 204 * 33 Self Test Failure 205 * 37 Tape positioning failure while removing readaheads 206 * 40 Door open 207 * (UNRECOVERED DATA/FORMAT ERRORS) 208 * 41 Tape velocity out of spec 209 * 45 Multiple track data error 210 * 47 Write verify failed 211 * 48 Noise found while trying to detect data record 212 * 49 Data format error 213 * 50 Couldn't identify tape after rewind 214 * 51 Gap detected before end of data record 215 * 52 Data block dropout 216 * 53 CRC error 217 * 54 Parity error 218 * 55 Door open 219 * 57 Maximum skew exceeded 220 * 58 False data block detected 221 * 59 Corrected data error on write 222 * 60 Buffer overrun - record size on tape larger than supported 223 * 61 Data block timeout (possibly record length too long) 224 * 62 Tape mark dropout 225 * 63 Tape mark unverified 226 * 64 Tape mark timeout (no gap following tape mark) 227 * (POSITION or SERVO ERRORS) - these are ALL internal to tape drive 228 * 81 Servo unresponsive 229 * 82 Servo didn't respond with corect state 230 * 83 Servo shutdown 231 * 84 Servo detected hardware failure 232 * 85 Servo protocol error 233 * 86 Runtime Servo error 234 * 87 Missing position interrupt 235 * 88 No Gap after read or write 236 * 89 Motor shutdown for safety reasons 237 * 90 Couldn't find tape BOT mark 238 * 91 Drive motor running too fast or slow 239 * 92 Requested controller state invalid within context 240 * 94 Tape positioning failure 241 * (FORMATTER ERROR) 242 * 101,108 Read formatter unresponsive 243 * 102,107 Read formatter hardware error 244 * 103 Write detected bad block 245 * 104 Erase failure 246 * 105 No data detected after write 247 * 106 Tracks out of sync on write verify 248 * 109 No gap timeout 249 * 110 Formatter <--> data buffer byte count mismatch 250 * (CONTROLLER ERROR) - these are ALL internal to drive 251 * 121 Transaction ID mismatch (device vs. controller) 252 * 122 Devoce report has no coorepinding command 253 * 123 Invalid device report 254 * 124 Repost queue overflow 255 * 125 Unknown command from device 256 * 126 Command queue overflow 257 * 128 Missing End-Of-Record flag in data buffer 258 * 129 Data buffer parity error 259 * 130 Data buffer underrun during write 260 * 131 Byte count mismatch in data buffer queue 261 * 132 Bad message type from device 262 * 133 Abort between HPIB interface and channel program 263 * 134 Unknown HPIB interface exception 264 * 137 Illegal access to servo conntroller registers 265 * 138 Device program firmware error 266 * 139 Hardware utilities firmware error 267 * 140 Channel program firmware error 268 * 141 Encoder inoperative 269 * 150 Tape position synchronization error 270 * 151 Tape deblocking error (Xtra Capacity only) 271 * 152 Compression/Decompression hardware error (Xtra Capacity only) 272 * (PROTOCOL ERROR) - USUALLY indicates deficiency in driver 273 * 161 No room in Command Queue 274 * 162 Expected "request DSJ" 275 * 163 Expected status request 276 * 165 Unknown unit select 277 * 166 Tape command secondary expected 278 * 167 Data byte expected 279 * 168 Missing EOI on data byte 280 * 170 Write command phase protocol error 281 * 172 Read record report phase error 282 * 173 Report phase protocol error 283 * 174 Cold load sequence error 284 * 175 HPIB protocol sequence error 285 * 176 END command expected 286 * 178 END DATA expected 287 * 180 Unknown interface secondary command 288 * 181 Misplaced data byte 289 * 184 Interface Loopback protocol error 290 * 185 Self test protocol error 291 * 188 HPIB parity error 292 * 189 Operator reset during protocol sequence 293 * 190 Device clear received 294 */ 295 296/* SR6 is count of commands accepted since Immediate Response command failed */ 297