2003-11-17 14:16:10 +03:00
|
|
|
/* $NetBSD: ts.c,v 1.28 2003/11/17 11:16:10 wiz Exp $ */
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1991 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1996-01-06 19:43:46 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1996-07-20 23:00:22 +04:00
|
|
|
* @(#)tmscp.c 7.16 (Berkeley) 5/9/91
|
1996-01-06 19:43:46 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1996-07-20 23:00:22 +04:00
|
|
|
* sccsid = "@(#)tmscp.c 1.24 (ULTRIX) 1/21/86";
|
1996-01-06 19:43:46 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/************************************************************************
|
1996-07-20 23:00:22 +04:00
|
|
|
* *
|
|
|
|
* Licensed from Digital Equipment Corporation *
|
|
|
|
* Copyright (c) *
|
|
|
|
* Digital Equipment Corporation *
|
|
|
|
* Maynard, Massachusetts *
|
|
|
|
* 1985, 1986 *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* The Information in this software is subject to change *
|
|
|
|
* without notice and should not be construed as a commitment *
|
|
|
|
* by Digital Equipment Corporation. Digital makes no *
|
|
|
|
* representations about the suitability of this software for *
|
|
|
|
* any purpose. It is supplied "As Is" without expressed or *
|
|
|
|
* implied warranty. *
|
|
|
|
* *
|
|
|
|
* If the Regents of the University of California or its *
|
|
|
|
* licensees modify the software in a manner creating *
|
1999-04-13 00:57:52 +04:00
|
|
|
* derivative copyright rights, appropriate copyright *
|
|
|
|
* legends may be placed on the derivative work in addition *
|
1996-07-20 23:00:22 +04:00
|
|
|
* to that set forth above. *
|
|
|
|
* *
|
1996-04-08 22:32:26 +04:00
|
|
|
************************************************************************/
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* TSV05/TS05 device driver, written by Bertram Barth.
|
|
|
|
*
|
|
|
|
* should be TS11 compatible (untested)
|
|
|
|
*/
|
|
|
|
|
2003-07-15 06:15:00 +04:00
|
|
|
#include <sys/cdefs.h>
|
2003-11-17 14:16:10 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ts.c,v 1.28 2003/11/17 11:16:10 wiz Exp $");
|
2003-07-15 06:15:00 +04:00
|
|
|
|
1996-01-06 19:43:46 +03:00
|
|
|
#define TS11_COMPAT /* don't use extended features provided by TS05 */
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
#ifdef NEED_18BIT
|
1996-01-06 19:43:46 +03:00
|
|
|
#define TS_UBAFLAGS UBA_NEED16
|
|
|
|
#else
|
|
|
|
#define TS_UBAFLAGS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ENABLE_ESS
|
|
|
|
#define ENABLE_END
|
|
|
|
|
|
|
|
#define ENABLE_EAI /* enable Attention-Interrupts */
|
1996-07-20 23:00:22 +04:00
|
|
|
#undef ENABLE_EAI
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
#define ENABLE_ERI /* Enable Release Buffer Interrupts */
|
1996-07-20 23:00:22 +04:00
|
|
|
#undef ENABLE_ERI
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
int tsdebug = 1;
|
1996-10-13 07:29:05 +04:00
|
|
|
# define debug(x) if (tsdebug > 0) {DELAY(2000); printf x; DELAY(3000);}
|
|
|
|
# define debug10(x) if (tsdebug > 9) printf x
|
1996-01-06 19:43:46 +03:00
|
|
|
#else
|
|
|
|
# define debug(x) /* just ignore it */
|
|
|
|
# define debug10(x) /* just ignore it */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TRACE
|
|
|
|
int tstrace = 1;
|
1996-10-13 07:29:05 +04:00
|
|
|
# define trace(x) if (tstrace > 0) {DELAY(2000); printf x; DELAY(3000);}
|
1996-01-06 19:43:46 +03:00
|
|
|
#else
|
|
|
|
# define trace(x) /* just ignore it */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO: most :-)
|
|
|
|
*
|
|
|
|
* include uba-mapping into tsinit();
|
|
|
|
* merge tsinit(), tsreset() and tsprobe();
|
|
|
|
* complete tsintr();
|
|
|
|
* add proper error/status messages
|
|
|
|
* make messages appear where they are intended to.
|
|
|
|
* check for termination-classes and appropriate actions.
|
|
|
|
* check if flags like CVC and ATTN should be used.
|
|
|
|
* look for correct handling of attentions.
|
|
|
|
* check for correct usage of retry-commands.
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1996-02-02 21:05:36 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/mtio.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
|
|
|
#include <machine/pte.h>
|
|
|
|
#include <machine/sid.h>
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/mtpr.h>
|
|
|
|
|
2000-06-04 10:16:53 +04:00
|
|
|
#include <dev/qbus/ubareg.h>
|
|
|
|
#include <dev/qbus/ubavar.h>
|
1996-01-06 19:43:46 +03:00
|
|
|
|
1996-02-02 21:59:16 +03:00
|
|
|
#include <vax/uba/tsreg.h>
|
1996-01-06 19:43:46 +03:00
|
|
|
|
2000-01-17 07:55:25 +03:00
|
|
|
#include "opt_vax750.h"
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
#include "ts.h"
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ts command packets and communication area (per controller)
|
|
|
|
*/
|
1996-07-20 23:00:22 +04:00
|
|
|
struct ts {
|
1996-01-06 19:43:46 +03:00
|
|
|
struct tsdevice *reg; /* address of i/o-registers */
|
1996-07-20 23:00:22 +04:00
|
|
|
struct tscmd cmd; /* command packet(s) */
|
1996-01-06 19:43:46 +03:00
|
|
|
struct tsmsg msg; /* message packet(s) */
|
|
|
|
} ts[NTS];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Software status, per controller.
|
|
|
|
* also status per tape-unit, since only one unit per controller
|
|
|
|
* (thus we have no struct ts_info)
|
|
|
|
*/
|
|
|
|
struct ts_softc {
|
1996-07-20 23:00:22 +04:00
|
|
|
struct device sc_dev; /* Autoconf ... */
|
|
|
|
struct uba_unit sc_unit; /* Struct common for UBA to talk */
|
|
|
|
struct ts *sc_ts; /* Unibus address of uda struct */
|
|
|
|
short sc_mapped; /* Unibus map allocated ? */
|
|
|
|
int sc_ubainfo; /* Unibus mapping info */
|
|
|
|
short sc_state; /* see below: ST_xxx */
|
|
|
|
short sc_flags; /* see below: FL_xxx */
|
1996-01-06 19:43:46 +03:00
|
|
|
short sc_lcmd; /* last command word */
|
|
|
|
short sc_rtc; /* retry count for lcmd */
|
|
|
|
short sc_lssr; /* last status register */
|
|
|
|
short sc_lmsgh; /* last message header */
|
|
|
|
short sc_lxst0; /* last status word */
|
|
|
|
short sc_cmdf; /* command flags (ack,cvc,ie) */
|
1996-07-20 23:00:22 +04:00
|
|
|
short sc_openf; /* lock against multiple opens */
|
1996-01-06 19:43:46 +03:00
|
|
|
short sc_liowf; /* last operation was write */
|
1996-07-20 23:00:22 +04:00
|
|
|
int sc_micro; /* microcode revision */
|
|
|
|
int sc_ivec; /* interrupt vector address */
|
|
|
|
short sc_ipl; /* interrupt priority, Q-bus */
|
|
|
|
};
|
|
|
|
|
1996-04-08 22:32:26 +04:00
|
|
|
void tsintr __P((int));
|
1996-07-20 23:00:22 +04:00
|
|
|
int tsinit __P((struct ts_softc *));
|
1996-04-08 22:32:26 +04:00
|
|
|
void tscommand __P((dev_t, int, int));
|
|
|
|
int tsstatus __P((int));
|
|
|
|
int tsexec __P((int, int));
|
1996-07-20 23:00:22 +04:00
|
|
|
int tsstart __P((struct ts_softc *, struct buf *));
|
1996-04-08 22:32:26 +04:00
|
|
|
int tswchar __P((int));
|
|
|
|
void tsreset __P((int));
|
|
|
|
void tsxstatus __P((struct tsmsg *));
|
1996-07-20 23:00:22 +04:00
|
|
|
int tsmatch __P((struct device *, void *, void *));
|
|
|
|
void tsattach __P((struct device *, struct device *, void *));
|
|
|
|
void tsstrategy __P((struct buf *));
|
1996-04-08 22:32:26 +04:00
|
|
|
|
2002-10-01 09:18:59 +04:00
|
|
|
CFATTACH_DECL(ts, sizeof(struct ts_softc),
|
2002-10-02 20:02:08 +04:00
|
|
|
tsmatch, tsattach, NULL, NULL);
|
1996-07-20 23:00:22 +04:00
|
|
|
|
1998-01-12 23:52:29 +03:00
|
|
|
extern struct cfdriver ts_cd;
|
1996-04-08 22:32:26 +04:00
|
|
|
|
2002-09-06 17:18:43 +04:00
|
|
|
dev_type_open(tsopen);
|
|
|
|
dev_type_close(tsclose);
|
|
|
|
dev_type_read(tsread);
|
|
|
|
dev_type_write(tswrite);
|
|
|
|
dev_type_ioctl(tsioctl);
|
|
|
|
dev_type_strategy(tsstrategy);
|
|
|
|
dev_type_dump(tsdump);
|
|
|
|
|
|
|
|
const struct bdevsw ts_bdevsw = {
|
|
|
|
tsopen, tsclose, tsstrategy, tsioctl, tsdump, nosize, D_TAPE
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct cdevsw ts_cdevsw = {
|
|
|
|
tsopen, tsclose, tsread, tswrite, tsioctl,
|
2002-10-23 13:10:23 +04:00
|
|
|
nostop, notty, nopoll, nommap, nokqfilter, D_TAPE
|
2002-09-06 17:18:43 +04:00
|
|
|
};
|
|
|
|
|
1996-01-06 19:43:46 +03:00
|
|
|
#define ST_INVALID 0 /* uninitialized, before probe */
|
|
|
|
#define ST_PROBE 1 /* during tsprobe(), not used */
|
|
|
|
#define ST_SLAVE 2 /* in tsslave(), init almost complete */
|
|
|
|
#define ST_ATTACH 3 /* during tsattach(), not used */
|
1996-07-20 23:00:22 +04:00
|
|
|
#define ST_INITIALIZED 4 /* init completed, set by tsintr() */
|
1996-01-06 19:43:46 +03:00
|
|
|
#define ST_RUNNING 5
|
|
|
|
#define ST_IDLE 6
|
|
|
|
#define ST_BUSY 7
|
|
|
|
|
|
|
|
/* Bits in minor device */
|
|
|
|
#define TS_UNIT(dev) (minor(dev)&03)
|
|
|
|
#define TS_HIDENSITY 010
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
#define TS_PRI LOG_INFO
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we don't have credits and thus only one operation per time,
|
|
|
|
* we don't have and don't need queues like MSCP/TMSCP use them.
|
|
|
|
* Per controller we only need one internal buffer for ioctls and
|
|
|
|
* two pointers to buffers to simulate similiar behaviour ...
|
|
|
|
*/
|
|
|
|
struct buf ts_cbuf[NTS]; /* internal cmd buffer (for ioctls) */
|
|
|
|
struct buf *ts_wtab[NTS]; /* dummy I/O wait queue */
|
|
|
|
#define b_ubinfo b_resid /* Unibus mapping info, per buffer */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize a TS device. Set up UBA mapping registers,
|
|
|
|
* initialize data structures, what else ???
|
|
|
|
*/
|
|
|
|
int
|
1996-07-20 23:00:22 +04:00
|
|
|
tsinit (sc)
|
|
|
|
struct ts_softc *sc;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
|
|
|
volatile struct tsdevice *tsregs;
|
1996-07-20 23:00:22 +04:00
|
|
|
int unit = sc->sc_dev.dv_unit;
|
|
|
|
struct uba_unit *uu;
|
1996-01-06 19:43:46 +03:00
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
uu = &sc->sc_unit;
|
|
|
|
tsregs = (struct tsdevice *)ts[unit].reg;
|
1996-01-06 19:43:46 +03:00
|
|
|
if (sc->sc_mapped == 0) {
|
|
|
|
/*
|
|
|
|
* Map the communications area and command and message
|
|
|
|
* buffer into Unibus address space.
|
|
|
|
*/
|
1997-01-11 14:34:39 +03:00
|
|
|
sc->sc_ubainfo = uballoc((struct uba_softc *)
|
|
|
|
sc->sc_dev.dv_parent,
|
1996-07-20 23:00:22 +04:00
|
|
|
(caddr_t)&ts[unit], sizeof (struct ts), TS_UBAFLAGS);
|
1996-01-06 19:43:46 +03:00
|
|
|
sc->sc_ts = (struct ts *)(UBAI_ADDR(sc->sc_ubainfo));
|
|
|
|
sc->sc_mapped = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* bertram: start hardware initialization ??????
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* tsreset(unit); */
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send a command using the default command-buffer for this unit/controller.
|
|
|
|
* If a command-word is given, then assemble a one-word command.
|
|
|
|
* other words in command-buffer are unchanged and must thus be initialized
|
|
|
|
* before calling this function.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
tsexec (ctlr, cmd)
|
|
|
|
int ctlr;
|
|
|
|
int cmd;
|
|
|
|
{
|
1996-07-20 23:00:22 +04:00
|
|
|
register struct ts_softc *sc = ts_cd.cd_devs[ctlr];
|
1996-01-06 19:43:46 +03:00
|
|
|
register struct tscmd *tscmdp = &ts[ctlr].cmd;
|
|
|
|
register long tscmdma = (long)&sc->sc_ts->cmd; /* mapped address */
|
|
|
|
volatile struct tsdevice *tsreg = ts[ctlr].reg;
|
|
|
|
volatile char *dbx = ((char*)tsreg) + 3;
|
|
|
|
volatile short sr;
|
|
|
|
|
|
|
|
sc->sc_cmdf |= TS_CF_ACK | TS_CF_IE;
|
|
|
|
tscmdp->cmdr = sc->sc_cmdf | cmd;
|
|
|
|
tscmdp->cmdr = TS_CF_ACK | TS_CF_IE | sc->sc_cmdf | cmd;
|
|
|
|
sc->sc_cmdf = 0; /* XXX */
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
switch (tscmdp->cmdr & TS_CF_CMASK) {
|
|
|
|
case TS_CMD_RNF: cmdName = "Read Next (Forward)"; break;
|
|
|
|
case TS_CMD_RPR: cmdName = "Read Previous (Reverse)"; break;
|
|
|
|
case TS_CMD_WCHAR: cmdName = "Write Characteristics"; break;
|
|
|
|
case TS_CMD_WD: cmdName = "Write Data (Next)"; break;
|
|
|
|
case TS_CMD_WDR: cmdName = "Write Data (Retry)"; break;
|
|
|
|
case TS_CMD_SRF: cmdName = "Space Records Forward"; break;
|
|
|
|
case TS_CMD_SRR: cmdName = "Space Records Reverse"; break;
|
|
|
|
case TS_CMD_STMF: cmdName = "Skip Tape Marks Forward"; break;
|
|
|
|
case TS_CMD_STMR: cmdName = "Skip Tape Marks Reverse"; break;
|
|
|
|
case TS_CMD_RWND: cmdName = "Rewind"; break;
|
|
|
|
case TS_CMD_WTM: cmdName = "Write Tape Mark"; break;
|
|
|
|
case TS_CMD_WTMR: cmdName = "Write Tape Mark (Retry)"; break;
|
|
|
|
case TS_CMD_STAT: cmdName = "Get Status (END)"; break;
|
|
|
|
default: cmdName = "unexptected Command"; break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sr = tsreg->tssr;
|
|
|
|
if ((sr & TS_SSR) == 0) { /* subsystem NOT ready */
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s%d: subsystem not ready [%x]\n",
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_dev.dv_xname, sr);
|
1996-01-06 19:43:46 +03:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
dbx = ((char*)tsreg) + 3; /* dbx is located at the fourth byte */
|
|
|
|
*dbx = (tscmdma >> 18) & 0x0F; /* load bits 18-21 into dbx */
|
|
|
|
|
|
|
|
/* possible race-condition with ATTN !!! */
|
|
|
|
|
|
|
|
sr = tsreg->tssr;
|
|
|
|
if ((sr & TS_RMR) != 0) { /* Register modification Refused */
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("ts: error writing TSDBX\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
/* now load bits 15-2 at pos 15-2 and bits 17,16 at pos 1,0 of TSDB */
|
|
|
|
tsreg->tsdb = (tscmdma & 0xfffc) | ((tscmdma >> 16) & 0x03);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wait for SSR or RMR to show up
|
|
|
|
*/
|
|
|
|
sr = tsreg->tssr;
|
1996-07-20 23:00:22 +04:00
|
|
|
if ((sr & TS_SSR) != 0) { /* something went wrong .. */
|
1996-01-06 19:43:46 +03:00
|
|
|
if (sr & TS_RMR) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("ts: error writing TSDB (RMR)\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
if (sr & TS_NXM) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("ts: error writing TSDB (NXM)\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
return (-1);
|
|
|
|
}
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("ts: error 0x%x while writing TSDB\n", sr);
|
1996-01-06 19:43:46 +03:00
|
|
|
tsstatus (sr);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0); /* completed successfully */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Execute a (ioctl) command on the tape drive a specified number of times.
|
|
|
|
* This routine sets up a buffer and calls the strategy routine which
|
|
|
|
* issues the command to the controller.
|
|
|
|
*/
|
1996-04-08 22:32:26 +04:00
|
|
|
void
|
1996-01-06 19:43:46 +03:00
|
|
|
tscommand (dev, cmd, count)
|
|
|
|
register dev_t dev;
|
|
|
|
int cmd;
|
|
|
|
int count;
|
|
|
|
{
|
|
|
|
register struct buf *bp;
|
1996-07-20 23:00:22 +04:00
|
|
|
register int s;
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
trace (("tscommand (%d, %x, %d)\n", TS_UNIT(dev), cmd, count));
|
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
bp = &ts_cbuf[TS_UNIT(dev)];
|
1996-07-20 23:00:22 +04:00
|
|
|
|
1996-01-06 19:43:46 +03:00
|
|
|
while (bp->b_flags & B_BUSY) {
|
|
|
|
/*
|
|
|
|
* This special check is because B_BUSY never
|
|
|
|
* gets cleared in the non-waiting rewind case. ???
|
|
|
|
*/
|
|
|
|
if (bp->b_bcount == 0 && (bp->b_flags & B_DONE))
|
|
|
|
break;
|
|
|
|
bp->b_flags |= B_WANTED;
|
2000-05-27 08:52:27 +04:00
|
|
|
(void) tsleep(bp, PRIBIO, "tscmd", 0);
|
1996-01-06 19:43:46 +03:00
|
|
|
/* check MOT-flag !!! */
|
|
|
|
}
|
|
|
|
bp->b_flags = B_BUSY | B_READ;
|
1996-07-20 23:00:22 +04:00
|
|
|
|
1996-01-06 19:43:46 +03:00
|
|
|
splx(s);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load the buffer. The b_count field gets used to hold the command
|
|
|
|
* count. the b_resid field gets used to hold the command mneumonic.
|
|
|
|
* These 2 fields are "known" to be "safe" to use for this purpose.
|
|
|
|
* (Most other drivers also use these fields in this way.)
|
|
|
|
*/
|
|
|
|
bp->b_dev = dev;
|
|
|
|
bp->b_bcount = count;
|
|
|
|
bp->b_resid = cmd;
|
|
|
|
bp->b_blkno = 0;
|
|
|
|
tsstrategy (bp);
|
|
|
|
/*
|
|
|
|
* In case of rewind from close, don't wait.
|
|
|
|
* This is the only case where count can be 0.
|
|
|
|
*/
|
|
|
|
if (count == 0) {
|
2000-01-18 22:51:03 +03:00
|
|
|
debug (("tscommand: direct return, no biowait.\n"));
|
1996-01-06 19:43:46 +03:00
|
|
|
return;
|
|
|
|
}
|
2003-01-20 08:29:53 +03:00
|
|
|
debug (("tscommand: calling biowait ...\n"));
|
2000-01-18 22:51:03 +03:00
|
|
|
biowait (bp);
|
1996-01-06 19:43:46 +03:00
|
|
|
if (bp->b_flags & B_WANTED)
|
|
|
|
wakeup ((caddr_t)bp);
|
|
|
|
bp->b_flags &= B_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start an I/O operation on TS05 controller
|
|
|
|
*/
|
|
|
|
int
|
1996-07-20 23:00:22 +04:00
|
|
|
tsstart (sc, bp)
|
|
|
|
register struct ts_softc *sc;
|
1996-01-06 19:43:46 +03:00
|
|
|
register struct buf *bp;
|
|
|
|
{
|
1996-07-20 23:00:22 +04:00
|
|
|
int ctlr = sc->sc_dev.dv_unit;
|
|
|
|
volatile struct tsdevice *tsreg = ts[ctlr].reg;
|
|
|
|
register struct tscmd *tscmdp = &ts[ctlr].cmd;
|
1996-01-06 19:43:46 +03:00
|
|
|
register struct buf *dp;
|
|
|
|
volatile int i, itmp;
|
|
|
|
int ioctl;
|
|
|
|
int cmd;
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
if ((dp = ts_wtab[ctlr]) != NULL) {
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* There's already a command pending ...
|
|
|
|
* Either we are called by tsintr or we have missed
|
|
|
|
* something important (race condition).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* bertram: ubarelse ??? */
|
1996-07-20 23:00:22 +04:00
|
|
|
ts_wtab[ctlr] = NULL;
|
1996-01-06 19:43:46 +03:00
|
|
|
dp->b_flags |= B_ERROR;
|
2000-01-18 22:51:03 +03:00
|
|
|
biodone (dp);
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
if (tsreg->tssr & TS_SC) { /* Special Condition; Error */
|
1996-07-20 23:00:22 +04:00
|
|
|
log (TS_PRI, "%s: tssr 0x%x, state %d\n",
|
|
|
|
sc->sc_dev.dv_xname, tsreg->tssr, sc->sc_state);
|
|
|
|
tsinit (sc);
|
1996-01-06 19:43:46 +03:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
/* XXX */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if command is an ioctl or not (ie. read or write).
|
|
|
|
* If it's an ioctl then just set the flags for later use;
|
|
|
|
* For other commands attempt to setup a buffer pointer.
|
|
|
|
*/
|
1996-07-20 23:00:22 +04:00
|
|
|
if (bp == &ts_cbuf[ctlr]) {
|
1996-01-06 19:43:46 +03:00
|
|
|
ioctl = 1;
|
|
|
|
} else {
|
|
|
|
ioctl = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* now we try to map the buffer into uba map space (???)
|
|
|
|
*/
|
|
|
|
i = TS_UBAFLAGS;
|
1996-07-20 23:00:22 +04:00
|
|
|
switch (vax_cputype) {
|
1996-01-06 19:43:46 +03:00
|
|
|
case VAX_8600:
|
|
|
|
case VAX_780:
|
|
|
|
i |= UBA_CANTWAIT;
|
|
|
|
break;
|
|
|
|
case VAX_750:
|
1996-07-20 23:00:22 +04:00
|
|
|
i |= sc->sc_unit.uu_ubinfo | UBA_CANTWAIT;
|
1996-01-06 19:43:46 +03:00
|
|
|
break;
|
|
|
|
case VAX_730:
|
|
|
|
case VAX_78032:
|
|
|
|
i |= UBA_CANTWAIT;
|
|
|
|
break;
|
|
|
|
default:
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("unsupported cpu %d in tsstart.\n", vax_cputype);
|
1996-07-20 23:00:22 +04:00
|
|
|
} /* end switch (vax_cputype) */
|
1996-01-06 19:43:46 +03:00
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
if ((i = ubasetup(sc->sc_dev.dv_parent->dv_unit, bp, i)) == 0) {
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* For some reasons which I don't (yet? :) understand,
|
|
|
|
* tmscp.c initiates in this situation a GET-UNIT
|
2003-11-17 14:16:10 +03:00
|
|
|
* command. (Because no data-buffers are necessary?)
|
1996-01-06 19:43:46 +03:00
|
|
|
*/
|
|
|
|
cmd = TS_CMD_STAT;
|
|
|
|
goto do_cmd;
|
|
|
|
return (-1); /* ??? */
|
|
|
|
}
|
2001-05-16 09:36:53 +04:00
|
|
|
#if VAX750 || VAXANY
|
1996-07-20 23:00:22 +04:00
|
|
|
if (vax_cputype == VAX_750)
|
1996-01-06 19:43:46 +03:00
|
|
|
itmp = i & 0xfffffff; /* mask off bdp */
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
itmp = i;
|
|
|
|
|
|
|
|
/* XXX */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If it's an ioctl command, then assemble the command.
|
|
|
|
* The "b_resid" field holds the command-number as defined
|
|
|
|
* in <sys/mtio.h>
|
|
|
|
*/
|
|
|
|
if (ioctl) {
|
|
|
|
switch ((int)bp->b_resid) {
|
|
|
|
case MTWEOF:
|
|
|
|
cmd = TS_CMD_WTM;
|
|
|
|
break;
|
|
|
|
case MTFSF:
|
|
|
|
cmd = TS_CMD_STMF;
|
|
|
|
tscmdp->cw1 = bp->b_bcount;
|
|
|
|
break;
|
|
|
|
case MTBSF:
|
|
|
|
cmd = TS_CMD_STMR;
|
|
|
|
tscmdp->cw1 = bp->b_bcount;
|
|
|
|
break;
|
|
|
|
case MTFSR:
|
|
|
|
cmd = TS_CMD_SRF;
|
|
|
|
tscmdp->cw1 = bp->b_bcount;
|
|
|
|
break;
|
|
|
|
case MTBSR:
|
|
|
|
cmd = TS_CMD_SRR;
|
|
|
|
tscmdp->cw1 = bp->b_bcount;
|
|
|
|
break;
|
|
|
|
case MTREW:
|
|
|
|
cmd = TS_CMD_RWND;
|
|
|
|
#ifndef TS11_COMPAT
|
|
|
|
if (bp->b_bcount == 0) {
|
|
|
|
cmd = TS_CMD_RWII;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case MTOFFL:
|
|
|
|
cmd = TS_CMD_RWUL;
|
|
|
|
break;
|
|
|
|
case MTNOP:
|
|
|
|
cmd = TS_CMD_STAT;
|
|
|
|
break;
|
|
|
|
default:
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s: bad ioctl %d\n", sc->sc_dev.dv_xname,
|
1996-07-20 23:00:22 +04:00
|
|
|
(int)bp->b_resid);
|
1996-01-06 19:43:46 +03:00
|
|
|
/* Need a no-op. get status */
|
|
|
|
cmd = TS_CMD_STAT;
|
|
|
|
} /* end switch (bp->b_resid) */
|
|
|
|
} else { /* Its a read/write command (not an ioctl) */
|
|
|
|
tscmdp->cw1 = UBAI_ADDR(i) & 0xffff;
|
|
|
|
tscmdp->cw2 = (UBAI_ADDR(i) >> 16) & 0x3f;
|
|
|
|
tscmdp->cw3 = bp->b_bcount;
|
|
|
|
|
|
|
|
if (bp->b_flags & B_READ) {
|
|
|
|
cmd = TS_CMD_RNF;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cmd = TS_CMD_WD;
|
|
|
|
}
|
|
|
|
bp->b_ubinfo = itmp; /* save mapping info */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move buffer to I/O wait pseudo-queue
|
|
|
|
*/
|
1996-07-20 23:00:22 +04:00
|
|
|
if (ts_wtab[ctlr]) {
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* we are already waiting for something ...
|
|
|
|
* this should not happen, so we have a problem now.
|
2000-01-18 22:51:03 +03:00
|
|
|
* bertram: set error-flag and call biodone() ???
|
1996-01-06 19:43:46 +03:00
|
|
|
*/
|
|
|
|
}
|
1996-07-20 23:00:22 +04:00
|
|
|
ts_wtab[ctlr] = bp;
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that the command-buffer is setup, give it to the controller
|
|
|
|
*/
|
|
|
|
do_cmd:
|
1996-07-20 23:00:22 +04:00
|
|
|
return (tsexec(ctlr, cmd));
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* initialize the controller by sending WRITE CHARACTERISTICS command.
|
|
|
|
* contents of command- and message-buffer are assembled during this
|
|
|
|
* function.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
tswchar (ctlr)
|
|
|
|
int ctlr;
|
|
|
|
{
|
1996-07-20 23:00:22 +04:00
|
|
|
struct ts_softc *sc = ts_cd.cd_devs[ctlr];
|
1996-01-06 19:43:46 +03:00
|
|
|
volatile struct tsdevice *tsregs = ts[ctlr].reg;
|
|
|
|
volatile struct tscmd *tscmdp = &ts[ctlr].cmd;
|
|
|
|
volatile struct tsmsg *tsmsgp = &ts[ctlr].msg;
|
|
|
|
volatile unsigned int sr, ma, timeout;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* assemble and send "WRITE CHARACTERISTICS" command
|
|
|
|
*/
|
1996-07-20 23:00:22 +04:00
|
|
|
ma = (long)tsmsgp;
|
|
|
|
if (ma & 0x7FC00001) { /* address must be even and 22-bit */
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("invalid address 0x%0x for msg-buffer.\n", ma);
|
1996-07-20 23:00:22 +04:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
tsmsgp->hdr = ma & 0xFFFF; /* low order addr. bits */
|
|
|
|
tsmsgp->dfl = (ma >> 16) & 0x003F; /* high order addr. bits */
|
|
|
|
tsmsgp->rbpcr = 16; /* size of message-buffer */
|
|
|
|
tsmsgp->xst0 = 0; /* chacacteristics mode word */
|
|
|
|
tsmsgp->xst1 = 0; /* control word (ext.feat.) */
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
#ifdef TS11_COMPAT
|
|
|
|
tsmsgp->rbpcr = 14; /* size of message-buffer */
|
|
|
|
tsmsgp->xst0 = 0; /* chacacteristics mode word */
|
|
|
|
tsmsgp->xst1 = 0; /* control word (ext.feat.) */
|
|
|
|
#else
|
|
|
|
tsmsgp->rbpcr = 16; /* size of extended message buffer */
|
|
|
|
tsmsgp->xst0 = 0; /* chacacteristics mode word */
|
|
|
|
tsmsgp->xst1 = 0; /* unit-select */
|
|
|
|
tsmsgp->xst1 |= TS_WC_HSP; /* high speed */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ENABLE_ESS
|
|
|
|
tsmsgp->xst0 |= TS_WC_ESS;
|
|
|
|
#ifdef ENABLE_ENB
|
|
|
|
tsmsgp->xst0 |= TS_WC_ENB;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ENABLE_EAI
|
|
|
|
tsmsgp->xst0 |= TS_WC_EAI;
|
|
|
|
#ifdef ENABLE_ERI
|
|
|
|
tsmsgp->xst0 |= TS_WC_ERI;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
tscmdp->cmdr = TS_CF_ACK | TS_CF_IE | TS_CMD_WCHAR; /* obsolete */
|
|
|
|
tscmdp->cw1 = ma & 0xFFFF;
|
|
|
|
tscmdp->cw2 = (ma >> 16) & 0x003F;
|
|
|
|
tscmdp->cw3 = 10; /* size of charact.-data */
|
1996-01-06 19:43:46 +03:00
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
if (tsexec (ctlr, TS_CMD_WCHAR) < 0) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s: write characteristics command failed [%x]\n",
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_dev.dv_xname, tsregs->tssr);
|
|
|
|
return (-1);
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
timeout = 1000; /* timeout in 10 seconds */
|
|
|
|
do {
|
1996-01-06 19:43:46 +03:00
|
|
|
DELAY(10000);
|
1996-07-20 23:00:22 +04:00
|
|
|
sr = tsregs->tssr;
|
|
|
|
debug10 (("\ttssr: 0x%x\n", sr));
|
|
|
|
if (timeout-- > 0) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("timeout during initialize.");
|
1996-07-20 23:00:22 +04:00
|
|
|
tsstatus (sr);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
} while ((sr & TS_SSR) == 0);
|
|
|
|
tsstatus (sr);
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
1996-04-08 22:32:26 +04:00
|
|
|
void
|
|
|
|
tsreset(ctlr)
|
1996-01-06 19:43:46 +03:00
|
|
|
int ctlr;
|
|
|
|
{
|
1996-07-20 23:00:22 +04:00
|
|
|
struct ts_softc *sc = ts_cd.cd_devs[ctlr];
|
1996-01-06 19:43:46 +03:00
|
|
|
volatile struct tsdevice *tsreg = ts[ctlr].reg;
|
|
|
|
volatile unsigned int sr, timeout;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* reset ctlr by writing into TSSR, then write characteristics
|
|
|
|
*/
|
1996-07-20 23:00:22 +04:00
|
|
|
timeout = 1000; /* timeout in 10 seconds */
|
|
|
|
tsreg->tssr = 0; /* start initialization */
|
|
|
|
do {
|
1996-01-06 19:43:46 +03:00
|
|
|
DELAY(10000);
|
1996-07-20 23:00:22 +04:00
|
|
|
sr = tsreg->tssr;
|
|
|
|
debug10 (("\ttssr: 0x%x\n", sr));
|
|
|
|
if (timeout-- > 0) {
|
|
|
|
if (sr != 0)
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s: timeout waiting for TS_SSR\n",
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
tsstatus (sr);
|
1996-04-08 22:32:26 +04:00
|
|
|
return;
|
1996-07-20 23:00:22 +04:00
|
|
|
}
|
|
|
|
} while ((sr & TS_SSR) == 0); /* wait until subsystem ready */
|
|
|
|
tsstatus (sr);
|
1996-01-06 19:43:46 +03:00
|
|
|
|
1996-04-08 22:32:26 +04:00
|
|
|
return;
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* probe for device. If found, try to raise an interrupt.
|
1996-07-20 23:00:22 +04:00
|
|
|
* XXX - most of this should be done in the attach routine.
|
1996-01-06 19:43:46 +03:00
|
|
|
*/
|
1996-07-20 23:00:22 +04:00
|
|
|
int
|
|
|
|
tsmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
void *match, *aux;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
1996-07-20 23:00:22 +04:00
|
|
|
struct ts_softc *sc = match;
|
|
|
|
struct uba_softc *uh = (void *)parent;
|
|
|
|
struct uba_attach_args *ua = aux;
|
|
|
|
struct tsdevice *tsregs = (struct tsdevice*)ua->ua_addr;
|
1996-01-06 19:43:46 +03:00
|
|
|
volatile unsigned int sr, timeout, count;
|
1996-07-20 23:00:22 +04:00
|
|
|
int ctlr = sc->sc_dev.dv_unit;
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
ts_wtab[ctlr] = NULL;
|
|
|
|
sc->sc_ts = &ts[ctlr];
|
|
|
|
sc->sc_state = ST_PROBE;
|
|
|
|
sc->sc_flags = 0;
|
1996-07-20 23:00:22 +04:00
|
|
|
ts[ctlr].reg = (struct tsdevice*)ua->ua_addr;
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
/*
|
1996-07-20 23:00:22 +04:00
|
|
|
* Set host-settable interrupt vector.
|
|
|
|
* Assign 0 to the TSSR register to start the ts-device initialization.
|
|
|
|
* The device is not really initialized at this point, this is just to
|
|
|
|
* find out if the device exists.
|
|
|
|
*/
|
|
|
|
sc->sc_ivec = (uh->uh_lastiv -= 4);
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
count = 0;
|
|
|
|
again:
|
|
|
|
timeout = 1000; /* timeout in 10 seconds */
|
1996-07-20 23:00:22 +04:00
|
|
|
tsregs->tssr = 0; /* start initialization */
|
1996-01-06 19:43:46 +03:00
|
|
|
do {
|
|
|
|
DELAY(10000);
|
|
|
|
sr = tsregs->tssr;
|
|
|
|
debug10 (("\ttssr-1: 0x%x\n", sr));
|
|
|
|
if (timeout-- > 0) {
|
|
|
|
if (sr != 0) /* the device exists !!! */
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s: timeout waiting for TS_SSR\n",
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
1996-01-06 19:43:46 +03:00
|
|
|
tsstatus (sr);
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
} while ((sr & TS_SSR) == 0); /* wait until subsystem ready */
|
|
|
|
tsstatus (sr);
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
tswchar (ctlr); /* write charact. to enable interrupts */
|
1996-01-06 19:43:46 +03:00
|
|
|
/* completion of this will raise the intr. */
|
|
|
|
|
|
|
|
#ifdef notyet
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_ipl = br = qbgetpri();
|
1996-01-06 19:43:46 +03:00
|
|
|
#else
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_ipl = 0x15;
|
1996-01-06 19:43:46 +03:00
|
|
|
#endif
|
1996-07-20 23:00:22 +04:00
|
|
|
return (sizeof (struct tsdevice));
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
bad: if (++count < 3)
|
|
|
|
goto again;
|
|
|
|
|
|
|
|
#ifdef notyet
|
1996-07-20 23:00:22 +04:00
|
|
|
splx(s);
|
1996-01-06 19:43:46 +03:00
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to find a slave (a drive) on the controller.
|
|
|
|
* Since there's only one drive per controller there's nothing to do.
|
|
|
|
* (we could check the status of the drive (online/offline/...)
|
|
|
|
*/
|
1996-07-20 23:00:22 +04:00
|
|
|
void
|
|
|
|
tsattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
1996-07-20 23:00:22 +04:00
|
|
|
struct ts_softc *sc = (void *)self;
|
|
|
|
int ctlr = sc->sc_dev.dv_unit;
|
|
|
|
struct tsmsg *tsmsgp = &ts[ctlr].msg;
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
trace (("tsslave (%x, %x)\n", ui, reg));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* write the characteristics (again)
|
|
|
|
* This will raise an interrupt during ST_SLAVE which indicates
|
|
|
|
* completion of initialization ...
|
|
|
|
*/
|
|
|
|
sc->sc_state = ST_SLAVE; /* tsintr() checks this ... */
|
|
|
|
if (tswchar (ctlr) < 0) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s: cannot initialize", sc->sc_dev.dv_xname);
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
sc->sc_micro = (tsmsgp->xst2 & TS_SF_MCRL) >> 2;
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s: rev %d, extended features %s, transport %s\n",
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_dev.dv_xname, sc->sc_micro,
|
1996-01-06 19:43:46 +03:00
|
|
|
(tsmsgp->xst2 & TS_SF_EFES ? "enabled" : "disabled"),
|
|
|
|
(ts[ctlr].reg->tssr & TS_OFL ? "offline" : "online"));
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
tsinit (sc); /* must be called once, why not here ? */
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TSV05/TS05 interrupt routine
|
|
|
|
*/
|
1996-04-08 22:32:26 +04:00
|
|
|
void
|
1996-01-06 19:43:46 +03:00
|
|
|
tsintr(ctlr)
|
1996-04-08 22:32:26 +04:00
|
|
|
int ctlr;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
1996-07-20 23:00:22 +04:00
|
|
|
register struct ts_softc *sc = ts_cd.cd_devs[ctlr];
|
1996-01-06 19:43:46 +03:00
|
|
|
register struct tsmsg *tsmsgp = &ts[ctlr].msg;
|
|
|
|
register struct tscmd *tscmdp = &ts[ctlr].cmd;
|
|
|
|
volatile struct tsdevice *tsreg = ts[ctlr].reg;
|
1996-07-20 23:00:22 +04:00
|
|
|
struct uba_unit *um = &sc->sc_unit;
|
1996-01-06 19:43:46 +03:00
|
|
|
register struct buf *bp;
|
|
|
|
|
|
|
|
unsigned short sr = tsreg->tssr; /* save TSSR */
|
|
|
|
unsigned short mh = tsmsgp->hdr; /* and msg-header */
|
|
|
|
/* clear the message header ??? */
|
|
|
|
|
|
|
|
short ccode = tscmdp->cmdr & TS_CF_CCODE;
|
|
|
|
short cmask = tscmdp->cmdr & TS_CF_CMASK;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1996-11-15 06:32:46 +03:00
|
|
|
{
|
|
|
|
char bits[64];
|
|
|
|
printf ("TSSR: %s, MSG: %x ", bitmask_snprintf(sr,
|
|
|
|
TS_TSSR_BITS, bits, sizeof(bits)), mh);
|
|
|
|
}
|
1996-01-06 19:43:46 +03:00
|
|
|
switch (tsmsgp->hdr & 0x001F) {
|
1996-10-13 07:29:05 +04:00
|
|
|
case 16: printf ("(End)"); break;
|
|
|
|
case 17: printf ("(Fail)"); break;
|
|
|
|
case 18: printf ("(Error)"); break;
|
|
|
|
case 19: printf ("(Attention)"); break;
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
trace ((" tsintr (%d, %d, %d, %x)\n", uba, vector, level, ctlr));
|
|
|
|
|
|
|
|
if (tsmsgp->xst0 & TS_SF_VCK)
|
|
|
|
sc->sc_cmdf |= TS_CF_CVC;
|
|
|
|
|
|
|
|
#ifdef QBA /* copied from uda.c */
|
1996-07-20 23:00:22 +04:00
|
|
|
if(vax_cputype == VAX_78032)
|
|
|
|
splx(sc->sc_ipl); /* Qbus interrupt protocol is odd */
|
1996-01-06 19:43:46 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There are two different things which can (and should) be checked:
|
|
|
|
* the actual (internal) state and the device's result (tssr/msg.hdr)
|
|
|
|
*
|
|
|
|
* For each state there's only one "normal" interrupt. Anything else
|
|
|
|
* has to be checked more intensively. Thus in a first run according
|
|
|
|
* to the internal state the expected interrupt is checked/handled.
|
|
|
|
*
|
|
|
|
* In a second run the remaining (not yet handled) interrupts are
|
|
|
|
* checked according to the drive's result.
|
|
|
|
*/
|
|
|
|
switch (sc->sc_state) {
|
|
|
|
|
|
|
|
case ST_INVALID:
|
1996-07-20 23:00:22 +04:00
|
|
|
/*
|
|
|
|
* Ignore unsolicited interrupts.
|
|
|
|
*/
|
|
|
|
log (LOG_WARNING, "%s: stray intr [%x,%x]\n",
|
|
|
|
sc->sc_dev.dv_xname, sr, mh);
|
|
|
|
return;
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
case ST_SLAVE:
|
|
|
|
/*
|
|
|
|
* this interrupt was caused by write-charact. command
|
|
|
|
* issued by tsslave() and indicates the end of the
|
|
|
|
* initialization phase. Just ignore it ...
|
|
|
|
*/
|
|
|
|
if ((sr & TS_SC) != 0 || (sr & TS_TC) != TS_TC_NORM) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf("%s: problem during init [%x,%x]\n",
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_dev.dv_xname, sr, mh);
|
1996-01-06 19:43:46 +03:00
|
|
|
/* return here ??? */
|
|
|
|
/* break and check the error outside switch ??? */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sc->sc_state = ST_RUNNING;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
case ST_RUNNING:
|
|
|
|
/*
|
|
|
|
* Here we expect interrupts indicating the end of
|
|
|
|
* commands or indicating problems.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Anything else is handled outside this switch ...
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ST_IDLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s: unexpected interrupt during state %d [%x,%x]\n",
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_dev.dv_xname, sc->sc_state, sr, mh);
|
1996-01-06 19:43:46 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* now we check the termination class.
|
|
|
|
*/
|
|
|
|
switch (sr & TS_TC) {
|
|
|
|
|
|
|
|
case TS_TC_NORM:
|
|
|
|
/*
|
|
|
|
* Normal termination -- The operation is completed
|
|
|
|
* witout incident.
|
|
|
|
*/
|
|
|
|
sc->sc_state = ST_IDLE; /* XXX ??? */
|
|
|
|
sc->sc_state = ST_RUNNING;
|
|
|
|
sc->sc_liowf = (ccode == TS_CC_WRITE);
|
|
|
|
sc->sc_rtc = 0;
|
|
|
|
if ((bp = ts_wtab[ctlr]) != NULL) {
|
|
|
|
ts_wtab[ctlr] = NULL; /* pseudo-unlink */
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
if (bp != &ts_cbuf[ctlr]) { /* no ioctl */
|
1997-01-11 14:34:39 +03:00
|
|
|
ubarelse((struct uba_softc *)
|
|
|
|
sc->sc_dev.dv_parent,
|
1996-07-20 23:00:22 +04:00
|
|
|
(int *)&bp->b_ubinfo);
|
2001-05-16 09:36:53 +04:00
|
|
|
#if VAX750 || VAXANY
|
1996-07-20 23:00:22 +04:00
|
|
|
if (vax_cputype == VAX_750 &&
|
|
|
|
sc->sc_unit.uu_ubinfo != 0)
|
1997-01-11 14:34:39 +03:00
|
|
|
ubarelse((struct uba_softc *)
|
|
|
|
sc->sc_dev.dv_parent,
|
1996-07-20 23:00:22 +04:00
|
|
|
&sc->sc_unit.uu_ubinfo);
|
1996-01-06 19:43:46 +03:00
|
|
|
/* XXX */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
bp->b_resid = tsmsgp->rbpcr;
|
2000-01-18 22:51:03 +03:00
|
|
|
debug (("tsintr: biodone(NORM) [%d,%d,%d]\n",
|
1996-01-06 19:43:46 +03:00
|
|
|
bp->b_resid, bp->b_bcount, tsmsgp->rbpcr));
|
2000-01-18 22:51:03 +03:00
|
|
|
biodone (bp); /* bertram: ioctl ??? */
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TS_TC_ATTN:
|
|
|
|
/*
|
|
|
|
* Attention condition -- this code indicates that the
|
|
|
|
* drive has undergone a status change, such as going
|
|
|
|
* off-line or coming on-line.
|
|
|
|
* (Without EAI enabled, no Attention interrupts occur.
|
|
|
|
* drive status changes are signaled by the VCK flag.)
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
case TS_TC_TSA:
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* Tape Status Alert -- A status condition is encountered
|
|
|
|
* that may have significance to the program. Bits of
|
|
|
|
* interest in the extended status registers include
|
|
|
|
* TMK, EOT and RLL.
|
|
|
|
*/
|
|
|
|
debug (("Tape Status Alert\n"));
|
|
|
|
tsxstatus (tsmsgp);
|
|
|
|
if (tsmsgp->xst0 & TS_SF_TMK) {
|
|
|
|
debug (("Tape Mark detected"));
|
|
|
|
}
|
|
|
|
if (tsmsgp->xst0 & TS_SF_EOT) {
|
|
|
|
debug (("End of Tape"));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
case TS_TC_FR:
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* Function Reject -- The specified function was not
|
|
|
|
* initiated. Bits of interest include OFL, VCK, BOT,
|
|
|
|
* WLE, ILC and ILA.
|
|
|
|
*/
|
|
|
|
debug (("Function reject\n"));
|
|
|
|
tsxstatus (tsmsgp);
|
|
|
|
if (sr & TS_OFL) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("tape is off-line.\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (tsmsgp->xst0 & TS_SF_VCK) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("Volume check: repeating command ...\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
tsexec (ctlr, tscmdp->cmdr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (tsmsgp->xst0 & TS_SF_BOT) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("bottom of tape.\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
if (tsmsgp->xst0 & TS_SF_WLE) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("Write Lock Error\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
case TS_TC_TPD:
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* Recoverable Error -- Tape position is a record beyond
|
|
|
|
* what its position was when the function was initiated.
|
|
|
|
* Suggested recovery procedure is to log the error and
|
|
|
|
* issue the appropriate retry command.
|
|
|
|
*/
|
|
|
|
debug (("Tape position down\n"));
|
|
|
|
switch (cmask) {
|
|
|
|
case TS_CMD_RNF: /* Read Next (forward) */
|
|
|
|
debug (("retry read forward ...\n"));
|
|
|
|
sc->sc_rtc = 1;
|
|
|
|
tsexec (ctlr, TS_CMD_RPF);
|
|
|
|
return;
|
|
|
|
case TS_CMD_RPR: /* Read Previous (Reverse) */
|
|
|
|
debug (("retry read reverse ...\n"));
|
|
|
|
sc->sc_rtc = 1;
|
|
|
|
tsexec (ctlr, TS_CMD_RNR);
|
|
|
|
return;
|
|
|
|
case TS_CMD_WD: /* Write Data (Next) */
|
|
|
|
debug (("retry write data ...\n"));
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_rtc = 1;
|
1996-01-06 19:43:46 +03:00
|
|
|
tsexec (ctlr, TS_CMD_WDR);
|
|
|
|
return;
|
|
|
|
case TS_CMD_WTM:
|
|
|
|
debug (("retry write tape mark ...\n"));
|
|
|
|
sc->sc_rtc = 1;
|
|
|
|
tsexec (ctlr, TS_CMD_WTMR);
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
debug (("TPD in command %x\n", cmask));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
case TS_TC_TNM:
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* Recoverable Error -- Tape position has not changed.
|
|
|
|
* Suggested recovery procedure is to log the error and
|
|
|
|
* reissue the original command.
|
|
|
|
*/
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("Tape not moved\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
if (sc->sc_rtc < 3) {
|
|
|
|
sc->sc_rtc++;
|
|
|
|
/* bertram: log the error !!! */
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("retrying command %x (%d)\n",
|
1996-01-06 19:43:46 +03:00
|
|
|
tscmdp->cmdr, sc->sc_rtc);
|
|
|
|
tsexec (ctlr, tscmdp->cmdr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
case TS_TC_TPL:
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* Unrecoverable Error -- Tape position has been lost.
|
|
|
|
* No valid recovery procedures exist unless the tape
|
|
|
|
* has labels or sequence numbers.
|
|
|
|
*/
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("Tape position lost\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
break;
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
case TS_TC_FCE:
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* Fatal subsytem Error -- The subsytem is incapable
|
|
|
|
* of properly performing commands, or at least its
|
|
|
|
* integrity is seriously questionable. Refer to the
|
|
|
|
* fatal class code field in the TSSR register for
|
|
|
|
* additional information on the type of fatal error.
|
|
|
|
*/
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("Fatal Controller Error\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
default:
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s: error 0x%x, resetting controller\n",
|
1996-07-20 23:00:22 +04:00
|
|
|
sc->sc_dev.dv_xname, sr & TS_TC);
|
1996-01-06 19:43:46 +03:00
|
|
|
tsreset (ctlr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* reset controller ?? call tsinit() ???
|
|
|
|
*/
|
|
|
|
if ((bp = ts_wtab[ctlr]) != NULL) {
|
|
|
|
ts_wtab[ctlr] = NULL; /* pseudo unlink */
|
|
|
|
|
1997-01-11 14:34:39 +03:00
|
|
|
if (bp != &ts_cbuf[ctlr]) /* no ioctl */
|
|
|
|
ubarelse((struct uba_softc *)sc->sc_dev.dv_parent,
|
1996-07-20 23:00:22 +04:00
|
|
|
(int *)&bp->b_ubinfo);
|
1997-01-11 14:34:39 +03:00
|
|
|
|
|
|
|
if ((sr & TS_TC) != TS_TC_NORM)
|
1996-01-06 19:43:46 +03:00
|
|
|
bp->b_flags |= B_ERROR;
|
1997-01-11 14:34:39 +03:00
|
|
|
|
1996-01-06 19:43:46 +03:00
|
|
|
debug (("resid:%d, count:%d, rbpcr:%d\n",
|
|
|
|
bp->b_resid, bp->b_bcount, tsmsgp->rbpcr));
|
|
|
|
bp->b_resid = tsmsgp->rbpcr; /* XXX */
|
2000-01-18 22:51:03 +03:00
|
|
|
debug (("tsintr: biodone(%x)\n", bp->b_flags));
|
|
|
|
biodone (bp);
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
if ((sr & TS_TC) > TS_TC_FR)
|
|
|
|
tsreset (ctlr);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open a ts device and set the unit online. If the controller is not
|
|
|
|
* in the run state, call init to initialize the ts controller first.
|
|
|
|
*/
|
|
|
|
int
|
1996-04-08 22:32:26 +04:00
|
|
|
tsopen (dev, flag, type, p)
|
1996-01-06 19:43:46 +03:00
|
|
|
dev_t dev;
|
1996-04-08 22:32:26 +04:00
|
|
|
int flag, type;
|
|
|
|
struct proc *p;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
|
|
|
register struct uba_device *ui;
|
|
|
|
register struct uba_ctlr *um;
|
|
|
|
register struct ts_softc *sc;
|
|
|
|
register int unit = TS_UNIT(dev);
|
|
|
|
int s;
|
|
|
|
|
|
|
|
trace (("tsopen (%x, %x)\n", dev, flag));
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
if (unit >= ts_cd.cd_ndevs)
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
sc = ts_cd.cd_devs[unit];
|
|
|
|
if (sc == 0)
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
if (sc->sc_openf)
|
|
|
|
return EBUSY;
|
|
|
|
|
1996-01-06 19:43:46 +03:00
|
|
|
sc->sc_openf = 1;
|
1996-07-20 23:00:22 +04:00
|
|
|
|
1996-01-06 19:43:46 +03:00
|
|
|
s = splbio ();
|
|
|
|
if (sc->sc_state < ST_RUNNING) { /* XXX */
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s not running.\n", sc->sc_dev.dv_xname);
|
1996-01-06 19:43:46 +03:00
|
|
|
(void) splx (s);
|
|
|
|
sc->sc_openf = 0;
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
(void) splx (s);
|
1996-07-20 23:00:22 +04:00
|
|
|
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* check if transport is really online.
|
|
|
|
* (without attention-interrupts enabled, we really don't know
|
|
|
|
* the actual state of the transport. Thus we call get-status
|
|
|
|
* (ie. MTNOP) once and check the actual status.)
|
|
|
|
*/
|
|
|
|
tscommand (dev, MTNOP, 1);
|
1996-07-20 23:00:22 +04:00
|
|
|
if (ts[unit].reg->tssr & TS_OFL) {
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("%s: transport is offline.\n", sc->sc_dev.dv_xname);
|
1996-01-06 19:43:46 +03:00
|
|
|
sc->sc_openf = 0;
|
1996-07-20 23:00:22 +04:00
|
|
|
return EIO; /* transport is offline */
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
1996-07-20 23:00:22 +04:00
|
|
|
|
1996-01-06 19:43:46 +03:00
|
|
|
sc->sc_liowf = 0;
|
1996-07-20 23:00:22 +04:00
|
|
|
return 0;
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close tape device.
|
|
|
|
*
|
|
|
|
* If tape was open for writing or last operation was
|
|
|
|
* a write, then write two EOF's and backspace over the last one.
|
|
|
|
* Unless this is a non-rewinding special file, rewind the tape.
|
|
|
|
*
|
|
|
|
* Make the tape available to others, by clearing openf flag.
|
|
|
|
*/
|
|
|
|
int
|
1996-04-08 22:32:26 +04:00
|
|
|
tsclose (dev, flag, type, p)
|
1996-07-20 23:00:22 +04:00
|
|
|
dev_t dev;
|
|
|
|
int flag, type;
|
1996-04-08 22:32:26 +04:00
|
|
|
struct proc *p;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
1996-07-20 23:00:22 +04:00
|
|
|
register struct ts_softc *sc = ts_cd.cd_devs[TS_UNIT(dev)];
|
1996-01-06 19:43:46 +03:00
|
|
|
|
1996-04-08 22:32:26 +04:00
|
|
|
if (flag == FWRITE || ((flag & FWRITE) && sc->sc_liowf)) {
|
1996-01-06 19:43:46 +03:00
|
|
|
/*
|
|
|
|
* We are writing two tape marks (EOT), but place the tape
|
|
|
|
* before the second one, so that another write operation
|
|
|
|
* will overwrite the second one and leave and EOF-mark.
|
|
|
|
*/
|
|
|
|
tscommand (dev, MTWEOF, 1); /* Write Tape Mark */
|
|
|
|
tscommand (dev, MTWEOF, 1); /* Write Tape Mark */
|
1996-07-20 23:00:22 +04:00
|
|
|
tscommand (dev, MTBSF, 1); /* Skip Tape Marks Reverse */
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
if ((dev & T_NOREWIND) == 0)
|
1996-01-06 19:43:46 +03:00
|
|
|
tscommand (dev, MTREW, 0);
|
|
|
|
|
|
|
|
sc->sc_openf = 0;
|
|
|
|
sc->sc_liowf = 0;
|
1996-07-20 23:00:22 +04:00
|
|
|
return 0;
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Manage buffers and perform block mode read and write operations.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
tsstrategy (bp)
|
1996-07-20 23:00:22 +04:00
|
|
|
register struct buf *bp;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
|
|
|
register int unit = TS_UNIT(bp->b_dev);
|
1996-07-20 23:00:22 +04:00
|
|
|
struct ts_softc *sc = (void *)ts_cd.cd_devs[unit];
|
1996-01-06 19:43:46 +03:00
|
|
|
int s;
|
|
|
|
|
|
|
|
s = splbio ();
|
|
|
|
/*
|
|
|
|
* we have only one command at one time, no credits.
|
|
|
|
* thus we don't need buffer management and controller queue
|
|
|
|
* just try to execute the command ...
|
|
|
|
*/
|
|
|
|
|
1996-07-20 23:00:22 +04:00
|
|
|
tsstart (sc, bp);
|
1996-01-06 19:43:46 +03:00
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Catch ioctl commands, and call the "command" routine to do them.
|
|
|
|
*/
|
|
|
|
int
|
1996-04-08 22:32:26 +04:00
|
|
|
tsioctl (dev, cmd, data, flag, p)
|
1996-07-20 23:00:22 +04:00
|
|
|
dev_t dev;
|
1996-04-08 22:32:26 +04:00
|
|
|
u_long cmd;
|
1996-07-20 23:00:22 +04:00
|
|
|
caddr_t data;
|
|
|
|
int flag;
|
1996-04-08 22:32:26 +04:00
|
|
|
struct proc *p;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
|
|
|
register struct buf *bp = &ts_cbuf[TS_UNIT(dev)];
|
|
|
|
register struct ts_softc *sc;
|
|
|
|
register struct mtop *mtop; /* mag tape cmd op to perform */
|
|
|
|
register struct mtget *mtget; /* mag tape struct to get info in */
|
|
|
|
register callcount; /* number of times to call routine */
|
|
|
|
int scount; /* number of files/records to space */
|
|
|
|
int spaceop = 0; /* flag for skip/space operation */
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
trace (("tsioctl (%x, %x, %x, %d)\n", dev, cmd, data, flag));
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case MTIOCTOP: /* do a mag tape op */
|
|
|
|
mtop = (struct mtop *)data;
|
|
|
|
switch (mtop->mt_op) {
|
|
|
|
case MTWEOF: /* write an end-of-file record */
|
|
|
|
callcount = mtop->mt_count;
|
|
|
|
scount = 1;
|
|
|
|
break;
|
|
|
|
case MTFSF: /* forward space file */
|
|
|
|
case MTBSF: /* backward space file */
|
|
|
|
case MTFSR: /* forward space record */
|
|
|
|
case MTBSR: /* backward space record */
|
|
|
|
spaceop = 1;
|
|
|
|
callcount = 1;
|
|
|
|
scount = mtop->mt_count;
|
|
|
|
break;
|
|
|
|
case MTREW: /* rewind */
|
|
|
|
case MTOFFL: /* rewind and put the drive offline */
|
|
|
|
case MTNOP: /* no operation, sets status only */
|
|
|
|
callcount = 1;
|
|
|
|
scount = 1; /* wait for this rewind */
|
|
|
|
break;
|
|
|
|
case MTRETEN: /* retension */
|
|
|
|
case MTERASE: /* erase entire tape */
|
|
|
|
case MTEOM: /* forward to end of media */
|
|
|
|
case MTNBSF: /* backward space to begin of file */
|
|
|
|
case MTCACHE: /* enable controller cache */
|
|
|
|
case MTNOCACHE: /* disable controller cache */
|
|
|
|
case MTSETBSIZ: /* set block size; 0 for variable */
|
|
|
|
case MTSETDNSTY: /* set density code for current mode */
|
|
|
|
debug (("ioctl %d not implemented.\n", mtop->mt_op));
|
|
|
|
return (ENXIO);
|
|
|
|
default:
|
|
|
|
debug (("invalid ioctl %d\n", mtop->mt_op));
|
|
|
|
return (ENXIO);
|
|
|
|
} /* switch (mtop->mt_op) */
|
|
|
|
|
|
|
|
if (callcount <= 0 || scount <= 0) {
|
|
|
|
debug (("invalid values %d/%d\n", callcount, scount));
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
do {
|
|
|
|
tscommand (dev, mtop->mt_op, scount);
|
|
|
|
if (spaceop && bp->b_resid) {
|
|
|
|
debug (("spaceop didn't complete\n"));
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
if (bp->b_flags & B_ERROR) {
|
|
|
|
debug (("error in ioctl %d\n", mtop->mt_op));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (--callcount > 0);
|
|
|
|
if (bp->b_flags & B_ERROR)
|
|
|
|
if ((error = bp->b_error) == 0)
|
|
|
|
return (EIO);
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
case MTIOCGET: /* get tape status */
|
1996-07-20 23:00:22 +04:00
|
|
|
sc = ts_cd.cd_devs[TS_UNIT(dev)];
|
1996-01-06 19:43:46 +03:00
|
|
|
mtget = (struct mtget *)data;
|
|
|
|
mtget->mt_type = MT_ISTS;
|
1996-07-20 23:00:22 +04:00
|
|
|
mtget->mt_dsreg = (unsigned)(ts[TS_UNIT(dev)].reg->tssr);
|
|
|
|
mtget->mt_erreg = (unsigned)(ts[TS_UNIT(dev)].msg.hdr);
|
1996-01-06 19:43:46 +03:00
|
|
|
mtget->mt_resid = 0; /* ??? */
|
|
|
|
mtget->mt_density = 0; /* ??? */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MTIOCIEOT: /* ignore EOT error */
|
|
|
|
debug (("MTIOCIEOT not implemented.\n"));
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
case MTIOCEEOT: /* enable EOT error */
|
|
|
|
debug (("MTIOCEEOT not implemented.\n"));
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
default:
|
|
|
|
debug (("invalid ioctl cmd 0x%x\n", cmd));
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int
|
2002-09-06 17:18:43 +04:00
|
|
|
tsread (dev, uio, flag)
|
1996-01-06 19:43:46 +03:00
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
2002-09-06 17:18:43 +04:00
|
|
|
int flag;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
|
|
|
return (physio (tsstrategy, NULL, dev, B_READ, minphys, uio));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int
|
2002-09-06 17:18:43 +04:00
|
|
|
tswrite (dev, uio, flag)
|
1996-01-06 19:43:46 +03:00
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
2002-09-06 17:18:43 +04:00
|
|
|
int flag;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
|
|
|
return (physio (tsstrategy, NULL, dev, B_WRITE, minphys, uio));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int
|
1996-04-08 22:32:26 +04:00
|
|
|
tsdump(dev, blkno, va, size)
|
1996-01-06 19:43:46 +03:00
|
|
|
dev_t dev;
|
1996-04-08 22:32:26 +04:00
|
|
|
daddr_t blkno;
|
|
|
|
caddr_t va;
|
|
|
|
size_t size;
|
1996-01-06 19:43:46 +03:00
|
|
|
{
|
|
|
|
trace (("tsdump (%x)\n", dev));
|
1996-04-08 22:32:26 +04:00
|
|
|
return 0;
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
int
|
|
|
|
tsstatus (sr)
|
|
|
|
int sr;
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
1996-11-15 06:32:46 +03:00
|
|
|
char bits[64];
|
|
|
|
|
|
|
|
debug (("status: TSSR=%s\n", bitmask_snprintf(sr, TS_TSSR_BITS,
|
|
|
|
bits, sizeof(bits))));
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
if (tsdebug < 5)
|
|
|
|
return (0);
|
|
|
|
|
1996-10-13 07:29:05 +04:00
|
|
|
if (sr & TS_SC) printf ("special condition\n");
|
|
|
|
if (sr & TS_UPE) printf ("UPE\n");
|
|
|
|
if (sr & TS_SCE) printf ("Sanity Check Error\n");
|
|
|
|
if (sr & TS_RMR) printf ("Register Modification Refused\n");
|
|
|
|
if (sr & TS_NXM) printf ("Nonexistent Memory\n");
|
|
|
|
if (sr & TS_NBA) printf ("Need Buffer Address\n");
|
|
|
|
if (sr & TS_A11) printf ("Address Bits 17-16\n");
|
|
|
|
if (sr & TS_SSR) printf ("Subsystem Ready\n");
|
|
|
|
if (sr & TS_OFL) printf ("Off Line\n");
|
|
|
|
if (sr & TS_FTC) printf ("Fatal Termination Class Code\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
switch (sr & TS_TC) {
|
1996-10-13 07:29:05 +04:00
|
|
|
case TS_TC_NORM: printf ("Normal Termination\n"); break;
|
|
|
|
case TS_TC_ATTN: printf ("Attention Condition\n"); break;
|
|
|
|
case TS_TC_TSA: printf ("Tape status \n"); break;
|
|
|
|
case TS_TC_FR: printf ("Function reject\n"); break;
|
|
|
|
case TS_TC_TPD: printf ("Tape position down\n"); break;
|
|
|
|
case TS_TC_TNM: printf ("Tape not moved\n"); break;
|
|
|
|
case TS_TC_TPL: printf ("Tape position lost\n"); break;
|
|
|
|
case TS_TC_FCE: printf ("Fatal Controller Error\n"); break;
|
1996-01-06 19:43:46 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-04-08 22:32:26 +04:00
|
|
|
void
|
1996-01-06 19:43:46 +03:00
|
|
|
tsxstatus (mp)
|
|
|
|
struct tsmsg *mp;
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
1996-11-15 06:32:46 +03:00
|
|
|
char bits[64];
|
|
|
|
|
|
|
|
debug (("tsxstatus: xst0=%s, ", bitmask_snprintf(mp->xst0,
|
|
|
|
TS_XST0_BITS, bits, sizeof(bits))));
|
|
|
|
debug (("xst1=%s, ", bitmask_snprintf(mp->xst1, TS_XST1_BITS,
|
|
|
|
bits, sizeof(bits))));
|
|
|
|
debug (("xst2=%s, ", bitmask_snprintf(mp->xst2, TS_XST2_BITS,
|
|
|
|
bits, sizeof(bits))));
|
|
|
|
debug (("xst3=%s, ", bitmask_snprintf(mp->xst3, TS_XST3_BITS,
|
|
|
|
bits, sizeof(bits))));
|
|
|
|
debug (("xst4=%s\n", bitmask_snprintf(mp->xst4, "\20",
|
|
|
|
bits, sizeof(bits))));
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
if (tsdebug < 10)
|
|
|
|
return (0);
|
|
|
|
|
1996-10-13 07:29:05 +04:00
|
|
|
if (mp->xst0 & TS_SF_TMK) printf ("Tape Mark Detected\n");
|
|
|
|
if (mp->xst0 & TS_SF_RLS) printf ("Record Length Short\n");
|
|
|
|
if (mp->xst0 & TS_SF_LET) printf ("Logical End of Tape\n");
|
|
|
|
if (mp->xst0 & TS_SF_RLL) printf ("Record Length Long\n");
|
|
|
|
if (mp->xst0 & TS_SF_WLE) printf ("Write Lock Error\n");
|
|
|
|
if (mp->xst0 & TS_SF_NEF) printf ("Nonexecutable Function\n");
|
|
|
|
if (mp->xst0 & TS_SF_ILC) printf ("Illegal Command\n");
|
|
|
|
if (mp->xst0 & TS_SF_ILA) printf ("Illegal Address\n");
|
|
|
|
if (mp->xst0 & TS_SF_MOT) printf ("Motion\n");
|
|
|
|
if (mp->xst0 & TS_SF_ONL) printf ("On-Line\n");
|
|
|
|
if (mp->xst0 & TS_SF_IE) printf ("Interrupt Enable\n");
|
|
|
|
if (mp->xst0 & TS_SF_VCK) printf ("Volume Check\n");
|
|
|
|
if (mp->xst0 & TS_SF_PED) printf ("Phase Encoded Drive\n");
|
|
|
|
if (mp->xst0 & TS_SF_WLK) printf ("Write Locked\n");
|
|
|
|
if (mp->xst0 & TS_SF_BOT) printf ("Beginning of Tape\n");
|
|
|
|
if (mp->xst0 & TS_SF_EOT) printf ("End of Tape\n");
|
|
|
|
|
|
|
|
if (mp->xst1 & TS_SF_DLT) printf ("Data Late\n");
|
|
|
|
if (mp->xst1 & TS_SF_COR) printf ("Correctable Data\n");
|
|
|
|
if (mp->xst1 & TS_SF_RBP) printf ("Read Bus Parity Error\n");
|
|
|
|
if (mp->xst1 & TS_SF_UNC) printf ("Uncorrectable Data or Hard Error\n");
|
|
|
|
|
|
|
|
if (mp->xst2 & TS_SF_OPM) printf ("Operation in Progress\n");
|
|
|
|
if (mp->xst2 & TS_SF_RCE) printf ("RAM Checksum Error\n");
|
|
|
|
if (mp->xst2 & TS_SF_WCF) printf ("Write Clock Failure\n");
|
|
|
|
if (mp->xst2 & TS_SF_EFES) printf ("extended features enabled\n");
|
|
|
|
if (mp->xst2 & TS_SF_BES) printf ("Buffering enabled\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("micro-code revision level: %d\n", (mp->xst2 & TS_SF_MCRL)>>2);
|
|
|
|
printf ("unit number: %d\n", (mp->xst2 & TS_SF_UNIT));
|
1996-01-06 19:43:46 +03:00
|
|
|
|
|
|
|
if (mp->xst3 & TS_SF_MDE)
|
1996-10-13 07:29:05 +04:00
|
|
|
printf ("Micro-Diagnostics Error Code: 0x%x\n", mp->xst3 >> 8);
|
|
|
|
if (mp->xst3 & TS_SF_OPI) printf ("Operation Incomplete\n");
|
|
|
|
if (mp->xst3 & TS_SF_REV) printf ("Revers\n");
|
|
|
|
if (mp->xst3 & TS_SF_DCK) printf ("Density Check\n");
|
|
|
|
if (mp->xst3 & TS_SF_RIB) printf ("Reverse into BOT\n");
|
|
|
|
|
|
|
|
if (mp->xst4 & TS_SF_HSP) printf ("High Speed\n");
|
|
|
|
if (mp->xst4 & TS_SF_RCX) printf ("Retry Count Exceeded\n");
|
1996-01-06 19:43:46 +03:00
|
|
|
#endif
|
|
|
|
}
|