summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1996-06-16 03:07:22 +0000
committerJason Downs <downsj@cvs.openbsd.org>1996-06-16 03:07:22 +0000
commit587016bbab30c6eac8d7b9ad4e1abe505c5922bb (patch)
tree032390297f9c7f4b93f3d331fe6c6e7687a4ba8d /sys/scsi
parent13504ad958d6c727d842b1f2bda7f17b50c877e8 (diff)
NetBSD PR#2535: add mode sense 5 and floppy support in our framework.
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/scsi_base.c4
-rw-r--r--sys/scsi/scsi_disk.h37
-rw-r--r--sys/scsi/sd.c36
3 files changed, 72 insertions, 5 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index c607a0cb41d..ac52d489caa 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.9 1996/05/06 11:33:35 deraadt Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.10 1996/06/16 03:07:19 downsj Exp $ */
/* $NetBSD: scsi_base.c,v 1.36 1996/05/03 19:48:20 christos Exp $ */
/*
@@ -688,6 +688,8 @@ scsi_interpret_sense(xs)
case 0x5: /* ILLEGAL REQUEST */
if ((xs->flags & SCSI_IGNORE_ILLEGAL_REQUEST) != 0)
return 0;
+ if ((xs->flags & SCSI_SILENT) != 0)
+ return EIO;
error = EINVAL;
break;
case 0x6: /* UNIT ATTENTION */
diff --git a/sys/scsi/scsi_disk.h b/sys/scsi/scsi_disk.h
index e19e0f176a0..9ebd2492492 100644
--- a/sys/scsi/scsi_disk.h
+++ b/sys/scsi/scsi_disk.h
@@ -174,6 +174,43 @@ union disk_pages {
u_int8_t reserved2;
u_int8_t reserved3;
} rigid_geometry;
+ struct page_flex_geometry {
+ u_char pg_code; /* page code (should be 5) */
+ u_char pg_length; /* page length (should be 0x1e) */
+ u_char xfr_rate1;
+ u_char xfr_rate0;
+ u_char nheads; /* number of heads */
+ u_char ph_sec_t; /* physical sectors per track */
+ u_char bytes_s_1; /* bytes per sector (MSB) */
+ u_char bytes_s_0; /* bytes per sector (LSB) */
+ u_char ncyl_1; /* number of cylinders (MSB) */
+ u_char ncyl_0; /* number of cylinders (LSB) */
+ u_char st_cyl_wp_1; /* starting cyl., write precomp (MSB) */
+ u_char st_cyl_wp_0; /* starting cyl., write precomp (LSB) */
+ u_char st_cyl_rwc_1; /* starting cyl., red. write cur (MSB) */
+ u_char st_cyl_rwc_0; /* starting cyl., red. write cur (LSB) */
+ u_char driv_step_1; /* drive step rate (MSB) */
+ u_char driv_step_0; /* drive step rate (LSB) */
+ u_char driv_step_w; /* drive step pulse width */
+ u_char head_settle_1; /* head settle delay (MSB) */
+ u_char head_settle_0; /* head settle delay (LSB) */
+ u_char motor_on; /* motor on delay */
+ u_char motor_off; /* motor off delay */
+ u_char flags; /* various flags */
+#define MO 0x20 /* motor on (pin 16)? */
+#define SSN 0x40 /* start at sector 1 */
+#define TRDY 0x20 /* RDY (pin 34) valid */
+ u_char step_p_cyl; /* step pulses per cylinder */
+ u_char write_pre; /* write precompensation */
+ u_char head_load; /* head load delay */
+ u_char head_unload; /* head unload delay */
+ u_char pin_34_2; /* pin 34 (6) and pin 2 (7/11) definition */
+ u_char pin_4_1; /* pin 4 (8/9) and pin 1 (13) definition */
+ u_char reserved1;
+ u_char reserved2;
+ u_char reserved3;
+ u_char reserved4;
+ } flex_geometry;
};
#endif /* _SCSI_SCSI_DISK_H */
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index f715be74e6d..55cf4821a2f 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.14 1996/06/10 07:31:20 deraadt Exp $ */
+/* $OpenBSD: sd.c,v 1.15 1996/06/16 03:07:21 downsj Exp $ */
/* $NetBSD: sd.c,v 1.100.4.1 1996/06/04 23:14:08 thorpej Exp $ */
/*
@@ -901,10 +901,38 @@ sd_get_parms(sd, flags)
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);
+ } else {
+ /*
+ * do a "mode sense page 5"
+ */
+ scsi_cmd.opcode = MODE_SENSE;
+ scsi_cmd.page = 5;
+ scsi_cmd.length = 0x20;
+ 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 | SCSI_SILENT) == 0) {
+ dp->heads = scsi_sense.pages.flex_geometry.nheads;
+ dp->cyls =
+ scsi_sense.pages.flex_geometry.ncyl_1 * 256 +
+ scsi_sense.pages.flex_geometry.ncyl_0;
+ dp->blksize = _3btol(scsi_sense.blk_desc.blklen);
+ dp->sectors = scsi_sense.pages.flex_geometry.ph_sec_t;
+ dp->disksize = dp->heads * dp->cyls * dp->sectors;
+ if (dp->heads == 0 || dp->cyls == 0
+ || dp->sectors == 0) {
+ printf("%s: mode sense (5) returned nonsense",
+ sd->sc_dev.dv_xname);
+ goto fake_it;
+ }
+ if (dp->blksize == 0)
+ dp->blksize = 512;
+
+ return 0;
+ } else
+ printf("%s: could not mode sense (4/5)", sd->sc_dev.dv_xname);
+ }
fake_it:
/*