summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/vax/mscp/mscp.c10
-rw-r--r--sys/arch/vax/mscp/mscp.h6
-rw-r--r--sys/arch/vax/mscp/mscp_disk.c57
-rw-r--r--sys/arch/vax/mscp/mscp_tape.c64
4 files changed, 86 insertions, 51 deletions
diff --git a/sys/arch/vax/mscp/mscp.c b/sys/arch/vax/mscp/mscp.c
index e97bee46017..4d1821b29c6 100644
--- a/sys/arch/vax/mscp/mscp.c
+++ b/sys/arch/vax/mscp/mscp.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: mscp.c,v 1.2 1997/05/29 00:05:01 niklas Exp $ */
-/* $NetBSD: mscp.c,v 1.5 1997/01/11 11:20:31 ragge Exp $ */
+/* $OpenBSD: mscp.c,v 1.3 1997/09/12 09:25:47 maja Exp $ */
+/* $NetBSD: mscp.c,v 1.6 1997/07/04 11:58:20 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -306,6 +306,7 @@ loop:
* off line (the idiot controller does not tell us until
* it comes back *on* line, or until we try to use it).
*/
+rwend:
#ifdef DIAGNOSTIC
if (mp->mscp_cmdref == 0) {
/*
@@ -317,9 +318,12 @@ loop:
break;
}
#endif
-rwend:
bp = (struct buf *) mp->mscp_cmdref;
+ if (mp->mscp_cmdref == -1) {
+ (*me->me_cmddone)(drive, mp);
+ break;
+ }
/*
* Mark any error-due-to-bad-LBN (via `goto rwend').
* WHAT STATUS WILL THESE HAVE? IT SURE WOULD BE NICE
diff --git a/sys/arch/vax/mscp/mscp.h b/sys/arch/vax/mscp/mscp.h
index efc3915a0f3..ffae864af27 100644
--- a/sys/arch/vax/mscp/mscp.h
+++ b/sys/arch/vax/mscp/mscp.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: mscp.h,v 1.2 1997/05/29 00:05:02 niklas Exp $ */
-/* $NetBSD: mscp.h,v 1.2 1996/07/10 23:35:59 ragge Exp $ */
+/* $OpenBSD: mscp.h,v 1.3 1997/09/12 09:25:51 maja Exp $ */
+/* $NetBSD: mscp.h,v 1.3 1997/07/04 11:58:21 ragge Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
@@ -65,7 +65,7 @@
#define M_OP_COMPHD 0x20 /* Compare host data command */
#define M_OP_READ 0x21 /* Read command */
#define M_OP_WRITE 0x22 /* Write command */
-#define M_OP_WRITM 0x23 /* Write mark command */
+#define M_OP_WRITM 0x24 /* Write mark command */
#define M_OP_POS 0x25 /* Positioning command */
#define M_OP_AVAILATTN 0x40 /* Available attention message */
#define M_OP_DUPUNIT 0x41 /* Duplicate unit number attention message */
diff --git a/sys/arch/vax/mscp/mscp_disk.c b/sys/arch/vax/mscp/mscp_disk.c
index de7f63beda6..11644806151 100644
--- a/sys/arch/vax/mscp/mscp_disk.c
+++ b/sys/arch/vax/mscp/mscp_disk.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: mscp_disk.c,v 1.4 1997/09/10 11:54:42 maja Exp $ */
-/* $NetBSD: mscp_disk.c,v 1.10 1997/03/15 16:32:19 ragge Exp $ */
+/* $OpenBSD: mscp_disk.c,v 1.5 1997/09/12 09:25:51 maja Exp $ */
+/* $NetBSD: mscp_disk.c,v 1.13 1997/06/24 01:12:40 thorpej Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* Copyright (c) 1988 Regents of the University of California.
@@ -46,6 +46,7 @@
/*
* TODO
* write bad block forwarding code
+ * split the file into a separate floppy file
*/
#include <sys/param.h>
@@ -181,6 +182,8 @@ raattach(parent, self, aux)
ra->ra_havelabel = 0;
ra->ra_hwunit = mp->mscp_unit;
mi->mi_dp[mp->mscp_unit] = self;
+
+ ra->ra_disk.dk_name = ra->ra_dev.dv_xname;
disk_attach((struct disk *)&ra->ra_disk);
/* Fill in what we know. The actual size is gotten later */
@@ -234,9 +237,6 @@ ra_putonline(ra)
return MSCP_FAILED;
if (ra->ra_isafloppy)
return MSCP_DONE;
- dl->d_partitions[0].p_size = dl->d_partitions[2].p_size =
- dl->d_secperunit;
- dl->d_partitions[0].p_offset = dl->d_partitions[2].p_offset = 0;
printf("%s", ra->ra_dev.dv_xname);
if ((msg = readdisklabel(raminor(ra->ra_dev.dv_unit, 0),
@@ -281,7 +281,11 @@ raopen(dev, flag, fmt, p)
if (ra_putonline(ra) == MSCP_FAILED)
return EIO;
- part = raunit(dev);
+ /* If the disk has no label; allow writing everywhere */
+ if (ra->ra_havelabel == 0)
+ ra->ra_wlabel = 1;
+
+ part = rapart(dev);
if (ra->ra_isafloppy == 0)
if (part >= ra->ra_disk.dk_label->d_npartitions)
return ENXIO;
@@ -338,7 +342,7 @@ raclose(dev, flags, fmt, p)
* Should wait for I/O to complete on this partition even if
* others are open, but wait for work on blkflush().
*/
-#if 0
+#if notyet
if (ra->ra_openpart == 0) {
s = splbio();
while (udautab[unit].b_actf)
@@ -371,7 +375,8 @@ rastrategy(bp)
unit = raunit(bp->b_dev);
if (unit > ra_cd.cd_ndevs || (ra = ra_cd.cd_devs[unit]) == NULL) {
bp->b_error = ENXIO;
- goto bad;
+ bp->b_flags |= B_ERROR;
+ goto done;
}
/*
* If drive is open `raw' or reading label, let it at it.
@@ -393,16 +398,15 @@ rastrategy(bp)
}
} else
if (bounds_check_with_label(bp, ra->ra_disk.dk_label,
- ra->ra_disk.dk_cpulabel, ra->ra_wlabel) <= 0) {
- bp->b_error = ENXIO;
- goto bad;
- }
+ ra->ra_disk.dk_cpulabel, ra->ra_wlabel) <= 0)
+ goto done;
+ /* Make some statistics... /bqt */
+ ra->ra_disk.dk_xfer++;
+ ra->ra_disk.dk_bytes += bp->b_bcount;
mscp_strategy(bp, ra->ra_dev.dv_parent);
return;
-bad:
- bp->b_flags |= B_ERROR;
done:
biodone(bp);
}
@@ -534,6 +538,12 @@ raonline(usc, mp)
dl->d_typename[p++] = n + '0';
dl->d_typename[p] = 0;
dl->d_npartitions = MAXPARTITIONS;
+ dl->d_partitions[0].p_size = dl->d_partitions[2].p_size =
+ dl->d_secperunit;
+ dl->d_partitions[0].p_offset = dl->d_partitions[2].p_offset = 0;
+ dl->d_interleave = dl->d_headswitch = 1;
+ dl->d_magic = dl->d_magic2 = DISKMAGIC;
+ dl->d_checksum = dkcksum(dl);
return (MSCP_DONE);
}
@@ -652,11 +662,18 @@ raioctl(dev, cmd, data, flag, p)
&lp->d_partitions[rapart(dev)];
break;
+ case DIOCWDINFO:
case DIOCSDINFO:
if ((flag & FWRITE) == 0)
error = EBADF;
- else
+ else {
error = setdisklabel(lp, (struct disklabel *)data,0,0);
+ if ((error == 0) && (cmd == DIOCWDINFO)) {
+ ra->ra_wlabel = 1;
+ error = writedisklabel(dev, rastrategy, lp,0);
+ ra->ra_wlabel = 0;
+ }
+ }
break;
case DIOCWLABEL:
@@ -666,16 +683,6 @@ raioctl(dev, cmd, data, flag, p)
ra->ra_wlabel = 1;
break;
- case DIOCWDINFO:
- if ((flag & FWRITE) == 0)
- error = EBADF;
- else {
- ra->ra_wlabel = 1;
- error = writedisklabel(dev, rastrategy, lp,0);
- ra->ra_wlabel = 0;
- }
- break;
-
default:
error = ENOTTY;
break;
diff --git a/sys/arch/vax/mscp/mscp_tape.c b/sys/arch/vax/mscp/mscp_tape.c
index c90bd87c9a6..9e3a23dcf2d 100644
--- a/sys/arch/vax/mscp/mscp_tape.c
+++ b/sys/arch/vax/mscp/mscp_tape.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: mscp_tape.c,v 1.2 1997/05/29 00:05:03 niklas Exp $ */
-/* $NetBSD: mscp_tape.c,v 1.4 1997/01/11 11:20:35 ragge Exp $ */
+/* $OpenBSD: mscp_tape.c,v 1.3 1997/09/12 09:25:52 maja Exp $ */
+/* $NetBSD: mscp_tape.c,v 1.5 1997/07/04 11:58:22 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -65,6 +65,7 @@ struct mt_softc {
int mt_inuse; /* Locks the tape drive for others */
int mt_waswrite; /* Last operation was a write op */
int mt_serex; /* Got serious exception */
+ int mt_ioctlerr; /* Error after last ioctl */
};
#define MT_OFFLINE 0
@@ -85,7 +86,7 @@ int mtread __P((dev_t, struct uio *));
int mtwrite __P((dev_t, struct uio *));
int mtioctl __P((dev_t, int, caddr_t, int, struct proc *));
int mtdump __P((dev_t, daddr_t, caddr_t, size_t));
-void mtcmd __P((struct mt_softc *, int));
+int mtcmd __P((struct mt_softc *, int, int, int));
void mtcmddone __P((struct device *, struct mscp *));
struct mscp_device mt_device = {
@@ -228,14 +229,14 @@ mtclose(dev, flags, fmt, p)
* If we just have finished a writing, write EOT marks.
*/
if ((flags & FWRITE) && mt->mt_waswrite) {
- mtcmd(mt, MTWEOF);
- mtcmd(mt, MTWEOF);
- mtcmd(mt, MTBSR);
+ mtcmd(mt, MTWEOF, 0, 0);
+ mtcmd(mt, MTWEOF, 0, 0);
+ mtcmd(mt, MTBSR, 1, 0);
}
if (mtnorewind(dev) == 0)
- mtcmd(mt, MTREW);
+ mtcmd(mt, MTREW, 0, 1);
if (mt->mt_serex)
- mtcmd(mt, -1);
+ mtcmd(mt, -1, 0, 0);
mt->mt_inuse = 0; /* Release the tape */
return 0;
@@ -257,6 +258,7 @@ mtstrategy(bp)
goto bad;
}
+ mt->mt_waswrite = bp->b_flags & B_READ ? 0 : 1;
mscp_strategy(bp, mt->mt_dev.dv_parent);
return;
@@ -419,17 +421,20 @@ mtioctl(dev, cmd, data, flag, p)
register struct mt_softc *mt = mt_cd.cd_devs[unit];
struct mtop *mtop;
struct mtget *mtget;
- int error = 0, i;
+ int error = 0, i, count;
+ count = mtop->mt_count;
switch (cmd) {
case MTIOCTOP:
mtop = (void *)data;
- i = mtop->mt_count;
- while (i-- > 0)
- mtcmd(mt, mtop->mt_op);
- break;
+ if (mtop->mt_op == MTWEOF) {
+ while (mtop->mt_count-- > 0)
+ if ((error = mtcmd(mt, mtop->mt_op, 0, 0)))
+ break;
+ } else
+ error = mtcmd(mt, mtop->mt_op, mtop->mt_count, 0);
case MTIOCGET:
mtget = (void *)data;
@@ -460,11 +465,15 @@ mtdump(dev, blkno, va, size)
/*
* Send a command to the tape drive. Wait until the command is
* finished before returning.
+ * This routine must only be called when there are no data transfer
+ * active on this device. Can we be sure of this? Or does the ctlr
+ * queue up all command packets and take them in sequential order?
+ * It sure would be nice if my manual stated this... /ragge
*/
-void
-mtcmd(mt, cmd)
+int
+mtcmd(mt, cmd, count, complete)
struct mt_softc *mt;
- int cmd;
+ int cmd, count, complete;
{
struct mscp *mp;
struct mscp_softc *mi = (void *)mt->mt_dev.dv_parent;
@@ -472,6 +481,7 @@ mtcmd(mt, cmd)
mp = mscp_getcp(mi, MSCP_WAIT);
+ mt->mt_ioctlerr = 0;
mp->mscp_unit = mt->mt_hwunit;
mp->mscp_cmdref = -1;
*mp->mscp_addr |= MSCP_OWN | MSCP_INT;
@@ -485,8 +495,7 @@ mtcmd(mt, cmd)
mp->mscp_modifier = M_MD_REVERSE;
case MTFSF:
mp->mscp_opcode = M_OP_POS;
- mp->mscp_modifier |= M_MD_OBJCOUNT;
- mp->mscp_seq.seq_buffer = 1;
+ mp->mscp_seq.seq_buffer = count;
break;
case MTBSR:
@@ -494,15 +503,27 @@ mtcmd(mt, cmd)
case MTFSR:
mp->mscp_opcode = M_OP_POS;
mp->mscp_modifier |= M_MD_OBJCOUNT;
- mp->mscp_seq.seq_bytecount = 1;
+ mp->mscp_seq.seq_bytecount = count;
break;
case MTREW:
mp->mscp_opcode = M_OP_POS;
mp->mscp_modifier = M_MD_REWIND | M_MD_CLSEX;
+ if (complete)
+ mp->mscp_modifier |= M_MD_IMMEDIATE;
mt->mt_serex = 0;
break;
+ case MTOFFL:
+ mp->mscp_opcode = M_OP_AVAILABLE;
+ mp->mscp_modifier = M_MD_UNLOAD | M_MD_CLSEX;
+ mt->mt_serex = 0;
+ break;
+
+ case MTNOP:
+ mp->mscp_opcode = M_OP_GETUNITST;
+ break;
+
case -1: /* Clear serious exception only */
mp->mscp_opcode = M_OP_POS;
mp->mscp_modifier = M_MD_CLSEX;
@@ -517,6 +538,7 @@ mtcmd(mt, cmd)
i = *mi->mi_ip;
tsleep(&mt->mt_inuse, PRIBIO, "mtioctl", 0);
+ return mt->mt_ioctlerr;
}
/*
@@ -529,8 +551,10 @@ mtcmddone(usc, mp)
{
struct mt_softc *mt = (void *)usc;
- if (mp->mscp_status)
+ if (mp->mscp_status) {
+ mt->mt_ioctlerr = EIO;
printf("%s: bad status %x\n", mt->mt_dev.dv_xname,
mp->mscp_status);
+ }
wakeup(&mt->mt_inuse);
}