From c996d2bc71caff69a3408e5c791bdc847b1ab875 Mon Sep 17 00:00:00 2001 From: njl Date: Sat, 14 Jun 2003 22:17:38 +0000 Subject: [PATCH] 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: --- sys/cam/cam.c | 25 +++++++++++++++++++++++++ sys/cam/cam_ccb.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/sys/cam/cam.c b/sys/cam/cam.c index 0c76d9614f2d..b84132d2fcfd 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 1df01cef7343..62adfe649546 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 */