Specification for LC-81 Tape Drives

Storage for the LC-81 is based on tapes. These can be of any kind: paper tape, audio cassette, audio open reel magnetic tape, etc. It can also be "virtual tapes", that is simulated by non-tape media such as floppy disks or even a computer files managed by a Tape Simulation program.

In any case, there is a standard way for applications to communicate with tape drives. Such standard is specified in this document in full detail.

Assumptions about the tape format

We need to differentiate between "encoding" and "data format". The former refers to how bits are represented in the media, it can be frequency-keying, bi-phase encoding, etc. The later refers to how bits (once decoded) are organized and what they represent. Reading a tape, therefor, takes two steps: decoding bits and making sense of them.

For LC-81 tape drives, the encoding is mostly drive-specific. In general, it it is assumed that data is grouped into "blocks" separated by physical "gaps". This is generally required in real tapes because the transport will eventually stop in the middle of a file (particularly true for long files). For synchronization purposes, the reading head must stop on a gap, not a data area. The drive must be able to detect the presence of blocks and gaps as they read.

As per data format, the drive must be totally agnostic. This ignorance allows the drive to transparently serve to different file systems and formats. It is the software running at the LC-81 that actually makes sense of the data and the tape data format.

Nevertheless, some assumptions have been made about that format:

* Blocks contain 8-bits bytes.
* There is only one file per tape.
* Software will refer to this file by a "File Identification number" (FID).
* The tape could contain a LABEL with metadata having the FID as part of it.

Tape Drives must be designed to support these assumptions without fully committing to them, that is being able to serve as well in cases where those assumptions do not hold.

Front Panel

The drive's Front Panel must contain the following controls:

* Button "On-Line"
* Switch "Write Protect"
* Rotatory Hex key for the Operator to set the File Identification number (FID)
* 2-digits Hex 7-Segment display to show the effective FID
* Button Rewind
* Button Fast Forward
* Button Stop
* Status Lamps:
  -- On-Line
  -- Read
  -- Write
  -- Stop
  -- Rewind (RWD)
  -- Fast Forward (FF)
  -- Begin of Tape (BOT)
  -- End of Tape (EOT)
  -- Alarm
* Button to Clear Alarm

The Drive can be either "On-Line" or "Off-Line". When "On-Line", the Software can take control of it; when "Off-Line", it can not. The button On-Line switches the drive between these two modes.

The "Write Protect" switch, when active (up position) prevents the tape from being written. This is intended as a protection from misbehaved software.

The File Identification Number (FID) can be manually set by the Operator. The operator uses the rotatory Hex key for that purpose. When the drive goes On-Line that setting becomes effective and it is displayed in the FID 7-Segment Display.

The FID can also be set automatically by Software; it can exists as metadata in a LABEL heading the file which is the case of the VTFS file system. In that case the LC-81 software would obtain the FID from the tape and send it to the drive for displaying in the FID 7-segnment display.

Buttons Rewind, Fast Forward and Stop allow the operator to take control of the transport mechanism in case it was needed, but those operations are initiated by software in most cases.

The Status Lamps signal whether the drive is On-Line or not and what operation is currently taking place: Read, Write, Stop, Rwd, FF. Also, if the tape is at the Beginning or the End and whether an error condition (Alarm) exists.

An error condition occurs, for instance, if software tries to write when Write Protect is On, or if an invalid command is received. Error conditions do nothing else beyond lighting the "Alarm" lamp. Once on, the only way to turn that lamp off again is by pressing the "Alarm Clear" button.

Internal Registers

Tape Drives connect to the LC-81, physically, through the EXT-BUS. The computer communicates with the Drive by the mean of three 8-bits read/write registers (having each its own I/O address) that are directly exposed to the bus:

  Register D: Data
  Register C: Control
  Register F: FID

The register D is used for data interchange.
The register C is used to report status from and send commands to the Drive.
The register F is used to read or set the File Identification number (FID).

Register's addresses must be consecutive in this order: D, C, F; the address of D is considered the "Base Address" of the device. Other registers could also exists to support advanced functionality in which case their addresses must also be consecutive after F. If some kind of programmable chip is used to implement D (for instance, an UART chip) and that chip takes more than one I/O address, then the address of C must follow the last address occupied by the chip.

It is also possible to connect the Drive via serial port instead of EXT-BUS but that approach is only acceptable for simulation software such as VTCOM, not for actual drives.

Register D

In real tapes, bits are encoded serially along the tape. The drive must decode them and group them into bytes using some kind of shift register. Once a byte have been decoded, it is transferred in parallel to register D and an interrupt is asserted to the EXT-BUS to let LC-81 know that a byte is ready for reading. Software running at LC-81 reads register D in response to the interrupt.

The time needed to decode a byte, and consequently the time between interrupts, varies depending of the drive, but is expected to be in the order of milisecons.

Register C

Register C holds drive's Status and operational Mode, according to the following bit-map:

  Bits    Meaning
  ----------------------------
  0-3     Mode
  4       BOT (Begin Of Tape)
  5       EOT (End Of Tape)
  6       On-Line
  7       Alarm
  ----------------------------

