Commit | Line | Data |
---|---|---|
a7a8eebc | 1 | /* ht.c 4.1 %G% */ |
fbfcdb0a BJ |
2 | |
3 | /* | |
4 | * TJU16 tape driver | |
5 | */ | |
6 | ||
7 | #include "../h/param.h" | |
8 | #include "../h/inode.h" | |
f7acbdcc | 9 | #include "../h/pte.h" |
fbfcdb0a BJ |
10 | #include "../h/mba.h" |
11 | #include "saio.h" | |
12 | ||
13 | struct device | |
14 | { | |
15 | int htcs1; | |
16 | int htds; | |
17 | int hter; | |
18 | int htmr; | |
19 | int htas; | |
20 | int htfc; | |
21 | int htdt; | |
22 | int htck; | |
23 | int htsn; | |
24 | int httc; | |
25 | }; | |
26 | ||
f7acbdcc BJ |
27 | #define HTMBA PHYSMBA1 |
28 | #define HTMBANUM 1 | |
fbfcdb0a BJ |
29 | |
30 | #define GO 01 | |
31 | #define WCOM 060 | |
32 | #define RCOM 070 | |
33 | #define NOP 0 | |
34 | #define WEOF 026 | |
35 | #define SFORW 030 | |
36 | #define SREV 032 | |
37 | #define ERASE 024 | |
38 | #define REW 06 | |
39 | #define DCLR 010 | |
40 | #define P800 01700 /* 800 + pdp11 mode */ | |
41 | #define P1600 02300 /* 1600 + pdp11 mode */ | |
42 | #define IENABLE 0100 | |
43 | #define RDY 0200 | |
44 | #define TM 04 | |
45 | #define DRY 0200 | |
46 | #define EOT 02000 | |
47 | #define CS 02000 | |
48 | #define COR 0100000 | |
49 | #define PES 040 | |
50 | #define WRL 04000 | |
51 | #define MOL 010000 | |
52 | #define ERR 040000 | |
53 | #define FCE 01000 | |
54 | #define TRE 040000 | |
55 | #define HARD 064023 /* UNS|OPI|NEF|FMT|RMR|ILR|ILF */ | |
56 | ||
57 | #define SIO 1 | |
58 | #define SSFOR 2 | |
59 | #define SSREV 3 | |
60 | #define SRETRY 4 | |
61 | #define SCOM 5 | |
62 | #define SOK 6 | |
63 | ||
64 | htopen(io) | |
65 | register struct iob *io; | |
66 | { | |
67 | register skip; | |
68 | int i; | |
69 | ||
f7acbdcc BJ |
70 | if ((mbaact&(1<<HTMBANUM)) == 0) |
71 | mbainit(HTMBANUM); | |
fbfcdb0a BJ |
72 | htinit(); |
73 | htstrategy(io, REW); | |
74 | skip = io->i_boff; | |
75 | while (skip--) { | |
76 | io->i_cc = -1; | |
77 | while (htstrategy(io, SFORW)) | |
78 | ; | |
79 | i = 65536; | |
80 | while (--i) | |
81 | ; | |
82 | htstrategy(io, NOP); | |
83 | } | |
84 | } | |
85 | ||
86 | htclose(io) | |
87 | register struct iob *io; | |
88 | { | |
89 | htstrategy(io, REW); | |
90 | } | |
91 | ||
92 | htstrategy(io, func) | |
93 | register struct iob *io; | |
94 | { | |
95 | register int unit, den, errcnt, ds; | |
96 | short fc; | |
f7acbdcc | 97 | register struct device *htp = mbadev(HTMBA,0); |
fbfcdb0a BJ |
98 | |
99 | unit = io->i_unit; | |
100 | errcnt = 0; | |
101 | retry: | |
102 | if(unit & 1) | |
103 | den = P1600; | |
104 | else | |
105 | den = P800; | |
106 | htquiet(); | |
f7acbdcc BJ |
107 | if((htp->httc&03777) != den) |
108 | htp->httc = den; | |
109 | htp->htfc = -io->i_cc; | |
fbfcdb0a | 110 | if (func == SREV) { |
f7acbdcc BJ |
111 | htp->htfc = -1; |
112 | htp->htcs1 = SREV | GO; | |
fbfcdb0a BJ |
113 | return(0); |
114 | } | |
115 | if (func == READ || func == WRITE) | |
f7acbdcc | 116 | mbastart(io, htp, func); |
fbfcdb0a | 117 | else |
f7acbdcc | 118 | htp->htcs1 = func | GO; |
fbfcdb0a | 119 | htquiet(); |
f7acbdcc | 120 | ds = htp->htds & TM; |
fbfcdb0a BJ |
121 | if (ds&TM) { |
122 | htinit(); | |
123 | return(0); | |
124 | } | |
125 | if (ds&ERR) { | |
126 | if (errcnt == 0) | |
127 | printf("tape error: ds=%x, er=%x, mbasr=%x", | |
f7acbdcc BJ |
128 | htp->htds, htp->hter, |
129 | HTMBA->mba_sr); | |
fbfcdb0a BJ |
130 | htinit(); |
131 | if (errcnt == 10) { | |
132 | printf("\n"); | |
133 | return(-1); | |
134 | } | |
135 | errcnt++; | |
136 | htstrategy(io, SREV); | |
137 | goto retry; | |
138 | } | |
139 | if (errcnt) | |
140 | printf(" recovered by retry\n"); | |
f7acbdcc | 141 | fc = htp->htfc; |
fbfcdb0a BJ |
142 | return(io->i_cc+fc); |
143 | } | |
144 | ||
145 | htinit() | |
146 | { | |
147 | ||
f7acbdcc | 148 | mbadev(HTMBA,0)->htcs1 = DCLR|GO; |
fbfcdb0a BJ |
149 | } |
150 | ||
151 | htquiet() | |
152 | { | |
153 | register int s; | |
f7acbdcc | 154 | register struct device *htp = mbadev(HTMBA,0); |
fbfcdb0a BJ |
155 | |
156 | do | |
f7acbdcc | 157 | s = htp->htds; |
fbfcdb0a BJ |
158 | while ((s & RDY) == 0); |
159 | } |