From d8cae47cb3934e72d96d0801339c5a8b9eff39bd Mon Sep 17 00:00:00 2001 From: Ken Thompson Date: Thu, 24 May 1979 01:15:06 -0500 Subject: [PATCH] Research V7 development Work on file usr/src/cmd/standalone/tm.c Work on file usr/src/cmd/standalone/ht.c Co-Authored-By: Dennis Ritchie Synthesized-from: v7 --- usr/src/cmd/standalone/ht.c | 168 ++++++++++++++++++++++++++++++++++++ usr/src/cmd/standalone/tm.c | 112 ++++++++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 usr/src/cmd/standalone/ht.c create mode 100644 usr/src/cmd/standalone/tm.c diff --git a/usr/src/cmd/standalone/ht.c b/usr/src/cmd/standalone/ht.c new file mode 100644 index 0000000000..2fe9592bb2 --- /dev/null +++ b/usr/src/cmd/standalone/ht.c @@ -0,0 +1,168 @@ +/* + * TJU16 tape driver + */ + +#include +#include +#include "saio.h" + +struct device +{ + int htcs1; + int htwc; + caddr_t htba; + int htfc; + int htcs2; + int htds; + int hter; + int htas; + int htck; + int htdb; + int htmr; + int htdt; + int htsn; + int httc; + int htbae; /* 11/70 bus extension */ + int htcs3; +}; + + + +#define HTADDR ((struct device *)0172440) + +#define GO 01 +#define WCOM 060 +#define RCOM 070 +#define NOP 0 +#define WEOF 026 +#define SFORW 030 +#define SREV 032 +#define ERASE 024 +#define REW 06 +#define DCLR 010 +#define CLR 040 +#define P800 01300 /* 800 + pdp11 mode */ +#define P1600 02300 /* 1600 + pdp11 mode */ +#define IENABLE 0100 +#define RDY 0200 +#define TM 04 +#define DRY 0200 +#define EOT 02000 +#define CS 02000 +#define COR 0100000 +#define PES 040 +#define WRL 04000 +#define MOL 010000 +#define PIP 020000 +#define ERR 040000 +#define FCE 01000 +#define TRE 040000 +#define HARD 064023 /* UNS|OPI|NEF|FMT|RMR|ILR|ILF */ + +#define SIO 1 +#define SSFOR 2 +#define SSREV 3 +#define SRETRY 4 +#define SCOM 5 +#define SOK 6 + +htopen(io) +register struct iob *io; +{ + register skip; +int i; + + htstrategy(io, REW); + skip = io->i_boff; + while (skip--) { + io->i_cc = -1; + while (htstrategy(io, SFORW)) + ; + i = 0; + while (--i) + ; + htstrategy(io, NOP); + } +} + +htclose(io) +register struct iob *io; +{ + htstrategy(io, REW); +} + +htstrategy(io, func) +register struct iob *io; +{ + register unit, den, errcnt; + + unit = io->i_unit; + errcnt = 0; +retry: + HTADDR->htcs2 = unit&03; + if(unit > 3) + den = P1600; + else + den = P800; + htquiet(); + if((HTADDR->httc&03777) != den) + HTADDR->httc = den; + HTADDR->htba = io->i_ma; + HTADDR->htfc = -io->i_cc; + HTADDR->htwc = -(io->i_cc>>1); + den = ((segflag) << 8) | GO; + if (func == READ) + den =| RCOM; + else if (func == WRITE) + den =| WCOM; + else if (func == SREV) { + HTADDR->htfc = -1; + HTADDR->htcs1 = den | SREV; + return(0); + } else + den |= func; + HTADDR->htcs1 = den; + while ((HTADDR->htcs1&RDY) == 0) + ; + if (HTADDR->htds&TM) { + htinit(); + return(0); + } + if (HTADDR->htcs1&TRE) { + if (errcnt == 0) + printf("tape error: cs2=%o, er=%o", + HTADDR->htcs2, HTADDR->hter); + htinit(); + if (errcnt == 10) { + printf("\n"); + return(-1); + } + errcnt++; + htstrategy(io, SREV); + goto retry; + } + if (errcnt) + printf(" recovered by retry\n"); + return(io->i_cc+HTADDR->htfc); +} + +htinit() +{ + int omt, ocs2; + + omt = HTADDR->httc & 03777; + ocs2 = HTADDR->htcs2 & 07; + + HTADDR->htcs2 = CLR; + HTADDR->htcs2 = ocs2; + HTADDR->httc = omt; + HTADDR->htcs1 = DCLR|GO; +} + +htquiet() +{ + while ((HTADDR->htcs1&RDY) == 0) + ; + while (HTADDR->htds&PIP) + ; +} diff --git a/usr/src/cmd/standalone/tm.c b/usr/src/cmd/standalone/tm.c new file mode 100644 index 0000000000..cd4a0bf65c --- /dev/null +++ b/usr/src/cmd/standalone/tm.c @@ -0,0 +1,112 @@ +# + +/* + * TM tape driver + */ + +#include +#include +#include "saio.h" + +struct device { + int tmer; + int tmcs; + int tmbc; + char *tmba; + int tmdb; + int tmrd; +}; + +#define TMADDR ((struct device *)0172520) + +#define GO 01 +#define RCOM 02 +#define WCOM 04 +#define WEOF 06 +#define SFORW 010 +#define SREV 012 +#define WIRG 014 +#define REW 016 +#define DENS 060000 /* 9-channel */ +#define IENABLE 0100 +#define CRDY 0200 +#define GAPSD 010000 +#define TUR 1 +#define SDWN 010 +#define HARD 0102200 /* ILC, EOT, NXM */ +#define EOF 0040000 + +#define SSEEK 1 +#define SIO 2 + + +tmrew(io) +register struct iob *io; +{ + tmstrategy(io, REW); +} + +tmopen(io) +register struct iob *io; +{ + register skip; + + tmstrategy(io, REW); + skip = io->i_boff; + while (skip--) { + io->i_cc = 0; + while (tmstrategy(io, SFORW)) + ; + } +} +tmstrategy(io, func) +register struct iob *io; +{ + register int com, unit, errcnt; + + unit = io->i_unit; + errcnt = 0; +retry: + tmquiet(); + com = (unit<<8)|(segflag<<4)|DENS; + TMADDR->tmbc = -io->i_cc; + TMADDR->tmba = io->i_ma; + if (func == READ) + TMADDR->tmcs = com | RCOM | GO; + else if (func == WRITE) + TMADDR->tmcs = com | WCOM | GO; + else if (func == SREV) { + TMADDR->tmbc = -1; + TMADDR->tmcs = com | SREV | GO; + return(0); + } else + TMADDR->tmcs = com | func | GO; + while ((TMADDR->tmcs&CRDY) == 0) + ; + if (TMADDR->tmer&EOF) + return(0); + if (TMADDR->tmer < 0) { + if (errcnt == 0) + printf("tape error: er=%o", TMADDR->tmer); + if (errcnt==10) { + printf("\n"); + return(-1); + } + errcnt++; + tmstrategy(io, SREV); + goto retry; + } + if (errcnt) + printf(" recovered by retry\n"); + return( io->i_cc+TMADDR->tmbc ); +} + +tmquiet() +{ + while ((TMADDR->tmcs&CRDY) == 0) + ; + while ((TMADDR->tmer&TUR) == 0) + ; + while ((TMADDR->tmer&SDWN) != 0) + ; +} -- 2.20.1