Change scsipi_inquiry_data strucure to be ANSI SPC-2 rev16 compliant

This commit is contained in:
dante 2000-05-14 18:20:11 +00:00
parent ac9d663468
commit f65d97bb57
3 changed files with 58 additions and 62 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsiconf.c,v 1.140 2000/04/19 04:49:50 enami Exp $ */ /* $NetBSD: scsiconf.c,v 1.141 2000/05/14 18:20:11 dante Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -718,11 +718,16 @@ scsi_probedev(scsi, target, lun)
goto bad; goto bad;
{ {
u_int8_t *extension = &inqbuf.flags1;
int len = inqbuf.additional_length; int len = inqbuf.additional_length;
while (len < 3) while (len < 3)
inqbuf.unused[len++] = '\0'; extension[len++] = '\0';
while (len < 3 + 28) while (len < 3 + 28)
inqbuf.unused[len++] = ' '; extension[len++] = ' ';
while (len < 3 + 28 + 20)
extension[len++] = '\0';
while (len < 3 + 28 + 20 + 1)
extension[len++] = '\0';
} }
sa.sa_sc_link = sc_link; sa.sa_sc_link = sc_link;
@ -745,11 +750,11 @@ scsi_probedev(scsi, target, lun)
* at SCSI-2 or better, set some limiting quirks. * at SCSI-2 or better, set some limiting quirks.
*/ */
if ((inqbuf.version & SID_ANSII) >= 2) { if ((inqbuf.version & SID_ANSII) >= 2) {
if ((inqbuf.flags & SID_CmdQue) == 0) if ((inqbuf.flags3 & SID_CmdQue) == 0)
sc_link->quirks |= SDEV_NOTAG; sc_link->quirks |= SDEV_NOTAG;
if ((inqbuf.flags & SID_Sync) == 0) if ((inqbuf.flags3 & SID_Sync) == 0)
sc_link->quirks |= SDEV_NOSYNC; sc_link->quirks |= SDEV_NOSYNC;
if ((inqbuf.flags & SID_WBus16) == 0) if ((inqbuf.flags3 & SID_WBus16) == 0)
sc_link->quirks |= SDEV_NOWIDE; sc_link->quirks |= SDEV_NOWIDE;
} }
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsipi_all.h,v 1.12 1998/12/30 11:17:34 dbj Exp $ */ /* $NetBSD: scsipi_all.h,v 1.13 2000/05/14 18:20:11 dante Exp $ */
/* /*
* SCSI and SCSI-like general interface description * SCSI and SCSI-like general interface description
@ -170,30 +170,37 @@ struct scsipi_sense_data_unextended {
#define T_FIXED 0 /* device is not removable */ #define T_FIXED 0 /* device is not removable */
/* /*
* XXX * According to SPC-2r16, in order to know if a U3W device support PPR,
* Actually I think some SCSI driver expects this structure to be 32 bytes, so * Inquiry Data structure should be at least 58 Bytes.
* don't change it unless you really know what you are doing
*/ */
struct scsipi_inquiry_data { struct scsipi_inquiry_data {
u_int8_t device; /* 1*/ u_int8_t device;
#define SID_TYPE 0x1F #define SID_TYPE 0x1F
#define SID_QUAL 0xE0 #define SID_QUAL 0xE0
#define SID_QUAL_LU_OK 0x00 #define SID_QUAL_LU_OK 0x00
#define SID_QUAL_LU_OFFLINE 0x20 #define SID_QUAL_LU_OFFLINE 0x20
#define SID_QUAL_RSVD 0x40 #define SID_QUAL_RSVD 0x40
#define SID_QUAL_BAD_LU 0x60 #define SID_QUAL_BAD_LU 0x60
u_int8_t dev_qual2; /* 2*/ u_int8_t dev_qual2;
#define SID_QUAL2 0x7F #define SID_QUAL2 0x7F
#define SID_REMOVABLE 0x80 #define SID_REMOVABLE 0x80
u_int8_t version; /* 3*/ u_int8_t version;
#define SID_ANSII 0x07 #define SID_ANSII 0x07
#define SID_ECMA 0x38 #define SID_ECMA 0x38
#define SID_ISO 0xC0 #define SID_ISO 0xC0
u_int8_t response_format; /* 4*/ u_int8_t response_format;
u_int8_t additional_length; #define SID_RespDataFmt 0x0F
u_int8_t unused[2]; /* 5*/ u_int8_t additional_length; /* n-4 */
u_int8_t flags; /* 6*/ u_int8_t flags1;
#define SID_SCC 0x80
/* 7*/ u_int8_t flags2;
#define SID_Addr16 0x01
#define SID_MChngr 0x08
#define SID_MultiPort 0x10
#define SID_EncServ 0x40
#define SID_BasQue 0x80
/* 8*/ u_int8_t flags3;
#define SID_SftRe 0x01 #define SID_SftRe 0x01
#define SID_CmdQue 0x02 #define SID_CmdQue 0x02
#define SID_Linked 0x08 #define SID_Linked 0x08
@ -201,10 +208,19 @@ struct scsipi_inquiry_data {
#define SID_WBus16 0x20 #define SID_WBus16 0x20
#define SID_WBus32 0x40 #define SID_WBus32 0x40
#define SID_RelAdr 0x80 #define SID_RelAdr 0x80
char vendor[8]; /* 9*/ char vendor[8];
char product[16]; /*17*/ char product[16];
char revision[4]; /*33*/ char revision[4];
u_int8_t extra[8]; /*37*/ u_int8_t vendor_specific[20];
}; /*57*/ u_int8_t flags4;
#define SID_IUS 0x01
#define SID_QAS 0x02
#define SID_Cloacking 0x0C
#define SIDV_CLOCKING_ST_ONLY 0x00
#define SIDV_CLOCKING_DT_ONLY 0x04
#define SIDV_CLOCKING_SD_DT 0x0C
/*58*/ u_int8_t reserved;
/*59*/ char version_descriptor[8][2];
}; /* 74 Bytes */
#endif /* _DEV_SCSIPI_SCSIPI_ALL_H_ */ #endif /* _DEV_SCSIPI_SCSIPI_ALL_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ses.c,v 1.4 2000/02/20 21:30:44 mjacob Exp $ */ /* $NetBSD: ses.c,v 1.5 2000/05/14 18:20:11 dante Exp $ */
/* /*
* Copyright (C) 2000 National Aeronautics & Space Administration * Copyright (C) 2000 National Aeronautics & Space Administration
* All rights reserved. * All rights reserved.
@ -92,7 +92,7 @@ typedef struct {
#define SEN_ID "UNISYS SUN_SEN" #define SEN_ID "UNISYS SUN_SEN"
#define SEN_ID_LEN 24 #define SEN_ID_LEN 24
static enctyp ses_type __P((void *, int)); static enctyp ses_type __P((struct scsipi_inquiry_data *));
/* Forward reference to Enclosure Functions */ /* Forward reference to Enclosure Functions */
@ -276,8 +276,6 @@ ses_attach(parent, self, aux)
} }
#define NETBSD_SAFTE_END 50
static enctyp static enctyp
ses_device_type(sa) ses_device_type(sa)
struct scsipibus_attach_args *sa; struct scsipibus_attach_args *sa;
@ -288,32 +286,7 @@ ses_device_type(sa)
if (inqp == NULL) if (inqp == NULL)
return (SES_NONE); return (SES_NONE);
/* return (ses_type(inqp));
* If we can get longer data to check for the
* presence of a SAF-TE device, try and do so.
*
* Because we do deferred target attach in NetBSD,
* we don't have to run this as a polled command.
*/
if (inqp->additional_length >= NETBSD_SAFTE_END-4) {
size_t amt = inqp->additional_length + 4;
struct scsipi_generic cmd;
static u_char more[64];
bzero(&cmd, sizeof(cmd));
cmd.opcode = INQUIRY;
cmd.bytes[3] = amt;
if (scsipi_command(sa->sa_sc_link, &cmd, 6, more, amt,
SCSIPIRETRIES, 10000, NULL,
XS_CTL_DATA_IN | XS_CTL_DISCOVERY) == 0) {
length = amt;
inqp = (struct scsipi_inquiry_data *) more;
}
} else {
length = sizeof (struct scsipi_inquiry_data);
}
return (ses_type(inqp, length));
} }
int int
@ -595,17 +568,18 @@ ses_log(ssc, fmt, va_alist)
#define SAFTE_LEN SAFTE_END-SAFTE_START #define SAFTE_LEN SAFTE_END-SAFTE_START
static enctyp static enctyp
ses_type(void *buf, int buflen) ses_type(inqp)
struct scsipi_inquiry_data *inqp;
{ {
unsigned char *iqd = buf; size_t given_len = inqp->additional_length + 4;
if (buflen < 8+SEN_ID_LEN) if (given_len < 8+SEN_ID_LEN)
return (SES_NONE); return (SES_NONE);
if ((iqd[0] & 0x1f) == T_ENCLOSURE) { if ((inqp->device & SID_TYPE) == T_ENCLOSURE) {
if (STRNCMP(&iqd[8], SEN_ID, SEN_ID_LEN) == 0) { if (STRNCMP(inqp->vendor, SEN_ID, SEN_ID_LEN) == 0) {
return (SES_SEN); return (SES_SEN);
} else if ((iqd[2] & 0x7) > 2) { } else if ((inqp->version & SID_ANSII) > 2) {
return (SES_SES); return (SES_SES);
} else { } else {
return (SES_SES_SCSI2); return (SES_SES_SCSI2);
@ -614,7 +588,7 @@ ses_type(void *buf, int buflen)
} }
#ifdef SES_ENABLE_PASSTHROUGH #ifdef SES_ENABLE_PASSTHROUGH
if ((iqd[6] & 0x40) && (iqd[2] & 0x7) >= 2) { if ((inqp->flags2 & SID_EncServ) && (inqp->version & SID_ANSII) >= 2) {
/* /*
* PassThrough Device. * PassThrough Device.
*/ */
@ -627,13 +601,14 @@ ses_type(void *buf, int buflen)
* some vendors were chopping it short. * some vendors were chopping it short.
*/ */
if (buflen < SAFTE_END - 2) { if (given_len < SAFTE_END - 2) {
return (SES_NONE); return (SES_NONE);
} }
if (STRNCMP((char *)&iqd[SAFTE_START], "SAF-TE", SAFTE_LEN - 2) == 0) { if (STRNCMP((char *)&inqp->vendor_specific[8], "SAF-TE",
SAFTE_LEN - 2) == 0) {
return (SES_SAFT); return (SES_SAFT);
}
return (SES_NONE); return (SES_NONE);
} }