ts.c revision 1.1 1 1.1 ragge /* $NetBSD: ts.c,v 1.1 2001/05/13 15:30:10 ragge Exp $ */
2 1.1 ragge
3 1.1 ragge /*-
4 1.1 ragge * Copyright (c) 1991 The Regents of the University of California.
5 1.1 ragge * All rights reserved.
6 1.1 ragge *
7 1.1 ragge * Redistribution and use in source and binary forms, with or without
8 1.1 ragge * modification, are permitted provided that the following conditions
9 1.1 ragge * are met:
10 1.1 ragge * 1. Redistributions of source code must retain the above copyright
11 1.1 ragge * notice, this list of conditions and the following disclaimer.
12 1.1 ragge * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 ragge * notice, this list of conditions and the following disclaimer in the
14 1.1 ragge * documentation and/or other materials provided with the distribution.
15 1.1 ragge * 3. All advertising materials mentioning features or use of this software
16 1.1 ragge * must display the following acknowledgement:
17 1.1 ragge * This product includes software developed by the University of
18 1.1 ragge * California, Berkeley and its contributors.
19 1.1 ragge * 4. Neither the name of the University nor the names of its contributors
20 1.1 ragge * may be used to endorse or promote products derived from this software
21 1.1 ragge * without specific prior written permission.
22 1.1 ragge *
23 1.1 ragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 ragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 ragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 ragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 ragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 ragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 ragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 ragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 ragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 ragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 ragge * SUCH DAMAGE.
34 1.1 ragge *
35 1.1 ragge * @(#)tmscp.c 7.16 (Berkeley) 5/9/91
36 1.1 ragge */
37 1.1 ragge
38 1.1 ragge /*
39 1.1 ragge * sccsid = "@(#)tmscp.c 1.24 (ULTRIX) 1/21/86";
40 1.1 ragge */
41 1.1 ragge
42 1.1 ragge /************************************************************************
43 1.1 ragge * *
44 1.1 ragge * Licensed from Digital Equipment Corporation *
45 1.1 ragge * Copyright (c) *
46 1.1 ragge * Digital Equipment Corporation *
47 1.1 ragge * Maynard, Massachusetts *
48 1.1 ragge * 1985, 1986 *
49 1.1 ragge * All rights reserved. *
50 1.1 ragge * *
51 1.1 ragge * The Information in this software is subject to change *
52 1.1 ragge * without notice and should not be construed as a commitment *
53 1.1 ragge * by Digital Equipment Corporation. Digital makes no *
54 1.1 ragge * representations about the suitability of this software for *
55 1.1 ragge * any purpose. It is supplied "As Is" without expressed or *
56 1.1 ragge * implied warranty. *
57 1.1 ragge * *
58 1.1 ragge * If the Regents of the University of California or its *
59 1.1 ragge * licensees modify the software in a manner creating *
60 1.1 ragge * derivative copyright rights, appropriate copyright *
61 1.1 ragge * legends may be placed on the derivative work in addition *
62 1.1 ragge * to that set forth above. *
63 1.1 ragge * *
64 1.1 ragge ************************************************************************/
65 1.1 ragge
66 1.1 ragge /*
67 1.1 ragge * TSV05/TS05 device driver, written by Bertram Barth.
68 1.1 ragge *
69 1.1 ragge * should be TS11 compatible (untested)
70 1.1 ragge */
71 1.1 ragge
72 1.1 ragge #define TS11_COMPAT /* don't use extended features provided by TS05 */
73 1.1 ragge
74 1.1 ragge #ifdef NEED_18BIT
75 1.1 ragge #define TS_UBAFLAGS UBA_NEED16
76 1.1 ragge #else
77 1.1 ragge #define TS_UBAFLAGS 0
78 1.1 ragge #endif
79 1.1 ragge
80 1.1 ragge #define ENABLE_ESS
81 1.1 ragge #define ENABLE_END
82 1.1 ragge
83 1.1 ragge #define ENABLE_EAI /* enable Attention-Interrupts */
84 1.1 ragge #undef ENABLE_EAI
85 1.1 ragge
86 1.1 ragge #define ENABLE_ERI /* Enable Release Buffer Interrupts */
87 1.1 ragge #undef ENABLE_ERI
88 1.1 ragge
89 1.1 ragge #ifdef DEBUG
90 1.1 ragge int tsdebug = 1;
91 1.1 ragge # define debug(x) if (tsdebug > 0) {DELAY(2000); printf x; DELAY(3000);}
92 1.1 ragge # define debug10(x) if (tsdebug > 9) printf x
93 1.1 ragge #else
94 1.1 ragge # define debug(x) /* just ignore it */
95 1.1 ragge # define debug10(x) /* just ignore it */
96 1.1 ragge #endif
97 1.1 ragge
98 1.1 ragge #ifdef TRACE
99 1.1 ragge int tstrace = 1;
100 1.1 ragge # define trace(x) if (tstrace > 0) {DELAY(2000); printf x; DELAY(3000);}
101 1.1 ragge #else
102 1.1 ragge # define trace(x) /* just ignore it */
103 1.1 ragge #endif
104 1.1 ragge
105 1.1 ragge /*
106 1.1 ragge * TODO: most :-)
107 1.1 ragge *
108 1.1 ragge * include uba-mapping into tsinit();
109 1.1 ragge * merge tsinit(), tsreset() and tsprobe();
110 1.1 ragge * complete tsintr();
111 1.1 ragge * add proper error/status messages
112 1.1 ragge * make messages appear where they are intended to.
113 1.1 ragge * check for termination-classes and appropriate actions.
114 1.1 ragge * check if flags like CVC and ATTN should be used.
115 1.1 ragge * look for correct handling of attentions.
116 1.1 ragge * check for correct usage of retry-commands.
117 1.1 ragge * ...
118 1.1 ragge */
119 1.1 ragge
120 1.1 ragge
121 1.1 ragge #include <sys/param.h>
122 1.1 ragge #include <sys/systm.h>
123 1.1 ragge #include <sys/kernel.h>
124 1.1 ragge #include <sys/buf.h>
125 1.1 ragge #include <sys/conf.h>
126 1.1 ragge #include <sys/errno.h>
127 1.1 ragge #include <sys/file.h>
128 1.1 ragge #include <sys/map.h>
129 1.1 ragge #include <sys/syslog.h>
130 1.1 ragge #include <sys/ioctl.h>
131 1.1 ragge #include <sys/mtio.h>
132 1.1 ragge #include <sys/uio.h>
133 1.1 ragge #include <sys/proc.h>
134 1.1 ragge
135 1.1 ragge #include <machine/pte.h>
136 1.1 ragge #include <machine/sid.h>
137 1.1 ragge #include <machine/cpu.h>
138 1.1 ragge #include <machine/mtpr.h>
139 1.1 ragge
140 1.1 ragge #include <dev/qbus/ubareg.h>
141 1.1 ragge #include <dev/qbus/ubavar.h>
142 1.1 ragge
143 1.1 ragge #include <vax/uba/tsreg.h>
144 1.1 ragge
145 1.1 ragge #include "opt_vax750.h"
146 1.1 ragge
147 1.1 ragge #include "ts.h"
148 1.1 ragge
149 1.1 ragge /*
150 1.1 ragge * ts command packets and communication area (per controller)
151 1.1 ragge */
152 1.1 ragge struct ts {
153 1.1 ragge struct tsdevice *reg; /* address of i/o-registers */
154 1.1 ragge struct tscmd cmd; /* command packet(s) */
155 1.1 ragge struct tsmsg msg; /* message packet(s) */
156 1.1 ragge } ts[NTS];
157 1.1 ragge
158 1.1 ragge /*
159 1.1 ragge * Software status, per controller.
160 1.1 ragge * also status per tape-unit, since only one unit per controller
161 1.1 ragge * (thus we have no struct ts_info)
162 1.1 ragge */
163 1.1 ragge struct ts_softc {
164 1.1 ragge struct device sc_dev; /* Autoconf ... */
165 1.1 ragge struct uba_unit sc_unit; /* Struct common for UBA to talk */
166 1.1 ragge struct ts *sc_ts; /* Unibus address of uda struct */
167 1.1 ragge short sc_mapped; /* Unibus map allocated ? */
168 1.1 ragge int sc_ubainfo; /* Unibus mapping info */
169 1.1 ragge short sc_state; /* see below: ST_xxx */
170 1.1 ragge short sc_flags; /* see below: FL_xxx */
171 1.1 ragge short sc_lcmd; /* last command word */
172 1.1 ragge short sc_rtc; /* retry count for lcmd */
173 1.1 ragge short sc_lssr; /* last status register */
174 1.1 ragge short sc_lmsgh; /* last message header */
175 1.1 ragge short sc_lxst0; /* last status word */
176 1.1 ragge short sc_cmdf; /* command flags (ack,cvc,ie) */
177 1.1 ragge short sc_openf; /* lock against multiple opens */
178 1.1 ragge short sc_liowf; /* last operation was write */
179 1.1 ragge int sc_micro; /* microcode revision */
180 1.1 ragge int sc_ivec; /* interrupt vector address */
181 1.1 ragge short sc_ipl; /* interrupt priority, Q-bus */
182 1.1 ragge };
183 1.1 ragge
184 1.1 ragge void tsintr __P((int));
185 1.1 ragge int tsinit __P((struct ts_softc *));
186 1.1 ragge void tscommand __P((dev_t, int, int));
187 1.1 ragge int tsstatus __P((int));
188 1.1 ragge int tsexec __P((int, int));
189 1.1 ragge int tsstart __P((struct ts_softc *, struct buf *));
190 1.1 ragge int tswchar __P((int));
191 1.1 ragge void tsreset __P((int));
192 1.1 ragge void tsxstatus __P((struct tsmsg *));
193 1.1 ragge int tsmatch __P((struct device *, void *, void *));
194 1.1 ragge void tsattach __P((struct device *, struct device *, void *));
195 1.1 ragge void tsstrategy __P((struct buf *));
196 1.1 ragge
197 1.1 ragge int tsopen __P((dev_t, int, int, struct proc *));
198 1.1 ragge int tsclose __P((dev_t, int, int, struct proc *));
199 1.1 ragge int tsioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
200 1.1 ragge int tsread __P((dev_t, struct uio *));
201 1.1 ragge int tswrite __P((dev_t, struct uio *));
202 1.1 ragge int tsdump __P((dev_t, daddr_t, caddr_t, size_t));
203 1.1 ragge
204 1.1 ragge struct cfattach ts_ca = {
205 1.1 ragge sizeof(struct ts_softc), tsmatch, tsattach
206 1.1 ragge };
207 1.1 ragge
208 1.1 ragge extern struct cfdriver ts_cd;
209 1.1 ragge
210 1.1 ragge #define ST_INVALID 0 /* uninitialized, before probe */
211 1.1 ragge #define ST_PROBE 1 /* during tsprobe(), not used */
212 1.1 ragge #define ST_SLAVE 2 /* in tsslave(), init almost complete */
213 1.1 ragge #define ST_ATTACH 3 /* during tsattach(), not used */
214 1.1 ragge #define ST_INITIALIZED 4 /* init completed, set by tsintr() */
215 1.1 ragge #define ST_RUNNING 5
216 1.1 ragge #define ST_IDLE 6
217 1.1 ragge #define ST_BUSY 7
218 1.1 ragge
219 1.1 ragge /* Bits in minor device */
220 1.1 ragge #define TS_UNIT(dev) (minor(dev)&03)
221 1.1 ragge #define TS_HIDENSITY 010
222 1.1 ragge
223 1.1 ragge #define TS_PRI LOG_INFO
224 1.1 ragge
225 1.1 ragge
226 1.1 ragge /*
227 1.1 ragge * Since we don't have credits and thus only one operation per time,
228 1.1 ragge * we don't have and don't need queues like MSCP/TMSCP use them.
229 1.1 ragge * Per controller we only need one internal buffer for ioctls and
230 1.1 ragge * two pointers to buffers to simulate similiar behaviour ...
231 1.1 ragge */
232 1.1 ragge struct buf ts_cbuf[NTS]; /* internal cmd buffer (for ioctls) */
233 1.1 ragge struct buf *ts_wtab[NTS]; /* dummy I/O wait queue */
234 1.1 ragge #define b_ubinfo b_resid /* Unibus mapping info, per buffer */
235 1.1 ragge
236 1.1 ragge /*----------------------------------------------------------------------*/
237 1.1 ragge
238 1.1 ragge /*
239 1.1 ragge * Initialize a TS device. Set up UBA mapping registers,
240 1.1 ragge * initialize data structures, what else ???
241 1.1 ragge */
242 1.1 ragge int
243 1.1 ragge tsinit (sc)
244 1.1 ragge struct ts_softc *sc;
245 1.1 ragge {
246 1.1 ragge volatile struct tsdevice *tsregs;
247 1.1 ragge int unit = sc->sc_dev.dv_unit;
248 1.1 ragge struct uba_unit *uu;
249 1.1 ragge
250 1.1 ragge uu = &sc->sc_unit;
251 1.1 ragge tsregs = (struct tsdevice *)ts[unit].reg;
252 1.1 ragge if (sc->sc_mapped == 0) {
253 1.1 ragge /*
254 1.1 ragge * Map the communications area and command and message
255 1.1 ragge * buffer into Unibus address space.
256 1.1 ragge */
257 1.1 ragge sc->sc_ubainfo = uballoc((struct uba_softc *)
258 1.1 ragge sc->sc_dev.dv_parent,
259 1.1 ragge (caddr_t)&ts[unit], sizeof (struct ts), TS_UBAFLAGS);
260 1.1 ragge sc->sc_ts = (struct ts *)(UBAI_ADDR(sc->sc_ubainfo));
261 1.1 ragge sc->sc_mapped = 1;
262 1.1 ragge }
263 1.1 ragge
264 1.1 ragge /*
265 1.1 ragge * bertram: start hardware initialization ??????
266 1.1 ragge */
267 1.1 ragge
268 1.1 ragge /* tsreset(unit); */
269 1.1 ragge
270 1.1 ragge return (1);
271 1.1 ragge }
272 1.1 ragge
273 1.1 ragge /*
274 1.1 ragge * send a command using the default command-buffer for this unit/controller.
275 1.1 ragge * If a command-word is given, then assemble a one-word command.
276 1.1 ragge * other words in command-buffer are unchanged and must thus be initialized
277 1.1 ragge * before calling this function.
278 1.1 ragge */
279 1.1 ragge int
280 1.1 ragge tsexec (ctlr, cmd)
281 1.1 ragge int ctlr;
282 1.1 ragge int cmd;
283 1.1 ragge {
284 1.1 ragge register struct ts_softc *sc = ts_cd.cd_devs[ctlr];
285 1.1 ragge register struct tscmd *tscmdp = &ts[ctlr].cmd;
286 1.1 ragge register long tscmdma = (long)&sc->sc_ts->cmd; /* mapped address */
287 1.1 ragge volatile struct tsdevice *tsreg = ts[ctlr].reg;
288 1.1 ragge volatile char *dbx = ((char*)tsreg) + 3;
289 1.1 ragge volatile short sr;
290 1.1 ragge
291 1.1 ragge sc->sc_cmdf |= TS_CF_ACK | TS_CF_IE;
292 1.1 ragge tscmdp->cmdr = sc->sc_cmdf | cmd;
293 1.1 ragge tscmdp->cmdr = TS_CF_ACK | TS_CF_IE | sc->sc_cmdf | cmd;
294 1.1 ragge sc->sc_cmdf = 0; /* XXX */
295 1.1 ragge
296 1.1 ragge #ifdef DEBUG
297 1.1 ragge switch (tscmdp->cmdr & TS_CF_CMASK) {
298 1.1 ragge case TS_CMD_RNF: cmdName = "Read Next (Forward)"; break;
299 1.1 ragge case TS_CMD_RPR: cmdName = "Read Previous (Reverse)"; break;
300 1.1 ragge case TS_CMD_WCHAR: cmdName = "Write Characteristics"; break;
301 1.1 ragge case TS_CMD_WD: cmdName = "Write Data (Next)"; break;
302 1.1 ragge case TS_CMD_WDR: cmdName = "Write Data (Retry)"; break;
303 1.1 ragge case TS_CMD_SRF: cmdName = "Space Records Forward"; break;
304 1.1 ragge case TS_CMD_SRR: cmdName = "Space Records Reverse"; break;
305 1.1 ragge case TS_CMD_STMF: cmdName = "Skip Tape Marks Forward"; break;
306 1.1 ragge case TS_CMD_STMR: cmdName = "Skip Tape Marks Reverse"; break;
307 1.1 ragge case TS_CMD_RWND: cmdName = "Rewind"; break;
308 1.1 ragge case TS_CMD_WTM: cmdName = "Write Tape Mark"; break;
309 1.1 ragge case TS_CMD_WTMR: cmdName = "Write Tape Mark (Retry)"; break;
310 1.1 ragge case TS_CMD_STAT: cmdName = "Get Status (END)"; break;
311 1.1 ragge default: cmdName = "unexptected Command"; break;
312 1.1 ragge }
313 1.1 ragge #endif
314 1.1 ragge
315 1.1 ragge sr = tsreg->tssr;
316 1.1 ragge if ((sr & TS_SSR) == 0) { /* subsystem NOT ready */
317 1.1 ragge printf ("%s%d: subsystem not ready [%x]\n",
318 1.1 ragge sc->sc_dev.dv_xname, sr);
319 1.1 ragge return (-1);
320 1.1 ragge }
321 1.1 ragge dbx = ((char*)tsreg) + 3; /* dbx is located at the fourth byte */
322 1.1 ragge *dbx = (tscmdma >> 18) & 0x0F; /* load bits 18-21 into dbx */
323 1.1 ragge
324 1.1 ragge /* possible race-condition with ATTN !!! */
325 1.1 ragge
326 1.1 ragge sr = tsreg->tssr;
327 1.1 ragge if ((sr & TS_RMR) != 0) { /* Register modification Refused */
328 1.1 ragge printf ("ts: error writing TSDBX\n");
329 1.1 ragge return (-1);
330 1.1 ragge }
331 1.1 ragge /* now load bits 15-2 at pos 15-2 and bits 17,16 at pos 1,0 of TSDB */
332 1.1 ragge tsreg->tsdb = (tscmdma & 0xfffc) | ((tscmdma >> 16) & 0x03);
333 1.1 ragge
334 1.1 ragge /*
335 1.1 ragge * wait for SSR or RMR to show up
336 1.1 ragge */
337 1.1 ragge sr = tsreg->tssr;
338 1.1 ragge if ((sr & TS_SSR) != 0) { /* something went wrong .. */
339 1.1 ragge if (sr & TS_RMR) {
340 1.1 ragge printf ("ts: error writing TSDB (RMR)\n");
341 1.1 ragge return (-1);
342 1.1 ragge }
343 1.1 ragge if (sr & TS_NXM) {
344 1.1 ragge printf ("ts: error writing TSDB (NXM)\n");
345 1.1 ragge return (-1);
346 1.1 ragge }
347 1.1 ragge printf ("ts: error 0x%x while writing TSDB\n", sr);
348 1.1 ragge tsstatus (sr);
349 1.1 ragge return (-1);
350 1.1 ragge }
351 1.1 ragge
352 1.1 ragge return (0); /* completed successfully */
353 1.1 ragge }
354 1.1 ragge
355 1.1 ragge /*
356 1.1 ragge * Execute a (ioctl) command on the tape drive a specified number of times.
357 1.1 ragge * This routine sets up a buffer and calls the strategy routine which
358 1.1 ragge * issues the command to the controller.
359 1.1 ragge */
360 1.1 ragge void
361 1.1 ragge tscommand (dev, cmd, count)
362 1.1 ragge register dev_t dev;
363 1.1 ragge int cmd;
364 1.1 ragge int count;
365 1.1 ragge {
366 1.1 ragge register struct buf *bp;
367 1.1 ragge register int s;
368 1.1 ragge
369 1.1 ragge trace (("tscommand (%d, %x, %d)\n", TS_UNIT(dev), cmd, count));
370 1.1 ragge
371 1.1 ragge s = splbio();
372 1.1 ragge bp = &ts_cbuf[TS_UNIT(dev)];
373 1.1 ragge
374 1.1 ragge while (bp->b_flags & B_BUSY) {
375 1.1 ragge /*
376 1.1 ragge * This special check is because B_BUSY never
377 1.1 ragge * gets cleared in the non-waiting rewind case. ???
378 1.1 ragge */
379 1.1 ragge if (bp->b_bcount == 0 && (bp->b_flags & B_DONE))
380 1.1 ragge break;
381 1.1 ragge bp->b_flags |= B_WANTED;
382 1.1 ragge (void) tsleep(bp, PRIBIO, "tscmd", 0);
383 1.1 ragge /* check MOT-flag !!! */
384 1.1 ragge }
385 1.1 ragge bp->b_flags = B_BUSY | B_READ;
386 1.1 ragge
387 1.1 ragge splx(s);
388 1.1 ragge
389 1.1 ragge /*
390 1.1 ragge * Load the buffer. The b_count field gets used to hold the command
391 1.1 ragge * count. the b_resid field gets used to hold the command mneumonic.
392 1.1 ragge * These 2 fields are "known" to be "safe" to use for this purpose.
393 1.1 ragge * (Most other drivers also use these fields in this way.)
394 1.1 ragge */
395 1.1 ragge bp->b_dev = dev;
396 1.1 ragge bp->b_bcount = count;
397 1.1 ragge bp->b_resid = cmd;
398 1.1 ragge bp->b_blkno = 0;
399 1.1 ragge tsstrategy (bp);
400 1.1 ragge /*
401 1.1 ragge * In case of rewind from close, don't wait.
402 1.1 ragge * This is the only case where count can be 0.
403 1.1 ragge */
404 1.1 ragge if (count == 0) {
405 1.1 ragge debug (("tscommand: direct return, no biowait.\n"));
406 1.1 ragge return;
407 1.1 ragge }
408 1.1 ragge debug (("tscommand: calling biowait ...\n"));;
409 1.1 ragge biowait (bp);
410 1.1 ragge if (bp->b_flags & B_WANTED)
411 1.1 ragge wakeup ((caddr_t)bp);
412 1.1 ragge bp->b_flags &= B_ERROR;
413 1.1 ragge }
414 1.1 ragge
415 1.1 ragge /*
416 1.1 ragge * Start an I/O operation on TS05 controller
417 1.1 ragge */
418 1.1 ragge int
419 1.1 ragge tsstart (sc, bp)
420 1.1 ragge register struct ts_softc *sc;
421 1.1 ragge register struct buf *bp;
422 1.1 ragge {
423 1.1 ragge int ctlr = sc->sc_dev.dv_unit;
424 1.1 ragge volatile struct tsdevice *tsreg = ts[ctlr].reg;
425 1.1 ragge register struct tscmd *tscmdp = &ts[ctlr].cmd;
426 1.1 ragge register struct buf *dp;
427 1.1 ragge volatile int i, itmp;
428 1.1 ragge int ioctl;
429 1.1 ragge int cmd;
430 1.1 ragge
431 1.1 ragge if ((dp = ts_wtab[ctlr]) != NULL) {
432 1.1 ragge /*
433 1.1 ragge * There's already a command pending ...
434 1.1 ragge * Either we are called by tsintr or we have missed
435 1.1 ragge * something important (race condition).
436 1.1 ragge */
437 1.1 ragge
438 1.1 ragge /* bertram: ubarelse ??? */
439 1.1 ragge ts_wtab[ctlr] = NULL;
440 1.1 ragge dp->b_flags |= B_ERROR;
441 1.1 ragge biodone (dp);
442 1.1 ragge
443 1.1 ragge if (tsreg->tssr & TS_SC) { /* Special Condition; Error */
444 1.1 ragge log (TS_PRI, "%s: tssr 0x%x, state %d\n",
445 1.1 ragge sc->sc_dev.dv_xname, tsreg->tssr, sc->sc_state);
446 1.1 ragge tsinit (sc);
447 1.1 ragge return (-1);
448 1.1 ragge }
449 1.1 ragge /* XXX */
450 1.1 ragge }
451 1.1 ragge
452 1.1 ragge /*
453 1.1 ragge * Check if command is an ioctl or not (ie. read or write).
454 1.1 ragge * If it's an ioctl then just set the flags for later use;
455 1.1 ragge * For other commands attempt to setup a buffer pointer.
456 1.1 ragge */
457 1.1 ragge if (bp == &ts_cbuf[ctlr]) {
458 1.1 ragge ioctl = 1;
459 1.1 ragge } else {
460 1.1 ragge ioctl = 0;
461 1.1 ragge
462 1.1 ragge /*
463 1.1 ragge * now we try to map the buffer into uba map space (???)
464 1.1 ragge */
465 1.1 ragge i = TS_UBAFLAGS;
466 1.1 ragge switch (vax_cputype) {
467 1.1 ragge case VAX_8600:
468 1.1 ragge case VAX_780:
469 1.1 ragge i |= UBA_CANTWAIT;
470 1.1 ragge break;
471 1.1 ragge case VAX_750:
472 1.1 ragge i |= sc->sc_unit.uu_ubinfo | UBA_CANTWAIT;
473 1.1 ragge break;
474 1.1 ragge case VAX_730:
475 1.1 ragge case VAX_78032:
476 1.1 ragge i |= UBA_CANTWAIT;
477 1.1 ragge break;
478 1.1 ragge default:
479 1.1 ragge printf ("unsupported cpu %d in tsstart.\n", vax_cputype);
480 1.1 ragge } /* end switch (vax_cputype) */
481 1.1 ragge
482 1.1 ragge if ((i = ubasetup(sc->sc_dev.dv_parent->dv_unit, bp, i)) == 0) {
483 1.1 ragge /*
484 1.1 ragge * For some reasons which I don't (yet? :) understand,
485 1.1 ragge * tmscp.c initiates in this situation a GET-UNIT
486 1.1 ragge * command. (Because no data-buffers are neccess. ??)
487 1.1 ragge */
488 1.1 ragge cmd = TS_CMD_STAT;
489 1.1 ragge goto do_cmd;
490 1.1 ragge return (-1); /* ??? */
491 1.1 ragge }
492 1.1 ragge #if VAX750
493 1.1 ragge if (vax_cputype == VAX_750)
494 1.1 ragge itmp = i & 0xfffffff; /* mask off bdp */
495 1.1 ragge else
496 1.1 ragge #endif
497 1.1 ragge itmp = i;
498 1.1 ragge
499 1.1 ragge /* XXX */
500 1.1 ragge }
501 1.1 ragge
502 1.1 ragge /*
503 1.1 ragge * If it's an ioctl command, then assemble the command.
504 1.1 ragge * The "b_resid" field holds the command-number as defined
505 1.1 ragge * in <sys/mtio.h>
506 1.1 ragge */
507 1.1 ragge if (ioctl) {
508 1.1 ragge switch ((int)bp->b_resid) {
509 1.1 ragge case MTWEOF:
510 1.1 ragge cmd = TS_CMD_WTM;
511 1.1 ragge break;
512 1.1 ragge case MTFSF:
513 1.1 ragge cmd = TS_CMD_STMF;
514 1.1 ragge tscmdp->cw1 = bp->b_bcount;
515 1.1 ragge break;
516 1.1 ragge case MTBSF:
517 1.1 ragge cmd = TS_CMD_STMR;
518 1.1 ragge tscmdp->cw1 = bp->b_bcount;
519 1.1 ragge break;
520 1.1 ragge case MTFSR:
521 1.1 ragge cmd = TS_CMD_SRF;
522 1.1 ragge tscmdp->cw1 = bp->b_bcount;
523 1.1 ragge break;
524 1.1 ragge case MTBSR:
525 1.1 ragge cmd = TS_CMD_SRR;
526 1.1 ragge tscmdp->cw1 = bp->b_bcount;
527 1.1 ragge break;
528 1.1 ragge case MTREW:
529 1.1 ragge cmd = TS_CMD_RWND;
530 1.1 ragge #ifndef TS11_COMPAT
531 1.1 ragge if (bp->b_bcount == 0) {
532 1.1 ragge cmd = TS_CMD_RWII;
533 1.1 ragge }
534 1.1 ragge #endif
535 1.1 ragge break;
536 1.1 ragge case MTOFFL:
537 1.1 ragge cmd = TS_CMD_RWUL;
538 1.1 ragge break;
539 1.1 ragge case MTNOP:
540 1.1 ragge cmd = TS_CMD_STAT;
541 1.1 ragge break;
542 1.1 ragge default:
543 1.1 ragge printf ("%s: bad ioctl %d\n", sc->sc_dev.dv_xname,
544 1.1 ragge (int)bp->b_resid);
545 1.1 ragge /* Need a no-op. get status */
546 1.1 ragge cmd = TS_CMD_STAT;
547 1.1 ragge } /* end switch (bp->b_resid) */
548 1.1 ragge } else { /* Its a read/write command (not an ioctl) */
549 1.1 ragge tscmdp->cw1 = UBAI_ADDR(i) & 0xffff;
550 1.1 ragge tscmdp->cw2 = (UBAI_ADDR(i) >> 16) & 0x3f;
551 1.1 ragge tscmdp->cw3 = bp->b_bcount;
552 1.1 ragge
553 1.1 ragge if (bp->b_flags & B_READ) {
554 1.1 ragge cmd = TS_CMD_RNF;
555 1.1 ragge }
556 1.1 ragge else {
557 1.1 ragge cmd = TS_CMD_WD;
558 1.1 ragge }
559 1.1 ragge bp->b_ubinfo = itmp; /* save mapping info */
560 1.1 ragge }
561 1.1 ragge
562 1.1 ragge /*
563 1.1 ragge * Move buffer to I/O wait pseudo-queue
564 1.1 ragge */
565 1.1 ragge if (ts_wtab[ctlr]) {
566 1.1 ragge /*
567 1.1 ragge * we are already waiting for something ...
568 1.1 ragge * this should not happen, so we have a problem now.
569 1.1 ragge * bertram: set error-flag and call biodone() ???
570 1.1 ragge */
571 1.1 ragge }
572 1.1 ragge ts_wtab[ctlr] = bp;
573 1.1 ragge
574 1.1 ragge /*
575 1.1 ragge * Now that the command-buffer is setup, give it to the controller
576 1.1 ragge */
577 1.1 ragge do_cmd:
578 1.1 ragge return (tsexec(ctlr, cmd));
579 1.1 ragge }
580 1.1 ragge
581 1.1 ragge /*
582 1.1 ragge * initialize the controller by sending WRITE CHARACTERISTICS command.
583 1.1 ragge * contents of command- and message-buffer are assembled during this
584 1.1 ragge * function.
585 1.1 ragge */
586 1.1 ragge int
587 1.1 ragge tswchar (ctlr)
588 1.1 ragge int ctlr;
589 1.1 ragge {
590 1.1 ragge struct ts_softc *sc = ts_cd.cd_devs[ctlr];
591 1.1 ragge volatile struct tsdevice *tsregs = ts[ctlr].reg;
592 1.1 ragge volatile struct tscmd *tscmdp = &ts[ctlr].cmd;
593 1.1 ragge volatile struct tsmsg *tsmsgp = &ts[ctlr].msg;
594 1.1 ragge volatile unsigned int sr, ma, timeout;
595 1.1 ragge
596 1.1 ragge /*
597 1.1 ragge * assemble and send "WRITE CHARACTERISTICS" command
598 1.1 ragge */
599 1.1 ragge ma = (long)tsmsgp;
600 1.1 ragge if (ma & 0x7FC00001) { /* address must be even and 22-bit */
601 1.1 ragge printf ("invalid address 0x%0x for msg-buffer.\n", ma);
602 1.1 ragge return (-1);
603 1.1 ragge }
604 1.1 ragge
605 1.1 ragge tsmsgp->hdr = ma & 0xFFFF; /* low order addr. bits */
606 1.1 ragge tsmsgp->dfl = (ma >> 16) & 0x003F; /* high order addr. bits */
607 1.1 ragge tsmsgp->rbpcr = 16; /* size of message-buffer */
608 1.1 ragge tsmsgp->xst0 = 0; /* chacacteristics mode word */
609 1.1 ragge tsmsgp->xst1 = 0; /* control word (ext.feat.) */
610 1.1 ragge
611 1.1 ragge #ifdef TS11_COMPAT
612 1.1 ragge tsmsgp->rbpcr = 14; /* size of message-buffer */
613 1.1 ragge tsmsgp->xst0 = 0; /* chacacteristics mode word */
614 1.1 ragge tsmsgp->xst1 = 0; /* control word (ext.feat.) */
615 1.1 ragge #else
616 1.1 ragge tsmsgp->rbpcr = 16; /* size of extended message buffer */
617 1.1 ragge tsmsgp->xst0 = 0; /* chacacteristics mode word */
618 1.1 ragge tsmsgp->xst1 = 0; /* unit-select */
619 1.1 ragge tsmsgp->xst1 |= TS_WC_HSP; /* high speed */
620 1.1 ragge #endif
621 1.1 ragge
622 1.1 ragge #ifdef ENABLE_ESS
623 1.1 ragge tsmsgp->xst0 |= TS_WC_ESS;
624 1.1 ragge #ifdef ENABLE_ENB
625 1.1 ragge tsmsgp->xst0 |= TS_WC_ENB;
626 1.1 ragge #endif
627 1.1 ragge #endif
628 1.1 ragge
629 1.1 ragge #ifdef ENABLE_EAI
630 1.1 ragge tsmsgp->xst0 |= TS_WC_EAI;
631 1.1 ragge #ifdef ENABLE_ERI
632 1.1 ragge tsmsgp->xst0 |= TS_WC_ERI;
633 1.1 ragge #endif
634 1.1 ragge #endif
635 1.1 ragge
636 1.1 ragge tscmdp->cmdr = TS_CF_ACK | TS_CF_IE | TS_CMD_WCHAR; /* obsolete */
637 1.1 ragge tscmdp->cw1 = ma & 0xFFFF;
638 1.1 ragge tscmdp->cw2 = (ma >> 16) & 0x003F;
639 1.1 ragge tscmdp->cw3 = 10; /* size of charact.-data */
640 1.1 ragge
641 1.1 ragge if (tsexec (ctlr, TS_CMD_WCHAR) < 0) {
642 1.1 ragge printf ("%s: write characteristics command failed [%x]\n",
643 1.1 ragge sc->sc_dev.dv_xname, tsregs->tssr);
644 1.1 ragge return (-1);
645 1.1 ragge }
646 1.1 ragge
647 1.1 ragge timeout = 1000; /* timeout in 10 seconds */
648 1.1 ragge do {
649 1.1 ragge DELAY(10000);
650 1.1 ragge sr = tsregs->tssr;
651 1.1 ragge debug10 (("\ttssr: 0x%x\n", sr));
652 1.1 ragge if (timeout-- > 0) {
653 1.1 ragge printf ("timeout during initialize.");
654 1.1 ragge tsstatus (sr);
655 1.1 ragge return (-1);
656 1.1 ragge }
657 1.1 ragge } while ((sr & TS_SSR) == 0);
658 1.1 ragge tsstatus (sr);
659 1.1 ragge
660 1.1 ragge return (0);
661 1.1 ragge }
662 1.1 ragge
663 1.1 ragge /*
664 1.1 ragge *
665 1.1 ragge */
666 1.1 ragge void
667 1.1 ragge tsreset(ctlr)
668 1.1 ragge int ctlr;
669 1.1 ragge {
670 1.1 ragge struct ts_softc *sc = ts_cd.cd_devs[ctlr];
671 1.1 ragge volatile struct tsdevice *tsreg = ts[ctlr].reg;
672 1.1 ragge volatile unsigned int sr, timeout;
673 1.1 ragge
674 1.1 ragge /*
675 1.1 ragge * reset ctlr by writing into TSSR, then write characteristics
676 1.1 ragge */
677 1.1 ragge timeout = 1000; /* timeout in 10 seconds */
678 1.1 ragge tsreg->tssr = 0; /* start initialization */
679 1.1 ragge do {
680 1.1 ragge DELAY(10000);
681 1.1 ragge sr = tsreg->tssr;
682 1.1 ragge debug10 (("\ttssr: 0x%x\n", sr));
683 1.1 ragge if (timeout-- > 0) {
684 1.1 ragge if (sr != 0)
685 1.1 ragge printf ("%s: timeout waiting for TS_SSR\n",
686 1.1 ragge sc->sc_dev.dv_xname);
687 1.1 ragge tsstatus (sr);
688 1.1 ragge return;
689 1.1 ragge }
690 1.1 ragge } while ((sr & TS_SSR) == 0); /* wait until subsystem ready */
691 1.1 ragge tsstatus (sr);
692 1.1 ragge
693 1.1 ragge return;
694 1.1 ragge }
695 1.1 ragge
696 1.1 ragge /*
697 1.1 ragge * probe for device. If found, try to raise an interrupt.
698 1.1 ragge * XXX - most of this should be done in the attach routine.
699 1.1 ragge */
700 1.1 ragge int
701 1.1 ragge tsmatch(parent, match, aux)
702 1.1 ragge struct device *parent;
703 1.1 ragge void *match, *aux;
704 1.1 ragge {
705 1.1 ragge struct ts_softc *sc = match;
706 1.1 ragge struct uba_softc *uh = (void *)parent;
707 1.1 ragge struct uba_attach_args *ua = aux;
708 1.1 ragge struct tsdevice *tsregs = (struct tsdevice*)ua->ua_addr;
709 1.1 ragge volatile unsigned int sr, timeout, count;
710 1.1 ragge int ctlr = sc->sc_dev.dv_unit;
711 1.1 ragge
712 1.1 ragge ts_wtab[ctlr] = NULL;
713 1.1 ragge sc->sc_ts = &ts[ctlr];
714 1.1 ragge sc->sc_state = ST_PROBE;
715 1.1 ragge sc->sc_flags = 0;
716 1.1 ragge ts[ctlr].reg = (struct tsdevice*)ua->ua_addr;
717 1.1 ragge
718 1.1 ragge /*
719 1.1 ragge * Set host-settable interrupt vector.
720 1.1 ragge * Assign 0 to the TSSR register to start the ts-device initialization.
721 1.1 ragge * The device is not really initialized at this point, this is just to
722 1.1 ragge * find out if the device exists.
723 1.1 ragge */
724 1.1 ragge sc->sc_ivec = (uh->uh_lastiv -= 4);
725 1.1 ragge
726 1.1 ragge count = 0;
727 1.1 ragge again:
728 1.1 ragge timeout = 1000; /* timeout in 10 seconds */
729 1.1 ragge tsregs->tssr = 0; /* start initialization */
730 1.1 ragge do {
731 1.1 ragge DELAY(10000);
732 1.1 ragge sr = tsregs->tssr;
733 1.1 ragge debug10 (("\ttssr-1: 0x%x\n", sr));
734 1.1 ragge if (timeout-- > 0) {
735 1.1 ragge if (sr != 0) /* the device exists !!! */
736 1.1 ragge printf ("%s: timeout waiting for TS_SSR\n",
737 1.1 ragge sc->sc_dev.dv_xname);
738 1.1 ragge tsstatus (sr);
739 1.1 ragge goto bad;
740 1.1 ragge }
741 1.1 ragge } while ((sr & TS_SSR) == 0); /* wait until subsystem ready */
742 1.1 ragge tsstatus (sr);
743 1.1 ragge
744 1.1 ragge tswchar (ctlr); /* write charact. to enable interrupts */
745 1.1 ragge /* completion of this will raise the intr. */
746 1.1 ragge
747 1.1 ragge #ifdef notyet
748 1.1 ragge sc->sc_ipl = br = qbgetpri();
749 1.1 ragge #else
750 1.1 ragge sc->sc_ipl = 0x15;
751 1.1 ragge #endif
752 1.1 ragge return (sizeof (struct tsdevice));
753 1.1 ragge
754 1.1 ragge bad: if (++count < 3)
755 1.1 ragge goto again;
756 1.1 ragge
757 1.1 ragge #ifdef notyet
758 1.1 ragge splx(s);
759 1.1 ragge #endif
760 1.1 ragge return (0);
761 1.1 ragge }
762 1.1 ragge
763 1.1 ragge
764 1.1 ragge /*
765 1.1 ragge * Try to find a slave (a drive) on the controller.
766 1.1 ragge * Since there's only one drive per controller there's nothing to do.
767 1.1 ragge * (we could check the status of the drive (online/offline/...)
768 1.1 ragge */
769 1.1 ragge void
770 1.1 ragge tsattach(parent, self, aux)
771 1.1 ragge struct device *parent, *self;
772 1.1 ragge void *aux;
773 1.1 ragge {
774 1.1 ragge struct ts_softc *sc = (void *)self;
775 1.1 ragge int ctlr = sc->sc_dev.dv_unit;
776 1.1 ragge struct tsmsg *tsmsgp = &ts[ctlr].msg;
777 1.1 ragge
778 1.1 ragge trace (("tsslave (%x, %x)\n", ui, reg));
779 1.1 ragge
780 1.1 ragge /*
781 1.1 ragge * write the characteristics (again)
782 1.1 ragge * This will raise an interrupt during ST_SLAVE which indicates
783 1.1 ragge * completion of initialization ...
784 1.1 ragge */
785 1.1 ragge sc->sc_state = ST_SLAVE; /* tsintr() checks this ... */
786 1.1 ragge if (tswchar (ctlr) < 0) {
787 1.1 ragge printf ("%s: cannot initialize", sc->sc_dev.dv_xname);
788 1.1 ragge }
789 1.1 ragge sc->sc_micro = (tsmsgp->xst2 & TS_SF_MCRL) >> 2;
790 1.1 ragge printf ("%s: rev %d, extended features %s, transport %s\n",
791 1.1 ragge sc->sc_dev.dv_xname, sc->sc_micro,
792 1.1 ragge (tsmsgp->xst2 & TS_SF_EFES ? "enabled" : "disabled"),
793 1.1 ragge (ts[ctlr].reg->tssr & TS_OFL ? "offline" : "online"));
794 1.1 ragge
795 1.1 ragge tsinit (sc); /* must be called once, why not here ? */
796 1.1 ragge }
797 1.1 ragge
798 1.1 ragge
799 1.1 ragge /*
800 1.1 ragge * TSV05/TS05 interrupt routine
801 1.1 ragge */
802 1.1 ragge void
803 1.1 ragge tsintr(ctlr)
804 1.1 ragge int ctlr;
805 1.1 ragge {
806 1.1 ragge register struct ts_softc *sc = ts_cd.cd_devs[ctlr];
807 1.1 ragge register struct tsmsg *tsmsgp = &ts[ctlr].msg;
808 1.1 ragge register struct tscmd *tscmdp = &ts[ctlr].cmd;
809 1.1 ragge volatile struct tsdevice *tsreg = ts[ctlr].reg;
810 1.1 ragge struct uba_unit *um = &sc->sc_unit;
811 1.1 ragge register struct buf *bp;
812 1.1 ragge
813 1.1 ragge unsigned short sr = tsreg->tssr; /* save TSSR */
814 1.1 ragge unsigned short mh = tsmsgp->hdr; /* and msg-header */
815 1.1 ragge /* clear the message header ??? */
816 1.1 ragge
817 1.1 ragge short ccode = tscmdp->cmdr & TS_CF_CCODE;
818 1.1 ragge short cmask = tscmdp->cmdr & TS_CF_CMASK;
819 1.1 ragge
820 1.1 ragge #ifdef DEBUG
821 1.1 ragge {
822 1.1 ragge char bits[64];
823 1.1 ragge printf ("TSSR: %s, MSG: %x ", bitmask_snprintf(sr,
824 1.1 ragge TS_TSSR_BITS, bits, sizeof(bits)), mh);
825 1.1 ragge }
826 1.1 ragge switch (tsmsgp->hdr & 0x001F) {
827 1.1 ragge case 16: printf ("(End)"); break;
828 1.1 ragge case 17: printf ("(Fail)"); break;
829 1.1 ragge case 18: printf ("(Error)"); break;
830 1.1 ragge case 19: printf ("(Attention)"); break;
831 1.1 ragge }
832 1.1 ragge #endif
833 1.1 ragge
834 1.1 ragge trace ((" tsintr (%d, %d, %d, %x)\n", uba, vector, level, ctlr));
835 1.1 ragge
836 1.1 ragge if (tsmsgp->xst0 & TS_SF_VCK)
837 1.1 ragge sc->sc_cmdf |= TS_CF_CVC;
838 1.1 ragge
839 1.1 ragge #ifdef QBA /* copied from uda.c */
840 1.1 ragge if(vax_cputype == VAX_78032)
841 1.1 ragge splx(sc->sc_ipl); /* Qbus interrupt protocol is odd */
842 1.1 ragge #endif
843 1.1 ragge
844 1.1 ragge /*
845 1.1 ragge * There are two different things which can (and should) be checked:
846 1.1 ragge * the actual (internal) state and the device's result (tssr/msg.hdr)
847 1.1 ragge *
848 1.1 ragge * For each state there's only one "normal" interrupt. Anything else
849 1.1 ragge * has to be checked more intensively. Thus in a first run according
850 1.1 ragge * to the internal state the expected interrupt is checked/handled.
851 1.1 ragge *
852 1.1 ragge * In a second run the remaining (not yet handled) interrupts are
853 1.1 ragge * checked according to the drive's result.
854 1.1 ragge */
855 1.1 ragge switch (sc->sc_state) {
856 1.1 ragge
857 1.1 ragge case ST_INVALID:
858 1.1 ragge /*
859 1.1 ragge * Ignore unsolicited interrupts.
860 1.1 ragge */
861 1.1 ragge log (LOG_WARNING, "%s: stray intr [%x,%x]\n",
862 1.1 ragge sc->sc_dev.dv_xname, sr, mh);
863 1.1 ragge return;
864 1.1 ragge
865 1.1 ragge case ST_SLAVE:
866 1.1 ragge /*
867 1.1 ragge * this interrupt was caused by write-charact. command
868 1.1 ragge * issued by tsslave() and indicates the end of the
869 1.1 ragge * initialization phase. Just ignore it ...
870 1.1 ragge */
871 1.1 ragge if ((sr & TS_SC) != 0 || (sr & TS_TC) != TS_TC_NORM) {
872 1.1 ragge printf("%s: problem during init [%x,%x]\n",
873 1.1 ragge sc->sc_dev.dv_xname, sr, mh);
874 1.1 ragge /* return here ??? */
875 1.1 ragge /* break and check the error outside switch ??? */
876 1.1 ragge break;
877 1.1 ragge }
878 1.1 ragge sc->sc_state = ST_RUNNING;
879 1.1 ragge return;
880 1.1 ragge
881 1.1 ragge
882 1.1 ragge case ST_RUNNING:
883 1.1 ragge /*
884 1.1 ragge * Here we expect interrupts indicating the end of
885 1.1 ragge * commands or indicating problems.
886 1.1 ragge */
887 1.1 ragge /*
888 1.1 ragge * Anything else is handled outside this switch ...
889 1.1 ragge */
890 1.1 ragge break;
891 1.1 ragge
892 1.1 ragge case ST_IDLE:
893 1.1 ragge break;
894 1.1 ragge
895 1.1 ragge
896 1.1 ragge default:
897 1.1 ragge printf ("%s: unexpected interrupt during state %d [%x,%x]\n",
898 1.1 ragge sc->sc_dev.dv_xname, sc->sc_state, sr, mh);
899 1.1 ragge return;
900 1.1 ragge }
901 1.1 ragge
902 1.1 ragge /*
903 1.1 ragge * now we check the termination class.
904 1.1 ragge */
905 1.1 ragge switch (sr & TS_TC) {
906 1.1 ragge
907 1.1 ragge case TS_TC_NORM:
908 1.1 ragge /*
909 1.1 ragge * Normal termination -- The operation is completed
910 1.1 ragge * witout incident.
911 1.1 ragge */
912 1.1 ragge sc->sc_state = ST_IDLE; /* XXX ??? */
913 1.1 ragge sc->sc_state = ST_RUNNING;
914 1.1 ragge sc->sc_liowf = (ccode == TS_CC_WRITE);
915 1.1 ragge sc->sc_rtc = 0;
916 1.1 ragge if ((bp = ts_wtab[ctlr]) != NULL) {
917 1.1 ragge ts_wtab[ctlr] = NULL; /* pseudo-unlink */
918 1.1 ragge
919 1.1 ragge if (bp != &ts_cbuf[ctlr]) { /* no ioctl */
920 1.1 ragge ubarelse((struct uba_softc *)
921 1.1 ragge sc->sc_dev.dv_parent,
922 1.1 ragge (int *)&bp->b_ubinfo);
923 1.1 ragge #if VAX750
924 1.1 ragge if (vax_cputype == VAX_750 &&
925 1.1 ragge sc->sc_unit.uu_ubinfo != 0)
926 1.1 ragge ubarelse((struct uba_softc *)
927 1.1 ragge sc->sc_dev.dv_parent,
928 1.1 ragge &sc->sc_unit.uu_ubinfo);
929 1.1 ragge /* XXX */
930 1.1 ragge #endif
931 1.1 ragge }
932 1.1 ragge bp->b_resid = tsmsgp->rbpcr;
933 1.1 ragge debug (("tsintr: biodone(NORM) [%d,%d,%d]\n",
934 1.1 ragge bp->b_resid, bp->b_bcount, tsmsgp->rbpcr));
935 1.1 ragge biodone (bp); /* bertram: ioctl ??? */
936 1.1 ragge }
937 1.1 ragge return;
938 1.1 ragge
939 1.1 ragge case TS_TC_ATTN:
940 1.1 ragge /*
941 1.1 ragge * Attention condition -- this code indicates that the
942 1.1 ragge * drive has undergone a status change, such as going
943 1.1 ragge * off-line or coming on-line.
944 1.1 ragge * (Without EAI enabled, no Attention interrupts occur.
945 1.1 ragge * drive status changes are signaled by the VCK flag.)
946 1.1 ragge */
947 1.1 ragge return;
948 1.1 ragge
949 1.1 ragge case TS_TC_TSA:
950 1.1 ragge /*
951 1.1 ragge * Tape Status Alert -- A status condition is encountered
952 1.1 ragge * that may have significance to the program. Bits of
953 1.1 ragge * interest in the extended status registers include
954 1.1 ragge * TMK, EOT and RLL.
955 1.1 ragge */
956 1.1 ragge debug (("Tape Status Alert\n"));
957 1.1 ragge tsxstatus (tsmsgp);
958 1.1 ragge if (tsmsgp->xst0 & TS_SF_TMK) {
959 1.1 ragge debug (("Tape Mark detected"));
960 1.1 ragge }
961 1.1 ragge if (tsmsgp->xst0 & TS_SF_EOT) {
962 1.1 ragge debug (("End of Tape"));
963 1.1 ragge }
964 1.1 ragge break;
965 1.1 ragge
966 1.1 ragge case TS_TC_FR:
967 1.1 ragge /*
968 1.1 ragge * Function Reject -- The specified function was not
969 1.1 ragge * initiated. Bits of interest include OFL, VCK, BOT,
970 1.1 ragge * WLE, ILC and ILA.
971 1.1 ragge */
972 1.1 ragge debug (("Function reject\n"));
973 1.1 ragge tsxstatus (tsmsgp);
974 1.1 ragge if (sr & TS_OFL) {
975 1.1 ragge printf ("tape is off-line.\n");
976 1.1 ragge break;
977 1.1 ragge }
978 1.1 ragge if (tsmsgp->xst0 & TS_SF_VCK) {
979 1.1 ragge printf ("Volume check: repeating command ...\n");
980 1.1 ragge tsexec (ctlr, tscmdp->cmdr);
981 1.1 ragge return;
982 1.1 ragge }
983 1.1 ragge if (tsmsgp->xst0 & TS_SF_BOT) {
984 1.1 ragge printf ("bottom of tape.\n");
985 1.1 ragge }
986 1.1 ragge if (tsmsgp->xst0 & TS_SF_WLE) {
987 1.1 ragge printf ("Write Lock Error\n");
988 1.1 ragge }
989 1.1 ragge break;
990 1.1 ragge
991 1.1 ragge case TS_TC_TPD:
992 1.1 ragge /*
993 1.1 ragge * Recoverable Error -- Tape position is a record beyond
994 1.1 ragge * what its position was when the function was initiated.
995 1.1 ragge * Suggested recovery procedure is to log the error and
996 1.1 ragge * issue the appropriate retry command.
997 1.1 ragge */
998 1.1 ragge debug (("Tape position down\n"));
999 1.1 ragge switch (cmask) {
1000 1.1 ragge case TS_CMD_RNF: /* Read Next (forward) */
1001 1.1 ragge debug (("retry read forward ...\n"));
1002 1.1 ragge sc->sc_rtc = 1;
1003 1.1 ragge tsexec (ctlr, TS_CMD_RPF);
1004 1.1 ragge return;
1005 1.1 ragge case TS_CMD_RPR: /* Read Previous (Reverse) */
1006 1.1 ragge debug (("retry read reverse ...\n"));
1007 1.1 ragge sc->sc_rtc = 1;
1008 1.1 ragge tsexec (ctlr, TS_CMD_RNR);
1009 1.1 ragge return;
1010 1.1 ragge case TS_CMD_WD: /* Write Data (Next) */
1011 1.1 ragge debug (("retry write data ...\n"));
1012 1.1 ragge sc->sc_rtc = 1;
1013 1.1 ragge tsexec (ctlr, TS_CMD_WDR);
1014 1.1 ragge return;
1015 1.1 ragge case TS_CMD_WTM:
1016 1.1 ragge debug (("retry write tape mark ...\n"));
1017 1.1 ragge sc->sc_rtc = 1;
1018 1.1 ragge tsexec (ctlr, TS_CMD_WTMR);
1019 1.1 ragge return;
1020 1.1 ragge default:
1021 1.1 ragge debug (("TPD in command %x\n", cmask));
1022 1.1 ragge }
1023 1.1 ragge break;
1024 1.1 ragge
1025 1.1 ragge case TS_TC_TNM:
1026 1.1 ragge /*
1027 1.1 ragge * Recoverable Error -- Tape position has not changed.
1028 1.1 ragge * Suggested recovery procedure is to log the error and
1029 1.1 ragge * reissue the original command.
1030 1.1 ragge */
1031 1.1 ragge printf ("Tape not moved\n");
1032 1.1 ragge if (sc->sc_rtc < 3) {
1033 1.1 ragge sc->sc_rtc++;
1034 1.1 ragge /* bertram: log the error !!! */
1035 1.1 ragge printf ("retrying command %x (%d)\n",
1036 1.1 ragge tscmdp->cmdr, sc->sc_rtc);
1037 1.1 ragge tsexec (ctlr, tscmdp->cmdr);
1038 1.1 ragge return;
1039 1.1 ragge }
1040 1.1 ragge break;
1041 1.1 ragge
1042 1.1 ragge case TS_TC_TPL:
1043 1.1 ragge /*
1044 1.1 ragge * Unrecoverable Error -- Tape position has been lost.
1045 1.1 ragge * No valid recovery procedures exist unless the tape
1046 1.1 ragge * has labels or sequence numbers.
1047 1.1 ragge */
1048 1.1 ragge printf ("Tape position lost\n");
1049 1.1 ragge break;
1050 1.1 ragge
1051 1.1 ragge case TS_TC_FCE:
1052 1.1 ragge /*
1053 1.1 ragge * Fatal subsytem Error -- The subsytem is incapable
1054 1.1 ragge * of properly performing commands, or at least its
1055 1.1 ragge * integrity is seriously questionable. Refer to the
1056 1.1 ragge * fatal class code field in the TSSR register for
1057 1.1 ragge * additional information on the type of fatal error.
1058 1.1 ragge */
1059 1.1 ragge printf ("Fatal Controller Error\n");
1060 1.1 ragge
1061 1.1 ragge default:
1062 1.1 ragge printf ("%s: error 0x%x, resetting controller\n",
1063 1.1 ragge sc->sc_dev.dv_xname, sr & TS_TC);
1064 1.1 ragge tsreset (ctlr);
1065 1.1 ragge }
1066 1.1 ragge
1067 1.1 ragge /*
1068 1.1 ragge * reset controller ?? call tsinit() ???
1069 1.1 ragge */
1070 1.1 ragge if ((bp = ts_wtab[ctlr]) != NULL) {
1071 1.1 ragge ts_wtab[ctlr] = NULL; /* pseudo unlink */
1072 1.1 ragge
1073 1.1 ragge if (bp != &ts_cbuf[ctlr]) /* no ioctl */
1074 1.1 ragge ubarelse((struct uba_softc *)sc->sc_dev.dv_parent,
1075 1.1 ragge (int *)&bp->b_ubinfo);
1076 1.1 ragge
1077 1.1 ragge if ((sr & TS_TC) != TS_TC_NORM)
1078 1.1 ragge bp->b_flags |= B_ERROR;
1079 1.1 ragge
1080 1.1 ragge debug (("resid:%d, count:%d, rbpcr:%d\n",
1081 1.1 ragge bp->b_resid, bp->b_bcount, tsmsgp->rbpcr));
1082 1.1 ragge bp->b_resid = tsmsgp->rbpcr; /* XXX */
1083 1.1 ragge debug (("tsintr: biodone(%x)\n", bp->b_flags));
1084 1.1 ragge biodone (bp);
1085 1.1 ragge }
1086 1.1 ragge if ((sr & TS_TC) > TS_TC_FR)
1087 1.1 ragge tsreset (ctlr);
1088 1.1 ragge
1089 1.1 ragge return;
1090 1.1 ragge }
1091 1.1 ragge
1092 1.1 ragge
1093 1.1 ragge /*
1094 1.1 ragge * Open a ts device and set the unit online. If the controller is not
1095 1.1 ragge * in the run state, call init to initialize the ts controller first.
1096 1.1 ragge */
1097 1.1 ragge int
1098 1.1 ragge tsopen (dev, flag, type, p)
1099 1.1 ragge dev_t dev;
1100 1.1 ragge int flag, type;
1101 1.1 ragge struct proc *p;
1102 1.1 ragge {
1103 1.1 ragge register struct uba_device *ui;
1104 1.1 ragge register struct uba_ctlr *um;
1105 1.1 ragge register struct ts_softc *sc;
1106 1.1 ragge register int unit = TS_UNIT(dev);
1107 1.1 ragge int s;
1108 1.1 ragge
1109 1.1 ragge trace (("tsopen (%x, %x)\n", dev, flag));
1110 1.1 ragge
1111 1.1 ragge if (unit >= ts_cd.cd_ndevs)
1112 1.1 ragge return ENXIO;
1113 1.1 ragge
1114 1.1 ragge sc = ts_cd.cd_devs[unit];
1115 1.1 ragge if (sc == 0)
1116 1.1 ragge return ENXIO;
1117 1.1 ragge
1118 1.1 ragge if (sc->sc_openf)
1119 1.1 ragge return EBUSY;
1120 1.1 ragge
1121 1.1 ragge sc->sc_openf = 1;
1122 1.1 ragge
1123 1.1 ragge s = splbio ();
1124 1.1 ragge if (sc->sc_state < ST_RUNNING) { /* XXX */
1125 1.1 ragge printf ("%s not running.\n", sc->sc_dev.dv_xname);
1126 1.1 ragge (void) splx (s);
1127 1.1 ragge sc->sc_openf = 0;
1128 1.1 ragge return (ENXIO);
1129 1.1 ragge }
1130 1.1 ragge (void) splx (s);
1131 1.1 ragge
1132 1.1 ragge /*
1133 1.1 ragge * check if transport is really online.
1134 1.1 ragge * (without attention-interrupts enabled, we really don't know
1135 1.1 ragge * the actual state of the transport. Thus we call get-status
1136 1.1 ragge * (ie. MTNOP) once and check the actual status.)
1137 1.1 ragge */
1138 1.1 ragge tscommand (dev, MTNOP, 1);
1139 1.1 ragge if (ts[unit].reg->tssr & TS_OFL) {
1140 1.1 ragge printf ("%s: transport is offline.\n", sc->sc_dev.dv_xname);
1141 1.1 ragge sc->sc_openf = 0;
1142 1.1 ragge return EIO; /* transport is offline */
1143 1.1 ragge }
1144 1.1 ragge
1145 1.1 ragge sc->sc_liowf = 0;
1146 1.1 ragge return 0;
1147 1.1 ragge }
1148 1.1 ragge
1149 1.1 ragge
1150 1.1 ragge /*
1151 1.1 ragge * Close tape device.
1152 1.1 ragge *
1153 1.1 ragge * If tape was open for writing or last operation was
1154 1.1 ragge * a write, then write two EOF's and backspace over the last one.
1155 1.1 ragge * Unless this is a non-rewinding special file, rewind the tape.
1156 1.1 ragge *
1157 1.1 ragge * Make the tape available to others, by clearing openf flag.
1158 1.1 ragge */
1159 1.1 ragge int
1160 1.1 ragge tsclose (dev, flag, type, p)
1161 1.1 ragge dev_t dev;
1162 1.1 ragge int flag, type;
1163 1.1 ragge struct proc *p;
1164 1.1 ragge {
1165 1.1 ragge register struct ts_softc *sc = ts_cd.cd_devs[TS_UNIT(dev)];
1166 1.1 ragge
1167 1.1 ragge if (flag == FWRITE || ((flag & FWRITE) && sc->sc_liowf)) {
1168 1.1 ragge /*
1169 1.1 ragge * We are writing two tape marks (EOT), but place the tape
1170 1.1 ragge * before the second one, so that another write operation
1171 1.1 ragge * will overwrite the second one and leave and EOF-mark.
1172 1.1 ragge */
1173 1.1 ragge tscommand (dev, MTWEOF, 1); /* Write Tape Mark */
1174 1.1 ragge tscommand (dev, MTWEOF, 1); /* Write Tape Mark */
1175 1.1 ragge tscommand (dev, MTBSF, 1); /* Skip Tape Marks Reverse */
1176 1.1 ragge }
1177 1.1 ragge
1178 1.1 ragge if ((dev & T_NOREWIND) == 0)
1179 1.1 ragge tscommand (dev, MTREW, 0);
1180 1.1 ragge
1181 1.1 ragge sc->sc_openf = 0;
1182 1.1 ragge sc->sc_liowf = 0;
1183 1.1 ragge return 0;
1184 1.1 ragge }
1185 1.1 ragge
1186 1.1 ragge
1187 1.1 ragge /*
1188 1.1 ragge * Manage buffers and perform block mode read and write operations.
1189 1.1 ragge */
1190 1.1 ragge void
1191 1.1 ragge tsstrategy (bp)
1192 1.1 ragge register struct buf *bp;
1193 1.1 ragge {
1194 1.1 ragge register int unit = TS_UNIT(bp->b_dev);
1195 1.1 ragge struct ts_softc *sc = (void *)ts_cd.cd_devs[unit];
1196 1.1 ragge int s;
1197 1.1 ragge
1198 1.1 ragge s = splbio ();
1199 1.1 ragge /*
1200 1.1 ragge * we have only one command at one time, no credits.
1201 1.1 ragge * thus we don't need buffer management and controller queue
1202 1.1 ragge * just try to execute the command ...
1203 1.1 ragge */
1204 1.1 ragge
1205 1.1 ragge tsstart (sc, bp);
1206 1.1 ragge splx(s);
1207 1.1 ragge return;
1208 1.1 ragge }
1209 1.1 ragge
1210 1.1 ragge
1211 1.1 ragge /*
1212 1.1 ragge * Catch ioctl commands, and call the "command" routine to do them.
1213 1.1 ragge */
1214 1.1 ragge int
1215 1.1 ragge tsioctl (dev, cmd, data, flag, p)
1216 1.1 ragge dev_t dev;
1217 1.1 ragge u_long cmd;
1218 1.1 ragge caddr_t data;
1219 1.1 ragge int flag;
1220 1.1 ragge struct proc *p;
1221 1.1 ragge {
1222 1.1 ragge register struct buf *bp = &ts_cbuf[TS_UNIT(dev)];
1223 1.1 ragge register struct ts_softc *sc;
1224 1.1 ragge register struct mtop *mtop; /* mag tape cmd op to perform */
1225 1.1 ragge register struct mtget *mtget; /* mag tape struct to get info in */
1226 1.1 ragge register callcount; /* number of times to call routine */
1227 1.1 ragge int scount; /* number of files/records to space */
1228 1.1 ragge int spaceop = 0; /* flag for skip/space operation */
1229 1.1 ragge int error = 0;
1230 1.1 ragge
1231 1.1 ragge trace (("tsioctl (%x, %x, %x, %d)\n", dev, cmd, data, flag));
1232 1.1 ragge
1233 1.1 ragge switch (cmd) {
1234 1.1 ragge case MTIOCTOP: /* do a mag tape op */
1235 1.1 ragge mtop = (struct mtop *)data;
1236 1.1 ragge switch (mtop->mt_op) {
1237 1.1 ragge case MTWEOF: /* write an end-of-file record */
1238 1.1 ragge callcount = mtop->mt_count;
1239 1.1 ragge scount = 1;
1240 1.1 ragge break;
1241 1.1 ragge case MTFSF: /* forward space file */
1242 1.1 ragge case MTBSF: /* backward space file */
1243 1.1 ragge case MTFSR: /* forward space record */
1244 1.1 ragge case MTBSR: /* backward space record */
1245 1.1 ragge spaceop = 1;
1246 1.1 ragge callcount = 1;
1247 1.1 ragge scount = mtop->mt_count;
1248 1.1 ragge break;
1249 1.1 ragge case MTREW: /* rewind */
1250 1.1 ragge case MTOFFL: /* rewind and put the drive offline */
1251 1.1 ragge case MTNOP: /* no operation, sets status only */
1252 1.1 ragge callcount = 1;
1253 1.1 ragge scount = 1; /* wait for this rewind */
1254 1.1 ragge break;
1255 1.1 ragge case MTRETEN: /* retension */
1256 1.1 ragge case MTERASE: /* erase entire tape */
1257 1.1 ragge case MTEOM: /* forward to end of media */
1258 1.1 ragge case MTNBSF: /* backward space to begin of file */
1259 1.1 ragge case MTCACHE: /* enable controller cache */
1260 1.1 ragge case MTNOCACHE: /* disable controller cache */
1261 1.1 ragge case MTSETBSIZ: /* set block size; 0 for variable */
1262 1.1 ragge case MTSETDNSTY: /* set density code for current mode */
1263 1.1 ragge debug (("ioctl %d not implemented.\n", mtop->mt_op));
1264 1.1 ragge return (ENXIO);
1265 1.1 ragge default:
1266 1.1 ragge debug (("invalid ioctl %d\n", mtop->mt_op));
1267 1.1 ragge return (ENXIO);
1268 1.1 ragge } /* switch (mtop->mt_op) */
1269 1.1 ragge
1270 1.1 ragge if (callcount <= 0 || scount <= 0) {
1271 1.1 ragge debug (("invalid values %d/%d\n", callcount, scount));
1272 1.1 ragge return (EINVAL);
1273 1.1 ragge }
1274 1.1 ragge do {
1275 1.1 ragge tscommand (dev, mtop->mt_op, scount);
1276 1.1 ragge if (spaceop && bp->b_resid) {
1277 1.1 ragge debug (("spaceop didn't complete\n"));
1278 1.1 ragge return (EIO);
1279 1.1 ragge }
1280 1.1 ragge if (bp->b_flags & B_ERROR) {
1281 1.1 ragge debug (("error in ioctl %d\n", mtop->mt_op));
1282 1.1 ragge break;
1283 1.1 ragge }
1284 1.1 ragge } while (--callcount > 0);
1285 1.1 ragge if (bp->b_flags & B_ERROR)
1286 1.1 ragge if ((error = bp->b_error) == 0)
1287 1.1 ragge return (EIO);
1288 1.1 ragge return (error);
1289 1.1 ragge
1290 1.1 ragge case MTIOCGET: /* get tape status */
1291 1.1 ragge sc = ts_cd.cd_devs[TS_UNIT(dev)];
1292 1.1 ragge mtget = (struct mtget *)data;
1293 1.1 ragge mtget->mt_type = MT_ISTS;
1294 1.1 ragge mtget->mt_dsreg = (unsigned)(ts[TS_UNIT(dev)].reg->tssr);
1295 1.1 ragge mtget->mt_erreg = (unsigned)(ts[TS_UNIT(dev)].msg.hdr);
1296 1.1 ragge mtget->mt_resid = 0; /* ??? */
1297 1.1 ragge mtget->mt_density = 0; /* ??? */
1298 1.1 ragge break;
1299 1.1 ragge
1300 1.1 ragge case MTIOCIEOT: /* ignore EOT error */
1301 1.1 ragge debug (("MTIOCIEOT not implemented.\n"));
1302 1.1 ragge return (ENXIO);
1303 1.1 ragge
1304 1.1 ragge case MTIOCEEOT: /* enable EOT error */
1305 1.1 ragge debug (("MTIOCEEOT not implemented.\n"));
1306 1.1 ragge return (ENXIO);
1307 1.1 ragge
1308 1.1 ragge default:
1309 1.1 ragge debug (("invalid ioctl cmd 0x%x\n", cmd));
1310 1.1 ragge return (ENXIO);
1311 1.1 ragge }
1312 1.1 ragge
1313 1.1 ragge return (0);
1314 1.1 ragge }
1315 1.1 ragge
1316 1.1 ragge
1317 1.1 ragge /*
1318 1.1 ragge *
1319 1.1 ragge */
1320 1.1 ragge int
1321 1.1 ragge tsread (dev, uio)
1322 1.1 ragge dev_t dev;
1323 1.1 ragge struct uio *uio;
1324 1.1 ragge {
1325 1.1 ragge return (physio (tsstrategy, NULL, dev, B_READ, minphys, uio));
1326 1.1 ragge }
1327 1.1 ragge
1328 1.1 ragge /*
1329 1.1 ragge *
1330 1.1 ragge */
1331 1.1 ragge int
1332 1.1 ragge tswrite (dev, uio)
1333 1.1 ragge dev_t dev;
1334 1.1 ragge struct uio *uio;
1335 1.1 ragge {
1336 1.1 ragge return (physio (tsstrategy, NULL, dev, B_WRITE, minphys, uio));
1337 1.1 ragge }
1338 1.1 ragge
1339 1.1 ragge /*
1340 1.1 ragge *
1341 1.1 ragge */
1342 1.1 ragge int
1343 1.1 ragge tsdump(dev, blkno, va, size)
1344 1.1 ragge dev_t dev;
1345 1.1 ragge daddr_t blkno;
1346 1.1 ragge caddr_t va;
1347 1.1 ragge size_t size;
1348 1.1 ragge {
1349 1.1 ragge trace (("tsdump (%x)\n", dev));
1350 1.1 ragge return 0;
1351 1.1 ragge }
1352 1.1 ragge
1353 1.1 ragge /*----------------------------------------------------------------------*/
1354 1.1 ragge
1355 1.1 ragge int
1356 1.1 ragge tsstatus (sr)
1357 1.1 ragge int sr;
1358 1.1 ragge {
1359 1.1 ragge #ifdef DEBUG
1360 1.1 ragge char bits[64];
1361 1.1 ragge
1362 1.1 ragge debug (("status: TSSR=%s\n", bitmask_snprintf(sr, TS_TSSR_BITS,
1363 1.1 ragge bits, sizeof(bits))));
1364 1.1 ragge
1365 1.1 ragge if (tsdebug < 5)
1366 1.1 ragge return (0);
1367 1.1 ragge
1368 1.1 ragge if (sr & TS_SC) printf ("special condition\n");
1369 1.1 ragge if (sr & TS_UPE) printf ("UPE\n");
1370 1.1 ragge if (sr & TS_SCE) printf ("Sanity Check Error\n");
1371 1.1 ragge if (sr & TS_RMR) printf ("Register Modification Refused\n");
1372 1.1 ragge if (sr & TS_NXM) printf ("Nonexistent Memory\n");
1373 1.1 ragge if (sr & TS_NBA) printf ("Need Buffer Address\n");
1374 1.1 ragge if (sr & TS_A11) printf ("Address Bits 17-16\n");
1375 1.1 ragge if (sr & TS_SSR) printf ("Subsystem Ready\n");
1376 1.1 ragge if (sr & TS_OFL) printf ("Off Line\n");
1377 1.1 ragge if (sr & TS_FTC) printf ("Fatal Termination Class Code\n");
1378 1.1 ragge switch (sr & TS_TC) {
1379 1.1 ragge case TS_TC_NORM: printf ("Normal Termination\n"); break;
1380 1.1 ragge case TS_TC_ATTN: printf ("Attention Condition\n"); break;
1381 1.1 ragge case TS_TC_TSA: printf ("Tape status \n"); break;
1382 1.1 ragge case TS_TC_FR: printf ("Function reject\n"); break;
1383 1.1 ragge case TS_TC_TPD: printf ("Tape position down\n"); break;
1384 1.1 ragge case TS_TC_TNM: printf ("Tape not moved\n"); break;
1385 1.1 ragge case TS_TC_TPL: printf ("Tape position lost\n"); break;
1386 1.1 ragge case TS_TC_FCE: printf ("Fatal Controller Error\n"); break;
1387 1.1 ragge }
1388 1.1 ragge #endif
1389 1.1 ragge return (0);
1390 1.1 ragge }
1391 1.1 ragge
1392 1.1 ragge void
1393 1.1 ragge tsxstatus (mp)
1394 1.1 ragge struct tsmsg *mp;
1395 1.1 ragge {
1396 1.1 ragge #ifdef DEBUG
1397 1.1 ragge char bits[64];
1398 1.1 ragge
1399 1.1 ragge debug (("tsxstatus: xst0=%s, ", bitmask_snprintf(mp->xst0,
1400 1.1 ragge TS_XST0_BITS, bits, sizeof(bits))));
1401 1.1 ragge debug (("xst1=%s, ", bitmask_snprintf(mp->xst1, TS_XST1_BITS,
1402 1.1 ragge bits, sizeof(bits))));
1403 1.1 ragge debug (("xst2=%s, ", bitmask_snprintf(mp->xst2, TS_XST2_BITS,
1404 1.1 ragge bits, sizeof(bits))));
1405 1.1 ragge debug (("xst3=%s, ", bitmask_snprintf(mp->xst3, TS_XST3_BITS,
1406 1.1 ragge bits, sizeof(bits))));
1407 1.1 ragge debug (("xst4=%s\n", bitmask_snprintf(mp->xst4, "\20",
1408 1.1 ragge bits, sizeof(bits))));
1409 1.1 ragge
1410 1.1 ragge if (tsdebug < 10)
1411 1.1 ragge return (0);
1412 1.1 ragge
1413 1.1 ragge if (mp->xst0 & TS_SF_TMK) printf ("Tape Mark Detected\n");
1414 1.1 ragge if (mp->xst0 & TS_SF_RLS) printf ("Record Length Short\n");
1415 1.1 ragge if (mp->xst0 & TS_SF_LET) printf ("Logical End of Tape\n");
1416 1.1 ragge if (mp->xst0 & TS_SF_RLL) printf ("Record Length Long\n");
1417 1.1 ragge if (mp->xst0 & TS_SF_WLE) printf ("Write Lock Error\n");
1418 1.1 ragge if (mp->xst0 & TS_SF_NEF) printf ("Nonexecutable Function\n");
1419 1.1 ragge if (mp->xst0 & TS_SF_ILC) printf ("Illegal Command\n");
1420 1.1 ragge if (mp->xst0 & TS_SF_ILA) printf ("Illegal Address\n");
1421 1.1 ragge if (mp->xst0 & TS_SF_MOT) printf ("Motion\n");
1422 1.1 ragge if (mp->xst0 & TS_SF_ONL) printf ("On-Line\n");
1423 1.1 ragge if (mp->xst0 & TS_SF_IE) printf ("Interrupt Enable\n");
1424 1.1 ragge if (mp->xst0 & TS_SF_VCK) printf ("Volume Check\n");
1425 1.1 ragge if (mp->xst0 & TS_SF_PED) printf ("Phase Encoded Drive\n");
1426 1.1 ragge if (mp->xst0 & TS_SF_WLK) printf ("Write Locked\n");
1427 1.1 ragge if (mp->xst0 & TS_SF_BOT) printf ("Beginning of Tape\n");
1428 1.1 ragge if (mp->xst0 & TS_SF_EOT) printf ("End of Tape\n");
1429 1.1 ragge
1430 1.1 ragge if (mp->xst1 & TS_SF_DLT) printf ("Data Late\n");
1431 1.1 ragge if (mp->xst1 & TS_SF_COR) printf ("Correctable Data\n");
1432 1.1 ragge if (mp->xst1 & TS_SF_RBP) printf ("Read Bus Parity Error\n");
1433 1.1 ragge if (mp->xst1 & TS_SF_UNC) printf ("Uncorrectable Data or Hard Error\n");
1434 1.1 ragge
1435 1.1 ragge if (mp->xst2 & TS_SF_OPM) printf ("Operation in Progress\n");
1436 1.1 ragge if (mp->xst2 & TS_SF_RCE) printf ("RAM Checksum Error\n");
1437 1.1 ragge if (mp->xst2 & TS_SF_WCF) printf ("Write Clock Failure\n");
1438 1.1 ragge if (mp->xst2 & TS_SF_EFES) printf ("extended features enabled\n");
1439 1.1 ragge if (mp->xst2 & TS_SF_BES) printf ("Buffering enabled\n");
1440 1.1 ragge
1441 1.1 ragge printf ("micro-code revision level: %d\n", (mp->xst2 & TS_SF_MCRL)>>2);
1442 1.1 ragge printf ("unit number: %d\n", (mp->xst2 & TS_SF_UNIT));
1443 1.1 ragge
1444 1.1 ragge if (mp->xst3 & TS_SF_MDE)
1445 1.1 ragge printf ("Micro-Diagnostics Error Code: 0x%x\n", mp->xst3 >> 8);
1446 1.1 ragge if (mp->xst3 & TS_SF_OPI) printf ("Operation Incomplete\n");
1447 1.1 ragge if (mp->xst3 & TS_SF_REV) printf ("Revers\n");
1448 1.1 ragge if (mp->xst3 & TS_SF_DCK) printf ("Density Check\n");
1449 1.1 ragge if (mp->xst3 & TS_SF_RIB) printf ("Reverse into BOT\n");
1450 1.1 ragge
1451 1.1 ragge if (mp->xst4 & TS_SF_HSP) printf ("High Speed\n");
1452 1.1 ragge if (mp->xst4 & TS_SF_RCX) printf ("Retry Count Exceeded\n");
1453 1.1 ragge #endif
1454 1.1 ragge }
1455