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 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* 27 * This file contains functions to prompt the user for various 28 * disk characteristics. By isolating these into functions, 29 * we can guarantee that prompts, defaults, etc are identical. 30 */ 31 #include "global.h" 32 #include "prompts.h" 33 #include "io.h" 34 #include "param.h" 35 #include "startup.h" 36 37 #ifdef sparc 38 #include <sys/hdio.h> 39 #endif 40 41 42 /* 43 * Prompt for max number of LBA 44 */ 45 uint64_t 46 get_mlba(void) 47 { 48 u_ioparam_t ioparam; 49 50 ioparam.io_bounds.lower = (1024 * 16) + 68; 51 ioparam.io_bounds.upper = UINT_MAX64; 52 53 return (input(FIO_INT64, "Enter maximum number of LBAs", 54 ':', &ioparam, NULL, DATA_INPUT)); 55 } 56 57 /* 58 * Prompt for number of cylinders 59 */ 60 int 61 get_ncyl(void) 62 { 63 u_ioparam_t ioparam; 64 65 ioparam.io_bounds.lower = 1; 66 ioparam.io_bounds.upper = MAX_CYLS - 2; 67 return (input(FIO_INT, "Enter number of data cylinders", 68 ':', &ioparam, NULL, DATA_INPUT)); 69 } 70 71 /* 72 * Prompt for number of alternate cylinders 73 */ 74 int 75 get_acyl(int n_cyls) 76 { 77 u_ioparam_t ioparam; 78 int deflt; 79 80 ioparam.io_bounds.lower = 2; 81 /* n_cyls is at least 1, see get_ncyl() above. */ 82 if (n_cyls >= 1 && MAX_CYLS - n_cyls >= 2) 83 ioparam.io_bounds.upper = MAX_CYLS - n_cyls; 84 else 85 ioparam.io_bounds.upper = 2; 86 deflt = 2; 87 return (input(FIO_INT, "Enter number of alternate cylinders", ':', 88 &ioparam, &deflt, DATA_INPUT)); 89 } 90 91 /* 92 * Prompt for number of physical cylinders 93 */ 94 int 95 get_pcyl(int n_cyls, int a_cyls) 96 { 97 u_ioparam_t ioparam; 98 int deflt; 99 100 ioparam.io_bounds.lower = n_cyls + a_cyls; 101 ioparam.io_bounds.upper = MAX_CYLS; 102 deflt = n_cyls + a_cyls; 103 return (input(FIO_INT, "Enter number of physical cylinders", ':', 104 &ioparam, &deflt, DATA_INPUT)); 105 } 106 107 /* 108 * Prompt for number of heads 109 */ 110 int 111 get_nhead(void) 112 { 113 u_ioparam_t ioparam; 114 115 ioparam.io_bounds.lower = 1; 116 ioparam.io_bounds.upper = MAX_HEADS; 117 return (input(FIO_INT, "Enter number of heads", ':', 118 &ioparam, NULL, DATA_INPUT)); 119 } 120 121 /* 122 * Prompt for number of physical heads 123 */ 124 int 125 get_phead(int n_heads, ulong_t *options) 126 { 127 u_ioparam_t ioparam; 128 int deflt; 129 130 if (SCSI) { 131 ioparam.io_bounds.lower = n_heads; 132 ioparam.io_bounds.upper = INFINITY; 133 if (input(FIO_OPINT, "Enter physical number of heads", 134 ':', &ioparam, &deflt, DATA_INPUT)) { 135 *options |= SUP_PHEAD; 136 return (deflt); 137 } 138 } 139 return (0); 140 } 141 142 143 /* 144 * Prompt for number of sectors per track 145 */ 146 int 147 get_nsect(void) 148 { 149 u_ioparam_t ioparam; 150 151 ioparam.io_bounds.lower = 1; 152 ioparam.io_bounds.upper = MAX_SECTS; 153 return (input(FIO_INT, 154 "Enter number of data sectors/track", ':', 155 &ioparam, NULL, DATA_INPUT)); 156 } 157 158 /* 159 * Prompt for number of physical sectors per track 160 */ 161 int 162 get_psect(ulong_t *options) 163 { 164 u_ioparam_t ioparam; 165 int deflt; 166 167 if (SCSI) { 168 ioparam.io_bounds.lower = 0; 169 ioparam.io_bounds.upper = INFINITY; 170 if (input(FIO_OPINT, "Enter number of physical sectors/track", 171 ':', &ioparam, &deflt, DATA_INPUT)) { 172 *options |= SUP_PSECT; 173 return (deflt); 174 } 175 } 176 return (0); 177 } 178 179 /* 180 * Prompt for bytes per track 181 */ 182 int 183 get_bpt(int n_sects, ulong_t *options) 184 { 185 u_ioparam_t ioparam; 186 int deflt; 187 188 if (SMD) { 189 *options |= SUP_BPT; 190 ioparam.io_bounds.lower = 1; 191 ioparam.io_bounds.upper = INFINITY; 192 deflt = n_sects * cur_blksz; 193 return (input(FIO_INT, "Enter number of bytes/track", 194 ':', &ioparam, &deflt, DATA_INPUT)); 195 } 196 197 return (0); 198 } 199 200 /* 201 * Prompt for rpm 202 */ 203 int 204 get_rpm(void) 205 { 206 u_ioparam_t ioparam; 207 int deflt; 208 209 ioparam.io_bounds.lower = MIN_RPM; 210 ioparam.io_bounds.upper = MAX_RPM; 211 deflt = AVG_RPM; 212 return (input(FIO_INT, "Enter rpm of drive", ':', 213 &ioparam, &deflt, DATA_INPUT)); 214 } 215 216 /* 217 * Prompt for formatting time 218 */ 219 int 220 get_fmt_time(ulong_t *options) 221 { 222 u_ioparam_t ioparam; 223 int deflt; 224 225 ioparam.io_bounds.lower = 0; 226 ioparam.io_bounds.upper = INFINITY; 227 if (input(FIO_OPINT, "Enter format time", ':', 228 &ioparam, &deflt, DATA_INPUT)) { 229 *options |= SUP_FMTTIME; 230 return (deflt); 231 } 232 return (0); 233 } 234 235 /* 236 * Prompt for cylinder skew 237 */ 238 int 239 get_cyl_skew(ulong_t *options) 240 { 241 u_ioparam_t ioparam; 242 int deflt; 243 244 ioparam.io_bounds.lower = 0; 245 ioparam.io_bounds.upper = INFINITY; 246 if (input(FIO_OPINT, "Enter cylinder skew", ':', 247 &ioparam, &deflt, DATA_INPUT)) { 248 *options |= SUP_CYLSKEW; 249 return (deflt); 250 } 251 return (0); 252 } 253 254 /* 255 * Prompt for track skew 256 */ 257 int 258 get_trk_skew(ulong_t *options) 259 { 260 u_ioparam_t ioparam; 261 int deflt; 262 263 ioparam.io_bounds.lower = 0; 264 ioparam.io_bounds.upper = INFINITY; 265 if (input(FIO_OPINT, "Enter track skew", ':', 266 &ioparam, &deflt, DATA_INPUT)) { 267 *options |= SUP_TRKSKEW; 268 return (deflt); 269 } 270 return (0); 271 } 272 273 /* 274 * Prompt for tracks per zone 275 */ 276 int 277 get_trks_zone(ulong_t *options) 278 { 279 u_ioparam_t ioparam; 280 int deflt; 281 282 ioparam.io_bounds.lower = 0; 283 ioparam.io_bounds.upper = INFINITY; 284 if (input(FIO_OPINT, "Enter tracks per zone", ':', 285 &ioparam, &deflt, DATA_INPUT)) { 286 *options |= SUP_TRKS_ZONE; 287 return (deflt); 288 } 289 return (0); 290 } 291 292 /* 293 * Prompt for alternate tracks 294 */ 295 int 296 get_atrks(ulong_t *options) 297 { 298 u_ioparam_t ioparam; 299 int deflt; 300 301 ioparam.io_bounds.lower = 0; 302 ioparam.io_bounds.upper = INFINITY; 303 if (input(FIO_OPINT, "Enter alternate tracks", ':', 304 &ioparam, &deflt, DATA_INPUT)) { 305 *options |= SUP_ATRKS; 306 return (deflt); 307 } 308 return (0); 309 } 310 311 /* 312 * Prompt for alternate sectors 313 */ 314 int 315 get_asect(ulong_t *options) 316 { 317 u_ioparam_t ioparam; 318 int deflt; 319 320 ioparam.io_bounds.lower = 0; 321 ioparam.io_bounds.upper = INFINITY; 322 if (input(FIO_OPINT, "Enter alternate sectors", ':', 323 &ioparam, &deflt, DATA_INPUT)) { 324 *options |= SUP_ASECT; 325 return (deflt); 326 } 327 return (0); 328 } 329 330 /* 331 * Prompt for cache setting 332 */ 333 int 334 get_cache(ulong_t *options) 335 { 336 u_ioparam_t ioparam; 337 int deflt; 338 339 ioparam.io_bounds.lower = 0; 340 ioparam.io_bounds.upper = 0xff; 341 if (input(FIO_OPINT, "Enter cache control", ':', 342 &ioparam, &deflt, DATA_INPUT)) { 343 *options |= SUP_CACHE; 344 return (deflt); 345 } 346 return (0); 347 } 348 349 /* 350 * Prompt for prefetch threshold 351 */ 352 int 353 get_threshold(ulong_t *options) 354 { 355 u_ioparam_t ioparam; 356 int deflt; 357 358 ioparam.io_bounds.lower = 0; 359 ioparam.io_bounds.upper = INFINITY; 360 if (input(FIO_OPINT, "Enter prefetch threshold", 361 ':', &ioparam, &deflt, DATA_INPUT)) { 362 *options |= SUP_PREFETCH; 363 return (deflt); 364 } 365 return (0); 366 } 367 368 /* 369 * Prompt for minimum prefetch 370 */ 371 int 372 get_min_prefetch(ulong_t *options) 373 { 374 u_ioparam_t ioparam; 375 int deflt; 376 377 ioparam.io_bounds.lower = 0; 378 ioparam.io_bounds.upper = INFINITY; 379 if (input(FIO_OPINT, "Enter minimum prefetch", 380 ':', &ioparam, &deflt, DATA_INPUT)) { 381 *options |= SUP_CACHE_MIN; 382 return (deflt); 383 } 384 return (0); 385 } 386 387 /* 388 * Prompt for maximum prefetch 389 */ 390 int 391 get_max_prefetch(int min_prefetch, ulong_t *options) 392 { 393 u_ioparam_t ioparam; 394 int deflt; 395 396 ioparam.io_bounds.lower = min_prefetch; 397 ioparam.io_bounds.upper = INFINITY; 398 if (input(FIO_OPINT, "Enter maximum prefetch", 399 ':', &ioparam, &deflt, DATA_INPUT)) { 400 *options |= SUP_CACHE_MAX; 401 return (deflt); 402 } 403 return (0); 404 } 405 406 /* 407 * Prompt for bytes per sector 408 */ 409 int 410 get_bps(void) 411 { 412 u_ioparam_t ioparam; 413 int deflt; 414 415 if (cur_ctype->ctype_flags & CF_SMD_DEFS) { 416 ioparam.io_bounds.lower = MIN_BPS; 417 ioparam.io_bounds.upper = MAX_BPS; 418 deflt = AVG_BPS; 419 return (input(FIO_INT, "Enter bytes per sector", 420 ':', &ioparam, &deflt, DATA_INPUT)); 421 } 422 423 return (0); 424 } 425 426 /* 427 * Prompt for ascii label 428 */ 429 char * 430 get_asciilabel(void) 431 { 432 return ((char *)(uintptr_t)input(FIO_OSTR, 433 "Enter disk type name (remember quotes)", ':', 434 NULL, NULL, DATA_INPUT)); 435 } 436