|
|
1.1 root 1: /* ts.c 4.4 81/12/01 */
2:
3: /*
4: * TS11 tape driver
5: */
6:
7: #include "../h/param.h"
8: #include "../h/tsreg.h"
9: #include "../h/inode.h"
10: #include "../h/pte.h"
11: #include "../h/ubareg.h"
12: #include "saio.h"
13: #include "savax.h"
14:
15:
16: u_short tsstd[] = { 0772520 };
17:
18: struct iob ctsbuf;
19:
20: u_short ts_uba; /* Unibus address of ts structure */
21:
22: struct tsdevice *tsaddr = 0;
23:
24: struct ts {
25: struct ts_cmd ts_cmd;
26: struct ts_char ts_char;
27: struct ts_sts ts_sts;
28: } ts;
29:
30: tsopen(io)
31: register struct iob *io;
32: {
33: static struct ts *ts_ubaddr;
34: long i = 0;
35:
36: if (tsaddr == 0)
37: tsaddr = ubamem(io->i_unit, tsstd[0]);
38: tsaddr->tssr = 0;
39: while ((tsaddr->tssr & TS_SSR)==0) {
40: if (++i > 1000000) {
41: printf("ts: not ready\n");
42: return;
43: }
44: }
45: if (tsaddr->tssr&TS_OFL) {
46: printf("ts: offline\n");
47: return;
48: }
49: if (tsaddr->tssr&TS_NBA) {
50: int i;
51:
52: ctsbuf.i_ma = (caddr_t) &ts;
53: ctsbuf.i_cc = sizeof(ts);
54: if (ts_ubaddr == 0)
55: ts_ubaddr = (struct ts *)ubasetup(&ctsbuf, 2);
56: ts_uba = (u_short)((long)ts_ubaddr + (((long)ts_ubaddr>>16)&03));
57: ts.ts_char.char_addr = (int)&ts_ubaddr->ts_sts;
58: ts.ts_char.char_size = sizeof(ts.ts_sts);
59: ts.ts_char.char_mode = TS_ESS;
60: ts.ts_cmd.c_cmd = TS_ACK|TS_SETCHR;
61: i = (int)&ts_ubaddr->ts_char;
62: ts.ts_cmd.c_loba = i;
63: ts.ts_cmd.c_hiba = (i>>16)&3;
64: ts.ts_cmd.c_size = sizeof(ts.ts_char);
65: tsaddr->tsdb = ts_uba;
66: }
67: tsstrategy(io, TS_REW);
68: if (io->i_cc = io->i_boff)
69: tsstrategy(io, TS_SFORWF);
70: }
71:
72: tsclose(io)
73: register struct iob *io;
74: {
75:
76: tsstrategy(io, TS_REW);
77: }
78:
79: tsstrategy(io, func)
80: register struct iob *io;
81: {
82: register int errcnt, info = 0;
83:
84: errcnt = 0;
85: retry:
86: while ((tsaddr->tssr & TS_SSR) == 0)
87: DELAY(100);
88: if (func == TS_REW || func == TS_SFORWF)
89: ts.ts_cmd.c_repcnt = io->i_cc;
90: else {
91: info = ubasetup(io, 1);
92: ts.ts_cmd.c_size = io->i_cc;
93: ts.ts_cmd.c_loba = info;
94: ts.ts_cmd.c_hiba = (info>>16)&3;
95: }
96: if (func == READ)
97: func = TS_RCOM;
98: else if (func == WRITE)
99: func = TS_WCOM;
100: ts.ts_cmd.c_cmd = TS_ACK|TS_CVC|func;
101: tsaddr->tsdb = ts_uba;
102: do
103: DELAY(100)
104: while ((tsaddr->tssr & TS_SSR) == 0);
105: if (info)
106: ubafree(io, info);
107: if (ts.ts_sts.s_xs0 & TS_TMK)
108: return (0);
109: if (tsaddr->tssr & TS_SC) {
110: printf("ts tape error: er=%b, xs0=%b",
111: tsaddr->tssr, TSSR_BITS,
112: ts.ts_sts.s_xs0, TSXS0_BITS);
113: if (errcnt==10) {
114: printf("ts: unrecovered error\n");
115: return (-1);
116: }
117: errcnt++;
118: if (func == TS_RCOM || func == TS_WCOM)
119: func |= TS_RETRY;
120: goto retry;
121: }
122: if (errcnt)
123: printf("ts: recovered by retry\n");
124: return (io->i_cc - ts.ts_sts.s_rbpcr);
125: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.