2 * Copyright (c) 1997 by Simon Shapiro
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions, and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. 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/usr.sbin/dpt/dpt_sysinfo/dpt_sysinfo.c,v 1.3 1999/08/28 01:16:10 peter Exp $
30 * $DragonFly: src/usr.sbin/dpt/dpt_sysinfo/dpt_sysinfo.c,v 1.3 2004/12/18 22:48:03 swildner Exp $
33 /* dpt_ctlinfo.c: Dunp a DPT HBA Information Block */
41 #include <sys/queue.h>
42 #include <sys/ioctl.h>
43 #include <scsi/scsi_all.h>
44 #include <scsi/scsi_message.h>
45 #include <scsi/scsiconf.h>
47 #define DPT_MEASURE_PERFORMANCE
53 main(int argc, char **argv, char **argp)
56 dpt_sysinfo_t sysinfo;
62 if ( (fd = open(argv[1], O_RDWR, S_IRUSR | S_IWUSR)) == -1 ) {
63 fprintf(stderr, "%s ERROR: Failed to open \"%s\" - %s\n",
64 argv[0], argv[1], strerror(errno));
68 pass_thru.eataID[0] = 'E';
69 pass_thru.eataID[1] = 'A';
70 pass_thru.eataID[2] = 'T';
71 pass_thru.eataID[3] = 'A';
72 pass_thru.command = DPT_SYSINFO;
73 pass_thru.command_buffer = (u_int8_t *)&sysinfo;
75 if ( (result = ioctl(fd, DPT_IOCTL_SEND, &pass_thru)) != 0 ) {
76 fprintf(stderr, "%s ERROR: Failed to send IOCTL %lx - %s\n",
77 argv[0], DPT_IOCTL_SEND,
82 fprintf(stdout, "%x:%x:%d:",
83 sysinfo.drive0CMOS, sysinfo.drive1CMOS, sysinfo.numDrives);
85 switch (sysinfo.processorFamily) {
87 fprintf(stdout, "Intel:");
88 switch (sysinfo.processorType) {
90 fprintf(stdout, "8086:");
93 fprintf(stdout, "80286:");
96 fprintf(stdout, "i386:");
99 fprintf(stdout, "80486:");
102 fprintf(stdout, "Pentium:");
105 fprintf(stdout, "Pentium-Pro:");
108 fprintf(stdout, "Unknown (%d):", sysinfo.processorType);
112 fprintf(stdout, "Motorola:");
113 switch (sysinfo.processorType) {
115 fprintf(stdout, "M68000");
118 fprintf(stdout, "M68020");
121 fprintf(stdout, "M68030");
124 fprintf(stdout, "M68040");
127 fprintf(stdout, "Unknown (%d):", sysinfo.processorType);
131 fprintf(stdout, "MIPS:Any:");
134 fprintf(stdout, "Alpha:Any:");
137 fprintf(stdout, "Unknown (%d):Any:", sysinfo.processorFamily);
140 fprintf(stdout, "%d.%d.%d:",
141 sysinfo.smartROMMajorVersion,
142 sysinfo.smartROMMinorVersion,
143 sysinfo.smartROMRevision);
145 fprintf(stdout, "%c%c%c%c%c%c%c%c%c%c%c:",
146 (sysinfo.flags & SI_CMOS_Valid) ? '+' : '-',
147 (sysinfo.flags & SI_NumDrivesValid) ? '+' : '-',
148 (sysinfo.flags & SI_ProcessorValid) ? '+' : '-',
149 (sysinfo.flags & SI_MemorySizeValid) ? '+' : '-',
150 (sysinfo.flags & SI_DriveParamsValid) ? '+' : '-',
151 (sysinfo.flags & SI_SmartROMverValid) ? '+' : '-',
152 (sysinfo.flags & SI_OSversionValid) ? '+' : '-',
153 (sysinfo.flags & SI_OSspecificValid) ? '+' : '-',
154 (sysinfo.flags & SI_BusTypeValid) ? '+' : '-',
155 (sysinfo.flags & SI_ALL_VALID) ? '+' : '-',
156 (sysinfo.flags & SI_NO_SmartROM) ? '+' : '-');
158 fprintf(stdout, "%d:", sysinfo.conventionalMemSize);
159 fprintf(stdout, "%d:", sysinfo.extendedMemSize);
161 switch (sysinfo.osType) {
163 fprintf(stdout, "DOS:");
166 fprintf(stdout, "Win3.1:");
169 fprintf(stdout, "NT:");
172 fprintf(stdout, "OS/2-std:");
175 fprintf(stdout, "OS/2-LADDR:");
178 fprintf(stdout, "OS/2-2.x:");
181 fprintf(stdout, "NetWare-286:");
184 fprintf(stdout, "NetWare-386:");
187 fprintf(stdout, "Unix:");
190 fprintf(stdout, "SCO Unix:");
193 fprintf(stdout, "AT&T Unix:");
196 fprintf(stdout, "UnixWare:");
199 fprintf(stdout, "IAC Unix:");
202 fprintf(stdout, "Solaris:");
205 fprintf(stdout, "Qnx:");
208 fprintf(stdout, "NextStep:");
211 fprintf(stdout, "Banyan:");
213 case OS_OLIVETTI_UNIX:
214 fprintf(stdout, "Olivetti Unix:");
217 fprintf(stdout, "FreeBSD:");
220 fprintf(stdout, "Other (%d):", sysinfo.osType);
223 fprintf(stdout, "Unknown (%d):", sysinfo.osType);
226 fprintf(stdout, "%d.%d.%d.%d:", sysinfo.osMajorVersion,
227 sysinfo.osMinorVersion, sysinfo.osRevision,
228 sysinfo.osSubRevision);
230 switch (sysinfo.busType) {
232 fprintf(stdout, "ISA:");
235 fprintf(stdout, "EISA:");
238 fprintf(stdout, "PCI:");
241 fprintf(stdout, "Unknown (%d):", sysinfo.busType);
244 for (ndx = 0; ndx < 16; ndx++) {
245 if (sysinfo.drives[ndx].cylinders == 0)
247 fprintf(stdout, "d%dc%dh%ds%d:", ndx,
248 sysinfo.drives[ndx].cylinders,
249 sysinfo.drives[ndx].heads,
250 sysinfo.drives[ndx].sectors);
253 fprintf(stdout, "\n");