-/* tm.c 4.10 %G% */
+/* tm.c 4.11 %G% */
#include "tm.h"
#if NTM > 0
#include "../h/tmreg.h"
-struct buf tmtab;
struct buf ctmbuf;
struct buf rtmbuf;
int tmcntrlr(), tmslave(), tmdgo(), tmintr();
-struct uba_dinfo *tminfo[NTM];
-extern u_short tmstd[];
+struct uba_dinfo *tmdinfo[NTM];
+struct uba_minfo *tmminfo[NTM];
+u_short tmstd[] = { 0772520, 0 };
struct uba_driver tmdriver =
- { tmcntrlr, tmslave, tmdgo, 4, 0, tmstd, "tm", tminfo };
+ { tmcntrlr, tmslave, tmdgo, 0, tmstd, "tm", tmdinfo, tmminfo };
int tm_ubinfo;
/* bits in minor device */
* Determine if there is a controller for
* a tm at address reg. Our goal is to make the
* device interrupt.
- * THE ARGUMENT UI IS OBSOLETE
*/
-tmcntrlr(ui, reg)
- struct uba_dinfo *ui;
+tmcntrlr(um, reg)
+ struct uba_minfo *um;
caddr_t reg;
{
+ register int br, cvec;
((struct device *)reg)->tmcs = IENABLE;
/*
* If this is a tm03/tc11, it ought to have interrupted
* by now, if it isn't (ie: it is a ts04) then we just
- * pray that it didn't interrupt, so autoconf will ignore it
- * - just in case out prayers fail, we will reference one
+ * hope that it didn't interrupt, so autoconf will ignore it.
+ * Just in case, we will reference one
* of the more distant registers, and hope for a machine
- * check, or similar disaster
+ * check, or similar disaster if this is a ts.
*/
if (badaddr(&((struct device *)reg)->tmrd, 2))
- return(0);
- return(1);
+ return (0);
+ return (1);
}
tmslave(ui, reg, slaveno)
struct uba_dinfo *ui;
caddr_t reg;
{
+
/*
* Due to a design flaw, we cannot ascertain if the tape
* exists or not unless it is on line - ie: unless a tape is
* Something better will have to be done if you have two
* tapes on one controller, or two controllers
*/
- printf("tm: sl %d - tmi %x\n", slaveno, tminfo[0]);
- if (slaveno != 0 || tminfo[0])
+ if (slaveno != 0 || tmdinfo[0])
return(0);
- return(1);
+ return (1);
}
tmopen(dev, flag)
register ds, unit;
register struct uba_dinfo *ui;
- tmtab.b_flags |= B_TAPE;
+ tmminfo[0]->um_tab.b_flags |= B_TAPE;
unit = minor(dev)&03;
- if (unit>=NTM || t_openf || !(ui = tminfo[minor(dev)&03])->ui_alive) {
+ if (unit>=NTM || t_openf || !(ui = tmdinfo[minor(dev)&03])->ui_alive) {
u.u_error = ENXIO; /* out of range or open */
return;
}
register dev;
{
register struct device *addr =
- (struct device *)tminfo[minor(dev)&03]->ui_addr;
+ (struct device *)tmdinfo[minor(dev)&03]->ui_addr;
spl5();
for (;;) {
register struct buf *bp;
{
register daddr_t *p;
+ register struct buf *tmi;
tmwaitrws(bp->b_dev);
if (bp != &ctmbuf) {
}
bp->av_forw = NULL;
(void) spl5();
- if (tmtab.b_actf == NULL)
- tmtab.b_actf = bp;
+ tmi = &tmminfo[0]->um_tab;
+ if (tmi->b_actf == NULL)
+ tmi->b_actf = bp;
else
- tmtab.b_actl->av_forw = bp;
- tmtab.b_actl = bp;
- if (tmtab.b_active == 0)
+ tmi->b_actl->av_forw = bp;
+ tmi->b_actl = bp;
+ if (tmi->b_active == 0)
tmstart();
(void) spl0();
}
int s;
loop:
- if ((bp = tmtab.b_actf) == 0)
+ if ((bp = tmminfo[0]->um_tab.b_actf) == 0)
return;
- ui = tminfo[minor(bp->b_dev)&03];
+ ui = tmdinfo[minor(bp->b_dev)&03];
addr = (struct device *)ui->ui_addr;
t_dsreg = addr->tmcs;
t_erreg = addr->tmer;
goto next; /* just get status */
else {
cmd |= bp->b_command;
- tmtab.b_active = SCOM;
+ tmminfo[0]->um_tab.b_active = SCOM;
if (bp->b_command == SFORW || bp->b_command == SREV)
addr->tmbc = bp->b_repcnt;
addr->tmcs = cmd;
tm_ubinfo = ubasetup(ui->ui_ubanum, bp, 1);
splx(s);
if ((bp->b_flags&B_READ) == 0) {
- if (tmtab.b_errcnt)
+ if (tmminfo[0]->um_tab.b_errcnt)
cmd |= WIRG;
else
cmd |= WCOM;
} else
cmd |= RCOM;
cmd |= (tm_ubinfo >> 12) & 0x30;
- tmtab.b_active = SIO;
+ tmminfo[0]->um_tab.b_active = SIO;
addr->tmba = tm_ubinfo;
addr->tmcs = cmd;
return;
}
- tmtab.b_active = SSEEK;
+ tmminfo[0]->um_tab.b_active = SSEEK;
if (blkno < dbtofsb(bp->b_blkno)) {
cmd |= SFORW;
addr->tmbc = blkno - dbtofsb(bp->b_blkno);
next:
ubarelse(ui->ui_ubanum, &tm_ubinfo);
- tmtab.b_actf = bp->av_forw;
+ tmminfo[0]->um_tab.b_actf = bp->av_forw;
iodone(bp);
goto loop;
}
tmintr(d)
{
register struct buf *bp;
- register struct device *addr = (struct device *)tminfo[d]->ui_addr;
+ register struct device *addr = (struct device *)tmdinfo[d]->ui_addr;
register state;
if (t_flags&WAITREW && (addr->tmer&RWS) == 0) {
t_flags &= ~WAITREW;
wakeup((caddr_t)&t_flags);
}
- if ((bp = tmtab.b_actf) == NULL)
+ if ((bp = tmminfo[0]->um_tab.b_actf) == NULL)
return;
t_dsreg = addr->tmcs;
t_erreg = addr->tmer;
t_resid = addr->tmbc;
if ((bp->b_flags & B_READ) == 0)
t_flags |= LASTIOW;
- state = tmtab.b_active;
- tmtab.b_active = 0;
+ state = tmminfo[0]->um_tab.b_active;
+ tmminfo[0]->um_tab.b_active = 0;
if (addr->tmcs&ERROR) {
while(addr->tmer & SDWN)
; /* await settle down */
if ((bp->b_flags&B_READ) && (addr->tmer&(HARD|SOFT)) == RLE)
goto out;
if ((addr->tmer&HARD)==0 && state==SIO) {
- if (++tmtab.b_errcnt < 7) {
+ if (++tmminfo[0]->um_tab.b_errcnt < 7) {
if((addr->tmer&SOFT) == NXM)
printf("TM UBA late error\n");
t_blkno++;
- ubarelse(tminfo[d]->ui_ubanum, &tm_ubinfo);
+ ubarelse(tmdinfo[d]->ui_ubanum, &tm_ubinfo);
tmstart();
return;
}
}
}
errout:
- tmtab.b_errcnt = 0;
- tmtab.b_actf = bp->av_forw;
+ tmminfo[0]->um_tab.b_errcnt = 0;
+ tmminfo[0]->um_tab.b_actf = bp->av_forw;
bp->b_resid = -addr->tmbc;
- ubarelse(tminfo[d]->ui_ubanum, &tm_ubinfo);
+ ubarelse(tmdinfo[d]->ui_ubanum, &tm_ubinfo);
iodone(bp);
break;
register struct buf *bp;
{
register struct device *addr =
- (struct device *)tminfo[minor(bp->b_dev)&03]->ui_addr;
+ (struct device *)tmdinfo[minor(bp->b_dev)&03]->ui_addr;
if (bp == &ctmbuf) {
if (t_blkno > dbtofsb(bp->b_blkno)) {
start = 0;
num = maxfree;
#define phys(a,b) ((b)((int)(a)&0x7fffffff))
- if (tminfo[0] == 0) {
+ if (tmdinfo[0] == 0) {
printf("dna\n");
return (-1);
}
- ui = phys(tminfo[0], struct uba_dinfo *);
+ ui = phys(tmdinfo[0], struct uba_dinfo *);
up = phys(ui->ui_hd, struct uba_hd *)->uh_physuba;
#if VAX780
if (cpu == VAX_780)
-/* up.c 4.14 81/02/15 */
+/* up.c 4.15 81/02/16 */
#include "up.h"
#if NSC21 > 0
int upcntrlr(), upslave(), updgo(), upintr();
struct uba_minfo *upminfo[NSC21];
struct uba_dinfo *updinfo[NUP];
-struct uba_minfo up_minfo[NSC21];
- /* there is no reason for this to be a global structure, it
- is only known/used locally, it would be better combined
- with up_softc - but that would mean I would have to alter
- more than I want to just now. Similarly, there is no longer
- any real need for upminfo, but the code still uses it so ...
- */
-
-extern u_short upstd[];
+
+u_short upstd[] = { 0776700, 0774400, 0776300 };
struct uba_driver updriver =
- { upcntrlr, upslave, updgo, 4, 0, upstd, "up", updinfo };
+ { upcntrlr, upslave, updgo, 0, upstd, "up", updinfo, upminfo };
struct buf uputab[NUP];
struct upst {
struct uba_minfo *um;
caddr_t reg;
{
+ register int br, cvec;
+
((struct device *)reg)->upcs1 |= (IE|RDY);
- return(1); /* just assume it is us (for now) */
+ return (1);
}
-upslave(ui, reg, slaveno, uban)
+upslave(ui, reg, slaveno)
struct uba_dinfo *ui;
caddr_t reg;
{
register struct device *upaddr = (struct device *)reg;
- register struct uba_minfo *um;
- register int sc21;
upaddr->upcs1 = 0; /* conservative */
upaddr->upcs2 = slaveno;
upaddr->upcs1 = DCLR|GO;
return (0);
}
- /*** we should check device type (return 0 if we don't like it) ***/
- /*** and set type index in ui->ui_type, but we KNOW all we are ***/
- /*** going to see at the minute is a 9300, and the index for a ***/
- /*** 9300 is 0, which is the value already in ui->ui_type, so ..***/
-
- um = &up_minfo[0];
- for (sc21 = 0; sc21 < NSC21; sc21++) {
- if (um->um_alive == 0) { /* this is a new ctrlr */
- um->um_addr = reg;
- um->um_ubanum = uban;
- um->um_num = sc21; /* not needed after up_softc
- combined with um ??? */
- um->um_alive = 1;
- upminfo[sc21] = um; /* just till upminfo vanishes */
- goto found;
- }
- if (um->um_addr == reg && um->um_ubanum == uban)
- goto found;
- um++;
- }
- return(0); /* too many sc21's */
-
- found:
- ui->ui_mi = um;
-
if (upwstart == 0) {
timeout(upwatch, (caddr_t)0, HZ);
upwstart++;
/* dont confuse controller by giving SEARCH while dt in progress */
um = ui->ui_mi;
if (um->um_tab.b_active) {
- up_softc[um->um_num].sc_softas |= 1<<ui->ui_slave;
+ up_softc[um->um_ctlr].sc_softas |= 1<<ui->ui_slave;
return (0);
}
if (dp->b_active)
upaddr = (struct device *)ui->ui_addr;
if ((upaddr->upcs2 & 07) != dn)
upaddr->upcs2 = dn;
- up_softc[um->um_num].sc_info =
+ up_softc[um->um_ctlr].sc_info =
ubasetup(ui->ui_ubanum, bp, UBA_NEEDBDP|UBA_CANTWAIT);
/*
* If drive is not present and on-line, then
bp->b_flags |= B_ERROR;
iodone(bp);
/* A funny place to do this ... */
- ubarelse(ui->ui_ubanum, &up_softc[um->um_num].sc_info);
+ ubarelse(ui->ui_ubanum, &up_softc[um->um_ctlr].sc_info);
goto loop;
}
printf("-- came back\n");
*/
upaddr->updc = bp->b_cylin;
upaddr->upda = (tn << 8) + sn;
- upaddr->upba = up_softc[um->um_num].sc_info;
+ upaddr->upba = up_softc[um->um_ctlr].sc_info;
upaddr->upwc = -bp->b_bcount / sizeof (short);
- cmd = (up_softc[um->um_num].sc_info >> 8) & 0x300;
+ cmd = (up_softc[um->um_ctlr].sc_info >> 8) & 0x300;
if (bp->b_flags & B_READ)
cmd |= IE|RCOM|GO;
else
int needie = 1;
(void) spl6();
- up_softc[um->um_num].sc_wticks = 0;
+ up_softc[um->um_ctlr].sc_wticks = 0;
if (um->um_tab.b_active) {
if ((upaddr->upcs1 & RDY) == 0) {
printf("!RDY: cs1 %o, ds %o, wc %d\n", upaddr->upcs1,
if (upustart(ui))
needie = 0;
}
- up_softc[um->um_num].sc_softas &= ~(1<<ui->ui_slave);
- ubarelse(ui->ui_ubanum, &up_softc[um->um_num].sc_info);
+ up_softc[um->um_ctlr].sc_softas &= ~(1<<ui->ui_slave);
+ ubarelse(ui->ui_ubanum, &up_softc[um->um_ctlr].sc_info);
} else {
if (upaddr->upcs1 & TRE)
upaddr->upcs1 = TRE;
}
- as |= up_softc[um->um_num].sc_softas;
+ as |= up_softc[um->um_ctlr].sc_softas;
for (unit = 0; unit < NUP; unit++) {
if ((ui = updinfo[unit]) == 0 || ui->ui_mi != um)
continue;
* O is offset within a memory page of the first byte transferred.
*/
npf = btop((up->upwc * sizeof(short)) + bp->b_bcount) - 1;
- reg = btop(up_softc[um->um_num].sc_info&0x3ffff) + npf;
+ reg = btop(up_softc[um->um_ctlr].sc_info&0x3ffff) + npf;
o = (int)bp->b_un.b_addr & PGOFSET;
printf("%D ", bp->b_blkno+npf);
prdev("ECC", bp->b_dev);
* is the byte offset in the transfer, the variable byte
* is the offset from a page boundary in main memory.
*/
- ubp->uba_dpr[(up_softc[um->um_num].sc_info>>28)&0x0f] |= UBA_BNE;
+ ubp->uba_dpr[(up_softc[um->um_ctlr].sc_info>>28)&0x0f] |= UBA_BNE;
i = up->upec1 - 1; /* -1 makes 0 origin */
bit = i&07;
i = (i&~07)>>3;
}
um->um_tab.b_active = 0;
um->um_tab.b_actf = um->um_tab.b_actl = 0;
- if (up_softc[um->um_num].sc_info) {
- printf("<%d>", (up_softc[um->um_num].sc_info>>28)&0xf);
- ubarelse(um->um_ubanum, &up_softc[um->um_num].sc_info);
+ if (up_softc[um->um_ctlr].sc_info) {
+ printf("<%d>", (up_softc[um->um_ctlr].sc_info>>28)&0xf);
+ ubarelse(um->um_ubanum, &up_softc[um->um_ctlr].sc_info);
}
((struct device *)(um->um_addr))->upcs2 = CLR;
for (unit = 0; unit < NUP; unit++) {