summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-08-12 01:49:09 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-08-12 01:49:09 +0000
commit4141c81d91c42e46104b22fc24587be05da5913b (patch)
treea78847536993008f8cfae3e402fead2195517a14 /sys/scsi
parent18d690b08f718bff60fbcea9c54e539f99ec44a1 (diff)
Move disk mode page structure declarations out of scsi_disk_pages
union declaration to allow pointers to individual page types. Simplify sd.c code by using individual page type pointers. No functional change. ok tdeval@
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/scsi_disk.h153
-rw-r--r--sys/scsi/sd.c54
2 files changed, 106 insertions, 101 deletions
diff --git a/sys/scsi/scsi_disk.h b/sys/scsi/scsi_disk.h
index 35cc6b2e0da..74484649c1b 100644
--- a/sys/scsi/scsi_disk.h
+++ b/sys/scsi/scsi_disk.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_disk.h,v 1.16 2005/07/03 04:03:25 krw Exp $ */
+/* $OpenBSD: scsi_disk.h,v 1.17 2005/08/12 01:49:08 krw Exp $ */
/* $NetBSD: scsi_disk.h,v 1.10 1996/07/05 16:19:05 christos Exp $ */
/*
@@ -236,93 +236,102 @@ struct scsi_reassign_blocks_data {
} defect_descriptor[1];
};
-union scsi_disk_pages {
-#define DISK_PGCODE 0x3F /* only 6 bits valid */
- struct page_disk_format {
- u_int8_t pg_code; /* page code (should be 3) */
- u_int8_t pg_length; /* page length (should be 0x16) */
- u_int8_t trk_z[2]; /* tracks per zone */
- u_int8_t alt_sec[2]; /* alternate sectors per zone */
- u_int8_t alt_trk_z[2]; /* alternate tracks per zone */
- u_int8_t alt_trk_v[2]; /* alternate tracks per volume */
- u_int8_t ph_sec_t[2]; /* physical sectors per track */
- u_int8_t bytes_s[2]; /* bytes per sector */
- u_int8_t interleave[2]; /* interleave */
- u_int8_t trk_skew[2]; /* track skew factor */
- u_int8_t cyl_skew[2]; /* cylinder skew */
- u_int8_t flags; /* various */
+#define DISK_PGCODE 0x3F /* Only 6 bits of pg_code are valid. */
+
+struct page_disk_format {
+ u_int8_t pg_code; /* page code (should be 3) */
+ u_int8_t pg_length; /* page length (should be 0x16) */
+ u_int8_t trk_z[2]; /* tracks per zone */
+ u_int8_t alt_sec[2]; /* alternate sectors per zone */
+ u_int8_t alt_trk_z[2]; /* alternate tracks per zone */
+ u_int8_t alt_trk_v[2]; /* alternate tracks per volume */
+ u_int8_t ph_sec_t[2]; /* physical sectors per track */
+ u_int8_t bytes_s[2]; /* bytes per sector */
+ u_int8_t interleave[2]; /* interleave */
+ u_int8_t trk_skew[2]; /* track skew factor */
+ u_int8_t cyl_skew[2]; /* cylinder skew */
+ u_int8_t flags; /* various */
#define DISK_FMT_SURF 0x10
#define DISK_FMT_RMB 0x20
#define DISK_FMT_HSEC 0x40
#define DISK_FMT_SSEC 0x80
- u_int8_t reserved1;
- u_int8_t reserved2;
- u_int8_t reserved3;
- } disk_format;
- struct page_rigid_geometry {
- u_int8_t pg_code; /* page code (should be 4) */
- u_int8_t pg_length; /* page length (should be 0x16) */
- u_int8_t ncyl[3]; /* number of cylinders */
- u_int8_t nheads; /* number of heads */
- u_int8_t st_cyl_wp[3]; /* starting cyl., write precomp */
- u_int8_t st_cyl_rwc[3]; /* starting cyl., red. write cur */
- u_int8_t driv_step[2]; /* drive step rate */
- u_int8_t land_zone[3]; /* landing zone cylinder */
- u_int8_t sp_sync_ctl; /* spindle synch control */
+ u_int8_t reserved1;
+ u_int8_t reserved2;
+ u_int8_t reserved3;
+};
+
+struct page_rigid_geometry {
+ u_int8_t pg_code; /* page code (should be 4) */
+ u_int8_t pg_length; /* page length (should be 0x16) */
+ u_int8_t ncyl[3]; /* number of cylinders */
+ u_int8_t nheads; /* number of heads */
+ u_int8_t st_cyl_wp[3]; /* starting cyl., write precomp */
+ u_int8_t st_cyl_rwc[3]; /* starting cyl., red. write cur */
+ u_int8_t driv_step[2]; /* drive step rate */
+ u_int8_t land_zone[3]; /* landing zone cylinder */
+ u_int8_t sp_sync_ctl; /* spindle synch control */
#define SPINDLE_SYNCH_MASK 0x03 /* mask of valid bits */
#define SPINDLE_SYNCH_NONE 0x00 /* synch disabled or not supported */
#define SPINDLE_SYNCH_SLAVE 0x01 /* disk is a slave */
#define SPINDLE_SYNCH_MASTER 0x02 /* disk is a master */
#define SPINDLE_SYNCH_MCONTROL 0x03 /* disk is a master control */
- u_int8_t rot_offset; /* rotational offset (for spindle synch) */
- u_int8_t reserved1;
- u_int8_t rpm[2]; /* media rotation speed */
- u_int8_t reserved2;
- u_int8_t reserved3;
- } rigid_geometry;
- struct page_flex_geometry {
- u_int8_t pg_code; /* page code (should be 5) */
- u_int8_t pg_length; /* page length (should be 0x1e) */
- u_int8_t xfr_rate[2];
- u_int8_t nheads; /* number of heads */
- u_int8_t ph_sec_tr; /* physical sectors per track */
- u_int8_t bytes_s[2]; /* bytes per sector */
- u_int8_t ncyl[2]; /* number of cylinders */
- u_int8_t st_cyl_wp[2]; /* start cyl., write precomp */
- u_int8_t st_cyl_rwc[2]; /* start cyl., red. write cur */
- u_int8_t driv_step[2]; /* drive step rate */
- u_int8_t driv_step_w; /* drive step pulse width */
- u_int8_t head_settle[2];/* head settle delay */
- u_int8_t motor_on; /* motor on delay */
- u_int8_t motor_off; /* motor off delay */
- u_int8_t flags; /* various flags */
+ u_int8_t rot_offset; /* rotational offset (for spindle synch) */
+ u_int8_t reserved1;
+ u_int8_t rpm[2]; /* media rotation speed */
+ u_int8_t reserved2;
+ u_int8_t reserved3;
+};
+
+struct page_flex_geometry {
+ u_int8_t pg_code; /* page code (should be 5) */
+ u_int8_t pg_length; /* page length (should be 0x1e) */
+ u_int8_t xfr_rate[2];
+ u_int8_t nheads; /* number of heads */
+ u_int8_t ph_sec_tr; /* physical sectors per track */
+ u_int8_t bytes_s[2]; /* bytes per sector */
+ u_int8_t ncyl[2]; /* number of cylinders */
+ u_int8_t st_cyl_wp[2]; /* start cyl., write precomp */
+ u_int8_t st_cyl_rwc[2]; /* start cyl., red. write cur */
+ u_int8_t driv_step[2]; /* drive step rate */
+ u_int8_t driv_step_w; /* drive step pulse width */
+ u_int8_t head_settle[2];/* head settle delay */
+ u_int8_t motor_on; /* motor on delay */
+ u_int8_t motor_off; /* motor off delay */
+ u_int8_t flags; /* various flags */
#define MOTOR_ON 0x20 /* motor on (pin 16)? */
#define START_AT_SECTOR_1 0x40 /* start at sector 1 */
#define READY_VALID 0x20 /* RDY (pin 34) valid */
- u_int8_t step_p_cyl; /* step pulses per cylinder */
- u_int8_t write_pre; /* write precompensation */
- u_int8_t head_load; /* head load delay */
- u_int8_t head_unload; /* head unload delay */
- u_int8_t pin_34_2; /* pin 34 (6) pin 2 (7/11) definition */
- u_int8_t pin_4_1; /* pin 4 (8/9) pin 1 (13) definition */
- u_int8_t rpm[2]; /* media rotation speed */
- u_int8_t reserved1;
- u_int8_t reserved2;
- } 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 */
+ u_int8_t step_p_cyl; /* step pulses per cylinder */
+ u_int8_t write_pre; /* write precompensation */
+ u_int8_t head_load; /* head load delay */
+ u_int8_t head_unload; /* head unload delay */
+ u_int8_t pin_34_2; /* pin 34 (6) pin 2 (7/11) definition */
+ u_int8_t pin_4_1; /* pin 4 (8/9) pin 1 (13) definition */
+ u_int8_t rpm[2]; /* media rotation speed */
+ u_int8_t reserved1;
+ u_int8_t reserved2;
+};
+
+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;
+ u_int8_t reserved;
+};
+
+union scsi_disk_pages {
+ struct page_disk_format disk_format;
+ struct page_rigid_geometry rigid_geometry;
+ struct page_flex_geometry flex_geometry;
+ struct page_reduced_geometry reduced_geometry;
};
#endif /* _SCSI_SCSI_DISK_H */
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index becd6f1ae38..d5d39dba48f 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.82 2005/07/30 15:54:45 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.83 2005/08/12 01:49:08 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -1331,7 +1331,9 @@ sd_get_parms(sd, dp, flags)
int flags;
{
struct scsi_mode_sense_buf buf;
- union scsi_disk_pages *sense_pages;
+ struct page_rigid_geometry *rigid;
+ struct page_flex_geometry *flex;
+ struct page_reduced_geometry *reduced;
u_int32_t heads = 0, sectors = 0, cyls = 0, blksize, ssblksize;
u_int16_t rpm = 0;
@@ -1344,48 +1346,43 @@ sd_get_parms(sd, dp, flags)
case T_RDIRECT:
/* T_RDIRECT only supports RBC Device Parameter Page (6). */
- scsi_do_mode_sense(sd->sc_link, 6, &buf, (void **)&sense_pages,
- NULL, NULL, &blksize, sizeof(sense_pages->reduced_geometry),
- flags | SCSI_SILENT, NULL);
- if (sense_pages) {
+ scsi_do_mode_sense(sd->sc_link, 6, &buf, (void **)&reduced,
+ NULL, NULL, &blksize, sizeof(*reduced), flags | SCSI_SILENT,
+ NULL);
+ if (reduced) {
if (dp->disksize == 0)
- dp->disksize = _5btol(sense_pages->
- reduced_geometry.sectors);
+ dp->disksize = _5btol(reduced->sectors);
if (blksize == 0)
- blksize = _2btol(sense_pages->
- reduced_geometry.bytes_s);
+ blksize = _2btol(reduced->bytes_s);
}
break;
default:
- sense_pages = NULL;
+ rigid = NULL;
if (((sd->sc_link->flags & SDEV_ATAPI) == 0) ||
((sd->sc_link->flags & SDEV_REMOVABLE) == 0))
/* Try mode sense page 4 (RIGID GEOMETRY). */
scsi_do_mode_sense(sd->sc_link, 4, &buf,
- (void **)&sense_pages, NULL, NULL, &blksize,
- sizeof(sense_pages->rigid_geometry),
- flags | SCSI_SILENT, NULL);
- if (sense_pages) {
- heads = sense_pages->rigid_geometry.nheads;
- cyls = _3btol(sense_pages->rigid_geometry.ncyl);
- rpm = _2btol(sense_pages->rigid_geometry.rpm);
+ (void **)&rigid, NULL, NULL, &blksize,
+ sizeof(*rigid), flags | SCSI_SILENT, NULL);
+ if (rigid) {
+ heads = rigid->nheads;
+ cyls = _3btol(rigid->ncyl);
+ rpm = _2btol(rigid->rpm);
if (heads * cyls > 0)
sectors = dp->disksize / (heads * cyls);
} else {
/* * Try page 5 (FLEX GEOMETRY). */
- scsi_do_mode_sense(sd->sc_link, 5, &buf,
- (void **)&sense_pages, NULL, NULL, &blksize,
- sizeof(sense_pages->flex_geometry),
+ scsi_do_mode_sense(sd->sc_link, 5, &buf, (void **)&flex,
+ NULL, NULL, &blksize, sizeof(*flex),
flags | SCSI_SILENT, NULL);
- if (sense_pages) {
- sectors = sense_pages->flex_geometry.ph_sec_tr;
- heads = sense_pages->flex_geometry.nheads;
- cyls = _2btol(sense_pages->flex_geometry.ncyl);
- rpm = _2btol(sense_pages->flex_geometry.rpm);
+ if (flex) {
+ sectors = flex->ph_sec_tr;
+ heads = flex->nheads;
+ cyls = _2btol(flex->ncyl);
+ rpm = _2btol(flex->rpm);
if (blksize == 0)
- blksize = _2btol(sense_pages->
- flex_geometry.bytes_s);
+ blksize = _2btol(flex->bytes_s);
if (dp->disksize == 0)
dp->disksize = heads * cyls * sectors;
}
@@ -1400,7 +1397,6 @@ sd_get_parms(sd, dp, flags)
else
dp->blksize = (blksize == 0) ? 512 : blksize;
-
/*
* Use Adaptec standard geometry values for anything we still don't
* know.