2 * Implementation of Utility functions for all SCSI device types.
4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
5 * Copyright (c) 1997, 1998 Kenneth D. Merry.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions, and the following disclaimer,
13 * without modification, immediately at the beginning of the file.
14 * 2. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $FreeBSD: src/sys/cam/scsi/scsi_all.c,v 1.38 2002/09/23 04:56:35 mjacob Exp $
37 * Table of syncrates that don't follow the "divisible by 4"
38 * rule. This table will be expanded in future SCSI specs.
42 u_int period; /* in 100ths of ns */
43 } scsi_syncrates[] = {
44 { 0x08, 625 }, /* FAST-160 */
45 { 0x09, 1250 }, /* FAST-80 */
46 { 0x0a, 2500 }, /* FAST-40 40MHz */
47 { 0x0b, 3030 }, /* FAST-40 33MHz */
48 { 0x0c, 5000 } /* FAST-20 */
52 * Return the frequency in kHz corresponding to the given
56 aic_calc_syncsrate(u_int period_factor)
61 num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
62 /* See if the period is in the "exception" table */
63 for (i = 0; i < num_syncrates; i++) {
65 if (period_factor == scsi_syncrates[i].period_factor) {
67 return (100000000 / scsi_syncrates[i].period);
72 * Wasn't in the table, so use the standard
75 return (10000000 / (period_factor * 4 * 10));
79 aic_parse_brace_option(char *opt_name, char *opt_arg, char *end, int depth,
80 aic_option_callback_t *callback, u_long callback_arg)
88 char tok_list[] = {'.', ',', '{', '}', '\0'};
90 /* All options use a ':' name/arg separator */
98 * Restore separator that may be in
99 * the middle of our option argument.
101 tok_end = strchr(opt_arg, '\0');
107 if (instance == -1) {
114 printf("Malformed Option %s\n",
124 else if (instance != -1)
134 else if (instance >= 0)
143 for (i = 0; tok_list[i]; i++) {
144 tok_end2 = strchr(opt_arg, tok_list[i]);
145 if ((tok_end2) && (tok_end2 < tok_end))
148 callback(callback_arg, instance, targ,
149 simple_strtol(opt_arg, NULL, 0));