2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 1999 Michael Smith
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/types.h>
36 #include <dev/mlx/mlxio.h>
37 #include <dev/mlx/mlxreg.h>
39 #include "mlxcontrol.h"
41 /********************************************************************************
42 * Various name-producing and -parsing functions
45 /* return path of controller (unit) */
51 sprintf(buf, "%s%s", _PATH_DEV, ctrlrname(unit));
55 /* return name of controller (unit) */
61 sprintf(buf, "mlx%d", unit);
65 /* return path of drive (unit) */
71 sprintf(buf, "%s%s", _PATH_DEV, drivename(unit));
75 /* return name of drive (unit) */
81 sprintf(buf, "mlxd%d", unit);
85 /* get controller unit number from name in (str) */
91 if (sscanf(str, "mlx%d", &unit) == 1)
96 /* get drive unit number from name in (str) */
102 if (sscanf(str, "mlxd%d", &unit) == 1)
107 /********************************************************************************
108 * Standardised output of various data structures.
112 mlx_print_phys_drv(struct mlx_phys_drv *drv, int chn, int targ, char *prefix, int verbose)
114 char *type, *device, *vendor, *revision;
116 switch(drv->pd_flags2 & 0x03) {
117 case MLX_PHYS_DRV_DISK:
120 case MLX_PHYS_DRV_SEQUENTIAL:
123 case MLX_PHYS_DRV_CDROM:
126 case MLX_PHYS_DRV_OTHER:
131 printf("%s%s%02d%02d ", prefix, type, chn, targ);
132 switch(drv->pd_status) {
133 case MLX_PHYS_DRV_DEAD:
136 case MLX_PHYS_DRV_WRONLY:
137 printf(" (write-only) ");
139 case MLX_PHYS_DRV_ONLINE:
140 printf(" (online) ");
142 case MLX_PHYS_DRV_STANDBY:
143 printf(" (standby) ");
146 printf(" (0x%02x) ", drv->pd_status);
152 printf("%s ", prefix);
153 if (!mlx_scsi_inquiry(0, chn, targ, &vendor, &device, &revision)) {
154 printf("'%8.8s' '%16.16s' '%4.4s'", vendor, device, revision);
156 printf("<IDENTIFY FAILED>");
159 printf(" %dMB ", drv->pd_config_size / 2048);
161 if (drv->pd_flags2 & MLX_PHYS_DRV_FAST20) {
163 } else if (drv->pd_flags2 & MLX_PHYS_DRV_FAST) {
166 if (drv->pd_flags2 & MLX_PHYS_DRV_WIDE)
168 if (drv->pd_flags2 & MLX_PHYS_DRV_SYNC)
170 if (drv->pd_flags2 & MLX_PHYS_DRV_TAG)
171 printf(" tag-enabled");