Store the SCSI version in the scsi_link, and set the LUN in the CDB

if the version is <= SCSI-2.  This should help some older SCSI
devices that previously needed the "NOLUNS" quirk.  While this is
not strictly necessary on SCSI-2 devices, the spec allows it,
so we set it for SCSI-2 devices "just in case".  See section 7.2.2 of
Draft X3T9.2 Rev 10L for details.
This commit is contained in:
thorpej 1996-09-03 18:20:31 +00:00
parent e9e01a4d00
commit f60341a382
8 changed files with 44 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi_all.h,v 1.8 1996/07/10 22:48:56 explorer Exp $ */
/* $NetBSD: scsi_all.h,v 1.9 1996/09/03 18:20:31 thorpej Exp $ */
/*
* SCSI general interface description
@ -34,8 +34,14 @@
#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 */
/*
* 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 {

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi_base.c,v 1.37 1996/07/05 16:19:02 christos Exp $ */
/* $NetBSD: scsi_base.c,v 1.38 1996/09/03 18:20:33 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
@ -180,6 +180,14 @@ scsi_make_xs(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
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;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsiconf.c,v 1.62 1996/08/28 18:47:51 cgd Exp $ */
/* $NetBSD: scsiconf.c,v 1.63 1996/09/03 18:20:35 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -586,6 +586,7 @@ scsi_probedev(scsi, target, lun)
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);

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsiconf.h,v 1.31 1996/08/28 18:47:55 cgd Exp $ */
/* $NetBSD: scsiconf.h,v 1.32 1996/09/03 18:20:36 thorpej Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
@ -139,6 +139,7 @@ struct scsi_device {
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 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi_all.h,v 1.8 1996/07/10 22:48:56 explorer Exp $ */
/* $NetBSD: scsi_all.h,v 1.9 1996/09/03 18:20:31 thorpej Exp $ */
/*
* SCSI general interface description
@ -34,8 +34,14 @@
#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 */
/*
* 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 {

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi_base.c,v 1.37 1996/07/05 16:19:02 christos Exp $ */
/* $NetBSD: scsi_base.c,v 1.38 1996/09/03 18:20:33 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
@ -180,6 +180,14 @@ scsi_make_xs(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
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;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsiconf.c,v 1.62 1996/08/28 18:47:51 cgd Exp $ */
/* $NetBSD: scsiconf.c,v 1.63 1996/09/03 18:20:35 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -586,6 +586,7 @@ scsi_probedev(scsi, target, lun)
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);

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsiconf.h,v 1.31 1996/08/28 18:47:55 cgd Exp $ */
/* $NetBSD: scsiconf.h,v 1.32 1996/09/03 18:20:36 thorpej Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
@ -139,6 +139,7 @@ struct scsi_device {
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 */