// DDTapes.d - Definitions for the Dual Density Tape I/O Routines
// Copyright Xerox Corporation 1981
// Last modified by Tim Diebert, March 16, 1981  4:18 PM
external
   [
// Procedures in the DDTapeIO package that are useful
   ActOnDDTape
   CloseDDTape
   EraseInches
   FileSkipFwd
   FileSkipRev
   OpenDDTape
   PerformVDDTCB
   RecSkipFwd
   RecSkipRev
   SetDensity
   TapeEOF
   TapeStatus
   TapeRewind
   TapeRewindWait
   TapeUnload
   WaitTapeReady
// Procedures in the DDTapeInit package that are useful
   InitializeDDTape
// Procedures in the DDTapeUtilA package that are useful
   DDTapeVertIntCode   // used by the R/W code for use to sync the Display turn off
   UBlockEq
   BlockEq
   UPupChecksum
   AsciiXlate
   EbcdicXlate
   TapeTfsSwatProc
// Procedures in the DDTape Microcode package that are useful
   DDTapeImage
// Statics or externals for use in other parts of the tape code
   DDTapeDispSaveData1
   DDTapeDispSaveData2
   DDTapeDispSaveData3
   DDTapeDispSavervDCBStart
   DDTapeVertIntFlag
   DDTapeVertIntMask
   DDTapeVertIntChannel
   TapeOpened
   TapeActive
   ]
manifest
   [
// Low core stuff and more
   DCBStart = #420 // Display start
   DCBInterupt = #421 // Display interupt field
   DDTCBStart = #622// Tape Control Block Head
   IntVec = #501
   IntActive = #453
   MaxUnitNum = 3// four drives: 0,1,2 and 3
// StartIO defs
   TapeNormalOp = #200
   TapeResetOp = #100
   ]
// Tape Controller Status Definitions
//--------------------------------------------------------------------------
structure DDStatus:
//--------------------------------------------------------------------------
   [
   RDY bit//  100000 ReaDY. Unit loaded, Tape not in motion
   ONL bit//   40000 ON Line. Unit loaded, Tape may be in motion
   RWD bit//   20000 ReWinDing. Unit is rewinding
   FPT bit//   10000 File ProTect. Write Ring removed.
   BOT bit//    4000 Beginning Of Tape. Tape is at load point
   EOT bit//    2000 End Of Tape. EOT marker was crossed in a forward direction
   FMK bit//    1000 End Of File. Last record (R/W) was an EOF mark (Tape Mark)
   NRZI bit//     400 NRZI Status is present in the drive. 800 bits per inch mode.
   HE bit//     200 Hard Error.  A non recoverable error occured during R/W operation
   SE bit//     100 Soft Error. A correctable error occured during R/W operation.
   DL bit//      40 Data Late. Write or Read buffer went empty or overflowed
   RDP bit//      20 Read Data Parity. A read parity error occured.
   ICL bit//      10 InCorrect Length on write
   HDWERR bit//       4 HarDWare ERRor. THe controller microcode detected an error.
   WFP bit//       2 Write on File Protected reel. (FPT & Write-Op)
   CMDER bit//       1 ComManD ERror. Unkown command type.
   ]
manifest
   [   // Status bit masks
   Bot = #4000
   Eot = #2000
   Eof = #1000
   Rewound = #144000// RDY % ONL % BOT
   TapeErr = #367
   ]
// Tape Control Block as Required by the hardware
//--------------------------------------------------------------------------
structure DDTCB:
//--------------------------------------------------------------------------
   [
   ChainAddr   word// Next TCB to be executed if error not detected by the current op.
   Command    word = 
      [
      Density bit 1// 1 = NRZI mode, 0 = PE mode.
      Threshold bit 1// 0 = normal, 1 = Low read threshold for data recovery.
      ReadAfterWrite bit 1// 0 = no read data transfered after write, 1 = read trasnfered.
      blank bit 2// should be zero
      Unit bit 3 // Unit this op selects.
      blank bit 3// should be zero
      Opcode bit 5 =// Define both direction and action
         [
         REV bit 1// Reverse direction bit
         WRT bit 1// Write operation
         WFM bit 1// File mark operation
         EDIT bit 1// Edit spacing operation
         ERASE bit 1// Erase or disable data
         ]
      ]
   ReadBuffer word// Address of main memory read buffer
   ReadCount word// Read buffer WORD count
   WriteBuffer word// Address of main memory write buffer
   WriteCount word// The number of BYTES to write.  May be odd
   ByteCount word// Number of data bytes moved on R/W.
   Flags word =
      [
      @DDStatus       // Controller Ending Status
      ]
   ]
manifest
   [
// DDTCB size
   lDDTCB = ((size DDTCB)+15)/16
// Timeout timers for various things
   RewindTimeout = 19200   // The total time to rewind at 150ips
   RecordTimeout = 250   // Time to pass 25’ of tape at 125ips
   FileTimeout = 23040   // Time to pass 2400’ of tape at 125ips for a file search.
   NoOpTimeout = 10   // The total time to perform a NoOp
   ]
 
// Virtual Tape Control Block used by the software to keep track of things
//--------------------------------------------------------------------------
structure VDDTCB:   // virtual tape control block
//--------------------------------------------------------------------------
   [
   @DDTCB
   opDensity word// flag indicating drives current density
   operation word// Operation code as supplied to the software
   drive word// Unit this operation is for
   errProc word// Procedure to call in case an error is detected
   interventionProc word// Procedure to call in case an operator intervention.
   retries word// Retry count
   lowthresh word// Flag used to keep track of a read at low threshold.
   timeout word// Timeout flag. If true then timeout detected by PerformVTCB
   regap word// Flag used to keep track of a long gap write during write retry
   ]
manifest
   [
// Operation Density Defs
   PE = 1600
   NRZI = 800
// VDDTCB size
   lVDDTCB = ((size VDDTCB)+15)/16
// Tape Op Codes as passed to the routines by the user program
// Assignments must be maintained so that the hardware gets what is needs.
   BackSpaceRecord = #21
   FwdSpaceRecord = #01
   BackSpaceFile = #25
   FwdSpaceFile = #05
   ReadFwd = #00
   ReadRev = #20
   ReadRevEdit = #22
   Write = #10
   WriteEdit = #12
   Erase = #15
   EraseVar = #11
   WriteEOF = #14
   Rewind = #35
   Unload = #36
   NoOp = #37
   Reset = #40
   ]