auto_sense.c (5786:09923a2f905d) auto_sense.c (5790:4c57e157a3c5)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 987 unchanged lines hidden (view full) ---

996 page3->track_skew = BE_16(page3->track_skew);
997 page3->cylinder_skew = BE_16(page3->cylinder_skew);
998
999
1000 /*
1001 * Construct a new label out of the sense data,
1002 * Inquiry and Capacity.
1003 */
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 987 unchanged lines hidden (view full) ---

996 page3->track_skew = BE_16(page3->track_skew);
997 page3->cylinder_skew = BE_16(page3->cylinder_skew);
998
999
1000 /*
1001 * Construct a new label out of the sense data,
1002 * Inquiry and Capacity.
1003 */
1004 pcyl = (page4->cyl_ub << 16) + (page4->cyl_mb << 8) + page4->cyl_lb;
1004 pcyl = (page4->cyl_ub << 16) + (page4->cyl_mb << 8) +
1005 page4->cyl_lb;
1005 nhead = page4->heads;
1006 nsect = page3->sect_track;
1007 rpm = page4->rpm;
1008
1009 /*
1010 * If the number of physical cylinders reported is less
1011 * the SUN_MIN_CYL(3) then try to adjust the geometry so that
1012 * we have atleast SUN_MIN_CYL cylinders.
1013 */
1014 if (pcyl < SUN_MIN_CYL) {
1015 if (nhead <= 0 || nsect <= 0) {
1016 setdefault = 1;
1006 nhead = page4->heads;
1007 nsect = page3->sect_track;
1008 rpm = page4->rpm;
1009
1010 /*
1011 * If the number of physical cylinders reported is less
1012 * the SUN_MIN_CYL(3) then try to adjust the geometry so that
1013 * we have atleast SUN_MIN_CYL cylinders.
1014 */
1015 if (pcyl < SUN_MIN_CYL) {
1016 if (nhead <= 0 || nsect <= 0) {
1017 setdefault = 1;
1017 } else if (adjust_disk_geometry((int)(capacity->sc_capacity + 1),
1018 } else if (adjust_disk_geometry(
1019 (int)(capacity->sc_capacity + 1),
1018 &pcyl, &nhead, &nsect)) {
1019 setdefault = 1;
1020 }
1021 }
1022 }
1023
1024 if (setdefault == 1) {
1025 /*
1026 * If the number of cylinders or the number of heads reported
1027 * is zero, we think the inquiry of page 3 and page 4 failed.
1028 * We will set the geometry infomation by ourselves.
1029 */
1020 &pcyl, &nhead, &nsect)) {
1021 setdefault = 1;
1022 }
1023 }
1024 }
1025
1026 if (setdefault == 1) {
1027 /*
1028 * If the number of cylinders or the number of heads reported
1029 * is zero, we think the inquiry of page 3 and page 4 failed.
1030 * We will set the geometry infomation by ourselves.
1031 */
1030 err_print("\nThe device does not support mode page 3 or page 4,");
1032 err_print("\nThe device does not support mode page 3 "
1033 "or page 4,");
1031 err_print("\nor the reported geometry info is invalid.");
1034 err_print("\nor the reported geometry info is invalid.");
1032 err_print("\nWARNING: Disk geometry is based on capacity data.\n\n");
1035 err_print("\nWARNING: Disk geometry is based on "
1036 "capacity data.\n\n");
1033
1034 /* convert capacity to nsect * nhead * pcyl */
1035 /* Unlabeled SCSI floppy device */
1036 if (nblocks <= 0x1000) {
1037 nhead = 2;
1038 pcyl = 80;
1039 nsect = nblocks / (nhead * pcyl);
1040 } else {

--- 30 unchanged lines hidden (view full) ---

1071 }
1072
1073 /*
1074 * Some drives do not support page4 or report 0 for page4->rpm,
1075 * adjust it to AVG_RPM, 3600.
1076 */
1077 if (rpm < MIN_RPM || rpm > MAX_RPM) {
1078 err_print("The current rpm value %d is invalid,"
1037
1038 /* convert capacity to nsect * nhead * pcyl */
1039 /* Unlabeled SCSI floppy device */
1040 if (nblocks <= 0x1000) {
1041 nhead = 2;
1042 pcyl = 80;
1043 nsect = nblocks / (nhead * pcyl);
1044 } else {

--- 30 unchanged lines hidden (view full) ---

1075 }
1076
1077 /*
1078 * Some drives do not support page4 or report 0 for page4->rpm,
1079 * adjust it to AVG_RPM, 3600.
1080 */
1081 if (rpm < MIN_RPM || rpm > MAX_RPM) {
1082 err_print("The current rpm value %d is invalid,"
1079 " adjusting it to %d\n", rpm, AVG_RPM);
1083 " adjusting it to %d\n", rpm, AVG_RPM);
1080 rpm = AVG_RPM;
1081 }
1082
1083 /*
1084 * Some drives report 0 for nsect (page 3, byte 10 and 11) if they
1085 * have variable number of sectors per track. So adjust nsect.
1086 * Also the value is defined as vendor specific, hence check if
1087 * it is in a tolerable range. The values (32 and 4 below) are

--- 1134 unchanged lines hidden (view full) ---

2222
2223 assert(lcyl < SUN_MIN_CYL);
2224
2225 /*
2226 * reduce nsect by 2 for each iteration and re-calculate
2227 * the number of cylinders.
2228 */
2229 while (lnsect > MINIMUM_NO_SECTORS &&
1084 rpm = AVG_RPM;
1085 }
1086
1087 /*
1088 * Some drives report 0 for nsect (page 3, byte 10 and 11) if they
1089 * have variable number of sectors per track. So adjust nsect.
1090 * Also the value is defined as vendor specific, hence check if
1091 * it is in a tolerable range. The values (32 and 4 below) are

--- 1134 unchanged lines hidden (view full) ---

2226
2227 assert(lcyl < SUN_MIN_CYL);
2228
2229 /*
2230 * reduce nsect by 2 for each iteration and re-calculate
2231 * the number of cylinders.
2232 */
2233 while (lnsect > MINIMUM_NO_SECTORS &&
2230 lcyl < MINIMUM_NO_CYLINDERS) {
2234 lcyl < MINIMUM_NO_CYLINDERS) {
2231 /*
2232 * make sure that we do not go below MINIMUM_NO_SECTORS.
2233 */
2234 lnsect = max(MINIMUM_NO_SECTORS, lnsect / 2);
2235 lcyl = (capacity) / (lnhead * lnsect);
2236 }
2237 /*
2238 * If the geometry still does not satisfy
2239 * MINIMUM_NO_CYLINDERS then try to reduce the
2240 * no of heads.
2241 */
2242 while (lnhead > MINIMUM_NO_HEADS &&
2235 /*
2236 * make sure that we do not go below MINIMUM_NO_SECTORS.
2237 */
2238 lnsect = max(MINIMUM_NO_SECTORS, lnsect / 2);
2239 lcyl = (capacity) / (lnhead * lnsect);
2240 }
2241 /*
2242 * If the geometry still does not satisfy
2243 * MINIMUM_NO_CYLINDERS then try to reduce the
2244 * no of heads.
2245 */
2246 while (lnhead > MINIMUM_NO_HEADS &&
2243 lcyl < MINIMUM_NO_CYLINDERS) {
2247 lcyl < MINIMUM_NO_CYLINDERS) {
2244 lnhead = max(MINIMUM_NO_HEADS, lnhead / 2);
2245 lcyl = (capacity) / (lnhead * lnsect);
2246 }
2247 /*
2248 * now we should have atleast SUN_MIN_CYL cylinders.
2249 * If we still do not get SUN_MIN_CYL with MINIMUM_NO_HEADS
2250 * and MINIMUM_NO_HEADS then return error.
2251 */

--- 94 unchanged lines hidden ---
2248 lnhead = max(MINIMUM_NO_HEADS, lnhead / 2);
2249 lcyl = (capacity) / (lnhead * lnsect);
2250 }
2251 /*
2252 * now we should have atleast SUN_MIN_CYL cylinders.
2253 * If we still do not get SUN_MIN_CYL with MINIMUM_NO_HEADS
2254 * and MINIMUM_NO_HEADS then return error.
2255 */

--- 94 unchanged lines hidden ---