1 /* TAPEDEV.H    (c) Copyright Ivan Warren and others, 2003-2009      */
2 /*              Tape Device Handler Structure Definitions            */
3 
4 /*-------------------------------------------------------------------*/
5 /* This header file contains tape related structures and defines     */
6 /* for the Hercules ESA/390 emulator.                                */
7 /*-------------------------------------------------------------------*/
8 
9 #ifndef __TAPEDEV_H__
10 #define __TAPEDEV_H__
11 
12 #include "scsitape.h"       /* SCSI Tape handling functions          */
13 #include "htypes.h"         /* Hercules struct typedefs              */
14 #include "opcode.h"         /* device_attention, SETMODE, etc.       */
15 #include "parser.h"         /* generic parameter string parser       */
16 
17 /*-------------------------------------------------------------------*/
18 /* Internal macro definitions                                        */
19 /*-------------------------------------------------------------------*/
20 #define MAX_BLKLEN              65535   /* Maximum I/O buffer size   */
21 #define TAPE_UNLOADED           "*"     /* Name for unloaded drive   */
22 
23 /*-------------------------------------------------------------------*/
24 /* Definitions for 3420/3480 sense bytes                             */
25 /*-------------------------------------------------------------------*/
26 #define SENSE1_TAPE_NOISE       0x80    /* Noise                     */
27 #define SENSE1_TAPE_TUA         0x40    /* TU Status A (ready)       */
28 #define SENSE1_TAPE_TUB         0x20    /* TU Status B (not ready)   */
29 #define SENSE1_TAPE_7TRK        0x10    /* 7-track feature           */
30 #define SENSE1_TAPE_RSE         0x10    /* Record sequence error     */
31 #define SENSE1_TAPE_LOADPT      0x08    /* Tape is at load point     */
32 #define SENSE1_TAPE_WRT         0x04    /* Tape is in write status   */
33 #define SENSE1_TAPE_FP          0x02    /* File protect status       */
34 #define SENSE1_TAPE_NCA         0x01    /* Not capable               */
35 
36 #define SENSE4_TAPE_EOT         0x20    /* Tape indicate (EOT)       */
37 
38 #define SENSE5_TAPE_SRDCHK      0x08    /* Start read check          */
39 #define SENSE5_TAPE_PARTREC     0x04    /* Partial record            */
40 
41 #define SENSE7_TAPE_LOADFAIL    0x01    /* Load failure              */
42 
43 /*-------------------------------------------------------------------*/
44 /* ISW : Internal error types used to build Device Dependent Sense   */
45 /*-------------------------------------------------------------------*/
46 #define TAPE_BSENSE_TAPEUNLOADED   0    /* I/O Attempted but no tape loaded */
47 #define TAPE_BSENSE_TAPELOADFAIL   1    /* I/O and load failed       */
48 #define TAPE_BSENSE_READFAIL       2    /* Error reading block       */
49 #define TAPE_BSENSE_WRITEFAIL      3    /* Error writing block       */
50 #define TAPE_BSENSE_BADCOMMAND     4    /* The CCW code is not known
51                                            or sequence error         */
52 #define TAPE_BSENSE_INCOMPAT       5    /* The CCW code is known
53                                            but is not unsupported    */
54 #define TAPE_BSENSE_WRITEPROTECT   6    /* Write CCW code was issued
55                                            to a read-only media      */
56 #define TAPE_BSENSE_EMPTYTAPE      7    /* A read was issued but the
57                                            tape is empty             */
58 #define TAPE_BSENSE_ENDOFTAPE      8    /* A read was issued past the
59                                            end of the tape or a write
60                                            was issued and there is no
61                                            space left on the tape    */
62 #define TAPE_BSENSE_LOADPTERR      9    /* BSF/BSR/RdBW attempted
63                                            from BOT                  */
64 #define TAPE_BSENSE_FENCED         10   /* Media damaged - unload
65                                            or /reload required       */
66 #define TAPE_BSENSE_BADALGORITHM   11   /* Bad compression - HET
67                                            tape compressed with an
68                                            unsuported method         */
69 #define TAPE_BSENSE_RUN_SUCCESS    12   /* Rewind Unload success     */
70 #define TAPE_BSENSE_STATUSONLY     13   /* No exception occured      */
71 #define TAPE_BSENSE_LOCATEERR      14   /* Can't find block or TM    */
72 #define TAPE_BSENSE_READTM         15   /* A Tape Mark was read      */
73 
74 #define TAPE_BSENSE_BLOCKSHORT     17   /* Short Tape block */
75 #define TAPE_BSENSE_ITFERROR       18   /* Interface error (SCSI
76                                            driver unexpected err)    */
77 #define TAPE_BSENSE_REWINDFAILED   19   /* Rewind operation failed   */
78 #define TAPE_BSENSE_UNSOLICITED    20   /* Sense without UC          */
79 
80 /*-------------------------------------------------------------------*/
81 /* Definitions for 3480 and later commands                           */
82 /*-------------------------------------------------------------------*/
83 /* Format control byte for Load Display command */
84 #define FCB_FS                  0xE0    /* Function Select bits...   */
85 #define FCB_FS_READYGO          0x00    /* Display msg until motion, */
86                                         /* or until msg is updated   */
87 #define FCB_FS_UNMOUNT          0x20    /* Display msg until unloaded*/
88 #define FCB_FS_MOUNT            0x40    /* Display msg until loaded  */
89 #define FCB_FS_RESET_DISPLAY    0x80    /* Reset display (clear Host */
90                                         /* msg; replace w/Unit msg)  */
91 #define FCB_FS_NOP              0x60    /* No-op                     */
92 #define FCB_FS_UMOUNTMOUNT      0xE0    /* Display msg 1 until tape  */
93                                         /* is unloaded, then msg 2   */
94                                         /* until tape is loaded      */
95 #define FCB_AM                  0x10    /* Alternate between msg 1/2 */
96 #define FCB_BM                  0x08    /* Blink message             */
97 #define FCB_M2                  0x04    /* Display only message 2    */
98 #define FCB_RESV                0x02    /* (reserved)                */
99 #define FCB_AL                  0x01    /* Activate AutoLoader on    */
100                                         /* mount/unmount messages    */
101 /* Mode Set commands */
102 #define MSET_WRITE_IMMED        0x20    /* Tape-Write-Immediate mode */
103 #define MSET_SUPVR_INHIBIT      0x10    /* Supervisor Inhibit mode   */
104 #define MSET_IDRC               0x08    /* IDRC mode                 */
105 
106 /* Path state byte for Sense Path Group ID command */
107 #define SPG_PATHSTAT            0xC0    /* Pathing status bits...    */
108 #define SPG_PATHSTAT_RESET      0x00    /* ...reset                  */
109 #define SPG_PATHSTAT_RESV       0x40    /* ...reserved bit setting   */
110 #define SPG_PATHSTAT_UNGROUPED  0x80    /* ...ungrouped              */
111 #define SPG_PATHSTAT_GROUPED    0xC0    /* ...grouped                */
112 #define SPG_PARTSTAT            0x30    /* Partitioning status bits..*/
113 #define SPG_PARTSTAT_IENABLED   0x00    /* ...implicitly enabled     */
114 #define SPG_PARTSTAT_RESV       0x10    /* ...reserved bit setting   */
115 #define SPG_PARTSTAT_DISABLED   0x20    /* ...disabled               */
116 #define SPG_PARTSTAT_XENABLED   0x30    /* ...explicitly enabled     */
117 #define SPG_PATHMODE            0x08    /* Path mode bit...          */
118 #define SPG_PATHMODE_SINGLE     0x00    /* ...single path mode       */
119 #define SPG_PATHMODE_RESV       0x08    /* ...reserved bit setting   */
120 #define SPG_RESERVED            0x07    /* Reserved bits, must be 0  */
121 
122 /* Function control byte for Set Path Group ID command */
123 #define SPG_SET_MULTIPATH       0x80    /* Set multipath mode        */
124 #define SPG_SET_COMMAND         0x60    /* Set path command bits...  */
125 #define SPG_SET_ESTABLISH       0x00    /* ...establish group        */
126 #define SPG_SET_DISBAND         0x20    /* ...disband group          */
127 #define SPG_SET_RESIGN          0x40    /* ...resign from group      */
128 #define SPG_SET_COMMAND_RESV    0x60    /* ...reserved bit setting   */
129 #define SPG_SET_RESV            0x1F    /* Reserved bits, must be 0  */
130 
131 /* Perform Subsystem Function order byte for PSF command             */
132 #define PSF_ORDER_PRSD          0x18    /* Prep for Read Subsys Data */
133 #define PSF_ACTION_SSD_ATNMSG   0x03    /* ..Attention Message       */
134 #define PSF_ORDER_SSIC          0x1B    /* Set Special Intercept Cond*/
135 #define PSF_ORDER_MNS           0x1C    /* Message Not Supported     */
136 #define PSF_ORDER_AFEL          0x80    /* Activate Forced Error Log.*/
137 #define PSF_ORDER_DFEL          0x81    /* Deact. Forced Error Log.  */
138 #define PSF_ACTION_FEL_IMPLICIT 0x01    /* ..Implicit (De)Activate   */
139 #define PSF_ACTION_FEL_EXPLICIT 0x02    /* ..Explicit (De)Activate   */
140 #define PSF_ORDER_AAC           0x82    /* Activate Access Control   */
141 #define PSF_ORDER_DAC           0x83    /* Deact. Access Control     */
142 #define PSF_ACTION_AC_LWP       0x80    /* ..Logical Write Protect   */
143 #define PSF_ACTION_AC_DCD       0x10    /* ..Data Compaction Default */
144 #define PSF_ACTION_AC_DCR       0x02    /* ..Data Check Recovery     */
145 #define PSF_ACTION_AC_ER        0x01    /* ..Extended Recovery       */
146 #define PSF_ORDER_RVF           0x90    /* Reset Volume Fenced       */
147 #define PSF_ORDER_PIN_DEV       0xA1    /* Pin Device                */
148 #define PSF_ACTION_PIN_CU0      0x00    /* ..Control unit 0          */
149 #define PSF_ACTION_PIN_CU1      0x01    /* ..Control unit 1          */
150 #define PSF_ORDER_UNPIN_DEV     0xA2    /* Unpin Device              */
151 #define PSF_FLAG_ZERO           0x00    /* Must be zero for all ord. */
152 
153 /* Control Access Function Control                                   */
154 #define CAC_FUNCTION            0xC0    /* Function control bits     */
155 #define CAC_SET_PASSWORD        0x00    /* ..Set Password            */
156 #define CAC_COND_ENABLE         0x80    /* ..Conditional Enable      */
157 #define CAC_COND_DISABLE        0x40    /* ..Conditional Disable     */
158 
159 /*-------------------------------------------------------------------*/
160 /* Definitions for tape device type field in device block            */
161 /*-------------------------------------------------------------------*/
162 #define TAPEDEVT_UNKNOWN        0       /* AWSTAPE format disk file  */
163 #define TAPEDEVT_AWSTAPE        1       /* AWSTAPE format disk file  */
164 #define TAPEDEVT_OMATAPE        2       /* OMATAPE format disk files */
165 #define TAPEDEVT_SCSITAPE       3       /* Physical SCSI tape        */
166 #define TAPEDEVT_HETTAPE        4       /* HET format disk file      */
167 #define TAPEDEVT_FAKETAPE       5       /* Flex FakeTape disk format */
168 
169 /*-------------------------------------------------------------------*/
170 /* Fish - macros for checking SCSI tape device-independent status    */
171 /*-------------------------------------------------------------------*/
172 #if defined(OPTION_SCSI_TAPE)
173 #define STS_TAPEMARK(dev)       GMT_SM      ( (dev)->sstat )
174 #define STS_EOF(dev)            GMT_EOF     ( (dev)->sstat )
175 #define STS_BOT(dev)            GMT_BOT     ( (dev)->sstat )
176 #define STS_EOT(dev)            GMT_EOT     ( (dev)->sstat )
177 #define STS_EOD(dev)            GMT_EOD     ( (dev)->sstat )
178 #define STS_WR_PROT(dev)        GMT_WR_PROT ( (dev)->sstat )
179 #define STS_ONLINE(dev)         GMT_ONLINE  ( (dev)->sstat )
180 #define STS_MOUNTED(dev)        ((dev)->fd >= 0 && !GMT_DR_OPEN( (dev)->sstat ))
181 #define STS_NOT_MOUNTED(dev)    (!STS_MOUNTED(dev))
182 #endif
183 
184 #define  AUTOLOAD_WAIT_FOR_TAPEMOUNT_INTERVAL_SECS  (5) /* (default) */
185 
186 /*-------------------------------------------------------------------*/
187 /* Structure definition for HET/AWS/OMA tape block headers           */
188 /*-------------------------------------------------------------------*/
189 /*
190  * The integer fields in the HET, AWSTAPE and OMATAPE headers are
191  * encoded in the Intel format (i.e. the bytes of the integer are held
192  * in reverse order).  For this reason the integers are defined as byte
193  * arrays, and the bytes are fetched individually in order to make
194  * the code portable across architectures which use either the Intel
195  * format or the S/370 format.
196  *
197  * Block length fields contain the length of the emulated tape block
198  * and do not include the length of the header.
199  *
200  * For the AWSTAPE and HET formats:
201  * - the first block has a previous block length of zero
202  * - a tapemark is indicated by a header with a block length of zero
203  *   and a flag byte of X'40'
204  *
205  * For the OMATAPE format:
206  * - the first block has a previous header offset of X'FFFFFFFF'
207  * - a tapemark is indicated by a header with a block length of
208  *   X'FFFFFFFF'
209  * - each block is followed by padding bytes if necessary to ensure
210  *   that the next header starts on a 16-byte boundary
211  *
212  */
213 typedef struct _AWSTAPE_BLKHDR
214 {  /*
215     * PROGRAMMING NOTE: note that for AWS tape files, the "current
216     * chunk size" comes FIRST and the "previous chunk size" comes
217     * second. This is the complete opposite from the way it is for
218     * Flex FakeTape. Also note that for AWS the size fields are in
219     * LITTLE endian binary whereas for Flex FakeTape they're a BIG
220     * endian ASCII hex-string.
221     */
222     HWORD   curblkl;                    /* Length of this block      */
223     HWORD   prvblkl;                    /* Length of previous block  */
224     BYTE    flags1;                     /* Flags byte 1 (see below)  */
225     BYTE    flags2;                     /* Flags byte 2              */
226 
227     /* Definitions for AWSTAPE_BLKHDR flags byte 1 */
228 #define  AWSTAPE_FLAG1_NEWREC     0x80  /* Start of new record       */
229 #define  AWSTAPE_FLAG1_TAPEMARK   0x40  /* Tape mark                 */
230 #define  AWSTAPE_FLAG1_ENDREC     0x20  /* End of record             */
231 }
232 AWSTAPE_BLKHDR;
233 
234 /*-------------------------------------------------------------------*/
235 /* Structure definition for OMA block header                         */
236 /*-------------------------------------------------------------------*/
237 typedef struct _OMATAPE_BLKHDR
238 {
239     FWORD   curblkl;                    /* Length of this block      */
240     FWORD   prvhdro;                    /* Offset of previous block
241                                            header from start of file */
242     FWORD   omaid;                      /* OMA identifier (contains
243                                            ASCII characters "@HDF")  */
244     FWORD   resv;                       /* Reserved                  */
245 }
246 OMATAPE_BLKHDR;
247 
248 /*-------------------------------------------------------------------*/
249 /* Structure definition for OMA tape descriptor array                */
250 /*-------------------------------------------------------------------*/
251 typedef struct _OMATAPE_DESC
252 {
253     int     fd;                         /* File Descriptor for file  */
254     char    filename[256];              /* Filename of data file     */
255     char    format;                     /* H=HEADERS,T=TEXT,F=FIXED,X=Tape Mark */
256     BYTE    resv;                       /* Reserved for alignment    */
257     U16     blklen;                     /* Fixed block length        */
258 }
259 OMATAPE_DESC;
260 
261 /*-------------------------------------------------------------------*/
262 /* Structure definition for Flex FakeTape block headers              */
263 /*-------------------------------------------------------------------*/
264 /*
265  * The character length fields in a Flex FakeTape header are in BIG
266  * endian ASCII hex. That is to say, when the length field is ASCII
267  * "0123" (i.e. 0x30, 0x31, 0x32, 0x33), the length of the block is
268  * decimal 291 bytes (0x0123 == 291).
269  *
270  * The two block length fields are followed by an XOR "check" field
271  * calculated as the XOR of the two preceding length fields and is
272  * used to verify the integrity of the header.
273  *
274  * The Flex FakeTape tape format does not support any flag fields
275  * in its header and thus does not support any type of compression.
276  */
277 typedef struct _FAKETAPE_BLKHDR
278 {  /*
279     * PROGRAMMING NOTE: note that for Flex FakeTapes, the "previous
280     * chunk size" comes FIRST, followed by the "current chunk size"
281     * second. This is the complete opposite from the way it is for
282     * AWS tape files. Also note that for Flex FakeTape the size fields
283     * are in BIG endian ASCII hex-string whereas for AWS tapes
284     * they're LITTLE endian binary.
285     */
286     char  sprvblkl[4];                  /* length of previous block  */
287     char  scurblkl[4];                  /* length of this block      */
288     char  sxorblkl[4];                  /* XOR both lengths together */
289 }
290 FAKETAPE_BLKHDR;
291 
292 /*-------------------------------------------------------------------*/
293 /* Tape Auto-Loader table entry                                      */
294 /*-------------------------------------------------------------------*/
295 struct TAPEAUTOLOADENTRY
296 {
297     char  *filename;
298     int    argc;
299     char **argv;
300 };
301 
302 /*-------------------------------------------------------------------*/
303 /* Tape AUTOMOUNT CCWS directory control                             */
304 /*-------------------------------------------------------------------*/
305 struct TAMDIR
306 {
307     TAMDIR    *next;            /* ptr to next entry or NULL         */
308     char      *dir;             /* resolved directory value          */
309     int        len;             /* strlen(dir)                       */
310     int        rej;             /* 1 == reject, 0 == accept          */
311 };
312 
313 /*-------------------------------------------------------------------*/
314 /* Generic media-handler-call parameters block                       */
315 /*-------------------------------------------------------------------*/
316 typedef struct _GENTMH_PARMS
317 {
318     int      action;        // action code  (i.e. "what to do")
319     DEVBLK*  dev;           // -> device block
320     BYTE*    unitstat;      // -> unit status
321     BYTE     code;          // CCW opcode
322     // TODO: define whatever additional arguments may be needed...
323 }
324 GENTMH_PARMS;
325 
326 /*-------------------------------------------------------------------*/
327 /* Generic media-handler-call action codes                           */
328 /*-------------------------------------------------------------------*/
329 #define  GENTMH_SCSI_ACTION_UPDATE_STATUS       (0)
330 //efine  GENTMH_AWS_ACTION_xxxxx...             (x)
331 //efine  GENTMH_HET_ACTION_xxxxx...             (x)
332 //efine  GENTMH_OMA_ACTION_xxxxx...             (x)
333 
334 /*-------------------------------------------------------------------*/
335 /* Tape media I/O function vector table layout                       */
336 /*-------------------------------------------------------------------*/
337 struct TAPEMEDIA_HANDLER
338 {
339     int  (*generic)    (GENTMH_PARMS*);                 // (generic call)
340     int  (*open)       (DEVBLK*,                        BYTE *unitstat, BYTE code);
341     void (*close)      (DEVBLK*);
342     int  (*read)       (DEVBLK*, BYTE *buf,             BYTE *unitstat, BYTE code);
343     int  (*write)      (DEVBLK*, BYTE *buf, U16 blklen, BYTE *unitstat, BYTE code);
344     int  (*rewind)     (DEVBLK*,                        BYTE *unitstat, BYTE code);
345     int  (*bsb)        (DEVBLK*,                        BYTE *unitstat, BYTE code);
346     int  (*fsb)        (DEVBLK*,                        BYTE *unitstat, BYTE code);
347     int  (*bsf)        (DEVBLK*,                        BYTE *unitstat, BYTE code);
348     int  (*fsf)        (DEVBLK*,                        BYTE *unitstat, BYTE code);
349     int  (*wtm)        (DEVBLK*,                        BYTE *unitstat, BYTE code);
350     int  (*sync)       (DEVBLK*,                        BYTE *unitstat, BYTE code);
351     int  (*dse)        (DEVBLK*,                        BYTE *unitstat, BYTE code);
352     int  (*erg)        (DEVBLK*,                        BYTE *unitstat, BYTE code);
353     int  (*tapeloaded) (DEVBLK*,                        BYTE *unitstat, BYTE code);
354     int  (*passedeot)  (DEVBLK*);
355 
356     /* readblkid o/p values are returned in BIG-ENDIAN guest format  */
357     int  (*readblkid)  (DEVBLK*, BYTE* logical, BYTE* physical);
358 
359     /* locateblk i/p value is passed in little-endian host format  */
360     int  (*locateblk)  (DEVBLK*, U32 blockid,           BYTE *unitstat, BYTE code);
361 };
362 
363 /*-------------------------------------------------------------------*/
364 /* Functions defined in TAPEDEV.C                                    */
365 /*-------------------------------------------------------------------*/
366 extern int   tapedev_init_handler   (DEVBLK *dev, int argc, char *argv[]);
367 extern int   tapedev_close_device   (DEVBLK *dev );
368 extern void  tapedev_query_device   (DEVBLK *dev, char **class, int buflen, char *buffer);
369 
370 extern void  autoload_init          (DEVBLK *dev, int ac,   char **av);
371 extern int   autoload_mount_first   (DEVBLK *dev);
372 extern int   autoload_mount_next    (DEVBLK *dev);
373 extern void  autoload_close         (DEVBLK *dev);
374 extern void  autoload_global_parms  (DEVBLK *dev, char *par);
375 extern void  autoload_clean_entry   (DEVBLK *dev, int ix);
376 extern void  autoload_tape_entry    (DEVBLK *dev, char *fn, char **strtokw);
377 extern int   autoload_mount_tape    (DEVBLK *dev, int alix);
378 
379 extern void* autoload_wait_for_tapemount_thread (void *db);
380 
381 extern int   gettapetype            (DEVBLK *dev, char **short_descr);
382 extern int   gettapetype_byname     (DEVBLK *dev);
383 extern int   gettapetype_bydata     (DEVBLK *dev);
384 
385 extern int   mountnewtape           (DEVBLK *dev, int argc, char **argv);
386 extern void  GetDisplayMsg          (DEVBLK *dev, char *msgbfr, size_t  lenbfr);
387 extern int   IsAtLoadPoint          (DEVBLK *dev);
388 extern void  ReqAutoMount           (DEVBLK *dev);
389 extern void  UpdateDisplay          (DEVBLK *dev);
390 extern int   return_false1          (DEVBLK *dev);
391 extern int   write_READONLY5        (DEVBLK *dev, BYTE *bfr, U16 blklen, BYTE *unitstat, BYTE code);
392 extern int   is_tapeloaded_filename (DEVBLK *dev,             BYTE *unitstat, BYTE code);
393 extern int   write_READONLY         (DEVBLK *dev,             BYTE *unitstat, BYTE code);
394 extern int   no_operation           (DEVBLK *dev,             BYTE *unitstat, BYTE code);
395 extern int   readblkid_virtual      (DEVBLK*, BYTE* logical,  BYTE* physical);
396 extern int   locateblk_virtual      (DEVBLK*, U32 blockid,    BYTE *unitstat, BYTE code);
397 extern int   generic_tmhcall        (GENTMH_PARMS*);
398 
399 /*-------------------------------------------------------------------*/
400 /* Functions (and data areas) defined in TAPECCWS.C                  */
401 /*-------------------------------------------------------------------*/
402 typedef void TapeSenseFunc( int, DEVBLK*, BYTE*, BYTE );    // (sense handling function)
403 
404 #define  TAPEDEVTYPELIST_ENTRYSIZE  (5)    // #of int's per 'TapeDevtypeList' table entry
405 
406 extern int             TapeDevtypeList[];
407 extern BYTE*           TapeCommandTable[];
408 extern TapeSenseFunc*  TapeSenseTable[];
409 //tern BYTE            TapeCommandsXXXX[256]...
410 extern BYTE            TapeImmedCommands[];
411 
412 extern int   TapeCommandIsValid     (BYTE code, U16 devtype, BYTE *rustat);
413 extern void  tapedev_execute_ccw    (DEVBLK *dev, BYTE code, BYTE flags,
414                                      BYTE chained, U16 count, BYTE prevcode, int ccwseq,
415                                      BYTE *iobuf, BYTE *more, BYTE *unitstat, U16 *residual);
416 extern void  load_display           (DEVBLK *dev, BYTE *buf, U16 count);
417 
418 extern void  build_senseX           (int ERCode, DEVBLK *dev, BYTE *unitstat, BYTE ccwcode);
419 extern void  build_sense_3410       (int ERCode, DEVBLK *dev, BYTE *unitstat, BYTE ccwcode);
420 extern void  build_sense_3420       (int ERCode, DEVBLK *dev, BYTE *unitstat, BYTE ccwcode);
421 extern void  build_sense_3410_3420  (int ERCode, DEVBLK *dev, BYTE *unitstat, BYTE ccwcode);
422 extern void  build_sense_3480_etal  (int ERCode, DEVBLK *dev, BYTE *unitstat, BYTE ccwcode);
423 extern void  build_sense_3490       (int ERCode, DEVBLK *dev, BYTE *unitstat, BYTE ccwcode);
424 extern void  build_sense_3590       (int ERCode, DEVBLK *dev, BYTE *unitstat, BYTE ccwcode);
425 extern void  build_sense_Streaming  (int ERCode, DEVBLK *dev, BYTE *unitstat, BYTE ccwcode);
426 
427 /*-------------------------------------------------------------------*/
428 /* Calculate I/O Residual                                            */
429 /*-------------------------------------------------------------------*/
430 #define RESIDUAL_CALC(_data_len)         \
431     len = (_data_len);                   \
432     num = (count < len) ? count : len;   \
433     *residual = count - num;             \
434     if (count < len) *more = 1
435 
436 /*-------------------------------------------------------------------*/
437 /* Assign a unique Message Id for this asynchronous I/O if needed    */
438 /*-------------------------------------------------------------------*/
439 #if defined(OPTION_SCSI_TAPE)
440   #define INCREMENT_MESSAGEID(_dev)   \
441     if ((_dev)->SIC_active)           \
442         (_dev)->msgid++
443 #else
444   #define INCREMENT_MESSAGEID(_dev)
445 #endif // defined(OPTION_SCSI_TAPE)
446 
447 /*-------------------------------------------------------------------*/
448 /* Functions defined in AWSTAPE.C                                    */
449 /*-------------------------------------------------------------------*/
450 extern int  open_awstape      (DEVBLK *dev, BYTE *unitstat, BYTE code);
451 extern void close_awstape     (DEVBLK *dev);
452 extern int  passedeot_awstape (DEVBLK *dev);
453 extern int  rewind_awstape    (DEVBLK *dev, BYTE *unitstat, BYTE code);
454 extern int  write_awsmark     (DEVBLK *dev, BYTE *unitstat, BYTE code);
455 extern int  sync_awstape      (DEVBLK *dev, BYTE *unitstat, BYTE code);
456 extern int  fsb_awstape       (DEVBLK *dev, BYTE *unitstat, BYTE code);
457 extern int  bsb_awstape       (DEVBLK *dev, BYTE *unitstat, BYTE code);
458 extern int  fsf_awstape       (DEVBLK *dev, BYTE *unitstat, BYTE code);
459 extern int  bsf_awstape       (DEVBLK *dev, BYTE *unitstat, BYTE code);
460 extern int  readhdr_awstape   (DEVBLK *dev, off_t blkpos, AWSTAPE_BLKHDR *buf,
461                                             BYTE *unitstat, BYTE code);
462 extern int  read_awstape      (DEVBLK *dev, BYTE *buf,
463                                             BYTE *unitstat, BYTE code);
464 extern int  write_awstape     (DEVBLK *dev, BYTE *buf, U16 blklen,
465                                             BYTE *unitstat, BYTE code);
466 
467 /*-------------------------------------------------------------------*/
468 /* Functions defined in FAKETAPE.C                                   */
469 /*-------------------------------------------------------------------*/
470 extern int  open_faketape      (DEVBLK *dev, BYTE *unitstat, BYTE code);
471 extern void close_faketape     (DEVBLK *dev);
472 extern int  passedeot_faketape (DEVBLK *dev);
473 extern int  rewind_faketape    (DEVBLK *dev, BYTE *unitstat, BYTE code);
474 extern int  write_fakemark     (DEVBLK *dev, BYTE *unitstat, BYTE code);
475 extern int  sync_faketape      (DEVBLK *dev, BYTE *unitstat, BYTE code);
476 extern int  fsb_faketape       (DEVBLK *dev, BYTE *unitstat, BYTE code);
477 extern int  bsb_faketape       (DEVBLK *dev, BYTE *unitstat, BYTE code);
478 extern int  fsf_faketape       (DEVBLK *dev, BYTE *unitstat, BYTE code);
479 extern int  bsf_faketape       (DEVBLK *dev, BYTE *unitstat, BYTE code);
480 extern int  readhdr_faketape   (DEVBLK *dev, off_t blkpos,
481                                              U16* pprvblkl, U16* pcurblkl,
482                                              BYTE *unitstat, BYTE code);
483 extern int  writehdr_faketape  (DEVBLK *dev, off_t blkpos,
484                                              U16   prvblkl, U16   curblkl,
485                                              BYTE *unitstat, BYTE code);
486 extern int  read_faketape      (DEVBLK *dev, BYTE *buf,
487                                              BYTE *unitstat, BYTE code);
488 extern int  write_faketape     (DEVBLK *dev, BYTE *buf, U16 blklen,
489                                              BYTE *unitstat, BYTE code);
490 
491 /*-------------------------------------------------------------------*/
492 /* Functions defined in HETTAPE.C                                    */
493 /*-------------------------------------------------------------------*/
494 extern int  open_het      (DEVBLK *dev, BYTE *unitstat, BYTE code);
495 extern void close_het     (DEVBLK *dev);
496 extern int  passedeot_het (DEVBLK *dev);
497 extern int  rewind_het    (DEVBLK *dev, BYTE *unitstat, BYTE code);
498 extern int  write_hetmark (DEVBLK *dev, BYTE *unitstat, BYTE code);
499 extern int  sync_het      (DEVBLK *dev, BYTE *unitstat, BYTE code);
500 extern int  fsb_het       (DEVBLK *dev, BYTE *unitstat, BYTE code);
501 extern int  bsb_het       (DEVBLK *dev, BYTE *unitstat, BYTE code);
502 extern int  fsf_het       (DEVBLK *dev, BYTE *unitstat, BYTE code);
503 extern int  bsf_het       (DEVBLK *dev, BYTE *unitstat, BYTE code);
504 extern int  read_het      (DEVBLK *dev, BYTE *buf,
505                                         BYTE *unitstat, BYTE code);
506 extern int  write_het     (DEVBLK *dev, BYTE *buf, U16 blklen,
507                                         BYTE *unitstat, BYTE code);
508 
509 /*-------------------------------------------------------------------*/
510 /* Functions defined in OMATAPE.C                                    */
511 /*-------------------------------------------------------------------*/
512 extern int  open_omatape       (DEVBLK *dev, BYTE *unitstat, BYTE code);
513 extern void close_omatape      (DEVBLK *dev);
514 extern void close_omatape2     (DEVBLK *dev);
515 extern int  rewind_omatape     (DEVBLK *dev, BYTE *unitstat, BYTE code);
516 extern int  fsb_omatape        (DEVBLK *dev, BYTE *unitstat, BYTE code);
517 extern int  bsb_omatape        (DEVBLK *dev, BYTE *unitstat, BYTE code);
518 extern int  fsf_omatape        (DEVBLK *dev, BYTE *unitstat, BYTE code);
519 extern int  bsf_omatape        (DEVBLK *dev, BYTE *unitstat, BYTE code);
520 
521 extern int  read_omadesc       (DEVBLK *dev);
522 extern int  fsb_omaheaders     (DEVBLK *dev, OMATAPE_DESC *omadesc,            BYTE *unitstat, BYTE code);
523 extern int  fsb_omafixed       (DEVBLK *dev, OMATAPE_DESC *omadesc,            BYTE *unitstat, BYTE code);
524 extern int  read_omaheaders    (DEVBLK *dev, OMATAPE_DESC *omadesc, BYTE *buf, BYTE *unitstat, BYTE code);
525 extern int  read_omafixed      (DEVBLK *dev, OMATAPE_DESC *omadesc, BYTE *buf, BYTE *unitstat, BYTE code);
526 extern int  read_omatext       (DEVBLK *dev, OMATAPE_DESC *omadesc, BYTE *buf, BYTE *unitstat, BYTE code);
527 extern int  read_omatape       (DEVBLK *dev,                        BYTE *buf, BYTE *unitstat, BYTE code);
528 extern int  readhdr_omaheaders (DEVBLK *dev, OMATAPE_DESC *omadesc,
529                                              long blkpos, S32 *pcurblkl,
530                                              S32 *pprvhdro, S32 *pnxthdro,     BYTE *unitstat, BYTE code);
531 
532 /*-------------------------------------------------------------------*/
533 /* Functions defined in SCSITAPE.C                                   */
534 /*-------------------------------------------------------------------*/
535 // (see SCSITAPE.H)
536 
537 /*
538 || Tape ERA, HRA and SENSE constants
539 || Note: For 3480/3490 tape drives HRA was an assumed function of the OS
540 ||       For 3590 (NTP) tape drives HRA is no longer assumed. The labels
541 ||       here are the 3480/3590 labels but the values are NTP values. See
542 ||       sense byte 2 for additional information.
543 */
544 /*-------------------------------------------------------------------*/
545 /* Host Recovery Action (HRA)    (these are the 3590 codes           */
546 /*-------------------------------------------------------------------*/
547 #define TAPE_HRA_PERMANENT_ERROR             0x00
548 #define TAPE_HRA_RETRY                       0x80
549 #define TAPE_HRA_DDR                         0x00       // Same as error for VT
550 #define TAPE_HRA_RESUME                      0x40
551 #define TAPE_HRA_OPERATOR_INTERVENTION       0xC0
552 
553 // Sense byte 0
554 
555 #define  TAPE_SNS0_CMDREJ     0x80          // Command Reject
556 #define  TAPE_SNS0_INTVREQ    0x40          // Intervention Required
557 #define  TAPE_SNS0_BUSCHK     0x20          // Bus-out Check
558 #define  TAPE_SNS0_EQUIPCHK   0x10          // Equipment Check
559 #define  TAPE_SNS0_DATACHK    0x08          // Data check
560 #define  TAPE_SNS0_OVERRUN    0x04          // Overrun
561 #define  TAPE_SNS0_DEFUNITCK  0x02          // Deferred Unit Check
562 #define  TAPE_SNS0_ASSIGNED   0x01          // Assigned Elsewhere
563 
564 // Sense byte 1
565 
566 #define  TAPE_SNS1_LOCFAIL    0x80          // Locate Failure
567 #define  TAPE_SNS1_ONLINE     0x40          // Drive Online to CU
568 #define  TAPE_SNS1_RSRVD      0x20          // Reserved
569 #define  TAPE_SNS1_RCDSEQ     0x10          // Record Sequence Error
570 #define  TAPE_SNS1_BOT        0x08          // Beginning of Tape
571 #define  TAPE_SNS1_WRTMODE    0x04          // Write Mode
572 #define  TAPE_SNS1_FILEPROT   0x02          // Write Protect
573 #define  TAPE_SNS1_NOTCAPBL   0x01          // Not Capable
574 
575 // Sense byte 2
576 /*
577 ||  NTP SENSE BYTE 2
578 ||  Log code is in byte 2(3-4), BRAC is in byte 2(0-1)
579 */
580 #define  TAPE_SNS2_NTP_BRAC_00_PERM_ERR     0x00      // BRAC 00 - PERM ERR
581 #define  TAPE_SNS2_NTP_BRAC_01_CONTINUE     0x40      // BRAC 01 - Continue ( RESUME )
582 #define  TAPE_SNS2_NTP_BRAC_10_REISSUE      0x80      // BRAC 10 - Reissue  ( RETRY  )
583 #define  TAPE_SNS2_NTP_BRAC_11_DEFER_REISS  0xC0      // BRAC 11 - Deferred Reissue ( I/R ? )
584 #define  TAPE_SNS2_NTP_LOG_CD0_NO_LOG       0x00
585 #define  TAPE_SNS2_NTP_LOG_CD1_TEMP_OBR     0x08
586 #define  TAPE_SNS2_NTP_LOG_CD2_PERM_OBR     0x10
587 #define  TAPE_SNS2_NTP_LOG_CD3_A3           0x18
588 
589 #define  TAPE_SNS2_REPORTING_CHAN_PATH      0xF0      // Interface in the first 4 bits
590 #define  TAPE_SNS2_REPORTING_CHAN_A         0x20      // Channel A Interface
591 #define  TAPE_SNS2_REPORTING_CHAN_B         0x40      // Channel B Interface
592 #define  TAPE_SNS2_REPORTING_CU             0x00      // Always 0 (ZERO) Bit 4
593 #define  TAPE_SNS2_ACL_ACTIVE               0x04      // AutoLoader in SYS MODE and has Cart
594 #define  TAPE_SNS2_SYNCMODE                 0x02      // Tape Synchronous Mode
595 #define  TAPE_SNS2_POSITION                 0x01      // Tape Positioning
596 
597 // Sense Byte 3
598 /*-------------------------------------------------------------------*/
599 /* Error Recovery Action (ERA) SENSE BYTE 3                          */
600 /*-------------------------------------------------------------------*/
601 
602 #define  TAPE_ERA_UNSOLICITED_SENSE           0x00
603 
604 #define  TAPE_ERA_DATA_STREAMING_NOT_OPER     0x21
605 #define  TAPE_ERA_PATH_EQUIPMENT_CHECK        0x22
606 #define  TAPE_ERA_READ_DATA_CHECK             0x23
607 #define  TAPE_ERA_LOAD_DISPLAY_CHECK          0x24
608 #define  TAPE_ERA_WRITE_DATA_CHECK            0x25
609 #define  TAPE_ERA_READ_OPPOSITE               0x26
610 #define  TAPE_ERA_COMMAND_REJECT              0x27
611 #define  TAPE_ERA_WRITE_ID_MARK_CHECK         0x28
612 #define  TAPE_ERA_FUNCTION_INCOMPATIBLE       0x29
613 #define  TAPE_ERA_UNSOL_ENVIRONMENTAL_DATA    0x2A
614 #define  TAPE_ERA_ENVIRONMENTAL_DATA_PRESENT  0x2B
615 #define  TAPE_ERA_PERMANENT_EQUIPMENT_CHECK   0x2C
616 #define  TAPE_ERA_DATA_SECURE_ERASE_FAILURE   0x2D
617 #define  TAPE_ERA_NOT_CAPABLE_BOT_ERROR       0x2E
618 
619 #define  TAPE_ERA_WRITE_PROTECTED             0x30
620 #define  TAPE_ERA_TAPE_VOID                   0x31
621 #define  TAPE_ERA_TENSION_LOST                0x32
622 #define  TAPE_ERA_LOAD_FAILURE                0x33
623 #define  TAPE_ERA_UNLOAD_FAILURE              0x34
624 #define  TAPE_ERA_MANUAL_UNLOAD               0x34
625 #define  TAPE_ERA_DRIVE_EQUIPMENT_CHECK       0x35
626 #define  TAPE_ERA_END_OF_DATA                 0x36
627 #define  TAPE_ERA_TAPE_LENGTH_ERROR           0x37
628 #define  TAPE_ERA_PHYSICAL_END_OF_TAPE        0x38
629 #define  TAPE_ERA_BACKWARD_AT_BOT             0x39
630 #define  TAPE_ERA_DRIVE_SWITCHED_NOT_READY    0x3A
631 #define  TAPE_ERA_DRIVE_RESET_BY_OPERATOR     0x3A
632 #define  TAPE_ERA_MANUAL_REWIND_OR_UNLOAD     0x3B
633 #define  TAPE_ERA_VOLUME_REMOVE_BY_OPERATOR   0x3B
634 #define  TAPE_ERA_VOLUME_MANUALLY_UNLOADED    0x3C
635 
636 #define  TAPE_ERA_OVERRUN                     0x40
637 #define  TAPE_ERA_DEVICE_DEFERRED_ACCESS      0x40
638 #define  TAPE_ERA_RECORD_SEQUENCE_ERROR       0x41
639 #define  TAPE_ERA_BLOCK_ID_SEQUENCE_ERROR     0x41
640 #define  TAPE_ERA_DEGRADED_MODE               0x42
641 #define  TAPE_ERA_DRIVE_NOT_READY             0x43
642 #define  TAPE_ERA_INTERVENTION_REQ            0x43
643 #define  TAPE_ERA_LOCATE_BLOCK_FAILED         0x44
644 #define  TAPE_ERA_DRIVE_ASSIGNED_ELSEWHERE    0x45
645 #define  TAPE_ERA_DRIVE_NOT_ONLINE            0x46
646 #define  TAPE_ERA_VOLUME_FENCED               0x47
647 #define  TAPE_ERA_UNSOL_INFORMATIONAL_DATA    0x48
648 #define  TAPE_ERA_CONTROLLING_COMP_RETRY_REQ  0x48
649 #define  TAPE_ERA_BUS_OUT_CHECK               0x49
650 #define  TAPE_ERA_BUS_OUT_PARITY              0x49
651 #define  TAPE_ERA_CU_ERP_FAILURE              0x4A
652 #define  TAPE_ERA_CU_AND_DRIVE_INCOMPATIBLE   0x4B
653 #define  TAPE_ERA_RECOVERED_CHECKONE_FAILURE  0x4C
654 #define  TAPE_ERA_RESETTING_EVENT             0x4D
655 #define  TAPE_ERA_MAX_BLOCKSIZE_EXCEEDED      0x4E
656 #define  TAPE_ERA_DEVICE_CONTROLLER_INCOMP    0x4F
657 
658 #define  TAPE_ERA_READ_BUFFERED_LOG           0x50
659 #define  TAPE_ERA_BUFFERED_LOG_OVERFLOW       0x50
660 #define  TAPE_ERA_BUFFERED_LOG_END_OF_VOLUME  0x51
661 #define  TAPE_ERA_END_OF_VOLUME_PROCESSING    0x51
662 #define  TAPE_ERA_END_OF_VOLUME_COMPLETE      0x52
663 #define  TAPE_ERA_GLOBAL_COMMAND_INTERCEPT    0x53
664 #define  TAPE_ERA_TEMP_CHNL_INTERFACE_ERROR   0x54
665 #define  TAPE_ERA_PERM_CHNL_INTERFACE_ERROR   0x55
666 #define  TAPE_ERA_CHNL_PROTOCOL_ERROR         0x56
667 #define  TAPE_ERA_GLOBAL_STATUS_INTERCEPT     0x57
668 #define  TAPE_ERA_ATTENTION_INTERCEPT         0x57
669 #define  TAPE_ERA_TAPE_LENGTH_INCOMPAT        0x5A
670 #define  TAPE_ERA_FORMAT_3480_XF_INCOMPAT     0x5B
671 #define  TAPE_ERA_FORMAT_3480_2_XF_INCOMPAT   0x5C
672 #define  TAPE_ERA_TAPE_LENGTH_VIOLATION       0x5D
673 #define  TAPE_ERA_COMPACT_ALGORITHM_INCOMPAT  0x5E
674 
675 /*
676 || 3490/3590/NTP IN AN AUTOMATED LIBRARY SYSTEM
677 */
678 #define  TAPE_ERA_LIB_ATT_FAC_EQ_CHK          0x60
679 #define  TAPE_ERA_LIB_MGR_OFFLINE_TO_SUBSYS   0x62
680 #define  TAPE_ERA_LIB_MGR_CU_INCOMPAT         0x63
681 #define  TAPE_ERA_LIB_VOLSER_IN_USE           0x64
682 #define  TAPE_ERA_LIB_VOLUME_RESERVED         0x65
683 #define  TAPE_ERA_LIB_VOLSER_NOT_IN_LIB       0x66
684 #define  TAPE_ERA_LIB_CATEGORY_EMPTY          0x67
685 #define  TAPE_ERA_LIB_ORDER_SEQ_CHK           0x68
686 #define  TAPE_ERA_LIB_OUTPUT_STATIONS_FULL    0x69
687 #define  TAPE_ERA_LIB_VOLUME_MISPLACED        0x6B
688 #define  TAPE_ERA_LIB_MISPLACED_VOLUME_FOUND  0x6C
689 #define  TAPE_ERA_LIB_DRIVE_NOT_UNLOADED      0x6D
690 #define  TAPE_ERA_LIB_INACCESS_VOLUME_REST    0x6E
691 #define  TAPE_ERA_LIB_OPTICS_FAILURE          0x6F
692 #define  TAPE_ERA_LIB_MGR_EQ_CHK              0x70
693 #define  TAPE_ERA_LIB_EQ_CHK                  0x71
694 #define  TAPE_ERA_LIB_NOT_CAP_MANUAL_MODE     0x72
695 #define  TAPE_ERA_LIB_INTERVENTION_REQ        0x73
696 #define  TAPE_ERA_LIB_INFORMATION_DATA        0x74
697 #define  TAPE_ERA_LIB_VOLSER_INACCESS         0x75
698 #define  TAPE_ERA_LIB_ALL_CELLS_FULL          0x76
699 #define  TAPE_ERA_LIB_DUP_VOLSER_EJECTED      0x77
700 #define  TAPE_ERA_LIB_DUP_VOLSER_LEFT_IN_STAT 0x78
701 #define  TAPE_ERA_LIB_UNREADABLE_INVLD_VOLSER 0x79
702 #define  TAPE_ERA_LIB_READ_STATISTICS         0x7A
703 #define  TAPE_ERA_LIB_VOLUME_MAN_EJECTED      0x7B
704 #define  TAPE_ERA_LIB_OUT_OF_CLEANER_VOLUMES  0x7C
705 #define  TAPE_ERA_LIB_VOLUME_EXPORTED         0x7D
706 #define  TAPE_ERA_LIB_CATEGORY_IN_USE         0x7F
707 
708 #define  TAPE_ERA_LIB_UNEXPECTED_VOLUME_EJECT 0x80
709 #define  TAPE_ERA_LIB_IO_STATION_DOOR_OPEN    0x81
710 #define  TAPE_ERA_LIB_MGR_PROG_EXCEPTION      0x82
711 #define  TAPE_ERA_LIB_DRIVE_EXCEPTION         0x83
712 #define  TAPE_ERA_LIB_DRIVE_FAILURE           0x84
713 #define  TAPE_ERA_LIB_SMOKE_DETECTION_ALERT   0x85
714 #define  TAPE_ERA_LIB_ALL_CATEGORYS_RESERVED  0x86
715 #define  TAPE_ERA_LIB_DUP_VOLSER_ADDITION     0x87
716 #define  TAPE_ERA_LIB_DAMAGE_CART_EJECTED     0x88
717 
718 #define  TAPE_ERA_LIB_VOLUME_INACCESSIBLE     0x91
719 
720 /*
721 || SENSE BYTE 3 for NTP (3590) TAPES
722 */
723 
724 #define  TAPE_ERA_RAC_USE_BRAC                0xC0
725 #define  TAPE_ERA_RAC_FENCE_DEVICE            0xC1
726 #define  TAPE_ERA_RAC_FENCH_DEVICE_PATH       0xC2
727 #define  TAPE_ERA_RAC_LONG_BUSY               0xC6
728 #define  TAPE_ERA_RAC_READ_ALT                0xD2
729 
730 // Sense byte 4
731 /*
732 ||  SENSE BYTE 4 FOR TAPES
733 */
734 #define  TAPE_SNS4_3420_TAPE_INDICATE         0x20      // EOT FOUND
735 #define  TAPE_SNS4_3480_FORMAT_MODE           0xC0
736 #define  TAPE_SNS4_3480_FORMAT_MODE_XF        0x80
737 #define  TAPE_SNS4_3490_FORMAT_MODE           0x00
738 #define  TAPE_SNS4_3490_FORMAT_MODE_RSVD      0x40
739 #define  TAPE_SNS4_3490_FORMAT_MODE_IDRC      0x80
740 #define  TAPE_SNS4_3490_FORMAT_MODE_SPECIAL   0xC0
741 
742 #define  TAPE_SNS4_3480_HO_CHAN_LOG_BLK_ID    0x3F      // 22-bits for BLK ID
743 
744 // Sense byte 5
745 /*
746 ||  SENSE BYTE 5 FOR TAPES
747 */
748 #define  TAPE_SNS5_3480_MO_CHAN_LOG_BLK_ID    0xFF
749 
750 // Sense byte 6
751 /*
752 ||  SENSE BYTE 6 FOR TAPES
753 */
754 #define  TAPE_SNS6_3480_LO_CHAN_LOG_BLK_ID    0xFF
755 
756 /*
757 || SENSE BYTES 4-5 FOR NTP BYTE 4 is Reason Code(RC) and 5 is Reason Qualifer Code(RQC)
758 */
759 #define  TAPE_SNS4_5_NTP_RC_UA_RQC_DEV_LOG      0x1110      // UNIT ATTENTION/Device Log
760 
761 #define  TAPE_SNS4_5_NTP_RC_LA_RQC_DEV_CLEANED  0x1211      // LIBRARY ATTENTION/Device CLEANED
762 #define  TAPE_SNS4_5_NTP_RC_LA_RQC_DEV_QUIESCED 0x1212      // LIBRARY ATTENTION/Device QUIESCE
763 #define  TAPE_SNS4_5_NTP_RC_LA_RQC_DEV_RESUMED  0x1213      // LIBRARY ATTENTION/Device RESUMED
764 
765 #define  TAPE_SNS4_5_NTP_RC_CMD_REJ             0x2000      // COMMAND REJECT
766 
767 #define  TAPE_SNS4_5_NTP_RC_PE_RQC_GBL_CMD      0x2230      // PROTECTION EXCEPTION/Global Command
768 #define  TAPE_SNS4_5_NTP_RC_PE_RQC_GBL_STATUS   0x2231      // PROTECTION EXCEPTION/Global Status
769 
770 #define  TAPE_SNS4_5_NTP_RC_BE_RQC_EOV          0x3012      // BOUNDARY EXCEPTION/End of Volume
771 
772 #define  TAPE_SNS4_5_NTP_RC_DC_RQC_NO_FMT_BOV   0x5050      // DATA CHECK/No Formatting at BOV
773 #define  TAPE_SNS4_5_NTP_RC_DC_RQC_NO_FMT       0x5051      // DATA CHECK/No Formatting Past BOV
774 
775 #define  TAPE_SNS4_5_NTP_RC_OE_RQC_MED_NOT_LD   0x4010      // OPERATIONAL EXCEPTION/Medium Not Loaded
776 #define  TAPE_SNS4_5_NTP_RC_OE_RQC_DRV_NOT_RDY  0x4011      // OPERATIONAL EXCEPTION/Drive Not Ready
777 #define  TAPE_SNS4_5_NTP_RC_OE_RQC_DEV_LONG_BSY 0x4012      // OPERATIONAL EXCEPTION/Device long busy
778 #define  TAPE_SNS4_5_NTP_RC_OE_RQC_LDR_IR       0x4020      // OPERATIONAL EXCEPTION/Loader Interv Req'd
779 
780 // Sense byte 7
781 /*
782 ||  SENSE BYTE 7 FOR TAPES
783 */
784 #define  TAPE_SNS7_TAPE_SECURITY_ERASE_CMD    0x08
785 #define  TAPE_SNS7_FMT_20_3480                0x20 // DRIVE AND CU ERROR INFORMATION
786 #define  TAPE_SNS7_FMT_21_3480_READ_BUF_LOG   0x21 // BUFFERED LOG DATA WHEN NO IDRC is installed
787 #define  TAPE_SNS7_FMT_30_3480_READ_BUF_LOG   0x30 // BUFFERED LOG DATA WHEN IDRC is installed
788 #define  TAPE_SNS7_FMT_22_3480_EOV_STATS      0x22
789 #define  TAPE_SNS7_FMT_23_ALT                 0x23
790 #define  TAPE_SNS7_FMT_50_NTP                 0x50
791 #define  TAPE_SNS7_FMT_51_NTP                 0x51
792 #define  TAPE_SNS7_FMT_70_3490                0x70
793 #define  TAPE_SNS7_FMT_71_3490                0x71
794 
795 #endif // __TAPEDEV_H__
796