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
get_mlba(void)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
get_ncyl(void)61 get_ncyl(void)
62 {
63 u_ioparam_t ioparam;
64
65 ioparam.io_bounds.lower = 1;
66 ioparam.io_bounds.upper = MAX_CYLS;
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
get_acyl(int n_cyls)75 get_acyl(int n_cyls)
76 {
77 u_ioparam_t ioparam;
78 int deflt;
79
80 ioparam.io_bounds.lower = 2;
81 ioparam.io_bounds.upper = MAX_CYLS - n_cyls;
82 deflt = 2;
83 return (input(FIO_INT, "Enter number of alternate cylinders", ':',
84 &ioparam, &deflt, DATA_INPUT));
85 }
86
87 /*
88 * Prompt for number of physical cylinders
89 */
90 int
get_pcyl(int n_cyls,int a_cyls)91 get_pcyl(int n_cyls, int a_cyls)
92 {
93 u_ioparam_t ioparam;
94 int deflt;
95
96 ioparam.io_bounds.lower = n_cyls + a_cyls;
97 ioparam.io_bounds.upper = MAX_CYLS;
98 deflt = n_cyls + a_cyls;
99 return (input(FIO_INT, "Enter number of physical cylinders", ':',
100 &ioparam, &deflt, DATA_INPUT));
101 }
102
103 /*
104 * Prompt for number of heads
105 */
106 int
get_nhead(void)107 get_nhead(void)
108 {
109 u_ioparam_t ioparam;
110
111 ioparam.io_bounds.lower = 1;
112 ioparam.io_bounds.upper = MAX_HEADS;
113 return (input(FIO_INT, "Enter number of heads", ':',
114 &ioparam, NULL, DATA_INPUT));
115 }
116
117 /*
118 * Prompt for number of physical heads
119 */
120 int
get_phead(int n_heads,ulong_t * options)121 get_phead(int n_heads, ulong_t *options)
122 {
123 u_ioparam_t ioparam;
124 int deflt;
125
126 if (SCSI) {
127 ioparam.io_bounds.lower = n_heads;
128 ioparam.io_bounds.upper = INFINITY;
129 if (input(FIO_OPINT, "Enter physical number of heads",
130 ':', &ioparam, &deflt, DATA_INPUT)) {
131 *options |= SUP_PHEAD;
132 return (deflt);
133 }
134 }
135 return (0);
136 }
137
138
139 /*
140 * Prompt for number of sectors per track
141 */
142 int
get_nsect(void)143 get_nsect(void)
144 {
145 u_ioparam_t ioparam;
146
147 ioparam.io_bounds.lower = 1;
148 ioparam.io_bounds.upper = MAX_SECTS;
149 return (input(FIO_INT,
150 "Enter number of data sectors/track", ':',
151 &ioparam, NULL, DATA_INPUT));
152 }
153
154 /*
155 * Prompt for number of physical sectors per track
156 */
157 int
get_psect(ulong_t * options)158 get_psect(ulong_t *options)
159 {
160 u_ioparam_t ioparam;
161 int deflt;
162
163 if (SCSI) {
164 ioparam.io_bounds.lower = 0;
165 ioparam.io_bounds.upper = INFINITY;
166 if (input(FIO_OPINT, "Enter number of physical sectors/track",
167 ':', &ioparam, &deflt, DATA_INPUT)) {
168 *options |= SUP_PSECT;
169 return (deflt);
170 }
171 }
172 return (0);
173 }
174
175 /*
176 * Prompt for bytes per track
177 */
178 int
get_bpt(int n_sects,ulong_t * options)179 get_bpt(int n_sects, ulong_t *options)
180 {
181 u_ioparam_t ioparam;
182 int deflt;
183
184 if (SMD) {
185 *options |= SUP_BPT;
186 ioparam.io_bounds.lower = 1;
187 ioparam.io_bounds.upper = INFINITY;
188 deflt = n_sects * cur_blksz;
189 return (input(FIO_INT, "Enter number of bytes/track",
190 ':', &ioparam, &deflt, DATA_INPUT));
191 }
192
193 return (0);
194 }
195
196 /*
197 * Prompt for rpm
198 */
199 int
get_rpm(void)200 get_rpm(void)
201 {
202 u_ioparam_t ioparam;
203 int deflt;
204
205 ioparam.io_bounds.lower = MIN_RPM;
206 ioparam.io_bounds.upper = MAX_RPM;
207 deflt = AVG_RPM;
208 return (input(FIO_INT, "Enter rpm of drive", ':',
209 &ioparam, &deflt, DATA_INPUT));
210 }
211
212 /*
213 * Prompt for formatting time
214 */
215 int
get_fmt_time(ulong_t * options)216 get_fmt_time(ulong_t *options)
217 {
218 u_ioparam_t ioparam;
219 int deflt;
220
221 ioparam.io_bounds.lower = 0;
222 ioparam.io_bounds.upper = INFINITY;
223 if (input(FIO_OPINT, "Enter format time", ':',
224 &ioparam, &deflt, DATA_INPUT)) {
225 *options |= SUP_FMTTIME;
226 return (deflt);
227 }
228 return (0);
229 }
230
231 /*
232 * Prompt for cylinder skew
233 */
234 int
get_cyl_skew(ulong_t * options)235 get_cyl_skew(ulong_t *options)
236 {
237 u_ioparam_t ioparam;
238 int deflt;
239
240 ioparam.io_bounds.lower = 0;
241 ioparam.io_bounds.upper = INFINITY;
242 if (input(FIO_OPINT, "Enter cylinder skew", ':',
243 &ioparam, &deflt, DATA_INPUT)) {
244 *options |= SUP_CYLSKEW;
245 return (deflt);
246 }
247 return (0);
248 }
249
250 /*
251 * Prompt for track skew
252 */
253 int
get_trk_skew(ulong_t * options)254 get_trk_skew(ulong_t *options)
255 {
256 u_ioparam_t ioparam;
257 int deflt;
258
259 ioparam.io_bounds.lower = 0;
260 ioparam.io_bounds.upper = INFINITY;
261 if (input(FIO_OPINT, "Enter track skew", ':',
262 &ioparam, &deflt, DATA_INPUT)) {
263 *options |= SUP_TRKSKEW;
264 return (deflt);
265 }
266 return (0);
267 }
268
269 /*
270 * Prompt for tracks per zone
271 */
272 int
get_trks_zone(ulong_t * options)273 get_trks_zone(ulong_t *options)
274 {
275 u_ioparam_t ioparam;
276 int deflt;
277
278 ioparam.io_bounds.lower = 0;
279 ioparam.io_bounds.upper = INFINITY;
280 if (input(FIO_OPINT, "Enter tracks per zone", ':',
281 &ioparam, &deflt, DATA_INPUT)) {
282 *options |= SUP_TRKS_ZONE;
283 return (deflt);
284 }
285 return (0);
286 }
287
288 /*
289 * Prompt for alternate tracks
290 */
291 int
get_atrks(ulong_t * options)292 get_atrks(ulong_t *options)
293 {
294 u_ioparam_t ioparam;
295 int deflt;
296
297 ioparam.io_bounds.lower = 0;
298 ioparam.io_bounds.upper = INFINITY;
299 if (input(FIO_OPINT, "Enter alternate tracks", ':',
300 &ioparam, &deflt, DATA_INPUT)) {
301 *options |= SUP_ATRKS;
302 return (deflt);
303 }
304 return (0);
305 }
306
307 /*
308 * Prompt for alternate sectors
309 */
310 int
get_asect(ulong_t * options)311 get_asect(ulong_t *options)
312 {
313 u_ioparam_t ioparam;
314 int deflt;
315
316 ioparam.io_bounds.lower = 0;
317 ioparam.io_bounds.upper = INFINITY;
318 if (input(FIO_OPINT, "Enter alternate sectors", ':',
319 &ioparam, &deflt, DATA_INPUT)) {
320 *options |= SUP_ASECT;
321 return (deflt);
322 }
323 return (0);
324 }
325
326 /*
327 * Prompt for cache setting
328 */
329 int
get_cache(ulong_t * options)330 get_cache(ulong_t *options)
331 {
332 u_ioparam_t ioparam;
333 int deflt;
334
335 ioparam.io_bounds.lower = 0;
336 ioparam.io_bounds.upper = 0xff;
337 if (input(FIO_OPINT, "Enter cache control", ':',
338 &ioparam, &deflt, DATA_INPUT)) {
339 *options |= SUP_CACHE;
340 return (deflt);
341 }
342 return (0);
343 }
344
345 /*
346 * Prompt for prefetch threshold
347 */
348 int
get_threshold(ulong_t * options)349 get_threshold(ulong_t *options)
350 {
351 u_ioparam_t ioparam;
352 int deflt;
353
354 ioparam.io_bounds.lower = 0;
355 ioparam.io_bounds.upper = INFINITY;
356 if (input(FIO_OPINT, "Enter prefetch threshold",
357 ':', &ioparam, &deflt, DATA_INPUT)) {
358 *options |= SUP_PREFETCH;
359 return (deflt);
360 }
361 return (0);
362 }
363
364 /*
365 * Prompt for minimum prefetch
366 */
367 int
get_min_prefetch(ulong_t * options)368 get_min_prefetch(ulong_t *options)
369 {
370 u_ioparam_t ioparam;
371 int deflt;
372
373 ioparam.io_bounds.lower = 0;
374 ioparam.io_bounds.upper = INFINITY;
375 if (input(FIO_OPINT, "Enter minimum prefetch",
376 ':', &ioparam, &deflt, DATA_INPUT)) {
377 *options |= SUP_CACHE_MIN;
378 return (deflt);
379 }
380 return (0);
381 }
382
383 /*
384 * Prompt for maximum prefetch
385 */
386 int
get_max_prefetch(int min_prefetch,ulong_t * options)387 get_max_prefetch(int min_prefetch, ulong_t *options)
388 {
389 u_ioparam_t ioparam;
390 int deflt;
391
392 ioparam.io_bounds.lower = min_prefetch;
393 ioparam.io_bounds.upper = INFINITY;
394 if (input(FIO_OPINT, "Enter maximum prefetch",
395 ':', &ioparam, &deflt, DATA_INPUT)) {
396 *options |= SUP_CACHE_MAX;
397 return (deflt);
398 }
399 return (0);
400 }
401
402 /*
403 * Prompt for bytes per sector
404 */
405 int
get_bps(void)406 get_bps(void)
407 {
408 u_ioparam_t ioparam;
409 int deflt;
410
411 if (cur_ctype->ctype_flags & CF_SMD_DEFS) {
412 ioparam.io_bounds.lower = MIN_BPS;
413 ioparam.io_bounds.upper = MAX_BPS;
414 deflt = AVG_BPS;
415 return (input(FIO_INT, "Enter bytes per sector",
416 ':', &ioparam, &deflt, DATA_INPUT));
417 }
418
419 return (0);
420 }
421
422 /*
423 * Prompt for ascii label
424 */
425 char *
get_asciilabel(void)426 get_asciilabel(void)
427 {
428 return ((char *)(uintptr_t)input(FIO_OSTR,
429 "Enter disk type name (remember quotes)", ':',
430 NULL, NULL, DATA_INPUT));
431 }
432