diff options
-rw-r--r-- | sys/dev/atapi/acd.c | 18 | ||||
-rw-r--r-- | sys/dev/atapi/atapilink.h | 19 | ||||
-rw-r--r-- | sys/scsi/cd.c | 14 | ||||
-rw-r--r-- | sys/scsi/scsi_debug.h | 8 | ||||
-rw-r--r-- | sys/scsi/scsiconf.c | 6 | ||||
-rw-r--r-- | sys/scsi/scsiconf.h | 14 | ||||
-rw-r--r-- | sys/scsi/sd.c | 58 |
7 files changed, 94 insertions, 43 deletions
diff --git a/sys/dev/atapi/acd.c b/sys/dev/atapi/acd.c index 8d7b862550c..702d39d11cd 100644 --- a/sys/dev/atapi/acd.c +++ b/sys/dev/atapi/acd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acd.c,v 1.3 1996/06/09 18:42:46 downsj Exp $ */ +/* $OpenBSD: acd.c,v 1.4 1996/06/10 00:43:56 downsj Exp $ */ /* * Copyright (c) 1996 Manuel Bouyer. All rights reserved. @@ -37,6 +37,7 @@ #include <sys/file.h> #include <sys/stat.h> #include <sys/ioctl.h> +#include <sys/mtio.h> #include <sys/buf.h> #include <sys/uio.h> #include <sys/malloc.h> @@ -350,6 +351,12 @@ acdclose(dev, flag, fmt) atapi_prevent(acd->ad_link, PR_ALLOW); acd->ad_link->flags &= ~ADEV_OPEN; + + if (acd->ad_link->flags & ADEV_EJECTING) { + atapi_start_stop(acd->ad_link, SSS_STOP|SSS_LOEJ, 0); + + acd->ad_link->flags &= ~ADEV_EJECTING; + } } acdunlock(acd); @@ -873,9 +880,14 @@ acdioctl(dev, cmd, addr, flag, p) case CDIOCSTOP: return atapi_start_stop(acd->ad_link, SSS_STOP, 0); - case CDIOCEJECT: + case MTIOCTOP: + if (((struct mtop *)addr)->mt_op != MTOFFL) + return EIO; + /* FALLTHROUGH */ + case CDIOCEJECT: /* FALLTHROUGH */ case DIOCEJECT: - return atapi_start_stop(acd->ad_link, SSS_STOP|SSS_LOEJ, 0); + acd->ad_link->flags |= ADEV_EJECTING; + return 0; case CDIOCALLOW: return atapi_prevent(acd->ad_link, PR_ALLOW); diff --git a/sys/dev/atapi/atapilink.h b/sys/dev/atapi/atapilink.h index 22a5d880dee..d8791f97ce3 100644 --- a/sys/dev/atapi/atapilink.h +++ b/sys/dev/atapi/atapilink.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atapilink.h,v 1.2 1996/06/09 08:59:50 downsj Exp $ */ +/* $OpenBSD: atapilink.h,v 1.3 1996/06/10 00:43:57 downsj Exp $ */ /* * Copyright (c) 1996 Manuel Bouyer. All rights reserved. @@ -140,14 +140,15 @@ struct at_dev_link { struct atapi_identify id; struct bus_link *bus; u_int16_t flags; -#define ADEV_REMOVABLE 0x001 /* media is removable */ -#define ADEV_MEDIA_LOADED 0x002 /* device figures are still valid */ -#define ADEV_WAITING 0x004 /* a process is waiting for this */ -#define ADEV_OPEN 0x008 /* at least 1 open session */ -#define ACAP_DRQ_MPROC 0x000 /* microprocessor DRQ */ -#define ACAP_DRQ_INTR 0x100 /* interrupt DRQ */ -#define ACAP_DRQ_ACCEL 0x200 /* accelerated DRQ */ -#define ACAP_LEN 0x400 /* 16 bit commands */ +#define ADEV_REMOVABLE 0x0001 /* media is removable */ +#define ADEV_MEDIA_LOADED 0x0002 /* device figures are still valid */ +#define ADEV_WAITING 0x0004 /* a process is waiting for this */ +#define ADEV_OPEN 0x0008 /* at least 1 open session */ +#define ADEV_EJECTING 0x0010 /* eject on close */ +#define ACAP_DRQ_MPROC 0x0000 /* microprocessor DRQ */ +#define ACAP_DRQ_INTR 0x0100 /* interrupt DRQ */ +#define ACAP_DRQ_ACCEL 0x0200 /* accelerated DRQ */ +#define ACAP_LEN 0x0400 /* 16 bit commands */ void (*start)(); /* device start routine */ int (*done)(); /* device done routine */ }; diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index f50dfa66037..ed5a0c51bf2 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -53,6 +53,7 @@ #include <sys/file.h> #include <sys/stat.h> #include <sys/ioctl.h> +#include <sys/mtio.h> #include <sys/buf.h> #include <sys/uio.h> #include <sys/malloc.h> @@ -416,6 +417,12 @@ cdclose(dev, flag, fmt, p) scsi_prevent(cd->sc_link, PR_ALLOW, SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY); cd->sc_link->flags &= ~SDEV_OPEN; + + if (cd->sc_link->flags & SDEV_EJECTING) { + scsi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0); + + cd->sc_link->flags &= ~SDEV_EJECTING; + } } cdunlock(cd); @@ -929,9 +936,14 @@ cdioctl(dev, cmd, addr, flag, p) return scsi_start(cd->sc_link, SSS_START, 0); case CDIOCSTOP: return scsi_start(cd->sc_link, SSS_STOP, 0); + case MTIOCTOP: + if (((struct mtop *)addr)->mt_op != MTOFFL) + return EIO; + /* FALLTHROUGH */ case CDIOCEJECT: /* FALLTHROUGH */ case DIOCEJECT: - return scsi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0); + cd->sc_link->flags |= SDEV_EJECTING; + return 0; case CDIOCALLOW: return scsi_prevent(cd->sc_link, PR_ALLOW, 0); case CDIOCPREVENT: diff --git a/sys/scsi/scsi_debug.h b/sys/scsi/scsi_debug.h index ad2c3da29be..67e109788a5 100644 --- a/sys/scsi/scsi_debug.h +++ b/sys/scsi/scsi_debug.h @@ -11,10 +11,10 @@ * the following DEBUG bits are defined to exist in the flags word of * the scsi_link structure. */ -#define SDEV_DB1 0x10 /* scsi commands, errors, data */ -#define SDEV_DB2 0x20 /* routine flow tracking */ -#define SDEV_DB3 0x40 /* internal to routine flows */ -#define SDEV_DB4 0x80 /* level 4 debugging for this dev */ +#define SDEV_DB1 0x0010 /* scsi commands, errors, data */ +#define SDEV_DB2 0x0020 /* routine flow tracking */ +#define SDEV_DB3 0x0040 /* internal to routine flows */ +#define SDEV_DB4 0x0080 /* level 4 debugging for this dev */ /* target and LUN we want to debug */ #define DEBUGTARGET -1 /* -1 = disable */ diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index d55fe655f43..1437348a9d0 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.10 1996/05/06 11:33:06 deraadt Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.11 1996/06/10 00:43:59 downsj Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -347,6 +347,10 @@ struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = { "SEAGATE ", "ST296N ", ""}, SDEV_NOLUNS}, {{T_DIRECT, T_FIXED, "TOSHIBA ", "MK538FB ", "6027"}, SDEV_NOLUNS}, + {{T_DIRECT, T_REMOV, + "iomega", "jaz 1GB", ""}, SDEV_NOMODESENSE}, + {{T_DIRECT, T_REMOV, + "IOMEGA", "ZIP 100", ""}, SDEV_NOMODESENSE}, /* XXX: QIC-36 tape behind Emulex adapter. Very broken. */ diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index 60ccc31c775..6a4991efd7a 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -140,17 +140,19 @@ struct scsi_link { u_int8_t adapter_target; /* what are we on the scsi bus */ u_int8_t openings; /* available operations */ u_int8_t active; /* operations in progress */ - u_int8_t flags; /* flags that all devices have */ -#define SDEV_REMOVABLE 0x01 /* media is removable */ -#define SDEV_MEDIA_LOADED 0x02 /* device figures are still valid */ -#define SDEV_WAITING 0x04 /* a process is waiting for this */ -#define SDEV_OPEN 0x08 /* at least 1 open session */ -#define SDEV_DBX 0xf0 /* debuging flags (scsi_debug.h) */ + u_int16_t flags; /* flags that all devices have */ +#define SDEV_REMOVABLE 0x0001 /* media is removable */ +#define SDEV_MEDIA_LOADED 0x0002 /* device figures are still valid */ +#define SDEV_WAITING 0x0004 /* a process is waiting for this */ +#define SDEV_OPEN 0x0008 /* at least 1 open session */ +#define SDEV_DBX 0x00f0 /* debuging flags (scsi_debug.h) */ +#define SDEV_EJECTING 0x0100 /* eject on device close */ u_int8_t quirks; /* per-device oddities */ #define SDEV_AUTOSAVE 0x01 /* do implicit SAVEDATAPOINTER on disconnect */ #define SDEV_NOSYNCWIDE 0x02 /* does not grok SDTR or WDTR */ #define SDEV_NOLUNS 0x04 /* does not grok LUNs */ #define SDEV_FORCELUNS 0x08 /* prehistoric drive/ctlr groks LUNs */ +#define SDEV_NOMODESENSE 0x10 /* removable media/optical drives */ u_int8_t inquiry_flags; /* copy of flags from probe INQUIRY */ struct scsi_device *device; /* device entry points etc. */ void *device_softc; /* needed for call to foo_start */ diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 890b5413fba..5f574feee58 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.12 1996/06/01 09:35:03 deraadt Exp $ */ +/* $OpenBSD: sd.c,v 1.13 1996/06/10 00:44:00 downsj Exp $ */ /* $NetBSD: sd.c,v 1.100 1996/05/14 10:38:47 leo Exp $ */ /* @@ -54,6 +54,7 @@ #include <sys/file.h> #include <sys/stat.h> #include <sys/ioctl.h> +#include <sys/mtio.h> #include <sys/buf.h> #include <sys/uio.h> #include <sys/malloc.h> @@ -397,6 +398,12 @@ sdclose(dev, flag, fmt, p) scsi_prevent(sd->sc_link, PR_ALLOW, SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY); sd->sc_link->flags &= ~(SDEV_OPEN|SDEV_MEDIA_LOADED); + + if (sd->sc_link->flags & SDEV_EJECTING) { + scsi_start(sd->sc_link, SSS_STOP|SSS_LOEJ, 0); + + sd->sc_link->flags &= ~SDEV_EJECTING; + } } sdunlock(sd); @@ -730,9 +737,15 @@ sdioctl(dev, cmd, addr, flag, p) return scsi_prevent(sd->sc_link, (*(int *)addr) ? PR_PREVENT : PR_ALLOW, 0); + case MTIOCTOP: + if (((struct mtop *)addr)->mt_op != MTOFFL) + return EIO; + /* FALLTHROUGH */ case DIOCEJECT: - return ((sd->sc_link->flags & SDEV_REMOVABLE) == 0 ? ENOTTY : - scsi_start(sd->sc_link, SSS_STOP|SSS_LOEJ, 0)); + if ((sd->sc_link->flags & SDEV_REMOVABLE) == 0) + return ENOTTY; + sd->sc_link->flags |= SDEV_EJECTING; + return 0; default: if (SDPART(dev) != RAW_PART) @@ -838,6 +851,9 @@ sd_get_parms(sd, flags) } scsi_sense; u_long sectors; + if ((sd->sc_link->quirks & SDEV_NOMODESENSE) != 0) + goto fake_it; + /* * do a "mode sense page 4" */ @@ -845,28 +861,14 @@ sd_get_parms(sd, flags) scsi_cmd.opcode = MODE_SENSE; scsi_cmd.page = 4; scsi_cmd.length = 0x20; + /* * If the command worked, use the results to fill out * the parameter structure */ if (scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), (u_char *)&scsi_sense, sizeof(scsi_sense), - SDRETRIES, 6000, NULL, flags | SCSI_DATA_IN) != 0) { - printf("%s: could not mode sense (4)", sd->sc_dev.dv_xname); - fake_it: - printf("; using fictitious geometry\n"); - /* - * use adaptec standard fictitious geometry - * this depends on which controller (e.g. 1542C is - * different. but we have to put SOMETHING here..) - */ - sectors = scsi_size(sd->sc_link, flags); - dp->heads = 64; - dp->sectors = 32; - dp->cyls = sectors / (64 * 32); - dp->blksize = 512; - dp->disksize = sectors; - } else { + SDRETRIES, 6000, NULL, flags | SCSI_DATA_IN) == 0) { 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), @@ -898,8 +900,26 @@ sd_get_parms(sd, flags) dp->disksize = sectors; sectors /= (dp->heads * dp->cyls); dp->sectors = sectors; /* XXX dubious on SCSI */ + return 0; } + else + printf("%s: could not mode sense (4)", sd->sc_dev.dv_xname); + +fake_it: + /* + * use adaptec standard fictitious geometry + * this depends on which controller (e.g. 1542C is + * different. but we have to put SOMETHING here..) + */ + if ((sd->sc_link->quirks & SDEV_NOMODESENSE) == 0) + printf("; using fictitious geometry\n"); + sectors = scsi_size(sd->sc_link, flags); + dp->heads = 64; + dp->sectors = 32; + dp->cyls = sectors / (64 * 32); + dp->blksize = 512; + dp->disksize = sectors; return 0; } |