1: /*
2: * Copyright (c) 1986 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)tm.c 2.3 (2.11BSD) 1997/1/19
7: */
8:
9: /*
10: * TM11 - TU10/TE10/TS03 standalone tape driver
11: */
12:
13: #include "../h/param.h"
14: #include "../pdpuba/tmreg.h"
15: #include "saio.h"
16:
17: #define NTM 2
18:
19: struct tmdevice *TMcsr[NTM + 1] =
20: {
21: (struct tmdevice *)0172520,
22: (struct tmdevice *)0,
23: (struct tmdevice *)-1
24: };
25:
26: extern int tapemark; /* flag to indicate tapemark
27: has been encountered (see sys.c) */
28:
29: /*
30: * Bits in device code.
31: */
32: #define T_NOREWIND 04 /* not used in stand alone driver */
33: #define TMDENS(dev) (((dev) & 030) >> 3)
34:
35: tmclose(io)
36: struct iob *io;
37: {
38: tmstrategy(io, TM_REW);
39: }
40:
41: tmopen(io)
42: register struct iob *io;
43: {
44: register skip;
45:
46: if (genopen(NTM, io) < 0)
47: return(-1);
48: io->i_flgs |= F_TAPE;
49: tmstrategy(io, TM_REW);
50: skip = io->i_part;
51: while (skip--) {
52: io->i_cc = 0;
53: while (tmstrategy(io, TM_SFORW))
54: continue;
55: }
56: return(0);
57: }
58:
59: u_short tmdens[4] = { TM_D800, TM_D1600, TM_D6250, TM_D800 };
60:
61: tmstrategy(io, func)
62: register struct iob *io;
63: {
64: int com, unit = io->i_unit;
65: register struct tmdevice *tmaddr;
66: int errcnt = 0, ctlr = io->i_ctlr, bae, lo16, fnc;
67:
68: tmaddr = TMcsr[ctlr];
69: retry:
70: while ((tmaddr->tmcs&TM_CUR) == 0)
71: continue;
72: while ((tmaddr->tmer&TMER_TUR) == 0)
73: continue;
74: while ((tmaddr->tmer&TMER_SDWN) != 0)
75: continue;
76: iomapadr(io->i_ma, &bae, &lo16);
77: com = (unit<<8)|(bae<<4) | tmdens[TMDENS(unit)];
78: tmaddr->tmbc = -io->i_cc;
79: tmaddr->tmba = (caddr_t)lo16;
80: switch (func)
81: {
82: case READ:
83: fnc = TM_RCOM;
84: break;
85: case WRITE:
86: fnc = TM_WCOM;
87: break;
88: /*
89: * Just pass all others thru - all other functions are TM_* opcodes and
90: * had better be valid.
91: */
92: default:
93: fnc = func;
94: break;
95: }
96: tmaddr->tmcs = com | fnc | TM_GO;
97: while ((tmaddr->tmcs&TM_CUR) == 0)
98: continue;
99: if (tmaddr->tmer&TMER_EOF) {
100: tapemark=1;
101: return(0);
102: }
103: if (tmaddr->tmer & TM_ERR) {
104: if (errcnt == 0)
105: printf("\n%s err: er=%o cs=%o",
106: devname(io), tmaddr->tmer, tmaddr->tmcs);
107: if (errcnt++ == 10) {
108: printf("\n(FATAL ERROR)\n");
109: return(-1);
110: }
111: tmstrategy(io, TM_SREV);
112: goto retry;
113: }
114: return(io->i_cc+tmaddr->tmbc);
115: }
116:
117: tmseek(io, space)
118: register struct iob *io;
119: int space;
120: {
121: int fnc;
122:
123: if (space < 0)
124: {
125: fnc = TM_SREV;
126: space = -space;
127: }
128: else
129: fnc = TM_SFORW;
130: io->i_cc = space;
131: tmstrategy(io, fnc);
132: return(0);
133: }
Defined functions
Defined variables
TMcsr
defined in line
19; used 2 times
Defined macros
NTM
defined in line
17; used 2 times