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.

Looked over by:	scottl
This commit is contained in:
Nate Lawson 2003-06-14 22:17:41 +00:00
parent 141bdcc15a
commit 2813692cc2
17 changed files with 19 additions and 305 deletions

View File

@ -1285,26 +1285,7 @@ scsi_low_scsi_action_cam(sim, ccb)
}
case XPT_CALC_GEOMETRY: { /* not yet HN2 */
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended;
extended = 1;
ccg = &ccb->ccg;
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, /*extended*/1);
xpt_done(ccb);
break;
}

View File

@ -431,26 +431,10 @@ adv_action(struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended;
ccg = &ccb->ccg;
size_mb = ccg->volume_size
/ ((1024L * 1024L) / ccg->block_size);
extended = (adv->control & ADV_CNTL_BIOS_GT_1GB) != 0;
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, extended);
xpt_done(ccb);
break;
}

View File

@ -724,30 +724,11 @@ adw_action(struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended;
/*
* XXX Use Adaptec translation until I find out how to
* get this information from the card.
*/
ccg = &ccb->ccg;
size_mb = ccg->volume_size
/ ((1024L * 1024L) / ccg->block_size);
extended = 1;
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, /*extended*/1);
xpt_done(ccb);
break;
}

View File

@ -1171,24 +1171,7 @@ ahbaction(struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
ccg = &ccb->ccg;
size_mb = ccg->volume_size
/ ((1024L * 1024L) / ccg->block_size);
if (size_mb > 1024 && (ahb->extended_trans != 0)) {
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, ahb->extended_trans);
xpt_done(ccb);
break;
}

View File

@ -254,25 +254,7 @@ aic_action(struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended = 0;
ccg = &ccb->ccg;
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, /*extended*/1);
xpt_done(ccb);
break;
}

View File

@ -550,26 +550,10 @@ ahd_action(struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
uint32_t size_mb;
uint32_t secs_per_cylinder;
int extended;
ccg = &ccb->ccg;
size_mb = ccg->volume_size
/ ((1024L * 1024L) / ccg->block_size);
extended = ahd->flags & AHD_EXTENDED_TRANS_A;
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, extended);
xpt_done(ccb);
break;
}

View File

@ -819,28 +819,12 @@ ahc_action(struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
uint32_t size_mb;
uint32_t secs_per_cylinder;
int extended;
ccg = &ccb->ccg;
size_mb = ccg->volume_size
/ ((1024L * 1024L) / ccg->block_size);
extended = SIM_IS_SCSIBUS_B(ahc, sim)
? ahc->flags & AHC_EXTENDED_TRANS_B
: ahc->flags & AHC_EXTENDED_TRANS_A;
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, extended);
xpt_done(ccb);
break;
}

View File

@ -680,25 +680,10 @@ amd_action(struct cam_sim * psim, union ccb * pccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended;
ccg = &pccb->ccg;
size_mb = ccg->volume_size/((1024L * 1024L)/ccg->block_size);
extended = (amd->eepromBuf[EE_MODE2] & GREATER_1G) != 0;
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;
pccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&pccb->ccg, extended);
xpt_done(pccb);
break;
}

View File

@ -265,22 +265,7 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb)
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg = &ccb->ccg;
u_int32_t size_in_mb;
u_int32_t secs_per_cylinder;
size_in_mb = ccg->volume_size / ((1024L * 1024L) / ccg->block_size);
if (size_in_mb > 1024) {
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, /*extended*/1);
break;
}

View File

@ -330,26 +330,8 @@ atapi_action(struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY: {
struct ccb_calc_geometry *ccg;
unsigned int size_mb;
unsigned int secs_per_cylinder;
int extended;
CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("CALC_GEOMETRY\n"));
ccg = &ccb->ccg;
size_mb = ccg->volume_size / ((1024L * 1024L) / ccg->block_size);
extended = 1;
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, /*extended*/1);
xpt_done(ccb);
return;
}

View File

