summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2003-06-14 22:17:38 +0000
committernjl <njl@FreeBSD.org>2003-06-14 22:17:38 +0000
commitb184633199beba93ad13f46cf12a67fbaa20ad06 (patch)
tree5752708c01d3bc91355e1bfb4660548fdad1e887
parent9dc1a1166f0a73431cabc077b5f45d5042a753c1 (diff)
downloadFreeBSD-src-b184633199beba93ad13f46cf12a67fbaa20ad06.zip
FreeBSD-src-b184633199beba93ad13f46cf12a67fbaa20ad06.tar.gz
Merge common XPT_CALC_GEOMETRY functions into a single convenience function.
Devices below may experience a change in geometry. * Due to a bug, aic(4) never used extended geometry. Changes all drives >1G to now use extended translation. * sbp(4) drives exactly 1 GB in size now no longer use extended geometry. * umass(4) drives exactly 1 GB in size now no longer use extended geometry. For all other controllers in this commit, this should be a no-op. PR: Submitted by: Looked over by: scottl Approved by: Obtained from: MFC after:
-rw-r--r--sys/cam/cam.c25
-rw-r--r--sys/cam/cam_ccb.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/sys/cam/cam.c b/sys/cam/cam.c
index 0c76d96..b84132d 100644
--- a/sys/cam/cam.c
+++ b/sys/cam/cam.c
@@ -360,3 +360,28 @@ cam_error_print(struct cam_device *device, union ccb *ccb,
}
#endif /* _KERNEL/!_KERNEL */
+
+/*
+ * Common calculate geometry fuction
+ *
+ * Caller should set ccg->volume_size and block_size.
+ * The extended parameter should be zero if extended translation
+ * should not be used.
+ */
+void
+cam_calc_geometry(struct ccb_calc_geometry *ccg, int extended)
+{
+ uint32_t size_mb, secs_per_cylinder;
+
+ size_mb = ccg->volume_size / ((1024L * 1024L) / ccg->block_size);
+ if (size_mb > 1024 && extended) {
+ ccg->heads = 255;
+ ccg->secs_per_track = 63;
+ } else {
+ ccg->heads = 64;
+ ccg->secs_per_track = 32;
+ }
+ secs_per_cylinder = ccg->heads * ccg->secs_per_track;
+ ccg->cylinders = ccg->volume_size / secs_per_cylinder;
+ ccg->ccb_h.status = CAM_REQ_CMP;
+}
diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h
index 1df01ce..62adfe6 100644
--- a/sys/cam/cam_ccb.h
+++ b/sys/cam/cam_ccb.h
@@ -979,6 +979,8 @@ cam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries,
csio->init_id = init_id;
}
+void cam_calc_geometry(struct ccb_calc_geometry *ccg, int extended);
+
__END_DECLS
#endif /* _CAM_CAM_CCB_H */
OpenPOWER on IntegriCloud