summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/cd.c118
-rw-r--r--sys/scsi/ch.c829
-rw-r--r--sys/scsi/files.scsi33
-rw-r--r--sys/scsi/scsi_all.h67
-rw-r--r--sys/scsi/scsi_base.c90
-rw-r--r--sys/scsi/scsi_cd.h176
-rw-r--r--sys/scsi/scsi_changer.h412
-rw-r--r--sys/scsi/scsi_conf.h50
-rw-r--r--sys/scsi/scsi_disk.h166
-rw-r--r--sys/scsi/scsi_scanner.h78
-rw-r--r--sys/scsi/scsi_tape.h120
-rw-r--r--sys/scsi/scsiconf.c29
-rw-r--r--sys/scsi/scsiconf.h154
-rw-r--r--sys/scsi/sd.c127
-rw-r--r--sys/scsi/ss.c40
-rw-r--r--sys/scsi/ss_mustek.c84
-rw-r--r--sys/scsi/ss_mustek.h133
-rw-r--r--sys/scsi/ss_scanjet.c41
-rw-r--r--sys/scsi/ssvar.h24
-rw-r--r--sys/scsi/st.c77
-rw-r--r--sys/scsi/uk.c22
21 files changed, 1629 insertions, 1241 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index 0121681ae20..c75805af618 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cd.c,v 1.82 1996/02/14 21:46:52 christos Exp $ */
+/* $NetBSD: cd.c,v 1.90 1996/03/30 21:44:50 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
@@ -63,14 +63,14 @@
#include <sys/cdio.h>
#include <sys/proc.h>
#include <sys/cpu.h>
+#include <sys/conf.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_cd.h>
#include <scsi/scsi_disk.h> /* rw_big and start_stop come from there */
#include <scsi/scsiconf.h>
-#include <scsi/scsi_conf.h>
-#define CDOUTSTANDING 2
+#define CDOUTSTANDING 4
#define CDRETRIES 1
#define CDUNIT(z) DISKUNIT(z)
@@ -86,6 +86,7 @@ struct cd_softc {
#define CDF_WANTED 0x02
#define CDF_WLABEL 0x04 /* label is writable */
#define CDF_LABELLING 0x08 /* writing label */
+#define CDF_ANCIENT 0x10 /* disk is ancient; for minphys */
struct scsi_link *sc_link; /* contains our targ, lun, etc. */
struct cd_parms {
int blksize;
@@ -117,8 +118,12 @@ int cd_read_toc __P((struct cd_softc *, int, int, struct cd_toc_entry *,
int ));
int cd_get_parms __P((struct cd_softc *, int));
-struct cfdriver cdcd = {
- NULL, "cd", cdmatch, cdattach, DV_DISK, sizeof(struct cd_softc)
+struct cfattach cd_ca = {
+ sizeof(struct cd_softc), cdmatch, cdattach
+};
+
+struct cfdriver cd_cd = {
+ NULL, "cd", DV_DISK
};
struct dkdriver cddkdriver = { cdstrategy };
@@ -184,10 +189,16 @@ cdattach(parent, self, aux)
cd->sc_dk.dk_name = cd->sc_dev.dv_xname;
disk_attach(&cd->sc_dk);
-#if !defined(i386) || defined(NEWCONFIG)
+#if !defined(i386)
dk_establish(&cd->sc_dk, &cd->sc_dev); /* XXX */
#endif
+ /*
+ * Note if this device is ancient. This is used in cdminphys().
+ */
+ if ((sa->sa_inqbuf->version & SID_ANSII) == 0)
+ cd->flags |= CDF_ANCIENT;
+
printf("\n");
}
@@ -242,9 +253,9 @@ cdopen(dev, flag, fmt, p)
int error;
unit = CDUNIT(dev);
- if (unit >= cdcd.cd_ndevs)
+ if (unit >= cd_cd.cd_ndevs)
return ENXIO;
- cd = cdcd.cd_devs[unit];
+ cd = cd_cd.cd_devs[unit];
if (!cd)
return ENXIO;
@@ -252,7 +263,7 @@ cdopen(dev, flag, fmt, p)
SC_DEBUG(sc_link, SDEV_DB1,
("cdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit,
- cdcd.cd_ndevs, part));
+ cd_cd.cd_ndevs, part));
if ((error = cdlock(cd)) != 0)
return error;
@@ -357,7 +368,7 @@ cdclose(dev, flag, fmt, p)
int flag, fmt;
struct proc *p;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(dev)];
+ struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
int part = CDPART(dev);
int error;
@@ -395,7 +406,7 @@ void
cdstrategy(bp)
struct buf *bp;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(bp->b_dev)];
+ struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(bp->b_dev)];
int opri;
SC_DEBUG(cd->sc_link, SDEV_DB2, ("cdstrategy "));
@@ -549,9 +560,7 @@ cdstart(v)
bzero(&cmd_small, sizeof(cmd_small));
cmd_small.opcode = (bp->b_flags & B_READ) ?
READ_COMMAND : WRITE_COMMAND;
- cmd_small.addr_2 = (blkno >> 16) & 0x1f;
- cmd_small.addr_1 = (blkno >> 8) & 0xff;
- cmd_small.addr_0 = blkno & 0xff;
+ _lto3b(blkno, cmd_small.addr);
cmd_small.length = nblks & 0xff;
cmdlen = sizeof(cmd_small);
cmdp = (struct scsi_generic *)&cmd_small;
@@ -562,12 +571,8 @@ cdstart(v)
bzero(&cmd_big, sizeof(cmd_big));
cmd_big.opcode = (bp->b_flags & B_READ) ?
READ_BIG : WRITE_BIG;
- cmd_big.addr_3 = (blkno >> 24) & 0xff;
- cmd_big.addr_2 = (blkno >> 16) & 0xff;
- cmd_big.addr_1 = (blkno >> 8) & 0xff;
- cmd_big.addr_0 = blkno & 0xff;
- cmd_big.length2 = (nblks >> 8) & 0xff;
- cmd_big.length1 = nblks & 0xff;
+ _lto4b(blkno, cmd_big.addr);
+ _lto2b(nblks, cmd_big.length);
cmdlen = sizeof(cmd_big);
cmdp = (struct scsi_generic *)&cmd_big;
}
@@ -600,16 +605,42 @@ cddone(xs, complete)
return (0);
}
+void
+cdminphys(bp)
+ struct buf *bp;
+{
+ struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(bp->b_dev)];
+ long max;
+
+ /*
+ * If the device is ancient, we want to make sure that
+ * the transfer fits into a 6-byte cdb.
+ *
+ * XXX Note that the SCSI-I spec says that 256-block transfers
+ * are allowed in a 6-byte read/write, and are specified
+ * by settng the "length" to 0. However, we're conservative
+ * here, allowing only 255-block transfers in case an
+ * ancient device gets confused by length == 0. A length of 0
+ * in a 10-byte read/write actually means 0 blocks.
+ */
+ if (cd->flags & CDF_ANCIENT) {
+ max = cd->sc_dk.dk_label->d_secsize * 0xff;
+
+ if (bp->b_bcount > max)
+ bp->b_bcount = max;
+ }
+
+ (*cd->sc_link->adapter->scsi_minphys)(bp);
+}
+
int
cdread(dev, uio, ioflag)
dev_t dev;
struct uio *uio;
int ioflag;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(dev)];
- return (physio(cdstrategy, NULL, dev, B_READ,
- cd->sc_link->adapter->scsi_minphys, uio));
+ return (physio(cdstrategy, NULL, dev, B_READ, cdminphys, uio));
}
int
@@ -618,10 +649,8 @@ cdwrite(dev, uio, ioflag)
struct uio *uio;
int ioflag;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(dev)];
- return (physio(cdstrategy, NULL, dev, B_WRITE,
- cd->sc_link->adapter->scsi_minphys, uio));
+ return (physio(cdstrategy, NULL, dev, B_WRITE, cdminphys, uio));
}
/*
@@ -636,7 +665,7 @@ cdioctl(dev, cmd, addr, flag, p)
int flag;
struct proc *p;
{
- struct cd_softc *cd = cdcd.cd_devs[CDUNIT(dev)];
+ struct cd_softc *cd = cd_cd.cd_devs[CDUNIT(dev)];
int error;
SC_DEBUG(cd->sc_link, SDEV_DB2, ("cdioctl 0x%lx ", cmd));
@@ -730,9 +759,8 @@ cdioctl(dev, cmd, addr, flag, p)
&data, len);
if (error)
return error;
- len = min(len, ((data.header.data_len[0] << 8) +
- data.header.data_len[1] +
- sizeof(struct cd_sub_channel_header)));
+ len = min(len, _2btol(data.header.data_len) +
+ sizeof(struct cd_sub_channel_header));
return copyout(&data, args->data, len);
}
case CDIOREADTOCHEADER: {
@@ -968,14 +996,12 @@ cd_size(cd, flags)
2000, NULL, flags | SCSI_DATA_IN) != 0)
return 0;
- blksize = (rdcap.length_3 << 24) + (rdcap.length_2 << 16) +
- (rdcap.length_1 << 8) + rdcap.length_0;
+ blksize = _4btol(rdcap.length);
if (blksize < 512)
blksize = 2048; /* some drives lie ! */
cd->params.blksize = blksize;
- size = (rdcap.addr_3 << 24) + (rdcap.addr_2 << 16) +
- (rdcap.addr_1 << 8) + rdcap.addr_0 + 1;
+ size = _4btol(rdcap.addr) + 1;
if (size < 100)
size = 400000; /* ditto */
cd->params.disksize = size;
@@ -1036,12 +1062,8 @@ cd_play(cd, blkno, nblks)
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = PLAY;
- scsi_cmd.blk_addr[0] = (blkno >> 24) & 0xff;
- scsi_cmd.blk_addr[1] = (blkno >> 16) & 0xff;
- scsi_cmd.blk_addr[2] = (blkno >> 8) & 0xff;
- scsi_cmd.blk_addr[3] = blkno & 0xff;
- scsi_cmd.xfer_len[0] = (nblks >> 8) & 0xff;
- scsi_cmd.xfer_len[1] = nblks & 0xff;
+ _lto4b(blkno, scsi_cmd.blk_addr);
+ _lto2b(nblks, scsi_cmd.xfer_len);
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(scsi_cmd), 0, 0, CDRETRIES, 200000, NULL, 0);
}
@@ -1058,14 +1080,8 @@ cd_play_big(cd, blkno, nblks)
bzero(&scsi_cmd, sizeof(scsi_cmd));
scsi_cmd.opcode = PLAY_BIG;
- scsi_cmd.blk_addr[0] = (blkno >> 24) & 0xff;
- scsi_cmd.blk_addr[1] = (blkno >> 16) & 0xff;
- scsi_cmd.blk_addr[2] = (blkno >> 8) & 0xff;
- scsi_cmd.blk_addr[3] = blkno & 0xff;
- scsi_cmd.xfer_len[0] = (nblks >> 24) & 0xff;
- scsi_cmd.xfer_len[1] = (nblks >> 16) & 0xff;
- scsi_cmd.xfer_len[2] = (nblks >> 8) & 0xff;
- scsi_cmd.xfer_len[3] = nblks & 0xff;
+ _lto4b(blkno, scsi_cmd.blk_addr);
+ _lto4b(nblks, scsi_cmd.xfer_len);
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(scsi_cmd), 0, 0, CDRETRIES, 20000, NULL, 0);
}
@@ -1159,8 +1175,7 @@ cd_read_subchannel(cd, mode, format, track, data, len)
scsi_cmd.byte3 = SRS_SUBQ;
scsi_cmd.subchan_format = format;
scsi_cmd.track = track;
- scsi_cmd.data_len[0] = (len >> 8) & 0xff;
- scsi_cmd.data_len[1] = len & 0xff;
+ _lto2b(len, scsi_cmd.data_len);
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(struct scsi_read_subchannel), (u_char *)data, len,
CDRETRIES, 5000, NULL, SCSI_DATA_IN);
@@ -1187,8 +1202,7 @@ cd_read_toc(cd, mode, start, data, len)
if (mode == CD_MSF_FORMAT)
scsi_cmd.byte2 |= CD_MSF;
scsi_cmd.from_track = start;
- scsi_cmd.data_len[0] = (ntoc >> 8) & 0xff;
- scsi_cmd.data_len[1] = ntoc & 0xff;
+ _lto2b(ntoc, scsi_cmd.data_len);
return scsi_scsi_cmd(cd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(struct scsi_read_toc), (u_char *)data, len, CDRETRIES,
5000, NULL, SCSI_DATA_IN);
diff --git a/sys/scsi/ch.c b/sys/scsi/ch.c
index a99dc2ad7b5..811bb057fb2 100644
--- a/sys/scsi/ch.c
+++ b/sys/scsi/ch.c
@@ -1,8 +1,13 @@
-/* $OpenBSD: ch.c,v 1.3 1996/04/19 16:10:12 niklas Exp $ */
-/* $NetBSD: ch.c,v 1.16 1996/03/05 00:15:09 thorpej Exp $ */
+/* $OpenBSD: ch.c,v 1.4 1996/04/21 22:30:45 deraadt Exp $ */
+/* $NetBSD: ch.c,v 1.20 1996/04/03 00:25:39 thorpej Exp $ */
/*
- * Copyright (c) 1994 Charles Hannum. All rights reserved.
+ * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
+ * All rights reserved.
+ *
+ * Partially based on an autochanger driver written by Stefan Grefen
+ * and on an autochanger driver written by the Systems Programming Group
+ * at the University of Utah Computer Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -13,8 +18,9 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Charles Hannum.
+ * must display the following acknowledgements:
+ * This product includes software developed by Jason R. Thorpe
+ * for And Communications, http://www.and.com/
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
@@ -22,20 +28,15 @@
* 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 AUTHOR 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.
- */
-
-/*
- * Originally written by grefen@?????
- * Based on scsi drivers by Julian Elischer (julian@tfs.com)
+ * 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.
*/
-#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
@@ -43,63 +44,76 @@
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/user.h>
-#include <sys/chio.h>
+#include <sys/chio.h>
#include <sys/device.h>
+#include <sys/malloc.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_changer.h>
#include <scsi/scsiconf.h>
-#include <scsi/scsi_conf.h>
-#define CHRETRIES 2
-
-#define CHMODE(z) (minor(z) & 0x0f)
-#define CHUNIT(z) (minor(z) >> 4)
+#define CHRETRIES 2
+#define CHUNIT(x) (minor((x)))
struct ch_softc {
- struct device sc_dev;
-
- struct scsi_link *sc_link; /* all the inter level info */
- u_int16_t chmo; /* Offset of first CHM */
- u_int16_t chms; /* No. of CHM */
- u_int16_t slots; /* No. of Storage Elements */
- u_int16_t sloto; /* Offset of first SE */
- u_int16_t imexs; /* No. of Import/Export Slots */
- u_int16_t imexo; /* Offset of first IM/EX */
- u_int16_t drives; /* No. of CTS */
- u_int16_t driveo; /* Offset of first CTS */
- u_int16_t rot; /* CHM can rotate */
- u_long op_matrix; /* possible operations */
- u_int16_t lsterr; /* details of lasterror */
- u_char stor; /* posible Storage locations */
+ struct device sc_dev; /* generic device info */
+ struct scsi_link *sc_link; /* link in the SCSI bus */
+
+ int sc_picker; /* current picker */
+
+ /*
+ * The following information is obtained from the
+ * element address assignment page.
+ */
+ int sc_firsts[4]; /* firsts, indexed by CHET_* */
+ int sc_counts[4]; /* counts, indexed by CHET_* */
+
+ /*
+ * The following mask defines the legal combinations
+ * of elements for the MOVE MEDIUM command.
+ */
+ u_int8_t sc_movemask[4];
+
+ /*
+ * As above, but for EXCHANGE MEDIUM.
+ */
+ u_int8_t sc_exchangemask[4];
+
+ int flags; /* misc. info */
};
+/* sc_flags */
+#define CHF_ROTATE 0x01 /* picker can rotate */
+
+/* Autoconfiguration glue */
int chmatch __P((struct device *, void *, void *));
void chattach __P((struct device *, struct device *, void *));
-int ch_getelem __P((struct ch_softc *, short *, int, int , char *, int));
-int ch_move __P((struct ch_softc *, short *, int, int , int , int ));
-int ch_position __P((struct ch_softc *, short *, int, int , int ));
-int ch_mode_sense __P((struct ch_softc *, int));
-struct cfdriver chcd = {
- NULL, "ch", chmatch, chattach, DV_DULL, sizeof(struct ch_softc)
+struct cfattach ch_ca = {
+ sizeof(struct ch_softc), chmatch, chattach
};
-/*
- * This driver is so simple it uses all the default services
- */
-struct scsi_device ch_switch = {
- NULL,
- NULL,
- NULL,
- NULL,
+struct cfdriver ch_cd = {
+ NULL, "ch", DV_DULL
};
struct scsi_inquiry_pattern ch_patterns[] = {
{T_CHANGER, T_REMOV,
- "", "", ""},
+ "", "", ""},
};
+/* SCSI glue */
+struct scsi_device ch_switch = {
+ NULL, NULL, NULL, NULL
+};
+
+int ch_move __P((struct ch_softc *, struct changer_move *));
+int ch_exchange __P((struct ch_softc *, struct changer_exchange *));
+int ch_position __P((struct ch_softc *, struct changer_position *));
+int ch_usergetelemstatus __P((struct ch_softc *, int, u_int8_t *));
+int ch_getelemstatus __P((struct ch_softc *, int, int, caddr_t, size_t));
+int ch_get_params __P((struct ch_softc *, int));
+
int
chmatch(parent, match, aux)
struct device *parent;
@@ -111,366 +125,509 @@ chmatch(parent, match, aux)
(void)scsi_inqmatch(sa->sa_inqbuf,
(caddr_t)ch_patterns, sizeof(ch_patterns)/sizeof(ch_patterns[0]),
sizeof(ch_patterns[0]), &priority);
+
return (priority);
}
-/*
- * The routine called by the low level scsi routine when it discovers
- * a device suitable for this driver.
- */
-void
+void
chattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
- struct ch_softc *ch = (void *)self;
+ struct ch_softc *sc = (struct ch_softc *)self;
struct scsibus_attach_args *sa = aux;
- struct scsi_link *sc_link = sa->sa_sc_link;
+ struct scsi_link *link = sa->sa_sc_link;
- SC_DEBUG(sc_link, SDEV_DB2, ("chattach: "));
+ /* Glue into the SCSI bus */
+ sc->sc_link = link;
+ link->device = &ch_switch;
+ link->device_softc = sc;
+ link->openings = 1;
- /*
- * Store information needed to contact our base driver
- */
- ch->sc_link = sc_link;
- sc_link->device = &ch_switch;
- sc_link->device_softc = ch;
- sc_link->openings = 1;
+ printf("\n");
/*
- * Use the subdriver to request information regarding
- * the drive. We cannot use interrupts yet, so the
- * request must specify this.
+ * Get information about the device. Note we can't use
+ * interrupts yet.
*/
- printf("\n");
- printf("%s: ", ch->sc_dev.dv_xname);
- if (ch_mode_sense(ch, SCSI_AUTOCONF) != 0)
- printf("offline\n");
- else
- printf("%d slot(s), %d drive(s), %d arm(s), %d i/e-slot(s)\n",
- ch->slots, ch->drives, ch->chms, ch->imexs);
+ if (ch_get_params(sc, SCSI_AUTOCONF))
+ printf("%s: offline\n", sc->sc_dev.dv_xname);
+ else {
+ printf("%s: %d slot%s, %d drive%s, %d picker%s",
+ sc->sc_dev.dv_xname,
+ sc->sc_counts[CHET_ST], (sc->sc_counts[CHET_ST] > 1) ?
+ "s" : "",
+ sc->sc_counts[CHET_DT], (sc->sc_counts[CHET_DT] > 1) ?
+ "s" : "",
+ sc->sc_counts[CHET_MT], (sc->sc_counts[CHET_MT] > 1) ?
+ "s" : "");
+ if (sc->sc_counts[CHET_IE])
+ printf(", %d portal%s", sc->sc_counts[CHET_IE],
+ (sc->sc_counts[CHET_IE] > 1) ? "s" : "");
+ printf("\n");
+#ifdef CHANGER_DEBUG
+ printf("%s: move mask: 0x%x 0x%x 0x%x 0x%x\n",
+ sc->sc_dev.dv_xname,
+ sc->sc_movemask[CHET_MT], sc->sc_movemask[CHET_ST],
+ sc->sc_movemask[CHET_IE], sc->sc_movemask[CHET_DT]);
+ printf("%s: exchange mask: 0x%x 0x%x 0x%x 0x%x\n",
+ sc->sc_dev.dv_xname,
+ sc->sc_exchangemask[CHET_MT], sc->sc_exchangemask[CHET_ST],
+ sc->sc_exchangemask[CHET_IE], sc->sc_exchangemask[CHET_DT]);
+#endif /* CHANGER_DEBUG */
+ }
+
+ /* Default the current picker. */
+ sc->sc_picker = sc->sc_firsts[CHET_MT];
}
-/*
- * open the device.
- */
-int
-chopen(dev, flags, mode, p)
+int
+chopen(dev, flags, fmt, p)
dev_t dev;
- int flags;
- int mode;
+ int flags, fmt;
struct proc *p;
{
- int error = 0;
- int unit;
- struct ch_softc *ch;
- struct scsi_link *sc_link;
+ struct ch_softc *sc;
+ int unit, error = 0;
unit = CHUNIT(dev);
- if (unit >= chcd.cd_ndevs)
- return ENXIO;
- ch = chcd.cd_devs[unit];
- if (!ch)
- return ENXIO;
-
- sc_link = ch->sc_link;
-
- SC_DEBUG(sc_link, SDEV_DB1,
- ("chopen: dev=0x%x (unit %d (of %d))\n", dev, unit, chcd.cd_ndevs));
+ if ((unit >= ch_cd.cd_ndevs) ||
+ ((sc = ch_cd.cd_devs[unit]) == NULL))
+ return (ENXIO);
/*
- * Only allow one at a time
+ * Only allow one open at a time.
*/
- if (sc_link->flags & SDEV_OPEN) {
- printf("%s: already open\n", ch->sc_dev.dv_xname);
- return EBUSY;
- }
+ if (sc->sc_link->flags & SDEV_OPEN)
+ return (EBUSY);
+
+ sc->sc_link->flags |= SDEV_OPEN;
/*
- * Catch any unit attention errors.
+ * Absorb any unit attention errors. Ignore "not ready"
+ * since this might occur if e.g. a tape isn't actually
+ * loaded in the drive.
*/
- error = scsi_test_unit_ready(sc_link, SCSI_IGNORE_MEDIA_CHANGE);
- if (error)
+ if (error = scsi_test_unit_ready(sc->sc_link,
+ SCSI_IGNORE_NOT_READY|SCSI_IGNORE_MEDIA_CHANGE))
goto bad;
- sc_link->flags |= SDEV_OPEN; /* unit attn are now errors */
-
/*
- * Make sure data is loaded
+ * Make sure our parameters are up to date.
*/
- if ((error = ch_mode_sense(ch, 0)) != 0) {
- printf("%s: offline\n", ch->sc_dev.dv_xname);
+ if (error = ch_get_params(sc, 0))
goto bad;
- }
- SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
- return 0;
+ return (0);
-bad:
- sc_link->flags &= ~SDEV_OPEN;
- return error;
+ bad:
+ sc->sc_link->flags &= ~SDEV_OPEN;
+ return (error);
}
-/*
- * close the device.. only called if we are the LAST
- * occurence of an open device
- */
-int
-chclose(dev, flags, mode, p)
+int
+chclose(dev, flags, fmt, p)
dev_t dev;
- int flags;
- int mode;
+ int flags, fmt;
struct proc *p;
{
- struct ch_softc *ch = chcd.cd_devs[CHUNIT(dev)];
-
- SC_DEBUG(ch->sc_link, SDEV_DB1, ("closing\n"));
- ch->sc_link->flags &= ~SDEV_OPEN;
+ struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)];
- return 0;
+ sc->sc_link->flags &= ~SDEV_OPEN;
+ return (0);
}
-/*
- * Perform special action on behalf of the user
- * Knows about the internals of this device
- */
-int
-chioctl(dev, cmd, arg, mode, p)
+int
+chioctl(dev, cmd, data, flags, p)
dev_t dev;
u_long cmd;
- caddr_t arg;
- int mode;
+ caddr_t data;
+ int flags;
struct proc *p;
{
- struct ch_softc *ch = chcd.cd_devs[CHUNIT(dev)];
- struct scsi_link *sc_link = ch->sc_link;
- int flags;
-
- /*
- * Find the device that the user is talking about
- */
- flags = 0; /* give error messages, act on errors etc. */
+ struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)];
+ caddr_t elemdata;
+ int error = 0;
switch (cmd) {
- case CHIOOP: {
- struct chop *chop = (struct chop *) arg;
- SC_DEBUG(sc_link, SDEV_DB2, ("[chtape_chop: %x]\n",
- chop->ch_op));
-
- switch (chop->ch_op) {
- case CHGETPARAM:
- chop->u.getparam.chmo = ch->chmo;
- chop->u.getparam.chms = ch->chms;
- chop->u.getparam.sloto = ch->sloto;
- chop->u.getparam.slots = ch->slots;
- chop->u.getparam.imexo = ch->imexo;
- chop->u.getparam.imexs = ch->imexs;
- chop->u.getparam.driveo = ch->driveo;
- chop->u.getparam.drives = ch->drives;
- chop->u.getparam.rot = ch->rot;
- chop->result = 0;
- return 0;
- break;
- case CHPOSITION:
- return ch_position(ch, &chop->result,
- chop->u.position.chm, chop->u.position.to, flags);
- case CHMOVE:
- return ch_move(ch, &chop->result, chop->u.position.chm,
- chop->u.move.from, chop->u.move.to, flags);
- case CHGETELEM:
- return ch_getelem(ch, &chop->result,
- chop->u.get_elem_stat.type,
- chop->u.get_elem_stat.from,
- (char *) &chop->u.get_elem_stat.elem_data, flags);
- default:
- return EINVAL;
- }
- }
+ case CHIOMOVE:
+ error = ch_move(sc, (struct changer_move *)data);
+ break;
+
+ case CHIOEXCHANGE:
+ error = ch_exchange(sc, (struct changer_exchange *)data);
+ break;
+
+ case CHIOPOSITION:
+ error = ch_position(sc, (struct changer_position *)data);
+ break;
+
+ case CHIOGPICKER:
+ *(int *)data = sc->sc_picker - sc->sc_firsts[CHET_MT];
+ break;
+
+ case CHIOSPICKER: {
+ int new_picker = *(int *)data;
+
+ if (new_picker > (sc->sc_counts[CHET_MT] - 1))
+ return (EINVAL);
+ sc->sc_picker = sc->sc_firsts[CHET_MT] + new_picker;
+ break; }
+
+ case CHIOGPARAMS: {
+ struct changer_params *cp = (struct changer_params *)data;
+
+ cp->cp_curpicker = sc->sc_picker - sc->sc_firsts[CHET_MT];
+ cp->cp_npickers = sc->sc_counts[CHET_MT];
+ cp->cp_nslots = sc->sc_counts[CHET_ST];
+ cp->cp_nportals = sc->sc_counts[CHET_IE];
+ cp->cp_ndrives = sc->sc_counts[CHET_DT];
+ break; }
+
+ case CHIOGSTATUS: {
+ struct changer_element_status *ces =
+ (struct changer_element_status *)data;
+
+ error = ch_usergetelemstatus(sc, ces->ces_type, ces->ces_data);
+ break; }
+
+ /* Implement prevent/allow? */
+
default:
- return scsi_do_ioctl(sc_link, dev, cmd, arg, mode, p);
+ error = scsi_do_ioctl(sc->sc_link, dev, cmd, data, flags, p);
+ break;
}
-#ifdef DIAGNOSTIC
- panic("chioctl: impossible");
-#endif
+
+ return (error);
}
-int
-ch_getelem(ch, stat, type, from, data, flags)
- struct ch_softc *ch;
- short *stat;
- int type, from;
- char *data;
- int flags;
+int
+ch_move(sc, cm)
+ struct ch_softc *sc;
+ struct changer_move *cm;
{
- struct scsi_read_element_status scsi_cmd;
- char elbuf[32];
- int error;
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = READ_ELEMENT_STATUS;
- scsi_cmd.byte2 = type;
- scsi_cmd.starting_element_addr[0] = (from >> 8) & 0xff;
- scsi_cmd.starting_element_addr[1] = from & 0xff;
- scsi_cmd.number_of_elements[1] = 1;
- scsi_cmd.allocation_length[2] = 32;
-
- error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), (u_char *) elbuf, 32, CHRETRIES, 100000, NULL,
- SCSI_DATA_IN | flags);
- if (error)
- *stat = ch->lsterr;
- else
- *stat = 0;
- bcopy(elbuf + 16, data, 16);
- return error;
+ struct scsi_move_medium cmd;
+ u_int16_t fromelem, toelem;
+
+ /*
+ * Check arguments.
+ */
+ if ((cm->cm_fromtype > CHET_DT) || (cm->cm_totype > CHET_DT))
+ return (EINVAL);
+ if ((cm->cm_fromunit > (sc->sc_counts[cm->cm_fromtype] - 1)) ||
+ (cm->cm_tounit > (sc->sc_counts[cm->cm_totype] - 1)))
+ return (ENODEV);
+
+ /*
+ * Check the request against the changer's capabilities.
+ */
+ if ((sc->sc_movemask[cm->cm_fromtype] & (1 << cm->cm_totype)) == 0)
+ return (EINVAL);
+
+ /*
+ * Calculate the source and destination elements.
+ */
+ fromelem = sc->sc_firsts[cm->cm_fromtype] + cm->cm_fromunit;
+ toelem = sc->sc_firsts[cm->cm_totype] + cm->cm_tounit;
+
+ /*
+ * Build the SCSI command.
+ */
+ bzero(&cmd, sizeof(cmd));
+ cmd.opcode = MOVE_MEDIUM;
+ _lto2b(sc->sc_picker, cmd.tea);
+ _lto2b(fromelem, cmd.src);
+ _lto2b(toelem, cmd.dst);
+ if (cm->cm_flags & CM_INVERT)
+ cmd.flags |= MOVE_MEDIUM_INVERT;
+
+ /*
+ * Send command to changer.
+ */
+ return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), NULL, 0, CHRETRIES, 100000, NULL, 0));
}
-int
-ch_move(ch, stat, chm, from, to, flags)
- struct ch_softc *ch;
- short *stat;
- int chm, from, to, flags;
+int
+ch_exchange(sc, ce)
+ struct ch_softc *sc;
+ struct changer_exchange *ce;
{
- struct scsi_move_medium scsi_cmd;
- int error;
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = MOVE_MEDIUM;
- scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff;
- scsi_cmd.transport_element_address[1] = chm & 0xff;
- scsi_cmd.source_address[0] = (from >> 8) & 0xff;
- scsi_cmd.source_address[1] = from & 0xff;
- scsi_cmd.destination_address[0] = (to >> 8) & 0xff;
- scsi_cmd.destination_address[1] = to & 0xff;
- scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0;
- error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags);
- if (error)
- *stat = ch->lsterr;
- else
- *stat = 0;
- return error;
+ struct scsi_exchange_medium cmd;
+ u_int16_t src, dst1, dst2;
+
+ /*
+ * Check arguments.
+ */
+ if ((ce->ce_srctype > CHET_DT) || (ce->ce_fdsttype > CHET_DT) ||
+ (ce->ce_sdsttype > CHET_DT))
+ return (EINVAL);
+ if ((ce->ce_srcunit > (sc->sc_counts[ce->ce_srctype] - 1)) ||
+ (ce->ce_fdstunit > (sc->sc_counts[ce->ce_fdsttype] - 1)) ||
+ (ce->ce_sdstunit > (sc->sc_counts[ce->ce_sdsttype] - 1)))
+ return (ENODEV);
+
+ /*
+ * Check the request against the changer's capabilities.
+ */
+ if (((sc->sc_exchangemask[ce->ce_srctype] &
+ (1 << ce->ce_fdsttype)) == 0) ||
+ ((sc->sc_exchangemask[ce->ce_fdsttype] &
+ (1 << ce->ce_sdsttype)) == 0))
+ return (EINVAL);
+
+ /*
+ * Calculate the source and destination elements.
+ */
+ src = sc->sc_firsts[ce->ce_srctype] + ce->ce_srcunit;
+ dst1 = sc->sc_firsts[ce->ce_fdsttype] + ce->ce_fdstunit;
+ dst2 = sc->sc_firsts[ce->ce_sdsttype] + ce->ce_sdstunit;
+
+ /*
+ * Build the SCSI command.
+ */
+ bzero(&cmd, sizeof(cmd));
+ cmd.opcode = EXCHANGE_MEDIUM;
+ _lto2b(sc->sc_picker, cmd.tea);
+ _lto2b(src, cmd.src);
+ _lto2b(dst1, cmd.fdst);
+ _lto2b(dst2, cmd.sdst);
+ if (ce->ce_flags & CE_INVERT1)
+ cmd.flags |= EXCHANGE_MEDIUM_INV1;
+ if (ce->ce_flags & CE_INVERT2)
+ cmd.flags |= EXCHANGE_MEDIUM_INV2;
+
+ /*
+ * Send command to changer.
+ */
+ return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), NULL, 0, CHRETRIES, 100000, NULL, 0));
}
-int
-ch_position(ch, stat, chm, to, flags)
- struct ch_softc *ch;
- short *stat;
- int chm, to, flags;
+int
+ch_position(sc, cp)
+ struct ch_softc *sc;
+ struct changer_position *cp;
{
- struct scsi_position_to_element scsi_cmd;
- int error;
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = POSITION_TO_ELEMENT;
- scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff;
- scsi_cmd.transport_element_address[1] = chm & 0xff;
- scsi_cmd.source_address[0] = (to >> 8) & 0xff;
- scsi_cmd.source_address[1] = to & 0xff;
- scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0;
- error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags);
- if (error)
- *stat = ch->lsterr;
- else
- *stat = 0;
- return error;
+ struct scsi_position_to_element cmd;
+ u_int16_t dst;
+
+ /*
+ * Check arguments.
+ */
+ if (cp->cp_type > CHET_DT)
+ return (EINVAL);
+ if (cp->cp_unit > (sc->sc_counts[cp->cp_type] - 1))
+ return (ENODEV);
+
+ /*
+ * Calculate the destination element.
+ */
+ dst = sc->sc_firsts[cp->cp_type] + cp->cp_unit;
+
+ /*
+ * Build the SCSI command.
+ */
+ bzero(&cmd, sizeof(cmd));
+ cmd.opcode = POSITION_TO_ELEMENT;
+ _lto2b(sc->sc_picker, cmd.tea);
+ _lto2b(dst, cmd.dst);
+ if (cp->cp_flags & CP_INVERT)
+ cmd.flags |= POSITION_TO_ELEMENT_INVERT;
+
+ /*
+ * Send command to changer.
+ */
+ return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), NULL, 0, CHRETRIES, 100000, NULL, 0));
}
/*
- * Get the scsi driver to send a full inquiry to the
- * device and use the results to fill out the global
- * parameter structure.
+ * Perform a READ ELEMENT STATUS on behalf of the user, and return to
+ * the user only the data the user is interested in (i.e. an array of
+ * flags bytes).
*/
-int
-ch_mode_sense(ch, flags)
- struct ch_softc *ch;
- int flags;
+int
+ch_usergetelemstatus(sc, chet, uptr)
+ struct ch_softc *sc;
+ int chet;
+ u_int8_t *uptr;
+{
+ struct read_element_status_header *st_hdr;
+ struct read_element_status_page_header *pg_hdr;
+ struct read_element_status_descriptor *desc;
+ caddr_t data = NULL;
+ size_t size, desclen;
+ int avail, i, error = 0;
+ u_int8_t *user_data = NULL;
+
+ /*
+ * If there are no elements of the requested type in the changer,
+ * the request is invalid.
+ */
+ if (sc->sc_counts[chet] == 0)
+ return (EINVAL);
+
+ /*
+ * Request one descriptor for the given element type. This
+ * is used to determine the size of the descriptor so that
+ * we can allocate enough storage for all of them. We assume
+ * that the first one can fit into 1k.
+ */
+ data = (caddr_t)malloc(1024, M_DEVBUF, M_WAITOK);
+ if (error = ch_getelemstatus(sc, sc->sc_firsts[chet], 1, data, 1024))
+ goto done;
+
+ st_hdr = (struct read_element_status_header *)data;
+ pg_hdr = (struct read_element_status_page_header *)((u_long)st_hdr +
+ sizeof(struct read_element_status_header));
+ desclen = _2btol(pg_hdr->edl);
+
+ size = sizeof(struct read_element_status_header) +
+ sizeof(struct read_element_status_page_header) +
+ (desclen * sc->sc_counts[chet]);
+
+ /*
+ * Reallocate storage for descriptors and get them from the
+ * device.
+ */
+ free(data, M_DEVBUF);
+ data = (caddr_t)malloc(size, M_DEVBUF, M_WAITOK);
+ if (error = ch_getelemstatus(sc, sc->sc_firsts[chet],
+ sc->sc_counts[chet], data, size))
+ goto done;
+
+ /*
+ * Fill in the user status array.
+ */
+ st_hdr = (struct read_element_status_header *)data;
+ avail = _2btol(st_hdr->count);
+ if (avail != sc->sc_counts[chet])
+ printf("%s: warning, READ ELEMENT STATUS avail != count\n",
+ sc->sc_dev.dv_xname);
+
+ user_data = (u_int8_t *)malloc(avail, M_DEVBUF, M_WAITOK);
+
+ desc = (struct read_element_status_descriptor *)((u_long)data +
+ sizeof(struct read_element_status_header) +
+ sizeof(struct read_element_status_page_header));
+ for (i = 0; i < avail; ++i) {
+ user_data[i] = desc->flags1;
+ (u_long)desc += desclen;
+ }
+
+ /* Copy flags array out to userspace. */
+ error = copyout(user_data, uptr, avail);
+
+ done:
+ if (data != NULL)
+ free(data, M_DEVBUF);
+ if (user_data != NULL)
+ free(user_data, M_DEVBUF);
+ return (error);
+}
+
+int
+ch_getelemstatus(sc, first, count, data, datalen)
+ struct ch_softc *sc;
+ int first, count;
+ caddr_t data;
+ size_t datalen;
{
- struct scsi_mode_sense scsi_cmd;
- u_char scsi_sense[128]; /* Can't use scsi_mode_sense_data because of
- * missing block descriptor.
- */
- u_char *b;
- int i, l;
- int error;
- struct scsi_link *sc_link = ch->sc_link;
+ struct scsi_read_element_status cmd;
/*
- * First check if we have it all loaded
+ * Build SCSI command.
*/
- if (sc_link->flags & SDEV_MEDIA_LOADED)
- return 0;
+ bzero(&cmd, sizeof(cmd));
+ cmd.opcode = READ_ELEMENT_STATUS;
+ _lto2b(first, cmd.sea);
+ _lto2b(count, cmd.count);
+ _lto3b(datalen, cmd.len);
/*
- * First do a mode sense
+ * Send command to changer.
*/
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = MODE_SENSE;
- scsi_cmd.byte2 = SMS_DBD;
- scsi_cmd.page = 0x3f; /* All Pages */
- scsi_cmd.length = sizeof(scsi_sense);
+ return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), (u_char *)data, datalen, CHRETRIES, 100000, NULL, 0));
+}
+
+
+/*
+ * Ask the device about itself and fill in the parameters in our
+ * softc.
+ */
+int
+ch_get_params(sc, scsiflags)
+ struct ch_softc *sc;
+ int scsiflags;
+{
+ struct scsi_mode_sense cmd;
+ struct scsi_mode_sense_data {
+ struct scsi_mode_header header;
+ union {
+ struct page_element_address_assignment ea;
+ struct page_transport_geometry_parameters tg;
+ struct page_device_capabilities cap;
+ } pages;
+ } sense_data;
+ int error, from;
+ u_int8_t *moves, *exchanges;
/*
- * Read in the pages
+ * Grab info from the element address assignment page.
*/
- error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd,
- sizeof(scsi_cmd), (u_char *) &scsi_sense,
- sizeof(scsi_sense), CHRETRIES, 5000, NULL,
- flags | SCSI_DATA_IN);
+ bzero(&cmd, sizeof(cmd));
+ bzero(&sense_data, sizeof(sense_data));
+ cmd.opcode = MODE_SENSE;
+ cmd.byte2 |= 0x08; /* disable block descriptors */
+ cmd.page = 0x1d;
+ cmd.length = (sizeof(sense_data) & 0xff);
+ error = scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), (u_char *)&sense_data, sizeof(sense_data), CHRETRIES,
+ 6000, NULL, scsiflags | SCSI_DATA_IN);
if (error) {
- printf("%s: could not mode sense\n", ch->sc_dev.dv_xname);
- return error;
+ printf("%s: could not sense element address page\n");
+ return (error);
}
- sc_link->flags |= SDEV_MEDIA_LOADED;
- l = scsi_sense[0] - 3;
- b = &scsi_sense[4];
+ sc->sc_firsts[CHET_MT] = _2btol(sense_data.pages.ea.mtea);
+ sc->sc_counts[CHET_MT] = _2btol(sense_data.pages.ea.nmte);
+ sc->sc_firsts[CHET_ST] = _2btol(sense_data.pages.ea.fsea);
+ sc->sc_counts[CHET_ST] = _2btol(sense_data.pages.ea.nse);
+ sc->sc_firsts[CHET_IE] = _2btol(sense_data.pages.ea.fieea);
+ sc->sc_counts[CHET_IE] = _2btol(sense_data.pages.ea.niee);
+ sc->sc_firsts[CHET_DT] = _2btol(sense_data.pages.ea.fdtea);
+ sc->sc_counts[CHET_DT] = _2btol(sense_data.pages.ea.ndte);
+
+ /* XXX ask for page trasport geom */
/*
- * To avoid alignment problems
+ * Grab info from the capabilities page.
*/
-/* XXXX - FIX THIS FOR MSB */
-#define p2copy(valp) (valp[1] | (valp[0]<<8)); valp+=2
-#define p4copy(valp) (valp[3] | (valp[2]<<8) | (valp[1]<<16) | (valp[0]<<24)); valp+=4
-#if 0
- printf("\nmode_sense %d\n", l);
- for (i = 0; i < l + 4; i++)
- printf("%x%c", scsi_sense[i], i % 8 == 7 ? '\n' : ':');
- printf("\n");
-#endif
- for (i = 0; i < l;) {
- u_char pc = (*b++) & 0x3f;
- u_char pl = *b++;
- u_char *bb = b;
- switch (pc) {
- case 0x1d:
- ch->chmo = p2copy(bb);
- ch->chms = p2copy(bb);
- ch->sloto = p2copy(bb);
- ch->slots = p2copy(bb);
- ch->imexo = p2copy(bb);
- ch->imexs = p2copy(bb);
- ch->driveo = p2copy(bb);
- ch->drives = p2copy(bb);
- break;
- case 0x1e:
- ch->rot = *b & 0x1;
- break;
- case 0x1f:
- ch->stor = *b & 0xf;
- bb += 2;
- ch->stor = p4copy(bb);
- break;
- default:
- break;
- }
- b += pl;
- i += pl + 2;
+ bzero(&cmd, sizeof(cmd));
+ bzero(&sense_data, sizeof(sense_data));
+ cmd.opcode = MODE_SENSE;
+ cmd.byte2 |= 0x08; /* disable block descriptors */
+ cmd.page = 0x1f;
+ cmd.length = (sizeof(sense_data) & 0xff);
+ error = scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
+ sizeof(cmd), (u_char *)&sense_data, sizeof(sense_data), CHRETRIES,
+ 6000, NULL, scsiflags | SCSI_DATA_IN);
+ if (error) {
+ printf("%s: could not sense capabilities page\n");
+ return (error);
+ }
+
+ bzero(sc->sc_movemask, sizeof(sc->sc_movemask));
+ bzero(sc->sc_exchangemask, sizeof(sc->sc_exchangemask));
+ moves = &sense_data.pages.cap.move_from_mt;
+ exchanges = &sense_data.pages.cap.exchange_with_mt;
+ for (from = CHET_MT; from <= CHET_DT; ++from) {
+ sc->sc_movemask[from] = moves[from];
+ sc->sc_exchangemask[from] = exchanges[from];
}
- SC_DEBUG(sc_link, SDEV_DB2,
- (" cht(%d-%d)slot(%d-%d)imex(%d-%d)cts(%d-%d) %s rotate\n",
- ch->chmo, ch->chms, ch->sloto, ch->slots, ch->imexo, ch->imexs,
- ch->driveo, ch->drives, ch->rot ? "can" : "can't"));
- return 0;
+
+ sc->sc_link->flags |= SDEV_MEDIA_LOADED;
+ return (0);
}
diff --git a/sys/scsi/files.scsi b/sys/scsi/files.scsi
index 554ac2ac95c..de5ac8bfd71 100644
--- a/sys/scsi/files.scsi
+++ b/sys/scsi/files.scsi
@@ -1,4 +1,4 @@
-# $NetBSD: files.scsi,v 1.2 1996/02/18 20:32:40 mycroft Exp $
+# $NetBSD: files.scsi,v 1.3 1996/03/17 00:59:45 thorpej Exp $
#
# Config.new file and device description for machine-independent SCSI code.
# Included by ports that need it. Ports that usee it must provide
@@ -9,22 +9,35 @@ file scsi/scsi_base.c scsi
file scsi/scsi_ioctl.c scsi
file scsi/scsiconf.c scsi
-device scsibus at scsi {target = -1, lun = -1}
+device scsibus {target = -1, lun = -1}
+attach scsibus at scsi
-device cd at scsibus: disk
+device cd: disk
+attach cd at scsibus
file scsi/cd.c cd needs-flag
-device ch at scsibus: disk
+
+device ch: disk
+attach ch at scsibus
file scsi/ch.c ch needs-flag
-device sd at scsibus: disk
+
+device sd: disk
+attach sd at scsibus
file scsi/sd.c sd needs-flag
-device st at scsibus: tape
+
+device st: tape
+attach st at scsibus
file scsi/st.c st needs-flag
-device ss at scsibus: tape
+
+device ss: tape
+attach ss at scsibus
file scsi/ss.c ss needs-flag
file scsi/ss_mustek.c ss
file scsi/ss_scanjet.c ss
-device su at scsibus: disk
+
+device su: disk
+attach su at scsibus
file scsi/su.c su needs-flag
-device uk at scsibus: disk
-file scsi/uk.c uk needs-flag
+device uk: disk
+attach uk at scsibus
+file scsi/uk.c uk needs-flag
diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h
index 646826c872b..f0ab11090ef 100644
--- a/sys/scsi/scsi_all.h
+++ b/sys/scsi/scsi_all.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_all.h,v 1.6 1994/12/28 19:42:54 mycroft Exp $ */
+/* $NetBSD: scsi_all.h,v 1.7 1996/03/19 03:06:10 mycroft Exp $ */
/*
* SCSI general interface description
@@ -229,58 +229,33 @@ struct scsi_inquiry_data {
u_int8_t extra[8];
};
-/*
- * This looks bad, and it is. However it fixes padding problems
- * caused by using unions. This *needs* to be an array, if this code
- * is to work on any architecture.
- */
-struct scsi_sense_data {
-/* 1*/ u_int8_t error_code; /* same bits as new version */
-#define XXX_unextended_blockhi extended_segment
-#define XXX_unextended_blockmed extended_flags
-#define XXX_unextended_blocklow extended_info[0]
-/* 2*/ u_int8_t extended_segment;
-/* 3*/ u_int8_t extended_flags; /* same bits as new version */
-/* 7*/ u_int8_t extended_info[4];
-/* 8*/ u_int8_t extended_extra_len;
- /*
- * allocate enough room to hold new stuff
- * (by increasing 16 to 24 below)
- */
-/*32*/ u_int8_t extended_extra_bytes[24];
-}; /* total of 32 bytes */
-
-struct scsi_sense_data_new {
+struct scsi_sense_data_unextended {
+/* 1*/ u_int8_t error_code;
+/* 4*/ u_int8_t block[3];
+};
+
+struct scsi_sense_data {
/* 1*/ u_int8_t error_code;
#define SSD_ERRCODE 0x7F
#define SSD_ERRCODE_VALID 0x80
- union {
- struct { /* this is deprecated, the standard says "DON'T"*/
-/* 2*/ u_int8_t blockhi;
-/* 3*/ u_int8_t blockmed;
-/* 4*/ u_int8_t blocklow;
- } unextended;
- struct {
-/* 2*/ u_int8_t segment;
-/* 3*/ u_int8_t flags;
+/* 2*/ u_int8_t segment;
+/* 3*/ u_int8_t flags;
#define SSD_KEY 0x0F
#define SSD_ILI 0x20
#define SSD_EOM 0x40
#define SSD_FILEMARK 0x80
-/* 7*/ u_int8_t info[4];
-/* 8*/ u_int8_t extra_len;
-/*12*/ u_int8_t cmd_spec_info[4];
-/*13*/ u_int8_t add_sense_code;
-/*14*/ u_int8_t add_sense_code_qual;
-/*15*/ u_int8_t fru;
-/*16*/ u_int8_t sense_key_spec_1;
-#define SSD_SCS_VALID 0x80
-/*17*/ u_int8_t sense_key_spec_2;
-/*18*/ u_int8_t sense_key_spec_3;
-/*32*/ u_int8_t extra_bytes[14];
- } extended;
- } ext;
-}; /* total of 32 bytes */
+/* 7*/ u_int8_t info[4];
+/* 8*/ u_int8_t extra_len;
+/*12*/ u_int8_t cmd_spec_info[4];
+/*13*/ u_int8_t add_sense_code;
+/*14*/ u_int8_t add_sense_code_qual;
+/*15*/ u_int8_t fru;
+/*16*/ u_int8_t sense_key_spec_1;
+#define SSD_SCS_VALID 0x80
+/*17*/ u_int8_t sense_key_spec_2;
+/*18*/ u_int8_t sense_key_spec_3;
+/*32*/ u_int8_t extra_bytes[14];
+};
struct scsi_blk_desc {
u_int8_t density;
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index aa1bd6e86aa..99d310233e9 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: scsi_base.c,v 1.6 1996/02/29 13:12:22 niklas Exp $ */
-/* $NetBSD: scsi_base.c,v 1.33 1996/02/14 21:47:14 christos Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.7 1996/04/21 22:30:50 deraadt Exp $ */
+/* $NetBSD: scsi_base.c,v 1.34 1996/03/19 03:06:28 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
@@ -195,7 +195,6 @@ scsi_size(sc_link, flags)
{
struct scsi_read_cap_data rdcap;
struct scsi_read_capacity scsi_cmd;
- u_long size;
/*
* make up a scsi command and ask the scsi driver to do
@@ -214,13 +213,9 @@ scsi_size(sc_link, flags)
sc_print_addr(sc_link);
printf("could not get size\n");
return 0;
- } else {
- size = rdcap.addr_0 + 1;
- size += rdcap.addr_1 << 8;
- size += rdcap.addr_2 << 16;
- size += rdcap.addr_3 << 24;
}
- return size;
+
+ return _4btol(rdcap.addr) + 1;
}
/*
@@ -626,20 +621,20 @@ scsi_interpret_sense(xs)
sense->error_code & SSD_ERRCODE,
sense->error_code & SSD_ERRCODE_VALID ? 1 : 0);
printf("seg%x key%x ili%x eom%x fmark%x\n",
- sense->extended_segment,
- sense->extended_flags & SSD_KEY,
- sense->extended_flags & SSD_ILI ? 1 : 0,
- sense->extended_flags & SSD_EOM ? 1 : 0,
- sense->extended_flags & SSD_FILEMARK ? 1 : 0);
+ sense->segment,
+ sense->flags & SSD_KEY,
+ sense->flags & SSD_ILI ? 1 : 0,
+ sense->flags & SSD_EOM ? 1 : 0,
+ sense->flags & SSD_FILEMARK ? 1 : 0);
printf("info: %x %x %x %x followed by %d extra bytes\n",
- sense->extended_info[0],
- sense->extended_info[1],
- sense->extended_info[2],
- sense->extended_info[3],
- sense->extended_extra_len);
+ sense->info[0],
+ sense->info[1],
+ sense->info[2],
+ sense->info[3],
+ sense->extra_len);
printf("extra: ");
- for (count = 0; count < sense->extended_extra_len; count++)
- printf("%x ", sense->extended_extra_bytes[count]);
+ for (count = 0; count < sense->extra_len; count++)
+ printf("%x ", sense->extra_bytes[count]);
printf("\n");
}
#endif /*SCSIDEBUG */
@@ -661,15 +656,14 @@ scsi_interpret_sense(xs)
*/
case 0x71: /* delayed error */
sc_print_addr(sc_link);
- key = sense->extended_flags & SSD_KEY;
+ key = sense->flags & SSD_KEY;
printf(" DELAYED ERROR, key = 0x%x\n", key);
case 0x70:
- if ((sense->error_code & SSD_ERRCODE_VALID) != 0) {
- bcopy(sense->extended_info, &info, sizeof info);
- info = ntohl(info);
- } else
+ if ((sense->error_code & SSD_ERRCODE_VALID) != 0)
+ info = _4btol(sense->info);
+ else
info = 0;
- key = sense->extended_flags & SSD_KEY;
+ key = sense->flags & SSD_KEY;
switch (key) {
case 0x0: /* NO SENSE */
@@ -749,11 +743,11 @@ scsi_interpret_sense(xs)
printf(", info = %d (decimal)", info);
}
}
- if (sense->extended_extra_len != 0) {
+ if (sense->extra_len != 0) {
int n;
printf(", data =");
- for (n = 0; n < sense->extended_extra_len; n++)
- printf(" %02x", sense->extended_extra_bytes[n]);
+ for (n = 0; n < sense->extra_len; n++)
+ printf(" %02x", sense->extra_bytes[n]);
}
printf("\n");
}
@@ -767,10 +761,10 @@ scsi_interpret_sense(xs)
printf("error code %d",
sense->error_code & SSD_ERRCODE);
if ((sense->error_code & SSD_ERRCODE_VALID) != 0) {
+ struct scsi_sense_data_unextended *usense =
+ (struct scsi_sense_data_unextended *)sense;
printf(" at block no. %d (decimal)",
- (sense->XXX_unextended_blockhi << 16) +
- (sense->XXX_unextended_blockmed << 8) +
- (sense->XXX_unextended_blocklow));
+ _3btol(usense->block));
}
printf("\n");
return EIO;
@@ -781,36 +775,6 @@ scsi_interpret_sense(xs)
* Utility routines often used in SCSI stuff
*/
-/*
- * convert a physical address to 3 bytes,
- * MSB at the lowest address,
- * LSB at the highest.
- */
-void
-lto3b(val, bytes)
- u_int32_t val;
- u_int8_t *bytes;
-{
-
- *bytes++ = (val >> 16) & 0xff;
- *bytes++ = (val >> 8) & 0xff;
- *bytes = val & 0xff;
-}
-
-/*
- * The reverse of lto3b
- */
-u_int32_t
-_3btol(bytes)
- u_int8_t *bytes;
-{
- u_int32_t rc;
-
- rc = (*bytes++ << 16);
- rc += (*bytes++ << 8);
- rc += *bytes;
- return (rc);
-}
/*
* Print out the scsi_link structure's address info.
diff --git a/sys/scsi/scsi_cd.h b/sys/scsi/scsi_cd.h
index bbd15676e98..ddf2431b2da 100644
--- a/sys/scsi/scsi_cd.h
+++ b/sys/scsi/scsi_cd.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_cd.h,v 1.5 1994/12/28 19:42:58 mycroft Exp $ */
+/* $NetBSD: scsi_cd.h,v 1.6 1996/03/19 03:06:39 mycroft Exp $ */
/*
* Written by Julian Elischer (julian@tfs.com)
@@ -31,117 +31,111 @@
struct scsi_read_capacity_cd {
u_int8_t opcode;
- u_char byte2;
- u_char addr_3; /* Most Significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least Significant */
- u_char unused[3];
- u_char control;
+ u_int8_t byte2;
+ u_int8_t addr[4];
+ u_int8_t unused[3];
+ u_int8_t control;
};
struct scsi_pause {
- u_char opcode;
- u_char byte2;
- u_char unused[6];
- u_char resume;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[6];
+ u_int8_t resume;
+ u_int8_t control;
};
#define PA_PAUSE 1
#define PA_RESUME 0
struct scsi_play_msf {
- u_char opcode;
- u_char byte2;
- u_char unused;
- u_char start_m;
- u_char start_s;
- u_char start_f;
- u_char end_m;
- u_char end_s;
- u_char end_f;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused;
+ u_int8_t start_m;
+ u_int8_t start_s;
+ u_int8_t start_f;
+ u_int8_t end_m;
+ u_int8_t end_s;
+ u_int8_t end_f;
+ u_int8_t control;
};
struct scsi_play_track {
- u_char opcode;
- u_char byte2;
- u_char unused[2];
- u_char start_track;
- u_char start_index;
- u_char unused1;
- u_char end_track;
- u_char end_index;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[2];
+ u_int8_t start_track;
+ u_int8_t start_index;
+ u_int8_t unused1;
+ u_int8_t end_track;
+ u_int8_t end_index;
+ u_int8_t control;
};
struct scsi_play {
- u_char opcode;
- u_char byte2;
- u_char blk_addr[4];
- u_char unused;
- u_char xfer_len[2];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t blk_addr[4];
+ u_int8_t unused;
+ u_int8_t xfer_len[2];
+ u_int8_t control;
};
struct scsi_play_big {
- u_char opcode;
- u_char byte2; /* same as above */
- u_char blk_addr[4];
- u_char xfer_len[4];
- u_char unused;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2; /* same as above */
+ u_int8_t blk_addr[4];
+ u_int8_t xfer_len[4];
+ u_int8_t unused;
+ u_int8_t control;
};
struct scsi_play_rel_big {
- u_char opcode;
- u_char byte2; /* same as above */
- u_char blk_addr[4];
- u_char xfer_len[4];
- u_char track;
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2; /* same as above */
+ u_int8_t blk_addr[4];
+ u_int8_t xfer_len[4];
+ u_int8_t track;
+ u_int8_t control;
};
struct scsi_read_header {
- u_char opcode;
- u_char byte2;
- u_char blk_addr[4];
- u_char unused;
- u_char data_len[2];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t blk_addr[4];
+ u_int8_t unused;
+ u_int8_t data_len[2];
+ u_int8_t control;
};
struct scsi_read_subchannel {
- u_char opcode;
- u_char byte2;
- u_char byte3;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t byte3;
#define SRS_SUBQ 0x40
- u_char subchan_format;
- u_char unused[2];
- u_char track;
- u_char data_len[2];
- u_char control;
+ u_int8_t subchan_format;
+ u_int8_t unused[2];
+ u_int8_t track;
+ u_int8_t data_len[2];
+ u_int8_t control;
};
struct scsi_read_toc {
- u_char opcode;
- u_char byte2;
- u_char unused[4];
- u_char from_track;
- u_char data_len[2];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[4];
+ u_int8_t from_track;
+ u_int8_t data_len[2];
+ u_int8_t control;
};
;
struct scsi_read_cd_capacity {
- u_char opcode;
- u_char byte2;
- u_char addr_3; /* Most Significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least Significant */
- u_char unused[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t addr[4];
+ u_int8_t unused[3];
+ u_int8_t control;
};
/*
@@ -162,33 +156,27 @@ struct scsi_read_cd_capacity {
struct scsi_read_cd_cap_data {
- u_char addr_3; /* Most significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least significant */
- u_char length_3; /* Most significant */
- u_char length_2;
- u_char length_1;
- u_char length_0; /* Least significant */
+ u_int8_t addr[4];
+ u_int8_t length[4];
};
union cd_pages {
struct audio_page {
- u_char page_code;
+ u_int8_t page_code;
#define CD_PAGE_CODE 0x3F
#define AUDIO_PAGE 0x0e
#define CD_PAGE_PS 0x80
- u_char param_len;
- u_char flags;
+ u_int8_t param_len;
+ u_int8_t flags;
#define CD_PA_SOTC 0x02
#define CD_PA_IMMED 0x04
- u_char unused[2];
- u_char format_lba;
+ u_int8_t unused[2];
+ u_int8_t format_lba;
#define CD_PA_FORMAT_LBA 0x0F
#define CD_PA_APR_VALID 0x80
- u_char lb_per_sec[2];
+ u_int8_t lb_per_sec[2];
struct port_control {
- u_char channels;
+ u_int8_t channels;
#define CHANNEL 0x0F
#define CHANNEL_0 1
#define CHANNEL_1 2
@@ -196,7 +184,7 @@ union cd_pages {
#define CHANNEL_3 8
#define LEFT_CHANNEL CHANNEL_0
#define RIGHT_CHANNEL CHANNEL_1
- u_char volume;
+ u_int8_t volume;
} port[4];
#define LEFT_PORT 0
#define RIGHT_PORT 1
diff --git a/sys/scsi/scsi_changer.h b/sys/scsi/scsi_changer.h
index 5161ce8e166..ef7c6146313 100644
--- a/sys/scsi/scsi_changer.h
+++ b/sys/scsi/scsi_changer.h
@@ -1,11 +1,48 @@
-/* $NetBSD: scsi_changer.h,v 1.5 1994/12/28 19:42:59 mycroft Exp $ */
+/* $NetBSD: scsi_changer.h,v 1.7 1996/04/03 00:25:48 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
+ * All rights reserved.
+ *
+ * Partially based on an autochanger driver written by Stefan Grefen
+ * and on an autochanger driver written by the Systems Programming Group
+ * at the University of Utah Computer Science Department.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgements:
+ * This product includes software developed by Jason R. Thorpe
+ * for And Communications, http://www.and.com/
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
/*
* SCSI changer interface description
*/
/*
- * Written by Stefan Grefen (grefen@goofy.zdv.uni-mainz.de soon grefen@convex.com)
+ * Partially derived from software written by Stefan Grefen
+ * (grefen@goofy.zdv.uni-mainz.de soon grefen@convex.com)
* based on the SCSI System by written Julian Elischer (julian@tfs.com)
* for TRW Financial Systems.
*
@@ -21,74 +58,343 @@
*
* Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
*/
+
#ifndef _SCSI_SCSI_CHANGER_H
#define _SCSI_SCSI_CHANGER_H 1
/*
* SCSI command format
*/
-struct scsi_read_element_status {
- u_char opcode;
- u_char byte2;
-#define SRES_ELEM_TYPE_CODE 0x0F
-#define SRES_ELEM_VOLTAG 0x10
- u_char starting_element_addr[2];
- u_char number_of_elements[2];
- u_char resv1;
- u_char allocation_length[3];
- u_char resv2;
- u_char control;
+
+/*
+ * Exchange the medium in the source element with the medium
+ * located at the destination element.
+ */
+struct scsi_exchange_medium {
+ u_int8_t opcode;
+#define EXCHANGE_MEDIUM 0xa6
+ u_int8_t byte2;
+ u_int8_t tea[2]; /* transport element address */
+ u_int8_t src[2]; /* source address */
+ u_int8_t fdst[2]; /* first destination address */
+ u_int8_t sdst[2]; /* second destination address */
+ u_int8_t flags;
+#define EXCHANGE_MEDIUM_INV1 0x01
+#define EXCHANGE_MEDIUM_INV2 0x02
+ u_int8_t control;
};
-#define RE_ALL_ELEMENTS 0
-#define RE_MEDIUM_TRANSPORT_ELEMENT 1
-#define RE_STORAGE_ELEMENT 2
-#define RE_IMPORT_EXPORT 3
-#define RE_DATA_TRANSFER_ELEMENT 4
+/*
+ * Cause the medium changer to check all elements for medium and any
+ * other status relevant to the element.
+ */
+struct scsi_initialize_elememt_status {
+ u_int8_t opcode;
+#define INITIALIZE_ELEMENT_STATUS 0x07
+ u_int8_t byte2;
+ u_int8_t reserved[3];
+ u_int8_t control;
+};
+
+/*
+ * Request the changer to move a unit of media from the source element
+ * to the destination element.
+ */
struct scsi_move_medium {
- u_char opcode;
- u_char byte2;
- u_char transport_element_address[2];
- u_char source_address[2];
- u_char destination_address[2];
- u_char rsvd[2];
- u_char invert;
- u_char control;
+ u_int8_t opcode;
+#define MOVE_MEDIUM 0xa5
+ u_int8_t byte2;
+ u_int8_t tea[2]; /* transport element address */
+ u_int8_t src[2]; /* source element address */
+ u_int8_t dst[2]; /* destination element address */
+ u_int8_t reserved[2];
+ u_int8_t flags;
+#define MOVE_MEDIUM_INVERT 0x01
+ u_int8_t control;
};
+/*
+ * Position the specified transport element (picker) in front of
+ * the destination element specified.
+ */
struct scsi_position_to_element {
- u_char opcode;
- u_char byte2;
- u_char transport_element_address[2];
- u_char source_address[2];
- u_char rsvd[2];
- u_char invert;
- u_char control;
+ u_int8_t opcode;
+#define POSITION_TO_ELEMENT 0x2b
+ u_int8_t byte2;
+ u_int8_t tea[2]; /* transport element address */
+ u_int8_t dst[2]; /* destination element address */
+ u_int8_t reserved[2];
+ u_int8_t flags;
+#define POSITION_TO_ELEMENT_INVERT 0x01
+ u_int8_t control;
+};
+
+/*
+ * Request that the changer report the status of its internal elements.
+ */
+struct scsi_read_element_status {
+ u_int8_t opcode;
+#define READ_ELEMENT_STATUS 0xb8
+ u_int8_t byte2;
+#define READ_ELEMENT_STATUS_VOLTAG 0x10 /* report volume tag info */
+ /* ...next 4 bits are an element type code... */
+ u_int8_t sea[2]; /* starting element address */
+ u_int8_t count[2]; /* number of elements */
+ u_int8_t reserved0;
+ u_int8_t len[3]; /* length of data buffer */
+ u_int8_t reserved1;
+ u_int8_t control;
};
-
+
+struct scsi_request_volume_element_address {
+ u_int8_t opcode;
+#define REQUEST_VOLUME_ELEMENT_ADDRESS 0xb5
+ u_int8_t byte2;
+#define REQUEST_VOLUME_ELEMENT_ADDRESS_VOLTAG 0x10
+ /* ...next 4 bits are an element type code... */
+ u_int8_t eaddr[2]; /* element address */
+ u_int8_t count[2]; /* number of elements */
+ u_int8_t reserved0;
+ u_int8_t len[3]; /* length of data buffer */
+ u_int8_t reserved1;
+ u_int8_t control;
+};
+
+/* XXX scsi_release */
+
/*
- * Opcodes
+ * Data returned by READ ELEMENT STATUS consists of an 8-byte header
+ * followed by one or more read_element_status_pages.
*/
-#define POSITION_TO_ELEMENT 0x2b
-#define MOVE_MEDIUM 0xa5
-#define READ_ELEMENT_STATUS 0xb8
-
-struct scsi_element_status_data {
- u_char first_element_reported[2];
- u_char number_of_elements_reported[2];
- u_char rsvd;
- u_char byte_count_of_report[3];
+struct read_element_status_header {
+ u_int8_t fear[2]; /* first element address reported */
+ u_int8_t count[2]; /* number of elements available */
+ u_int8_t reserved;
+ u_int8_t nbytes[3]; /* byte count of all pages */
};
-struct element_status_page {
- u_char element_type_code;
- u_char flags;
-#define ESP_AVOLTAG 0x40
-#define ESP_PVOLTAG 0x80
- u_char element_descriptor_length[2];
- u_char rsvd;
- u_char byte_count_of_descriptor_data[3];
+struct read_element_status_page_header {
+ u_int8_t type; /* element type code; see type codes below */
+ u_int8_t flags;
+#define READ_ELEMENT_STATUS_AVOLTAG 0x40
+#define READ_ELEMENT_STATUS_PVOLTAG 0x80
+ u_int8_t edl[2]; /* element descriptor length */
+ u_int8_t reserved;
+ u_int8_t nbytes[3]; /* byte count of all descriptors */
};
-#endif /* _SCSI_SCSI_CHANGER_H */
+struct read_element_status_descriptor {
+ u_int8_t eaddr[2]; /* element address */
+ u_int8_t flags1;
+
+#define READ_ELEMENT_STATUS_FULL 0x01
+#define READ_ELEMENT_STATUS_IMPEXP 0x02
+#define READ_ELEMENT_STATUS_EXCEPT 0x04
+#define READ_ELEMENT_STATUS_ACCESS 0x08
+#define READ_ELEMENT_STATUS_EXENAB 0x10
+#define READ_ELEMENT_STATUS_INENAB 0x20
+
+#define READ_ELEMENT_STATUS_MT_MASK1 0x05
+#define READ_ELEMENT_STATUS_ST_MASK1 0x0c
+#define READ_ELEMENT_STATUS_IE_MASK1 0x3f
+#define READ_ELEMENT_STATUS_DT_MASK1 0x0c
+
+ u_int8_t reserved0;
+ u_int8_t sense_code;
+ u_int8_t sense_qual;
+ /*
+ * dt_scsi_flags and dt_scsi_addr are valid only on data transport
+ * elements. These bytes are undefined for all other element types.
+ */
+ u_int8_t dt_scsi_flags;
+
+#define READ_ELEMENT_STATUS_DT_LUNMASK 0x07
+#define READ_ELEMENT_STATUS_DT_LUVALID 0x10
+#define READ_ELEMENT_STATUS_DT_IDVALID 0x20
+#define READ_ELEMENT_STATUS_DT_NOTBUS 0x80
+
+ u_int8_t dt_scsi_addr;
+
+ u_int8_t reserved1;
+
+ u_int8_t flags2;
+#define READ_ELEMENT_STATUS_INVERT 0x40
+#define READ_ELEMENT_STATUS_SVALID 0x80
+ u_int8_t ssea[2]; /* source storage element address */
+
+ /*
+ * bytes 12-47: Primary volume tag information.
+ * (field omitted if PVOLTAG = 0)
+ *
+ * bytes 48-83: Alternate volume tag information.
+ * (field omitted if AVOLTAG = 0)
+ *
+ * bytes 84-87: Reserved (moved up if either of the above fields
+ * are omitted)
+ *
+ * bytes 88-end: Vendor-specific: (moved up if either of the
+ * above fields are missing)
+ */
+};
+
+/* XXX add data returned by REQUEST VOLUME ELEMENT ADDRESS */
+
+/* Element type codes */
+#define ELEMENT_TYPE_MASK 0x0f /* Note: these aren't bits */
+#define ELEMENT_TYPE_ALL 0x00
+#define ELEMENT_TYPE_MT 0x01
+#define ELEMENT_TYPE_ST 0x02
+#define ELEMENT_TYPE_IE 0x03
+#define ELEMENT_TYPE_DT 0x04
+
+/*
+ * XXX The following definitions should be common to all SCSI device types.
+ */
+#define PGCODE_MASK 0x3f /* valid page number bits in pg_code */
+#define PGCODE_PS 0x80 /* indicates page is savable */
+
+/*
+ * Device capabilities page.
+ *
+ * This page defines characteristics of the elemenet types in the
+ * medium changer device.
+ *
+ * Note in the definitions below, the following abbreviations are
+ * used:
+ * MT Medium transport element (picker)
+ * ST Storage transport element (slot)
+ * IE Import/export element (portal)
+ * DT Data tranfer element (tape/disk drive)
+ */
+struct page_device_capabilities {
+ u_int8_t pg_code; /* page code (0x1f) */
+ u_int8_t pg_length; /* page length (0x12) */
+
+ /*
+ * The STOR_xx bits indicate that an element of a given
+ * type may provide independent storage for a unit of
+ * media. The top four bits of this value are reserved.
+ */
+ u_int8_t stor;
+#define STOR_MT 0x01
+#define STOR_ST 0x02
+#define STOR_IE 0x04
+#define STOR_DT 0x08
+
+ u_int8_t reserved0;
+
+ /*
+ * The MOVE_TO_yy bits indicate the changer supports
+ * moving a unit of medium from an element of a given type to an
+ * element of type yy. This is used to determine if a given
+ * MOVE MEDIUM command is legal. The top four bits of each
+ * of these values are reserved.
+ */
+ u_int8_t move_from_mt;
+ u_int8_t move_from_st;
+ u_int8_t move_from_ie;
+ u_int8_t move_from_dt;
+#define MOVE_TO_MT 0x01
+#define MOVE_TO_ST 0x02
+#define MOVE_TO_IE 0x04
+#define MOVE_TO_DT 0x08
+
+ u_int8_t reserved1[2];
+
+ /*
+ * Similar to above, but for EXCHANGE MEDIUM.
+ */
+ u_int8_t exchange_with_mt;
+ u_int8_t exchange_with_st;
+ u_int8_t exchange_with_ie;
+ u_int8_t exchange_with_dt;
+#define EXCHANGE_WITH_MT 0x01
+#define EXCHANGE_WITH_ST 0x02
+#define EXCHANGE_WITH_IE 0x04
+#define EXCHANGE_WITH_DT 0x08
+};
+
+/*
+ * Medium changer elemement address assignment page.
+ *
+ * Some of these fields can be a little confusing, so an explanation
+ * is in order.
+ *
+ * Each component within a a medium changer apparatus is called an
+ * "element".
+ *
+ * The "medium transport element address" is the address of the first
+ * picker (robotic arm). "Number of medium transport elements" tells
+ * us how many pickers exist in the changer.
+ *
+ * The "first storage element address" is the address of the first
+ * slot in the tape or disk magazine. "Number of storage elements" tells
+ * us how many slots exist in the changer.
+ *
+ * The "first import/export element address" is the address of the first
+ * medium portal accessible both by the medium changer and an outside
+ * human operator. This is where the changer might deposit tapes destined
+ * for some vault. The "number of import/export elements" tells us
+ * not many of these portals exist in the changer. NOTE: this number may
+ * be 0.
+ *
+ * The "first data transfer element address" is the address of the first
+ * tape or disk drive in the changer. "Number of data transfer elements"
+ * tells us how many drives exist in the changer.
+ */
+struct page_element_address_assignment {
+ u_int8_t pg_code; /* page code (0x1d) */
+ u_int8_t pg_length; /* page length (0x12) */
+
+ /* Medium transport element address */
+ u_int8_t mtea[2];
+
+ /* Number of medium transport elements */
+ u_int8_t nmte[2];
+
+ /* First storage element address */
+ u_int8_t fsea[2];
+
+ /* Number of storage elements */
+ u_int8_t nse[2];
+
+ /* First import/export element address */
+ u_int8_t fieea[2];
+
+ /* Number of import/export elements */
+ u_int8_t niee[2];
+
+ /* First data transfer element address */
+ u_int8_t fdtea[2];
+
+ /* Number of data trafer elements */
+ u_int8_t ndte[2];
+
+ u_int8_t reserved[2];
+};
+
+/*
+ * Transport geometry parameters page.
+ *
+ * Defines whether each medium transport element is a member of a set of
+ * elements that share a common robotics subsystem and whether the element
+ * is capable of media rotation. One transport geometry descriptor is
+ * transferred for each medium transport element, beginning with the first
+ * medium transport element (other than the default transport element address
+ * of 0).
+ */
+struct page_transport_geometry_parameters {
+ u_int8_t pg_code; /* page code (0x1e) */
+ u_int8_t pg_length; /* page length; variable */
+
+ /* Transport geometry descriptor(s) are here. */
+
+ u_int8_t misc;
+#define CAN_ROTATE 0x01
+
+ /* Member number in transport element set. */
+ u_int8_t member;
+};
+
+#endif /* _SCSI_SCSI_CHANGER_H */
diff --git a/sys/scsi/scsi_conf.h b/sys/scsi/scsi_conf.h
deleted file mode 100644
index 65a67f410d1..00000000000
--- a/sys/scsi/scsi_conf.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* $NetBSD: scsi_conf.h,v 1.2 1996/02/18 20:32:41 mycroft Exp $ */
-
-/*
- * Copyright (c) 1995 Christos Zoulas. 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- */
-
-#include <sys/conf.h>
-
-#include "ch.h"
-cdev_decl(ch);
-
-#include "ss.h"
-cdev_decl(ss);
-
-#include "sd.h"
-bdev_decl(sd);
-cdev_decl(sd);
-
-#include "st.h"
-bdev_decl(st);
-cdev_decl(st);
-
-#include "cd.h"
-bdev_decl(cd);
-cdev_decl(cd);
diff --git a/sys/scsi/scsi_disk.h b/sys/scsi/scsi_disk.h
index 3b3e3350c88..e19e0f176a0 100644
--- a/sys/scsi/scsi_disk.h
+++ b/sys/scsi/scsi_disk.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_disk.h,v 1.8 1995/10/15 23:32:02 thorpej Exp $ */
+/* $NetBSD: scsi_disk.h,v 1.9 1996/03/19 03:07:02 mycroft Exp $ */
/*
* SCSI interface description
@@ -57,56 +57,47 @@
#define _SCSI_SCSI_DISK_H 1
struct scsi_reassign_blocks {
- u_char opcode;
- u_char byte2;
- u_char unused[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[3];
+ u_int8_t control;
};
struct scsi_rw {
- u_char opcode;
- u_char addr_2; /* Most significant */
+ u_int8_t opcode;
+ u_int8_t addr[3];
#define SRW_TOPADDR 0x1F /* only 5 bits here */
- u_char addr_1;
- u_char addr_0; /* least significant */
- u_char length;
- u_char control;
+ u_int8_t length;
+ u_int8_t control;
};
struct scsi_rw_big {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SRWB_RELADDR 0x01
- u_char addr_3; /* Most significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* least significant */
- u_char reserved;
- u_char length2;
- u_char length1;
- u_char control;
+ u_int8_t addr[4];
+ u_int8_t reserved;
+ u_int8_t length[2];
+ u_int8_t control;
};
struct scsi_read_capacity {
- u_char opcode;
- u_char byte2;
- u_char addr_3; /* Most Significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least Significant */
- u_char unused[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t addr[4];
+ u_int8_t unused[3];
+ u_int8_t control;
};
struct scsi_start_stop {
- u_char opcode;
- u_char byte2;
- u_char unused[2];
- u_char how;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[2];
+ u_int8_t how;
#define SSS_STOP 0x00
#define SSS_START 0x01
#define SSS_LOEJ 0x02
- u_char control;
+ u_int8_t control;
};
@@ -128,89 +119,60 @@ struct scsi_start_stop {
struct scsi_read_cap_data {
- u_char addr_3; /* Most significant */
- u_char addr_2;
- u_char addr_1;
- u_char addr_0; /* Least significant */
- u_char length_3; /* Most significant */
- u_char length_2;
- u_char length_1;
- u_char length_0; /* Least significant */
+ u_int8_t addr[4];
+ u_int8_t length[4];
};
struct scsi_reassign_blocks_data {
- u_char reserved[2];
- u_char length_msb;
- u_char length_lsb;
+ u_int8_t reserved[2];
+ u_int8_t length[2];
struct {
- u_char dlbaddr_3; /* defect logical block address (MSB) */
- u_char dlbaddr_2;
- u_char dlbaddr_1;
- u_char dlbaddr_0; /* defect logical block address (LSB) */
+ u_int8_t dlbaddr[4];
} defect_descriptor[1];
};
-union disk_pages { /* this is the structure copied from osf */
- struct page_disk_format {
- u_char pg_code; /* page code (should be 3) */
+union disk_pages {
#define DISK_PGCODE 0x3F /* only 6 bits valid */
- u_char pg_length; /* page length (should be 0x16) */
- u_char trk_z_1; /* tracks per zone (MSB) */
- u_char trk_z_0; /* tracks per zone (LSB) */
- u_char alt_sec_1; /* alternate sectors per zone (MSB) */
- u_char alt_sec_0; /* alternate sectors per zone (LSB) */
- u_char alt_trk_z_1; /* alternate tracks per zone (MSB) */
- u_char alt_trk_z_0; /* alternate tracks per zone (LSB) */
- u_char alt_trk_v_1; /* alternate tracks per volume (MSB) */
- u_char alt_trk_v_0; /* alternate tracks per volume (LSB) */
- u_char ph_sec_t_1; /* physical sectors per track (MSB) */
- u_char ph_sec_t_0; /* physical sectors per track (LSB) */
- u_char bytes_s_1; /* bytes per sector (MSB) */
- u_char bytes_s_0; /* bytes per sector (LSB) */
- u_char interleave_1;/* interleave (MSB) */
- u_char interleave_0;/* interleave (LSB) */
- u_char trk_skew_1; /* track skew factor (MSB) */
- u_char trk_skew_0; /* track skew factor (LSB) */
- u_char cyl_skew_1; /* cylinder skew (MSB) */
- u_char cyl_skew_0; /* cylinder skew (LSB) */
- u_char flags; /* various */
-#define DISK_FMT_SURF 0x10
-#define DISK_FMT_RMB 0x20
-#define DISK_FMT_HSEC 0x40
-#define DISK_FMT_SSEC 0x80
- u_char reserved2;
- u_char reserved3;
+ struct page_disk_format {
+ u_int8_t pg_code; /* page code (should be 3) */
+ u_int8_t pg_length; /* page length (should be 0x16) */
+ u_int8_t trk_z[2]; /* tracks per zone */
+ u_int8_t alt_sec[2]; /* alternate sectors per zone */
+ u_int8_t alt_trk_z[2]; /* alternate tracks per zone */
+ u_int8_t alt_trk_v[2]; /* alternate tracks per volume */
+ u_int8_t ph_sec_t[2]; /* physical sectors per track */
+ u_int8_t bytes_s[2]; /* bytes per sector */
+ u_int8_t interleave[2]; /* interleave */
+ u_int8_t trk_skew[2]; /* track skew factor */
+ u_int8_t cyl_skew[2]; /* cylinder skew */
+ u_int8_t flags; /* various */
+#define DISK_FMT_SURF 0x10
+#define DISK_FMT_RMB 0x20
+#define DISK_FMT_HSEC 0x40
+#define DISK_FMT_SSEC 0x80
+ u_int8_t reserved2;
+ u_int8_t reserved3;
} disk_format;
struct page_rigid_geometry {
- u_char pg_code; /* page code (should be 4) */
- u_char pg_length; /* page length (should be 0x16) */
- u_char ncyl_2; /* number of cylinders (MSB) */
- u_char ncyl_1; /* number of cylinders */
- u_char ncyl_0; /* number of cylinders (LSB) */
- u_char nheads; /* number of heads */
- u_char st_cyl_wp_2; /* starting cyl., write precomp (MSB) */
- u_char st_cyl_wp_1; /* starting cyl., write precomp */
- u_char st_cyl_wp_0; /* starting cyl., write precomp (LSB) */
- u_char st_cyl_rwc_2;/* starting cyl., red. write cur (MSB)*/
- u_char st_cyl_rwc_1;/* starting cyl., red. write cur */
- u_char st_cyl_rwc_0;/* starting cyl., red. write cur (LSB)*/
- u_char driv_step_1; /* drive step rate (MSB) */
- u_char driv_step_0; /* drive step rate (LSB) */
- u_char land_zone_2; /* landing zone cylinder (MSB) */
- u_char land_zone_1; /* landing zone cylinder */
- u_char land_zone_0; /* landing zone cylinder (LSB) */
- u_char sp_sync_ctl; /* spindle synch control */
+ u_int8_t pg_code; /* page code (should be 4) */
+ u_int8_t pg_length; /* page length (should be 0x16) */
+ u_int8_t ncyl[3]; /* number of cylinders */
+ u_int8_t nheads; /* number of heads */
+ u_int8_t st_cyl_wp[3]; /* starting cyl., write precomp */
+ u_int8_t st_cyl_rwc[3]; /* starting cyl., red. write cur */
+ u_int8_t driv_step[2]; /* drive step rate */
+ u_int8_t land_zone[3]; /* landing zone cylinder */
+ u_int8_t sp_sync_ctl; /* spindle synch control */
#define SPINDLE_SYNCH_MASK 0x03 /* mask of valid bits */
#define SPINDLE_SYNCH_NONE 0x00 /* synch disabled or not supported */
#define SPINDLE_SYNCH_SLAVE 0x01 /* disk is a slave */
#define SPINDLE_SYNCH_MASTER 0x02 /* disk is a master */
#define SPINDLE_SYNCH_MCONTROL 0x03 /* disk is a master control */
- u_char rot_offset; /* rotational offset (for spindle synch) */
- u_char reserved1;
- u_char rpm_1; /* media rotation speed (MSB) */
- u_char rpm_0; /* media rotation speed (LSB) */
- u_char reserved2;
- u_char reserved3;
+ u_int8_t rot_offset; /* rotational offset (for spindle synch) */
+ u_int8_t reserved1;
+ u_int8_t rpm[2]; /* media rotation speed */
+ u_int8_t reserved2;
+ u_int8_t reserved3;
} rigid_geometry;
};
diff --git a/sys/scsi/scsi_scanner.h b/sys/scsi/scsi_scanner.h
index 087d4ecc346..c5e785c188b 100644
--- a/sys/scsi/scsi_scanner.h
+++ b/sys/scsi/scsi_scanner.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_scanner.h,v 1.2 1996/04/19 16:10:13 niklas Exp $ */
+/* $OpenBSD: scsi_scanner.h,v 1.3 1996/04/21 22:31:00 deraadt Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@@ -49,62 +49,62 @@
struct scsi_rw_scanner {
#define READ 0x08
#define WRITE 0x0a
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SRW_FIXED 0x01
- u_char len[3];
- u_char control;
+ u_int8_t len[3];
+ u_int8_t control;
};
struct scsi_start_stop {
- u_char opcode;
- u_char byte2;
- u_char unused[2];
- u_char how;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[2];
+ u_int8_t how;
#define SSS_STOP 0x00
#define SSS_START 0x01
#define SSS_LOEJ 0x02
- u_char control;
+ u_int8_t control;
};
struct scsi_set_window {
#define SET_WINDOW 0x24 /* set params of image area and windows */
#define GET_WINDOW 0x25
- u_char opcode;
- u_char byte2;
- u_char reserved[4];
- u_char len[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t reserved[4];
+ u_int8_t len[3];
+ u_int8_t control;
};
struct scsi_window_header {
- u_char reserved[6];
- u_char len[2]; /* MSB-LSB */
+ u_int8_t reserved[6];
+ u_int8_t len[2];
};
struct scsi_window_data {
- u_char window_id; /* must be zero */
- u_char res1:7;
- u_char auto_bit:1;
- u_char x_res[2];
- u_char y_res[2];
- u_char x_org[4];
- u_char y_org[4];
- u_char width[4];
- u_char length[4];
- u_char brightness;
- u_char threshold;
- u_char contrast;
- u_char image_comp; /* image composition (data type) */
- u_char bits_per_pixel;
- u_char halftone_pattern[2];
- u_char rif:1; /* reverse image format (mono negative) */
- u_char res2:4;
- u_char pad_type:3;
- u_char bit_ordering[2];
- u_char compression_type;
- u_char compression_arg;
- u_char res3[6];
+ u_int8_t window_id; /* must be zero */
+ u_int8_t res1:7;
+ u_int8_t auto_bit:1;
+ u_int8_t x_res[2];
+ u_int8_t y_res[2];
+ u_int8_t x_org[4];
+ u_int8_t y_org[4];
+ u_int8_t width[4];
+ u_int8_t length[4];
+ u_int8_t brightness;
+ u_int8_t threshold;
+ u_int8_t contrast;
+ u_int8_t image_comp; /* image composition (data type) */
+ u_int8_t bits_per_pixel;
+ u_int8_t halftone_pattern[2];
+ u_int8_t rif:1; /* reverse image format (mono negative) */
+ u_int8_t res2:4;
+ u_int8_t pad_type:3;
+ u_int8_t bit_ordering[2];
+ u_int8_t compression_type;
+ u_int8_t compression_arg;
+ u_int8_t res3[6];
};
/* mustek scsi commands */
diff --git a/sys/scsi/scsi_tape.h b/sys/scsi/scsi_tape.h
index 25b8f2624d8..9e38bf2dc6c 100644
--- a/sys/scsi/scsi_tape.h
+++ b/sys/scsi/scsi_tape.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_tape.h,v 1.6 1994/12/28 19:43:08 mycroft Exp $ */
+/* $NetBSD: scsi_tape.h,v 1.8 1996/03/19 03:07:36 mycroft Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -60,97 +60,93 @@
#define READ 0x08
#define WRITE 0x0a
struct scsi_rw_tape {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SRW_FIXED 0x01
- u_char len[3];
- u_char control;
+ u_int8_t len[3];
+ u_int8_t control;
};
#define SPACE 0x11
struct scsi_space {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SS_CODE 0x03
#define SP_BLKS 0x00
#define SP_FILEMARKS 0x01
#define SP_SEQ_FILEMARKS 0x02
#define SP_EOM 0x03
- u_char number[3];
- u_char control;
+ u_int8_t number[3];
+ u_int8_t control;
};
#define WRITE_FILEMARKS 0x10
struct scsi_write_filemarks {
- u_char opcode;
- u_char byte2;
- u_char number[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t number[3];
+ u_int8_t control;
};
#define REWIND 0x01
struct scsi_rewind {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SR_IMMED 0x01
- u_char unused[3];
- u_char control;
+ u_int8_t unused[3];
+ u_int8_t control;
};
-#define ERASE 0x19
-struct scsi_erase {
- u_char opcode;
- u_char byte2;
-#define SE_LONG 0x01 /* some units do not allow short erase */
-#define SE_IMMED 0x02
- u_char unused[3];
- u_char control;
-} erase;
-
#define LOAD 0x1b
struct scsi_load {
- u_char opcode;
- u_char byte2;
+ u_int8_t opcode;
+ u_int8_t byte2;
#define SL_IMMED 0x01
- u_char unused[2];
- u_char how;
+ u_int8_t unused[2];
+ u_int8_t how;
#define LD_UNLOAD 0x00
#define LD_LOAD 0x01
#define LD_RETENSION 0x02
- u_char control;
+ u_int8_t control;
+};
+
+#define ERASE 0x19
+struct scsi_erase {
+ u_int8_t opcode;
+ u_int8_t byte2;
+#define SE_LONG 0x01
+#define SE_IMMED 0x02
+ u_int8_t unused[3];
+ u_int8_t control;
};
#define READ_BLOCK_LIMITS 0x05
struct scsi_block_limits {
- u_char opcode;
- u_char byte2;
- u_char unused[3];
- u_char control;
+ u_int8_t opcode;
+ u_int8_t byte2;
+ u_int8_t unused[3];
+ u_int8_t control;
};
struct scsi_block_limits_data {
- u_char reserved;
- u_char max_length_2; /* Most significant */
- u_char max_length_1;
- u_char max_length_0; /* Least significant */
- u_char min_length_1; /* Most significant */
- u_char min_length_0; /* Least significant */
+ u_int8_t reserved;
+ u_int8_t max_length[3]; /* Most significant */
+ u_int8_t min_length[2]; /* Most significant */
};
/* See SCSI-II spec 9.3.3.1 */
struct scsi_tape_dev_conf_page {
- u_char pagecode; /* 0x10 */
- u_char pagelength; /* 0x0e */
- u_char byte2;
+ u_int8_t pagecode; /* 0x10 */
+ u_int8_t pagelength; /* 0x0e */
+ u_int8_t byte2;
#define SMT_CAP 0x40 /* change active partition */
#define SMT_CAF 0x20 /* change active format */
#define SMT_AFMASK 0x1f /* active format mask */
- u_char active_partition;
- u_char wb_full_ratio;
- u_char rb_empty_ratio;
- u_char wrdelay_time_1; /* MSB */
- u_char wrdelay_time_0; /* LSB */
- u_char byte8;
+ u_int8_t active_partition;
+ u_int8_t wb_full_ratio;
+ u_int8_t rb_empty_ratio;
+ u_int8_t wrdelay_time[2];
+ u_int8_t byte8;
#define SMT_DBR 0x80 /* data buffer recovery */
#define SMT_BIS 0x40 /* block identifiers supported */
#define SMT_RSMK 0x20 /* report setmarks */
@@ -158,18 +154,16 @@ struct scsi_tape_dev_conf_page {
#define SMT_SOCF_MASK 0xc0 /* stop on consecutive formats */
#define SMT_RBO 0x20 /* recover buffer order */
#define SMT_REW 0x10 /* report early warning */
- u_char gap_size;
- u_char byte10;
+ u_int8_t gap_size;
+ u_int8_t byte10;
#define SMT_EODDEFINED 0xe0 /* EOD defined */
#define SMT_EEG 0x10 /* enable EOD generation */
#define SMT_SEW 0x80 /* synchronize at early warning */
- u_char ew_bufsize_2; /* MSB */
- u_char ew_bufsize_1; /* ... */
- u_char ew_bufsize_0; /* LSB */
- u_char sel_comp_alg;
+ u_int8_t ew_bufsize[3];
+ u_int8_t sel_comp_alg;
#define SMT_COMP_NONE 0x00
#define SMT_COMP_DEFAULT 0x01
- u_char reserved;
+ u_int8_t reserved;
};
/* defines for the device specific byte in the mode select/sense header */
@@ -182,11 +176,11 @@ struct scsi_tape_dev_conf_page {
/* A special for the CIPHER ST150S(old drive) */
struct block_desc_cipher {
- u_char density;
- u_char nblocks[3];
- u_char reserved;
- u_char blklen[3];
- u_char other;
+ u_int8_t density;
+ u_int8_t nblocks[3];
+ u_int8_t reserved;
+ u_int8_t blklen[3];
+ u_int8_t other;
#define ST150_SEC 0x01 /* soft error count */
#define SR150_AUI 0x02 /* autoload inhibit */
};
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c
index 64936097162..7f6475474ac 100644
--- a/sys/scsi/scsiconf.c
+++ b/sys/scsi/scsiconf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: scsiconf.c,v 1.7 1996/04/19 16:10:15 niklas Exp $ */
-/* $NetBSD: scsiconf.c,v 1.52 1996/03/05 01:45:42 thorpej Exp $ */
+/* $OpenBSD: scsiconf.c,v 1.8 1996/04/21 22:31:04 deraadt Exp $ */
+/* $NetBSD: scsiconf.c,v 1.55 1996/03/21 03:29:40 scottr Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -89,9 +89,12 @@ int scsibusmatch __P((struct device *, void *, void *));
void scsibusattach __P((struct device *, struct device *, void *));
int scsibussubmatch __P((struct device *, void *, void *));
-struct cfdriver scsibuscd = {
- NULL, "scsibus", scsibusmatch, scsibusattach, DV_DULL,
- sizeof(struct scsibus_softc)
+struct cfattach scsibus_ca = {
+ sizeof(struct scsibus_softc), scsibusmatch, scsibusattach
+};
+
+struct cfdriver scsibus_cd = {
+ NULL, "scsibus", DV_DULL
};
int scsibusprint __P((void *, char *));
@@ -146,7 +149,7 @@ scsibussubmatch(parent, match, aux)
return 0;
if (cf->cf_loc[1] != -1 && cf->cf_loc[1] != sc_link->lun)
return 0;
- return ((*cf->cf_driver->cd_match)(parent, match, aux));
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
}
/*
@@ -160,8 +163,8 @@ scsi_probe_busses(bus, target, lun)
{
if (bus == -1) {
- for (bus = 0; bus < scsibuscd.cd_ndevs; bus++)
- if (scsibuscd.cd_devs[bus])
+ for (bus = 0; bus < scsibus_cd.cd_ndevs; bus++)
+ if (scsibus_cd.cd_devs[bus])
scsi_probe_bus(bus, target, lun);
return 0;
} else {
@@ -181,9 +184,9 @@ scsi_probe_bus(bus, target, lun)
int maxtarget, mintarget, maxlun, minlun;
u_int8_t scsi_addr;
- if (bus < 0 || bus >= scsibuscd.cd_ndevs)
+ if (bus < 0 || bus >= scsibus_cd.cd_ndevs)
return ENXIO;
- scsi = scsibuscd.cd_devs[bus];
+ scsi = scsibus_cd.cd_devs[bus];
if (!scsi)
return ENXIO;
@@ -297,6 +300,9 @@ struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
{{T_CDROM, T_REMOV,
"TEXEL ", "CD-ROM DM-XX24 K", "1.10"}, SDEV_NOLUNS},
+ {{T_OPTICAL, T_REMOV,
+ "EPSON ", "OMD-5010 ", "3.08"}, SDEV_NOLUNS},
+
{{T_DIRECT, T_FIXED,
"DEC ", "RZ55 (C) DEC", ""}, SDEV_AUTOSAVE},
{{T_DIRECT, T_FIXED,
@@ -320,6 +326,8 @@ struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
{{T_DIRECT, T_FIXED,
"MST ", "SnapLink ", ""}, SDEV_NOLUNS},
{{T_DIRECT, T_FIXED,
+ "NEC ", "D3847 ", "0307"}, SDEV_NOLUNS},
+ {{T_DIRECT, T_FIXED,
"QUANTUM ", "LPS525S ", ""}, SDEV_NOLUNS},
{{T_DIRECT, T_FIXED,
"QUANTUM ", "P105S 910-10-94x", ""}, SDEV_NOLUNS},
@@ -338,6 +346,7 @@ struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = {
{{T_DIRECT, T_FIXED,
"TOSHIBA ", "MK538FB ", "6027"}, SDEV_NOLUNS},
+
/* XXX: QIC-36 tape behind Emulex adapter. Very broken. */
{{T_SEQUENTIAL, T_REMOV,
" ", " ", " "}, SDEV_NOLUNS},
diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h
index 9df8aee05e4..60ccc31c775 100644
--- a/sys/scsi/scsiconf.h
+++ b/sys/scsi/scsiconf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsiconf.h,v 1.28 1996/02/18 20:32:45 mycroft Exp $ */
+/* $NetBSD: scsiconf.h,v 1.29 1996/03/19 03:07:50 mycroft Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
@@ -289,8 +289,156 @@ void show_mem __P((u_char *, int));
int scsi_probe_busses __P((int, int, int));
void scsi_strvis __P((u_char *, u_char *, int));
+static __inline void _lto2b __P((u_int32_t val, u_int8_t *bytes));
+static __inline void _lto3b __P((u_int32_t val, u_int8_t *bytes));
+static __inline void _lto4b __P((u_int32_t val, u_int8_t *bytes));
+static __inline u_int32_t _2btol __P((u_int8_t *bytes));
+static __inline u_int32_t _3btol __P((u_int8_t *bytes));
+static __inline u_int32_t _4btol __P((u_int8_t *bytes));
-void lto3b __P((u_int32_t val, u_int8_t *bytes));
-u_int32_t _3btol __P((u_int8_t *bytes));
+static __inline void _lto2l __P((u_int32_t val, u_int8_t *bytes));
+static __inline void _lto3l __P((u_int32_t val, u_int8_t *bytes));
+static __inline void _lto4l __P((u_int32_t val, u_int8_t *bytes));
+static __inline u_int32_t _2ltol __P((u_int8_t *bytes));
+static __inline u_int32_t _3ltol __P((u_int8_t *bytes));
+static __inline u_int32_t _4ltol __P((u_int8_t *bytes));
+
+static __inline void
+_lto2b(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = (val >> 8) & 0xff;
+ bytes[1] = val & 0xff;
+}
+
+static __inline void
+_lto3b(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = (val >> 16) & 0xff;
+ bytes[1] = (val >> 8) & 0xff;
+ bytes[2] = val & 0xff;
+}
+
+static __inline void
+_lto4b(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = (val >> 24) & 0xff;
+ bytes[1] = (val >> 16) & 0xff;
+ bytes[2] = (val >> 8) & 0xff;
+ bytes[3] = val & 0xff;
+}
+
+static __inline u_int32_t
+_2btol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = (bytes[0] << 8) |
+ bytes[1];
+ return (rv);
+}
+
+static __inline u_int32_t
+_3btol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = (bytes[0] << 16) |
+ (bytes[1] << 8) |
+ bytes[2];
+ return (rv);
+}
+
+static __inline u_int32_t
+_4btol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = (bytes[0] << 24) |
+ (bytes[1] << 16) |
+ (bytes[2] << 8) |
+ bytes[3];
+ return (rv);
+}
+
+static __inline void
+_lto2l(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = val & 0xff;
+ bytes[1] = (val >> 8) & 0xff;
+}
+
+static __inline void
+_lto3l(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = val & 0xff;
+ bytes[1] = (val >> 8) & 0xff;
+ bytes[2] = (val >> 16) & 0xff;
+}
+
+static __inline void
+_lto4l(val, bytes)
+ u_int32_t val;
+ u_int8_t *bytes;
+{
+
+ bytes[0] = val & 0xff;
+ bytes[1] = (val >> 8) & 0xff;
+ bytes[2] = (val >> 16) & 0xff;
+ bytes[3] = (val >> 24) & 0xff;
+}
+
+static __inline u_int32_t
+_2ltol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = bytes[0] |
+ (bytes[1] << 8);
+ return (rv);
+}
+
+static __inline u_int32_t
+_3ltol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = bytes[0] |
+ (bytes[1] << 8) |
+ (bytes[2] << 16);
+ return (rv);
+}
+
+static __inline u_int32_t
+_4ltol(bytes)
+ u_int8_t *bytes;
+{
+ register u_int32_t rv;
+
+ rv = bytes[0] |
+ (bytes[1] << 8) |
+ (bytes[2] << 16) |
+ (bytes[3] << 24);
+ return (rv);
+}
#endif /* SCSI_SCSICONF_H */
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index 3e5463051ef..3e7f348f3b7 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: sd.c,v 1.6 1996/04/19 16:10:17 niklas Exp $ */
-/* $NetBSD: sd.c,v 1.88 1996/03/05 00:15:15 thorpej Exp $ */
+/* $OpenBSD: sd.c,v 1.7 1996/04/21 22:31:10 deraadt Exp $ */
+/* $NetBSD: sd.c,v 1.95 1996/03/30 21:45:14 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
@@ -63,13 +63,13 @@
#include <sys/disk.h>
#include <sys/proc.h>
#include <sys/cpu.h>
+#include <sys/conf.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_disk.h>
#include <scsi/scsiconf.h>
-#include <scsi/scsi_conf.h>
-#define SDOUTSTANDING 2
+#define SDOUTSTANDING 4
#define SDRETRIES 4
#define SDUNIT(dev) DISKUNIT(dev)
@@ -107,12 +107,15 @@ void sdminphys __P((struct buf *));
void sdgetdisklabel __P((struct sd_softc *));
void sdstart __P((void *));
int sddone __P((struct scsi_xfer *, int));
-u_long sd_size __P((struct sd_softc *, int));
int sd_reassign_blocks __P((struct sd_softc *, u_long));
int sd_get_parms __P((struct sd_softc *, int));
-struct cfdriver sdcd = {
- NULL, "sd", sdmatch, sdattach, DV_DISK, sizeof(struct sd_softc)
+struct cfattach sd_ca = {
+ sizeof(struct sd_softc), sdmatch, sdattach
+};
+
+struct cfdriver sd_cd = {
+ NULL, "sd", DV_DISK
};
struct dkdriver sddkdriver = { sdstrategy };
@@ -181,8 +184,7 @@ sdattach(parent, self, aux)
sd->sc_dk.dk_name = sd->sc_dev.dv_xname;
disk_attach(&sd->sc_dk);
- sd->sc_dk.dk_driver = &sddkdriver;
-#if !defined(i386) || defined(NEWCONFIG)
+#if !defined(i386)
dk_establish(&sd->sc_dk, &sd->sc_dev); /* XXX */
#endif
@@ -204,7 +206,7 @@ sdattach(parent, self, aux)
sd_get_parms(sd, SCSI_AUTOCONF) != 0)
printf("drive offline\n");
else
- printf("%dMB, %d cyl, %d head, %d sec, %d bytes/sec\n",
+ printf("%ldMB, %d cyl, %d head, %d sec, %d bytes/sec\n",
dp->disksize / (1048576 / dp->blksize), dp->cyls,
dp->heads, dp->sectors, dp->blksize);
}
@@ -260,9 +262,9 @@ sdopen(dev, flag, fmt, p)
int error;
unit = SDUNIT(dev);
- if (unit >= sdcd.cd_ndevs)
+ if (unit >= sd_cd.cd_ndevs)
return ENXIO;
- sd = sdcd.cd_devs[unit];
+ sd = sd_cd.cd_devs[unit];
if (!sd)
return ENXIO;
@@ -270,7 +272,7 @@ sdopen(dev, flag, fmt, p)
SC_DEBUG(sc_link, SDEV_DB1,
("sdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit,
- sdcd.cd_ndevs, part));
+ sd_cd.cd_ndevs, part));
if ((error = sdlock(sd)) != 0)
return error;
@@ -375,7 +377,7 @@ sdclose(dev, flag, fmt, p)
int flag, fmt;
struct proc *p;
{
- struct sd_softc *sd = sdcd.cd_devs[SDUNIT(dev)];
+ struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
int part = SDPART(dev);
int error;
@@ -413,7 +415,7 @@ void
sdstrategy(bp)
struct buf *bp;
{
- struct sd_softc *sd = sdcd.cd_devs[SDUNIT(bp->b_dev)];
+ struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(bp->b_dev)];
int s;
SC_DEBUG(sd->sc_link, SDEV_DB2, ("sdstrategy "));
@@ -566,9 +568,7 @@ sdstart(v)
bzero(&cmd_small, sizeof(cmd_small));
cmd_small.opcode = (bp->b_flags & B_READ) ?
READ_COMMAND : WRITE_COMMAND;
- cmd_small.addr_2 = (blkno >> 16) & 0x1f;
- cmd_small.addr_1 = (blkno >> 8) & 0xff;
- cmd_small.addr_0 = blkno & 0xff;
+ _lto3b(blkno, cmd_small.addr);
cmd_small.length = nblks & 0xff;
cmdlen = sizeof(cmd_small);
cmdp = (struct scsi_generic *)&cmd_small;
@@ -579,12 +579,8 @@ sdstart(v)
bzero(&cmd_big, sizeof(cmd_big));
cmd_big.opcode = (bp->b_flags & B_READ) ?
READ_BIG : WRITE_BIG;
- cmd_big.addr_3 = (blkno >> 24) & 0xff;
- cmd_big.addr_2 = (blkno >> 16) & 0xff;
- cmd_big.addr_1 = (blkno >> 8) & 0xff;
- cmd_big.addr_0 = blkno & 0xff;
- cmd_big.length2 = (nblks >> 8) & 0xff;
- cmd_big.length1 = nblks & 0xff;
+ _lto4b(blkno, cmd_big.addr);
+ _lto2b(nblks, cmd_big.length);
cmdlen = sizeof(cmd_big);
cmdp = (struct scsi_generic *)&cmd_big;
}
@@ -621,7 +617,7 @@ void
sdminphys(bp)
struct buf *bp;
{
- struct sd_softc *sd = sdcd.cd_devs[SDUNIT(bp->b_dev)];
+ struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(bp->b_dev)];
long max;
/*
@@ -677,7 +673,7 @@ sdioctl(dev, cmd, addr, flag, p)
int flag;
struct proc *p;
{
- struct sd_softc *sd = sdcd.cd_devs[SDUNIT(dev)];
+ struct sd_softc *sd = sd_cd.cd_devs[SDUNIT(dev)];
int error;
SC_DEBUG(sd->sc_link, SDEV_DB2, ("sdioctl 0x%lx ", cmd));
@@ -736,7 +732,7 @@ sdioctl(dev, cmd, addr, flag, p)
(*(int *)addr) ? PR_PREVENT : PR_ALLOW, 0);
case DIOCEJECT:
- return ((sd->sc_link->flags & SDEV_REMOVABLE == 0) ? ENOTTY :
+ return ((sd->sc_link->flags & SDEV_REMOVABLE) == 0 ? ENOTTY :
scsi_start(sd->sc_link, SSS_STOP|SSS_LOEJ, 0));
default:
@@ -803,46 +799,12 @@ sdgetdisklabel(sd)
}
/*
- * Find out from the device what it's capacity is
- */
-u_long
-sd_size(sd, flags)
- struct sd_softc *sd;
- int flags;
-{
- struct scsi_read_cap_data rdcap;
- struct scsi_read_capacity scsi_cmd;
- u_long size;
-
- /*
- * make up a scsi command and ask the scsi driver to do
- * it for you.
- */
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- scsi_cmd.opcode = READ_CAPACITY;
-
- /*
- * If the command works, interpret the result as a 4 byte
- * number of blocks
- */
- if (scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd,
- sizeof(scsi_cmd), (u_char *)&rdcap, sizeof(rdcap), SDRETRIES,
- 2000, NULL, flags | SCSI_DATA_IN) != 0)
- return 0;
-
- size = (rdcap.addr_3 << 24) + (rdcap.addr_2 << 16) +
- (rdcap.addr_1 << 8) + rdcap.addr_0 + 1;
-
- return size;
-}
-
-/*
* Tell the device to map out a defective block
*/
int
-sd_reassign_blocks(sd, block)
+sd_reassign_blocks(sd, blkno)
struct sd_softc *sd;
- u_long block;
+ u_long blkno;
{
struct scsi_reassign_blocks scsi_cmd;
struct scsi_reassign_blocks_data rbdata;
@@ -851,20 +813,14 @@ sd_reassign_blocks(sd, block)
bzero(&rbdata, sizeof(rbdata));
scsi_cmd.opcode = REASSIGN_BLOCKS;
- rbdata.length_msb = 0;
- rbdata.length_lsb = sizeof(rbdata.defect_descriptor[0]);
- rbdata.defect_descriptor[0].dlbaddr_3 = (block >> 24) & 0xff;
- rbdata.defect_descriptor[0].dlbaddr_2 = (block >> 16) & 0xff;
- rbdata.defect_descriptor[0].dlbaddr_1 = (block >> 8) & 0xff;
- rbdata.defect_descriptor[0].dlbaddr_0 = block & 0xff;
+ _lto2b(sizeof(rbdata.defect_descriptor[0]), rbdata.length);
+ _lto4b(blkno, rbdata.defect_descriptor[0].dlbaddr);
return scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd,
sizeof(scsi_cmd), (u_char *)&rbdata, sizeof(rbdata), SDRETRIES,
5000, NULL, SCSI_DATA_OUT);
}
-#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0 )
-
/*
* Get the scsi driver to send a full inquiry to the * device and use the
* results to fill out the disk parameter structure.
@@ -905,7 +861,7 @@ sd_get_parms(sd, flags)
* this depends on which controller (e.g. 1542C is
* different. but we have to put SOMETHING here..)
*/
- sectors = sd_size(sd, flags);
+ sectors = scsi_size(sd->sc_link, flags);
dp->heads = 64;
dp->sectors = 32;
dp->cyls = sectors / (64 * 32);
@@ -914,11 +870,11 @@ sd_get_parms(sd, flags)
} else {
SC_DEBUG(sd->sc_link, SDEV_DB3,
("%d cyls, %d heads, %d precomp, %d red_write, %d land_zone\n",
- _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2),
+ _3btol(scsi_sense.pages.rigid_geometry.ncyl),
scsi_sense.pages.rigid_geometry.nheads,
- b2tol(scsi_sense.pages.rigid_geometry.st_cyl_wp),
- b2tol(scsi_sense.pages.rigid_geometry.st_cyl_rwc),
- b2tol(scsi_sense.pages.rigid_geometry.land_zone)));
+ _2btol(scsi_sense.pages.rigid_geometry.st_cyl_wp),
+ _2btol(scsi_sense.pages.rigid_geometry.st_cyl_rwc),
+ _2btol(scsi_sense.pages.rigid_geometry.land_zone)));
/*
* KLUDGE!! (for zone recorded disks)
@@ -927,8 +883,7 @@ sd_get_parms(sd, flags)
* can lead to wasted space! THINK ABOUT THIS !
*/
dp->heads = scsi_sense.pages.rigid_geometry.nheads;
- dp->cyls =
- _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2);
+ dp->cyls = _3btol(scsi_sense.pages.rigid_geometry.ncyl);
dp->blksize = _3btol(scsi_sense.blk_desc.blklen);
if (dp->heads == 0 || dp->cyls == 0) {
@@ -940,7 +895,7 @@ sd_get_parms(sd, flags)
if (dp->blksize == 0)
dp->blksize = 512;
- sectors = sd_size(sd, flags);
+ sectors = scsi_size(sd->sc_link, flags);
dp->disksize = sectors;
sectors /= (dp->heads * dp->cyls);
dp->sectors = sectors; /* XXX dubious on SCSI */
@@ -959,7 +914,7 @@ sdsize(dev)
if (sdopen(dev, 0, S_IFBLK, NULL) != 0)
return -1;
- sd = sdcd.cd_devs[SDUNIT(dev)];
+ sd = sd_cd.cd_devs[SDUNIT(dev)];
part = SDPART(dev);
if (sd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1;
@@ -1009,11 +964,11 @@ sddump(dev, blkno, va, size)
part = SDPART(dev);
/* Check for acceptable drive number. */
- if (unit >= sdcd.cd_ndevs || (sd = sdcd.cd_devs[unit]) == NULL)
+ if (unit >= sd_cd.cd_ndevs || (sd = sd_cd.cd_devs[unit]) == NULL)
return ENXIO;
/* Make sure it was initialized. */
- if (sd->sc_link->flags & SDEV_MEDIA_LOADED != SDEV_MEDIA_LOADED)
+ if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) != SDEV_MEDIA_LOADED)
return ENXIO;
/* Convert to disk sectors. Request must be a multiple of size. */
@@ -1044,12 +999,8 @@ sddump(dev, blkno, va, size)
*/
bzero(&cmd, sizeof(cmd));
cmd.opcode = WRITE_BIG;
- cmd.addr_3 = (blkno >> 24) & 0xff;
- cmd.addr_2 = (blkno >> 16) & 0xff;
- cmd.addr_1 = (blkno >> 8) & 0xff;
- cmd.addr_0 = blkno & 0xff;
- cmd.length2 = (nwrt >> 8) & 0xff;
- cmd.length1 = nwrt & 0xff;
+ _lto4b(blkno, cmd.addr);
+ _lto2b(nwrt, cmd.length);
/*
* Fill out the scsi_xfer structure
* Note: we cannot sleep as we may be an interrupt
diff --git a/sys/scsi/ss.c b/sys/scsi/ss.c
index 706056905fa..b924bdd8890 100644
--- a/sys/scsi/ss.c
+++ b/sys/scsi/ss.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ss.c,v 1.2 1996/04/19 16:10:19 niklas Exp $ */
-/* $NetBSD: ss.c,v 1.7 1996/03/05 00:15:18 thorpej Exp $ */
+/* $OpenBSD: ss.c,v 1.3 1996/04/21 22:31:12 deraadt Exp $ */
+/* $NetBSD: ss.c,v 1.9 1996/03/30 21:47:00 christos Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@@ -42,7 +42,7 @@
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/device.h>
-#include <sys/conf.h> /* for cdevsw */
+#include <sys/conf.h>
#include <sys/scanio.h>
#include <scsi/scsi_all.h>
@@ -67,12 +67,17 @@
int ssmatch __P((struct device *, void *, void *));
void ssattach __P((struct device *, struct device *, void *));
-struct cfdriver sscd = {
- NULL, "ss", ssmatch, ssattach, DV_DULL, sizeof(struct ss_softc)
+struct cfattach ss_ca = {
+ sizeof(struct ss_softc), ssmatch, ssattach
+};
+
+struct cfdriver ss_cd = {
+ NULL, "ss", DV_DULL
};
void ssstrategy __P((struct buf *));
void ssstart __P((void *));
+void ssminphys __P((struct buf *));
struct scsi_device ss_switch = {
NULL,
@@ -150,8 +155,6 @@ ssattach(parent, self, aux)
ss->buf_queue.b_active = 0;
ss->buf_queue.b_actf = 0;
ss->buf_queue.b_actb = &ss->buf_queue.b_actf;
-
- printf("\n");
}
/*
@@ -171,9 +174,9 @@ ssopen(dev, flag, mode, p)
struct scsi_link *sc_link;
unit = SSUNIT(dev);
- if (unit >= sscd.cd_ndevs)
+ if (unit >= ss_cd.cd_ndevs)
return (ENXIO);
- ss = sscd.cd_devs[unit];
+ ss = ss_cd.cd_devs[unit];
if (!ss)
return (ENXIO);
@@ -181,7 +184,7 @@ ssopen(dev, flag, mode, p)
sc_link = ss->sc_link;
SC_DEBUG(sc_link, SDEV_DB1, ("open: dev=0x%x (unit %d (of %d))\n", dev,
- unit, sscd.cd_ndevs));
+ unit, ss_cd.cd_ndevs));
if (sc_link->flags & SDEV_OPEN) {
printf("%s: already open\n", ss->sc_dev.dv_xname);
@@ -224,10 +227,13 @@ bad:
* occurence of an open device
*/
int
-ssclose(dev)
+ssclose(dev, flag, mode, p)
dev_t dev;
+ int flag;
+ int mode;
+ struct proc *p;
{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(dev)];
+ struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(dev)];
int error;
SC_DEBUG(ss->sc_link, SDEV_DB1, ("closing\n"));
@@ -259,7 +265,7 @@ void
ssminphys(bp)
struct buf *bp;
{
- register struct ss_softc *ss = sscd.cd_devs[SSUNIT(bp->b_dev)];
+ register struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(bp->b_dev)];
(ss->sc_link->adapter->scsi_minphys)(bp);
@@ -284,7 +290,7 @@ ssread(dev, uio, flag)
struct uio *uio;
int flag;
{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(dev)];
+ struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(dev)];
int error;
/* if the scanner has not yet been started, do it now */
@@ -309,7 +315,7 @@ void
ssstrategy(bp)
struct buf *bp;
{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(bp->b_dev)];
+ struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(bp->b_dev)];
struct buf *dp;
int s;
@@ -347,7 +353,6 @@ ssstrategy(bp)
splx(s);
return;
-bad:
bp->b_flags |= B_ERROR;
done:
/*
@@ -425,9 +430,8 @@ ssioctl(dev, cmd, addr, flag, p)
int flag;
struct proc *p;
{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(dev)];
+ struct ss_softc *ss = ss_cd.cd_devs[SSUNIT(dev)];
int error = 0;
- int unit;
struct scan_io *sio;
switch (cmd) {
diff --git a/sys/scsi/ss_mustek.c b/sys/scsi/ss_mustek.c
index fa707b958fe..3fd7abfc862 100644
--- a/sys/scsi/ss_mustek.c
+++ b/sys/scsi/ss_mustek.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ss_mustek.c,v 1.2 1996/04/19 16:10:21 niklas Exp $ */
-/* $NetBSD: ss_mustek.c,v 1.1 1996/02/18 20:32:47 mycroft Exp $ */
+/* $OpenBSD: ss_mustek.c,v 1.3 1996/04/21 22:31:13 deraadt Exp $ */
+/* $NetBSD: ss_mustek.c,v 1.3 1996/03/30 21:47:04 christos Exp $ */
/*
* Copyright (c) 1995 Joachim Koenig-Baltes. All rights reserved.
@@ -102,19 +102,23 @@ mustek_attach(ss, sa)
struct ss_softc *ss;
struct scsibus_attach_args *sa;
{
+#ifdef SCSIDEBUG
struct scsi_link *sc_link = sa->sa_sc_link;
+#endif
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_attach: start\n"));
ss->sio.scan_scanner_type = 0;
+ printf("\n%s: ", ss->sc_dev.dv_xname);
+
/* first, check the model which determines resolutions */
if (!bcmp(sa->sa_inqbuf->product, "MFS-06000CX", 11)) {
ss->sio.scan_scanner_type = MUSTEK_06000CX;
- printf(": Mustek 6000CX Flatbed 3-pass color scanner, 3 - 600 dpi\n");
+ printf("Mustek 6000CX Flatbed 3-pass color scanner, 3 - 600 dpi\n");
}
if (!bcmp(sa->sa_inqbuf->product, "MFS-12000CX", 11)) {
ss->sio.scan_scanner_type = MUSTEK_12000CX;
- printf(": Mustek 12000CX Flatbed 3-pass color scanner, 6 - 1200 dpi\n");
+ printf("Mustek 12000CX Flatbed 3-pass color scanner, 6 - 1200 dpi\n");
}
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_attach: scanner_type = %d\n",
@@ -253,7 +257,9 @@ mustek_minphys(ss, bp)
struct ss_softc *ss;
struct buf *bp;
{
+#ifdef SCSIDEBUG
struct scsi_link *sc_link = ss->sc_link;
+#endif
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_minphys: before: %d\n",
bp->b_bcount));
@@ -278,9 +284,7 @@ mustek_trigger_scanner(ss)
struct mustek_set_window_data window_data;
struct mustek_start_scan_cmd start_scan_cmd;
struct scsi_link *sc_link = ss->sc_link;
-#ifndef MUSTEK_INCH_SPEC
int pixel_tlx, pixel_tly, pixel_brx, pixel_bry, paperlength;
-#endif
int error;
mustek_compute_sizes(ss);
@@ -295,46 +299,29 @@ mustek_trigger_scanner(ss)
window_cmd.length = sizeof(window_data);
bzero(&window_data, sizeof(window_data));
- window_data.frame_header = MUSTEK_LINEART_BACKGROUND | MUSTEK_UNIT_SPEC;
+ window_data.frame.header = MUSTEK_LINEART_BACKGROUND | MUSTEK_UNIT_SPEC;
#ifdef MUSTEK_INCH_SPEC
/* the positional values are all 1 byte because 256 / 8 = 32" */
- window_data.frame_tl_x_0 = ss->sio.scan_x_origin / 150;
- window_data.frame_tl_x_1 = 0;
- window_data.frame_tl_y_0 = ss->sio.scan_y_origin / 150;
- window_data.frame_tl_y_1 = 0;
- window_data.frame_br_x_0 = (ss->sio.scan_x_origin +
- ss->sio.scan_width) / 150;
- window_data.frame_br_x_1 = 0;
- window_data.frame_br_y_0 = (ss->sio.scan_y_origin +
- ss->sio.scan_height) / 150;
- window_data.frame_br_y_1 = 0;
+ pixel_tlx = ss->sio.scan_x_origin / 150;
+ pixel_tly = ss->sio.scan_y_origin / 150;
+ pixel_brx = pixel_tlx + ss->sio.scan_width / 150;
+ pixel_bry = pixel_tly + ss->sio.scan_height / 150;
#else
pixel_tlx = (ss->sio.scan_x_origin * ss->sio.scan_x_resolution) / 1200;
- window_data.frame_tl_x_0 = pixel_tlx & 0xff;
- window_data.frame_tl_x_1 = (pixel_tlx >> 8) & 0xff;
pixel_tly = (ss->sio.scan_y_origin * ss->sio.scan_y_resolution) / 1200;
- window_data.frame_tl_y_0 = pixel_tly & 0xff;
- window_data.frame_tl_y_1 = (pixel_tly >> 8) & 0xff;
pixel_brx = pixel_tlx +
(ss->sio.scan_width * ss->sio.scan_x_resolution) / 1200;
- window_data.frame_br_x_0 = pixel_brx & 0xff;
- window_data.frame_br_x_1 = (pixel_brx >> 8) & 0xff;
pixel_bry = pixel_tly +
(ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200;
- window_data.frame_br_y_0 = pixel_bry & 0xff;
- window_data.frame_br_y_1 = (pixel_bry >> 8) & 0xff;
#endif
+ _lto2l(pixel_tlx, window_data.frame.tl_x);
+ _lto2l(pixel_tly, window_data.frame.tl_y);
+ _lto2l(pixel_brx, window_data.frame.br_x);
+ _lto2l(pixel_bry, window_data.frame.br_y);
#if MUSTEK_WINDOWS >= 1
- window_data.window1_header = MUSTEK_WINDOW_MASK | MUSTEK_UNIT_SPEC;
- window_data.window1_tl_x_0 = window_data.frame_tl_x_0;
- window_data.window1_tl_x_1 = window_data.frame_tl_x_1;
- window_data.window1_tl_y_0 = window_data.frame_tl_y_0;
- window_data.window1_tl_y_1 = window_data.frame_tl_y_1;
- window_data.window1_br_x_0 = window_data.frame_br_x_0;
- window_data.window1_br_x_1 = window_data.frame_br_x_1;
- window_data.window1_br_y_0 = window_data.frame_br_y_0;
- window_data.window1_br_y_1 = window_data.frame_br_y_1;
+ window_data.window1 = window_data.frame;
+ window_data.window1.header = MUSTEK_WINDOW_MASK | MUSTEK_UNIT_SPEC;
#endif
/* send the set window command to the scanner */
@@ -350,7 +337,7 @@ mustek_trigger_scanner(ss)
*/
bzero(&mode_cmd, sizeof(mode_cmd));
mode_cmd.opcode = MUSTEK_MODE_SELECT;
- mode_cmd.length_0 = sizeof(mode_data);
+ _lto2b(sizeof(mode_data), mode_cmd.length);
bzero(&mode_data, sizeof(mode_data));
mode_data.mode =
@@ -370,13 +357,11 @@ mustek_trigger_scanner(ss)
mode_data.grain = 0;
mode_data.velocity = ss->sio.scan_quality / 20 - 1;
#ifdef MUSTEK_INCH_SPEC
- mode_data.paperlength_0 = 14 * 8; /* 14" */
- mode_data.paperlength_1 = 0;
+ paperlength = 14 * 8; /* 14" */
#else
- paperlength = 14 * ss->sio.scan_y_resolution; /* 14" */
- mode_data.paperlength_0 = paperlength & 0xff;
- mode_data.paperlength_1 = (paperlength >> 8) & 0xff;
+ paperlength = 14 * ss->sio.scan_y_resolution; /* 14" */
#endif
+ _lto2l(paperlength, mode_data.paperlength);
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: mode_select\n"));
/* send the command to the scanner */
@@ -493,9 +478,7 @@ mustek_read(ss, bp)
((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
SC_DEBUG(sc_link, SDEV_DB1, ("mustek_read: read %d lines\n",
lines_to_read));
- cmd.length_0 = lines_to_read & 0xff;
- cmd.length_1 = (lines_to_read >> 8) & 0xff;
- cmd.length_2 = (lines_to_read >> 16) & 0xff;
+ _lto3b(lines_to_read, cmd.length);
/*
* go ask the adapter to do all this for us
@@ -548,26 +531,21 @@ mustek_get_status(ss, timeout, update)
}
if (update) {
- bytes_per_line =
- (data.bytes_per_line_1 << 8) |
- data.bytes_per_line_0;
- lines =
- (data.lines_2 << 16) |
- (data.lines_1 << 8) |
- data.lines_0;
+ bytes_per_line = _2ltol(data.bytes_per_line);
+ lines = _3ltol(data.lines);
if (lines != ss->sio.scan_lines) {
- printf("mustek: lines actual(%d) != computed(%d)\n",
+ printf("mustek: lines actual(%d) != computed(%ld)\n",
lines, ss->sio.scan_lines);
return (EIO);
}
if (bytes_per_line * lines != ss->sio.scan_window_size) {
- printf("mustek: win-size actual(%d) != computed(%d)\n",
+ printf("mustek: win-size actual(%d) != computed(%ld)\n",
bytes_per_line * lines, ss->sio.scan_window_size);
return (EIO);
}
SC_DEBUG(sc_link, SDEV_DB1,
- ("mustek_get_size: bpl=%d, lines=%d\n",
+ ("mustek_get_size: bpl=%ld, lines=%ld\n",
(ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8,
ss->sio.scan_lines));
SC_DEBUG(sc_link, SDEV_DB1, ("window size = %d\n",
diff --git a/sys/scsi/ss_mustek.h b/sys/scsi/ss_mustek.h
index 5fa5653c3b5..5ea70e95d86 100644
--- a/sys/scsi/ss_mustek.h
+++ b/sys/scsi/ss_mustek.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: ss_mustek.h,v 1.2 1996/04/19 16:10:22 niklas Exp $ */
-/* $NetBSD: ss_mustek.h,v 1.1 1996/02/18 20:32:48 mycroft Exp $ */
+/* $OpenBSD: ss_mustek.h,v 1.3 1996/04/21 22:31:15 deraadt Exp $ */
+/* $NetBSD: ss_mustek.h,v 1.2 1996/03/19 03:08:37 mycroft Exp $ */
/*
* Copyright (c) 1995 Joachim Koenig-Baltes. All rights reserved.
@@ -71,104 +71,66 @@
*/
struct mustek_set_window_cmd {
- u_char opcode; /* 0x04 */
- u_char reserved[3];
- u_char length; /* in bytes */
- u_char control;
+ u_int8_t opcode; /* 0x04 */
+ u_int8_t reserved[3];
+ u_int8_t length; /* in bytes */
+ u_int8_t control;
+};
+
+struct mustek_window {
+ u_int8_t header; /* unit-defines also apply */
+ u_int8_t tl_x[2]; /* LSB */
+ u_int8_t tl_y[2];
+ u_int8_t br_x[2];
+ u_int8_t br_y[2];
};
struct mustek_set_window_data {
#define MUSTEK_LINEART_BACKGROUND 0x00
#define MUSTEK_HALFTONE_BACKGROUND 0x01
- u_char frame_header; /* unit-defines also apply */
- u_char frame_tl_x_0;
- u_char frame_tl_x_1;
- u_char frame_tl_y_0;
- u_char frame_tl_y_1;
- u_char frame_br_x_0;
- u_char frame_br_x_1;
- u_char frame_br_y_0;
- u_char frame_br_y_1;
+ struct mustek_window frame;
#if MUSTEK_WINDOWS >= 1
#define MUSTEK_WINDOW_MASK 0x80
- u_char window1_header; /* unit-defines also apply */
- u_char window1_tl_x_0;
- u_char window1_tl_x_1;
- u_char window1_tl_y_0;
- u_char window1_tl_y_1;
- u_char window1_br_x_0;
- u_char window1_br_x_1;
- u_char window1_br_y_0;
- u_char window1_br_y_1;
+ struct mustek_window window1;
#endif
#if MUSTEK_WINDOWS >= 2
- u_char window2_header;
- u_char window2_tl_x_0;
- u_char window2_tl_x_1;
- u_char window2_tl_y_0;
- u_char window2_tl_y_1;
- u_char window2_br_x_0;
- u_char window2_br_x_1;
- u_char window2_br_y_0;
- u_char window2_br_y_1;
+ struct mustek_window window2;
#endif
#if MUSTEK_WINDOWS >= 3
- u_char window3_header;
- u_char window3_tl_x_0;
- u_char window3_tl_x_1;
- u_char window3_tl_y_0;
- u_char window3_tl_y_1;
- u_char window3_br_x_0;
- u_char window3_br_x_1;
- u_char window3_br_y_0;
- u_char window3_br_y_1;
+ struct mustek_window window3;
#endif
-#if MUSTEK_WINDOWS == 4
- u_char window4_header;
- u_char window4_tl_x_0;
- u_char window4_tl_x_1;
- u_char window4_tl_y_0;
- u_char window4_tl_y_1;
- u_char window4_br_x_0;
- u_char window4_br_x_1;
- u_char window4_br_y_0;
- u_char window4_br_y_1;
+#if MUSTEK_WINDOWS >= 4
+ struct mustek_window window4;
#endif
};
struct mustek_read_cmd {
- u_char opcode; /* 0x08 */
- u_char reserved;
- u_char length_2; /* number of LINES to be read (MSB) */
- u_char length_1; /* number of LINES to be read */
- u_char length_0; /* number of LINES to be read (LSB) */
- u_char control;
+ u_int8_t opcode; /* 0x08 */
+ u_int8_t reserved;
+ u_int8_t length[3];
+ u_int8_t control;
};
struct mustek_get_status_cmd {
- u_char opcode; /* 0x0f */
- u_char reserved[3];
- u_char length; /* 0x06 */
- u_char control;
+ u_int8_t opcode; /* 0x0f */
+ u_int8_t reserved[3];
+ u_int8_t length; /* 0x06 */
+ u_int8_t control;
};
struct mustek_get_status_data {
#define MUSTEK_READY 0
#define MUSTEK_BUSY -1
- u_char ready_busy; /* 0 = ready */
- u_char bytes_per_line_0; /* LSB */
- u_char bytes_per_line_1; /* MSB */
- u_char lines_0; /* LSB */
- u_char lines_1;
- u_char lines_2; /* MSB */
+ u_int8_t ready_busy; /* 0 = ready */
+ u_int8_t bytes_per_line[2]; /* LSB */
+ u_int8_t lines[3]; /* LSB */
};
struct mustek_mode_select_cmd {
- u_char opcode; /* 0x15 */
- u_char reserved[2];
- u_char length_1; /* MSB */
- u_char length_0; /* LSB */
- u_char control;
+ u_int8_t opcode; /* 0x15 */
+ u_int8_t reserved[2];
+ u_int8_t length[2];
+ u_int8_t control;
};
/*
@@ -188,20 +150,19 @@ struct mustek_mode_select_data {
#define MUSTEK_MODE_MASK 0x83
#define MUSTEK_HT_PATTERN_BUILTIN 0x00
#define MUSTEK_HT_PATTERN_DOWNLOADED 0x10
- u_char mode;
- u_char resolution;
- u_char brightness;
- u_char contrast;
- u_char grain; /* 0 = 8x8, ..... 5 = 2x2 */
- u_char velocity; /* 0 = fast, ...., 4 = slow */
- u_char reserved[2];
- u_char paperlength_0; /* LSB */
- u_char paperlength_1; /* MSB */
+ u_int8_t mode;
+ u_int8_t resolution;
+ u_int8_t brightness;
+ u_int8_t contrast;
+ u_int8_t grain; /* 0 = 8x8, ..... 5 = 2x2 */
+ u_int8_t velocity; /* 0 = fast, ...., 4 = slow */
+ u_int8_t reserved[2];
+ u_int8_t paperlength[2]; /* LSB */
};
struct mustek_start_scan_cmd {
- u_char opcode; /* 0x1b */
- u_char reserved[3];
+ u_int8_t opcode; /* 0x1b */
+ u_int8_t reserved[3];
#define MUSTEK_SCAN_STOP 0x00
#define MUSTEK_SCAN_START 0x01
#define MUSTEK_GRAY_FILTER 0x00
@@ -212,8 +173,8 @@ struct mustek_start_scan_cmd {
#define MUSTEK_BIT_MODE 0x00
#define MUSTEK_RES_STEP_1 0x00
#define MUSTEK_RES_STEP_10 0x80
- u_char mode;
- u_char control;
+ u_int8_t mode;
+ u_int8_t control;
};
#endif /* _SS_MUSTEK_H_ */
diff --git a/sys/scsi/ss_scanjet.c b/sys/scsi/ss_scanjet.c
index 7a3ec6eb987..6c1bb689e55 100644
--- a/sys/scsi/ss_scanjet.c
+++ b/sys/scsi/ss_scanjet.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ss_scanjet.c,v 1.2 1996/04/19 16:10:24 niklas Exp $ */
-/* $NetBSD: ss_scanjet.c,v 1.1 1996/02/18 20:32:49 mycroft Exp $ */
+/* $OpenBSD: ss_scanjet.c,v 1.3 1996/04/21 22:31:17 deraadt Exp $ */
+/* $NetBSD: ss_scanjet.c,v 1.3 1996/03/30 21:47:07 christos Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@@ -87,23 +87,27 @@ scanjet_attach(ss, sa)
struct ss_softc *ss;
struct scsibus_attach_args *sa;
{
+#ifdef SCSIDEBUG
struct scsi_link *sc_link = sa->sa_sc_link;
+#endif
SC_DEBUG(sc_link, SDEV_DB1, ("scanjet_attach: start\n"));
ss->sio.scan_scanner_type = 0;
+ printf("\n%s: ", ss->sc_dev.dv_xname);
+
/* first, check the model (which determines nothing yet) */
if (!bcmp(sa->sa_inqbuf->product, "C1750A", 6)) {
ss->sio.scan_scanner_type = HP_SCANJET_IIC;
- printf(": HP ScanJet IIc\n");
+ printf("HP ScanJet IIc\n");
}
if (!bcmp(sa->sa_inqbuf->product, "C2500A", 6)) {
ss->sio.scan_scanner_type = HP_SCANJET_IIC;
- printf(": HP ScanJet IIcx\n");
+ printf("HP ScanJet IIcx\n");
}
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_attach: scanner_type = %d\n",
+ SC_DEBUG(sc_link, SDEV_DB1, ("scanjet_attach: scanner_type = %d\n",
ss->sio.scan_scanner_type));
/* now install special handlers */
@@ -118,8 +122,8 @@ scanjet_attach(ss, sa)
ss->sio.scan_y_resolution = 100;
ss->sio.scan_x_origin = 0;
ss->sio.scan_y_origin = 0;
- ss->sio.scan_brightness = 100;
- ss->sio.scan_contrast = 100;
+ ss->sio.scan_brightness = 128;
+ ss->sio.scan_contrast = 128;
ss->sio.scan_quality = 100;
ss->sio.scan_image_mode = SIM_GRAYSCALE;
@@ -144,9 +148,9 @@ scanjet_set_params(ss, sio)
struct ss_softc *ss;
struct scan_io *sio;
{
+#if 0
int error;
-#if 0
/*
* if the scanner is triggered, then rewind it
*/
@@ -200,7 +204,9 @@ scanjet_trigger_scanner(ss)
struct ss_softc *ss;
{
char escape_codes[20];
+#ifdef SCSIDEBUG
struct scsi_link *sc_link = ss->sc_link;
+#endif
int error;
scanjet_compute_sizes(ss);
@@ -241,7 +247,7 @@ scanjet_read(ss, bp)
* Handle "fixed-block-mode" tape drives by using the
* block count instead of the length.
*/
- lto3b(bp->b_bcount, cmd.len);
+ _lto3b(bp->b_bcount, cmd.len);
/*
* go ask the adapter to do all this for us
@@ -279,7 +285,7 @@ scanjet_write(ss, buf, size, flags)
return (0);
bzero(&cmd, sizeof(cmd));
cmd.opcode = WRITE;
- lto3b(size, cmd.len);
+ _lto3b(size, cmd.len);
return (scsi_scsi_cmd(ss->sc_link, (struct scsi_generic *) &cmd,
sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL,
flags | SCSI_DATA_OUT));
@@ -311,13 +317,13 @@ scanjet_set_window(ss)
p = escape_codes;
- sprintf(p, "\033*f%dP", ss->sio.scan_width / 4);
+ sprintf(p, "\033*f%ldP", ss->sio.scan_width / 4);
p += strlen(p);
- sprintf(p, "\033*f%dQ", ss->sio.scan_height / 4);
+ sprintf(p, "\033*f%ldQ", ss->sio.scan_height / 4);
p += strlen(p);
- sprintf(p, "\033*f%dX", ss->sio.scan_x_origin / 4);
+ sprintf(p, "\033*f%ldX", ss->sio.scan_x_origin / 4);
p += strlen(p);
- sprintf(p, "\033*f%dY", ss->sio.scan_y_origin / 4);
+ sprintf(p, "\033*f%ldY", ss->sio.scan_y_origin / 4);
p += strlen(p);
sprintf(p, "\033*a%dR", ss->sio.scan_x_resolution);
p += strlen(p);
@@ -375,6 +381,7 @@ void
scanjet_compute_sizes(ss)
struct ss_softc *ss;
{
+ int r = 0; /* round up by r 1/1200" */
/*
* Deal with the fact that the HP ScanJet IIc uses 1/300" not 1/1200"
@@ -390,22 +397,24 @@ scanjet_compute_sizes(ss)
ss->sio.scan_bits_per_pixel = 1;
break;
case SIM_GRAYSCALE:
+ r = 600;
ss->sio.scan_bits_per_pixel = 8;
break;
case SIM_COLOR:
+ r = 600;
ss->sio.scan_bits_per_pixel = 24;
break;
}
ss->sio.scan_pixels_per_line =
- (ss->sio.scan_width * ss->sio.scan_x_resolution) / 1200;
+ (ss->sio.scan_width * ss->sio.scan_x_resolution + r) / 1200;
if (ss->sio.scan_bits_per_pixel == 1)
/* pad to byte boundary: */
ss->sio.scan_pixels_per_line =
(ss->sio.scan_pixels_per_line + 7) & 0xfffffff8;
ss->sio.scan_lines =
- (ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200;
+ (ss->sio.scan_height * ss->sio.scan_y_resolution + r) / 1200;
ss->sio.scan_window_size = ss->sio.scan_lines *
((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
}
diff --git a/sys/scsi/ssvar.h b/sys/scsi/ssvar.h
index 27afc3a70e1..166c9d3770f 100644
--- a/sys/scsi/ssvar.h
+++ b/sys/scsi/ssvar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: ssvar.h,v 1.2 1996/04/19 16:10:26 niklas Exp $ */
-/* $NetBSD: ssvar.h,v 1.1 1996/02/18 20:32:50 mycroft Exp $ */
+/* $OpenBSD: ssvar.h,v 1.3 1996/04/21 22:31:18 deraadt Exp $ */
+/* $NetBSD: ssvar.h,v 1.2 1996/03/30 21:47:11 christos Exp $ */
/*
* Copyright (c) 1995 Kenneth Stailey. All rights reserved.
@@ -40,15 +40,19 @@
* Register NULL for a function if you want to try the real SCSI code
* (with quirks table)
*/
+struct ss_softc;
+struct scan_io;
+
struct ss_special {
- int (*set_params)();
- int (*trigger_scanner)();
- int (*get_params)();
- void (*minphys)(); /* some scanners only send line-multiples */
- int (*read)();
- int (*rewind_scanner)();
- int (*load_adf)();
- int (*unload_adf)();
+ int (*set_params) __P((struct ss_softc *, struct scan_io *));
+ int (*trigger_scanner) __P((struct ss_softc *));
+ int (*get_params) __P((struct ss_softc *));
+ /* some scanners only send line-multiples */
+ void (*minphys) __P((struct ss_softc *, struct buf *));
+ int (*read) __P((struct ss_softc *, struct buf *));
+ int (*rewind_scanner) __P((struct ss_softc *));
+ int (*load_adf) __P((struct ss_softc *));
+ int (*unload_adf) __P((struct ss_softc *));
};
/*
diff --git a/sys/scsi/st.c b/sys/scsi/st.c
index 3a652acea0d..39dd0ac1a5b 100644
--- a/sys/scsi/st.c
+++ b/sys/scsi/st.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: st.c,v 1.9 1996/04/19 16:10:28 niklas Exp $ */
-/* $NetBSD: st.c,v 1.62 1996/03/05 00:15:23 thorpej Exp $ */
+/* $OpenBSD: st.c,v 1.10 1996/04/21 22:31:20 deraadt Exp $ */
+/* $NetBSD: st.c,v 1.65 1996/03/30 21:45:04 christos Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -66,11 +66,11 @@
#include <sys/user.h>
#include <sys/mtio.h>
#include <sys/device.h>
+#include <sys/conf.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_tape.h>
#include <scsi/scsiconf.h>
-#include <scsi/scsi_conf.h>
/* Defines for device specific stuff */
#define DEF_FIXED_BSIZE 512
@@ -281,8 +281,12 @@ int st_interpret_sense __P((struct scsi_xfer *));
int st_touch_tape __P((struct st_softc *));
int st_erase __P((struct st_softc *, int full, int flags));
-struct cfdriver stcd = {
- NULL, "st", stmatch, stattach, DV_TAPE, sizeof(struct st_softc)
+struct cfattach st_ca = {
+ sizeof(struct st_softc), stmatch, stattach
+};
+
+struct cfdriver st_cd = {
+ NULL, "st", DV_TAPE
};
struct scsi_device st_switch = {
@@ -468,9 +472,9 @@ stopen(dev, flags, mode, p)
struct scsi_link *sc_link;
unit = STUNIT(dev);
- if (unit >= stcd.cd_ndevs)
+ if (unit >= st_cd.cd_ndevs)
return ENXIO;
- st = stcd.cd_devs[unit];
+ st = st_cd.cd_devs[unit];
if (!st)
return ENXIO;
@@ -479,7 +483,7 @@ stopen(dev, flags, mode, p)
sc_link = st->sc_link;
SC_DEBUG(sc_link, SDEV_DB1, ("open: dev=0x%x (unit %d (of %d))\n", dev,
- unit, stcd.cd_ndevs));
+ unit, st_cd.cd_ndevs));
/*
* Only allow one at a time
@@ -554,7 +558,7 @@ stclose(dev, flags, mode, p)
int mode;
struct proc *p;
{
- struct st_softc *st = stcd.cd_devs[STUNIT(dev)];
+ struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
SC_DEBUG(st->sc_link, SDEV_DB1, ("closing\n"));
if ((st->flags & (ST_WRITTEN | ST_FM_WRITTEN)) == ST_WRITTEN)
@@ -597,7 +601,7 @@ st_mount_tape(dev, flags)
unit = STUNIT(dev);
mode = STMODE(dev);
dsty = STDSTY(dev);
- st = stcd.cd_devs[unit];
+ st = st_cd.cd_devs[unit];
sc_link = st->sc_link;
if (st->flags & ST_MOUNTED)
@@ -820,7 +824,7 @@ void
ststrategy(bp)
struct buf *bp;
{
- struct st_softc *st = stcd.cd_devs[STUNIT(bp->b_dev)];
+ struct st_softc *st = st_cd.cd_devs[STUNIT(bp->b_dev)];
struct buf *dp;
int s;
@@ -1009,9 +1013,9 @@ ststart(v)
*/
if (st->flags & ST_FIXEDBLOCKS) {
cmd.byte2 |= SRW_FIXED;
- lto3b(bp->b_bcount / st->blksize, cmd.len);
+ _lto3b(bp->b_bcount / st->blksize, cmd.len);
} else
- lto3b(bp->b_bcount, cmd.len);
+ _lto3b(bp->b_bcount, cmd.len);
/*
* go ask the adapter to do all this for us
@@ -1029,7 +1033,7 @@ stread(dev, uio, iomode)
struct uio *uio;
int iomode;
{
- struct st_softc *st = stcd.cd_devs[STUNIT(dev)];
+ struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
return (physio(ststrategy, NULL, dev, B_READ,
st->sc_link->adapter->scsi_minphys, uio));
@@ -1041,7 +1045,7 @@ stwrite(dev, uio, iomode)
struct uio *uio;
int iomode;
{
- struct st_softc *st = stcd.cd_devs[STUNIT(dev)];
+ struct st_softc *st = st_cd.cd_devs[STUNIT(dev)];
return (physio(ststrategy, NULL, dev, B_WRITE,
st->sc_link->adapter->scsi_minphys, uio));
@@ -1074,7 +1078,7 @@ stioctl(dev, cmd, arg, flag, p)
flags = 0; /* give error messages, act on errors etc. */
unit = STUNIT(dev);
dsty = STDSTY(dev);
- st = stcd.cd_devs[unit];
+ st = st_cd.cd_devs[unit];
hold_blksize = st->blksize;
hold_density = st->density;
@@ -1258,21 +1262,15 @@ st_read(st, buf, size, flags)
cmd.opcode = READ;
if (st->flags & ST_FIXEDBLOCKS) {
cmd.byte2 |= SRW_FIXED;
- lto3b(size / (st->blksize ? st->blksize : DEF_FIXED_BSIZE),
+ _lto3b(size / (st->blksize ? st->blksize : DEF_FIXED_BSIZE),
cmd.len);
} else
- lto3b(size, cmd.len);
+ _lto3b(size, cmd.len);
return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd,
sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL,
flags | SCSI_DATA_IN);
}
-#ifdef __STDC__
-#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0)
-#else
-#define b2tol(a) (((unsigned)(a/**/_1) << 8) + (unsigned)a/**/_0)
-#endif
-
/*
* Ask the drive what it's min and max blk sizes are.
*/
@@ -1308,8 +1306,8 @@ st_read_block_limits(st, flags)
if (error)
return error;
- st->blkmin = b2tol(block_limits.min_length);
- st->blkmax = _3btol(&block_limits.max_length_2);
+ st->blkmin = _2btol(block_limits.min_length);
+ st->blkmax = _3btol(block_limits.max_length);
SC_DEBUG(sc_link, SDEV_DB3,
("(%d <= blksize <= %d)\n", st->blkmin, st->blkmax));
@@ -1417,7 +1415,7 @@ st_mode_select(st, flags)
else
scsi_select.header.dev_spec |= SMH_DSP_BUFF_MODE_ON;
if (st->flags & ST_FIXEDBLOCKS)
- lto3b(st->blksize, scsi_select.blk_desc.blklen);
+ _lto3b(st->blksize, scsi_select.blk_desc.blklen);
if (st->page_0_size)
bcopy(st->sense_data, scsi_select.sense_data, st->page_0_size);
@@ -1535,7 +1533,7 @@ st_space(st, number, what, flags)
bzero(&cmd, sizeof(cmd));
cmd.opcode = SPACE;
cmd.byte2 = what;
- lto3b(number, cmd.number);
+ _lto3b(number, cmd.number);
return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd,
sizeof(cmd), 0, 0, 0, 900000, NULL, flags);
@@ -1574,7 +1572,7 @@ st_write_filemarks(st, number, flags)
bzero(&cmd, sizeof(cmd));
cmd.opcode = WRITE_FILEMARKS;
- lto3b(number, cmd.number);
+ _lto3b(number, cmd.number);
return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &cmd,
sizeof(cmd), 0, 0, 0, 100000, NULL, flags);
@@ -1690,26 +1688,25 @@ st_interpret_sense(xs)
/*
* Get the sense fields and work out what code
*/
- if (sense->error_code & SSD_ERRCODE_VALID) {
- bcopy(sense->extended_info, &info, sizeof info);
- info = ntohl(info);
- } else
+ if (sense->error_code & SSD_ERRCODE_VALID)
+ info = _4btol(sense->info);
+ else
info = xs->datalen; /* bad choice if fixed blocks */
if ((sense->error_code & SSD_ERRCODE) != 0x70)
return -1; /* let the generic code handle it */
if (st->flags & ST_FIXEDBLOCKS) {
xs->resid = info * st->blksize;
- if (sense->extended_flags & SSD_EOM) {
+ if (sense->flags & SSD_EOM) {
st->flags |= ST_EIO_PENDING;
if (bp)
bp->b_resid = xs->resid;
}
- if (sense->extended_flags & SSD_FILEMARK) {
+ if (sense->flags & SSD_FILEMARK) {
st->flags |= ST_AT_FILEMARK;
if (bp)
bp->b_resid = xs->resid;
}
- if (sense->extended_flags & SSD_ILI) {
+ if (sense->flags & SSD_ILI) {
st->flags |= ST_EIO_PENDING;
if (bp)
bp->b_resid = xs->resid;
@@ -1743,14 +1740,14 @@ st_interpret_sense(xs)
}
} else { /* must be variable mode */
xs->resid = xs->datalen; /* to be sure */
- if (sense->extended_flags & SSD_EOM)
+ if (sense->flags & SSD_EOM)
return EIO;
- if (sense->extended_flags & SSD_FILEMARK) {
+ if (sense->flags & SSD_FILEMARK) {
if (bp)
bp->b_resid = bp->b_bcount;
return 0;
}
- if (sense->extended_flags & SSD_ILI) {
+ if (sense->flags & SSD_ILI) {
if (info < 0) {
/*
* the record was bigger than the read
@@ -1766,7 +1763,7 @@ st_interpret_sense(xs)
bp->b_resid = info;
}
}
- key = sense->extended_flags & SSD_KEY;
+ key = sense->flags & SSD_KEY;
if (key == 0x8) {
/*
diff --git a/sys/scsi/uk.c b/sys/scsi/uk.c
index 73ec0acfb0c..f040a359e38 100644
--- a/sys/scsi/uk.c
+++ b/sys/scsi/uk.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uk.c,v 1.2 1996/04/19 16:10:30 niklas Exp $ */
-/* $NetBSD: uk.c,v 1.14 1996/03/05 00:15:33 thorpej Exp $ */
+/* $OpenBSD: uk.c,v 1.3 1996/04/21 22:31:23 deraadt Exp $ */
+/* $NetBSD: uk.c,v 1.15 1996/03/17 00:59:57 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@@ -55,8 +55,12 @@ struct uk_softc {
int ukmatch __P((struct device *, void *, void *));
void ukattach __P((struct device *, struct device *, void *));
-struct cfdriver ukcd = {
- NULL, "uk", ukmatch, ukattach, DV_DULL, sizeof(struct uk_softc)
+struct cfattach uk_ca = {
+ sizeof(struct uk_softc), ukmatch, ukattach
+};
+
+struct cfdriver uk_cd = {
+ NULL, "uk", DV_DULL
};
/*
@@ -117,16 +121,16 @@ ukopen(dev)
struct scsi_link *sc_link;
unit = UKUNIT(dev);
- if (unit >= ukcd.cd_ndevs)
+ if (unit >= uk_cd.cd_ndevs)
return ENXIO;
- uk = ukcd.cd_devs[unit];
+ uk = uk_cd.cd_devs[unit];
if (!uk)
return ENXIO;
sc_link = uk->sc_link;
SC_DEBUG(sc_link, SDEV_DB1,
- ("ukopen: dev=0x%x (unit %d (of %d))\n", dev, unit, ukcd.cd_ndevs));
+ ("ukopen: dev=0x%x (unit %d (of %d))\n", dev, unit, uk_cd.cd_ndevs));
/*
* Only allow one at a time
@@ -150,7 +154,7 @@ int
ukclose(dev)
dev_t dev;
{
- struct uk_softc *uk = ukcd.cd_devs[UKUNIT(dev)];
+ struct uk_softc *uk = uk_cd.cd_devs[UKUNIT(dev)];
SC_DEBUG(uk->sc_link, SDEV_DB1, ("closing\n"));
uk->sc_link->flags &= ~SDEV_OPEN;
@@ -170,7 +174,7 @@ ukioctl(dev, cmd, addr, flag, p)
int flag;
struct proc *p;
{
- register struct uk_softc *uk = ukcd.cd_devs[UKUNIT(dev)];
+ register struct uk_softc *uk = uk_cd.cd_devs[UKUNIT(dev)];
return scsi_do_ioctl(uk->sc_link, dev, cmd, addr, flag, p);
}