Where Mode, in turn, is bit-mapped as following:

  Bits    Meaning
  ----------------------------
  0-1     Transport Status:
            00   STOP
            01   Rewinding
            10   Fast Forwarding
            11   Moving at nominal speed (Read, Write, or Making GAP)

  2-3     Operation:
            00  (Illegal)
            01   READ
            10   WRITE
            11   Making GAP
  ----------------------------

The register can be read or written though the EXT-BUS but the Drive's electronics must prevent bits 4-7 from being overwritten. Software running at the LC-81 can then read the entire register but only write the least significant nibble (Mode); the most significant nibble is simply ignored and can be filled with zeros. This results in the following:

  Mode    Meaning
  ----------------------------
  00H     STOP
  01H     RWD
  02H     FF
  07H     READ
  0bH     WRITE
  0fH     Make GAP
  ----------------------------

Register F

This register holds the effective File Identification Number (FID) and its content is always shown in Hex in the 2-digits seven-segment display on the front panel.

When the drive goes "On-Line" the content of the FID rotatory Hex key is copied into F so LC-81 software can read it. Software can also write the FID to F so the Operator can see it.

In reality, the only role of register F is to display its content in the front panel. It can be used for other purposes as well, such as reporting status or error conditions to the Operator.

Controlling the Tape Drive

Software controls the Tape Drive by writing the mode (4 least significant bits) to drive's register C, as following:

  Mode    Operation
  ------------------
  00H     STOP
  01H     RWD
  02H     FF
  07H     READ
  0bH     WRITE
  0fH     Make GAP
  -------------------

The drive executes the associated operation immediately after receiving the mode and remains in that state until a new mode is written to C, or the operation finished by its own which occurs when the tape reaches its end; when that happens, the drive changes automatically to mode STOP and writes 00H to register C. Current mode can also change if the Operator intervene performing a manual operation.

Every time the content of C changes (for whatever reason) an interrupt is asserted to the to EXT-BUS so appropriate actions can be taken by software. Software can also read the register C at any time to learn about current Mode and Status of the drive.

Tape Operations

Read

The READ operation is initiated by Software writing Mode READ to register C. An interrupt is asserted to confirm that mode has changed.

The Drive makes preparations to start reading the tape starting at the current tape position. If it happens to be in a GAP (as it is supposed to), reading starts at the first bit of the block following the GAP. If it is in a data zone instead, the Drive skips to the next GAP, then start reading the next block.

Once an entire byte has been decoded, it is copied to register D and an interrupt is asserted to notify that a byte is waiting for reading. The Software must act quickly to read that byte from D. This process continues, byte after byte, until a GAP is reached in which case the Drive automatically changes to Mode STOP and another interrupt is asserted to notify that.

Software can also abort the READ operation by writing Mode STOP to register C, which is not advisable in normal circumstances because then the tape would stop in data area instead of on a GAP. Software is expected to read an entire block into a buffer. Once the block has been read and the tape has stopped, Software is plenty of time to process that block for their own purposes.
  

Write

The WRITE operation is initiated by Software writing Mode WRITE to register C. An interrupt is asserted to confirm that mode has changed.

The Drive makes preparations to start writing starting at the current tape location. Unlike with READ operation, in this case the Drive does not check for GAPs.

Once the Drive is ready, it asserts an interrupt and Software responses by writing the first byte to register D. The Drive's circuitry senses this write operation and starts encoding and writing the byte to tape. Once finished, a new interrupt is asserted and Software writes the next byte to D in response.

This process continues until Software decides to finish. Normally this occurs when an entire block has been written. Software are then expected to write Mode Make GAP to register C. In response, the Drive let a GAP in the tape and STOPs automatically. An interrupt is asserted because the Mode changed (from Make GAP to STOP).

This completes the writing of a block on tape. Software will possibly initiate a new WRITE operation to write the next block.

A word about Block Length

We already mentioned that the Drive must be agnostic with respect to the tape format. This includes block length. As we can infer from the previous discussion, it is possible for Software to make blocks of variable lengths along the tape. Although this is not the must likely case (fixed-length blocks makes it easy for data manipulation), this specification does not put any restriction on that respect. Care about block length must laid in Software, no Drive's hardware.

Other drive operations

Get FID

Software can obtain the File Identification number (FID) in two ways: extracting it from the LABEL of the tape, if it is present, or reading the drive's register F, if it was set manually by the operator.

Reading register F takes a simple read I/O cycle on that I/O address.

Set FID

Writing the FID to drive's register F takes a simple I/O write cycle. The drive circuitry senses that write operation and displays its content in Hex in the FID seven-segment display.

This mechanism has been conceived for advanced applications working with multiple files. The operator places tapes on drives arbitrarily. Software reads LABELs obtaining the FID and maps those to drive IDs. Then, Software writes each FID to the corresponding drive's register F so the Operator can know which file has been mounted in which drive.

Alarm Condition

Software has no write access to the Alarm bit in register C, it can only read it. Alarm conditions are detected and reported by the Drive circuitry only.

An alarm condition does not prevent further Drive functionality in any way. Its only effect is to illuminate the Alarm Lamp to alert the Operator.

The following conditions cause the Alarm Lamp to illuminate.

  * Software writes an illegal Mode to register C.
  * Read or Write operation aborted because tape reaches its end (EOT).
  * Software attempts to make a WRITE operation while the Write Protect switch is in active position.

The only way to turn the lamp off again is by pressing the Clear Alarm button.