home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / diskutil / tapebios / programr.doc < prev    next >
Encoding:
Text File  |  1993-08-06  |  41.9 KB  |  999 lines

  1. Programmer's Manual for access to the TapeBIOS software driver Version 1.5
  2. ==========================================================================
  3.  
  4.     TAPEBIOS.TOS is a program that provides the low-level BIOS routines
  5. to access a SCSI tape drive connected the the Atari ST's DMA bus and also
  6. the Atari TT's DMA bus(not the SCSI bus). The low-level routines are 
  7. documented in this section and all defines are provided for the GNU 'C'
  8. compiler through tapebind.h and tapebind.cpp.
  9.     Any calls to the tape BIOS need to be made through the trap #10
  10. vector with command $ACE, if this is not met then the command is then
  11. passed to the next vector in the XBRA chain, usually displaying a full line
  12. of the familiar bombs as nothing uses trap #10 as standard in the Atari
  13. Operating System.
  14.  
  15.     Ah yes, When TAPEBIOS.TOS installs itself, it hooks itself into the OS
  16. with the XBRA ID of 'TAPE' into the trap #10 chain, and also installs itself
  17. into the COOKIE JAR, again with the ID of 'TAPE' with the vector containing
  18. the version number of the TapeBIOS software. The driver remains resident after
  19. loading with approximately 2KB taken from the system.
  20.  
  21.  
  22. The Commands
  23. ============
  24.  
  25.     Most commands documented below comply to the standard SCSI command
  26. set, although some commands are vendor specific and need to noted if any
  27. of these commands are going to be used over a variety of vendor specific
  28. tape drives.  
  29.  
  30. Definitions taken from TAPEBIND.H
  31. ---------------------------------
  32.  
  33. /* DEFINITIONS FOR TAPE I/O FUNCTIONS */
  34.  
  35. #define Tfunc    0x0ACE    /* BIOS Call for Tape function */
  36.  
  37. #define Ready    0    /* Tape Ready */
  38. #define Read    1    /* Tape Read */
  39. #define Write    2    /* Tape Write */
  40. #define Rewind    3    /* Tape Rewind */
  41. #define Load    4    /* Tape Load */
  42. #define Unload    5    /* Tape Unload */
  43. #define WrtFM    6    /* Write FileMark */
  44. #define ReqSen    7    /* Request Sense */
  45. #define ModSel    8    /* Mode Select */
  46. #define ModSen    9    /* Mode Sense */
  47. #define Space    10    /* Tape Space */
  48. #define Erase    11    /* Tape Erase */
  49. #define Inquire 12    /* Tape Inquiry */
  50.  
  51. #define Tready()    trap_10_wwll(Tfunc, Ready, 0L, 0L)
  52. #define Tread(a, b)    trap_10_wwll(Tfunc, Read, a, b)
  53. #define Twrite(a, b)    trap_10_wwll(Tfunc, Write, a, b)
  54. #define Trewind()    trap_10_wwll(Tfunc, Rewind, 0L, 0L)
  55. #define Tload(a)    trap_10_wwll(Tfunc, Load, 0L, a)
  56. #define Tunload(a)    trap_10_wwll(Tfunc, Unload, 0L, a)
  57. #define Tfmark(a)    trap_10_wwll(Tfunc, WrtFM, 0L, a)
  58. #define Trsense(a, b)    trap_10_wwll(Tfunc, ReqSen, a, b)
  59. #define Tmselect(a, b)    trap_10_wwll(Tfunc, ModSel, a, b)
  60. #define Tmsense(a, b)    trap_10_wwll(Tfunc, ModSen, a, b)
  61. #define Tspace(a)    trap_10_wwll(Tfunc, Space, 0L, a)
  62. #define Terase()    trap_10_wwll(Tfunc, Erase, 0L, 0L)
  63. #define Tinquir(a, b)    trap_10_wwll(Tfunc, Inquire, a, b)
  64.  
  65. NOTE: When using any of the above commands which support the fourth parameter
  66. or Number of Blocks, as it is commonly known, DO NOT use a value greater than
  67. 65535 unless you know exactly what you are doing. If this value is increased
  68. over this limit then the timeout code will fail within the driver. If you
  69. need to have more than 65535 blocks for your program to work then split the
  70. command over two new commands.
  71.  
  72. For example, in 'C'.
  73.  
  74.         status = Tspace(80000L);  - This will fail.
  75.  
  76. Use this instead.
  77.  
  78.         status = Tspace(40000L);  }  This will
  79.         status = Tspace(40000L);  }  work fine.
  80.  
  81. If you don't like the above approach the 'swait:' timeout value can be increased
  82. if necessary, although this will lead to longer delays when something wrong
  83. occurs. I don't advise increasing the 'swait:' value and suggest you do use
  84. the above approach.
  85.  
  86.  
  87. Status Codes
  88. ------------
  89.  
  90.     A single byte of status information is returned to the initiator
  91. after the command is completed. The status code informs the initiator whether
  92. the command was executed, and whether errors occured in execution.
  93.  
  94.     The status is not sent if the command is reset or aborted by a message
  95. passed from the initiator.
  96.  
  97.     Status byte Code Values:
  98.  
  99.         HEX        Status represented
  100.         ---        ------------------
  101.  
  102.         00        GOOD
  103.         02        CHECK CONDITION
  104.         08        BUSY
  105.         10        INTERMEDIATE/GOOD
  106.         18        RESERVATION CONFLICT
  107.  
  108.  
  109. GOOD: This status indicates that the TAPE CONTROLLER has successfully 
  110. completed the command.
  111.  
  112. CHECK CONDITION: This status is set when any error, or abnormal condition
  113. that causes sense data to be set occurs. The REQUEST SENSE command should
  114. be used to establish the precise nature of the condition.
  115.  
  116. BUSY: This status is returned to the initiator when the TAPE CONTROLLER
  117. is already processing a command, and cannot accept the command supplied.
  118.  
  119. INTERMEDIATE: This status is identical to the GOOD status except that it is
  120. sent in response to a Linked command. If this status is sent the TAPE
  121. CONTROLLER will send a LINK COMPLETE message (with or without FLAG) and
  122. then request the next command without first disconnecting. If a Linked 
  123. command does not end with an INTERMEDIATE status, the linked chain is broken.
  124.  
  125. RESERVATION CONFLICT: This status indicates that the TAPE CONTROLLER has been
  126. reserved for another initiator, and cannot therefore accept the command.
  127.  
  128.  
  129. Test Unit Ready
  130. ---------------
  131.  
  132.     Assembler:    tapebios(0xACE, Ready, 0L, 0L)
  133.  
  134.     'C'     :    Tready();
  135.  
  136.     The Test Unit Ready command provides a means to check if the Tape
  137. drive is ready. This is not a request for self test.
  138.  
  139.     If the Drive is ready, the command is terminated with GOOD status.
  140.  
  141.  
  142. Read
  143. ----
  144.  
  145.     Assembler:    tapebios(0xACE, Read, (long)(BUFADR), (long)(blocks))
  146.  
  147.     'C'     :    Tread((long)(BUFADR), (long)(blocks));
  148.  
  149.     The Read command transfers one or more blocks to the initiator
  150. beginning with the next block on the tape. The Fixed bit specifies both the
  151. meaning of the transfer length field and whether the fixed-length or variable-
  152. length block(s) are to be transferred. The TAPE CONTROLLER is operating in
  153. Variable Block Mode if the Block Length Bytes in the Mode Select Command are
  154. set to zero, otherwise the TAPE CONTROLLER is in Fixed mode. The Fixed bit
  155. must match the current transfer mode of the TAPE CONTROLLER. If the Fixed
  156. Bit does no match the current mode the TAPE CONTROLLER will reject the command
  157. by returning CHECK CONDITION status and by setting the Sense Key to ILLEGAL
  158. REQUEST.
  159.  
  160. Variable Mode Operation.
  161.     If the Fixed bit is zero, a single block is transferred, with the
  162. Transfer Length specifying the maximum number of bytes the initiator has 
  163. allocated for the returned data. This form of the Read command is valid
  164. only when the TAPE CONTROLLER is in the variable block mode.
  165.  
  166. Several possibilities exist:-
  167.     
  168.     - The data block read from the tape is exactly the same length as the
  169. transfer length. All the data in the block is transferred and the command
  170. completes with a GOOD status.
  171.  
  172.     - The data block read from tape is shorter than the transfer length.
  173. All the data in the block is transferred and the command completes with CHECK
  174. CONDITION status. The ILI and VALID bits are set in the sense information.
  175. The information bytes will be set to the difference between the Transfer 
  176. Length and the data block length.
  177.  
  178.     - The data block read from tape is longer than the transfer length. 
  179. The Transfer Length value is used to determine how many bytes should be 
  180. transferred to the initiator, the remaining bytes being discarded. The command
  181. completes with a CHECK CONDITION status. The ILI and VALID bits are set in
  182. the sense information. The Information bytes will be set to the difference
  183. between the Transfer Length and the data block length. This will be a 2's
  184. complement negative value.
  185.  
  186.     - The data block read from tape is longer than the available buffer
  187. within the TAPE CONTROLLER. The Transfer Length value is used to determine
  188. how many bytes should be transferred to the initiator, the remaining bytes
  189. being discarded. The command completes with CHECK CONDITION status. Th ILI
  190. bit will be set in the sense information, the information bytes will be set
  191. to zero.
  192.  
  193.  
  194. Fixed Mode Operation.
  195.     If the Fixed bit is one, the Transfer Length specifies the number of
  196. blocks to be transferred to the initiator. This form of the Read Command is
  197. valid only if the TAPE CONTROLLER is currently operating in Fixed Bit mode.
  198. The Current Block Length is the Block Length defined in the Mode Select
  199. command.
  200.  
  201.     A successful Read Command with the Fixed Bit set will transfer the
  202. number of blocks specified by the Transfer Length bytes to the initiator.
  203. Each block will be the same length as that specified by the MODE SET command.
  204. Upon termination of the Read Command, the tape will be positioned after the
  205. last block transferred (EOT side).
  206.  
  207.     If the Fixed bit is one and if a block is read which is larger or 
  208. smaller than the Current Block Length, CHECK CONDITION status is returned
  209. to the initiator. The ILI bit and the Valid bit in Extended Sense will be
  210. set to one. The Information Bytes will be set to the difference (residue)
  211. between the requested Transfer Length and the actual number of blocks read
  212. (not including the incorrect length block). Upon termination, the tape will
  213. be positioned after the incorrect length block (EOT side).
  214.  
  215. Filemark Detection.
  216.     If the TAPE CONTROLLER reads a filemark during a Read Command, it will
  217. send a CHECK CONDITION status to the initiator and will set the Filemark bit
  218. in the Extended Sense. Upon termination, the tape will be positioned after 
  219. the filemark (EOT side). If the Fixed bit is one, the TAPE CONTROLLER will set
  220. the Valid bit to one and the Information Bytes will be set to the difference
  221. (residue) between the requested Transfer Length and the actual number of blocks
  222. read (not including the filemark).
  223.  
  224. End of Tape Detection.
  225.     If a Logical Unit encounters the EOT marker during a Read command, the
  226. TAPE CONTROLLER returns a CHECK CONDITION status to the initiator and sets
  227. the End of Medium (EOM) bit to one in the Sense bytes. If the Fixed bit is one,
  228. the TAPE CONTROLLER sets the Valid bit to one and the Information Bytes to
  229. the difference (residue) between the requested Transfer Length and the actual
  230. number of blocks successfully read. The tape will be positioned after the last
  231. block transferred.
  232.     It is possible to read data after the EOT marker, but in this case all
  233. transfers will terminate after a single block with the EOM bit set as above.
  234. Great care should be taken when commanding the TAPE CONTROLLER to read past
  235. EOT since it may then be possible to run the tape off the supply reel. In an
  236. attempt to avoid this situation the TAPE CONTROLLER always selects slow speed
  237. (where available) during post-EOT reads, and "no-data" detection occurs sooner
  238. than normal.
  239.     
  240.     Note that the TAPE CONTROLLER maintains a look-ahead buffer, which may
  241. contain upto 64 blocks, therefore the tape will not normally move for each
  242. block transferred to the initiator.
  243.  
  244.     When the Transfer Length is zero, no data will be transferred and the
  245. tape position on the drive will not be changed. This condition is not 
  246. considered as an error.
  247.  
  248. Write
  249. -----
  250.  
  251.     Assembler:    tapebios(0xACE, Write, (long)(BUFADR), (long)(blocks))
  252.  
  253.     'C'     :    Twrite((long)(BUFADR), (long)(blocks));
  254.  
  255.     The Write command transfers one or more blocks from the initiator to
  256. the current position on the Logical Unit. The Fixed bit specified both the 
  257. meaning of the Transfer Length field and whether fixed-length or variable-
  258. length block(s) are to be transferred. The TAPE CONTROLLER is operating in
  259. Variable Block Mode if the Block Length Bytes in the Mode Select Command are
  260. set to zero, otherwise the TAPE CONTROLLER is in Fixed Mode. The Fixed bit
  261. must match the current transfer mode of the TAPE CONTROLLER. If the Fixed bit
  262. does not match the current mode the TAPE CONTROLLER will reject the command
  263. by returning CHECK CONDITION status and by setting the Sense Key to ILLEGAL
  264. REQUEST.
  265.  
  266. Variable Mode.
  267.     If the Fixed bit is zero, a single block will be transferred from the
  268. initiator and will be written to the tape beginning at the current tape
  269. position. The Transfer Length specifies the length of the block to be written
  270. (in bytes). The requested block length must be within the Minimum and Maximum
  271. Block Length range. If this condition is not met, a CHECK CONDITION status is
  272. returned with the Sense Key set to ILLEGAL REQUEST and no data is written. Upon
  273. successful termination, the tape is positioned after the block written by this
  274. command (End-of-Tape side).
  275.  
  276. Fixed Mode.
  277.     If the Fixed bit is one, the Transfer Length field specifies the number
  278. of block(s) to be transferred to the tape beginning at the current tape
  279. position. This form of the Write command is valid only if the TAPE CONTROLLER
  280. is currently operating in Fixed Block Mode (see the Read command description).
  281. Upon termination, the tape will be positioned after the block(s) written by 
  282. this command (End-of-Tape side).
  283.  
  284. End of Tape Detection.
  285.     If the early warning End-of-Tape marker is encountered while writing,
  286. an attempt to finish writing any buffered data is made (unless the PEOT bit is
  287. set - see MODE SELECT command). The command will terminate with CHECK CONDITION
  288. status and the EOM bit in Extended Sense will be set to one. If the Fixed bit 
  289. is one and the TAPE CONTROLLER is not buffered (Buffered Mode of the Mode Sense
  290. command is zero), then the valid bit in Extended Sense will be set to one and
  291. the Information Bytes will be set to the difference (residue) between the
  292. requested Transfer Length and the actual number of blocks written to the tape.
  293. If the Fixed bit is one and the TAPE CONTROLLER is buffered (Buffered Mode of
  294. the Mode Sense command is one), then the valid bit will be set to one and the
  295. Information Bytes will be set to the total number of blocks not written (the
  296. number of blocks not transferred from the initiator plus the number of blocks
  297. remaining in the Target's buffer). Note that in this case it is possible for
  298. the value in the Information Bytes to exceed the Transfer Length.
  299.  
  300.     
  301.     Note that the TAPE CONTROLLER has a large buffer area, which is capable
  302. of holding up to 64 blocks. Therefore in buffered mode the tape position may
  303. not change with each write command. The TAPE CONTROLLER will write all data
  304. contained in the buffer on receipt of a write filemark, space, or rewind
  305. command.
  306.  
  307.     When the Transfer Length is zero, no data will be transferred and the
  308. current tape position on the Tape Drive will not change. This condition is not
  309. considered an error.
  310.  
  311.  
  312. Rewind
  313. ------
  314.  
  315.     Assembler:    tapebios(0xACE, Rewind, 0L, 0L)
  316.  
  317.     'C'     :    Trewind();
  318.  
  319.     The Rewind command requests that the Target rewind the Logical
  320. Unit to the Beginning-of-Medium or Load-Point.
  321.  
  322.     The immediate bit, If set, indicates that the operation will complete
  323. by returning the status byte as soon as the rewind is started. The immed bit,
  324. If zero, indicates that the completion status will be returned only after the
  325. rewind is completed.
  326.  
  327.     If a Rewind command is issued to the TAPE CONTROLLER when the tape is
  328. already at Beginning-Of-Tape, a Check Status will be returned, and sense
  329. information will have the EOM bit set.
  330.  
  331.  
  332. Load Tape
  333. ---------
  334.  
  335.     Assembler:    tapebios(0xACE, Load, 0L, (long)(retension))
  336.  
  337.     'C'     :    Tload((long)(retension));
  338.  
  339.     The Load bit, if one, indicates the load function. The TAPE CONTROLLER
  340. checks that the drive has been OFF Line and is now On Line and the tape is 
  341. positioned at the BOT marker. If this is the case the TAPE CONTROLLER assumes
  342. that the operator has placed the correct tape in the drive, and returns a
  343. GOOD STATUS. If the Drive has not been through the OFF Line - ON Line cycle
  344. since the last tape movementm, or the tape is not at BOT, then the tape is
  345. unloaded to force operator intervention, and a CHECK CONDITION status is
  346. returned with the Sense Key set to Not Ready. Note that the TAPE CONTROLLER
  347. requires the operator to perform the actual tape load sequence.
  348.     
  349. Unload Tape
  350. -----------
  351.  
  352.     Assembler:    tapebios(0xACE, Unload, 0L, (long)(retension))
  353.  
  354.     'C'     :    Tunload((long)(retension));
  355.  
  356.     The Load bit, if zero, indicates the unload function, and requests
  357. that the tape be unloaded from the drive. The drive is set OFF Line to allow
  358. an operator to remove the tape. The Not Ready Sense Key is set.
  359.  
  360.  
  361.  
  362. Write File Mark
  363. ---------------
  364.  
  365.     Assembler:    tapebios(0xACE, WrtFM, 0L, (long)(marks))
  366.  
  367.     'C'     :    Tfmark((long)(marks));
  368.  
  369.     The Write Filemarks command causes the specified Number of Filemarks
  370. to be written beginning at the current tape position. A zero in this field
  371. indicates that no filemarks are to be written.
  372.  
  373.     This command is also used to force any buffered data (see Buffered Mode
  374. in the Mode Sense command) to be written. This command will not return GOOD
  375. STATUS unless all buffered data blocks and the filemarks (if any) are correctly
  376. written on the medium.
  377.  
  378.     If the End of Tape marker is encountered while writing, an attempt to
  379. finish writing any buffered data is made. The command will terminate with CHECK
  380. CONDITION status and with the EOM bit set in the Extended Sense set to one. If
  381. any filemarks remain to be written, then the Sense Key will be set to VOLUME
  382. OVERFLOW. If the TAPE CONTROLLER is not buffered (Buffered Mode of the Mode 
  383. Sense command is zero), then the valid bit in Extended Sense will be set to one
  384. and the Information Bytes will be set to the number of unwritten filemarks. If
  385. the TAPE CONTROLLER is buffered (Buffered Mode of the Mode Sense command is
  386. one), then the valid bit will be set to one and the Information Bytes will be
  387. set to the total number of blocks not written i.e. the number of unwritten
  388. filemarks plus the number of blocks remaining in the TAPE CONTROLLER's buffer.
  389. Note that in this case, it is possible for the value in the Information Bytes
  390. to exceed the Transfer Length.
  391.  
  392.     If the Str bit in byte 5 of the command is set to one, the TAPE
  393. CONTROLLER will return a GOOD STATUS byte immediately after issuing the last
  394. write filemark command to the tape. This can be used to help maintain tape
  395. streaming over multiple files.
  396.  
  397.  
  398. Request Sense
  399. -------------
  400.  
  401.     Assembler:    tapebios(0xACE, Reqsen, *(long)(buffer), 
  402.                     (long)(bytecount))
  403.  
  404.     'C'     :    Trsense(*(long)(buffer), (long)(bytecount));
  405. *
  406. *    bios(0xACE, RSENSE, *(long)(buffer), (long)(bytecount));
  407. *        Supply buffer address pointer
  408. *        and bytecount of sense data (11)
  409.  
  410.     The Request Sense command requests that the TAPE CONTROLLER transfer
  411. Sense Data to the initiator.
  412.  
  413.     The Sense Data will be valid for a CHECK CONDITION status returned for
  414. the last command issued by the initiator. This Sense Data will be preserved
  415. by the TAPE CONTROLLER for the initiator until retrieved by the Request Sense
  416. command or until receipt of any other command from the initiator for the same
  417. Logical Unit.
  418.  
  419.     The Allocation Length specifies the number of bytes that the initiator
  420. has allocated for the returned Sense Data. An Allocation Length of zero 
  421. Indicates that four bytes of Sense Data will be transferred. Any other value
  422. indicates the maximum number of bytes that will be transferred. The TAPE
  423. CONTROLLER will terminate the DATA IN phase when allocation length bytes have
  424. been transferred or when all available Sense Data has been transferred to the
  425. initiator.
  426.  
  427.     The CHECK CONDITION status is only used to report fatal errors for this
  428. command. For example:-
  429.  
  430.     - The Target receives a non-zero RESERVED bit in the Command
  431.       Descriptor Block.
  432.  
  433.     - An unrecovered parity error occurs on the DATA BUS.
  434.  
  435.     - A SCSI Bus or TAPE CONTROLLER malfunction prevents return of the
  436.       Sense Data.
  437.  
  438.     Following a fatal error on a Request Sense command, Sense Data may be
  439. invalid.
  440.  
  441.     Non-extended Sense
  442.     ------------------
  443.  
  444.     The format of the Sense Data is determined by the Error Class. Error
  445. Classes zero to six use the Nonextended Sense Data format, Error Class seven
  446. is described in the Extended Sense section.
  447.  
  448.     All the Nonextended Sense Data format classes provide vendor unique
  449. information and, as such, have limited value due to potential incompatibility
  450. between SCSI devices. Since the Extended Sense is properly defined, and is 
  451. more suitable for sequential devices, It is used exclusively by the TAPE
  452. CONTROLLER.
  453.  
  454.     Extended Sense
  455.     --------------
  456.  
  457. Extended Sense Data Format
  458. --------------------------
  459.  
  460.     ================================================================
  461.       BIT    |   7  |   6  |     5  |    4  |   3    |   2  |   1    |     0  |
  462.     BYTE    |      |      |        |         |      |     |    |     |
  463.     ================================================================
  464.     0    |Valid |   1     1    1  |   0      0      0        0  |
  465.     -------|-------------------------------------------------------|
  466.     1    |         Segment Number                 |
  467.     -------|-------------------------------------------------------|
  468.     2    |File- |      |        |         |                    |
  469.         |mark  | EOM  | ILI  |    0  |                     |
  470.     -------|-------------------------------------------------------|
  471.     3    |            Information Byte (MSB)           |
  472.     -------|-------------------------------------------------------|
  473.     4    |            Information Byte             |
  474.     -------|-------------------------------------------------------|
  475.     5    |            Information Byte             |
  476.     -------|-------------------------------------------------------|
  477.     6    |            Information Byte (LSB)           |
  478.     -------|-------------------------------------------------------|
  479.     7    |            Additional Sense Length           |
  480.     -------|-------------------------------------------------------|
  481.     8    |            Additional Sense Bytes           |
  482.     ================================================================
  483.  
  484.  
  485.     Error Class seven specifies Extended Sense. Error Code zero specifies
  486. the Extended Sense Data format.
  487.  
  488.     The valid bit indicates that the information bytes contain valid
  489. information as follows:
  490.  
  491.     The information bytes normally specify the difference (residue)
  492. between the requested length and the actual length in either bytes or blocks,
  493. as determined by the command. (Negative values are indicated by two's
  494. complement notation.)
  495.  
  496.     The information bytes are not defined if the valid bit is zero.
  497.  
  498.     The Segment Number is always set to 0.
  499.  
  500.     The Filemark bit indicates that the command moved the tape over a
  501. filemark.
  502.  
  503.     The End of Medium (EOM) bit Indicates that an end of medium has been
  504. detected by the tape drive. This bit indicates end-of-tape if the direction
  505. was forward or beginning-of-tape if the direction was reverse.
  506.  
  507.     The Incorrect Length Indicator (ILI) bit indicates that the requested
  508. logical block length did not match the logical block length of the data on
  509. the medium.
  510.  
  511.     The Sense Keys are described in the tables that follow.
  512.  
  513.     The Additional Sense Length specifies the number of Additional Sense
  514. Bytes to follow. If the Allocation Length of the Command Descriptor Block is
  515. too small to transfer all of the Additional Sense Bytes, the Additional Sense
  516. Length is not adjusted to reflect the truncation.
  517.  
  518.     The TAPE CONTROLLER sets one additional (Vendor Unique) byte to 
  519. provide information about the current status of the tape. This information
  520. is generated at the time of the first Request Sense command. Subsequent
  521. REQUEST SENSE command will not update this information.
  522.  
  523. Additional Sense Bytes
  524. ----------------------
  525.  
  526.     =================================================================
  527.       BIT    |   7* |   6  |     5  |     4  |    3  |   2  |   1  |     0    |
  528.     BYTE    |      |        |       |         |       |      |     |    |
  529.     =================================================================
  530.     8    | PROT |  EOT |  BOT |       Soft Error Count        |
  531.     =================================================================
  532.  
  533. Sense Key (0-7) Descriptions
  534. ----------------------------
  535.  
  536.     =================================================================
  537.     Sense Key     Description
  538.     ---------     ---------------------------------------------------
  539.     0H          NO SENSE. Indicates that there is no specific Sense
  540.             Key information to be reported. This would be the
  541.             case for a successful command or a command checked
  542.             because of Filemark, EOM or ILI bits being set to
  543.             one.
  544.  
  545.     1H          RECOVERED ERROR.    Indicates that the last command
  546.             completed successfully with some recovery action 
  547.             performed by the target.
  548.  
  549.     2H          NOT READY. Indicates that the Tape Drive addressed
  550.             cannot be accessed. Operator intervention may be
  551.             required to correct this condition.
  552.  
  553.     3H          MEDIUM ERROR. Indicates that the target detected a 
  554.             non-recovered error condition which was probably
  555.             caused by a flaw in the medium or an error in the
  556.             recorded data.
  557.  
  558.     4H          HARDWARE ERROR. Indicates that the target detected
  559.             a non-recoverable hardware failure (for example,
  560.             controller failure, device failure, parity error,
  561.             etc.) while performing the commandor during a self
  562.             test.
  563.     
  564.     5H          ILLEGAL REQUEST. Indicates that there was an Illegal
  565.             parameter in the Command Descriptor Block or in the
  566.             additional parameters supplied as data for some
  567.             commands (Set Mode, etc.).
  568.  
  569.     6H          UNIT ATTENTION. Indicates that the Tape Drive may have
  570.             been taken off line or the TAPE CONTROLLER reset (by
  571.             BUS DEVICE RESET message or "Hard" Reset Condition or
  572.             by CLEAR DRIVE command) since the last command was 
  573.             issued to the Logical Unit. This Sense Key is reported
  574.             the first time that any command is issued after the
  575.             condition is detected and the requested command is not
  576.             performed. The UNIT ATTENTION Sense Key is reported to
  577.             all Initiators which subsequently issue a command to 
  578.             the TAPE CONTROLLER. This Sense Key is cleared for the
  579.             next command from the same initiator.
  580.  
  581.     7H          DATA PROTECT. Indicates that a command which writes to
  582.             the tape was prevented by the absense of a write enable
  583.             ring. The write operation is not performed.
  584.  
  585.     8H          BLANK CHECK. Indicates that a read operation timed out
  586.             without finding data.
  587.  
  588.     9H          VENDOR UNIQUE. Provided by SCSI to report vendor unique
  589.             conditions.
  590.  
  591.     AH          COPY ABORTED. Generally not used.
  592.  
  593.     BH          ABORTED COMMAND. Indicates that the target aborted the
  594.             command. The initiator may be able to recover by trying
  595.             the command again.
  596.  
  597.     CH          EQUAL. not used.
  598.  
  599.     DH          VOLUME OVERFLOW. Indicates that the tape drive has
  600.             reached the End of Tape and data remains in the buffer
  601.             which has not been written to the tape. A Recover
  602.             Buffered Data command may be issued to read the 
  603.             unwritten data from the buffer. ( set only when PEOT
  604.             is set in MODE SELECT command)
  605.  
  606.     EH          MISCOMPARE. not used.
  607.  
  608.     FH          This Sense Key is RESERVED.
  609.  
  610.  
  611. Mode Select
  612. -----------
  613.  
  614.     Assembler:    tapebios(0xACE, Modsel, *(long)(parameter_list),
  615.                     (long)(list_len))
  616.  
  617.     'C'     :    Tmselect(*(long)(parameter_list), (long)(list_len));
  618.  
  619.     The Mode Select command provides a means for the initiator to specify
  620. device parameters to the TAPE CONTROLLER.
  621.  
  622.     The Parameter List Length specifies the length in bytes of the 
  623. Parameter List which will be transferred during the DATA OUT phase. The Length
  624. of Parameter List, if zero, indicates no data will be transferred. This is
  625. not considered an error condition.
  626.  
  627.     The Parameter List contains a four byte header, followed by zero or one
  628. eight byte Block Descriptors, followed by the VENDOR UNIQUE parameters.
  629.  
  630.     The Buffered Mode is defined as follows:
  631.  
  632.     0H    The TAPE CONTROLLER will not report GOOD STATUS on Write
  633.         commands until all data blocks are actually written
  634.         correctly onto the tape.
  635.  
  636.     1H    The TAPE CONTROLLER will report GOOD STATUS on Write commands
  637.         as soon as the last (or only) data block has been received
  638.         by the TAPE CONTROLLER, therefore data may be resident in the
  639.         buffer until more data is sent, or a Write Filemark command
  640.         is issued.
  641.  
  642.     2H-7H    Reserved.
  643.  
  644.  
  645. Mode Select Parameter List
  646. --------------------------
  647.  
  648.     ================================================================
  649.       BIT    |   7  |   6  |     5  |    4  |   3    |   2  |   1    |     0  |
  650.     BYTE    |      |      |        |         |      |     |    |     |
  651.     ================================================================
  652.     0    |   0        0     0    0        0       0      0        0  |
  653.     -------|-------------------------------------------------------|
  654.     1    |   0        0     0    0        0       0      0        0  |
  655.     -------|-------------------------------------------------------|
  656.     2    |RE-   |            |                 |
  657.         |SERVED|    Buffered Mode   |        Speed            |
  658.     -------|-------------------------------------------------------|
  659.     3    |            Block Descriptor Length           |
  660.     ================================================================
  661.  
  662.                 Block Descriptor
  663.     ================================================================
  664.     0    |            Density Code                 |
  665.     -------|-------------------------------------------------------|
  666.     1    |            Number of Blocks (MSB)           |
  667.     -------|-------------------------------------------------------|
  668.     2    |            Number of Blocks             |
  669.     -------|-------------------------------------------------------|
  670.     3    |            Number of Blocks (LSB)           |
  671.     -------|-------------------------------------------------------|
  672.     4    |   0        0     0    0        0       0      0        0  |
  673.     -------|-------------------------------------------------------|
  674.     5    |            Block Length (MSB)            |
  675.     -------|-------------------------------------------------------|
  676.     6    |            Block Length                 |
  677.     -------|-------------------------------------------------------|
  678.     7    |            Block Length (LSB)            |
  679.     ================================================================
  680.     
  681.       Two Vendor Unique parameter bytes follow the Block Descriptor
  682.      
  683.     ================================================================
  684.     0    |         Vendor Unique  Byte 0                 |
  685.     -------|-------------------------------------------------------|
  686.     1    |         Vendor Unique  Byte 1                 |
  687.     ================================================================
  688.  
  689.     
  690.     The Speed is defined as follows:
  691.  
  692.     0H    Default Speed (high speed)
  693.     1H    low speed
  694.     2H-FH    high speed
  695.  
  696.     The Block Descriptor Length must be set to either 0 or 8 to specify
  697. 0 or 1 Block Descriptors. It is equal to the number of Block Descriptors times
  698. eight. A Block Descriptor Length of zero indicates no Block Descriptors are 
  699. included in the Parameter List. This shall not be considered an error
  700. condition.
  701.     
  702.     The Block Descriptor specifies the medium characteristics for all or
  703. part of a Logical Unit. Each Block Descriptors contains a Number of Blocks and
  704. a Block Length.
  705.  
  706.     The Density Code parameters are drive dependant. Consult the manual for
  707. your tape drive to obtain the definitions for this field.
  708.  
  709.     The Number of Blocks field may or may not be ignored by your TAPE 
  710. CONTROLER. Again, consult the manual for your tape drive.
  711.  
  712.     The Block Length specifies the length in bytes of the logical block.
  713. The Block Length, if zero, indicates the length is variable.
  714.  
  715.     The next two bytes are Vendor Unique. Check the definition of these
  716. bytes in the manual for your tape drive.
  717.  
  718.  
  719. Mode Sense
  720. ----------
  721.  
  722.     Assembler:    tapebios(0xACE, Modsen, *(long)(parameter_list),
  723.                     (long)(list_len))
  724.  
  725.     'C'     :    Tmsense(*(long)(parameter_list), (long)(list_len));
  726.  
  727.     The Mode Sense command provides a means for the TAPE CONTROLLER to 
  728. report its current operational mode. It is a complementary command to the Mode
  729. Select command.
  730.  
  731.     The Allocation Length specifies the number of bytes that the initiator
  732. has allocated for returned Mode Sense Data. An Allocation Length of zero
  733. indicates that no Mode Sense Data will be transferred. This is not considered
  734. an error condition. Any other value indicates that number of bytes or less
  735. will be transferred. The TAPE CONTROLLER will terminate the DATA IN phase when
  736. Allocation Length bytes have been transferred or when all the Mode Sense Data
  737. has been transferred to the initiator.
  738.  
  739. NOTE: Check the manual for your tape drive. Some drives report back to the
  740. initiator with CHECK CONDITION if specific values for the Allocation Length
  741. are not specified.
  742.  
  743.     The Mode Sense Data contains a four byte header, followed by one eight
  744. byte Block Descriptor followed by the VENDOR UNIQUE parameters.
  745.  
  746.     The Sense Data Length specifies the length in bytes of the Mode Sense
  747. Data which is available to be transferred during the DATA IN phase.
  748.  
  749.     The Medium Type is always set to zero indicating only one medium type
  750. is supported.
  751.     
  752.     The Write Protected (WP) bit, if zero, indicates the tape is write
  753. enabled. The Write Protected bit, if one, indicates the tape is write
  754. protected.
  755.  
  756.  
  757. Mode Sense Data
  758. ---------------
  759.  
  760.     ================================================================
  761.       BIT    |   7  |   6  |     5  |    4  |   3    |   2  |   1    |     0  |
  762.     BYTE    |      |      |        |         |      |     |    |     |
  763.     ================================================================
  764.     0    |        Sense Data Length                 |
  765.     -------|-------------------------------------------------------|
  766.     1    |            Medium Type                |
  767.     -------|-------------------------------------------------------|
  768.     2    |  WP  |   Buffered Mode    |         Speed           |
  769.     -------|-------------------------------------------------------|
  770.     3    |            Block Descriptor Length           |
  771.     ================================================================
  772.  
  773.                 Block Descriptor
  774.     ================================================================
  775.     0    |            Density Code                 |
  776.     -------|-------------------------------------------------------|
  777.     1    |            Number of Blocks (MSB)           |
  778.     -------|-------------------------------------------------------|
  779.     2    |            Number of Blocks             |
  780.     -------|-------------------------------------------------------|
  781.     3    |            Number of Blocks (LSB)           |
  782.     -------|-------------------------------------------------------|
  783.     4    |   0        0     0    0        0       0      0        0  |
  784.     -------|-------------------------------------------------------|
  785.     5    |            Block Length (MSB)            |
  786.     -------|-------------------------------------------------------|
  787.     6    |            Block Length                 |
  788.     -------|-------------------------------------------------------|
  789.     7    |            Block Length (LSB)            |
  790.     ================================================================
  791.  
  792.       Two Vendor Unique parameter bytes follow the Block Descriptor
  793.  
  794.     ================================================================
  795.     0    |        Vendor Unique  Byte 0             |
  796.     -------|-------------------------------------------------------|
  797.     1    |        Vendor Unique  Byte 1             |
  798.     ================================================================
  799.  
  800.     The Buffered Mode and Speed field are defined in the Mode Select
  801. Command.
  802.  
  803.     The Block Descriptor Length bytes is set to 08H to indicate 1 Block
  804. Descriptor (of 8 bytes) is available.
  805.  
  806.     The Density Code is defined in the Mode Select Command.
  807.  
  808.     The Number of Blocks field is always set to zero, indicating all the
  809. remaining logical blocks of the Logical Unit
  810.  
  811.     The Block Length specifies the length in bytes of the Tape block. This
  812. is initialised at power up to be zero, indicating the length is variable, but
  813. can be updated by the Mode Select Command to provide a fixed block size. This
  814. value is maintained solely by the Mode Select Command, and is not affected by
  815. the size of any data block read or written to tape.
  816.  
  817.     The following two bytes are Vendor Unique.
  818.  
  819. Space
  820. -----
  821.  
  822.     Assembler:    tapebios(0xACE, Space, 0L, (long)(code/count))
  823.  
  824.     'C'     :    Tspace((long)(code/count));
  825.  
  826.     The Space command provides a variety of tape positioning functions
  827. which are determined by the Code and Count. Both forward (toward EOT) and
  828. reverse (toward BOT) positioning are provided.
  829.  
  830.     The Code is defined as follows:
  831.  
  832.         DB(1)    DB(0)    Description
  833.         0    0    Blocks
  834.         0    1    Filemarks
  835.         1    0    Sequential Filemarks
  836.         1    1    Physical End-of-Data
  837.  
  838.     When spacing over Blocks or Filemarks the Count field specifies the
  839. number of blocks or filemarks to be spaced over. A positive value N in the
  840. Count field causes forward tape movement over N blocks or filemarks ending on
  841. the EOT side of the last block or filemark. A zero vlaue in the Count field
  842. causes no tape movement. A negative value -N (2's complement notation) in the
  843. Count field causes reverse tape movement over N blocks or filemarks ending
  844. on the BOT side of the last block or filemark.
  845.  
  846. NOTE: Not all streamers support the BACKSPACE function, experiment !!!!!
  847.  
  848.     If a filemark is encountered while spacing over Blocks, tape movement
  849. is stopped. The tape will be positioned on the EOT side of the filemark if
  850. movement was in the forward direction and on the BOT side of the filemark if
  851. movement was in the reverse direction. CHECK CONDITION status will be sent
  852. to the initiator and the Filemark and Valid bits in Extended Sense will be 
  853. set to one. The Information Bytes will be set to the difference (residue) in
  854. the requested Count and the actual number of blocks spaced over (not including
  855. the filemark).
  856.  
  857.     If the EOT marker is encountered while spacing forward over Blocks or
  858. Filemarks, the TAPE CONTROLLER will return CHECK CONDITION status to the
  859. initiator and will set the End-of-Medium (EOM) bit in Extended Sense to one.
  860. The Sense Key will be set to MEDIUM ERROR. The TAPE CONTROLLER will set the
  861. valid bit to one and the Information Bytes to the difference (residue) between
  862. the requested Count and the actual number of blocks or filemarks spaced over.
  863.  
  864.     If the BOT marker is encountered while spacing over Blocks or Filemarks
  865. in the reverse direction, the TAPE CONTROLLER returns CHECK CONDITION status to
  866. the initiator and sets the End-of-Medium (EOM) bit in Extended Sense to one.
  867. The Sense Key will be set to NO SENSE. The TAPE CONTROLLER will set the valid
  868. bit to one and the Information Bytes to the difference (residue) between the
  869. requested Count and the actual number of blocks or filemarks spaced over.
  870.  
  871.     When spacing over Sequential Filemarks, the Count field is interpreted
  872. as follows:
  873.  
  874.     - A positive value N causes forward tape movement to the first 
  875.       occurence of N or more consecutive filemarks stopping after the Nth
  876.       filemark.
  877.  
  878.     - A zero value shall cause no tape movement.
  879.  
  880.     - A negative value -N (2's complement notation) causes reverse tape
  881.       movement to the first occurence of N or more consecutive filemarks
  882.       stopping on the BOT side of the Nth filemark.
  883.  
  884.     When spacing to physical End-of-Data, the Count field is ignored.
  885. Forward tape movement occurs until the TAPE CONTROLLER has passed over blank
  886. tape for approximately 10 seconds. The tape is then repositioned to the point
  887. immediately after the last data block or filemark read. This leaves the tape
  888. positioned so that a subsequent write command would append data to the last
  889. recorded information on the tape.
  890.  
  891.  
  892. Erase
  893. -----
  894.  
  895.     Assembler:    tapebios(0xACE, Erase, 0L, 0L)
  896.  
  897.     'C'     :    Tspace();
  898.  
  899.     The Erase command causes part or all of the remaining tape to be erased
  900. beginning from the current tape position.
  901.  
  902.     The distance to be erased is controlled by the Long bit. The Long bit,
  903. if one, indicates all remaining tape is erased. If zero, it indicates that a
  904. standard length of tape is erased. The length in this case is governed by the
  905. tape formatter, but is typically 4 inches of tape.
  906.  
  907.     Some other tape controllers (especially those concerned with 1/4 inch
  908. cartridges) may only be able to erase a tape from BOT (i.e. before writing to
  909. the tape). Programmers should therefore only issue an erase command from BOT.
  910.  
  911.  
  912.  
  913.  
  914. Inquiry
  915. -------
  916.  
  917.     Assembler:    tapebios(0xACE, Inquire, *(long)(buffer), 
  918.                     (long)(bytecount))
  919.  
  920.     'C'     :    Tinquir(*(long)(buffer), (long)(bytecount));
  921.  
  922.     The Inquiry command requests that information regarding parameters of
  923. the TAPE CONTROLLER be sent to the initiator.
  924.  
  925.     The Allocation Length specifies the number of bytes that the initiator
  926. has allocated for returned Inquiry Data. An allocation Length of zero indicates
  927. no inquiry data shall be transferred. This is not considered an error
  928. condition. Any other value indicates the maximum number of bytes to be
  929. transferred. The TAPE CONTROLLER terminates the DATA IN phase when this number
  930. of bytes have been transferred or when all available Inquiry Data has been 
  931. transferred to the initiator.
  932.  
  933.     The CHECK CONDITION status will only be reported when the TAPE
  934. CONTROLLER cannot return the Inquiry Data.
  935.  
  936.     The Inquiry Data contains a five byte header, followed by the VENDOR
  937. UNIQUE parameters, if any.
  938.  
  939.     The Peripheral Device Type is set to 01 to indicate a sequential 
  940. device, unless the Logical Unit Number set in the command is not valid (i.e.
  941. not 000) In which case this byte is set to 7FH to indicate the Logical Unit
  942. is not present.
  943.  
  944.     The Removable Medium (RMB) bit is set to 1 to indicate the medium is
  945. removable.
  946.  
  947. Inquiry Data
  948. ------------
  949.  
  950.     ================================================================
  951.       BIT    |   7  |   6  |     5  |    4  |   3    |   2  |   1    |     0  |
  952.     BYTE    |      |      |        |         |      |     |    |     |
  953.     ================================================================
  954.     0    |            Peripheral Device Type           |
  955.     ---------------------------------------------------------------|
  956.     1    | RMB  |          Device Type Qualifier            |
  957.     ---------------------------------------------------------------|
  958.     2    |            Version                 |
  959.     ---------------------------------------------------------------|
  960.     3    |   0        0     0    0        0       0      0        0  |
  961.     ---------------------------------------------------------------|
  962.     4    |            Additional Length              |
  963.     ===============================================================|
  964.     5    |        Custom Version number (see text)           |
  965.     ---------------------------------------------------------------|
  966.     6    |   0        0     0    0        0       0      0        0  |
  967.     ---------------------------------------------------------------|
  968.     7    |   0        0     0    0        0       0      0        0  |
  969.     ---------------------------------------------------------------|
  970.     8 - 35 | (TAPE CONTROLLER's title and revision details, ASCII) |
  971.     ---------------------------------------------------------------|
  972.     36 ->    | (Vendor Unique parameters (see text)               |
  973.     ================================================================
  974.  
  975.     The Device Type Qualifier is a seven bit user specified code. This code
  976. is normally set to 0.
  977.  
  978.     The Version if the implemented version of the SCSI standard and is 
  979. defined in the TAPE CONTROLLER as follows:
  980.  
  981.     00H    Pre-release firmware
  982.     01H    Standard release firmware. This code is used by SCSI Devices
  983.         who claim to comply with SCSI rev 17B.
  984.  
  985.     The Additional Length specifies the length in bytes of the extra and
  986. VENDOR UNIQUE parameters.
  987.  
  988.     Byte 5 will normally be set to 00H unless customized firmware is
  989. supplied. Bytes 8 to 35 generate the TAPE CONTROLLER's title and revision 
  990. details in accordance with the SCSI Command Command Set Specification.
  991.  
  992.     The remaining bytes are Vendor Unique.
  993.  
  994. Alan Hourihane.
  995. email: alanh@logitek.co.uk
  996. 17/3/92.
  997.  
  998.  
  999.