Subject: Re: SCSI CD changers supported?
To: Tom I Helbekkmo <tih@hamartun.priv.no>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 09/03/1996 11:35:00
On Sun, 1 Sep 1996 06:15:07 +0000 (GMT)
Tom I Helbekkmo <tih@Hamartun.Priv.NO> wrote:
> This sounds like a much better solution than my suggestion of adding a
> new quirk to the SCSI subsystem. Unless I am much mistaken, this is a
> one-liner in /sys/scsi/scsi_base.c, and can't hurt anything so long as
> it's done only for SCSI 1 devices. Get it in there before 1.2 ships!
Ok, I've committed the following patch to the trunk, and am going to
request that it be pulled up for the 1.2 release ... If it doesn't make
the release, I'll make sure it's in the first Official Patch.
Anyhow, the diff is appended below (it might apply to 1.2 with fuzz, so
be careful).
-- save the ancient forests - http://www.bayarea.net/~thorpej/forest/ --
Jason R. Thorpe thorpej@nas.nasa.gov
NASA Ames Research Center Home: 408.866.1912
NAS: M/S 258-6 Work: 415.604.0935
Moffett Field, CA 94035 Pager: 415.428.6939
----- snip -----
Index: scsi_all.h
===================================================================
RCS file: /mastersrc/netbsd/src/sys/scsi/scsi_all.h,v
retrieving revision 1.1.1.3
diff -c -r1.1.1.3 scsi_all.h
*** scsi_all.h 1996/07/17 02:42:37 1.1.1.3
--- scsi_all.h 1996/09/01 15:53:18
***************
*** 34,41 ****
#define SCSI_CTL_LINK 0x01
#define SCSI_CTL_FLAG 0x02
#define SCSI_CTL_VENDOR 0xC0
! #define SCSI_CMD_LUN 0xA0 /* these two should not be needed */
! #define SCSI_CMD_LUN_SHIFT 5 /* LUN in the cmd is no longer SCSI */
struct scsi_generic {
--- 34,47 ----
#define SCSI_CTL_LINK 0x01
#define SCSI_CTL_FLAG 0x02
#define SCSI_CTL_VENDOR 0xC0
!
!
! /*
! * Some old SCSI devices need the LUN to be set in the top 3 bits of the
! * second byte of the CDB.
! */
! #define SCSI_CMD_LUN_MASK 0xe0
! #define SCSI_CMD_LUN_SHIFT 5
struct scsi_generic {
Index: scsi_base.c
===================================================================
RCS file: /mastersrc/netbsd/src/sys/scsi/scsi_base.c,v
retrieving revision 1.9
diff -c -r1.9 scsi_base.c
*** scsi_base.c 1996/07/09 04:09:07 1.9
--- scsi_base.c 1996/09/03 16:03:16
***************
*** 180,185 ****
--- 180,193 ----
xs->timeout = timeout;
xs->bp = bp;
+ /*
+ * Set the LUN in the CDB if we have an older device. We also
+ * set it for more modern SCSI-II devices "just in case".
+ */
+ if ((sc_link->scsi_version & SID_ANSII) <= 2)
+ xs->cmd->bytes[0] |=
+ ((sc_link->lun << SCSI_CMD_LUN_SHIFT) & SCSI_CMD_LUN_MASK);
+
return xs;
}
Index: scsiconf.c
===================================================================
RCS file: /mastersrc/netbsd/src/sys/scsi/scsiconf.c,v
retrieving revision 1.15
diff -c -r1.15 scsiconf.c
*** scsiconf.c 1996/08/31 02:32:06 1.15
--- scsiconf.c 1996/09/01 15:45:26
***************
*** 588,593 ****
--- 588,594 ----
if ((inqbuf.version & SID_ANSII) == 0 &&
(sc_link->quirks & SDEV_FORCELUNS) == 0)
sc_link->quirks |= SDEV_NOLUNS;
+ sc_link->scsi_version = inqbuf.version;
if ((sc_link->quirks & SDEV_NOLUNS) == 0)
scsi->moreluns |= (1 << target);
Index: scsiconf.h
===================================================================
RCS file: /mastersrc/netbsd/src/sys/scsi/scsiconf.h,v
retrieving revision 1.9
diff -c -r1.9 scsiconf.h
*** scsiconf.h 1996/08/31 02:32:08 1.9
--- scsiconf.h 1996/09/01 18:42:07
***************
*** 139,144 ****
--- 139,145 ----
struct scsi_link {
int channel; /* channel, i.e. bus # on controller */
+ u_int8_t scsi_version; /* SCSI-I, SCSI-II, etc. */
u_int8_t scsibus; /* the Nth scsibus */
u_int8_t target; /* targ of this dev */
u_int8_t lun; /* lun of this dev */