@ -1034,30 +1034,11 @@ dpt_action(struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended;
/*
* XXX Use Adaptec translation until I find out how to
* get this information from the card.
*/
ccg = &ccb->ccg;
size_mb = ccg->volume_size
/ ((1024L * 1024L) / ccg->block_size);
extended = 1;
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, /*extended*/1);
xpt_done(ccb);
break;
}

View File

@ -2291,11 +2291,8 @@ printf("ORB %08x %08x %08x %08x\n", ntohl(ocb->orb[4]), ntohl(ocb->orb[5]), ntoh
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended = 1;
ccg = &ccb->ccg;
ccg = &ccb->ccg;
if (ccg->block_size == 0) {
printf("sbp_action1: block_size is 0.\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
@ -2318,19 +2315,7 @@ SBP_DEBUG(1)
ccg->volume_size);
END_DEBUG
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(ccg, /*extended*/1);
xpt_done(ccb);
break;
}

View File

@ -2532,8 +2532,6 @@ isp_action(struct cam_sim *sim, union ccb *ccb)
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t secs_per_cylinder;
u_int32_t size_mb;
ccg = &ccb->ccg;
if (ccg->block_size == 0) {
@ -2544,17 +2542,7 @@ isp_action(struct cam_sim *sim, union ccb *ccb)
xpt_done(ccb);
break;
}
size_mb = ccg->volume_size /((1024L * 1024L) / ccg->block_size);
if (size_mb > 1024) {
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(ccg, /*extended*/1);
xpt_done(ccb);
break;
}

View File

@ -1400,8 +1400,6 @@ mpt_action(struct cam_sim *sim, union ccb *ccb)
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t secs_per_cylinder;
u_int32_t size_mb;
ccg = &ccb->ccg;
if (ccg->block_size == 0) {
@ -1410,17 +1408,7 @@ mpt_action(struct cam_sim *sim, union ccb *ccb)
break;
}
size_mb = ccg->volume_size /((1024L * 1024L) / ccg->block_size);
if (size_mb > 1024) {
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(ccg, /*extended*/1);
xpt_done(ccb);
break;
}

View File

@ -8554,28 +8554,7 @@ static void sym_action2(struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u32 size_mb;
u32 secs_per_cylinder;
int extended;
/*
* Silly DOS geometry.
*/
ccg = &ccb->ccg;
size_mb = ccg->volume_size
/ ((1024L * 1024L) / ccg->block_size);
extended = 1;
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;
cam_calc_geometry(&ccb->ccg, /*extended*/1);
sym_xpt_done2(np, ccb, CAM_REQ_CMP);
break;
}

View File

@ -984,29 +984,10 @@ trm_action(struct cam_sim *psim, union ccb *pccb)
* Calculate the geometry parameters for a device give
* the sector size and volume size.
*/
case XPT_CALC_GEOMETRY: {
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended;
case XPT_CALC_GEOMETRY:
TRM_DPRINTF(" XPT_CALC_GEOMETRY \n");
ccg = &pccb->ccg;
size_mb = ccg->volume_size /
((1024L * 1024L) / ccg->block_size);
extended = 1;
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;
pccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&pccb->ccg, /*extended*/1);
xpt_done(pccb);
}
break;
case XPT_ENG_INQ:
TRM_DPRINTF(" XPT_ENG_INQ \n");

View File

@ -4334,30 +4334,11 @@ ncr_action (struct cam_sim *sim, union ccb *ccb)
}
case XPT_CALC_GEOMETRY:
{
struct ccb_calc_geometry *ccg;
u_int32_t size_mb;
u_int32_t secs_per_cylinder;
int extended;
/* XXX JGibbs - I'm sure the NCR uses a different strategy,
* but it should be able to deal with Adaptec
* geometry too.
*/
extended = 1;
ccg = &ccb->ccg;
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;
ccb->ccb_h.status = CAM_REQ_CMP;
cam_calc_geometry(&ccb->ccg, /*extended*/1);
xpt_done(ccb);
break;
}