projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
somehow a real old version snuck in
[unix-history]
/
usr
/
src
/
sys
/
vax
/
uba
/
ts.c
diff --git
a/usr/src/sys/vax/uba/ts.c
b/usr/src/sys/vax/uba/ts.c
index
7874356
..
e7c16ac
100644
(file)
--- a/
usr/src/sys/vax/uba/ts.c
+++ b/
usr/src/sys/vax/uba/ts.c
@@
-1,20
+1,12
@@
-/* ts.c 4.
10 81/04/14
*/
+/* ts.c 4.
23 82/02/03
*/
#include "ts.h"
#include "ts.h"
-#include "tm.h"
#if NTS > 0
#if NTS > 0
-#define printd if(tsdebug)printf
-int tsdebug;
/*
* TS11 tape driver
*
* TODO:
/*
* TS11 tape driver
*
* TODO:
- * test driver with more than one controller
- * test reset code
- * test dump code
- * test rewinds without hanging in driver
- * what happens if you offline tape during rewind?
- * test using file system on tape
+ * write dump code
*/
#include "../h/param.h"
#include "../h/systm.h"
*/
#include "../h/param.h"
#include "../h/systm.h"
@@
-59,7
+51,7
@@
struct buf rtsbuf[NTS];
int tsprobe(), tsslave(), tsattach(), tsdgo(), tsintr();
struct uba_ctlr *tsminfo[NTS];
struct uba_device *tsdinfo[NTS];
int tsprobe(), tsslave(), tsattach(), tsdgo(), tsintr();
struct uba_ctlr *tsminfo[NTS];
struct uba_device *tsdinfo[NTS];
-struct buf ts
buf
[NTS];
+struct buf ts
utab
[NTS];
u_short tsstd[] = { 0772520, 0 };
/*** PROBABLY DON'T NEED ALL THESE SINCE CONTROLLER == DRIVE ***/
struct uba_driver zsdriver =
u_short tsstd[] = { 0772520, 0 };
/*** PROBABLY DON'T NEED ALL THESE SINCE CONTROLLER == DRIVE ***/
struct uba_driver zsdriver =
@@
-90,14
+82,14
@@
struct ts_softc {
short sc_resid; /* copy of last bc */
daddr_t sc_blkno; /* block number, for block device tape */
daddr_t sc_nxrec; /* position of end of tape, if known */
short sc_resid; /* copy of last bc */
daddr_t sc_blkno; /* block number, for block device tape */
daddr_t sc_nxrec; /* position of end of tape, if known */
- struct ts_cmd sc_cmd; /* the command packet - ADDR MUST BE 0 MOD 4 */
- struct ts_sts sc_sts; /* status packet, for returned status */
- struct ts_char sc_char; /* characteristics packet */
+ struct ts_cmd sc_cmd; /* the command packet */
+ struct ts_sts sc_sts; /* status packet, for returned status */
+ struct ts_char sc_char; /* characteristics packet */
+ struct ts_softc *sc_ubaddr; /* Unibus address of ts_softc structure */
u_short sc_uba; /* Unibus addr of cmd pkt for tsdb */
u_short sc_uba; /* Unibus addr of cmd pkt for tsdb */
+ short sc_mapped; /* is ts_sfotc mapped in Unibus space? */
} ts_softc[NTS];
} ts_softc[NTS];
-struct ts_softc *ts_ubaddr; /* Unibus address of ts_softc */
-
/*
* States for um->um_tab.b_active, the per controller state flag.
* This is used to sequence control in the driver.
/*
* States for um->um_tab.b_active, the per controller state flag.
* This is used to sequence control in the driver.
@@
-107,15
+99,12
@@
struct ts_softc *ts_ubaddr; /* Unibus address of ts_softc */
#define SCOM 3 /* sending control command */
#define SREW 4 /* sending a drive rewind */
#define SCOM 3 /* sending control command */
#define SREW 4 /* sending a drive rewind */
-#if NTM > 0
-/* kludge... see tm.c */
-extern havetm;
-#endif
/*
* Determine if there is a controller for
* a ts at address reg. Our goal is to make the
* device interrupt.
*/
/*
* Determine if there is a controller for
* a ts at address reg. Our goal is to make the
* device interrupt.
*/
+/*ARGSUSED*/
tsprobe(reg)
caddr_t reg;
{
tsprobe(reg)
caddr_t reg;
{
@@
-123,21
+112,16
@@
tsprobe(reg)
#ifdef lint
br = 0; cvec = br; br = cvec;
#ifdef lint
br = 0; cvec = br; br = cvec;
+ tsintr(0);
#endif
#endif
- /****************/
- /* */
- /* K L U D G E */
- /* */
- /****************/
-
-#if NTM > 0
- if (havetm)
- return (0);
-#endif
- /* IT'S TOO HARD TO MAKE THIS THING INTERRUPT
- JUST TO FIND ITS VECTOR */
- cvec = 0224;
+ ((struct tsdevice *)reg)->tssr = 0;
+ DELAY(100);
+ if ((((struct tsdevice *)reg)->tssr & TS_NBA) == 0)
+ return(0);
+ /* IT'S TOO HARD TO MAKE THIS THING INTERRUPT JUST TO FIND ITS VECTOR */
+ cvec = ((unsigned)reg) & 07 ? 0260 : 0224;
br = 0x15;
br = 0x15;
+ return (1);
}
/*
}
/*
@@
-192,17
+176,16
@@
tsopen(dev, flag)
}
if (tsinit(tsunit)) {
u.u_error = ENXIO;
}
if (tsinit(tsunit)) {
u.u_error = ENXIO;
- printd("init failed\n");
return;
}
return;
}
- printd("init ok\n");
tscommand(dev, TS_SENSE, 1);
tscommand(dev, TS_SENSE, 1);
- printd("sense xs0 %o\n", sc->sc_sts.s_xs0);
- if ((sc->sc_sts.s_xs0&TS_ONL) == 0 || ((flag&(FREAD|FWRITE)) ==
- FWRITE && (sc->sc_sts.s_xs0&TS_WLK))) {
- /*
- * Not online or write locked.
- */
+ if ((sc->sc_sts.s_xs0&TS_ONL) == 0) {
+ uprintf("ts%d: not online\n", tsunit);
+ u.u_error = EIO;
+ return;
+ }
+ if ((flag&(FREAD|FWRITE)) == FWRITE && (sc->sc_sts.s_xs0&TS_WLK)) {
+ uprintf("ts%d: no write ring\n", tsunit);
u.u_error = EIO;
return;
}
u.u_error = EIO;
return;
}
@@
-251,7
+234,7
@@
tsinit(unit)
{
register struct ts_softc *sc = &ts_softc[unit];
register struct uba_ctlr *um = tsminfo[unit];
{
register struct ts_softc *sc = &ts_softc[unit];
register struct uba_ctlr *um = tsminfo[unit];
- register struct
device *addr = (struct
device *)um->um_addr;
+ register struct
tsdevice *addr = (struct ts
device *)um->um_addr;
register int i;
/*
register int i;
/*
@@
-260,42
+243,33
@@
tsinit(unit)
* packets at once to minimize the amount of Unibus
* mapping necessary.
*/
* packets at once to minimize the amount of Unibus
* mapping necessary.
*/
- if (
ts_ubaddr
== 0) {
- ctsbuf[unit].b_un.b_addr = (caddr_t)
ts_soft
c;
- ctsbuf[unit].b_bcount = sizeof(
ts_soft
c);
+ if (
sc->sc_mapped
== 0) {
+ ctsbuf[unit].b_un.b_addr = (caddr_t)
s
c;
+ ctsbuf[unit].b_bcount = sizeof(
*s
c);
i = ubasetup(um->um_ubanum, &ctsbuf[unit], 0);
i &= 0777777;
i = ubasetup(um->um_ubanum, &ctsbuf[unit], 0);
i &= 0777777;
- ts_ubaddr = (struct ts_softc *)i;
- /* MAKE SURE WE DON'T GET UNIBUS ADDRESS ZERO */
- if (ts_ubaddr == 0)
- printf("ts%d: zero ubaddr\n", unit);
+ sc->sc_ubaddr = (struct ts_softc *)i;
+ sc->sc_mapped++;
}
/*
* Now initialize the TS11 controller.
* Set the characteristics.
*/
}
/*
* Now initialize the TS11 controller.
* Set the characteristics.
*/
- if (addr->tssr &
TS_NBA
) {
+ if (addr->tssr &
(TS_NBA|TS_OFL)
) {
addr->tssr = 0; /* subsystem initialize */
tswait(addr);
addr->tssr = 0; /* subsystem initialize */
tswait(addr);
- i = (int)&ts_ubaddr[unit].sc_cmd; /* Unibus addr of cmd */
- if (i&3) {
- printf("addr mod 4 != 0\n");
- return(1);
- }
+ i = (int)&sc->sc_ubaddr->sc_cmd; /* Unibus addr of cmd */
sc->sc_uba = (u_short)(i + ((i>>16)&3));
sc->sc_uba = (u_short)(i + ((i>>16)&3));
- sc->sc_char.char_addr = (int)&
ts_ubaddr[unit].
sc_sts;
+ sc->sc_char.char_addr = (int)&
sc->sc_ubaddr->
sc_sts;
sc->sc_char.char_size = sizeof(struct ts_sts);
sc->sc_char.char_mode = TS_ESS;
sc->sc_cmd.c_cmd = TS_ACK | TS_SETCHR;
sc->sc_char.char_size = sizeof(struct ts_sts);
sc->sc_char.char_mode = TS_ESS;
sc->sc_cmd.c_cmd = TS_ACK | TS_SETCHR;
- i = (int)&
ts_ubaddr[unit].
sc_char;
+ i = (int)&
sc->sc_ubaddr->
sc_char;
sc->sc_cmd.c_loba = i;
sc->sc_cmd.c_hiba = (i>>16)&3;
sc->sc_cmd.c_size = sizeof(struct ts_char);
addr->tsdb = sc->sc_uba;
tswait(addr);
sc->sc_cmd.c_loba = i;
sc->sc_cmd.c_hiba = (i>>16)&3;
sc->sc_cmd.c_size = sizeof(struct ts_char);
addr->tsdb = sc->sc_uba;
tswait(addr);
-/*
- printd("%o %o %o %o %o %o %o %o\n", addr->tssr, sc->sc_sts.s_sts, sc->sc_sts.s_len, sc->sc_sts.s_rbpcr, sc->sc_sts.s_xs0, sc->sc_sts.s_xs1,sc->sc_sts.s_xs1,sc->sc_sts.s_xs2,sc->sc_sts.s_xs3);
-*/
if (addr->tssr & TS_NBA)
return(1);
}
if (addr->tssr & TS_NBA)
return(1);
}
@@
-311,9
+285,10
@@
tscommand(dev, com, count)
int com, count;
{
register struct buf *bp;
int com, count;
{
register struct buf *bp;
+ register int s;
bp = &ctsbuf[TSUNIT(dev)];
bp = &ctsbuf[TSUNIT(dev)];
-
(void)
spl5();
+
s =
spl5();
while (bp->b_flags&B_BUSY) {
/*
* This special check is because B_BUSY never
while (bp->b_flags&B_BUSY) {
/*
* This special check is because B_BUSY never
@@
-325,8
+300,7
@@
tscommand(dev, com, count)
sleep((caddr_t)bp, PRIBIO);
}
bp->b_flags = B_BUSY|B_READ;
sleep((caddr_t)bp, PRIBIO);
}
bp->b_flags = B_BUSY|B_READ;
- (void) spl0();
- printd("command %o dev %x count %d\n", com, dev, count);
+ splx(s);
bp->b_dev = dev;
bp->b_repcnt = count;
bp->b_command = com;
bp->b_dev = dev;
bp->b_repcnt = count;
bp->b_command = com;
@@
-353,14
+327,15
@@
tsstrategy(bp)
int tsunit = TSUNIT(bp->b_dev);
register struct uba_ctlr *um;
register struct buf *dp;
int tsunit = TSUNIT(bp->b_dev);
register struct uba_ctlr *um;
register struct buf *dp;
+ register int s;
/*
* Put transfer at end of controller queue
*/
bp->av_forw = NULL;
um = tsdinfo[tsunit]->ui_mi;
/*
* Put transfer at end of controller queue
*/
bp->av_forw = NULL;
um = tsdinfo[tsunit]->ui_mi;
-
dp = &tsbuf[tsunit]
;
-
(void) spl5()
;
+
s = spl5()
;
+
dp = &tsutab[tsunit]
;
if (dp->b_actf == NULL)
dp->b_actf = bp;
else
if (dp->b_actf == NULL)
dp->b_actf = bp;
else
@@
-373,7
+348,7
@@
tsstrategy(bp)
*/
if (um->um_tab.b_active == 0)
tsstart(um);
*/
if (um->um_tab.b_active == 0)
tsstart(um);
-
(void) spl0(
);
+
splx(s
);
}
/*
}
/*
@@
-383,7
+358,7
@@
tsstart(um)
register struct uba_ctlr *um;
{
register struct buf *bp;
register struct uba_ctlr *um;
{
register struct buf *bp;
- register struct
device *addr = (struct
device *)um->um_addr;
+ register struct
tsdevice *addr = (struct ts
device *)um->um_addr;
register struct ts_softc *sc;
register struct ts_cmd *tc;
register struct uba_device *ui;
register struct ts_softc *sc;
register struct ts_cmd *tc;
register struct uba_device *ui;
@@
-404,7
+379,7
@@
loop:
* Default is that last command was NOT a write command;
* if we do a write command we will notice this in tsintr().
*/
* Default is that last command was NOT a write command;
* if we do a write command we will notice this in tsintr().
*/
- sc->sc_lastiow =
1
;
+ sc->sc_lastiow =
0
;
if (sc->sc_openf < 0 || (addr->tssr&TS_OFL)) {
/*
* Have had a hard error on a non-raw tape
if (sc->sc_openf < 0 || (addr->tssr&TS_OFL)) {
/*
* Have had a hard error on a non-raw tape
@@
-421,7
+396,6
@@
loop:
um->um_tab.b_active =
bp->b_command == TS_REW ? SREW : SCOM;
tc->c_repcnt = bp->b_repcnt;
um->um_tab.b_active =
bp->b_command == TS_REW ? SREW : SCOM;
tc->c_repcnt = bp->b_repcnt;
- printd("strat: do cmd\n");
goto dobpcmd;
}
/*
goto dobpcmd;
}
/*
@@
-468,7
+442,6
@@
loop:
cmd |= TS_RETRY;
um->um_tab.b_active = SIO;
tc->c_cmd = TS_ACK | TS_CVC | TS_IE | cmd;
cmd |= TS_RETRY;
um->um_tab.b_active = SIO;
tc->c_cmd = TS_ACK | TS_CVC | TS_IE | cmd;
- printd("r/w %o size %d\n", tc->c_cmd, tc->c_size);
(void) ubago(ui);
return;
}
(void) ubago(ui);
return;
}
@@
-478,7
+451,6
@@
loop:
* This happens for raw tapes only on error retries.
*/
um->um_tab.b_active = SSEEK;
* This happens for raw tapes only on error retries.
*/
um->um_tab.b_active = SSEEK;
- printd("seek blkno %d b_blkno %d\n", blkno, bp->b_blkno);
if (blkno < dbtofsb(bp->b_blkno)) {
bp->b_command = TS_SFORW;
tc->c_repcnt = dbtofsb(bp->b_blkno) - blkno;
if (blkno < dbtofsb(bp->b_blkno)) {
bp->b_command = TS_SFORW;
tc->c_repcnt = dbtofsb(bp->b_blkno) - blkno;
@@
-516,12
+488,11
@@
next:
tsdgo(um)
register struct uba_ctlr *um;
{
tsdgo(um)
register struct uba_ctlr *um;
{
- register struct
device *addr = (struct
device *)um->um_addr;
+ register struct
tsdevice *addr = (struct ts
device *)um->um_addr;
register struct ts_softc *sc = &ts_softc[um->um_ctlr];
register int i;
i = um->um_ubinfo & 0777777;
register struct ts_softc *sc = &ts_softc[um->um_ctlr];
register int i;
i = um->um_ubinfo & 0777777;
- printd("dgo addr %o\n", i);
sc->sc_cmd.c_loba = i;
sc->sc_cmd.c_hiba = (i>>16)&3;
addr->tsdb = sc->sc_uba;
sc->sc_cmd.c_loba = i;
sc->sc_cmd.c_hiba = (i>>16)&3;
addr->tsdb = sc->sc_uba;
@@
-536,16
+507,15
@@
tsintr(ts11)
{
register struct buf *bp;
register struct uba_ctlr *um = tsminfo[ts11];
{
register struct buf *bp;
register struct uba_ctlr *um = tsminfo[ts11];
- register struct device *addr;
+ register struct
ts
device *addr;
register struct ts_softc *sc;
int tsunit;
register state;
register struct ts_softc *sc;
int tsunit;
register state;
- printd("intr\n");
if ((bp = um->um_tab.b_actf->b_actf) == NULL)
return;
tsunit = TSUNIT(bp->b_dev);
if ((bp = um->um_tab.b_actf->b_actf) == NULL)
return;
tsunit = TSUNIT(bp->b_dev);
- addr = (struct device *)tsdinfo[tsunit]->ui_addr;
+ addr = (struct
ts
device *)tsdinfo[tsunit]->ui_addr;
/*
* If last command was a rewind, and tape is still
* rewinding, wait for the rewind complete interrupt.
/*
* If last command was a rewind, and tape is still
* rewinding, wait for the rewind complete interrupt.
@@
-560,7
+530,6
@@
tsintr(ts11)
/*
* An operation completed... record status
*/
/*
* An operation completed... record status
*/
- printd(" ok1\n");
sc = &ts_softc[tsunit];
if ((bp->b_flags & B_READ) == 0)
sc->sc_lastiow = 1;
sc = &ts_softc[tsunit];
if ((bp->b_flags & B_READ) == 0)
sc->sc_lastiow = 1;
@@
-633,8
+602,15
@@
tsintr(ts11)
/*
* Couldn't recover error
*/
/*
* Couldn't recover error
*/
- printf("ts%d: hard error bn%d xs0=%b
\n
", TSUNIT(bp->b_dev),
+ printf("ts%d: hard error bn%d xs0=%b", TSUNIT(bp->b_dev),
bp->b_blkno, sc->sc_sts.s_xs0, TSXS0_BITS);
bp->b_blkno, sc->sc_sts.s_xs0, TSXS0_BITS);
+ if (sc->sc_sts.s_xs1)
+ printf(" xs1=%b", sc->sc_sts.s_xs1, TSXS1_BITS);
+ if (sc->sc_sts.s_xs2)
+ printf(" xs2=%b", sc->sc_sts.s_xs2, TSXS2_BITS);
+ if (sc->sc_sts.s_xs3)
+ printf(" xs3=%b", sc->sc_sts.s_xs3, TSXS3_BITS);
+ printf("\n");
bp->b_flags |= B_ERROR;
goto opdone;
}
bp->b_flags |= B_ERROR;
goto opdone;
}
@@
-684,7
+660,6
@@
opdone:
um->um_tab.b_actf->b_actf = bp->av_forw;
bp->b_resid = sc->sc_sts.s_rbpcr;
ubadone(um);
um->um_tab.b_actf->b_actf = bp->av_forw;
bp->b_resid = sc->sc_sts.s_rbpcr;
ubadone(um);
- printd(" iodone\n");
iodone(bp);
if (um->um_tab.b_actf->b_actf == 0)
return;
iodone(bp);
if (um->um_tab.b_actf->b_actf == 0)
return;
@@
-761,8
+736,9
@@
tsreset(uban)
int uban;
{
register struct uba_ctlr *um;
int uban;
{
register struct uba_ctlr *um;
- register
ts11
;
+ register
struct uba_device *ui
;
register struct buf *dp;
register struct buf *dp;
+ register ts11;
for (ts11 = 0; ts11 < NTS; ts11++) {
if ((um = tsminfo[ts11]) == 0 || um->um_alive == 0 ||
for (ts11 = 0; ts11 < NTS; ts11++) {
if ((um = tsminfo[ts11]) == 0 || um->um_alive == 0 ||
@@
-771,12
+747,23
@@
tsreset(uban)
printf(" ts%d", ts11);
um->um_tab.b_active = 0;
um->um_tab.b_actf = um->um_tab.b_actl = 0;
printf(" ts%d", ts11);
um->um_tab.b_active = 0;
um->um_tab.b_actf = um->um_tab.b_actl = 0;
- ts_softc[ts11].sc_openf = -1;
+ if (ts_softc[ts11].sc_openf > 0)
+ ts_softc[ts11].sc_openf = -1;
if (um->um_ubinfo) {
printf("<%d>", (um->um_ubinfo>>28)&0xf);
ubadone(um);
}
if (um->um_ubinfo) {
printf("<%d>", (um->um_ubinfo>>28)&0xf);
ubadone(um);
}
- tsinit(ts11);
+ if ((ui = tsdinfo[ts11]) && ui->ui_mi == um && ui->ui_alive) {
+ dp = &tsutab[ts11];
+ dp->b_active = 0;
+ dp->b_forw = 0;
+ if (um->um_tab.b_actf == NULL)
+ um->um_tab.b_actf = dp;
+ else
+ um->um_tab.b_actl->b_forw = dp;
+ um->um_tab.b_actl = dp;
+ }
+ (void) tsinit(ts11);
tsstart(um);
}
}
tsstart(um);
}
}
@@
-795,7
+782,7
@@
tsioctl(dev, cmd, addr, flag)
struct mtget mtget;
/* we depend of the values and order of the MT codes here */
static tsops[] =
struct mtget mtget;
/* we depend of the values and order of the MT codes here */
static tsops[] =
- {TS_WEOF,TS_SFORW
,TS_SREV,TS_SFORWF,TS_SREVF
,TS_REW,TS_OFFL,TS_SENSE};
+ {TS_WEOF,TS_SFORW
F,TS_SREVF,TS_SFORW,TS_SREV
,TS_REW,TS_OFFL,TS_SENSE};
switch (cmd) {
case MTIOCTOP: /* tape operation */
switch (cmd) {
case MTIOCTOP: /* tape operation */
@@
-856,7
+843,7
@@
tsdump()
{
register struct uba_device *ui;
register struct uba_regs *up;
{
register struct uba_device *ui;
register struct uba_regs *up;
- register struct device *addr;
+ register struct
ts
device *addr;
int blk, num;
int start;
int blk, num;
int start;
@@
-869,7
+856,7
@@
tsdump()
up = phys(ui->ui_hd, struct uba_hd *)->uh_physuba;
ubainit(up);
DELAY(1000000);
up = phys(ui->ui_hd, struct uba_hd *)->uh_physuba;
ubainit(up);
DELAY(1000000);
- addr = (struct device *)ui->ui_physaddr;
+ addr = (struct
ts
device *)ui->ui_physaddr;
addr->tssr = 0;
tswait(addr);
while (num > 0) {
addr->tssr = 0;
tswait(addr);
while (num > 0) {
@@
-890,7
+877,7
@@
tsdump()
tsdwrite(dbuf, num, addr, up)
register dbuf, num;
tsdwrite(dbuf, num, addr, up)
register dbuf, num;
- register struct device *addr;
+ register struct
ts
device *addr;
struct uba_regs *up;
{
register struct pte *io;
struct uba_regs *up;
{
register struct pte *io;
@@
-910,7
+897,7
@@
tsdwrite(dbuf, num, addr, up)
}
tswait(addr)
}
tswait(addr)
- register struct device *addr;
+ register struct
ts
device *addr;
{
register s;
{
register s;
@@
-920,7
+907,7
@@
tswait(addr)
}
tseof(addr)
}
tseof(addr)
- struct device *addr;
+ struct
ts
device *addr;
{
tswait(addr);
{
tswait(addr);