diff options
author | 2002-09-04 23:07:28 +0000 | |
---|---|---|
committer | 2002-09-04 23:07:28 +0000 | |
commit | c6e2d171c33ff3ec63b15ad53618e3276b535032 (patch) | |
tree | 8e5b9c379910e7ac04aab0cb5ab36646888fe961 | |
parent | don't dereference ecb on default case, it's uninitialized. (diff) | |
download | wireguard-openbsd-c6e2d171c33ff3ec63b15ad53618e3276b535032.tar.xz wireguard-openbsd-c6e2d171c33ff3ec63b15ad53618e3276b535032.zip |
Add support for RBC (simplified direct) devices.
ok costa@, krw@
-rw-r--r-- | sys/scsi/scsi_all.h | 3 | ||||
-rw-r--r-- | sys/scsi/scsi_disk.h | 16 | ||||
-rw-r--r-- | sys/scsi/scsiconf.c | 6 | ||||
-rw-r--r-- | sys/scsi/sd.c | 9 | ||||
-rw-r--r-- | sys/scsi/sd_scsi.c | 70 |
5 files changed, 86 insertions, 18 deletions
diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h index a0bc2d01886..2517d7ee289 100644 --- a/sys/scsi/scsi_all.h +++ b/sys/scsi/scsi_all.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_all.h,v 1.12 2001/11/11 21:38:17 krw Exp $ */ +/* $OpenBSD: scsi_all.h,v 1.13 2002/09/04 23:07:28 tdeval Exp $ */ /* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */ /* @@ -199,6 +199,7 @@ struct scsi_changedef { #define T_CDROM 5 #define T_SCANNER 6 #define T_OPTICAL 7 +#define T_RDIRECT 14 #define T_NODEVICE 0x1F #define T_CHANGER 8 diff --git a/sys/scsi/scsi_disk.h b/sys/scsi/scsi_disk.h index 33d8cfbbc29..347ba8bf4f0 100644 --- a/sys/scsi/scsi_disk.h +++ b/sys/scsi/scsi_disk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_disk.h,v 1.11 2001/06/22 14:35:43 deraadt Exp $ */ +/* $OpenBSD: scsi_disk.h,v 1.12 2002/09/04 23:07:28 tdeval Exp $ */ /* $NetBSD: scsi_disk.h,v 1.10 1996/07/05 16:19:05 christos Exp $ */ /* @@ -325,6 +325,20 @@ union scsi_disk_pages { u_int8_t reserved3; u_int8_t reserved4; } flex_geometry; + struct page_reduced_geometry { + u_int8_t pg_code; /* page code (should be 6) */ + u_int8_t pg_length; /* page length (should be 0x0B) */ + u_int8_t wcd; /* bit 0 = write cache disable */ + u_int8_t bytes_s[2]; /* bytes per sector */ + u_int8_t sectors[5]; /* total number of sectors */ + u_int8_t pow_perf; /* power/performance level */ + u_int8_t flags; /* various */ +#define LOCK_DISABLED 0x1 +#define FORMAT_DISABLED 0x2 +#define WRITE_DISABLED 0x4 +#define READ_DISABLED 0x8 + u_int8_t reserved; + } reduced_geometry; }; #endif /* _SCSI_SCSI_DISK_H */ diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index d9008e88d6b..99c3ffa7104 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.67 2002/03/14 01:27:13 millert Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.68 2002/09/04 23:07:28 tdeval Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -730,6 +730,9 @@ scsibusprint(aux, pnp) case T_ENCLOSURE: dtype = "enclosure services"; break; + case T_RDIRECT: + dtype = "simplified direct"; + break; case T_NODEVICE: panic("scsibusprint: impossible device type"); default: @@ -903,6 +906,7 @@ scsi_probedev(scsi, target, lun) case T_OPTICAL: case T_CHANGER: case T_COMM: + case T_RDIRECT: default: break; case T_NODEVICE: diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index fa288e71d5c..1c30de210f1 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.54 2002/08/12 06:59:46 fgsch Exp $ */ +/* $OpenBSD: sd.c,v 1.55 2002/09/04 23:07:28 tdeval Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -129,6 +129,10 @@ struct scsi_inquiry_pattern sd_patterns[] = { "", "", ""}, {T_DIRECT, T_REMOV, "", "", ""}, + {T_RDIRECT, T_FIXED, + "", "", ""}, + {T_RDIRECT, T_REMOV, + "", "", ""}, {T_OPTICAL, T_FIXED, "", "", ""}, {T_OPTICAL, T_REMOV, @@ -197,6 +201,9 @@ sdattach(parent, self, aux) sd->sc_ops = &sd_scsibus_ops; } + if (!(sc_link->inquiry_flags & SID_RelAdr)) + sc_link->quirks |= SDEV_NOCDB6; + /* * Note if this device is ancient. This is used in sdminphys(). */ diff --git a/sys/scsi/sd_scsi.c b/sys/scsi/sd_scsi.c index 52858b2a8da..de9d08e64ff 100644 --- a/sys/scsi/sd_scsi.c +++ b/sys/scsi/sd_scsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd_scsi.c,v 1.3 2002/03/14 01:27:13 millert Exp $ */ +/* $OpenBSD: sd_scsi.c,v 1.4 2002/09/04 23:07:28 tdeval Exp $ */ /* $NetBSD: sd_scsi.c,v 1.8 1998/10/08 20:21:13 thorpej Exp $ */ /*- @@ -177,6 +177,7 @@ sd_scsibus_get_parms(sd, dp, flags) int flags; { struct sd_scsibus_mode_sense_data scsi_sense; + union scsi_disk_pages *sense_pages; u_long sectors; int page; int error; @@ -192,13 +193,17 @@ sd_scsibus_get_parms(sd, dp, flags) if ((error = sd_scsibus_mode_sense(sd, &scsi_sense, page = 4, flags)) == 0) { + sense_pages = (union scsi_disk_pages *) + ((char *)&scsi_sense.blk_desc + + (size_t)scsi_sense.header.blk_desc_len); 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), - scsi_sense.pages.rigid_geometry.nheads, - _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))); + ("%d cyls, %d heads, %d precomp, %d red_write," + " %d land_zone\n", + _3btol(sense_pages->rigid_geometry.ncyl), + sense_pages->rigid_geometry.nheads, + _2btol(sense_pages->rigid_geometry.st_cyl_wp), + _2btol(sense_pages->rigid_geometry.st_cyl_rwc), + _2btol(sense_pages->rigid_geometry.land_zone))); /* * KLUDGE!! (for zone recorded disks) @@ -206,9 +211,12 @@ sd_scsibus_get_parms(sd, dp, flags) * is <= disk_size * 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); - dp->blksize = _3btol(scsi_sense.blk_desc.blklen); + dp->heads = sense_pages->rigid_geometry.nheads; + dp->cyls = _3btol(sense_pages->rigid_geometry.ncyl); + if (scsi_sense.header.blk_desc_len >= 8) + dp->blksize = _3btol(scsi_sense.blk_desc.blklen); + else + dp->blksize = 0; if (dp->heads == 0 || dp->cyls == 0) goto fake_it; @@ -226,10 +234,17 @@ sd_scsibus_get_parms(sd, dp, flags) if ((error = sd_scsibus_mode_sense(sd, &scsi_sense, page = 5, flags)) == 0) { - dp->heads = scsi_sense.pages.flex_geometry.nheads; - dp->cyls = _2btol(scsi_sense.pages.flex_geometry.ncyl); - dp->blksize = _3btol(scsi_sense.blk_desc.blklen); - dp->sectors = scsi_sense.pages.flex_geometry.ph_sec_tr; + sense_pages = (union scsi_disk_pages *) + ((char *)&scsi_sense.blk_desc + + (size_t)scsi_sense.header.blk_desc_len); + dp->heads = sense_pages->flex_geometry.nheads; + dp->cyls = _2btol(sense_pages->flex_geometry.ncyl); + if (scsi_sense.header.blk_desc_len >= 8) + dp->blksize = _3btol(scsi_sense.blk_desc.blklen); + else + dp->blksize = + _2btol(sense_pages->reduced_geometry.bytes_s); + dp->sectors = sense_pages->flex_geometry.ph_sec_tr; dp->disksize = dp->heads * dp->cyls * dp->sectors; if (dp->disksize == 0) goto fake_it; @@ -240,6 +255,33 @@ sd_scsibus_get_parms(sd, dp, flags) return (SDGP_RESULT_OK); } + /* T_RDIRECT define page 6. */ + if ((error = sd_scsibus_mode_sense(sd, &scsi_sense, page = 6, + flags)) == 0) { + sense_pages = (union scsi_disk_pages *) + ((char *)&scsi_sense.blk_desc + + (size_t)scsi_sense.header.blk_desc_len); + dp->heads = 64; + dp->sectors = 32; + dp->disksize = + _4btol(sense_pages->reduced_geometry.sectors+1); + dp->cyls = dp->disksize / (64 * 32); + if (scsi_sense.header.blk_desc_len >= 8) + dp->blksize = _3btol(scsi_sense.blk_desc.blklen); + else + dp->blksize = + _2btol(sense_pages->reduced_geometry.bytes_s); + + if (dp->disksize == 0 || + sense_pages->reduced_geometry.sectors[0] != 0) + goto fake_it; + + if (dp->blksize == 0) + dp->blksize = 512; + + return (SDGP_RESULT_OK); + } + fake_it: if ((sd->sc_link->quirks & SDEV_NOMODESENSE) == 0) { if (error == 0) |