Specs

Table of Content


Content

This section contains specs for current and future developments, written ahead of time with the purpose of mature ideas before getting into implementation.

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.

VTFS File System

VTFS stands for Virtual Tape File System. It is intended as an abstraction for programs running at the LC-81 minicomputer for interchanging data between disimiles tape-based storage mediums. Tapes can be either real such audio cassettes and open reel audio tapes, or virtual, simulated with Floppy Disks or ROM memory.

Format

The tape content is encoded in ASCII. In the case of non-textual content (such as binary files or programs object code), it is coded in Hexadecimal which in turn is encoded in ASCII.

The entire media is treated as a single sequence of bytes broken into Blocks being this the transfer unit. VTFS reads or writes tapes one block at the time into internal buffers. Applications read or write one byte at the time from VTFS buffers. VTFS takes care of the synchronization between application requests and buffers content.

In real tapes, blocks are physically separated by gaps. This is required for tapes containing long files because they will eventually stop in the middle of a file; tapes must stop with the head positioned over a gap, not a data zone.

The size of the block is fixed for a given tape but it can vary from tape to tape. Some types of media such as Floppy have a pr-established block size but this parameter is generally user-defined and ranges from 256 to 4096 bytes. The maximum number of blocks a file can contain is 256, hence the maximun size for a VTFS file is 1 MB.

The block format for real tapes is as following:

    gap
    02H     ASCII Start-Of-Transmission (STX)
    MSN     Block Number (Hex less signif. nibble)
    LSN     Block Number (Hex most signif. nibble)
    .
    .
    data
    .
    .                                .
    03H        ASCII End-Of-Transmission (ETX)
    gap

In virtual tapes, blocks contain just the data.

LABEL

The first block of a volume (Block 0) is always a LABEL containing information about the rest of the volume. The format is as following:

    Start Mark            (ASCII 'SOH': 01H)
    File System ID        (VTFS)
    File System Version   (1.0)
    Medium                (ex: T)
    Block Size            (ex: 1024)
    Block Count           (ex: 21)
    Encoding              (ex: A)
    File ID (FID)         (ex: 04)
    File Description      (ex: Employees Master File)
    Read-Only             (Y or N)
    File Creation Date    (ej: 2016-08-11)

These fields are delimited by a Line Feed character (0AH). The last one after the 'File Creation Date' field is interpreted as the end of the LABEL.

Field 'Medium' accept one of the values: 'T' (real Tape), 'V' (Virtual tape). This is important since some VTFS operations (such as overwriting a block in the middle of the tape) are restricted to virtual tapes.

Field 'Block Count' is mandatory for program files but can be ignored for other kind of files, specially those stored in real tapes: having to rewind the tape to the begining for just updating the LABEL can prove impractical in certain cases.

Encoding can be one of the values: 'A' (textual), 'H' (hexadecimal). This is important because VTFS makes the conversion hex-to-bin as it writes to the memory buffer in case of Enconding 'H'.

File ID or FID, is the way programs refer files. When the tape is mount on the tape drive, a 2-digits 7-segments display shows that ID to tell the operator which file is in which drive. This allows the operator to place tapes in arbitrary drives without getting lost.

'File Description' is optional being its purpose to show some additional information in a terminal, if that were the case.

End Of Tape mark (EOT)

Each file ends with a End-Of-Tile mark (EOT) placed after the last data byte of the file. Actual mark is ASCII FS (1CH).