Commit | Line | Data |
---|---|---|
2e0ec09b | 1 | /* tm.c 4.6 81/12/01 */ |
99fe9747 | 2 | |
32ce6f5e | 3 | /* |
99fe9747 | 4 | * TM11/TE?? |
32ce6f5e BJ |
5 | */ |
6 | ||
7 | #include "../h/param.h" | |
8 | #include "../h/inode.h" | |
9 | #include "../h/pte.h" | |
99fe9747 | 10 | #include "../h/ubareg.h" |
32ce6f5e | 11 | #include "saio.h" |
99fe9747 | 12 | #include "savax.h" |
32ce6f5e | 13 | |
99fe9747 | 14 | #include "../h/tmreg.h" |
32ce6f5e | 15 | |
99fe9747 | 16 | u_short tmstd[] = { 0172520 }; |
32ce6f5e BJ |
17 | |
18 | tmopen(io) | |
327a6aab | 19 | register struct iob *io; |
32ce6f5e BJ |
20 | { |
21 | register skip; | |
22 | ||
99fe9747 | 23 | tmstrategy(io, TM_REW); |
32ce6f5e BJ |
24 | skip = io->i_boff; |
25 | while (skip--) { | |
26 | io->i_cc = 0; | |
78a7384b | 27 | tmstrategy(io, TM_SFORW); |
32ce6f5e BJ |
28 | } |
29 | } | |
30 | ||
31 | tmclose(io) | |
327a6aab | 32 | register struct iob *io; |
32ce6f5e | 33 | { |
327a6aab | 34 | |
99fe9747 | 35 | tmstrategy(io, TM_REW); |
32ce6f5e BJ |
36 | } |
37 | ||
38 | tmstrategy(io, func) | |
327a6aab | 39 | register struct iob *io; |
32ce6f5e BJ |
40 | { |
41 | register int com, unit, errcnt; | |
2e0ec09b BJ |
42 | register struct tmdevice *tmaddr = |
43 | (struct tmdevice *)ubamem(io->i_unit, tmstd[0]); | |
99fe9747 | 44 | int word, info; |
32ce6f5e BJ |
45 | |
46 | unit = io->i_unit; | |
47 | errcnt = 0; | |
48 | retry: | |
99fe9747 BJ |
49 | tmquiet(tmaddr); |
50 | com = (unit<<8); | |
32ce6f5e | 51 | info = ubasetup(io, 1); |
99fe9747 BJ |
52 | tmaddr->tmbc = -io->i_cc; |
53 | tmaddr->tmba = info; | |
32ce6f5e | 54 | if (func == READ) |
99fe9747 | 55 | tmaddr->tmcs = com | TM_RCOM | TM_GO; |
32ce6f5e | 56 | else if (func == WRITE) |
99fe9747 BJ |
57 | tmaddr->tmcs = com | TM_WCOM | TM_GO; |
58 | else if (func == TM_SREV) { | |
59 | tmaddr->tmbc = -1; | |
60 | tmaddr->tmcs = com | TM_SREV | TM_GO; | |
327a6aab | 61 | return (0); |
32ce6f5e | 62 | } else |
99fe9747 | 63 | tmaddr->tmcs = com | func | TM_GO; |
327a6aab | 64 | for (;;) { |
99fe9747 BJ |
65 | word = tmaddr->tmcs; |
66 | if (word&TM_CUR) | |
327a6aab BJ |
67 | break; |
68 | } | |
99fe9747 BJ |
69 | ubafree(io, info); |
70 | word = tmaddr->tmer; | |
71 | if (word&TMER_EOT) | |
32ce6f5e | 72 | return(0); |
327a6aab | 73 | if (word < 0) { |
32ce6f5e | 74 | if (errcnt == 0) |
78a7384b | 75 | printf("te error: er=%b", tmaddr->tmer, TMER_BITS); |
32ce6f5e BJ |
76 | if (errcnt==10) { |
77 | printf("\n"); | |
78 | return(-1); | |
79 | } | |
80 | errcnt++; | |
99fe9747 | 81 | tmstrategy(io, TM_SREV); |
32ce6f5e BJ |
82 | goto retry; |
83 | } | |
84 | if (errcnt) | |
85 | printf(" recovered by retry\n"); | |
99fe9747 | 86 | return (io->i_cc+tmaddr->tmbc); |
32ce6f5e BJ |
87 | } |
88 | ||
99fe9747 | 89 | tmquiet(tmaddr) |
2e0ec09b | 90 | register struct tmdevice *tmaddr; |
32ce6f5e | 91 | { |
327a6aab BJ |
92 | register word; |
93 | for (;;) { | |
99fe9747 BJ |
94 | word = tmaddr->tmcs; |
95 | if (word&TM_CUR) | |
327a6aab BJ |
96 | break; |
97 | } | |
98 | for (;;) { | |
99fe9747 BJ |
99 | word = tmaddr->tmer; |
100 | if ((word&TMER_TUR) && (word&TMER_SDWN)==0) | |
327a6aab BJ |
101 | break; |
102 | } | |
32ce6f5e | 103 | } |